diff --git a/ConfigGenerale.cfg b/ConfigGenerale.cfg index 70db4d9..fa9e3f4 100644 --- a/ConfigGenerale.cfg +++ b/ConfigGenerale.cfg @@ -1,5 +1,5 @@ /****************************************** -/ fichier de configuration de client-GL.log +/ fichier de configuration / gily - f1iwq - 2018 /****************************************** / ce programme permet de commander les signaux complexes avec ou sans @@ -18,7 +18,7 @@ / / / Taille de la fonte de la fenêtre -Fonte=16 +Fonte=10 / / Adresse IP V4 du PC sur lequel s'execute CDM : port IpV4_PC=127.0.0.1:9999 @@ -60,6 +60,9 @@ Init_Aig=1 /Temporisation entre aiguillages en ms à l'initialisation en mode autonome Tempo_Aig=100 / +/ Temporisation entre deux commandes aux décodeurs de feux en ms +Tempo_Feu=100 +/ / Fenêtre d'exécution en plein écran (1) ou réduite (0) Fenetre=0 / @@ -100,34 +103,34 @@ Serveur_interface=1 retro=1 RazSignaux=0 [section_aig] -1,P518,D523,S3P,V30,I0,INIT(2,3) -2,P12S,D519,S5S,V0,I0,INIT(2,3) -3,P1S,D4P,S5D,V0,I0,INIT(2,3) -4,P3D,D6S,S514,V0,I0,INIT(2,3) -5,P515,D3S,S2S,V0,I0,INIT(1,3) -6,P516,D0,S4D,V0,I0,INIT(2,3) -7,P527,D519,S520,V0,I0,INIT(1,3) -8,P527,D521,S522,V0,I0,INIT(2,3) -9,P526,D513,S515,V60,I0,INIT(2,3) -10,P19P,D29P,S528,V30,I0,INIT(2,3) -11,P18P,D30D,S525,V0,I0,INIT(2,3) -12,P517,D20S,S2P,V0,I0,INIT(1,3) -17,P525,D535,S528,V0,I0,INIT(1,3) -18,P11P,D23P,S517,V0,I0,INIT(2,4) -19,P10P,D22P,S531,V0,I0,INIT(1,4) -20,P520,D21P,S12D,V0,I0,INIT(2,4) -21,P20D,D28D,S28D,V0,I0,INIT(2,3) -22,P19D,D537,S538,V0,I0,INIT(1,3) -23,P18D,D538,S534,V0,I0,INIT(1,3) -24,P538,D32S,S533,V0,I0,INIT(1,3) -25,P31S,D529,S27P,V0,I0,INIT(1,3) -26TJD,D(530,28D),S(529,28S),V0,I0,INIT(2,3),E4 -27,P25S,D530,S537,V0,I0,INIT(2,3) -28TJD,D(21D,26D),S(21S,26S),V0,I0,INIT(2,3),E4 -29,P10D,D513,S30S,V60,I0,INIT(2,3) -30,P524,D11D,S29D,V0,I0,INIT(2,3) -31,P534,D0,S25P,V0,I0,INIT(1,3) -32,P22S,D0,S24D,V0,I0,INIT(1,3) +1,P518,D523,S3P,V30,I0,INIT(9,5) +2,P12S,D519,S5S,V0,I0,INIT(9,5) +3,P1S,D4P,S5D,V0,I0,INIT(9,5) +4,P3D,D6S,S514,V0,I0,INIT(9,5) +5,P515,D3S,S2S,V0,I0,INIT(9,5) +6,P516,D0,S4D,V0,I0,INIT(9,5) +7,P527,D519,S520,V0,I0,INIT(9,5) +8,P527,D521,S522,V0,I0,INIT(9,5) +9,P526,D513,S515,V60,I0,INIT(9,5) +10,P19P,D29P,S528,V30,I0,INIT(9,5) +11,P18P,D30D,S525,V0,I0,INIT(9,5) +12,P517,D20S,S2P,V0,I0,INIT(9,5) +17,P525,D535,S528,V0,I0,INIT(9,5) +18,P11P,D23P,S517,V0,I0,INIT(9,5) +19,P10P,D22P,S531,V0,I0,INIT(9,5) +20,P520,D21P,S12D,V0,I0,INIT(9,5) +21,P20D,D28D,S28D,V0,I0,INIT(9,5) +22,P19D,D537,S538,V0,I0,INIT(9,5) +23,P18D,D538,S534,V0,I0,INIT(9,5) +24,P538,D32S,S533,V0,I0,INIT(9,5) +25,P31S,D529,S27P,V0,I0,INIT(9,5) +26TJD,D(530,28D),S(529,28S),V0,I0,INIT(9,5),E4 +27,P25S,D530,S537,V0,I0,INIT(9,5) +28TJD,D(21D,26D),S(21S,26S),V0,I0,INIT(9,5),E4 +29,P10D,D513,S30S,V60,I0,INIT(9,5) +30,P524,D11D,S29D,V0,I0,INIT(9,5) +31,P534,D0,S25P,V0,I0,INIT(9,5) +32,P22S,D0,S24D,V0,I0,INIT(9,5) 0 [section_branches] A2,A12,517,A18,A11,A30,524,521,A8,527,A7,519,A2 @@ -156,8 +159,8 @@ A31,0 302,9,0,1,(526,A9),1 316,7,1,1,(515,A5),1 330,7,0,1,(519,A2),1 -320,9,0,1,(528,A10),1 -344,9,0,1,(517,A18),1 +344,9,0,1,(528,A10),1 +358,9,0,1,(517,A18),1 372,D3,1,(A10D)(A19S)(A19D,A22D)(A19D,A22S) 382,D3,1,(A29S,A10S)(A19S)(A19D,A22D)(A19D,A22S) 392,3,0,1,(535,533),1 diff --git a/Notice avancée pour les signaux complexes GL.pdf b/Notice avancée pour les signaux complexes GL.pdf index 8ebb65b..05919ae 100644 Binary files a/Notice avancée pour les signaux complexes GL.pdf and b/Notice avancée pour les signaux complexes GL.pdf differ diff --git a/Notice d'utilisation des signaux_complexes_GL_V3.5.pdf b/Notice d'utilisation des signaux_complexes_GL_V3.6.pdf similarity index 75% rename from Notice d'utilisation des signaux_complexes_GL_V3.5.pdf rename to Notice d'utilisation des signaux_complexes_GL_V3.6.pdf index dafe863..c366841 100644 Binary files a/Notice d'utilisation des signaux_complexes_GL_V3.5.pdf and b/Notice d'utilisation des signaux_complexes_GL_V3.6.pdf differ diff --git a/Signaux_complexes_GL.cfg b/Signaux_complexes_GL.cfg index 96ac18b..fb83b3c 100644 --- a/Signaux_complexes_GL.cfg +++ b/Signaux_complexes_GL.cfg @@ -31,5 +31,5 @@ -M -$M16384,1048576 -K$00400000 --LE"c:\program files\borland\delphi7\Projects\Bpl" --LN"c:\program files\borland\delphi7\Projects\Bpl" +-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl" +-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl" diff --git a/UnitConfig.dcu b/UnitConfig.dcu index 6e615c9..2bc5e8d 100644 Binary files a/UnitConfig.dcu and b/UnitConfig.dcu differ diff --git a/UnitConfig.dfm b/UnitConfig.dfm index f2802e1..5d417a0 100644 --- a/UnitConfig.dfm +++ b/UnitConfig.dfm @@ -6,7 +6,7 @@ object FormConfig: TFormConfig 'ies' BorderStyle = bsDialog Caption = 'Configuration g'#233'n'#233'rale' - ClientHeight = 501 + ClientHeight = 526 ClientWidth = 902 Color = clBtnFace Font.Charset = DEFAULT_CHARSET @@ -1555,7 +1555,7 @@ object FormConfig: TFormConfig end object ButtonAppliquerEtFermer: TButton Left = 384 - Top = 472 + Top = 496 Width = 201 Height = 25 Caption = 'Enregistre la configuration et Fermer' @@ -1566,7 +1566,7 @@ object FormConfig: TFormConfig end object Button2: TButton Left = 24 - Top = 472 + Top = 496 Width = 201 Height = 25 Caption = 'Fermer sans enregistrer la configuration' @@ -1577,8 +1577,8 @@ object FormConfig: TFormConfig Left = 8 Top = 8 Width = 633 - Height = 457 - ActivePage = TabSheetCDM + Height = 481 + ActivePage = TabSheetSig Font.Charset = DEFAULT_CHARSET Font.Color = clBlack Font.Height = -11 @@ -1589,6 +1589,14 @@ object FormConfig: TFormConfig OnChange = PageControlChange object TabSheetCDM: TTabSheet Caption = 'CDM Rail' + object Label36: TLabel + Left = 8 + Top = 424 + Width = 255 + Height = 13 + Caption = 'Param'#232'tres de connexion et d'#39#233'change avec CDM rail' + WordWrap = True + end object GroupBox1: TGroupBox Left = 16 Top = 8 @@ -1937,7 +1945,7 @@ object FormConfig: TFormConfig ImageIndex = 1 object Label9: TLabel Left = 8 - Top = 400 + Top = 424 Width = 294 Height = 13 Caption = 'Ces param'#232'tres sont utilis'#233's en fonctionnement sans CDM Rail' @@ -2161,26 +2169,15 @@ object FormConfig: TFormConfig Height = 13 Caption = 'Temporisation de s'#233'quencement d'#39'init (ms)' end - object CheckBoxRazSignaux: TCheckBox - Left = 8 - Top = 16 - Width = 177 - Height = 17 - Hint = 'Envoie un 0 apr'#232's chaque commande sur un signal au d'#233'codeur' - Caption = 'Raz signaux apr'#232's commande' - ParentShowHint = False - ShowHint = True - TabOrder = 0 - end object CheckBoxInitAig: TCheckBox - Left = 8 - Top = 32 - Width = 281 + Left = 16 + Top = 24 + Width = 257 Height = 25 Caption = 'Initialisation des aiguillages ' ParentShowHint = False ShowHint = False - TabOrder = 1 + TabOrder = 0 WordWrap = True end object EditTempoAig: TEdit @@ -2188,7 +2185,7 @@ object FormConfig: TFormConfig Top = 62 Width = 41 Height = 21 - TabOrder = 2 + TabOrder = 1 Text = 'EditTempoAig' end end @@ -2743,6 +2740,13 @@ object FormConfig: TFormConfig 'Liste de mod'#233'lisation des signaux du fichier config.cfg - clique' + 'z sur une ligne pour afficher la description du signal' end + object Label35: TLabel + Left = 40 + Top = 428 + Width = 201 + Height = 13 + Caption = 'Temporisation entre deux commandes (ms)' + end object GroupBox12: TGroupBox Left = 336 Top = 32 @@ -2978,7 +2982,6 @@ object FormConfig: TFormConfig Width = 33 Height = 21 TabOrder = 0 - Text = ' ' OnChange = EditAdrSigChange end object ComboBoxAsp: TComboBox @@ -3039,6 +3042,7 @@ object FormConfig: TFormConfig Height = 25 Caption = 'Configuration' TabOrder = 16 + Visible = False OnClick = ButtonConfigSRClick end end @@ -3046,7 +3050,7 @@ object FormConfig: TFormConfig Left = 0 Top = 56 Width = 329 - Height = 369 + Height = 345 Color = clBlack Font.Charset = DEFAULT_CHARSET Font.Color = clYellow @@ -3089,6 +3093,25 @@ object FormConfig: TFormConfig TabOrder = 4 OnClick = ButtonInsFeuClick end + object CheckBoxRazSignaux: TCheckBox + Left = 0 + Top = 402 + Width = 169 + Height = 17 + Hint = 'Envoie un 0 apr'#232's chaque commande sur un signal aux d'#233'codeurs' + Caption = 'Raz signaux apr'#232's commande' + ParentShowHint = False + ShowHint = True + TabOrder = 5 + end + object EditTempoFeu: TEdit + Left = 0 + Top = 424 + Width = 33 + Height = 21 + TabOrder = 6 + OnChange = EditTempoFeuChange + end end object TabSheetAct: TTabSheet Caption = 'Actionneurs/D'#233'tecteurs' diff --git a/UnitConfig.pas b/UnitConfig.pas index 9bcf3a0..6d1ffa6 100644 --- a/UnitConfig.pas +++ b/UnitConfig.pas @@ -82,7 +82,6 @@ type Memo3: TMemo; Memo4: TMemo; GroupBox9: TGroupBox; - CheckBoxRazSignaux: TCheckBox; GroupBox11: TGroupBox; LabelAdresse: TLabel; GroupBox10: TGroupBox; @@ -238,6 +237,10 @@ type EditSon: TEdit; LabelNomSon: TLabel; SpeedButtonJoue: TSpeedButton; + CheckBoxRazSignaux: TCheckBox; + EditTempoFeu: TEdit; + Label35: TLabel; + Label36: TLabel; procedure ButtonAppliquerEtFermerClick(Sender: TObject); procedure FormActivate(Sender: TObject); procedure FormCreate(Sender: TObject); @@ -330,6 +333,7 @@ type procedure RadioButtonSonClick(Sender: TObject); procedure EditSonChange(Sender: TObject); procedure SpeedButtonJoueClick(Sender: TObject); + procedure EditTempoFeuChange(Sender: TObject); private { Déclarations privées } public @@ -354,6 +358,7 @@ CDM_ch='CDM'; Serveur_interface_ch='Serveur_interface'; fenetre_ch='Fenetre'; Tempo_aig_ch='Tempo_Aig'; +Tempo_Feu_ch='Tempo_Feu'; NOTIF_VERSION_ch='NOTIF_VERSION'; verif_version_ch='verif_version'; Fonte_ch='Fonte'; @@ -519,9 +524,18 @@ begin // demande des services services_CDM; - // demande les trains mais on ne l'utilise pas! + // 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 @@ -875,7 +889,7 @@ begin if (j=2) then feux[i].Adr_det2:=adr; if (j=3) then feux[i].Adr_det3:=adr; if (j=4) then feux[i].Adr_det4:=adr; - //type de l'élément suivant (1=détecteur 2=aig ou TJD ou TJS 4=tri + //type de l'élément suivant (1=détecteur 2=aig ou TJD ou TJS 4=tri if s[1]='A' then begin if (j=1) then feux[i].Btype_Suiv1:=aig; @@ -1162,6 +1176,10 @@ begin writeln(fichierN,'RazSignaux='+s); //copie_commentaire; + // temporisation entre 2 commandes décodeurs feu + writeln(fichierN,Tempo_feu_ch+'=',IntToSTR(Tempo_feu)); + copie_commentaire; + // aiguillages writeln(fichierN,section_aig_ch); for i:=1 to MaxAiguillage do @@ -1226,7 +1244,7 @@ var s,sa,chaine,SOrigine: string; trouve_sec_init,trouve_init_aig,trouve_lay,trouve_IPV4_INTERFACE,trouve_PROTOCOLE_SERIE,trouve_INTER_CAR, trouve_Tempo_maxi,trouve_Entete,trouve_tco,trouve_cdm,trouve_Serveur_interface,trouve_fenetre, trouve_NOTIF_VERSION,trouve_verif_version,trouve_fonte,trouve_tempo_aig,trouve_raz,trouve_section_aig, - pds,trouve_section_branche,trouve_section_sig,trouve_section_act,fichier_trouve : boolean; + pds,trouve_section_branche,trouve_section_sig,trouve_section_act,fichier_trouve,trouve_tempo_feu : boolean; bd,virgule,i_detect,i,erreur,aig2,detect,offset,index, adresse,j,position,temporisation,invers,indexPointe,indexDevie,indexDroit, ComptEl,Compt_IT,Num_Element,k,modele,adr,adr2,erreur2,l,t,Nligne,postriple,itl, postjd,postjs,nv,it,Num_Champ,asp,adraig : integer; @@ -1901,6 +1919,18 @@ begin val(s,Tempo_Aig,erreur); end; + // temporisation décodeurs de feux + sa:=uppercase(Tempo_Feu_ch)+'='; + i:=pos(sa,s); + if i<>0 then + begin + inc(nv); + trouve_Tempo_feu:=true; + delete(s,i,length(sa)); + val(s,Tempo_Feu,erreur); + if tempo_Feu=0 then Tempo_feu:=100; + end; + sa:=uppercase(verif_version_ch)+'='; i:=pos(sa,s); if i<>0 then @@ -2052,6 +2082,7 @@ begin trouve_sec_init:=false; trouve_init_aig:=false; trouve_tempo_aig:=false; + trouve_tempo_feu:=false; trouve_INTER_CAR:=false; trouve_entete:=false; trouve_IPV4_INTERFACE:=false; @@ -2175,6 +2206,12 @@ begin if not(trouve_Serveur_interface) then s:=Serveur_interface_ch; if not(trouve_fenetre) then s:=fenetre_ch; if not(trouve_tempo_aig) then s:=tempo_aig_ch; + if not(trouve_tempo_feu) then + begin + s:=tempo_feu_ch; + tempo_feu:=100; + s:=''; + end; if not(trouve_NOTIF_VERSION) then s:=NOTIF_VERSION_ch; if not(trouve_verif_version) then s:=verif_version_ch; if not(trouve_fonte) then s:=fonte_ch; @@ -2214,7 +2251,7 @@ begin // contrôle adresse IP interface s:=EditIPLenz.text; - if not(IpOk(s)) and (s<>'0') then begin labelInfo.Caption:='Adresse IP Lenz incorrecte';sauve_config:=false;exit;end; + if not(IpOk(s)) and (s<>'0') then begin labelInfo.Caption:='Adresse IP interface Xpressnet incorrecte';sauve_config:=false;exit;end; changeInterface:=s<>AdresseIP; AdresseIP:=s; @@ -2418,7 +2455,8 @@ begin EditDevie_HD.ReadOnly:=false; EditDroit_BD.ReadOnly:=false; Edit_HG.ReadOnly:=false; - + + EditTempoFeu.Text:=IntToSTR(Tempo_feu); EditNbDetDist.text:=IntToSTR(Nb_Det_dist); EditAdrIPCDM.text:=adresseIPCDM; EditPortCDM.Text:=IntToSTR(portCDM); @@ -3332,7 +3370,8 @@ begin Aiguillage[index].Adroit:=adr; Aiguillage[index].AdroitB:=B; - + Edit_HG.Hint:=TypeElAIg_to_char(adr,B); + // réencoder la ligne s:=encode_aig(index); formconfig.RichAig.Lines[ligneclicAig]:=s; @@ -3378,6 +3417,7 @@ begin if b=#0 then b:='Z'; Aiguillage[Index].ADevie:=adr; Aiguillage[Index].ADevieB:=B; + EditDevie_HD.Hint:=TypeElAIg_to_char(adr,B); // réencoder la ligne s:=encode_aig(Index); formconfig.RichAig.Lines[ligneclicAig]:=s; @@ -3424,7 +3464,7 @@ begin // ne pas traiter si on a cliqué sur la liste if clicliste then exit; if affevt then affiche('Evt change droit',clyellow); - + if FormConfig.PageControl.ActivePage=FormConfig.TabSheetAig then with Formconfig do begin @@ -3447,6 +3487,7 @@ begin if b=#0 then b:='Z'; Aiguillage[index].ADroit:=adr; Aiguillage[index].ADroitB:=B; + EditDroit_BD.Hint:=TypeElAIg_to_char(adr,B); // réencoder la ligne s:=encode_aig(Index); formconfig.RichAig.Lines[ligneclicAig]:=s; @@ -3531,6 +3572,7 @@ begin s:=encode_aig(index); formconfig.RichAig.Lines[ligneclicAig]:=s; end; + EditPointe_BG.Hint:=TypeElAIg_to_char(adr,B); end else LabelInfo.caption:='Erreur pointe aiguillage '+intToSTR(AdrAig); @@ -3704,9 +3746,10 @@ var s: string; begin // Affiche(IntToStr(ComboBoxDec.ItemIndex),clyellow); if clicListe then exit; - + if NbreFeux'') and (erreur<>0) then begin LabelInfo.caption:='Erreur temporisation décodeurs ';exit;end; + LabelInfo.caption:=' '; + tempo_feu:=i; +end; + procedure Suiv1; var s : string; i,erreur : integer; @@ -4075,7 +4129,8 @@ begin if radioButtonLoc.Checked or RadioButtonAccess.Checked or RadioButtonSon.Checked then begin Val(s,act,erreur); - det:=s[erreur]='Z'; // si détecteur + if s='' then exit; + det:=pos('Z',s)<>0; // si détecteur if det then s2:='Détecteur ' else s2:='Actionneur '; s2:=s2+intToSTR(act); EditAct.Hint:=s2; @@ -4299,9 +4354,10 @@ begin with Formconfig do begin s:=EditAdrSig.Text; + if (s='') or (ligneClicSig<0) then exit; Val(s,i,erreur); - if (erreur<>0) or (i<=0) or (i>MaxAcc) then - begin + if (erreur<>0) or (i<=0) or (i>MaxAcc) then + begin EditAdrSig.Color:=clred; LabelInfo.caption:='Erreur adresse signal ';exit; end; @@ -4310,14 +4366,14 @@ begin EditAdrSig.Color:=clred; LabelInfo.caption:='Signal '+intToSTR(i)+' existe, il ne sera pas écrasé';exit; end; - + EditAdrSig.Color:=clWindow; LabelInfo.caption:=' '; feux[ligneClicSig+1].adresse:=i; s:=encode_sig_feux(ligneClicSig+1); - RichSig.Lines[ligneClicSig]:=s; + RichSig.Lines[ligneClicSig]:=s; Feux[ligneClicSig+1].Lbl.caption:='@'+IntToSTR(i); - end; + end; end; @@ -4411,8 +4467,9 @@ begin 4 : aspect:=7; 5 : aspect:=9; else aspect:=i+6; - end; + end; index:=ligneClicSig+1; // index du feu + if index<1 then exit; if NbreFeux SimplePanel = True @@ -1281,7 +1281,7 @@ object FormPrinc: TFormPrinc 00020000802500000000080000000000000000003F00000011000000} end object Panel1: TPanel - Left = 903 + Left = 904 Top = 5 Width = 282 Height = 132 @@ -1310,22 +1310,13 @@ object FormPrinc: TFormPrinc WordWrap = True OnClick = BoutVersionClick end - object loco: TButton - Left = 190 - Top = 88 - Width = 83 - Height = 33 - Caption = 'loco' - TabOrder = 2 - OnClick = locoClick - end object ButtonInfo: TButton Left = 104 Top = 48 Width = 81 Height = 33 Caption = 'Informations' - TabOrder = 3 + TabOrder = 2 OnClick = ButtonInfoClick end object ButtonReprise: TButton @@ -1337,7 +1328,7 @@ object FormPrinc: TFormPrinc '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 = 4 + TabOrder = 3 OnClick = ButtonRepriseClick end object ButtonTest: TButton @@ -1346,7 +1337,7 @@ object FormPrinc: TFormPrinc Width = 89 Height = 33 Caption = 'Demande '#233'tat aiguillages' - TabOrder = 5 + TabOrder = 4 WordWrap = True OnClick = ButtonTestClick end @@ -1356,7 +1347,7 @@ object FormPrinc: TFormPrinc Width = 89 Height = 33 Caption = 'Arret simulation' - TabOrder = 6 + TabOrder = 5 Visible = False WordWrap = True OnClick = ButtonArretSimuClick @@ -1367,7 +1358,7 @@ object FormPrinc: TFormPrinc Width = 81 Height = 33 Caption = 'Affiche TCO' - TabOrder = 7 + TabOrder = 6 OnClick = ButtonAffTCOClick end object ButtonLanceCDM: TButton @@ -1377,12 +1368,21 @@ object FormPrinc: TFormPrinc Height = 33 Hint = 'Lance CDM Rail' Caption = 'Lance CDM rail' - TabOrder = 8 + TabOrder = 7 OnClick = ButtonLanceCDMClick end + object ButtonLocCV: TButton + Left = 192 + Top = 88 + Width = 81 + Height = 33 + Caption = 'Trains / CVs' + TabOrder = 8 + OnClick = ButtonLocCVClick + end end object Panel2: TPanel - Left = 904 + Left = 905 Top = 144 Width = 281 Height = 25 @@ -1421,7 +1421,7 @@ object FormPrinc: TFormPrinc object FenRich: TRichEdit Left = 8 Top = 32 - Width = 617 + Width = 618 Height = 529 Anchors = [akLeft, akTop, akRight, akBottom] Color = clBlack @@ -1437,9 +1437,10 @@ object FormPrinc: TFormPrinc TabOrder = 7 WordWrap = False OnChange = FenRichChange + OnMouseDown = FenRichMouseDown end object GroupBox2: TGroupBox - Left = 632 + Left = 681 Top = 64 Width = 265 Height = 105 @@ -1456,7 +1457,7 @@ object FormPrinc: TFormPrinc end object LabelVCV: TLabel Left = 208 - Top = 55 + Top = 15 Width = 47 Height = 13 Caption = 'Valeur CV' @@ -1500,6 +1501,63 @@ object FormPrinc: TFormPrinc TabOrder = 3 end end + object GroupBox3: TGroupBox + Left = 632 + Top = 64 + Width = 265 + Height = 105 + Anchors = [akTop, akRight] + Caption = 'Commande vitesse trains' + TabOrder = 9 + object Label4: TLabel + Left = 8 + Top = 30 + Width = 67 + Height = 13 + Caption = 'Adresse train :' + end + object Label5: TLabel + Left = 8 + Top = 68 + Width = 74 + Height = 13 + Caption = 'Vitesse train % :' + end + object loco: TButton + Left = 142 + Top = 56 + Width = 83 + Height = 33 + Caption = 'Envoi '#224' loco' + TabOrder = 0 + OnClick = locoClick + end + object EditAdrTrain: TEdit + Left = 80 + Top = 24 + Width = 25 + Height = 21 + TabOrder = 1 + OnChange = EditAdrTrainChange + end + object EditVitesse: TEdit + Left = 80 + Top = 64 + Width = 25 + Height = 21 + TabOrder = 2 + Text = '30' + end + object ComboTrains: TComboBox + Left = 112 + Top = 24 + Width = 145 + Height = 21 + ItemHeight = 13 + TabOrder = 3 + OnChange = ComboTrainsChange + end + end object Timer1: TTimer Interval = 100 OnTimer = Timer1Timer diff --git a/UnitPrinc.pas b/UnitPrinc.pas index 04dc8c9..82317d9 100644 --- a/UnitPrinc.pas +++ b/UnitPrinc.pas @@ -3,6 +3,7 @@ Unit UnitPrinc; programme signaux complexes Graphique Lenz delphi 7 + activeX Tmscomm + clientSocket ******************************************** + 8/2/2022 14h note sur le pilotage des accessoires: raquette octet sortie + 2 = aiguillage droit = sortie 2 de l'adresse d'accessoire @@ -14,7 +15,7 @@ Unit UnitPrinc; interface uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, OleCtrls, ExtCtrls, jpeg, ComCtrls, ShellAPI, TlHelp32, ImgList, ScktComp, StrUtils, Menus, ActnList, MSCommLib_TLB, MMSystem ; @@ -71,7 +72,6 @@ type Panel1: TPanel; BoutonRaf: TButton; BoutVersion: TButton; - loco: TButton; ButtonInfo: TButton; ButtonReprise: TButton; ButtonTest: TButton; @@ -103,6 +103,14 @@ type Proprits1: TMenuItem; N8: TMenuItem; Vrifierlacohrence: TMenuItem; + GroupBox3: TGroupBox; + loco: TButton; + ButtonLocCV: TButton; + EditAdrTrain: TEdit; + Label4: TLabel; + Label5: TLabel; + EditVitesse: TEdit; + ComboTrains: TComboBox; procedure FormCreate(Sender: TObject); procedure MSCommUSBLenzComm(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); @@ -160,6 +168,12 @@ type procedure ButtonDevieClick(Sender: TObject); procedure Proprits1Click(Sender: TObject); procedure VrifierlacohrenceClick(Sender: TObject); + procedure FenRichMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure ButtonLocCVClick(Sender: TObject); + procedure EditAdrTrainChange(Sender: TObject); + procedure Button1Click(Sender: TObject); + procedure ComboTrainsChange(Sender: TObject); private { Déclarations privées } procedure DoHint(Sender : Tobject); @@ -173,7 +187,6 @@ type const titre='Signaux complexes GL '; espY = 15; // espacement Y entre deux lignes de feux -tempoFeu=100; // tempo en ms d'espacement entre deux envois consécutifs à un décodeur MaxAcc=2048; // adresse maxi d'accessoire XpressNet LargImg=50;HtImg=91; // Dimensions image des feux const_droit=2; // positions aiguillages transmises par la centrale LENZ @@ -286,12 +299,12 @@ TFeu = record var ancien_tablo_signalCplx,EtatsignalCplx : array[0..MaxAcc] of word; - tempsCli,NbreFeux,pasreponse,AdrDevie,fenetre,Tempo_Aig, + tempsCli,NbreFeux,pasreponse,AdrDevie,fenetre,Tempo_Aig,Tempo_feu, NombreImages,signalCpx,branche_trouve,Indexbranche_trouve,Actuel,Signal_suivant, Nbre_recu_cdm,Tempo_chgt_feux,Adj1,Adj2,NbrePN,ServeurInterfaceCDM, - ServeurRetroCDM,TailleFonte,Nb_Det_Dist : integer; + ServeurRetroCDM,TailleFonte,Nb_Det_Dist,Tdoubleclic : integer; - Hors_tension2,traceSign,TraceZone,Ferme,parSocketLenz,ackCdm,PremierFD, + Hors_tension2,traceSign,TraceZone,Ferme,parSocketLenz,ackCdm,PremierFD,doubleclic, NackCDM,MsgSim,succes,recu_cv,AffActionneur,AffAigDet,Option_demarrage,AffTiers, TraceListe,clignotant,nack,Maj_feux_cours,configNulle,LanceCDM,AvecInitAiguillages : boolean; @@ -304,7 +317,7 @@ var tablo : array of byte; // tableau rx usb Enregistrement,chaine_Envoi,chaine_recue,Id_CDM,Af, entete,suffixe,ConfStCom,LAY : string; - maxaiguillage,detecteur_chgt,Temps,Tempo_init,Suivant, + maxaiguillage,detecteur_chgt,Temps,Tempo_init,Suivant,ntrains, NbreImagePligne,NbreBranches,Index2_det,Index2_aig,branche_det,Index_det, I_simule,maxTablo_act,NbreVoies,AdresseFeuSuivant,El_suivant : integer; Ancien_detecteur : array[0..1024] of boolean; // anciens état des détecteurs et adresses des détecteurs et leur état @@ -321,7 +334,7 @@ var Tablo_actionneur : array[1..100] of record loco,act,son : boolean; // type loco actionneur ou son - adresse,etat,fonction,tempo, + adresse,etat,fonction,tempo,TempoCourante, accessoire,sortie : integer; Raz : boolean; det : boolean; // désigne un détecteur @@ -345,7 +358,7 @@ var tick : longint; Detecteur,Aiguillage,etat : integer ; end; - TempoAct,RangActCours,N_Cv,index_simule,NDetecteurs,N_Trains,N_routes : integer; + N_Cv,index_simule,NDetecteurs,N_Trains,N_routes : integer; tablo_CV : array [1..255] of integer; couleur : Tcolor; @@ -356,9 +369,13 @@ var aiguillage : array[0..MaxAcc] of Taiguillage; // signaux - L'index du tableau n'est pas son adresse feux : array[1..MaxAcc] of Tfeu; + trains : array[1..100] of record + nom_train : string; + adresse,vitmax : integer; + end; Feu_supprime,Feu_sauve : Tfeu; Aig_supprime,Aig_sauve : TAiguillage; - + Fimage : Timage; BrancheN : array[1..100,1..200] of TBranche; // @@ -1198,11 +1215,11 @@ function Index_feu(adresse : integer) : integer; var i : integer; trouve : boolean; begin - i:=1; + i:=1; repeat trouve:=feux[i].adresse=adresse; if not(trouve) then inc(i); - until (trouve) or (i>=100); + until (trouve) or (i>NbreFeux); if trouve then Index_feu:=i else Index_feu:=0 ; end; @@ -1220,7 +1237,6 @@ begin if trouve then Index_Aig:=i else Index_Aig:=0 ; end; - // dessine l'aspect du feu en fonction de son adresse dans la partie droite de droite procedure Dessine_feu_mx(CanvasDest : Tcanvas;x,y : integer;FrX,frY : real;adresse : integer;orientation : integer); var i : integer; @@ -1260,15 +1276,15 @@ begin val(s,AdrPilote,erreur); if adrPilote=0 then exit; i:=Index_feu(AdrPilote); - + with Formpilote do begin TFormPilote.Create(Self); show; - + ImagePilote.top:=40;ImagePilote.left:=220; ImagePilote.Parent:=FormPilote; - ImagePilote.Picture.Bitmap.TransparentMode:=tmAuto; + ImagePilote.Picture.Bitmap.TransparentMode:=tmAuto; ImagePilote.Picture.Bitmap.TransparentColor:=clblue; ImagePilote.Transparent:=true; ImagePilote.Picture.BitMap:=Feux[i].Img.Picture.Bitmap; @@ -1337,15 +1353,15 @@ begin Hint:=s; onClick:=Formprinc.Imageonclick; // affectation procédure clique sur image - PopUpMenu:=Formprinc.PopupMenuFeu; // affectation popupmenu sur clic droit - - Picture.Bitmap.TransparentMode:=tmAuto; + PopUpMenu:=Formprinc.PopupMenuFeu; // affectation popupmenu sur clic droit + + Picture.Bitmap.TransparentMode:=tmAuto; Picture.Bitmap.TransparentColor:=clblue; Transparent:=true; // affecter le type d'image de feu dans l'image créée picture.Bitmap:=Select_dessin_feu(TypeFeu); - + // mettre rouge par défaut adresse:=Feux[rang].adresse; if TypeFeu=2 then EtatSignalCplx[adresse]:=violet_F; @@ -1503,7 +1519,7 @@ begin if not(ack) or nack then begin Affiche('Pas de réponse de l''interface',clRed);inc(pasreponse); - // &&&&if pasreponse>3 then hors_tension2:=true; + // &&&if pasreponse>3 then hors_tension2:=true; end; if ack then begin pasreponse:=0;hors_tension2:=false;end; end; @@ -1511,6 +1527,7 @@ begin envoi:=ack; end; +// chaîne pour une fonction F à un train via CDM Function chaine_CDM_Func(fonction,etat : integer;train : string) : string; var so,sx,s : string; begin @@ -1531,8 +1548,8 @@ begin chaine_CDM_Func:=so+s; end; -// chaîne pour vitesse train -function chaine_CDM_vitesse(vitesse:integer;train:string) : string; +// chaîne pour vitesse train string +function chaine_CDM_vitesseST(vitesse:integer;train:string) : string; var s,so,sx: string; begin { C-C-00-0002-CMDTRN-SPEED|0xx|02|NAME=nomdutrain;UREQ=vitesse; } @@ -1542,10 +1559,24 @@ begin sx:=format('%.*d',[2,2])+'|'; // 2 paramètres so:=so+ '|'+format('%.*d',[3,length(s)+length(sx)])+'|'+sx; - chaine_CDM_vitesse:=so+s; + chaine_CDM_vitesseST:=so+s; end; -// prépare la chaîne de commande pour un accessoire via CDM +// chaîne pour vitesse train INT (adresse) +function chaine_CDM_vitesseINT(vitesse:integer;train:integer) : string; +var s,so,sx: string; +begin + { C-C-00-0002-CMDTRN-SPEED|0xx|02|NAME=nomdutrain;UREQ=vitesse; } + so:=place_id('C-C-01-0004-CMDTRN-SPEED'); + s:=s+'AD='+intToSTR(train)+';'; + s:=s+'UREQ='+intToSTR(vitesse)+';'; + sx:=format('%.*d',[2,2])+'|'; // 2 paramètres + so:=so+ '|'+format('%.*d',[3,length(s)+length(sx)])+'|'+sx; + + chaine_CDM_vitesseINT:=so+s; +end; + +// chaîne pour un accessoire via CDM Function chaine_CDM_Acc(adresse,etat : integer) : string; var so,sx,s : string; begin @@ -1580,7 +1611,8 @@ begin envoi_cdm(s); end; -// active ou désactive une sortie par xpressnet. Une adresse comporte deux sorties identifiées par "octet" +// active ou désactive une sortie par xpressnet (mode autonome, donc connecté à la centrale) +// Une adresse comporte deux sorties identifiées par "octet" // Adresse : adresse de l'accessoire // octet : numéro (1-2) de la sortie à cette adresse // etat : false (désactivé) true (activé) @@ -1620,7 +1652,7 @@ begin end; -procedure vitesse_loco(loco : integer;vitesse : integer;sens : boolean); +procedure vitesse_loco(nom_train :string;loco : integer;vitesse : integer;sens : boolean); var s : string; begin if portCommOuvert or parSocketLenz then @@ -1632,9 +1664,10 @@ begin end; if cdm_connecte then begin - //s:=chaine_CDM_vitesse(0,'BB25531'); - s:=chaine_CDM_vitesse(1,'CC406526'); // 0 n'arrete pas le train + //s:=chaine_CDM_vitesseST(vitesse,nom_train); // par nom du train + s:=chaine_CDM_vitesseINT(vitesse,loco); // par adresse du train envoi_CDM(s); + //affiche(s,clLime); end; end; @@ -1728,32 +1761,32 @@ begin case code of 0 : begin pilote_acc(adr,1,feu); // sortie 1 à 0 - sleep(tempoFeu); + sleep(tempo_Feu); pilote_acc(adr+1,1,feu); // sortie 2 à 0 - sleep(Tempofeu); + sleep(Tempo_feu); pilote_acc(adr+2,1,feu); // sortie 3 à 0 - sleep(TempoFeu); + sleep(Tempo_Feu); end; 1 : begin pilote_acc(adr,2,feu); // sortie 1 à 1 - sleep(tempoFeu); + sleep(tempo_Feu); pilote_acc(adr+1,1,feu); // sortie 2 à 0 - sleep(Tempofeu); + sleep(Tempo_feu); pilote_acc(adr+2,1,feu); // sortie 3 à 0 - sleep(TempoFeu); + sleep(Tempo_Feu); end; 2 : begin pilote_acc(adr,2,feu); // sortie 1 à 1 - sleep(tempoFeu); + sleep(tempo_Feu); pilote_acc(adr+1,2,feu); // sortie 2 à 1 - sleep(Tempofeu); + sleep(Tempo_feu); pilote_acc(adr+2,1,feu); // sortie 3 à 0 - sleep(TempoFeu); + sleep(Tempo_Feu); end; 3 : begin pilote_acc(adr,2,feu); // sortie 1 à 1 - sleep(tempoFeu); + sleep(tempo_Feu); pilote_acc(adr+1,2,feu); // sortie 2 à 1 - sleep(Tempofeu); + sleep(Tempo_feu); pilote_acc(adr+2,2,feu); // sortie 3 à 1 - sleep(TempoFeu); + sleep(Tempo_Feu); end; end; EtatSignalCplx[adr]:=code; @@ -2358,22 +2391,22 @@ begin end; 2 : // mode 2: plus de 4 feux begin - if (aspect=semaphore) then begin pilote_acc(adresse+2,1,feu);sleep(tempoFeu);pilote_acc(adresse,1,feu);end; - if (aspect=vert) then begin pilote_acc(adresse+2,1,feu);sleep(tempoFeu);pilote_acc(adresse,2,feu);end; - if (aspect=carre) then begin pilote_acc(adresse+2,1,feu);sleep(tempoFeu);pilote_acc(adresse+1,1,feu);end; - if (aspect=jaune) then begin pilote_acc(adresse+2,1,feu);sleep(tempoFeu);pilote_acc(adresse+1,2,feu);end; - if (aspect=violet) then begin pilote_acc(adresse+2,2,feu);sleep(tempoFeu);pilote_acc(adresse,1,feu);end; - if (aspect=blanc) then begin pilote_acc(adresse+2,2,feu);sleep(tempoFeu);pilote_acc(adresse,2,feu);end; - if (aspect=semaphore) then begin pilote_acc(adresse+2,2,feu);sleep(tempoFeu);pilote_acc(adresse+1,1,feu);end; - if (combine=aspect8) then begin pilote_acc(adresse+2,2,feu);sleep(tempoFeu);pilote_acc(adresse+1,2,feu);end; - if (combine=ral_60_jaune_cli) then begin pilote_acc(adresse+3,1,feu);sleep(tempoFeu);pilote_acc(adresse,1,feu);end; // demande groupe 3 - if (aspect=vert_cli) then begin pilote_acc(adresse+3,1,feu);sleep(tempoFeu);pilote_acc(adresse,2,feu);end; // demande groupe 3 - if (combine=Disque_D) then begin pilote_acc(adresse+3,1,feu);sleep(tempoFeu);pilote_acc(adresse+1,1,feu);end;// demande groupe 3 - if (aspect=jaune_cli) then begin pilote_acc(adresse+3,1,feu);sleep(tempoFeu);pilote_acc(adresse+1,2,feu);end; - if (combine=ral_30) then begin pilote_acc(adresse+3,2,feu);sleep(tempoFeu);pilote_acc(adresse,1,feu);end; - if (combine=ral_60) then begin pilote_acc(adresse+3,2,feu);sleep(tempoFeu);pilote_acc(adresse,2,feu);end; - if (combine=rappel_30) then begin pilote_acc(adresse+3,2,feu);sleep(tempoFeu);pilote_acc(adresse+1,1,feu);end; - if (combine=rappel_60) then begin pilote_acc(adresse+3,2,feu);sleep(tempoFeu);pilote_acc(adresse+1,2,feu);end; + if (aspect=semaphore) then begin pilote_acc(adresse+2,1,feu);sleep(tempo_Feu);pilote_acc(adresse,1,feu);end; + if (aspect=vert) then begin pilote_acc(adresse+2,1,feu);sleep(tempo_Feu);pilote_acc(adresse,2,feu);end; + if (aspect=carre) then begin pilote_acc(adresse+2,1,feu);sleep(tempo_Feu);pilote_acc(adresse+1,1,feu);end; + if (aspect=jaune) then begin pilote_acc(adresse+2,1,feu);sleep(tempo_Feu);pilote_acc(adresse+1,2,feu);end; + if (aspect=violet) then begin pilote_acc(adresse+2,2,feu);sleep(tempo_Feu);pilote_acc(adresse,1,feu);end; + if (aspect=blanc) then begin pilote_acc(adresse+2,2,feu);sleep(tempo_Feu);pilote_acc(adresse,2,feu);end; + if (aspect=semaphore) then begin pilote_acc(adresse+2,2,feu);sleep(tempo_Feu);pilote_acc(adresse+1,1,feu);end; + if (combine=aspect8) then begin pilote_acc(adresse+2,2,feu);sleep(tempo_Feu);pilote_acc(adresse+1,2,feu);end; + if (combine=ral_60_jaune_cli) then begin pilote_acc(adresse+3,1,feu);sleep(tempo_Feu);pilote_acc(adresse,1,feu);end; // demande groupe 3 + if (aspect=vert_cli) then begin pilote_acc(adresse+3,1,feu);sleep(tempo_Feu);pilote_acc(adresse,2,feu);end; // demande groupe 3 + if (combine=Disque_D) then begin pilote_acc(adresse+3,1,feu);sleep(tempo_Feu);pilote_acc(adresse+1,1,feu);end;// demande groupe 3 + if (aspect=jaune_cli) then begin pilote_acc(adresse+3,1,feu);sleep(tempo_Feu);pilote_acc(adresse+1,2,feu);end; + if (combine=ral_30) then begin pilote_acc(adresse+3,2,feu);sleep(tempo_Feu);pilote_acc(adresse,1,feu);end; + if (combine=ral_60) then begin pilote_acc(adresse+3,2,feu);sleep(tempo_Feu);pilote_acc(adresse,2,feu);end; + if (combine=rappel_30) then begin pilote_acc(adresse+3,2,feu);sleep(tempo_Feu);pilote_acc(adresse+1,1,feu);end; + if (combine=rappel_60) then begin pilote_acc(adresse+3,2,feu);sleep(tempo_Feu);pilote_acc(adresse+1,2,feu);end; end; end; end; @@ -2464,6 +2497,14 @@ var i,adresse,det,a,b,aspect,x,y,x0,y0,TailleX,TailleY,Orientation : integer; s : string; begin i:=index_feu(Adr); + if i=0 then + begin + s:='Erreur 75: index signal '+intToSTR(adr)+' nul'; + Affiche(s,clred); + AfficheDebug(s,clred); + exit; + end; + //Affiche(intToSTR(Adr)+' '+intToSTR(i),clWhite); if (ancien_tablo_signalCplx[adr]<>EtatSignalCplx[adr]) then //*** begin if feux[i].aspect<10 then // si signal non directionnel @@ -2500,7 +2541,7 @@ begin // arreter le train s:=detecteur[det].train; Affiche('et son détecteur '+IntToSTR(det)+'=1 tempo démarrage '+s,clYellow); - s:=chaine_CDM_vitesse(1,s); // 0% + s:=chaine_CDM_vitesseST(1,s); // 0% envoi_cdm(s); end; end; @@ -2758,9 +2799,9 @@ end; // 9996: arrêt sur position inconnue d'aiguillage function suivant_alg3(prec : integer;typeELprec : TEquipement;actuel : integer;typeElActuel : TEquipement;alg : integer) : integer; var Adr,AdrPrec,indexBranche_prec,branche_trouve_prec,indexBranche_actuel,branche_trouve_actuel, - tjsc1,tjsc2,AdrTjdP,Adr2,N_iteration,index,NetatTJD : integer; + tjsc1,tjsc2,AdrTjdP,Adr2,N_iteration,index,NetatTJD,index2 : integer; tjscourbe1,tjscourbe2,tjdC,tjsC : boolean; - A,Aprec,tjsc1B,tjsc2B: char; + A,Aprec,tjsc1B,tjsc2B,typeprec: char; Md,BT,BtypePrec,TypeEL : TEquipement; s : string; @@ -2785,6 +2826,7 @@ var Adr,AdrPrec,indexBranche_prec,branche_trouve_prec,indexBranche_actuel,branc label recommence; begin n_iteration:=0; + recommence: if (TypeELPrec=rien) or (typeElActuel=rien) then begin @@ -2793,7 +2835,7 @@ begin AfficheDebug(s,clred); Suivant_alg3:=9999;exit; end; - if NivDebug=3 then + if NivDebug=3 then AfficheDebug('Alg3 précédent='+intToSTR(prec)+'/'+BtypeToChaine(TypeElprec)+' actuel='+intToSTR(actuel)+'/'+BtypeToChaine(typeElActuel)+' Alg='+intToSTr(alg),clyellow); // trouver les éléments du précédent trouve_element(prec,TypeELPrec,1); // branche_trouve IndexBranche_trouve @@ -2868,11 +2910,13 @@ begin prec:=Aiguillage[index_aig(prec)].Ddroit; if NivDebug=3 then AfficheDebug('Le précedent est une TJD/S - substitution du precédent par la pointe de la TJD qui est '+intToSTR(prec),clYellow); end; - end; + end; inc(n_iteration); + if n_iteration>50 then begin - s:='Erreur fatale 9999, trop d''itérations'; + s:='Erreur fatale 9999, trop d''itérations:'; + s:=s+' Alg3 précédent='+intToSTR(prec)+'/'+BtypeToChaine(TypeElprec)+' actuel='+intToSTR(actuel)+'/'+BtypeToChaine(typeElActuel)+' Alg='+intToSTr(alg); Affiche(s,clRed); AfficheDebug(s,clRed); suivant_alg3:=9999; @@ -2884,7 +2928,7 @@ begin if (Bt=aig) or (Bt=buttoir) then // aiguillage ou buttoir begin index:=index_aig(adr); - if (aiguillage[index].modele=aig) and (Bt=aig) then // aiguillage normal + if (aiguillage[index].modele=aig) and (Bt=aig) then // aiguillage normal begin // aiguillage pris en pointe if (aiguillage[index].Apointe=prec) then @@ -2900,7 +2944,7 @@ begin Aprec:=a; 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; @@ -2925,7 +2969,7 @@ begin Aprec:=A; A:=aiguillage[index].AdevieB; Adr:=aiguillage[index].Adevie; - 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; @@ -2964,9 +3008,9 @@ begin end; end; - // AdrPrec:=Adr; // JU + // AdrPrec:=Adr; if Adr=0 then - begin + begin Affiche('136 - Erreur fatale',clRed); if NivDebug>=1 then AfficheDebug('136 - Erreur fatale',clRed); suivant_alg3:=9999;exit; @@ -2987,8 +3031,9 @@ begin s:='138 - Aiguillage '+IntToSTR(adr)+' non résolu'; if aiguillage[index].position=const_inconnu then s:=s+' car position inconnue'; AfficheDebug(s,clOrange); + Affiche(s,clOrange); end; - + suivant_alg3:=9999;exit; end; @@ -2996,22 +3041,23 @@ begin begin // récupérer les élements de la TJD/S AdrTjdP:=aiguillage[index].Ddroit; // 2eme adresse de la TJD/S + index2:=index_aig(AdrTjdP); tjdC:=aiguillage[index].modele=tjd; tjsC:=aiguillage[index].modele=tjs; tjsc1:=aiguillage[index].tjsint; // adresses de la courbe de la TJS - tjsc2:=aiguillage[index_aig(AdrTjdP)].tjsint; + tjsc2:=aiguillage[index2].tjsint; tjsc1B:=aiguillage[index].tjsintB; - tjsc2B:=aiguillage[index_aig(AdrTjdP)].tjsintB; + tjsc2B:=aiguillage[index2].tjsintB; NetatTJD:=aiguillage[index].etatTJD; if tjsc1<>0 then // si tjs begin - tjscourbe1:=(aiguillage[index].tjsintB='S') and (aiguillage[index_aig(tjsc1)].position<>const_droit); - tjscourbe1:=((aiguillage[index].tjsintB='D') and (aiguillage[index_aig(tjsc1)].position=const_droit)) or tjscourbe1; + tjscourbe1:=(aiguillage[index].tjsintB='S') and (aiguillage[index2].position<>const_droit); + tjscourbe1:=((aiguillage[index].tjsintB='D') and (aiguillage[index2].position=const_droit)) or tjscourbe1; end; if tjsc2<>0 then begin - tjscourbe2:=(aiguillage[index_aig(AdrTjdP)].tjsintB='S') and (aiguillage[index_aig(tjsc2)].position<>const_droit); - tjscourbe2:=((aiguillage[index_aig(AdrTjdP)].tjsintB='D') and (aiguillage[index_aig(tjsc2)].position=const_droit)) or tjscourbe2; + tjscourbe2:=(aiguillage[index2].tjsintB='S') and (aiguillage[index2].position<>const_droit); + tjscourbe2:=((aiguillage[index2].tjsintB='D') and (aiguillage[index2].position=const_droit)) or tjscourbe2; end; if NivDebug=3 then @@ -3022,44 +3068,62 @@ begin if aiguillage[index].position=const_droit then s:=s+'droit' else if aiguillage[index].position=const_devie then s:=s+'dévié' else s:=s+'inconnu' ; - if NetatTJD=4 then + if NetatTJD=4 then begin if aiguillage[index_aig(AdrTJDP)].position=const_droit then s:=s+'/droit' else if aiguillage[index_aig(AdrTJDP)].position=const_devie then s:=s+'/dévié' else s:=s+'/inconnu' ; - end; + end; AfficheDebug(s,clyellow); end; // rechercher le port de destination de la tjd Adr2:=0;A:='Z'; - if ((NetatTJD=4) or tjsC) then + { + if ((NetatTJD=4) or tjsC) then + begin + if (aiguillage[index].position=const_devie) and (aiguillage[index2].position=const_droit) then + begin + if nivDebug=3 then AfficheDebug('cas1',clyellow); + A:=aiguillage[index].dDroitB; + adr2:=aiguillage[index].dDroit; + end; + if (aiguillage[index].position=const_droit) and (aiguillage[index2].position=const_droit) then + begin + if nivDebug=3 then AfficheDebug('cas2',clyellow); + A:=aiguillage[index].dDroitB; + adr2:=aiguillage[index].droit; + end; + if (aiguillage[index].position=const_devie) and (aiguillage[index2].position=const_devie) then + begin + if nivDebug=3 then AfficheDebug('cas3',clyellow); + A:=aiguillage[index].DdevieB; + adr2:=aiguillage[index].Ddevie; + end; + if (aiguillage[index].position=const_droit) and (aiguillage[index2].position=const_devie) then + begin + if nivDebug=3 then AfficheDebug('cas4',clyellow); + A:=aiguillage[index].DdroitB; + adr2:=aiguillage[index].Ddroit; + end; + + if nivDebug=3 then Affichedebug('le port de destination de la tjd 4 états est '+IntToSTR(adr2)+a,clyellow); + end; + + if (NetatTJD=2) and tjdC then begin if aiguillage[index].position=const_droit then begin - A:=aiguillage[index].DDroitB; - adr2:=aiguillage[index].DDroit; + A:=aiguillage[index].ADroitB; + adr2:=aiguillage[index].ADroit; end; if aiguillage[index].position=const_devie then begin - A:=aiguillage[index].DDevieB; - adr2:=aiguillage[index].DDevie; + A:=aiguillage[index].ADevieB; + adr2:=aiguillage[index].ADevie; end; + if nivDebug=3 then Affichedebug('le port de destination de la tjd 2 états est '+IntToSTR(adr2)+a,clyellow); end; - if (NetatTJD=2) and tjdC then - begin - if aiguillage[index].position=const_droit then - begin - A:=aiguillage[index].DDroitB; - adr2:=aiguillage[index].DDroit; - end; - if aiguillage[index].position=const_devie then - begin - A:=aiguillage[index].DDevieB; - adr2:=aiguillage[index].DDevie; - end; - end; - if nivDebug=3 then Affichedebug('le port de destination de la tjd '+inttoSTR(NetatTJD)+'états est '+IntToSTR(adr2)+a,clyellow); // extraire l'élément connecté au port de destination de la tjd 4 états ou tjs if tjsC or (NetatTJD=4) then @@ -3086,29 +3150,45 @@ begin suivant_alg3:=9996; exit; end - else + else begin if NivDebug=3 then begin s:='1022 - Position TJD '+intToSTR(adr)+' non résolue car position inconnue'; affichedebug(s,clOrange); - end; + end; suivant_alg3:=9996; end; end; end; - + if nivDebug=3 then AfficheDebug('tjd: '+s+' Suiv='+intToSTR(adr2)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig suivant_alg3:=adr2; exit; + } + + if (NetatTJD=2) and tjdC then + begin + if aiguillage[index].position=const_droit then + begin + A:=aiguillage[index].ADroitB; + adr2:=aiguillage[index].ADroit; + end; + if aiguillage[index].position=const_devie then + begin + A:=aiguillage[index].ADevieB; + adr2:=aiguillage[index].ADevie; + end; + if nivDebug=3 then Affichedebug('le port de destination de la tjd 2 états est '+IntToSTR(adr2)+a,clyellow); + end; 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_aig(AdrTJdP)].position=const_droit) and - (aiguillage[index].position=const_droit) and tjdC) then + if (( aiguillage[index].position=const_droit) and + (aiguillage[index2].position=const_droit) and tjdC) then begin // d'où vient ton sur la tjd if aiguillage[index].Adroit=prec then @@ -3126,17 +3206,17 @@ begin A:=aiguillage[index_aig(AdrTjDP)].AdevieB; end; if NivDebug=3 then AfficheDebug('cas1.1 tjd: '+s+' Adr='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig suivant_alg3:=adr; substitue; exit; end; if aiguillage[index].Adevie=prec then begin - A:=aiguillage[index_aig(AdrTjdP)].AdroitB; - Adr:=aiguillage[index_aig(AdrTjdP)].Adroit; - if NivDebug=3 then AfficheDebug('cas1.2 tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + A:=aiguillage[index2].AdroitB; + Adr:=aiguillage[index2].Adroit; + if NivDebug=3 then AfficheDebug('cas1.2 jamais vu tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig suivant_alg3:=adr; substitue; exit; @@ -3148,25 +3228,25 @@ begin end; // cas 2 TJD if (aiguillage[index].position=const_devie) - and (aiguillage[index_aig(AdrTjdP)].position=const_droit) and tjdC then + and (aiguillage[index2].position=const_droit) and tjdC then begin - if aiguillage[index].Adevie=prec then + if (aiguillage[index].Adevie=prec) then begin - A:=aiguillage[index_aig(AdrTjdP)].AdroitB; - Adr:=aiguillage[index_aig(AdrTJDP)].Adroit; + A:=aiguillage[index2].AdevieB; //AdroitB; + Adr:=aiguillage[index2].Adevie; // Adroit; if NivDebug=3 then AfficheDebug('cas2.1 tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig substitue; suivant_alg3:=adr; exit; end; if (aiguillage[index].Adroit=prec) then begin - A:=aiguillage[index_aig(AdrTJDP)].AdevieB; - Adr:=aiguillage[index_aig(AdrTjdP)].Adevie; + A:=aiguillage[index2].AdevieB; + Adr:=aiguillage[index2].Adevie; if NivDebug=3 then AfficheDebug('cas2.2 tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig substitue; suivant_alg3:=adr; exit; @@ -3178,7 +3258,7 @@ begin end; // cas 3 TJD if (aiguillage[index].position=const_droit) - and (aiguillage[index_aig(AdrTjdP)].position=const_devie) and tjdC then + and (aiguillage[index2].position=const_devie) and tjdC then begin // si on vient de if (aiguillage[index].Adroit=prec) then @@ -3188,27 +3268,27 @@ begin Adr:=aiguillage[index].Ddroit; if A='D' then begin - Adr:=aiguillage[index_aig(AdrTjDP)].Adroit; - A:=aiguillage[index_aig(AdrTjDP)].AdroitB; + Adr:=aiguillage[index2].Adroit; + A:=aiguillage[index2].AdroitB; end; if A='S' then begin - Adr:=aiguillage[index_aig(AdrTjDP)].Adevie; - A:=aiguillage[index_aig(AdrTjDP)].AdevieB; + Adr:=aiguillage[index2].Adevie; + A:=aiguillage[index2].AdevieB; end; - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig - //substitue; + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + substitue; suivant_alg3:=adr; exit; end; // si on vient de if (aiguillage[index].Adevie=prec) then begin - A:=aiguillage[index_aig(AdrTJDP)].AdroitB; - Adr:=aiguillage[index_aig(AdrTJDP)].Adroit; + A:=aiguillage[index2].AdroitB; + Adr:=aiguillage[index2].Adroit; if NivDebug=3 then AfficheDebug('cas3.2 tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig substitue; suivant_alg3:=adr; exit; @@ -3220,12 +3300,12 @@ begin end; // cas 4 tjd if (aiguillage[index].position=const_devie) - and (aiguillage[index_aig(AdrTjdP)].position=const_devie) then + and (aiguillage[index2].position=const_devie) then begin if aiguillage[index].Adevie=prec then begin - A:=aiguillage[index_aig(AdrtjdP)].AdevieB; - Adr:=aiguillage[index_aig(AdrtjdP)].Adevie; + A:=aiguillage[index2].AdevieB; + Adr:=aiguillage[index2].Adevie; if NivDebug=3 then AfficheDebug('cas4.1 tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig substitue; @@ -3234,10 +3314,10 @@ begin end; if aiguillage[index].Adroit=prec then begin - A:=aiguillage[index_aig(AdrtjdP)].AdevieB; - Adr:=aiguillage[index_aig(AdrtjdP)].Adevie; - if NivDebug=3 then AfficheDebug('cas4.2 tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); - if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + A:=aiguillage[index2].AdevieB; + Adr:=aiguillage[index2].Adevie; + if NivDebug=3 then AfficheDebug('cas4.2 jamais vu tjd: '+s+' Suiv='+intToSTR(adr)+A,clYellow); + if A='Z' then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig substitue; suivant_alg3:=adr; exit; @@ -3403,7 +3483,7 @@ begin trouve4:=feux[i].Adr_det4=adr; trouve:=trouve1 or trouve2 or trouve3 or trouve4; if not(trouve) then inc(i); - until (trouve) or (i>=NbreFeux); + until (trouve) or (i>NbreFeux); if trouve then Index_feu_det:=i else Index_feu_det:=0; end; @@ -3466,8 +3546,8 @@ begin detecteur_suivant:=AdrSuiv; end; -// renvoie les adresses des détecteurs adjacents au détecteur "adresse" -// résultat dans adj1 et adj2 +// renvoie les adresses des détecteurs adjacents au détecteur "adresse" (avant, après) +// résultat dans adj1 et adj2 en variable globale procedure Det_Adj(adresse : integer); var Adr,AdrFonc,Branche,AdrPrec,IndexBranche,i,Dir : integer; sortie : boolean; @@ -3543,7 +3623,6 @@ begin if NivDebug=3 then begin s:='611. '+IntToSTR(el1)+' non trouvé'; - AfficheDebug(s,clred); AfficheDebug(s,clOrange); end; detecteur_suivant_El:=9999;exit; @@ -3615,7 +3694,11 @@ begin sortie:=((typeDet2=TypeGen) and (Adr=el2)) or (Adr=0) or (Adr>=9996) or (i=15) or (N_Det=Nb_det_dist); until sortie ; if (i=15) and (Nivdebug=3) then afficheDebug('Pas trouvé',clyellow); - if (N_det=Nb_det_dist) and (Nivdebug=3) then afficheDebug('Détecteurs trop distants',clred); + if (N_det=Nb_det_dist) and (Nivdebug=3) then + begin + s:='Elements trop distants '+intToStr(el1)+' '+intToSTR(el2); + afficheDebug(s,clorange); + end; end else @@ -3679,6 +3762,14 @@ var i,l,k,NCondCarre,adrAig,index : integer; s : string; begin i:=index_feu(adresse); + if i=0 then + begin + Affiche('Erreur 602 - feu '+IntToSTR(adresse)+' non trouvé',clred); + if NivDebug=3 then AfficheDebug('Erreur 602 - feu '+IntToSTR(adresse)+' non trouvé',clred); + cond_carre:=true; + exit; + end; + NCondCarre:=Length(feux[i].condcarre[1]); l:=1; @@ -3725,6 +3816,14 @@ begin if (NivDebug>=1) then AfficheDebug('Test si signal '+IntToSTR(adresse)+' doit afficher un carré si aiguillage avals mal positionnés',clyellow); i:=Index_feu(adresse); + if i=0 then + begin + Affiche('Erreur 603 - feu '+IntToSTR(adresse)+' non trouvé',clred); + if NivDebug=3 then AfficheDebug('Erreur 603 - feu '+IntToSTR(adresse)+' non trouvé',clred); + carre_signal:=true; + exit; + end; + j:=0; prec:=feux[i].Adr_det1; TypeElPrec:=Det; @@ -3822,13 +3921,13 @@ begin TypePrec:=det; if prec=0 then begin - Affiche('Msg 601 - feu '+intToSTR(adresse)+' non renseigné ',clOrange); - if NivDebug=3 then AfficheDebug('Msg 601 - feu '+intToSTR(adresse)+' non renseigné ',clOrange); + Affiche('Msg 601 - feu '+intToSTR(adresse)+' détecteur non renseigné ',clOrange); + if NivDebug=3 then AfficheDebug('Msg 601 - feu '+intToSTR(adresse)+' détecteur non renseigné ',clOrange); etat_signal_suivant:=0; AdresseFeuSuivant:=0; exit; end; - + actuel:=feux[i].Adr_el_suiv1; typeActuel:=feux[i].Btype_suiv1; if nivDebug=3 then AfficheDebug('Actuel ='+IntToSTR(actuel),clyellow); @@ -4026,8 +4125,8 @@ begin i:=Index_feu(adresse); if (i=0) then begin - Affiche('Erreur 650 - feu non trouvé',clred); - AfficheDebug('Erreur 650 - feu non trouvé',clred); + Affiche('Erreur 605 - feu '+IntToSTR(adresse)+' non trouvé',clred); + AfficheDebug('Erreur 605 - feu '+IntToSTR(adresse)+' non trouvé',clred); test_memoire_zones:=false; end; @@ -4242,8 +4341,8 @@ begin i:=index_feu(Adrfeu); if i=0 then begin - Affiche('Erreur 602 - feu '+IntToSTR(adrFeu)+' non trouvé',clred); - if NivDebug=3 then AfficheDebug('Erreur 602 - feu '+IntToSTR(adrFeu)+' non trouvé',clred); + Affiche('Erreur 604 - feu '+IntToSTR(adrFeu)+' non trouvé',clred); + if NivDebug=3 then AfficheDebug('Erreur 604 - feu '+IntToSTR(adrFeu)+' non trouvé',clred); PresTrainPrec:=false; exit; end; @@ -4685,6 +4784,7 @@ begin if N_Trains>=Max_Trains then begin Affiche('Erreur nombre de train maximal atteint',clRed); + N_trains:=0; end; Inc(N_trains); @@ -4806,8 +4906,7 @@ begin Affiche(st+intToSTR(adr)+' Train='+train+' F'+IntToSTR(Tablo_actionneur[i].fonction)+':'+intToSTR(etat),clyellow); // exécution de la fonction F vers CDM envoie_fonction_CDM(Tablo_actionneur[i].fonction,etat,train); - TempoAct:=tablo_actionneur[i].Tempo div 100; - RangActCours:=i; + tablo_actionneur[i].TempoCourante:=tablo_actionneur[i].Tempo div 100; end; // actionneur pour accessoire @@ -4820,7 +4919,6 @@ begin // exécution la fonction accessoire vers CDM if Tablo_actionneur[i].RAZ then Ts:=aigP else Ts:=Feu; pilote_acc(access,sortie,Ts); // sans RAZ - RangActCours:=i; end; // actionneur pour son @@ -4922,6 +5020,7 @@ begin N_Event_tick:=0; Affiche('Raz Evts détecteurs',clLime); end; + inc(N_Event_tick); event_det_tick[N_event_tick].tick:=tick; event_det_tick[N_event_tick].detecteur:=Adresse; @@ -4964,7 +5063,7 @@ begin // si le FD du détecteur a déjà été stocké à l'index précédent ne pas en tenir compte //if event_det[N_event_det]<>Adresse then begin - if AffFD then AfficheDebug('index='+intToSTR(N_event_tick)+' FD '+intToSTR(Adresse),clyellow); + if AffFD then AfficheDebug('Tick='+intToSTR(tick)+' Index='+intToSTR(N_event_tick)+' FD '+intToSTR(Adresse),clyellow); inc(N_event_det); event_det[N_event_det]:=Adresse; // vérification de la connaissance de la position de tous les aiguillages au premier évènement FD détecteur @@ -4997,7 +5096,7 @@ begin N_event_det:=0; FormDebug.MemoEvtDet.lines.add('Raz sur débordement'); end; - + // attention à partir de cette section le code est susceptible de ne pas être exécuté?? // Mettre à jour le TCO @@ -5038,18 +5137,19 @@ begin N_Event_tick:=0; Affiche('Raz Evts ',clLime); end; - s:='Tick='+IntToSTR(tick)+' Evt Aig '+intToSTR(adresse)+'='+intToSTR(pos); - case pos of - const_droit : s:=s+' droit'; - const_devie : s:=s+' dévié'; - const_inconnu : s:=s+' inconnu'; - end; - if inv then s:=s+' INV'; + if AffAigDet then begin - Affiche(s,clyellow); + s:='Tick='+IntToSTR(tick)+' Evt Aig '+intToSTR(adresse)+'='+intToSTR(pos); + case pos of + const_droit : s:=s+' droit'; + const_devie : s:=s+' dévié'; + const_inconnu : s:=s+' inconnu'; + end; + if inv then s:=s+' INV'; AfficheDebug(s,clyellow); end; + FormDebug.MemoEvtDet.lines.add(s) ; if (n_Event_tick mod 10) =0 then affiche_memoire; inc(N_Event_tick); @@ -5108,7 +5208,7 @@ begin 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); + s:=chaine_CDM_Acc(adresse,0); envoi_CDM(s); exit; end; @@ -5151,7 +5251,7 @@ begin end; -// le décodage de la rétro est appellée sur une réception d'une trame de la rétrosignalisation de la centrale. +// le décodage de la rétro est appelé sur une réception d'une trame de la rétrosignalisation de la centrale. // On déclenche ensuite les évènements détecteurs ou aiguillages. procedure decode_retro(adresse,valeur : integer); var s : string; @@ -5810,6 +5910,7 @@ begin TraceSign:=True; PremierFD:=false; // services commIP CDM par défaut + ntrains:=1; Srvc_Aig:=true; Srvc_Det:=true; Srvc_Act:=true; @@ -5834,7 +5935,6 @@ begin FormDebug.Caption:=AF+' debug'; N_Trains:=0; NivDebug:=0; - TempoAct:=0; debugtrames:=false; AvecInit:=true; //&&&& avec initialisation des aiguillages ou pas @@ -5849,6 +5949,7 @@ begin CDM_connecte:=false; pasreponse:=0; recuCDM:=''; + residuCDM:=''; Nbre_recu_cdm:=0; AffMem:=true; N_routes:=0; @@ -5862,7 +5963,7 @@ begin // lancer CDM rail et le connecte si on le demande if LanceCDM then Lance_CDM; ButtonAffTCO.visible:=AvecTCO; - Loco.Visible:=not(Diffusion); + Loco.Visible:=true; // tenter la liaison vers CDM rail if not(CDM_connecte) then connecte_CDM; @@ -5928,10 +6029,16 @@ begin I_Simule:=0; tick:=0; - N_Event_tick:=0 ; // dernier index NombreImages:=0; + GroupBox2.Left:=633; + GroupBox2.Top:=64; + GroupBox2.Visible:=false; + GroupBox3.Left:=633; + GroupBox3.Top:=64; + GroupBox3.visible:=true; + // TCO if avectco then begin @@ -5943,27 +6050,19 @@ begin Affiche('Fin des initialisations',clyellow); LabelEtat.Caption:=' '; Affiche_memoire; - -// i:=suivant_alg3(28,aig,529,det,1); - //--------------------------------- - { - NivDebug:=3; - FormDebug.show; + { aiguillage[index_aig(7)].position:=const_devie; aiguillage[index_aig(20)].position:=const_droit; aiguillage[index_aig(21)].position:=const_droit; - aiguillage[index_aig(28)].position:=const_devie; - aiguillage[index_aig(26)].position:=const_devie; - - i:=suivant_alg3(28,aig,529,det,1); - - //i:=Detecteur_suivant_El(520,det,527,det,1); - //i:=Detecteur_suivant_El(597,1,601,1); - // i:=Detecteur_suivant_El(598,1,599,1); - //i:=Detecteur_suivant_El(520,1,20,2); - // AfficheDebug(IntToSTR(i),clyellow); - } - + aiguillage[index_aig(25)].position:=const_devie; + aiguillage[index_aig(26)].position:=const_droit; + aiguillage[index_aig(27)].position:=const_droit; + aiguillage[index_aig(28)].position:=const_droit; + aiguillage[index_aig(31)].position:=const_devie; + } + //i:=suivant_alg3(520,det,20,aig,1); + + end; @@ -6034,6 +6133,7 @@ var aspect,i,a,x,y,Bimage,adresse,TailleX,TailleY,orientation : integer; s : string; begin inc(tick); + if Tdoubleclic>0 then dec(Tdoubleclic); if Tempo_init>0 then dec(Tempo_init); if (Tempo_init=1) and AvecInit then begin @@ -6128,18 +6228,21 @@ begin //if (not(Maj_feux_cours) and (Tempo_chgt_feux>0)) then dec(Tempo_chgt_feux); // tempo retombée actionneur - if TempoAct<>0 then + for i:=1 to maxTablo_act do begin - dec(tempoAct); - if tempoAct=0 then + if Tablo_actionneur[i].TempoCourante<>0 then begin - A:=Tablo_actionneur[RangActCours].adresse; - s:=Tablo_actionneur[RangActCours].train; - Affiche('Actionneur '+intToSTR(a)+' F'+IntToSTR(Tablo_actionneur[RangActCours].fonction)+':0',clyellow); - envoie_fonction_CDM(Tablo_actionneur[RangActCours].fonction,0,s); + dec(Tablo_actionneur[i].TempoCourante); + if Tablo_actionneur[i].TempoCourante=0 then + begin + A:=Tablo_actionneur[i].adresse; + s:=Tablo_actionneur[i].train; + Affiche('Actionneur '+intToSTR(a)+' F'+IntToSTR(Tablo_actionneur[i].fonction)+':0',clyellow); + envoie_fonction_CDM(Tablo_actionneur[i].fonction,0,s); + end; end; end; - + //simulation if (index_simule<>0) then begin @@ -6194,7 +6297,7 @@ begin //Affiche('tempo 0 Detecteur '+intToSTR(i),clyellow); s:=detecteur[i].train; Affiche('Tempo 0 timer train '+s,clOrange); - s:=chaine_CDM_vitesse(100,s); // 100% + s:=chaine_CDM_vitesseST(100,s); // 100% envoi(s); end; end; @@ -6254,13 +6357,13 @@ begin rafraichit; end; -// erreur sur socket Lenz +// erreur sur socket Lenz (interface XpressNet) procedure TFormPrinc.ClientSocketLenzError(Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer); var s : string; begin - s:='Erreur '+IntToSTR(ErrorCode)+' socket IP Lenz'; + s:='Erreur '+IntToSTR(ErrorCode)+' socket IP Xpressnet'; case ErrorCode of 10053 : s:=s+': Connexion avortée - Timeout'; 10054 : s:=s+': Connexion avortée par tiers'; @@ -6460,7 +6563,7 @@ begin begin s:=IntToSTR(i)+' Adr='+IntToSTR(adr); if aiguillage[i].modele=aig then s:=s+' Pointe='; - if (aiguillage[i].modele=tjd) then + if (aiguillage[i].modele=tjd) then begin s:=s+' TJD:'; s:=s+intToSTR(aiguillage[i].EtatTJD)+' états '; @@ -6526,10 +6629,11 @@ end; // la trame_CDM peut contenir 2000 caractères à l'initialisation du RUN. procedure Interprete_trameCDM(trame_CDM:string); var i,j,objet,posST,posAC,posDT,posSG,posXY,k,l,erreur, adr,adr2,etat,etataig, - vitesse,etatAig2,name,prv,nbre,nbreVir,long,index : integer ; + vitesse,etatAig2,name,prv,nbre,nbreVir,long,index,posDes : integer ; x,y,x2,y2 : longint ; s,ss,train,commandeCDM : string; traite,sort : boolean; +label reprise; begin { trame_CDM:='S-R-14-0004-CMDACC-__ACK|000|S-E-14-5162-CMDACC-ST_DT|052|05|NAME=2756;OBJ=2756;AD=518;TRAIN=CC406526;STATE=1;'; @@ -6540,9 +6644,14 @@ begin trame_cdm:=trame_cdm+'S-E-14-5167-CMDACC-ST_DT|051|05|NAME=7061;OBJ=7061;AD=520;TRAIN=BB25531;STATE=0'; trame_cdm:=trame_cdm+'S-E-14-5168-CMDACC-ST_DT|049|05|NAME=7057;OBJ=7057;AD=517;TRAIN=_NONE;STATE=0'; trame_cdm:=trame_cdm+'S-E-14-5169-CMDACC-ST_DT|049|05|NAME=7058;OBJ=7058;AD=517;TRAIN=_NONE;STATE=0'; - } - //debugtrames:=true; + trame_cdm:='S-R-07-0002-DSCTRN-__ACK|000|S-C-07-1369-DSCTRN-SPEED|030|03|NAME=BB25531;AD=1;TMAX=120;S-C-07-1370-DSCTRN-SPEED|026|03|NAME=TGV;AD=2;TMAX=120;' ; + trame_cdm:=trame_cdm+'S-C-07-1371-DSCTRN-SPEED|030|03|NAME=BB16024;AD=3;TMAX=120;' ; + trame_cdm:=trame_cdm+'S-C-07-1372-DSCTRN-SPEED|031|03|NAME=CC406526;AD=4;TMAX=120;' ; + trame_cdm:=trame_cdm+'S-C-07-1373-DSCTRN-SPEED|029|03|NAME=CAMERA;AD=6;TMAX=120;' ; + trame_cdm:=trame_cdm+'S-C-07-1374-DSCTRN-__END|000|' ; + } + residuCDM:=''; AckCDM:=trame_CDM<>''; if pos('ACK',trame_CDM)=0 then begin @@ -6552,31 +6661,49 @@ begin k:=0; //Affiche('L='+InTToSTR(length(recuCDM)),clyellow); repeat - // trouver la longueur de la chaîne de paramètres + // trouver la longueur de la chaîne de paramètres entre les 2 premiers |xxx| i:=pos('|',trame_CDM); + if i=0 then + begin + if debugTrames then AfficheDebug('tronqué1 : '+trame_CDM,clyellow); + residuCDM:=trame_CDM; + Nbre_recu_cdm:=0; + exit; + end; + j:=posEx('|',trame_CDM,i+1); + if j=0 then + begin + if debugTrames then AfficheDebug('tronqué2 : '+trame_CDM,clyellow); + residuCDM:=trame_CDM; + Nbre_recu_cdm:=0; + exit; + end; + + l:=length(trame_cdm)-j; val(copy(trame_CDM,i+1,5),long,erreur); + //Affiche('long chaine param='+intToSTR(long),clyellow); if long=0 then begin //if debugTrames then Affiche('Longueur nulle',clYellow); if pos('ACK',trame_cdm)<>0 then Ack_cdm:=true; - i:=posEx('|',trame_CDM,i+1); - if i=0 then begin Affiche('Erreur trames CDM manque 2ème |',clred);exit;end; - delete(trame_cdm,1,i); + delete(trame_cdm,1,j); + goto reprise; end; + if long>l then + begin + if debugTrames then AfficheDebug('tronqué3 : '+trame_CDM,clyellow); + residuCDM:=trame_CDM; + Nbre_recu_cdm:=0; + exit; + end; + + reprise: if long<>0 then begin - // trouver le nombre de paramètres - i:=posEx('|',trame_CDM,i+1); - if i=0 then - begin - if debugTrames then AfficheDebug('0 paramètres '+trame_CDM,clyellow); - Nbre_recu_cdm:=0; - exit; - end; - - val(copy(trame_CDM,i+1,5),nbre,erreur); + // nombre de paramètres + val(copy(trame_CDM,j+1,5),nbre,erreur); //Affiche('nbre='+IntToSTR(nbre),clyellow); // compter le nombre de virgules qui doit être égal au nombre de paramètres NbreVir:=0; // nombre de virgules @@ -6584,18 +6711,41 @@ begin i:=posEx(';',trame_CDM,i+1); if i<>0 then inc(NbreVir); until (i=0) or (NbreVir=nbre); - if i=0 then + if (i=0) then begin - if debugTrames then AfficheDebug('tronqué : '+trame_CDM,clyellow); + if debugTrames then AfficheDebug('tronqué4 : '+trame_CDM,clyellow); residuCDM:=trame_CDM; Nbre_recu_cdm:=0; exit; end; CommandeCDM:=copy(trame_CDM,1,i); - if debugTrames then AfficheDebug(commandeCDM,clorange); + //if debugTrames then AfficheDebug(commandeCDM,clorange); Delete(trame_CDM,1,i); + // description des trains 03|NAME=BB16024;AD=3;TMAX=120;' + posDES:=pos('DSCTRN-SPEED',commandeCDM); + if posDES<>0 then + begin + inc(ntrains); + delete(commandeCDM,1,posDES+12); + i:=posEx('NAME=',commandeCDM,posST);delete(commandeCDM,1,i+4); + i:=pos(';',commandeCDM); + trains[ntrains].nom_train:=copy(commandeCDM,1,i-1); + delete(commandeCDM,1,i); + + i:=pos('AD=',commandeCDM);Delete(commandeCDM,1,i+2); + val(commandeCDM,trains[ntrains].adresse,erreur); + i:=pos(';',commandeCDM); + delete(commandeCDM,1,i); + + i:=pos('TMAX=',commandeCDM);Delete(commandeCDM,1,i+4); + val(commandeCDM,trains[ntrains].vitmax,erreur); + i:=pos(';',commandeCDM); + delete(commandeCDM,1,i); + Formprinc.ComboTrains.Items.Add(trains[ntrains].nom_train); + end; + // évènement aiguillage. Le champ AD2 n'est pas forcément présent posST:=pos('CMDACC-ST_TO',commandeCDM); if posST<>0 then @@ -6637,26 +6787,56 @@ begin if (aiguillage[index].modele=tjd) or (aiguillage[index].modele=tjs) then begin //Affiche('TJD/S',clyellow); - //adr2:=aiguillage[index_aig(adr].Apointe; // 2eme adresse de la TJD - case etat of - 1 : begin etatAig:=const_devie;EtatAig2:=const_droit;end; - 4 : begin etatAig:=const_devie;EtatAig2:=const_devie;end; - 5 : begin etatAig:=const_droit;EtatAig2:=const_devie;end; - 0 : begin etatAig:=const_droit;EtatAig2:=const_droit;end; - end; - if (aiguillage[index].inversionCDM=1) or (aiguillage[index_aig(adr2)].inversionCDM=1) then + if aiguillage[index].EtatTJD=4 then begin - //Affiche('inverse',clyellow); - prv:=adr; - adr:=adr2; - adr2:=prv; + adr2:=aiguillage[index].Ddroit; // 2eme adresse de la TJD + if (aiguillage[index].inversionCDM=0) and (aiguillage[index_aig(adr2)].inversionCDM=0) then // pas d'inversions + case etat of + 0 : begin etatAig:=const_droit;EtatAig2:=const_droit;end; + 1 : begin etatAig:=const_devie;EtatAig2:=const_droit;end; + 4 : begin etatAig:=const_devie;EtatAig2:=const_devie;end; + 5 : begin etatAig:=const_droit;EtatAig2:=const_devie;end; + end; + + if (aiguillage[index].inversionCDM=1) then // inversion tjd1 + case etat of + 0 : begin etatAig:=const_devie;EtatAig2:=const_droit;end; + 1 : begin etatAig:=const_droit;EtatAig2:=const_droit;end; + 4 : begin etatAig:=const_droit;EtatAig2:=const_devie;end; + 5 : begin etatAig:=const_devie;EtatAig2:=const_devie;end; + end; + + if (aiguillage[index_aig(adr2)].inversionCDM=1) then // inversion tjd2 + case etat of + 0 : begin etatAig:=const_droit;EtatAig2:=const_devie;end; + 1 : begin etatAig:=const_devie;EtatAig2:=const_devie;end; + 4 : begin etatAig:=const_devie;EtatAig2:=const_droit;end; + 5 : begin etatAig:=const_droit;EtatAig2:=const_droit;end; + end; + + Event_Aig(adr,etatAig); + Event_Aig(adr2,etatAig2); + end; + + if aiguillage[index].EtatTJD=2 then + begin + if (aiguillage[index].inversionCDM=0) then + case etat of + 0 : etatAig:=const_droit; + 1 : etatAig:=const_devie; + end; + + if (aiguillage[index].inversionCDM=1) then + case etat of + 0 : etatAig:=const_devie; + 1 : etatAig:=const_droit; + end; + Event_Aig(adr,etatAig); end; - Event_Aig(adr,etatAig); - Event_Aig(adr2,etatAig2); end; // aiguillage triple - if aiguillage[index].modele=triple then + if aiguillage[index].modele=triple then begin //Affiche('Triple',clyellow); // état de l'aiguillage 1 @@ -6675,7 +6855,7 @@ begin AfficheDebug('Recu evt aig de CDM pour un aiguillage '+intToSTR(Adr)+' non déclaré',clOrange); end; end; - + // évènement détecteur posDT:=pos('CMDACC-ST_DT',commandeCDM); if posDT<>0 then @@ -6810,7 +6990,6 @@ begin //if Nbre_recu_cdm>1 then Affiche('Empilement de trames CDM: '+intToSTR(Nbre_recu_cdm),clred); recuCDM:=ClientSocketCDM.Socket.ReceiveText; // commandeCDM est le morceau tronqué de la fin de la réception précédente - residuCDM:=''; if traceTrames then AfficheDebug(recuCDM,clWhite); {begin @@ -6822,7 +7001,7 @@ begin inc(i); until l0) or (adr<0) then exit; + s:=editVitesse.Text; + val(s,vit,erreur); + if (erreur<>0) or (vit<0) then exit; + s:=trains[combotrains.itemindex+1].nom_train; + Affiche('Commande vitesse train '+s+ ' à '+IntToSTR(vit)+'%',cllime); + vitesse_loco(s,adr,vit,true); + end; // pour déplacer l'ascenseur de l'affichage automatiquement en bas @@ -7232,10 +7422,19 @@ end; procedure TFormPrinc.Apropos1Click(Sender: TObject); begin Affiche(' ',clyellow); - Affiche('Signaux complexes GL version '+version+sousVersion+' (C) 2021 F1IWQ Gily TDR',clWhite); - Affiche('http://cdmrail.free.fr/ForumCDR/viewtopic.php?f=77&t=3906',clWhite); - Affiche('https://github.com/f1iwq2/Signaux_complexes_GL',clWhite); - Affiche(' ',clyellow); + Affiche('Signaux complexes GL version '+version+sousVersion+' (C) 2022 F1IWQ Gily TDR',clWhite); + + FenRich.SelStart:=length(FenRich.Text); + FenRich.SelAttributes.Style:=[fsUnderline]; + FenRich.lines.add('https://github.com/f1iwq2/Signaux_complexes_GL'); + RE_ColorLine(FenRich,FenRich.lines.count-1,clAqua); + + FenRich.SelStart:=length(FenRich.Text); + FenRich.SelAttributes.Style:=[fsUnderline]; + FenRich.lines.add('http://cdmrail.free.fr/ForumCDR/viewtopic.php?f=77&t=3906'); + RE_ColorLine(FenRich,FenRich.lines.count-1,clAqua); + + Affiche(' ',clyellow); end; // cliqué droit sur un feu puis sur le menu propriétés @@ -7260,8 +7459,62 @@ begin if verif_coherence then affiche('La configuration est cohérente',clLime); end; +procedure TFormPrinc.FenRichMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +var lc : integer; + s : string; +begin + if Tdoubleclic=0 then doubleclic:=false; + if not(doubleclic) then + begin + doubleclic:=true; + Tdoubleclic:=3; + exit; + end; + if doubleclic then + begin + doubleclic:=false; + TdoubleClic:=0; + with FenRich do + begin + lc:=Perform(EM_LINEFROMCHAR,-1,0); + s:=lines[lc]; + end; + if pos('http',s)<>0 then + begin + ShellExecute(0,'open',Pchar(s),nil,nil,sw_shownormal); + end; + end; + + +end; + +procedure TFormPrinc.ButtonLocCVClick(Sender: TObject); +begin + if groupBox3.Visible then begin groupBox3.Visible:=false;groupBox2.Visible:=true;exit;end + else begin groupBox2.Visible:=false;groupBox3.Visible:=true;end; +end; + +procedure TFormPrinc.EditAdrTrainChange(Sender: TObject); +var i : integer; + s : string; +begin +end; + + + +procedure TFormPrinc.Button1Click(Sender: TObject); +begin + Interprete_trameCDM('j'); +end; + +procedure TFormPrinc.ComboTrainsChange(Sender: TObject); +var i : integer; +begin + i:=ComboTrains.itemIndex; + EditAdrTrain.Text:=intToSTR(trains[i+1].adresse); +end; begin - end. diff --git a/UnitSR.dcu b/UnitSR.dcu index 6237cb2..3e03169 100644 Binary files a/UnitSR.dcu and b/UnitSR.dcu differ diff --git a/UnitSR.dfm b/UnitSR.dfm index 9f4528e..67cd4b8 100644 --- a/UnitSR.dfm +++ b/UnitSR.dfm @@ -1,6 +1,6 @@ object FormSR: TFormSR - Left = 413 - Top = 214 + Left = 425 + Top = 73 Width = 491 Height = 600 Caption = 'Configuration du d'#233'codeur du signal St'#233'phane Ravaut' diff --git a/UnitSimule.dcu b/UnitSimule.dcu index fa43336..d8ac924 100644 Binary files a/UnitSimule.dcu and b/UnitSimule.dcu differ diff --git a/UnitTCO.dcu b/UnitTCO.dcu index fe1f050..c3ee174 100644 Binary files a/UnitTCO.dcu and b/UnitTCO.dcu differ diff --git a/UnitTCO.dfm b/UnitTCO.dfm index f4df491..2f1ada3 100644 --- a/UnitTCO.dfm +++ b/UnitTCO.dfm @@ -1,6 +1,6 @@ object FormTCO: TFormTCO - Left = 1326 - Top = 122 + Left = 1395 + Top = 198 Width = 1139 Height = 694 VertScrollBar.Visible = False @@ -23,7 +23,7 @@ object FormTCO: TFormTCO OnResize = FormResize DesignSize = ( 1123 - 655) + 656) PixelsPerInch = 96 TextHeight = 13 object LabelX: TLabel @@ -265,41 +265,41 @@ object FormTCO: TFormTCO OnEndDrag = ImagePalette1EndDrag OnMouseDown = ImagePalette1MouseDown end - object ImageSupG: TImage + object ImagePalette6: TImage Left = 216 Top = 56 Width = 41 Height = 41 DragMode = dmAutomatic - OnEndDrag = ImageSupGEndDrag - OnMouseDown = ImageSupGMouseDown + OnEndDrag = ImagePalette6EndDrag + OnMouseDown = ImagePalette6MouseDown end - object ImageSupD: TImage + object ImagePalette7: TImage Left = 288 Top = 56 Width = 41 Height = 41 DragMode = dmAutomatic - OnEndDrag = ImageSupDEndDrag - OnMouseDown = ImageSupDMouseDown + OnEndDrag = ImagePalette7EndDrag + OnMouseDown = ImagePalette7MouseDown end - object ImageInfD: TImage + object ImagePalette8: TImage Left = 360 Top = 56 Width = 41 Height = 41 DragMode = dmAutomatic - OnEndDrag = ImageInfDEndDrag - OnMouseDown = ImageInfDMouseDown + OnEndDrag = ImagePalette8EndDrag + OnMouseDown = ImagePalette8MouseDown end - object ImageInfG: TImage + object ImagePalette9: TImage Left = 432 Top = 56 Width = 41 Height = 41 DragMode = dmAutomatic - OnEndDrag = ImageInfGEndDrag - OnMouseDown = ImageInfGMouseDown + OnEndDrag = ImagePalette9EndDrag + OnMouseDown = ImagePalette9MouseDown end object Label11: TLabel Left = 200 @@ -397,14 +397,14 @@ object FormTCO: TFormTCO Font.Style = [fsBold] ParentFont = False end - object ImageDiag1: TImage + object ImagePalette10: TImage Left = 216 Top = 104 Width = 41 Height = 41 DragMode = dmAutomatic - OnEndDrag = ImageDiag1EndDrag - OnMouseDown = ImageDiag1MouseDown + OnEndDrag = ImageDiag10EndDrag + OnMouseDown = ImagePalette10MouseDown end object Label16: TLabel Left = 192 @@ -419,14 +419,14 @@ object FormTCO: TFormTCO Font.Style = [fsBold] ParentFont = False end - object ImageDiag2: TImage + object ImagePalette11: TImage Left = 288 Top = 104 Width = 41 Height = 41 DragMode = dmAutomatic - OnEndDrag = ImageDiag2EndDrag - OnMouseDown = ImageDiag2MouseDown + OnEndDrag = ImageDiag11EndDrag + OnMouseDown = ImagePalette11MouseDown end object Label17: TLabel Left = 264 @@ -441,15 +441,15 @@ object FormTCO: TFormTCO Font.Style = [fsBold] ParentFont = False end - object ImageFeu: TImage + object ImagePalette30: TImage Left = 376 Top = 104 Width = 25 Height = 41 DragMode = dmAutomatic Stretch = True - OnEndDrag = ImageFeuEndDrag - OnMouseDown = ImageFeuMouseDown + OnEndDrag = ImagePalette30EndDrag + OnMouseDown = ImagePalette30MouseDown end object Label18: TLabel Left = 336 @@ -464,14 +464,14 @@ object FormTCO: TFormTCO Font.Style = [fsBold] ParentFont = False end - object ImageAig45PG_AG: TImage + object ImagePalette12: TImage Left = 576 Top = 8 Width = 41 Height = 41 DragMode = dmAutomatic - OnEndDrag = ImageAig45PG_AGEndDrag - OnMouseDown = ImageAig45PG_AGMouseDown + OnEndDrag = ImagePalette12EndDrag + OnMouseDown = ImagePalette12MouseDown end object Label20: TLabel Left = 552 @@ -499,14 +499,14 @@ object FormTCO: TFormTCO Font.Style = [fsBold] ParentFont = False end - object ImageAig45PD_AD: TImage + object ImagePalette13: TImage Left = 648 Top = 8 Width = 41 Height = 41 DragMode = dmAutomatic - OnEndDrag = ImageAig45PD_ADEndDrag - OnMouseDown = ImageAig45PD_ADMouseDown + OnEndDrag = ImagePalette13EndDrag + OnMouseDown = ImagePalette13MouseDown end object Label21: TLabel Left = 696 @@ -521,14 +521,14 @@ object FormTCO: TFormTCO Font.Style = [fsBold] ParentFont = False end - object ImageAig45PD_AG: TImage + object ImagePalette14: TImage Left = 720 Top = 8 Width = 41 Height = 41 DragMode = dmAutomatic - OnEndDrag = ImageAig45PD_AGEndDrag - OnMouseDown = ImageAig45PD_AGMouseDown + OnEndDrag = ImagePalette14EndDrag + OnMouseDown = ImagePalette14MouseDown end object Label22: TLabel Left = 768 @@ -543,14 +543,14 @@ object FormTCO: TFormTCO Font.Style = [fsBold] ParentFont = False end - object ImageAig45PG_AD: TImage + object ImagePalette15: TImage Left = 792 Top = 8 Width = 41 Height = 41 DragMode = dmAutomatic - OnEndDrag = ImageAig45PG_ADEndDrag - OnMouseDown = ImageAig45PG_ADMouseDown + OnEndDrag = ImagePalette15EndDrag + OnMouseDown = ImagePalette15MouseDown end object Label23: TLabel Left = 8 diff --git a/UnitTCO.pas b/UnitTCO.pas index be46709..91f971f 100644 --- a/UnitTCO.pas +++ b/UnitTCO.pas @@ -39,10 +39,10 @@ type Label7: TLabel; Label10: TLabel; ImagePalette1: TImage; - ImageSupG: TImage; - ImageSupD: TImage; - ImageInfD: TImage; - ImageInfG: TImage; + ImagePalette6: TImage; + ImagePalette7: TImage; + ImagePalette8: TImage; + ImagePalette9: TImage; Label11: TLabel; Label12: TLabel; Label13: TLabel; @@ -51,11 +51,11 @@ type ImagePalette4: TImage; Label8: TLabel; Label9: TLabel; - ImageDiag1: TImage; + ImagePalette10: TImage; Label16: TLabel; - ImageDiag2: TImage; + ImagePalette11: TImage; Label17: TLabel; - ImageFeu: TImage; + ImagePalette30: TImage; Label18: TLabel; ButtonSauveTCO: TButton; ButtonRedessine: TButton; @@ -65,14 +65,14 @@ type ButtonConfigTCO: TButton; Annulercouper: TMenuItem; N5: TMenuItem; - ImageAig45PG_AG: TImage; + ImagePalette12: TImage; Label20: TLabel; Label3: TLabel; - ImageAig45PD_AD: TImage; + ImagePalette13: TImage; Label21: TLabel; - ImageAig45PD_AG: TImage; + ImagePalette14: TImage; Label22: TLabel; - ImageAig45PG_AD: TImage; + ImagePalette15: TImage; Label23: TLabel; EditTexte: TEdit; ButtonSimu: TButton; @@ -139,18 +139,18 @@ type Y: Integer); procedure ImagePalette1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); - procedure ImageSupGEndDrag(Sender, Target: TObject; X, Y: Integer); - procedure ImageSupGMouseDown(Sender: TObject; Button: TMouseButton; + procedure ImagePalette6EndDrag(Sender, Target: TObject; X, Y: Integer); + procedure ImagePalette6MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); - procedure ImageSupDEndDrag(Sender, Target: TObject; X, Y: Integer); - procedure ImageSupDMouseDown(Sender: TObject; Button: TMouseButton; + procedure ImagePalette7EndDrag(Sender, Target: TObject; X, Y: Integer); + procedure ImagePalette7MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); - procedure ImageInfDEndDrag(Sender, Target: TObject; X, Y: Integer); - procedure ImageInfDMouseDown(Sender: TObject; Button: TMouseButton; + procedure ImagePalette8EndDrag(Sender, Target: TObject; X, Y: Integer); + procedure ImagePalette8MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); - procedure ImageInfGMouseDown(Sender: TObject; Button: TMouseButton; + procedure ImagePalette9MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); - procedure ImageInfGEndDrag(Sender, Target: TObject; X, Y: Integer); + procedure ImagePalette9EndDrag(Sender, Target: TObject; X, Y: Integer); procedure ButtonSauveTCOClick(Sender: TObject); procedure MenuCouperClick(Sender: TObject); procedure ImageTCOMouseDown(Sender: TObject; Button: TMouseButton; @@ -171,15 +171,15 @@ type procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Maj_TCO(Adresse : integer); - procedure ImageDiag1EndDrag(Sender, Target: TObject; X, Y: Integer); - procedure ImageDiag1MouseDown(Sender: TObject; Button: TMouseButton; + procedure ImageDiag10EndDrag(Sender, Target: TObject; X, Y: Integer); + procedure ImagePalette10MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); - procedure ImageDiag2EndDrag(Sender, Target: TObject; X, Y: Integer); - procedure ImageDiag2MouseDown(Sender: TObject; Button: TMouseButton; + procedure ImageDiag11EndDrag(Sender, Target: TObject; X, Y: Integer); + procedure ImagePalette11MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure ButtonConfigTCOClick(Sender: TObject); - procedure ImageFeuEndDrag(Sender, Target: TObject; X, Y: Integer); - procedure ImageFeuMouseDown(Sender: TObject; Button: TMouseButton; + procedure ImagePalette30EndDrag(Sender, Target: TObject; X, Y: Integer); + procedure ImagePalette30MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Tourner90GClick(Sender: TObject); procedure Tourner90DClick(Sender: TObject); @@ -187,21 +187,21 @@ type procedure TrackBarZoomChange(Sender: TObject); procedure AnnulercouperClick(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); - procedure ImageAig45PG_AGEndDrag(Sender, Target: TObject; X, + procedure ImagePalette12EndDrag(Sender, Target: TObject; X, Y: Integer); - procedure ImageAig45PG_AGMouseDown(Sender: TObject; + procedure ImagePalette12MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); - procedure ImageAig45PD_ADEndDrag(Sender, Target: TObject; X, + procedure ImagePalette13EndDrag(Sender, Target: TObject; X, Y: Integer); - procedure ImageAig45PD_ADMouseDown(Sender: TObject; + procedure ImagePalette13MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); - procedure ImageAig45PD_AGEndDrag(Sender, Target: TObject; X, + procedure ImagePalette14EndDrag(Sender, Target: TObject; X, Y: Integer); - procedure ImageAig45PD_AGMouseDown(Sender: TObject; + procedure ImagePalette14MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); - procedure ImageAig45PG_ADEndDrag(Sender, Target: TObject; X, + procedure ImagePalette15EndDrag(Sender, Target: TObject; X, Y: Integer); - procedure ImageAig45PG_ADMouseDown(Sender: TObject; + procedure ImagePalette15MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure EditTexteChange(Sender: TObject); procedure ButtonSimuClick(Sender: TObject); @@ -334,14 +334,17 @@ var fichier : textfile; end; begin + {$I+} try - assignFile(fichier,'tco.cfg'); + assign(fichier,'tco.cfg'); reset(fichier); except Affiche('Nouveau tco',clyellow); - NbreCellX:=28;NbreCellY:=13;LargeurCell:=30;HauteurCell:=30; + NbreCellX:=35;NbreCellY:=20;LargeurCell:=30;HauteurCell:=30; exit; end; + {$I-} + x:=1;y:=1;NbreCellX:=0;NbreCellY:=0; // couleurs @@ -511,6 +514,25 @@ begin Affiche('TCO sauvegardé',clyellow); end; +procedure entoure_cell_grille(x,y : integer); +// redessine le carré de grille de la cellule qui a été altéré par la mise à + // jour de la cellule +var Xorg,Yorg : integer; +begin; + Xorg:=(x-1)*LargeurCell; + Yorg:=(y-1)*HauteurCell; + if AvecGrille then With PcanvasTCO do + begin + Pen.Color:=clGrille; + Pen.mode:=PmCopy; + MoveTo(Xorg,YOrg); + LineTo(Xorg+LargeurCell,YOrg); + LineTo(Xorg+LargeurCell,YOrg+HauteurCell); + LineTo(Xorg,YOrg+HauteurCell); + LineTo(Xorg,YOrg); + end; +end; + procedure TformTCO.grille; var x,y : integer; @@ -614,15 +636,20 @@ begin Brush.COlor:=clVoies; Pen.Mode:=pmCopy; - pen.color:=clVoies; - // aiguillage dévié (sans inversion) if ((inverse=false) and (position=const_Devie)) or ((inverse=true) and (position=const_Droit)) or (position=9) then begin horz; - if (mode=1) and (position=const_devie) then begin Pen.color:=clAllume;Brush.color:=ClAllume end else begin Pen.color:=clVoies;Brush.Color:=clVoies;end; + if (mode=1) and (position=const_devie) then + begin + Pen.color:=clAllume;Brush.color:=ClAllume + end + else + begin + Pen.color:=clVoies;Brush.Color:=clVoies; + end; deviation; r:=Rect(x0+(LargeurCell div 2),jy1,x0+LargeurCell,jy2); canvas.FillRect(r); @@ -2348,7 +2375,7 @@ end; // affiche la cellule x et y en cases procedure TformTCO.affiche_cellule(x,y : integer); -var Xorg,Yorg,mode,adresse,Bimage,aspect,oriente,pos : integer; +var Xorg,Yorg,xt,yt,mode,adresse,Bimage,aspect,oriente,pos : integer; Bt : TEquipement; s : string; begin @@ -2362,16 +2389,17 @@ begin if (bImage>=2) then //????? and (btype<=15) begin if Adresse<>0 then pos:=Aiguillage[Index_Aig(adresse)].position - - else pos:=9; - end; + + else pos:=9; + end; Xorg:=(x-1)*LargeurCell; Yorg:=(y-1)*HauteurCell; s:=IntToSTR(adresse); - + // pourquoi ? ? if y>1 then if (tco[x,y-1].Bimage=30) and (FeuTCO[i].FeuOriente=1) then exit; - - case Bimage of + + // affiche d'abord l'icone de la cellule et colore la voie si zone ou détecteur actionnée selon valeur mode + case Bimage of // 0 : efface_cellule(PCanvasTCO,x,y,Clyellow,Mode); &&&&&&&&& 1 : dessin_voie(PCanvasTCO,X,Y,mode); 2 : dessin_AigG_PD(PCanvasTCO,X,Y,mode,pos); @@ -2395,54 +2423,56 @@ begin 20 : dessin_20(PCanvasTCO,X,Y,mode); 21 : dessin_21(PCanvasTCO,X,Y,mode); 22 : dessin_22(PCanvasTCO,X,Y,mode); - + 30 : dessin_feu(PCanvasTCO,X,Y); end; PCanvasTCO.font.Size:=(LargeurCell div 10)+4 ; // Affiche(intToSTR( (LargeurCell div 30)+6),clyellow); - + // affiche le texte des aiguillages - if ((BImage=2) or (BImage=3) or (BImage=4) or (BImage=5) or (BImage=12) or (BImage=13) or (BImage=14) or (BImage=15) or (BImage=21) or (BImage=22)) and (adresse<>0) then - begin + if ((BImage=2) or (BImage=3) or (BImage=4) or (BImage=5) or (BImage=12) or (BImage=13) or (BImage=14) or (BImage=15) or (BImage=21) or (BImage=22)) and (adresse<>0) then + begin if Bt<>tjs then s:='A'+s else s:='A'+s+'B'; with PCanvasTCO do begin Brush.Color:=fond; Font.Color:=clYellow; - x:=0;y:=0; - if Bimage=4 then begin x:=1;y:=1;end; - if Bimage=5 then begin x:=1;y:=HauteurCell-round(20*fryGlob);end; - if Bimage=12 then begin x:=1;y:=HauteurCell-round(20*frYGlob);end; - if Bimage=21 then begin x:=2;y:=1;end; - if Bimage=22 then begin x:=1;y:=HauteurCell-round(15*frYGlob);end; - TextOut(xOrg+x,yOrg+y,s); - exit; - end; + xt:=0;yt:=0; + if Bimage=4 then begin xt:=1;yt:=1;end; + if Bimage=5 then begin xt:=1;yt:=HauteurCell-round(20*fryGlob);end; + if Bimage=12 then begin xt:=1;yt:=HauteurCell-round(20*frYGlob);end; + if Bimage=21 then begin xt:=2;yt:=1;end; + if Bimage=22 then begin xt:=1;yt:=HauteurCell-round(15*frYGlob);end; + TextOut(xOrg+xt,yOrg+yt,s); + //exit; + end; end; - + // détecteurs - if ((BImage=1) ) and (adresse<>0) then + if ((BImage=1) ) and (adresse<>0) then begin // Adresse de l'élément with PCanvasTCO do begin Brush.Color:=fond; Font.Color:=clWhite; - x:=round(15*frXGlob);y:=HauteurCell-round(17*frYGlob); - TextOut(xOrg+x,yOrg+y,s); - exit; - end; + xt:=round(15*frXGlob);yt:=HauteurCell-round(17*frYGlob); + TextOut(xOrg+xt,yOrg+yt,s); + //exit; + end; end; - if ((Bimage=10) or (Bimage=20)) and (adresse<>0) then + + if ((Bimage=10) or (Bimage=20)) and (adresse<>0) then begin // Adresse de l'élément with PCanvasTCO do begin Brush.Color:=fond; Font.Color:=clWhite; TextOut(xOrg+round(2*frXGlob),yOrg+round(2*fryGlob),s); - exit; + //exit; end; end; + if (Bimage=11) and (adresse<>0) then begin // Adresse de l'élément with PCanvasTCO do @@ -2450,7 +2480,7 @@ begin Brush.Color:=fond; Font.Color:=clWhite; TextOut(xOrg+round(28*frXGlob),yOrg+round(2*fryGlob),s); - exit; + //exit; end; end; @@ -2459,33 +2489,34 @@ begin begin aspect:=TCO[x,y].Aspect; oriente:=TCO[x,y].FeuOriente; - x:=0;y:=0; - if (aspect=9) and (Oriente=1) then begin x:=LargeurCell-round(25*frXGlob);y:=2*HauteurCell-round(25*fryGlob);end; - if (aspect=9) and (Oriente=2) then begin x:=round(10*frXGlob);y:=HauteurCell-round(17*frYGlob);end; // orientation G - if (aspect=9) and (Oriente=3) then begin x:=LargeurCell+2;y:=1;end; - if (aspect=7) and (Oriente=1) then begin x:=LargeurCell-round(25*frXGlob);y:=2*HauteurCell-round(25*fryGlob);;end; - if (aspect=7) and (Oriente=2) then begin x:=round(10*frXGlob);y:=HauteurCell-round(15*frYGlob);end; - if (aspect=7) and (Oriente=3) then begin x:=LargeurCell+2;y:=1;end; - if (aspect=5) and (Oriente=1) then begin x:=1;y:=1;end; - if (aspect=5) and (Oriente=2) then begin x:=round(10*frXGlob);y:=round(2*frYGlob);end; - if (aspect=5) and (Oriente=3) then begin x:=round(10*frXGlob);y:=HauteurCell-round(22*frYGlob);end; - if (aspect=4) and (Oriente=1) then begin x:=1;y:=1;end; - if (aspect=4) and (Oriente=2) then begin x:=round(10*frXGlob);y:=round(2*frYGlob);end; - if (aspect=4) and (Oriente=3) then begin x:=round(10*frXGlob);y:=HauteurCell-round(22*frYGlob);end; - if (aspect=3) and (Oriente=1) then begin x:=1;y:=1;end; - if (aspect=3) and (Oriente=2) then begin x:=round(10*frXGlob);y:=round(2*frYGlob);end; - if (aspect=3) and (Oriente=3) then begin x:=round(10*frXGlob);y:=HauteurCell-round(22*frYGlob);end; - if (aspect=2) and (Oriente=1) then begin x:=1;y:=1;end; // orientation V - if (aspect=2) and (Oriente=2) then begin x:=round(10*frXGlob);y:=round(2*frYGlob);end; // orientation G - if (aspect=2) and (Oriente=3) then begin x:=round(10*frXGlob);y:=HauteurCell-round(22*frYGlob);end; // orientation D + xt:=0;yt:=0; + if (aspect=9) and (Oriente=1) then begin xt:=LargeurCell-round(25*frXGlob);yt:=2*HauteurCell-round(25*fryGlob);end; + if (aspect=9) and (Oriente=2) then begin xt:=round(10*frXGlob);yt:=HauteurCell-round(17*frYGlob);end; // orientation G + if (aspect=9) and (Oriente=3) then begin xt:=LargeurCell+2;yt:=1;end; + if (aspect=7) and (Oriente=1) then begin xt:=LargeurCell-round(25*frXGlob);yt:=2*HauteurCell-round(25*fryGlob);;end; + if (aspect=7) and (Oriente=2) then begin xt:=round(10*frXGlob);yt:=HauteurCell-round(15*frYGlob);end; + if (aspect=7) and (Oriente=3) then begin xt:=LargeurCell+2;yt:=1;end; + if (aspect=5) and (Oriente=1) then begin xt:=1;yt:=1;end; + if (aspect=5) and (Oriente=2) then begin xt:=round(10*frXGlob);yt:=round(2*frYGlob);end; + if (aspect=5) and (Oriente=3) then begin xt:=round(10*frXGlob);yt:=HauteurCell-round(22*frYGlob);end; + if (aspect=4) and (Oriente=1) then begin xt:=1;yt:=1;end; + if (aspect=4) and (Oriente=2) then begin xt:=round(10*frXGlob);yt:=round(2*frYGlob);end; + if (aspect=4) and (Oriente=3) then begin xt:=round(10*frXGlob);yt:=HauteurCell-round(22*frYGlob);end; + if (aspect=3) and (Oriente=1) then begin xt:=1;yt:=1;end; + if (aspect=3) and (Oriente=2) then begin xt:=round(10*frXGlob);yt:=round(2*frYGlob);end; + if (aspect=3) and (Oriente=3) then begin xt:=round(10*frXGlob);yt:=HauteurCell-round(22*frYGlob);end; + if (aspect=2) and (Oriente=1) then begin xt:=1;yt:=1;end; // orientation V + if (aspect=2) and (Oriente=2) then begin xt:=round(10*frXGlob);yt:=round(2*frYGlob);end; // orientation G + if (aspect=2) and (Oriente=3) then begin xt:=round(10*frXGlob);yt:=HauteurCell-round(22*frYGlob);end; // orientation D with PCanvasTCO do begin Brush.Color:=fond; Font.Color:=clLime; - TextOut(xOrg+x,yOrg+y,s); + TextOut(xOrg+xt,yOrg+yt,s); end; end; + entoure_cell_grille(x,y); //canvasTCO.TextOut(xOrg+1,yOrg+1,IntToSTR(x)); end; @@ -2719,6 +2750,7 @@ end; procedure zone_TCO(det1,det2,mode : integer); var i,x,y,ancienY,ancien2Y,ancienX,ancien2X,Xdet1,Ydet1,Xdet2,Ydet2,Bimage,adresse, pos,pos2 : integer; + memtrouve : boolean; s : string; begin // trouver le détecteur det1 @@ -2736,13 +2768,20 @@ begin x:=Ydet2;Ydet2:=Ydet1;Ydet1:=x; x:=det2;det2:=det1;det1:=x; end; + + if yDet240); + inc(i); + if adresse=det2 then memTrouve:=true; + until (x=1) or (x=NbreCellX) or (y=NbreCellY) or ((adresse<>det2) and memTrouve) or (i>40); if i>40 then begin @@ -2951,16 +2991,16 @@ begin dessin_AigPG_AG(ImagePalette3.Canvas,1,1,0,9); dessin_AigD_PG(ImagePalette4.Canvas,1,1,0,9); dessin_voie(ImagePalette1.canvas,1,1,0); - dessin_SupG(ImageSupG.canvas,1,1,0); - dessin_SupD(ImageSupD.canvas,1,1,0); - dessin_InfD(ImageInfD.canvas,1,1,0); - dessin_infG(ImageInfG.canvas,1,1,0); - dessin_Diag1(ImageDiag1.Canvas,1,1,0); - dessin_Diag2(ImageDiag2.Canvas,1,1,0); - dessin_Aig45PG_AG(ImageAig45PG_AG.Canvas,1,1,0,9); - dessin_Aig45PD_AD(ImageAig45PD_AD.Canvas,1,1,0,9); - dessin_Aig45PD_AG(ImageAig45PD_AG.Canvas,1,1,0,9); - dessin_Aig45PG_AD(ImageAig45PG_AD.Canvas,1,1,0,9); + dessin_SupG(ImagePalette6.canvas,1,1,0); + dessin_SupD(ImagePalette7.canvas,1,1,0); + dessin_InfD(ImagePalette8.canvas,1,1,0); + dessin_infG(ImagePalette9.canvas,1,1,0); + dessin_Diag1(ImagePalette10.Canvas,1,1,0); + dessin_Diag2(ImagePalette11.Canvas,1,1,0); + dessin_Aig45PG_AG(ImagePalette12.Canvas,1,1,0,9); + dessin_Aig45PD_AD(ImagePalette13.Canvas,1,1,0,9); + dessin_Aig45PD_AG(ImagePalette14.Canvas,1,1,0,9); + dessin_Aig45PG_AD(ImagePalette15.Canvas,1,1,0,9); dessin_16(ImagePalette16.canvas,1,1,0); dessin_17(ImagePalette17.canvas,1,1,0); dessin_18(ImagePalette18.canvas,1,1,0); @@ -2984,7 +3024,7 @@ begin PImageTemp:=FormTCO.ImageTemp; PImageTemp.Canvas.Rectangle(0,0,PImageTemp.Width,PimageTemp.Height); - With ImageFeu do + With ImagePalette30 do begin Picture.Bitmap.TransparentMode:=tmAuto; Picture.Bitmap.TransparentColor:=clblue; @@ -3136,10 +3176,12 @@ begin dessin_AigPD_AD(ImageTCO.Canvas,XClicCell,YClicCell,0,9); tco[XClicCell,YClicCell].BType:=aig; // aiguillage tco[XClicCell,YClicCell].BImage:=5; // image 5 + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); + end; procedure TFormTCO.ImagePalette2EndDrag(Sender,Target: TObject; X,Y: Integer); @@ -3153,10 +3195,12 @@ begin tco[XClicCell,YClicCell].BType:=aig; // aiguillage tco[XClicCell,YClicCell].BImage:=2; // image 2 dessin_AigG_PD(ImageTCO.Canvas,XClicCell,YClicCell,0,9); + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); + end; procedure TFormTCO.ImagePalette2MouseDown(Sender: TObject; @@ -3176,10 +3220,11 @@ begin dessin_AigPG_AG(ImageTCO.Canvas,XClicCell,YClicCell,0,9); tco[XClicCell,YClicCell].BType:=aig; // aiguillage tco[XClicCell,YClicCell].BImage:=3; // image 3 + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); - EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); + EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); end; procedure TFormTCO.ImagePalette3MouseDown(Sender: TObject; @@ -3199,6 +3244,7 @@ begin dessin_AigD_PG(ImageTCO.Canvas,XClicCell,YClicCell,0,9); tco[XClicCell,YClicCell].BType:=aig; // aiguillage tco[XClicCell,YClicCell].BImage:=4; // image 4 + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); @@ -3224,10 +3270,12 @@ begin tco[XClicCell,YClicCell].BType:=voie; // voie (3) tco[XClicCell,YClicCell].BImage:=1; // image 1 tco[XClicCell,YClicCell].Adresse:=0; + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; - EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); + EditAdrElement.Text:=IntToSTR(tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); + end; procedure TFormTCO.ImagePalette1MouseDown(Sender: TObject; @@ -3236,7 +3284,7 @@ begin ImagePalette1.BeginDrag(true); end; -procedure TFormTCO.ImageSupGEndDrag(Sender, Target: TObject; X,Y: Integer); +procedure TFormTCO.ImagePalette6EndDrag(Sender, Target: TObject; X,Y: Integer); begin if (x=0) and (y=0) then exit; efface_entoure; @@ -3248,18 +3296,19 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=6; // image 6 tco[XClicCell,YClicCell].Adresse:=0; + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); end; -procedure TFormTCO.ImageSupGMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +procedure TFormTCO.ImagePalette6MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - ImageSupG.BeginDrag(true); + ImagePalette6.BeginDrag(true); end; -procedure TFormTCO.ImageSupDEndDrag(Sender, Target: TObject; X, +procedure TFormTCO.ImagePalette7EndDrag(Sender, Target: TObject; X, Y: Integer); begin if (x=0) and (y=0) then exit; @@ -3272,19 +3321,20 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=7; // image 7 tco[XClicCell,YClicCell].Adresse:=0; + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); end; -procedure TFormTCO.ImageSupDMouseDown(Sender: TObject; +procedure TFormTCO.ImagePalette7MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - ImageSupD.BeginDrag(true); + ImagePalette7.BeginDrag(true); end; -procedure TFormTCO.ImageInfDEndDrag(Sender, Target: TObject; X, +procedure TFormTCO.ImagePalette8EndDrag(Sender, Target: TObject; X, Y: Integer); begin if (x=0) and (y=0) then exit; @@ -3297,49 +3347,50 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=8; // image 8 tco[XClicCell,YClicCell].Adresse:=0; + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); end; -procedure TFormTCO.ImageInfDMouseDown(Sender: TObject; +procedure TFormTCO.ImagePalette8MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - ImageInfD.BeginDrag(true); + ImagePalette7.BeginDrag(true); end; -procedure TFormTCO.ImageInfGMouseDown(Sender: TObject; +procedure TFormTCO.ImagePalette9MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - ImageInfG.BeginDrag(true); + ImagePalette9.BeginDrag(true); end; -procedure TFormTCO.ImageAig45PG_AGMouseDown(Sender: TObject; +procedure TFormTCO.ImagePalette12MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - ImageAig45PG_AG.BeginDrag(true); + ImagePalette12.BeginDrag(true); end; -procedure TFormTCO.ImageAig45PD_ADMouseDown(Sender: TObject; +procedure TFormTCO.ImagePalette13MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - ImageAig45PD_AD.BeginDrag(true); + ImagePalette13.BeginDrag(true); end; -procedure TFormTCO.ImageAig45PD_AGMouseDown(Sender: TObject; +procedure TFormTCO.ImagePalette14MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - ImageAig45PD_AG.BeginDrag(true); + ImagePalette14.BeginDrag(true); end; -procedure TFormTCO.ImageAig45PG_ADMouseDown(Sender: TObject; +procedure TFormTCO.ImagePalette15MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - ImageAig45PG_AD.BeginDrag(true); + ImagePalette15.BeginDrag(true); end; procedure TFormTCO.ImagePalette16MouseDown(Sender: TObject; @@ -3385,7 +3436,7 @@ begin ImagePalette22.BeginDrag(true); end; -procedure TFormTCO.ImageInfGEndDrag(Sender, Target: TObject; X, +procedure TFormTCO.ImagePalette9EndDrag(Sender, Target: TObject; X, Y: Integer); begin if (x=0) and (y=0) then exit; @@ -3398,13 +3449,14 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=9; // image 9 tco[XClicCell,YClicCell].Adresse:=0; // rien + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); end; -procedure TFormTCO.ImageAig45PG_AGEndDrag(Sender, Target: TObject; X, +procedure TFormTCO.ImagePalette12EndDrag(Sender, Target: TObject; X, Y: Integer); begin if (x=0) and (y=0) then exit; @@ -3417,14 +3469,16 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=12; // image 12 tco[XClicCell,YClicCell].Adresse:=0; // rien + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); + end; -procedure TFormTCO.ImageAig45PD_ADEndDrag(Sender, Target: TObject; X, +procedure TFormTCO.ImagePalette13EndDrag(Sender, Target: TObject; X, Y: Integer); begin if (x=0) and (y=0) then exit; @@ -3437,13 +3491,15 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=13; // image 13 tco[XClicCell,YClicCell].Adresse:=0; // rien + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); + end; -procedure TFormTCO.ImageAig45PD_AGEndDrag(Sender, Target: TObject; X, +procedure TFormTCO.ImagePalette14EndDrag(Sender, Target: TObject; X, Y: Integer); begin if (x=0) and (y=0) then exit; @@ -3456,13 +3512,14 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=14; // image 14 tco[XClicCell,YClicCell].Adresse:=0; // rien + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); end; -procedure TFormTCO.ImageAig45PG_ADEndDrag(Sender, Target: TObject; X, +procedure TFormTCO.ImagePalette15EndDrag(Sender, Target: TObject; X, Y: Integer); begin if (x=0) and (y=0) then exit; @@ -3475,6 +3532,7 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=15; // image 15 tco[XClicCell,YClicCell].Adresse:=0; // rien + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); @@ -3493,6 +3551,7 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=16; // image 16 tco[XClicCell,YClicCell].Adresse:=0; // rien + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); @@ -3512,6 +3571,7 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=17; // image 17 tco[XClicCell,YClicCell].Adresse:=0; // rien + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); @@ -3531,6 +3591,7 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=18; // image 18 tco[XClicCell,YClicCell].Adresse:=0; // rien + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); @@ -3550,6 +3611,7 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=19; // image 19 tco[XClicCell,YClicCell].Adresse:=0; // rien + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); @@ -3569,6 +3631,7 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=20; // image 20 tco[XClicCell,YClicCell].Adresse:=0; // rien + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); @@ -3588,6 +3651,7 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=21; tco[XClicCell,YClicCell].Adresse:=0; // rien + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); @@ -3607,6 +3671,7 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=22; tco[XClicCell,YClicCell].Adresse:=0; // rien + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); @@ -3974,13 +4039,16 @@ begin end; procedure TFormTCO.Maj_TCO(Adresse : integer); -var x,y : integer; +var x,y,xOrg,yOrg : integer; begin for y:=1 to NbreCellY do for x:=1 to NbreCellX do begin - if tco[x,y].Adresse=Adresse then - affiche_cellule(x,y); + if tco[x,y].Adresse=Adresse then + begin + affiche_cellule(x,y); + entoure_cell_grille(x,y); + end; end; end; @@ -3999,7 +4067,7 @@ end; // dépose d'un feu sur le TCO -procedure TFormTCO.ImageDiag1EndDrag(Sender, Target: TObject; X, Y: Integer); +procedure TFormTCO.ImageDiag10EndDrag(Sender, Target: TObject; X, Y: Integer); begin if (x=0) and (y=0) then exit; TCO_modifie:=true; @@ -4010,7 +4078,8 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=10; // image 10 tco[XClicCell,YClicCell].Adresse:=0; - tco[XClicCell,YClicCell].FeuOriente:=1; + tco[XClicCell,YClicCell].FeuOriente:=1; + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; tco[XClicCell,YClicCell].x:=0; // XClicCell; //?? tco[XClicCell,YClicCell].y:=0; // YClicCell; //?? @@ -4020,13 +4089,13 @@ begin EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); end; -procedure TFormTCO.ImageDiag1MouseDown(Sender: TObject; +procedure TFormTCO.ImagePalette10MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - ImageDiag1.BeginDrag(true); + ImagePalette10.BeginDrag(true); end; -procedure TFormTCO.ImageDiag2EndDrag(Sender, Target: TObject; X, +procedure TFormTCO.ImageDiag11EndDrag(Sender, Target: TObject; X, Y: Integer); begin if (x=0) and (y=0) then exit; @@ -4038,16 +4107,17 @@ begin tco[XClicCell,YClicCell].BType:=rien; // rien tco[XClicCell,YClicCell].BImage:=11; tco[XClicCell,YClicCell].Adresse:=0; + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); end; -procedure TFormTCO.ImageDiag2MouseDown(Sender: TObject; +procedure TFormTCO.ImagePalette11MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - ImageDiag2.BeginDrag(true); + ImagePalette11.BeginDrag(true); end; procedure TFormTCO.ButtonConfigTCOClick(Sender: TObject); @@ -4057,7 +4127,7 @@ begin formconfigTCO.close; end; -procedure TFormTCO.ImageFeuEndDrag(Sender, Target: TObject; X, Y: Integer); +procedure TFormTCO.ImagePalette30EndDrag(Sender, Target: TObject; X, Y: Integer); begin if (x=0) and (y=0) then exit; efface_entoure; @@ -4073,21 +4143,22 @@ begin tco[XClicCell,YClicCell].Aspect:=9; tco[XClicCell,YClicCell].x:=0; tco[XClicCell,YClicCell].y:=0; - // ne pas convertir l'adresse sinon evt changement du composant et on écrase l'aspect EditAdrElement.Text:=IntToSTR( tco[XClicCell,YClicCell].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCell,YClicCell].Btype)); EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); dessin_feu(PCanvasTCO,XclicCell,YClicCell); + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; + end; -procedure TFormTCO.ImageFeuMouseDown(Sender: TObject; Button: TMouseButton; +procedure TFormTCO.ImagePalette30MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - ImageFeu.BeginDrag(true); + ImagePalette30.BeginDrag(true); end; @@ -4298,8 +4369,8 @@ begin ( FindComponent('No') as TButton).Caption:='dévié'; end; Result:=Msgdlg.ShowModal; - if Result=MrYes then begin efface_entoure;SelectionAffichee:=false;pilote_acc(adresse,2,aigP);end; // droit - if Result=MrNo then begin efface_entoure;SelectionAffichee:=false;pilote_acc(adresse,1,aigP);end; // dévié + if Result=MrYes then begin efface_entoure;SelectionAffichee:=false;pilote_acc(adresse,const_droit,aigP);end; // droit + if Result=MrNo then begin efface_entoure;SelectionAffichee:=false;pilote_acc(adresse,const_devie,aigP);end; // dévié sourisclic:=false; // évite de générer un cadre de sélection:=false; piloteAig:=true; @@ -4308,7 +4379,6 @@ begin // commande de signal if Bimage=30 then begin - if adresse=0 then exit; AdrPilote:=adresse; i:=Index_feu(adresse); @@ -4319,7 +4389,7 @@ begin show; ImagePilote.top:=40;ImagePilote.left:=220; ImagePilote.Parent:=FormPilote; - ImagePilote.Picture.Bitmap.TransparentMode:=tmAuto; + ImagePilote.Picture.Bitmap.TransparentMode:=tmAuto; ImagePilote.Picture.Bitmap.TransparentColor:=clblue; ImagePilote.Transparent:=true; @@ -4342,4 +4412,8 @@ begin + + + + end. diff --git a/verif_version.pas b/verif_version.pas index ce0de70..ea3384f 100644 --- a/verif_version.pas +++ b/verif_version.pas @@ -23,7 +23,7 @@ var Lance_verif : integer; verifVersion,notificationVersion : boolean; -Const Version='3.5'; // sert à la comparaison de la version publiée +Const Version='3.6'; // sert à la comparaison de la version publiée SousVersion=' '; // en cas d'absence de sous version mettre un espace implementation diff --git a/versions.txt b/versions.txt index 40c81af..d79171d 100644 --- a/versions.txt +++ b/versions.txt @@ -73,6 +73,13 @@ version 3.5 : Les actions "fonctions F, accessoires, sons" sur actionneurs sont Possibilité de jouer des sons sur un évènement actionneur/détecteur. Correction d'un bug sur le lancement de CDM en 32 bits. Correction des messages d'erreurs et de nombre de trains en mode "config nulle". +version 3.6 : Amélioration gestion temporisations des actionneurs. + Ajout temporisation pilotage des décodeurs de feux. + Correction d'affichage du TCO. + Correction des messages transmis de CDM. + Changement des vitesses courantes des trains. + +