V1.11
This commit is contained in:
348
UnitPrinc.pas
348
UnitPrinc.pas
@@ -9,10 +9,8 @@ Unit UnitPrinc;
|
||||
- 1 = aiguillage dévié
|
||||
*)
|
||||
|
||||
|
||||
interface
|
||||
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, StdCtrls, OleCtrls, ExtCtrls, jpeg, ComCtrls,
|
||||
@@ -76,6 +74,7 @@ type
|
||||
Codificationdesfeux1: TMenuItem;
|
||||
Divers1: TMenuItem;
|
||||
Versions1: TMenuItem;
|
||||
ChronoDetect: TMenuItem;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure MSComm1Comm(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
@@ -118,6 +117,7 @@ type
|
||||
procedure Versions1Click(Sender: TObject);
|
||||
procedure ClientSocketLenzDisconnect(Sender: TObject;
|
||||
Socket: TCustomWinSocket);
|
||||
procedure ChronoDetectClick(Sender: TObject);
|
||||
|
||||
private
|
||||
{ Déclarations privées }
|
||||
@@ -187,8 +187,7 @@ var ancien_tablo_signalCplx,EtatsignalCplx : array[0..MaxAcc] of word;
|
||||
dem_calcul_zone,Hors_tension2,traceSign,TraceZone,Ferme,ParUSB,parSocket,ackCdm,
|
||||
NackCDM : boolean;
|
||||
clignotant,nack,Maj_feux_cours,avecMSCom : boolean;
|
||||
N_event_det : integer; // index du dernier évènement (de 1 à 20)
|
||||
event_det : array[1..20] of integer;
|
||||
|
||||
branche : array [1..100] of string;
|
||||
parcours : array[1..MaxElParcours] of TBranche ; // parcours des locos en fonction des détecteurs
|
||||
|
||||
@@ -217,7 +216,7 @@ var
|
||||
couleur : Tcolor;
|
||||
fichier : text;
|
||||
recuCDML : array of string;
|
||||
|
||||
tick : longint;
|
||||
|
||||
// l'indice du tableau aiguillage est son adresse
|
||||
aiguillage : array[0..MaxAcc] of Taiguillage;
|
||||
@@ -521,7 +520,7 @@ begin
|
||||
cercle(ACanvas,43,13,6,GrisF);
|
||||
cercle(ACanvas,53,13,6,GrisF);
|
||||
end;
|
||||
if EtatSignal=4 then
|
||||
if EtatSignal=4 then
|
||||
begin
|
||||
cercle(ACanvas,11,13,6,clWhite);
|
||||
cercle(ACanvas,22,13,6,clWhite);
|
||||
@@ -2923,7 +2922,7 @@ begin
|
||||
// taille de fonte
|
||||
s:=lit_ligne;
|
||||
i:=StrToINT(s);
|
||||
with FormPrinc.ListBox1 do
|
||||
with FormPrinc.ListBox1 do
|
||||
begin
|
||||
Font.Height:=i;
|
||||
ItemHeight:=i+1;
|
||||
@@ -3892,7 +3891,8 @@ begin
|
||||
A:=aiguillage[AdrTjdP].AdroitB;
|
||||
Adr:=aiguillage[AdrTjdP].Adroit;
|
||||
Abis:=aiguillage[AdrTjdP].AdroitBis;
|
||||
if A='Z' then typeGen:=1 else typeGen:=2; //TypeEL=(1=détécteur 2=aig 3=aig Bis)
|
||||
if A='Z' then typeGen:=1 else typeGen:=2; //TypeEL=(1=détécteur 2=aig 3=aig Bis)
|
||||
if Abis=1 then typeGen:=3;
|
||||
suivant_alg3:=adr;
|
||||
exit;
|
||||
end;
|
||||
@@ -3917,8 +3917,8 @@ begin
|
||||
if aiguillage[Adr].Adevie=prec then
|
||||
begin
|
||||
A:=aiguillage[AdrTjdP].AdroitB;
|
||||
Adr:=aiguillage[AdrTjdP].Adroit;
|
||||
Abis:=aiguillage[AdrTjdP].AdroitBis;
|
||||
Adr:=aiguillage[AdrTjdP].Adroit;
|
||||
Abis:=aiguillage[AdrTjdP].AdroitBis;
|
||||
if A='Z' then typeGen:=1 else typeGen:=2; //TypeEL=(1=détécteur 2=aig 3=aig Bis)
|
||||
if Abis=1 then typeGen:=3;
|
||||
suivant_alg3:=adr;exit;
|
||||
@@ -3943,8 +3943,8 @@ begin
|
||||
if (aiguillage[Adr].Adroit=prec) then
|
||||
begin
|
||||
A:=aiguillage[Adr].AdevieB;
|
||||
Adr:=aiguillage[Adr].Adevie;
|
||||
Abis:=aiguillage[Adr].AdevieBis;
|
||||
Adr:=aiguillage[Adr].Adevie;
|
||||
Abis:=aiguillage[Adr].AdevieBis;
|
||||
if A='Z' then typeGen:=1 else typeGen:=2; //TypeEL=(1=détécteur 2=aig 3=aig Bis)
|
||||
if Abis=1 then typeGen:=3;
|
||||
suivant_alg3:=adr;exit;
|
||||
@@ -3969,8 +3969,8 @@ begin
|
||||
if aiguillage[Adr].Adevie=prec then
|
||||
begin
|
||||
A:=aiguillage[AdrtjdP].AdevieB;
|
||||
Adr:=aiguillage[AdrtjdP].Adevie;
|
||||
Abis:=aiguillage[AdrtjdP].AdevieBis;
|
||||
Adr:=aiguillage[AdrtjdP].Adevie;
|
||||
Abis:=aiguillage[AdrtjdP].AdevieBis;
|
||||
if A='Z' then typeGen:=1 else typeGen:=2; //TypeEL=(1=détécteur 2=aig 3=aig Bis)
|
||||
if Abis=1 then typeGen:=3;
|
||||
suivant_alg3:=adr;exit;
|
||||
@@ -4081,7 +4081,7 @@ begin
|
||||
// étape 1 trouver le sens
|
||||
repeat
|
||||
inc(j);
|
||||
AdrSuiv:=suivant_alg3(precCalc,BisPrecCalc,actuelCalc,BisActuelCalc,1);
|
||||
AdrSuiv:=suivant_alg3(precCalc,BisPrecCalc,actuelCalc,BisActuelCalc,1);
|
||||
precCalc:=actuelCalc;
|
||||
BisPrecCalc:=BisActuelCalc;
|
||||
actuelCalc:=AdrSuiv;
|
||||
@@ -4092,7 +4092,7 @@ begin
|
||||
if AdrSuiv=actuel then
|
||||
begin
|
||||
AdrSuiv:=suivant_alg3(prec,TypeElPrec,actuel,TypeElActuel,1);
|
||||
end;
|
||||
end;
|
||||
if NivDebug=3 then AfficheDebug('Le suivant est le '+intToSTR(AdrSuiv),clYellow);
|
||||
detecteur_suivant:=AdrSuiv;
|
||||
end;
|
||||
@@ -4144,6 +4144,7 @@ begin
|
||||
//trouve_element(det1,FALSE);
|
||||
Adr:=BrancheN[branche_trouve_det1,i].Adresse; // élément suivant le det1
|
||||
AdrFonc:=Adr;
|
||||
Btype:=BrancheN[branche_trouve_det1,i].BType; // élément suivant/précédent
|
||||
BisFonc:=Btype;
|
||||
i:=0;
|
||||
if (el2<>Adr) then
|
||||
@@ -4152,8 +4153,9 @@ begin
|
||||
if (Adr>=9997) then begin detecteur_suivant_el:=Adr;exit;end;
|
||||
if (NivDebug=3) then AfficheDebug('trouvé '+intToSTR(Adr)+' '+intToSTR(typeGen),clorange);
|
||||
trouve_element(Adr,typeGen);
|
||||
Btype:=BrancheN[branche_trouve,IndexBranche_trouve].BType;
|
||||
Btype:=BrancheN[branche_trouve,IndexBranche_trouve].BType;
|
||||
BisSuiv:=Btype; // si aiguillage bis
|
||||
//Affiche(intToSTR(adr)+'/'+intToStr(Btype),clorange);
|
||||
AdrPrec:=AdrFonc;AdrFonc:=Adr;
|
||||
BisPrec:=BisFonc;BisFonc:=typeGen;
|
||||
i:=i+1;
|
||||
@@ -4183,6 +4185,11 @@ begin
|
||||
begin
|
||||
// trouvé la route si j=2 : - si j=3 : +
|
||||
if (NivDebug=3) then AfficheDebug('El - Route trouvée',clyellow);
|
||||
i:=0;
|
||||
AdrFonc:=Adr;
|
||||
BisFonc:=1;
|
||||
//typeGen:=0; //?
|
||||
repeat
|
||||
Adr:=suivant_alg3(AdrPrec,BisPrec,AdrFonc,BisFonc,1);
|
||||
if Adr>9997 then
|
||||
begin
|
||||
@@ -4314,34 +4321,34 @@ begin
|
||||
actuel:=feux[i].Adr_el_suiv1;
|
||||
if feux[i].Btype_suiv1=1 then BisActuel:=1;
|
||||
if feux[i].Btype_suiv1=2 then BisActuel:=2;
|
||||
if feux[i].Btype_suiv1=4 then BisActuel:=2; // aiguillage triple
|
||||
if feux[i].Btype_suiv1=4 then BisActuel:=2; // aiguillage triple
|
||||
if feux[i].Btype_suiv1=5 then BisActuel:=3; // le type du feu 1=détécteur 2=aig 5=bis
|
||||
// si actuel est un détecteur, regarder si il ya un feu
|
||||
repeat
|
||||
inc(j);
|
||||
// à la première itération, si "actuel" est déja un détecteur, ne pas faire de recherche sur le suivant
|
||||
repeat
|
||||
inc(j);
|
||||
// à la première itération, si "actuel" est déja un détecteur, ne pas faire de recherche sur le suivant
|
||||
if (j=1) and (bisActuel=1) then
|
||||
AdrSuiv:=actuel;
|
||||
actuel:=prec;
|
||||
begin
|
||||
AdrSuiv:=actuel;
|
||||
actuel:=prec;BisActuel:=1;
|
||||
BisPrec:=1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
AdrSuiv:=suivant_alg3(prec,BisPrec,actuel,BisActuel,1);
|
||||
prec:=actuel;BisPrec:=BisActuel;
|
||||
actuel:=AdrSuiv;BisActuel:=typeGen;
|
||||
end;
|
||||
if (AdrSuiv=9999) then
|
||||
begin
|
||||
if (AdrSuiv=9999) then
|
||||
begin
|
||||
Etat_signal_suivant:=0;
|
||||
exit;
|
||||
end;
|
||||
if (AdrSuiv=0) then
|
||||
begin
|
||||
if NivDebug=3 then AfficheDebug('Le suivant est un buttoir',clyellow);
|
||||
if (AdrSuiv=0) then
|
||||
begin
|
||||
if NivDebug=3 then AfficheDebug('Le suivant est un buttoir',clyellow);
|
||||
Etat_signal_suivant:=carre_F; // faire comme si c'était un signal au carré
|
||||
|
||||
exit;
|
||||
end;
|
||||
|
||||
// si le suivant est un détecteur comporte t-il un signal?
|
||||
@@ -4397,7 +4404,7 @@ begin
|
||||
BisPrec:=1;
|
||||
actuel:=feux[i].Adr_el_suiv1;
|
||||
if feux[i].Btype_suiv1=1 then BisActuel:=1;
|
||||
if feux[i].Btype_suiv1=2 then BisActuel:=2;
|
||||
if feux[i].Btype_suiv1=2 then BisActuel:=2;
|
||||
if feux[i].Btype_suiv1=5 then BisActuel:=3; // le type du feu 1=détécteur 2=aig 5=bis
|
||||
|
||||
//Affiche(IntToSTR(actuel),clyellow);
|
||||
@@ -4410,13 +4417,11 @@ begin
|
||||
|
||||
repeat
|
||||
inc(j);
|
||||
// 3=demande si le suivant est un aiguillage en pointe dévié oui si AdrSuiv=9997
|
||||
// dans ce cas la variable globale AdrDevie est mise à jour
|
||||
AdrSuiv:=suivant_alg3(prec,BisPrec,actuel,BisActuel,3);
|
||||
if NivDebug=3 then AfficheDebug('701 - Suivant signalaig='+IntToSTR(AdrSuiv),clyellow);
|
||||
// 3=demande si le suivant est un aiguillage en pointe dévié oui si AdrSuiv=9997
|
||||
// dans ce cas la variable globale AdrDevie est mise à jour
|
||||
AdrSuiv:=suivant_alg3(prec,BisPrec,actuel,BisActuel,3);
|
||||
if NivDebug=3 then AfficheDebug('701 - Suivant signalaig='+IntToSTR(AdrSuiv),clyellow);
|
||||
prec:=actuel;
|
||||
if ADrSuiv<>9997 then
|
||||
begin
|
||||
prec:=actuel;BisPrec:=BisActuel;
|
||||
actuel:=AdrSuiv;BisActuel:=typeGen;
|
||||
@@ -4493,7 +4498,6 @@ begin
|
||||
begin
|
||||
// Affiche('i='+intToSTR(i),clyellow);
|
||||
dec(i,2); // i correspond au nombre de feux à allumer
|
||||
pilote_direction(Adr,i);
|
||||
pilote_direction(Adr,i);
|
||||
end;
|
||||
|
||||
@@ -4519,27 +4523,33 @@ begin
|
||||
Pres_train:=FALSE;
|
||||
ife:=1; // index feu de 1 à 4 pour explorer les 4 détecteurs d'un feu
|
||||
repeat
|
||||
j:=0;
|
||||
j:=0;
|
||||
if NivDebug=3 then AfficheDebug('Boucle de test feu '+intToSTR(ife)+'/4',clred);
|
||||
if (ife=1) then
|
||||
begin prec:=feux[i].Adr_det1;actuel:=feux[i].Adr_el_suiv1;
|
||||
if feux[i].Btype_suiv1=1 then BisActuel:=1;
|
||||
if feux[i].Btype_suiv1=1 then BisActuel:=1;
|
||||
if feux[i].Btype_suiv1=2 then BisActuel:=2;
|
||||
if feux[i].Btype_suiv1=5 then BisActuel:=3; // le type du feu 1=détécteur 2=aig 5=bis
|
||||
if feux[i].Btype_suiv1=2 then BisActuel:=2;
|
||||
if feux[i].Btype_suiv1=4 then BisActuel:=2; // aiguillage triple
|
||||
if feux[i].Btype_suiv1=5 then BisActuel:=3; // le type du feu 1=détecteur 2=aig 5=bis
|
||||
end; //détecteur sur le signal courant
|
||||
if (ife=2) then
|
||||
begin prec:=feux[i].Adr_det2;actuel:=feux[i].Adr_el_suiv2;
|
||||
if feux[i].Btype_suiv2=1 then BisActuel:=1;
|
||||
if feux[i].Btype_suiv1=1 then BisActuel:=1;
|
||||
if feux[i].Btype_suiv1=2 then BisActuel:=2;
|
||||
if feux[i].Btype_suiv1=5 then BisActuel:=3; // le type du feu 1=détécteur 2=aig 5=bis
|
||||
end; // détecteur sur le signal courant
|
||||
if feux[i].Btype_suiv2=2 then BisActuel:=2;
|
||||
if feux[i].Btype_suiv2=4 then BisActuel:=2; // aiguillage triple
|
||||
if feux[i].Btype_suiv2=5 then BisActuel:=3; // le type du feu 1=détecteur 2=aig 5=bis
|
||||
end; // détecteur sur le signal courant
|
||||
if (ife=3) then
|
||||
begin
|
||||
prec:=feux[i].Adr_det3;
|
||||
actuel:=feux[i].Adr_el_suiv3;
|
||||
if feux[i].Btype_suiv3=1 then BisActuel:=1;
|
||||
if feux[i].Btype_suiv1=1 then BisActuel:=1;
|
||||
if feux[i].Btype_suiv1=2 then BisActuel:=2;
|
||||
if feux[i].Btype_suiv1=5 then BisActuel:=3; // le type du feu 1=détécteur 2=aig 5=bis
|
||||
end; // détecteur sur le signal courant
|
||||
if feux[i].Btype_suiv3=2 then BisActuel:=2;
|
||||
if feux[i].Btype_suiv3=4 then BisActuel:=2; // aiguillage triple
|
||||
if feux[i].Btype_suiv3=5 then BisActuel:=3; // le type du feu 1=détecteur 2=aig 5=bis
|
||||
end; // détecteur sur le signal courant
|
||||
if (ife=4) then
|
||||
begin
|
||||
prec:=feux[i].Adr_det4;
|
||||
actuel:=feux[i].Adr_el_suiv4;
|
||||
if feux[i].Btype_suiv4=1 then BisActuel:=1;
|
||||
@@ -4554,24 +4564,26 @@ begin
|
||||
test_memoire_zones:=Pres_train;
|
||||
exit;
|
||||
end;
|
||||
BisPrec:=1;
|
||||
BisPrec:=1;
|
||||
|
||||
repeat
|
||||
inc(j);
|
||||
// à la première itération, si "actuel" est déja un détecteur, ne pas faire de recherche sur le suivant
|
||||
// à 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
|
||||
// et chaîner mémoire de zone
|
||||
if (j=1) and (Bisactuel=1) then // si détecteur
|
||||
begin
|
||||
//AfficheDebug('C''est un détecteur',clred);
|
||||
AdrSuiv:=actuel;
|
||||
actuel:=prec;
|
||||
BisPrec:=1;
|
||||
BisActuel:=1;
|
||||
BisActuel:=0;
|
||||
Pres_train:=MemZone[prec,actuel];
|
||||
if Pres_Train and (NivDebug=3) then Affiche('Présence train de '+intToSTR(prec)+' à '+intToSTR(actuel),clyellow);
|
||||
Detecteur_precedent:=actuel;
|
||||
end
|
||||
else
|
||||
AdrSuiv:=suivant_alg3(prec,BisPrec,actuel,BisActuel,1);
|
||||
//TypeGen:=1;
|
||||
Pres_train:=MemZone[prec,actuel];
|
||||
if Pres_Train and (NivDebug=3) then Affiche('Présence train de '+intToSTR(prec)+' à '+intToSTR(actuel),clyellow);
|
||||
Detecteur_precedent:=actuel;
|
||||
end
|
||||
else
|
||||
begin
|
||||
AdrSuiv:=suivant_alg3(prec,BisPrec,actuel,BisActuel,1);
|
||||
//AfficheDebug('A:'+IntToSTR(BisActuel);
|
||||
prec:=actuel;BisPrec:=BisActuel;
|
||||
@@ -4580,7 +4592,7 @@ begin
|
||||
//AfficheDebug('A suivant='+IntToSTR(adrsuiv),clred);
|
||||
if AdrSuiv=0 then
|
||||
begin
|
||||
// si c'est un buttoir
|
||||
// si c'est un buttoir
|
||||
test_memoire_zones:=false;
|
||||
exit;
|
||||
end;
|
||||
@@ -4626,30 +4638,49 @@ begin
|
||||
sort:=(j=10) or (AdrFeu<>0) ;
|
||||
until (sort);
|
||||
inc(ife);
|
||||
until ife>=5;
|
||||
until ife>=5;
|
||||
if (NivDebug=3) and (Etat=0) then AfficheDebug('Pas trouvé de signal suivant au '+intToSTR(adresse),clyellow);
|
||||
|
||||
test_memoire_zones:=Pres_train;
|
||||
end;
|
||||
|
||||
// trouve une séquence chronologique 010 sur un détecteur
|
||||
function trouve_seq_chrono_010(Adresse : integer) : boolean;
|
||||
var i,etat : integer;
|
||||
etat0_seq1,etat1_seq2,etat0_seq3 : boolean;
|
||||
begin
|
||||
i:=N_Event_tick;
|
||||
if i<2 then exit;
|
||||
Affiche('test si seq 010 sur det '+intToSTR(Adresse),clyellow);
|
||||
etat0_seq1:=false; etat1_seq2:=false; etat0_seq3:=false;
|
||||
if (event_det_tick[i].detecteur[Adresse]=0) then begin etat0_seq1:=true;end;
|
||||
repeat
|
||||
// if (event_det_tick[i].detecteur[Adresse]=0) then etat0_seq1:=true;
|
||||
|
||||
if (event_det_tick[i].detecteur[Adresse]=1) and etat0_seq1 then begin etat1_seq2:=true;end;
|
||||
dec(i); // remonter le temps ...
|
||||
until (i=0) or (etat1_seq2);
|
||||
trouve_seq_chrono_010:=etat1_seq2;
|
||||
end;
|
||||
|
||||
// calcul des zones depuis le tableau des fronts descendants des évènements détecteurs
|
||||
// calcul des zones depuis le tableau des fronts descendants des évènements détecteurs
|
||||
// les détecteurs doivent être consécutifs
|
||||
// trouve le détecteur suivant de det1 à det2 si la route est correcte. (détecteurs en entrée obligatoires)
|
||||
// transmis dans le tableau Event_det
|
||||
// Variable globale: El_suivant : adresse du détecteur suivant le détecteur "actuel"
|
||||
// Actuel,Suivant : nouveaux détecteurs du canton suivant
|
||||
// Résultat:
|
||||
// si 0 : pas de route
|
||||
// si 1 : détecteur det1 non trouvé
|
||||
// si 2 : détecteur det2 non trouvé
|
||||
// si 3 : erreur fatale
|
||||
// si 10 : ok route trouvée
|
||||
// si 1 : détecteur det1 non trouvé
|
||||
// si 2 : détecteur det2 non trouvé
|
||||
// si 3 : erreur fatale
|
||||
// si 10 : ok route trouvée
|
||||
function calcul_zones_det(det1,det2 : integer) : integer;
|
||||
var
|
||||
i,i1,i2,j,k,IndexBranche_det1,IndexBranche_det2,index_i1,index_i2,
|
||||
branche_trouve_det1,branche_trouve_det2,Adr,AdrPrec,position,Btype,BTypePrec,
|
||||
branche_trouve_det1,branche_trouve_det2,Adr,AdrPrec,position,Btype,BTypePrec,
|
||||
AdrFonc,BisPrec,BisSuiv,BisFonc,AdrSuiv : integer;
|
||||
sortie : boolean;
|
||||
s : string;
|
||||
|
||||
begin
|
||||
@@ -4688,19 +4719,24 @@ begin
|
||||
end;
|
||||
AdrPrec:=det1;
|
||||
BisPrec:=1;
|
||||
if (j=1) then i:=IndexBranche_det1-1 else i:=IndexBranche_det1+1;
|
||||
//trouve_element(det1,FALSE);
|
||||
Adr:=BrancheN[branche_trouve_det1,i].Adresse;
|
||||
AdrFonc:=Adr;
|
||||
Btype:=BrancheN[branche_trouve_det1,i].BType; // élément suivant/précédent
|
||||
BisFonc:=Btype;
|
||||
i:=0;
|
||||
if (det2<>Adr) then
|
||||
repeat
|
||||
Adr:=suivant_alg3(AdrPrec,BisPrec,AdrFonc,BisFonc,1); // donne l'élément suivant de AdrPrec à AdrFonc et dans Bis si c'est un aig bis
|
||||
trouve_element(Adr,typeGen);
|
||||
Btype:=BrancheN[branche_trouve,IndexBranche_trouve].BType;
|
||||
BisSuiv:=Btype; // si aiguillage bis
|
||||
if (j=1) then i:=IndexBranche_det1-1 else i:=IndexBranche_det1+1;
|
||||
//trouve_element(det1,FALSE);
|
||||
Adr:=BrancheN[branche_trouve_det1,i].Adresse;
|
||||
AdrFonc:=Adr;
|
||||
Btype:=BrancheN[branche_trouve_det1,i].BType; // élément suivant/précédent
|
||||
BisFonc:=Btype;
|
||||
|
||||
// si l'élémént suivant est un détecteur et il est différent de det2, c'est pas le bon sens : inutile de traiter le cas
|
||||
if (Btype<>1) or (Adr=Det2) then
|
||||
begin
|
||||
i:=0;
|
||||
if (det2<>Adr) then
|
||||
repeat
|
||||
Adr:=suivant_alg3(AdrPrec,BisPrec,AdrFonc,BisFonc,1); // donne l'élément suivant de AdrPrec à AdrFonc et dans Bis si c'est un aig bis
|
||||
trouve_element(Adr,typeGen);
|
||||
Btype:=BrancheN[branche_trouve,IndexBranche_trouve].BType;
|
||||
BisSuiv:=Btype; // si aiguillage bis
|
||||
//Affiche(intToSTR(adr)+'/'+intToStr(Btype),clorange);
|
||||
AdrPrec:=AdrFonc;AdrFonc:=Adr;
|
||||
BisPrec:=BisFonc;BisFonc:=typeGen;
|
||||
i:=i+1;
|
||||
@@ -4715,11 +4751,13 @@ begin
|
||||
inc(j);
|
||||
sortie:=((Adr=det2) and (Btype=1)) or (j=3);
|
||||
until sortie;
|
||||
|
||||
if ((j=3) and (Adr<>det2)) then
|
||||
begin
|
||||
if (NivDebug=3) then AfficheDebug('Pas de suivant sur séquence '+IntToSTR(det1)+' à '+intToStr(det2),clyellow);
|
||||
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
|
||||
@@ -4737,23 +4775,29 @@ begin
|
||||
trouve_element(Adr,typeGen);
|
||||
Btype:=BrancheN[branche_trouve,IndexBranche_trouve].BType;
|
||||
BisSuiv:=Btype; // si aiguillage bis
|
||||
if (NivDebug=3) then AfficheDebug('Suivant='+IntToSTR(Adr)+ '('+intToSTR(Btype)+')',clyellow);
|
||||
AdrPrec:=AdrFonc;AdrFonc:=Adr;
|
||||
BisPrec:=BisFonc;BisFonc:=typeGen;
|
||||
inc(i);
|
||||
sortie:=(Btype=1) or (Adr=0) or (i=20);
|
||||
until sortie;
|
||||
|
||||
if (i=20) then begin Affiche('Erreur fatale 201 : Itération trop longue',clred);
|
||||
AfficheDebug('Erreur fatale 201 : Itération trop longue',clred);calcul_zones_det:=3;end;
|
||||
*)
|
||||
sortie:=(Btype=1) or (Adr=0) or (i=20);
|
||||
until sortie;
|
||||
if (i=20) then begin Affiche('Erreur fatale 201 : Itération trop longue',clred);
|
||||
AfficheDebug('Erreur fatale 201 : Itération trop longue',clred);calcul_zones_det:=3;end;
|
||||
|
||||
// le train vient de det1, quitte det2 et va vers Adr
|
||||
Mem[det1]:=false;
|
||||
Mem[det2]:=true;
|
||||
MemZone[det1,det2]:=FALSE; // efface canton précédent
|
||||
|
||||
AdrSuiv:=detecteur_suivant_El(det1,1,det2,1);
|
||||
AdrPrec:=detecteur_suivant_El(det2,1,det1,1);
|
||||
|
||||
//Mem[det2]:=true;
|
||||
// le train vient de det1, quitte det2 et va vers Adr
|
||||
if Mem[AdrPrec]=FALSE then begin calcul_zones_det:=10;exit; end;
|
||||
Mem[AdrPrec]:=false;
|
||||
|
||||
MemZone[det1,det2]:=FALSE; // efface zone précédente
|
||||
MemZone[det2,AdrSuiv]:=TRUE; // valide la nouveau zone
|
||||
With FormDebug.MemoDet do
|
||||
begin
|
||||
precedent:=det1;
|
||||
Actuel:=det2;
|
||||
Suivant:=Adr;
|
||||
Lines.Add('route ok '+intToStr(det1)+' à '+intToStr(det2));
|
||||
s:='Mem '+IntToSTR(det2)+' à '+IntTOStr(AdrSuiv);
|
||||
Lines.Add(s);
|
||||
@@ -4761,7 +4805,7 @@ end;
|
||||
Affiche(s,clyellow);
|
||||
|
||||
calcul_zones_det:=10;
|
||||
exit; // réussi
|
||||
exit; // réussi
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -4880,13 +4924,13 @@ begin
|
||||
begin
|
||||
det_initial:=feux[i].Adr_det4;Adr_El_Suiv:=feux[i].Adr_el_suiv4;
|
||||
if feux[i].Btype_suiv1=1 then Btype_el_suivant:=1;
|
||||
if feux[i].Btype_suiv1=2 then Btype_el_suivant:=2;
|
||||
if feux[i].Btype_suiv1=2 then Btype_el_suivant:=2;
|
||||
if feux[i].Btype_suiv1=5 then Btype_el_suivant:=3; // le type du feu 1=détécteur 2=aig 5=bis
|
||||
end;
|
||||
if (det_initial<>0) then
|
||||
if (det_initial<>0) then
|
||||
begin
|
||||
DetPrec1:=detecteur_suivant(Adr_El_Suiv,Btype_el_suivant,det_initial,1);
|
||||
if DetPrec1<>9999 then // route bloquée par aiguillage mal positionné
|
||||
if DetPrec1<9997 then // route bloquée par aiguillage mal positionné
|
||||
begin
|
||||
DetPrec2:=detecteur_suivant_El(det_initial,1,DetPrec1,1);
|
||||
if DetPrec2<9997 then
|
||||
@@ -5092,6 +5136,7 @@ begin
|
||||
det1:=event_det[index_1];
|
||||
det2:=event_det[index_2];
|
||||
if det1=det2 then // si détecteurs identiques, supprimer le 2eme
|
||||
begin
|
||||
if traceListe then Affiche('trouvé doublon',clyellow);
|
||||
supprime_event(index_2);
|
||||
if traceListe then for index_3:=1 to N_event_det do affiche(intToSTR(event_det[index_3]),clyellow);
|
||||
@@ -5153,6 +5198,20 @@ begin
|
||||
var i : integer;
|
||||
begin
|
||||
Affiche('Demande état des aiguillages',ClYellow);
|
||||
for i:=1 to maxaiguillage do
|
||||
begin
|
||||
demande_info_acc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
// stocke les changements d'état des détecteurs dans le tableau chronologique
|
||||
// et la mémoire de zone
|
||||
procedure stocke_chrono_event_det(Adr,etat : integer);
|
||||
begin
|
||||
if (N_Event_tick<Max_Event_det_tick) then
|
||||
begin
|
||||
inc(N_Event_tick);
|
||||
event_det_tick[N_event_tick].tick:=tick;
|
||||
event_det_tick[N_event_tick].detecteur[Adr]:=etat;
|
||||
end;
|
||||
if etat=1 then Mem[Adr]:=true; // mémoriser l'état à 1
|
||||
@@ -5185,6 +5244,8 @@ begin
|
||||
detecteur[i]:=(valeur and $8) = $8;
|
||||
detecteur_chgt:=i;
|
||||
// mise a jour du tableau evt
|
||||
if ancien_detecteur[i] and not(detecteur[i]) and (N_Event_det<20) then
|
||||
begin
|
||||
inc(N_event_det);
|
||||
event_det[N_event_det]:=i;
|
||||
dem_calcul_zone:=true;
|
||||
@@ -5201,6 +5262,8 @@ begin
|
||||
detecteur[i]:=(valeur and $4) = $4;
|
||||
detecteur_chgt:=i;
|
||||
// mise a jour du tableau evt
|
||||
if ancien_detecteur[i] and not(detecteur[i]) and (N_Event_det<20) then
|
||||
begin
|
||||
inc(N_event_det);
|
||||
event_det[N_event_det]:=i;
|
||||
dem_calcul_zone:=true;
|
||||
@@ -5217,6 +5280,8 @@ begin
|
||||
detecteur[i]:=(valeur and $2) = $2;
|
||||
detecteur_chgt:=i;
|
||||
// mise a jour du tableau evt
|
||||
if ancien_detecteur[i] and not(detecteur[i]) and (N_Event_det<20) then
|
||||
begin
|
||||
inc(N_event_det);
|
||||
event_det[N_event_det]:=i;
|
||||
dem_calcul_zone:=true;
|
||||
@@ -5233,6 +5298,8 @@ begin
|
||||
detecteur[i]:=(valeur and $1) = $1;
|
||||
detecteur_chgt:=i;
|
||||
// mise a jour du tableau evt
|
||||
if ancien_detecteur[i] and not(detecteur[i]) and (N_Event_det<20) then
|
||||
begin
|
||||
inc(N_event_det);
|
||||
event_det[N_event_det]:=i;
|
||||
dem_calcul_zone:=true;
|
||||
@@ -5283,9 +5350,10 @@ begin
|
||||
detecteur[i]:=(valeur and $8) = $8;
|
||||
detecteur_chgt:=i;
|
||||
// mise a jour du tableau evt
|
||||
if ancien_detecteur[i] and not(detecteur[i]) and (N_Event_det<20) then
|
||||
begin
|
||||
inc(N_event_det);
|
||||
event_det[N_event_det]:=i;
|
||||
inc(N_event_det);
|
||||
dem_calcul_zone:=true;
|
||||
end;
|
||||
if ancien_detecteur[i] and not(detecteur[i]) then stocke_chrono_event_det(i,0);
|
||||
@@ -5299,6 +5367,8 @@ begin
|
||||
detecteur[i]:=(valeur and $4) = $4;
|
||||
detecteur_chgt:=i;
|
||||
// mise a jour du tableau evt
|
||||
if ancien_detecteur[i] and not(detecteur[i]) and (N_Event_det<20) then
|
||||
begin
|
||||
inc(N_event_det);
|
||||
event_det[N_event_det]:=i;
|
||||
dem_calcul_zone:=true;
|
||||
@@ -5315,6 +5385,8 @@ begin
|
||||
detecteur[i]:=(valeur and $2) = $2;
|
||||
detecteur_chgt:=i;
|
||||
// mise a jour du tableau evt
|
||||
if ancien_detecteur[i] and not(detecteur[i]) and (N_Event_det<20) then
|
||||
begin
|
||||
inc(N_event_det);
|
||||
event_det[N_event_det]:=i;
|
||||
dem_calcul_zone:=true;
|
||||
@@ -5331,6 +5403,8 @@ begin
|
||||
detecteur[i]:=(valeur and $1) = $1;
|
||||
detecteur_chgt:=i;
|
||||
// mise a jour du tableau evt
|
||||
if ancien_detecteur[i] and not(detecteur[i]) and (N_Event_det<20) then
|
||||
begin
|
||||
inc(N_event_det);
|
||||
event_det[N_event_det]:=i;
|
||||
dem_calcul_zone:=true;
|
||||
@@ -5653,7 +5727,7 @@ end;
|
||||
FreeLibrary(DLL);
|
||||
end;
|
||||
Result:=IsWow64;
|
||||
end;
|
||||
end;
|
||||
{$J-}
|
||||
|
||||
|
||||
@@ -5726,9 +5800,18 @@ begin
|
||||
|
||||
// Initialisation des images des signaux
|
||||
NbreImagePLigne:=Formprinc.ScrollBox1.Width div (largImg+5);
|
||||
|
||||
|
||||
// ajoute une image dynamiquement
|
||||
for i:=1 to NbreFeux do
|
||||
begin
|
||||
cree_image(i); // et initialisation tableaux signaux
|
||||
end;
|
||||
Tempo_init:=10; // démarre les initialisation des signaux et des aiguillages dans 1 s
|
||||
for i:=1 to Max_Event_det_tick do
|
||||
begin
|
||||
for j:=1 to 1100 do
|
||||
event_det_tick[i].detecteur[j]:=-1;
|
||||
end;
|
||||
|
||||
tick:=0;
|
||||
|
||||
@@ -5754,15 +5837,17 @@ begin
|
||||
// event_det[2]:=520;
|
||||
// N_event_det:=2;
|
||||
//aiguillage[31].Position:=2;
|
||||
//aiguillage[10].Position:=1;
|
||||
//traceDet:=true;
|
||||
// calcul_zones;
|
||||
//maj_feu(201);
|
||||
//etat_signal_suivant(201,1);
|
||||
//Aiguille_deviee(462);
|
||||
//aiguillage[10].Position:=1;
|
||||
//traceDet:=true;
|
||||
// calcul_zones;
|
||||
//maj_feu(201);
|
||||
//etat_signal_suivant(201,1);
|
||||
//Aiguille_deviee(462);
|
||||
//NivDebug:=3;
|
||||
//formdebug.Show;
|
||||
//AfficheDet:=true;
|
||||
NivDebug:=3;
|
||||
aiguillageB[1].Position:=1;
|
||||
//aiguillageB[1].Position:=1;
|
||||
//i:=suivant_alg3(553,1,1,3,1);
|
||||
//Affichedebug(intToSTr(i),clred);
|
||||
//Affiche(IntToSTR(calcul_zones_det(522,514)),clyellow);
|
||||
//test_memoire_zones(1011);
|
||||
@@ -6006,6 +6091,8 @@ end;
|
||||
|
||||
|
||||
end;
|
||||
|
||||
|
||||
// timer à 100 ms
|
||||
procedure TFormPrinc.Timer1Timer(Sender: TObject);
|
||||
var i,a : integer;
|
||||
@@ -6419,14 +6506,29 @@ begin
|
||||
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);
|
||||
Delete(recuCDM,j,i+5-j);
|
||||
val(ss,etat,erreur);
|
||||
|
||||
ancien_detecteur[adr]:=detecteur[adr];
|
||||
Detecteur[adr]:=etat=1;
|
||||
detecteur_chgt:=adr;
|
||||
// stockage du premier état du détecteur
|
||||
//if N_Event_tick=0 then stocke_chrono_event_det(Adr,etat);
|
||||
// front montant sur détecteur
|
||||
if not(ancien_detecteur[adr]) and (detecteur[adr]) then
|
||||
begin
|
||||
ancien_detecteur[adr]:=detecteur[adr];
|
||||
Detecteur[adr]:=etat=1;
|
||||
detecteur_chgt:=adr;
|
||||
FormDebug.MemoDet.Lines.Add(IntToSTR(adr)+' 1');
|
||||
stocke_chrono_event_det(Adr,1);
|
||||
end;
|
||||
// front descendant sur détecteur
|
||||
if ancien_detecteur[adr] and not(detecteur[adr]) and (N_Event_det<20) then
|
||||
begin
|
||||
if N_Event_det<20 then
|
||||
begin
|
||||
inc(N_event_det);
|
||||
event_det[N_event_det]:=adr;
|
||||
dem_calcul_zone:=true;
|
||||
FormDebug.MemoDet.Lines.Add(IntToSTR(adr)+' 0');
|
||||
end;
|
||||
stocke_chrono_event_det(Adr,0);
|
||||
end;
|
||||
@@ -6436,7 +6538,7 @@ begin
|
||||
end ;
|
||||
|
||||
inc(k);
|
||||
//traite:=(k<30) or (pos('CMDACC-ST_TO',recuCDM)<>0) or (pos('CMDACC-ST_DT',recuCDM)<>0) ;
|
||||
//traite:=(k<30) or (pos('CMDACC-ST_TO',recuCDM)<>0) or (pos('CMDACC-ST_DT',recuCDM)<>0) ;
|
||||
sort:=(k>70) or (pos('CMDACC-ST_TO',recuCDM)=0) and (pos('CMDACC-ST_DT',recuCDM)=0);
|
||||
until (sort);
|
||||
|
||||
@@ -6511,8 +6613,10 @@ begin
|
||||
end;
|
||||
|
||||
procedure TFormPrinc.Versions1Click(Sender: TObject);
|
||||
begin
|
||||
begin
|
||||
Affiche('Version 1.0 : première version',clLime);
|
||||
Affiche('Version 1.01 : gestion des trajectoires vers les buttoirs',clLime);
|
||||
Affiche('Version 1.02 : vérification automatique des versions',clLime);
|
||||
Affiche('Version 1.1 : gestion des tableaux indicateurs de direction',clLime);
|
||||
Affiche(' gestion du décodeur de signaux Unisemaf Paco (expérimental)',clLime);
|
||||
Affiche(' changement dynamique des feux en cliquant sur son image',clLime);
|
||||
@@ -6521,5 +6625,25 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TFormPrinc.ClientSocketLenzDisconnect(Sender: TObject;
|
||||
Socket: TCustomWinSocket);
|
||||
begin
|
||||
parSocket:=False;
|
||||
end;
|
||||
|
||||
|
||||
procedure TFormPrinc.ChronoDetectClick(Sender: TObject);
|
||||
var i,j,etat : integer;
|
||||
s : string;
|
||||
trouve : boolean;
|
||||
begin
|
||||
for i:=1 to N_Event_tick do
|
||||
begin
|
||||
s:=IntToSTR(i)+' Tick='+IntToSTR(event_det_tick[i].tick)+' Det=';
|
||||
trouve:=false;
|
||||
for j:=1 to 1100 do
|
||||
begin
|
||||
etat:=event_det_tick[i].detecteur[j];
|
||||
if etat<>-1 then begin s:=s+IntToSTR(j)+'='+intToSTR(etat);trouve:=true;end;
|
||||
end;
|
||||
if trouve then Affiche(s,clyellow);
|
||||
|
||||
Reference in New Issue
Block a user