diff --git a/2trains_séparés.txt b/2trains_séparés.txt deleted file mode 100644 index 2eca721..0000000 --- a/2trains_séparés.txt +++ /dev/null @@ -1,306 +0,0 @@ -1 Tick=1016 Det=521=0 -2 Tick=1016 Det=521=0 -3 Tick=1016 Det=524=0 -4 Tick=1016 Det=531=0 -5 Tick=1016 Det=518=0 -6 Tick=1016 Det=518=0 -7 Tick=1016 Det=519=0 -8 Tick=1016 Det=523=0 -9 Tick=1016 Det=526=1 -10 Tick=1016 Det=527=0 -11 Tick=1016 Det=526=1 -12 Tick=1016 Det=523=0 -13 Tick=1016 Det=513=0 -14 Tick=1016 Det=524=0 -15 Tick=1016 Det=515=0 -16 Tick=1016 Det=514=0 -17 Tick=1016 Det=516=1 -18 Tick=1016 Det=516=1 -19 Tick=1016 Det=515=0 -20 Tick=1016 Det=525=0 -21 Tick=1016 Det=528=1 -22 Tick=1016 Det=528=1 -23 Tick=1016 Det=522=0 -24 Tick=1017 Det=514=0 -25 Tick=1017 Det=522=0 -26 Tick=1017 Det=519=0 -27 Tick=1017 Det=527=0 -28 Tick=1017 Det=531=0 -29 Tick=1017 Det=525=0 -30 Tick=1017 Det=535=0 -31 Tick=1017 Det=535=0 -32 Tick=1017 Det=535=0 -33 Tick=1017 Det=535=0 -34 Tick=1017 Det=534=0 -35 Tick=1017 Det=534=0 -36 Tick=1017 Det=533=0 -37 Tick=1017 Det=533=0 -38 Tick=1017 Det=520=0 -39 Tick=1017 Det=520=0 -40 Tick=1017 Det=517=0 -41 Tick=1017 Det=517=0 -42 Tick=1017 Det=538=0 -43 Tick=1017 Det=538=0 -44 Tick=1017 Det=529=0 -45 Tick=1017 Det=529=0 -46 Tick=1017 Det=530=0 -47 Tick=1017 Det=530=0 -48 Tick=1017 Det=537=0 -49 Tick=1017 Det=537=0 -50 Tick=1017 Det=513=0 -51 Tick=1044 Det=526=0 -52 Tick=1044 Det=527=0 -53 Tick=1044 Det=526=0 -54 Tick=1044 Det=525=0 -55 Tick=1044 Det=528=1 -56 Tick=1044 Det=528=1 -57 Tick=1044 Det=527=0 -58 Tick=1044 Det=525=0 -59 Tick=1057 Det=526=0 -60 Tick=1057 Det=527=0 -61 Tick=1057 Det=526=0 -62 Tick=1057 Det=525=0 -63 Tick=1057 Det=528=0 -64 Tick=1057 Det=528=0 -65 Tick=1057 Det=527=0 -66 Tick=1057 Det=525=0 -67 Tick=1076 Det=531=1 -68 Tick=1076 Det=531=1 -69 Tick=1076 Det=529=0 -70 Tick=1076 Det=529=0 -71 Tick=1076 Det=530=0 -72 Tick=1076 Det=530=0 -73 Tick=1081 Det=531=0 -74 Tick=1081 Det=529=0 -75 Tick=1081 Det=529=0 -76 Tick=1081 Det=530=0 -77 Tick=1081 Det=530=0 -78 Tick=1086 Det=518=1 -79 Tick=1086 Det=518=1 -80 Tick=1086 Det=519=0 -81 Tick=1086 Det=519=0 -82 Tick=1086 Det=520=0 -83 Tick=1086 Det=520=0 -84 Tick=1086 Det=517=0 -85 Tick=1086 Det=517=0 -86 Tick=1097 Det=531=0 -87 Tick=1115 Det=518=0 -88 Tick=1115 Det=519=0 -89 Tick=1115 Det=519=0 -90 Tick=1115 Det=520=0 -91 Tick=1115 Det=520=0 -92 Tick=1115 Det=517=0 -93 Tick=1115 Det=517=0 -94 Tick=1121 Det=518=0 -95 Tick=1138 Det=521=0 -96 Tick=1138 Det=521=0 -97 Tick=1138 Det=524=0 -98 Tick=1138 Det=523=1 -99 Tick=1138 Det=523=1 -100 Tick=1138 Det=524=0 -101 Tick=1138 Det=522=0 -102 Tick=1138 Det=522=0 -103 Tick=1141 Det=513=1 -104 Tick=1141 Det=515=0 -105 Tick=1141 Det=514=0 -106 Tick=1141 Det=516=1 -107 Tick=1141 Det=516=1 -108 Tick=1141 Det=515=0 -109 Tick=1141 Det=514=0 -110 Tick=1141 Det=513=1 -111 Tick=1183 Det=521=0 -112 Tick=1183 Det=521=0 -113 Tick=1183 Det=524=0 -114 Tick=1183 Det=523=0 -115 Tick=1183 Det=524=0 -116 Tick=1183 Det=522=0 -117 Tick=1183 Det=522=0 -118 Tick=1191 Det=526=1 -119 Tick=1191 Det=527=0 -120 Tick=1191 Det=526=1 -121 Tick=1191 Det=525=0 -122 Tick=1191 Det=528=0 -123 Tick=1191 Det=528=0 -124 Tick=1191 Det=527=0 -125 Tick=1191 Det=525=0 -126 Tick=1194 Det=513=0 -127 Tick=1194 Det=515=0 -128 Tick=1194 Det=514=0 -129 Tick=1194 Det=516=1 -130 Tick=1194 Det=516=1 -131 Tick=1194 Det=515=0 -132 Tick=1194 Det=514=0 -133 Tick=1194 Det=513=0 -134 Tick=1214 Det=523=0 -135 Tick=1242 Det=531=1 -136 Tick=1242 Det=531=1 -137 Tick=1242 Det=529=0 -138 Tick=1242 Det=529=0 -139 Tick=1242 Det=530=0 -140 Tick=1242 Det=530=0 -141 Tick=1251 Det=531=0 -142 Tick=1251 Det=529=0 -143 Tick=1251 Det=529=0 -144 Tick=1251 Det=530=0 -145 Tick=1251 Det=530=0 -146 Tick=1260 Det=518=1 -147 Tick=1260 Det=518=1 -148 Tick=1260 Det=519=0 -149 Tick=1260 Det=519=0 -150 Tick=1260 Det=520=0 -151 Tick=1260 Det=520=0 -152 Tick=1260 Det=517=0 -153 Tick=1260 Det=517=0 -154 Tick=1272 Det=531=0 -155 Tick=1283 Det=527=0 -156 Tick=1283 Det=526=0 -157 Tick=1283 Det=525=0 -158 Tick=1283 Det=528=0 -159 Tick=1283 Det=528=0 -160 Tick=1283 Det=527=0 -161 Tick=1283 Det=525=0 -162 Tick=1290 Det=526=0 -163 Tick=1310 Det=518=0 -164 Tick=1310 Det=519=0 -165 Tick=1310 Det=519=0 -166 Tick=1310 Det=520=0 -167 Tick=1310 Det=520=0 -168 Tick=1310 Det=517=0 -169 Tick=1310 Det=517=0 -170 Tick=1321 Det=518=0 -171 Tick=1326 Det=513=0 -172 Tick=1326 Det=515=0 -173 Tick=1326 Det=514=1 -174 Tick=1326 Det=516=1 -175 Tick=1326 Det=516=1 -176 Tick=1326 Det=515=0 -177 Tick=1326 Det=514=1 -178 Tick=1326 Det=513=0 -179 Tick=1376 Det=513=1 -180 Tick=1376 Det=515=0 -181 Tick=1376 Det=514=1 -182 Tick=1376 Det=516=1 -183 Tick=1376 Det=516=1 -184 Tick=1376 Det=515=0 -185 Tick=1376 Det=514=1 -186 Tick=1376 Det=513=1 -187 Tick=1397 Det=521=0 -188 Tick=1397 Det=521=0 -189 Tick=1397 Det=524=0 -190 Tick=1397 Det=523=0 -191 Tick=1397 Det=523=0 -192 Tick=1397 Det=524=0 -193 Tick=1397 Det=522=1 -194 Tick=1397 Det=522=1 -195 Tick=1400 Det=515=0 -196 Tick=1421 Det=514=0 -197 Tick=1422 Det=513=0 -198 Tick=1437 Det=531=1 -199 Tick=1437 Det=531=1 -200 Tick=1437 Det=529=0 -201 Tick=1437 Det=529=0 -202 Tick=1437 Det=530=0 -203 Tick=1437 Det=530=0 -204 Tick=1441 Det=531=0 -205 Tick=1441 Det=531=0 -206 Tick=1441 Det=529=0 -207 Tick=1441 Det=529=0 -208 Tick=1441 Det=530=0 -209 Tick=1441 Det=530=0 -210 Tick=1446 Det=518=1 -211 Tick=1446 Det=518=1 -212 Tick=1446 Det=519=0 -213 Tick=1446 Det=519=0 -214 Tick=1446 Det=520=0 -215 Tick=1446 Det=520=0 -216 Tick=1446 Det=517=0 -217 Tick=1446 Det=517=0 -218 Tick=1475 Det=518=0 -219 Tick=1475 Det=519=0 -220 Tick=1475 Det=519=0 -221 Tick=1475 Det=520=0 -222 Tick=1475 Det=520=0 -223 Tick=1475 Det=517=0 -224 Tick=1475 Det=517=0 -225 Tick=1490 Det=518=0 -226 Tick=1491 Det=521=0 -227 Tick=1491 Det=521=0 -228 Tick=1491 Det=524=0 -229 Tick=1491 Det=523=0 -230 Tick=1491 Det=523=0 -231 Tick=1491 Det=524=0 -232 Tick=1491 Det=522=0 -233 Tick=1498 Det=521=0 -234 Tick=1498 Det=521=0 -235 Tick=1498 Det=524=0 -236 Tick=1498 Det=523=1 -237 Tick=1498 Det=523=1 -238 Tick=1498 Det=524=0 -239 Tick=1498 Det=522=0 -240 Tick=1498 Det=522=0 -241 Tick=1500 Det=522=0 -242 Tick=1541 Det=521=0 -243 Tick=1541 Det=521=0 -244 Tick=1541 Det=524=0 -245 Tick=1541 Det=526=0 -246 Tick=1541 Det=527=1 -247 Tick=1541 Det=526=0 -248 Tick=1541 Det=523=0 -249 Tick=1541 Det=524=0 -250 Tick=1541 Det=525=0 -251 Tick=1541 Det=528=0 -252 Tick=1541 Det=528=0 -253 Tick=1541 Det=522=0 -254 Tick=1541 Det=522=0 -255 Tick=1541 Det=527=1 -256 Tick=1541 Det=525=0 -257 Tick=1551 Det=526=1 -258 Tick=1551 Det=527=1 -259 Tick=1551 Det=526=1 -260 Tick=1551 Det=525=0 -261 Tick=1551 Det=528=0 -262 Tick=1551 Det=528=0 -263 Tick=1551 Det=527=1 -264 Tick=1551 Det=525=0 -265 Tick=1552 Det=523=0 -266 Tick=1598 Det=527=1 -267 Tick=1598 Det=526=0 -268 Tick=1598 Det=525=0 -269 Tick=1598 Det=528=0 -270 Tick=1598 Det=528=0 -271 Tick=1598 Det=527=1 -272 Tick=1598 Det=525=0 -273 Tick=1606 Det=526=0 -274 Tick=1606 Det=526=0 -275 Tick=1606 Det=525=0 -276 Tick=1606 Det=528=0 -277 Tick=1606 Det=528=0 -278 Tick=1606 Det=527=0 -279 Tick=1606 Det=525=0 -280 Tick=1643 Det=518=0 -281 Tick=1643 Det=518=0 -282 Tick=1643 Det=519=1 -283 Tick=1643 Det=519=1 -284 Tick=1643 Det=520=0 -285 Tick=1643 Det=520=0 -286 Tick=1643 Det=517=0 -287 Tick=1643 Det=517=0 -288 Tick=1645 Det=527=0 -289 Tick=1651 Det=526=0 -290 Tick=1708 Det=513=1 -291 Tick=1708 Det=515=0 -292 Tick=1709 Det=514=0 -293 Tick=1709 Det=516=1 -294 Tick=1709 Det=516=1 -295 Tick=1709 Det=515=0 -296 Tick=1709 Det=514=0 -297 Tick=1709 Det=513=1 -298 Tick=1709 Det=518=0 -299 Tick=1709 Det=518=0 -300 Tick=1709 Det=519=0 -301 Tick=1709 Det=519=0 -302 Tick=1709 Det=520=0 -303 Tick=1709 Det=520=0 -304 Tick=1709 Det=517=0 -305 Tick=1709 Det=517=0 - diff --git a/UnitConfig.dcu b/UnitConfig.dcu index b770598..48f5ec5 100644 Binary files a/UnitConfig.dcu and b/UnitConfig.dcu differ diff --git a/UnitConfig.dfm b/UnitConfig.dfm index a0b8259..a8b84e9 100644 --- a/UnitConfig.dfm +++ b/UnitConfig.dfm @@ -958,8 +958,8 @@ object FormConfig: TFormConfig ParentFont = False end object ImageAig: TImage - Left = 736 - Top = 432 + Left = 744 + Top = 480 Width = 137 Height = 57 Picture.Data = { @@ -1230,8 +1230,8 @@ object FormConfig: TFormConfig Visible = False end object ImageTJD: TImage - Left = 736 - Top = 400 + Left = 744 + Top = 416 Width = 137 Height = 57 Picture.Data = { @@ -1366,8 +1366,8 @@ object FormConfig: TFormConfig Visible = False end object ImageTri: TImage - Left = 736 - Top = 360 + Left = 744 + Top = 344 Width = 137 Height = 65 Picture.Data = { @@ -1578,7 +1578,7 @@ object FormConfig: TFormConfig Top = 8 Width = 633 Height = 497 - ActivePage = TabSheetAig + ActivePage = TabSheetAct Font.Charset = DEFAULT_CHARSET Font.Color = clBlack Font.Height = -11 @@ -1641,12 +1641,12 @@ object FormConfig: TFormConfig Left = 16 Top = 96 Width = 273 - Height = 185 + Height = 201 Caption = 'Au d'#233'marrage de Signaux_Complexes ' TabOrder = 1 object Label13: TLabel Left = 8 - Top = 124 + Top = 140 Width = 242 Height = 26 Caption = @@ -1656,7 +1656,7 @@ object FormConfig: TFormConfig end object CheckVerifVersion: TCheckBox Left = 8 - Top = 24 + Top = 40 Width = 249 Height = 17 Caption = 'V'#233'rifications de nouvelle version au d'#233'marrage' @@ -1664,7 +1664,7 @@ object FormConfig: TFormConfig end object CheckInfoVersion: TCheckBox Left = 8 - Top = 40 + Top = 56 Width = 241 Height = 17 Caption = 'Information sur la version actuelle' @@ -1672,7 +1672,7 @@ object FormConfig: TFormConfig end object CheckLanceCDM: TCheckBox Left = 8 - Top = 96 + Top = 112 Width = 241 Height = 25 Caption = 'Lancer CDM Rail au d'#233'marrage' @@ -1681,7 +1681,7 @@ object FormConfig: TFormConfig end object CheckAvecTCO: TCheckBox Left = 8 - Top = 56 + Top = 72 Width = 89 Height = 17 Hint = 'Affiche le TCO au d'#233'marrage' @@ -1692,7 +1692,7 @@ object FormConfig: TFormConfig end object EditNomLay: TEdit Left = 16 - Top = 154 + Top = 170 Width = 241 Height = 21 TabOrder = 4 @@ -1700,7 +1700,7 @@ object FormConfig: TFormConfig end object CheckFenEt: TCheckBox Left = 8 - Top = 72 + Top = 24 Width = 249 Height = 17 Hint = 'Taille de la fen'#234'tre maximalis'#233'e' @@ -1710,8 +1710,8 @@ object FormConfig: TFormConfig TabOrder = 5 end object CheckBandeauTCO: TCheckBox - Left = 128 - Top = 56 + Left = 8 + Top = 88 Width = 129 Height = 17 Hint = 'Masque le bandeau de param'#233'trage du TCO au d'#233'marrage' @@ -1722,9 +1722,9 @@ object FormConfig: TFormConfig end end object GroupBox6: TGroupBox - Left = 320 + Left = 312 Top = 8 - Width = 273 + Width = 281 Height = 169 Caption = 'Au d'#233'marrage de CDM Rail : serveur' TabOrder = 2 @@ -1802,9 +1802,9 @@ object FormConfig: TFormConfig end end object GroupBox7: TGroupBox - Left = 320 + Left = 312 Top = 184 - Width = 273 + Width = 281 Height = 137 Caption = 'Au d'#233'marrage de CDM Rail : interface LENZ' TabOrder = 3 @@ -1859,7 +1859,7 @@ object FormConfig: TFormConfig end object GroupBox8: TGroupBox Left = 16 - Top = 288 + Top = 304 Width = 273 Height = 113 Caption = 'Services CommIP CDM Rail' @@ -1913,42 +1913,66 @@ object FormConfig: TFormConfig end end object GroupBox15: TGroupBox - Left = 320 + Left = 312 Top = 328 - Width = 273 - Height = 73 + Width = 281 + Height = 89 Caption = 'Divers' TabOrder = 5 object Label31: TLabel Left = 8 - Top = 16 + Top = 24 Width = 204 Height = 13 Caption = 'Seuil du nombre de d'#233'tecteurs trop distants' end object Label41: TLabel Left = 8 - Top = 36 + Top = 68 Width = 188 Height = 13 Caption = 'Taille de la fonte de la fen'#234'tre principale' end + object Label44: TLabel + Left = 8 + Top = 45 + Width = 223 + Height = 13 + Caption = 'Nombre de cantons pr'#233'sence train avant signal' + end object EditNbDetDist: TEdit - Left = 232 - Top = 12 + Left = 240 + Top = 20 Width = 25 Height = 21 + ParentShowHint = False + ShowHint = False TabOrder = 0 Text = 'EditNbDetDist' end object EditFonte: TEdit - Left = 232 - Top = 32 + Left = 240 + Top = 64 Width = 25 Height = 21 + ParentShowHint = False ReadOnly = True + ShowHint = False TabOrder = 1 end + object EditNbCantons: TEdit + Left = 240 + Top = 41 + Width = 25 + Height = 21 + Hint = + 'Nombre de cantons pr'#233'sence train avant un signal pour le d'#233'clar' + + 'er verrouill'#233 + ParentShowHint = False + ShowHint = True + TabOrder = 2 + Text = 'EditNbCantons' + end end end object TabSheetAutonome: TTabSheet @@ -2185,9 +2209,10 @@ object FormConfig: TFormConfig Top = 24 Width = 257 Height = 25 + Hint = 'Initialisation des aiguillages au d'#233'marrage' Caption = 'Initialisation des aiguillages ' ParentShowHint = False - ShowHint = False + ShowHint = True TabOrder = 0 WordWrap = True end @@ -2628,6 +2653,7 @@ object FormConfig: TFormConfig ScrollBars = ssBoth TabOrder = 1 WordWrap = False + OnKeyDown = RichAigKeyDown OnMouseDown = RichAigMouseDown end object ButtonNouvAig: TButton @@ -2920,7 +2946,7 @@ object FormConfig: TFormConfig Top = 48 Width = 129 Height = 21 - ItemHeight = 0 + ItemHeight = 13 TabOrder = 1 OnChange = ComboBoxDecChange end @@ -3099,6 +3125,7 @@ object FormConfig: TFormConfig ScrollBars = ssBoth TabOrder = 1 WordWrap = False + OnKeyDown = RichSigKeyDown OnMouseDown = RichSigMouseDown end object ButtonNouvFeu: TButton @@ -3525,6 +3552,7 @@ object FormConfig: TFormConfig Top = 80 Width = 41 Height = 33 + Hint = 'Joue le son' Flat = True Glyph.Data = { 4E010000424D4E010000000000003E0000002800000022000000220000000100 @@ -3538,6 +3566,8 @@ object FormConfig: TFormConfig 00003FFFFFFF000000003FFFFFFF000000003FFFFFFF000000001FFFFFFE0000 000000000000000000008000000040000000C0000000C0000000FFFFFFFFC000 0000FFFFFFFFC0000000FFFFFFFFC0000000} + ParentShowHint = False + ShowHint = True OnClick = SpeedButtonJoueClick end object SpeedButtonCharger: TSpeedButton @@ -3545,6 +3575,7 @@ object FormConfig: TFormConfig Top = 80 Width = 25 Height = 34 + Hint = 'Ouvre un fichier son WAV' Flat = True Glyph.Data = { BA060000424DBA06000000000000360400002800000019000000170000000100 @@ -3601,6 +3632,8 @@ object FormConfig: TFormConfig 272752FFFFFFFF000000FF27BFBFBFBFBFBFBFBF25FFFFFFFFFFFFFFFFFFFFFF FFFFFF000000FF266F2727272727276F13FFFFFFFFFFFFFFFFFFFFFFFFFFFF00 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000} + ParentShowHint = False + ShowHint = True OnClick = SpeedButtonChargerClick end object Label42: TLabel @@ -3777,7 +3810,7 @@ object FormConfig: TFormConfig end end object OpenDialogSon: TOpenDialog - Left = 708 - Top = 500 + Left = 604 + Top = 508 end end diff --git a/UnitConfig.pas b/UnitConfig.pas index e791fea..b5ed098 100644 --- a/UnitConfig.pas +++ b/UnitConfig.pas @@ -253,6 +253,8 @@ type Label42: TLabel; Label43: TLabel; CheckBandeauTCO: TCheckBox; + EditNbCantons: TEdit; + Label44: TLabel; procedure ButtonAppliquerEtFermerClick(Sender: TObject); procedure FormActivate(Sender: TObject); procedure FormCreate(Sender: TObject); @@ -354,6 +356,10 @@ type procedure RichBrancheKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure EditTrainDestChange(Sender: TObject); + procedure RichAigKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure RichSigKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); private { Déclarations privées } public @@ -379,6 +385,7 @@ CDM_ch='CDM'; Serveur_interface_ch='Serveur_interface'; fenetre_ch='Fenetre'; Tempo_aig_ch='Tempo_Aig'; +Nb_cantons_Sig_ch='Nb_cantons_Sig'; Tempo_Feu_ch='Tempo_Feu'; Algo_Unisemaf_ch='Alg_Unisemaf'; NOTIF_VERSION_ch='NOTIF_VERSION'; @@ -396,10 +403,10 @@ var FormConfig: TFormConfig; AdresseIPCDM,AdresseIP,PortCom,recuCDM,residuCDM,trainsauve : string; portCDM,TempoOctet,TimoutMaxInterface,Valeur_entete,Port,protocole,NumPort, - LigneCliqueePN,AncLigneCliqueePN,clicMemo, + LigneCliqueePN,AncLigneCliqueePN,clicMemo,Nb_cantons_Sig, ligneclicAig,AncLigneClicAig,ligneClicSig,AncligneClicSig, ligneClicBr,AncligneClicBr,ligneClicAct,AncLigneClicAct,Adressefeuclic,NumTrameCDM : integer; - ack_cdm,clicliste,entreeTCO,affevt,config_modifie,clicproprietes : boolean; + ack_cdm,clicliste,entreeTCO,affevt,config_modifie,clicproprietes,confasauver : boolean; fichier : text; function config_com(s : string) : boolean; @@ -510,56 +517,59 @@ begin // déconnexion de l'ancienne liaison éventuelle Formprinc.ClientSocketCDM.Close; - if (AdresseIPCDM<>'0') and (ProcessRunning('CDR')) then + if (AdresseIPCDM<>'0') then begin - // ouverture du socket CDM - with Formprinc do + if(ProcessRunning('CDR')) then begin - ClientSocketCDM.port:=portCDM; - ClientSocketCDM.Address:=AdresseIPCDM; - ClientSocketCDM.Open; - end; - i:=0; - repeat - Sleep(50); - inc(i); - Application.processMessages; - until (i>10) or CDM_connecte ; - //if i>10 then affiche('Timeout',clred); - if not(CDM_connecte) then begin Affiche('Socket CDM non connecté',clOrange);exit;end; - - // connexion à CDM rail - recuCDM:=''; - s:='C-C-00-0001-CMDGEN-_CNCT|000|'; - envoi_cdm(s); - if ack_cdm then - begin - ack_cdm:=false; - Id_CDM:=copy(recuCDM,5,2); // récupère l'ID reçu de CDM, à utiliser dans toutes les futures trames - recucdm:=''; - s:='Connecté au serveur CDM rail avec l''ID='+Id_CDM; - - Affiche(s,clYellow); - AfficheDebug(s,clyellow); - CDM_connecte:=true; - - // demande des services - services_CDM; - - // demande la description des trains - s:=place_id('C-C-01-0002-DSCTRN-DLOAD|000|'); - ntrains:=0; - envoi_CDM(s); - sleep(10); - Application.ProcessMessages; - if ntrains<>0 then - with formprinc do + // ouverture du socket CDM + with Formprinc do begin - combotrains.ItemIndex:=0; - editAdrTrain.text:=IntToSTR(trains[1].adresse); + ClientSocketCDM.port:=portCDM; + ClientSocketCDM.Address:=AdresseIPCDM; + ClientSocketCDM.Open; end; - end; - end + i:=0; + repeat + Sleep(50); + inc(i); + Application.processMessages; + until (i>10) or CDM_connecte ; + //if i>10 then affiche('Timeout',clred); + if not(CDM_connecte) then begin Affiche('Socket CDM non connecté',clOrange);exit;end; + + // connexion à CDM rail + recuCDM:=''; + s:='C-C-00-0001-CMDGEN-_CNCT|000|'; + envoi_cdm(s); + if ack_cdm then + begin + ack_cdm:=false; + Id_CDM:=copy(recuCDM,5,2); // récupère l'ID reçu de CDM, à utiliser dans toutes les futures trames + recucdm:=''; + s:='Connecté au serveur CDM rail avec l''ID='+Id_CDM; + + Affiche(s,clYellow); + AfficheDebug(s,clyellow); + CDM_connecte:=true; + + // demande des services + services_CDM; + // demande la description des trains + s:=place_id('C-C-01-0002-DSCTRN-DLOAD|000|'); + ntrains:=0; + envoi_CDM(s); + sleep(10); + Application.ProcessMessages; + if ntrains<>0 then + with formprinc do + begin + combotrains.ItemIndex:=0; + editAdrTrain.text:=IntToSTR(trains[1].adresse); + end; + end; + end + else Affiche('CDM Rail non lancé',clOrange); + end else begin if adresseIPCDM='0' then Affiche('La connexion à CDM n''est pas demandée car l''adresse IP est nulle dans '+NomConfig,cyan); @@ -674,7 +684,7 @@ begin end; if croi then - begin //zizi + begin s:=s+'D('+intToSTR(aiguillage[index].Adroit); c:=aiguillage[index].AdroitB;if c<>'Z' then s:=s+c; s:=s+','+intToSTR(aiguillage[index].DDroit)+aiguillage[index].DDroitB+'),'; @@ -1136,7 +1146,7 @@ var s: string; continue : boolean; begin - assign(fichierN,NomConfig); + assign(fichierN,NomConfig); rewrite(fichierN); // entête @@ -1206,13 +1216,16 @@ begin writeln(fichierN,retro_ch+'=',intToSTR(ServeurRetroCDM)); // entête - // Raz Signaux + // Raz Signaux if Raz_Acc_signaux then s:='1' else s:='0'; writeln(fichierN,'RazSignaux='+s); // temporisation entre 2 commandes décodeurs feu writeln(fichierN,Tempo_feu_ch+'=',IntToSTR(Tempo_feu)); + // Nombre de cantons avant signal + writeln(fichierN,Nb_cantons_Sig_ch+'=',intToSTR(Nb_cantons_Sig)); + // algorithme Unisemaf writeln(fichierN,Algo_unisemaf_ch+'=',IntToSTR(algo_Unisemaf)); @@ -1283,11 +1296,11 @@ var s,sa,chaine,SOrigine: string; trouve_Tempo_maxi,trouve_Entete,trouve_tco,trouve_cdm,trouve_Serveur_interface,trouve_fenetre,trouve_MasqueTCO, 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, - trouve_algo_uni,croi : boolean; + trouve_algo_uni,croi,trouve_Nb_cantons_Sig : 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,poscroi : integer; - + function lit_ligne : string ; var esp,l1,l2,k : integer; guim : boolean; @@ -1829,13 +1842,15 @@ begin end; until (sOrigine='0'); end; - + procedure lit_flux; label ici1,ici2,ici3,ici4 ; var i : integer; // début de la procédure lit_config begin + // valeurs par défaut + Nb_cantons_Sig:=3; nv:=0; it:=0; // taille de fonte repeat @@ -1965,6 +1980,18 @@ begin if fenetre=1 then Formprinc.windowState:=wsMaximized; end; + // Nombre de cantons avant signal + sa:=uppercase(Nb_cantons_Sig_ch)+'='; + i:=pos(sa,s); + if i=1 then + begin + inc(nv); + trouve_Nb_cantons_Sig:=true; + delete(s,i,length(sa)); + val(s,Nb_cantons_Sig,erreur); + if (Nb_cantons_Sig<3) or (Nb_cantons_Sig>5) then Nb_cantons_Sig:=3; + end; + // temporisation aiguillages sa:=uppercase(Tempo_Aig_ch)+'='; i:=pos(sa,s); @@ -2213,6 +2240,7 @@ begin Tempo_Aig:=100; Tempo_feu:=100; ServeurInterfaceCDM:=1; + Nb_cantons_Sig:=3; ServeurRetroCDM:=1; algo_Unisemaf:=1; TailleFonte:=12; @@ -2243,6 +2271,7 @@ begin if not(trouve_fenetre) then s:=fenetre_ch; if not(trouve_tempo_aig) then s:=tempo_aig_ch; if not(trouve_Algo_Uni) then s:=Algo_unisemaf_ch; + if not(trouve_Nb_cantons_Sig) then s:=Nb_cantons_Sig_ch; if not(trouve_tempo_feu) then begin s:=tempo_feu_ch; @@ -2253,34 +2282,53 @@ begin if not(trouve_verif_version) then s:=verif_version_ch; if not(trouve_fonte) then s:=fonte_ch; - if s<>'' then affiche('ERREUR: manque variables dans '+NomConfig+' :'+s,clred); + if s<>'' then + begin + affiche('Manque variables dans '+NomConfig+' : '+s,clOrange); + confasauver:=true; + end; if not(trouve_section_aig) then Affiche('Manque section '+section_aig_ch,clred); if not(trouve_section_sig) then Affiche('Manque section '+section_sig_ch,clred); if not(trouve_section_branche) then Affiche('Manque section '+section_branches_ch,clred); verif_coherence; + formDebug.buttonCP.Caption:='Etat '+intToSTR(Nb_cantons_Sig)+' cantons précédents signal'; end; // sauvegarder la config dans le fichier cfg function Sauve_config : boolean; -var i,erreur : integer; - s : string; - ChangeCDM,changeInterface,changeUSB,change_srv : boolean; begin + // générer le fichier de config + genere_config; + Affiche('Configuration sauvegardée dans le fichier',clLime); + config_modifie:=false; + confasauver:=false; + sauve_config:=true; + exit; +end; + + + +function verifie_panneau_config : boolean; +var ChangeCDM,changeInterface,changeUSB,change_srv,ok : boolean; + i,erreur : integer; + s : string; +begin + ok:=true; // Vérification de la configuration------------------------------------------- // contrôle adresse IP CDM with FormConfig do begin s:=EditAdrIPCDM.text; if s='' then s:='127.0.0.1'; - if not(IpOk(s)) then begin labelInfo.Caption:='Adresse IP CDM rail incorrecte';sauve_config:=false;exit;end; + if not(IpOk(s)) then begin labelInfo.Caption:='Adresse IP CDM rail incorrecte';ok:=false;end; ChangeCDM:=s<>AdresseIPCDM; adresseIPCDM:=s; // contrôle port CDM val(EditPortCDM.Text,i,erreur); if i=0 then i:=9999; - if i>65535 then begin labelInfo.Caption:='Port CDM rail incorrect';sauve_config:=false;exit;end; + if i>65535 then begin labelInfo.Caption:='Port CDM rail incorrect';ok:=false;end; changeCDM:=(portCDM<>i) or ChangeCDM; portCDM:=i; @@ -2292,40 +2340,45 @@ begin // contrôle adresse IP interface s:=EditIPLenz.text; if s='' then s:='0'; - if not(IpOk(s)) and (s<>'0') then begin labelInfo.Caption:='Adresse IP interface Xpressnet incorrecte';sauve_config:=false;exit;end; + if not(IpOk(s)) and (s<>'0') then begin labelInfo.Caption:='Adresse IP interface Xpressnet incorrecte';ok:=false;end; changeInterface:=s<>AdresseIP; AdresseIP:=s; // contrôle port interface val(EditPortLenz.Text,i,erreur); if i=0 then i:=5550; - if i>65535 then begin labelInfo.Caption:='Port Interface incorrect';sauve_config:=false;exit;end; + if i>65535 then begin labelInfo.Caption:='Port Interface incorrect';ok:=false;end; changeInterface:=changeInterface or (i<>port); port:=i; Val(editTempoAig.Text,i,erreur); - if i>3000 then begin labelInfo.Caption:='Temporisation de séquencement incorrecte ';sauve_config:=false;exit;end; + if i>3000 then begin labelInfo.Caption:='Temporisation de séquencement incorrecte ';ok:=false;end; Tempo_Aig:=i; // contrôle protocole interface COM3:57600,N,8,1,2 s:=EditComUSB.Text; if s='' then s:='COM3:57600,N,8,1,2'; - if not(config_com(s)) then begin labelInfo.Caption:='Protocole série USB Interface incorrect';sauve_config:=false;exit;end; + if not(config_com(s)) then begin labelInfo.Caption:='Protocole série USB Interface incorrect';ok:=false;end; changeUSB:=portcom<>s; portcom:=s; val(EditTempoOctetUSB.text,i,erreur); - if erreur<>0 then begin labelInfo.Caption:='Valeur temporisation octet incorrecte';sauve_config:=false;exit;end; + if erreur<>0 then begin labelInfo.Caption:='Valeur temporisation octet incorrecte';ok:=false;end; TempoOctet:=i; val(EditTempoReponse.text,i,erreur); - if erreur<>0 then begin labelInfo.Caption:='Valeur temporisation de réponse interface';sauve_config:=false;exit;end; + if erreur<>0 then begin labelInfo.Caption:='Valeur temporisation de réponse interface';ok:=false;end; TimoutMaxInterface:=i; val(EditNbDetDist.text,i,erreur); - if (erreur<>0) or (i<3) then begin labelInfo.Caption:='Valeur nombre de détecteurs trop distants incorrecte';sauve_config:=false;exit;end; + if (erreur<>0) or (i<3) then begin labelInfo.Caption:='Valeur nombre de détecteurs trop distants incorrecte';ok:=false;end; Nb_Det_Dist:=i; + val(EditNbCantons.text,i,erreur); + if (erreur<>0) or ((i<3) or (i>5)) then begin labelInfo.Caption:='Valeur cantons signaux de 3 à 5';ok:=false;end; + Nb_cantons_Sig:=i; + formDebug.buttonCP.Caption:='Etat '+intToSTR(Nb_cantons_Sig)+' cantons précédents signal'; + if RadioButton1.checked then Valeur_entete:=0; if RadioButton2.checked then Valeur_entete:=1; if RadioButton3.checked then Valeur_entete:=2; @@ -2382,7 +2435,7 @@ begin if RadioButton17.Checked then ServeurRetroCDM:=5; if RadioButton18.Checked then ServeurRetroCDM:=6; - // changement sur les services CDM + // changement sur les services CDM change_srv:=Srvc_Aig<>CheckBoxServAig.checked; change_srv:=Srvc_Det<>CheckBoxServDet.checked or change_srv; change_srv:=Srvc_Act<>CheckBoxServAct.checked or change_srv; @@ -2398,17 +2451,19 @@ begin AvecInitAiguillages:=CheckBoxInitAig.Checked; end; if change_srv then services_CDM; - - // générer le fichier de config - genere_config; - Affiche('Configuration sauvegardée dans le fichier',clLime); - config_modifie:=false; - sauve_config:=true; + verifie_panneau_config:=ok; end; procedure TFormConfig.ButtonAppliquerEtFermerClick(Sender: TObject); +var ok : boolean; begin - if sauve_config then formConfig.close; // si la config est ok, on ferme la fenetre + ok:=verifie_panneau_config; + if ok then + begin + Sauve_config; + formConfig.close; // si la config est ok, on ferme la fenetre + end; + // TCO if avectco and not(entreeTCO) then begin @@ -2492,6 +2547,7 @@ begin EditDroit_BD.ReadOnly:=false; Edit_HG.ReadOnly:=false; + EditNbCantons.text:=intToSTR(Nb_cantons_Sig); EditTempoFeu.Text:=IntToSTR(Tempo_feu); EditNbDetDist.text:=IntToSTR(Nb_Det_dist); EditAdrIPCDM.text:=adresseIPCDM; @@ -2499,6 +2555,7 @@ begin EditIPLenz.text:=AdresseIP; EditportLenz.text:=IntToSTR(Port); EditTempoAig.Text:=IntToSTR(Tempo_Aig); + EditComUSB.Text:=PortCom; EditFonte.text:=IntToSTR(TailleFonte); EditTempoOctetUSB.text:=IntToSTR(TempoOctet); @@ -2667,6 +2724,7 @@ begin clicListe:=true; if affevt then affiche('FormConfig create',clLime); clicListe:=false; + end; @@ -2731,8 +2789,8 @@ begin GroupBoxEtatTJD.Visible:=false; GroupBox21.Visible:=true; GroupBox10.Visible:=true; - checkInverse.Visible:=true; - + checkInverse.Visible:=true; + // tjd if tjd or tjs or croi then begin @@ -2847,6 +2905,12 @@ begin editL.Visible:=false; labelL.Visible:=false; ComboBoxAig.ItemIndex:=4; + editP1.Visible:=false; + editP2.Visible:=false; + editP3.Visible:=false; + editP4.Visible:=false; + labelTJD1.Visible:=false; + labelTJD2.Visible:=false; end; // aiguillage normal ou tri @@ -5337,20 +5401,21 @@ begin config_modifie:=true; end; -procedure TFormConfig.ButtonSupFeuClick(Sender: TObject); + +procedure supprime_sig; var adresse,i,indexFeu,index,debut,fin,longueur,ltot,lignedeb,lignefin,l : integer; s : string; begin if affevt then affiche('Evt bouton Sup Feu',clyellow); //trouver ligne de début et de fin sélectionner. - debut:=RichSig.SelStart; - longueur:=RichSig.SelLength; + debut:=FormConfig.RichSig.SelStart; + longueur:=FormConfig.RichSig.SelLength; fin:=debut+longueur; //Affiche(inttostr(debut)+' '+inttostr(longueur),clyellow); // trouver les lignes sélectionnées i:=0;ltot:=0;ligneDeb:=0;LigneFin:=0; repeat - l:=length(RichSig.lines[i])+2; //+2 car CR LF + l:=length(FormConfig.RichSig.lines[i])+2; //+2 car CR LF ltot:=ltot+l; if (debut=fin) and (ligneFin=0) and (ligneDeb<>0) then ligneFin:=i+1; @@ -5370,7 +5435,7 @@ begin if Application.MessageBox(pchar(s),pchar('confirm'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then exit; - ButtonInsFeu.Caption:='Ajouter le feu '+intToSTR(feux[index].adresse)+' supprimé'; + FormConfig.ButtonInsFeu.Caption:='Ajouter le feu '+intToSTR(feux[index].adresse)+' supprimé'; clicliste:=true; Feu_supprime:=feux[index]; // sauvegarde le supprimé feu_sauve.adresse:=0; // dévalider sa définition @@ -5435,7 +5500,7 @@ begin Nbrefeux:=NbreFeux-(ligneFin-LigneDeb)-1; config_modifie:=true; - RichSig.Clear; + FormConfig.RichSig.Clear; // réafficher le richsig for i:=1 to NbreFeux do @@ -5443,8 +5508,8 @@ begin s:=encode_Sig_Feux(i); if s<>'' then begin - RichSig.Lines.Add(s); - RE_ColorLine(RichSig,RichSig.lines.count-1,ClAqua); + FormConfig.RichSig.Lines.Add(s); + RE_ColorLine(FormConfig.RichSig,FormConfig.RichSig.lines.count-1,ClAqua); end; end; ligneClicSig:=-1; @@ -5532,6 +5597,11 @@ begin } end; +procedure TFormConfig.ButtonSupFeuClick(Sender: TObject); +begin + Supprime_sig; +end; + // Ajouter le feu supprimé procedure TFormConfig.ButtonInsFeuClick(Sender: TObject); var s : string; @@ -6326,19 +6396,24 @@ begin Aig_sauve.Adresse:=0; end; -procedure TFormConfig.BoutSupAigClick(Sender: TObject); + +// supprime le ou les aiguillages sélectionnés dans le richEdit +procedure supprime_aig; var ligneDeb,LigneFin,i,index,index2,debut,longueur,fin,l,ltot : integer; s : string; begin //trouver ligne de début et de fin sélectionner. - debut:=RichAig.SelStart; - longueur:=RichAig.SelLength; + with formConfig do + begin + debut:=RichAig.SelStart; + longueur:=RichAig.SelLength; + end; fin:=debut+longueur; //Affiche(inttostr(debut)+' '+inttostr(longueur),clyellow); // trouver les lignes sélectionnées i:=0;ltot:=0;ligneDeb:=0;LigneFin:=0; repeat - l:=length(RichAig.lines[i])+2; //+2 car CR LF + l:=length(FormConfig.RichAig.lines[i])+2; //+2 car CR LF ltot:=ltot+l; if (debut=fin) and (ligneFin=0) and (ligneDeb<>0) then ligneFin:=i+1; @@ -6359,7 +6434,7 @@ begin if Application.MessageBox(pchar(s),pchar('confirm'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then exit; - ButtonAjSup.Caption:='Ajouter l''aig '+intToSTR(aiguillage[index].adresse)+' supprimé'; + FormConfig.ButtonAjSup.Caption:='Ajouter l''aig '+intToSTR(aiguillage[index].adresse)+' supprimé'; clicliste:=true; raz_champs_aig; Aig_supprime:=aiguillage[index]; // sauvegarde le supprimé @@ -6393,7 +6468,7 @@ begin MaxAiguillage:=maxAiguillage-(ligneFin-LigneDeb)-1; config_modifie:=true; - RichAig.Clear; + FormConfig.RichAig.Clear; // réafficher le richsig for i:=1 to MaxAiguillage do @@ -6401,11 +6476,11 @@ begin s:=encode_Aig(i); if s<>'' then begin - RichAig.Lines.Add(s); - RE_ColorLine(RichAig,RichAig.lines.count-1,ClAqua); + FormConfig.RichAig.Lines.Add(s); + RE_ColorLine(FormConfig.RichAig,FormConfig.RichAig.lines.count-1,ClAqua); end; end; - With RichAig do + With FormConfig.RichAig do begin SelStart:=0; Perform(EM_SCROLLCARET,0,0); @@ -6415,6 +6490,11 @@ begin clicliste:=false; end; +procedure TFormConfig.BoutSupAigClick(Sender: TObject); +begin + Supprime_aig; +end; + procedure TFormConfig.EditP1KeyPress(Sender: TObject; var Key: Char); var AdrAig,adr,adr2,erreur,index,id2 : integer; b,c : char; @@ -6999,7 +7079,7 @@ begin with Formconfig.RichBranche do begin lc:=Perform(EM_LINEFROMCHAR,-1,0); // numéro de la lignée cliquée - LabelNumBranche.Caption:='Branche n°'+intToSTR(lc+1); + if lines[lc]<>'' then LabelNumBranche.Caption:='Branche n°'+intToSTR(lc+1) else LabelNumBranche.Caption:=''; AncligneClicBr:=ligneClicBr; ligneClicBr:=lc; curseur:=SelStart; // position initiale du curseur @@ -7297,7 +7377,7 @@ begin aiguillage[ligneclicAig+1].tjsintb:=s[erreur]; s:=encode_aig(ligneclicAig+1); RichAig.Lines[ligneclicAig]:=s; - end; + end; end; procedure TFormConfig.Button2Click(Sender: TObject); @@ -7307,6 +7387,7 @@ end; procedure TFormConfig.FormClose(Sender: TObject; var Action: TCloseAction); var index : integer; + ok : boolean; begin for index:=1 to NbreFeux do begin @@ -7324,15 +7405,29 @@ begin Top:=HtImg+15+((HtImg+EspY+20)*((index-1) div NbreImagePLigne)); Left:=10+ (LargImg+5)*((index-1) mod (NbreImagePLigne)); BringToFront; - end; + end; end; // supprimer les checkBox de feux blancs si ils ont été décochés - if not(feux[index].FeuBlanc) and (feux[index].check<>nil) then + if not(feux[index].FeuBlanc) and (feux[index].check<>nil) then begin Feux[index].Check.free; Feux[index].Check:=nil; end; end; + + ok:=verifie_panneau_config; + + // TCO + if avectco and not(entreeTCO) then + begin + //créée la fenêtre TCO non modale + FormTCO:=TformTCO.Create(nil); + FormTCO.show; + FormPrinc.ButtonAffTCO.Visible:=true; + end; + + if not(ok) then action:=tCloseAction(caNone); // si la config est nok, on ferme pas la fenetre + end; procedure TFormConfig.ButtonConfigSRClick(Sender: TObject); @@ -7465,7 +7560,7 @@ begin if lc>0 then begin dec(lc); - LabelNumBranche.Caption:='Branche n°'+intToSTR(lc+1); + if lines[lc]<>'' then LabelNumBranche.Caption:='Branche n°'+intToSTR(lc+1) else LabelNumBranche.Caption:=''; AncligneClicBr:=ligneClicBr; ligneClicBr:=lc; curseur:=SelStart; // position initiale du curseur @@ -7510,15 +7605,22 @@ begin end; end; clicListe:=false; - end; +procedure TFormConfig.RichAigKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); begin + if key=VK_delete then supprime_aig; +end; +procedure TFormConfig.RichSigKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if key=VK_delete then supprime_sig; +end; - - +begin end. diff --git a/UnitConfigTCO.dcu b/UnitConfigTCO.dcu index 564fa53..9261fea 100644 Binary files a/UnitConfigTCO.dcu and b/UnitConfigTCO.dcu differ diff --git a/UnitConfigTCO.dfm b/UnitConfigTCO.dfm index 563716a..059a045 100644 --- a/UnitConfigTCO.dfm +++ b/UnitConfigTCO.dfm @@ -204,11 +204,11 @@ object FormConfigTCO: TFormConfigTCO Caption = 'Couleur des textes' end object Label12: TLabel - Left = 240 + Left = 192 Top = 40 - Width = 42 + Width = 93 Height = 13 - Caption = 'statiques' + Caption = 'statiques par d'#233'faut' end object ImageQuai: TImage Left = 296 @@ -229,7 +229,7 @@ object FormConfigTCO: TFormConfigTCO Top = 208 Width = 281 Height = 17 - Caption = 'Couleur des cantons activ'#233's par la couleur des trains' + Caption = 'Couleur du cantons activ'#233' par la couleur du train' TabOrder = 0 end end diff --git a/UnitDebug.dcu b/UnitDebug.dcu index f5d5398..278b8a6 100644 Binary files a/UnitDebug.dcu and b/UnitDebug.dcu differ diff --git a/UnitDebug.dfm b/UnitDebug.dfm index b625bb0..7797ac4 100644 --- a/UnitDebug.dfm +++ b/UnitDebug.dfm @@ -1,8 +1,8 @@ object FormDebug: TFormDebug - Left = 200 - Top = 155 - Width = 842 - Height = 784 + Left = -8 + Top = -8 + Width = 1382 + Height = 744 Caption = 'Fen'#234'tre de d'#233'bug' Color = clWindow TransparentColorValue = clTeal @@ -15,12 +15,12 @@ object FormDebug: TFormDebug Position = poMainFormCenter OnCreate = FormCreate DesignSize = ( - 809 - 746) + 1349 + 706) PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel - Left = 642 + Left = 1182 Top = 4 Width = 108 Height = 13 @@ -36,7 +36,7 @@ object FormDebug: TFormDebug ParentFont = False end object Label2: TLabel - Left = 474 + Left = 1014 Top = 2 Width = 131 Height = 18 @@ -50,7 +50,7 @@ object FormDebug: TFormDebug ParentFont = False end object EditNivDebug: TEdit - Left = 754 + Left = 1294 Top = 2 Width = 49 Height = 21 @@ -66,7 +66,7 @@ object FormDebug: TFormDebug OnKeyPress = EditNivDebugKeyPress end object MemoEvtDet: TMemo - Left = 570 + Left = 1110 Top = 336 Width = 239 Height = 201 @@ -87,7 +87,7 @@ object FormDebug: TFormDebug OnChange = MemoEvtDetChange end object ButtonEcrLog: TButton - Left = 466 + Left = 1006 Top = 328 Width = 97 Height = 29 @@ -97,7 +97,7 @@ object FormDebug: TFormDebug OnClick = ButtonEcrLogClick end object ButtonRazTampon: TButton - Left = 466 + Left = 1006 Top = 360 Width = 97 Height = 33 @@ -108,7 +108,7 @@ object FormDebug: TFormDebug OnClick = ButtonRazTamponClick end object ButtonCherche: TButton - Left = 466 + Left = 1006 Top = 296 Width = 97 Height = 25 @@ -118,7 +118,7 @@ object FormDebug: TFormDebug OnClick = ButtonChercheClick end object ButtonAffEvtChrono: TButton - Left = 466 + Left = 1006 Top = 256 Width = 97 Height = 33 @@ -129,7 +129,7 @@ object FormDebug: TFormDebug OnClick = ButtonAffEvtChronoClick end object ButtonCop: TButton - Left = 466 + Left = 1006 Top = 208 Width = 97 Height = 41 @@ -146,7 +146,7 @@ object FormDebug: TFormDebug OnClick = ButtonCopClick end object RichEdit: TRichEdit - Left = 570 + Left = 1110 Top = 176 Width = 239 Height = 153 @@ -165,7 +165,7 @@ object FormDebug: TFormDebug OnChange = RichEditChange end object ButtonRazLog: TButton - Left = 466 + Left = 1006 Top = 400 Width = 97 Height = 33 @@ -176,7 +176,7 @@ object FormDebug: TFormDebug OnClick = ButtonRazLogClick end object GroupBox1: TGroupBox - Left = 464 + Left = 1004 Top = 608 Width = 345 Height = 177 @@ -247,7 +247,7 @@ object FormDebug: TFormDebug ShowHint = True TabOrder = 2 end - object Button1: TButton + object ButtonCP: TButton Left = 128 Top = 16 Width = 81 @@ -255,7 +255,7 @@ object FormDebug: TFormDebug Caption = 'Etat 3 cantons pr'#233'c'#233'dents signal' TabOrder = 3 WordWrap = True - OnClick = Button1Click + OnClick = ButtonCPClick end object Button2: TButton Left = 208 @@ -324,7 +324,7 @@ object FormDebug: TFormDebug end end object GroupBox2: TGroupBox - Left = 464 + Left = 1004 Top = 20 Width = 345 Height = 149 @@ -357,9 +357,9 @@ object FormDebug: TFormDebug object CheckBoxEvtDetAig: TCheckBox Left = 8 Top = 32 - Width = 201 + Width = 289 Height = 17 - Caption = 'Ev'#232'nements d'#233'tecteurs et aiguillages' + Caption = 'Ev'#232'nements d'#233'tecteurs, aiguillages et actionneurs' Font.Charset = DEFAULT_CHARSET Font.Color = clBlack Font.Height = -11 @@ -399,21 +399,6 @@ object FormDebug: TFormDebug TabOrder = 3 OnClick = CheckTrameClick end - object CheckBoxAct: TCheckBox - Left = 8 - Top = 48 - Width = 153 - Height = 17 - Caption = 'Ev'#232'vements actionneurs' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlack - Font.Height = -11 - Font.Name = 'MS Sans Serif' - Font.Style = [] - ParentFont = False - TabOrder = 4 - OnClick = CheckBoxActClick - end object CheckBoxAffFD: TCheckBox Left = 8 Top = 112 @@ -428,7 +413,7 @@ object FormDebug: TFormDebug Font.Style = [] ParentColor = False ParentFont = False - TabOrder = 5 + TabOrder = 4 OnClick = CheckBoxAffFDClick end object CheckBoxAffDebDecSig: TCheckBox @@ -443,7 +428,7 @@ object FormDebug: TFormDebug Font.Name = 'MS Sans Serif' Font.Style = [] ParentFont = False - TabOrder = 6 + TabOrder = 5 OnClick = CheckBoxAffDebDecSigClick end object EditDebugSignal: TEdit @@ -456,7 +441,7 @@ object FormDebug: TFormDebug 'ignaux' ParentShowHint = False ShowHint = True - TabOrder = 7 + TabOrder = 6 OnChange = EditDebugSignalChange end object CheckBoxTiers: TCheckBox @@ -476,11 +461,11 @@ object FormDebug: TFormDebug ParentFont = False ParentShowHint = False ShowHint = True - TabOrder = 8 + TabOrder = 7 OnClick = CheckBoxTiersClick end object CheckBox1: TCheckBox - Left = 160 + Left = 8 Top = 48 Width = 177 Height = 17 @@ -491,7 +476,7 @@ object FormDebug: TFormDebug Font.Name = 'MS Sans Serif' Font.Style = [] ParentFont = False - TabOrder = 9 + TabOrder = 8 OnClick = CheckBox1Click end object CheckDebugTCO: TCheckBox @@ -506,15 +491,15 @@ object FormDebug: TFormDebug Font.Name = 'MS Sans Serif' Font.Style = [] ParentFont = False - TabOrder = 10 + TabOrder = 9 OnClick = CheckDebugTCOClick end end object RichDebug: TRichEdit Left = 0 Top = 0 - Width = 457 - Height = 737 + Width = 997 + Height = 697 Anchors = [akLeft, akTop, akRight, akBottom] Lines.Strings = ( 'RichDebug') @@ -525,7 +510,7 @@ object FormDebug: TFormDebug OnChange = RichDebugChange end object GroupBox5: TGroupBox - Left = 464 + Left = 1004 Top = 544 Width = 345 Height = 57 @@ -592,12 +577,17 @@ object FormDebug: TFormDebug end end object ButtonRazTout: TButton - Left = 467 + Left = 1007 Top = 176 Width = 97 Height = 25 + Hint = + 'Supprime les trains d'#233'tect'#233's ou en cas de nouveau RUN, permet de' + + ' partir de 0' Anchors = [akTop, akRight] Caption = 'RAZ tous trains' + ParentShowHint = False + ShowHint = True TabOrder = 13 OnClick = ButtonRazToutClick end diff --git a/UnitDebug.pas b/UnitDebug.pas index a1d23ab..8a30df8 100644 --- a/UnitDebug.pas +++ b/UnitDebug.pas @@ -28,7 +28,6 @@ type CheckBoxEvtDetAig: TCheckBox; CheckBoxTraceLIste: TCheckBox; CheckTrame: TCheckBox; - CheckBoxAct: TCheckBox; CheckBoxAffFD: TCheckBox; CheckBoxAffDebDecSig: TCheckBox; GroupBox3: TGroupBox; @@ -40,7 +39,7 @@ type ButtonDetSuiv: TButton; EditPrec: TEdit; EditActuel: TEdit; - Button1: TButton; + ButtonCP: TButton; Button2: TButton; RichDebug: TRichEdit; PopupMenuRD: TPopupMenu; @@ -69,14 +68,13 @@ type procedure ButtonCopClick(Sender: TObject); procedure copier1Click(Sender: TObject); procedure ButtonRazLogClick(Sender: TObject); - procedure CheckBoxActClick(Sender: TObject); procedure CheckBoxEvtDetAigClick(Sender: TObject); procedure CheckBoxAffFDClick(Sender: TObject); procedure CheckBoxAffDebDecSigClick(Sender: TObject); procedure ButtonSigSuivClick(Sender: TObject); procedure ButtonDetSuivClick(Sender: TObject); procedure ButtonCanSuivSigClick(Sender: TObject); - procedure Button1Click(Sender: TObject); + procedure ButtonCPClick(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Copier2Click(Sender: TObject); procedure RichDebugChange(Sender: TObject); @@ -98,9 +96,6 @@ type { Déclarations publiques } end; -Const -Max_Event_det_tick=30000; - var FormDebug: TFormDebug; NivDebug,signalDebug : integer; @@ -108,21 +103,10 @@ var N_event_det : integer; // index du dernier évènement (de 1 à 20) N_Event_tick : integer ; // dernier index - // tableau des évènements détecteurs et aiguillages - event_det_tick : array[0..Max_Event_det_tick] of - record - tick : longint; - detecteur : integer ; - Aiguillage : integer ; - actionneur : integer; - objet : integer; // numéro d'objet dans CDM - etat : integer ; // état du détecteur de l'aiguillage ou de l'actionneur - traite : boolean; // traité lors de a recherche d'une route - end; + procedure AfficheDebug(s : string;lacouleur : TColor); -Procedure Raz_tout; procedure RE_ColorLine(ARichEdit: TRichEdit; ARow: Integer; AColor: TColor); implementation @@ -148,21 +132,10 @@ begin begin Lines.add(s); RE_ColorLine(FormDebug.RichDebug,FormDebug.RichDebug.lines.count-1,lacouleur); - end; + end; end; -Procedure Raz_tout; -var i : integer; -begin - N_Event_tick:=0; - N_event_det:=0; - N_trains:=0; - Formprinc.LabelNbTrains.caption:=IntToSTR(N_trains); - for i:=1 to Max_Trains do Event_det_Train[i].NbEl:=0; - i_simule:=0; - FormDebug.MemoEvtDet.Clear; - FormDebug.Richedit.Clear; -end; + procedure TFormDebug.FormCreate(Sender: TObject); var s: string; @@ -238,23 +211,27 @@ begin end; procedure TFormDebug.ButtonChercheClick(Sender: TObject); -var i : integer; +var ligne,l,position : integer; + s : string; trouve : boolean; begin - with RichDebug do begin - i:=0; + ligne:=0; + l:=0; repeat - trouve:=pos('erreur',uppercase(Lines[i]))<>0; - inc(i); - until (i>=Lines.Count) or trouve; + s:=lowercase(Lines[ligne]); + l:=l+length(s)+2; + position:=pos('erreur',s); + trouve:=position<>0; + inc(ligne); + until (ligne>=Lines.Count) or trouve; if trouve then begin - Affiche('trouvé en '+intToSTR(i),clyellow); - SelStart := I - 1; - SelLength := Length('erreur'); - SetFocus; + //Affiche('trouvé en '+intToSTR(ligne),clyellow); + SelStart:= l-length(s)+position-3; + SelLength:=6; + SetFocus; end; end; end; @@ -262,6 +239,7 @@ end; procedure TFormDebug.ButtonAffEvtChronoClick(Sender: TObject); var i,j,etat : integer; s : string; + typ : Tequipement; begin RichDebug.Clear; if N_event_tick=0 then @@ -276,21 +254,19 @@ begin begin begin - j:=event_det_tick[i].detecteur; + j:=event_det_tick[i].adresse; etat:=event_det_tick[i].etat; if j<>-1 then begin - s:=IntToSTR(i)+' Tick='+IntToSTR(event_det_tick[i].tick)+' Det='+IntToSTR(j)+'='+intToSTR(etat); + s:=IntToSTR(i)+' Tick='+IntToSTR(event_det_tick[i].tick); + typ:=event_det_tick[i].modele; + if typ=det then s:=s+' Det='; + if typ=aig then s:=s+' Aig='; + if typ=act then s:=s+' Act='; + s:=s+IntToSTR(j)+'='+intToSTR(etat); AfficheDebug(s,clyellow); end; end; - - j:=event_det_tick[i].aiguillage; - if j<>-1 then - begin - s:=IntToSTR(i)+' Tick='+IntToSTR(event_det_tick[i].tick)+' Aig='+IntToSTR(j)+'='+intToSTR(event_det_tick[i].etat); - AfficheDebug(s,clyellow); - end; end; AfficheDebug('-----------------------------',cllime); end; @@ -324,11 +300,6 @@ begin RichDebug.Clear; end; -procedure TFormDebug.CheckBoxActClick(Sender: TObject); -begin - AffActionneur:=CheckBoxAct.Checked; -end; - procedure TFormDebug.CheckBoxEvtDetAigClick(Sender: TObject); begin AffAigDet:=CheckBoxEvtDetAig.checked; @@ -388,7 +359,7 @@ end; -procedure TFormDebug.Button1Click(Sender: TObject); +procedure TFormDebug.ButtonCPClick(Sender: TObject); var Adr,erreur,ancdebug : integer ; begin Val(EditSigSuiv.Text,Adr,erreur); if erreur<>0 then exit; diff --git a/UnitPilote.dcu b/UnitPilote.dcu index 6b58c1c..f2e544a 100644 Binary files a/UnitPilote.dcu and b/UnitPilote.dcu differ diff --git a/UnitPrinc.dcu b/UnitPrinc.dcu index 7f9d422..48ef4cb 100644 Binary files a/UnitPrinc.dcu and b/UnitPrinc.dcu differ diff --git a/UnitPrinc.dfm b/UnitPrinc.dfm index 32354e7..dd40240 100644 --- a/UnitPrinc.dfm +++ b/UnitPrinc.dfm @@ -1,6 +1,6 @@ object FormPrinc: TFormPrinc - Left = 10 - Top = 259 + Left = 6 + Top = 246 Width = 1213 Height = 664 Caption = 'Client TCP-IP CDM Rail ou USB - syst'#232'me LENZ' @@ -1284,7 +1284,7 @@ object FormPrinc: TFormPrinc Left = 904 Top = 5 Width = 282 - Height = 132 + Height = 92 Anchors = [akTop, akRight] TabOrder = 4 object BoutonRaf: TButton @@ -1299,66 +1299,24 @@ object FormPrinc: TFormPrinc TabOrder = 0 OnClick = BoutonRafClick end - object BoutVersion: TButton - Left = 102 - Top = 8 - Width = 83 - Height = 33 - Hint = 'Demande la version XpressNet '#224' la centrale' - Caption = 'Dem version centrale' - TabOrder = 1 - WordWrap = True - OnClick = BoutVersionClick - end - object ButtonInfo: TButton - Left = 104 - Top = 48 - Width = 81 - Height = 33 - Caption = 'Informations' - TabOrder = 2 - OnClick = ButtonInfoClick - end - object ButtonReprise: TButton - Left = 190 - Top = 48 - Width = 83 - Height = 33 - Hint = - 'Relance du bus DCC apr'#232's une '#233'criture d'#39'un CV ou une mise hors t' + - 'ension de la centrale' - Caption = 'Reprise DCC' - TabOrder = 3 - OnClick = ButtonRepriseClick - end - object ButtonTest: TButton - Left = 8 - Top = 48 - Width = 89 - Height = 33 - Caption = 'Demande '#233'tat aiguillages' - TabOrder = 4 - WordWrap = True - OnClick = ButtonTestClick - end object ButtonArretSimu: TButton Left = 8 - Top = 88 + Top = 48 Width = 89 Height = 33 Caption = 'Arret simulation' - TabOrder = 5 + TabOrder = 1 Visible = False WordWrap = True OnClick = ButtonArretSimuClick end object ButtonAffTCO: TButton Left = 104 - Top = 88 + Top = 48 Width = 81 Height = 33 Caption = 'Affiche TCO' - TabOrder = 6 + TabOrder = 2 OnClick = ButtonAffTCOClick end object ButtonLanceCDM: TButton @@ -1368,22 +1326,36 @@ object FormPrinc: TFormPrinc Height = 33 Hint = 'Lance CDM Rail' Caption = 'Lance CDM rail' - TabOrder = 7 + TabOrder = 3 OnClick = ButtonLanceCDMClick end object ButtonLocCV: TButton - Left = 192 - Top = 88 + Left = 104 + Top = 8 Width = 83 Height = 33 + Hint = 'Affichage du panneau de contr'#244'le des trains ou des CV' Caption = 'Trains / CVs' - TabOrder = 8 + TabOrder = 4 OnClick = ButtonLocCVClick end + object BoutonRazTrains: TButton + Left = 192 + Top = 48 + Width = 81 + Height = 33 + Hint = + 'Supprime les trains d'#233'tect'#233's ou en cas de nouveau RUN, permet de' + + ' partir de 0' + Caption = 'Raz trains ou nouveau RUN' + TabOrder = 5 + WordWrap = True + OnClick = BoutonRazTrainsClick + end end object Panel2: TPanel Left = 905 - Top = 144 + Top = 104 Width = 281 Height = 25 Anchors = [akTop, akRight] @@ -1421,7 +1393,7 @@ object FormPrinc: TFormPrinc object FenRich: TRichEdit Left = 8 Top = 32 - Width = 618 + Width = 601 Height = 529 Anchors = [akLeft, akTop, akRight, akBottom] Color = clBlack @@ -1640,6 +1612,10 @@ object FormPrinc: TFormPrinc Caption = 'Etat des signaux' OnClick = Etatdessignaux1Click end + object Etatdeszonespartrain1: TMenuItem + Caption = 'Etat des zones par train' + OnClick = Etatdeszonespartrain1Click + end object N3: TMenuItem Caption = '-' end @@ -1691,6 +1667,27 @@ object FormPrinc: TFormPrinc object N4: TMenuItem Caption = '-' end + object Demanderversiondelacentrale1: TMenuItem + Caption = 'Interface XpressNet:' + object Demanderlaversiondelacentrale1: TMenuItem + Caption = 'Demander la version de la centrale' + OnClick = Demanderlaversiondelacentrale1Click + end + object Demandetatdesaiguillages1: TMenuItem + Caption = 'Demande '#233'tat des aiguillages' + OnClick = Demandetatdesaiguillages1Click + end + object RepriseDCC1: TMenuItem + Caption = 'Reprise DCC' + Hint = + 'Relance du bus DCC apr'#232's une '#233'criture d'#39'un CV ou une mise hors t' + + 'ension de la centrale' + OnClick = RepriseDCC1Click + end + end + object N7: TMenuItem + Caption = '-' + end object ConnecterCDMrail: TMenuItem Caption = 'Connecter CDM rail' OnClick = ConnecterCDMrailClick diff --git a/UnitPrinc.pas b/UnitPrinc.pas index ff26645..dbe96d5 100644 --- a/UnitPrinc.pas +++ b/UnitPrinc.pas @@ -3,7 +3,7 @@ Unit UnitPrinc; programme signaux complexes Graphique Lenz delphi 7 + activeX Tmscomm + clientSocket ******************************************** - 02/5/2022 23h + 30/5/2022 22h note sur le pilotage des accessoires: raquette octet sortie + 2 = aiguillage droit = sortie 2 de l'adresse d'accessoire @@ -71,10 +71,6 @@ type OuvrirunfichiertramesCDM1: TMenuItem; Panel1: TPanel; BoutonRaf: TButton; - BoutVersion: TButton; - ButtonInfo: TButton; - ButtonReprise: TButton; - ButtonTest: TButton; ButtonArretSimu: TButton; ButtonDroit: TButton; Panel2: TPanel; @@ -117,11 +113,17 @@ type EditFonc01: TEdit; Label6: TLabel; Button1: TButton; + Etatdeszonespartrain1: TMenuItem; + N7: TMenuItem; + Demanderversiondelacentrale1: TMenuItem; + Demanderlaversiondelacentrale1: TMenuItem; + Demandetatdesaiguillages1: TMenuItem; + RepriseDCC1: TMenuItem; + BoutonRazTrains: TButton; procedure FormCreate(Sender: TObject); procedure MSCommUSBLenzComm(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Timer1Timer(Sender: TObject); - procedure BoutVersionClick(Sender: TObject); procedure ButtonDroitClick(Sender: TObject); procedure EditvalEnter(Sender: TObject); procedure BoutonRafClick(Sender: TObject); @@ -129,7 +131,6 @@ type ErrorEvent: TErrorEvent; var ErrorCode: Integer); procedure ClientSocketLenzRead(Sender: TObject; Socket: TCustomWinSocket); procedure ButtonTestClick(Sender: TObject); - procedure ButtonInfoClick(Sender: TObject); procedure MenuConnecterUSBClick(Sender: TObject); procedure DeconnecterUSBClick(Sender: TObject); procedure MenuConnecterEthernetClick(Sender: TObject); @@ -156,7 +157,6 @@ type Socket: TCustomWinSocket); procedure FichierSimuClick(Sender: TObject); procedure ButtonEcrCVClick(Sender: TObject); - procedure ButtonRepriseClick(Sender: TObject); procedure LireunfichierdeCV1Click(Sender: TObject); procedure Quitter1Click(Sender: TObject); procedure ConfigClick(Sender: TObject); @@ -181,6 +181,11 @@ type procedure ButtonFonctionClick(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); + procedure Etatdeszonespartrain1Click(Sender: TObject); + procedure Demanderlaversiondelacentrale1Click(Sender: TObject); + procedure Demandetatdesaiguillages1Click(Sender: TObject); + procedure RepriseDCC1Click(Sender: TObject); + procedure BoutonRazTrainsClick(Sender: TObject); private { Déclarations privées } procedure DoHint(Sender : Tobject); @@ -193,7 +198,6 @@ type const titre='Signaux complexes GL '; -espY = 15; // espacement Y entre deux lignes de feux MaxAcc=2048; // adresse maxi d'accessoire XpressNet NbMaxDet=100; // nombre maximal de détecteurs d'un réseau NbMemZone=2048; // adresse maximale des détecteurs @@ -202,6 +206,7 @@ Max_event_det=400; MaxBranches=100; MaxElBranches=200; LargImg=50;HtImg=91; // Dimensions image des feux +espY=15; // espacement Y entre deux lignes de feux const_droit=2; // positions aiguillages transmises par la centrale LENZ const_devie=1; // positions aiguillages transmises par la centrale LENZ const_devieG_CDM=3; // positions aiguillages transmises par cdm @@ -216,7 +221,7 @@ GrisF=$414141; clOrange=$0077FF; couleurTrain : array[1..NbCouleurTrain] of Tcolor = (clYellow,clLime,clOrange,clAqua,clFuchsia,clLtGray,clred,clWhite); Max_Simule=10000; - +Max_Event_det_tick=30000; EtatSign : array[0..13] of string[20] =('carré','sémaphore','sémaphore cli','vert','vert cli','violet', 'blanc','blanc cli','jaune','jaune cli','ral 30','ral 60','rappel 30','rappel 60'); NbDecodeur = 8; @@ -228,14 +233,14 @@ Etats : array[0..19] of string[30]=('Non command type Taccessoire = (aigP,feu); // aiguillage ou feu TMA = (valide,devalide); -TEquipement = (rien,aig,tjd,tjs,triple,det,buttoir,voie,crois); // voie uniquement pour le tco +TEquipement = (rien,aig,tjd,tjs,triple,det,buttoir,voie,crois,act); // voie uniquement pour le tco TBranche = record BType : Tequipement ; // ne prend que les valeurs suivantes: dét aig Buttoir Adresse : integer ; // adresse du détecteur ou de l'aiguillage end; Taiguillage = record - Adresse : integer; // adresse d'accessoire + Adresse : integer; // adresse de l'aiguillage modele : TEquipement; // rien, aig, tjd ... position, // position actuelle : 1=dévié 2=droit (centrale LENZ) posInit, // position d'initialisation 1=dévié 2=droit 9=non positionné @@ -273,16 +278,16 @@ Taiguillage = record end; TFeu = record - adresse, aspect : integer; // adresse du feu, aspect (2 feux..9 feux 12=direction 2 feux .. 16=direction 6 feux) - Img : TImage; // Pointeur sur structure TImage du feu - Lbl : TLabel; // pointeur sur structure Tlabel du feu - check : TCheckBox; // pointeur sur structure Checkbox "demande feu blanc" - FeuBlanc : boolean ; // avec checkbox ou pas - decodeur : integer; // type du décodeur // 'rien','Digital Bahn','CDF','LDT','LEB','NMRA','Unisemaf','SR' - Adr_det1 : integer; // adresse du détecteur1 sur lequel il est implanté - Adr_det2 : integer; // adresse du détecteur2 sur lequel il est implanté (si un signal est pour plusieurs voies) - Adr_det3 : integer; // adresse du détecteur3 sur lequel il est implanté (si un signal est pour plusieurs voies) - Adr_det4 : integer; // adresse du détecteur4 sur lequel il est implanté (si un signal est pour plusieurs voies) + adresse, aspect : integer; // adresse du feu, aspect (2 feux..9 feux 12=direction 2 feux .. 16=direction 6 feux) + Img : TImage; // Pointeur sur structure TImage du feu + Lbl : TLabel; // pointeur sur structure Tlabel du feu + check : TCheckBox; // pointeur sur structure Checkbox "demande feu blanc" + FeuBlanc : boolean ; // avec checkbox ou pas + decodeur : integer; // type du décodeur // 'rien','Digital Bahn','CDF','LDT','LEB','NMRA','Unisemaf','SR' + Adr_det1 : integer; // adresse du détecteur1 sur lequel il est implanté + Adr_det2 : integer; // adresse du détecteur2 sur lequel il est implanté (si un signal est pour plusieurs voies) + Adr_det3 : integer; // adresse du détecteur3 sur lequel il est implanté (si un signal est pour plusieurs voies) + Adr_det4 : integer; // adresse du détecteur4 sur lequel il est implanté (si un signal est pour plusieurs voies) Adr_el_suiv1 : integer; // adresse de l'élément1 suivant Adr_el_suiv2 : integer; // adresse de l'élément2 suivant (si un signal est pour plusieurs voies) Adr_el_suiv3 : integer; // adresse de l'élément3 suivant (si un signal est pour plusieurs voies) @@ -293,8 +298,8 @@ TFeu = record Btype_suiv4 : TEquipement ; // VerrouCarre : boolean ; // si vrai, le feu se verrouille au carré si pas de train avant le signal modifie : boolean; // feu modifié - EtatSignal : word ; // - AncienEtat : word ; + EtatSignal : word ; // état du signal + AncienEtat : word ; // ancien état du signal UniSemaf : integer ; // définition supplémentaire de la cible pour les décodeurs UNISEMAF AigDirection : array[1..6] of array of record // pour les signaux directionnels : contient la liste des aiguillages associés Adresse : integer; // 6 feux max associés à un tableau dynamique décrivant les aiguillages @@ -318,13 +323,13 @@ var ServeurRetroCDM,TailleFonte,Nb_Det_Dist,Tdoubleclic,algo_Unisemaf,fA,fB,AdrTrain : integer; Hors_tension2,traceSign,TraceZone,Ferme,parSocketLenz,ackCdm,PremierFD,doubleclic, - NackCDM,MsgSim,succes,recu_cv,AffActionneur,AffAigDet,Option_demarrage,AffTiers, + NackCDM,MsgSim,succes,recu_cv,AffAigDet,Option_demarrage,AffTiers, TraceListe,clignotant,nack,Maj_feux_cours,configNulle,LanceCDM,AvecInitAiguillages : boolean; CDMhd : THandle; FormPrinc: TFormPrinc; - ack,portCommOuvert,traceTrames,AffMem,AfficheDet,CDM_connecte,dupliqueEvt, + ack,portCommOuvert,traceTrames,AffMem,CDM_connecte,dupliqueEvt, Raz_Acc_signaux,AvecInit,AvecTCO,terminal,Srvc_Aig,Srvc_Det,Srvc_Act,MasqueBandeauTCO, Srvc_PosTrain,Srvc_Sig,debugtrames : boolean; tablo : array of byte; // tableau rx usb @@ -336,14 +341,42 @@ var Ancien_detecteur : array[0..NbMemZone] of boolean; // anciens état des détecteurs et adresses des détecteurs et leur état detecteur : array[0..NbMemZone] of record - etat : boolean; - tempo : integer; - train : string; + etat : boolean; + tempo : integer; + train : string; end; TypeGen : TEquipement; Adresse_detecteur : array[0..NbMaxDet] of integer; // adresses des détecteurs par index + // Historique des zones d'occupation par train + TrainZone : array[1..20] of // train, index + record + Nbre : integer; // nombre de zones (ci dessous) + Zone : array[1..200] of record det1,det2 : integer; end; + end; + + // tableau des évènements détecteurs , aiguillages, actionneurs + event_det_tick : array[0..Max_Event_det_tick] of + record + tick : longint; + adresse : integer ; + modele : Tequipement ; // détecteur, aiguillage, actionneur + etat : integer ; // état du détecteur de l'aiguillage ou de l'actionneur + traite : boolean; // traité lors de a recherche d'une route + end; + + // tableau des croisement rencontrés par la fonction suivant_alg3 + croisement : array[1..10] of + record + adresse,entree,sortie : integer; + end; + ncrois : integer; + + // Prévision des zones suivantes (en fonction de la position aiguillages) + TrainPrevZone : array[1..20] of array[1..5] of integer; + + // Zones d'occupations actuelles MemZone : array[0..NbMemZone,0..NbMemZone] of boolean ; // mémoires de zones des détecteurs Tablo_actionneur : array[1..100] of @@ -374,7 +407,8 @@ var Tablo_Simule : array[0..Max_Simule] of record tick : longint; - Detecteur,Aiguillage,etat : integer ; + modele : Tequipement; + Adresse,etat : integer ; end; N_Cv,index_simule,NDetecteurs,N_Trains,N_routes : integer; tablo_CV : array [1..255] of integer; @@ -394,7 +428,6 @@ var event_det : array[1..Max_event_det] of integer; event_det_train : array[1..Max_Trains] of record NbEl : integer; - prev : integer; Det : array[1..3] of integer; // tableau des evts détecteurs par train end; Feu_supprime,Feu_sauve : Tfeu; @@ -444,8 +477,9 @@ function Select_dessin_feu(TypeFeu : integer) : TBitmap; procedure cree_image(rang : integer); procedure trouve_aiguillage(adresse : integer); procedure trouve_detecteur(detecteur : integer); -function BTypeToNum(BT : TEquipement) : integer; +function BTypeToNum(BT : TEquipement) : string; function ProcessRunning(sExeName: String) : Boolean; +Procedure Raz_tout; implementation @@ -566,7 +600,7 @@ end; // dessine les feux sur une cible à 2 feux dans le canvas spécifié // x,y : offset en pixels du coin supérieur gauche du feu -// frX, frY : facteurs de réduction (pour agrandisseent) +// frX, frY : facteurs de réduction (pour agrandissement) procedure dessine_feu2(Acanvas : Tcanvas;x,y : integer;frX,frY : real;EtatSignal : word;orientation : integer); var Temp,rayon,xViolet,YViolet,xBlanc,yBlanc, LgImage,HtImage : integer; @@ -1201,14 +1235,21 @@ begin end; // transforme le type TEquipement en valeur numérique -function BTypeToNum(BT : TEquipement) : integer; -begin +// rien,aig,tjd,tjs,triple,det,buttoir,voie,crois,act +function BTypeToNum(BT : TEquipement) : string; +begin case BT of - det : result:=1; - aig : result:=2; - voie : result:=3; - buttoir : result:=4; - else result:=0; + rien : result:='rien'; + det : result:='det'; + aig : result:='aig'; + voie : result:='voie'; + buttoir : result:='buttoir'; + triple : result:='triple'; + tjd : result:='tjd'; + tjs : result:='tjs'; + crois : result:='crois'; + act : result:='act'; + else result:='???'; end; end; @@ -1410,7 +1451,7 @@ begin if feux[rang].FeuBlanc then begin Feux[rang].check:=TCheckBox.create(Formprinc.ScrollBox1); // ranger l'adresse de la Checkbox dans la structure du feu - Feux[rang].check.onClick:=formprinc.proc_checkBoxFB; // affecter l'adresse de la procédure de traitement quand on clique dessus + Feux[rang].check.onClick:=formprinc.proc_checkBoxFB; // affecter l'adresse de la procédure de traitement quand on clique dessus Feux[rang].check.Hint:=intToSTR(adresse); // affecter l'adresse du feu dans le HINT pour pouvoir le retrouver plus tard with Feux[rang].Check do @@ -3106,7 +3147,7 @@ end; // trouve un élément dans les branches à partir de la branche offset renvoie branche_trouve IndexBranche_trouve -// el : adresse de l'élément TypeEL=(1=détécteur 2=aig 3=aig Bis 4=aig triple) +// el : adresse de l'élément TypeEL=(1=détécteur 2=aig 3=aig Bis 4=aig triple - Buttoir) procedure trouve_element(el: integer; TypeEl : TEquipement; Offset : integer); var i,adr,Branche : integer ; s : string; @@ -3122,17 +3163,18 @@ begin Bt:=BrancheN[Branche,i].BType; if ((adr=0) and (Bt=rien)) then begin inc(Branche);i:=0;end; inc(i); - sort:=(Branche>NbreBranches) or ((adr=el) and (TypeEL=Bt)); + sort:=(Branche>NbreBranches) or ((adr=el) and (TypeEL=Bt)); until (sort); if (adr=el) then begin branche_trouve:=Branche; IndexBranche_trouve:=i-1; end - else begin s:='Erreur 175 - élément '+intToSTR(el); - s:=s+' non trouvé';Affiche(s,clred); - branche_trouve:=0; IndexBranche_trouve:=0; - if NivDebug>=1 then AfficheDebug(s,clred); + else begin s:='Erreur 175 - élément '+intToSTR(el)+' '; + s:=s+BTypeToNum(TypeEl); + s:=s+' non trouvé';Affiche(s,clred); + branche_trouve:=0; IndexBranche_trouve:=0; + if NivDebug>=1 then AfficheDebug(s,clred); end; end; @@ -3274,7 +3316,7 @@ begin end; if (aiguillage[index].modele=aig) and (Bt=aig) then // aiguillage normal begin - // aiguillage pris en pointe + // aiguillage index (adr) pris en pointe if (aiguillage[index].Apointe=prec) then begin if aiguillage[index].position=const_droit then @@ -3301,7 +3343,8 @@ begin begin typeGen:=rien; AdrDevie:=Adr; - suivant_alg3:=9997;exit; + suivant_alg3:=9997; + exit; end; if Adr=0 then begin Affiche('134 - Erreur fatale',clRed); @@ -3318,20 +3361,32 @@ begin suivant_alg3:=adr; exit; end; + if aiguillage[index].position=const_inconnu then + begin + s:='134.2 - Aiguillage '+IntToSTR(adr)+' non résolu car position inconnue'; + AfficheDebug(s,clOrange); + Affiche(s,clOrange); + typeGen:=rien; + suivant_alg3:=9996; + exit; + end; end else begin + // aiguillage index (adr) pris en talon if NivDebug=3 then AfficheDebug('135 - aiguillage '+intToSTR(Adr)+' Pris en talon',clyellow); if (alg=2) then // on demande d'arreter si l'aiguillage en talon est mal positionné 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; + md:=aiguillage[index_aig(prec)].modele; + if (md=tjd) or (md=tjs) 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; + suivant_alg3:=9998; + exit; end else begin @@ -3340,10 +3395,14 @@ begin end else begin - if prec<>aiguillage[index].Adevie then // Adevie + // si TJD (modele=2) sur le précédent, alors substituer avec la 2eme adresse de la TJD + md:=aiguillage[index_aig(prec)].modele; + if (md=tjd) or (md=tjs) then prec:=aiguillage[index_aig(prec)].Ddevie; + if prec<>aiguillage[index].Adevie then begin if NivDebug=3 then AfficheDebug('135.3 Aiguillage '+intToSTR(adr)+' mal positionné',clyellow); - suivant_alg3:=9998;exit; + suivant_alg3:=9998; + exit; end else begin @@ -3381,7 +3440,8 @@ begin exit; end; - if (aiguillage[index].modele=tjd) or (aiguillage[index].modele=tjs) then // TJD ou TJS + // TJD ou TJS----------------------------- + if (aiguillage[index].modele=tjd) or (aiguillage[index].modele=tjs) then begin // récupérer les élements de la TJD/S AdrTjdP:=aiguillage[index].Ddroit; // 2eme adresse de la TJD/S @@ -3406,7 +3466,7 @@ begin if NivDebug=3 then begin - s:='137 - TJD '+intToSTR(Adr); + s:='137 - TJD/S '+intToSTR(Adr); if NetatTJD=4 then s:=s+'/'+IntToSTR(AdrTjdP); s:=s+' pos='; if aiguillage[index].position=const_droit then s:=s+'droit' @@ -3436,9 +3496,9 @@ begin ( ((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 + ) then begin - Adr:=aiguillage[index].Adroit; //Ddroit + Adr:=aiguillage[index].Adroit; A:=aiguillage[index].AdroitB; end else @@ -3462,7 +3522,7 @@ begin begin if aiguillage[index].Adroit=prec then begin - Adr:=aiguillage[index].DDroit; //Ddroit + Adr:=aiguillage[index].DDroit; A:=aiguillage[index].DdroitB; end; if aiguillage[index].Adevie=prec then @@ -3528,24 +3588,24 @@ begin end; end; - //---------------TJD 4 états ou TJS + //--------------- 4 états ou TJS if (NetatTJD=4) or tjsC then begin // determiner la position de la première section de la TJD (4 cas) // cas 1 : droit droit if (( aiguillage[index].position=const_droit) and - (aiguillage[index2].position=const_droit) and tjdC) then + (aiguillage[index2].position=const_droit) ) then begin - // d'où vient ton sur la tjd + // d'où vient ton sur la tjs if BtypePrec=Aig then begin 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 + begin if NivDebug=3 then AfficheDebug('TJD/S '+intToSTR(adr)+' bien positionnée cas 1.1',clyellow);end else begin - if (nivdebug>1) or traceliste then AfficheDebug('135.5- TJD '+intToSTR(adr)+' mal positionnée cas 1.1',clyellow); + if (nivdebug>1) or traceliste then AfficheDebug('135.5- TJD/S '+intToSTR(adr)+' mal positionnée cas 1.1',clyellow); if alg=2 then begin suivant_alg3:=9998;exit; @@ -3557,10 +3617,10 @@ begin begin if (aiguillage[index].Adroit)=prec then begin - if NivDebug=3 then AfficheDebug('TJD '+intToSTR(adr)+' bien positionnée cas 1.2',clyellow);end + if NivDebug=3 then AfficheDebug('TJD/S '+intToSTR(adr)+' bien positionnée cas 1.2',clyellow);end else begin - if (nivdebug>1) or traceliste then AfficheDebug('135.6- TJD '+intToSTR(adr)+' mal positionnée cas 1.2',clyellow); + if (nivdebug>1) or traceliste then AfficheDebug('135.6- TJD/S '+intToSTR(adr)+' mal positionnée cas 1.2',clyellow); if alg=2 then begin suivant_alg3:=9998;exit; @@ -3579,11 +3639,11 @@ begin Adr:=aiguillage[index2].Adevie; A:=aiguillage[index2].AdevieB; end; - if NivDebug=3 then AfficheDebug('cas1.1 tjd: '+s+' Adr='+intToSTR(adr)+A,clYellow); + if NivDebug=3 then AfficheDebug('cas1.1 tjd/s: '+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); + if nivDebug=3 then Affichedebug('le port de destination de la tjd/s est '+IntToSTR(adr)+a,clyellow); exit; end; @@ -3597,7 +3657,7 @@ begin 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); + begin if NivDebug=3 then AfficheDebug('TJD/S '+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; @@ -3718,7 +3778,7 @@ begin 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); + if nivDebug=3 then Affichedebug('le port de destination de la tjd est '+IntToSTR(adr)+a,clyellow); exit; end; @@ -3773,7 +3833,7 @@ begin 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); + if nivDebug=3 then Affichedebug('le port de destination de la tjd est '+IntToSTR(adr)+a,clyellow); exit; end; @@ -3787,7 +3847,7 @@ begin 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); + if nivDebug=3 then Affichedebug('le port de destination de la tjd est '+IntToSTR(adr)+a,clyellow); exit; end; @@ -3801,30 +3861,42 @@ begin if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig suivant_alg3:=adr; Actuel:=aiguillage[index2].Adresse; - if nivDebug=3 then Affichedebug('le port de destination de la tjd 4 états est '+IntToSTR(adr)+a,clyellow); + if nivDebug=3 then Affichedebug('le port de destination de la tjd est '+IntToSTR(adr)+a,clyellow); exit; end; - s:='1026 - position TJD/S '+IntToSTR(Adr)+'/'+intToSTR(AdrTJDP)+' inconnue'; - AfficheDebug(s,clOrange); + if (nivdebug>1) or traceliste then + begin + s:='1026 - position TJD/S '+IntToSTR(Adr)+'/'+intToSTR(AdrTJDP)+' inconnue'; + AfficheDebug(s,clOrange); + end; suivant_alg3:=9999;exit; end; end; if (aiguillage[index].modele=crois) then begin - adr:=9999; - if aiguillage[index].Adroit=prec then begin adr:=aiguillage[index].Ddroit;A:=aiguillage[index].DdroitB;end; - if aiguillage[index].Adevie=prec then begin adr:=aiguillage[index].Ddevie;A:=aiguillage[index].DdevieB;end; - if aiguillage[index].Ddevie=prec then begin adr:=aiguillage[index].Adevie;A:=aiguillage[index].AdevieB;end; - if aiguillage[index].Ddroit=prec then begin adr:=aiguillage[index].Adroit;A:=aiguillage[index].AdroitB;end; + adr:=9999; + if aiguillage[index].Adroit=prec then begin adr:=aiguillage[index].Ddroit;A:=aiguillage[index].DdroitB;end; + if aiguillage[index].Adevie=prec then begin adr:=aiguillage[index].Ddevie;A:=aiguillage[index].DdevieB;end; + if aiguillage[index].Ddevie=prec then begin adr:=aiguillage[index].Adevie;A:=aiguillage[index].AdevieB;end; + if aiguillage[index].Ddroit=prec then begin adr:=aiguillage[index].Adroit;A:=aiguillage[index].AdroitB;end; - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig) - suivant_alg3:=adr; - if a='' then a:=' '; - if nivDebug=3 then Affichedebug('le port de destination du croisement est '+IntToSTR(adr)+a,clyellow); - exit; + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig) + suivant_alg3:=adr; + if a='' then a:=' '; + if (nivdebug>1) or traceliste then Affichedebug('le port de destination du croisement est '+IntToSTR(adr)+a,clyellow); + + // mémoriser dans un tableau l'entrée et la sortie du croisement + if ncrois<10 then + begin + inc(ncrois); + croisement[ncrois].adresse:=aiguillage[index].adresse; + croisement[ncrois].entree:=prec; + croisement[ncrois].sortie:=adr; + end; + exit; end; - + if (aiguillage[index].modele=triple) then // aiguillage triple begin Adr2:=aiguillage[index].AdrTriple; @@ -3832,17 +3904,17 @@ begin begin // aiguillage triple pris en pointe //Affiche('position='+intToSTR(aiguillage[index_aig(Adr].position),clyellow); - if (aiguillage[index].position=const_droit) and (aiguillage[index_aig(Adr2)].position=const_droit) then + if (aiguillage[index].position=const_droit) and (aiguillage[index_aig(Adr2)].position=const_droit) then begin if NivDebug=3 then AfficheDebug('Aiguillage triple pris en pointe droit',clYellow); A:=aiguillage[index].AdroitB; Adr:=aiguillage[index].Adroit; - 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 (aiguillage[index].position<>const_droit) and (aiguillage[index_aig(Adr2)].position=const_droit) then + if (aiguillage[index].position<>const_droit) and (aiguillage[index_aig(Adr2)].position=const_droit) then begin if NivDebug=3 then AfficheDebug('Aiguillage triple dévié1 (à gauche)',clYellow); A:=aiguillage[index].AdevieB; @@ -3852,7 +3924,7 @@ begin typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].BType; suivant_alg3:=adr;exit; end; - if (aiguillage[index].position=const_droit) and (aiguillage[index_aig(Adr2)].position<>const_droit) then + if (aiguillage[index].position=const_droit) and (aiguillage[index_aig(Adr2)].position<>const_droit) then begin if NivDebug=3 then AfficheDebug('Aiguillage triple dévié2 (à droite)',clYellow); A:=aiguillage[index].Adevie2B; @@ -3860,17 +3932,16 @@ 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; - end; - begin - if aiguillage[index].position=const_inconnu then begin suivant_alg3:=9996;exit;end; // pour échappement - s:='Aiguillage triple '+IntToSTR(Adr)+' : configuration des aiguilles interdite'; - if CDM_connecte then s:=s+': '+IntToSTR(aiguillage[index].position); - AfficheDebug(s,clYellow); - Affiche(s,clRed); - suivant_alg3:=9999; + suivant_alg3:=adr; exit; end; + if aiguillage[index].position=const_inconnu then begin suivant_alg3:=9996;exit;end; // pour échappement + s:='Aiguillage triple '+IntToSTR(Adr)+' : configuration des aiguilles interdite'; + if CDM_connecte then s:=s+': '+IntToSTR(aiguillage[index].position); + AfficheDebug(s,clYellow); + Affiche(s,clRed); + suivant_alg3:=9999; + exit; end else begin @@ -3882,7 +3953,8 @@ begin if prec<>aiguillage[index].Adroit then begin if (nivdebug>1) or traceliste then AfficheDebug('135.3 - Aiguillage '+intToSTR(adr)+'triple mal positionné',clyellow); - suivant_alg3:=9998;exit; + suivant_alg3:=9998; + exit; end else begin @@ -3894,7 +3966,8 @@ begin if prec<>aiguillage[index].Adevie then begin if (nivdebug>1) or traceliste then AfficheDebug('135.3 - Aiguillage '+intToSTR(adr)+'triple mal positionné',clyellow); - suivant_alg3:=9998;exit; + suivant_alg3:=9998; + exit; end else begin @@ -3906,7 +3979,8 @@ begin if prec<>aiguillage[index].Adevie2 then begin if (nivdebug>1) or traceliste then AfficheDebug('135.3 - Aiguillage '+intToSTR(adr)+'triple mal positionné',clyellow); - suivant_alg3:=9998;exit; + suivant_alg3:=9998; + exit; end else begin @@ -3919,7 +3993,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; end; @@ -3945,7 +4020,6 @@ begin trouve3:=feux[i].Adr_det3=adr; trouve4:=feux[i].Adr_det4=adr; - if trouve1 or trouve2 or trouve3 or trouve4 then begin inc(trouve); @@ -3974,8 +4048,8 @@ var actuelCalc,PrecCalc,j,AdrSuiv ,indexCalc : integer; TypeprecCalc,TypeActuelCalc : TEquipement; begin if NivDebug>=2 then - AfficheDebug('Proc Detecteur_suivant '+IntToSTR(prec)+','+IntToSTR(BTypeToNum(typeElPrec))+'/'+intToSTR(actuel)+','+ - intToSTR(BTypeToNum(TypeElActuel))+ + AfficheDebug('Proc Detecteur_suivant '+IntToSTR(prec)+','+BTypeToNum(typeElPrec)+'/'+intToSTR(actuel)+','+ + BTypeToNum(TypeElActuel)+ ' Alg='+IntToSTR(algo),clyellow); j:=0; @@ -4047,7 +4121,7 @@ begin end; end; - if (typ=tjd) or (typ=tjs) then + if (typ=tjd) or (typ=tjs) then begin //Affiche('TJD',clYellow); if connect='S' then @@ -4060,6 +4134,18 @@ begin end; end; + if (typ=crois) then + begin + if connect='S' then + begin + suiv:=aiguillage[i].ADevie;typ_suiv:=aiguillage[i].ADevieB; + end; + if connect='D' then + begin + suiv:=aiguillage[i].ADroit;typ_suiv:=aiguillage[i].ADroitB; + end; + end; + if typ_suiv=#0 then typ_suiv:='Z'; end; @@ -4068,16 +4154,16 @@ end; // si det1 et det2 sont contigus sans aiguillages entre eux, çà renvoie det1 // det_contigu(527,520: renvoie 7 dans suivant // det_contigu(514,522: renvoie 514 dans suivant -// procédure récursive procedure det_contigu(det1,det2 : integer;var suivant : integer;var ElSuiv : TEquipement); var suiv1,indexBranche_det1,indexBranche_det2,branche_det2,branche_det1, suiv_2,detC,indexBranche_det,suiv_pointe,dernier,it : integer; - type1,type_dernier : Tequipement; + type1,Tp,type_dernier : Tequipement; type_tmp : char; trouve,afdeb : boolean; // donne le suivant au point de connection de l'aiguillage // prec=det ou aig ; suiv=aig + // procédure récursive procedure aig_suiv(prec,suiv : integer) ; var adr2,index : integer; typ : Tequipement; @@ -4094,13 +4180,13 @@ var suiv1,indexBranche_det1,indexBranche_det2,branche_det2,branche_det1, // aiguillage en pointe? - if afdeb then afficheDebug('Aig_suiv('+intToSTR(prec)+','+intToSTR(suiv)+')',clOrange); + if afdeb then afficheDebug('250. Aig_suiv('+intToSTR(prec)+','+intToSTR(suiv)+')',clOrange); aig_ext(suiv,'P',suiv_pointe,type_tmp); if (suiv_pointe=prec) and ((typ=aig) or (typ=triple)) then begin // faire le droit - if afdeb then afficheDebug('Aig '+intToSTR(suiv)+' pris en pointe droit',clyellow); + if afdeb then afficheDebug('251. Aig '+intToSTR(suiv)+' test en pointe droit',clyellow); type_Dernier:=aig; aig_ext(suiv,'D',suiv_2,type_tmp); if type_tmp<>'Z' then aig_suiv(suiv,suiv_2) else @@ -4112,11 +4198,11 @@ var suiv1,indexBranche_det1,indexBranche_det2,branche_det2,branche_det1, if afdeb then afficheDebug('trouvé ',clLime); exit; end; - if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu',clyellow); + if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu('+intToSTR(det2)+')',clyellow); end; // faire le dévié - if afdeb then afficheDebug('Aig '+intToSTR(suiv)+' pris en pointe dévié',clyellow); + if afdeb then afficheDebug('252.Aig '+intToSTR(suiv)+' test en pointe dévié',clyellow); type_Dernier:=aig; aig_ext(suiv,'S',suiv_2,type_tmp); if type_tmp<>'Z' then aig_suiv(suiv,suiv_2) else @@ -4128,13 +4214,13 @@ var suiv1,indexBranche_det1,indexBranche_det2,branche_det2,branche_det1, if afdeb then afficheDebug('trouvé ',clLime); exit; end; - if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu',clyellow) + if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu ('+intToSTR(det2)+')',clyellow) end; // si triple faire S2 if typ=triple then begin - if afdeb then afficheDebug('Aig triple'+intToSTR(suiv)+' pris en pointe dévié2',clyellow); + if afdeb then afficheDebug('Aig triple'+intToSTR(suiv)+' test en pointe dévié2',clyellow); type_Dernier:=aig; aig_ext(suiv,'2',suiv_2,type_tmp); if type_tmp<>'Z' then aig_suiv(suiv,suiv_2) else @@ -4146,19 +4232,19 @@ var suiv1,indexBranche_det1,indexBranche_det2,branche_det2,branche_det1, if afdeb then afficheDebug('trouvé ',clLime); exit; end; - if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu',clyellow) + if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu('+intToSTR(det2)+')',clyellow) end; end; end else begin - // aiguillage en talon ou tjd + // aiguillage en talon ou tjd ou croisement type_Dernier:=aig; if (typ=aig) or (typ=triple) then begin - if afdeb then afficheDebug('Aig '+intToSTR(suiv)+' pris en talon',clyellow); + if afdeb then afficheDebug('Aig '+intToSTR(suiv)+' test en talon',clyellow); aig_ext(suiv,'P',suiv_2,type_tmp); if type_tmp<>'Z' then aig_suiv(suiv,suiv_2) else @@ -4170,7 +4256,7 @@ var suiv1,indexBranche_det1,indexBranche_det2,branche_det2,branche_det1, if afdeb then afficheDebug('trouvé ',clLime); exit; end; - if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu',clyellow) + if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu('+intToSTR(det2)+')',clyellow) end; end; @@ -4191,7 +4277,7 @@ var suiv1,indexBranche_det1,indexBranche_det2,branche_det2,branche_det1, if afdeb then afficheDebug('trouvé sur D',clLime); exit; end; - if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu',clyellow) + if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu('+intToSTR(det2)+')',clyellow) end; aig_ext(suiv,'S',suiv_2,type_tmp); @@ -4204,7 +4290,7 @@ var suiv1,indexBranche_det1,indexBranche_det2,branche_det2,branche_det1, if afdeb then afficheDebug('trouvé sur S',clLime); exit; end; - if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu',clyellow) + if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu('+intToSTR(det2)+')',clyellow) end; end; @@ -4225,7 +4311,7 @@ var suiv1,indexBranche_det1,indexBranche_det2,branche_det2,branche_det1, if afdeb then afficheDebug('trouvé sur D',clLime); exit; end; - if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu',clyellow) + if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu ('+intToSTR(det2)+')',clyellow) end; aig_ext(suiv,'S',suiv_2,type_tmp); @@ -4238,7 +4324,29 @@ var suiv1,indexBranche_det1,indexBranche_det2,branche_det2,branche_det1, if afdeb then afficheDebug('trouvé sur S',clLime); exit; end; - if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu',clyellow) + if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu('+intToSTR(det2)+')',clyellow) + end; + end; + + if typ=crois then + begin + if afdeb then afficheDebug('crois '+intToSTR(suiv),clyellow); + + if aiguillage[index].ADroit=prec then begin suiv_2:=aiguillage[index].Ddroit;type_tmp:=aiguillage[index].DdroitB;end; + if aiguillage[index].DDroit=prec then begin suiv_2:=aiguillage[index].Adroit;type_tmp:=aiguillage[index].AdroitB;end; + if aiguillage[index].ADevie=prec then begin suiv_2:=aiguillage[index].Ddevie;type_tmp:=aiguillage[index].DdevieB;end; + if aiguillage[index].DDevie=prec then begin suiv_2:=aiguillage[index].ADevie;type_tmp:=aiguillage[index].AdevieB;end; + + if type_tmp<>'Z' then aig_suiv(suiv,suiv_2) else + begin + trouve:=(suiv_2=det2); + if trouve then + begin + dernier:=suiv; + if afdeb then afficheDebug('trouvé ',clLime); + exit; + end; + if afdeb then afficheDebug('trouvé '+intToSTR(suiv_2)+' mais pas attendu ('+intToSTR(det2)+')',clyellow) end; end; end; @@ -4247,10 +4355,13 @@ var suiv1,indexBranche_det1,indexBranche_det2,branche_det2,branche_det1, begin // trouver les éléments du précédent - afdeb:=TraceListe ; + afdeb:=TraceListe ; it:=0; if afdeb then afficheDebug('Det_contigu '+intToSTR(det1)+' '+intToSTr(det2),clyellow); - trouve_element(det1,det,1); // branche_trouve IndexBranche_trouve + + tp:=det; + if det1=0 then tp:=buttoir; + trouve_element(det1,tp,1); // branche_trouve IndexBranche_trouve if IndexBranche_trouve=0 then begin if NivDebug=3 then AfficheDebug('Element '+intToSTR(det1)+' non trouvé',clred); @@ -4259,7 +4370,9 @@ begin indexBranche_det1:=IndexBranche_trouve; branche_det1:=branche_trouve; - trouve_element(det2,det,1); // branche_trouve IndexBranche_trouve + tp:=det; + if det2=0 then tp:=buttoir; + trouve_element(det2,tp,1); // branche_trouve IndexBranche_trouve if IndexBranche_trouve=0 then begin if NivDebug=3 then AfficheDebug('Element '+intToSTR(actuel)+' non trouvé',clred); @@ -4323,7 +4436,7 @@ begin if trouve then begin dernier:=det1; - type_dernier:=det; + if dernier=0 then type_dernier:=buttoir else type_dernier:=det; if afdeb then afficheDebug('ok4',ClLime); end; end; @@ -4396,7 +4509,7 @@ begin else begin Adr:=AdrFonc;TypeGen:=BtypeFonc;end; if Adr>9990 then typeGen:=det; - if (NivDebug=3) then AfficheDebug('trouvé '+intToSTR(Adr)+' '+intToSTR(BTypeToNum(typeGen)),clorange); + if (NivDebug=3) then AfficheDebug('trouvé '+intToSTR(Adr)+' '+BTypeToNum(typeGen),clorange); AdrPrec:=AdrFonc;BtypePrec:=BtypeFonc; AdrFonc:=Adr;BtypeFonc:=typeGen; i:=i+1; @@ -4410,8 +4523,8 @@ begin end; -// renvoie l'adresse du détecteur suivant des deux éléments -// les aiguillages doivent être ouverts entre El1 et el2 +// renvoie l'adresse du détecteur suivant les deux éléments +// les aiguillages doivent être correctement positionnés entre El1 et el2 // El1 et El2 peuvent être séparés par des aiguillages, mais de pas plus de 3 détecteurs // en sortie : 9999= det1 ou det2 non trouvé // 9996 : non trouvé @@ -4425,7 +4538,7 @@ var IndexBranche_det1,IndexBranche_det2,branche_trouve_det1,branche_trouve_det2, begin if NivDebug>=2 then - AfficheDebug('Proc Detecteur_suivant_EL '+intToSTR(el1)+','+intToSTR(BTypeToNum(Typedet1))+'/'+intToSTR(el2)+','+intToSTR(BTypeToNum(Typedet2))+'-------------------------',clLime); + AfficheDebug('Proc Detecteur_suivant_EL '+intToSTR(el1)+','+BTypeToNum(Typedet1)+'/'+intToSTR(el2)+','+BTypeToNum(Typedet2)+'-------------------------',clLime); if (el1>9000) or (el2>9000) then begin if NivDebug=3 then AfficheDebug('paramètres incorrects >9000',clred); @@ -4498,11 +4611,7 @@ begin if TypeGen=det then inc(N_Det); if NivDebug=3 then begin - s:='613 : trouvé='+intToSTR(Adr); - case typeGen of - det : s:=s+' detecteur'; - aig : s:=s+' aiguillage'; - end; + s:='613 : trouvé='+intToSTR(Adr)+BTypeToNum(typeGen); AfficheDebug(s,clYellow); end; @@ -4536,13 +4645,8 @@ begin if NivDebug=3 then begin - s:='614 : trouvé='+intToSTR(Adr); - case typeGen of - det : s:=s+' detecteur'; - aig : s:=s+' aiguillage'; - buttoir : s:=s+' buttoir'; - end; - AfficheDebug(s,clorange); + s:='615 : trouvé='+intToSTR(Adr)+BTypeToNum(typeGen); + AfficheDebug(s,clorange); end; AdrPrec:=AdrFonc;TypePrec:=TypeFonc; @@ -5215,7 +5319,7 @@ begin inc(i); repeat dec(i); - trouve:=(event_det_tick[i].etat=etat) and (event_det_tick[i].detecteur=Adr) ; + trouve:=(event_det_tick[i].etat=etat) and (event_det_tick[i].Adresse=Adr) and (event_det_tick[i].modele=det); until (trouve or (i=0)); if trouve then begin @@ -5245,7 +5349,7 @@ begin end; -// présence train précédent les 3 cantons du signal (soit 4 feux avant) +// présence train précédent les 3 cantons du signal (Nb_cantons_Sig) function PresTrainPrec(Adresse : integer) : boolean; var AdrSuiv,prec,ife,actuel,i,j,ifd, @@ -5258,13 +5362,13 @@ begin i:=Index_feu(adresse); if (i=0) then begin - Affiche('Erreur 605 - feu '+IntToSTR(adresse)+' non trouvé',clred); AfficheDebug('Erreur 605 - feu '+IntToSTR(adresse)+' non trouvé',clred); + Affiche('Erreur 605 - feu '+IntToSTR(adresse)+' non trouvé',clred); PresTrainPrec:=false; end; Nfeux:=0; - NFeuxMax:=3; // nombre de feux à trouver (nombre de cantons) + NFeuxMax:=Nb_cantons_Sig; // nombre de feux à trouver (nombre de cantons) Pres_train:=FALSE; ife:=1; // index feu de 1 à 4 pour explorer les 4 détecteurs d'un feu repeat @@ -5295,6 +5399,8 @@ begin Typeprec:=feux[i].Btype_suiv4; end; // détecteur sur le signal courant + pres_Train:=Detecteur[actuel].etat; + TypeActuel:=det; if actuel=0 then begin @@ -5313,8 +5419,16 @@ begin malpositionne:=(AdrSuiv=0) or (AdrSuiv>9990); if malpositionne then begin - if (nivDebug=3) then AfficheDebug('Aiguille en talon mal positionné',clYellow); + if AdrSuiv=0 then Pres_Train:=Pres_Train or Detecteur[actuel].etat; PresTrainPrec:=Pres_train; + if (nivDebug=3) then + begin + if (AdrSuiv>9990) then AfficheDebug('Aiguille en talon mal positionné',clYellow); + if AdrSuiv=0 then AfficheDebug('Buttoir',clyellow); + if Pres_train then AfficheDebug('Présence train de '+intToSTR(actuel)+' à '+intToSTR(dernierdet),clyellow) + else AfficheDebug('Absence train de '+intToSTR(actuel)+' à '+intToSTR(dernierdet),clyellow); + end; + exit; end; if not(malpositionne) then @@ -5324,7 +5438,7 @@ begin if typeactuel=det then begin - Pres_train:=MemZone[actuel,dernierdet] or Pres_Train; + Pres_train:=MemZone[actuel,dernierdet] or Pres_Train or Detecteur[actuel].etat; PresTrainPrec:=Pres_train; if Pres_Train then begin @@ -5341,7 +5455,7 @@ begin AdrFeu:=feux[ifd].adresse; // adresse du feu if (AdrFeu=adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant begin - AdrFeu:=0;j:=10; // on ne trouve pas de suivant + AdrFeu:=0; // on ne trouve pas de suivant PresTrainPrec:=false; exit; end; @@ -5352,13 +5466,13 @@ begin inc(Nfeux); j:=0; s:='Trouvé feu ('+IntToSTR(nfeux)+'/'+intToSTR(NFeuxMax)+') '+IntToSTR(AdrFeu); - if (NivDebug>0) And Pres_Train then AfficheDebug(s+' et mémoire de zone à 1',clyellow); + if (NivDebug>0) And Pres_Train then AfficheDebug(s+' et mémoire de zone à 1',clOrange); if (NivDebug>0) And (not(Pres_Train)) then AfficheDebug(s+' et mémoire de zone à 0',clOrange); if nFeux=NFeuxMax then begin PresTrainPrec:=Pres_train; exit; - end; + end; end else begin @@ -5368,11 +5482,11 @@ begin end; end; end; - end; + end; until (j=10) or malpositionne or (nfeux>=NFeuxMax); // on arrete jusqu'à trouver un signal ou si on va trop loin (10 itérations) inc(ife); until ife>=5; - if (NivDebug>0) then AfficheDebug('Pas trouvé de signal suivant au '+intToSTR(adresse),clyellow); + if (NivDebug>0) then AfficheDebug('606. Pas trouvé de signal suivant au '+intToSTR(adresse),clyellow); PresTrainPrec:=Pres_train; end; @@ -5425,8 +5539,9 @@ begin if (modele=2) then //or (feux[i].check<>nil) then // si carré violet begin //AfficheDebug('Feux à 2 feux',CLOrange); - // si aiguillage après signal mal positionnées - if carre_signal(AdrFeu) then + // si aiguillage après signal mal positionnées ou pas de train avant le signal + PresTrain:=PresTrainPrec(AdrFeu); + if carre_signal(AdrFeu) or not(PresTrain) then begin Maj_Etat_Signal(AdrFeu,violet); Envoi_signauxCplx; @@ -5472,7 +5587,7 @@ begin begin if AffSignal then AfficheDebug('Présence train après signal'+intToSTR(AdrFeu)+' -> sémaphore ou carré',clYellow); if testBit(feux[index].EtatSignal,carre)=FALSE then Maj_Etat_Signal(AdrFeu,semaphore); - end // zizi + end else begin Aig:=Aiguille_deviee(Adrfeu); @@ -5632,7 +5747,7 @@ end; // calcul des zones depuis le tableau des fronts descendants des évènements détecteurs // transmis dans le tableau Event_det procedure calcul_zones; -var AdrFeu,AdrDetFeu,Nbre,i,det1,det2,det3,AdrSuiv,AdrPrec,Prev,det_suiv : integer ; +var AdrFeu,AdrDetFeu,Nbre,i,n,det1,det2,det3,det4,AdrSuiv,AdrPrec,Prev,det_suiv : integer ; TypeSuiv : tEquipement; s : string; begin @@ -5641,33 +5756,26 @@ begin FormDebug.MemoEvtDet.lines.add('Le nouveau détecteur est '+IntToSTR(det3)) ; if TraceListe or dupliqueEvt then AfficheDebug('Le nouveau détecteur est '+IntToSTR(det3),clyellow) ; - // évaluer d'abord la route du nouveau détecteur sur tous les tableau déja rempli de 2 éléments + for i:=1 to N_trains do begin Nbre:=event_det_train[i].NbEl ; // Nombre d'éléments du tableau courant exploré + + // évaluer d'abord la route du nouveau détecteur sur tous les tableau déja rempli de 2 éléments if Nbre=2 then begin - if TraceListe or (NivDebug=3) then AfficheDebug('traitement Train n°'+intToSTR(i)+' 2 détecteurs',clyellow); + if TraceListe or (NivDebug=3) then AfficheDebug('Traitement Train n°'+intToSTR(i)+' 2 détecteurs',clyellow); det1:=event_det_train[i].det[1]; det2:=event_det_train[i].det[2]; - //det_suiv:=detecteur_suivant_el(det1,det,det2,det,1); det_suiv:=det_suiv_cont(det1,det2); - - {s:=intToSTr(det_suiv)+'=Det_suiv_cont('+intToSTR(det1)+','+intToSTR(det2)+')'; - FormDebug.MemoEvtDet.lines.add(s); - if TraceListe or (NivDebug=3) then afficheDebug(s,clyellow);} - - //Det_Adj(det2); // renvoie les adresses des détecteurs adjacents au détecteur "det1" résultat dans adj1 et adj2 - //s:='adjacents='+intToSTR(adj1)+' '+intToSTR(adj2); - //s:='Suivant='+intToSTR(det_suiv); - //FormDebug.MemoEvtDet.lines.add(s); - //if TraceListe or (NivDebug=3) then afficheDebug(s,clyellow); - if det_suiv=det3 then begin if TraceListe then AfficheDebug(' la route est valide',clyellow); - AdrSuiv:=detecteur_suivant_el(det2,det,det3,det,1); // ici on cherche le suivant à det2 det3, algo=1 + // ici on cherche le suivant à det2 det3, algo=1 + ncrois:=0; + AdrSuiv:=detecteur_suivant_el(det2,det,det3,det,1); + if (Adrsuiv>=9996) then begin Affiche('Erreur 1500 : pas de suivant sur la route de '+intToSTR(det2)+' à '+intToSTR(det3),clRed); @@ -5675,26 +5783,28 @@ begin end else begin - s:='route traitée de '+intToSTR(det2)+' à '+IntToSTR(det3)+' Mem '+intToSTR(det3)+' à '+IntToSTR(Adrsuiv); - FormDebug.MemoEvtDet.lines.add(s); - if traceListe then AfficheDebug(s,clyellow); - With FormDebug.RichEdit do - begin - s:='train '+IntToSTR(i)+' '+intToStr(det2)+' à '+intToStr(det3)+' => Mem '+IntToSTR(det3)+' à '+IntTOStr(AdrSuiv); - Lines.Add(s); - index_couleur:=((i - 1) mod NbCouleurTrain) +1; - RE_ColorLine(FormDebug.RichEdit,lines.count-1,CouleurTrain[index_couleur]); - end; - if TraceListe then AfficheDebug(s,clyellow); - Affiche(s,clyellow); - if AffAigDet then AfficheDebug(s,clyellow); - if (det2200 then begin n:=1;TrainZone[i].Nbre:=n;end; + TrainZone[i].Zone[n].det1:=det3; + TrainZone[i].Zone[n].det2:=AdrSuiv; + TrainZone[i].Nbre:=n; + // zone suivante en prévision + det4:=detecteur_suivant_EL(det3,det,AdrSuiv,det,1); + TrainPrevZone[i][1]:=det4; + end; + event_act(det2,det3,0,''); // désactivation zone event_act(det3,AdrSuiv,1,''); // activation zone + end else begin @@ -5710,16 +5820,42 @@ begin event_det_train[i].det[2]:=det3; event_det_train[i].NbEl:=2; + + // la route en avant croise-t-elle un croisement? + if ncrois<>0 then + begin + // FormDebug.RichEdit.Lines.Add('Croisement détecté'); + ncrois:=0; + end; + + + // affichages + s:='route traitée de '+intToSTR(det2)+' à '+IntToSTR(det3)+' '+intToSTR(det3)+' à '+IntToSTR(Adrsuiv); + FormDebug.MemoEvtDet.lines.add(s); + if traceListe then AfficheDebug(s,clyellow); + With FormDebug.RichEdit do + begin + s:='train '+IntToSTR(i)+' '+intToStr(det2)+' à '+intToStr(det3)+' => '+IntToSTR(det3)+' à '+IntToStr(AdrSuiv); + s:=s+' Prev='+intToSTR(TrainPrevZone[i][1]); + Lines.Add(s); + index_couleur:=((i - 1) mod NbCouleurTrain) +1; + RE_ColorLine(FormDebug.RichEdit,lines.count-1,CouleurTrain[index_couleur]); + end; + if TraceListe then AfficheDebug(s,clyellow); + Affiche(s,clyellow); + if AffAigDet then AfficheDebug(s,clyellow); + with FormDebug.MemoEvtDet do begin - lines.add('1.Nouveau Tampon train '+intToStr(i)+'--------'); + s:='1.Nouveau Tampon train '+intToStr(i)+'--------'; + lines.add(s); lines.add(intToSTR(event_det_train[i].det[1])); lines.add(intToSTR(event_det_train[i].det[2])); end; if TraceListe or dupliqueEvt then begin - AfficheDebug('1.Nouveau Tampon train '+intToStr(i)+'--------',clyellow); + AfficheDebug(s,clyellow); AfficheDebug(intToSTR(event_det_train[i].det[1]),clyellow); AfficheDebug(intToSTR(event_det_train[i].det[2]),clyellow); end; @@ -5730,28 +5866,46 @@ begin if ModeCouleurCanton=0 then zone_TCO(det3,AdrSuiv,1) else zone_TCO(det3,AdrSuiv,2); // affichage avec la couleur de index_couleur du train end; - event_det_train[i].prev:=prev; // prévisionnel Maj_feux; Maj_feux; Maj_feux; exit; // sortir absolument end; end - else if TraceLIste then AfficheDebug(' la route est invalide',clyellow); - event_det_train[i].prev:=prev; // prévisionnel - - end; + else + begin + if TraceListe then AfficheDebug(' la route est invalide',clyellow); + if event_det_train[i].det[2]=det3 then + begin + s:='Rebond dét. '+intToSTR(det3)+' déjà affecté au train '+IntToSTR(i); + FormDebug.MemoEvtDet.lines.add(s); + if dupliqueEvt then AfficheDebug(s,clyellow); + exit; // sortir + end; + end; + end; end; - // traiter pour les cas avec 1 élément for i:=1 to N_trains do begin Nbre:=event_det_train[i].NbEl ; // Nombre d'éléments du tableau courant exploré + + // traiter pour les cas avec 1 élément if Nbre=1 then begin if traceListe then AfficheDebug('traitement Train n°'+intToSTR(i)+' 1 détecteur',clyellow); - // vérifier si l'élément du tableau et le nouveau sont contigus + + // si le nouveau et l'ancien sont identiques, c'est un rebond det1:=event_det_train[i].det[1]; + if det1=det3 then + begin + s:='Rebond dét. '+intToSTR(det3)+' déjà affecté au train '+IntToSTR(i); + FormDebug.MemoEvtDet.lines.add(s); + if dupliqueEvt then AfficheDebug(s,clyellow); + exit; // sortir + end; + + // vérifier si l'élément du tableau et le nouveau sont contigus Det_Adj(det1); // renvoie les adresses des détecteurs adjacents au détecteur "det1" résultat dans adj1 et adj2 if (Adj1=det3) or (Adj2=det3) then begin @@ -5780,7 +5934,7 @@ begin end; end; end; - + // Nombre d'éléments à 0 : ici c'est un nouveau train donc créer un train, donc un tableau if N_Trains>=Max_Trains then begin @@ -5819,24 +5973,23 @@ begin // si on démarre d'un buttoir if buttoir_adjacent(det3) then begin - if TraceListe then AfficheDebug('detection démarrage depuis détecteur '+IntToSTR(det3)+' buttoir',clyellow); + if TraceListe then AfficheDebug('Détection démarrage depuis détecteur '+IntToSTR(det3)+' buttoir',clyellow); event_det_train[N_trains].det[1]:=0; event_det_train[N_trains].det[2]:=det3; event_det_train[N_trains].NbEl:=2; - + s:='3. Nouveau Tampon train '+intToStr(N_Trains)+'--------'; with FormDebug.MemoEvtDet do begin - lines.add('3. Nouveau Tampon train '+intToStr(N_Trains)+'--------'); + lines.add(s); lines.add(intToSTR(event_det_train[N_Trains].det[1])); lines.add(intToSTR(event_det_train[N_Trains].det[2])); end; if dupliqueEvt then begin - AfficheDebug('3. Nouveau Tampon train '+intToStr(N_Trains)+'--------',clyellow); + AfficheDebug(s,clyellow); AfficheDebug(intToSTR(event_det_train[N_Trains].det[1]),clyellow); AfficheDebug(intToSTR(event_det_train[N_Trains].det[2]),clyellow); end; - end else @@ -5910,7 +6063,7 @@ var i,v,va,etatAct,Af,Ao,Access,sortie : integer; Ts : TAccessoire; begin // vérifier si l'actionneur en évènement a été déclaré pour réagir - if AffActionneur then AfficheDebug('Act/Det '+intToSTR(Adr)+'='+intToSTR(etat),clyellow); + if AffAigDet then AfficheDebug('Act/Det '+intToSTR(Adr)+'='+intToSTR(etat),clyellow); //Affiche(intToSTR(adr)+'/'+intToSTR(adr2)+' '+intToSTR(etat),clyellow); for i:=1 to maxTablo_act do begin @@ -6042,9 +6195,8 @@ begin if AffAigDet then begin //s:='Evt Det '+intToSTR(adresse)+'='+intToSTR(etat01); - s:='Tick='+IntToSTR(tick)+' Evt Det='+IntToSTR(adresse)+'='+intToSTR(etat01); - Affiche(s,clyellow); - if not(TraceListe) then AfficheDebug(s,clyellow); + s:='Tick='+IntToSTR(tick)+' Evt Det='+IntToSTR(adresse)+'='+intToSTR(etat01)+' Train='+train; + AfficheDebug(s,clyellow); end; ancien_detecteur[Adresse]:=detecteur[Adresse].etat; @@ -6061,7 +6213,8 @@ begin inc(N_Event_tick); event_det_tick[N_event_tick].tick:=tick; - event_det_tick[N_event_tick].detecteur:=Adresse; + event_det_tick[N_event_tick].adresse:=Adresse; + event_det_tick[N_event_tick].modele:=det; event_det_tick[N_event_tick].etat:=etat01; if (n_Event_tick mod 10) =0 then affiche_memoire; // Affiche('stockage de '+intToSTR(N_event_tick)+' '+IntToSTR(Adresse)+' à '+intToSTR(etat01),clyellow); @@ -6080,7 +6233,7 @@ begin begin AdrSuiv:=Feux[i].Adr_el_suiv1; TypeSuiv:=Feux[i].Btype_suiv1; - if AffSignal then AfficheDebug('Pour Feu '+intToSTR(AdrFeu)+' detecteursuivant('+intToSTR(AdrSuiv)+','+IntToSTR(BTypeToNum(typeSuiv))+','+intToSTR(AdrDetFeu)+',1)',clyellow); + if AffSignal then AfficheDebug('Pour Feu '+intToSTR(AdrFeu)+' detecteursuivant('+intToSTR(AdrSuiv)+','+BTypeToNum(typeSuiv)+','+intToSTR(AdrDetFeu)+',1)',clyellow); AdrPrec:=detecteur_suivant(AdrSuiv,typeSuiv,AdrDetFeu,det,1) ; // détecteur précédent le feu, algo 1 if AdrPrec=0 then begin @@ -6199,7 +6352,8 @@ begin if (n_Event_tick mod 10) =0 then affiche_memoire; inc(N_Event_tick); event_det_tick[N_event_tick].tick:=tick; - event_det_tick[N_event_tick].aiguillage:=adresse; + event_det_tick[N_event_tick].adresse:=adresse; + event_det_tick[N_event_tick].modele:=aig; event_det_tick[N_event_tick].etat:=pos; // Mettre à jour le TCO @@ -6252,12 +6406,12 @@ begin //AfficheDebug(intToSTR(adresse),clred); 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); + 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); + envoi_CDM(s); event_aig(adresse,pilotage); exit; end; @@ -6274,18 +6428,19 @@ begin s:=checksum(s); 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 + event_aig(adresse,pilotage); // si l'accessoire est un feu et sans raz des signaux, sortir if (acc=feu) and not(Raz_Acc_signaux) then exit; // si aiguillage, faire une temporisation //if (index_feu(adresse)=0) or (Acc=aig) then - 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); @@ -6658,7 +6813,7 @@ begin end; {$J-} -// initialisation de la comm USB +// initialisation de la comm USB pour l'interface Xpressnet procedure connecte_USB; var i,j : integer; begin @@ -6674,7 +6829,7 @@ begin confStCom:=copy(portCom,i+1,j-i-1); Settings:=ConfStCom; // COMx:vitesse,n,8,1 - Affiche('Demande ouverture COM'+intToSTR(NumPort)+':'+ConfStCom+' protocole '+IntToSTR(protocole),CLYellow); + Affiche('Demande ouverture interface Xpressnet COM'+intToSTR(NumPort)+':'+ConfStCom+' protocole '+IntToSTR(protocole),CLYellow); if protocole>=4 then Handshaking:=0 {0=aucun 1=Xon-Xoff 2=cts 3=RTS-Xon-Xoff 4=5=protocoles "maison"} else Handshaking:=protocole; SThreshold:=1; @@ -6980,7 +7135,39 @@ begin Lance_CDM:=true; end; -// démarrage principal du programpe signaux_complexes +Procedure Raz_tout; +var i : integer; +begin + N_Event_tick:=0; + N_event_det:=0; + N_trains:=0; + Formprinc.LabelNbTrains.caption:=IntToSTR(N_trains); + for i:=1 to Max_Trains do Event_det_Train[i].NbEl:=0; + for i:=1 to 20 do TrainZone[i].Nbre:=0; + // initialisation de la chronologie des évènements détecteurs + for i:=0 to Max_Event_det_tick do + begin + event_det_tick[i].adresse:=-1; + event_det_tick[i].modele:=rien; + event_det_tick[i].etat:=-1; + event_det_tick[i].traite:=false ; // non traité + end; + + i_simule:=0; + FormDebug.MemoEvtDet.Clear; + FormDebug.Richedit.Clear; + { ralentit au démarrage + for i:=1 to NbreFeux do + begin + typeFeu:=feux[i].aspect; + if TypeFeu=2 then feux[i].EtatSignal:=violet_F; + if TypeFeu=3 then feux[i].EtatSignal:=semaphore_F; + if (TypeFeu>3) and (TypeFeu<10) then feux[i].EtatSignal:=carre_F; + envoi_signal(feux[i].adresse); + end; } +end; + +// démarrage principal du programme signaux_complexes procedure TFormPrinc.FormCreate(Sender: TObject); var i : integer; s : string; @@ -6994,6 +7181,7 @@ begin Srvc_Act:=true; Srvc_PosTrain:=false; Srvc_sig:=false; + confasauver:=false; config_modifie:=false; AF:='Client TCP-IP CDM Rail ou USB - système XpressNet - Version '+Version+sousVersion; @@ -7013,6 +7201,7 @@ begin FormDebug.Caption:=AF+' debug'; N_Trains:=0; NivDebug:=0; + ncrois:=0; debugtrames:=false; algo_Unisemaf:=1; @@ -7051,9 +7240,7 @@ begin // si CDM n'est pas connecté, on ouvre la liaison vers la centrale if not(CDM_connecte) then begin - Affiche('CDM absent',clYellow); // ouverture par USB - Affiche('Demande connexion à la centrale par USB protocole XpressNet',clyellow); connecte_USB; if not(portCommOuvert) then begin @@ -7061,7 +7248,7 @@ begin // Initialisation de la comm socket LENZ if AdresseIP<>'0' then begin - Affiche('Demande connexion à la centrale par Ethernet protocole XpressNet',clyellow); + Affiche('Demande ouverture interface XpressNet par Ethernet '+AdresseIP+':'+intToSTR(port),clyellow); ClientSocketLenz.port:=port; ClientSocketLenz.Address:=AdresseIP; ClientSocketLenz.Open; @@ -7082,7 +7269,7 @@ begin ButtonEcrCV.Enabled:=false; ButtonLitCV.Enabled:=false; LireunfichierdeCV1.enabled:=false; - end ; + end; // Initialisation des images des signaux NbreImagePLigne:=Formprinc.ScrollBox1.Width div (largImg+5); @@ -7094,17 +7281,8 @@ begin end; Tempo_init:=5; // démarre les initialisation des signaux et des aiguillages dans 0,5 s - // initialisation de la chronologie des évènements détecteurs - for i:=0 to Max_Event_det_tick do - begin - event_det_tick[i].aiguillage:=-1; - event_det_tick[i].detecteur:=-1; - event_det_tick[i].etat:=-1; - event_det_tick[i].aiguillage:=-1; - event_det_tick[i].actionneur:=-1; - event_det_tick[i].traite:=false ; // non traité - end; - + raz_tout; + I_Simule:=0; tick:=0; N_Event_tick:=0 ; // dernier index @@ -7128,16 +7306,18 @@ begin Affiche('Fin des initialisations',clyellow); LabelEtat.Caption:=' '; Affiche_memoire; - - { - aiguillage[index_aig(1)].position:=const_droit; + + { + aiguillage[index_aig(1)].position:=const_devie; aiguillage[index_aig(3)].position:=const_devie; + aiguillage[index_aig(4)].position:=const_devie; aiguillage[index_aig(5)].position:=const_droit; + aiguillage[index_aig(6)].position:=const_devie; aiguillage[index_aig(7)].position:=const_devie; aiguillage[index_aig(8)].position:=const_devie; aiguillage[index_aig(12)].position:=const_droit; aiguillage[index_aig(19)].position:=const_devie; - aiguillage[index_aig(20)].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; @@ -7145,10 +7325,14 @@ begin aiguillage[index_aig(31)].position:=const_devie; aiguillage[index_aig(25)].position:=const_droit; aiguillage[index_aig(9)].position:=const_droit; - i:=suivant_alg3(523,det,100,aig,1) ; - Affiche(intToSTR(i),clLime); - } - //det_suiv_cont(525,528) ; + + nivDebug:=3; + //i:=suivant_alg3(21,aig,26,aig,1) ; + //Affiche(intToSTR(i),clLime); + formDebug.Show; + traceListe:=true; + det_contigu(0,516,i,vide) ; + det_contigu(527,519,i,vide) ; } end; @@ -7173,24 +7357,26 @@ end; procedure TFormPrinc.FormClose(Sender: TObject; var Action: TCloseAction); begin Ferme:=true; + if portCommOuvert then begin portCommOuvert:=false;MSCommUSBLenz.Portopen:=false; end; portCommOuvert:=false; ClientSocketCDM.close; ClientSocketLenz.close; - if TCO_modifie then + if TCO_modifie then if MessageDlg('Le TCO a été modifié. Voulez vous le sauvegarder ?',mtConfirmation,[mbYes,mbNo],0)=mrYes then begin sauve_fichier_tco; ancienFormatTCO:=false; - end; + end; if config_modifie then if MessageDlg('La configuration a été modifiée. Voulez vous la sauvegarder ?',mtConfirmation,[mbYes,mbNo],0)=mrYes then sauve_config; - + if confasauver then sauve_config; if avecTCO then begin if ancienFormatTCO then sauve_fichier_tco; - end; + end; + Application.ProcessMessages; end; @@ -7198,24 +7384,34 @@ end; procedure init_aiguillages; var i,pos,index : integer; s : string; + model : Tequipement; begin - if portCommOuvert or parSocketLenz then + // positionnement des aiguillages meme si pas connecté à la centrale ou à CDM + // pour générer les evts de position + //Affiche('Positionnement aiguillages',cyan); + for i:=1 to MaxAcc do begin - Affiche('Positionnement aiguillages',cyan); - for i:=1 to maxaiguillage do + index:=index_aig(i); + + model:=aiguillage[index].modele; + if (model<>rien) and (model<>crois) then // si l'aiguillage existe et différent de croisement begin - index:=index_aig(i); - if aiguillage[index].modele<>rien then // si l'aiguillage existe + pos:=aiguillage[index].posInit; + if (pos=const_devie) or (pos=const_droit) then begin - pos:=aiguillage[index].posInit; s:='Init aiguillage '+intToSTR(i)+'='+intToSTR(pos); - if pos=const_devie then s:=s+' (dévié)' else s:=s+' (droit)'; + case pos of + const_devie : s:=s+' (dévié)'; + const_droit : s:=s+' (droit)'; + else + s:=s+' non positionné'; + end; Affiche(s,cyan); - pilote_acc(i,pos,aigP); - sleep(Tempo_Aig); - application.processMessages; + if pos<>const_inconnu then pilote_acc(i,pos,aigP); + if portCommOuvert or parSocketLenz or CDM_connecte then sleep(Tempo_Aig); + //application.processMessages; end; - end; + end; end; end; @@ -7349,21 +7545,23 @@ begin //while i_simule0 then + if Tablo_simule[I_simule].modele=det then begin - s:='Simulation '+intToSTR(I_simule)+' Tick='+IntToSTR(tick)+' det='+intToSTR(Tablo_simule[i_simule].detecteur)+'='+IntToSTR(Tablo_simule[i_simule].etat); - Event_Detecteur(Tablo_simule[i_simule].detecteur, Tablo_simule[i_simule].etat=1,''); // créer évt détecteur + s:='Simulation '+intToSTR(I_simule)+' Tick='+IntToSTR(tick)+' det='+intToSTR(Tablo_simule[i_simule].adresse)+'='+IntToSTR(Tablo_simule[i_simule].etat); + Event_Detecteur(Tablo_simule[i_simule].adresse, Tablo_simule[i_simule].etat=1,''); // créer évt détecteur StaticText.caption:=s; + //Affiche(s,clyellow); end; // evt aiguillage ? - if Tablo_simule[i_simule].aiguillage<>0 then + if Tablo_simule[I_simule].modele=aig then begin - s:='Simulation '+intToSTR(I_simule)+' Tick='+IntToSTR(tick)+' aig='+intToSTR(Tablo_simule[i_simule].aiguillage)+'='+IntToSTR(Tablo_simule[i_simule].etat); - Event_Aig(Tablo_simule[i_simule].Aiguillage,Tablo_simule[i_simule].etat); // créer évt aiguillage + s:='Simulation '+intToSTR(I_simule)+' Tick='+IntToSTR(tick)+' aig='+intToSTR(Tablo_simule[i_simule].adresse)+'='+IntToSTR(Tablo_simule[i_simule].etat); + Event_Aig(Tablo_simule[i_simule].Adresse,Tablo_simule[i_simule].etat); // créer évt aiguillage StaticText.caption:=s; + //Affiche(s,clyellow); end; end; @@ -7396,14 +7594,6 @@ begin end; end; -// bouton version centrale Lenz -procedure TFormPrinc.BoutVersionClick(Sender: TObject); -var s : string; -begin - s:=#$f0; - s:=checksum(s); - envoi(s); -end; // bouton de commande d'un accessoire procedure TFormPrinc.ButtonDroitClick(Sender: TObject); @@ -7543,19 +7733,6 @@ begin end; end; -procedure TFormPrinc.ButtonInfoClick(Sender: TObject); -begin - Affiche('Ce programme pilote des signaux complexes de façon autonome ou avec CDM rail ',ClYellow); - Affiche('En fonction des détecteurs mis à 1 ou 0 par des locomotives',ClYellow); - Affiche('en circulation sur le réseau',ClYellow); - Affiche('En vert : Trames envoyées à l''interface',ClWhite); - Affiche('En violet : Trames brutes reçues de l''interface',ClWhite); - Affiche('En rouge : erreurs et défauts',ClWhite); - Affiche('En orange : pilotage des signaux / erreurs mineures',ClWhite); - Affiche('En bleu : pilotage des aiguillages',ClWhite); - Affiche('En jaune : rétrosignalisation reçue depuis l''interface',ClWhite); -end; - procedure TFormPrinc.MenuConnecterUSBClick(Sender: TObject); begin Hors_tension2:=false; @@ -7626,7 +7803,7 @@ begin end; procedure TFormPrinc.Etatdesaiguillages1Click(Sender: TObject); -var i,j,index : integer; +var i,j,index,pos : integer; model : TEquipement; s : string; begin @@ -7635,19 +7812,24 @@ begin begin index:=index_aig(i); model:=aiguillage[index].modele ; - if model<>rien then + if (model<>rien) and (model<>crois) then begin s:='Aiguillage '+IntToSTR(i)+' : '; - if aiguillage[index].position=const_devie then s:=s+' (dévié)' ; - if aiguillage[index].position=const_droit then s:=s+' (droit)'; - if aiguillage[index].position=const_inconnu then s:=s+' inconnue'; - + pos:=aiguillage[index].position; + case pos of + const_devie : s:=s+' (dévié)' ; + const_droit : s:=s+' (droit)'; + const_inconnu : s:=s+' inconnue'; + else s:=s+' erreur ('+intToSTR(pos)+')'; + end; + if model=triple then // aig triple begin j:=aiguillage[index].AdrTriple; s:=s+' Aig '+IntToSTR(j)+': '+intToSTR(aiguillage[index_aig(j)].position); if aiguillage[index_aig(j)].position=1 then s:=s+' (dévié)' else s:=s+' (droit)'; end; + Affiche(s,clWhite); end; end; @@ -7665,32 +7847,38 @@ begin begin s:=IntToSTR(i)+' Adr='+IntToSTR(adr); if aiguillage[i].modele=aig then s:=s+' Pointe='; + + if (aiguillage[i].modele=crois) then + begin + s:=s+' CROI:'; + end; + if (aiguillage[i].modele=tjd) then begin s:=s+' TJD:'; s:=s+intToSTR(aiguillage[i].EtatTJD)+' états '; if aiguillage[i].inversionCDM=1 then s:=s+'(INV) '; - end; - if aiguillage[i].modele=tjs then + end; + if aiguillage[i].modele=tjs then begin s:=s+' TJS:'; if aiguillage[i].inversionCDM=1 then s:=s+'(INV) '; - end; + end; if aiguillage[i].modele=triple then s:=s+'/'+intToSTR(aiguillage[i].AdrTriple)+' Triple: Pointe='; - - if (aiguillage[i].modele=aig) or (aiguillage[i].modele=triple) then + + if (aiguillage[i].modele=aig) or (aiguillage[i].modele=triple) then begin s:=s+IntToSTR(aiguillage[i].APointe)+aiguillage[i].APointeB; s:=s+' Dévie='+IntToSTR(aiguillage[i].ADevie)+aiguillage[i].ADevieB+ ' Droit='+IntToSTR(aiguillage[i].ADroit)+aiguillage[i].ADroitB; - end; - if (aiguillage[i].modele=tjd) or (aiguillage[i].modele=tjs) then + end; + if (aiguillage[i].modele=tjd) or (aiguillage[i].modele=tjs) or (aiguillage[i].modele=crois) then begin s:=s+' Ddroit='+intToSTR(aiguillage[i].Ddroit)+aiguillage[i].DdroitB; s:=s+' Ddevie='+intToSTR(aiguillage[i].DDevie)+aiguillage[i].DdevieB; s:=s+' Adroit='+intToSTR(aiguillage[i].Adroit)+aiguillage[i].AdroitB; s:=s+' Adevie='+intToSTR(aiguillage[i].ADevie)+aiguillage[i].AdevieB; - if (aiguillage[i].modele=tjs) then + if (aiguillage[i].modele=tjs) then s:=s+' L='+IntToSTR(aiguillage[i].tjsInt)+aiguillage[i].tjsIntB; end; if aiguillage[i].modele=triple then s:=s+' Dévié2='+intToSTR(aiguillage[i].ADevie2)+aiguillage[i].ADevie2B; @@ -7875,7 +8063,7 @@ begin if pos('ERR=200',commandeCDM)<>0 then s:='Erreur CDM : réseau non chargé '; if pos('ERR=500',commandeCDM)<>0 then s:='Erreur CDM : serveur DCC non lancé '; if pos('ERR=300',commandeCDM)<>0 then s:='Erreur CDM : train non trouvé '; - j:=pos('MSG=',commandeCDM);if j<>0 then s:=s+copy(commandeCDM,j,i-j); + j:=pos('MSG CDM : ',commandeCDM);if j<>0 then s:=s+copy(commandeCDM,j,i-j); Affiche(s,clred); delete(commandeCDM,1,i); end; @@ -8016,7 +8204,8 @@ begin end; end; - // évènement détecteur + // évènement détecteur. Si det=1, Le nom du train est souvent _NONE + // si det=0 le nom du train est toujours _NONE posDT:=pos('CMDACC-ST_DT',commandeCDM); if posDT<>0 then begin @@ -8032,14 +8221,15 @@ begin train:=copy(commandeCDM,i+6,j-i-6); delete(commandeCDM,i,7); - //Affiche('Train=*'+Train+'*',clOrange); + //Affiche('Train='+Train,clOrange); i:=posEx('STATE=',commandeCDM,posDT);ss:=copy(commandeCDM,i+6,10); val(ss,etat,erreur); Delete(commandeCDM,i,7); if (train='_NONE') then train:=detecteur[Adr].train; + Event_detecteur(Adr,etat=1,train); + //Affiche(train,clYellow); //Affiche(IntToSTR(adr)+' '+IntToSTR(etat)+' '+train,clyellow); - if AfficheDet then Affiche('Rétro Détecteur '+intToSTR(adr)+'='+IntToStr(etat),clYellow); end ; // évènement signal - non stocké ni interprété @@ -8074,8 +8264,8 @@ begin Delete(commandeCDM,posAC,i-posAC); i:=pos(';',commandeCDM); if i<>0 then Delete(commandeCDM,1,i); - if AfficheDet then - Affiche('Actionneur AD='+intToSTR(adr)+' Nom='+intToSTR(name)+' Train='+train+' Etat='+IntToSTR(etat),clyellow); + if AffAigDet then + AfficheDebug('Actionneur AD='+intToSTR(adr)+' Nom='+intToSTR(name)+' Train='+train+' Etat='+IntToSTR(etat),clyellow); Event_act(adr,0,etat,train); // déclenche évent actionneur end; @@ -8195,7 +8385,7 @@ begin begin s:=s+' SIG Nbrefeux='+IntToSTR(feux[i].aspect)+' '; s:=s+' Det='+IntToSTR(feux[i].Adr_det1); - s:=s+' El_Suiv1='+IntToSTR(feux[i].Adr_el_suiv1)+' Type suiv1='+intToSTR(BTypeToNum(feux[i].Btype_suiv1)); + s:=s+' El_Suiv1='+IntToSTR(feux[i].Adr_el_suiv1)+' Type suiv1='+BTypeToNum(feux[i].Btype_suiv1); case feux[i].Btype_suiv1 of det : s:=s+' (det) '; aig,tjs,tjd : s:=s+' (aig ou TJD-S) '; @@ -8291,13 +8481,7 @@ begin end; -procedure TFormPrinc.ButtonRepriseClick(Sender: TObject); -var s : string; -begin - s:=#$21+#$81; - s:=checksum(s); - envoi(s); // envoi de la trame et attente Ack -end; + // lit un fichier de CV vers un accessoire procedure Lire_fichier_CV; @@ -8418,7 +8602,7 @@ begin Tformconfig.create(nil); FormConfig.PageControl.ActivePage:=Formconfig.TabSheetCDM; // force le premier onglet sur la page formconfig.showmodal; - formconfig.close; + // ne pas faire close : déja provoqué par le self de la fermeture end; procedure TFormPrinc.Codificationdesactionneurs1Click(Sender: TObject); @@ -8580,6 +8764,33 @@ begin end; end; +procedure TFormPrinc.Etatdeszonespartrain1Click(Sender: TObject); +var i,n,train,couleur : integer; + rien : boolean; + s : string; +begin + Affiche('',clyellow); + Affiche('Historique de l''état des zones par train',clWhite); + rien:=true; + for train:=1 to 20 do + begin + n:=TrainZone[train].Nbre; + //if n=0 then Affiche('Aucune zone n''a été activée',clOrange); + for i:=1 to n do + begin + rien:=false; + s:='Train='+intToSTR(train); + s:=s+' index='+intToSTR(i); + s:=s+' '+intToSTR(TrainZone[train].Zone[i].det1); + s:=s+' '+intToSTR(TrainZone[train].Zone[i].det2); + if i=n then s:=s+' Prev='+intToSTR(TrainPrevZone[train][1]); + couleur:=((train - 1) mod NbCouleurTrain) +1; + Affiche(s,CouleurTrain[couleur]); + end; + end; + if rien then Affiche('Aucune zone n''a été déclenchée',clOrange); +end; + procedure TFormPrinc.Apropos1Click(Sender: TObject); begin Affiche(' ',clyellow); @@ -8595,6 +8806,16 @@ begin FenRich.lines.add('http://cdmrail.free.fr/ForumCDR/viewtopic.php?f=77&t=3906'); RE_ColorLine(FenRich,FenRich.lines.count-1,clAqua); + Affiche('Ce programme pilote des signaux complexes de façon autonome ou avec CDM rail ',ClYellow); + Affiche('En fonction des détecteurs mis à 1 ou 0 par des locomotives',ClYellow); + Affiche('en circulation sur le réseau',ClYellow); + Affiche('En vert : Trames envoyées à l''interface',ClWhite); + Affiche('En violet : Trames brutes reçues de l''interface',ClWhite); + Affiche('En rouge : erreurs et défauts',ClWhite); + Affiche('En orange : pilotage des signaux / erreurs mineures',ClWhite); + Affiche('En bleu : pilotage des aiguillages',ClWhite); + Affiche('En jaune : rétrosignalisation reçue depuis l''interface',ClWhite); + Affiche(' ',clyellow); end; @@ -8732,11 +8953,43 @@ begin zone_TCO(518,515,1); end; - - - - +procedure TFormPrinc.Demanderlaversiondelacentrale1Click(Sender: TObject); +var s : string; begin + if portCommOuvert or parSocketLenz then + begin + s:=#$f0; + s:=checksum(s); + envoi(s); + end + else Affiche('L''interface XpressNet n''est pas connectée par USB ou par Ethernet',clorange); +end; + +procedure TFormPrinc.Demandetatdesaiguillages1Click(Sender: TObject); +begin + if portCommOuvert or parSocketLenz then demande_etat_acc + else Affiche('L''interface XpressNet n''est pas connectée par USB ou par Ethernet',clorange); +end; + + +procedure TFormPrinc.RepriseDCC1Click(Sender: TObject); +var s : string; +begin + if portCommOuvert or parSocketLenz then + begin + s:=#$21+#$81; + s:=checksum(s); + envoi(s); // envoi de la trame et attente Ack + end + else Affiche('L''interface XpressNet n''est pas connectée par USB ou par Ethernet',clorange); +end; + +procedure TFormPrinc.BoutonRazTrainsClick(Sender: TObject); +begin + Affiche('Raz tous trains et routes',clLime); + Raz_tout; +end; + end. diff --git a/UnitSR.dcu b/UnitSR.dcu index ea66fb7..99e977a 100644 Binary files a/UnitSR.dcu and b/UnitSR.dcu differ diff --git a/UnitSimule.dcu b/UnitSimule.dcu index ef004ad..2a6c643 100644 Binary files a/UnitSimule.dcu and b/UnitSimule.dcu differ diff --git a/UnitSimule.pas b/UnitSimule.pas index dd65b56..48140d1 100644 --- a/UnitSimule.pas +++ b/UnitSimule.pas @@ -71,7 +71,8 @@ begin if s[1]='=' then delete(s,1,1); if s[1]=' ' then delete(s,1,1); val(s,k,erreur); - Tablo_simule[index_simule].detecteur:=k; + Tablo_simule[index_simule].adresse:=k; + Tablo_simule[index_simule].modele:=det; i:=pos('=',s); if i<>0 then begin @@ -96,18 +97,20 @@ begin if s[1]='=' then delete(s,1,1); if s[1]=' ' then delete(s,1,1); val(s,k,erreur); - Tablo_simule[index_simule].aiguillage:=k; + Tablo_simule[index_simule].adresse:=k; + Tablo_simule[index_simule].modele:=aig; i:=pos('=',s); if i<>0 then begin Delete(s,1,i); val(s,k,erreur); - Tablo_simule[index_simule].etat:=k; + if (k=1) or (k=2) then Tablo_simule[index_simule].etat:=k + else Affiche('Erreur 622 : Position aiguillage '+intToSTR(Tablo_simule[index_simule].adresse)+' inconnue dans le fichier de simulation',clred); {s:=IntToSTR(Index_simule)+' Tick='+intToSTR(Tablo_simule[index_simule].tick)+ - ' Aiguillage='+intToSTR(Tablo_simule[index_simule].aiguillage)+ + ' Aiguillage='+intToSTR(Tablo_simule[index_simule].adresse)+ '='+intToSTR(Tablo_simule[index_simule].etat); - Affiche(s,ClLime); } + Affiche(s,ClLime); } inc(index_simule); end; @@ -120,7 +123,6 @@ begin dec(index_simule); closeFile(fte); formprinc.ButtonArretSimu.Visible:=true; - formprinc.ButtonArretSimu.top:=88; FormSimulation.Close; end; diff --git a/UnitTCO.dcu b/UnitTCO.dcu index ee4d2fc..411c342 100644 Binary files a/UnitTCO.dcu and b/UnitTCO.dcu differ diff --git a/UnitTCO.dfm b/UnitTCO.dfm index 34b51df..08cfe2e 100644 --- a/UnitTCO.dfm +++ b/UnitTCO.dfm @@ -1,6 +1,6 @@ object FormTCO: TFormTCO - Left = 117 - Top = 151 + Left = 151 + Top = 72 Width = 1139 Height = 694 VertScrollBar.Visible = False diff --git a/UnitTCO.pas b/UnitTCO.pas index 7350f49..afe74e1 100644 --- a/UnitTCO.pas +++ b/UnitTCO.pas @@ -3231,10 +3231,8 @@ begin s:='Erreur TCO: '; adresse:=tco[x,y].Adresse; i:=index_aig(adresse); - if i<>0 then - begin - s:=s+'position aiguillage '+intToSTR(adresse)+' inconnue'; - end; + if i=0 then s:=s+'aiguillage '+intToSTR(adresse)+' inconnu'; + if i<>0 then s:=s+'position aiguillage '+intToSTR(adresse)+' inconnue'; Affiche(s,clred); end; @@ -3297,7 +3295,11 @@ begin case Bimage of // voie 1 : begin - //if debugTCO then AfficheDebug('El 1',clyellow); + if debugTCO then + begin + s:='El 1';if adresse<>0 then s:=s+'adr='+intToStr(adresse); + AfficheDebug(s,clyellow); + end; if ancienX0 then begin j:=Index_Aig(adresse); - pos:=aiguillage[j].position; - if (pos=const_inconnu) then begin Erreur_TCO(x,y);exit;end; mdl:=aiguillage[j].modele; - if mdl=tjd then + if (mdl=tjs) or (mdl=tjd) then begin - j:=Index_Aig(aiguillage[j].Ddroit); - pos2:=aiguillage[j].position; // 2eme adresse de la TJD - if (pos2=const_inconnu) then Erreur_TCO(x,y); - if (pos=const_droit) and (pos2=const_droit) then + // tjd ou tjs + pos:=aiguillage[j].position; + if (pos=const_inconnu) then begin Erreur_TCO(x,y);exit;end; + + if (mdl=tjd) or (mdl=tjs) and (aiguillage[j].EtatTJD=4) then begin - if ancienXx) and (ancienY=Y) then xn:=x-1; if (ancienXY) then begin xn:=x+1;yn:=y-1;end; @@ -3445,70 +3455,72 @@ begin end; // TJD ou croisement 22 : begin - // tjd ou tjs - //if debugTCO then AfficheDebug('El 22',clyellow); - if adresse<>0 then + //if debugTCO then AfficheDebug('El 22',clyellow); + mdl:=rien; + if adresse<>0 then begin j:=Index_Aig(adresse); - pos:=aiguillage[j].position; - if (pos=const_inconnu) then begin Erreur_TCO(x,y);exit;end; mdl:=aiguillage[j].modele; - if mdl=tjd then + if (mdl=tjd) or (mdl=tjs) then begin - j:=Index_Aig(aiguillage[j].Ddroit); - pos2:=aiguillage[j].position; // 2eme adresse de la TJD - if (pos2=const_inconnu) then begin Erreur_TCO(x,y);exit;end; - if (pos=const_droit) and (pos2=const_droit) then + pos:=aiguillage[j].position; + if (pos=const_inconnu) then begin Erreur_TCO(x,y);exit;end; + + if (mdl=tjd) or (mdl=tjs) and (aiguillage[j].EtatTJD=4) then begin - if ancienXx) and (ancienY=Y) then xn:=x-1; if (ancienX>x) and (ancienY>Y) then begin xn:=x-1;yn:=y-1;end; if (ancienX