V1.75
This commit is contained in:
183
UnitPrinc.pas
183
UnitPrinc.pas
@@ -309,11 +309,15 @@ var ancien_tablo_signalCplx,EtatsignalCplx : array[0..MaxAcc] of word;
|
||||
VerrouCarre : boolean ; // si vrai, le feu se verrouille au carré si pas de train avant le signal
|
||||
EtatSignal : word ; // comme EtatSignalCplx
|
||||
UniSemaf : integer ; // définition supplémentaire de la cible pour les décodeurs UNISEMAF
|
||||
AigDirection : array[1..6] of array of record // pour les signaux directionnels : contient la liste des aiguillages associés
|
||||
AigDirection : array[1..6] of array of record // pour les signaux directionnels : contient la liste des aiguillages associés
|
||||
Adresse : integer; // 6 feux max associés à un tableau dynamique décrivant les aiguillages
|
||||
posAig : char;
|
||||
end;
|
||||
end;
|
||||
CondCarre : array[1..6] of array of record // conditions supplémentaires d'aiguillages en position pour le carré
|
||||
Adresse : integer; // aiguillage
|
||||
posAig : char;
|
||||
end;
|
||||
end;
|
||||
Fimage : Timage;
|
||||
|
||||
BrancheN : array[1..100,1..200] of TBranche;
|
||||
@@ -1503,6 +1507,7 @@ begin
|
||||
envoi(s); // envoi de la trame et attente Ack
|
||||
// si l'accessoire est un feu et sans raz des signaux, sortir
|
||||
if (acc=feu) and not(Raz_Acc_signaux) then exit;
|
||||
|
||||
|
||||
// si aiguillage, faire une temporisation
|
||||
//if (index_feu(adresse)=0) or (Acc=aig) then
|
||||
@@ -3888,7 +3893,7 @@ begin
|
||||
if j>1 then
|
||||
begin
|
||||
adresse:=StrToINT(copy(s,1,j-1));Delete(s,1,j); // adresse de feu
|
||||
feux[i].adresse:=adresse;
|
||||
feux[i].adresse:=adresse;
|
||||
j:=pos(',',s);
|
||||
if j>1 then
|
||||
begin
|
||||
@@ -3920,7 +3925,7 @@ begin
|
||||
//Affiche('Boucle de Ligne',clyellow);
|
||||
//Affiche(s,clOrange);
|
||||
repeat
|
||||
//Affiche('Boucle de direction',clyellow);
|
||||
//Affiche('Boucle de direction',clyellow);
|
||||
//Affiche(s,clOrange);
|
||||
if s[1]<>'A' then begin Affiche('Erreur a la ligne',clred);exit;end;
|
||||
delete(s,1,1);
|
||||
@@ -3943,7 +3948,7 @@ begin
|
||||
dec(k);
|
||||
if k<>l+1 then
|
||||
begin
|
||||
Affiche('Ligne '+chaine,clred);
|
||||
Affiche('Ligne '+chaine,clred);
|
||||
Affiche('Nombre incorrect de description des aiguillages: '+intToSTR(k)+' pour '+intToSTR(l)+' feux directionnels',clred);
|
||||
end;
|
||||
|
||||
@@ -3956,7 +3961,7 @@ begin
|
||||
if (k=0) or (k=6) or (k>9) then
|
||||
Affiche('Fichier config.cfg: configuration aspect ('+intToSTR(k)+') feu incorrecte à la ligne '+chaine,clRed);
|
||||
j:=pos(',',s);
|
||||
if j>1 then begin Feux[i].FeuBlanc:=(copy(s,1,j-1))='1';delete(s,1,j);end;
|
||||
if j>1 then begin Feux[i].FeuBlanc:=(copy(s,1,j-1))='1';delete(s,1,j);end;
|
||||
j:=pos(',',s);
|
||||
if j=0 then begin Feux[i].decodeur:=StrToInt(s);end else begin Feux[i].decodeur:=StrToInt(copy(s,1,j-1));delete(s,1,j);end;
|
||||
feux[i].Adr_el_suiv1:=0;feux[i].Adr_el_suiv2:=0;feux[i].Adr_el_suiv3:=0;feux[i].Adr_el_suiv4:=0;
|
||||
@@ -4055,6 +4060,45 @@ begin
|
||||
if k=0 then begin Affiche('Ligne '+chaine,clred);Affiche('Manque définition de la cible pour le décodeur UniSemaf',clred);end
|
||||
else
|
||||
begin
|
||||
Delete(S,1,k);
|
||||
Val(s,k,erreur);
|
||||
Feux[i].UniSemaf:=k;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
// voir si conditions supplémentaires de carré
|
||||
l:=1; // nombre de parenthèses
|
||||
repeat
|
||||
t:=pos('(',s);
|
||||
if t<>0 then
|
||||
begin
|
||||
//Affiche('Conditions supplémentaires pour le feu '+IntToSTR(adresse)+' parenthèse '+intToSTR(l),clyellow);
|
||||
k:=pos(')',s);
|
||||
sa:=copy(s,t+1,k-t-1); // contient l'intérieur des parenthèses sans les parenthèses
|
||||
//Affiche(sa,clRed);
|
||||
delete(s,1,k);//Affiche(s,clYellow);
|
||||
// boucle dans la parenthèse
|
||||
bd:=0;
|
||||
repeat
|
||||
inc(bd);
|
||||
setlength(feux[i].condCarre[l],bd+1); // une condition en plus
|
||||
k:=pos(',',sa);
|
||||
if k<>0 then
|
||||
chaine:=copy(sa,1,k-1)
|
||||
else
|
||||
chaine:=sa;
|
||||
|
||||
if chaine[1]='A' then
|
||||
begin
|
||||
delete(chaine,1,1);
|
||||
val(chaine,adresse,erreur);
|
||||
feux[i].condCarre[l][bd].Adresse:=adresse;
|
||||
if erreur<>0 then feux[i].condCarre[l][bd].PosAig:=chaine[erreur] else
|
||||
Affiche('Définition du feu '+IntToSTR(adresse)+': erreur dans les conditions de carré des aiguillages',clred);
|
||||
end;
|
||||
|
||||
|
||||
k:=pos(',',sa);if k<>0 then delete(sa,1,k);
|
||||
//Affiche(sa,clyellow);
|
||||
until k=0;
|
||||
//Affiche('Longueur tableau '+IntToSTR(l)+':'+intToSTR(length(feux[i].condCarre[l])),clyellow);
|
||||
@@ -4293,19 +4337,22 @@ end;
|
||||
|
||||
// renvoie élément suivant entre deux éléments quels qu'ils soient mais contigus
|
||||
// et en variables globales: typeGen le type de l'élément
|
||||
// s'ils ne sont pas contigus, on aura une erreur
|
||||
// s'ils ne sont pas contigus, on aura une erreur
|
||||
// alg= algorithme :
|
||||
// 1=arret sur suivant qu'il soit un détecteur ou un aiguillage
|
||||
// 2=arret sur aiguillage en talon mal positionné
|
||||
// 3=arret sur un aiguillage pris en pointe dévié et AdrDevie contient l'adresse de l'aiguillage dévié ainsi que typeGen
|
||||
// code de sortie : élément suivant ou:
|
||||
// 9999=erreur fatale ou itération trop longue
|
||||
// 9999=erreur fatale
|
||||
// 9998= arret sur aiguillage en talon mal positionnée
|
||||
// 9997: arrêt sur aiguillage dévié
|
||||
// 9996: arrêt sur position inconnue d'aiguillage
|
||||
// typeGen : 1=detecteur 2=aiguillage 3=aiguillage bis
|
||||
function suivant_alg3(prec : integer;typeELprec : integer;actuel : integer;typeElActuel : integer;alg : integer) : integer;
|
||||
var Btype,Adr,AdrPrec,BtypePrec,indexBranche_prec,branche_trouve_prec,indexBranche_actuel,branche_trouve_actuel,
|
||||
tjsc1,tjsc2,AdrTjdP,Adr2,Abis,TypeEl,N_iteration : integer;
|
||||
tjscourbe1,tjscourbe2,tjd,tjs : boolean;
|
||||
A,Aprec,tjsc1B,tjsc2B: char;
|
||||
s : string;
|
||||
label recommence;
|
||||
begin
|
||||
@@ -4385,6 +4432,15 @@ begin
|
||||
suivant_alg3:=adr;
|
||||
exit;
|
||||
end;
|
||||
// ici, les éléments sont non consécutifs. voir si l'un des deux est une TJD/TJS
|
||||
if (btypePrec=2) or (btypePrec=3) then
|
||||
begin
|
||||
if NivDebug=3 then AfficheDebug('Le précedent est une TJD/S - substitution du precédent par la pointe de la TJD',clYellow);
|
||||
// changer l'adresse du précédent par l'autre adresse de la TJD/S
|
||||
prec:=Aiguillage[prec].APointe;
|
||||
inc(n_iteration);
|
||||
if n_iteration>50 then
|
||||
begin
|
||||
s:='Erreur fatale 9999, trop d''itérations';
|
||||
Affiche(s,clRed);
|
||||
AfficheDebug(s,clRed);
|
||||
@@ -4646,8 +4702,9 @@ begin
|
||||
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)
|
||||
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;
|
||||
end;
|
||||
@@ -4673,11 +4730,13 @@ begin
|
||||
if aiguillage[Adr].Adevie=prec then
|
||||
begin
|
||||
A:=aiguillage[AdrTjdP].AdroitB;
|
||||
Adr:=aiguillage[AdrTjdP].Adroit;
|
||||
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;
|
||||
end;
|
||||
suivant_alg3:=adr;exit;
|
||||
s:='Erreur 1022, TJD '+IntToSTR(Adr)+'/'+IntToSTR(AdrTjdP)+' mal positionnée';
|
||||
if nivDebug=3 then AfficheDebug(s,clred);
|
||||
Affiche(s,clred);
|
||||
Suivant_alg3:=9998;exit;
|
||||
@@ -4699,7 +4758,9 @@ begin
|
||||
if (aiguillage[Adr].Adroit=prec) then
|
||||
begin
|
||||
A:=aiguillage[Adr].AdevieB;
|
||||
Adr:=aiguillage[Adr].Adevie;
|
||||
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;
|
||||
end;
|
||||
@@ -4725,7 +4786,9 @@ begin
|
||||
if aiguillage[Adr].Adevie=prec then
|
||||
begin
|
||||
A:=aiguillage[AdrtjdP].AdevieB;
|
||||
Adr:=aiguillage[AdrtjdP].Adevie;
|
||||
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;
|
||||
end;
|
||||
@@ -4801,7 +4864,7 @@ begin
|
||||
A:=aiguillage[Adr].Adevie2B;
|
||||
Adr:=aiguillage[Adr].Adevie2;
|
||||
if A='Z' then TypeEl:=1 else TypeEL:=2; //TypeEL=(1=détécteur 2=aig 3=aig Bis)
|
||||
if Abis=1 then TypeEl:=3;
|
||||
if Abis=1 then TypeEl:=3;
|
||||
trouve_element(Adr,TypeEl); // branche_trouve IndexBranche_trouve
|
||||
typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].BType;
|
||||
suivant_alg3:=adr;exit;
|
||||
@@ -4905,7 +4968,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;
|
||||
@@ -5108,6 +5171,42 @@ begin
|
||||
until sortie;
|
||||
if NivDebug>=2 Then AfficheDebug('Détecteur suivant='+intToSTR(Adr),clOrange);
|
||||
if (bType=1) or (Adr=0) then detecteur_suivant_el:=Adr;
|
||||
if (i=20) then begin
|
||||
if NivDebug=3 then AfficheDebug('Erreur fatale 201 : Itération trop longue',clred);
|
||||
Affiche('Erreur fatale 201 : Itération trop longue',clred);detecteur_suivant_el:=3;end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function cond_carre(adresse : integer) : boolean;
|
||||
var i,l,k,NCondCarre,adrAig : integer;
|
||||
resultatET,resultatOU: boolean;
|
||||
s : string;
|
||||
begin
|
||||
i:=index_feu(adresse);
|
||||
NCondCarre:=Length(feux[i].condcarre[1]);
|
||||
|
||||
l:=1;
|
||||
resultatOU:=false;
|
||||
|
||||
while NcondCarre<>0 do
|
||||
begin
|
||||
if Ncondcarre<>0 then dec(Ncondcarre);
|
||||
resultatET:=true;
|
||||
for k:=1 to NcondCarre do
|
||||
begin
|
||||
//s2:=s2+'A'+IntToSTR(feux[i].condcarre[l][k].Adresse)+feux[i].condcarre[l][k].PosAig+' ';
|
||||
AdrAig:=feux[i].condcarre[l][k].Adresse;
|
||||
resultatET:=((aiguillage[AdrAig].position=const_devie) and (feux[i].condcarre[l][k].PosAig='S') or (aiguillage[AdrAig].position=const_droit) and (feux[i].condcarre[l][k].PosAig='D'))
|
||||
and resultatET;
|
||||
end;
|
||||
//if resultatET then Affiche('VRAI',clyellow) else affiche('FAUX',clred);
|
||||
inc(l);
|
||||
resultatOU:=resultatOU or resultatET;
|
||||
NCondCarre:=Length(feux[i].condcarre[l]);
|
||||
end;
|
||||
//if resultatOU then Affiche('VRAI final',clyellow) else affiche('FAUX final',clred);
|
||||
if NivDebug=3 then
|
||||
begin
|
||||
s:='Conditions de carré suivant aiguillages: ';
|
||||
if ResultatOU then s:=s+'vrai' else s:=s+'faux';
|
||||
AfficheDebug(s,clyellow);
|
||||
@@ -5138,7 +5237,7 @@ begin
|
||||
begin
|
||||
carre_signal:=FALSE; // pour l'instant verrouillé
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
//Affiche(IntToSTR(actuel),clyellow);
|
||||
repeat
|
||||
@@ -5234,7 +5333,7 @@ begin
|
||||
TypeActuel:=1;
|
||||
TypePrec:=1;
|
||||
end
|
||||
else
|
||||
else
|
||||
begin
|
||||
AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,1);
|
||||
prec:=actuel;TypePrec:=TypeActuel;
|
||||
@@ -5483,9 +5582,14 @@ begin
|
||||
begin
|
||||
Pres_train:=MemZone[Prec,actuel];
|
||||
if Pres_Train and (NivDebug=3) then Affiche('Présence train de '+intToSTR(prec)+' à '+intToSTR(actuel),clyellow);
|
||||
end
|
||||
else
|
||||
begin
|
||||
AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,1);
|
||||
prec:=actuel;TypePrec:=TypeActuel;
|
||||
actuel:=AdrSuiv;TypeActuel:=typeGen;
|
||||
if AdrSuiv>9990 then
|
||||
begin
|
||||
begin
|
||||
test_memoire_zones:=false;exit;
|
||||
end;
|
||||
|
||||
@@ -5702,7 +5806,7 @@ begin
|
||||
|
||||
//if AffSignal then AfficheDebug('Debut du traitement général',clYellow);
|
||||
// traitement des feux >3 feux différents de violet (cas général)
|
||||
if (Feux[i].aspect>=3) and (EtatSignalCplx[AdrFeu]<>violet_F) then
|
||||
if (Feux[i].aspect>=3) and (EtatSignalCplx[AdrFeu]<>violet_F) then
|
||||
begin
|
||||
// détecteurs précédent le feu , pour déterminer si leurs mémoires de zones sont à 1 pour libérer le carré
|
||||
if Feux[i].VerrouCarre then
|
||||
@@ -5713,20 +5817,20 @@ begin
|
||||
PresTrain:=FALSE;
|
||||
|
||||
j:=1;
|
||||
repeat
|
||||
repeat
|
||||
if NivDebug=3 then afficheDebug('Séquence '+IntToSTR(j)+' de recherche des 4 détecteurs précédents-----',clOrange);
|
||||
if (j=1) then
|
||||
begin det_initial:=feux[i].Adr_det1;Adr_El_Suiv:=feux[i].Adr_el_suiv1;
|
||||
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=5 then Btype_el_suivant:=3; // 1=détécteur 2=aig 5=bis
|
||||
end;
|
||||
end;
|
||||
if (j=2) then
|
||||
begin
|
||||
det_initial:=feux[i].Adr_det2;Adr_El_Suiv:=feux[i].Adr_el_suiv2;
|
||||
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=5 then Btype_el_suivant:=3; // le type du feu 1=détécteur 2=aig 5=bis
|
||||
if feux[i].Btype_suiv1=5 then Btype_el_suivant:=3; // 1=détécteur 2=aig 5=bis
|
||||
end;
|
||||
if (j=3) then
|
||||
begin det_initial:=feux[i].Adr_det3;Adr_El_Suiv:=feux[i].Adr_el_suiv3;
|
||||
@@ -5771,6 +5875,8 @@ begin
|
||||
end;
|
||||
inc(j);
|
||||
until (j>=5);
|
||||
if presTrain and AffSignal Then afficheDebug('présence train feu '+intToSTR(AdrFeu),clorange);
|
||||
end;
|
||||
if AffSignal then afficheDebug('Fin de la recherche des 4 détecteurs précédents-----',clOrange);
|
||||
// si le signal peut afficher un carré et les aiguillages après le signal sont mal positionnées ou que pas présence train avant signal et signal
|
||||
// verrouillable au carré, afficher un carré
|
||||
@@ -5907,6 +6013,7 @@ begin
|
||||
procedure calcul_zones;
|
||||
var AdrFeu,AdrDetFeu,Nbre,Nouveau_Det,i,resultat,det1,det2,det3,AdrSuiv,TypeSuiv,AdrPrec : integer ;
|
||||
creer_tableau : boolean;
|
||||
s : string;
|
||||
begin
|
||||
creer_tableau:=false;
|
||||
det3:=event_det[N_event_det]; // c'est le nouveau détecteur
|
||||
@@ -5980,7 +6087,7 @@ begin
|
||||
// traiter pour les cas avec 1 élément
|
||||
for i:=1 to N_trains do
|
||||
begin
|
||||
Nbre:=event_det_train[i].NbEl ; // Nombre d'éléments du tableau courant exploré
|
||||
Nbre:=event_det_train[i].NbEl ; // Nombre d'éléments du tableau courant exploré
|
||||
if Nbre=1 then
|
||||
begin
|
||||
if traceListe then AfficheDebug('traitement Train n°'+intToSTR(i)+' 1 détecteur',clyellow);
|
||||
@@ -7011,7 +7118,7 @@ begin
|
||||
|
||||
// créée la fenetre debug
|
||||
FormDebug:=TFormDebug.Create(Self);
|
||||
FormDebug.Caption:=AF+' debug';
|
||||
FormDebug.Caption:=AF+' debug';
|
||||
N_Trains:=0;
|
||||
NivDebug:=0;
|
||||
TempoAct:=0;
|
||||
@@ -7833,11 +7940,11 @@ begin
|
||||
ss:=copy(recuCDM,i+3,10);
|
||||
val(ss,y2,erreur);
|
||||
//Affiche('Y2='+IntTostr(y2),clyellow);
|
||||
Delete(recuCDM,i,l-i+1);
|
||||
Delete(recuCDM,i,l-i+1);
|
||||
|
||||
Delete(recuCDM,posXY,12);
|
||||
end;
|
||||
|
||||
|
||||
inc(k);
|
||||
sort:=(k>100) or (posST=0) and (posDT=0) and (posAC=0) and (posSG=0);
|
||||
until (sort);
|
||||
@@ -7878,8 +7985,8 @@ end;
|
||||
CDM_connecte:=False;
|
||||
SocketCDM_connecte:=false;
|
||||
MenuConnecterUSB.enabled:=true;
|
||||
DeConnecterUSB.enabled:=true;
|
||||
ConnecterCDMRail.enabled:=true;
|
||||
DeConnecterUSB.enabled:=true;
|
||||
ConnecterCDMRail.enabled:=true;
|
||||
end;
|
||||
|
||||
|
||||
@@ -7901,6 +8008,23 @@ begin
|
||||
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
|
||||
s:=s+' Cible unisemaf='+intToSTR(feux[i].Unisemaf);
|
||||
|
||||
// conditions sur carré
|
||||
CondCarre:=Length(feux[i].condcarre[1]);
|
||||
l:=1;
|
||||
s2:='';
|
||||
while condCarre<>0 do
|
||||
begin
|
||||
if condcarre<>0 then dec(condcarre);
|
||||
for k:=1 to condCarre do
|
||||
begin
|
||||
s2:=s2+'A'+IntToSTR(feux[i].condcarre[l][k].Adresse)+feux[i].condcarre[l][k].PosAig+' ';
|
||||
end;
|
||||
s2:=s2+'/';
|
||||
inc(l);
|
||||
@@ -7918,6 +8042,7 @@ begin
|
||||
s:=s+'(';
|
||||
for k:=1 to Length(feux[i].AigDirection[j])-1 do
|
||||
begin
|
||||
s:=s+IntToSTR(feux[i].AigDirection[j][k].adresse) + feux[i].AigDirection[j][k].posaig+' ';
|
||||
end;
|
||||
s:=s+')';
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user