diff --git a/ConfigGenerale.cfg b/ConfigGenerale.cfg index fa9e3f4..553f03d 100644 --- a/ConfigGenerale.cfg +++ b/ConfigGenerale.cfg @@ -1,6 +1,6 @@ /****************************************** -/ fichier de configuration -/ gily - f1iwq - 2018 +/ fichier de configuration de ConfigGenerale.log +/ Gily - 2022 /****************************************** / ce programme permet de commander les signaux complexes avec ou sans / CDM rail. Il a trois modes de fonctionnement: @@ -18,7 +18,7 @@ / / / Taille de la fonte de la fenêtre -Fonte=10 +Fonte=16 / / Adresse IP V4 du PC sur lequel s'execute CDM : port IpV4_PC=127.0.0.1:9999 @@ -39,11 +39,9 @@ IPV4_INTERFACE=192.168.1.23:5550 / voir notice page 29 / PROTOCOLE_SERIE=COM3:57600,N,8,1,2 -/COM8:9600,N,8,1,0 / / Temporisation en ms d'envoi entre deux octets de la trame INTER_CAR=50 -/ / Temporisation maximale de contrôle après non réponse de l'interface, en tranches de 100ms / à adapter en fonction de l'interface. Ex 7=700ms d'attente maxi Tempo_maxi=7 @@ -55,14 +53,11 @@ Tempo_maxi=7 Entete=1 / =============================================================================== / -/ Avec (1) ou sans (0) initialisation des aiguillages au démarrage selon le tableau ci après +/ Avec (1) ou sans (0) initialisation des aiguillages au démarrage Init_Aig=1 /Temporisation entre aiguillages en ms à l'initialisation en mode autonome Tempo_Aig=100 / -/ Temporisation entre deux commandes aux décodeurs de feux en ms -Tempo_Feu=100 -/ / Fenêtre d'exécution en plein écran (1) ou réduite (0) Fenetre=0 / @@ -78,7 +73,6 @@ TCO=0 / Lancement de CDM Rail au démarrage CDM=0 / Nom du fichier LAY à ouvrir depuis CDM sans caractères spéciaux ( : / ) -/reseau_gily_signal_ajoute.lay Lay=RESEAU_GILY_SIGNAL_AJOUTE.LAY / / Démarrage du serveur d'interface automatique @@ -101,7 +95,9 @@ Serveur_interface=1 / 5=LI-100 / 6=GENLI retro=1 -RazSignaux=0 +RazSignaux=1 +Tempo_Feu=100 +Alg_Unisemaf=1 [section_aig] 1,P518,D523,S3P,V30,I0,INIT(9,5) 2,P12S,D519,S5S,V0,I0,INIT(9,5) @@ -129,7 +125,7 @@ RazSignaux=0 28TJD,D(21D,26D),S(21S,26S),V0,I0,INIT(9,5),E4 29,P10D,D513,S30S,V60,I0,INIT(9,5) 30,P524,D11D,S29D,V0,I0,INIT(9,5) -31,P534,D0,S25P,V0,I0,INIT(9,5) +31,P534,D0,S25P,V60,I0,INIT(9,5) 32,P22S,D0,S24D,V0,I0,INIT(9,5) 0 [section_branches] @@ -146,6 +142,7 @@ A22,537,A27 A22,A32,A24 A6,516,0 A31,0 +A32,0 0 [section_sig] 176,7,0,1,(520,A20),1 @@ -153,7 +150,7 @@ A31,0 204,9,0,1,(527,A7),1 218,7,0,1,(525,A17),0 232,2,1,1,(516,A6),0 -260,9,1,1,(518,A1),1 +260,9,1,1,(518,A1),0 274,3,0,1,(524,521),0 288,7,0,1,(522,A8),1 302,9,0,1,(526,A9),1 @@ -170,8 +167,9 @@ A31,0 476,9,0,1,(538,A23),1 497,9,0,4,(531,A19),1 600,7,0,0,(521,A8),1 -1000,9,0,0,(530,A26),1 -1001,9,0,0,(529,A26),1,(A21S,A6D) +1000,9,0,0,(530,A26),0 +1001,9,0,0,(529,A26),0 +1002,9,0,0,(534,A31),0 0 [section_act] 815,1,CC406526,F2,400 diff --git a/Notice d'utilisation des signaux_complexes_GL_V3.62.pdf b/Notice d'utilisation des signaux_complexes_GL_V3.7.pdf similarity index 78% rename from Notice d'utilisation des signaux_complexes_GL_V3.62.pdf rename to Notice d'utilisation des signaux_complexes_GL_V3.7.pdf index 8dff92f..0567394 100644 Binary files a/Notice d'utilisation des signaux_complexes_GL_V3.62.pdf and b/Notice d'utilisation des signaux_complexes_GL_V3.7.pdf differ diff --git a/UnitConfig.dcu b/UnitConfig.dcu index 9127467..2c54ee3 100644 Binary files a/UnitConfig.dcu and b/UnitConfig.dcu differ diff --git a/UnitConfig.dfm b/UnitConfig.dfm index b05e9d3..aceecd2 100644 --- a/UnitConfig.dfm +++ b/UnitConfig.dfm @@ -3446,13 +3446,13 @@ object FormConfig: TFormConfig end object LabelNomSon: TLabel Left = 16 - Top = 24 + Top = 40 Width = 91 Height = 13 Caption = 'Nom du fichier son:' end object SpeedButtonJoue: TSpeedButton - Left = 88 + Left = 80 Top = 64 Width = 41 Height = 33 @@ -3509,7 +3509,7 @@ object FormConfig: TFormConfig end object EditSon: TEdit Left = 16 - Top = 40 + Top = 48 Width = 177 Height = 21 TabOrder = 4 diff --git a/UnitConfig.pas b/UnitConfig.pas index 62eed74..6f3e1cc 100644 --- a/UnitConfig.pas +++ b/UnitConfig.pas @@ -359,6 +359,7 @@ Serveur_interface_ch='Serveur_interface'; fenetre_ch='Fenetre'; Tempo_aig_ch='Tempo_Aig'; Tempo_Feu_ch='Tempo_Feu'; +Algo_Unisemaf_ch='Alg_Unisemaf'; NOTIF_VERSION_ch='NOTIF_VERSION'; verif_version_ch='verif_version'; Fonte_ch='Fonte'; @@ -673,7 +674,7 @@ begin encode_aig:=s; end; -// renvoie un A si BT est un aiguillage +// renvoie un A si BT est un aiguillage (aig, tjd, tjs tri) function TypeEl_to_char(BT : TEquipement) : string; begin case BT of // 1=détecteur 2=aig ou TJD ou TJS 4=tri @@ -786,20 +787,25 @@ begin encode_sig_feux:=s; end; -// décode la ligne de signal et la stocke dans l'index du tableau feux +// décode la ligne de signal et la stocke dans l'index i du tableau feux procedure decode_ligne_feux(chaine_signal : string;i : integer); var s,chaine,sa : string; j,k,l,t,adresse,adr,erreur ,asp,bd: integer; c : char; multiple,fini : boolean; begin + if i=0 then + begin + AfficheDebug('Erreur 670 : index nul',clred); + exit; + end; s:=chaine_signal; j:=pos(',',s); if j>1 then begin // adresse de feu val(s,adresse,erreur); - if adresse=0 then begin affiche('Erreur ligne '+s,clred);exit;end; + if adresse=0 then begin affiche('Erreur 671 ligne '+s,clred);exit;end; Delete(s,1,j); feux[i].adresse:=adresse; j:=pos(',',s); @@ -814,14 +820,14 @@ begin val(sa,l,erreur); // nombre de feux du signal directionnel if l>6 then begin - Affiche('Ligne '+chaine_signal+' 6 feux maximum pour un panneau directionnel',clred); + Affiche('Erreur 672 ligne '+chaine_signal+' 6 feux maximum pour un panneau directionnel',clred); exit; end; feux[i].aspect:=l+10;Delete(s,1,j); // décodeur val(s,adr,erreur); Feux[i].decodeur:=adr; - if (adr>NbDecodeur-1) then Affiche('Ligne '+chaine_signal+' : erreur décodeur inconnu',clred); + if (adr>NbDecodeur-1) then Affiche('Erreur 673 ligne '+chaine_signal+' : erreur décodeur inconnu',clred); j:=pos(',',s);Delete(s,1,j); // liste des aiguillages k:=1; // numéro de feu directionnel @@ -830,7 +836,7 @@ begin delete(s,1,1); // supprimer ( ou le , j:=1; // Nombre de descriptions d'aiguillages dans le feu repeat - if s[1]<>'A' then begin Affiche('Erreur a la ligne '+chaine_signal,clred);exit;end; + if s[1]<>'A' then begin Affiche('Erreur 674 ligne '+chaine_signal,clred);exit;end; delete(s,1,1); val(s,adr,erreur); // adresse c:=s[erreur]; // type @@ -849,7 +855,7 @@ begin dec(k); if k<>l+1 then begin - Affiche('Ligne '+chaine_signal,clred); + Affiche('Erreur 675 ligne '+chaine_signal,clred); Affiche('Nombre incorrect de description des aiguillages: '+intToSTR(k)+' pour '+intToSTR(l)+' feux directionnels',clred); end; end @@ -859,12 +865,12 @@ begin val(sa,asp,erreur); //aspect feux[i].aspect:=asp;Delete(s,1,j); if (asp=0) or (asp=6) or (asp>9) then - Affiche('Fichier '+NomConfig+' configuration aspect ('+intToSTR(asp)+') feu incorrecte à la ligne '+chaine_signal,clRed); + Affiche('Erreur 676 Fichier '+NomConfig+' configuration aspect ('+intToSTR(asp)+') feu incorrecte à la ligne '+chaine_signal,clRed); j:=pos(',',s); if j>1 then begin Feux[i].FeuBlanc:=(copy(s,1,j-1))='1';delete(s,1,j);end; j:=pos(',',s); val(s,Feux[i].decodeur,erreur); - if (Feux[i].decodeur>NbDecodeur-1) then Affiche('Ligne '+chaine_signal+' : erreur décodeur inconnu',clred); + if (Feux[i].decodeur>NbDecodeur-1) then Affiche('Erreur 677 Ligne '+chaine_signal+' : erreur décodeur inconnu',clred); if j<>0 then delete(s,1,j); feux[i].Adr_el_suiv1:=0;feux[i].Adr_el_suiv2:=0;feux[i].Adr_el_suiv3:=0;feux[i].Adr_el_suiv4:=0; feux[i].Btype_Suiv1:=rien;feux[i].Btype_Suiv2:=rien;feux[i].Btype_Suiv3:=rien;feux[i].Btype_Suiv4:=rien; @@ -919,7 +925,7 @@ begin end; if (j>4) or (not(multiple)) then begin - Affiche('Erreur: fichier de configuration ligne erronnée : '+chaine_signal,clred); + Affiche('Erreur 678: fichier de configuration ligne erronnée : '+chaine_signal,clred); closefile(fichier); exit; end; @@ -927,7 +933,7 @@ begin k:=pos(',',s); delete(s,1,k); //Affiche('s='+s,clyellow); - if length(s)=0 then begin Affiche('Erreur: fichier de configuration ligne erronnée : '+chaine_signal,clred); closefile(fichier);exit;end; + if length(s)=0 then begin Affiche('Erreur 679: fichier de configuration ligne erronnée : '+chaine_signal,clred); closefile(fichier);exit;end; feux[i].VerrouCarre:=s[1]='1'; delete(s,1,1); @@ -938,16 +944,16 @@ begin if Feux[i].decodeur=6 then begin - if k=0 then begin Affiche('Ligne '+chaine_signal,clred);Affiche('Manque définition de la cible pour le décodeur UniSemaf',clred);end + if k=0 then begin Affiche('Erreur 680 Ligne '+chaine_signal,clred);Affiche('Manque définition de la cible pour le décodeur UniSemaf',clred);end else begin Val(s,k,erreur); Feux[i].UniSemaf:=k; erreur:=verif_UniSemaf(adresse,k); - if erreur=1 then begin Affiche('Ligne '+chaine_signal,clred);Affiche('Erreur code Unisemaf',clred);end; + if erreur=1 then begin Affiche('Erreur 681 Ligne '+chaine_signal,clred);Affiche('Erreur code Unisemaf',clred);end; if erreur=2 then begin - Affiche('Ligne '+chaine_signal,clred);Affiche('Erreur cohérence aspect signal ('+intToSTR(asp)+') et code Unisemaf ('+intToSTR(k)+')',clred); + Affiche('Erreur 682 Ligne '+chaine_signal,clred);Affiche('Erreur cohérence aspect signal ('+intToSTR(asp)+') et code Unisemaf ('+intToSTR(k)+')',clred); end; end; @@ -982,7 +988,7 @@ begin 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(feux[i].adresse)+': Manque D ou S dans les conditions de carré des aiguillages',clred); + Affiche('Erreur 683 Définition du feu '+IntToSTR(feux[i].adresse)+': Manque D ou S dans les conditions de carré des aiguillages',clred); end; k:=pos(',',sa);if k<>0 then delete(sa,1,k); @@ -1180,7 +1186,11 @@ begin // temporisation entre 2 commandes décodeurs feu writeln(fichierN,Tempo_feu_ch+'=',IntToSTR(Tempo_feu)); copie_commentaire; - + + // algorithme Unisemaf + writeln(fichierN,Algo_unisemaf_ch+'=',IntToSTR(algo_Unisemaf)); + copie_commentaire; + // aiguillages writeln(fichierN,section_aig_ch); for i:=1 to MaxAiguillage do @@ -1202,7 +1212,7 @@ begin writeln(fichierN,section_sig_ch); // feux - for i:=1 to NbreFeux do + for i:=1 to NbreFeux do begin s:=encode_sig_feux(i); // transformer le tableau feux en ligne @@ -1245,7 +1255,8 @@ var s,sa,chaine,SOrigine: string; trouve_sec_init,trouve_init_aig,trouve_lay,trouve_IPV4_INTERFACE,trouve_PROTOCOLE_SERIE,trouve_INTER_CAR, trouve_Tempo_maxi,trouve_Entete,trouve_tco,trouve_cdm,trouve_Serveur_interface,trouve_fenetre, trouve_NOTIF_VERSION,trouve_verif_version,trouve_fonte,trouve_tempo_aig,trouve_raz,trouve_section_aig, - pds,trouve_section_branche,trouve_section_sig,trouve_section_act,fichier_trouve,trouve_tempo_feu : boolean; + pds,trouve_section_branche,trouve_section_sig,trouve_section_act,fichier_trouve,trouve_tempo_feu, + trouve_algo_uni : boolean; bd,virgule,i_detect,i,erreur,aig2,detect,offset,index, adresse,j,position,temporisation,invers,indexPointe,indexDevie,indexDroit, ComptEl,Compt_IT,Num_Element,k,modele,adr,adr2,erreur2,l,t,Nligne,postriple,itl, postjd,postjs,nv,it,Num_Champ,asp,adraig : integer; @@ -1932,6 +1943,18 @@ begin if tempo_Feu=0 then Tempo_feu:=100; end; + // algo unisemaf + sa:=uppercase(Algo_unisemaf_ch)+'='; + i:=pos(sa,s); + if i<>0 then + begin + inc(nv); + trouve_Algo_Uni:=true; + delete(s,i,length(sa)); + val(s,algo_Unisemaf,erreur); + if (algo_Unisemaf<0) or (algo_Unisemaf>2) then algo_Unisemaf:=1; + end; + sa:=uppercase(verif_version_ch)+'='; i:=pos(sa,s); if i<>0 then @@ -2476,6 +2499,9 @@ begin if Valeur_entete=2 then RadioButton3.checked:=true; LabelInfo.Width:=253;LabelInfo.Height:=25; LabelResult.width:=137;LabelResult.Height:=25; + LabelNomSon.top:=16;LabelNomSon.Left:=48; + SpeedButtonJoue.Top:=64; SpeedButtonJoue.Left:=80; + EditSon.Top:=44;EditSon.Left:=16; CheckVerifVersion.Checked:=verifVersion; CheckFenEt.Checked:=Fenetre=1; @@ -3439,6 +3465,8 @@ begin if index=0 then exit; aiguillage[index].Adevie:=adr; aiguillage[index].AdevieB:=B; + RE_ColorLine(Formconfig.RichAig,index-1,ClWhite); + LabelInfo.caption:='Modification de la TJD homologe ('+IntToSTR(adr2)+')'; end; if aiguillage[index].EtatTJD=2 then begin @@ -3448,8 +3476,7 @@ begin s:=encode_aig(index); formconfig.RichAig.Lines[index-1]:=s; - RE_ColorLine(Formconfig.RichAig,index-1,ClWhite); - LabelInfo.caption:='Modification de la TJD homologe ('+IntToSTR(adr2)+')'; + end; end; end; @@ -3927,7 +3954,7 @@ var s : string; bt : Tequipement; begin if affevt then Affiche('Evt Element suivant2',clOrange); - + if FormConfig.PageControl.ActivePage=FormConfig.TabSheetSig then with Formconfig do begin @@ -4047,7 +4074,7 @@ var s : string; begin if clicliste then exit; if affevt then Affiche('Evt detecteur 4',clOrange); - + if FormConfig.PageControl.ActivePage=FormConfig.TabSheetSig then with Formconfig do begin @@ -4695,7 +4722,7 @@ begin if affevt then affiche('Evt EditCmdFerme Change',clyellow); if FormConfig.PageControl.ActivePage=FormConfig.TabSheetAct then with Formconfig do - begin + begin s:=EditCmdFerme.Text; if (s='+') or (s='-') then begin @@ -5079,7 +5106,7 @@ begin Selstart:=RichSig.GetTextLen-1; Perform(EM_SCROLLCARET,0,0); end; - + LabelInfo.caption:=''; ligneClicSig:=i-1; AncligneClicSig:=ligneClicSig; @@ -5151,7 +5178,7 @@ begin EditAdrSig.Text:=''; EditDet1.Text:='';EditDet2.Text:='';EditDet3.Text:='';EditDet4.Text:=''; EditSuiv1.Text:='';EditSuiv2.Text:='';EditSuiv3.Text:='';EditSuiv4.Text:=''; - + config_modifie:=true; RichSig.Clear; @@ -5208,8 +5235,9 @@ end; function verif_coherence : boolean; -var i,j,k,l,Indexaig,adr,adr2,detect,condcarre,nc : integer; +var i,j,k,l,Indexaig,adr,adr2,detect,condcarre,nc,index2 : integer; modAig,model,km: TEquipement; + c : char; ok : boolean; begin // vérification de la cohérence1 @@ -5247,7 +5275,7 @@ begin begin Affiche('Erreur 7: la TJD/S '+IntToStr(Indexaig)+' a des adresses de destination différentes ('+intToSTR(aiguillage[Indexaig].Ddroit)+' et '+intToSTR(aiguillage[Indexaig].Ddevie)+')',clred); ok:=false; - end; + end; // vérifier si son homologue est une tjd adr2:=aiguillage[Indexaig].Ddroit; if (aiguillage[Index_Aig(adr2)].modele<>tjd) and (aiguillage[Index_Aig(adr2)].modele<>tjs) then @@ -5315,7 +5343,7 @@ begin for Indexaig:=1 to maxaiguillage do begin adr:=aiguillage[Indexaig].Adresse; - if aiguillage[Indexaig].modele=triple then + if aiguillage[Indexaig].modele=triple then begin if aiguillage[Indexaig].AdrTriple=0 then begin @@ -5330,7 +5358,7 @@ begin affiche('Erreur 6.2: aiguillage '+intToSTR(adr)+' défini deux fois',clred); ok:=false; end; - end; + end; end; // cohérence 4 : vérifie si doublon signal @@ -5339,7 +5367,7 @@ begin adr:=feux[j].Adresse; for i:=j+1 to NbreFeux do begin - if adr=feux[i].Adresse then + if adr=feux[i].Adresse then begin affiche('Erreur 7 : signal '+intToSTR(adr)+' défini deux fois',clred); ok:=false; @@ -5385,9 +5413,9 @@ begin begin ok:=false; Affiche('Erreur 8.2: Adresse de détecteur nul sur signal '+IntToSTR(feux[j].adresse),clred); - end; + end; end; - + i:=feux[j].Adr_det2; if i<>0 then begin @@ -5409,7 +5437,7 @@ begin Affiche('Erreur 8.4: Détecteur '+intToSTR(i)+' non existant mais associé au signal '+IntToSTR(feux[j].adresse),clred); end; end; - + i:=feux[j].Adr_det4; if i<>0 then begin @@ -5463,7 +5491,7 @@ begin if ((km=aig) or (km=tjs) or (km=tjd) or (km=triple)) then begin // aiguillage - if index_aig(i)=0 then + if index_aig(i)=0 then begin ok:=false; Affiche('Erreur 9.4: aiguillage '+intToSTR(i)+' non existant mais associé au signal '+IntToSTR(feux[j].adresse),clred); @@ -5495,7 +5523,7 @@ begin end; end; end; - + // élement suivant 4 i:=feux[j].Adr_el_suiv4; km:=feux[j].Btype_suiv4; @@ -5513,14 +5541,58 @@ begin if ((km=aig) or (km=tjs) or (km=tjd) or (km=triple)) then begin // aiguillage - if index_aig(i)=0 then + if index_aig(i)=0 then begin ok:=false; Affiche('Erreur 9.10: aiguillage '+intToSTR(i)+' non existant mais associé au signal '+IntToSTR(feux[j].adresse),clred); - end; + end; end; end; end; + + // cohérence 7 + // parcoure les aiguillages pour voir si les aiguillages déclarés aux extrémités sont existants + for Indexaig:=1 to maxaiguillage do + begin + adr:=aiguillage[indexaig].Adresse; + + adr2:=aiguillage[indexaig].ADroit; + c:=aiguillage[indexaig].AdroitB; + if (c='D') or (c='S') or (c='P') then + begin + index2:=Index_aig(adr2); + if index2=0 then + begin + ok:=false; + Affiche('Erreur 10.1: aiguillage '+intToSTR(adr)+': déclaration d''un aiguillage '+IntToSTR(adr2)+' inexistant',clred); + end; + end; + + adr2:=aiguillage[indexaig].ADevie; + c:=aiguillage[indexaig].AdevieB; + if (c='D') or (c='S') or (c='P') then + begin + index2:=Index_aig(adr2); + if index2=0 then + begin + ok:=false; + Affiche('Erreur 10.2: aiguillage '+intToSTR(adr)+': déclaration d''un aiguillage '+IntToSTR(adr2)+' inexistant',clred); + end; + end; + + adr2:=aiguillage[indexaig].Apointe; + c:=aiguillage[indexaig].ApointeB; + if (c='D') or (c='S') or (c='P') then + begin + index2:=Index_aig(adr2); + if index2=0 then + begin + ok:=false; + Affiche('Erreur 10.3: aiguillage '+intToSTR(adr)+': déclaration d''un aiguillage '+IntToSTR(adr2)+' inexistant',clred); + end; + end; + end; + verif_coherence:=ok; end; @@ -5538,7 +5610,7 @@ begin aiguillage[i].EtatTJD:=4; aiguillage[i].ApointeB:='Z'; aiguillage[i].Adevie2B:='Z'; - aiguillage[i].tjsintB:='D'; + aiguillage[i].tjsintB:='D'; aiguillage[i].posInit:=const_inconnu; aiguillage[i].Temps:=5; @@ -5558,7 +5630,7 @@ begin ligneClicAig:=i-1; AncligneClicAig:=ligneClicAig; Aff_champs_aig_tablo(i); - clicliste:=false; + clicliste:=false; config_modifie:=true; Aig_sauve.Adresse:=0; end; diff --git a/UnitConfigTCO.dcu b/UnitConfigTCO.dcu index 262748b..8460aa8 100644 Binary files a/UnitConfigTCO.dcu and b/UnitConfigTCO.dcu differ diff --git a/UnitConfigTCO.pas b/UnitConfigTCO.pas index b918ec3..562c4da 100644 --- a/UnitConfigTCO.pas +++ b/UnitConfigTCO.pas @@ -196,6 +196,7 @@ begin AvecGrille:=checkDessineGrille.Checked; end; verif_config_TCO:=not(nokNbX or nokNbY or nokHt or nokLg); + NbCellulesTCO:=NbreCellX*NbreCellY; end; procedure TFormConfigTCO.ButtonOKClick(Sender: TObject); diff --git a/UnitDebug.dcu b/UnitDebug.dcu index c54f95c..0bca89d 100644 Binary files a/UnitDebug.dcu and b/UnitDebug.dcu differ diff --git a/UnitPrinc.dcu b/UnitPrinc.dcu index ca20b1d..1d608b1 100644 Binary files a/UnitPrinc.dcu and b/UnitPrinc.dcu differ diff --git a/UnitPrinc.pas b/UnitPrinc.pas index 75c6502..8e4222c 100644 --- a/UnitPrinc.pas +++ b/UnitPrinc.pas @@ -3,7 +3,7 @@ Unit UnitPrinc; programme signaux complexes Graphique Lenz delphi 7 + activeX Tmscomm + clientSocket ******************************************** - 15/2/2022 10h00 + 21/2/2022 14h00 note sur le pilotage des accessoires: raquette octet sortie + 2 = aiguillage droit = sortie 2 de l'adresse d'accessoire @@ -212,7 +212,7 @@ Etats : array[0..19] of string[30]=('Non command 'rappel 30 + jaune','rappel 30 + jaune cli','rappel 60 + jaune','rappel 60 + jaune cli'); type -Taccessoire = (aigP,feu); +Taccessoire = (aigP,feu); // aiguillage ou feu TMA = (valide,devalide); TEquipement = (rien,aig,tjd,tjs,triple,det,buttoir,voie); // voie uniquement pour le tco TBranche = record @@ -301,7 +301,7 @@ var tempsCli,NbreFeux,pasreponse,AdrDevie,fenetre,Tempo_Aig,Tempo_feu, NombreImages,signalCpx,branche_trouve,Indexbranche_trouve,Actuel,Signal_suivant, Nbre_recu_cdm,Tempo_chgt_feux,Adj1,Adj2,NbrePN,ServeurInterfaceCDM, - ServeurRetroCDM,TailleFonte,Nb_Det_Dist,Tdoubleclic : integer; + ServeurRetroCDM,TailleFonte,Nb_Det_Dist,Tdoubleclic,algo_Unisemaf : integer; Hors_tension2,traceSign,TraceZone,Ferme,parSocketLenz,ackCdm,PremierFD,doubleclic, NackCDM,MsgSim,succes,recu_cv,AffActionneur,AffAigDet,Option_demarrage,AffTiers, @@ -405,7 +405,7 @@ procedure Dessine_feu_mx(CanvasDest : Tcanvas;x,y : integer;FrX,frY : real;adres procedure Pilote_acc0_X(adresse : integer;octet : byte); procedure pilote_acc(adresse : integer;octet : byte;Acc : TAccessoire); function etat_signal_suivant(Adresse,rang : integer) : integer; -function suivant_alg3(prec : integer;typeELprec : TEquipement;actuel : integer;typeElActuel : TEquipement;alg : integer) : integer; +function suivant_alg3(prec : integer;typeELprec : TEquipement;var 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(Adresse : integer) : boolean; @@ -786,7 +786,7 @@ begin LgImage:=Formprinc.Image7feux.Picture.Bitmap.Width; HtImage:=Formprinc.Image7feux.Picture.Bitmap.Height; - + if (orientation=2) then begin //rotation 90° vers la gauche des feux @@ -1018,7 +1018,7 @@ begin cercle(ACanvas,33,13,6,clWhite); cercle(ACanvas,43,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); @@ -1134,7 +1134,7 @@ begin cercle(ACanvas,53,13,6,GrisF); cercle(ACanvas,63,13,6,GrisF); end; - if EtatSignal=5 then + if EtatSignal=5 then begin cercle(ACanvas,11,13,6,clWhite); cercle(ACanvas,22,13,6,clWhite); @@ -1579,7 +1579,7 @@ end; Function chaine_CDM_Acc(adresse,etat : integer) : string; var so,sx,s : string; begin - { exemple de commande envoyée au serveur pour un manoeuvrer accessoire + { exemple de commande envoyée au serveur pour manoeuvrer un accessoire C-C-00-0004-CMDACC-DCCAC|018|02|AD=100;STATE=1; " NAME : nom de l'aiguille " OBJ: numéro CDM-Rail de l'aiguille (index) @@ -2081,6 +2081,279 @@ begin modele:=feux[index].Unisemaf; //Affiche('Adresse='+intToSTR(Adresse)+' code='+intToSTR(code)+' combine'+intToSTR(combine),clyellow); + + // pilotage qui marche chez JEF + if algo_Unisemaf=1 then + begin + if modele=2 then // 2 feux + begin + if aspect=blanc then pilote_acc(adresse,1,feu); + if aspect=blanc_cli then pilote_acc(adresse,1,feu); + if aspect=violet then pilote_acc(adresse,2,feu); + end; + + if modele=3 then // 3 feux + begin + if aspect=vert then pilote_acc(adresse,1,feu); + if aspect=vert_cli then pilote_acc(adresse,1,feu); + + if aspect=semaphore then pilote_acc(adresse,2,feu); + if aspect=semaphore_cli then pilote_acc(adresse,2,feu); + + if aspect=jaune then pilote_acc(adresse+1,1,feu); + if aspect=jaune_cli then pilote_acc(adresse+1,1,feu); + end; + + if modele=4 then + begin + case aspect of + vert : pilote_acc(adresse,1,feu); + vert_cli : pilote_acc(adresse,1,feu); + jaune : pilote_acc(adresse,2,feu); + jaune_cli : pilote_acc(adresse,2,feu); + semaphore : pilote_acc(adresse+1,1,feu); + semaphore_cli : pilote_acc(adresse+1,1,feu); + carre : pilote_acc(adresse+1,2,feu); + end; + end; + // 51=carré + blanc + if modele=51 then + begin + case aspect of + vert : pilote_acc(adresse,1,feu); + vert_cli : pilote_acc(adresse,1,feu); + jaune : pilote_acc(adresse,2,feu); + jaune_cli : pilote_acc(adresse,2,feu); + semaphore : pilote_acc(adresse+1,1,feu); + semaphore_cli : pilote_acc(adresse+1,1,feu); + carre : pilote_acc(adresse+1,2,feu); + blanc : pilote_acc(adresse+2,1,feu); + blanc_cli : pilote_acc(adresse+2,1,feu); + end; + end; + // 52=VJR + blanc + violet + if modele=52 then + begin + case aspect of + vert : pilote_acc(adresse,1,feu); + vert_cli : pilote_acc(adresse,1,feu); + jaune : pilote_acc(adresse,2,feu); + jaune_cli : pilote_acc(adresse,2,feu); + semaphore : pilote_acc(adresse+1,1,feu); + semaphore_cli : pilote_acc(adresse+1,1,feu); + violet : pilote_acc(adresse+2,1,feu); + blanc : pilote_acc(adresse+1,2,feu); + blanc_cli : pilote_acc(adresse+1,2,feu); + end; + end; + // 71=VJR + ralentissement 30 + if modele=71 then + begin + case aspect of + vert : pilote_acc(adresse,1,feu); + vert_cli : pilote_acc(adresse,1,feu); + jaune : pilote_acc(adresse,2,feu); + jaune_cli : pilote_acc(adresse,2,feu); + semaphore : pilote_acc(adresse+1,1,feu); + semaphore_cli : pilote_acc(adresse+1,1,feu); + end; + if combine=ral_30 then pilote_acc(adresse+1,2,feu); + end; + // 72=VJR + carré + ralentissement 30 + if modele=72 then + begin + case aspect of + vert : pilote_acc(adresse,1,feu); + vert_cli : pilote_acc(adresse,1,feu); + jaune : pilote_acc(adresse,2,feu); + jaune_cli : pilote_acc(adresse,2,feu); + semaphore : pilote_acc(adresse+1,1,feu); + semaphore_cli : pilote_acc(adresse+1,1,feu); + carre : pilote_acc(adresse+1,2,feu); + end; + if combine=ral_30 then pilote_acc(adresse+2,1,feu); + end; + // 73=VJR + carré + ralentissement 60 + if modele=73 then + begin + case aspect of + vert : pilote_acc(adresse,1,feu); + vert_cli : pilote_acc(adresse,1,feu); + jaune : pilote_acc(adresse,2,feu); + jaune_cli : pilote_acc(adresse,2,feu); + semaphore : pilote_acc(adresse+1,1,feu); + semaphore_cli : pilote_acc(adresse+1,1,feu); + carre : pilote_acc(adresse+1,2,feu); + end; + if combine=ral_60 then pilote_acc(adresse+2,1,feu); + end; + // 91=VJR + carré + rappel 30 + if modele=91 then + begin + case aspect of + vert : pilote_acc(adresse,1,feu); + vert_cli : pilote_acc(adresse,1,feu); + jaune : pilote_acc(adresse,2,feu); + jaune_cli : pilote_acc(adresse,2,feu); + semaphore : pilote_acc(adresse+1,1,feu); + semaphore_cli : pilote_acc(adresse+1,1,feu); + carre : pilote_acc(adresse+1,2,feu); + end; + if combine=rappel_30 then pilote_acc(adresse+2,1,feu); + end; + + // 92=VJR + carré + rappel 60 + if modele=92 then + begin + case aspect of + vert : pilote_acc(adresse,1,feu); + vert_cli : pilote_acc(adresse,1,feu); + jaune : pilote_acc(adresse,2,feu); + jaune_cli : pilote_acc(adresse,2,feu); + semaphore : pilote_acc(adresse+1,1,feu); + semaphore_cli : pilote_acc(adresse+1,1,feu); + carre : pilote_acc(adresse+1,2,feu); + end; + if combine=rappel_60 then pilote_acc(adresse+2,1,feu); + end; + + // 93=VJR + carré + ral30 + rappel 30 + if modele=93 then + begin + if combine=16 then //pas de sig combinée + begin + if aspect=vert then pilote_acc(adresse,1,feu); + if aspect=vert_cli then pilote_acc(adresse,1,feu); + if aspect=jaune then pilote_acc(adresse,2,feu); + if aspect=jaune_cli then pilote_acc(adresse,2,feu); + if aspect=semaphore then pilote_acc(adresse+1,1,feu); + if aspect=semaphore_cli then pilote_acc(adresse+1,1,feu); + if aspect=carre then pilote_acc(adresse+1,2,feu); + end; + if combine=ral_30 then pilote_acc(adresse+2,1,feu); + if combine=rappel_30 then pilote_acc(adresse+2,2,feu); + if (aspect=jaune) and (combine=rappel_30) then pilote_acc(adresse+3,1,feu); + end; + + // 94=VJR + carré + ral60 + rappel60 + if modele=94 then + begin + if combine=16 then + begin + if aspect=vert then pilote_acc(adresse,1,feu); + if aspect=vert_cli then pilote_acc(adresse,1,feu); + if aspect=jaune then pilote_acc(adresse,2,feu); + if aspect=jaune_cli then pilote_acc(adresse,2,feu); + if aspect=semaphore then pilote_acc(adresse+1,1,feu); + if aspect=semaphore_cli then pilote_acc(adresse+1,1,feu); + if aspect=carre then pilote_acc(adresse+1,2,feu); + end; + if combine=ral_60 then pilote_acc(adresse+2,1,feu); + if combine=rappel_60 then pilote_acc(adresse+2,2,feu); + if (aspect=jaune) and (combine=rappel_60) then pilote_acc(adresse+3,1,feu); + end; + + // 95=VJR + carré + ral30 + rappel 60 + if modele=95 then + begin + if combine=16 then + begin + if aspect=vert then pilote_acc(adresse,1,feu); + if aspect=vert_cli then pilote_acc(adresse,1,feu); + if aspect=jaune then pilote_acc(adresse,2,feu); + if aspect=jaune_cli then pilote_acc(adresse,2,feu); + if aspect=semaphore then pilote_acc(adresse+1,1,feu); + if aspect=semaphore_cli then pilote_acc(adresse+1,1,feu); + if aspect=carre then pilote_acc(adresse+1,2,feu); + end; + if combine=ral_30 then pilote_acc(adresse+2,1,feu); + if combine=rappel_60 then pilote_acc(adresse+2,2,feu); + if (aspect=jaune) and (combine=rappel_60) then pilote_acc(adresse+3,1,feu); + end; + // 96=VJR + blanc + carré + ral30 + rappel30 + if modele=96 then + begin + if combine=16 then + begin + if aspect=vert then pilote_acc(adresse,1,feu); + if aspect=vert_cli then pilote_acc(adresse,1,feu); + if aspect=jaune then pilote_acc(adresse,2,feu); + if aspect=jaune_cli then pilote_acc(adresse,2,feu); + if aspect=semaphore then pilote_acc(adresse+1,1,feu); + if aspect=semaphore_cli then pilote_acc(adresse+1,1,feu); + if aspect=carre then pilote_acc(adresse+1,2,feu); + if aspect=blanc then pilote_acc(adresse+3,2,feu); + if aspect=blanc_cli then pilote_acc(adresse+3,2,feu); + end; + if combine=ral_30 then pilote_acc(adresse+2,1,feu); + if combine=rappel_30 then pilote_acc(adresse+2,2,feu); + if (aspect=jaune) and (combine=rappel_30) then pilote_acc(adresse+3,1,feu); + end; + + // 97=VJR + blanc + carré + ral30 + rappel60 + if modele=97 then + begin + if combine=16 then + begin + if aspect=vert then pilote_acc(adresse,1,feu); + if aspect=vert_cli then pilote_acc(adresse,1,feu); + if aspect=jaune then pilote_acc(adresse,2,feu); + if aspect=jaune_cli then pilote_acc(adresse,2,feu); + if aspect=semaphore then pilote_acc(adresse+1,1,feu); + if aspect=semaphore_cli then pilote_acc(adresse+1,1,feu); + if aspect=carre then pilote_acc(adresse+1,2,feu); + if aspect=blanc then pilote_acc(adresse+3,2,feu); + if aspect=blanc_cli then pilote_acc(adresse+3,2,feu); + end; + if combine=ral_30 then pilote_acc(adresse+2,1,feu); + if combine=rappel_60 then pilote_acc(adresse+2,2,feu); + if (aspect=jaune) and (combine=rappel_60) then pilote_acc(adresse+3,1,feu); + end; + + // 98=VJR + blanc + violet + ral30 + rappel30 + if modele=98 then + begin + if combine=16 then + begin + if aspect=vert then pilote_acc(adresse,1,feu); + if aspect=vert_cli then pilote_acc(adresse,1,feu); + if aspect=jaune then pilote_acc(adresse,2,feu); + if aspect=jaune_cli then pilote_acc(adresse,2,feu); + if aspect=semaphore then pilote_acc(adresse+1,1,feu); + if aspect=semaphore_cli then pilote_acc(adresse+1,1,feu); + if aspect=violet then pilote_acc(adresse+1,2,feu); + if aspect=blanc then pilote_acc(adresse+3,2,feu); + if aspect=blanc_cli then pilote_acc(adresse+3,2,feu); + end; + if (aspect=jaune) and (combine=rappel_30) then pilote_acc(adresse+3,1,feu); + if combine=ral_30 then pilote_acc(adresse+2,1,feu); + if combine=rappel_30 then pilote_acc(adresse+2,2,feu); + end; + + // 99=VJR + blanc + violet + ral30 + rappel60 + if modele=99 then + begin + if combine=16 then + begin + if aspect=vert then pilote_acc(adresse,1,feu); + if aspect=vert_cli then pilote_acc(adresse,1,feu); + if aspect=jaune then pilote_acc(adresse,2,feu); + if aspect=jaune_cli then pilote_acc(adresse,2,feu); + if aspect=semaphore then pilote_acc(adresse+1,1,feu); + if aspect=semaphore_cli then pilote_acc(adresse+1,1,feu); + if aspect=violet then pilote_acc(adresse+1,2,feu); + if aspect=blanc then pilote_acc(adresse+3,2,feu); + if aspect=blanc_cli then pilote_acc(adresse+3,2,feu); + end; + if (aspect=jaune) and (combine=rappel_60) then pilote_acc(adresse+3,1,feu); + if combine=ral_30 then pilote_acc(adresse+2,1,feu); + if combine=rappel_60 then pilote_acc(adresse+2,2,feu); + end; + end; + + // algo de la doc qui ne marche pas chez JEF + if algo_Unisemaf=2 then + begin if modele=2 then // 2 feux begin if (aspect=blanc) or (aspect=blanc_cli) then pilote_acc(adresse,1,feu); @@ -2290,6 +2563,7 @@ begin if ((aspect=jaune) or (aspect=jaune_cli)) and (combine=rappel_60) then begin pilote_acc(adresse,1,feu);pilote_acc(adresse+2,2,feu);pilote_acc(adresse+3,2,feu);end; end; + end; end; end; @@ -2732,7 +3006,8 @@ end; // 9998: arret sur aiguillage en talon mal positionnée // 9997: arrêt sur aiguillage dévié // 9996: arrêt sur position inconnue d'aiguillage -function suivant_alg3(prec : integer;typeELprec : TEquipement;actuel : integer;typeElActuel : TEquipement;alg : integer) : integer; +// la variable actuel peut etre changée en cas de TJD! +function suivant_alg3(prec : integer;typeELprec : TEquipement;var actuel : integer;typeElActuel : TEquipement;alg : integer) : integer; var Adr,AdrPrec,indexBranche_prec,branche_trouve_prec,indexBranche_actuel,branche_trouve_actuel, tjsc1,tjsc2,AdrTjdP,Adr2,N_iteration,index,NetatTJD,index2 : integer; tjscourbe1,tjscourbe2,tjdC,tjsC : boolean; @@ -2740,25 +3015,6 @@ var Adr,AdrPrec,indexBranche_prec,branche_trouve_prec,indexBranche_actuel,branc Md,BT,BtypePrec,TypeEL : TEquipement; s : string; - procedure substitue; - var IndexAdr,IndexActuel : integer; - begin - 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 - begin - if nivDebug=3 then AfficheDebug('500 - Détection Précédent=TJD/S Suivant=TJD/S',clyellow); - // subsituer la pointe - Actuel:=aiguillage[indexActuel].APointe; - end; - end; - end; - - label recommence; begin n_iteration:=0; @@ -2908,7 +3164,8 @@ begin if A='Z' then TypeEl:=det else TypeEL:=aig; //TypeEL=(1=détécteur 2=aig trouve_element(adr,TypeEl,1); // branche_trouve IndexBranche_trouve typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].Btype; - suivant_alg3:=adr;exit; + suivant_alg3:=adr; + exit; end; end else @@ -2919,28 +3176,28 @@ begin if aiguillage[index].position=const_droit then begin // si TJD (modele=2) sur le précédent, alors substituer avec la 2eme adresse de la TJD - if aiguillage[index_aig(prec)].modele=tjd then prec:=aiguillage[index_aig(prec)].DDroit; - if prec<>aiguillage[index_aig(Adr)].Adroit then - begin - if NivDebug=3 then AfficheDebug('135.1 - Aiguillage '+intToSTR(adr)+' mal positionné',clyellow); - suivant_alg3:=9998;exit; - end - else - begin - if NivDebug=3 then AfficheDebug('135.2 - Aiguillage '+intToSTR(adr)+' bien positionné',clyellow); - end; + //if aiguillage[index_aig(prec)].modele=tjd then prec:=aiguillage[index_aig(prec)].DDroit; + if prec<>aiguillage[index_aig(Adr)].Adroit then //Adroit + begin + if NivDebug=3 then AfficheDebug('135.1 - Aiguillage '+intToSTR(adr)+' mal positionné',clyellow); + suivant_alg3:=9998;exit; + end + else + begin + if NivDebug=3 then AfficheDebug('135.2 - Aiguillage '+intToSTR(adr)+' bien positionné',clyellow); + end; end else begin - if prec<>aiguillage[index].Adevie then - begin - if NivDebug=3 then AfficheDebug('135.3 Aiguillage '+intToSTR(adr)+' mal positionné',clyellow); - suivant_alg3:=9998;exit; - end - else - begin - if NivDebug=3 then AfficheDebug('135.4 Aiguillage '+intToSTR(adr)+' bien positionné',clyellow); - end; + if prec<>aiguillage[index].Adevie then // Adevie + begin + if NivDebug=3 then AfficheDebug('135.3 Aiguillage '+intToSTR(adr)+' mal positionné',clyellow); + suivant_alg3:=9998;exit; + end + else + begin + if NivDebug=3 then AfficheDebug('135.4 Aiguillage '+intToSTR(adr)+' bien positionné',clyellow); + end; end; end; @@ -2956,13 +3213,13 @@ begin A:=aiguillage[index].ApointeB; Adr:=aiguillage[index].Apointe; // Affiche('trouvé '+intToSTR(adr),clyellow); - if A='Z' then TypeEl:=det else TypeEL:=aig; //TypeEL=(1=détécteur 2=aig + if A='Z' then TypeEl:=det else TypeEL:=aig; //TypeEL=(1=détécteur 2=aig trouve_element(adr,TypeEl,1); // branche_trouve IndexBranche_trouve typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].Btype; suivant_alg3:=adr; exit; end; - if NivDebug=3 then + if NivDebug=3 then begin s:='138 - Aiguillage '+IntToSTR(adr)+' non résolu'; if aiguillage[index].position=const_inconnu then s:=s+' car position inconnue'; @@ -3015,110 +3272,111 @@ begin // rechercher le port de destination de la tjd Adr2:=0;A:='Z'; - { - if ((NetatTJD=4) or tjsC) then - begin - if (aiguillage[index].position=const_devie) and (aiguillage[index2].position=const_droit) then - begin - if nivDebug=3 then AfficheDebug('cas1',clyellow); - A:=aiguillage[index].dDroitB; - adr2:=aiguillage[index].dDroit; - end; - if (aiguillage[index].position=const_droit) and (aiguillage[index2].position=const_droit) then - begin - if nivDebug=3 then AfficheDebug('cas2',clyellow); - A:=aiguillage[index].dDroitB; - adr2:=aiguillage[index].droit; - end; - if (aiguillage[index].position=const_devie) and (aiguillage[index2].position=const_devie) then - begin - if nivDebug=3 then AfficheDebug('cas3',clyellow); - A:=aiguillage[index].DdevieB; - adr2:=aiguillage[index].Ddevie; - end; - if (aiguillage[index].position=const_droit) and (aiguillage[index2].position=const_devie) then - begin - if nivDebug=3 then AfficheDebug('cas4',clyellow); - A:=aiguillage[index].DdroitB; - adr2:=aiguillage[index].Ddroit; - end; - - if nivDebug=3 then Affichedebug('le port de destination de la tjd 4 états est '+IntToSTR(adr2)+a,clyellow); - end; + //---------------TJD 2 états if (NetatTJD=2) and tjdC then begin if aiguillage[index].position=const_droit then begin - A:=aiguillage[index].ADroitB; - adr2:=aiguillage[index].ADroit; + // d'où vient t-on de la tjd + if BtypePrec=Aig then + begin + if (aiguillage[index].Ddroit=prec) and + ( + ((aiguillage[index].DdroitB='D') and (aiguillage[index_aig(prec)].position=const_droit)) or + ((aiguillage[index].DdroitB='S') and (aiguillage[index_aig(prec)].position=const_devie)) + ) then + begin + Adr:=aiguillage[index].Adroit; //Ddroit + A:=aiguillage[index].AdroitB; + end + else + begin + if nivdebug=3 then + begin + s:='Erreur 120 : TJD 2 états '+intToSTR(Adr)+' non résolue'; + AfficheDebug(s,clred); + suivant_alg3:=9999; + exit; + end; + end; + + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig) + suivant_alg3:=adr; + if nivDebug=3 then Affichedebug('le port de destination de la tjd 2 états est '+IntToSTR(adr)+a,clyellow); + exit; + end; + + if BtypePrec=det then + begin + if aiguillage[index].Adroit=prec then + begin + Adr:=aiguillage[index].DDroit; //Ddroit + A:=aiguillage[index].DdroitB; + end; + if aiguillage[index].Adevie=prec then + begin + Adr:=aiguillage[index].Ddevie; + A:=aiguillage[index].DdevieB; + end; + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig) + suivant_alg3:=adr; + if nivDebug=3 then Affichedebug('le port de destination de la tjd 2 états est '+IntToSTR(adr)+a,clyellow); + exit; + end; end; + if aiguillage[index].position=const_devie then begin - A:=aiguillage[index].ADevieB; - adr2:=aiguillage[index].ADevie; - end; - if nivDebug=3 then Affichedebug('le port de destination de la tjd 2 états est '+IntToSTR(adr2)+a,clyellow); - end; - - // extraire l'élément connecté au port de destination de la tjd 4 états ou tjs - if tjsC or (NetatTJD=4) then - begin - if A='S' then - begin - A:=aiguillage[index_aig(adr2)].AdevieB; - adr2:=aiguillage[index_aig(adr2)].Adevie; - //Affichedebug('element connecté:'+inttostr(adr)+A,clred); - end - else - if A='D' then - begin - A:=aiguillage[index_aig(adr2)].AdroitB; - adr2:=aiguillage[index_aig(adr2)].Adroit; - end - else - begin - if aiguillage[index].position<>9 then + if BtypePrec=Aig then begin - s:='Erreur 1021 TJD '+intToSTR(adr)+' non résolue'; - affichedebug(s,clred); - Affiche(s,clred); - suivant_alg3:=9996; - exit; - end - else - begin - if NivDebug=3 then + if (aiguillage[index].Ddroit=prec) and + ( + ((aiguillage[index].DdroitB='D') and (aiguillage[index_aig(prec)].position=const_droit)) or + ((aiguillage[index].DdroitB='S') and (aiguillage[index_aig(prec)].position=const_devie)) + ) then begin - s:='1022 - Position TJD '+intToSTR(adr)+' non résolue car position inconnue'; - affichedebug(s,clOrange); + Adr:=aiguillage[index].Adevie; + A:=aiguillage[index].AdevieB; + end + else + begin + if nivdebug=3 then + begin + s:='Erreur 121 : TJD 2 états '+intToSTR(Adr)+' non résolue'; + AfficheDebug(s,clred); + suivant_alg3:=9999; + exit; + end; end; - suivant_alg3:=9996; + + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig) + suivant_alg3:=adr; + if nivDebug=3 then Affichedebug('le port de destination de la tjd 2 états est '+IntToSTR(adr)+a,clyellow); + exit; + end; + + if BtypePrec=det then + begin + if aiguillage[index].Adroit=prec then + begin + Adr:=aiguillage[index].Ddevie; + A:=aiguillage[index].DdevieB; + end; + if aiguillage[index].Adevie=prec then + begin + Adr:=aiguillage[index].Ddroit; + A:=aiguillage[index].DdroitB; + end; + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig) + suivant_alg3:=adr; + if nivDebug=3 then Affichedebug('le port de destination de la tjd 2 états est '+IntToSTR(adr)+a,clyellow); + exit; end; end; end; - if nivDebug=3 then AfficheDebug('tjd: '+s+' Suiv='+intToSTR(adr2)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig - suivant_alg3:=adr2; - exit; - } - - if (NetatTJD=2) and tjdC then - begin - if aiguillage[index].position=const_droit then - begin - A:=aiguillage[index].ADroitB; - adr2:=aiguillage[index].ADroit; - end; - if aiguillage[index].position=const_devie then - begin - A:=aiguillage[index].ADevieB; - adr2:=aiguillage[index].ADevie; - end; - if nivDebug=3 then Affichedebug('le port de destination de la tjd 2 états est '+IntToSTR(adr2)+a,clyellow); - end; - + //---------------TJD 4 états ou TJS if (NetatTJD=4) or tjsC then begin // determiner la position de la première section de la TJD (4 cas) @@ -3127,141 +3385,243 @@ begin (aiguillage[index2].position=const_droit) and tjdC) then begin // d'où vient ton sur la tjd - if aiguillage[index].Adroit=prec then + if BtypePrec=Aig then begin - A:=aiguillage[index].DdroitB; - Adr:=aiguillage[index].Ddroit; - if A='D' then - begin - Adr:=aiguillage[index_aig(AdrTjDP)].Adroit; - A:=aiguillage[index_aig(AdrTjDP)].AdroitB; - end; - if A='S' then - begin - Adr:=aiguillage[index_aig(AdrTjDP)].Adevie; - A:=aiguillage[index_aig(AdrTjDP)].AdevieB; - end; - if NivDebug=3 then AfficheDebug('cas1.1 tjd: '+s+' Adr='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig - suivant_alg3:=adr; - substitue; - exit; + if ( ((aiguillage[index].AdroitB)='S') and (aiguillage[index_aig(prec)].position=const_devie) ) or + ( ((aiguillage[index].AdroitB)='D') and (aiguillage[index_aig(prec)].position=const_droit) ) + then + begin if NivDebug=3 then AfficheDebug('TJD '+intToSTR(adr)+' bien positionnée cas 1.1',clyellow);end + else + begin + if NivDebug=3 then AfficheDebug('135.5- TJD '+intToSTR(adr)+' mal positionnée cas 1.1',clyellow); + if alg=2 then + begin + suivant_alg3:=9998;exit; + end; + end; end; - if aiguillage[index].Adevie=prec then + + if BtypePrec=det then + begin + if (aiguillage[index].Adroit)=prec then + begin + if NivDebug=3 then AfficheDebug('TJD '+intToSTR(adr)+' bien positionnée cas 1.2',clyellow);end + else + begin + if NivDebug=3 then AfficheDebug('135.6- TJD '+intToSTR(adr)+' mal positionnée cas 1.2',clyellow); + if alg=2 then + begin + suivant_alg3:=9998;exit; + end; + end; + end; + + if aiguillage[index].position=const_droit then begin - A:=aiguillage[index2].AdroitB; Adr:=aiguillage[index2].Adroit; - if NivDebug=3 then AfficheDebug('cas1.2 jamais vu tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig - suivant_alg3:=adr; - substitue; - exit; + A:=aiguillage[index2].AdroitB; + end + else + //if A='S' then + begin + Adr:=aiguillage[index2].Adevie; + A:=aiguillage[index2].AdevieB; end; - s:='Erreur 1021, TJD '+IntToSTR(Adr)+'/'+IntToSTR(AdrTjdP)+' mal positionnée'; - if nivDebug=3 then AfficheDebug(s,clred); - Affiche(s,clred); - Suivant_alg3:=9998;exit; + if NivDebug=3 then AfficheDebug('cas1.1 tjd: '+s+' Adr='+intToSTR(adr)+A,clYellow); + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + suivant_alg3:=adr; + Actuel:=aiguillage[index2].Adresse; // substitution de la TJS + if nivDebug=3 then Affichedebug('le port de destination de la tjd 4 états est '+IntToSTR(adr)+a,clyellow); + exit; end; + // cas 2 TJD if (aiguillage[index].position=const_devie) and (aiguillage[index2].position=const_droit) and tjdC then begin - if (aiguillage[index].Adevie=prec) then + // d'où vient ton sur la tjd + if BtypePrec=Aig then begin - A:=aiguillage[index2].AdevieB; //AdroitB; - Adr:=aiguillage[index2].Adevie; // Adroit; - if NivDebug=3 then AfficheDebug('cas2.1 tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig - substitue; - suivant_alg3:=adr; - exit; + if ( ((aiguillage[index].AdroitB)='S') and (aiguillage[index_aig(prec)].position=const_devie) ) or + ( ((aiguillage[index].AdroitB)='D') and (aiguillage[index_aig(prec)].position=const_droit) ) + then + begin if NivDebug=3 then AfficheDebug('TJD '+intToSTR(adr)+' bien positionnée - cas 2.1',clyellow); + if alg=3 then // on demande d'arreter si l'aiguillage pris en pointe est dévié + begin + typeGen:=rien; + AdrDevie:=Adr; + suivant_alg3:=9997;exit; + end; + end + else + begin + if NivDebug=3 then AfficheDebug('135.7- TJD '+intToSTR(adr)+' mal positionnée - cas 2.1',clyellow); + if alg=2 then + begin + suivant_alg3:=9998;exit; + end; + end; end; - if (aiguillage[index].Adroit=prec) then - begin - A:=aiguillage[index2].AdevieB; - Adr:=aiguillage[index2].Adevie; - if NivDebug=3 then AfficheDebug('cas2.2 tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig - substitue; - suivant_alg3:=adr; - exit; + if BtypePrec=det then + begin + if (aiguillage[index].Adroit)=prec then + begin + if NivDebug=3 then AfficheDebug('TJD '+intToSTR(adr)+' bien positionnée cas 2.2',clyellow); + if alg=3 then // on demande d'arreter si l'aiguillage pris en pointe est dévié + begin + typeGen:=rien; + AdrDevie:=Adr; + suivant_alg3:=9997;exit; + end; + end + else + begin + if NivDebug=3 then AfficheDebug('135.18- TJD '+intToSTR(adr)+' mal positionnée cas 2.2',clyellow); + if alg=2 then + begin + suivant_alg3:=9998;exit; + end; + end; end; - s:='Erreur 1023, TJD '+IntToSTR(Adr)+'/'+IntToSTR(AdrTjdP)+' mal positionnée'; - if nivDebug=3 then AfficheDebug(s,clred); - Affiche(s,clred); - Suivant_alg3:=9998;exit; + + if aiguillage[index].position=const_devie then + begin + Adr:=aiguillage[index2].Adevie; + A:=aiguillage[index2].AdevieB; + end + else + begin + Adr:=aiguillage[index2].Adroit; + A:=aiguillage[index2].AdroitB; + end; + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + Actuel:=aiguillage[index2].Adresse; + suivant_alg3:=adr; + if nivDebug=3 then Affichedebug('le port de destination de la tjd 4 états est '+IntToSTR(adr)+a,clyellow); + exit; end; + // cas 3 TJD if (aiguillage[index].position=const_droit) and (aiguillage[index2].position=const_devie) and tjdC then begin - // si on vient de - if (aiguillage[index].Adroit=prec) then + // d'où vient ton sur la tjd + if BtypePrec=Aig then begin - if NivDebug=3 then AfficheDebug('cas3.1 tjd: '+s,clYellow); - A:=aiguillage[index].DdroitB; - Adr:=aiguillage[index].Ddroit; - if A='D' then + if ( ((aiguillage[index].AdevieB)='S') and (aiguillage[index_aig(prec)].position=const_devie) ) or + ( ((aiguillage[index].AdevieB)='D') and (aiguillage[index_aig(prec)].position=const_droit) ) + then + begin if NivDebug=3 then AfficheDebug('TJD '+intToSTR(adr)+' bien positionnée cas 3.1',clyellow); + if alg=3 then // on demande d'arreter si l'aiguillage pris en pointe est dévié + begin + typeGen:=rien; + AdrDevie:=Adr; + suivant_alg3:=9997;exit; + end; + end + else begin - Adr:=aiguillage[index2].Adroit; - A:=aiguillage[index2].AdroitB; - end; - if A='S' then - begin - Adr:=aiguillage[index2].Adevie; - A:=aiguillage[index2].AdevieB; + if NivDebug=3 then AfficheDebug('135.7- TJD '+intToSTR(adr)+' mal positionnée cas 3.1',clyellow); + if alg=2 then + begin + suivant_alg3:=9998;exit; + end; end; + end; - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig - substitue; - suivant_alg3:=adr; - exit; - end; - // si on vient de - if (aiguillage[index].Adevie=prec) then + if BtypePrec=det then begin - A:=aiguillage[index2].AdroitB; - Adr:=aiguillage[index2].Adroit; - if NivDebug=3 then AfficheDebug('cas3.2 tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig - substitue; - suivant_alg3:=adr; - exit; + if (aiguillage[index].Adevie)=prec then + begin + if NivDebug=3 then AfficheDebug('TJD '+intToSTR(adr)+' bien positionnée cas 3.2',clyellow); + if alg=3 then // on demande d'arreter si l'aiguillage pris en pointe est dévié + begin + typeGen:=rien; + AdrDevie:=Adr; + suivant_alg3:=9997;exit; + end; + end + else + begin + if NivDebug=3 then AfficheDebug('135.8- TJD '+intToSTR(adr)+' mal positionnée cas 3.2',clyellow); + if alg=2 then + begin + suivant_alg3:=9998;exit; + end; + end; end; - s:='Erreur 1024, TJD '+IntToSTR(Adr)+'/'+IntToSTR(AdrTjdP)+' mal positionnée'; - if nivDebug=3 then AfficheDebug(s,clred); - Affiche(s,clred); - Suivant_alg3:=9998;exit; + + if aiguillage[index].position=const_devie then + begin + Adr:=aiguillage[index2].Adevie; + A:=aiguillage[index2].AdevieB; + end + //if A='S' then + else + begin + Adr:=aiguillage[index2].Adroit; + A:=aiguillage[index2].AdroitB; + end; + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + Actuel:=aiguillage[index2].Adresse; + suivant_alg3:=adr; + if nivDebug=3 then Affichedebug('le port de destination de la tjd 4 états est '+IntToSTR(adr)+a,clyellow); + exit; end; + // cas 4 tjd if (aiguillage[index].position=const_devie) and (aiguillage[index2].position=const_devie) then begin - if aiguillage[index].Adevie=prec then + // d'où vient ton sur la tjd + if BtypePrec=Aig then begin - A:=aiguillage[index2].AdevieB; - Adr:=aiguillage[index2].Adevie; - if NivDebug=3 then AfficheDebug('cas4.1 tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig - substitue; - suivant_alg3:=adr; - exit; - end; - if aiguillage[index].Adroit=prec then + if ( ((aiguillage[index].AdevieB)='S') and (aiguillage[index_aig(prec)].position=const_devie) ) or + ( ((aiguillage[index].AdevieB)='D') and (aiguillage[index_aig(prec)].position=const_droit) ) + then + begin if NivDebug=3 then AfficheDebug('TJD '+intToSTR(adr)+' bien positionnée cas 4.1',clyellow);end + else + begin + if NivDebug=3 then AfficheDebug('135.7- TJD '+intToSTR(adr)+' mal positionnée cas 4.1',clyellow); + if alg=2 then + begin + suivant_alg3:=9998;exit; + end; + end; + end; + + if BtypePrec=det then begin - A:=aiguillage[index2].AdevieB; - Adr:=aiguillage[index2].Adevie; - if NivDebug=3 then AfficheDebug('cas4.2 jamais vu tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig - substitue; - suivant_alg3:=adr; - exit; + if (aiguillage[index].Adevie)=prec then + begin + if NivDebug=3 then AfficheDebug('TJD '+intToSTR(adr)+' bien positionnée cas 4.2',clyellow);end + else + begin + if NivDebug=3 then AfficheDebug('135.8- TJD '+intToSTR(adr)+' mal positionnée cas 4.2',clyellow); + if alg=2 then + begin + suivant_alg3:=9998;exit; + end; + end; end; - s:='Erreur 1025, TJD '+IntToSTR(Adr)+'/'+IntToSTR(AdrTjdP)+' mal positionnée'; - if nivDebug=3 then AfficheDebug(s,clred); - Affiche(s,clred); - Suivant_alg3:=9998; + + if aiguillage[index].position=const_droit then + begin + Adr:=aiguillage[index2].Adroit; + A:=aiguillage[index2].AdroitB; + end + //if A='S' then + else + begin + Adr:=aiguillage[index2].Adevie; + A:=aiguillage[index2].AdevieB; + end; + if NivDebug=3 then AfficheDebug('cas4.1 tjd: '+s+' Adr='+intToSTR(adr)+A,clYellow); + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + Actuel:=aiguillage[index2].Adresse; + suivant_alg3:=adr; + if nivDebug=3 then Affichedebug('le port de destination de la tjd 4 états est '+IntToSTR(adr)+a,clyellow); exit; end; @@ -3272,9 +3632,10 @@ begin if NivDebug=3 then AfficheDebug('cas tjs en courbe1',clYellow); A:=aiguillage[index_aig(AdrTjdP)].AdevieB; Adr:=aiguillage[index_aig(AdrTjdP)].Adevie; - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig - substitue; + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + Actuel:=aiguillage[index2].Adresse; suivant_alg3:=adr; + if nivDebug=3 then Affichedebug('le port de destination de la tjd 4 états est '+IntToSTR(adr)+a,clyellow); exit; end; @@ -3285,23 +3646,16 @@ begin if NivDebug=3 then AfficheDebug('cas1 tjs en courbe 2',clYellow); A:=aiguillage[index_aig(AdrTjdP)].AdevieB; Adr:=aiguillage[index_aig(AdrTjdP)].Adevie; - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig suivant_alg3:=adr; - substitue; + Actuel:=aiguillage[index2].Adresse; + if nivDebug=3 then Affichedebug('le port de destination de la tjd 4 états est '+IntToSTR(adr)+a,clyellow); exit; end; s:='1026 - position TJD/S '+IntToSTR(Adr)+'/'+intToSTR(AdrTJDP)+' inconnue'; AfficheDebug(s,clOrange); suivant_alg3:=9999;exit; end; - - // TJD à 2 états - if (NetatTJD=2) and tjdC then - begin - Affiche('TJD 2 états',clOrange); - - end; - end; if (aiguillage[index].modele=triple) then // aiguillage triple @@ -3406,20 +3760,41 @@ begin end; // trouve l'index du feu associé au détecteur adr -function index_feu_det(adr : integer) : integer ; - var i : integer; - trouve,trouve1,trouve2,trouve3,trouve4 : boolean; +// renvoie dans voie le numéro de la voie (1 à 4) du signal sur lequel le détecteur se trouve +// attention , il peut y avoir plus d'un feu sur un detecteur (suivant le sens)! +// si 2eme feu, son indes est dans index2 +function index_feu_det(adr : integer;var voie,index2 : integer) : integer ; + var trouve,i,index1 : integer; + trouve1,trouve2,trouve3,trouve4 : boolean; begin i:=1; + trouve:=0; + index2:=0; + index1:=0; + voie:=0; repeat trouve1:=feux[i].Adr_det1=adr; trouve2:=feux[i].Adr_det2=adr; trouve3:=feux[i].Adr_det3=adr; trouve4:=feux[i].Adr_det4=adr; - trouve:=trouve1 or trouve2 or trouve3 or trouve4; - if not(trouve) then inc(i); - until (trouve) or (i>NbreFeux); - if trouve then Index_feu_det:=i else Index_feu_det:=0; + + + if trouve1 or trouve2 or trouve3 or trouve4 then + begin + inc(trouve); + if trouve=1 then index1:=i; + if trouve=2 then index2:=i; + if trouve=1 then // on ne mémorise la voie qu'a la premiere recherche + begin + if trouve1 then voie:=1; + if trouve2 then voie:=2; + if trouve3 then voie:=3; + if trouve4 then voie:=4; + end; + end; + inc(i); + until (trouve=2) or (i>NbreFeux); + Index_feu_det:=index1; end; // renvoie l'adresse du détecteur suivant des deux éléments contigus @@ -3465,17 +3840,6 @@ begin if AdrSuiv=actuel then begin AdrSuiv:=suivant_alg3(prec,TypeElPrec,actuel,TypeElActuel,1); - {if (typeGen=2) then // si le précédent est une TJD/S et le suivant aussi - begin - if ((aiguillage[index_aig(AdrSuiv].modele=2) or (aiguillage[index_aig(AdrSuiv].modele=3)) and - ((aiguillage[index_aig(actuel].modele=2) or (aiguillage[index_aig(Actuel].modele=3)) then - begin - if nivDebug=3 then AfficheDebug('501 - Détection Précédent=TJD/S Suivant=TJD/S',clyellow); - // subsituer la pointe - actuel:=aiguillage[index_aig(Actuel].APointe; - end; - end; - } end; if (NivDebug=3) and (AdrSuiv<9996) then AfficheDebug('618 : Le suivant est le '+intToSTR(AdrSuiv),clYellow); detecteur_suivant:=AdrSuiv; @@ -3724,7 +4088,7 @@ begin if nivDebug=3 then AfficheDebug('Contrôle aiguillage '+IntToSTR(AdrAig),clyellow); resultatET:=((aiguillage[index].position=const_devie) and (feux[i].condcarre[l][k].PosAig='S') or (aiguillage[index].position=const_droit) and (feux[i].condcarre[l][k].PosAig='D')) and resultatET; - end; + end; end; //if resultatET then Affiche('VRAI',clyellow) else affiche('FAUX',clred); inc(l); @@ -3744,9 +4108,10 @@ end; // renvoi vrai si les aiguillages au delà du signal sont mal positionnés function carre_signal(adresse : integer) : boolean; var - i,j,prec,AdrFeu,AdrSuiv,actuel : integer; + i,j,prec,indexFeu,AdrSuiv,index2,voie,AdrFeu : integer; TypeELPrec,TypeElActuel : TEquipement; multi, sort : boolean; + s : string; begin if (NivDebug>=1) then AfficheDebug('Test si signal '+IntToSTR(adresse)+' doit afficher un carré si aiguillage avals mal positionnés',clyellow); @@ -3758,7 +4123,7 @@ begin carre_signal:=true; exit; end; - + j:=0; prec:=feux[i].Adr_det1; TypeElPrec:=Det; @@ -3777,21 +4142,10 @@ begin repeat inc(j); AdrSuiv:=suivant_alg3(prec,typeElPrec,actuel,typeELActuel,2); - {if (typeGen=2) then // si le précédent est une TJD/S et le suivant aussi - begin - if ((aiguillage[index_aig(AdrSuiv].modele=2) or (aiguillage[index_aig(AdrSuiv].modele=3)) and - ((aiguillage[index_aig(actuel].modele=2) or (aiguillage[index_aig(actuel].modele=3)) then - begin - if nivDebug=3 then AfficheDebug('505 - Détection Précédent=TJD/S Suivant=TJD/S',clyellow); - // subsituer la pointe - actuel:=aiguillage[index_aig(actuel].APointe; - end; - end; } - if (AdrSuiv=9999) or (AdrSuiv=9996) then // élément non trouvé ou position aiguillage inconnu begin - carre_signal:=true; + carre_signal:=true; exit; end; if (AdrSuiv<>9998) then // arret sur aiguillage en talon mal positionnée @@ -3802,13 +4156,61 @@ begin TypeElActuel:=typeGen; end; // si le suivant est un détecteur comporte t-il un signal? - AdrFeu:=0; - if (AdrSuiv>500) then + indexFeu:=0; + if (prec>500) then begin - AdrFeu:=index_feu_det(AdrSuiv); // trouve l'index du feu correspondant au détecteur AdrSuiv + //indexFeu:=index_feu_det(AdrSuiv,voie,index2); // trouve l'index du feu correspondant au détecteur AdrSuiv + indexFeu:=index_feu_det(prec,voie,index2); // trouve l'index du feu correspondant au détecteur AdrSuiv + + if indexFeu<>0 then + begin + AdrFeu:=feux[indexFeu].adresse; + + if nivdebug=3 then s:='Trouvé signal '+intToSTR(AdrFeu); + if ((voie=1) and (Feux[indexFeu].Adr_el_suiv1=AdrSuiv)) or + ((voie=2) and (Feux[indexFeu].Adr_el_suiv2=AdrSuiv)) or + ((voie=3) and (Feux[indexFeu].Adr_el_suiv3=AdrSuiv)) or + ((voie=4) and (Feux[indexFeu].Adr_el_suiv4=AdrSuiv)) + then // le feu est-il dans le bon sens de progression? + begin + if nivdebug=3 then begin s:=s+' dans le bon sens';AfficheDebug(s,clYellow);end; + end + else + begin + if nivdebug=3 then + begin + s:=s+' dans le mauvais sens'; + AfficheDebug(s,clYellow); + end; + indexFeu:=0; + // 2eme feu? + if index2<>0 then + begin + // vérifier le 2eme feu + AdrFeu:=Feux[index2].Adresse; + + if (adrFeu=Adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant + begin + IndexFeu:=0;j:=10; // on ne trouve pas de suivant + end; + //AdrSuivProv:=suivant_alg3(prec,typeElPrec,actuel,typeELActuel,2); + if (Feux[index2].Adr_el_suiv1=AdrSuiv) then // le feu est-il dans le bon sens de progression? + begin + // oui + if NivDebug=3 then AfficheDebug('Sur même détecteur, trouvé feu2 suivant Adr='+IntToSTR(AdrFeu)+': ',clYellow); + indexFeu:=index2; + end + else + begin + if NivDebug=3 then AfficheDebug('Sur même détecteur, trouvé feu2 '+intToSTR(AdrFeu)+' mais dans le mauvais sens',clYellow); + IndexFeu:=0; + end; + end; + end; + end; //Affiche(IntToSTR(AdrFeu),clOrange); end; - sort:=(j=10) or (AdrFeu<>0) or (AdrSuiv=9998) or (AdrSuiv=0); // arret si aiguillage en talon ou buttoir + sort:=(j=10) or (indexFeu<>0) or (AdrSuiv=9998) or (AdrSuiv=0); // arret si aiguillage en talon ou buttoir until (sort); // si trouvé un feu ou j=10, les aiguillages sont bien positionnés // si trouvé 9998, aiguillages mal positionnés @@ -3825,7 +4227,7 @@ end; // rang=1 pour feu suivant, 2 pour feu suivant le 1, etc // Dans AdresseFeuSuivant : adresse du feu suivant (variable globale) function etat_signal_suivant(adresse,rang : integer) : integer ; -var num_feu,etat,AdrFeu,i,j,prec,AdrSuiv : integer; +var num_feu,etat,AdrFeu,i,j,prec,AdrSuiv,index2,voie : integer; aspect,combine : word; TypePrec,TypeActuel : TEquipement; s : string; @@ -3859,7 +4261,7 @@ begin j:=0; num_feu:=0; prec:=Feux[i].Adr_det1; // détecteur sur le courant - TypePrec:=det; + TypePrec:=det; if prec=0 then begin Affiche('Msg 601 - feu '+intToSTR(adresse)+' détecteur non renseigné ',clOrange); @@ -3871,7 +4273,7 @@ begin actuel:=feux[i].Adr_el_suiv1; typeActuel:=feux[i].Btype_suiv1; - if nivDebug=3 then AfficheDebug('Actuel ='+IntToSTR(actuel),clyellow); + if nivDebug=3 then AfficheDebug('Actuel ='+IntToSTR(actuel),clyellow); repeat inc(j); if nivDebug=3 then AfficheDebug('Itération '+IntToSTR(j),clyellow); @@ -3907,19 +4309,24 @@ begin AdrFeu:=0; if (TypeActuel=det) then // détecteur? begin - i:=Index_feu_det(Actuel); // trouve l'index de feu affecté au détecteur "Actuel" + i:=Index_feu_det(Actuel,voie,index2); // trouve l'index de feu affecté au détecteur "Actuel" 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 AdrFeu:=0;j:=10; // on ne trouve pas de suivant 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? + AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,1); + if nivdebug=3 then afficheDebug('Trouvé Feu='+IntToSTR(AdrFeu)+'sur det '+intToSTR(actuel)+' Suivant='+IntToSTR(AdrSuiv)+' sur voie='+IntToSTR(voie),clyellow ); + //if NivDebug=3 then AfficheDebug('Suiv='+intToSTR(AdrSuiv),clyellow); + if ((voie=1) and (Feux[i].Adr_el_suiv1=AdrSuiv)) or + ((voie=2) and (Feux[i].Adr_el_suiv2=AdrSuiv)) or + ((voie=3) and (Feux[i].Adr_el_suiv3=AdrSuiv)) or + ((voie=4) and (Feux[i].Adr_el_suiv4=AdrSuiv)) + then // le feu est-il dans le bon sens de progression? begin // oui inc(num_feu); @@ -3932,6 +4339,32 @@ begin begin if NivDebug=3 then AfficheDebug('Trouvé feu '+intToSTR(AdrFeu)+' mais dans le mauvais sens',clOrange); AdrFeu:=0; + if index2<>0 then + begin + // vérifier le 2eme feu + AdrFeu:=Feux[index2].Adresse; + + 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 + end; + if (Feux[index2].Adr_el_suiv1=AdrSuiv) then // le feu est-il dans le bon sens de progression? + begin + // oui + inc(num_feu); + Etat:=EtatSignalCplx[AdrFeu]; + code_to_aspect(Etat,aspect,combine); + Signal_suivant:=AdrFeu; + if NivDebug=3 then AfficheDebug('Sur même détecteur, trouvé feu2 suivant Adr='+IntToSTR(AdrFeu)+': '+IntToSTR(etat)+'='+EtatSign[aspect]+' '+EtatSign[combine],clorange); + + end + else + begin + if NivDebug=3 then AfficheDebug('Sur même détecteur, trouvé feu2 '+intToSTR(AdrFeu)+' mais dans le mauvais sens',clOrange); + AdrFeu:=0; + end; + end; +// AdrFeu:=0; end; end end @@ -3948,7 +4381,7 @@ end; // sinon renvoie 0 // adresse=adresse du signal function Aiguille_deviee(adresse : integer) : integer ; -var AdrFeu,i,j,prec,AdrSuiv,Actuel,index : integer; +var AdrFeu,i,j,prec,AdrSuiv,Actuel,index,index2,voie : integer; TypePrec,TypeActuel : TEquipement; s : string; begin @@ -3979,20 +4412,21 @@ begin AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,3); if NivDebug=3 then AfficheDebug('701 - Suivant signalaig='+IntToSTR(AdrSuiv),clyellow); - if ADrSuiv<>9997 then + if (AdrSuiv<>9997) and (AdrSuiv<>0) then begin + // pas trouvé aig dévié prec:=actuel;TypePrec:=TypeActuel; actuel:=AdrSuiv;TypeActuel:=typeGen; // si le suivant est un détecteur comporte t-il un signal? AdrFeu:=0; if (TypeActuel=det) then // détecteur begin - i:=Index_feu_det(AdrSuiv); // trouve l'index de feu affecté au détecteur "AdrSuiv" + i:=Index_feu_det(AdrSuiv,voie,index2); // trouve l'index de feu affecté au détecteur "AdrSuiv" AdrFeu:=Feux[i].Adresse; if NivDebug=3 then AfficheDebug('trouvé signal '+intToSTR(AdrFeu)+' associé au détecteur '+IntToSTR(AdrSuiv),clyellow); end; end; - until (j=10) or (AdrSuiv>=9996) or (AdrFeu<>0) ; + until (j=10) or (AdrSuiv>=9996) or (AdrFeu<>0) or (AdrSuiv=0) ; if (AdrSuiv=9997) then begin s:='le signal '+intToSTR(adresse)+' doit afficher un rappel car l''aiguillage '+intToSTR(AdrDevie); @@ -4058,11 +4492,12 @@ begin end; // renvoie vrai si une mémoire de zone est occupée du signal courant au signal suivant +// sort de suite si on trouve un train // adresse=adresse du signal function test_memoire_zones(adresse : integer) : boolean; var AdrSuiv,prec,ife,actuel,i,j, - dernierdet,AdrFeu,Nfeux,NFeuxMax : integer; + dernierdet,AdrFeu,Nfeux,NFeuxMax,voie,index2 : integer; TypePrec,TypeActuel : TEquipement; Pres_train : boolean; s : string; @@ -4108,9 +4543,16 @@ begin TypeActuel:=feux[i].Btype_suiv4; end; // détecteur sur le signal courant + if prec=0 then + begin + // sortie si aucun détecteur déclaré sur le feu + test_memoire_zones:=Pres_train; + exit; + end; + TypePrec:=det; dernierdet:=prec; - + // purge les aiguillages après le feu if TypeActuel=aig then repeat @@ -4135,9 +4577,22 @@ begin 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; + Pres_train:=MemZone[actuel,dernierdet] or Pres_Train; + if (nivDebug=3) then + begin + if Pres_Train then AfficheDebug('Présence train inverse de '+intToSTR(actuel)+' à '+intToSTR(dernierdet),clyellow) + else AfficheDebug('Absence train de '+intToSTR(actuel)+' à '+intToSTR(dernierdet),clyellow) + end; + // sortir de suite + if Pres_train then + begin + test_memoire_zones:=Pres_train; + exit; + 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 + i:=index_feu_det(Actuel,voie,index2); // 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 @@ -4219,7 +4674,7 @@ var i : integer; begin if index<=0 then begin - affiche('Erreur 784 index détecteur invalide',clred); + affiche('Erreur 784 index détecteur invalide',clred); AfficheDebug('Erreur 784 index détecteur invalide',clred); trouve_index_det_chrono:=0; exit; @@ -4260,7 +4715,7 @@ end; function PresTrainPrec(Adresse : integer) : boolean; var AdrSuiv,prec,ife,actuel,i,j, - dernierdet,AdrFeu,Nfeux,NFeuxMax : integer; + dernierdet,AdrFeu,Nfeux,NFeuxMax,voie,index2 : integer; TypePrec,TypeActuel : TEquipement; Pres_train : boolean; s : string; @@ -4315,7 +4770,7 @@ begin end; dernierdet:=actuel; - + repeat inc(j); @@ -4329,22 +4784,22 @@ begin prec:=actuel;TypePrec:=TypeActuel; actuel:=AdrSuiv;TypeActuel:=typeGen; - if typeactuel=det then + if typeactuel=det then begin Pres_train:=MemZone[actuel,dernierdet] or Pres_Train; if (nivDebug=3) then begin - if Pres_Train then + if Pres_Train then begin AfficheDebug('Présence train de '+intToSTR(actuel)+' à '+intToSTR(dernierdet),clyellow); PresTrainPrec:=Pres_train; exit; - end + 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 + i:=index_feu_det(Actuel,voie,index2); // 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 @@ -4363,7 +4818,7 @@ begin 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 + if nFeux=NFeuxMax then begin PresTrainPrec:=Pres_train; exit; @@ -4480,8 +4935,7 @@ end; // mise à jour de l'état d'un feu en fontion de son environnement et affiche le feu procedure Maj_Feu(Adrfeu : integer); -var Adr_det,etat,Aig,Adr_El_Suiv, - modele,index : integer ; +var Adr_det,etat,Aig,Adr_El_Suiv,modele,index,IndexAig : integer ; PresTrain,Aff_semaphore,car : boolean; code,combine : word; Btype_el_suivant : TEquipement; @@ -4573,7 +5027,7 @@ begin // verrouillable au carré, afficher un carré car:=carre_signal(AdrFeu); // conditions supplémentaires de carré en fonction des aiguillages décrits - car:=cond_carre(AdrFeu) or car; + car:=cond_carre(AdrFeu) or car; if AffSignal and car then AfficheDebug('le signal a des aiguilles en talon aval mal positionnées',clYellow); if (NivDebug>=1) and car then AfficheDebug('le signal a des aiguilles en talon aval mal positionnées',clYellow); if (Feux[index].aspect>=4) and ( (not(PresTrain) and Feux[index].VerrouCarre) or car) then Maj_Etat_Signal(AdrFeu,carre) @@ -4582,7 +5036,7 @@ begin // si on quitte le détecteur on affiche un sémaphore : attention tester le sens de circulation // pour ne pas passer au rouge un feu à contresens. // trouver la mémoire de zone MemZone[Adr_det,?] qui a déclenché le feu rouge - //if adrFeu=197 then NivDebug:=3; + //if adrFeu=1002 then NivDebug:=3; if AffSignal then AfficheDebug('test du sémaphore',clYellow); Aff_semaphore:=test_memoire_zones(AdrFeu); // test si présence train après signal //Nivdebug:=0; @@ -4597,10 +5051,11 @@ begin // si aiguille locale déviée if (aig<>0) and (feux[index].aspect>=9) then // si le signal peut afficher un rappel et aiguille déviée begin - if AffSignal then AfficheDebug('Aiguille '+intToSTR(AdrFeu)+' déviée',clYellow); + indexAig:=Index_aig(aig); + if AffSignal then AfficheDebug('Aiguille '+intToSTR(aig)+' du signal '+intToSTR(AdrFeu)+' déviée',clYellow); EtatSignalCplx[AdrFeu]:=0; - if (aiguillage[index].vitesse=30) or (aiguillage[index].vitesse=0) then Maj_Etat_Signal(AdrFeu,rappel_30); - if aiguillage[index].vitesse=60 then Maj_Etat_Signal(AdrFeu,rappel_60); + if (aiguillage[indexAig].vitesse=30) or (aiguillage[indexAig].vitesse=0) then Maj_Etat_Signal(AdrFeu,rappel_30); + if aiguillage[indexAig].vitesse=60 then Maj_Etat_Signal(AdrFeu,rappel_60); // 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)) @@ -5160,6 +5615,9 @@ begin end; end; +// note: si on pilote un aiguillage par signaux complexes vers CDM et que celui ci est inversé, +// on recoit un evt de CDM de l'aiguillage dans le mauvais sens. +// par contre si on pilote cet aiguillage dans CDM, on le recoit dans le bon sens. // évènement d'aiguillage (accessoire) // pos = const_droit=2 ou const_devie=1 procedure Event_Aig(adresse,pos : integer); @@ -5168,10 +5626,10 @@ var s: string; prov,index : integer; begin // vérifier que l'évènement accessoire vient bien d'un aiguillage et pas d'un feu qu'on pilote (et que cdm renvoie) - index:=index_aig(adresse); - if index=0 then exit; // non ce n'est pas un aiguillage, on sort + index:=index_aig(adresse); + if index=0 then exit; // non ce n'est pas un aiguillage ou alors aiguillage non déclaré, on sort - // si l'aiguillage est inversé dans CDM et qu'on est en mode autonome, inverser sa position + // si l'aiguillage est inversé dans CDM et qu'on est en mode autonome ou CDM, inverser sa position inv:=false; if (aiguillage[index].inversionCDM=1) and (portCommOuvert or parSocketLenz) then begin @@ -5238,19 +5696,20 @@ end; // acc = aig ou feu procedure pilote_acc(adresse : integer;octet : byte;Acc : TAccessoire); var groupe,temps,index : integer ; - fonction : byte; + fonction,pilotage : byte; s : string; label mise0; begin //Affiche(IntToSTR(adresse)+' '+intToSTr(octet),clYellow); + pilotage:=octet; // test si pilotage aiguillage inversé if (acc=aigP) then begin index:=index_aig(adresse); if (aiguillage[index].inversionCDM=1) then begin - if octet=1 then octet:=2 else octet:=1; + if octet=1 then pilotage:=2 else pilotage:=1; end; end; @@ -5258,29 +5717,29 @@ begin if CDM_connecte then begin //AfficheDebug(intToSTR(adresse),clred); - if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' '+intToSTR(octet),clorange); - s:=chaine_CDM_Acc(adresse,octet); + if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' '+intToSTR(pilotage),clorange); + s:=chaine_CDM_Acc(adresse,pilotage); envoi_CDM(s); if (acc=feu) and not(Raz_Acc_signaux) then exit; if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' 0',clorange); sleep(50); s:=chaine_CDM_Acc(adresse,0); envoi_CDM(s); - event_aig(adresse,octet); + event_aig(adresse,pilotage); exit; end; // pilotage par USB ou par éthernet de la centrale ------------ if (hors_tension2=false) and (portCommOuvert or parSocketLenz) then begin - if (octet=0) or (octet>2) then exit; + if (pilotage=0) or (pilotage>2) then exit; groupe:=(adresse-1) div 4; - fonction:=((adresse-1) mod 4)*2 + (octet-1); + fonction:=((adresse-1) mod 4)*2 + (pilotage-1); // pilotage à 1 s:=#$52+Char(groupe)+char(fonction or $88); // activer la sortie s:=checksum(s); - if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' '+intToSTR(octet),clorange); + if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' '+intToSTR(pilotage),clorange); envoi(s); // envoi de la trame et attente Ack // si l'accessoire est un feu et sans raz des signaux, sortir @@ -5288,13 +5747,12 @@ begin // si aiguillage, faire une temporisation //if (index_feu(adresse)=0) or (Acc=aig) then - if Acc=AigP then + if Acc=AigP then begin temps:=aiguillage[index].temps;if temps=0 then temps:=4; if portCommOuvert or parSocketLenz then tempo(temps); end; - //sleep(50); - + //sleep(50); // pilotage à 0 pour éteindre le pilotage de la bobine du relais s:=#$52+Char(groupe)+char(fonction or $80); // désactiver la sortie s:=checksum(s); @@ -5979,7 +6437,7 @@ end; // démarrage principal du programpe signaux_complexes procedure TFormPrinc.FormCreate(Sender: TObject); -var i : integer; +var i,voie : integer; s : string; begin TraceSign:=True; @@ -6011,6 +6469,7 @@ begin N_Trains:=0; NivDebug:=0; debugtrames:=false; + algo_Unisemaf:=1; AvecInit:=true; //&&&& avec initialisation des aiguillages ou pas Option_demarrage:=false; // démarrage des trains après tempo, pas encore au point @@ -6123,16 +6582,26 @@ begin Affiche('Fin des initialisations',clyellow); LabelEtat.Caption:=' '; Affiche_memoire; - { + { 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(3)].position:=const_devie; + aiguillage[index_aig(5)].position:=const_droit; + aiguillage[index_aig(7)].position:=const_droit; + aiguillage[index_aig(19)].position:=const_devie; + aiguillage[index_aig(20)].position:=const_droit; + aiguillage[index_aig(21)].position:=const_droit; aiguillage[index_aig(26)].position:=const_droit; aiguillage[index_aig(27)].position:=const_droit; - aiguillage[index_aig(28)].position:=const_droit; + aiguillage[index_aig(28)].position:=const_devie; aiguillage[index_aig(31)].position:=const_devie; + aiguillage[index_aig(25)].position:=const_droit; aiguillage[index_aig(9)].position:=const_droit; + + // index_feu_det(530,voie,i); + // Affiche(intToSTR(voie)+intToSTr(i),clred); + //Affiche(IntToSTR(aiguille_deviee(1001)),clyellow); + + //cursor:=crHandPoint; } end; @@ -6505,7 +6974,7 @@ begin etat:=feux[i].EtatSignal; affiche(IntToSTR(etat),clyellow); // si le feu est vert et que la coche est mise, substituer le blanc - if (etat=vert_F) and coche then + if (etat=vert_F) and coche then begin Maj_Etat_Signal(Adresse,blanc); Envoi_signauxCplx; @@ -7565,7 +8034,7 @@ end; procedure TFormPrinc.Button1Click(Sender: TObject); begin - Interprete_trameCDM('j'); + zone_TCO(513,515,1); end; procedure TFormPrinc.ComboTrainsChange(Sender: TObject); diff --git a/UnitSimule.dcu b/UnitSimule.dcu index 32e4184..f5bee2a 100644 Binary files a/UnitSimule.dcu and b/UnitSimule.dcu differ diff --git a/UnitTCO.dcu b/UnitTCO.dcu index afc2c84..cfb547c 100644 Binary files a/UnitTCO.dcu and b/UnitTCO.dcu differ diff --git a/UnitTCO.dfm b/UnitTCO.dfm index 2f1ada3..6e4b667 100644 --- a/UnitTCO.dfm +++ b/UnitTCO.dfm @@ -1,6 +1,6 @@ object FormTCO: TFormTCO - Left = 1395 - Top = 198 + Left = 20 + Top = 203 Width = 1139 Height = 694 VertScrollBar.Visible = False @@ -833,7 +833,7 @@ object FormTCO: TFormTCO Top = 120 Width = 161 Height = 17 - Caption = 'Pilotage aiguillage invers'#233 + Caption = 'aiguillage invers'#233 TabOrder = 10 OnClick = CheckPinvClick end diff --git a/UnitTCO.pas b/UnitTCO.pas index 91f971f..64054f0 100644 --- a/UnitTCO.pas +++ b/UnitTCO.pas @@ -303,7 +303,7 @@ var PImageTCO : Timage; PImageTemp : TImage; frXGlob,frYGlob : real; - LargeurCell,HauteurCell,NbreCellX,NbreCellY : integer ; + LargeurCell,HauteurCell,NbreCellX,NbreCellY,NbCellulesTCO : integer ; procedure calcul_reduction(Var frx,fry : real;DimDestX,DimDestY,DimOrgX,DimOrgY : integer); procedure sauve_fichier_tco; @@ -365,6 +365,7 @@ begin Val(s,NbreCellX,erreur); delete(s,1,erreur); Val(s,NbreCellY,erreur); + NbCellulesTCO:=NbreCellX*NbreCellY; // largeur et hauteur des cellules s:=lit_ligne; @@ -583,7 +584,8 @@ begin pen.color:=clAllume; jy1:=y0+(HauteurCell div 2)-round(6*frYGlob); // pos Y de la bande sup jy2:=y0+(HauteurCell div 2)+round(6*frYGlob); // pos Y de la bande inf - r:=Rect(x0+1,jy1,x0+LargeurCell-1,jy2); + if avecGrille then r:=Rect(x0+1,jy1,x0+LargeurCell-1,jy2) else + r:=Rect(x0,jy1,x0+LargeurCell,jy2) ; FillRect(r); end; end; @@ -599,6 +601,13 @@ begin end; end; + + { diagonale + x1:=x0;y1:=y0+hauteurCell-round(3*FryGlob); + x2:=x0+largeurCell-round(3*FrXGlob);y2:=y0; + x3:=x0+largeurCell;y3:=y0+round(4*FrYGlob); + x4:=x0+round(4*FrXGlob); y4:=y0+hauteurCell; + } // element 2 procedure TformTCO.dessin_AigG_PD(canvas : Tcanvas;x,y : integer; Mode,position : integer); var x0,y0,x1,y1,x2,y2,x3,y3,x4,y4,jy1,jy2 : integer; @@ -614,11 +623,13 @@ var x0,y0,x1,y1,x2,y2,x3,y3,x4,y4,jy1,jy2 : integer; procedure deviation; begin + //Canvas.Brush.Color:=clRed; x1:=x0+(largeurCell div 2); y1:=jy1+round(1*frYGlob); - x2:=x0-round(1*FrXGlob);y2:=y0+HauteurCell-round(2*FrYGlob); - x3:=x0+round(2*FrXGlob);y3:=y0+HauteurCell; - x4:=x1+round(1*FrXGlob);y4:=jy2; + x2:=x0-round(1*FrXGlob);y2:=y0+HauteurCell-round(2*FrYGlob); //1 + x3:=x0+round(2*FrXGlob);y3:=y0+HauteurCell; //2 + x4:=x1+round(1*FrXGlob);y4:=jy2; //1 canvas.Polygon([point(x1,y1),Point(x2,y2),Point(x3,y3),Point(x4,y4)]); + //Canvas.Brush.Color:=clVoies; end; begin @@ -634,12 +645,12 @@ begin r:=Rect(x0,y0,x0+LargeurCell,y0+HauteurCell); FillRect(r); - Brush.COlor:=clVoies; + Brush.Color:=clVoies; Pen.Mode:=pmCopy; // aiguillage dévié (sans inversion) - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) or - (position=9) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) or (position=9) then + if (position=const_Devie) or (position=9) then begin horz; if (mode=1) and (position=const_devie) then @@ -655,8 +666,9 @@ begin canvas.FillRect(r); // effacement du morceau - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) then + if (position=const_Devie) then begin x1:=x1;y1:=jy1; x2:=x1-6;y2:=jy2; @@ -669,8 +681,9 @@ begin end; // aiguillage droit (sans inversion) dévié (avec inversion) - if ((inverse=false) and (position=const_Droit)) or - ((inverse=true) and (position=const_Devie)) then + //if ((inverse=false) and (position=const_Droit)) or + // ((inverse=true) and (position=const_Devie)) then + if (position=const_Droit) then begin deviation; if (mode=1) and ( ((inverse=false) and (position=const_droit)) or ((inverse=true) and (position=const_devie)) ) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -727,9 +740,10 @@ begin Pen.Mode:=pmCopy; // aiguillage dévié (sans inversion) - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) or - (position=9) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) or + // (position=9) then + if (position=const_Devie) or (position=9) then begin horz; if (mode=1) and (position=const_Devie) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -738,8 +752,9 @@ begin canvas.FillRect(r); // effacement du morceau - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) then + if (position=const_Devie) then begin x1:=x4+round(2*frXGlob);y1:=jy2-round(1*frYGlob); x2:=x1+round(5*frXGlob);y2:=jy1; @@ -752,8 +767,9 @@ begin end; // aiguillage droit (sans inversion) dévié (avec inversion) - if ((inverse=false) and (position=const_Droit)) or - ((inverse=true) and (position=const_Devie)) then + //if ((inverse=false) and (position=const_Droit)) or + // ((inverse=true) and (position=const_Devie)) then + if (position=const_Droit) then begin devie; if (mode=1) and ( ((inverse=false) and (position=const_droit)) or ((inverse=true) and (position=const_devie)) ) @@ -813,9 +829,10 @@ begin Brush.color:=clVoies; // aiguillage dévié (sans inversion) - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) or - (position=9) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) or + // (position=9) then + if (position=const_Devie) or (position=9) then begin bande_horz; if (mode=1) and ( ((inverse=false) and (position=const_Devie)) or ((inverse=true) and (position=const_Droit)) ) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -824,8 +841,9 @@ begin Canvas.FillRect(r); deviation; // effacement du morceau - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) then + if (position=const_Devie) then begin x1:=x1;y1:=jy1; x2:=x1+5;y2:=jy2-1; @@ -838,8 +856,9 @@ begin end; // aiguillage droit (sans inversion) dévié (avec inversion) - if ((inverse=false) and (position=const_Droit)) or - ((inverse=true) and (position=const_Devie)) then + //if ((inverse=false) and (position=const_Droit)) or + // ((inverse=true) and (position=const_Devie)) then + if (position=const_Droit) then begin deviation; if (mode=1) and ( ((inverse=false) and (position=const_droit)) or ((inverse=true) and (position=const_devie)) ) then Brush.color:=clAllume else Brush.Color:=couleur; @@ -899,9 +918,10 @@ begin pen.color:=clVoies; // aiguillage dévié (sans inversion) - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) or - (position=9) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) or + // (position=9) then + if (position=const_Devie) or (position=9) then begin horz; if (mode=1) and ( ((inverse=false) and (position=const_Devie)) or ((inverse=true) and (position=const_Droit)) ) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -911,8 +931,9 @@ begin deviation; // efface le morceau - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) then + if (position=const_Devie) then begin x1:=x1-12;y1:=jy1; x2:=x1+5;y2:=jy2-1; @@ -925,8 +946,9 @@ begin end; // aiguillage droit (sans inversion) ou dévie (avec inversion) - if ((inverse=false) and (position=const_Droit)) or - ((inverse=true) and (position=const_Devie)) then + //if ((inverse=false) and (position=const_Droit)) or + // ((inverse=true) and (position=const_Devie)) then + if (position=const_Droit) then begin deviation; if (mode=1) and ( ((inverse=false) and (position=const_droit)) or ((inverse=true) and (position=const_devie)) ) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -1206,9 +1228,10 @@ begin pen.color:=clVoies; // aiguillage dévié (sans inversion) - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) or - (position=9) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) or + // (position=9) then + if (position=const_Devie) or (position=9) then begin diagonale; if (mode=1) and ( ((inverse=false) and (position=const_Devie)) or ((inverse=true) and (position=const_Droit)) ) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -1223,9 +1246,10 @@ begin canvas.PolyGon([point(x1,y1),point(x2,y2),point(x3,y3),point(x4,y4)]); end; - // efface le morceau - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) then + // efface le morceau + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) then + if (position=const_Devie) then begin x1:=x0+round(22*frxGlob);y1:=jy2; //+round(FrYGlob*1); x2:=x1+round(12*frxGlob);y2:=y1; @@ -1238,8 +1262,9 @@ begin end; // aiguillage droit (sans inversion) ou dévie (avec inversion) - if ((inverse=false) and (position=const_Droit)) or - ((inverse=true) and (position=const_Devie)) then + //if ((inverse=false) and (position=const_Droit)) or + // ((inverse=true) and (position=const_Devie)) then + if (position=const_Droit) then begin horz; if (mode=1) and ( ((inverse=false) and (position=const_droit)) or ((inverse=true) and (position=const_devie)) ) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -1296,9 +1321,10 @@ begin pen.color:=clVoies; // aiguillage dévié (sans inversion) ou position inconnue (9) - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) or - (position=9) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) or + // (position=9) then + if (position=const_Devie) or (position=9) then begin diagonale; if (mode=1) and ( ((inverse=false) and (position=const_Devie)) or ((inverse=true) and (position=const_Droit)) ) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -1314,8 +1340,9 @@ begin end; // efface le morceau - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) then + if (position=const_Devie) then begin // efface le morceau x1:=x0+round(12*frXGlob);y1:=jy2; @@ -1329,8 +1356,9 @@ begin end; // aiguillage droit (sans inversion) ou dévie (avec inversion) - if ((inverse=false) and (position=const_Droit)) or - ((inverse=true) and (position=const_Devie)) then + //if ((inverse=false) and (position=const_Droit)) or + // ((inverse=true) and (position=const_Devie)) then + if (position=const_droit) then begin horz; if (mode=1) and ( ((inverse=false) and (position=const_droit)) or ((inverse=true) and (position=const_devie)) ) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -1385,9 +1413,10 @@ begin pen.color:=clVoies; // aiguillage dévié (sans inversion) - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) or - (position=9) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) or + // (position=9) then + if (position=const_Devie) or (position=9) then begin diagonale; if (mode=1) and ( ((inverse=false) and (position=const_Devie)) or ((inverse=true) and (position=const_Droit)) ) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -1403,8 +1432,9 @@ begin canvas.PolyGon([point(x1,y1),point(x2,y2),point(x3,y3),point(x4,y4)]); end; // efface le morceau - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) then + if (position=const_Devie) then begin // efface le morceau x1:=x0+round(2*frXGlob);y1:=jy1-round(1*fryGlob); @@ -1418,8 +1448,9 @@ begin end; // aiguillage droit (sans inversion) ou dévie (avec inversion) - if ((inverse=false) and (position=const_Droit)) or - ((inverse=true) and (position=const_Devie)) then + //if ((inverse=false) and (position=const_Droit)) or + // ((inverse=true) and (position=const_Devie)) then + if (position=const_Droit) then begin horz; if (mode=1) and ( ((inverse=false) and (position=const_droit)) or ((inverse=true) and (position=const_devie)) ) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -1475,9 +1506,10 @@ begin pen.color:=clVoies; // aiguillage dévié (sans inversion) - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) or - (position=9) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) or + // (position=9) then + if (position=const_Devie) or (position=9) then begin diagonale; if (mode=1) and ( ((inverse=false) and (position=const_Devie)) or ((inverse=true) and (position=const_Droit)) ) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -1493,8 +1525,9 @@ begin end; // efface le morceau - if ((inverse=false) and (position=const_Devie)) or - ((inverse=true) and (position=const_Droit)) then + //if ((inverse=false) and (position=const_Devie)) or + // ((inverse=true) and (position=const_Droit)) then + if (position=const_Devie) then begin x1:=x0+round(20*frXGlob);y1:=jy1-round(1*frYGlob); x2:=x1+round(23*frxGlob);y2:=y1; @@ -1507,8 +1540,9 @@ begin end; // aiguillage droit (sans inversion) ou dévie (avec inversion) - if ((inverse=false) and (position=const_Droit)) or - ((inverse=true) and (position=const_Devie)) then + //if ((inverse=false) and (position=const_Droit)) or + // ((inverse=true) and (position=const_Devie)) then + if (position=const_Droit) then begin horz; if (mode=1) and ( ((inverse=false) and (position=const_droit)) or ((inverse=true) and (position=const_devie)) ) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; @@ -2375,7 +2409,7 @@ end; // affiche la cellule x et y en cases procedure TformTCO.affiche_cellule(x,y : integer); -var Xorg,Yorg,xt,yt,mode,adresse,Bimage,aspect,oriente,pos : integer; +var p,Xorg,Yorg,xt,yt,mode,adresse,Bimage,aspect,oriente,pos : integer; Bt : TEquipement; s : string; begin @@ -2389,8 +2423,15 @@ begin if (bImage>=2) then //????? and (btype<=15) begin if Adresse<>0 then pos:=Aiguillage[Index_Aig(adresse)].position - - else pos:=9; + else pos:=const_inconnu; + if TCO[x,y].inverse then + begin + p:=const_inconnu; + if pos=const_devie then p:=const_droit; + if pos=const_droit then p:=const_devie; + pos:=p; + end; + end; Xorg:=(x-1)*LargeurCell; Yorg:=(y-1)*HauteurCell; @@ -2423,12 +2464,11 @@ begin 20 : dessin_20(PCanvasTCO,X,Y,mode); 21 : dessin_21(PCanvasTCO,X,Y,mode); 22 : dessin_22(PCanvasTCO,X,Y,mode); - 30 : dessin_feu(PCanvasTCO,X,Y); end; PCanvasTCO.font.Size:=(LargeurCell div 10)+4 ; -// Affiche(intToSTR( (LargeurCell div 30)+6),clyellow); + //Affiche(intToSTR( (LargeurCell div 30)+6),clyellow); // affiche le texte des aiguillages if ((BImage=2) or (BImage=3) or (BImage=4) or (BImage=5) or (BImage=12) or (BImage=13) or (BImage=14) or (BImage=15) or (BImage=21) or (BImage=22)) and (adresse<>0) then @@ -2439,11 +2479,16 @@ begin Brush.Color:=fond; Font.Color:=clYellow; xt:=0;yt:=0; - if Bimage=4 then begin xt:=1;yt:=1;end; - if Bimage=5 then begin xt:=1;yt:=HauteurCell-round(20*fryGlob);end; - if Bimage=12 then begin xt:=1;yt:=HauteurCell-round(20*frYGlob);end; - if Bimage=21 then begin xt:=2;yt:=1;end; - if Bimage=22 then begin xt:=1;yt:=HauteurCell-round(15*frYGlob);end; + if Bimage=2 then begin xt:=3;yt:=1;end; + if Bimage=3 then begin xt:=3;yt:=HauteurCell-round(20*fryGlob);end; + if Bimage=4 then begin xt:=3;yt:=1;end; + if Bimage=5 then begin xt:=3;yt:=HauteurCell-round(20*fryGlob);end; + if Bimage=12 then begin xt:=3;yt:=HauteurCell-round(20*frYGlob);end; + if Bimage=13 then begin xt:=3;yt:=1;end; + if Bimage=14 then begin xt:=LargeurCell-round(25*frXGlob);yt:=1;end; + if Bimage=15 then begin xt:=3;yt:=1;end; + if Bimage=21 then begin xt:=3;yt:=1;end; + if Bimage=22 then begin xt:=3;yt:=HauteurCell-round(15*frYGlob);end; TextOut(xOrg+xt,yOrg+yt,s); //exit; end; @@ -2767,19 +2812,19 @@ begin x:=Xdet2;Xdet2:=Xdet1;Xdet1:=x; x:=Ydet2;Ydet2:=Ydet1;Ydet1:=x; x:=det2;det2:=det1;det1:=x; - end; - if yDet2det2) and memTrouve) or (i>40); - - if i>40 then + //Affiche(intToSTR(x),clLime); + if i>NbCellulesTCO then begin s:='Erreur 1000 : dépassement d''itérations TCO: '+IntToSTR(det1)+' - '+IntToSTR(det2); Affiche(s,clred); AfficheDebug(s,clred); end; @@ -2983,6 +3028,7 @@ begin PScrollBoxTCO:=FormTCO.ScrollBox; lire_fichier_tco; + NbCellulesTCO:=NbreCellX*NbreCellY; calcul_reduction(frxGlob,fryGlob,LargeurCell,HauteurCell,ZoomMax,ZoomMax); // dessiner les icônes diff --git a/verif_version.dcu b/verif_version.dcu index ea2b651..ade75f8 100644 Binary files a/verif_version.dcu and b/verif_version.dcu differ diff --git a/verif_version.pas b/verif_version.pas index 3e7cce1..0f1a6c7 100644 --- a/verif_version.pas +++ b/verif_version.pas @@ -23,7 +23,7 @@ var Lance_verif : integer; verifVersion,notificationVersion : boolean; -Const Version='3.63'; // sert à la comparaison de la version publiée +Const Version='3.7'; // sert à la comparaison de la version publiée SousVersion=' '; // en cas d'absence de sous version mettre un espace implementation diff --git a/versions.txt b/versions.txt index 62511c2..f2b46b8 100644 --- a/versions.txt +++ b/versions.txt @@ -80,7 +80,10 @@ version 3.6 : Am 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. -version 3.63 : Gestion améliorée du décodeur Unisemaf +version 3.7 : Gestion améliorée du décodeur Unisemaf + Présentation du rappel30/60 sur TJD déviées + Correction erreur 1000 au TCO +