V1.44
This commit is contained in:
343
UnitPrinc.pas
343
UnitPrinc.pas
@@ -86,6 +86,8 @@ type
|
||||
Label1: TLabel;
|
||||
LabelNbTrains: TLabel;
|
||||
ButtonLitCV: TButton;
|
||||
Codificationdesactionneurs1: TMenuItem;
|
||||
ButtonArretSimu: TButton;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure MSCommUSBLenzComm(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
@@ -135,6 +137,9 @@ type
|
||||
procedure Quitter1Click(Sender: TObject);
|
||||
procedure ConfigClick(Sender: TObject);
|
||||
procedure ButtonLitCVClick(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure Codificationdesactionneurs1Click(Sender: TObject);
|
||||
procedure ButtonArretSimuClick(Sender: TObject);
|
||||
|
||||
private
|
||||
{ Déclarations privées }
|
||||
@@ -202,11 +207,11 @@ TMA = (valide,devalide);
|
||||
|
||||
|
||||
var ancien_tablo_signalCplx,EtatsignalCplx : array[0..MaxAcc] of word;
|
||||
AvecInitAiguillages,tempsCli,combine,NbreFeux,pasreponse,AdrDevie,precedent ,
|
||||
AvecInitAiguillages,tempsCli,combine,NbreFeux,pasreponse,AdrDevie,
|
||||
NombreImages,signalCpx,branche_trouve,Indexbranche_trouve,Actuel,Signal_suivant,
|
||||
Nbre_recu_cdm,Tempo_chgt_feux,Adj1,Adj2,NbrePN : integer;
|
||||
Hors_tension2,traceSign,TraceZone,Ferme,parSocket,ackCdm,
|
||||
NackCDM,MsgSim,succes,recu_cv,AffActionneur,
|
||||
NackCDM,MsgSim,succes,recu_cv,AffActionneur,AffAigDet,
|
||||
TraceListe,clignotant,nack,Maj_feux_cours,configNulle : boolean;
|
||||
|
||||
branche : array [1..100] of string;
|
||||
@@ -218,7 +223,7 @@ const
|
||||
GrisF=$414141;
|
||||
clOrange=$0077FF;
|
||||
Feu_X=50;Feu_Y=91;
|
||||
Max_Simule=1000;
|
||||
Max_Simule=10000;
|
||||
couleurTrain : array[1..8] of Tcolor = (clYellow,clLime,clOrange,clAqua,clFuchsia,clLtGray,clred,clWhite);
|
||||
|
||||
var
|
||||
@@ -230,7 +235,7 @@ var
|
||||
entete,suffixe,ConfStCom : string;
|
||||
maxaiguillage,detecteur_chgt,Temps,TpsRecuCom,Tempo_init,Suivant,TypeGen,
|
||||
NbreImagePligne,NbreBranches,Index2_det,branche_det,Index_det,
|
||||
I_simule,maxTablo_act,NbreVoies : integer;
|
||||
I_simule,maxTablo_act,NbreVoies,AdresseFeuSuivant : integer;
|
||||
Ancien_detecteur,detecteur : array[0..1024] of boolean; // anciens état des détecteurs et adresses des détecteurs et leur état
|
||||
Adresse_detecteur : array[0..60] of integer; // adresses des détecteurs par index
|
||||
mem : array[0..1024] of boolean ; // mémoire des états des détecteurs
|
||||
@@ -281,7 +286,7 @@ var
|
||||
aiguillageB : array[0..MaxAcc] of Taiguillage;
|
||||
|
||||
|
||||
// dessin des feux
|
||||
// signaux
|
||||
feux : array[1..MaxAcc] of record
|
||||
adresse, aspect : integer; // adresse du feu, aspect (2 feux..9 feux 12=direction 2 feux .. 16=direction 6 feux)
|
||||
Img : TImage; // Pointeur sur structure TImage du feu
|
||||
@@ -3887,7 +3892,12 @@ begin
|
||||
// on part de l'actuel pour retomber sur le précédent
|
||||
if BrancheN[branche_trouve_actuel,indexBranche_actuel-1].Adresse=prec then // c'est l'autre sens
|
||||
begin
|
||||
if NivDebug=3 then AfficheDebug('40 - trouvé détecteur '+intToSTR(adr)+' en + ',clwhite);
|
||||
if NivDebug=3 then AfficheDebug('40 - trouvé détecteur '+intToSTR(adr)+' en + ',clwhite);
|
||||
Prec:=Adr;
|
||||
Aprec:=a;
|
||||
A:='Z';
|
||||
Adr:=BrancheN[branche_trouve_actuel,indexBranche_actuel+1].Adresse;
|
||||
typeGen:=BrancheN[branche_trouve_actuel,indexBranche_actuel+1].Btype;
|
||||
if NivDebug=3 then
|
||||
begin
|
||||
s:='41 - Le suivant est :'+intToSTR(adr);
|
||||
@@ -3899,7 +3909,12 @@ begin
|
||||
end;
|
||||
if BrancheN[branche_trouve_actuel,indexBranche_actuel+1].Adresse=prec then
|
||||
begin
|
||||
if NivDebug=3 then AfficheDebug('42 - trouvé détecteur '+intToSTR(adr)+' en - ',clwhite);
|
||||
if NivDebug=3 then AfficheDebug('42 - trouvé détecteur '+intToSTR(adr)+' en - ',clwhite);
|
||||
Prec:=Adr;
|
||||
Aprec:=a;
|
||||
A:='Z';
|
||||
Adr:=BrancheN[branche_trouve_actuel,indexBranche_actuel-1].Adresse;
|
||||
typeGen:=BrancheN[branche_trouve_actuel,indexBranche_actuel-1].Btype;
|
||||
if NivDebug=3 then
|
||||
begin
|
||||
s:='43 - Le suivant est :'+intToSTR(adr);
|
||||
@@ -4583,12 +4598,30 @@ begin
|
||||
AdrFonc:=Adr;
|
||||
BisFonc:=1;
|
||||
//typeGen:=0; //?
|
||||
repeat
|
||||
Adr:=suivant_alg3(AdrPrec,BisPrec,AdrFonc,BisFonc,1);
|
||||
repeat
|
||||
Adr:=suivant_alg3(AdrPrec,BisPrec,AdrFonc,BisFonc,1);
|
||||
if Adr>9997 then
|
||||
begin
|
||||
detecteur_suivant_el:=Adr;
|
||||
exit;
|
||||
end;
|
||||
if NivDebug=3 then
|
||||
begin
|
||||
s:='trouvé 2: Adr='+intToSTR(Adr);
|
||||
case typeGen of
|
||||
1 : s:=s+' detecteur';
|
||||
2 : s:=s+' aiguillage';
|
||||
3 : s:=s+' aiguillage bis';
|
||||
exit;
|
||||
end;
|
||||
AfficheDebug(s,clorange);
|
||||
end;
|
||||
trouve_element(Adr,typeGen);
|
||||
Btype:=BrancheN[branche_trouve,IndexBranche_trouve].BType;
|
||||
BisSuiv:=Btype; // si aiguillage bis
|
||||
if (NivDebug=3) then
|
||||
begin
|
||||
s:='Suivant='+intToSTR(Adr);
|
||||
case Btype of
|
||||
1 : s:=s+' detecteur';
|
||||
2 : s:=s+' aiguillage';
|
||||
3 : s:=s+' aiguillage bis';
|
||||
@@ -4662,6 +4695,7 @@ end;
|
||||
else AfficheDebug('Le signal '+IntToSTR(adresse)+' ne doit pas être au carré',clYellow);
|
||||
end;
|
||||
carre_signal:=AdrSuiv=9998;
|
||||
end;
|
||||
|
||||
|
||||
// renvoie l'état du signal suivant
|
||||
@@ -4684,6 +4718,7 @@ begin
|
||||
AfficheDebug(s,clred);
|
||||
etat_signal_suivant:=0;
|
||||
exit;
|
||||
end;
|
||||
|
||||
if i=0 then
|
||||
begin
|
||||
@@ -4695,6 +4730,7 @@ begin
|
||||
Etat:=0;
|
||||
j:=0;
|
||||
num_feu:=0;
|
||||
prec:=Feux[i].Adr_det1; // détecteur sur le courant
|
||||
|
||||
if prec=0 then
|
||||
begin
|
||||
@@ -4723,12 +4759,14 @@ begin
|
||||
else
|
||||
begin
|
||||
AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,1);
|
||||
prec:=actuel;TypePrec:=TypeActuel;
|
||||
actuel:=AdrSuiv;TypeActuel:=typeGen;
|
||||
end;
|
||||
if (AdrSuiv=9999) then
|
||||
begin
|
||||
Etat_signal_suivant:=0;
|
||||
AdresseFeuSuivant:=0;
|
||||
exit;
|
||||
end;
|
||||
if (AdrSuiv=0) then
|
||||
begin
|
||||
@@ -4752,6 +4790,7 @@ begin
|
||||
end;
|
||||
if (AdrFeu<>0) then // si l'adresse est <>0
|
||||
begin
|
||||
if (Feux[i].Adr_el_suiv1<>prec) then // le feu est-il dans le bon sens de progression?
|
||||
begin
|
||||
// oui
|
||||
inc(num_feu);
|
||||
@@ -4764,6 +4803,7 @@ begin
|
||||
begin
|
||||
if NivDebug=3 then AfficheDebug('Trouvé feu '+intToSTR(AdrFeu)+' mais dans le mauvais sens',clOrange);
|
||||
AdrFeu:=0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
until (j=10) or ((AdrFeu<>0) and (num_feu=rang));
|
||||
@@ -4885,13 +4925,14 @@ begin
|
||||
begin
|
||||
// Affiche('i='+intToSTR(i),clyellow);
|
||||
dec(i,2); // i correspond au nombre de feux à allumer
|
||||
pilote_direction(Adr,i);
|
||||
end;
|
||||
|
||||
|
||||
end;
|
||||
|
||||
// renvoie vrai si une mémoire de zone est occupée du signal courant au signal suivant
|
||||
// adresse=adresse du signal
|
||||
function test_memoire_zones(adresse : integer) : boolean;
|
||||
function test_memoire_zones(adresse : integer) : boolean;
|
||||
var
|
||||
AdrSuiv,prec,TypePrec,TypeActuel,ife,actuel,AdrDet,Etat,AdrFeu,i,j,PresTrain01,PrecInitial : integer;
|
||||
Pres_train,sort : boolean;
|
||||
@@ -4942,7 +4983,6 @@ begin
|
||||
begin
|
||||
prec:=feux[i].Adr_det4;
|
||||
actuel:=feux[i].Adr_el_suiv4;
|
||||
if feux[i].Btype_suiv4=1 then TypeActuel:=1;
|
||||
if feux[i].Btype_suiv4=1 then TypeActuel:=1;
|
||||
if feux[i].Btype_suiv4=2 then TypeActuel:=2;
|
||||
if feux[i].Btype_suiv4=4 then TypeActuel:=2; // aiguillage triple
|
||||
@@ -4950,44 +4990,41 @@ begin
|
||||
end; // détecteur sur le signal courant
|
||||
|
||||
TypePrec:=1;
|
||||
if (prec=0) then
|
||||
begin
|
||||
test_memoire_zones:=Pres_train;
|
||||
exit;
|
||||
end;
|
||||
|
||||
PrecInitial:=Prec;
|
||||
repeat
|
||||
inc(j);
|
||||
// à la première itération, si "actuel" est déja un détecteur, ne pas faire de recherche sur le suivant
|
||||
// et chaîner mémoire de zone
|
||||
if (j=1) and (Typeactuel=1) then // si détecteur
|
||||
begin
|
||||
//AfficheDebug('C''est un détecteur',clred);
|
||||
repeat
|
||||
inc(j);
|
||||
actuel:=prec;
|
||||
// à la première itération, si "actuel" est déja un détecteur, ne pas faire de recherche sur le suivant
|
||||
// et chaîner mémoire de zone
|
||||
if (j=1) and (Typeactuel=1) then // si détecteur
|
||||
begin
|
||||
if Pres_Train and (NivDebug=3) then Affiche('Présence train de '+intToSTR(prec)+' à '+intToSTR(actuel),clyellow);
|
||||
Pres_train:=MemZone[Prec,actuel];
|
||||
if Pres_Train and (NivDebug=3) then Affiche('Présence train de '+intToSTR(prec)+' à '+intToSTR(actuel),clyellow);
|
||||
end
|
||||
begin
|
||||
AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,1);
|
||||
else
|
||||
begin
|
||||
AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,1);
|
||||
prec:=actuel;TypePrec:=TypeActuel;
|
||||
actuel:=AdrSuiv;TypeActuel:=typeGen;
|
||||
end;
|
||||
|
||||
if NivDebug=3 then AfficheDebug('A suivant='+IntToSTR(adrsuiv),clred);
|
||||
if actuel=0 then
|
||||
if AdrSuiv=0 then
|
||||
begin
|
||||
// si c'est un buttoir
|
||||
test_memoire_zones:=false;
|
||||
if NivDebug=3 then AfficheDebug('sortie car buttoir',clyellow);
|
||||
exit;
|
||||
exit;
|
||||
end;
|
||||
// si le suivant est un détecteur comporte t-il un signal?
|
||||
AdrFeu:=0;
|
||||
// si le suivant est un détecteur ; contrôler mémoire de zone et comporte t-il un signal?
|
||||
AdrFeu:=0;
|
||||
if (TypeActuel=1) then // détecteur
|
||||
begin
|
||||
if (NivDebug=3) and MemZone[PrecInitial][actuel] then AfficheDebug('Présence train de '+intToSTR(PrecInitial)+' à '+intToSTR(actuel),clyellow);
|
||||
|
||||
Pres_train:=MemZone[PrecInitial][actuel] or Pres_train; // mémoire de zone
|
||||
@@ -5020,7 +5057,7 @@ begin
|
||||
//if (traceDet) {sprintf(Affiche,"Trouvé détecteur %d mais sans signal\r\n",AdrSuiv,Etat);Display(Affiche);
|
||||
AdrFeu:=0;
|
||||
end;
|
||||
end
|
||||
end
|
||||
else
|
||||
begin
|
||||
if (NivDebug=3) then AfficheDebug('Trouvé aiguillage '+intToSTR(AdrSuiv),clyellow);
|
||||
@@ -5080,7 +5117,7 @@ begin
|
||||
var i : integer;
|
||||
trouve : boolean;
|
||||
begin
|
||||
if index<=0 then begin affiche('Erreur 784 index invalide',clred);exit; end;
|
||||
if index<=0 then begin affiche('Erreur 784 index invalide',clred);exit; end;
|
||||
i:=index;
|
||||
if i>N_Event_tick then begin trouve_index_det_chrono:=0;exit; end;
|
||||
inc(i);
|
||||
@@ -5195,6 +5232,7 @@ begin
|
||||
calcul_zones_det:=0;exit;
|
||||
end;
|
||||
|
||||
// étape 2 : on a trouvé le sens de progression, trouver le détecteur suivant
|
||||
if (Adr=det2) then
|
||||
begin
|
||||
// trouvé la route si j=2 : - si j=3 : +
|
||||
@@ -5205,22 +5243,25 @@ begin
|
||||
AdrPrec:=detecteur_suivant_El(det2,1,det1,1);
|
||||
|
||||
// le train vient de det1, quitte det2 et va vers Adr
|
||||
// il faut vérifier si le détecteur précédent à été mis à 1 puis à 0 (on cherche 0)
|
||||
//s:='Test route pour prec='+intToSTR(AdrPrec)+' det1='+intToSTR(det1)+' det2='+IntToSTR(det2) ;
|
||||
//FormDebug.MemoDet.lines.add(s);
|
||||
if traceListe then AfficheDebug(s,clyellow);
|
||||
|
||||
// trouver l'index du détecteur (det1) à 0
|
||||
if traceListe then AfficheDebug('trouve_index_det_chrono('+intToSTR(det1)+',0,'+intToSTR(N_event_tick)+')',clYellow);
|
||||
i:=trouve_index_det_chrono(det1,0,N_Event_tick);
|
||||
if TraceListe then AfficheDebug('Index det='+intToSTR(i),clyellow);
|
||||
|
||||
// et trouver l'index du détecteur précédent à 0 avant l'index i
|
||||
if traceListe then AfficheDebug('trouve_index_det_chrono('+intToSTR(AdrPrec)+',0,'+intToSTR(i-1)+')',clYellow);
|
||||
i:=trouve_index_det_chrono(AdrPrec,0,i-1);
|
||||
i:=trouve_index_det_chrono(AdrPrec,0,i-1);
|
||||
if TraceListe then AfficheDebug('Index prec='+intToSTR(i),clyellow);
|
||||
|
||||
if TraceListe then AfficheDebug('Index prec='+intToSTR(i),clyellow);
|
||||
|
||||
t:=event_det_tick[i].traite; // détecteur précédent déja traité ?
|
||||
if (i=0) or t then
|
||||
begin
|
||||
begin
|
||||
if (i=0) and TraceListe then AfficheDebug('La mémoire préc '+intToSTR(AdrPrec)+'=0 donc route non valide',clyellow);
|
||||
if t and TraceListe then AfficheDebug('La mémoire préc '+intToSTR(AdrPrec)+' a déja été traitée donc route non valide',clyellow);
|
||||
calcul_zones_det:=0;exit;
|
||||
@@ -5281,6 +5322,7 @@ begin
|
||||
|
||||
With FormDebug.RichEdit do
|
||||
begin
|
||||
s:='train '+IntToSTR(Train_Courant)+' '+intToStr(det1)+' à '+intToStr(det2)+' => Mem '+IntToSTR(det2)+' à '+IntTOStr(AdrSuiv);
|
||||
Lines.Add(s);
|
||||
RE_ColorLine(FormDebug.RichEdit,lines.count,CouleurTrain[((Train_Courant - 1) mod 8)+1 ]);
|
||||
end;
|
||||
@@ -5342,7 +5384,8 @@ begin
|
||||
if (modele>10) then
|
||||
begin
|
||||
//Affiche('Signal directionnel '+IntToSTR(AdrFeu),clyellow);
|
||||
Signal_direction(AdrFeu);
|
||||
Signal_direction(AdrFeu);
|
||||
exit;
|
||||
end;
|
||||
|
||||
// signal non directionnel
|
||||
@@ -5479,11 +5522,11 @@ begin
|
||||
if (aiguillage[aig].vitesse=30) or (aiguillage[aig].vitesse=0) then Maj_Etat_Signal(AdrFeu,rappel_30);
|
||||
if aiguillage[aig].vitesse=60 then Maj_Etat_Signal(AdrFeu,rappel_60);
|
||||
|
||||
// si signal suivant affiche rappel ou rouge
|
||||
// si signal suivant affiche rappel ou rouge
|
||||
if (TestBit(etat,rappel_60)) or (testBit(etat,rappel_30)) or (testBit(etat,carre)) or (testBit(etat,semaphore))
|
||||
then Maj_Etat_Signal(AdrFeu,jaune)
|
||||
else
|
||||
begin
|
||||
begin
|
||||
// sinon si signal suivant=jaune
|
||||
if (TestBit(etat,jaune)) then Maj_Etat_Signal(AdrFeu,jaune_cli);
|
||||
end;
|
||||
@@ -5784,27 +5827,27 @@ begin
|
||||
procedure Event_Detecteur(Adresse : integer;etat : boolean);
|
||||
var i,trainAdj1,TrainAdj2,TrainActuel,Etat01 : integer;
|
||||
s : string;
|
||||
begin
|
||||
if Etat then Etat01:=1 else Etat01:=0;
|
||||
begin
|
||||
if Etat then Etat01:=1 else Etat01:=0;
|
||||
// vérifier si l'état du détecteur est déja stocké, car on peut reçevoir plusieurs évènements pour le même détecteur dans le même état
|
||||
// on reçoit un doublon dans deux index consécutifs.
|
||||
if N_Event_tick>=1 then
|
||||
begin
|
||||
if (event_det_tick[N_event_tick].etat=etat01) and (event_det_tick[N_event_tick].detecteur=Adresse) then
|
||||
begin
|
||||
begin
|
||||
//Affiche(IntToSTR(Adresse)+' déja stocké',clorange);
|
||||
exit; // déja stocké
|
||||
end;
|
||||
end;
|
||||
|
||||
if Traceliste then AfficheDebug('--------------------- détecteur '+intToSTR(Adresse)+' à '+intToSTR(etat01)+'-----------------------------',clOrange);
|
||||
if AffAigDet then
|
||||
begin
|
||||
s:='Evt Det '+intToSTR(adresse)+'='+intToSTR(etat01);
|
||||
Affiche(s,clyellow);
|
||||
AfficheDebug(s,clyellow);
|
||||
end;
|
||||
|
||||
//if etat then Mem[Adresse]:=true; // mémoriser l'état à 1
|
||||
|
||||
ancien_detecteur[Adresse]:=detecteur[Adresse];
|
||||
detecteur[Adresse]:=etat;
|
||||
detecteur_chgt:=Adresse;
|
||||
|
||||
// mise a jour du tableau evt de fronts descendants
|
||||
if ancien_detecteur[Adresse] and not(detecteur[Adresse]) and (N_Event_det<20) then
|
||||
begin
|
||||
//if etat then Mem[Adresse]:=true; // mémoriser l'état à 1
|
||||
|
||||
ancien_detecteur[Adresse]:=detecteur[Adresse];
|
||||
@@ -5812,10 +5855,32 @@ begin
|
||||
detecteur_chgt:=Adresse;
|
||||
|
||||
// stocke les changements d'état des détecteurs dans le tableau chronologique
|
||||
if (N_Event_tick<Max_Event_det_tick) then
|
||||
begin
|
||||
inc(N_Event_tick);
|
||||
if (N_Event_tick<Max_Event_det_tick) then
|
||||
begin
|
||||
inc(N_Event_tick);
|
||||
// event_det_tick[N_event_tick].train:=0;
|
||||
|
||||
event_det_tick[N_event_tick].tick:=tick;
|
||||
event_det_tick[N_event_tick].detecteur:=Adresse;
|
||||
event_det_tick[N_event_tick].etat:=etat01;
|
||||
// Affiche('stockage de '+intToSTR(N_event_tick)+' '+IntToSTR(Adresse)+' à '+intToSTR(etat01),clyellow);
|
||||
end;
|
||||
|
||||
// mise a jour du tableau evt de fronts descendants
|
||||
if ancien_detecteur[Adresse] and not(detecteur[Adresse]) and (N_Event_det<Max_event_det) then
|
||||
begin
|
||||
// si le FD du détecteur a déjà été stocké à l'index précédent ne pas en tenir compte
|
||||
if event_det[N_event_det]<>Adresse then
|
||||
begin
|
||||
if AffFD then AfficheDebug('index='+intToSTR(N_event_tick)+' FD '+intToSTR(Adresse),clyellow);
|
||||
inc(N_event_det);
|
||||
event_det[N_event_det]:=Adresse;
|
||||
if not(configNulle) then calcul_zones; // en avant les calculs
|
||||
end;
|
||||
end;
|
||||
if (N_event_det>=Max_event_det) then
|
||||
begin
|
||||
Affiche('Débordement d''évènements FD - Raz tampon',clred);
|
||||
N_event_det:=0;
|
||||
FormDebug.MemoEvtDet.lines.add('Raz sur débordement');
|
||||
end;
|
||||
@@ -5859,9 +5924,17 @@ end;
|
||||
end;
|
||||
event_det_tick[N_event_tick].train:=N_trains;
|
||||
end;
|
||||
end;
|
||||
}
|
||||
end;
|
||||
|
||||
// évènement d'aiguillage
|
||||
procedure Event_Aig(adresse,pos : integer);
|
||||
var s: string;
|
||||
begin
|
||||
aiguillage[adresse].position:=pos;
|
||||
if (N_Event_tick<Max_Event_det_tick) then
|
||||
begin
|
||||
if AffAigDet then
|
||||
begin
|
||||
s:='Aig '+intToSTR(adresse)+'='+intToSTR(pos);
|
||||
@@ -6004,25 +6077,21 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
// état de l'aiguillage
|
||||
// état de l'aiguillage
|
||||
if bitsITT=$00 then // module d'aiguillages, N=1
|
||||
begin
|
||||
adraig:=((adresse * 4)+1 ); // *4 car N=1, c'est le "poids fort"
|
||||
if (valeur and $C)=$8 then
|
||||
aiguillage[adraig+3].position:=2 ; // état aiguillage haut
|
||||
begin
|
||||
Event_Aig(adraig+3,2);
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig+3)+'=2';Affiche(s,clYellow);end;
|
||||
end;
|
||||
if (valeur and $C)=$4 then
|
||||
aiguillage[adraig+3].position:=1 ; // état aiguillage haut
|
||||
begin
|
||||
Event_Aig(adraig+3,1);
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig+3)+'=1';Affiche(s,clYellow);end;
|
||||
end;
|
||||
if (valeur and $3)=$2 then
|
||||
aiguillage[adraig+2].position:=2; // état aiguillage bas
|
||||
begin
|
||||
Event_Aig(adraig+2,2);
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig+2)+'=2';Affiche(s,clYellow);end;
|
||||
@@ -6064,25 +6133,21 @@ begin
|
||||
Event_detecteur(i,(valeur and $1) = $1);
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
if bitsITT=$00 then // module d'aiguillages
|
||||
begin
|
||||
adraig:=(adresse * 4)+1;
|
||||
if (valeur and $C)=$8 then
|
||||
aiguillage[adraig+1].position:=2 ; // état aiguillage haut
|
||||
begin
|
||||
Event_Aig(adraig+1,2);
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig+1)+'=2';Affiche(s,clYellow);end;
|
||||
end;
|
||||
if (valeur and $C)=$4 then
|
||||
aiguillage[adraig+1].position:=1 ; // état aiguillage haut
|
||||
begin
|
||||
Event_Aig(adraig+1,1);
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig+1)+'=1';Affiche(s,clYellow);end;
|
||||
end;
|
||||
if (valeur and $3)=$2 then
|
||||
aiguillage[adraig].position:=2; // état aiguillage bas
|
||||
begin
|
||||
Event_Aig(adraig,2);
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig)+'=2';Affiche(s,clYellow);end;
|
||||
@@ -6554,8 +6619,8 @@ begin
|
||||
//EnumerateDevices;
|
||||
//for i:=1 to NumLine do
|
||||
//begin
|
||||
// if pos('Ports',Line[i])<>0 then Affiche(Line[i],clyellow);
|
||||
//end;
|
||||
// if pos('Ports',Line[i])<>0 then Affiche(Line[i],clyellow);
|
||||
//end;
|
||||
//essai
|
||||
// event_det[1]:=527;
|
||||
// event_det[2]:=520;
|
||||
@@ -6567,14 +6632,13 @@ begin
|
||||
//maj_feu(201);
|
||||
// formdebug.Show;
|
||||
//AfficheDet:=true;
|
||||
//NivDebug:=3;
|
||||
//NivDebug:=3;
|
||||
//Aiguille_deviee(462);
|
||||
//aiguillageB[1].Position:=1;
|
||||
//i:=suivant_alg3(553,1,1,3,1);
|
||||
//Affichedebug(intToSTr(i),clred);
|
||||
//Affiche(IntToSTR(calcul_zones_det(522,514)),clyellow);
|
||||
|
||||
//i:=detecteur_suivant_El(514,1,518,1); // donne l'élément suivant de AdrPrec à AdrFonc et dans Bis si c'est un aig bis
|
||||
//i:=detecteur_suivant_El(514,1,518,1); // donne l'élément suivant de AdrPrec à AdrFonc et dans Bis si c'est un aig bis
|
||||
//i:=etat_signal_suivant(1001,1);
|
||||
// Affiche(IntToSTR(detecteur_suivant(25,2,529,1)),clyellow);
|
||||
@@ -6726,29 +6790,44 @@ begin
|
||||
begin
|
||||
A:=Tablo_actionneur[RangActCours].actionneur;
|
||||
s:=Tablo_actionneur[RangActCours].train;
|
||||
Affiche('Actionneur '+intToSTR(a)+' F'+IntToSTR(Tablo_actionneur[RangActCours].fonction)+':0',clyellow);
|
||||
Affiche('Actionneur '+intToSTR(a)+' F'+IntToSTR(Tablo_actionneur[RangActCours].fonction)+':0',clyellow);
|
||||
envoie_fonction_CDM(Tablo_actionneur[RangActCours].fonction,0,s);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
//simulation
|
||||
if (index_simule<>0) then
|
||||
begin
|
||||
if not(MsgSim) then
|
||||
begin
|
||||
Affiche('Simulation en cours ',Cyan);MsgSim:=true;
|
||||
N_Event_tick:=0;
|
||||
N_event_det:=0;
|
||||
N_trains:=0;
|
||||
FormDebug.MemoEvtDet.Clear;
|
||||
FormDebug.Richedit.Clear;
|
||||
end;
|
||||
while tick=Tablo_simule[i_simule+1].tick do
|
||||
while tick=Tablo_simule[i_simule+1].tick do
|
||||
begin
|
||||
inc(I_simule);
|
||||
|
||||
// evt détecteur ?
|
||||
if Tablo_simule[i_simule].detecteur<>0 then
|
||||
begin
|
||||
// if i_simule=164 then
|
||||
// begin
|
||||
// if Tablo_simule[i_simule].detecteur=538 then Affiche('création evt 538 index '+intToSTR(i_simule),clorange);
|
||||
// end;
|
||||
|
||||
Affiche('Simulation tick='+IntToSTR(tick)+' det='+intToSTR(Tablo_simule[i_simule].detecteur)+'='+IntToSTR(Tablo_simule[i_simule].etat),Cyan);
|
||||
Event_Detecteur(Tablo_simule[i_simule].detecteur, Tablo_simule[i_simule].etat=1); // créer évt détecteur
|
||||
Affiche('Simulation '+intToSTR(I_simule)+' Tick='+IntToSTR(tick)+' det='+intToSTR(Tablo_simule[i_simule].detecteur)+'='+IntToSTR(Tablo_simule[i_simule].etat),Cyan);
|
||||
Event_Detecteur(Tablo_simule[i_simule].detecteur, Tablo_simule[i_simule].etat=1); // créer évt détecteur
|
||||
end;
|
||||
// evt aiguillage ?
|
||||
if Tablo_simule[i_simule].aiguillage<>0 then
|
||||
begin
|
||||
Affiche('Simulation '+intToSTR(I_simule)+' Tick='+IntToSTR(tick)+' aig='+intToSTR(Tablo_simule[i_simule].aiguillage)+'='+IntToSTR(Tablo_simule[i_simule].etat),Cyan);
|
||||
Event_Aig(Tablo_simule[i_simule].Aiguillage,Tablo_simule[i_simule].etat); // créer évt aiguillage
|
||||
end;
|
||||
|
||||
end;
|
||||
if i_Simule>=Index_simule then
|
||||
@@ -6957,8 +7036,8 @@ begin
|
||||
|
||||
procedure TFormPrinc.AffEtatDetecteurs(Sender: TObject);
|
||||
var j,adr,NBranche : integer;
|
||||
s : string;
|
||||
begin
|
||||
s : string;
|
||||
begin
|
||||
for j:=1 to NDetecteurs do
|
||||
begin
|
||||
s:='Dét '+intToSTR(Adresse_detecteur[j])+'=';
|
||||
@@ -7006,10 +7085,8 @@ begin
|
||||
if aiguillage[i].modele=1 then s:=s+' Pointe=';
|
||||
if aiguillage[i].modele=2 then s:=s+' TJD: centre TJD=';
|
||||
if aiguillage[i].modele=3 then s:=s+' TJS:';
|
||||
if aiguillage[i].modele=4 then s:=s+' Triple: Pointe=';
|
||||
s:=s+IntToSTR(aiguillage[i].APointe)+aiguillage[i].APointeB+
|
||||
' Dévie='+IntToSTR(aiguillage[i].ADevie)+aiguillage[i].ADevieB+
|
||||
' Droit='+IntToSTR(aiguillage[i].ADroit)+aiguillage[i].ADroitB;
|
||||
if aiguillage[i].modele=4 then s:=s+' Triple: Pointe=';
|
||||
s:=s+IntToSTR(aiguillage[i].APointe)+aiguillage[i].APointeB+
|
||||
' Dévie='+IntToSTR(aiguillage[i].ADevie)+aiguillage[i].ADevieB+
|
||||
' Droit='+IntToSTR(aiguillage[i].ADroit)+aiguillage[i].ADroitB;
|
||||
if aiguillage[i].modele=4 then s:=s+' Dévié2='+intToSTR(aiguillage[i].ADevie2)+aiguillage[i].ADevie2B;
|
||||
@@ -7026,11 +7103,8 @@ begin
|
||||
if aiguillageB[i].modele=1 then s:=s+' Pointe=';
|
||||
if aiguillageB[i].modele=2 then s:=s+' TJD: centre TJD=';
|
||||
if aiguillageB[i].modele=3 then s:=s+' TJS:';
|
||||
if aiguillageB[i].modele=4 then s:=s+' Triple: Pointe=';
|
||||
s:=s+IntToSTR(aiguillageB[i].APointe)+aiguillageB[i].APointeB+
|
||||
' Dévie='+IntToSTR(aiguillageB[i].ADevie)+aiguillageB[i].ADevieB+
|
||||
' Droit='+IntToSTR(aiguillageB[i].ADroit)+aiguillageB[i].ADroitB;
|
||||
if aiguillageB[i].modele=4 then s:=s+' Dévié2='+intToSTR(aiguillageB[i].ADevie2)+aiguillageB[i].ADevie2B;
|
||||
if aiguillageB[i].modele=4 then s:=s+' Triple: Pointe=';
|
||||
s:=s+IntToSTR(aiguillageB[i].APointe)+aiguillageB[i].APointeB+
|
||||
' Dévie='+IntToSTR(aiguillageB[i].ADevie)+aiguillageB[i].ADevieB+
|
||||
' Droit='+IntToSTR(aiguillageB[i].ADroit)+aiguillageB[i].ADroitB;
|
||||
if aiguillageB[i].modele=4 then s:=s+' Dévié2='+intToSTR(aiguillageB[i].ADevie2)+aiguillageB[i].ADevie2B;
|
||||
@@ -7107,15 +7181,15 @@ begin
|
||||
end;
|
||||
val(ss,etat,erreur);
|
||||
//Affiche('Aiguillage CDM'+intToSTR(adr)+'='+IntToStr(etat),clLime);
|
||||
// conversion en position :
|
||||
// conversion en position :
|
||||
// CDM: 0=droit 1=droite 3=gauche
|
||||
// logiciel : 1=dévié 2=droit
|
||||
// logiciel : 1=dévié 2=droit
|
||||
|
||||
|
||||
// aiguillage normal
|
||||
if aiguillage[adr].modele=1 then
|
||||
begin
|
||||
//Affiche('Normal',clyellow);
|
||||
if etat=0 then etatAig:=2 else etatAig:=1;
|
||||
Event_Aig(adr,etatAig);
|
||||
end;
|
||||
// TJD TJS
|
||||
@@ -7123,21 +7197,19 @@ begin
|
||||
begin
|
||||
//Affiche('TJDS',clyellow);
|
||||
adr2:=aiguillage[adr].Apointe; // 2eme adresse de la TJD
|
||||
case etat of
|
||||
case etat of
|
||||
1 : begin etatAig:=1;EtatAig2:=2;end;
|
||||
4 : begin etatAig:=1;EtatAig2:=1;end;
|
||||
5 : begin etatAig:=2;EtatAig2:=1;end;
|
||||
0 : begin etatAig:=2;EtatAig2:=2;end;
|
||||
end;
|
||||
Event_Aig(adr,etatAig);
|
||||
Event_Aig(adr2,etatAig2);
|
||||
end;
|
||||
end;
|
||||
if aiguillage[adr].modele=4 then // aiguillage triple
|
||||
begin
|
||||
//Affiche('Triple',clyellow);
|
||||
// état de l'aiguillage 1
|
||||
if etat=3 then etatAig:=1;
|
||||
if (etat=0) or (etat=2) then etatAig:=2;
|
||||
if etat=3 then etatAig:=1;
|
||||
// état de l'aiguillage 2
|
||||
@@ -7158,7 +7230,7 @@ begin
|
||||
j:=pos('CMDACC-ST_DT',recuCDM);
|
||||
if j<>0 then
|
||||
begin
|
||||
i:=posEx('AD=',recuCDM,j);ss:=copy(recuCDM,i+3,10);
|
||||
i:=posEx('AD=',recuCDM,j);ss:=copy(recuCDM,i+3,10);
|
||||
val(ss,adr,erreur);
|
||||
i:=posEx('STATE=',recuCDM,j);ss:=copy(recuCDM,i+6,10);
|
||||
Delete(recuCDM,j,i+5-j);
|
||||
@@ -7231,21 +7303,26 @@ begin
|
||||
procedure TFormPrinc.Codificationdesfeux1Click(Sender: TObject);
|
||||
var i,j,k,NfeuxDir,adresse : integer;
|
||||
s : string;
|
||||
begin
|
||||
begin
|
||||
Affiche('Codification interne des feux',Cyan);
|
||||
|
||||
for i:=1 to NbreFeux do
|
||||
begin
|
||||
// feu de signalisation
|
||||
s:=IntToSTR(i)+' Adresse='+IntToSTR(feux[i].Adresse);
|
||||
s:=s+' décodeur='+IntToStr(feux[i].decodeur);
|
||||
// feu de signalisation
|
||||
s:=IntToSTR(i)+' Adr='+IntToSTR(feux[i].Adresse);
|
||||
s:=s+' décodeur='+IntToStr(feux[i].decodeur);
|
||||
|
||||
if feux[i].aspect<10 then
|
||||
begin
|
||||
s:=s+' SIG Nbre de feux='+IntToSTR(feux[i].aspect)+' ';
|
||||
s:=s+' El_Suivant1='+IntToSTR(feux[i].Adr_el_suiv1)+' Type suivant1='+intToSTR(feux[i].Btype_suiv1);
|
||||
case feux[i].Btype_suiv1 of
|
||||
1 : s:=s+' (détecteur)';
|
||||
2 : s:=s+' (aiguillage ou TJD-S)';
|
||||
4 : s:=s+' (aiguillage triple)';
|
||||
5 : s:=s+' (aiguillage bis)';
|
||||
end;
|
||||
if feux[i].decodeur=6 then
|
||||
if feux[i].decodeur=6 then
|
||||
s:=s+' Cible unisemaf='+intToSTR(feux[i].Unisemaf);
|
||||
end
|
||||
else
|
||||
@@ -7279,8 +7356,8 @@ begin
|
||||
Affiche(' verrouillages routes pour trains consécutifs',clLime);
|
||||
Affiche('Version 1.2 : Renforcement de l''algorithme de suivi des trains',clLime);
|
||||
Affiche('Version 1.3 : Décodeur Unisemaf fonctionnel - Lecture/écriture des CV',clLime);
|
||||
Affiche(' Protocoles variables de l''interface',clLime);
|
||||
Affiche(' Configuration statique modifiable dans menu',clLime);
|
||||
Affiche(' Protocoles variables de l''interface',clLime);
|
||||
Affiche(' Configuration statique modifiable dans menu',clLime);
|
||||
Affiche('Version 1.31 : Correction des positions aiguillages triples et TJD',clLime);
|
||||
Affiche('Version 1.4 : Gestion des Fx vers les locomotives par actionneurs',clLime);
|
||||
Affiche('Version 1.41 : Gestion des passages à niveaux par actionneurs',clLime);
|
||||
@@ -7293,27 +7370,30 @@ procedure TFormPrinc.ChronoDetectClick(Sender: TObject);
|
||||
Socket: TCustomWinSocket);
|
||||
begin
|
||||
parSocket:=False;
|
||||
end;
|
||||
|
||||
procedure TFormPrinc.ChronoDetectClick(Sender: TObject);
|
||||
var i,j,etat : integer;
|
||||
s : string;
|
||||
begin
|
||||
if N_event_tick=0 then
|
||||
begin
|
||||
Affiche('Aucun évenèment détecteur ou aiguillage',clYellow);
|
||||
begin
|
||||
for i:=1 to N_Event_tick do
|
||||
end;
|
||||
for i:=1 to N_Event_tick do
|
||||
begin
|
||||
|
||||
|
||||
begin
|
||||
//for j:=1 to 1100 do
|
||||
begin
|
||||
j:=event_det_tick[i].detecteur;
|
||||
if j<>-1 then
|
||||
begin
|
||||
s:=IntToSTR(i)+' Tick='+IntToSTR(event_det_tick[i].tick);
|
||||
s:=s+' Det='+IntToSTR(j)+'='+intToSTR(etat);
|
||||
// s:=s+' Det suiv='+intTostr(event_det_tick[i].suivant);
|
||||
s:=s+' Det='+IntToSTR(j)+'='+intToSTR(event_det_tick[i].etat);
|
||||
// s:=s+' Det suiv='+intTostr(event_det_tick[i].suivant);
|
||||
Affiche(s,clyellow);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
j:=event_det_tick[i].aiguillage;
|
||||
if j<>-1 then
|
||||
@@ -7324,7 +7404,6 @@ end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@@ -7492,6 +7571,68 @@ begin
|
||||
end;
|
||||
|
||||
procedure TFormPrinc.ConfigClick(Sender: TObject);
|
||||
begin
|
||||
Tformconfig.create(self);
|
||||
formconfig.showmodal;
|
||||
formconfig.close;
|
||||
end;
|
||||
|
||||
procedure TFormPrinc.Button2Click(Sender: TObject);
|
||||
var i : integer;
|
||||
begin
|
||||
nivDebug:=3;
|
||||
//test_memoire_zones(1005);
|
||||
MemZone[569][538]:=true;
|
||||
test_memoire_zones(177);
|
||||
end;
|
||||
|
||||
|
||||
procedure TFormPrinc.Codificationdesactionneurs1Click(Sender: TObject);
|
||||
var i,adr,etatAct,v,aO,aF : integer;
|
||||
s,s2 : string;
|
||||
begin
|
||||
if (maxTablo_act=0) and (NbrePN=0) then
|
||||
begin
|
||||
Affiche('Aucun actionneur déclaré',clYellow);
|
||||
end;
|
||||
|
||||
|
||||
for i:=1 to maxTablo_act do
|
||||
begin
|
||||
s:=Tablo_actionneur[i].train;
|
||||
etatAct:=Tablo_actionneur[i].etat ;
|
||||
Adr:=Tablo_actionneur[i].actionneur;
|
||||
s2:=Tablo_actionneur[i].train;
|
||||
if (s2<>'') then
|
||||
begin
|
||||
Affiche('FonctionF Actionneur='+intToSTR(adr)+' Train='+s2+' F'+IntToSTR(Tablo_actionneur[i].fonction)+':'+intToSTR(etatAct)+
|
||||
' Temporisation='+intToSTR(tablo_actionneur[i].Tempo),clyellow);
|
||||
end;
|
||||
end;
|
||||
|
||||
// dans le tableau des PN
|
||||
for i:=1 to NbrePN do
|
||||
begin
|
||||
s:='PN'+intToSTR(i)+' Adresse fermeture PN='+IntToSTR(Tablo_PN[i].AdresseFerme);
|
||||
s:=s+' Adresse ouverture PN='+IntToSTR(Tablo_PN[i].AdresseOuvre);
|
||||
Affiche(s,clyellow);
|
||||
s:=' Commande fermeture='+intToSTR(Tablo_PN[i].commandeFerme);
|
||||
s:=s+' Commande ouverture='+intToSTR(Tablo_PN[i].commandeOuvre);
|
||||
s:=s+' Nbre de voies='+intToSTR(Tablo_PN[i].nbVoies);
|
||||
Affiche(s,clyellow);
|
||||
for v:=1 to Tablo_PN[i].nbvoies do
|
||||
begin
|
||||
s:=' Voie '+IntToSTR(v)+': Actionneur de fermeture='+intToSTR(Tablo_PN[i].voie[v].ActFerme);
|
||||
s:=s+' Actionneur d''ouverture='+intToSTR(Tablo_PN[i].voie[v].ActOuvre);
|
||||
Affiche(s,clyellow);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TFormPrinc.ButtonArretSimuClick(Sender: TObject);
|
||||
begin
|
||||
Index_Simule:=0; // fin de simulation
|
||||
I_Simule:=0;
|
||||
MsgSim:=false;
|
||||
|
||||
Reference in New Issue
Block a user