diff --git a/UnitDebug.dcu b/UnitDebug.dcu index a7e77b4..c54f95c 100644 Binary files a/UnitDebug.dcu and b/UnitDebug.dcu differ diff --git a/UnitDebug.dfm b/UnitDebug.dfm index 77648df..ca05fd4 100644 --- a/UnitDebug.dfm +++ b/UnitDebug.dfm @@ -1,9 +1,9 @@ object FormDebug: TFormDebug - Left = 285 - Top = 142 + Left = 219 + Top = 67 Width = 842 Height = 784 - VertScrollBar.Position = 7 + VertScrollBar.Position = 39 Caption = 'Fen'#234'tre de d'#233'bug' Color = clWindow TransparentColorValue = clTeal @@ -22,7 +22,7 @@ object FormDebug: TFormDebug TextHeight = 13 object Label1: TLabel Left = 642 - Top = -3 + Top = -35 Width = 108 Height = 13 Anchors = [akTop, akRight] @@ -38,7 +38,7 @@ object FormDebug: TFormDebug end object Label2: TLabel Left = 474 - Top = -5 + Top = -37 Width = 131 Height = 18 Anchors = [akTop, akRight] @@ -52,7 +52,7 @@ object FormDebug: TFormDebug end object EditNivDebug: TEdit Left = 754 - Top = -5 + Top = -37 Width = 49 Height = 21 Anchors = [akTop, akRight] @@ -68,7 +68,7 @@ object FormDebug: TFormDebug end object MemoEvtDet: TMemo Left = 570 - Top = 329 + Top = 297 Width = 239 Height = 201 Anchors = [akTop, akRight] @@ -89,7 +89,7 @@ object FormDebug: TFormDebug end object ButtonEcrLog: TButton Left = 466 - Top = 321 + Top = 289 Width = 97 Height = 29 Anchors = [akTop, akRight] @@ -99,7 +99,7 @@ object FormDebug: TFormDebug end object ButtonRazTampon: TButton Left = 466 - Top = 353 + Top = 321 Width = 97 Height = 33 Anchors = [akTop, akRight] @@ -110,7 +110,7 @@ object FormDebug: TFormDebug end object ButtonCherche: TButton Left = 466 - Top = 289 + Top = 257 Width = 97 Height = 25 Anchors = [akTop, akRight] @@ -120,7 +120,7 @@ object FormDebug: TFormDebug end object ButtonAffEvtChrono: TButton Left = 466 - Top = 249 + Top = 217 Width = 97 Height = 33 Anchors = [akTop, akRight] @@ -131,7 +131,7 @@ object FormDebug: TFormDebug end object ButtonCop: TButton Left = 466 - Top = 201 + Top = 169 Width = 97 Height = 41 Anchors = [akTop, akRight] @@ -148,7 +148,7 @@ object FormDebug: TFormDebug end object RichEdit: TRichEdit Left = 570 - Top = 169 + Top = 137 Width = 239 Height = 153 Anchors = [akTop, akRight] @@ -167,7 +167,7 @@ object FormDebug: TFormDebug end object ButtonRazLog: TButton Left = 466 - Top = 393 + Top = 361 Width = 97 Height = 33 Anchors = [akTop, akRight] @@ -178,9 +178,9 @@ object FormDebug: TFormDebug end object GroupBox1: TGroupBox Left = 464 - Top = 601 + Top = 569 Width = 345 - Height = 145 + Height = 177 Anchors = [akTop, akRight] Caption = 'Fonctions primitives' Color = cl3DLight @@ -273,8 +273,8 @@ object FormDebug: TFormDebug Left = 8 Top = 88 Width = 329 - Height = 49 - Caption = 'D'#233'tecteur suivant' + Height = 81 + Caption = 'D'#233'tecteur/'#233'l'#233'ment suivant' TabOrder = 1 object ButtonDetSuiv: TButton Left = 16 @@ -282,8 +282,8 @@ object FormDebug: TFormDebug Width = 185 Height = 25 Hint = - 'Renvoie l'#39#233'l'#233'ment suivant aux deux '#233'l'#233'ments (d'#233'tecteurs ou aigui' + - 'llages) ' + 'Renvoie le d'#233'tecteur suivant aux deux '#233'l'#233'ments (d'#233'tecteurs ou ai' + + 'guillages) ' Caption = 'D'#233'tecteur suivant aux '#233'l'#233'ments' ParentShowHint = False ShowHint = True @@ -292,7 +292,7 @@ object FormDebug: TFormDebug end object EditPrec: TEdit Left = 208 - Top = 18 + Top = 34 Width = 49 Height = 21 Hint = 'Element pr'#233'c'#233'dent' @@ -302,7 +302,7 @@ object FormDebug: TFormDebug end object EditActuel: TEdit Left = 264 - Top = 18 + Top = 34 Width = 49 Height = 21 Hint = 'Element actuel' @@ -310,11 +310,23 @@ object FormDebug: TFormDebug ShowHint = True TabOrder = 2 end + object ButtonElSuiv: TButton + Left = 16 + Top = 48 + Width = 185 + Height = 25 + Hint = + 'Renvoie l'#39#233'l'#233'ment suivant aux deux '#233'l'#233'ments (d'#233'tecteurs ou aigui' + + 'llages) ' + Caption = 'Element suivant aux '#233'l'#233'ments' + TabOrder = 3 + OnClick = ButtonElSuivClick + end end end object GroupBox2: TGroupBox Left = 464 - Top = 13 + Top = -19 Width = 345 Height = 149 Anchors = [akTop, akRight] @@ -486,7 +498,7 @@ object FormDebug: TFormDebug end object RichDebug: TRichEdit Left = 8 - Top = 1 + Top = -31 Width = 457 Height = 743 Anchors = [akLeft, akTop, akRight, akBottom] @@ -500,7 +512,7 @@ object FormDebug: TFormDebug end object GroupBox5: TGroupBox Left = 464 - Top = 537 + Top = 505 Width = 345 Height = 57 Anchors = [akTop, akRight] @@ -567,7 +579,7 @@ object FormDebug: TFormDebug end object ButtonRazTout: TButton Left = 467 - Top = 169 + Top = 137 Width = 97 Height = 25 Anchors = [akTop, akRight] diff --git a/UnitDebug.pas b/UnitDebug.pas index fb63157..aaf8fbd 100644 --- a/UnitDebug.pas +++ b/UnitDebug.pas @@ -55,6 +55,7 @@ type ButtonSimuAct0: TButton; ButtonSimuAct1: TButton; CheckDebugTrames: TCheckBox; + ButtonElSuiv: TButton; procedure FormCreate(Sender: TObject); procedure ButtonEcrLogClick(Sender: TObject); procedure EditNivDebugKeyPress(Sender: TObject; var Key: Char); @@ -88,6 +89,7 @@ type procedure ButtonSimuAct1Click(Sender: TObject); procedure ButtonSimuAct0Click(Sender: TObject); procedure CheckDebugTramesClick(Sender: TObject); + procedure ButtonElSuivClick(Sender: TObject); private { Déclarations privées } public @@ -499,4 +501,37 @@ begin debugtrames:=checkDebugTrames.checked; end; +procedure TFormDebug.ButtonElSuivClick(Sender: TObject); +var Adr,Prec,Actuel,erreur,ancdebug : integer ; + type1,type2 : tequipement; + s1,s2,s : string; +begin + ancdebug:=NivDebug; + NivDebug:=3; + s1:=EditPrec.Text; + s2:=EditActuel.Text; + if (s1='') or (s2='') then exit; + if s1[1]='A' then begin type1:=aig;delete(s1,1,1);end else type1:=det; + if s2[1]='A' then begin type2:=aig;delete(s2,1,1);end else type2:=det; + Val(s1,prec,erreur); if erreur<>0 then exit; + Val(s2,Actuel,erreur); if erreur<>0 then exit; + Adr:=suivant_Alg3(prec,type1,actuel,type2,1); + if Adr<9996 then + begin + s:='L''élément suivant aux éléments '+IntToSTR(prec)+'/'+IntToSTR(actuel)+' est '+IntToSTR(Adr)+' '; + case typeGen of + aig : s:=s+'aiguillage'; + tjd : s:=s+'tjd'; + tjs : s:=s+'tjs'; + triple : s:=s+'triple'; + det : s:=s+'détecteur'; + buttoir : s:=s+'buttoir'; + end; + AfficheDebug(s,clYellow); + end + else AfficheDebug('Pas trouvé d''élement suvant aux éléments '+IntToSTR(prec)+'/'+IntToSTR(actuel),clyellow); + NivDebug:=AncDebug; + +end; + end. diff --git a/UnitPrinc.dcu b/UnitPrinc.dcu index d21508c..f73e602 100644 Binary files a/UnitPrinc.dcu and b/UnitPrinc.dcu differ diff --git a/UnitPrinc.pas b/UnitPrinc.pas index 82317d9..d78f15c 100644 --- a/UnitPrinc.pas +++ b/UnitPrinc.pas @@ -3,7 +3,7 @@ Unit UnitPrinc; programme signaux complexes Graphique Lenz delphi 7 + activeX Tmscomm + clientSocket ******************************************** - 8/2/2022 14h + 13/2/2022 11h00 note sur le pilotage des accessoires: raquette octet sortie + 2 = aiguillage droit = sortie 2 de l'adresse d'accessoire @@ -377,7 +377,7 @@ var Aig_supprime,Aig_sauve : TAiguillage; Fimage : Timage; - BrancheN : array[1..100,1..200] of TBranche; // + BrancheN : array[1..100,1..200] of TBranche; {$R *.dfm} @@ -409,7 +409,7 @@ function etat_signal_suivant(Adresse,rang : integer) : integer; function suivant_alg3(prec : integer;typeELprec : TEquipement;actuel : integer;typeElActuel : TEquipement;alg : integer) : integer; function detecteur_suivant_El(el1: integer;TypeDet1 : TEquipement;el2 : integer;TypeDet2 : TEquipement;alg : integer) : integer ; function test_memoire_zones(adresse : integer) : boolean; -function PresTrainPrec(AdrFeu : integer) : boolean; +function PresTrainPrec(Adresse : integer) : boolean; function cond_carre(adresse : integer) : boolean; function carre_signal(adresse : integer) : boolean; procedure Event_Detecteur(Adresse : integer;etat : boolean;train : string); @@ -665,7 +665,7 @@ begin Temp:=HtImage-ySem; YSem:=XSem;XSem:=Temp; Temp:=HtImage-yvert; Yvert:=Xvert;Xvert:=Temp; end; - + if (orientation=3) then begin //rotation 90° vers la droite des feux @@ -1743,7 +1743,7 @@ begin end; // mise à jour de l'état du signal dans le tableau Feux i:=Index_feu(adresse); - feux[i].EtatSignal:=EtatSignalCplx[adresse]; + if i<>0 then feux[i].EtatSignal:=EtatSignalCplx[adresse]; end; @@ -2732,9 +2732,9 @@ begin if ((aspect=2) and (UniSem=2)) or ((aspect=3) and (UniSem=3)) or ((aspect=4) and (UniSem=4)) or - ((aspect=5) and ((UniSem=51) or (UniSem=52))) or - ((aspect=7) and ((UniSem=71) or (UniSem=72) or (UniSem=73))) or - ((aspect=9) and ((UniSem>=90) or (UniSem<=99))) + ((aspect=5) and ((UniSem=51) or (UniSem=52))) or + ((aspect=7) and ((UniSem=71) or (UniSem=72) or (UniSem=73))) or + ((aspect=9) and ((UniSem>=90) or (UniSem<=99))) then Verif_unisemaf:=0 else Verif_Unisemaf:=2; end; @@ -2786,6 +2786,7 @@ end; // renvoie élément suivant entre deux éléments quels qu'ils soient mais contigus +// attention, si les éléments ne sont pas contigus, le résultat est erronné!!! // et en variables globales: typeGen le type de l'élément // s'ils ne sont pas contigus, on aura une erreur // alg= algorithme : @@ -2811,6 +2812,7 @@ var Adr,AdrPrec,indexBranche_prec,branche_trouve_prec,indexBranche_actuel,branc if (typeGen=tjd) then // si le précédent est une TJD/S et le suivant aussi , substituer pointe (chgt de actuel en VAR dans la déclaration de alg3) begin IndexAdr:=index_aig(Adr); + IndexActuel:=index_aig(Actuel); if ((aiguillage[IndexAdr].modele=tjd) or (aiguillage[indexAdr].modele=tjs)) and ((aiguillage[indexActuel].modele=tjd) or (aiguillage[indexActuel].modele=tjs)) then @@ -3354,9 +3356,8 @@ begin substitue; exit; end; - s:='1026 - Erreur fatale - position TJD/S '+IntToSTR(Adr)+'/'+intToSTR(AdrTJDP)+' inconnue'; - Affiche(s,clred); - AfficheDebug(s,clred); + s:='1026 - position TJD/S '+IntToSTR(Adr)+'/'+intToSTR(AdrTJDP)+' inconnue'; + AfficheDebug(s,clOrange); suivant_alg3:=9999;exit; end; @@ -3492,7 +3493,7 @@ end; // algo= type d'algorythme pour suivant_alg3 function detecteur_suivant(prec : integer;TypeElPrec : TEquipement;actuel : integer;TypeElActuel : TEquipement;algo : integer) : integer ; var actuelCalc,PrecCalc,j,AdrSuiv ,indexCalc : integer; - TypeprecCalc,TypeActuelCalc : TEquipement; + TypeprecCalc,TypeActuelCalc : TEquipement; begin if NivDebug>=2 then AfficheDebug('Proc Detecteur_suivant '+IntToSTR(prec)+','+IntToSTR(BTypeToNum(typeElPrec))+'/'+intToSTR(actuel)+','+ @@ -3606,7 +3607,7 @@ var IndexBranche_det1,IndexBranche_det2,branche_trouve_det1,branche_trouve_det2, TypePrec,TypeFonc : Tequipement; s : string; label reprise; - + begin if NivDebug>=2 then AfficheDebug('Proc Detecteur_suivant_EL '+intToSTR(el1)+','+intToSTR(BTypeToNum(Typedet1))+'/'+intToSTR(el2)+','+intToSTR(BTypeToNum(Typedet2))+'-------------------------',clLime); @@ -3647,7 +3648,7 @@ begin j:=1; // J=1 test en incrément J=2 test en décrément // étape 1 : trouver le sens de progression (en incrément ou en décrément) - + repeat //préparer les variables AdrPrec:=el1;TypePrec:=typeDet1; @@ -3694,7 +3695,7 @@ begin sortie:=((typeDet2=TypeGen) and (Adr=el2)) or (Adr=0) or (Adr>=9996) or (i=15) or (N_Det=Nb_det_dist); until sortie ; if (i=15) and (Nivdebug=3) then afficheDebug('Pas trouvé',clyellow); - if (N_det=Nb_det_dist) and (Nivdebug=3) then + if (N_det=Nb_det_dist) and (Nivdebug=3) then begin s:='Elements trop distants '+intToStr(el1)+' '+intToSTR(el2); afficheDebug(s,clorange); @@ -3765,7 +3766,7 @@ begin if i=0 then begin Affiche('Erreur 602 - feu '+IntToSTR(adresse)+' non trouvé',clred); - if NivDebug=3 then AfficheDebug('Erreur 602 - feu '+IntToSTR(adresse)+' non trouvé',clred); + if NivDebug=3 then AfficheDebug('Erreur 602 - feu '+IntToSTR(adresse)+' non trouvé',clred); cond_carre:=true; exit; end; @@ -3816,10 +3817,10 @@ begin if (NivDebug>=1) then AfficheDebug('Test si signal '+IntToSTR(adresse)+' doit afficher un carré si aiguillage avals mal positionnés',clyellow); i:=Index_feu(adresse); - if i=0 then + if i=0 then begin Affiche('Erreur 603 - feu '+IntToSTR(adresse)+' non trouvé',clred); - if NivDebug=3 then AfficheDebug('Erreur 603 - feu '+IntToSTR(adresse)+' non trouvé',clred); + if NivDebug=3 then AfficheDebug('Erreur 603 - feu '+IntToSTR(adresse)+' non trouvé',clred); carre_signal:=true; exit; end; @@ -3898,6 +3899,12 @@ begin //traceDet:=true; if NivDebug>=2 then AfficheDebug('Cherche état du signal suivant au '+IntToSTR(adresse),clyellow); i:=Index_feu(adresse); + if i=0 then + begin + if NivDebug>=2 then AfficheDebug('Feu '+IntToSTR(adresse)+' non trouvé',clyellow); + etat_signal_suivant:=0; + exit; + end; if feux[i].aspect>10 then begin s:='La demande de l''état du signal suivant depuis un feu directionnel '+IntToSTR(Adresse)+' est irrecevable'; @@ -3967,9 +3974,9 @@ begin if (TypeActuel=det) then // détecteur? begin i:=Index_feu_det(Actuel); // trouve l'index de feu affecté au détecteur "Actuel" - AdrFeu:=Feux[i].Adresse; - if adrFeu<>0 then + if i<>0 then begin + AdrFeu:=Feux[i].Adresse; if nivdebug=3 then afficheDebug('Détecteur='+IntToSTR(AdrSuiv)+' AdrFeu='+IntToSTR(AdrFeu)+' prec='+IntToSTR(prec),clyellow ); if (adrFeu=Adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant begin @@ -4014,6 +4021,11 @@ begin if NivDebug>=2 then AfficheDebug('Test si aiguille déviée après signal '+IntToSTR(Adresse),clyellow); j:=0; i:=Index_feu(adresse); + if i=0 then + begin + Affiche('Erreur 168: signal '+intToSTR(adresse)+' non trouvé',clred); + exit; + end; prec:=feux[i].Adr_det1; TypePrec:=det; actuel:=feux[i].Adr_el_suiv1; @@ -4115,13 +4127,13 @@ end; // adresse=adresse du signal function test_memoire_zones(adresse : integer) : boolean; var - AdrSuiv,prec,ife,actuel,Etat,AdrFeu,i,j,PresTrain01,PrecInitial, - N_Det : integer; + AdrSuiv,prec,ife,actuel,i,j, + dernierdet,AdrFeu,Nfeux,NFeuxMax : integer; TypePrec,TypeActuel : TEquipement; - Pres_train,sort : boolean; + Pres_train : boolean; s : string; begin - if NivDebug>=1 then AfficheDebug('Proc test_memoire_zones('+intToSTR(adresse)+') au signal suivant ',clyellow); + if NivDebug>=1 then AfficheDebug('Proc test_memoire_zones('+intToSTR(adresse)+')',clyellow); i:=Index_feu(adresse); if (i=0) then begin @@ -4130,123 +4142,114 @@ begin test_memoire_zones:=false; end; + Nfeux:=0; + NFeuxMax:=1; // nombre de feux à trouver (nombre de cantons) Pres_train:=FALSE; ife:=1; // index feu de 1 à 4 pour explorer les 4 détecteurs d'un feu repeat j:=0; - N_Det:=0; if NivDebug=3 then AfficheDebug('Boucle de test feu '+intToSTR(ife)+'/4',clOrange); if (ife=1) then begin prec:=feux[i].Adr_det1; - actuel:=feux[i].Adr_el_suiv1; + Actuel:=feux[i].Adr_el_suiv1; TypeActuel:=feux[i].Btype_suiv1; end; //détecteur sur le signal courant if (ife=2) then begin prec:=feux[i].Adr_det2; - actuel:=feux[i].Adr_el_suiv2; + Actuel:=feux[i].Adr_el_suiv2; TypeActuel:=feux[i].Btype_suiv2; end; // détecteur sur le signal courant if (ife=3) then begin prec:=feux[i].Adr_det3; - actuel:=feux[i].Adr_el_suiv3; + Actuel:=feux[i].Adr_el_suiv3; TypeActuel:=feux[i].Btype_suiv3; end; // détecteur sur le signal courant if (ife=4) then begin prec:=feux[i].Adr_det4; - actuel:=feux[i].Adr_el_suiv4; + Actuel:=feux[i].Adr_el_suiv4; TypeActuel:=feux[i].Btype_suiv4; end; // détecteur sur le signal courant TypePrec:=det; - if (prec=0) then - begin - // sortie si aucun détecteur déclaré sur le feu - test_memoire_zones:=Pres_train; - exit; - end; + dernierdet:=prec; - PrecInitial:=Prec; + // purge les aiguillages après le feu + if TypeActuel=aig then 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=det) then // si détecteur + AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,1); + if (AdrSuiv>9900) or (AdrSuiv=0) then 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); - if Typegen=det then inc(N_Det); - prec:=actuel;TypePrec:=TypeActuel; - actuel:=AdrSuiv;TypeActuel:=typeGen; - if AdrSuiv>9990 then - begin - test_memoire_zones:=false;exit; - end; - end; - - if NivDebug=3 then AfficheDebug('132 - suivant='+IntToSTR(adrsuiv)+'/'+BtypeToChaine(TypeGen),clYellow); - if actuel=0 then - begin - // si c'est un buttoir - test_memoire_zones:=false; - if NivDebug=3 then AfficheDebug('sortie car buttoir',clyellow); + test_memoire_zones:=Pres_train; exit; end; - // si le suivant est un détecteur ; contrôler mémoire de zone et comporte t-il un signal? - AdrFeu:=0; - if (TypeActuel=det) then // détecteur + prec:=actuel;TypePrec:=TypeActuel; + actuel:=AdrSuiv;TypeActuel:=typeGen; + until typeactuel=det; + + repeat + inc(j); + + if (typeactuel=det) and (dernierdet<>0) then begin - if (NivDebug>0) 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 - if Pres_Train then PresTrain01:=1 else PresTrain01:=0; - if NivDebug=3 then AfficheDebug('de '+IntToSTR(PrecInitial)+' à '+intToSTR(actuel)+'='+IntToSTR(PresTrain01),clyellow); - precInitial:=actuel; // pour préparer le suivant - - i:=index_feu_det(AdrSuiv); // renvoie l'index du signal se trouvant au détecteur "AdrSuiv": il peut y avoir 4 détecteurs par signal - AdrFeu:=feux[i].adresse; // adresse du feu - if (AdrFeu=adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant + Pres_train:=MemZone[dernierdet,actuel] or Pres_Train; + if (nivDebug=3) then begin - AdrFeu:=0;j:=10; // on ne trouve pas de suivant + if Pres_Train then AfficheDebug('Présence train de '+intToSTR(dernierdet)+' à '+intToSTR(actuel),clyellow) + else AfficheDebug('Absence train de '+intToSTR(dernierdet)+' à '+intToSTR(actuel),clyellow) 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 - s:='Trouvé feu '+IntToSTR(AdrFeu); - if (NivDebug>0) And Pres_Train then AfficheDebug(s+' et mémoire de zone à 1',clyellow); - if (NivDebug>0) And (not(Pres_Train)) then AfficheDebug(s+' et sortie proced:Mémoire de zone à 0',clyellow); - test_memoire_zones:=Pres_train;exit; + dernierdet:=actuel; - end - else + i:=index_feu_det(Actuel); // renvoie l'index du signal se trouvant au détecteur "AdrSuiv": il peut y avoir 4 détecteurs par signal + if i<>0 then + begin + AdrFeu:=feux[i].adresse; // adresse du feu + if (AdrFeu=adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant begin - if NivDebug=3 then AfficheDebug('Trouvé feu '+intToSTR(AdrFeu)+' mais dans le mauvais sens',clOrange); - AdrFeu:=0; + AdrFeu:=0;j:=10; // on ne trouve pas de suivant + test_memoire_zones:=false; + exit; + 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 + inc(Nfeux); + j:=0; + s:='Trouvé feu ('+IntToSTR(nfeux)+'/'+intToSTR(NFeuxMax)+') '+IntToSTR(AdrFeu); + if (NivDebug>0) And Pres_Train then AfficheDebug(s+' et mémoire de zone à 1',clyellow); + if (NivDebug>0) And (not(Pres_Train)) then AfficheDebug(s+' et mémoire de zone à 0',clOrange); + if nFeux=NFeuxMax then + begin + test_memoire_zones:=Pres_train; + exit; + end; + end + else + begin + if NivDebug=3 then AfficheDebug('Trouvé feu '+intToSTR(AdrFeu)+' mais dans le mauvais sens',clYellow); + AdrFeu:=0; + end; end; - end - else - begin - //if (traceDet) {sprintf(Affiche,"Trouvé détecteur %d mais sans signal\r\n",AdrSuiv,Etat);Display(Affiche); - AdrFeu:=0; end; - end - else - begin - if (NivDebug=3) then AfficheDebug('Trouvé aiguillage '+intToSTR(AdrSuiv),clyellow); end; - sort:=(j=10) or (AdrFeu<>0) or (N_Det>=Nb_det_dist); - until (sort); // on arrete jusqu'à trouver un signal ou si on va trop loin (10 itérations) + + AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,1); + if (AdrSuiv=0) or (AdrSuiv>9990) then + begin + test_memoire_zones:=Pres_train; + exit; + end; + prec:=actuel;TypePrec:=TypeActuel; + actuel:=AdrSuiv;TypeActuel:=typeGen; + + until (j=10); // on arrete si on va trop loin (10 itérations) inc(ife); until ife>=5; - if (NivDebug>0) and (Etat=0) then AfficheDebug('Pas trouvé de signal suivant au '+intToSTR(adresse),clyellow); + if (NivDebug>0) then AfficheDebug('Pas trouvé de signal suivant au '+intToSTR(adresse),clyellow); test_memoire_zones:=Pres_train; end; @@ -4306,7 +4309,7 @@ end; // 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 // Résultat: -// si >=9996 : pas de route +// si 9999 : pas de route // si 10 : ok route trouvée function test_route_valide(det1,det2,det3 : integer) : integer; var det_suiv,resultat : integer; @@ -4317,33 +4320,150 @@ begin test_route_valide:=9999; exit; - - if (det_suiv>=9996) or (det3<>det_suiv) then begin resultat:=0; NivDebug:=0;end; - // test sens inverse.... - if resultat=0 then +end; + +// présence train précédent les 3 cantons du signal (soit 4 feux avant) +function PresTrainPrec(Adresse : integer) : boolean; +var + AdrSuiv,prec,ife,actuel,i,j, + dernierdet,AdrFeu,Nfeux,NFeuxMax : integer; + TypePrec,TypeActuel : TEquipement; + Pres_train : boolean; + s : string; +begin + if NivDebug>=1 then AfficheDebug('Proc testTrainPrec('+intToSTR(adresse)+')',clyellow); + i:=Index_feu(adresse); + if (i=0) then begin - test_route_valide:=0;exit; - // si manipulation proche aiguillage - det_suiv:=detecteur_suivant_el(det3,det,det2,det,1); - if (det_suiv>=9996) or (det1<>det_suiv) then begin test_route_valide:=0; NivDebug:=0;exit;end; + Affiche('Erreur 605 - feu '+IntToSTR(adresse)+' non trouvé',clred); + AfficheDebug('Erreur 605 - feu '+IntToSTR(adresse)+' non trouvé',clred); + PresTrainPrec:=false; end; - test_route_valide:=10 ; + + Nfeux:=0; + NFeuxMax:=3; // nombre de feux à trouver (nombre de cantons) + Pres_train:=FALSE; + ife:=1; // index feu de 1 à 4 pour explorer les 4 détecteurs d'un feu + repeat + j:=0; + if NivDebug=3 then AfficheDebug('Boucle de test feu '+intToSTR(ife)+'/4',clOrange); + if (ife=1) then + begin + actuel:=feux[i].Adr_det1; + prec:=feux[i].Adr_el_suiv1; + Typeprec:=feux[i].Btype_suiv1; + end; //détecteur sur le signal courant + if (ife=2) then + begin + actuel:=feux[i].Adr_det2; + prec:=feux[i].Adr_el_suiv2; + Typeprec:=feux[i].Btype_suiv2; + end; // détecteur sur le signal courant + if (ife=3) then + begin + actuel:=feux[i].Adr_det3; + prec:=feux[i].Adr_el_suiv3; + Typeprec:=feux[i].Btype_suiv3; + end; // détecteur sur le signal courant + if (ife=4) then + begin + actuel:=feux[i].Adr_det4; + prec:=feux[i].Adr_el_suiv4; + Typeprec:=feux[i].Btype_suiv4; + end; // détecteur sur le signal courant + + TypeActuel:=det; + if actuel=0 then + begin + // sortie si aucun détecteur déclaré sur le feu + PresTrainPrec:=Pres_train; + exit; + end; + + dernierdet:=actuel; + + repeat + inc(j); + + AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,2); // 2 car arrêt sur aiguille en talon mal positionnée + if (AdrSuiv=0) or (AdrSuiv>9990) then + begin + PresTrainPrec:=Pres_train; + exit; + end; + + prec:=actuel;TypePrec:=TypeActuel; + actuel:=AdrSuiv;TypeActuel:=typeGen; + + if typeactuel=det then + begin + Pres_train:=MemZone[actuel,dernierdet] or Pres_Train; + if (nivDebug=3) then + begin + if Pres_Train then + begin + AfficheDebug('Présence train de '+intToSTR(actuel)+' à '+intToSTR(dernierdet),clyellow); + PresTrainPrec:=Pres_train; + exit; + end + else AfficheDebug('Absence train de '+intToSTR(actuel)+' à '+intToSTR(dernierdet),clyellow) + end; + dernierdet:=actuel; + + i:=index_feu_det(Actuel); // renvoie l'index du signal se trouvant au détecteur "AdrSuiv": il peut y avoir 4 détecteurs par signal + if i<>0 then + begin + AdrFeu:=feux[i].adresse; // adresse du feu + if (AdrFeu=adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant + begin + AdrFeu:=0;j:=10; // on ne trouve pas de suivant + PresTrainPrec:=false; + exit; + 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 + inc(Nfeux); + j:=0; + s:='Trouvé feu ('+IntToSTR(nfeux)+'/'+intToSTR(NFeuxMax)+') '+IntToSTR(AdrFeu); + if (NivDebug>0) And Pres_Train then AfficheDebug(s+' et mémoire de zone à 1',clyellow); + if (NivDebug>0) And (not(Pres_Train)) then AfficheDebug(s+' et mémoire de zone à 0',clOrange); + if nFeux=NFeuxMax then + begin + PresTrainPrec:=Pres_train; + exit; + end; + end + else + begin + if NivDebug=3 then AfficheDebug('Trouvé feu '+intToSTR(AdrFeu)+' mais dans le mauvais sens',clYellow); + AdrFeu:=0; + end; + end; + end; + end; + until (j=10); // on arrete jusqu'à trouver un signal ou si on va trop loin (10 itérations) + inc(ife); + until ife>=5; + if (NivDebug>0) then AfficheDebug('Pas trouvé de signal suivant au '+intToSTR(adresse),clyellow); + PresTrainPrec:=Pres_train; end; // présence train 3 détecteurs avant le feu -function PresTrainPrec(AdrFeu : integer) : boolean; +function PresTrainPrecVieux(AdrFeu : integer) : boolean; var PresTrain : boolean; j,i,Det_initial,Adr_El_Suiv,DetPrec1,DetPrec2,DetPrec3,DetPrec4 : integer; Btype_el_suivant : TEquipement; begin - If NivDebug=3 then AfficheDebug('Proc PresTrainPrec('+intToSTR(AdrFeu)+') ---------------',clOrange); + If NivDebug=3 then AfficheDebug('Proc PresTrainPrec('+intToSTR(AdrFeu)+') ---------------',clOrange); i:=index_feu(Adrfeu); - if i=0 then + if i=0 then begin Affiche('Erreur 604 - feu '+IntToSTR(adrFeu)+' non trouvé',clred); - if NivDebug=3 then AfficheDebug('Erreur 604 - feu '+IntToSTR(adrFeu)+' non trouvé',clred); - PresTrainPrec:=false; + if NivDebug=3 then AfficheDebug('Erreur 604 - feu '+IntToSTR(adrFeu)+' non trouvé',clred); + PresTrainPrecVieux:=false; exit; end; @@ -4420,7 +4540,7 @@ begin if presTrain Then afficheDebug('présence train feu '+intToSTR(AdrFeu),clorange) else AfficheDebug('Absence train feu '+intToSTR(AdrFeu),clorange); end; - PresTrainPrec:=presTrain; + PresTrainPrecVieux:=presTrain; end; @@ -4513,7 +4633,7 @@ begin PresTrain:=false; // 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[index].VerrouCarre) and (Feux[index].aspect>=4) then presTrain:=PresTrainPrec(AdrFeu); - + 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é @@ -4666,8 +4786,8 @@ function buttoir_adjacent(adr : integer) : boolean; begin trouve_element(adr,det,1); // branche_trouve IndexBranche_trouve if Branche_trouve=0 then begin buttoir_adjacent:=false;exit;end; - buttoir_adjacent:=( (BrancheN[branche_trouve,IndexBranche_trouve+1].Adresse=0) and (BrancheN[branche_trouve,IndexBranche_trouve+1].BType=buttoir) or - (BrancheN[branche_trouve,IndexBranche_trouve-1].Adresse=0) and (BrancheN[branche_trouve,IndexBranche_trouve-1].BType=buttoir) ) + buttoir_adjacent:=( (BrancheN[branche_trouve,IndexBranche_trouve+1].Adresse=0) and (BrancheN[branche_trouve,IndexBranche_trouve+1].BType=buttoir) or + (BrancheN[branche_trouve,IndexBranche_trouve-1].Adresse=0) and (BrancheN[branche_trouve,IndexBranche_trouve-1].BType=buttoir) ) end; // calcul des zones depuis le tableau des fronts descendants des évènements détecteurs @@ -5190,13 +5310,15 @@ label mise0; begin //Affiche(IntToSTR(adresse)+' '+intToSTr(octet),clYellow); - index:=index_aig(adresse); - // test si pilotage aiguillage inversé - if (acc=aigP) and (aiguillage[index].inversionCDM=1) then + if (acc=aigP) then begin - if octet=1 then octet:=2 else octet:=1; - end; + index:=index_aig(adresse); + if (aiguillage[index].inversionCDM=1) then + begin + if octet=1 then octet:=2 else octet:=1; + end; + end; // pilotage par CDM rail ----------------- if CDM_connecte then @@ -6050,19 +6172,17 @@ begin Affiche('Fin des initialisations',clyellow); LabelEtat.Caption:=' '; Affiche_memoire; - { - aiguillage[index_aig(7)].position:=const_devie; - aiguillage[index_aig(20)].position:=const_droit; - aiguillage[index_aig(21)].position:=const_droit; + { + aiguillage[index_aig(1)].position:=const_devie; + aiguillage[index_aig(3)].position:=const_droit; + aiguillage[index_aig(4)].position:=const_devie; aiguillage[index_aig(25)].position:=const_devie; aiguillage[index_aig(26)].position:=const_droit; aiguillage[index_aig(27)].position:=const_droit; aiguillage[index_aig(28)].position:=const_droit; aiguillage[index_aig(31)].position:=const_devie; - } - //i:=suivant_alg3(520,det,20,aig,1); - - + aiguillage[index_aig(9)].position:=const_droit; + } end; @@ -6421,13 +6541,14 @@ var s : string; i : word; coche : boolean; begin - Cb:=Sender as TcheckBox; + Cb:=Sender as TcheckBox; coche:=cb.Checked; // état de la checkbox - s:=Cb.Hint; + s:=Cb.Hint; val(s,adresse,erreur); // adresse du signal correspondant au checkbox cliqué if erreur=0 then begin i:=index_feu(adresse); + if i=0 then exit; etat:=feux[i].EtatSignal; affiche(IntToSTR(etat),clyellow); // si le feu est vert et que la coche est mise, substituer le blanc @@ -7386,9 +7507,10 @@ begin val(s,vit,erreur); if (erreur<>0) or (vit<0) then exit; s:=trains[combotrains.itemindex+1].nom_train; - Affiche('Commande vitesse train '+s+ ' à '+IntToSTR(vit)+'%',cllime); vitesse_loco(s,adr,vit,true); - + if s='' then s:=intToSTR(adr); + Affiche('Commande vitesse train '+s+ ' à '+IntToSTR(vit)+'%',cllime); + end; // pour déplacer l'ascenseur de l'affichage automatiquement en bas diff --git a/verif_version.dcu b/verif_version.dcu index bf1b667..bddaf62 100644 Binary files a/verif_version.dcu and b/verif_version.dcu differ diff --git a/verif_version.dfm b/verif_version.dfm index 92d5e61..a5fba23 100644 --- a/verif_version.dfm +++ b/verif_version.dfm @@ -4,7 +4,7 @@ object FormVersion: TFormVersion BorderIcons = [] BorderStyle = bsNone Caption = 'V'#233'rification de version' - ClientHeight = 215 + ClientHeight = 234 ClientWidth = 645 Color = clNavy Font.Charset = ANSI_CHARSET @@ -20,7 +20,7 @@ object FormVersion: TFormVersion Left = 8 Top = 16 Width = 625 - Height = 185 + Height = 209 Color = clNavy Font.Charset = ANSI_CHARSET Font.Color = clYellow diff --git a/verif_version.pas b/verif_version.pas index ea3384f..04aba77 100644 --- a/verif_version.pas +++ b/verif_version.pas @@ -23,7 +23,7 @@ var Lance_verif : integer; verifVersion,notificationVersion : boolean; -Const Version='3.6'; // sert à la comparaison de la version publiée +Const Version='3.62'; // sert à la comparaison de la version publiée SousVersion=' '; // en cas d'absence de sous version mettre un espace implementation @@ -220,8 +220,8 @@ begin if ncomm>0 then begin Aff('Nouveautés de la V'+version_p+SV_publie+' de Signaux_Complexes_GL :'); - Aff(' '); - for i:=1 to ncomm do aff(comm[i]); + aff(' '); + for i:=1 to ncomm-1 do aff(comm[i]); end; if MessageDlg(s+'. Voulez-vous la télécharger?',mtConfirmation,[mbYes,mbNo],0)=mrYes then begin diff --git a/versions.txt b/versions.txt index d79171d..1a58538 100644 --- a/versions.txt +++ b/versions.txt @@ -78,6 +78,8 @@ version 3.6 : Am Correction d'affichage du TCO. Correction des messages transmis de CDM. Changement des vitesses courantes des trains. +version 3.61 : Correction de la non présentation de certains signaux s'ils sont séparés par plus d'un détecteur. +version 3.62 : Correction présence trains 3 cantons avant signaux et 1 canton après signaux.