diff --git a/ConfigGenerale.cfg b/ConfigGenerale.cfg index 9e761f3..2437f25 100644 --- a/ConfigGenerale.cfg +++ b/ConfigGenerale.cfg @@ -1,41 +1,54 @@ -/ Fichier de configuration de signaux_complexes_GL version 8.2 -LargeurF=1222 -HauteurF=652 -OffsetX=29 -OffsetY=186 -Splitter=1 -AvecVerifIconesTCO=1 +/ Fichier de configuration de signaux_complexes_GL version 8.79 +LargeurF=1120 +HauteurF=681 +OffsetX=128 +OffsetY=28 +LargeurFC=250 +HauteurFC=250 +OffsetXC=998 +OffsetYC=427 +Splitter=531 +AvecVerifIconesTCO=0 Algo_localisation=1 +Max_Signal_Sens=5 +Mode_reservation=0 Avec_roulage=1 Debug=0 +Mode_Sombre=0 +coul_fond=000040 +serveurIPCDM_Touche=0 +Port_Serveur=4500 Filtrage_det=3 +nCantonsRes=2 AntiTimeoutEthLenz=0 +TempoTC=3 Fonte=10 +Style=3 Protocole=1 Verif_AdrXpressNet=1 IpV4_PC=127.0.0.1:9999 ServicesCDM=15 Ipv4_interface=192.168.1.23:5550 -MaxCom=30 -Protocole_serie=COMX:115200,N,8,1,0 -ProtocolePortCde=COMX:115200,N,8,1 +Protocole_serie=COM6:57600,N,8,1,0 Inter_car=50 Tempo_maxi=15 Entete=1 -Init_Aig=0 +Init_Aig=1 +PilotageTrainsCDMNom=1 Init_Dem_Aig=0 -Tempo_Aig=50 +Tempo_Aig=200 Init_demUSBCOM=0 Init_demETH=0 Fenetre=0 -AffMemoFenetre=0 +Ecran=1 +AffMemoFenetre=1 nb_det_dist=3 verif_version=0 notif_version=0 TCO=1 NbreTCO=1 Nom_fichier_TCO1=TCO.CFG -Nom_fichier_TCO2=DEUXIEME.CFG +Nom_fichier_TCO2=TCO_ESSAI Nom_fichier_TCO3=TCO3.CFG Nom_fichier_TCO4=TCO4.CFG Nom_fichier_TCO5=TCO5.CFG @@ -50,46 +63,49 @@ Lay=RESEAU_GILY_SIGNAL_AJOUTE.LAY NomModuleCDM=reseau_gily_signal_ajoute_top.cdm Serveur_interface=1 retro=1 +Z21=0 RazSignaux=0 +AigND=0 Tempo_Feu=100 Nb_cantons_Sig=3 Alg_Unisemaf=1 +ModeResa=0 /------------ [section_aig] -1,P518,D100D,S3P,V30,I0,INIT(1,2) -2,P12S,D519,S100S,V0,I0,INIT(1,2) -3,P1S,D4P,S5D,V0,I0,INIT(2,2) -4,P3D,D6S,S514,V0,I0,INIT(1,2) -5,P515,D3S,S100S,V0,I0,INIT(1,2) -6,P516,D0,S4D,V0,I0,INIT(1,2) -7,P527,D519,S520,V0,I0,INIT(2,2) -8,P527,D521,S103S,V40,I0,INIT(1,2) -9,P526,D103D,S515,V60,I0,INIT(1,2) -10,P101S,D29P,S528,V30,I0,INIT(1,2) -11,P18P,D30D,S101D,V0,I0,INIT(1,2) -12,P517,D20S,S2P,V0,I0,INIT(1,2) -17,P525,D535,S528,V0,I0,INIT(1,4) -18,P11P,D23P,S102S,V0,I0,INIT(1,2) -19,P101D,D22P,S531,V0,I0,INIT(1,2) -20,P520,D21P,S12D,V0,I0,INIT(2,2) -21,P20D,D28S,S28D,V0,I0,INIT(2,2) -22,P19D,D537,S32P,V0,I0,INIT(2,2) -23,P18D,D538,S534,V0,I0,INIT(2,2) -24,P538,D32S,S533,V0,I0,INIT(2,2) -25,P104S,D529,S27P,V0,I0,INIT(2,2) -26TJD,D(530,28D),S(529,28S),V0,I0,INIT(2,2),E4 -27,P25S,D530,S537,V0,I0,INIT(2,2) -28TJD,D(21D,26D),S(21S,26S),V0,I0,INIT(2,2),E4 -29,P10D,D513,S30S,V60,I0,INIT(2,2) -30,P524,D11D,S29S,V0,I0,INIT(2,2) -31,P534,D34D,S104S,V0,I0,INIT(1,2) -32,P22S,D34S,S24D,V0,I0,INIT(1,2) -34,P0,D31D,S32D,V0,I0,INIT(2,2) -100CROI,D(1D,523),S(2S,5S) -101CROI,D(11S,525),S(19P,10P) -102CROI,D(22P,19D),S(517,18S) -103CROI,D(513,9D),S(522,8S) -104CROI,D(0,32D),S(25P,31S) +1,P518,D100D,S3P,V30,I0,INIT(1,2),C0 +2,P12S,D519,S100S,V0,I0,INIT(2,2),C0 +3,P1S,D4P,S5D,V0,I0,INIT(2,2),C0 +4,P3D,D6S,S514,V0,I0,INIT(2,2),C0 +5,P515,D3S,S100S,V0,I0,INIT(1,2),C0 +6,P516,D0,S4D,V0,I0,INIT(1,2),C0 +7,P527,D519,S520,V30,I0,INIT(1,2),C0 +8,P527,D521,S103S,V0,I0,INIT(2,2),C0 +9,P526,D103D,S515,V60,I0,INIT(1,2),C0 +10,P101S,D29P,S528,V30,I0,INIT(1,2),C0 +11,P18P,D30D,S101D,V0,I0,INIT(2,2),C0 +12,P517,D20S,S2P,V0,I0,INIT(1,2),C0 +17,P525,D535,S528,V0,I0,INIT(1,4),C0 +18,P11P,D23P,S102S,V0,I0,INIT(1,2),C0 +19,P101S,D102D,S531,V0,I0,INIT(1,2),C0 +20,P520,D21P,S12D,V0,I0,INIT(1,2),C0 +21,P20D,D28S,S28D,V0,I0,INIT(2,2),C0 +22,P102D,D537,S32P,V0,I0,INIT(2,2),C0 +23,P18D,D538,S534,V0,I0,INIT(2,2),C0 +24,P538,D32S,S533,V0,I0,INIT(1,2),C0 +25,P104S,D529,S27P,V0,I0,INIT(2,2),C0 +26TJD,D(530,28D),S(529,28S),V0,I0,INIT(2,2),E4,C0 +27,P25S,D530,S537,V0,I0,INIT(1,2),C0 +28TJD,D(21D,26D),S(21S,26S),V0,I0,INIT(2,2),E4,C0 +29,P10D,D513,S30S,V60,I0,INIT(2,2),C0 +30,P524,D11D,S29S,V0,I0,INIT(2,2),C0 +31,P534,D34D,S104S,V0,I0,INIT(1,2),C0 +32,P22S,D34S,S24D,V0,I0,INIT(1,2),C0 +34,P0,D31D,S32D,V0,I0,INIT(2,2),C0 +100CROI,D(1D,523),S(2S,5S),C0 +101CROI,D(11S,525),S(19P,10P),C0 +102CROI,D(22P,19D),S(517,18S),C0 +103CROI,D(513,9D),S(522,8S),C0 +104CROI,D(0,32D),S(25P,31S),C0 0 /------------ [section_branches] @@ -109,23 +125,80 @@ A31,A34,0 0 /------------ [section_decodeurs] -Nom_dec_pers=Personnalisé 1 +/ décodeur n°1 +Nom_dec_pers=Personnalise1 NombreAdresses=4 -Nation=1 +Nation=2 +Commande=0 +Periph=0 1,2,0,1,2 3,4,1,1,2 5,9,2,1,2 -10,11,3,1,2 +7,8,3,1,2 +/ décodeur n°2 Nom_dec_pers=grand -NombreAdresses=7 +NombreAdresses=8 Nation=1 +Commande=0 +Periph=0 1,2,0,1,2 3,4,1,0,0 5,6,2,0,0 7,8,3,0,0 -9,10,4,0,0 -11,12,5,0,0 -13,14,6,0,0 +0,0,0,0,0 +0,0,0,0,0 +0,0,0,0,0 +0,0,0,0,0 +/ décodeur n°3 +Nom_dec_pers=decodeur com +NombreAdresses=10 +Nation=1 +Commande=1 +Periph=1 +carré,car +sémaphore,sem +sémaphore cli,semcli +vert, +vert cli, +violet, +blanc, +blanc cli, +jaune, +jaune cli, +ralen 30, +ralen 60, +rappel 30, +rappel 60, +ralen 60 + jaune cli, +rappel 30 + jaune, +rappel 30 + jaune cli, +rappel 60 + jaune, +rappel 60 + jaune cli, +/ décodeur n°4 +Nom_dec_pers=decodeur USB Belge +NombreAdresses=10 +Nation=2 +Commande=1 +Periph=1 +vert jaune horizontal,vjh +rouge,r +vert,v +vert jaune vertical, +rouge blanc, +deux jaunes, +Chiffre, +Chevron, +Clignote, + , + , + , + , + , + , + , + , + , + , 0 /------------ [section_sig] @@ -151,20 +224,18 @@ Nation=1 476,9,0,1,(538,A23),1,FVC0,FRC0 497,9,0,4,(531,A19),1,FVC0,FRC0 520,9,1,1,(518,A1),1,FVC0,FRC0,(A1S,A3S,A5S),CFB(A1S,A3D,A4D,A6S) -600,20,0,10,(521,A8),0,FVC0,FRC0,NA5,VCV0,CV0 +620,7,0,0,(521,A8),1,FVC0,FRC0 +800,9,0,2,(521,A8),0,FVC0,FRC0,MOT(1,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),NA5 0 /------------ -[section_act] -40,1,TGV,COM5,CM5 -A91,1,X,F1,100,MONTRAIN -815,1,CC406526,F2,200,TGV -Mem[527,520],1,X,"KLAXON_2.WAV" -821,1,BB16024,"KLAXON_3.WAV" -818,1,TGV,A10,1,S -A12,2,X,"KLAXON_3.WAV" +[section_PN] +(516-513,515-516),PN(2,ferme,ouvre,0),1,1 +0 /------------ -(817,830),(820,840),PN(12,2,12,1),1 -(527-519,519-517),(530-531,531-532),(123-456,789-123),(654-654,854-124),(659-154,555-888),PN(122,0,122,1),0 +[section_actions] +Action 3,D4,800,1,traindecl,B1,C5,12,12,13,45,N3,A10,1,30,traindest,A2,1,A8,1 +Action 5,D1,12,30,B1,C3,162,30,tagadah,N1,A4,1,15,2,Z +klaxon_temporisé,D8,330,0,B1,C6,330,CC406526,N2,A14,1,50,A12,1,4,300,CC406526 0 /------------ [section_dcc++] @@ -176,19 +247,34 @@ AdrBaseDetDccpp=513 0 /------------ [section_trains] -TrainElectrique,11,110,40,30 -BB25531,1,120,50,40 -TGV,2,120,50,30 -BB16024,3,120,60,50 -CC406526,4,120,50,30 -CAMERA,0,120,0,0 +BB25531,1,120,60,50,BB67000.BMP,5,0 +TGV,2,120,80,60,TGV.BMP,6,0 +BB16024,3,120,100,60,BB16024.BMP,7,0 +CC406526,4,120,60,40,CC406526.BMP,10,0 +CAMERA,6,120,0,0,EAD.BMP,8,0 0 /------------ [section_placement] -TRAINELECTRIQUE,0,0,0 BB25531,0,0,0 -TGV,0,0,0 -BB16024,523,526,0 -CC406526,0,0,0 +TGV,7,1,0 +BB16024,0,0,0 +CC406526,9,2,0 CAMERA,0,0,0 0 +/------------ +[section_accCOMUSB] +Socket,0,0,0,0,0,0,0,192.1.2.250:150 +Nouveau ,0,0,0,1,1,0,0,COM15:9600,N,8,1 +0 +/------------ +[section horloge] +HorlogeInterne=1 +LanceHorl=0 +AffHorl=0 +relanceHorl_init=0 +HeureInit=10 +MinuteInit=3 +RetourHeure=10 +RetourMinute=7 +DureeMinute=1 +0 diff --git a/Notice d'utilisation des signaux_complexes_GL_V8.7.pdf b/Notice d'utilisation des signaux_complexes_GL_V8.8.pdf similarity index 77% rename from Notice d'utilisation des signaux_complexes_GL_V8.7.pdf rename to Notice d'utilisation des signaux_complexes_GL_V8.8.pdf index 0ebdbf6..9d06c66 100644 Binary files a/Notice d'utilisation des signaux_complexes_GL_V8.7.pdf and b/Notice d'utilisation des signaux_complexes_GL_V8.8.pdf differ diff --git a/Signaux_complexes_GL.cfg b/Signaux_complexes_GL.cfg index bcc5ab2..326b5d5 100644 --- a/Signaux_complexes_GL.cfg +++ b/Signaux_complexes_GL.cfg @@ -13,9 +13,9 @@ -$M- -$N+ -$O- --$P+ --$Q+ --$R+ +-$P- +-$Q- +-$R- -$S- -$T- -$U- diff --git a/Signaux_complexes_GL.dof b/Signaux_complexes_GL.dof index da70fe3..96f1ba5 100644 --- a/Signaux_complexes_GL.dof +++ b/Signaux_complexes_GL.dof @@ -16,9 +16,9 @@ L=1 M=0 N=1 O=0 -P=1 -Q=1 -R=1 +P=0 +Q=0 +R=0 S=0 T=0 U=0 diff --git a/Signaux_complexes_GL.dpr b/Signaux_complexes_GL.dpr index 6009071..a480465 100644 --- a/Signaux_complexes_GL.dpr +++ b/Signaux_complexes_GL.dpr @@ -14,7 +14,7 @@ uses Unit_Pilote_aig in 'Unit_Pilote_aig.pas' {FormAig}, UnitConfigCellTCO in 'UnitConfigCellTCO.pas' {FormConfCellTCO}, UnitCDF in 'UnitCDF.pas' {FormCDF}, - Unitplace in 'Unitplace.pas' {FormPlace}, + Unitplace in 'Unitplace.pas' {FormRoulage}, UnitPareFeu in 'UnitPareFeu.pas', UnitAnalyseSegCDM in 'UnitAnalyseSegCDM.pas' {FormAnalyseCDM}, Importation in 'Importation.pas' {FormImportation}, @@ -22,7 +22,8 @@ uses UnitHorloge in 'UnitHorloge.pas' {FormHorloge}, UnitFicheHoraire in 'UnitFicheHoraire.pas' {FormFicheHoraire}, UnitClock in 'UnitClock.pas' {FormClock}, - UnitModifAction in 'UnitModifAction.pas' {FormModifAction}; + UnitModifAction in 'UnitModifAction.pas' {FormModifAction}, + selection_train in 'selection_train.pas' {FormSelTrain}; {$R *.res} @@ -40,7 +41,7 @@ begin Application.CreateForm(TFormAig, FormAig); Application.CreateForm(TFormConfCellTCO, FormConfCellTCO); Application.CreateForm(TFormCDF, FormCDF); - Application.CreateForm(TFormPlace, FormPlace); + Application.CreateForm(TFormRoulage, FormRoulage); Application.CreateForm(TFormAnalyseCDM, FormAnalyseCDM); Application.CreateForm(TFormImportation, FormImportation); Application.CreateForm(TFormFicheHoraire, FormFicheHoraire); @@ -48,6 +49,7 @@ begin Application.CreateForm(TFormClock, FormClock); Application.CreateForm(TFormHorloge, FormHorloge); Application.CreateForm(TFormModifAction, FormModifAction); + Application.CreateForm(TFormSelTrain, FormSelTrain); fin_preliminaire; Application.Run; end. diff --git a/Signaux_complexes_GL.map b/Signaux_complexes_GL.map index f8f1dea..883f76c 100644 --- a/Signaux_complexes_GL.map +++ b/Signaux_complexes_GL.map @@ -1,8 +1,8 @@ Start Length Name Class - 0001:00000000 001C19ACH .text CODE - 0002:00000000 00002D30H .data DATA - 0002:00002D30 045EEF79H .bss BSS + 0001:00000000 001D1334H .text CODE + 0002:00000000 00002D60H .data DATA + 0002:00002D60 04660941H .bss BSS Detailed map of segments @@ -10,101 +10,102 @@ Detailed map of segments 0001:00000000 00005F3F C=CODE S=.text G=(none) M=System ACBP=A9 0001:00005F40 00000140 C=CODE S=.text G=(none) M=SysInit ACBP=A9 0001:00006080 00000108 C=CODE S=.text G=(none) M=Types ACBP=A9 - 0001:00006188 00000F20 C=CODE S=.text G=(none) M=Windows ACBP=A9 - 0001:000070A8 00000038 C=CODE S=.text G=(none) M=Messages ACBP=A9 - 0001:000070E0 00000338 C=CODE S=.text G=(none) M=SysConst ACBP=A9 - 0001:00007418 00006F74 C=CODE S=.text G=(none) M=SysUtils ACBP=A9 - 0001:0000E38C 0000081B C=CODE S=.text G=(none) M=VarUtils ACBP=A9 - 0001:0000EBA8 0000804E C=CODE S=.text G=(none) M=Variants ACBP=A9 - 0001:00016BF8 000001A0 C=CODE S=.text G=(none) M=RTLConsts ACBP=A9 - 0001:00016D98 0000083C C=CODE S=.text G=(none) M=TypInfo ACBP=A9 - 0001:000175D4 00000358 C=CODE S=.text G=(none) M=ActiveX ACBP=A9 - 0001:0001792C 0000A7FE C=CODE S=.text G=(none) M=Classes ACBP=A9 - 0001:0002212C 00000370 C=CODE S=.text G=(none) M=Consts ACBP=A9 - 0001:0002249C 00009BFB C=CODE S=.text G=(none) M=Graphics ACBP=A9 - 0001:0002C098 00000124 C=CODE S=.text G=(none) M=Math ACBP=A9 - 0001:0002C1BC 000002B8 C=CODE S=.text G=(none) M=Contnrs ACBP=A9 - 0001:0002C474 00000198 C=CODE S=.text G=(none) M=CommCtrl ACBP=A9 - 0001:0002C60C 00000787 C=CODE S=.text G=(none) M=MultiMon ACBP=A9 - 0001:0002CD94 00000038 C=CODE S=.text G=(none) M=Imm ACBP=A9 - 0001:0002CDCC 00000FF8 C=CODE S=.text G=(none) M=HelpIntfs ACBP=A9 - 0001:0002DDC4 00000058 C=CODE S=.text G=(none) M=WinSpool ACBP=A9 - 0001:0002DE1C 000010C8 C=CODE S=.text G=(none) M=Printers ACBP=A9 - 0001:0002EEE4 0000031F C=CODE S=.text G=(none) M=FlatSB ACBP=A9 - 0001:0002F204 000003F0 C=CODE S=.text G=(none) M=SyncObjs ACBP=A9 - 0001:0002F5F4 000009BB C=CODE S=.text G=(none) M=UxTheme ACBP=A9 - 0001:0002FFB0 00000038 C=CODE S=.text G=(none) M=RichEdit ACBP=A9 - 0001:0002FFE8 00000038 C=CODE S=.text G=(none) M=ToolWin ACBP=A9 - 0001:00030020 00000040 C=CODE S=.text G=(none) M=ShellAPI ACBP=A9 - 0001:00030060 00000038 C=CODE S=.text G=(none) M=RegStr ACBP=A9 - 0001:00030098 00000058 C=CODE S=.text G=(none) M=WinInet ACBP=A9 - 0001:000300F0 00000038 C=CODE S=.text G=(none) M=UrlMon ACBP=A9 - 0001:00030128 0000006C C=CODE S=.text G=(none) M=ShlObj ACBP=A9 - 0001:00030194 00000060 C=CODE S=.text G=(none) M=CommDlg ACBP=A9 - 0001:000301F4 00000038 C=CODE S=.text G=(none) M=Dlgs ACBP=A9 - 0001:0003022C 000036D1 C=CODE S=.text G=(none) M=Dialogs ACBP=A9 - 0001:00033900 0000602A C=CODE S=.text G=(none) M=ExtCtrls ACBP=A9 - 0001:0003992C 00000090 C=CODE S=.text G=(none) M=ComStrs ACBP=A9 - 0001:000399BC 000007A0 C=CODE S=.text G=(none) M=Clipbrd ACBP=A9 - 0001:0003A15C 00000128 C=CODE S=.text G=(none) M=StrUtils ACBP=A9 - 0001:0003A284 00003821 C=CODE S=.text G=(none) M=Buttons ACBP=A9 - 0001:0003DAA8 00000038 C=CODE S=.text G=(none) M=ExtDlgs ACBP=A9 - 0001:0003DAE0 00000068 C=CODE S=.text G=(none) M=IniFiles ACBP=A9 - 0001:0003DB48 00000068 C=CODE S=.text G=(none) M=Registry ACBP=A9 - 0001:0003DBB0 0000006C C=CODE S=.text G=(none) M=Mapi ACBP=A9 - 0001:0003DC1C 00000058 C=CODE S=.text G=(none) M=ExtActns ACBP=A9 - 0001:0003DC74 00000038 C=CODE S=.text G=(none) M=ListActns ACBP=A9 - 0001:0003DCAC 00009948 C=CODE S=.text G=(none) M=ComCtrls ACBP=A9 - 0001:000475F4 00000EA0 C=CODE S=.text G=(none) M=Themes ACBP=A9 - 0001:00048494 0000C698 C=CODE S=.text G=(none) M=StdCtrls ACBP=A9 - 0001:00054B2C 00000168 C=CODE S=.text G=(none) M=StdActns ACBP=A9 - 0001:00054C94 00000D1F C=CODE S=.text G=(none) M=WinHelpViewer ACBP=A9 - 0001:000559B4 00011403 C=CODE S=.text G=(none) M=Controls ACBP=A9 - 0001:00066DB8 00001292 C=CODE S=.text G=(none) M=ActnList ACBP=A9 - 0001:0006804C 00001C04 C=CODE S=.text G=(none) M=ImgList ACBP=A9 - 0001:00069C50 000066E1 C=CODE S=.text G=(none) M=Menus ACBP=A9 - 0001:00070334 0000CF8C C=CODE S=.text G=(none) M=Forms ACBP=A9 - 0001:0007D2C0 00000050 C=CODE S=.text G=(none) M=JConsts ACBP=A9 - 0001:0007D310 000133EC C=CODE S=.text G=(none) M=jpeg ACBP=A9 - 0001:000906FC 00000060 C=CODE S=.text G=(none) M=ComConst ACBP=A9 - 0001:0009075C 00001259 C=CODE S=.text G=(none) M=ComObj ACBP=A9 - 0001:000919B8 00000038 C=CODE S=.text G=(none) M=StdVCL ACBP=A9 - 0001:000919F0 00001793 C=CODE S=.text G=(none) M=AxCtrls ACBP=A9 - 0001:00093184 00000060 C=CODE S=.text G=(none) M=OleConst ACBP=A9 - 0001:000931E4 00003519 C=CODE S=.text G=(none) M=OleCtrls ACBP=A9 - 0001:00096700 00000314 C=CODE S=.text G=(none) M=TlHelp32 ACBP=A9 - 0001:00096A14 00000128 C=CODE S=.text G=(none) M=WinSock ACBP=A9 - 0001:00096B3C 00003A78 C=CODE S=.text G=(none) M=ScktComp ACBP=A9 - 0001:0009A5B4 000008EA C=CODE S=.text G=(none) M=OleServer ACBP=A9 - 0001:0009AEA0 000005A0 C=CODE S=.text G=(none) M=MSCommLib_TLB ACBP=A9 - 0001:0009B440 00000040 C=CODE S=.text G=(none) M=MMSystem ACBP=A9 - 0001:0009B480 00000038 C=CODE S=.text G=(none) M=Nb30 ACBP=A9 - 0001:0009B4B8 00000038 C=CODE S=.text G=(none) M=DateUtils ACBP=A9 - 0001:0009B4F0 00000A18 C=CODE S=.text G=(none) M=MaskUtils ACBP=A9 - 0001:0009BF08 00002108 C=CODE S=.text G=(none) M=Mask ACBP=A9 - 0001:0009E010 000092A4 C=CODE S=.text G=(none) M=Grids ACBP=A9 - 0001:000A72B4 00001BFC C=CODE S=.text G=(none) M=Spin ACBP=A9 - 0001:000A8EB0 00001988 C=CODE S=.text G=(none) M=UnitPilote ACBP=A9 - 0001:000AA838 0000057C C=CODE S=.text G=(none) M=Importation ACBP=A9 - 0001:000AADB4 00019484 C=CODE S=.text G=(none) M=UnitAnalyseSegCDM ACBP=A9 - 0001:000C4238 00002E3F C=CODE S=.text G=(none) M=UnitConfigTCO ACBP=A9 - 0001:000C7078 00000D78 C=CODE S=.text G=(none) M=Unit_Pilote_aig ACBP=A9 - 0001:000C7DF0 000054E8 C=CODE S=.text G=(none) M=UnitConfigCellTCO ACBP=A9 - 0001:000CD2D8 000011D0 C=CODE S=.text G=(none) M=UnitFicheHoraire ACBP=A9 - 0001:000CE4A8 000017D4 C=CODE S=.text G=(none) M=UnitClock ACBP=A9 - 0001:000CFC7C 000471B0 C=CODE S=.text G=(none) M=UnitTCO ACBP=A9 - 0001:00116E2C 000039DC C=CODE S=.text G=(none) M=UnitSR ACBP=A9 - 0001:0011A808 00002BF8 C=CODE S=.text G=(none) M=UnitCDF ACBP=A9 - 0001:0011D400 00005DC8 C=CODE S=.text G=(none) M=UnitModifAction ACBP=A9 - 0001:001231C8 00046AD8 C=CODE S=.text G=(none) M=UnitConfig ACBP=A9 - 0001:00169CA0 00000E78 C=CODE S=.text G=(none) M=UnitHorloge ACBP=A9 - 0001:0016AB18 000024FF C=CODE S=.text G=(none) M=verif_version ACBP=A9 - 0001:0016D018 000011D0 C=CODE S=.text G=(none) M=UnitPareFeu ACBP=A9 - 0001:0016E1E8 00000F6C C=CODE S=.text G=(none) M=UnitSimule ACBP=A9 - 0001:0016F154 00002E60 C=CODE S=.text G=(none) M=Unitplace ACBP=A9 - 0001:00171FB4 0004C52C C=CODE S=.text G=(none) M=UnitPrinc ACBP=A9 - 0001:001BE4E0 00002F78 C=CODE S=.text G=(none) M=UnitDebug ACBP=A9 - 0001:001C1458 00000554 C=CODE S=.text G=(none) M=Signaux_complexes_GL ACBP=A9 + 0001:00006188 00000F28 C=CODE S=.text G=(none) M=Windows ACBP=A9 + 0001:000070B0 00000038 C=CODE S=.text G=(none) M=Messages ACBP=A9 + 0001:000070E8 00000338 C=CODE S=.text G=(none) M=SysConst ACBP=A9 + 0001:00007420 00006F90 C=CODE S=.text G=(none) M=SysUtils ACBP=A9 + 0001:0000E3B0 0000081B C=CODE S=.text G=(none) M=VarUtils ACBP=A9 + 0001:0000EBCC 0000804E C=CODE S=.text G=(none) M=Variants ACBP=A9 + 0001:00016C1C 000001A0 C=CODE S=.text G=(none) M=RTLConsts ACBP=A9 + 0001:00016DBC 0000083C C=CODE S=.text G=(none) M=TypInfo ACBP=A9 + 0001:000175F8 00000358 C=CODE S=.text G=(none) M=ActiveX ACBP=A9 + 0001:00017950 0000A7FE C=CODE S=.text G=(none) M=Classes ACBP=A9 + 0001:00022150 00000378 C=CODE S=.text G=(none) M=Consts ACBP=A9 + 0001:000224C8 00009DC7 C=CODE S=.text G=(none) M=Graphics ACBP=A9 + 0001:0002C290 00000124 C=CODE S=.text G=(none) M=Math ACBP=A9 + 0001:0002C3B4 000002B8 C=CODE S=.text G=(none) M=Contnrs ACBP=A9 + 0001:0002C66C 00000198 C=CODE S=.text G=(none) M=CommCtrl ACBP=A9 + 0001:0002C804 00000787 C=CODE S=.text G=(none) M=MultiMon ACBP=A9 + 0001:0002CF8C 00000038 C=CODE S=.text G=(none) M=Imm ACBP=A9 + 0001:0002CFC4 00000FF8 C=CODE S=.text G=(none) M=HelpIntfs ACBP=A9 + 0001:0002DFBC 00000058 C=CODE S=.text G=(none) M=WinSpool ACBP=A9 + 0001:0002E014 000010C8 C=CODE S=.text G=(none) M=Printers ACBP=A9 + 0001:0002F0DC 0000031F C=CODE S=.text G=(none) M=FlatSB ACBP=A9 + 0001:0002F3FC 000003F0 C=CODE S=.text G=(none) M=SyncObjs ACBP=A9 + 0001:0002F7EC 000009BB C=CODE S=.text G=(none) M=UxTheme ACBP=A9 + 0001:000301A8 00000038 C=CODE S=.text G=(none) M=RichEdit ACBP=A9 + 0001:000301E0 00000038 C=CODE S=.text G=(none) M=ToolWin ACBP=A9 + 0001:00030218 00000040 C=CODE S=.text G=(none) M=ShellAPI ACBP=A9 + 0001:00030258 00000038 C=CODE S=.text G=(none) M=RegStr ACBP=A9 + 0001:00030290 00000058 C=CODE S=.text G=(none) M=WinInet ACBP=A9 + 0001:000302E8 00000038 C=CODE S=.text G=(none) M=UrlMon ACBP=A9 + 0001:00030320 0000006C C=CODE S=.text G=(none) M=ShlObj ACBP=A9 + 0001:0003038C 00000060 C=CODE S=.text G=(none) M=CommDlg ACBP=A9 + 0001:000303EC 00000038 C=CODE S=.text G=(none) M=Dlgs ACBP=A9 + 0001:00030424 000036D1 C=CODE S=.text G=(none) M=Dialogs ACBP=A9 + 0001:00033AF8 0000602A C=CODE S=.text G=(none) M=ExtCtrls ACBP=A9 + 0001:00039B24 00000090 C=CODE S=.text G=(none) M=ComStrs ACBP=A9 + 0001:00039BB4 000007A0 C=CODE S=.text G=(none) M=Clipbrd ACBP=A9 + 0001:0003A354 00000128 C=CODE S=.text G=(none) M=StrUtils ACBP=A9 + 0001:0003A47C 00003821 C=CODE S=.text G=(none) M=Buttons ACBP=A9 + 0001:0003DCA0 00000038 C=CODE S=.text G=(none) M=ExtDlgs ACBP=A9 + 0001:0003DCD8 00000068 C=CODE S=.text G=(none) M=IniFiles ACBP=A9 + 0001:0003DD40 00000068 C=CODE S=.text G=(none) M=Registry ACBP=A9 + 0001:0003DDA8 0000006C C=CODE S=.text G=(none) M=Mapi ACBP=A9 + 0001:0003DE14 00000058 C=CODE S=.text G=(none) M=ExtActns ACBP=A9 + 0001:0003DE6C 00000038 C=CODE S=.text G=(none) M=ListActns ACBP=A9 + 0001:0003DEA4 00009948 C=CODE S=.text G=(none) M=ComCtrls ACBP=A9 + 0001:000477EC 00000EA0 C=CODE S=.text G=(none) M=Themes ACBP=A9 + 0001:0004868C 0000C698 C=CODE S=.text G=(none) M=StdCtrls ACBP=A9 + 0001:00054D24 00000168 C=CODE S=.text G=(none) M=StdActns ACBP=A9 + 0001:00054E8C 00000D1F C=CODE S=.text G=(none) M=WinHelpViewer ACBP=A9 + 0001:00055BAC 00011403 C=CODE S=.text G=(none) M=Controls ACBP=A9 + 0001:00066FB0 00001292 C=CODE S=.text G=(none) M=ActnList ACBP=A9 + 0001:00068244 00001C04 C=CODE S=.text G=(none) M=ImgList ACBP=A9 + 0001:00069E48 000066E1 C=CODE S=.text G=(none) M=Menus ACBP=A9 + 0001:0007052C 0000CF8C C=CODE S=.text G=(none) M=Forms ACBP=A9 + 0001:0007D4B8 00000050 C=CODE S=.text G=(none) M=JConsts ACBP=A9 + 0001:0007D508 000133EC C=CODE S=.text G=(none) M=jpeg ACBP=A9 + 0001:000908F4 00000060 C=CODE S=.text G=(none) M=ComConst ACBP=A9 + 0001:00090954 00001259 C=CODE S=.text G=(none) M=ComObj ACBP=A9 + 0001:00091BB0 00000038 C=CODE S=.text G=(none) M=StdVCL ACBP=A9 + 0001:00091BE8 00001793 C=CODE S=.text G=(none) M=AxCtrls ACBP=A9 + 0001:0009337C 00000060 C=CODE S=.text G=(none) M=OleConst ACBP=A9 + 0001:000933DC 00003519 C=CODE S=.text G=(none) M=OleCtrls ACBP=A9 + 0001:000968F8 00000314 C=CODE S=.text G=(none) M=TlHelp32 ACBP=A9 + 0001:00096C0C 00000128 C=CODE S=.text G=(none) M=WinSock ACBP=A9 + 0001:00096D34 00003A78 C=CODE S=.text G=(none) M=ScktComp ACBP=A9 + 0001:0009A7AC 000008EA C=CODE S=.text G=(none) M=OleServer ACBP=A9 + 0001:0009B098 000005A0 C=CODE S=.text G=(none) M=MSCommLib_TLB ACBP=A9 + 0001:0009B638 00000040 C=CODE S=.text G=(none) M=MMSystem ACBP=A9 + 0001:0009B678 00000038 C=CODE S=.text G=(none) M=Nb30 ACBP=A9 + 0001:0009B6B0 00000038 C=CODE S=.text G=(none) M=DateUtils ACBP=A9 + 0001:0009B6E8 00000A18 C=CODE S=.text G=(none) M=MaskUtils ACBP=A9 + 0001:0009C100 00002108 C=CODE S=.text G=(none) M=Mask ACBP=A9 + 0001:0009E208 000092A4 C=CODE S=.text G=(none) M=Grids ACBP=A9 + 0001:000A74AC 00001BFC C=CODE S=.text G=(none) M=Spin ACBP=A9 + 0001:000A90A8 000018C4 C=CODE S=.text G=(none) M=UnitPilote ACBP=A9 + 0001:000AA96C 0000057C C=CODE S=.text G=(none) M=Importation ACBP=A9 + 0001:000AAEE8 00019624 C=CODE S=.text G=(none) M=UnitAnalyseSegCDM ACBP=A9 + 0001:000C450C 00002E3F C=CODE S=.text G=(none) M=UnitConfigTCO ACBP=A9 + 0001:000C734C 00000D78 C=CODE S=.text G=(none) M=Unit_Pilote_aig ACBP=A9 + 0001:000C80C4 0000579C C=CODE S=.text G=(none) M=UnitConfigCellTCO ACBP=A9 + 0001:000CD860 000011E4 C=CODE S=.text G=(none) M=UnitFicheHoraire ACBP=A9 + 0001:000CEA44 000017D4 C=CODE S=.text G=(none) M=UnitClock ACBP=A9 + 0001:000D0218 00000C50 C=CODE S=.text G=(none) M=Unitplace ACBP=A9 + 0001:000D0E68 000038FC C=CODE S=.text G=(none) M=selection_train ACBP=A9 + 0001:000D4764 0004DEFC C=CODE S=.text G=(none) M=UnitTCO ACBP=A9 + 0001:00122660 00003958 C=CODE S=.text G=(none) M=UnitSR ACBP=A9 + 0001:00125FB8 00002B98 C=CODE S=.text G=(none) M=UnitCDF ACBP=A9 + 0001:00128B50 00008714 C=CODE S=.text G=(none) M=UnitModifAction ACBP=A9 + 0001:00131264 00000EE0 C=CODE S=.text G=(none) M=UnitHorloge ACBP=A9 + 0001:00132144 00002503 C=CODE S=.text G=(none) M=verif_version ACBP=A9 + 0001:00134648 000011D0 C=CODE S=.text G=(none) M=UnitPareFeu ACBP=A9 + 0001:00135818 00000F6C C=CODE S=.text G=(none) M=UnitSimule ACBP=A9 + 0001:00136784 0004E920 C=CODE S=.text G=(none) M=UnitPrinc ACBP=A9 + 0001:001850A4 00048DA4 C=CODE S=.text G=(none) M=UnitConfig ACBP=A9 + 0001:001CDE48 00002F78 C=CODE S=.text G=(none) M=UnitDebug ACBP=A9 + 0001:001D0DC0 00000574 C=CODE S=.text G=(none) M=Signaux_complexes_GL ACBP=A9 0002:00000000 000000CC C=DATA S=.data G=DGROUP M=System ACBP=A9 0002:000000CC 00000020 C=DATA S=.data G=DGROUP M=SysInit ACBP=A9 0002:000000EC 00000254 C=DATA S=.data G=DGROUP M=SysUtils ACBP=A9 @@ -135,8 +136,8 @@ Detailed map of segments 0002:00001C34 00000009 C=DATA S=.data G=DGROUP M=MaskUtils ACBP=A9 0002:00001C40 00000004 C=DATA S=.data G=DGROUP M=Mask ACBP=A9 0002:00001C44 00000006 C=DATA S=.data G=DGROUP M=Grids ACBP=A9 - 0002:00001C4C 000000D4 C=DATA S=.data G=DGROUP M=UnitTCO ACBP=A9 - 0002:00001D20 0000060D C=DATA S=.data G=DGROUP M=UnitPrinc ACBP=A9 + 0002:00001C4C 000000D8 C=DATA S=.data G=DGROUP M=UnitTCO ACBP=A9 + 0002:00001D24 0000060D C=DATA S=.data G=DGROUP M=UnitPrinc ACBP=A9 0002:00003000 00000664 C=BSS S=.bss G=DGROUP M=System ACBP=A9 0002:00003664 00000010 C=BSS S=.bss G=DGROUP M=SysInit ACBP=A9 0002:00003674 00000004 C=BSS S=.bss G=DGROUP M=Types ACBP=A9 @@ -220,20 +221,21 @@ Detailed map of segments 0002:0001873C 00000014 C=BSS S=.bss G=DGROUP M=UnitConfigTCO ACBP=A9 0002:00018750 00000014 C=BSS S=.bss G=DGROUP M=Unit_Pilote_aig ACBP=A9 0002:00018764 00000020 C=BSS S=.bss G=DGROUP M=UnitConfigCellTCO ACBP=A9 - 0002:00018784 00001908 C=BSS S=.bss G=DGROUP M=UnitFicheHoraire ACBP=A9 - 0002:0001A08C 00000034 C=BSS S=.bss G=DGROUP M=UnitClock ACBP=A9 - 0002:0001A0C0 0041870C C=BSS S=.bss G=DGROUP M=UnitTCO ACBP=A9 - 0002:004327CC 00000010 C=BSS S=.bss G=DGROUP M=UnitSR ACBP=A9 - 0002:004327DC 00000014 C=BSS S=.bss G=DGROUP M=UnitCDF ACBP=A9 - 0002:004327F0 00000018 C=BSS S=.bss G=DGROUP M=UnitModifAction ACBP=A9 - 0002:00432808 0000057C C=BSS S=.bss G=DGROUP M=UnitConfig ACBP=A9 - 0002:00432D84 00000038 C=BSS S=.bss G=DGROUP M=UnitHorloge ACBP=A9 - 0002:00432DBC 000001EC C=BSS S=.bss G=DGROUP M=verif_version ACBP=A9 - 0002:00432FA8 00000004 C=BSS S=.bss G=DGROUP M=UnitPareFeu ACBP=A9 - 0002:00432FAC 0000000C C=BSS S=.bss G=DGROUP M=UnitSimule ACBP=A9 - 0002:00432FB8 00000008 C=BSS S=.bss G=DGROUP M=Unitplace ACBP=A9 - 0002:00432FC0 041BEF8C C=BSS S=.bss G=DGROUP M=UnitPrinc ACBP=A9 - 0002:045F1F4C 0000002C C=BSS S=.bss G=DGROUP M=UnitDebug ACBP=A9 + 0002:00018784 0000190C C=BSS S=.bss G=DGROUP M=UnitFicheHoraire ACBP=A9 + 0002:0001A090 00000034 C=BSS S=.bss G=DGROUP M=UnitClock ACBP=A9 + 0002:0001A0C4 00000008 C=BSS S=.bss G=DGROUP M=Unitplace ACBP=A9 + 0002:0001A0CC 00000020 C=BSS S=.bss G=DGROUP M=selection_train ACBP=A9 + 0002:0001A0EC 00489740 C=BSS S=.bss G=DGROUP M=UnitTCO ACBP=A9 + 0002:004A382C 00000010 C=BSS S=.bss G=DGROUP M=UnitSR ACBP=A9 + 0002:004A383C 00000014 C=BSS S=.bss G=DGROUP M=UnitCDF ACBP=A9 + 0002:004A3850 0000001C C=BSS S=.bss G=DGROUP M=UnitModifAction ACBP=A9 + 0002:004A386C 00000038 C=BSS S=.bss G=DGROUP M=UnitHorloge ACBP=A9 + 0002:004A38A4 000001EC C=BSS S=.bss G=DGROUP M=verif_version ACBP=A9 + 0002:004A3A90 00000004 C=BSS S=.bss G=DGROUP M=UnitPareFeu ACBP=A9 + 0002:004A3A94 0000000C C=BSS S=.bss G=DGROUP M=UnitSimule ACBP=A9 + 0002:004A3AA0 041BF8E8 C=BSS S=.bss G=DGROUP M=UnitPrinc ACBP=A9 + 0002:04663388 0000058C C=BSS S=.bss G=DGROUP M=UnitConfig ACBP=A9 + 0002:04663914 0000002C C=BSS S=.bss G=DGROUP M=UnitDebug ACBP=A9 Bound resource files @@ -249,19 +251,20 @@ Unit_Pilote_aig.dfm UnitConfigCellTCO.dfm UnitFicheHoraire.dfm UnitClock.dfm +Unitplace.dfm +selection_train.dfm UnitTCO.dfm UnitSR.dfm UnitCDF.dfm UnitModifAction.dfm -UnitConfig.dfm UnitHorloge.dfm verif_version.dfm UnitSimule.dfm -Unitplace.dfm UnitPrinc.dfm +UnitConfig.dfm UnitDebug.dfm Signaux_complexes_GL.res Signaux_complexes_GL.drf -Program entry point at 0001:001C1798 +Program entry point at 0001:001D1108 diff --git a/UnitAnalyseSegCDM.dfm b/UnitAnalyseSegCDM.dfm index 77aabbf..809d616 100644 --- a/UnitAnalyseSegCDM.dfm +++ b/UnitAnalyseSegCDM.dfm @@ -1,9 +1,9 @@ object FormAnalyseCDM: TFormAnalyseCDM - Left = 198 - Top = 41 + Left = 193 + Top = 60 AutoScroll = False Caption = 'Fen'#234'tre r'#233'seau CDM' - ClientHeight = 648 + ClientHeight = 596 ClientWidth = 1041 Color = clBtnFace Font.Charset = DEFAULT_CHARSET @@ -18,7 +18,7 @@ object FormAnalyseCDM: TFormAnalyseCDM OnResize = FormResize DesignSize = ( 1041 - 648) + 596) PixelsPerInch = 96 TextHeight = 13 object Label4: TLabel @@ -60,7 +60,7 @@ object FormAnalyseCDM: TFormAnalyseCDM Left = 8 Top = 16 Width = 986 - Height = 509 + Height = 457 HorzScrollBar.Tracking = True Anchors = [akLeft, akTop, akRight, akBottom] AutoScroll = False @@ -80,7 +80,7 @@ object FormAnalyseCDM: TFormAnalyseCDM end object GroupBox1: TGroupBox Left = 8 - Top = 536 + Top = 484 Width = 385 Height = 109 Anchors = [akLeft, akBottom] @@ -224,7 +224,7 @@ object FormAnalyseCDM: TFormAnalyseCDM end object GroupBoxSegment: TGroupBox Left = 400 - Top = 536 + Top = 484 Width = 145 Height = 109 Anchors = [akLeft, akBottom] @@ -274,7 +274,7 @@ object FormAnalyseCDM: TFormAnalyseCDM end object Memo1: TMemo Left = 552 - Top = 544 + Top = 492 Width = 105 Height = 93 Anchors = [akLeft, akBottom] @@ -288,7 +288,7 @@ object FormAnalyseCDM: TFormAnalyseCDM end object ButtonAnime: TButton Left = 752 - Top = 548 + Top = 496 Width = 75 Height = 25 Anchors = [akLeft, akBottom] diff --git a/UnitAnalyseSegCDM.pas b/UnitAnalyseSegCDM.pas index e956774..a86b088 100644 --- a/UnitAnalyseSegCDM.pas +++ b/UnitAnalyseSegCDM.pas @@ -71,6 +71,7 @@ type procedure ImageCDMMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure ButtonAnimeClick(Sender: TObject); + procedure Button1Click(Sender: TObject); private { Déclarations privées } public @@ -1079,19 +1080,19 @@ end; // dessine un arc orienté de xa,ya à xb,yb dans le canvas image (pas imprimante) // coordonnées CDM procedure arc_xy_CDM(canvas : tcanvas;centreX,centreY,rayon,xa,ya,xb,yb : integer); -var x1,y1,x2,y2: integer ; +var x1,y1,x2,y2 : integer ; arcXa,arcYa,arcxb,arcYb,angleA,angleB, - cosA,SinA,CosB,SinB,vectoriel,AngleAB: double; + cosA,SinA,CosB,SinB: double; inverse,maxA,maxB,deb : boolean; begin deb:=false; if rayon=0 then exit; - if deb then Affiche('Xa='+intToSTr(xa)+' Ya='+intToSTr(ya)+' Xb='+intToSTr(xb)+' Yb='+intToSTr(yb),clyellow); coords(centreX,centreY); coords(xa,ya); coords(xb,yb); - rayon:=round(rayon*reducX) div 1000; + if deb then Affiche('Xa='+intToSTr(xa)+' Ya='+intToSTr(ya)+' Xb='+intToSTr(xb)+' Yb='+intToSTr(yb),clyellow); + rayon:=round(rayon*reducX) div 1000; X1:=centreX - rayon; Y1:=centreY - rayon; @@ -1121,8 +1122,22 @@ begin if SinB<-1 then SinB:=-1; arcYb:=arcsin(SinB)*_180surpi; - // quadrant des angles + if deb then + begin + affiche('arcXA='+FloatToSTR(ArcXA)+' arcYA='+FloatToSTR(ArcYA)+' arcXB='+FloatToSTR(ArcXB)+' arcYB='+FloatToSTR(ArcYB),clLime); + with canvas do + begin + pen.Width:=1; + Textout(xa+10,ya+10,'A'); + Textout(xb+10,yb+10,'B'); + MoveTo(xa,ya);LineTo(centreX,centreY); + LineTo(xb,yb); + end; + end; + { + + // quadrant des angles quadrantA:=0;QuadrantB:=0; if (cosA>=0) and (sinA>=0) then quadrantA:=1; if (cosA<=0) and (sinA>=0) then quadrantA:=2; @@ -1140,20 +1155,10 @@ begin Affiche('QuadrantB='+intToSTR(QuadrantB),clyellow); end; } - - vectoriel:=((rayon*rayon*cosA*cosB)+(rayon*rayon*sinA*sinB)) / (rayon*rayon); - if vectoriel>1 then vectoriel:=1; - if vectoriel<-1 then vectoriel:=-1; - AngleAB:=arccos(vectoriel)*_180surpi; - if deb then Affiche('ProdVect='+FloatToSTR(vectoriel*_180surpi)+' AngleAB='+FloatToStr(AngleAB),clYellow); - - - //arcXb:=0;arcYb:=0; - // en déduire l'angle A et B - if arcYa<0 then angleA:=180-ArcXa+180 else angleA:=ArcXa; - if arcYb<0 then angleB:=180-ArcXb+180 else angleB:=ArcXb; - if angleA>=360 then angleA:=360-angleA; + if arcYa<0 then angleA:=360-ArcXa else angleA:=ArcXa; + if arcYb<0 then angleB:=360-ArcXb else angleB:=ArcXb; + if angleA>360 then angleA:=360-angleA; if abs(angleA-angleB)>180 then begin @@ -1172,21 +1177,27 @@ begin end; end; - inverse:=angleB>angleA; - //inverse:=AngleAB>0; + //inverse:=AngleAB>0; if deb then begin + if inverse then affiche('Inverse',clOrange) else affiche('Normal',clOrange); + affiche('Angle A='+floatToSTR(angleA)+' Angle B='+floatToSTR(angleB),clOrange); affiche('AngleXa='+intToSTR(round(ArcXa))+' AngleYa='+intToSTR(round(ArcYa)),clred); affiche('AngleXb='+intToSTR(round(ArcXb))+' AngleYb='+intToSTR(round(ArcYb)),clred); + affiche('AngleA='+intToSTR(round(AngleA))+' AngleB='+intToSTR(round(AngleB)),clred); + end; if angleA<>angleB then with Canvas do begin - setArcDirection(Canvas.Handle,AD_COUNTERCLOCKWISE); - if inverse then canvas.Arc(X1,Y1,X2,Y2,xa,ya,xb,yb) - else canvas.Arc(X1,Y1,X2,Y2,xb,yb,xa,ya); + if deb then rectangle(x1,y1,x2,y2); + pen.Width:=largeur_voie; + if inverse then setArcDirection(Canvas.Handle,AD_COUNTERCLOCKWISE) else + setArcDirection(Canvas.Handle,AD_CLOCKWISE); + + Arc(X1,Y1,X2,Y2,xa,ya,xb,yb) end; end; @@ -4672,10 +4683,10 @@ begin index_segment_det(adresse,tabloDetSeg,nombre); circuit_det[1].index:=tabloDetSeg[1].index; - ind1:=tabloDetSeg[1].index; - ind2:=tabloDetSeg[2].index; - per1:=tabloDetSeg[1].periph; - per2:=tabloDetSeg[2].periph; + ind1:=tabloDetSeg[1].index; + ind2:=tabloDetSeg[2].index; + per1:=tabloDetSeg[1].periph; + per2:=tabloDetSeg[2].periph; //Affiche('Trouvé détecteur sur le segment '+inttoSTR(segment[i1].numero),clYellow); @@ -4847,7 +4858,7 @@ begin // déterminer la destination // trouve le port connecté au segment suivant tp:=index_port_connecte(index,circuit_det[2].index,indexPort); - // trouver les coordonnées su x,y sur lequel est connecté le port + // trouver les coordonnées x,y sur lequel est connecté le port xs:=Segment[index].port[IndexPort].x; ys:=Segment[index].port[IndexPort].y; // donc tracer un arc de (x,y) détecteur à (xs,ys) port @@ -5033,6 +5044,11 @@ end; +procedure TFormAnalyseCDM.Button1Click(Sender: TObject); +begin + dessine_det(523); +end; + end. diff --git a/UnitConfig.dfm b/UnitConfig.dfm index 2e71bf1..27c4ac3 100644 --- a/UnitConfig.dfm +++ b/UnitConfig.dfm @@ -1,6 +1,6 @@ object FormConfig: TFormConfig - Left = 220 - Top = 130 + Left = 323 + Top = 128 Hint = 'Modifie la configuration selon les s'#233'lections choisies' BorderStyle = bsDialog Caption = 'Configuration g'#233'n'#233'rale' @@ -651,6 +651,7 @@ object FormConfig: TFormConfig Font.Name = 'Arial Narrow' Font.Style = [fsBold, fsItalic] ParentFont = False + Visible = False end object ButtonAppliquerEtFermer: TButton Left = 240 @@ -2918,7 +2919,12 @@ object FormConfig: TFormConfig Top = 272 Width = 75 Height = 25 + Hint = + 'Modifie l'#39'action : permet d'#39'attribuer un d'#233'clencheur et des op'#233'r' + + 'ations' Caption = 'Modifier' + ParentShowHint = False + ShowHint = True TabOrder = 2 OnClick = ButtonModActionClick end @@ -3135,7 +3141,7 @@ object FormConfig: TFormConfig OnClick = RadioGroupActPNClick end object ComboBoxPNCom: TComboBox - Left = 80 + Left = 88 Top = 128 Width = 145 Height = 21 @@ -3448,147 +3454,11 @@ object FormConfig: TFormConfig Font.Style = [fsBold] ParentFont = False end - object LabelInfVitesse: TLabel - Left = 320 - Top = 248 - Width = 256 - Height = 26 - Caption = - 'Les param'#232'tres de vitesse ne sont utilis'#233's que dans le mode roul' + - 'age' - WordWrap = True - end - object ImageTrain: TImage - Left = 384 - Top = 312 - Width = 153 - Height = 49 - Picture.Data = { - 07544269746D6170D20D0000424DD20D00000000000076000000280000009600 - 00002D00000001000400000000005C0D00000000000000000000100000000000 - 0000000000000000800000800000008080008000000080008000808000008080 - 8000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF - FF00FFFFF70000008FFF80000007FFFFFFFFFFFFFFFFFFFF70000008FFFF0000 - 007FFFFFFFFFFFFF70000008FFFF0000007FFFFFFFFFFFFFFFFFFFF70000008F - FFF0000007FFFFFFFFFFFFFFFF00FFFF7000000008F8000000000FFFFFFFFFFF - FFFFFFF7000000008FF000000000FFFFFFFFFFF7000000008FF000000000FFFF - FFFFFFFFFFFFFF7000000007FF000000000FFFFFFFFFFFFFFF00FFF800000000 - 00F00000000008FFFFFFFFFFFFFFFFF0000000000F00000000008FFFFFFFFFF0 - 000000000F00000000007FFFFFFFFFFFFFFFFF0000000000F70000000007FFFF - FFFFFFFFFF00FFF70000000000800000000000FFFFFFFFFFFFFFFF7000000000 - 0800000000000FFFFFFFFF70000000000800000000000FFFFFFFFFFFFFFFF700 - 00000000800000000000FFFFFFFFFFFFFF00FFF00000000000700000000000FF - FFFFFFFFFFFFFF00000000000700000000000FFFFFFFFF000000000007000000 - 00000FFFFFFFFFFFFFFFF70000000000700000000000FFFFFFFFFFFFFF000000 - 000000000000000000000000000000000000000000000000000000000000000F - FFF0000000000000000000000000000000000000000000000000000000000000 - 0000008FFFFFFFFFFF0000000000000000000000000000000000000000000000 - 00000000000000000000000FFFF0000000000000000000000000000000000000 - 00000000000000000000000000000007FFFFFFFFFF00008FFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00888F008FFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7007FFFFFFF - FF00008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFF000000008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFF7000FFFFFFFF00008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000008FFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80008FFFFFF00008FFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000008FF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - F0007FFFFF00008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFF00FFFF008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFF0007FFFF00008FFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFF008FFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7000FFF00008F - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00F - FFF008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFF80008F0000999999999999999999999999999999999999999999 - 99999999999999999999900FFFF0099999999999999999999999999999999999 - 9999999999999999999999999999999999999900080000999999999999999999 - 99999999999999999999999999999999999999999999900FFFF0099999999999 - 9999999999999999999999999999999999999999999999999999999999999910 - 0000009999999999999999999999999999999999999999999999999999999999 - 9999900FFFF00999999999999999999999999999999999999999999999999999 - 9999999999999999999991007F00007888888888888888888888888888888888 - 8888888888888888888888888888800FFFF00788888888888888888888888888 - 888888888888888888888888888888888888888888881007FF0000FFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFF00FFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFF0007FFF000000000000000000000000000000000000000000000000000000 - 000000000000000FFFF000000000000000000000000000000000000000000000 - 000000000000000000000000000008FFFF000000000000000000000000000000 - 000000000000000000000000000000000000000FFFF000000000000000000000 - 00000000000000000000000000000000000000000000000000008FFFFF000000 - 000000000000000000000000000000000000000000000000000000000000000F - FFF0000000000000000000000000000000000000000000000000000000000000 - 00000000000FFFFFFF000000088FFFFFFF700000088FFFFFFF700000078FFFFF - FF7000000788FFFFFF80000FFFF0000088FFFFFFF700000078FFFFFFF7000000 - 7888FFFFF8000000000000000000000000FFFFFFFF000004F888FFFFFFF70000 - F8888FFFFFF800008F888FFFFFFF00008F888FFFFFFF000FFFF0000F888FFFFF - FF800008F88FFFFFFF800008F88FFFFFFFF0000000000007F8FFF7007FFFFFFF - FF00000888888FFFFFFF000888888FFFFFFF700788888FFFFFFF7007F88888FF - FFFF800FFFF00088888FFFFFFFF7008888888FFFFFF7007888888FFFFFF80000 - 0000000788FF4007FFFFFFFFFF00000F888888FFFFFF700F88888FFFFFFF8008 - 888888FFFFFFF00888888FFFFFFFF00FFFF000F88888FFFFFFF8008888888FFF - FFF800888888FFFFFFFF00000000000788F0007FFFFFFFFFFF00006F88888FFF - FFFF700F88888FFFFFFF800F888888FFFFFFF00888888FFFFFFFF00FFFF000F8 - 8888FFFFFFF8008888888FFFFFFF00888888FFFFFFFF000000000007F80008FF - FFFFFFFFFF00000F888888FFFFFF700888888FFFFFFF7008888888FFFFFF8007 - 888888FFFFFFF00FFFF000F88888FFFFFFF7008888888FFFFFF8008888888FFF - FFFF0000000000078000FFFFFFFFFFFFFF000007F888FFFFFFFF0007F8888FFF - FFFF0004F888FFFFFFFF0000F8888FFFFFFF700FFFF0007F8888FFFFFFF0007F - 8888FFFFFFF0000F8888FFFFFFF7000000000007000FFFFFFFFFFFFFFF000000 - 7FFFFFFFFF8000007FFFFFFFFFF000007FFFFFFFFFF7000008FFFFFFFFF7000F - FFF00007FFFFFFFFFF000007FFFFFFFFFF000006FFFFFFFFFF70000000000000 - 00FFFFFFFFFFFFFFFF0000000077777770000000007777777400000000777777 - 77000000006777777700000FFFF0000007777777000000000777777770000000 - 0677777770000000000000007FFFFFFFFFFFFFFFFF0000000000000000000000 - 00000000000000000000000000000000000000000000000FFFF0000000000000 - 000000000000000000000000000000000000000000000007FFFFFFFFFFFFFFFF - FF00000000000000000000000000000000000000000000000000000000000000 - 0000000FFFF00000000000000000000000000000000000000000000000000000 - 0000008FFFFFFFFFFFFFFFFFFF00000000000000000000000000000000000000 - 0000000000000000000000000000000FFFF00000000000000000000000000000 - 000000000000000000000000000008FFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF700000000000FFFFFFFFFFFFFFFFFF - FFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF888870 - 008888FFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFF7007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7007FFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFF0007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFF0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF008FFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF008FFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000 - 0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - FFFFFFFFFFFFFFFFFF0000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00} - Transparent = True - end - object Label31: TLabel - Left = 288 - Top = 10 - Width = 223 - Height = 13 - Caption = ' Pour utilisation en mode autonome uniquement' - end object GroupBox24: TGroupBox Left = 312 Top = 72 Width = 297 - Height = 161 + Height = 377 Caption = 'Trains' TabOrder = 0 object Label51: TLabel @@ -3626,6 +3496,30 @@ object FormConfig: TFormConfig Height = 13 Caption = 'Vitesse nominale' end + object Label16: TLabel + Left = 24 + Top = 280 + Width = 27 + Height = 13 + Caption = 'Ic'#244'ne' + end + object ImageTrain: TImage + Left = 16 + Top = 312 + Width = 257 + Height = 49 + end + object SpeedButtonOuvre: TSpeedButton + Left = 128 + Top = 272 + Width = 23 + Height = 22 + Hint = 'Charger ic'#244'ne' + Caption = '...' + ParentShowHint = False + ShowHint = True + OnClick = SpeedButtonOuvreClick + end object EditNomTrain: TEdit Left = 136 Top = 24 @@ -3681,6 +3575,41 @@ object FormConfig: TFormConfig TabOrder = 4 OnChange = EditVitNomChange end + object EditIcone: TEdit + Left = 160 + Top = 272 + Width = 121 + Height = 21 + TabOrder = 5 + OnChange = EditIconeChange + end + object LabeledEditTempoD: TLabeledEdit + Left = 240 + Top = 144 + Width = 41 + Height = 21 + EditLabel.Width = 146 + EditLabel.Height = 26 + EditLabel.Caption = 'Temporisation de d'#233'marrage '#224' l'#39'ouverture de signal (s)' + EditLabel.Layout = tlBottom + EditLabel.WordWrap = True + LabelPosition = lpLeft + LabelSpacing = 78 + TabOrder = 6 + OnChange = LabeledEditTempoDChange + end + object CheckBoxSens: TCheckBox + Left = 16 + Top = 176 + Width = 241 + Height = 17 + Hint = 'Inverse le sens de pilotage en mode roulage' + Caption = 'Sens de pilotage invers'#233 + ParentShowHint = False + ShowHint = True + TabOrder = 7 + OnClick = CheckBoxSensClick + end end object ButtonNT: TButton Left = 8 @@ -3704,7 +3633,7 @@ object FormConfig: TFormConfig Left = 8 Top = 72 Width = 281 - Height = 337 + Height = 281 Color = clBlack Font.Charset = DEFAULT_CHARSET Font.Color = clAqua @@ -3721,7 +3650,7 @@ object FormConfig: TFormConfig end end object TabSheetPeriph: TTabSheet - Caption = 'COM/USB/Socket' + Caption = 'P'#233'riph'#233'riques' ImageIndex = 9 object Label73: TLabel Left = 8 @@ -3794,13 +3723,13 @@ object FormConfig: TFormConfig object Label23: TLabel Left = 8 Top = 36 - Width = 606 + Width = 534 Height = 26 Caption = - 'Les p'#233'riph'#233'riques sont utilis'#233's pour '#234'tre activ'#233's par un actionn' + - 'eur et pour leur envoyer des ordres ASCII. On peut '#233'galement leu' + - 'r envoyer des informations sur les '#233'v'#232'nements aiguillage, d'#233'tect' + - 'eurs et actionneurs via les services.' + 'Les p'#233'riph'#233'riques sont utilis'#233's pour '#234'tre activ'#233's par une action' + + ' et pour leur envoyer des ordres ASCII. On peut '#233'galement leur e' + + 'nvoyer des informations sur les '#233'v'#232'nements aiguillage, d'#233'tecteur' + + 's et actionneurs via les services.' WordWrap = True end object ListBoxPeriph: TListBox diff --git a/UnitConfig.pas b/UnitConfig.pas index 4c5ec84..0294ecb 100644 --- a/UnitConfig.pas +++ b/UnitConfig.pas @@ -228,10 +228,8 @@ type EditVitRalenti: TEdit; Label57: TLabel; EditVitNom: TEdit; - LabelInfVitesse: TLabel; CheckRoulage: TCheckBox; CheckBoxVerifXpressNet: TCheckBox; - ImageTrain: TImage; PopupMenuRichedit: TPopupMenu; Copier1: TMenuItem; Coller1: TMenuItem; @@ -316,7 +314,6 @@ type ButtonPropage: TButton; ButtonPFCDM: TButton; TabAvance: TTabSheet; - Label31: TLabel; Label39: TLabel; CheckBoxMsgAigInc: TCheckBox; TabSheet1: TTabSheet; @@ -332,6 +329,12 @@ type ButtonTestAction: TButton; PopupMenuActions: TPopupMenu; ModifAction: TMenuItem; + Label16: TLabel; + ImageTrain: TImage; + EditIcone: TEdit; + SpeedButtonOuvre: TSpeedButton; + LabeledEditTempoD: TLabeledEdit; + CheckBoxSens: TCheckBox; procedure ButtonAppliquerEtFermerClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ListBoxAigMouseDown(Sender: TObject; Button: TMouseButton; @@ -500,6 +503,10 @@ type procedure ListBoxActionsKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure ListBoxOperationsDblClick(Sender: TObject); + procedure SpeedButtonOuvreClick(Sender: TObject); + procedure EditIconeChange(Sender: TObject); + procedure LabeledEditTempoDChange(Sender: TObject); + procedure CheckBoxSensClick(Sender: TObject); private { Déclarations privées } @@ -526,6 +533,7 @@ couleur_fond_ch='coul_fond'; serveurIPCDM_Touche_ch='serveurIPCDM_Touche'; PortServeur_ch='Port_Serveur'; AntiTimeoutEthLenz_ch='AntiTimeoutEthLenz'; +TempoTC_ch='TempoTC'; Verif_AdrXpressNet_ch='Verif_AdrXpressNet'; Filtrage_det_ch='Filtrage_det'; nCantons_Res_ch='nCantonsRes'; @@ -614,6 +622,8 @@ section_DecPers_ch='[section_decodeurs]'; section_accCOM_ch='[section_accCOMUSB]'; section_horloge_ch='[section horloge]'; +rep_icones='icones'; + var FormConfig: TFormConfig; AdresseIPCDM,AdresseIP,PortCom,recuCDM,residuCDM,RepConfig : string; //,trainsauve : string; @@ -624,7 +634,8 @@ var ligneClicBr,AncligneClicBr,ligneClicAct,AncLigneClicAct,IndexSignalclic,NumTrameCDM, Algo_localisation,Verif_AdrXpressNet,ligneclicTrain,AncligneclicTrain,AntiTimeoutEthLenz, ligneDCC,decCourant,AffMemoFenetre,ligneClicAccPeriph,AncligneClicAccPeriph,ligneCherche, - compt_Ligne,Style_aff,Ancien_Style,Ecran_SC,Mode_reserve,Max_Signal_Sens,nCantonsRes : integer; + compt_Ligne,Style_aff,Ancien_Style,Ecran_SC,Mode_reserve,Max_Signal_Sens,nCantonsRes, + TempoTC,Nbuttoirs : integer; ack_cdm,clicliste,config_modifie,clicproprietes,confasauver,trouve_MaxPort,fermeSC, modif_branches,ConfigPrete,trouve_section_dccpp,trouve_section_trains,trouve_section_acccomusb, @@ -647,7 +658,7 @@ var EditZdet1V4F,EditZdet2V4F,EditZdet1V4O,EditZdet2V4O, EditZdet1V5F,EditZdet2V5F,EditZdet1V5O,EditZdet2V5O,EditOuvreEcran, EditNbDetDist,EditNbCantons,EditFiltrDet,EditAlgo, - EditMaxSignalSens,EditnCantonsRes,EditAntiTO,EditRep : Tedit; + EditMaxSignalSens,EditnCantonsRes,EditAntiTO,EditRep,EditTempoTC : Tedit; EditT : Array[1..10] of Tedit; TextBoxCde : array[1..19] of Tedit; @@ -655,7 +666,7 @@ var LabelPortCde,LbPnVoie1,LbAPnVoie1,LbAPnVoie2,LbAPnVoie3,LbAPnVoie4,LbAPnVoie5,LbATitre, LbZTitre,LbZPnVoie1,LbZPnVoie2,LbZPnVoie3,LbZPnVoie4,LbZPnVoie5,LabelMP,LabelNumeroP, LabelStyle,LabelOuvreEcran,LabelAvance1,LabelAvance2,LabelAntiTO, - LabelTD,LabelNC,LabelFiltre,LabelAlgo,LabelNbSignBS,LabelnCantonsRes : Tlabel; + LabelTD,LabelNC,LabelFiltre,LabelAlgo,LabelNbSignBS,LabelnCantonsRes,LabelTempoTC : Tlabel; RadioReserve,RadioServeurCDM,rgPilTrains : TradioGroup; @@ -689,6 +700,7 @@ function encode_actions(i : integer) : string; function encode_act_pn(i : integer) : string; function encode_Periph(index : integer) : string; procedure ajoute_champs_combos(i : integer); +function verif_trains : boolean; implementation @@ -1611,6 +1623,25 @@ begin DeclAccessoire : s:=s+intToSTR(Tablo_Actionneur[i].adresse)+','+intToSTR(Tablo_Actionneur[i].etat)+','; DeclDetAct : s:=s+intToSTR(Tablo_Actionneur[i].adresse)+','+intToSTR(Tablo_Actionneur[i].etat)+','+Tablo_Actionneur[i].trainDecl+','; DeclZoneDet : s:=s+intToSTR(Tablo_Actionneur[i].adresse)+','+intToSTR(Tablo_Actionneur[i].adresse2)+','+intToSTR(Tablo_Actionneur[i].etat)+','+Tablo_Actionneur[i].trainDecl+','; + DeclDemarTrain : s:=s+intToSTR(Tablo_Actionneur[i].adresse)+','+Tablo_Actionneur[i].trainDecl+','; + DeclArretTrain : s:=s+intToSTR(Tablo_Actionneur[i].adresse)+','+Tablo_Actionneur[i].trainDecl+','; + DeclSignal : s:=s+intToSTR(Tablo_Actionneur[i].adresse)+','+intToSTR(Tablo_Actionneur[i].etat)+','; + end; + + // conditions + Nb:=Tablo_Actionneur[i].NbCond; + s:=s+'B'+IntToSTR(Nb)+','; + for j:=1 to Nb do + begin + action:=Tablo_Actionneur[i].TabloCond[j].numcondition; // il n'y a qu'une condition (v8.8) + s:=s+'C'+intToSTR(action)+','; // numéro de condition + case action of + condVitTrain : s:=s+intToSTR(Tablo_Actionneur[i].TabloCond[j].vitmini)+','+intToSTR(Tablo_Actionneur[i].TabloCond[j].vitmaxi)+','+Tablo_Actionneur[i].TabloCond[j].train+','; + condPosAcc : s:=s+intToSTR(Tablo_Actionneur[i].TabloCond[j].accessoire)+','+intToSTR(Tablo_Actionneur[i].TabloCond[j].etat)+','; + condHorl : s:=s+intToSTR(Tablo_Actionneur[i].TabloCond[j].HeureMin)+','+intToSTR(Tablo_Actionneur[i].TabloCond[j].MinuteMin)+','+ + intToSTR(Tablo_Actionneur[i].TabloCond[j].HeureMax)+','+intToSTR(Tablo_Actionneur[i].TabloCond[j].MinuteMax)+','; + condTrainSig : s:=s+intToSTR(Tablo_Actionneur[i].TabloCond[j].adresse)+','+Tablo_Actionneur[i].TabloCond[j].train+','; + end; end; Nb:=Tablo_Actionneur[i].NbOperations; @@ -1749,10 +1780,13 @@ end; function Train_tablo(index : integer) : string; +var s: string; begin - result:=trains[index].nom_train+','+inttostr(trains[index].adresse)+','+ + s:=trains[index].nom_train+','+inttostr(trains[index].adresse)+','+ intToSTR(trains[index].vitmax)+','+intToSTR(trains[index].vitnominale)+','+ - intToSTR(trains[index].vitRalenti); + intToSTR(trains[index].vitRalenti)+','+trains[index].NomIcone+','+intToSTR(trains[index].TempsDemarreSig)+','; + if trains[index].inverse then s:=s+'1' else s:=s+'0'; + result:=s; end; // modifie le fichier de config en fonction du paramétrage @@ -1797,6 +1831,7 @@ begin writeln(fichierN,Filtrage_det_ch+'=',filtrageDet0); writeln(fichierN,nCantons_Res_ch+'=',nCantonsRes); writeln(fichierN,AntiTimeoutEthLenz_ch+'=',AntiTimeoutEthLenz); + writeln(fichierN,TempoTC_ch+'=',TempoTC); // taille de la fonte writeln(fichierN,Fonte_ch+'=',TailleFonte); FormPrinc.FenRich.Font.Size:=TailleFonte; @@ -2075,11 +2110,14 @@ begin // placement des trains writeln(fichierN,'/------------'); writeln(fichierN,section_placement_ch); - for i:=1 to 6 do + for i:=1 to ntrains do begin - s:=placement[i].train+','+inttoSTR(placement[i].detecteur)+','; - s:=s+intToSTR(placement[i].detdir)+','; - if placement[i].inverse then s:=s+'1' else s:=s+'0'; + s:=trains[i].nom_train+','; + j:=trains[i].canton; //numéro du canton + s:=s+inttoSTR(j)+','; + j:=index_canton_numero(j); + if j<>0 then s:=s+intToSTR(canton[j].Sens)+',' else s:=s+'0,'; + if trains[i].inverse then s:=s+'1' else s:=s+'0'; writeln(fichierN,s); end; writeln(fichierN,'0'); @@ -2234,9 +2272,18 @@ begin end; end; +// compte le nombre de virgules dans la chaine +function Nbre_virgules(s : string) : integer ; +var i,c : integer; +begin + c:=0; + for i:=1 to length(s) do + if s[i]=',' then inc(c); + result:=c; +end; procedure lit_config; -var s,sa,SOrigine: string; +var train,s,sa,SOrigine: string; c : char; tec,tjdC,tjsC,s2,triC,debugConfig,trouve_NbDetDist,trouve_ipv4_PC,trouve_retro,trouve_protocole, trouve_sec_init,trouve_init_aig,trouve_lay,trouve_IPV4_INTERFACE,trouve_PROTOCOLE_SERIE,trouve_INTER_CAR, @@ -2244,11 +2291,14 @@ var s,sa,SOrigine: string; trouve_NOTIF_VERSION,trouve_verif_version,trouve_fonte,trouve_tempo_aig,trouve_raz,trouve_section_aig, trouve_section_branche,trouve_section_sig,trouve_section_act,trouve_tempo_signal, trouve_algo_uni,croi,trouve_Nb_cantons_Sig,trouve_dem_aig,trouve_demcnxCOMUSB,trouve_demcnxEth : boolean; + virgule,i_detect,i,erreur,aig2,detect,offset,j,position, - ComptEl,Compt_IT,Num_Element,adr,Nligne,postriple,itl, - postjd,postjs,nv,it,Num_Champ,asp,adraig,poscroi : integer; + ComptEl,Compt_IT,Num_Element,adr,Nligne,postriple,itl,vers, + postjd,postjs,nv,it,Num_Champ,asp,adraig,poscroi,idtrain : integer; tabloDet : TTabloDet; + versR : double; + function lit_ligne : string ; var esp,l1,l2 : integer; begin @@ -2302,6 +2352,7 @@ var s,sa,SOrigine: string; NDetecteurs:=0; Nligne:=1; i_detect:=1; + Nbuttoirs:=0; i:=1; //Affiche('Définition des branches',clyellow); @@ -2466,6 +2517,11 @@ var s,sa,SOrigine: string; s:=sOrigine; // travailler en min/maj Tablo_actionneur[maxtablo_act].NomAction:='Action '+intToSTR(maxtablo_act); + // Mettre au moins une condition : vrai + setlength(tablo_actionneur[maxtablo_act].TabloCond,2); + Tablo_Actionneur[maxtablo_act].NbCond:=1; + Tablo_actionneur[maxtablo_act].TabloCond[1].numcondition:=CondVrai; + // évènement actionneur par horloge if (upcase(s[1])='H') then begin @@ -2753,7 +2809,7 @@ var s,sa,SOrigine: string; // nouveaux procedure compile_actions; - var n,k,l : integer; + var n,k,l,c : integer; begin maxTablo_act:=1; Nligne:=1; @@ -2767,7 +2823,13 @@ var s,sa,SOrigine: string; i:=pos(',',s); sa:=copy(s,1,i-1); if sa='' then sa:='Action '+intToSTR(maxtablo_act); + Tablo_actionneur[maxtablo_act].traite:=false; Tablo_actionneur[maxtablo_act].NomAction:=sa; + // initialiser la condition toujours vrai par défaut + Tablo_Actionneur[maxtablo_act].NbCond:=1; + Setlength(Tablo_actionneur[maxtablo_act].TabloCond,2); + Tablo_actionneur[maxtablo_act].TabloCond[1].numcondition:=CondVrai; + Delete(s,1,i); // déclencheur delete(s,1,1); @@ -2786,7 +2848,7 @@ var s,sa,SOrigine: string; begin Val(s,i,erreur);Delete(s,1,erreur); Tablo_actionneur[maxtablo_act].NumPeriph:=i; - i:=pos(',',s); + i:=pos(',',s); if i=0 then i:=length(s)+1; sa:=copy(s,1,i-1);delete(s,1,i); Tablo_actionneur[maxtablo_act].ordrePeriph:=sa; end; @@ -2803,7 +2865,7 @@ var s,sa,SOrigine: string; Tablo_actionneur[maxtablo_act].adresse:=i; Val(s,i,erreur);Delete(s,1,erreur); Tablo_actionneur[maxtablo_act].etat:=i; - i:=pos(',',s); + i:=pos(',',s);if i=0 then i:=length(s)+1; sa:=copy(s,1,i-1);delete(s,1,i); Tablo_actionneur[maxtablo_act].trainDecl:=sa; end; @@ -2819,6 +2881,100 @@ var s,sa,SOrigine: string; sa:=copy(s,1,i-1);delete(s,1,i); Tablo_actionneur[maxtablo_act].trainDecl:=sa; end; + DeclDemarTrain : + begin + Val(s,i,erreur);Delete(s,1,erreur); // seuil de vitesse + Tablo_actionneur[maxtablo_act].adresse:=i; + i:=pos(',',s);if i=0 then i:=length(s)+1; + sa:=copy(s,1,i-1);delete(s,1,i); + Tablo_actionneur[maxtablo_act].trainDecl:=sa; + end; + DeclArretTrain : + begin + Val(s,i,erreur);Delete(s,1,erreur); // seuil de vitesse + Tablo_actionneur[maxtablo_act].adresse:=i; + i:=pos(',',s);if i=0 then i:=length(s)+1; + sa:=copy(s,1,i-1);delete(s,1,i); + Tablo_actionneur[maxtablo_act].trainDecl:=sa; + end; + DeclSignal : + begin + Val(s,i,erreur);Delete(s,1,erreur); // adresse + Tablo_actionneur[maxtablo_act].adresse:=i; + i:=pos(',',s); + Val(s,i,erreur);Delete(s,1,erreur); // seuil de vitesse + if (i<0) or (i>1) then i:=0; + Tablo_actionneur[maxtablo_act].Etat:=i; + end; + end; + + + // conditions + if s[1]='B' then + begin + delete(s,1,1); + // nombre de conditions + Val(s,n,erreur); + Tablo_actionneur[maxtablo_act].NbCond:=n; + Delete(s,1,erreur); + setlength(Tablo_actionneur[maxtablo_act].TabloCond,n+1); + for k:=1 to n do + begin + delete(s,1,1); + val(s,j,erreur); delete(s,1,erreur); + // numéro de l'opération + if (j<0) or (j>NbreConditions) then + begin + Affiche('Condition '+intToSTR(maxtablo_act)+' dans opération n°'+intToSTR(k)+' : cond inconnue :'+intToSTR(j),clred); + end; + Tablo_actionneur[maxtablo_act].tabloCond[k].numCondition:=j; + case j of + condVitTrain: + begin + val(s,j,erreur); delete(s,1,erreur); + Tablo_actionneur[maxtablo_act].tabloCond[k].vitmini:=j; + val(s,j,erreur); delete(s,1,erreur); + Tablo_actionneur[maxtablo_act].tabloCond[k].vitmaxi:=j; + i:=pos(',',s); + if i<>0 then + begin + sa:=copy(s,1,i-1);delete(s,1,i); + end + else sa:=s; + Tablo_actionneur[maxtablo_act].tabloCond[k].train:=sa; + end; + condPosAcc : + begin + val(s,j,erreur); delete(s,1,erreur); + Tablo_actionneur[maxtablo_act].tabloCond[k].accessoire:=j; + val(s,j,erreur); delete(s,1,erreur); + Tablo_actionneur[maxtablo_act].tabloCond[k].etat:=j; + end; + condHorl : + begin + val(s,j,erreur); delete(s,1,erreur); + Tablo_actionneur[maxtablo_act].tabloCond[k].HeureMin:=j; + val(s,j,erreur); delete(s,1,erreur); + Tablo_actionneur[maxtablo_act].tabloCond[k].MinuteMin:=j; + val(s,j,erreur); delete(s,1,erreur); + Tablo_actionneur[maxtablo_act].tabloCond[k].HeureMax:=j; + val(s,j,erreur); delete(s,1,erreur); + Tablo_actionneur[maxtablo_act].tabloCond[k].MinuteMax:=j; + end; + condTrainSig : + begin + val(s,j,erreur); delete(s,1,erreur); + Tablo_actionneur[maxtablo_act].tabloCond[k].adresse:=j; + i:=pos(',',s); + if i<>0 then + begin + sa:=copy(s,1,i-1);delete(s,1,i); + end + else sa:=s; + Tablo_actionneur[maxtablo_act].tabloCond[k].train:=sa; + end; + end; + end; end; // nombre d'actions @@ -2838,9 +2994,14 @@ var s,sa,SOrigine: string; Affiche('Action '+intToSTR(maxtablo_act)+' dans opération n°'+intToSTR(k)+' : op inconnue :'+intToSTR(j),clred); end; Tablo_actionneur[maxtablo_act].tabloOP[k].numoperation:=j; - val(s,l,erreur); delete(s,1,erreur); - // état validé ou dévalidé - Tablo_actionneur[maxtablo_act].tabloOP[k].valide:=l=1; + + // nouvelle version (pour paramètre d'activation) + if versR>8.71 then + begin + val(s,l,erreur); delete(s,1,erreur); + // état validé ou dévalidé + Tablo_actionneur[maxtablo_act].tabloOP[k].valide:=l=1; + end else Tablo_actionneur[maxtablo_act].tabloOP[k].valide:=true; // paramètres des opérations case j of ActionAffTCO : @@ -3414,20 +3575,52 @@ var s,sa,SOrigine: string; delete(s,1,erreur-1); end; - Formprinc.ComboTrains.Items.Add(trains[ntrains].nom_train); + i:=pos(',',s); + if i<>0 then + begin + delete(s,i,1); + i:=pos(',',s); + if i=0 then i:=length(s)+1; + trains[ntrains].NomIcone:=copy(s,1,i-1); + Formprinc.ComboTrains.Items.Add(trains[ntrains].nom_train); + delete(s,1,i-1); + end; + + i:=pos(',',s); + if i<>0 then + begin + delete(s,i,1); + val(s,i,erreur); + if (i<0) or (i>20) then i:=0; + trains[ntrains].TempsDemarreSig:=i; + delete(s,1,erreur-1); + end; + + i:=pos(',',s); + if i<>0 then + begin + delete(s,i,1); + val(s,i,erreur); + if (i<0) or (i>1) then i:=0; + trains[ntrains].inverse:=i=1; + delete(s,1,erreur-1); + end; end; - if ntrains>1 then + + until (sOrigine='0') or (ntrains>=Max_Trains); + for i:=1 to ntrains do + begin + trains[i].canton:=0; + trains[i].x:=-999999; + trains[i].y:=-999999; + end; + if ntrains>1 then with Formprinc do begin ComboTrains.ItemIndex:=0; editadrtrain.Text:=inttostr(trains[1].adresse); end; - until (sOrigine='0') or (ntrains>=Max_Trains); - for i:=1 to ntrains do - begin - trains[i].x:=-999999; - trains[i].y:=-999999; - end; + end; procedure compile_periph; @@ -3606,7 +3799,6 @@ var s,sa,SOrigine: string; // valeurs par défaut Nb_cantons_Sig:=3; nv:=0; it:=0; - // taille de fonte repeat s:=lit_ligne; @@ -3630,7 +3822,7 @@ var s,sa,SOrigine: string; sa:=uppercase(couleur_fond_ch)+'='; i:=pos(sa,s); if i=1 then - begin + begin delete(s,i,length(sa)); val('$'+s,CouleurFond,erreur); end; @@ -3774,6 +3966,14 @@ var s,sa,SOrigine: string; val(s,AntiTimeoutEthLenz,erreur); end; + sa:=uppercase(TempoTC_ch)+'='; + i:=pos(sa,s); + if i=1 then + begin + delete(s,i,length(sa)); + val(s,tempoTC,erreur); + end; + sa:=uppercase(Algo_localisation_ch)+'='; i:=pos(sa,s); if i=1 then @@ -4337,7 +4537,7 @@ var s,sa,SOrigine: string; compile_dec_pers; end; - // section placement + // section placement : mis dans les trains sa:=uppercase(section_placement_ch); if pos(sa,s)<>0 then begin @@ -4349,22 +4549,26 @@ var s,sa,SOrigine: string; j:=pos(',',s); if j<>0 then begin - placement[i].train:=copy(s,1,j-1); + // train + train:=copy(s,1,j-1); + idtrain:=index_train_nom(train); delete(s,1,j); + // numéro de canton (pas index) val(s,j,erreur); - placement[i].detecteur:=j; + trains[idtrain].canton:=j; j:=pos(',',s); if j<>0 then begin + // sens delete(s,1,j); val(s,j,erreur); - placement[i].detdir:=j; + trains[idtrain].sens:=j; + // inverse, mais ne pas stocker, déja lu dans compile_trains j:=pos(',',s); if j<>0 then begin delete(s,1,j); val(s,j,erreur); - placement[i].inverse:=j=1; end; end; end; @@ -4510,6 +4714,22 @@ begin assignFile(fichier,NomConfig); reset(fichier); end; + readln(fichier,s); + i:=pos('version',s); + if i<>0 then + begin + delete(s,1,i+7); + val(s,versR,erreur); + if erreur<>0 then + begin + delete(s,erreur,length(s)-erreur+1); + val(s,versR,erreur); + end; + end else + begin + versR:=0; + Affiche('Version fichier de configuration inconnue',clred); + end; lit_flux; close(fichier); @@ -4659,6 +4879,10 @@ begin if (i<0) or (i>1) then i:=0; AntiTimeoutEthLenz:=i; + val(EditTempoTC.Text,i,erreur); + if (i<0) or (i>10) then i:=1; + TempoTC:=i; + Val(editTempoAig.Text,i,erreur); if i>3000 then begin labelInfo.Caption:='Temporisation de séquencement incorrecte ';ok:=false;end; Tempo_Aig:=i; @@ -5340,6 +5564,10 @@ var i,j,x,y,l,LongestLength,PixelLength : integer; begin if AffEvt or (debug=1) then Affiche('Création fenêtre config',clLime); + s:=GetCurrentDir; + if not(directoryExists(rep_icones)) then CreateDir(rep_icones); + ChDir(s); // revient au rep initial + visible:=false; clicListe:=true; position:=poMainFormCenter; @@ -5370,6 +5598,25 @@ begin EditNbreAdr.Text:='2'; + for i:=1 to nTrains do // + begin + cs:=trains[i].NomIcone; + s:=GetCurrentDir; + s:=s+'\icones'; + s:=s+'\'+cs; + if cs<>'' then + begin + // lire le fichier icone + if fileExists(s) then + begin + trains[i].icone.Picture.LoadFromFile(s); + end + else Affiche('Le fichier icône train '+s+' n''a pas été trouvé',clred); + + end; + end; + + // création des champs dynamiques de l'onglet CDM Rail EditOuvreEcran:=TEdit.create(GroupBox5); with EditOuvreEcran do @@ -6164,8 +6411,6 @@ begin for i:=1 to ntrains do items.Add(Train_tablo(i)); end; - - // composants dynamiques car on ne peut plus ajouter de composants en mode conception! // onglet périphériques COM/USB/Socket //--------- groupbox @@ -6396,7 +6641,7 @@ begin GroupBoxAvance:=TGroupBox.Create(FormConfig.TabAvance); with GroupBoxAvance do begin - Left:=3;Top:=40;Width:=300;Height:=150; // maxi=580 + Left:=3;Top:=40;Width:=300;Height:=160; // maxi=580 caption:='Jeu de paramètres avancés'; name:='GroupBoxAvance'; parent:=TabAvance; @@ -6504,6 +6749,27 @@ begin ShowHint:=true; end; + LabelTempoTC:=TLabel.Create(FormConfig.TabAvance); + with LabelTempoTC do + begin + Left:=10;Top:=130;Width:=170;Height:=12; + caption:='Facteur de temporisation de télécommande CDM'; + name:='LabelTempoTC'; + parent:=GroupBoxAvance; + end; + EditTempoTC:=TEdit.Create(TabAvance); + with EditTempoTC do + begin + Left:=x;Top:=130;Width:=30;Height:=15; + name:='EditTempoTC'; + text:=''; + parent:=GroupBoxAvance; + s:='Facteur multiplicateur de 1 à 10 pour la temporisation'+#13+ + 'de la télécommande du démarrage de CDM'; + hint:=s; + ShowHint:=true; + end; + RadioReserve:=TRadioGroup.Create(TabAvance); with RadioReserve do begin @@ -8602,7 +8868,13 @@ begin Tablo_actionneur[maxtablo_act].NomAction:='ACTION'+intToSTR(maxtablo_act); SetLength(Tablo_actionneur[maxtablo_act].TabloOp,2); - + SetLength(Tablo_actionneur[maxtablo_act].TabloCond,2); + Tablo_actionneur[maxtablo_act].NbCond:=1; + Tablo_actionneur[maxtablo_act].NbOperations:=0; + + Tablo_actionneur[maxtablo_act].TabloCond[1].numcondition:=CondVrai; + Tablo_actionneur[maxtablo_act].TabloOP[1].numoperation:=0; + s:=encode_actions(MaxTablo_act); with formconfig.listBoxActions do begin @@ -8935,6 +9207,8 @@ begin config_modifie:=true; FormConfig.ListBoxActions.Clear; + FormConfig.ListBoxOperations.clear; + formConfig.RichEditInfo.Clear; // réafficher la liste for i:=1 to maxTablo_act do @@ -9342,6 +9616,27 @@ begin nombre_adresses_signal:=nc; end; +//vérifie si il n'y a pas de doublon dans l'adresse des trains +function verif_trains : boolean; +var i,j,adr : integer; + nom : string; +begin + result:=true; + for i:=1 to nTrains do + begin + adr:=trains[i].adresse; + nom:=trains[i].nom_train; + for j:=i+1 to ntrains do + begin + if trains[j].Adresse=adr then Affiche('Les trains '+intToSTR(i)+' et '+intToSTR(j)+' ont la même adresse : '+intToSTR(adr),clred); + if trains[j].nom_train=nom then Affiche('Les trains '+intToSTR(i)+' et '+intToSTR(j)+' ont le même nom : '+nom,clred); + + result:=false; + + end; + end; +end; + function verif_coherence : boolean; var AncAdr,i,j,k,l,Indexaig,adr,adr2,extr,detect,condcarre,nc,index2,SuivAdr,indexTCO,AdrAig, @@ -9371,7 +9666,7 @@ begin repeat detect:=BrancheN[i][j].Adresse; - if detect>NbMaxDet then + if (detect>NbMaxDet) and (detect<10000) then begin Affiche('Erreur 1: adresse détecteur trop grand: '+intToSTR(detect),clred); ok:=false; @@ -10204,6 +10499,9 @@ begin end; end; + // 10 trains + if not(verif_trains) then ok:=false; + // 11 Divers i:=pos(':',portcom);j:=pos(',',portcom); val(copy(portcom,i+1,j-i),vitesse,l); @@ -11197,7 +11495,7 @@ begin // détecteur if erreur=0 then begin - if detect>NbMaxDet then + if (detect>NbMaxDet) and (detect<10000) then begin Affiche('Erreur 20 ligne '+s+' : adresse détecteur trop grand: '+intToSTR(detect),clred); detect:=NbMaxDet; @@ -11208,7 +11506,13 @@ begin detecteur[detect].NumBranche:=i; // detecteur[] est indexé par le détecteur detecteur[detect].IndexBranche:=j; - if detect=0 then begin BrancheN[i,j].btype:=buttoir;end; // buttoir + if (detect=0) or (detect>10000) then + begin + inc(Nbuttoirs); + BrancheN[i,j].btype:=buttoir; +// non BrancheN[i,j].adresse:=10000+nButtoirs; + end; + // vérifier si le détecteur est déja stocké bd:=0; repeat @@ -11903,7 +12207,43 @@ begin if CheckEnvAigDccpp.checked then EnvAigDccpp:=1 else EnvAigDccpp:=0; end; +// affiche l'icone du train index dans le canvas +procedure Maj_icone_train(Icanvas : Tcanvas;index :integer); +var h,l,HautDest,LargDest,y : integer; + rd : double; +begin + with formConfig do + begin + // source + l:=Trains[index].Icone.width; + h:=Trains[index].Icone.Height; + if h=0 then exit; + rd:=l/h; + //Affiche(FloatToSTR(rd),clred); + + // destination : la hauteur est fixée + HautDest:=round(ImageTrain.Height); + LargDest:=round(Hautdest*rd); + + // si la largeur > que l'image, on fixe la largeur + if LargDest>ImageTrain.Width then + begin + LargDest:=ImageTrain.Width; + HautDest:=round(LargDest/rd); + end; + + y:=ImageTrain.Height-HautDest; + + TransparentBlt(Icanvas.Handle,0,y,largDest,hautDest, + Trains[index].Icone.canvas.Handle,0,0,l,h,clWhite); + + end; + formconfig.ImageTrain.Repaint; +end; + procedure clicListeTrains(index : integer); +var s : string; + begin if index<1 then exit; if Trains[index].nom_train='' then exit; @@ -11912,8 +12252,16 @@ begin editNomTrain.text:=Trains[index].nom_train; editAdresseTrain.Text:=intToSTR(trains[index].adresse); editVitesseMaxi.Text:=intToSTR(trains[index].vitmax); + LabeledEditTempoD.Text:=intToSTR(trains[index].TempsDemarreSig); editVitRalenti.Text:=IntToSTR(trains[index].Vitralenti); editvitnom.text:=IntToSTR(trains[index].VitNominale); + CheckBoxSens.Checked:=trains[index].inverse; + s:=trains[index].NomIcone; + editIcone.Text:=s; + + ImageTrain.Canvas.Rectangle(0,0,ImageTrain.Width,ImageTrain.Height); + + if s<>'' then Maj_icone_train(formconfig.ImageTrain.Canvas,index); end; end; @@ -13962,7 +14310,7 @@ begin clicListe:=false; Edit_HG.Visible:=false; labelHG.Visible:=false; - EditP1.Visible:=false; + EditP1.Visible:=false; EditP2.Visible:=false; EditP3.Visible:=false; EditP4.Visible:=false; @@ -13971,7 +14319,7 @@ begin EditDevieS2.Visible:=false; Label18.Visible:=false; Label20.Visible:=false; - if AvecRoulage=1 then LabelInfVitesse.Visible:=false else LabelInfVitesse.Visible:=true; + // if AvecRoulage=1 then LabelInfVitesse.Visible:=false else LabelInfVitesse.Visible:=true; EditP1.ReadOnly:=false; EditP2.ReadOnly:=false; @@ -13994,6 +14342,7 @@ begin EditFiltrDet.text:=intToSTR(filtrageDet0); EditnCantonsRes.Text:=intToSTR(nCantonsRes); EditAntiTO.Text:=intToSTR(AntiTimeoutEthLenz); + EditTempoTC.Text:=intToSTR(TempoTC); EditRep.Text:=RepConfig; {$IF CompilerVersion >= 28.0} @@ -14263,8 +14612,68 @@ procedure TFormConfig.ListBoxOperationsDblClick(Sender: TObject); s:=operations[op].nom; if not(Tablo_Actionneur[ligneclicact+1].tabloOp[clicaction+1].valide) then s:=s+' [dévalidé]'; listBoxOperations.Items[clicaction]:=Format('%d%s', [icone, s]); + ListBoxActions.items[ligneClicAct]:=encode_actions(ligneclicAct+1); end; + + procedure TFormConfig.SpeedButtonOuvreClick(Sender: TObject); + var s,repini :string; + i : integer; + begin + if ligneclicTrain<0 then exit; + i:=ligneclicTrain+1; + s:=rep_icones; + repIni:=GetCurrentDir; // si le repertoire icones n'existe pas, il passe au supérieur + OpenDialogSon.InitialDir:=s; // ça le change de rep !! + OpenDialogSon.DefaultExt:='bmp'; + OpenDialogSon.Title:='Ouvrir un fichier BMP'; + OpenDialogSon.Filter:='Fichiers BMP (*.BMP)|*.bmp|Tous fichiers (*.*)|*.*'; + if openDialogSon.execute then + begin + s:=openDialogSon.filename; + trains[i].NomIcone:=ExtractFileName(s); + s:=trains[i].NomIcone; + EditIcone.Text:=s; + trains[i].icone.Picture.LoadFromFile(s); + ImageTrain.Canvas.Rectangle(0,0,ImageTrain.Width,ImageTrain.Height); + Maj_icone_train(formconfig.ImageTrain.Canvas,i); + //formconfig.ImageTrain.Picture.assign(trains[i].icone.Picture); + end; + chDir(RepIni); +end; + +procedure TFormConfig.EditIconeChange(Sender: TObject); + begin + if ligneclicTrain<0 then exit; + trains[ligneclicTrain+1].NomIcone:=EditIcone.Text; +end; + +procedure TFormConfig.LabeledEditTempoDChange(Sender: TObject); + var erreur,i :integer; +begin + if clicliste then exit; + if affevt then affiche('Evt change temps démarre train',clyellow); + if (ligneclicTrain<0) or (ligneclicTrain>=ntrains) or (ntrains<1) then exit; + val(LabeledEditTempoD.text,i,erreur); + if i<0 then exit; + trains[ligneclicTrain+1].TempsDemarreSig:=i; + formconfig.ListBoxTrains.items[ligneclicTrain]:=Train_tablo(ligneclicTrain+1); + formconfig.ListBoxTrains.selected[ligneclicTrain]:=true; +end; + +procedure TFormConfig.CheckBoxSensClick(Sender: TObject); + begin + if clicliste then exit; + if affevt then affiche('Evt inverse train',clyellow); + if (ligneclicTrain<0) or (ligneclicTrain>=ntrains) or (ntrains<1) then exit; + + trains[ligneclicTrain+1].inverse:=CheckBoxSens.Checked; + formconfig.ListBoxTrains.items[ligneclicTrain]:=Train_tablo(ligneclicTrain+1); + formconfig.ListBoxTrains.selected[ligneclicTrain]:=true; +end; + + + end. diff --git a/UnitConfigCellTCO.dfm b/UnitConfigCellTCO.dfm index 250bcf2..9c97809 100644 --- a/UnitConfigCellTCO.dfm +++ b/UnitConfigCellTCO.dfm @@ -83,8 +83,8 @@ object FormConfCellTCO: TFormConfCellTCO object GroupBox2: TGroupBox Left = 8 Top = 8 - Width = 289 - Height = 297 + Width = 297 + Height = 289 Caption = 'El'#233'ment' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText @@ -144,8 +144,8 @@ object FormConfCellTCO: TFormConfCellTCO OnChange = EditTypeImageChange end object GroupBoxOrientation: TGroupBox - Left = 8 - Top = 144 + Left = 0 + Top = 192 Width = 273 Height = 57 Caption = 'Orientation du signal' @@ -283,7 +283,7 @@ object FormConfCellTCO: TFormConfCellTCO OnClick = ButtonFondClick end object RadioGroupSel: TRadioGroup - Left = 120 + Left = 128 Top = 80 Width = 153 Height = 57 @@ -319,8 +319,8 @@ object FormConfCellTCO: TFormConfCellTCO OnClick = CheckPinvClick end object GroupBoxAction: TGroupBox - Left = 16 - Top = 152 + Left = 120 + Top = 208 Width = 273 Height = 145 Caption = 'Actions' @@ -391,12 +391,40 @@ object FormConfCellTCO: TFormConfCellTCO TabOrder = 5 OnClick = BitBtnAnnuleClick end + object GroupBoxCanton: TGroupBox + Left = 16 + Top = 152 + Width = 281 + Height = 129 + Caption = 'Canton' + TabOrder = 6 + object LabelNumC: TLabel + Left = 19 + Top = 17 + Width = 97 + Height = 13 + Caption = 'Num'#233'ro du canton : ' + end + object RadioGroupAlign: TRadioGroup + Left = 16 + Top = 40 + Width = 257 + Height = 57 + Caption = 'Placement des trains' + Items.Strings = ( + 'Centr'#233 + 'Align'#233' '#224' gauche' + 'Align'#233' '#224' droite') + TabOrder = 0 + OnClick = RadioGroupAlignClick + end + end object ImageListIcones: TImageList Left = 160 Top = 8 Bitmap = { - 494C010113001800040010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600 - 0000000000003600000028000000400000006000000001002000000000000060 + 494C010118001D00040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 0000000000003600000028000000400000008000000001002000000000000080 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 @@ -551,19 +579,9 @@ object FormConfCellTCO: TFormConfCellTCO 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000FF000000 - FF000000FF000000FF000000FF000000FF000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000FF000000 - FF000000FF000000FF000000FF00000000000000000000000000000000000000 - FF000000FF000000FF000000FF000000FF000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000FF000000 - FF000000FF000000FF000000FF000000FF000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000FF000000 - FF000000FF000000FF000000FF00000000000000000000000000000000000000 - FF000000FF000000FF000000FF000000FF000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 @@ -581,6 +599,222 @@ object FormConfCellTCO: TFormConfCellTCO 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF00000000000000000000000000000000 + 00000000000000FF000000FF000000FF000000FF000000FF000000FF00000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000040800000408000004080000040 + 8000004080000040800000408000004080000040800000408000004080000040 + 8000004080000040800000408000FFFFFF00FFFFFF0000FF000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF000000000000000000000000000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF00000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000004080000000 + 0000000000000040800000408000004080000040800000408000004080000040 + 8000004080000040800000408000FFFFFF00FFFFFF00FFFFFF0000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF0000000000000000000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000040800000408000004080000040 + 8000004080000040800000408000004080000000000000000000000000000040 + 8000004080000040800000408000FFFFFF00FFFFFF00FFFFFF00FFFFFF0000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF0000000000000000000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF0000000000000000000000000000000000000000 + 00000000000000000000000000004080E0004080E00000000000000000000000 + 000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00004080000000000000000000000000000040 + 80000040800000408000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF0000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF00000000000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF0000000000000000000000000000000000000000 + 00000000000000000000000000004080E0004080E00000000000000000000000 + 000000000000000000000000000000000000FFFFFF00FFFFFF00000000000000 + 00000000000000000000FFFFFF00004080000040800000408000004080000040 + 8000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF0000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF0000000000000000000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF00000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000FFFFFF0000000000000000000000 + 0000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF0000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF00000000000000000000000000000000000000FF000000FF + 000000FF000000FF000000FF000000FF00000000000000000000000000000000 + 00000000000000000000000000004020E0004020E00000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000004080 + E0004080E000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF0000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000000000000000000000000000000000000000000000000000FF + 000000FF000000FF000000FF000000FF00000000000000000000000000000000 + 00000000000000000000000000004020E0004020E00000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000004080 + E0004080E000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0000FF000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000000000000000000000000000000000000000000000000000FF + 000000FF000000FF000000FF000000FF00000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0000FF000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF00000000000000000000000000000000000000FF000000FF + 000000FF000000FF000000FF000000FF00000000000000000000000000000000 + 000000000000000000000000000000FF000000FF000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000000FF + 000000FF0000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF0000000000000000000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF00000000000000000000000000000000 + 000000000000000000000000000000FF000000FF000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000000FF + 000000FF0000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0000FF + 000000FF000000FF000000FF000000FF00000000000000FF000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF0000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF0000FF000000FF000000FF000000FF0000000000000000000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000FF0000000000000000000000000000000000000000 + 00000000000000000000000000004020E0004020E00000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000004020 + E0004020E000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF0000FF000000FF000000FF0000000000000000000000FF000000FF + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 000000FF000000FF000000000000000000000000000000000000000000000000 + 00000000000000000000000000004020E0004020E00000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000004020 + E0004020E000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF0000FF000000FF00000000000000000000000000000000 + 000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000FFFFFF0000000000000000000000 + 0000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF0000FF00000000000000000000000000000000 + 00000000000000FF000000FF000000FF000000FF000000FF000000FF00000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000FFFFFF00FFFFFF00000000000000 + 00000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000FF000000FF000000FF000000 FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 FF000000FF000000FF000000FF000000FF000000000000000000000000000000 @@ -589,71 +823,121 @@ object FormConfCellTCO: TFormConfCellTCO 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000FF0000000000000000000000 + 0000000000000000000000000000000000000000FF000000FF000000FF000000 + FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 + FF000000FF000000FF000000FF00FFFFFF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000FF000000FF000000FF000000 + FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 + FF000000FF000000FF00FFFFFF00FFFFFF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000FF000000 + FF000000FF000000FF000000FF000000FF000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000FF000000 + FF000000FF000000FF000000FF00000000000000000000000000000000000000 + FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 + FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 + FF000000FF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000FF000000 + FF000000FF000000FF000000FF000000FF000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000FF000000 + FF000000FF000000FF000000FF00000000000000000000000000000000000000 + FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 + FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000FF000000FF000000FF000000 + FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000FF000000FF000000FF000000 + FF000000FF000000FF000000FF000000FF000000FF000000FF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000FF000000FF000000FF000000 + FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 + FF000000FF000000FF000000FF000000FF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000FF000000FF000000FF000000 + FF000000FF000000FF000000FF000000FF000000FF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000FF0000000000000000000000 FF000000FF00000000000000FF000000FF0000000000000000000000FF000000 FF00000000000000FF000000FF000000FF000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000FF000000FF000000 + 0000000000000000000000000000000000000000FF000000FF000000FF000000 + FF000000FF000000FF000000FF000000FF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00000000000000FF000000FF000000 00000000FF00000000000000FF00000000000000FF000000FF00000000000000 FF00000000000000FF000000FF000000FF000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000FF000000FF000000FF000000 + FF000000FF000000FF000000FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000FF000000FF000000FF000000 00000000FF00000000000000FF00000000000000FF000000FF00000000000000 FF00000000000000FF000000FF000000FF000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000FF0000000000000000000000 + 0000000000000000000000000000000000000000FF000000FF000000FF000000 + FF000000FF000000FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000FF0000000000000000000000 FF000000FF00000000000000FF00000000000000FF000000FF00000000000000 FF000000000000000000000000000000FF000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000FF000000FF000000 + 0000000000000000000000000000000000000000FF000000FF000000FF000000 + FF000000FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00000000000000FF000000FF000000 FF000000FF00000000000000FF00000000000000FF000000FF00000000000000 FF00000000000000FF000000FF00000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000FF000000FF000000 + 0000000000000000000000000000000000000000FF000000FF000000FF000000 + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00000000000000FF000000FF000000 00000000FF00000000000000FF00000000000000FF000000FF00000000000000 FF00000000000000FF000000FF00000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000FF0000000000000000000000 + 0000000000000000000000000000000000000000FF000000FF000000FF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000FF0000000000000000000000 FF000000000000000000000000000000FF0000000000000000000000FF000000 FF000000000000000000000000000000FF000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000FF000000FF000000FF000000 + 0000000000000000000000000000000000000000FF000000FF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000FF000000FF000000FF000000 FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 FF000000FF000000FF000000FF000000FF000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000000000000FF00 + 0000000000000000000000000000000000000000FF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00000000000000000000000000FF00 0000FF000000FF000000FF000000FF0000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 @@ -1166,12 +1450,20 @@ object FormConfCellTCO: TFormConfCellTCO 0000000000000000000000000000000000008080000080800000808000008080 0000808000008080000080800000808000008080000080800000808000008080 000080800000808000008080000080800000424D3E000000000000003E000000 - 2800000040000000600000000100010000000000000300000000000000000000 + 2800000040000000800000000100010000000000000400000000000000000000 000000000000000000000000FFFFFF0000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000FFFFFFFFFFFF0000FFFFFFFFFFFF0000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F81FFFFF00000000E007FC3F0000 + 0000C003F81F00000000C001F00F000000008001F00F000000000180F00F0000 + 000003C0F00F0000000007E0F00F0000000007E0F00F0000000003C0F00F0000 + 00000180F00F000000008001F00F00000000C001F00F00000000C003F00F0000 + 0000F00FF81F00000000F81FFC3F0000FFFFFFFFFFFF0000FFFFFFFFFFFF0000 FFFFFFFFFFFF0000FFFFC0FFC1E00000FFFFC0FFC1E00000FFFFFFFFFFFF0000 FFFFFFFFFFFF00000000B6DBB6DB000000000000000000000000B6DBB6DB0000 00000000000000000000B6DBB6DB00000000FFFFFFFF00000000FFFFFFFF0000 @@ -1191,6 +1483,7 @@ object FormConfCellTCO: TFormConfCellTCO 0000FFFFFFFFF56F0000FFFFFFFFF56F0000C1C1FFFFF54F0000988C8866FB6F 0000F81F39A6FFFF0000F81F39A600000000C11F39A200000000871F39A40000 00008F1F886E000000008C8CFFFF00000000C1C1FFFF00000000FFFFFFFF0000 - 0000FFFFFFFF00000000FFFFFFFF0000} + 0000FFFFFFFF00000000FFFFFFFF000000000000000000000000000000000000 + 000000000000} end end diff --git a/UnitConfigCellTCO.pas b/UnitConfigCellTCO.pas index fc0f793..a456081 100644 --- a/UnitConfigCellTCO.pas +++ b/UnitConfigCellTCO.pas @@ -40,6 +40,9 @@ type ImageListIcones: TImageList; BitBtnOk: TBitBtn; BitBtnAnnule: TBitBtn; + GroupBoxCanton: TGroupBox; + LabelNumC: TLabel; + RadioGroupAlign: TRadioGroup; procedure EditAdrElementChange(Sender: TObject); procedure EditTexteCCTCOChange(Sender: TObject); procedure ButtonFonteClick(Sender: TObject); @@ -69,6 +72,7 @@ type procedure BitBtnAnnuleClick(Sender: TObject); procedure ListBoxActionKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure RadioGroupAlignClick(Sender: TObject); private { Déclarations privées } public @@ -106,80 +110,19 @@ uses UnitPrinc,UnitAnalyseSegCDM,UnitConfigTCO,UnitTCO; // procédure qui met la bd à jour, et réactualise la cellule, ce qui appelle "select elements" procedure stocke_bd; -var x,y,act : integer; +var Bim,x,y,act : integer; begin - act:=ligneclicAction+1; - x:=XClicCell[IndexTCOCourant]; y:=yClicCell[IndexTCOCourant]; - tco[IndexTCOCourant,X,Y].PiedFeu:=act; - efface_cellule(indexTCOCourant,PCanvasTCO[indexTCOcourant],x,y,pmcopy); - affiche_cellule(IndexTCOCourant,x,Y); - actualise(indexTCOCourant); - - - {case act of - // affiche TCO - ChangeTCO : + Bim:=tco[IndexTCOCourant,x,y].BImage; + if bim=Id_action then begin - x:=XClicCell[IndexTCOCourant]; - y:=yClicCell[IndexTCOCourant]; - tco[IndexTCOCourant,X,Y].PiedFeu:=ChangeTCO; + act:=ligneclicAction+1; + tco[IndexTCOCourant,X,Y].PiedFeu:=act; efface_cellule(indexTCOCourant,PCanvasTCO[indexTCOcourant],x,y,pmcopy); affiche_cellule(IndexTCOCourant,x,Y); actualise(indexTCOCourant); end; - // affiche SC - AffSC : begin - x:=XClicCell[IndexTCOCourant]; - y:=yClicCell[IndexTCOCourant]; - tco[IndexTCOCourant,X,Y].PiedFeu:=AffSC; - efface_cellule(indexTCOCourant,PCanvasTCO[indexTCOcourant],x,y,pmcopy); - affiche_cellule(IndexTCOCourant,x,Y); - actualise(indexTCOCourant); - end; - // affiche CDM - AffCDM : begin - x:=XClicCell[IndexTCOCourant]; - y:=yClicCell[IndexTCOCourant]; - tco[IndexTCOCourant,X,Y].PiedFeu:=AffCDM; - efface_cellule(indexTCOCourant,PCanvasTCO[indexTCOcourant],x,y,pmcopy); - affiche_cellule(IndexTCOCourant,x,Y); - actualise(indexTCOCourant); - end; - - // activer sortie - ActSortie : - begin - x:=XClicCell[IndexTCOCourant]; - y:=yClicCell[IndexTCOCourant]; - tco[IndexTCOCourant,x,y].PiedFeu:=ActSortie; - efface_cellule(indexTCOCourant,PCanvasTCO[indexTCOcourant],x,y,pmcopy); - affiche_cellule(IndexTCOCourant,x,y); - actualise(indexTCOCourant); - end; - - StopTrains : // Arret des trains - begin - x:=XClicCell[IndexTCOCourant]; - y:=yClicCell[IndexTCOCourant]; - tco[IndexTCOCourant,x,y].PiedFeu:=StopTrains; - efface_cellule(indexTCOCourant,PCanvasTCO[indexTCOcourant],x,y,pmcopy); - affiche_cellule(IndexTCOCourant,x,y); - actualise(indexTCOCourant); - end; - - Marche_Horloge : // démarre horloge - begin - x:=XClicCell[IndexTCOCourant]; - y:=yClicCell[IndexTCOCourant]; - tco[IndexTCOCourant,x,y].PiedFeu:=Marche_Horloge; - efface_cellule(indexTCOCourant,PCanvasTCO[indexTCOcourant],x,y,pmcopy); - affiche_cellule(IndexTCOCourant,x,y); - actualise(indexTCOCourant); - end; - - end; } end; @@ -249,14 +192,14 @@ end; // actualise le contenu de la fenetre et de la zone tco procedure actualise(indexTCO : integer); -var Bimage,oriente,piedFeu,act : integer; +var i,Bimage,oriente,piedFeu,act : integer; s : string; ip : Timage; r : trect; + sauvConfcellTCO : boolean; begin if (indexTCO=0) or (formConfCellTCO=nil) then exit; if affevt then affiche('FormConfigCellTCO actualise',clyellow); - xclicC:=XclicCell[indexTCO]; yclicC:=YclicCell[indexTCO]; @@ -274,21 +217,65 @@ begin begin Pen.Mode:=pmCopy; Pen.Width:=1; - Pen.color:=tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].CouleurFond; - Brush.Color:=tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].couleurFond; + Pen.color:=tco[indexTCO,XclicC,YclicC].CouleurFond; + Brush.Color:=tco[indexTCO,XclicC,YclicC].couleurFond; Brush.style:=bsSolid; fillRect(r); end; end; FormConfCellTCO.ImagePaletteCC.Repaint; - Bimage:=tco[indexTCO,XClicCell[indexTCO],YClicCell[indexTCO]].Bimage; + Bimage:=tco[indexTCO,XClicC,YClicC].Bimage; + + if isCanton(Bimage) then + begin + with formConfCellTCO do + begin + // ramener la coordonnée cliquée à l'origine du canton + if (Bimage>=Id_cantonH) and (Bimage<=Id_cantonH+9) then xClicC:=xClicC-(Bimage-Id_cantonH); + if (Bimage>=Id_cantonV) and (Bimage<=Id_cantonV+9) then yClicC:=yClicC-(Bimage-Id_cantonV); + XclicCell[indexTCO]:=XclicC; + YclicCell[indexTCO]:=YclicC; + + GroupBoxOrientation.visible:=false; + GroupBoxImplantation.visible:=false; + GroupBoxAction.Visible:=false; + with GroupBoxCanton do + begin + visible:=true; + left:=16; + top:=152; + width:=280; + height:=130; + EditTypeImage.Enabled:=false; + with RadioGroupAlign do + begin + ItemIndex:=TCO[indexTCO,Xclicc,YClicC].pont; // Alignement + if isCantonH(Bimage) then + begin + items[1]:='Aligné à gauche'; + items[2]:='Aligné à droite'; + end + else + begin + items[1]:='Aligné en haut'; + items[2]:='Aligné en bas'; + end; + end; + end; + end; + end + + else if Bimage=Id_Action then begin with formConfCellTCO do begin + EditTypeImage.Enabled:=true; GroupBoxOrientation.visible:=false; GroupBoxImplantation.visible:=false; + GroupBoxCanton.Visible:=false; + EditTypeImage.Enabled:=true; with GroupBoxAction do begin visible:=true; @@ -309,6 +296,7 @@ begin end; end else + begin with formConfCellTCO do begin @@ -318,19 +306,21 @@ begin left:=8; top:=152; end; + EditTypeImage.Enabled:=true; GroupBoxImplantation.visible:=true; GroupBoxAction.visible:=false; + GroupBoxCanton.Visible:=false; end; end; if (Bimage=1) or (Bimage=10) or (Bimage=11) or (Bimage=20) then begin - if tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].buttoir<>0 then + if tco[indexTCO,XclicC,YclicC].buttoir<>0 then begin formConfCellTCO.EditAdrElement.enabled:=false; formTCO[indexTCO].EditAdrElement.enabled:=false; - tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].Adresse:=0; + tco[indexTCO,XclicC,YclicC].Adresse:=0; end else begin @@ -354,9 +344,9 @@ begin with FormConfCellTCO.CheckPinv do begin enabled:=true; - checked:=TCO[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].inverse; + checked:=TCO[indexTCO,XclicC,YclicC].inverse; end; - FormTCO[indexTCO].CheckPinv.checked:=TCO[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].inverse; + FormTCO[indexTCO].CheckPinv.checked:=TCO[indexTCO,XclicC,YclicC].inverse; FormTCO[indexTCO].CheckPinv.enabled:=true ; end else @@ -369,7 +359,7 @@ begin // si voie ou rien ou signal ou quai if (Bimage=1) or (Bimage=0) or (Bimage=Id_signal) or (Bimage=Id_Quai) then begin - s:=Tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].Texte; + s:=Tco[indexTCO,XclicC,YclicC].Texte; with formTCO[indexTCO] do begin EditTexte.Text:=s; @@ -384,24 +374,26 @@ begin end; s:=IntToSTR(XclicC)+','+intToSTR(yClicC); + sauvConfcellTCO:=ConfcellTCO; + ConfCellTCO:=false; FormTCO[indexTCO].GroupBox1.Caption:='Configuration cellule '+s; - XclicCellInserer:=XclicCell[indexTCO]; - YclicCellInserer:=YclicCell[indexTCO]; + XclicCellInserer:=XclicC; + YclicCellInserer:=YclicC; FormTCO[indexTCO].EditAdrElement.Text:=IntToSTR(tco[indexTCO,XclicCellInserer,YclicCellInserer].Adresse); FormTCO[indexTCO].EdittypeImage.Text:=IntToSTR(BImage); - FormTCO[indexTCO].ComboRepr.ItemIndex:=tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].repr; - FormTCO[indexTCO].ShapeCoulFond.Brush.Color:=tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].CouleurFond; - FormTCO[indexTCO].CheckPinv.Checked:=tco[indextco,XclicCell[indexTCO],YclicCell[indexTCO]].inverse; - - s:='El='+intToSTR(tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].BImage); - if tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].adresse<>0 then s:=s+' Adr='+intToSTR(tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].adresse); + FormTCO[indexTCO].ComboRepr.ItemIndex:=tco[indexTCO,XclicC,YclicC].repr; + FormTCO[indexTCO].ShapeCoulFond.Brush.Color:=tco[indexTCO,XclicC,YclicC].CouleurFond; + FormTCO[indexTCO].CheckPinv.Checked:=tco[indextco,XclicC,YclicC].inverse; + confCellTCO:=sauvConfcellTCO; + s:='El='+intToSTR(tco[indexTCO,XclicC,YclicC].BImage); + if tco[indexTCO,Xclic,Yclic].adresse<>0 then s:=s+' Adr='+intToSTR(tco[indexTCO,XclicC,YclicC].adresse); //hint:=s; if not(ConfCellTCO) then exit; actualize:=true; // évite les évènements parasites - FormConfCellTCO.caption:='Propriétés de la cellule '+IntToSTR(XclicCell[indexTCO])+','+intToSTR(YclicCell[indexTCO])+' TCO '+intToSTR(IndexTCO); - Bimage:=tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].Bimage; + FormConfCellTCO.caption:='Propriétés de la cellule '+IntToSTR(XclicC)+','+intToSTR(YclicC)+' TCO '+intToSTR(IndexTCO); + Bimage:=tco[indexTCO,XclicC,YclicC].Bimage; formConfCellTCO.EditTypeImage.Text:=intToSTR(Bimage); // si signal @@ -411,6 +403,7 @@ begin //Height:=FormTCO.ImagePalette1.Picture.Height; //Width:=FormTCO.ImagePalette1.Picture.Width; Transparent:=false; + FormConfCellTCO.LabelNumC.visible:=false; end; // si pas signal @@ -423,7 +416,7 @@ begin RadioButtonHD.Enabled:=false; RadioButtonG.Enabled:=false; RadioButtonD.Enabled:=false; - + LabelNumC.visible:=false; ImagePaletteCC.transparent:=false; end; @@ -440,85 +433,83 @@ begin RadioButtonD.Enabled:=false; end; end - else - // Bimage non nulle begin ip:=formTCO[indexTCO].findComponent('ImagePalette'+intToSTR(Bimage)) as Timage; - if ip=nil then exit; - - // affiche l'icone cliquée dans la fenetre ----------------------------------------------- - // pour que le stretchBlt soit visible, il faut mettre à jour la taille du bitmap - with FormConfCellTCO.ImagePaletteCC.Picture.Bitmap do + if ip<>nil then begin - width:=iconeX; - Height:=iconeY; - end; - - StretchBlt(FormConfCellTCO.ImagePaletteCC.canvas.Handle,0,0,iconeX,iconeY, // destination - formTCO[indexTCO].ImageTCO.Canvas.Handle,(XclicCell[indexTCO]-1)*largeurCell[indexTCO] ,(YclicCell[indexTCO]-1)*Hauteurcell[indexTCO],largeurCell[indexTCO],Hauteurcell[indexTCO],srccopy); // source } - - FormConfCellTCO.ImagePaletteCC.repaint; // obligatoire sinon il ne s'affiche pas - //----------------------------------------------------------------------------------------- - - if Bimage=Id_signal then - begin // signal - With formConfCellTCO.ImagePaletteCC do + // affiche l'icone cliquée dans la fenetre ----------------------------------------------- + // pour que le stretchBlt soit visible, il faut mettre à jour la taille du bitmap + with FormConfCellTCO.ImagePaletteCC.Picture.Bitmap do begin - // Height:=FormTCO.ImagePalette50.Height; - // Width:=FormTCO.ImagePalette50.Width; - //Picture.Assign(FormTCO.ImagePalette50.Picture); - Picture.Bitmap.TransparentMode:=tmAuto; - Picture.Bitmap.TransparentColor:=clblue; - Transparent:=true; + width:=iconeX; + Height:=iconeY; end; - with formconfCellTCO do - begin - RadioButtonV.Enabled:=true; - RadioButtonV180.Enabled:=true; - RadioButtonHG.Enabled:=true; - RadioButtonHD.Enabled:=true; - RadioButtonG.Enabled:=true; - RadioButtonD.Enabled:=true; - oriente:=tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].Feuoriente; - case oriente of - 1: begin - RadioButtonV.checked:=true; - RadioButtonV180.checked:=false; - RadioButtonHG.checked:=false; - RadioButtonHD.checked:=false; - end; - 2: begin - RadioButtonV.checked:=false; - RadioButtonV180.checked:=false; - RadioButtonHG.checked:=true; - RadioButtonHD.checked:=false; - end; - 3: begin - RadioButtonV.checked:=false; - RadioButtonV180.checked:=false; - RadioButtonHG.checked:=false; - RadioButtonHD.checked:=true; - end; - 4: begin - RadioButtonV.checked:=false; - RadioButtonV180.checked:=true; - RadioButtonHG.checked:=false; - RadioButtonHD.checked:=false; - end; - end; + StretchBlt(FormConfCellTCO.ImagePaletteCC.canvas.Handle,0,0,iconeX,iconeY, // destination + formTCO[indexTCO].ImageTCO.Canvas.Handle,(XclicC-1)*largeurCell[indexTCO] ,(YclicC-1)*Hauteurcell[indexTCO],largeurCell[indexTCO],Hauteurcell[indexTCO],srccopy); // source } - PiedFeu:=tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].PiedFeu; - if PiedFeu=1 then + FormConfCellTCO.ImagePaletteCC.repaint; // obligatoire sinon il ne s'affiche pas + //----------------------------------------------------------------------------------------- + + if Bimage=Id_signal then + begin // signal + With formConfCellTCO.ImagePaletteCC do begin - RadioButtonG.checked:=true; - RadioButtonD.checked:=false; + // Height:=FormTCO.ImagePalette50.Height; + // Width:=FormTCO.ImagePalette50.Width; + //Picture.Assign(FormTCO.ImagePalette50.Picture); + Picture.Bitmap.TransparentMode:=tmAuto; + Picture.Bitmap.TransparentColor:=clblue; + Transparent:=true; end; - if PiedFeu=2 then + with formconfCellTCO do begin - RadioButtonG.checked:=false; - RadioButtonD.checked:=true; + RadioButtonV.Enabled:=true; + RadioButtonV180.Enabled:=true; + RadioButtonHG.Enabled:=true; + RadioButtonHD.Enabled:=true; + RadioButtonG.Enabled:=true; + RadioButtonD.Enabled:=true; + oriente:=tco[indexTCO,XclicC,YclicC].Feuoriente; + case oriente of + 1: begin + RadioButtonV.checked:=true; + RadioButtonV180.checked:=false; + RadioButtonHG.checked:=false; + RadioButtonHD.checked:=false; + end; + 2: begin + RadioButtonV.checked:=false; + RadioButtonV180.checked:=false; + RadioButtonHG.checked:=true; + RadioButtonHD.checked:=false; + end; + 3: begin + RadioButtonV.checked:=false; + RadioButtonV180.checked:=false; + RadioButtonHG.checked:=false; + RadioButtonHD.checked:=true; + end; + 4: begin + RadioButtonV.checked:=false; + RadioButtonV180.checked:=true; + RadioButtonHG.checked:=false; + RadioButtonHD.checked:=false; + end; + end; + + PiedFeu:=tco[indexTCO,XclicC,YclicC].PiedFeu; + if PiedFeu=1 then + begin + RadioButtonG.checked:=true; + RadioButtonD.checked:=false; + end; + if PiedFeu=2 then + begin + RadioButtonG.checked:=false; + RadioButtonD.checked:=true; + end; end; end; end; @@ -531,9 +522,9 @@ begin with formConfCellTCO do begin - EditTexteCCTCO.Text:=tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].Texte; + EditTexteCCTCO.Text:=tco[indexTCO,xclicC,yclicC].Texte; EditAdrElement.Text:=IntToSTR(tco[indexTCO,XclicCellInserer,YclicCellInserer].Adresse); - ComboRepr.ItemIndex:=tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].repr; + ComboRepr.ItemIndex:=tco[indexTCO,XclicC,YclicC].repr; end; // Epaisseur ou pont @@ -551,6 +542,17 @@ begin FormConfCellTCO.RadioGroupSel.Items[1]:='Buttoir'; end; + if isCanton(Bimage) then + begin + FormConfCellTCO.LabelNumC.visible:=true; + if (Bimage=Id_cantonV) or (Bimage=Id_cantonH) then + begin + i:=index_canton(indexTCO,xclicC,yclicC); + if i>0 then FormConfCellTCO.LabelNumC.caption:='Canton n°'+intToSTR(canton[i].numero) + end + else FormConfCellTCO.LabelNumC.caption:='Elément de canton'; + end; + actualize:=false; end; @@ -599,19 +601,32 @@ begin end; procedure TFormConfCellTCO.EditTexteCCTCOChange(Sender: TObject); +var i,El,x,y : integer; begin if clicTCO or not(ConfCellTCO) or actualize then exit; PCanvasTCO[indexTCOCourant].Brush.Color:=clfond[indexTCOCourant]; - - if tco[indexTCOCourant,XclicCell[indexTCOCourant],YclicCell[indexTCOCourant]].texte='' then + x:=XclicCell[indexTCOCourant]; + y:=YclicCell[indexTCOCourant]; + if tco[indexTCOCourant,x,y].texte='' then begin - tco[indexTCOCourant,XclicCell[indexTCOCourant],YclicCell[indexTCOCourant]].CoulFonte:=clTexte; - tco[indexTCOCourant,XclicCell[indexTCOCourant],YclicCell[indexTCOCourant]].TailleFonte:=8; + tco[indexTCOCourant,x,y].CoulFonte:=clTexte; + tco[indexTCOCourant,x,y].TailleFonte:=8; end; - tco[indexTCOCourant,XclicCell[indexTCOCourant],YclicCell[indexTCOCourant]].Texte:=EditTexteCCTCO.Text; + tco[indexTCOCourant,x,y].Texte:=EditTexteCCTCO.Text; if not(clicTCO) then TCO_modifie:=true; if not(selectionaffichee[indexTCOcourant]) then efface_entoure(indexTCOCourant); - affiche_texte(indexTCOCourant,XclicCell[indexTCOCourant],YclicCell[indexTCOCourant]); + + El:=Tco[indexTCOCourant,x,y].BImage; + if isCanton(El) then + begin + i:=Index_canton(indexTCOCourant,x,y); + if i=0 then exit; + canton[i].nom:=EditTexteCCTCO.Text; + Dessin_canton(indexTCOCourant,PcanvasTCO[indexTCOCourant],x,y,0,0); + end + else + affiche_texte(indexTCOCourant,x,y); + formTCO[indexTCOCourant].EditTexte.Text:=EditTexteCCTCO.text; if not(selectionaffichee[indexTCOcourant]) then _entoure_cell_clic(indexTCOCourant); end; @@ -783,6 +798,7 @@ begin if affevt then Affiche('BitBtnOk',clyellow); stocke_bd; ConfCellTCO:=false; + Affiche_TCO(indexTCOcourant); close; end; @@ -1095,10 +1111,14 @@ begin end; end; +procedure TFormConfCellTCO.RadioGroupAlignClick(Sender: TObject); +var idc : integer; +begin + TCO[indexTCOCourant,XclicCell[indexTCOcourant],YclicCell[indexTCOcourant]].pont:=RadiogroupAlign.ItemIndex; + idc:=TCO[indexTCOCourant,XclicCell[indexTCOcourant],YclicCell[indexTCOcourant]].PiedFeu; + if (idc>0) and (idc<=ncantons) then dessin_canton(IdC,0,0); - - - +end; end. diff --git a/UnitFicheHoraire.pas b/UnitFicheHoraire.pas index f4d2d11..1716f31 100644 --- a/UnitFicheHoraire.pas +++ b/UnitFicheHoraire.pas @@ -28,6 +28,7 @@ const var FormFicheHoraire: TFormFicheHoraire; + Nombre_horaires : integer; GrilleHoraire : Array[1..MaxHoraire] of record NomTrain : string ; @@ -208,6 +209,7 @@ begin end; end; until eof(f) or (ligne>MaxHoraire); + Nombre_horaires:=ligne-1; closefile(f); couleurs_Fiche; diff --git a/UnitHorloge.dfm b/UnitHorloge.dfm index e9052a1..53b40c9 100644 --- a/UnitHorloge.dfm +++ b/UnitHorloge.dfm @@ -362,7 +362,7 @@ object FormHorloge: TFormHorloge object LabelErreur: TLabel Left = 288 Top = 192 - Width = 113 + Width = 3 Height = 13 Caption = '.' end diff --git a/UnitHorloge.pas b/UnitHorloge.pas index 450a930..460f619 100644 --- a/UnitHorloge.pas +++ b/UnitHorloge.pas @@ -67,7 +67,7 @@ procedure Demarre_horloge; implementation -uses unitconfig, UnitClock; +uses unitconfig, UnitClock, UnitFicheHoraire; {$R *.dfm} @@ -144,12 +144,18 @@ begin end; procedure Init_Horloge; +var i : integer; begin heure:=HeureInit; minute:=MinuteInit; seconde:=0; if clock<>nil then clock.DrawArrows; FormPrinc.labelClock.Caption:=format('%.2dh%.2d:%.2d',[heure,minute,seconde] ); + if formFicheHoraire<>nil then + begin + for i:=1 to Nombre_horaires do + FormFicheHoraire.StringGridFO.Cells[1,i]:=GrilleHoraire[i].NomTrain; + end; end; procedure TFormHorloge.ButtonInitClick(Sender: TObject); diff --git a/UnitModifAction.dfm b/UnitModifAction.dfm index 1e02561..7e21da1 100644 --- a/UnitModifAction.dfm +++ b/UnitModifAction.dfm @@ -1,6 +1,6 @@ object FormModifAction: TFormModifAction - Left = 309 - Top = 112 + Left = 311 + Top = 157 BorderStyle = bsDialog Caption = 'Modifier une action' ClientHeight = 443 @@ -33,7 +33,7 @@ object FormModifAction: TFormModifAction object LabelInfo: TLabel Left = 316 Top = 416 - Width = 237 + Width = 3 Height = 13 end object ButtonOk: TButton @@ -60,7 +60,7 @@ object FormModifAction: TFormModifAction Top = 64 Width = 729 Height = 337 - ActivePage = TabSheetOp + ActivePage = TabSheet1 MultiLine = True TabOrder = 2 object TabSheetDecl: TTabSheet @@ -79,10 +79,10 @@ object FormModifAction: TFormModifAction ParentFont = False end object ListBoxDeclench: TListBox - Left = 16 + Left = 0 Top = 60 - Width = 185 - Height = 185 + Width = 201 + Height = 189 ItemHeight = 13 TabOrder = 0 OnDrawItem = ListBoxDeclenchDrawItem @@ -100,6 +100,7 @@ object FormModifAction: TFormModifAction Width = 38 Height = 13 Caption = 'Adresse' + WordWrap = True end object LabelTrain: TLabel Left = 8 @@ -171,30 +172,253 @@ object FormModifAction: TFormModifAction Value = 0 OnChange = SpinEditEtatChange end + object RadioEtatSignal: TRadioGroup + Left = 152 + Top = 24 + Width = 433 + Height = 73 + Caption = 'Etat de changements du signal' + Items.Strings = ( + 'Ouverture inconditionnelle du signal (quitte le rouge)' + + 'Ouverture du signal sur VL (passage au vert, vert cli, blanc, bl' + + 'anc cli)' + + 'Ouverture restreinte du signal (passage '#224' l'#39'avertissement, ralen' + + ' ou rappel)' + 'Fermeture du signal (passage au carr'#233', s'#233'maphore,violet)') + TabOrder = 4 + OnClick = RadioEtatSignalClick + end end object RichEditInf: TRichEdit Left = 224 Top = 216 Width = 481 - Height = 49 + Height = 65 + ReadOnly = True TabOrder = 2 end object ButtonApplDecl: TButton Left = 16 - Top = 256 + Top = 276 Width = 75 Height = 25 Hint = 'Application du d'#233'clencheur '#224' l'#39'action s'#233'lectionn'#233'e' - Caption = 'Appliquer' + Caption = 'Appliquer >>>' ParentShowHint = False ShowHint = True TabOrder = 3 OnClick = ButtonApplDeclClick end end + object TabSheet1: TTabSheet + Caption = 'Conditions' + ImageIndex = 1 + object Label4: TLabel + Left = 16 + Top = 24 + Width = 169 + Height = 13 + Caption = 'Liste de conditions diponibles' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [fsBold] + ParentFont = False + end + object Shape2: TShape + Left = 216 + Top = 8 + Width = 3 + Height = 293 + Brush.Color = clBlack + end + object Label6: TLabel + Left = 258 + Top = 8 + Width = 118 + Height = 13 + Caption = 'Condition '#224' observer' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [fsBold] + ParentFont = False + end + object ListBoxCondTot: TListBox + Left = 0 + Top = 60 + Width = 201 + Height = 185 + ItemHeight = 13 + TabOrder = 0 + OnDrawItem = ListBoxCondTotDrawItem + end + object ListBoxConditions: TListBox + Left = 232 + Top = 28 + Width = 217 + Height = 201 + Hint = 'Condition de r'#233'alisation du d'#233'clencheur' + ItemHeight = 13 + ParentShowHint = False + ShowHint = True + TabOrder = 1 + OnDrawItem = ListBoxConditionsDrawItem + OnMouseDown = ListBoxConditionsMouseDown + end + object GroupBox1: TGroupBox + Left = 464 + Top = 24 + Width = 249 + Height = 265 + Caption = 'Param'#232'tres de la condition' + TabOrder = 2 + object LabelHeureDebut: TLabel + Left = 8 + Top = 86 + Width = 74 + Height = 13 + Caption = 'Heure de d'#233'but' + end + object LabelHeureFin: TLabel + Left = 8 + Top = 104 + Width = 58 + Height = 13 + Caption = 'Heure de fin' + end + object LabelEtat2: TLabel + Left = 8 + Top = 136 + Width = 19 + Height = 13 + Caption = 'Etat' + end + object ChampTrain: TLabeledEdit + Left = 24 + Top = 184 + Width = 161 + Height = 21 + Hint = 'train' + EditLabel.Width = 24 + EditLabel.Height = 13 + EditLabel.Caption = 'Train' + ParentShowHint = False + ShowHint = True + TabOrder = 0 + OnChange = ChampTrainChange + end + object Champ1: TLabeledEdit + Left = 64 + Top = 40 + Width = 41 + Height = 21 + EditLabel.Width = 38 + EditLabel.Height = 13 + EditLabel.Caption = 'Adresse' + EditLabel.WordWrap = True + LabelPosition = lpLeft + LabelSpacing = 10 + ParentShowHint = False + ShowHint = True + TabOrder = 1 + OnChange = Champ1Change + end + object Champ2: TLabeledEdit + Left = 176 + Top = 40 + Width = 41 + Height = 21 + EditLabel.Width = 39 + EditLabel.Height = 13 + EditLabel.Caption = 'Champ2' + LabelPosition = lpLeft + LabelSpacing = 10 + ParentShowHint = False + ShowHint = True + TabOrder = 2 + OnChange = Champ2Change + end + object SpinEditHeure1: TSpinEdit + Left = 96 + Top = 80 + Width = 41 + Height = 22 + MaxValue = 23 + MinValue = 0 + TabOrder = 3 + Value = 0 + OnChange = SpinEditHeure1Change + end + object SpinEditMn1: TSpinEdit + Left = 160 + Top = 80 + Width = 41 + Height = 22 + MaxValue = 59 + MinValue = 0 + TabOrder = 4 + Value = 0 + OnChange = SpinEditMn1Change + end + object SpinEditHeure2: TSpinEdit + Left = 96 + Top = 104 + Width = 41 + Height = 22 + MaxValue = 23 + MinValue = 0 + TabOrder = 5 + Value = 0 + OnChange = SpinEditHeure2Change + end + object SpinEditMn2: TSpinEdit + Left = 160 + Top = 104 + Width = 41 + Height = 22 + MaxValue = 59 + MinValue = 0 + TabOrder = 6 + Value = 0 + OnChange = SpinEditMn2Change + end + object SpinEditEtat2: TSpinEdit + Left = 96 + Top = 136 + Width = 33 + Height = 22 + MaxValue = 0 + MinValue = 0 + ParentShowHint = False + ShowHint = True + TabOrder = 7 + Value = 0 + OnChange = SpinEditEtat2Change + end + end + object ButtonAppCond: TButton + Left = 16 + Top = 276 + Width = 75 + Height = 25 + Hint = + 'Mise '#224' jour du champ de conditions vers le champ de la liste de' + + 's conditions '#224' observer' + Caption = 'Appliquer >>>' + ParentShowHint = False + ShowHint = True + TabOrder = 3 + OnClick = ButtonAppCondClick + end + end object TabSheetOp: TTabSheet Caption = 'Op'#233'rations' - ImageIndex = 1 + ImageIndex = 2 object Shape1: TShape Left = 216 Top = 8 @@ -216,11 +440,17 @@ object FormModifAction: TFormModifAction ParentFont = False end object Label2: TLabel - Left = 32 + Left = 16 Top = 8 - Width = 67 + Width = 168 Height = 13 - Caption = 'Liste d'#39'actions' + Caption = 'Liste d'#39'op'#233'rations disponibles' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [fsBold] + ParentFont = False end object SpeedButtonSupprime: TSpeedButton Left = 338 @@ -251,17 +481,17 @@ object FormModifAction: TFormModifAction object ComboBoxFamille: TComboBox Left = 0 Top = 32 - Width = 209 + Width = 201 Height = 21 - ItemHeight = 13 + ItemHeight = 0 TabOrder = 0 OnChange = ComboBoxFamilleChange end object ListBoxOper: TListBox Left = 0 - Top = 64 + Top = 60 Width = 201 - Height = 193 + Height = 185 Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 @@ -288,7 +518,7 @@ object FormModifAction: TFormModifAction end object GroupBoxParam: TGroupBox Left = 464 - Top = 32 + Top = 24 Width = 249 Height = 265 Caption = 'Param'#232'tres de l'#39'op'#233'ration' @@ -389,6 +619,13 @@ object FormModifAction: TFormModifAction Height = 13 Caption = 'P'#233'riph'#233'rique:' end + object LabelEtatOp: TLabel + Left = 128 + Top = 36 + Width = 19 + Height = 13 + Caption = 'Etat' + end object LabeledEditTrain: TLabeledEdit Left = 24 Top = 184 @@ -429,26 +666,13 @@ object FormModifAction: TFormModifAction TabOrder = 2 OnChange = LabeledEditFonctionFChange end - object LabeledEditEtat: TLabeledEdit - Left = 144 - Top = 32 - Width = 25 - Height = 21 - EditLabel.Width = 19 - EditLabel.Height = 13 - EditLabel.Caption = 'Etat' - LabelPosition = lpLeft - LabelSpacing = 10 - TabOrder = 3 - OnChange = LabeledEditEtatChange - end object CheckBoxRAZ: TCheckBox Left = 24 Top = 104 Width = 145 Height = 17 Caption = 'Remise '#224' 0 apr'#232's pilotage' - TabOrder = 4 + TabOrder = 3 OnClick = CheckBoxRAZClick end object ComboBoxAccComUSB: TComboBox @@ -458,10 +682,10 @@ object FormModifAction: TFormModifAction Height = 21 Hint = 'Nom de l'#39'accessoire d'#233'fini dans l'#39'onglet "p'#233'riph'#233'riques COM/USB"' Style = csDropDownList - ItemHeight = 13 + ItemHeight = 0 ParentShowHint = False ShowHint = True - TabOrder = 5 + TabOrder = 4 OnChange = ComboBoxAccComUSBChange end object LabeledEditTempoF: TLabeledEdit @@ -474,9 +698,22 @@ object FormModifAction: TFormModifAction EditLabel.Caption = 'Tempo x100ms' LabelPosition = lpLeft LabelSpacing = 10 - TabOrder = 6 + TabOrder = 5 OnChange = LabeledEditTempoFChange end + object SpinEditEtatop: TSpinEdit + Left = 152 + Top = 32 + Width = 33 + Height = 22 + MaxValue = 0 + MinValue = 0 + ParentShowHint = False + ShowHint = True + TabOrder = 6 + Value = 0 + OnChange = SpinEditEtatopChange + end end object ButtonAjouter: TButton Left = 128 @@ -545,11 +782,14 @@ object FormModifAction: TFormModifAction Top = 36 Width = 225 Height = 21 + Hint = 'Nom de l'#39'action au choix' EditLabel.Width = 73 EditLabel.Height = 13 EditLabel.Caption = 'Nom de l'#39'action' LabelPosition = lpLeft LabelSpacing = 5 + ParentShowHint = False + ShowHint = True TabOrder = 3 OnChange = LabeledEditNomActChange end diff --git a/UnitModifAction.pas b/UnitModifAction.pas index 095003c..02c4c77 100644 --- a/UnitModifAction.pas +++ b/UnitModifAction.pas @@ -41,7 +41,6 @@ type SpeedButtonJoue: TSpeedButton; LabeledEditAdresse: TLabeledEdit; LabeledEditFonctionF: TLabeledEdit; - LabeledEditEtat: TLabeledEdit; CheckBoxRAZ: TCheckBox; Label5: TLabel; RichEditInf: TRichEdit; @@ -53,6 +52,28 @@ type ImageIcone: TImage; LabelPeriph: TLabel; LabelInfo: TLabel; + TabSheet1: TTabSheet; + Label4: TLabel; + ListBoxCondTot: TListBox; + Shape2: TShape; + Label6: TLabel; + ListBoxConditions: TListBox; + GroupBox1: TGroupBox; + ChampTrain: TLabeledEdit; + Champ1: TLabeledEdit; + Champ2: TLabeledEdit; + ButtonAppCond: TButton; + SpinEditHeure1: TSpinEdit; + SpinEditMn1: TSpinEdit; + SpinEditHeure2: TSpinEdit; + SpinEditMn2: TSpinEdit; + LabelHeureDebut: TLabel; + LabelHeureFin: TLabel; + SpinEditEtat2: TSpinEdit; + LabelEtat2: TLabel; + RadioEtatSignal: TRadioGroup; + SpinEditEtatop: TSpinEdit; + LabelEtatOp: TLabel; procedure ButtonOkClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ListBoxOperDrawItem(Control: TWinControl; Index: Integer; @@ -81,12 +102,28 @@ type procedure SpeedButtonJoueClick(Sender: TObject); procedure SpeedButtonChargerClick(Sender: TObject); procedure CheckBoxRAZClick(Sender: TObject); - procedure LabeledEditEtatChange(Sender: TObject); procedure ButtonApplDeclClick(Sender: TObject); procedure LabeledEditNomActChange(Sender: TObject); procedure ComboBoxAccComUSBChange(Sender: TObject); procedure LabeledEditTempoFChange(Sender: TObject); procedure ListBoxOperationsDblClick(Sender: TObject); + procedure ListBoxCondTotDrawItem(Control: TWinControl; Index: Integer; + Rect: TRect; State: TOwnerDrawState); + procedure ListBoxConditionsMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + procedure ListBoxConditionsDrawItem(Control: TWinControl; + Index: Integer; Rect: TRect; State: TOwnerDrawState); + procedure ButtonAppCondClick(Sender: TObject); + procedure Champ1Change(Sender: TObject); + procedure Champ2Change(Sender: TObject); + procedure SpinEditHeure1Change(Sender: TObject); + procedure SpinEditMn1Change(Sender: TObject); + procedure SpinEditHeure2Change(Sender: TObject); + procedure SpinEditMn2Change(Sender: TObject); + procedure ChampTrainChange(Sender: TObject); + procedure SpinEditEtat2Change(Sender: TObject); + procedure RadioEtatSignalClick(Sender: TObject); + procedure SpinEditEtatopChange(Sender: TObject); private { Déclarations privées } public @@ -96,7 +133,7 @@ type var FormModifAction: TFormModifAction; AffParam : boolean; - ClicDeclenche,ClicAction,DeclencheurAffiche,OperationAffiche : integer; + ClicDeclenche,ClicAction,ClicCond,DeclencheurAffiche,OperationAffiche : integer; function Info_action(i : integer) : string; @@ -113,6 +150,7 @@ procedure efface_tous_parametres; begin with FormModifAction do begin + RadioEtatSignal.Visible:=false; LabelAdresse.Visible:=false; SpinEditEtat.Visible:=false; EditAdr.visible:=false; @@ -128,11 +166,23 @@ begin SpeedButtonCharger.visible:=false; LabeledEditFonctionF.Visible:=false; LabeledEditAdresse.Visible:=false; - LabeledEditEtat.visible:=false; + SpinEditEtatop.Visible:=false; checkBoxRaz.Visible:=false; GroupBoxParam.Visible:=true; + labelEtatOp.Visible:=false; RichEditInf.clear; ComboBoxAccComUSB.visible:=false; + Champ1.Visible:=false; + Champ2.Visible:=false; + LabelHeureDebut.Visible:=false; + LabelHeureFin.Visible:=false; + SpinEditHeure1.visible:=false; + SpinEditMn1.visible:=false; + SpinEditHeure2.visible:=false; + SpinEditMn2.visible:=false; + LabelEtat2.Visible:=false; + SpinEditEtat2.Visible:=false; + ChampTrain.Visible:=false; end; end; @@ -143,11 +193,30 @@ begin ListBoxOper.Style:=lbOwnerDrawVariable; // pour afficher des icones ListBoxDeclench.Style:=lbOwnerDrawVariable; ListBoxOperations.Style:=lbOwnerDrawVariable; + ListBoxCondTot.Style:=lbOwnerDrawVariable; + ListBoxConditions.Style:=lbOwnerDrawVariable; + for i:=1 to NbreOperations do begin ListBoxOper.Items.Add(Format('%d%s', [i-1, operations[i].nom])); // valeur d'index de l'icone dans la ImagelistIcones ListBoxOper.itemHeight:=17; // 16 mini taille des éléments pour l'icone end; + + for i:=1 to NbreConditions do + begin + icone:=0; + case i of + CondVrai : icone:=iconeVrai; + CondFaux : icone:=iconeFaux; + CondVitTrain : icone:=IconeVitTrain; + CondPosAcc : icone:=IconeAccessoire; + condHorl : icone:=IconeLanceHorl; + condTrainSig : icone:=IconeDeclSignal; + end; + ListBoxCondTot.Items.Add(Format('%d%s', [icone, Conditions[i].nom])); // valeur d'index de l'icone dans la ImagelistIcones + ListBoxCondTot.itemHeight:=17; // 16 mini taille des éléments pour l'icone + end; + for i:=1 to NbreDeclencheurs do begin icone:=0; @@ -157,6 +226,9 @@ begin DeclAccessoire: icone:=IconeAccessoire; DeclDetAct: icone:=IconeDet; DeclZoneDet: icone:=IconeZoneDet; + DeclDemarTrain : icone:=IconeDemarTrain; + DeclArretTrain : icone:=IconeArretTrain; + DeclSignal : icone:=IconeSignal; end; ListBoxDeclench.Items.Add(Format('%d%s', [icone, declencheurs[i].nom])); // valeur d'index de l'icone dans la ImagelistIcones ListBoxDeclench.itemHeight:=17; @@ -171,11 +243,8 @@ begin itemIndex:=0; end; - EdittrainDecl.Hint:='Train(s) déclencheur(s) séparés par des virgules pour lesquels la condition s''applique.' - +#13+'Mettre X pour tous les trains.'+#13+'Déclenchement par actionneur uniquement'; - ListBoxOperations.Hint:='Liste chronologique des opérations à effectuer'+#13+ - 'Double clic pour valider/dévalider une action'; + 'Double clic pour valider/dévalider une opération'; Efface_tous_parametres; PageControlAct.ActivePage:=TabSheetDecl; @@ -262,32 +331,59 @@ begin s:='Le déclencheur '; case decl of DeclHorloge : - begin // affiche XX - s:=s+'Horloge à '+format('%.2d',[Tablo_Actionneur[i].heure])+'h'+format('%.2d',[Tablo_Actionneur[i].minute]); - end; + s:=s+'horloge à '+format('%.2d',[Tablo_Actionneur[i].heure])+'h'+format('%.2d',[Tablo_Actionneur[i].minute]); DeclPeriph : - begin - s:=s+'Périphérique : '+Tablo_Actionneur[i].ordrePeriph; - end; + s:=s+'périphérique : '+Tablo_Actionneur[i].ordrePeriph; DeclAccessoire : - begin - s:=s+'Accessoire '+intToSTR(Tablo_Actionneur[i].adresse); - end; + s:=s+'accessoire '+intToSTR(Tablo_Actionneur[i].adresse); DeclDetAct : - begin - s:=s+'Détecteur/Actionneur '+intToSTR(Tablo_Actionneur[i].adresse); - s:=s+' par le train "'+Tablo_Actionneur[i].trainDecl+'"'; - end; + begin + s:=s+'détecteur/Actionneur '+intToSTR(Tablo_Actionneur[i].adresse); + s:=s+' par le train "'+Tablo_Actionneur[i].trainDecl+'"'; + end; DeclZoneDet : + s:=s+'Zone détection '+intToSTR(Tablo_Actionneur[i].adresse)+' '+intToSTR(Tablo_Actionneur[i].adresse2); + DeclDemarTrain : + s:=s+'démarrage du train '+Tablo_Actionneur[i].trainDecl+' au seuil de '+intToSTR(Tablo_Actionneur[i].adresse); + DeclArretTrain : + s:=s+'arrêt du train '+Tablo_Actionneur[i].trainDecl+' au seuil de '+intToSTR(Tablo_Actionneur[i].adresse); + DeclSignal : begin - s:=s+'Zone détection '+intToSTR(Tablo_Actionneur[i].adresse)+' '+intToSTR(Tablo_Actionneur[i].adresse2); - end; + s:=s+'changement du signal '+intToSTR(Tablo_Actionneur[i].adresse); + case Tablo_Actionneur[i].etat of + 0 : s:=s+' sur ouverture'; + 1 : s:=s+' sur voie libre'; + 2 : s:=s+' sur ouverture restreinte'; + 3 : s:=s+' sur fermeture'; + end; + end; end; + + // conditions + s:=s+#13; + nop:=tablo_actionneur[i].NbCond; + for op:=1 to nop do + begin + s:=s+'condition '; + top:=tablo_actionneur[i].tabloCond[op].numcondition; + case top of + CondVrai : s:=s+'toujours vraie '; + CondFaux : s:=s+'toujours fausse '; + CondVitTrain : s:=s+'vitesse train '+tablo_actionneur[i].tabloCond[op].train+' '+intToSTR(tablo_actionneur[i].tabloCond[op].vitmini)+ + ' '+intToSTR(tablo_actionneur[i].tabloCond[op].vitMaxi); + CondPosAcc : s:=s+' position d''accessoire '+intToSTR(tablo_actionneur[i].tabloCond[op].accessoire)+' état '+intToSTR(tablo_actionneur[i].tabloCond[op].etat); + CondHorl : s:=s+' horloge '+intToSTR(tablo_actionneur[i].tabloCond[op].HeureMin)+'h'+intToSTR(tablo_actionneur[i].tabloCond[op].MinuteMin)+' à '+ + intToSTR(tablo_actionneur[i].tabloCond[op].HeureMax)+'h'+intToSTR(tablo_actionneur[i].tabloCond[op].MinuteMax)+' '; + condTrainSig : s:=s+'train '+tablo_actionneur[i].tabloCond[op].train+' arrêté au signal '+intToSTR(tablo_actionneur[i].tabloCond[op].Adresse); + end; + s:=s+#13; + end; + nop:=Tablo_Actionneur[i].NbOperations; - if nop=0 then s:=s+' ne déclenche aucune opération'+#13; - if nop=1 then s:=s+' déclenche 1 opération '+#13; - if nop>1 then s:=s+' déclenche '+intToSTR(nop)+' opérations:'+#13; + if nop=0 then s:=s+'ne déclenche aucune opération'+#13; + if nop=1 then s:=s+'déclenche 1 opération :'+#13; + if nop>1 then s:=s+'déclenche '+intToSTR(nop)+' opérations :'+#13; s:=s+'--------------------'+#13; @@ -327,8 +423,8 @@ end; // affiche les champs en fonction de l'index du tablo actionneur et de l'index de l'action -procedure Aff_champs(index,IndexAction : integer); -var i,decl,act,Nb,icone : integer; +procedure Aff_champs(index,IndexCond,IndexAction : integer); +var i,decl,act,cond,Nb,icone : integer; s : string; begin if (index<1) or clicListe then exit; @@ -357,7 +453,6 @@ begin Lines.Add(s); end; - FormModifAction.LabeledEditNomAct.Text:=Tablo_Actionneur[index].NomAction; // ListBox opérations @@ -368,17 +463,44 @@ begin for i:=1 to Tablo_Actionneur[index].NbOperations do begin act:=Tablo_Actionneur[index].tabloOp[i].numoperation; - s:=operations[act].nom; - if not(Tablo_Actionneur[index].tabloOp[i].valide) then s:=s+' [dévalidé]'; - if act<1 then icone:=0 else icone:=act-1; + if act<=NbreOperations then + begin + s:=operations[act].nom; + if not(Tablo_Actionneur[index].tabloOp[i].valide) then s:=s+' [dévalidé]'; + if act<1 then icone:=0 else icone:=act-1; + + items.Add(Format('%d%s', [icone, s])); // valeur d'index de l'icone dans la ImagelistIcones + + // listboxOperations de la formConfig + formConfig.ListBoxOperations.Items.add(Format('%d%s', [act-1, s])); + itemHeight:=17; + end; + end; + if indexaction<>0 then itemIndex:=indexaction-1; + end; + + // listbox conditions + with FormModifAction.ListBoxConditions do + begin + clear; + for i:=1 to Tablo_Actionneur[index].NbCond do + begin + cond:=Tablo_Actionneur[index].tabloCond[i].numcondition; + s:=conditions[cond].nom; + case cond of + CondVrai : icone:=iconeVrai; + CondFaux : icone:=iconeFaux; + CondVitTrain : icone:=IconeVitTrain; + CondPosAcc : icone:=IconeAccessoire; + condHorl : icone:=IconeLanceHorl; + condTrainSig : icone:=IconeDeclSignal; + end; items.Add(Format('%d%s', [icone, s])); // valeur d'index de l'icone dans la ImagelistIcones - // listboxOperations de la formConfig - formConfig.ListBoxOperations.Items.add(Format('%d%s', [act-1, s])); itemHeight:=17; end; - if indexaction<>0 then itemIndex:=indexaction-1; + if indexCond<>0 then itemIndex:=indexCond-1; end; // listBoxActions de la formConfig @@ -392,6 +514,7 @@ begin efface_tous_parametres; + // déclencheurs with FormModifAction do case decl of DeclHorloge : @@ -447,7 +570,7 @@ begin MaxValue:=2; Hint:='Etat de l''accessoire'+#13+ '0=nul'+#13+ - '1=devié'+#13+ + '1=dévié'+#13+ '2=droit'; ShowHint:=true; visible:=true; @@ -456,7 +579,7 @@ begin LabelHeure.visible:=false; LabelAdresse.caption:='Adresse'; LabelAdresse.visible:=true; - EditAdr.Hint:='Adresse du déclencheur'; + EditAdr.Hint:='Adresse de l''accessoire sur le bus'; EditAdr.Visible:=true; EditAdr2.Visible:=false; @@ -475,11 +598,12 @@ begin EditAdr.text:=intToSTR(Tablo_Actionneur[index].adresse); EditTrainDecl.Visible:=true; EditTrainDecl.Text:=Tablo_Actionneur[index].trainDecl; + EdittrainDecl.Hint:='Train(s) déclencheur(s) séparés par des virgules pour lesquels la condition s''applique.' +#13+'Mettre X pour tous les trains.'+#13+'Déclenchement par actionneur uniquement'; LabelAdresse.visible:=true; EditAdr.Visible:=true; - EditAdr.Hint:='Adresse du déclencheur'; + EditAdr.Hint:='Adresse du détecteur sur le bus de rétrosignalisation '+#13+'ou de l''actionneur CDM'; LabelHeure.visible:=false; EditAdr2.Visible:=false; LabelAdresse.Caption:='Adresse'; @@ -498,8 +622,10 @@ begin LabelTrain.Visible:=true; LabelTrain.Caption:='Train déclencheur'; + s:='Déclenchement par détecteur/actionneur suivant son état et un train, un groupe de trains ou tous les trains.'+#13; + s:=s+'Le déclenchement par détecteur conditionné par un train n''est pas garanti, contrairement aux actionneurs.'; + RichEditInf.Lines.Add(s); - RichEditInf.Lines.Add('Déclenchement par détecteur/actionneur suivant son état et un train, un groupe de trains ou tous les trains.'); ImageIcone.Picture:=nil; formConfCellTCO.ImageListIcones.GetBitmap(IconeDet,ImageIcone.Picture.Bitmap); ImageIcone.repaint; @@ -542,16 +668,136 @@ begin formConfCellTCO.ImageListIcones.GetBitmap(IconeZoneDet,ImageIcone.Picture.Bitmap); ImageIcone.repaint; end; + + DeclDemarTrain : + begin + LabelTrain.visible:=true; + EditTrainDecl.Visible:=true; + LabelAdresse.Visible:=true; + LabelAdresse.caption:='Seuil de vitesse'; + EditAdr.Visible:=true; + + EdittrainDecl.Hint:='Train déclencheur unique'; + + EditADR.Hint:='Seuil de vitesse de démarrage du train '; + EditTrainDecl.Text:=Tablo_Actionneur[index].trainDecl; + EditAdr.Text:=IntToSTR(Tablo_Actionneur[index].adresse); + RichEditInf.Lines.Add('Déclenchement par démarrage d''un train à un seuil donné'); + ImageIcone.Picture:=nil; + formConfCellTCO.ImageListIcones.GetBitmap(IconeDemarTrain,ImageIcone.Picture.Bitmap); + ImageIcone.repaint; + end; + + DeclArretTrain : + begin + LabelTrain.visible:=true; + EditTrainDecl.Visible:=true; + LabelAdresse.Visible:=true; + LabelAdresse.caption:='Seuil de vitesse'; + EdittrainDecl.Hint:='Train déclencheur unique'; + + EditAdr.Visible:=true; + EditADR.Hint:='Seuil de vitesse d''arrêt du train'; + EditTrainDecl.Text:=Tablo_Actionneur[index].trainDecl; + EditAdr.Text:=IntToSTR(Tablo_Actionneur[index].adresse); + RichEditInf.Lines.Add('Déclenchement par arrêt d''un train à un seuil donné'); + ImageIcone.Picture:=nil; + formConfCellTCO.ImageListIcones.GetBitmap(IconeArretTrain,ImageIcone.Picture.Bitmap); + ImageIcone.repaint; + end; + + DeclSignal : + begin + LabelAdresse.Visible:=true; + EditAdr.text:=intToSTR(Tablo_Actionneur[index].adresse); + RadioEtatSignal.ItemIndex:=Tablo_Actionneur[index].Etat; + LabelAdresse.Caption:='Adresse'; + EditAdr.Hint:='Adresse de base du signal'; + EditAdr.Visible:=true; + RadioEtatSignal.Visible:=true; + RadioEtatSignal.Left:=16; + RadioEtatSignal.top:=64; + RichEditInf.Lines.Add('Déclenchement par changement d''état d''un signal'); + ImageIcone.Picture:=nil; + formConfCellTCO.ImageListIcones.GetBitmap(IconeSignal,ImageIcone.Picture.Bitmap); + ImageIcone.repaint; + end; end; - - if indexAction=0 then + // conditions + if indexCond>0 then begin - Clicliste:=false; - exit; + cond:=Tablo_Actionneur[index].tablocond[indexCond].numcondition; + with formModifAction do + begin + case cond of + CondVitTrain : + begin + champ1.Text:=intToSTR(Tablo_actionneur[index].tabloCond[indexCond].vitmini); + champ2.Text:=intToSTR(Tablo_actionneur[index].tabloCond[indexCond].vitmaxi); + ChampTrain.text:=Tablo_actionneur[index].tabloCond[indexCond].train; + Champ1.EditLabel.Caption:='Vitesse'+#13+'mini'; + Champ2.EditLabel.Caption:='Vitesse'+#13+'maxi'; + Champ1.Hint:='Vitesse minimale du train pour la condition'; + Champ2.Hint:='Vitesse minimale du train pour la condition'; + ChampTrain.Hint:='Nom du train unique pour la condition'; + champ1.Visible:=true; + champ2.Visible:=true; + ChampTrain.Visible:=true; + end; + CondPosAcc : + begin + champ1.Text:=intToSTR(Tablo_actionneur[index].tabloCond[indexCond].accessoire); + Champ1.Hint:='Adresse DCC de l''accessoire pour la condition'; + SpinEditEtat2.Value:=Tablo_actionneur[index].tabloCond[indexCond].etat; + SpinEditEtat2.visible:=true; + SpinEditEtat2.hint:='Etat de l''accessoire'+#13+ + '0=nul'+#13+ + '1=dévié'+#13+ + '2=droit'; + Champ1.EditLabel.Caption:='Adresse'+#13+'acc'; + champ1.Visible:=true; + labelEtat2.Visible:=true; + SpinEditEtat2.visible:=true; + SpinEditEtat2.MaxValue:=2; + end; + condHorl : + begin + SpinEditHeure1.Value:=Tablo_actionneur[index].tabloCond[indexCond].HeureMin; + SpinEditmn1.Value:=Tablo_actionneur[index].tabloCond[indexCond].MinuteMin; + SpinEditHeure2.Value:=Tablo_actionneur[index].tabloCond[indexCond].HeureMax; + SpinEditmn2.Value:=Tablo_actionneur[index].tabloCond[indexCond].MinuteMax; + + SpinEditHeure1.visible:=true; + SpinEditHeure2.visible:=true; + SpinEditMn1.visible:=true; + SpinEditMn2.visible:=true; + LabelHeureDebut.Visible:=true; + LabelHeureFin.Visible:=true; + end; + condTrainSig : + begin + champ1.Text:=intToSTR(Tablo_actionneur[index].tabloCond[indexCond].adresse); + champ1.editLabel.Caption:='Adresse du signal'; + champTrain.Text:=Tablo_actionneur[index].tabloCond[indexCond].train; + champ1.Visible:=true; + champTrain.Visible:=true; + end; + end; + end; end; + Nb:=Tablo_Actionneur[index].NbOperations; + + // si pas d'action sélectionnée et que la liste n'est pas nulle, sélectionner la première + if (Nb>0) and (indexAction=0) then + begin + indexAction:=1; + formModifAction.listBoxOperations.itemIndex:=indexaction; + formModifAction.listBoxOperations.Selected[indexaction-1]:=true; + end; + if Nb>=indexAction then begin @@ -571,10 +817,18 @@ begin begin LabeledEditAdresse.EditLabel.Caption:='Adresse'; LabeledEditAdresse.visible:=true; - LabeledEditEtat.visible:=true; + SpinEditEtatop.Visible:=true; + labelEtatOp.Visible:=true; + SpinEditEtatop.MinValue:=0; + SpinEditEtatop.MaxValue:=2; + SpinEditEtatop.hint:='Etat de l''accessoire'+#13+ + '0=nul'+#13+ + '1=dévié'+#13+ + '2=droit'; + checkBoxRaz.Visible:=true; LabeledEditAdresse.Text:=intToSTR(Tablo_actionneur[index].tabloop[indexAction].adresse); - LabeledEditEtat.Text:=intToSTR(Tablo_actionneur[index].tabloop[indexAction].etat); + SpinEditEtatop.Value:=Tablo_actionneur[index].tabloop[indexAction].etat; checkBoxRAZ.Checked:=Tablo_actionneur[index].tabloop[indexAction].zero; end; ActionVitesse : @@ -593,6 +847,7 @@ begin ComboBoxAccComUSB.Visible:=true; LabelPeriph.Visible:=true; LabeledEditTrain.EditLabel.Caption:='Commande'; + LabeledEditTrain.Hint:='Commande Ascii'; LabeledEditTrain.Text:=Tablo_actionneur[index].tabloop[indexAction].chaine; ComboBoxAccComUSB.itemIndex:=Tablo_actionneur[index].tabloop[indexAction].periph-1; end; @@ -623,7 +878,6 @@ begin LabeledEditTempoF.EditLabel.Caption:='Temporisation (x100 ms)'; LabeledEditTempoF.Text:=intToSTR(Tablo_actionneur[index].tabloop[indexAction].TempoF); end; - end; end; end; @@ -632,7 +886,7 @@ end; procedure TFormModifAction.ButtonOkClick(Sender: TObject); begin - Aff_champs(ligneclicAct+1,1); + Aff_champs(ligneclicAct+1,1,1); close; end; @@ -650,8 +904,8 @@ begin end; //ligneclicACt:=0; ComboBoxActions.ItemIndex:=ligneclicAct; - LabelDecl.Caption:='Liste de déclencheurs de l''action n°'+intToSTR(ComboBoxactions.ItemIndex+1); - Aff_champs(ligneclicAct+1,ClicAction+1); + LabelDecl.Caption:='Déclencheur de l''action n°'+intToSTR(ComboBoxactions.ItemIndex+1); + Aff_champs(ligneclicAct+1,ClicCond+1,ClicAction+1); if OperationAffiche<>0 then begin @@ -662,7 +916,7 @@ end; procedure TFormModifAction.ComboBoxActionsChange(Sender: TObject); begin ligneclicAct:=ComboBoxActions.ItemIndex; - Aff_champs(ligneclicAct+1,0); + Aff_champs(ligneclicAct+1,0,0); LabelDecl.Caption:='Liste de déclencheurs de l''action n°'+intToSTR(ComboBoxactions.ItemIndex+1); end; @@ -684,11 +938,12 @@ begin listboxoperations.Items[indexDest]:=ListBoxOper.Items[indexSrc]; - Aff_champs(ligneClicAct+1,indexDest+1); + clicAction:=ligneclicact; + Aff_champs(ligneClicAct+1,1,indexDest+1); end; procedure TFormModifAction.ButtonAjouterClick(Sender: TObject); -var indexSrc,idBD,NbOp,i : integer; +var indexSrc,idBD,NbOp,NbCond,i : integer; s : string; begin indexSrc:=listboxOper.ItemIndex; @@ -700,6 +955,7 @@ begin idBD:=ligneClicAct+1; NbOp:=Tablo_Actionneur[idBD].NbOperations; + NbCond:=Tablo_Actionneur[idBD].NbCond; inc(NbOp); Tablo_Actionneur[idBD].NbOperations:=NbOp; Setlength(Tablo_Actionneur[idBD].tabloOp,NbOp+1); @@ -707,14 +963,14 @@ begin Tablo_Actionneur[idBD].tabloOp[NbOp].numoperation:=i; Tablo_Actionneur[idBD].tabloOp[NbOp].valide:=true; - Aff_champs(idbd,Nbop); + Aff_champs(idbd,nbCond,Nbop); clicAction:=NbOp-1; ListBoxOperations.ItemIndex:=clicAction; end; procedure TFormModifAction.SpeedButtonSupprimeClick(Sender: TObject); -var i,indexSrc,idBD,NbOp,NumOp,res : integer; +var i,indexSrc,idBD,NbOp,NumOp : integer; s : string; begin indexSrc:=listboxOperations.ItemIndex; @@ -726,8 +982,8 @@ begin NumOp:=Tablo_Actionneur[idBD].TabloOp[indexSrc+1].numoperation; s:='Voulez vous supprimer l''action '+#13+operations[NumOp].Nom+' ?'; - res:=MessageDlg(s,mtConfirmation,[mbYes,mbNo],0); - if res=mrNo then exit;; + + if Application.MessageBox(pchar(s),pchar('confirm'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then exit; // supprimer listboxoperations.Items.Delete(indexSrc); @@ -740,7 +996,7 @@ begin Tablo_Actionneur[idBD].NbOperations:=NbOp; Setlength(Tablo_Actionneur[idBD].tabloOp,NbOp+1); - Aff_champs(idBD,IndexSrc+1); + Aff_champs(idBD,1,IndexSrc+1); exit; @@ -914,9 +1170,11 @@ begin index:=ligneclicAct+1; decl:=Tablo_actionneur[ligneclicAct+1].declencheur; - if (decl<>declDetAct) and (decl<>DeclZoneDet) and (decl<>DeclPeriph) then exit; + if (decl<>declDetAct) and (decl<>DeclZoneDet) and (decl<>DeclPeriph) and + (decl<>DeclDemarTrain) and (decl<>DeclArretTrain) then exit; - if (decl=declDetAct) or (decl=DeclZoneDet) then Tablo_actionneur[index].trainDecl:=EditTrainDecl.text; + if (decl=declDetAct) or (decl=DeclZoneDet) or (decl=DeclDemarTrain) or (decl=DeclArretTrain) + then Tablo_actionneur[index].trainDecl:=EditTrainDecl.text; if decl=DeclPeriph then Tablo_actionneur[index].ordrePeriph:=EditTrainDecl.text; maj_combocactions(ligneclicAct); @@ -928,7 +1186,7 @@ begin //Affiche('Clic ListBoxOperations',clyellow); ClicAction:=ListBoxOperations.itemindex; if ClicAction<0 then exit; - Aff_champs(ligneclicAct+1,ClicAction+1); + Aff_champs(ligneclicAct+1,1,ClicAction+1); end; @@ -1017,18 +1275,6 @@ begin maj_combocactions(ligneclicAct); end; -procedure TFormModifAction.LabeledEditEtatChange(Sender: TObject); -var i,erreur,op : integer; -begin - if (ligneclicAct<0) or clicliste then exit; - val(LabeledEditEtat.Text,i,erreur); - op:=Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].numoperation; - case op of - ActionAccessoire : Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].etat:=i; - end; - maj_combocactions(ligneclicAct); -end; - // affiche les champs de l'actionneur PN en fonction de l'index du tableau { procedure aff_champs_PN(i : integer); @@ -1172,7 +1418,7 @@ begin if clicDeclenche<0 then exit; i:=Clicdeclenche+1; Tablo_actionneur[ligneclicAct+1].declencheur:=i; - Aff_champs(ligneclicAct+1,0); + Aff_champs(ligneclicAct+1,0,0); end; @@ -1184,7 +1430,7 @@ begin Tablo_actionneur[index].NomAction:=LabeledEditNomAct.text; - Aff_champs(index,0); + Aff_champs(index,0,0); end; @@ -1196,7 +1442,7 @@ begin index:=ligneclicAct+1; if affevt then affiche('Evt ComboBox Change',clyellow); Tablo_Actionneur[ligneClicAct+1].TabloOp[clicaction+1].periph:=formModifAction.ComboBoxAccComUSB.ItemIndex+1; - Aff_champs(index,clicaction+1); + Aff_champs(index,0,clicaction+1); end; procedure TFormModifAction.LabeledEditTempoFChange(Sender: TObject); @@ -1216,4 +1462,196 @@ begin maj_combocactions(ligneclicAct); end; + + +procedure TFormModifAction.ListBoxCondTotDrawItem(Control: TWinControl; + Index: Integer; Rect: TRect; State: TOwnerDrawState); +var + i,erreur: Integer; + ItemText: string; +begin + with ListBoxCondTot do + begin + ItemText:=Items[index]; + val(ItemText,i,erreur); + Delete(ItemText,1,erreur-1); + Canvas.Fillrect(Rect); + formConfCellTCO.ImageListIcones.Draw(Canvas, Rect.Left, Rect.Top, i); + Canvas.Textout(Rect.Left + formConfCellTCO.ImageListIcones.Width + 2, Rect.Top, ItemText); + end; +end; + +procedure TFormModifAction.ListBoxConditionsMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + //Affiche('Clic ListBoxOperations',clyellow); + ClicCond:=ListBoxConditions.itemindex; + if ClicCond<0 then exit; + Aff_champs(ligneclicAct+1,ClicCond+1,ClicAction+1); +end; + +procedure TFormModifAction.ListBoxConditionsDrawItem(Control: TWinControl; + Index: Integer; Rect: TRect; State: TOwnerDrawState); +var + i,erreur: Integer; + ItemText: string; +begin + with ListBoxConditions do + begin + ItemText:=Items[index]; + val(ItemText,i,erreur); + Delete(ItemText,1,erreur-1); + Canvas.Fillrect(Rect); + formConfCellTCO.ImageListIcones.Draw(Canvas, Rect.Left, Rect.Top, i); + Canvas.Textout(Rect.Left + formConfCellTCO.ImageListIcones.Width + 2, Rect.Top, ItemText); + end; +end; + +procedure TFormModifAction.ButtonAppCondClick(Sender: TObject); +var indexSrc,IndexDest,i : integer; + s : string; +begin + indexSrc:=listboxCondTot.ItemIndex; + IndexDest:=ListBoxConditions.Itemindex; + if (indexSrc<0) or (ligneclicAct<0) then exit; + + + s:=ListBoxCondTot.Items[indexSrc]; + i:=Index_Condition(s); + + if (IndexDest<0) then IndexDest:=0; + Tablo_Actionneur[ligneClicAct+1].TabloCond[IndexDest+1].numCondition:=i; + + listboxConditions.Items[indexDest]:=ListBoxCondTot.Items[indexSrc]; + + clicAction:=ligneclicact; + Aff_champs(ligneClicAct+1,indexDest+1,0); + +end; + + +procedure TFormModifAction.Champ1Change(Sender: TObject); +var cond,i,erreur : integer; +begin + if (ligneclicAct<0) or clicliste then exit; + val(Champ1.Text,i,erreur); + cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + case cond of + CondVitTrain : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].vitmini:=i; + CondPosAcc : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].accessoire:=i; + CondTrainSig : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].adresse:=i; + end; + maj_combocactions(ligneclicAct); +end; + +procedure TFormModifAction.Champ2Change(Sender: TObject); +var cond,i,erreur : integer; +begin + if (ligneclicAct<0) or clicliste then exit; + val(Champ2.Text,i,erreur); + cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + case cond of + CondVitTrain : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].vitmaxi:=i; + end; + maj_combocactions(ligneclicAct); +end; + +procedure TFormModifAction.SpinEditHeure1Change(Sender: TObject); +var cond,i : integer; +begin + if (ligneclicAct<0) or clicliste then exit; + i:=SpinEditHeure1.Value; + cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + case cond of + CondHorl : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].HeureMin:=i; + end; + maj_combocactions(ligneclicAct); +end; + + +procedure TFormModifAction.SpinEditMn1Change(Sender: TObject); +var cond,i : integer; +begin + if (ligneclicAct<0) or clicliste then exit; + i:=SpinEditMn1.Value; + cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + case cond of + CondHorl : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].MinuteMin:=i; + end; + maj_combocactions(ligneclicAct); +end; + +procedure TFormModifAction.SpinEditHeure2Change(Sender: TObject); +var cond,i : integer; +begin + if (ligneclicAct<0) or clicliste then exit; + i:=SpinEditHeure2.Value; + cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + case cond of + CondHorl : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].HeureMax:=i; + end; + maj_combocactions(ligneclicAct); +end; + +procedure TFormModifAction.SpinEditMn2Change(Sender: TObject); +var cond,i : integer; +begin + if (ligneclicAct<0) or clicliste then exit; + i:=SpinEditMn2.Value; + cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + case cond of + CondHorl : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].MinuteMax:=i; + end; + maj_combocactions(ligneclicAct); + +end; + +procedure TFormModifAction.ChampTrainChange(Sender: TObject); +var cond : integer; +begin + if (ligneclicAct<0) or clicliste then exit; + cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + case cond of + CondVitTrain,CondTrainSig : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].train:=ChampTrain.Text; + end; + maj_combocactions(ligneclicAct); + +end; + +procedure TFormModifAction.SpinEditEtat2Change(Sender: TObject); +var cond,i : integer; +begin + if (ligneclicAct<0) or clicliste then exit; + i:=SpinEditEtat2.Value; + cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + case cond of + CondPosAcc : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].etat:=i; + end; + maj_combocactions(ligneclicAct); +end; + +procedure TFormModifAction.RadioEtatSignalClick(Sender: TObject); +var index : integer; +begin + if (ligneclicAct<0) or clicliste then exit; + index:=ligneclicAct+1; + if affevt then Affiche('EditAdrChange',clyellow); + + Tablo_actionneur[index].etat:=RadioEtatSignal.ItemIndex; + + maj_combocactions(ligneclicAct); +end; + +procedure TFormModifAction.SpinEditEtatopChange(Sender: TObject); +var i,erreur,op : integer; +begin + if (ligneclicAct<0) or clicliste then exit; + i:=SpinEditEtatop.Value; + op:=Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].numoperation; + case op of + ActionAccessoire : Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].etat:=i; + end; + maj_combocactions(ligneclicAct); +end; + end. diff --git a/UnitPilote.pas b/UnitPilote.pas index 692e59c..fcff1ce 100644 --- a/UnitPilote.pas +++ b/UnitPilote.pas @@ -386,14 +386,14 @@ begin radioBlanccli.visible:=true; end; - + { // checkcarré if (n<4) or (n>10) then checkVerrouCarre.Visible:=false else begin checkVerrouCarre.Visible:=false; //true; checkVerrouCarre.Checked:=Signaux[i].VerrouCarre; end; - + } with imagePilote do begin Parent:=FormPilote; @@ -448,7 +448,7 @@ begin i:=Index_Signal(AdrPilote); if Signaux[i].VerrouCarre then begin - Signaux[i].EtatVerrouCarre:=checkVerrouCarre.Checked=true; + //Signaux[i].EtatVerrouCarre:=checkVerrouCarre.Checked=true; Maj_Etat_Signal(AdrPilote,carre); envoi_signal(Adrpilote); Maj_Etat_Signal(0,carre); diff --git a/UnitPrinc.dfm b/UnitPrinc.dfm index ef680fb..814829c 100644 --- a/UnitPrinc.dfm +++ b/UnitPrinc.dfm @@ -1,6 +1,6 @@ object FormPrinc: TFormPrinc - Left = 134 - Top = 114 + Left = 54 + Top = 186 Width = 1148 Height = 624 Anchors = [akLeft, akTop, akRight] @@ -1473,8 +1473,8 @@ object FormPrinc: TFormPrinc OnDrawPanel = StatusBar1DrawPanel end object Button1: TButton - Left = 919 - Top = 16 + Left = 1023 + Top = 0 Width = 75 Height = 25 Anchors = [akTop, akRight] @@ -1986,8 +1986,8 @@ object FormPrinc: TFormPrinc end end object GroupBoxCV: TGroupBox - Left = 585 - Top = 72 + Left = 713 + Top = 32 Width = 265 Height = 129 Anchors = [akTop, akRight] @@ -2048,6 +2048,26 @@ object FormPrinc: TFormPrinc end end end + object Button2: TButton + Left = 360 + Top = 0 + Width = 75 + Height = 25 + Caption = 'Affiche routes' + TabOrder = 3 + Visible = False + OnClick = Button2Click + end + object Button3: TButton + Left = 496 + Top = 8 + Width = 75 + Height = 25 + Caption = 'Button3' + TabOrder = 4 + Visible = False + OnClick = Button3Click + end object Timer1: TTimer Interval = 100 OnTimer = Timer1Timer @@ -2120,6 +2140,10 @@ object FormPrinc: TFormPrinc Caption = 'Codification des signaux' OnClick = CodificationdessignauxClick end + object Codificationdescantons1: TMenuItem + Caption = 'Codification des cantons' + OnClick = Codificationdescantons1Click + end object N5: TMenuItem Caption = '-' end @@ -2408,9 +2432,9 @@ object FormPrinc: TFormPrinc end object Roulage1: TMenuItem Caption = 'Roulage' - object Placerlestrains1: TMenuItem - Caption = 'Placer les trains' - OnClick = Placerlestrains1Click + object OpRoulage: TMenuItem + Caption = 'Op'#233'rations de roulage' + OnClick = OpRoulageClick end object RazResa: TMenuItem Caption = 'Mise '#224' z'#233'ro des r'#233'servations des aiguillages' diff --git a/UnitPrinc.pas b/UnitPrinc.pas index 3c66748..964a71c 100644 --- a/UnitPrinc.pas +++ b/UnitPrinc.pas @@ -1,5 +1,5 @@ Unit UnitPrinc; -// 05/04/2024 22h +// 06/04/2024 22h (******************************************** Programme signaux complexes Graphique Lenz Delphi 7 + activeX Tmscomm + clientSocket @@ -28,16 +28,15 @@ Unit UnitPrinc; ligne de commande en mode administrateur pour valider le socket du pare feu: netsh advfirewall firewall add rule name="cdm rail" dir=in action=allow program="C:\Program Files (x86)\CDM-Rail\cdr.exe" enable=yes *) - +// S-E-01-0190-CMDACC-ST_DT|049|05|NAME=2758;OBJ=2758;AD=519;TRAIN=_NONE;STATE=1 // En mode simulation run: -// CDM ne renvoie pas les détecteurs au départ du RUN. -// il ne renvoie pas non plus le nom des trains sur les actionneurs -// les noms des trains sont bien renvoyés sur les détecteurs à 1 +// CDM ne renvoie pas les détecteurs au départ du RUN, ou pendant le RUN +// les noms des trains sont bien renvoyés sur les actionneurs à 1 // // En mode RUN CDM avec train: // CDM renvoie le nom des trains sur les actionneurs à 1, jamais à 0 -// et quelquefois (pas toujours!) sur les détecteurs à 1, jamais à 0 -// Au début du RUN, CDM renvoie les états des détecteurs et en mélangé les aiguillages et on en reçoit les états. +// et quelquefois (pas toujours!) sur les détecteurs à 1, jamais à 0 (il renvoie _NONE) +// Au début du RUN, CDM renvoie les états des détecteurs à 1 et en mélangé les aiguillages et on en reçoit les états. // Puis on reçoit la position des trains qui bougent. Si un train parqué ne bouge pas, on ne reçoit rien de ce train. // // En mode RUN TCO CDM (sans trains) : une commande de vitesse à un train n'est pas transmise @@ -138,7 +137,7 @@ type Demandetataccessoires1: TMenuItem; LancerCDMrail1: TMenuItem; Roulage1: TMenuItem; - Placerlestrains1: TMenuItem; + OpRoulage: TMenuItem; Demandetatdtecteurs1: TMenuItem; Informationsdusignal1: TMenuItem; Button1: TButton; @@ -242,6 +241,9 @@ type Ini1: TMenuItem; N16: TMenuItem; Afficherlhorloge1: TMenuItem; + Codificationdescantons1: TMenuItem; + Button2: TButton; + Button3: TButton; procedure FormCreate(Sender: TObject); procedure RecuInterface(Sender: TObject); procedure RecuPeriph1(Sender: TObject); @@ -311,7 +313,7 @@ type procedure TrackBarVitChange(Sender: TObject); procedure EditVitesseChange(Sender: TObject); procedure ButtonEnvClick(Sender: TObject); - procedure Placerlestrains1Click(Sender: TObject); + procedure OpRoulageClick(Sender: TObject); procedure Demandetatdtecteurs1Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Informationsdusignal1Click(Sender: TObject); @@ -386,6 +388,9 @@ type procedure Validationdeshoraires1Click(Sender: TObject); procedure Ini1Click(Sender: TObject); procedure Afficherlhorloge1Click(Sender: TObject); + procedure Codificationdescantons1Click(Sender: TObject); + procedure Button2Click(Sender: TObject); + procedure Button3Click(Sender: TObject); private { Déclarations privées } procedure DoHint(Sender : Tobject); @@ -403,6 +408,7 @@ type const titre='Signaux complexes GL '; +itMaxi=50; // itérations maxi pour les recherches MaxAcc=1024; // adresse maxi d'accessoire XpressNet (testé à la LH100) NbMaxDet=2048; // indice maximal de détecteurs d'un réseau Max_Trains=100; // nombre maximal de train de CDM ou déclarés ou en circulation @@ -479,6 +485,17 @@ DeclPeriph=2; DeclAccessoire=3; DeclDetAct=4; DeclZoneDet=5; +DeclDemarTrain=6; +DeclArretTrain=7; +DeclSignal=8; + +// conditions +CondVrai=1; +CondFaux=2; +CondVitTrain=3; +CondPosAcc=4; +CondHorl=5; +CondTrainSig=6; // Type d'opération (action) Action0=0; @@ -507,15 +524,22 @@ IconeLanceHorl=5; IconeArretHorl=6; IconeInitHorl=7; IconeHorloge=8; +IconeVitTrain=9; IconePeriph=10; //usb IconeDet=17; IconeZoneDet=18; +IconeArretTrain=19; +IconeDemarTrain=20; +IconeVrai=21; +IconeFaux=15; +IconeSignal=22; +IconeDeclSignal=23; type Tinterface = (_interface,periph1,periph2); // interface USB : interface vers centrale, périphérique 1 ou 2 Taccessoire = (aigP,signal); // aiguillage ou signal -TEquipement = (rien,aig,tjd,tjs,triple,det,buttoir,voie,crois,act); // voie uniquement pour le tco +TEquipement = (rien,aig,tjd,tjs,triple,det,buttoir,voie,crois,act,sig); // voie uniquement pour le tco TBranche = record BType : Tequipement ; // ne prend que les valeurs suivantes: dét aig Buttoir Adresse : integer ; // adresse du détecteur ou de l'aiguillage @@ -582,7 +606,7 @@ TSignal = record Btype_suiv3 : TEquipement ; // type de l'élément suivant voie 3 - Ne prend que les valeurs rien, det ou aig Btype_suiv4 : TEquipement ; // type de l'élément suivant voie 4 - Ne prend que les valeurs rien, det ou aig VerrouCarre : boolean ; // si vrai, le feu se verrouille au carré si pas de train avant le signal - EtatVerrouCarre : boolean ; // si vrai, le feu est verrouillé au carré + // EtatVerrouCarre : boolean ; // si vrai, le feu est verrouillé au carré modifie : boolean; // feu modifié EtatSignal : word ; // état du signal AncienEtat : word ; // ancien état du signal @@ -648,13 +672,25 @@ Toperation = record train,traincourant : string; end; -Tactionneur = +Tcondition = record + numcondition : integer ; + adresse : integer; + vitmini,vitMaxi : integer; + accessoire,etat : integer; + HeureMin,MinuteMin, + HeureMax,MinuteMax : integer; + train : string; +end; + +Taction = record // action - NbOperations,declencheur,vitesse, + NbCond,NbOperations,declencheur,vitesse, heure,minute,NumPeriph, adresse,etat,adresse2 : integer; // adresse: adresse de base ou heure ; adresse2=cas d'une Zone ou minute trainDecl,ordrePeriph,NomAction : string; + traite : boolean; + TabloCond : array of Tcondition; TabloOp : array of Toperation; end; @@ -671,7 +707,7 @@ var etape,idEl,avecRoulage,intervalle_courant,filtrageDet0, TpsTimeoutSL,formatY,OsBits,NbreDecPers,NbDecodeur,NbDecodeurdeBase, LargeurF,HauteurF,OffsetXF,OffsetYF,PosSplitter,NbPeriph,NbPeriph_COMUSB,NbPeriph_Socket, - AigMal,AncMinute,axFP,ayFP,NbreOperations,NbreDeclencheurs,index_seqAct : integer; + AigMal,AncMinute,axFP,ayFP,NbreOperations,NbreDeclencheurs,index_seqAct,NbreConditions : integer; ack,portCommOuvert,traceTrames,AffMem,CDM_connecte,dupliqueEvt,affiche_retour_dcc, Raz_Acc_signaux,AvecInit,AvecTCO,terminal,Srvc_Aig,Srvc_Det,Srvc_Act,MasqueBandeauTCO, @@ -696,6 +732,7 @@ var CheminProgrammes,cheminWin,fichierAide : string; Ancien_detecteur : array[0..NbMaxDet] of boolean; // anciens état des détecteurs et adresses des détecteurs et leur état + detecteur : array[0..NbMaxDet] of // détecteurs indexés par l'adresse record Etat : boolean; // état 0/1 du détecteur @@ -753,7 +790,7 @@ var AdrTrain : integer; end; - Tablo_actionneur : array[0..Max_actionneurs] of Tactionneur; + Tablo_actionneur : array[0..Max_actionneurs] of Taction; // décodeurs personnalisés de signaux decodeur_pers : array[1..NbreMaxiDecPers] of @@ -800,6 +837,13 @@ var famille : integer; // 1=système 2=CDM 3=SC ne sert qu'a filtrer l'affichage par la combobox end; + Conditions : array[0..10] of + record + nom : string; + index : integer; + famille : integer; + end; + operations : array[0..20] of record nom : string; @@ -829,14 +873,19 @@ var // trains en roulage sur le réseau et de la base de données [section_trains] trains : array[0..Max_Trains] of record nom_train : string; + inverse : boolean; // placement adresse,vitmax,VitNominale,VitRalenti : integer; vitesse : integer; // vitesse actuelle de pilotage - sens : boolean; // sens de déplacement + sens : integer; // sens de déplacement, stockage provisoire pour restocker dans le tableau canton[] compteur_consigne : integer; // compteur de consigne pour envoyer deux fois la vitesse en 10eme de s TempoArret : integer; // tempo d'arret pour le timer - TempoDemarre : integer; // tempo de démarrage + TempoDemarre : integer; // tempo de démarrage, valeur dynamique + TempsDemarreSig : integer; // temps de redémarrage du signal, valeur d'initialisation (fichier de config) index_event_det_train : integer; // index du train en cours de roulage du tableau event_det_train + canton : integer ; // numéro du canton (pas index) sur lequel le train se trouve roulage : boolean; // train en roulage + icone : Timage ; + NomIcone : string; //----------------------------------- SbitMap : TBitmap ; // pointeur sur tampon sous l'icone de déplacement du train en page CDM ax,ay,x,y : integer; // coordonnées du train (anciennes et nouvelles) en points windows @@ -850,14 +899,6 @@ var typ : Tequipement; end; - // liste des trains placés - Placement : array[1..10] of - record - train : string; - detecteur,detdir : integer; - inverse : boolean; - end; - // liste des évènements détecteurs event_det : array[1..Max_event_det] of record @@ -934,6 +975,7 @@ procedure init_dccpp; procedure init_aiguillages; function index_adresse_detecteur(de : integer) : integer; function index_train_adresse(adr : integer) : integer; +function index_train_nom(nom : string) : integer; procedure vitesse_loco(nom_train :string;index : integer;adr_loco : integer;vitesse : integer;repetition : boolean); procedure Maj_Signaux(detect : boolean); procedure Det_Adj(adresse : integer); @@ -973,16 +1015,21 @@ function envoi_CDM(s : string) : boolean; function place_id(s : string) : string; procedure fin_preliminaire; function Index_operation(s : string) : integer; +function Index_Condition(s : string) : integer; function Lance_CDM(avecSocket : boolean) : boolean; procedure action(action : integer); function Signal_precedent(adresse : integer) : integer; +procedure cercle(ACanvas : Tcanvas;x,y,rayon : integer;couleur : Tcolor); +procedure Event_vitesse(adr: integer ;train : string;vitesse : integer); +function detecteur_suivant(prec : integer;TypeElPrec : TEquipement;actuel : integer;TypeElActuel : TEquipement;algo : integer) : integer ; implementation uses UnitDebug, UnitPilote, UnitSimule, UnitTCO, UnitConfig, Unitplace, verif_version , UnitCDF, UnitAnalyseSegCDM, UnitConfigCellTCO, UnitConfigTCO,UnitSR, UnitHorloge, UnitFicheHoraire, UnitClock, - UnitModifAction; + UnitModifAction, + selection_train; { procedure menu_interface(MA : TMA); @@ -1126,7 +1173,6 @@ begin if LanceHorl then Demarre_horloge; end; - formConfig.listBoxPeriph.clear; formModifAction.ComboBoxAccComUSB.Clear; formconfig.ComboBoxPNCom.Clear; @@ -1135,10 +1181,19 @@ begin formconfig.listBoxPeriph.items.Add(encode_Periph(i)); ajoute_champs_combos(i); end; - + + + if avecTCO then + for i:=1 to NbreTco do + begin + FormTCO[i].Visible:=false; + Affiche_Fenetre_TCO(i,avecTCO); + end; + renseigne_tous_cantons; formprinc.SetFocus; -end; + +end; // envoi une chaine à un périphérique COM/USB en fonction de l'interface // non utilisé @@ -1206,8 +1261,11 @@ begin StatusBar1.Panels[0].text:=s; // détection d'un hint provoqué dans formtco - NomForm:=uppercase(Screen.activeform.Name); - formeTCO:=copy(NomForm,1,7)='FORMTCO'; + if Screen.ActiveForm<>nil then + begin + NomForm:=uppercase(Screen.activeform.Name); + formeTCO:=copy(NomForm,1,7)='FORMTCO'; + end; // dessine les encadrés de colonne/ligne dans le tco suivant sélection du popup menu, en fonction du hint qu'on accroche if formeTCO then @@ -2027,7 +2085,7 @@ begin end; // inverse une image (miroir horizontal) et la met dans dest -// Utilisé pour les signaux belges +// Utilisé pour les signaux belges, et les trains procedure inverse_image(imageDest,ImageSrc : Timage); var mrect,nrect : trect; larg,haut : integer; @@ -2952,7 +3010,7 @@ begin maxi=C-C-00-0002-CMDTRN-DCCSF|111|15|NAME=train;FX0=1;FX1=1;FX2=1;FX3=1;FX4=0;FX5=0;FX6=0;FX7=0;FX8=0;FX9=0;FX10=0;FX11=0;FX12=0;FX13=0; } so:=place_id('C-C-01-0004-CMDTRN-DCCSF'); - s:=s+'NAME='+train+';'; + s:='NAME='+train+';'; s:=s+'FX'+intToSTR(fonction)+'='+intToSTR(etat)+';'; sx:=format('%.*d',[2,2])+'|'; // 2 paramètres so:=so+ '|'+format('%.*d',[3,length(s)+length(sx)])+'|'+sx; @@ -2965,7 +3023,7 @@ 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+'NAME='+train+';'; + s:='NAME='+train+';'; s:=s+'UREQ='+intToSTR(vitesse)+';'; sx:=format('%.*d',[2,2])+'|'; // 2 paramètres so:=so+ '|'+format('%.*d',[3,length(s)+length(sx)])+'|'+sx; @@ -2981,13 +3039,25 @@ 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:='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; + //C-C-01-0004-CMDTRN-_STOP|055|01|NAME=C-C-01-0004-CMDTRN-_STOP|017|01|NAME=CC406526;; +// renvoie une chaîne pour vitesse train INT par son adresse +function chaine_CDM_StopTrainST(train:string) : string; +var s,so,sx: string; +begin + so:=place_id('C-C-01-0004-CMDTRN-_STOP'); + s:='NAME='+train+';'; + sx:=format('%.*d',[2,1])+'|'; // 1 paramètre + so:=so+ '|'+format('%.*d',[3,length(s)+length(sx)])+'|'+sx; + chaine_CDM_StopTrainST:=so+s; +end; + // renvoie une chaîne pour piloter un accessoire via CDM Function chaine_CDM_Acc(adresse,etat : integer) : string; @@ -3007,7 +3077,7 @@ begin en fait seules les fonctions 1 et 2 fonctionnent... } so:=place_id('C-C-01-0004-CMDACC-DCCAC'); - s:=s+'AD='+format('%.*d',[1,adresse])+';'; + s:='AD='+format('%.*d',[1,adresse])+';'; s:=s+'STATE='+format('%.*d',[1,etat])+';'; sx:=format('%.*d',[2,2])+'|'; // 2 paramètres @@ -3312,7 +3382,7 @@ begin if PilotageTrainsCDMNom then s:=chaine_CDM_vitesseST(vitesse,nom_train) // par nom du train else - s:=chaine_CDM_vitesseINT(vitesse,adr_loco); // par adresse du train + s:=chaine_CDM_vitesseINT(vitesse,adr_loco); // par adresse du train : ne marche pas toujours!!! envoi_CDM(s); //affiche(s,clLime); end; @@ -5237,7 +5307,7 @@ end; // TypeElprec/actuel: 1= détecteur 2= aiguillage 4=Buttoir // algo= type d'algorithme pour suivant_alg3 function detecteur_suivant(prec : integer;TypeElPrec : TEquipement;actuel : integer;TypeElActuel : TEquipement;algo : integer) : integer ; -var actuelCalc,PrecCalc,j,AdrSuiv ,indexCalc : integer; +var actuelCalc,PrecCalc,j,AdrSuiv ,indexCalc,ia : integer; TypeprecCalc,TypeActuelCalc : TEquipement; begin if NivDebug>=2 then @@ -5254,7 +5324,15 @@ begin repeat inc(j); AdrSuiv:=suivant_alg3(precCalc,TypeprecCalc,actuelCalc,TypeActuelCalc,algo); - indexCalc:=index_aig(actuelCalc); + //Affiche(intToSTR(AdrSuiv)+'=alg3('+intToSTR(precCalc)+','+intToSTR(actuelCalc)+')',clWhite); + // modif spécial TJD ============== + ia:=index_aig(actuelCalc); + if aiguillage[ia].modele=tjd then + PrecCalc:=aiguillage[ia].Ddevie else + // ================================ + + + {indexCalc:=index_aig(actuelCalc); if (typeGen=tjd) and false then // si le précédent est une TJD/S et le suivant aussi begin if ((aiguillage[index_aig(AdrSuiv)].modele=tjd) or (aiguillage[index_aig(AdrSuiv)].modele=tjs)) and @@ -5264,13 +5342,14 @@ begin // subsituer la pointe actuelCalc:=aiguillage[indexCalc].APointe; end; - end; + end; } precCalc:=actuelCalc; TypeprecCalc:=TypeActuelCalc; + actuelCalc:=AdrSuiv; TypeActuelCalc:=typeGen; //Affiche('Suivant signalaig='+IntToSTR(AdrSuiv),clyellow); - until (j=10) or (typeGen=det) or (AdrSuiv=0) or (AdrSuiv>=9990); // arret si détecteur + until (j=itmaxi) or (typeGen=det) or (AdrSuiv=0) or (AdrSuiv>=9990); // arret si détecteur // si trouvé le sens, trouver le suivant if AdrSuiv=actuel then @@ -5281,11 +5360,115 @@ begin detecteur_suivant:=AdrSuiv; end; +function teste_condition(action : integer) : boolean; +var condValide : boolean; + vit,vit1,vit2,it,pa,m1,m2,hc,n,ncond,cond : integer; + tr : string; +begin + // 1 condition - pas de chaînage avec 1 seule condition + condValide:=false; + n:=Tablo_actionneur[action].NbCond; + for ncond:=1 to n do + begin + cond:=Tablo_actionneur[action].tabloCond[ncond].numcondition; + case cond of + CondVrai : condValide:=true; + CondFaux : condValide:=false; + CondVitTrain : + begin + tr:=Tablo_actionneur[action].tabloCond[ncond].train; + vit1:=Tablo_actionneur[action].tabloCond[ncond].vitmini; + vit2:=Tablo_actionneur[action].tabloCond[ncond].vitmaxi; + it:=index_train_nom(tr); + if it>0 then + begin + vit:=Trains[it].vitesse; + condvalide:=(vit>=vit1) and (vit<=vit2); + end; + end; + CondPosAcc : + begin + vit1:=Tablo_actionneur[action].tabloCond[ncond].accessoire; + vit2:=Tablo_actionneur[action].tabloCond[ncond].etat; + it:=index_aig(vit1); + if it>0 then + begin + pa:=aiguillage[it].position; + if pa=const_inconnu then Affiche('Action '+intToSTR(action)+' / condition '+intToSTR(ncond)+' : position accessoire '+intToSTR(vit1)+' inconnue',clred); + condvalide:=pa=vit2; + end else Affiche('Action '+intToSTR(action)+' / condition '+intToSTR(ncond)+' : Aiguillage '+intToSTR(vit1)+' inconnu',clred); + end; + CondHorl : + begin + vit1:=Tablo_actionneur[action].tabloCond[ncond].HeureMin*60; + vit2:=Tablo_actionneur[action].tabloCond[ncond].HeureMax*60; + m1:=Tablo_actionneur[action].tabloCond[ncond].MinuteMin; + m2:=Tablo_actionneur[action].tabloCond[ncond].MinuteMax; + vit1:=vit1+m1; + vit2:=vit2+m2; + hc:=heure*60+minute; + condValide:=(hc>=vit1) and (hc<=vit2); + end; + condTrainSig : + begin + vit1:=Tablo_actionneur[action].tabloCond[ncond].adresse; + tr:=Tablo_actionneur[action].tabloCond[ncond].train; + it:=index_Signal(vit1); + if it=0 then begin Affiche('Action '+intToSTR(action)+' / condition '+intToSTR(ncond)+' signal '+intToSTR(vit1)+' inconnu',clred);exit;end; + vit1:=signaux[it].Adr_det1; + condValide:=detecteur[vit1].Train=tr; + end; + end; + end; + result:=condValide; +end; + + + +// index signal niveau=0 : (ouvert) 1= ouvert au vert =2 ouvert restreint =3 fermé (carré sémaphore violet) +procedure event_Signal(idSignal,niveau : integer); +var i : integer; +begin + for i:=1 to MaxTablo_act do + begin + if (Tablo_actionneur[i].declencheur=DeclSignal) then + begin + if (Tablo_actionneur[i].adresse=signaux[idSignal].adresse) then + begin + if (Tablo_actionneur[i].etat=niveau) then + begin + if teste_condition(i) then + begin + action(i); // exécute toutes les opérations de l'actionneur i + end + end; + end; + end; + end; +end; + + +procedure arret_train(nom : string;id,adresse : integer); +var s : string; +begin + if Cdm_connecte then + begin + s:=chaine_CDM_StopTrainST(nom); + envoi_cdm(s); + end + else + if (portCommOuvert or parSocketLenz) then + begin + vitesse_loco(nom,id,adr,0,true); + end; +end; + + // pilotage d'un signal, et mise à jour du graphisme du signal dans les 3 fenetres procedure envoi_signal(Adr : integer); -var i,it,j,index_train,adresse,detect,detsuiv,a,b,aspect,x,y,TailleX,TailleY,Orientation, - indexTCO,AdrTrain,dec : integer; - rougeA,rougeB : boolean; +var i,it,index_train,adresse,detect,detsuiv,a,b,aspect,x,y,TailleX,TailleY,Orientation, + indexTCO,AdrTrain,dec,td : integer; + etatAvert,etatBvert,etatArouge,etatBrouge : boolean; ImageSignal : TImage; frX,frY : real; s : string; @@ -5325,21 +5508,22 @@ begin if (dec0 then begin @@ -5347,10 +5531,8 @@ begin if detecteur[detect].etat then begin AdrTrain:=detecteur[detect].AdrTrain; - if AdrTrain<>0 then + if (AdrTrain<>0) then begin - s:='Le train @'+intToSTR(AdrTrain)+' va démarrer du signal '+intToSTR(adr); - Affiche(s,clWhite); if TraceListe then AfficheDebug(s,clWhite); index_train:=index_train_adresse(adrtrain); if index_train<>0 then it:=trains[index_train].index_event_det_train; @@ -5359,25 +5541,29 @@ begin if Signaux[i].Btype_suiv1<>det then detSuiv:=detecteur_suivant(detect,det,Signaux[i].Adr_el_suiv1,Signaux[i].Btype_suiv1,1) else detSuiv:=Signaux[i].Adr_el_suiv1; if detSuiv<9990 then reserve_canton(detect,detSuiv,Adrtrain,0,nCantonsRes); - // démarrage d'un train - j:=index_train_adresse(adrtrain); - trains[j].tempoDemarre:=20; // armer la tempo à 2s - // annuler la demande d'arret éventuelle - trains[j].TempoArret:=0; - // arreter le train - //s:=detecteur[det].train; - //detecteur[det].train:=s; - //Affiche('et son détecteur '+IntToSTR(det)+'=1 tempo démarrage ; train '+s,clYellow); - //if cdm_connecte then - //begin - // s:=chaine_CDM_vitesseST(0,s); // 0% - // envoi_cdm(s); - //end; + // démarrage d'un train + td:=trains[index_train].TempsDemarreSig; + if td<>0 then + begin + trains[index_train].tempoDemarre:=td*10; // armer la tempo, en dixièmes de s + // annuler la demande d'arret éventuelle + trains[index_train].TempoArret:=0; + s:='Le train @'+intToSTR(AdrTrain)+' va démarrer dans '+intToSTR(td)+'s du signal '+intToSTR(adr); + Affiche(s,clyellow); + // arreter le train + + //detecteur[det].train:=s; + //Affiche('et son détecteur '+IntToSTR(det)+'=1 tempo démarrage ; train '+s,clYellow); + s:=detecteur[detect].train; + arret_train(s,index_train,AdrTrain); + //Affiche('arret train cdm '+s,clorange); + end; end; end; end; end; + end; end @@ -5407,12 +5593,12 @@ begin begin aspect:=Signaux[Index_Signal(adresse)].Aspect; case aspect of - 2 : ImageSignal:=Formprinc.Image2feux; - 3 : ImageSignal:=Formprinc.Image3feux; - 4 : ImageSignal:=Formprinc.Image4feux; - 5 : ImageSignal:=Formprinc.Image5feux; - 7 : ImageSignal:=Formprinc.Image7feux; - 9 : ImageSignal:=Formprinc.Image9feux; + 2 : ImageSignal:=Formprinc.Image2feux; + 3 : ImageSignal:=Formprinc.Image3feux; + 4 : ImageSignal:=Formprinc.Image4feux; + 5 : ImageSignal:=Formprinc.Image5feux; + 7 : ImageSignal:=Formprinc.Image7feux; + 9 : ImageSignal:=Formprinc.Image9feux; 12 : ImageSignal:=Formprinc.Image2Dir; 13 : ImageSignal:=Formprinc.Image3Dir; 14 : ImageSignal:=Formprinc.Image4Dir; @@ -5644,15 +5830,14 @@ begin if el>NbMaxDet then begin - s:='Erreur 78 : trouve_element el='+inttoStr(el); + s:='Erreur 80 : trouve_element el='+inttoStr(el); Affiche(s,clred); AfficheDebug(s,clred); exit; end; - if el<1 then + if (el<1) and (typeEL<>buttoir) then begin - if TypeEL=buttoir then exit; - s:='Erreur 79 : trouve_element el='+inttoStr(el); + s:='Erreur 81 : trouve_element el='+inttoStr(el); Affiche(s,clred); AfficheDebug(s,clred); exit; @@ -5693,7 +5878,7 @@ begin end; // renvoie l'élément suivant des deux éléments dans le sens (prec,typeElprec) -> (actuel,typeElActuel) quels qu'ils soient mais contigus -// *** attention, si les éléments ne sont pas contigus, le résultat est erronné!!! *** +// *** attention, si les éléments ne sont pas contigus, le résultat est erroné!!! *** // un élément est constitué de son adresse et de son type // et renvoie aussi en variable globale: typeGen le type de l'élément (det aig uniquement! pas tjd ni crois) // : AigMal = aiguillage mal positionné ou inconnu @@ -5711,11 +5896,10 @@ end; // 9995: arrêt sur buttoir // 9994: arrêt sur aiguillage réservé // 9993: éléments non consécutifs - // la variable "actuel" peut etre changée en cas de TJD! 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,index2 : integer; + tjsc1,tjsc2,AdrTjdP,Adr2,N_iteration,index,NetatTJD,index2,k : integer; tjscourbe1,tjscourbe2,tjdC,tjsC,id : boolean; A,Aprec,tjsc1B,tjsc2B,typeprec: char; Md,BT,BtypePrec,TypeEL : TEquipement; @@ -5942,9 +6126,11 @@ begin begin // si TJD (modele=2) sur le précédent, alors substituer avec la 2eme adresse de la TJD // V1 md:=aiguillage[index_aig(prec)].modele; - md:=aiguillage[tablo_index_aiguillage[prec]].modele; - if (md=tjd) or (md=tjs) then prec:=aiguillage[index_aig(prec)].DDroit; - if prec<>aiguillage[index_aig(Adr)].Adroit then //Adroit + // md:=aiguillage[tablo_index_aiguillage[prec]].modele; + // if (md=tjd) or (md=tjs) then prec:=aiguillage[index_aig(prec)].DDroit; + k:=index_aig(Adr); + if ( (prec<>aiguillage[index_aig(Adr)].Adroit) and (aiguillage[k].InversionCDM=0) ) or //Adroit + ( (prec=aiguillage[k].Adroit) and (aiguillage[k].InversionCDM=1) ) then begin if NivDebug=3 then AfficheDebug('135.1 - Aiguillage '+intToSTR(adr)+' mal positionné',clyellow); suivant_alg3:=9998; @@ -6403,7 +6589,7 @@ begin if (A='Z') or (a=#0) then typeGen:=det else typeGen:=aig; Actuel:=aiguillage[index2].Adresse; suivant_alg3:=adr; - if nivDebug=3 then Affichedebug('le port de destination de la tjd est '+IntToSTR(adr)+a,clyellow); + if nivDebug=3 then Affichedebug('Le port de destination de la tjd 4 états est '+IntToSTR(adr)+a,clyellow); exit; end; @@ -7099,7 +7285,7 @@ end; // les aiguillages entre det1 et det2 doivent être positionnés // résultat dans adj1 et adj2 en variable globale procedure Det_Adj(adresse : integer); -var Adr,AdrFonc,Branche,AdrPrec,IndexBranche,i,Dir : integer; +var ia,Adr,AdrFonc,Branche,AdrPrec,IndexBranche,i,Dir : integer; sortie : boolean; BtypeFonc,BtypePrec : TEquipement; s : string; @@ -7130,6 +7316,7 @@ begin if BtypeFonc<>det then begin Adr:=suivant_alg3(AdrPrec,BtypePrec,AdrFonc,BtypeFonc,2); // élément suivant mais arret sur aiguillage en talon mal positionnée + //Affiche(intToSTR(Adr)+'=alg3('+intToSTR(Adrprec)+','+intToSTR(AdrFonc)+')',clWhite); end else begin @@ -7138,10 +7325,17 @@ begin end; if Adr>9990 then typeGen:=det; if (NivDebug=3) then AfficheDebug('trouvé '+intToSTR(Adr)+' '+BTypeToChaine(typeGen),clorange); + + // modif spécial TJD ============== + ia:=index_aig(AdrFonc); + if aiguillage[ia].modele=tjd then + AdrPrec:=aiguillage[ia].Ddevie else + // ================================ + AdrPrec:=AdrFonc;BtypePrec:=BtypeFonc; AdrFonc:=Adr;BtypeFonc:=typeGen; i:=i+1; - sortie:=(i=20) or (Adr=0) or (Adr>=9990) or (TypeGen=det); + sortie:=(i=itmaxi) or (Adr=0) or (Adr>=9990) or (TypeGen=det); until (sortie) ; // boucle de parcours if (typeGen=det) and (Dir=1) then begin Adj1:=Adr;end; if (typeGen=det) and (Dir=2) then begin Adj2:=Adr;end; @@ -7501,12 +7695,13 @@ end; // les aiguillages doivent être correctement positionnés entre El1 et el2 // El1 et El2 peuvent être séparés par des aiguillages, mais de pas plus de 3 détecteurs // remplit aussi le tableau des éléments[idEl] rencontrés de el2 au suivant +// ne fonctionne pas si un des éléments est un buttoir!!! // en sortie : 9999= det1 ou det2 non trouvé // 9995 : el2=0 buttoir // 9996 : non trouvé function detecteur_suivant_El(el1: integer;TypeDet1 : TEquipement;el2 : integer;TypeDet2 : TEquipement;alg : integer) : integer ; var IndexBranche_det1,IndexBranche_det2,branche_trouve_det1,branche_trouve_det2,i, - j,AdrPrec,Adr,AdrFonc,i1,N_det : integer; + j,AdrPrec,Adr,AdrFonc,i1,N_det,Ia : integer; Sortie : boolean; TypePrec,TypeFonc : Tequipement; s : string; @@ -7529,6 +7724,21 @@ begin exit; end; + if typeDet1=buttoir then + begin + // inverser det1 et det2 pour qu'on parte du détecteur en det1 + //mais ne marche pas... + j:=el1; + typePrec:=Typedet1; + + el1:=el2; + typedet1:=typedet2; + + el2:=j; + typeDet2:=TypePrec; + end; + + // trouver détecteur 1 trouve_element(el1,Typedet1); // branche_trouve IndexBranche_trouve if (IndexBranche_trouve=0) then @@ -7566,6 +7776,8 @@ begin repeat //préparer les variables AdrPrec:=el1;TypePrec:=typeDet1; + + // sens if j=1 then i1:=IndexBranche_det1+1; if j=2 then i1:=IndexBranche_det1-1; // les suivants dansla branche sont: @@ -7592,7 +7804,9 @@ begin begin Adr:=9999; end; - //AfficheDebug('Sortie Alg3: '+IntToSTR(Adr)+'/'+intToSTR(typeGen),clyellow); + + //Affiche(intToSTR(Adr)+'=alg3('+intToSTR(Adrprec)+','+intToSTR(Adrfonc)+')',clyellow); + if TypeGen=det then inc(N_Det); if NivDebug=3 then begin @@ -7600,12 +7814,17 @@ begin AfficheDebug(s,clYellow); end; + // modif spécial TJD ============== + ia:=index_aig(adrfonc); + if aiguillage[ia].modele=tjd then + AdrPrec:=aiguillage[ia].Ddevie else + // ================================ AdrPrec:=AdrFonc;TypePrec:=TypeFonc; AdrFonc:=Adr;TypeFonc:=typeGen; inc(i); sortie:=((typeDet2=TypeGen) and (Adr=el2)) or (Adr=0) or (Adr>=9990) or (i=15) or (N_Det=Nb_det_dist); until sortie ; - if (i=15) and (Nivdebug=3) then afficheDebug('Pas trouvé',clyellow); + if (i=itMaxi) and (Nivdebug=3) then afficheDebug('Pas trouvé',clyellow); if (N_det=Nb_det_dist) and (Nivdebug=3) then begin s:='Elements trop distants '+intToStr(el1)+' '+intToSTR(el2); @@ -7631,6 +7850,8 @@ begin repeat //AfficheDebug('Engage '+IntToSTR(AdrPrec)+','+IntToSTR(typePrec)+'/'+IntToSTR(AdrFonc)+','+IntToSTR(typeFonc),clyellow); Adr:=suivant_alg3(AdrPrec,TypePrec,AdrFonc,TypeFonc,alg); + // Affiche(intToSTR(Adr)+'=alg3('+intToSTR(AdrPrec)+','+intToSTR(adrFonc)+')',clWhite); + //AfficheDebug('Sortie Alg3: '+IntToSTR(Adr)+'/'+intToSTR(typeGen),clyellow); if NivDebug=3 then @@ -7642,12 +7863,18 @@ begin elements[idEl].adresse:=adr; elements[idEl].typ:=TypeGen; - ADrPrec:=AdrFonc;TypePrec:=TypeFonc; + // modif spécial TJD ============== + ia:=index_aig(ADrFonc); + if aiguillage[ia].modele=tjd then + AdrPrec:=aiguillage[ia].Ddevie else + // ================================ + + AdrPrec:=AdrFonc;TypePrec:=TypeFonc; AdrFonc:=Adr;TypeFonc:=typeGen; inc(i); - sortie:=(TypeGen=det) or (Adr=0) or (Adr>=9990) or (i=10); + sortie:=(TypeGen=det) or (Adr=0) or (Adr>=9990) or (i>=itMaxi); until sortie; - + if i>=itMaxi then Affiche('Erreur 67 : Dépassement itérations',clred); if (TypeGen=det) or (TypeGen=buttoir) then begin if NivDebug=3 then @@ -7660,7 +7887,7 @@ begin exit; end; end; - if (i=10) then if NivDebug=3 then AfficheDebug('201 : Itération trop longue',clred); + if (i>=itMaxi) then if NivDebug=3 then AfficheDebug('201 : Itération trop longue',clred); inc(j); //AfficheDebug('j='+intToSTR(j),clyellow); until j=3; // boucle incrément/décrément @@ -7674,7 +7901,7 @@ end; // mode=0 = libère 1=réserve reserve_dereserve_det(detecteur1,detecteur2,adrTrain,i,1); function reserve_dereserve_det(det1,det2,adrTrain,indexTrain,mode : integer) : integer; var IndexBranche_det1,IndexBranche_det2,branche_trouve_det1,branche_trouve_det2,i, - j,k,AdrPrec,Adr,AdrFonc,i1,N_det : integer; + j,k,AdrPrec,Adr,AdrFonc,i1,N_det,ia : integer; Sortie : boolean; TypePrec,TypeFonc : Tequipement; s : string; @@ -7769,12 +7996,18 @@ begin AfficheDebug(s,clYellow); end; + // modif spécial TJD ============== + ia:=index_aig(adrfonc); + if aiguillage[ia].modele=tjd then + adrPrec:=aiguillage[ia].Ddevie else + // ================================ + AdrPrec:=AdrFonc;TypePrec:=TypeFonc; AdrFonc:=Adr;TypeFonc:=typeGen; inc(i); sortie:=((TypeGen=det) and (Adr=det2)) or (Adr=0) or (Adr>=9990) or (i=15) or (N_Det=Nb_det_dist); until sortie ; - if (i=15) and (Nivdebug=3) then afficheDebug('Pas trouvé',clyellow); + if (i=itMaxi) and (Nivdebug=3) then afficheDebug('Pas trouvé',clyellow); if (N_det=Nb_det_dist) and (Nivdebug=3) then begin s:='Elements trop distants '+intToStr(det1)+' '+intToSTR(det2); @@ -7810,11 +8043,17 @@ begin elements[idEl].adresse:=adr; elements[idEl].typ:=TypeGen; + // modif spécial TJD ============== + ia:=index_aig(adrprec); + if aiguillage[ia].modele=tjd then + AdrFonc:=aiguillage[ia].Ddevie else + // ================================ + AdrFonc:=AdrPrec;TypeFonc:=TypePrec; AdrPrec:=Adr;TypePrec:=TypeGen; inc(i); - sortie:=(TypeGen=det) or (Adr=0) or (Adr>=9990) or (i=10); + sortie:=(TypeGen=det) or (Adr=0) or (Adr>=9990) or (i>=itMaxi); until sortie; if (TypeGen=det) or (TypeGen=buttoir) then @@ -7839,8 +8078,8 @@ begin reserve_dereserve_det:=0; exit; end; - end; - if (i=10) then if NivDebug=3 then AfficheDebug('201 : Itération trop longue',clred); + end; + if (i>=itMaxi) then if NivDebug=3 then AfficheDebug('201 : Itération trop longue',clred); inc(j); //AfficheDebug('j='+intToSTR(j),clyellow); until j=3; // boucle incrément/décrément @@ -7854,7 +8093,7 @@ end; // jamais utilisée ! function Test_croisement(el1,el2,alg: integer) : integer ; var IndexBranche_det1,IndexBranche_det2,branche_trouve_det1,branche_trouve_det2,i, - j,AdrPrec,Adr,AdrFonc,i1,N_det : integer; + j,AdrPrec,Adr,AdrFonc,i1,N_det,ia : integer; Sortie : boolean; TypePrec,TypeFonc : Tequipement; s : string; @@ -7939,17 +8178,23 @@ begin AfficheDebug(s,clYellow); end; + // modif spécial TJD ============== + ia:=index_aig(AdrFonc); + if aiguillage[ia].modele=tjd then + AdrPrec:=aiguillage[ia].Ddevie else + // ================================ + AdrPrec:=AdrFonc;TypePrec:=TypeFonc; AdrFonc:=Adr;TypeFonc:=typeGen; inc(i); - sortie:=((TypeGen=det) and (Adr=el2)) or (Adr=0) or (Adr>=9990) or (i=15) or (N_Det=Nb_det_dist); + sortie:=((TypeGen=det) and (Adr=el2)) or (Adr=0) or (Adr>=9990) or (i>=itMaxi) or (N_Det=Nb_det_dist); until sortie ; - if (i=15) and (Nivdebug=3) then afficheDebug('Pas trouvé',clyellow); + if (i>=itMaxi) and (Nivdebug=3) then afficheDebug('Pas trouvé',clyellow); if (N_det=Nb_det_dist) and (Nivdebug=3) then begin s:='Elements trop distants '+intToStr(el1)+' '+intToSTR(el2); afficheDebug(s,clorange); - end; + end; end else @@ -7957,13 +8202,13 @@ begin // déja trouvé adr:=el2;typeGen:=det; end; - + if (TypeGen=det) and (Adr=el2) and (N_Det<>Nb_det_dist) then begin test_croisement:=ncrois; exit; end; - if (i=10) then if NivDebug=3 then AfficheDebug('711 : Itération trop longue',clred); + if (i>=itMaxi) then if NivDebug=3 then AfficheDebug('711 : Itération trop longue',clred); inc(j); //AfficheDebug('j='+intToSTR(j),clyellow); until j=3; // boucle incrément/décrément @@ -7973,7 +8218,6 @@ begin if NivDebug=3 then affichedebug('------------------',clyellow); end; - // renvoie vrai si les aiguillages déclarés pour le feu blanc sont bien positionnés function cond_feuBlanc(adresse : integer) : boolean; var i,l,k,NCondCarre,adrAig,index : integer; @@ -8087,7 +8331,7 @@ end; // Si reserveTrainTiers=vrai, le parcours est réservé par un autre train function carre_signal(adresse,TrainReserve : integer;var reserveTrainTiers : boolean;Var AdrTrain : integer) : integer; var - i,j,k,prec,indexSignal,AdrSuiv,index2,voie,AdrSignal : integer; + ia,i,j,k,prec,indexSignal,AdrSuiv,index2,voie,AdrSignal : integer; TypeELPrec,TypeElActuel : TEquipement; sort,prestrain : boolean; s : string; @@ -8186,8 +8430,15 @@ begin exit; end; - if (AdrSuiv<>9998) then // arret sur aiguillage en talon mal positionnée + if (AdrSuiv<>9998) then // pas arret sur aiguillage en talon mal positionnée begin + // modif spécial TJD ============== + ia:=index_aig(Actuel); + if aiguillage[ia].modele=tjd then + prec:=aiguillage[ia].Ddevie else + // ================================ + + prec:=actuel; TypeElPrec:=TypeElActuel; actuel:=AdrSuiv; @@ -8265,8 +8516,9 @@ begin end; end; - sort:=(j=10) or (indexSignal<>0) or (AdrSuiv=9998) or (AdrSuiv=0); // arret si aiguillage en talon ou buttoir + sort:=(j>=itMaxi) or (indexSignal<>0) or (AdrSuiv=9998) or (AdrSuiv=0); // arret si aiguillage en talon ou buttoir until (sort); + if j>=itMaxi then Affiche('Erreur 76 : itération maximale',clred); // si trouvé un signal ou j=10, les aiguillages sont bien positionnés // si trouvé 9998, aiguillages mal positionnés if (NivDebug=3) then @@ -8284,7 +8536,7 @@ end; // renvoie l'adresse du signal suivant (et dans le bon sens) à partir du détecteur det1 (non compris) et dans le sens det1 vers det2. // Si renvoie 0, pas trouvé le signal suivant. function signal_suivant_det(det1,det2 : integer) : integer; -var num_signal,AdrSignal,i,j,prec,AdrSuiv,index2,voie : integer; +var num_signal,AdrSignal,i,j,prec,AdrSuiv,index2,voie,ia : integer; Typ,TypePrec,TypeActuel : TEquipement; s : string; begin @@ -8340,6 +8592,13 @@ begin AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,1); // arret sur élément suivant if Nivdebug=3 then AfficheDebug('Suivant='+intToSTR(AdrSuiv),clyellow); + // modif spécial TJD ============== + ia:=index_aig(actuel); + if aiguillage[ia].modele=tjd then + prec:=aiguillage[ia].Ddevie else + // ================================ + + prec:=actuel;TypePrec:=TypeActuel; actuel:=AdrSuiv;TypeActuel:=typeGen; @@ -8421,9 +8680,9 @@ begin end else if nivDebug=3 then AfficheDebug('Pas de signal pour le det '+IntToSTR(AdrSuiv),clyellow); end; - until (j=10) or (AdrSignal<>0); + until (j>=itMaxi) or (AdrSignal<>0); signal_suivant_det:=AdrSignal; - + if j>=itMaxi then affiche('Erreur 77 : itération maximale',clred); if debug=3 then formprinc.Caption:=''; if (NivDebug=3) and (AdrSignal=0) then AfficheDebug('Pas Trouvé de signal suivant au signal Adr='+IntToSTR(det1),clOrange); end; @@ -8447,7 +8706,7 @@ end; // stocke les éléments trouvés dans Elements function etat_signal_suivant(Adresse,rang : integer;var AdrSignalsuivant : integer) : integer; var index,num_signal,etat,AdrSignal,i,j,prec,AdrSuiv,index2,voie : integer; - aspect,combine : integer; + aspect,combine,ia : integer; TypePrec,TypeActuel,typ : TEquipement; s : string; begin @@ -8509,6 +8768,13 @@ begin if AdrSuiv=9996 then AfficheDebug('position aiguillage inconnue',clorange) else AfficheDebug('Suivant='+intToSTR(AdrSuiv),clyellow); end; + + // modif spécial TJD ============== + ia:=index_aig(Actuel); + if aiguillage[ia].modele=tjd then + Prec:=aiguillage[ia].Ddevie else + // ================================ + prec:=actuel;TypePrec:=TypeActuel; actuel:=AdrSuiv;TypeActuel:=typeGen; @@ -8621,18 +8887,20 @@ begin end else if nivDebug=3 then AfficheDebug('Pas de signal pour le det '+IntToSTR(AdrSuiv),clyellow); end; - until (j=10) or ((AdrSignal<>0) and (num_signal=rang)); + until (j>=20) or ((AdrSignal<>0) and (num_signal=rang)); + // laisser 20, il peut ne pas y avoir de signal suivant + if etat=0 then Signal_Suivant:=0; etat_signal_suivant:=Etat; AdrSignalsuivant:=Signal_suivant; - if (NivDebug=3) and (AdrSignal=0) then AfficheDebug('Pas Trouvé de signal suivant au signal Adr='+IntToSTR(ADresse),clOrange); + if (NivDebug=3) and (AdrSignal=0) then AfficheDebug('Pas trouvé de signal suivant au signal Adr='+IntToSTR(ADresse)+')',clOrange); end; // renvoie l'adresse de la première aiguille déviée après le signal "adresse" et ce jusqu'au prochain signal // sinon il n'y a pas d'aiguille ou si pas dévié, renvoie 0 // adresse=adresse du signal function Aiguille_deviee(adresse : integer) : integer ; -var AdrSignal,i,j,prec,AdrSuiv,Actuel,index,index2,voie : integer; +var AdrSignal,i,j,prec,AdrSuiv,Actuel,index,index2,voie,ia : integer; TypePrec,TypeActuel : TEquipement; s : string; begin @@ -8667,6 +8935,13 @@ begin if (AdrSuiv<>9997) and (AdrSuiv<>0) then begin // pas trouvé aig dévié + + // modif spécial TJD ============== + ia:=index_aig(Actuel); + if aiguillage[ia].modele=tjd then + Prec:=aiguillage[ia].Ddevie else + // ================================ + prec:=actuel;TypePrec:=TypeActuel; actuel:=AdrSuiv;TypeActuel:=typeGen; // si le suivant est un détecteur comporte t-il un signal? @@ -8678,17 +8953,19 @@ begin if NivDebug=3 then AfficheDebug('trouvé signal '+intToSTR(AdrSignal)+' associé au détecteur '+IntToSTR(AdrSuiv),clyellow); end; end; - until (j=10) or (AdrSuiv>=9990) or (AdrSignal<>0) or (AdrSuiv=0) ; + until (j>=itMaxi) or (AdrSuiv>=9990) or (AdrSignal<>0) or (AdrSuiv=0) ; + + if j>=itMaxi then affiche('Erreur 79 : itération maximale',clred); if (AdrSuiv=9997) then begin s:='Le signal '+intToSTR(adresse)+' doit afficher un rappel car l''aiguillage '+intToSTR(AdrDevie); s:=s+' est dévié'; if NivDebug=3 then AfficheDebug(s,clWhite); end; - if ((AdrSuiv<>9997) or (j=10)) and (NivDebug=3) then + if ((AdrSuiv<>9997) or (j>=itmaxi)) and (NivDebug=3) then begin S:='Le signal '+intToSTR(adresse)+' ne doit pas afficher de rappel car '; - if j<>10 then s:=s+'trouvé un signal suivant ('+intToSTR(AdrSignal)+') et pas d''aiguillage dévié' + if j0) and (index_train0) and (index_train0) and (index_train0) and (index_train0) and (index_train6) or trouve; - dec(j); - //si début de démarrage train i - if not(trouve) or (TrainZone[i].Nbre>0) then exit; - // affecter le nouveau détecteur - detecteur[det3].train:=Train_ch; - detecteur[det3].AdrTrain:=AdrTrainLoc; - detecteur[det3].IndexTrain:=i; - end; + + // affecter le nouveau détecteur + detecteur[det3].train:=Train_ch; + detecteur[det3].AdrTrain:=AdrTrainLoc; + detecteur[det3].IndexTrain:=i; AdrSuiv:=detecteur_suivant_el(det1,det,det3,det,1); if adrSuiv>NbMaxDet then @@ -10348,15 +10653,15 @@ begin if TraceListe then AfficheDebug(s,clyellow); if dupliqueEvt then Affiche(s,clyellow); - for tco:=1 to nbreTCO do + for ntco:=1 to nbreTCO do begin - if PcanvasTCO[tco]<>nil then + if PcanvasTCO[ntco]<>nil then begin // désactivation - Zone_TCO(tco,det1,det3,i,0); + Zone_TCO(ntco,det1,det3,i,AdrTrainLoc,0); // tco,det1,det2,train, mode // activation - if ModeCouleurCanton=0 then zone_TCO(tco,det3,AdrSuiv,i,1) - else zone_TCO(tco,det3,adrSuiv,i,2); // affichage avec la couleur de index_couleur du train + if ModeCouleurCanton=0 then zone_TCO(ntco,det3,AdrSuiv,i,AdrTrainLoc,1) + else zone_TCO(ntco,det3,adrSuiv,i,AdrTrainLoc,2); // affichage avec la couleur de index_couleur du train end; end; exit; // sortir absolument @@ -10364,9 +10669,9 @@ begin else begin Affiche_evt('1-0 Train '+intToSTR(i)+' Eléments '+intToSTR(det1)+' et '+intToSTR(det3)+' non contigus',clyellow); - - for tco:=1 to nbreTCO do - maj_tco(tco,det3); + + for ntco:=1 to nbreTCO do + maj_tco(ntco,det3); // det3 et det1 non adjacents end; end; @@ -10376,6 +10681,21 @@ begin if (nbre=1) and etat then begin if traceListe or ProcPrinc then AfficheDebug('1-1 Traitement Train n°'+intToSTR(i)+' 1 détecteur',clyellow); + + // si le détecteur est déja connu et que le nom du train est ok, l'affecter + // (on recoit un 2eme evt sur ce det à 1 depuis CDM avec le nom du train) + if (event_det_train[i].det[2].adresse=det3) then + begin + s:=detecteur[det3].Train; + if (s<>'_NONE') and (s<>'') then + begin + event_det_train[i].nom_train:=s; + l:=index_train_nom(s); + if l>0 then event_det_train[i].AdrTrain:=trains[l].adresse; + end; + exit; + end; + // vérifier si l'élément du tableau et le nouveau sont contigus Det_Adj(det1); // renvoie les adresses des détecteurs adjacents au détecteur "det1" résultat dans adj1 et adj2 suivok:=((Adj1=det3) and (adj1<9999)) or ((Adj2=det3) and (adj2<9990)); @@ -10389,12 +10709,12 @@ begin // en mode roulage, on a placé les trains //if roulage then begin - j:=1; + { j:=1; repeat - trouve:=placement[j].detdir=det3; + trouve:=trains[j].detdir=det3; inc(j); until (j>6) or trouve; - dec(j); + dec(j);} //si début de démarrage train i //if trouve and (TrainZone[i].Nbre=0) and (det10 then s:=s+' @'+intToSTR(AdrTrainLoc); s:=s+' '+Train_ch+' sur zones '+IntToSTR(det3)+' à '+IntToStr(AdrSuiv); @@ -10608,18 +10933,25 @@ begin AfficheDebug(intToSTR(event_det_train[i].det[2].adresse),couleur); end; - for tco:=1 to nbreTCO do + //Affiche('AdrTrainLoc='+inttoSTR(adrTrainLoc),clRed); + //Affiche('>>> Le canton 7 contient le train '+intToSTR(canton[7].indexTrain),clWhite); + + for ntco:=1 to nbreTCO do begin - if PcanvasTCO[tco]<>nil then + if PcanvasTCO[ntco]<>nil then begin - Maj_Aig_TCO(tco); - zone_TCO(tco,det2,det3,i,0); // désactivation + Maj_Aig_TCO(ntco); + zone_TCO(ntco,det2,det3,i,AdrTrainLoc,0); // désactivation // activation - if ModeCouleurCanton=0 then zone_TCO(tco,det3,AdrSuiv,i,1) - else zone_TCO(tco,det3,AdrSuiv,i,2); // affichage avec la couleur de index_couleur du train + //affiche('Efface train '+intToSTR(AdrTrainLoc),clred); + raz_cantons_train(AdrTrainLoc); // efface tous les cantons contenant le train + if ModeCouleurCanton=0 then zone_TCO(ntco,det3,AdrSuiv,i,AdrTrainLoc,1) + else zone_TCO(ntco,det3,AdrSuiv,i,AdrTrainLoc,2); // affichage avec la couleur de index_couleur du train end; end; + //Affiche('§§§ Le canton 7 contient le train '+intToSTR(canton[7].indexTrain),clWhite); + // mettre à jour si présence signal sur det3 pour le passer au rouge de suite j:=signal_detecteur(det3); if j<>0 then @@ -10647,9 +10979,10 @@ begin if (nbre=2) and etat then begin if TraceListe or (NivDebug=3) or ProcPrinc then AfficheDebug('2-1 traitement Train n°'+intToSTR(i)+' 2 détecteurs',couleur); - // front descendant sur détecteur 2 + det_suiv:=det_suiv_cont(det1,det2,1); // test si le suivant de det1 à det2 est bien le nouveau détecteur (det3) if traceliste then affichedebug('Le suivant aux '+intToSTR(det1)+' '+intToSTR(det2)+' est '+intToSTR(det_suiv),clWhite); + if (det_suiv=det3) and (det_suiv<9990) then begin event_det_tick[N_event_tick].train:=i; @@ -10714,7 +11047,7 @@ begin Affiche_evt(s,couleur); if traceListe then AfficheDebug(s,Couleur); if AffAigDet then AfficheDebug(s,couleur); - for tco:=1 to nbreTCO do + for ntco:=1 to nbreTCO do begin // désactivation du morceau avant l'aiguillage efface_trajet(det3,i); @@ -10746,7 +11079,7 @@ begin if TraceListe then AfficheDebug('La route est invalide car les détecteurs '+intToSTR(det1)+' '+intToSTR(det2)+' n''ont pas le '+intToSTR(det3)+' attendu',clOrange); s:='2-1 Train n°'+intToSTR(i)+' Route nok de '+intToSTR(det2)+' à '+IntToSTR(det3); Affiche_evt(s,couleur); - for tco:=1 to nbreTCO do + for ntco:=1 to nbreTCO do begin // désactivation du morceau avant l'aiguillage efface_trajet(det3,i); @@ -10855,20 +11188,39 @@ begin det[1].etat:=etat; NbEl:=1; nom_train:=detecteur[det3].train; + // Affiche('détecteur='+intToSTR(det3)+' '+nom_train,clWhite); AdrTrain:=detecteur[det3].AdrTrain; end; TrainZone[n_trains].train:=detecteur[det3].train; TrainZone[n_trains].AdrTrain:=detecteur[det3].Adrtrain; + + // chercher le train sur le canton par le détecteur det3 + { if roulage then begin - j:=index_train_adresse(detecteur[det3].AdrTrain); - j:=placement[j].detdir; // detecteur destination - MemZone[det3,j].etat:=true; - MemZone[det3,j].train:=detecteur[det3].train; - MemZone[det3,j].AdrTrain:=detecteur[det3].AdrTrain; - end; - MemZone[det3,j].IndexTrain:=n_trains; + n:=1; + repeat + d1:=canton[n].det1; + d2:=canton[n].det2; + if (d1=det3) or (d2=det3) then trouve:=true; + inc(n); + until (n>nCantons); + if trouve then // + begin + dec(n); + sens:=canton[n].sens; + //case sens of + //sensGauche : d1:= + j:=index_train_adresse(detecteur[det3].AdrTrain); + // j:=trains[j].detdir; // detecteur destination + MemZone[det3,j].etat:=true; + MemZone[det3,j].train:=detecteur[det3].train; + MemZone[det3,j].AdrTrain:=detecteur[det3].AdrTrain; + MemZone[det3,j].IndexTrain:=n_trains; + end; + end; } + s:=intToSTR(event_det_train[N_trains].det[1].adresse); id_couleur:=((N_trains - 1) mod NbCouleurTrain) +1; @@ -11254,7 +11606,8 @@ begin if (op=actionArretTrains) then begin Affiche(st+' Arrêt de tous les trains',clYellow); - for t:=1 to ntrains do vitesse_loco(trains[t].nom_train,t,trains[t].adresse,0,true); + for t:=1 to ntrains do + arret_train(trains[t].nom_train,t,trains[t].adresse); end; // 6 : Lance Horloge @@ -11346,7 +11699,7 @@ end; // lance les opérations de l'action action procedure action(action : integer); -var i,j,nb : integer; +var i,nb : integer; sort : boolean; begin nb:=tablo_actionneur[action].NbOperations; @@ -11359,6 +11712,49 @@ begin until (i>nb) or sort; end; + +// fait l'évènement vitesse train - appellé depuis réception trame CDM +procedure Event_vitesse(adr: integer ;train : string;vitesse : integer); +var i : integer; +begin + for i:=1 to MaxTablo_act do + begin + if (Tablo_actionneur[i].declencheur=DeclDemarTrain) then + begin + if (Tablo_actionneur[i].trainDecl=train) then + begin + if (vitesse>Tablo_actionneur[i].adresse) then + begin + if not(Tablo_actionneur[i].traite) and teste_condition(i) then + begin + Tablo_actionneur[i].traite:=true; + action(i); // exécute toutes les opérations de l'actionneur i + end + end + else Tablo_actionneur[i].traite:=false; + end; + end; + + if (Tablo_actionneur[i].declencheur=DeclArretTrain) then + begin + if (Tablo_actionneur[i].trainDecl=train) then + begin + if (vitesse0) and not(CDM_connecte) and (i_simule=0) then begin @@ -11724,8 +12108,8 @@ begin end; end; - s:=detecteur[adresse].train; - if (train='') and (s<>'') then train:=s; + //s:=detecteur[adresse].train; + //if (train='') and (s<>'') then train:=s; if Etat then Etat01:=1 else Etat01:=0; //Affiche('Event Det '+inTToSTR(adresse)+' '+IntToSTR(etat01),Cyan); @@ -11752,7 +12136,11 @@ begin ancien_detecteur[Adresse]:=detecteur[Adresse].etat; detecteur[Adresse].etat:=etat; - detecteur[Adresse].train:=train; + if train<>'_NONE' then + begin + detecteur[Adresse].train:=train; + detecteur[Adresse].AdrTrain:=index_train_nom(train); + end; detecteur_chgt:=Adresse; // stocke les changements d'état des détecteurs dans le tableau chronologique @@ -11857,6 +12245,10 @@ begin FormDebug.MemoEvtDet.lines.add('Raz sur débordement'); end; + // si on reçoit un evt det train, il faut le gérer + if etat and (train<>'_NONE') and not(confignulle) then + calcul_zones(adresse,true); + // Envoyer évent vers périphériques si le service est demandé for i:=1 to NbPeriph do begin @@ -11962,7 +12354,8 @@ begin end; end - else if AffAigND then affiche('Avertissement 47 : un evt aiguillage '+intToSTR(adresse)+' non déclaré a été reçu',clOrange); + else + if AffAigND then affiche('Avertissement 47 : un evt aiguillage '+intToSTR(adresse)+' non déclaré a été reçu',clOrange); // evt actionneur d'aiguillage for i:=1 to maxTablo_act do @@ -12060,7 +12453,7 @@ begin repeat inc(temps); Sleep(50); - Application.processMessages; + Application.processMessages; until fermeSC or ackCDM or nackCDM or (temps>20); // CDM répond < 1s //Affiche(intToSTR(temps),clred); if not(ackCDM) or nack then @@ -12116,8 +12509,7 @@ begin begin //AfficheDebug(intToSTR(adresse),clred); if debug_dec_sig and (acc=signal) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' '+intToSTR(pilotage),clorange); - //if aff_acc then - Affiche('Accessoire '+intToSTR(adresse)+' à '+intToSTR(pilotage),clorange); + if aff_acc then Affiche('Accessoire '+intToSTR(adresse)+' à '+intToSTR(pilotage),clorange); if pilotage=1 then pilotageCDM:=1; // 3 = wrong state or value if pilotage=2 then pilotageCDM:=2; @@ -13682,13 +14074,15 @@ begin deconnecte_USB; Affiche('Lance les fonctions automatiques de CDM',clyellow); SetForegroundWindow(formprinc.Handle); // met SC devant - Sleep(1500); // attend le lancement de CDM - if serveurIPCDM_touche then sleep(1000); + Sleep(250*TempoTC); + Application.processMessages; + Sleep(380*tempoTC); // attend le lancement de CDM + if serveurIPCDM_touche then sleep(250*tempoTC); ProcessRunning(s); // récupérer le handle de CDM SetForegroundWindow(CDMhd); // met CDM en premier plan pour le télécommander par le clavier simulé SetActiveWindow(CdmHd); Application.ProcessMessages; - if serveurIPCDM_Touche then sleep(1000); + if serveurIPCDM_Touche then sleep(380*tempoTC); // démarre le serveur IP de CDM par simulation de touches if serveurIPCDM_Touche then @@ -13711,16 +14105,16 @@ begin // envoie les touches i:=SendInput(Length(KeyInputs),KeyInputs[0],SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); // la fenetre serveur démarré est affichée - Sleep(400); + Sleep(200*tempoTC); Application.ProcessMessages; end; KeybdInput(VK_RETURN,0); KeybdInput(VK_RETURN,KEYEVENTF_KEYUP); - SendInput(Length(KeyInputs),KeyInputs[0],SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); //fermer la fenetre - Sleep(500); + SendInput(Length(KeyInputs),KeyInputs[0],SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); //fermer la fenetre du serveur ip + Sleep(200*tempoTC); connecte_CDM; - Sleep(400); + Sleep(300*tempoTC); Application.processMessages; // Serveur d'interface -------------------------------------- @@ -13739,7 +14133,7 @@ begin KeybdInput(VK_RETURN,0); KeybdInput(VK_RETURN,KEYEVENTF_KEYUP); SendInput(Length(KeyInputs), KeyInputs[0], SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); // affiche la fenetre d'interface - Sleep(400); + Sleep(180*tempoTC); // descendre le curseur n fois pour sélectionner le serveur for i:=1 to ServeurInterfaceCDM-1 do @@ -13752,7 +14146,7 @@ begin KeybdInput(VK_TAB,0);KeybdInput(VK_TAB,KEYEVENTF_KEYUP); KeybdInput(VK_SPACE,0);KeybdInput(VK_SPACE,KEYEVENTF_KEYUP); SendInput(Length(KeyInputs), KeyInputs[0], SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); - Sleep(400); + Sleep(180*tempoTC); // Interface if (ServeurInterfaceCDM=1) or (ServeurInterfaceCDM=5) then @@ -13777,15 +14171,22 @@ begin // TAB pour sélectionner OK KeybdInput(VK_TAB,0);KeybdInput(VK_TAB,KEYEVENTF_KEYUP); SendInput(Length(KeyInputs),KeyInputs[0],SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); - Sleep(200); + Sleep(200*tempoTC); end; KeybdInput(VK_SPACE,0);KeybdInput(VK_SPACE,KEYEVENTF_KEYUP); // valide la fenetre d'interface SendInput(Length(KeyInputs), KeyInputs[0], SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); - Sleep(400); + Sleep(400*tempoTC); + application.ProcessMessages; KeybdInput(VK_RETURN,0);KeybdInput(VK_RETURN, KEYEVENTF_KEYUP); // valide la fenetre finale SendInput(Length(KeyInputs), KeyInputs[0], SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); + + Sleep(200*tempoTC); + application.ProcessMessages; + KeybdInput(VK_RETURN,0);KeybdInput(VK_RETURN, KEYEVENTF_KEYUP); // valide la fenetre finale + SendInput(Length(KeyInputs), KeyInputs[0], SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); + end; end; end; @@ -13802,7 +14203,7 @@ end; // supprime les events, les trains etc Procedure Raz_tout; -var i,j,index : integer; +var i,j,index,Bim : integer; begin N_Event_tick:=0; N_event_det:=0; @@ -13869,11 +14270,27 @@ begin Tablo_Pn[i].compteur:=0; end; + For i:=1 to ncantons do + begin + canton[i].indexTrain:=0; + canton[i].adresseTrain:=0; + canton[i].NomTrain:=''; + end; + + for i:=1 to Ntrains do + begin + trains[i].canton:=0; + end; + for index:=1 to NbreTCO do begin for i:=1 to NbreCellx[index] do for j:=1 to NbreCelly[index] do + begin + Bim:=tco[index,i,j].BImage; tco[index,i,j].mode:=0; + tco[index,i,j].train:=0; + end; if pCanvasTCO[index]<>nil then affiche_TCO(index); end; @@ -14336,6 +14753,60 @@ begin if trouve then result:=i-1; end; +function Index_Condition(s : string) : integer; +var i : integer; + trouve : boolean; +begin + i:=1; + result:=0; + repeat + trouve:=pos(conditions[i].nom,s)<>0; + inc(i); + until trouve or (i>NbreConditions); + if trouve then result:=i-1; +end; + +procedure init_conditions; +begin + with Conditions[CondVrai] do + begin + nom:='Toujours vrai'; + index:=CondVrai; + famille:=0; + end; + with Conditions[CondFaux] do + begin + nom:='Toujours faux'; + index:=CondFaux; + famille:=0; + end; + with Conditions[CondVitTrain] do + begin + nom:='Vitesse train'; + index:=CondVitTrain; + famille:=0; + end; + with Conditions[CondPosAcc] do + begin + nom:='Position d''accessoire'; + index:=CondPosAcc; + famille:=0; + end; + with Conditions[CondHorl] do + begin + nom:='Horloge'; + index:=CondHorl; + famille:=0; + end; + with Conditions[CondTrainSig] do + begin + nom:='Train arrêté au signal'; + index:=CondTrainSig; + famille:=0; + end; + NbreConditions:=CondTrainSig; +end; + procedure init_declencheurs; begin with declencheurs[Decl0] do @@ -14374,7 +14845,25 @@ begin index:=DeclZoneDet; famille:=2; end; - Nbredeclencheurs:=5; + with declencheurs[DeclDemarTrain] do + begin + nom:='Démarrage de train'; + index:=DeclDemarTrain; + famille:=2; + end; + with declencheurs[DeclArretTrain] do + begin + nom:='Arrêt d''un train'; + index:=DeclArretTrain; + famille:=2; + end; + with declencheurs[DeclSignal] do + begin + nom:='Signal'; + index:=DeclSignal; + famille:=2; + end; + Nbredeclencheurs:=DeclSignal; end; function Index_Declencheur(s : string) : integer; @@ -14390,6 +14879,7 @@ begin if trouve then result:=i-1; end; + // démarrage principal du programme signaux_complexes procedure TFormPrinc.FormCreate(Sender: TObject); var n,t,i,index,OrgMilieu : integer; @@ -14418,13 +14908,15 @@ begin horloge:=false; ntrains:=0; + TempoTC:=5; mode_reserve:=0; // mode_reserve 0 = par canton - 1=par détecteurs ntrains_cdm:=0; protocole:=1; filtrageDet0:=3; cdmHd:=0; CouleurFond:=$404040 ; - couleurAction:=$606060; + couleurAction:=$404040; + couleurCanton:=$303030; // services commIP CDM par défaut Srvc_Aig:=true; @@ -14480,6 +14972,7 @@ begin Algo_localisation:=1; // normal nCantonsRes:=2; AntiTimeoutEthLenz:=0; + nCantons:=0; Verif_AdrXpressNet:=1; Max_Signal_Sens:=5; portServeur:=4500; @@ -14501,8 +14994,25 @@ begin Decodeur[9]:='LS-DEC-NMBS';Decodeur[10]:='B-models'; init_operations; + init_conditions; init_declencheurs; + // créer icones des trains + for i:=1 to Max_Trains do + begin + Trains[i].icone:=Timage.create(self); + with Trains[i].icone do + begin + autosize:=true; + align:=alNone; + parent:=nil; + name:='IconeTrain'+intToSTR(i); + top:=0;left:=0; + width:=200; + height:=100; + end; + end; + if versionSC='8.53' then begin Horaires1.enabled:=false; @@ -14686,6 +15196,7 @@ begin lire_fichier_tco(i); end; + verif_coherence; procetape('La configuration a été lue'); @@ -14713,7 +15224,41 @@ begin cree_image(i); // et initialisation tableaux signaux end; - Tempo_init:=5; // démarre les initialisation des signaux et des aiguillages dans 0,5 s + procetape('Mise à jour des trains cantons'); + // affecter les trains au cantons + for i:=1 to Ntrains do + begin + n:=trains[i].canton; + if n>nCantons then + begin + Affiche('Anomalie canton numéro '+intToSTR(n)+' train index='+intToSTR(i)+' - forçage à 0',clred); + n:=0; + trains[i].canton:=0; + end; + if n<>0 then + begin + t:=index_canton_numero(n); + ProcEtape('Train '+intToSTR(i)+' canton numéro '+intToSTR(n)); + affecte_Train_canton(trains[i].adresse,t); + end; + end; + + procetape('Affecter les sens des trains aux cantons'); + // affecter les sens des trains dans les cantons + for i:=1 to nCantons do + begin + t:=canton[i].indexTrain; + if t>nTrains then + begin + Affiche('Anomalie train index='+intToSTR(t)+'au canton '+intToSTR(i)+' - forçage à 0',clred); + t:=0; + canton[i].Sens:=0; + end + else + canton[i].Sens:=trains[t].sens; + end; + + Tempo_init:=5; // démarre les initialisations des signaux et des aiguillages dans 0,5 s OrgMilieu:=formprinc.width div 2; with statusbar1 do @@ -14750,7 +15295,7 @@ begin formTCO[index]:=nil; end else - if avecTCO then Affiche_Fenetre_TCO(index,avecTCO); + end; // ouvre les périphériques commandes actionneurs, car on a lu les com dans la config @@ -14852,7 +15397,7 @@ begin end; //Menu_interface(valide); end; - raz_tout; + { //DoubleBuffered:=true; aiguillage[index_aig(1)].position:=const_devie; @@ -15040,6 +15585,7 @@ begin vitesse:=grilleHoraire[i].vitesse; if not(grilleHoraire[i].sens) then vitesse:=-vitesse; Affiche('Démarrage train '+train+' à l''horaire '+format('%.2dh%.2d',[heure,minute]),clyellow); + FormFicheHoraire.StringGridFO.Cells[1,i]:=GrilleHoraire[i].NomTrain+' Départ'; Demarre_index_train(index_train_nom(train)); //vitesse_loco(train,0,adr,vitesse,true); end; @@ -15088,7 +15634,6 @@ begin faire:=(tablo_actionneur[i].TabloOp[a].numoperation=ActionTempo); inc(a); until (a>n) or faire; - end; end; @@ -15135,7 +15680,7 @@ begin gestion_horaire; // au chgt minute if (heure=RetourHeure) and (minute=RetourMinute) then begin - heure:=heureinit;Minute:=minuteInit; + init_horloge; Affiche('Horloge en initialisation',clyellow); if not(relanceHorl_init) then begin @@ -15338,27 +15883,36 @@ begin if a<>0 then begin dec(a); + //Affiche('tempo arret'+intToSTR(a),clWhite); trains[i].TempoArret:=a; if a=0 then vitesse_loco(trains[i].nom_train,i,trains[i].adresse,0,false) else if (a mod 10)=0 then begin vitesse:=trains[i].VitRalenti div 2; - if (placement[i].inverse) then vitesse:=-vitesse; + if (trains[i].inverse) then vitesse:=-vitesse; //Affiche('train'+intToSTR(i)+' '+intToSTR(vitesse),clred); vitesse_loco(trains[i].nom_train,i,trains[i].adresse,vitesse,false); end; - end; a:=trains[i].TempoDemarre; if a<>0 then begin + //Affiche('tempo démarre '+intToSTR(a)+' '+intToSTR(trains[i].TempsDemarreSig-5),clWhite); + if a=(trains[i].TempsDemarreSig*10)-5 then // renvoi consigne d'arret 5x1/10 de secondes apres + begin + s:=trains[i].nom_train; + //s:=chaine_CDM_vitesseST(1,s); + s:=chaine_CDM_StopTrainST(s); + envoi_cdm(s); + end; + dec(a); trains[i].TempoDemarre:=a; if a=0 then begin vitesse:=trains[i].VitNominale; - if (placement[i].inverse) then vitesse:=-vitesse; + if (trains[i].inverse) then vitesse:=-vitesse; vitesse_loco(trains[i].nom_train,i,trains[i].adresse,vitesse,false); end; end; @@ -15367,11 +15921,12 @@ begin if a<>0 then begin dec(a); + //Affiche('consigne '+intToSTR(a),clWhite); trains[i].compteur_consigne:=a; if a=0 then begin vitesse:=trains[i].Vitesse; - if (placement[i].inverse) then vitesse:=-vitesse; + if (trains[i].inverse) then vitesse:=-vitesse; vitesse_loco(trains[i].nom_train,i,trains[i].adresse,vitesse,false); end; //Affiche('vitesse ' +intToSTR(i)+' '+intToSTR(trains[i].vitesse),clred); @@ -15698,7 +16253,7 @@ procedure deconnecte_socket_periph(index : integer); begin if (index>NbMaxi_Periph) or (index=0) then begin - Affiche('Erreur 62 : numéro de périphérique hors limite ',clred); + Affiche('Erreur 627 : numéro de périphérique hors limite ',clred); exit; end; if tablo_periph[index].PortOuvert then @@ -15942,10 +16497,10 @@ end; // la trame_CDM peut contenir 2000 caractères à l'initialisation du RUN. procedure Interprete_trameCDM(trame_CDM:string); var i,j,objet,k,l,erreur,posErr,adr,adr2,etat,etataig, - vitesse,etatAig2,name,prv,nbre,nbreVir,long,index,posDes,AncNumTrameCDM : integer ; + vitesse,etatAig2,name,prv,nbre,nbreVir,long,index,posDes,AncNumTrameCDM,idt : integer ; x,y,x2,y2 : longint ; nom,s,ss,train,commandeCDM : string; - traite,sort : boolean; + traite,sort,trouve : boolean; label reprise; begin { @@ -15996,27 +16551,50 @@ begin begin //if debugTrames then Affiche('Longueur nulle',clYellow); if pos('ACK',trame_cdm)<>0 then Ack_cdm:=true; - if pos('DSCTRN-__END',trame_cdm)<>0 then + if (pos('DSCTRN-__END',trame_cdm)<>0) and (ntrains_CDM<>0) then begin //fin de la description des trains FormPrinc.ComboTrains.Items.Clear; // on remplace les trains du combo et de la base (non stockée) + // dans la même adresse que l'existante + // ne pas écraser j for i:=1 to ntrains_cdm do begin - Formprinc.ComboTrains.Items.Add(trains_cdm[i].nom_train); - Trains[i].nom_train:=trains_cdm[i].nom_train; - Trains[i].adresse:=Trains_cdm[i].adresse; - Trains[i].vitmax:=Trains_cdm[i].vitmax; + l:=1; + repeat + trouve:=trains[l].adresse=trains_cdm[i].adresse; + if trouve then + begin + //affiche('train '+intToSTR(trains_cdm[i].adresse)+' trouvé dans l''existant',clLime); + Formprinc.ComboTrains.Items.Add(trains_cdm[i].nom_train); + Trains[l].nom_train:=trains_cdm[i].nom_train; + Trains[l].adresse:=Trains_cdm[i].adresse; + Trains[l].vitmax:=Trains_cdm[i].vitmax; + end; + inc(l); + until (l>ntrains) or trouve; + + if not(trouve) then + begin + inc(ntrains); + //affiche('train '+intToSTR(trains_cdm[i].adresse)+' créé',clLime); + + Trains[ntrains].nom_train:=trains_cdm[i].nom_train; + Trains[ntrains].adresse:=Trains_cdm[i].adresse; + Trains[ntrains].vitmax:=Trains_cdm[i].vitmax; + end; end; - ntrains:=ntrains_cdm; + + // vérifier si pas doublon adresse train + verif_trains; + + //ntrains:=ntrains_cdm; with formprinc do begin ComboTrains.ItemIndex:=0; editadrtrain.Text:=inttostr(trains_cdm[1].adresse); end; - - end; delete(trame_cdm,1,j); goto reprise; @@ -16134,7 +16712,7 @@ begin nom:=ss; Delete(commandeCDM,i,l-i+1); end; - + i:=posEx('OBJ=',commandeCDM,1);l:=posEx(';',commandeCDM,i); if (i<>0) and (l<>0) then begin @@ -16303,7 +16881,7 @@ begin val(ss,objet,erreur); Delete(commandeCDM,i,l-i+1); end; - + //if etat=1 then Affiche(intToSTR(adr)+' '+TRain,clWhite); Event_detecteur(Adr,etat=1,train); end ; @@ -16475,6 +17053,13 @@ begin Delete(commandeCDM,i,l-i+1); end; if horloge then verifie_train_horaire(adr,train,vitesse); + + idt:=index_train_adresse(adr); + if idt>0 then + begin + trains[idt].vitesse:=vitesse; + end; + Event_vitesse(adr,train,vitesse); // déclenche évent actionneur vitesse train // fait bouger le train dans la fenetre cdm if fichier_module_CDM then Aff_train(adr,train,x,y,x2,y2); if afftiers then afficheDebug(s,clAqua); @@ -17350,7 +17935,7 @@ begin if Cond_Carre(Adresse) then s:=s+'les aiguillages déclarés dans la définition du signal sont mal positionnés'+#13; if Signaux[i].VerrouCarre and not(PresTrainPrec(Adresse,Nb_cantons_Sig,false,TrainReserve,voie)) then s:=s+'le signal est verrouillable au carré et aucun train n''est présent avant le signal'+#13; if test_memoire_zones(Adresse) then s:=s+'présence train dans canton suivant le signal'+#13; - if Signaux[i].EtatVerrouCarre then s:=s+'le signal est verrouillé au carré dans la fenêtre de pilotage'+#13; + // if Signaux[i].EtatVerrouCarre then s:=s+'le signal est verrouillé au carré dans la fenêtre de pilotage'+#13; end; if (aspect=vert_jaune_H) and (nation=2) then @@ -17374,7 +17959,7 @@ begin if Cond_Carre(Adresse) then s:=s+'les aiguillages déclarés dans la définition du signal sont mal positionnés'+#13; if Signaux[i].VerrouCarre and not(PresTrainPrec(Adresse,Nb_cantons_Sig,false,TrainReserve,voie)) then s:=s+'le signal est verrouillable au carré et aucun train n''est présent avant le signal'+#13; if test_memoire_zones(Adresse) then s:=s+'présence train dans canton suivant le signal'+#13; - if Signaux[i].EtatVerrouCarre then s:=s+'le signal est verrouillé au rouge dans la fenêtre de pilotage'+#13; + //if Signaux[i].EtatVerrouCarre then s:=s+'le signal est verrouillé au rouge dans la fenêtre de pilotage'+#13; end; end; // avertissement ou deux-jaunes (belge) @@ -17648,7 +18233,7 @@ begin envoi(s); end; -procedure TFormPrinc.Placerlestrains1Click(Sender: TObject); +procedure TFormPrinc.OpRoulageClick(Sender: TObject); begin if PlaceAffiche then begin @@ -17657,7 +18242,7 @@ begin Affiche('Placement des trains incompatible en mode CDM rail',clOrange); exit; end; - formplace.showmodal; + formRoulage.showmodal; end; end; @@ -17671,6 +18256,7 @@ begin else Affiche('L''interface n''est pas connectée par USB ou par Ethernet',clorange); end; +{ // place les trains, positionne aiguillages et lance le roulage procedure placement_trains; var adr,AdrTrain,i,j,vitesse : integer; @@ -17680,10 +18266,10 @@ begin trouve:=false; for i:=1 to 6 do begin - Adr:=placement[i].detecteur; + Adr:=trains[i].detecteur; if adr<>0 then begin - detecteur[Adr].train:=placement[i].train; + detecteur[Adr].train:=trains[i].nom_train; detecteur[Adr].AdrTrain:=trains[i].adresse; event_detecteur(Adr,true,trains[i].nom_train); Affiche('Positionnement train '+detecteur[Adr].train+' sur détecteur '+intToSTR(Adr),clLime); @@ -17703,7 +18289,7 @@ begin j:=index_train_adresse(AdrTrain); vitesse:=trains[j].VitNominale; - if (placement[j].inverse) then vitesse:=-vitesse; + if (trains[j].inverse) then vitesse:=-vitesse; vitesse_loco('',j,adrTrain,vitesse,true); trouve:=true; @@ -17711,7 +18297,7 @@ begin end; end; if trouve then Maj_Signaux(true); -end; +end; } procedure TFormPrinc.Button1Click(Sender: TObject); begin @@ -18678,7 +19264,7 @@ begin end; procedure Supprimer_TCO(TcoS : integer); -var i,SauvNbreTCO : integer; +var c,x,y,i,SauvNbreTCO : integer; s : string; begin if Tcos>NbreTCO then exit; @@ -18690,6 +19276,18 @@ begin TCOActive:=false; Affiche('Suppression du TCO '+intToSTR(Tcos),clOrange); + + // supprimer les cantons + for y:=1 to NbreCellY[tcos] do + for x:=1 to NbreCellX[tcos] do + begin + if isCanton(tco[tcos,x,y].Bimage) then + begin + c:=tco[tcos,x,y].PiedFeu; + if c<>0 then supprime_canton(c); + end; + end; + FormTCO[tcos].Release; // annuler le pointeur et raz les mémoires de la form for i:=tCos to SauvNbreTCO-1 do @@ -19094,8 +19692,60 @@ begin inherited; end; - +procedure TFormPrinc.Codificationdescantons1Click(Sender: TObject); + var i : integer; + s : string; +begin + Affiche('Etat des cantons',clWhite); + for i:=1 to ncantons do + begin + s:=intToSTR(i)+' num='+IntToSTR(canton[i].numero); + if canton[i].horizontal then s:=s+' H ' else s:=s+' V '; + s:=s+' TCO'+intToSTR(canton[i].nTco)+' x='+intToSTR(canton[i].x)+' y='+ + intToSTR(canton[i].y)+' Nel='+intToSTR(canton[i].Nelements)+' '+canton[i].nom+ + ' IndexTrain='+intToSTR(Canton[i].indexTrain)+' train='+Canton[i].NomTrain+ + ' El contigu1='+intToSTR(canton[i].el1); + if canton[i].typ1=aig then s:=s+' Aig' else s:=s+' Det'; + s:=s+' El contigu2='+intToSTR(canton[i].el2); + if canton[i].typ2=aig then s:=s+' Aig' else s:=s+' Det'; + Affiche(s,clyellow); + end; +end; + +procedure affiche_routes; +var i,j,v : integer; + s : string; +begin + for i:=1 to N_trains do + begin + v:=event_det_train[i].AdrTrain; + s:=intToSTR(i)+' AdresseTrain='+intToSTR(v)+' '+event_det_train[i].nom_train+' '; + v:=event_det_train[i].NbEl; + s:=s+' NbEl='+intToSTR(v)+' '; + Affiche(s,clWhite); + for j:=1 to v do + begin + s:=' -> El='+intToSTR(j)+' '+intToSTR(event_det_train[i].Det[j].adresse)+' état='; + if event_det_train[i].Det[j].etat then s:=s+'1' else s:=s+'0'; + Affiche(s,clwhite); + end; + end; +end; + +procedure TFormPrinc.Button2Click(Sender: TObject); +var s : string; +begin + affiche_routes; +end; + +procedure TFormPrinc.Button3Click(Sender: TObject); +begin + nivdebug:=3; + det_adj(563); + Affiche(intToSTR(adj1)+' '+intToSTR(adj2),clred); + nivDebug:=0; +end; end. diff --git a/UnitTCO.dfm b/UnitTCO.dfm index 38677cc..6b98ae2 100644 --- a/UnitTCO.dfm +++ b/UnitTCO.dfm @@ -1,8 +1,8 @@ object FormTCO: TFormTCO - Left = 58 - Top = 115 - Width = 1220 - Height = 594 + Left = 116 + Top = 138 + Width = 1219 + Height = 612 VertScrollBar.Visible = False Caption = 'c' Color = clBtnFace @@ -24,12 +24,12 @@ object FormTCO: TFormTCO OnKeyPress = FormKeyPress OnMouseWheel = FormMouseWheel DesignSize = ( - 1212 - 543) + 1211 + 561) PixelsPerInch = 96 TextHeight = 13 object LabelZoom: TLabel - Left = 1170 + Left = 1169 Top = 0 Width = 32 Height = 13 @@ -43,24 +43,27 @@ object FormTCO: TFormTCO ParentFont = False end object ImageTemp: TImage - Left = 1023 - Top = 0 + Left = 1022 + Top = 8 Width = 121 Height = 121 + Hint = 'haha' Anchors = [akTop, akRight] + ParentShowHint = False + ShowHint = True end object ImageTemp2: TImage - Left = 1022 - Top = 129 - Width = 121 - Height = 121 + Left = 894 + Top = 137 + Width = 248 + Height = 256 Anchors = [akTop, akRight] end object ScrollBox: TScrollBox Left = 8 Top = 12 - Width = 692 - Height = 347 + Width = 691 + Height = 365 HorzScrollBar.Smooth = True HorzScrollBar.Tracking = True VertScrollBar.Smooth = True @@ -71,13 +74,13 @@ object FormTCO: TFormTCO ParentColor = False TabOrder = 1 DesignSize = ( - 688 - 343) + 687 + 361) object ImageTCO: TImage Left = 120 Top = 41 - Width = 491 - Height = 257 + Width = 490 + Height = 275 Anchors = [akLeft, akTop, akRight, akBottom] AutoSize = True ParentShowHint = False @@ -85,13 +88,14 @@ object FormTCO: TFormTCO ShowHint = True OnDblClick = ImageTCODblClick OnDragOver = ImageTCODragOver + OnEndDrag = ImageTCOEndDrag OnMouseDown = ImageTCOMouseDown OnMouseMove = ImageTCOMouseMove OnMouseUp = ImageTCOMouseUp end end object TrackBarZoom: TTrackBar - Left = 1168 + Left = 1167 Top = 15 Width = 41 Height = 311 @@ -109,8 +113,8 @@ object FormTCO: TFormTCO end object PanelBas: TPanel Left = 0 - Top = 395 - Width = 1204 + Top = 413 + Width = 1203 Height = 140 Anchors = [akLeft, akRight, akBottom] Color = clActiveBorder @@ -123,7 +127,7 @@ object FormTCO: TFormTCO TabOrder = 2 OnDragOver = PanelBasDragOver DesignSize = ( - 1204 + 1203 140) object Label1: TLabel Left = 240 @@ -905,8 +909,33 @@ object FormTCO: TFormTCO Font.Style = [fsBold] ParentFont = False end + object ImagePalette53: TImage + Left = 960 + Top = 107 + Width = 33 + Height = 33 + Hint = 'Canton' + ParentShowHint = False + ShowHint = True + OnDragOver = ImagePalette53DragOver + OnEndDrag = ImagePalette53EndDrag + OnMouseDown = ImagePalette53MouseDown + end + object Label53: TLabel + Left = 936 + Top = 110 + Width = 18 + Height = 19 + Caption = '53' + Font.Charset = ANSI_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Arial' + Font.Style = [fsBold] + ParentFont = False + end object ButtonSauveTCO: TButton - Left = 1095 + Left = 1094 Top = 8 Width = 96 Height = 33 @@ -918,7 +947,7 @@ object FormTCO: TFormTCO OnClick = ButtonSauveTCOClick end object ButtonConfigTCO: TButton - Left = 1095 + Left = 1094 Top = 48 Width = 96 Height = 33 @@ -929,7 +958,7 @@ object FormTCO: TFormTCO OnClick = ButtonConfigTCOClick end object ButtonSimu: TButton - Left = 883 + Left = 882 Top = 80 Width = 113 Height = 25 @@ -1122,7 +1151,7 @@ object FormTCO: TFormTCO end end object buttonRaz: TButton - Left = 1096 + Left = 1095 Top = 88 Width = 97 Height = 33 @@ -1134,7 +1163,7 @@ object FormTCO: TFormTCO OnClick = buttonRazClick end object ButtonCalibrage: TButton - Left = 923 + Left = 922 Top = 56 Width = 75 Height = 25 @@ -1145,7 +1174,7 @@ object FormTCO: TFormTCO OnClick = ButtonCalibrageClick end object ButtonDessiner: TButton - Left = 992 + Left = 991 Top = 48 Width = 97 Height = 33 @@ -1161,7 +1190,7 @@ object FormTCO: TFormTCO OnClick = ButtonDessinerClick end object ButtonAffSC: TButton - Left = 992 + Left = 991 Top = 8 Width = 97 Height = 33 @@ -1173,7 +1202,7 @@ object FormTCO: TFormTCO OnClick = ButtonAffSCClick end object RadioGroupSel: TRadioGroup - Left = 844 + Left = 843 Top = 8 Width = 138 Height = 49 @@ -1191,6 +1220,14 @@ object FormTCO: TFormTCO TabOrder = 8 OnClick = RadioGroupSelClick end + object Button1: TButton + Left = 1032 + Top = 96 + Width = 75 + Height = 25 + Caption = 'Button1' + TabOrder = 9 + end end object PopupMenu1: TPopupMenu OnPopup = PopupMenu1Popup @@ -1294,6 +1331,17 @@ object FormTCO: TFormTCO OnClick = ColonneClick end end + object N9: TMenuItem + Caption = '-' + end + object Affecterlocomotiveaucanton1: TMenuItem + Caption = 'Affecter/d'#233'saffecter locomotive au canton' + OnClick = Affecterlocomotiveaucanton1Click + end + object Supprimercanton1: TMenuItem + Caption = 'Supprimer le canton' + OnClick = Supprimercanton1Click + end object N6: TMenuItem Caption = '-' end diff --git a/UnitTCO.pas b/UnitTCO.pas index 484ec32..32c61a5 100644 --- a/UnitTCO.pas +++ b/UnitTCO.pas @@ -1,7 +1,6 @@ unit UnitTCO; // ne pas utiliser les éléments 30 et 31 qui sont les anciens signaux et quais interface - uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids , UnitPrinc, StdCtrls, ExtCtrls, Menus, UnitPilote, UnitDebug, @@ -153,6 +152,12 @@ type Signalvertical180: TMenuItem; RafrachirleTCO1: TMenuItem; RechargerleTCOdepuislefichier1: TMenuItem; + ImagePalette53: TImage; + Label53: TLabel; + Supprimercanton1: TMenuItem; + N9: TMenuItem; + Affecterlocomotiveaucanton1: TMenuItem; + Button1: TButton; //TimerTCO: TTimer; procedure FormCreate(Sender: TObject); procedure FormActivate(Sender: TObject); @@ -197,7 +202,6 @@ type procedure MenuCollerClick(Sender: TObject); procedure ButtonRedessineClick(Sender: TObject); procedure EditAdrElementChange(Sender: TObject); - procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure ImagePalette10EndDrag(Sender, Target: TObject; X, Y: Integer); procedure ImagePalette10MouseDown(Sender: TObject; Button: TMouseButton; @@ -405,11 +409,11 @@ type procedure ImagePalette34MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure EditAdrElementClick(Sender: TObject); - procedure ImagePalette52DragOver(Sender, Source: TObject; X, + procedure ImagePalette53DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); procedure ImagePalette52EndDrag(Sender, Target: TObject; X, Y: Integer); - procedure ImagePalette52MouseDown(Sender: TObject; + procedure ImagePalette53MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure ButtonAffSCClick(Sender: TObject); procedure RadioGroupSelClick(Sender: TObject); @@ -423,8 +427,17 @@ type procedure AfficherSignauxComplexes1Click(Sender: TObject); procedure Signalvertical180Click(Sender: TObject); procedure RechargerleTCOdepuislefichier1Click(Sender: TObject); - - private + procedure Supprimercanton1Click(Sender: TObject); + procedure Affecterlocomotiveaucanton1Click(Sender: TObject); + procedure ImagePalette52MouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + procedure ImagePalette52DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette53EndDrag(Sender, Target: TObject; X, + Y: Integer); + procedure ImageTCOEndDrag(Sender, Target: TObject; X, Y: Integer); + + private { Déclarations privées } function index_TCOMainMenu : integer; public @@ -432,6 +445,11 @@ type end; const + MaxCantons=100; + SensGauche=1; + SensDroit=2; + SensHaut=3; + SensBas=4; MaxCellX=150;MaxCellY=70; licone=26; // largeur icone du bas 35 hicone=licone; @@ -461,13 +479,17 @@ const Id_signal=50; Id_Quai=51; Id_action=52; + Id_canton=53; // codification de l'icone à la dépose + Id_cantonH=60; // codifications de l'icone dans le TCO + Id_cantonV=70; // " + // liaisons des voies pour chaque icone par bit (0=NO 1=Nord 2=NE 3=Est 4=SE 5=S 6=SO 7=Ouest) - Liaisons : array[0..52] of integer= + Liaisons : array[0..53] of integer= // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 (0,$88,$c8,$8c,$98,$89,$9,$84,$90,$48,$44,$11,$19,$c4,$91,$4c,$21,$24,$42,$12,$22,$cc,$99,$66,$23,$33,$26,$62,$32,$31,0,0, - // 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 - $64,$13,$46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ; + // 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 + $64,$13,$46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ; type // structure d'une cellule du TCO TTCO = record @@ -485,13 +507,13 @@ type TailleFonte : integer; CouleurFond : Tcolor; // couleur de fond // pour les signaux seulement ou action - PiedFeu : integer; // type de pied au signal : signal à gauche=1 ou à droite=2 de la voie OU si action: type d'action + PiedFeu : integer; // type de pied au signal : signal à gauche=1 ou à droite=2 de la voie OU si action: type d'action OU numerocanton x,y : integer; // coordonnées pixels relativés du coin sup gauche du signal pour le décalage par rapport au 0,0 cellule Xundo,Yundo : integer; // coordonnées x,y de la cellule pour le undo - FeuOriente : integer; // orientation du signal : 1 vertical en bas / 2 horizontal gauche / 3 horizontal droit / OU si action : numéro du TCO etc + FeuOriente : integer; // orientation du signal : 1 vertical en bas / 2 horizontal gauche / 3 horizontal droit / OU si action : numéro du TCO etc / OU Nbre éléments du canton liaisons : integer; // quadrants des liaisons epaisseurs : integer; // épaisseur des liaisons : si le bit n est à 1 : liaison fine - pont : integer; // définition du pont : si le bit n est à 1 : pont (bits symétriques) + pont : integer; // définition du pont : si le bit n est à 1 : pont (bits symétriques) OU si canton: alignement train buttoir : integer; // définition des buttoirs : si le bit n°n est à 1 : buttoir sortie : integer; // si action sortie : état end; @@ -504,24 +526,55 @@ type end; var - couleurAdresse,cltexte,CoulFonte : Tcolor; + couleurAdresse,cltexte,CoulFonte,clFondCantonV,clFondCantonR : Tcolor; TamponAffecte,TCO_modifie,clicsouris,prise_N, - clicTCO,piloteAig,BandeauMasque,eval_format,sauve_tco,prise_droit,prise_haut, + clicTCO,piloteAig,BandeauMasque,eval_format,sauve_tco,prise_droit,prise_haut,deja_calcule, prise_bas,prise_gauche,prise_NE,prise_NO,prise_SE,prise_SO,ligneAffiche,colonneAffiche, - drag,TCOActive,TCOCree,ancienok,dbleClicTCO,auto_tcurs,EvtClicDet,SelecBouge : boolean; + TCOActive,TCOCree,ancienok,dbleClicTCO,auto_tcurs,EvtClicDet,SelecBouge : boolean; HtImageTCO,LargImageTCO,XminiSel,YminiSel,Temposouris,ligne_supprime, XmaxiSel,YmaxiSel,AncienXMiniSel,AncienXMaxiSel,AncienYMiniSel,AncienYMaxiSel, Xclic,Yclic,XClicCellInserer,YClicCellInserer,RatioC,ModeCouleurCanton, - AncienXClicCell,AncienYClicCell,TCODrag,epaisseur_voies,Ax,Ay,TpsBougeSouris, + AncienXClicCell,AncienYClicCell,TCODrag,epaisseur_voies,ASourisx,ASourisy,TpsBougeSouris, Epaisseur,oldX,oldY,offsetSourisY,offsetSourisX,AvecVerifIconesTCO,indexTrace,IndexTCOCourant, ancienTraceX,ancienTraceY,rangUndo,NbreTCO,IndexTCOCreate,deltaXrect,deltaYrect, CellX,CellY,AncienXclic,AncienYclic,xCadre1,yCadre1,xCadre2,yCadre2,colonne_supprime, - couleurAction : integer; + couleurAction,couleurCanton,Ncantons,Xcanton,Ycanton,IdCantonSelect,AxSC,AySC,Drag, + Ldrag,Hdrag,IdCantonDragOrg : integer; + + Tel1,tel2 : Tequipement; titre_Fonte,s90,s91,s93,s94,s100,s101 : string; + // élements dupliqués dans le TCO : + //TCO[i,x,y].FeuOriente=Nelements + //TCO[i,x,y].PiedFeu=numéro + canton : array[1..MaxCantons] of record + numero : integer; // numéro du canton + Sens : integer; // sens de la loco 1=gauche 2=droit 3=haut 4=bas + Ntco : integer; // numéro du tco + Nelements : integer; // nombre de cellules du canton + nom : string; // nom du canton + x,y : integer; // début du canton dans le TCO + el1,el2 : integer; // éléments contigus au canton el1=gauche/haut el2=droit/bas + typ1,typ2 : tEquipement; // type des éléments contigus au canton + det1,det2 : integer; // détecteurs contigus, changement en fonction des aiguillages + Sens1,Sens2 : integer; // indique le sens de l'élément par rapport au canton + signal : integer; // adresse du signal associé (le canton est avant le signal) + NomTrain : string; // nom du train sur le canton + indexTrain : integer; // index du train sur le canton + adresseTrain : integer; // adresse du train sur le canton + Gd : tRect; // rectangle de sélection + rO,rE,rS,rN : tRect; // poignées + Xicone,yIcone : integer; // début de l'image du train (coord absolues) + Licone,HIcone : integer; // largeur, hauteur icone du train + bouton : integer; // état du bouton de commande du canton: 0=jaune 1=vert 2=bleu + select : boolean; // si le canton a été sélectionné par clic souris + horizontal : boolean; // si le canton est horizontal ou verticel + maxi,mini : integer; // valeurs mini et maxi des coordonnées à ne pas dépasser lors d'un tirage des poignées + end; + // structure de tous les tco TCO : array[1..10] of array of array of TTco ; @@ -545,8 +598,8 @@ var Sauv_rect_select : Trect; // tracé du train dans les TCO - Trace_Train : array[1..10] of record - train : array[1..Max_Trains] of record + Trace_Train : array[0..10] of record + train : array[0..Max_Trains] of record nombre : integer; route : array[1..500] of record x,y : integer; end; @@ -577,7 +630,7 @@ var procedure calcul_reduction(Var frx,fry : real;DimDestX,DimDestY : integer); procedure calcul_cellules(indextco : integer); procedure sauve_fichiers_tco; -procedure zone_TCO(indexTCO,det1,det2,train,mode: integer); +procedure zone_tco(indexTCO,det1,det2,train,adrTrain,mode: integer); procedure _entoure_cell_clic(indexTCO: integer); procedure Affiche_TCO(indexTCO : integer) ; procedure affiche_cellule(indexTCO,x,y : integer); @@ -607,13 +660,72 @@ Procedure Texte_aig_fond(adresse : integer); procedure Maj_Aig_TCO(indexTCO : integer); procedure encadre_ligne; procedure encadre_colonne; +function IsCanton(i : integer) : boolean; +function index_canton(indexTCO,x,y : integer) : integer; +function IsCantonH(i : integer) : boolean; overload; +function IsCantonV(i : integer) : boolean; overload; +procedure dessin_canton(indexTCO : integer;Canvas : Tcanvas;x,y,mode,bouton: integer); overload; +procedure dessin_canton(IdCanton : integer;mode,bouton: integer) ; overload; +procedure supprime_canton(c : integer); +procedure renseigne_tous_cantons; +procedure renseigne_canton(i : integer); +function index_canton_numero(n : integer) : integer; implementation -uses UnitConfigTCO, Unit_Pilote_aig, UnitConfigCellTCO, UnitClock ; +uses UnitConfigTCO, Unit_Pilote_aig, UnitConfigCellTCO, UnitClock, selection_train , unitPlace ; {$R *.dfm} +procedure supprime_canton(c : integer); +var i : integer; +begin + if c<>0 then + begin + //Affiche('Suppression canton '+intToSTR(c),clorange); + for i:=c to ncantons-1 do // supprime le canton c de la liste + canton[i]:=canton[i+1]; + dec(ncantons); + end; +end; + +// renvoie l'index du canton en x,y +function index_canton(IndexTCO,x,y : integer) : integer; +var El,i : integer; + trouve : boolean; +begin + El:=TCO[indexTCO,x,y].BImage; + // ramener les coordonnées à la première cellule du canton + if (El>=Id_cantonH) and (El<=Id_cantonH+9) then + begin + x:=x-(el-Id_cantonH); + end; + if (El>=Id_cantonV) and (El<=Id_cantonV+9) then + begin + y:=y-(el-Id_cantonV); + end; + i:=1; + repeat + trouve:=(canton[i].x=x) and (canton[i].y=y); + inc(i); + until (i>nCantons) or trouve; + if trouve then result:=i-1 else result:=0; +end; + +// renvoie l'index du canton en fonction de son numéro +function index_canton_numero(n : integer) : integer; +var i : integer; + trouve : boolean; +begin + i:=1; + result:=0; + repeat + trouve:=canton[i].numero=n; + inc(i); + until (i=Ncantons+1) or trouve; + if trouve then result:=i-1; +end; + // renvoie l'index du tco d'après le nom de la forme (TCO1 TCO2) // ne fonctionne que si t est un composant dont on peut remonter jusqu'à la form parent // attention : si T est un popup menu, ca ne marche pas!!! @@ -969,6 +1081,378 @@ begin screen.cursor:=crDefault; end; + +// calcule les poignées du rectangle de sélection canton +procedure Init_rectangle_canton(IndexTCO,indexCanton : integer); +var xp,yp : integer; +begin + + with canton[indexcanton] do + begin + // poignée nord (haut) + xp:=(Gd.right+Gd.Left) div 2; + yp:=Gd.Top; + rn.Left:=xp-5; + rn.top:=yp-5; + rn.Right:=xp+5; + rn.Bottom:=yp+5; + + // poignée droite + xp:=Gd.Right; + yp:=(Gd.Bottom+Gd.top) div 2; + rE.Left:=xp-5; + re.top:=yp-5; + re.Right:=xp+5; + re.Bottom:=yp+5; + + // poignée bas + xp:=(gd.right+gd.Left) div 2; + yp:=gd.Bottom; + rS.Left:=xp-5; + rs.top:=yp-5; + rs.Right:=xp+5; + rs.Bottom:=yp+5; + + // poignée gauche + xp:=gd.Left; + yp:=(gd.Bottom+gd.top) div 2; + rO.Left:=xp-5; + rO.top:=yp-5; + ro.Right:=xp+5; + ro.Bottom:=yp+5; + + end; +end; + +// affiche le rectangle de sélection canton +Procedure Affiche_Rectangle_canton(IndexTCO,indexCanton : integer); +var h : boolean; +begin + if indexTCO<1 then exit; + with PCanvasTCO[IndexTCO],canton[indexCanton] do + begin + with pen do + begin + Mode:=PmXor; + color:=clWhite; + width:=1; + end; + Brush.Color:=clblue; + + Rectangle(canton[indexCanton].Gd); // Grand rectangle + h:=canton[indexcanton].horizontal; + if h then + begin + Rectangle(rE); + Rectangle(rO); + end + else + begin + Rectangle(rN); // rectangle poignée haut + Rectangle(rS); + end; + end; +end; + +// si accroché, résultat=true +// x y coordonnées graphiques +function Accroche_canton(IndexTCO,IndexCanton,x,y : integer) : boolean; +var n,Bim,larg,haut,xt,yt,adr,Xorg,Yorg,yr,xr,xm,ym : integer; + r : Trect; + ok,rien,versE,versO,versN,versS : boolean; +begin + if canton[indexCanton].Ntco<>IndexTCO then begin result:=false; exit; end; // si le canton n'est pas sur le bon TCO + rien:=not(prise_droit) and not(prise_bas) and not(prise_gauche) and not(prise_haut) ; + + larg:=largeurCell[IndexTCO]; + haut:=HauteurCell[IndexTCO]; + xt:=(x div larg)+1; // coords cellule de la souris + yt:=(y div Haut)+1; + Xorg:=canton[indexCanton].x; // origine du canton + Yorg:=canton[indexCanton].y; + Bim:=tco[indexTCO,xt,yt].Bimage; + Adr:=tco[indexTCO,xt,yt].Adresse; +// Affiche(intToSTR(adr)+' '+intToSTR(Bim),clred); + + // calcule les limites en cas de détecteur + n:=canton[indexCanton].Nelements; + //if ( (adr<>0) or (Bim<>1) ) and not(deja_calcule) then + if ( (adr<>0) ) and not(deja_calcule) then + begin + //Affiche('recalcul',clYellow); + deja_calcule:=true; + if canton[indexCanton].horizontal then + begin + xr:=canton[indexCanton].x; + xm:=xr+n; + canton[indexCanton].maxi:=(xt-1)*larg; + canton[indexCanton].mini:=(xt)*larg; + end + else + begin + yr:=canton[indexCanton].y; + ym:=yr+n; + canton[indexCanton].maxi:=(ym-1)*haut; + canton[indexCanton].mini:=(yr-1)*haut; + end; + end; + + // Affiche('x='+IntToSTR(x)+' y='+intToSTR(y)+' mini='+intToSTR(canton[indexCanton].mini)+' maxi='+intToSTR(canton[indexCanton].maxi),clred); + versE:=x>AxSC; + versO:=x<=AxSC; + versS:=y>AySC; + versN:=y=Id_cantonH) and (bim<=Id_cantonH+9)) or ((Bim>=Id_cantonV) and (bim<=Id_cantonV+9))); + //ok:=( (Bim=1) or (Bim=20) or ((Bim>=Id_cantonH) and (bim<=Id_cantonH+9)) or ((Bim>=Id_cantonV) and (bim<=Id_cantonV+9))); + //if ok then affiche('O',clLime); + //if not(ok) then affiche('N',clred); + if not(ok) then // sortir car non ok + begin + //result:=true; + result:=false; + exit; + end; + + // gauche + r:=canton[indexCanton].rO; + // si x est dans le rectangle + if (((x>=r.left-5) and (x<=r.Right+5) and (y>=r.top-5) and (y<=r.bottom+5)) or prise_gauche) then //and (x>0) then + begin + ok:=( (Bim=1) or (Bim=20) or ((Bim>=Id_cantonH) and (bim<=Id_cantonH+9)) or ((Bim>=Id_cantonV) and (bim<=Id_cantonV+9))); + ok:=ok and (x>canton[indexCanton].mini); // empeche d'aller à gauche + if not(ok) then begin result:=false;exit;end; + + n:=abs(canton[indexCanton].gd.right-x) div larg; + if (n>9) or (n<3) then exit; // nombre de cellules tirées : maxi 9 + screen.cursor:=crSizeWE; + if (rien and clicsouris) or prise_gauche then + begin + // efface l'ancien + Affiche_Rectangle_canton(IndexTCO,IndexCanton); + prise_gauche:=true; + if (x=r.left-5) and (x<=r.Right+5) and (y>=r.top-5) and (y<=r.bottom+5)) or prise_droit) then //and (x=Id_cantonH) and (bim<=Id_cantonH+9)) or ((Bim>=Id_cantonV) and (bim<=Id_cantonV+9))); + ok:=ok and (x9) or (n<3) then exit; // nombre de cellules tirées : maxi 9 + screen.cursor:=crSizeWE; + if (rien and clicsouris) or prise_droit then + begin + // efface l'ancien + Affiche_Rectangle_canton(IndexTCO,IndexCanton); + prise_droit:=true; + if x>canton[indexCanton].Gd.Left then // si la souris passe à gauche de la poignée gauche : inversion + begin + canton[indexCanton].gd.right:=x; + end + else + begin + // inversion + canton[indexCanton].gd.left:=x; + end; + Init_rectangle_canton(indexTCO,IndexCanton); + Affiche_Rectangle_canton(indexTCO,IndexCanton); + prise_droit:=true; + end; + result:=true; + exit; + end; + + // poignée haut + r:=canton[indexCanton].rN; + if ( ((x>=r.left-5) and (x<=r.Right+5) and (y>=r.top-5) and (y<=r.bottom+5)) or prise_haut) and (y>0) then + begin + ok:=(Bim=1) or (Bim=20) or ((Bim>=Id_cantonH) and (bim<=Id_cantonH+9)) or ((Bim>=Id_cantonV) and (bim<=Id_cantonV+9)); + ok:=ok and (y>canton[indexCanton].mini); // empeche d'aller en haut + if not(ok) then begin result:=true;exit;end; + + n:=abs(canton[indexCanton].gd.bottom-y) div larg; // nombre de cellules tirées + if (n>9) or (n<3) then exit; // nombre de cellules tirées : maxi 9 + screen.cursor:=crSizeNS; + if (rien and clicsouris) or prise_haut then + begin + // efface l'ancien + Affiche_Rectangle_canton(IndexTCO,IndexCanton); + if y=r.left-5) and (x<=r.Right+5) and (y>=r.top-5) and (y<=r.bottom+5)) or prise_bas) then //and (y=Id_cantonH) and (bim<=Id_cantonH+9)) or ((Bim>=Id_cantonV) and (bim<=Id_cantonV+9)); + ok:=ok and (y9) or (n<3) then exit; // nombre de cellules tirées : maxi 9 + screen.cursor:=crSizeNS; + if (rien and clicsouris) or prise_bas then + begin + // efface l'ancien + Affiche_Rectangle_canton(IndexTCO,IndexCanton); + prise_bas:=true; + if y>canton[indexCanton].Gd.top then + begin + canton[indexCanton].gd.bottom:=y; + end + else + begin + // inversion + canton[indexCanton].gd.top:=y; + end; + Init_rectangle_canton(indexTCO,IndexCanton); + Affiche_Rectangle_canton(indexTCO,IndexCanton); + end; + result:=true; + exit; + end; + + + // si hors sélection, on remet le curseur normal + screen.cursor:=crDefault; + result:=false; +end; + +// trouve l'élément adresse de type el dans le TCO et renvoie x et y +// si on le trouve pas, renvoie x=0,y=0 +procedure trouve_El(indexTCO,adresse: integer;el : tequipement;var x,y : integer); +var xc,yc,b : integer; + tq : tequipement; + trouve : boolean; +begin + yc:=1; + repeat + xc:=0; + repeat + inc(xc); + b:=tco[indextco,xc,yc].Bimage; + if isAigTCO(b) then tq:=aig else tq:=det; + if b=id_signal then tq:=sig; + if tco[indextco,xc,yc].buttoir<>0 then tq:=buttoir; + + trouve:=(tco[indextco,xc,yc].Adresse=adresse) and (tq=el) ; + + until (xc=NbreCellX[indexTCO]) or trouve; + inc(yc); + until (yc>NbreCellY[indexTCO]) or trouve; + dec(yc); + if trouve then + begin + x:=xc; + y:=yc; + end + else + begin + x:=0; + y:=0; + end; +end; + + + +// remplit la base des cantons avec les éléments adjacents, et des détecteurs adjacents +// Cantons uniquement TCO1 +// i : indexCanton +procedure renseigne_canton(i : integer); +var t,x,y,indexTCO : integer; + Horz: boolean; +begin + if i<1 then exit; + indexTCO:=canton[i].Ntco; + if indexTCO>NbreTCO then + begin + Affiche('Erreur 32',clred); + exit; + end; + x:=canton[i].x; + y:=canton[i].y; + t:=canton[i].Ntco; + + canton[i].horizontal:=tco[indexTCO,x,y].BImage=Id_cantonH; + Horz:=canton[i].horizontal; + + if horz then + begin + zone_tco(t,i,5,0,0,11); // demande éléments contigus à gauche (5) du canton, résultats dans var globales xCanton et tel1 + canton[i].el1:=xCanton; + canton[i].typ1:=tel1; + canton[i].Sens1:=SensGauche; + + zone_tco(t,i,6,0,0,11); // demande éléments contigus à droite (6) du canton, résultats dans var globales xCanton et tel1 + canton[i].el2:=xCanton; + canton[i].typ2:=tel1; + canton[i].Sens2:=SensDroit; + + end + else + begin + zone_tco(t,i,7,0,0,11); // demande éléments contigus en haut (7) du canton, résultats dans var globales xCanton et tel1 + canton[i].el1:=xCanton; + canton[i].typ1:=tel1; + canton[i].Sens1:=SensHaut; + + zone_tco(t,i,8,0,0,11); // demande éléments contigus en bas (8) du canton, résultats dans var globales xCanton et tel1 + canton[i].el2:=xCanton; + canton[i].typ2:=tel1; + canton[i].Sens2:=SensBas; + end; + + //Affiche(intToSTR(xCanton)+' '+intToStr(yCanton),clyellow); +end; + +procedure renseigne_tous_cantons; +var i : integer; +begin + for i:=1 to Ncantons do + begin + renseigne_canton(i); + end; +end; + + // créée un nouveau TCO qui n'existait pas procedure Init_TCO(indexTCO : integer); var x,y : integer; @@ -983,7 +1467,7 @@ begin ClVoies[indexTCO]:=$0077FF; ClAllume[indexTCO]:=$00FFFF; ClGrille[IndexTCO]:=$404040; - ClTexte:=$00FF00; + ClQuai[indexTCO]:=$808080; clPiedSignal[indexTCO]:=$4080FF; ClCanton[indexTCO]:=$00FFFF; @@ -1016,10 +1500,10 @@ end; procedure lire_fichier_tco(indexTCO : integer); var fichier : textfile; s,sa,so : string; - nv,x,y,i,j,m,adresse,valeur,erreur,FeuOriente,PiedFeu,tailleFont,e,NPar : integer; + Bim,nv,x,y,i,j,m,adresse,valeur,erreur,FeuOriente,PiedFeu,tailleFont,e,NPar : integer; trouve_CoulFond,trouve_clVoies,trouve_clAllume,trouve_clGrille,trouve_clCanton, trouve_clTexte,trouve_clQuai,trouve_matrice,trouve_ratio,trouve_ModeCanton, - trouve_AvecGrille,trouve_clPiedSignal : boolean; + trouve_AvecGrille,trouve_clPiedSignal,cuc : boolean; function lit_ligne : string ; var c : char; begin @@ -1066,6 +1550,12 @@ begin AvecGrille[indexTCO]:=true; clCanton[indexTCO]:=ClYellow; + // supprimer les cantons de ce TCO + for i:=1 to Ncantons do + begin + if canton[i].Ntco=indexTCO then supprime_canton(i); + end; + // couleurs repeat s:=lit_ligne; @@ -1353,33 +1843,67 @@ begin i:=pos(',',s); if i=0 then begin Affiche('ETCO6',clred);closefile(fichier);exit;end; val(copy(s,1,i-1),valeur,erreur);if erreur<>0 then begin Affiche('ETCO7',clred);closefile(fichier);exit;end; - if valeur=30 then begin valeur:=Id_signal;sauve_tco:=true;end; - if valeur=31 then begin valeur:=51;sauve_tco:=true;end; + // anciens id + if valeur=30 then begin valeur:=Id_signal;sauve_tco:=true;end; + if valeur=31 then begin valeur:=id_Quai;sauve_tco:=true;end; tco[indexTCO,x,y].Bimage:=valeur; - tco[indexTCO,x,y].liaisons:=liaisons[valeur]; + if valeur<=34 then tco[indexTCO,x,y].liaisons:=liaisons[valeur] else tco[indexTCO,x,y].liaisons:=0; + Bim:=valeur; + cuc:=false; + if (valeur=Id_CantonH) or (valeur=Id_CantonV) then + begin + if ncantons0 then begin Affiche('ETCO9',clred);closefile(fichier);exit;end; tco[indexTCO,x,y].inverse:=valeur=1; delete(s,1,i); - // 5 FeuOriente + // 5 - FeuOriente ou Nombre de cellules Canton i:=pos(',',s); if i=0 then begin Affiche('ETCO10',clred);closefile(fichier);exit;end; - val(copy(s,1,i-1),FeuOriente,erreur);if erreur<>0 then begin Affiche('ETCO11',clred);closefile(fichier);exit;end; + val(copy(s,1,i-1),FeuOriente,erreur); + + if cuc then + begin + if FeuOriente=0 then FeuOriente:=3; + canton[ncantons].Nelements:=FeuOriente; + tco[indexTCO,x,y].FeuOriente:=FeuOriente; + end; + + if erreur<>0 then begin Affiche('ETCO11',clred);closefile(fichier);exit;end; delete(s,1,i); - // 6 PiedFeu - i:=pos(',',s); //j:=pos(')',s); + // 6 - PiedFeu ou numéro de canton + i:=pos(',',s); //if j0 then @@ -1410,10 +1934,16 @@ begin if j>1 then // le , est avant le ) donc il y a un texte begin if j=14 then begin delete(s,1,1); // supprimer la virgule @@ -1500,7 +2030,6 @@ begin e:=sizeof(Tco) div 1024; //Affiche('Dimensions du tco : '+intToSTR(NbreCellX)+'x'+intToSTR(NbreCellY)+' / '+IntToSTR(e)+'Ko',clyellow); if not(trouve_clPiedSignal) then clPiedSignal:=Clvoies; - end; procedure echange(var a,b : integer); @@ -1523,7 +2052,7 @@ procedure sauve_fichiers_tco; var fichier : textfile; s : string; couleurFonte : Tcolor; - x,y,i : integer; + x,y,i,Bimage : integer; begin //x:=formconfig.MemoNomTCO.Lines.Count; //if x<0 then @@ -1562,11 +2091,20 @@ begin s:=''; for x:=1 to NbreCellX[i] do begin - s:=s+'('+intToHex(tco[i,x,y].CouleurFond,6)+','+inttostr(tco[i,x,y].Adresse)+','+IntToSTR(tco[i,x,y].BImage)+','; + // couleur fond , adresse , Image + Bimage:=tco[i,x,y].BImage; + s:=s+'('+intToHex(tco[i,x,y].CouleurFond,6)+','+inttostr(tco[i,x,y].Adresse)+','+IntToSTR(Bimage)+','; + // inversion if tco[i,x,y].inverse then s:=s+'1,' else s:=s+'0,'; - s:=s+IntToSTR(tco[i,x,y].FeuOriente)+','+IntToSTR(tco[i,x,y].PiedFeu)+','; + // orientation signal ou Nombre éléments cantons + if (Bimage=Id_CantonH) or (Bimage=Id_cantonV) then s:=s+intToSTR(tco[i,x,y].FeuOriente) + else s:=s+IntToSTR(tco[i,x,y].FeuOriente); + + // piedFeu ou index canton + s:=s+','; + s:=s+IntToSTR(tco[i,x,y].PiedFeu)+','; // texte s:=s+tco[i,x,y].Texte+','; @@ -1776,6 +2314,38 @@ begin end; end; +// renvoie vrai si l'élément i est un canton H ou V +function IsCanton(i : integer) : boolean; +begin + result:=((i>=Id_cantonH) and (i<=Id_CantonH+9)) or ((i>=Id_cantonV) and (i<=Id_CantonV+9)) +end; + +// renvoie vrai si l'élément i est un canton H +function IsCantonH(i : integer) : boolean; overload; +begin + result:=((i>=Id_cantonH) and (i<=Id_CantonH+9)); +end; + +function IsCantonH(indexTCO,x,y : integer) : boolean; overload; +var b : integer; +begin + b:=tco[indexTCO,x,y].BImage; + result:=((b>=Id_cantonH) and (b<=Id_CantonH+9)); +end; + +// renvoie vrai si l'élément i est un canton V +function IsCantonV(i : integer) : boolean; +begin + result:=((i>=Id_cantonV) and (i=Id_cantonV) and (bId_Quai) and (b<>Id_action) then s:=s+' '; @@ -5099,7 +5686,6 @@ end; procedure dessin_Action(indexTCO : integer;Canvas : Tcanvas;x,y,mode: integer); var x0,y0,xf,yf,act,larg,haut : integer; r : Trect; - frX,frY : real; s : string; begin if PcanvasTCO[indexTCO]=nil then exit; @@ -5221,6 +5807,426 @@ begin } end; + +procedure dessin_icone_canton(indexTCO : integer;Canvas : Tcanvas;x,y,mode: integer); +var x0,y0,yc1,yc2,xf,yf,larg,haut : integer; + s : string; +begin + if PcanvasTCO[indexTCO]=nil then exit; + + larg:=LargeurCell[indexTCO]; + haut:=hauteurCell[indexTCO]; + + x0:=(x-1)*Larg; + y0:=(y-1)*haut; + xf:=x0+larg; + yf:=y0+Haut; + yc1:=y0+(haut div 4); + yc2:=yf-(haut div 4); + + with canvas do + begin + Pen.Width:=1; + + Brush.Color:=clFondCantonV; + pen.color:=clwhite; + + Roundrect(x0,yc1,xf,yc2,(xf-x0) div 2,(yc2-yc1) div 2); + + s:=tco[indexTCO,x,y].Fonte; + if s='' then tco[indexTCO,x,y].Fonte:='Arial'; + end; +end; + + +// dessine le canton +procedure dessin_cantonH(indexTCO : integer;Canvas : Tcanvas;x,y,mode,bouton : integer); +var i,tailleX,TailleY,x0,y0,yf,yc,larg,haut,xr,xm,LargDest,Hautdest,indexTrain,NumC, + offsetY,xf,AdrTrain,Xcentre,yCentre,n,al,r,l,h,HautDestF,LargDestF,LargSrc,HautSrc : integer; + frX,frY,rd : real; + coul : tcolor; + p : array[0..2] of TPoint; + s : string; +begin + if PcanvasTCO[indexTCO]=nil then exit; + //Affiche('CANTONH '+intToSTR(x)+' '+intToSTR(y),clred); + larg:=LargeurCell[indexTCO]; + haut:=hauteurCell[indexTCO]; + n:=tco[indexTCO,x,y].FeuOriente; // nombre de cellules du canton + + x0:=(x-1)*Larg; + y0:=(y-1)*haut; + yc:=y0+(haut div 2); // y centre + xf:=x0+n*larg+1; + yf:=y0+Haut+1; // +1 pour les jonctions verticales etre 2 cantons + + with canvas do + begin + Pen.Width:=1; + brush.Color:=tco[indexTCO,x,y].CouleurFond; + s:=tco[indexTCO,x,y].Fonte; + if s='' then tco[indexTCO,x,y].Fonte:='Arial'; + + NumC:=TCO[indexTCO,x,y].PiedFeu; // numéro du canton, pas son index; + i:=index_canton_numero(NumC); // index du canton "piedfeu" + if i=0 then begin Affiche('Erreur 19H : index canton nul en TCO'+intToSTR(indexTCO)+' x='+intToSTR(x)+' y='+intToSTR(y),clred);exit;end; + + // texte à gauche du canton + s:=canton[i].nom; + Pen.color:=clwhite; + textOUT(x0-length(s)*8,y0+1,s); + + indexTrain:=TCO[IndexTCO,x,y].train; + AdrTrain:=canton[i].adresseTrain; + if AdrTrain<>0 then indexTrain:=index_train_adresse(adrTrain); + + if (AdrTrain<>0) or (indexTrain=9999) then Brush.Color:=clFondCantonR // couleurCanton + else Brush.Color:=clFondCantonV; + + // mode=1 : représenter avec les poignées de sélection + if mode=1 then + begin + pen.Mode:=PmXor; + pen.Color:=ClWhite; + // init grand rectangle + with canton[i] do + begin + gd.Left:=x0; + gd.Top:=y0; + gd.Right:=x0+n*larg; + gd.Bottom:=y0+haut; + end; + + Init_rectangle_canton(indexTCO,i); + Affiche_Rectangle_canton(indexTCO,i); + canton[i].select:=true; + end + else + begin + pen.Mode:=pmCopy; + canton[i].select:=false; + end; + + pen.color:=clwhite; + Roundrect(x0,y0,xf,yf,15,15); + + // numéro de canton + Textout(x0+6,y0+2,intToSTR(canton[i].numero)); + + + Xcentre:=Xf-(larg div 2); + Ycentre:=Yc; + r:=larg div 3; + + case bouton of + 0 : couleur:=clyellow; + 1 : couleur:=clLime; + 2 : couleur:=clAqua; + end; + cercle(PcanvasTCO[indexTCO],xCentre,ycentre,r,couleur); + + if (indexTrain=0) or (indexTrain=9999) then + begin + //Affiche('pas de train',clYellow); + exit; + end; + + tailleX:=3*larg; + tailleY:=Haut; + + if (trains[indexTrain].icone=nil) or (Trains[indexTrain].Icone.height=0) then exit; + + calcul_reduction(frx,fry,Larg,haut); + HautDest:=round(haut/1.2); + + LargSrc:=Trains[indexTrain].Icone.width; + HautSrc:=Trains[indexTrain].Icone.height; + //r:=round(LargSrc/HautSrc); + rd:=LargSrc/HautSrc; + + largDest:=round(HautDest*rd); + if largdest>n*larg then + begin + largdest:=n*larg; + hautDest:=round(largdest/rd); + end; + + offsetY:=(haut div 2)-(hautDest div 2)+1; // centrer l'icone au centre Y + + al:=TCO[indexTCO,x,y].pont; //alignement + case al of + 0 : x0:=x0+((n*larg) div 2)-(largDest div 2); // centré + 2 : x0:=xf-largdest-larg; // aligné D + end; + //copie depuis la base vers la destination avec réduction + + Canton[i].Xicone:=x0; + Canton[i].Yicone:=y0; + Canton[i].Licone:=LargDest; + Canton[i].Hicone:=HautDest; + + if canton[i].Sens=SensGauche then + begin + with FormTCO[indexTCO].ImageTemp2.Canvas do + begin + pen.color:=clwhite; + brush.Color:=clblack; + Rectangle(0,0,500,500); + end; + + // matrice de copie à 180°G sans mise à l'échelle dans l'image provisoire + p[0].X:=largSrc; + p[0].Y:=0; + p[1].X:=0; + p[1].Y:=0; + p[2].X:=LargSrc; + p[2].Y:=HautSrc; + + PlgBlt(FormTCO[indexTCO].ImageTemp2.Canvas.Handle,p, + Trains[indexTrain].Icone.canvas.Handle,0,0,largSrc,HautSrc,0,0,0); // image 180° + // FormTCO[indexTCO].ImageTemp2.repaint; + + // !!! TransparentBLt ne mirroire pas les images. et StretchBlt pour inverser mais assombrit l'image + TransparentBlt(PcanvasTCO[indexTCO].Handle,x0,y0+offsetY,largDest,hautDest, + FormTCO[indexTCO].ImageTemp2.canvas.Handle,0,0,LargSrc,HautSrc,clWhite); + end + else + TransparentBlt(PcanvasTCO[indexTCO].Handle,x0,y0+offsetY,largDest,hautDest, + Trains[indexTrain].Icone.canvas.Handle,0,0,Trains[indexTrain].Icone.width,Trains[indexTrain].Icone.height,clWhite); + + PImageTCO[indexTCO].Picture.Bitmap.Modified:=True; // rafraichit l'affichage sinon le stretchblt n'apparaît pas. + end; +end; + +procedure dessin_cantonV(indexTCO : integer;Canvas : Tcanvas;x,y,mode,bouton : integer); +var AdrTrain,i,x0,xc,yc,y0,xf,yf,larg,haut,hautDest,LargDest,LargSrc,HautSrc,yr,ym, + xCentre,yCentre,r,indexTrain,n,al : integer; + frX,frY : real; + couleur : tcolor; + s : string; + p : array[0..2] of TPoint; + TailleY,TailleX : integer; +begin + if PcanvasTCO[indexTCO]=nil then exit; + + larg:=LargeurCell[indexTCO]; + haut:=hauteurCell[indexTCO]; + n:=tco[indexTCO,x,y].FeuOriente; // nombre de cellules du canton + + x0:=(x-1)*Larg; + y0:=(y-1)*Haut; + xc:=x0+(larg div 2); + yc:=y0+(Haut div 2); + xf:=x0+larg+1; + yf:=y0+(n*Haut)+1; // +1 pour les jonctions verticales etre 2 cantons + + tailleX:=larg; + tailleY:=n*Haut; + + with canvas do + begin + Pen.Width:=1; + brush.Color:=tco[indexTCO,x,y].CouleurFond; + s:=tco[indexTCO,x,y].Fonte; + if s='' then tco[indexTCO,x,y].Fonte:='Arial'; + + i:=TCO[indexTCO,x,y].PiedFeu; // numéro du canton + i:=index_canton_numero(i); // index du canton "piedfeu" + if i=0 then begin Affiche('Erreur 19V : canton nul',clred);exit;end; + + s:=canton[i].nom; + Pen.color:=clwhite; + textOUT(x0-length(s)*8,y0+1,s); + + indexTrain:=TCO[IndexTCO,x,y].train; + AdrTrain:=canton[i].adresseTrain; + if AdrTrain<>0 then indexTrain:=index_train_adresse(adrTrain); + + if (AdrTrain<>0) or (indexTrain=9999) then Brush.Color:=clFondCantonR // couleurCanton + else Brush.Color:=clFondCantonV; + + // mode=1 représenter avec les poignées de sélection + if mode=1 then + begin + pen.mode:=pmXor; + pen.color:=clWhite; + // init grand rectangle + with canton[i] do + begin + gd.Left:=x0; + gd.Top:=y0; + gd.Right:=x0+larg; + gd.Bottom:=y0+n*haut; + end; + Init_rectangle_canton(indexTCO,i); + Affiche_Rectangle_canton(indexTCO,i); + canton[i].select:=true; + end + else + begin + pen.Mode:=pmCopy; + canton[i].select:=false; + end; + + pen.color:=clwhite; + Roundrect(x0,y0,xf,yf,15,15); + + // numéro de canton + Textout(x0+2,y0+6,intToSTR(canton[i].numero)); + + Xcentre:=Xc+1; + Ycentre:=Yf-(haut div 2); + r:=larg div 3; + case bouton of + 0 : couleur:=clyellow; + 1 : couleur:=clLime; + 2 : couleur:=ClAqua; + end; + cercle(PcanvasTCO[indexTCO],xCentre,ycentre,r,couleur); + // Affiche_texte(indexTCO,x,y); + + + if (indexTrain=0) or (indexTrain=9999) then + begin + //Affiche('pas de train',clYellow); + exit; + end; + // pas d'icone + if (trains[indexTrain].icone=nil) or (Trains[indexTrain].Icone.height=0) then exit; + + calcul_reduction(frx,fry,Larg,haut); + hautdest:=round(haut/1.2); + + LargSrc:=Trains[indexTrain].Icone.width; + HautSrc:=Trains[indexTrain].Icone.height; + + + r:=round(LargSrc/HautSrc); + largDest:=hautdest*r; + + echange(largDest,HautDest); + + if HautDest>TailleY then + begin + hautDest:=tailleY; + largDest:=round(HautDest/r); + end; + + al:=TCO[indexTCO,x,y].pont; //alignement + case al of + 0 : y0:=y0+((n*Haut) div 2)-(HautDest div 2); // centré + 2 : y0:=yf-Hautdest; // aligné D + end; + + Canton[i].Xicone:=x0+round(8*frx); + Canton[i].Yicone:=y0; + Canton[i].Licone:=LargDest; + Canton[i].Hicone:=HautDest; + + if canton[i].Sens=SensHaut then + begin + with FormTCO[indexTCO].ImageTemp2.Canvas do + begin + pen.color:=clwhite; + brush.Color:=clblack; + Rectangle(0,0,500,500); + end; + // matrice de copie à -90°G sans mise à l'échelle dans l'image provisoire + // ok mais tournée dans mauvais sens (270 CW) + p[0].X:=0; + p[0].Y:=largSrc; + p[1].X:=0; + p[1].Y:=0; + p[2].X:=HautSrc; + p[2].Y:=LargSrc; + { p[0].X:=0; + p[0].Y:=0; + p[1].X:=LargDest; + p[1].Y:=0; + p[2].X:=LargSrc; + p[2].Y:=HautSrc;} + { + If Index = 0 Then 'Rotate Left + udtNewPoints(0).x = 0 + udtNewPoints(0).y = Picture2.ScaleHeight + + udtNewPoints(1).x = 0 + udtNewPoints(1).y = 0 + + udtNewPoints(2).x = Picture2.ScaleWidth + udtNewPoints(2).y = Picture2.ScaleHeight + + Else 'rotate right + udtNewPoints(0).x = Picture2.ScaleWidth + udtNewPoints(0).y = 0 + + udtNewPoints(1).x = Picture2.ScaleWidth + udtNewPoints(1).y = Picture2.ScaleHeight + + udtNewPoints(2).x = 0 + udtNewPoints(2).y = 0 + + } + + PlgBlt(FormTCO[indexTCO].ImageTemp2.Canvas.Handle,p, + Trains[indexTrain].Icone.canvas.Handle,0,0,largSrc,HautSrc,0,0,0); // image 90° + // FormTCO[indexTCO].ImageTemp2.repaint; + // copie l'image du signal retournée depuis image temporaire vers tco avec une réduction en mode transparent + TransparentBlt(pcanvasTCO[indexTCO].Handle,x0+round(8*frx),y0,largDest,hautDest, // destination avec mise à l'échelle + FormTCO[indexTCO].ImageTemp2.Canvas.Handle,0,0,HautSRC,LargSrc,clWhite); + end + else + begin + //bas + // matrice de copie à 90°G sans mise à l'échelle dans l'image provisoire + p[0].X:=HautSrc; //90; + p[0].Y:=0; //0; + p[1].X:=HautSrc; //90; + p[1].Y:=LargSrc; //49; + p[2].X:=0; //0; + p[2].Y:=0; //0; + PlgBlt(FormTCO[indexTCO].ImageTemp2.Canvas.Handle,p, + Trains[indexTrain].Icone.canvas.Handle,0,0,largSrc,HautSrc,0,0,0); // image 90° + // FormTCO[indexTCO].ImageTemp2.repaint; + // copie l'image du signal retournée depuis image temporaire vers tco avec une réduction en mode transparent + TransparentBlt(pcanvasTCO[indexTCO].Handle,x0+round(8*frx),y0,largDest,hautDest, // destination avec mise à l'échelle + FormTCO[indexTCO].ImageTemp2.Canvas.Handle,0,0,HautSrc,LargSrc,clWhite); + end; + end; +end; + + +//idcanton : indexcanton +procedure dessin_canton(IdCanton : integer;mode,bouton: integer) ; overload; +var indexTCO,x,y : integer; +begin + if IdCanton<1 then exit; + //Affiche('Dessin canton id='+intToSTR(Idcanton)+' num='+intToSTR(canton[idcanton].numero)+' mode='+inttostr(mode),clred); + indexTCO:=canton[idCanton].Ntco; + if (PcanvasTCO[indexTCO]=nil) or (indexTCO=0) then exit; + x:=canton[IdCanton].x; + y:=canton[IdCanton].y; + if isCantonV(indexTCO,x,y) then + begin + dessin_cantonV(indexTCO,PCanvasTCO[indexTCO],x,y,mode,bouton); + exit; + end; + dessin_cantonH(indexTCO,PCanvasTCO[indexTCO],x,y,mode,bouton); +end; + +// mode=0 canton normal mode=1 : affiche le canton en mode rectangle de sélection avec les poignées +// Bouton=0 bouton jaune bouton=1 bouton vert bouton=2 bouton bleu +procedure dessin_canton(indexTCO : integer;Canvas : Tcanvas;x,y,mode,bouton: integer); overload; +begin + if PcanvasTCO[indexTCO]=nil then exit; + if isCantonV(indexTCO,x,y) then + begin + dessin_cantonV(indexTCO,Canvas,x,y,mode,bouton); + exit; + end; + dessin_cantonH(indexTCO,Canvas,x,y,mode,bouton); +end; + // Element 24 procedure dessin_24L(indexTCO : integer;Canvas : Tcanvas;x,y,mode: integer); var x0,y0,xc,yc,jx1,jy1,xf,yf,position,ep : integer; @@ -8475,6 +9481,9 @@ begin Id_Quai : dessin_Quai(indexTCO,PCanvasTCO,X,Y,mode); Id_action : dessin_Action(indexTCO,PCanvasTCO,X,Y,mode); + // les cantons sont affichés dans affiche_cellule car il faut dessiner les trains + + end; end; @@ -8502,7 +9511,7 @@ begin BImage:=tco[indextco,x,y].BImage; mode:=tco[indextco,x,y].mode; // mode pour la couleur repr:=tco[indextco,x,y].repr; - Epaisseur:=LargeurCell[indexTCO]*epaisseur_voies div 30; + Epaisseur:=LargeurCell[indexTCO]*epaisseur_voies div 30; Xorg:=(x-1)*LargeurCell[indexTCO]; Yorg:=(y-1)*hauteurCell[indexTCO]; @@ -8512,6 +9521,10 @@ begin // affiche d'abord l'icone de la cellule et colore la voie si zone ou détecteur actionnée selon valeur mode dessine_icone(indexTCO,PCanvasTCO[indexTCO],Bimage,X,Y,mode); + + // dessin du train sur le canton + if (Bimage=Id_CantonH) or (Bimage=Id_CantonV) then dessin_canton(indexTCO,PCanvasTCO[indexTCO],x,y,0,0); + PCanvasTCO[indexTCO].font.Size:=(LargeurCell[indexTCO] div 10)+4 ; //Affiche(intToSTR( (LargeurCell[indexTCO] div 30)+6),clyellow); @@ -8588,25 +9601,26 @@ begin 3 : yt:=hauteurCell[indexTCO]-round(17*fryGlob[indexTCO]); // bas end; -{ // affiche/efface le nom du train du détecteur + { + // affiche/efface le nom du train du détecteur s:=s+' '; case repr of 1,3 : yt:=1; // haut 2 : yt:=hauteurCell[indexTCO]-round(17*fryGlob[indexTCO]); // bas - end; } - - - begin - i:=detecteur[adresse].AdrTrain; - if i<>0 then - begin - i:=index_train_adresse(i); // trouve le nom du train par son adresse - if i<>0 then s:=s+' '+trains[i].nom_train; - end - else if roulage then s:=s+' '; - //PCanvasTCO[indexTCO].font.Size:=(LargeurCell[indexTCO] div 13)+4 ; - TextOut(xOrg+xt,Yorg+yt,s+' '); end; + } + + {i:=detecteur[adresse].AdrTrain; + if i<>0 then + begin + i:=index_train_adresse(i); // trouve le nom du train par son adresse + if i<>0 then s:=s+' '+trains[i].nom_train; + end + else if roulage then s:=s+' '; + } + //PCanvasTCO[indexTCO].font.Size:=(LargeurCell[indexTCO] div 13)+4 ; + TextOut(xOrg+xt,Yorg+yt,s+' '); + end; end; @@ -8832,7 +9846,7 @@ end; // affiche le tco suivant le tableau TCO procedure Affiche_TCO(indexTCO : integer) ; -var x,y,x1,y1,DimX,DimY : integer; +var Bim,x,y,x1,y1,DimX,DimY : integer; s : string; r : Trect; begin @@ -8891,6 +9905,7 @@ begin end; end; + // afficher la grille if AvecGrille[indexTCO] then begin y1:=HauteurCell[IndexTCO]*NbreCellY[indexTCO]; @@ -8913,11 +9928,12 @@ begin end; end; - //afficher les cellules sauf les signaux + //afficher les cellules sauf les signaux et les cantons for y:=1 to NbreCellY[indexTCO] do for x:=1 to NbreCellX[indexTCO] do begin - if tco[indextco,x,y].BImage<>Id_signal then + Bim:=tco[indextco,x,y].BImage; + if (Bim<>Id_signal) and (Bim<>Id_CantonH) and (Bim<>Id_CantonV) then begin affiche_cellule(indexTCO,x,y); end; @@ -8927,13 +9943,18 @@ begin for y:=1 to NbreCellY[indexTCO] do for x:=1 to NbreCellX[indexTCO] do begin - if tco[indextco,x,y].BImage=Id_signal then + Bim:=tco[indextco,x,y].BImage; + if (Bim=Id_signal) or (Bim=Id_CantonH) or (Bim=Id_CantonV) then begin affiche_cellule(indexTCO,x,y); end; + //Affiche(intToSTR(indexTCO)+' '+intToSTR(x)+' '+intToSTR(y),clred); s:=tco[indextco,x,y].Texte; - if s<>'' then Affiche_texte(indexTCO,x,y); + if s<>'' then + begin + if (bim<>Id_cantonV) and (Bim<>id_cantonH) then Affiche_texte(indexTCO,x,y); + end; end; // afficher les sélections si elles sont présentes @@ -8949,6 +9970,10 @@ begin if affevt or (debug=1) then Affiche('FormTCO'+intToSTR(indexTCOCreate)+' create',clLime); //Screen.OnActiveControlChange := ActiveControlChanged; visible:=false; // ne s'affiche pas par défaut et évite l'effet fenetre fantome. + ClTexte:=$00FF00; + clFondCantonV:=$206020; + clFondCantonR:=$202060; + IdCantonSelect:=0; PCanvasTCO[indexTCOCreate]:=nil; offsetSourisY:=-10; // permet de tenir l'icone au milieu quand on fait un glisser offsetSourisX:=-10; @@ -8973,6 +9998,9 @@ begin SelecBouge:=false; //TrackBarZoom.position:=78; + ImageTemp2.Width:=500; + ImageTemp2.Height:=500; + couleurAdresse:=clCyan; xMiniSel:=99999;yMiniSel:=99999; // coordonnées cellules xMaxiSel:=0;yMaxiSel:=0; @@ -8992,8 +10020,8 @@ begin Left:=0; end; oldbmp:=Tbitmap.Create; - oldbmp.width:=100; - oldbmp.Height:=100; + oldbmp.width:=300; + oldbmp.Height:=300; modeTrace[indexTCOCreate]:=false; // pour tracer les voies à la souris //controlStyle:=controlStyle+[csOpaque]; @@ -9056,38 +10084,10 @@ begin tcoCree:=true; if debug=1 then Affiche('Fin création fenêtre TCO',clLime); + end; -// trouve le détecteur det dans le TCO et renvoie x et y -// si on le trouve pas, renvoie x=0,y=0 -procedure trouve_det(indexTCO,det : integer;var x,y : integer); -var xc,yc,b : integer; - trouve : boolean; -begin - yc:=1; - repeat - xc:=0; - repeat - inc(xc); - b:=tco[indextco,xc,yc].Bimage; - trouve:=(tco[indextco,xc,yc].Adresse=det) and - ( (b=1) or (b=10) or (b=11) or (b=20) ); // trouvé détecteur- obligé de regarder le type d'objet car un détecteur et un signal peuvent avoir la même adresse! - until (xc=NbreCellX[indexTCO]) or trouve; - inc(yc); - until (yc>NbreCellY[indexTCO]) or trouve; - dec(yc); - if trouve then - begin - x:=xc; - y:=yc; - end - else - begin - x:=0; - y:=0; - end; -end; procedure Erreur_TCO(indexTCO,x,y : integer); var s : string; @@ -9142,10 +10142,15 @@ begin end; // affiche le trajet dans le tco du train,ir =nombre d'éléments du tableau trace_train mode=couleur -procedure affiche_trajet(indexTCO,train,ir,mode : integer); -var i,sx,sy,x,y,ax,ay,Bimage,adresse : integer; +// mode=0 : effacement du trajet +// sinon mode = couleur du train +// affecte le train au canton +procedure affiche_trajet(indexTCO,train,AdrTrain,ir,mode : integer); +var i,sx,sy,x,y,ax,ay,Bimage,adresse,IdCanton,IdTrain,AncTrain : integer; + cant : boolean; begin // et affichage de la route + if debugTCO then begin if ir<>0 then @@ -9155,12 +10160,14 @@ begin ax:=Trace_Train[indexTCO].Train[train].route[ir].x; ay:=Trace_Train[indexTCO].Train[train].route[ir].y; end; - //AfficheDebug('Affiche_trajet TCO'+intToSTR(indexTCO)+' '+intToSTR(x)+','+intToSTR(y)+' à '+intToSTR(ax)+','+intToSTR(ay)+' mode='+intToSTR(mode),clOrange); + AfficheDebug('Affiche_trajet TCO'+intToSTR(indexTCO)+' '+intToSTR(x)+','+intToSTR(y)+' à '+intToSTR(ax)+','+intToSTR(ay)+' mode='+intToSTR(mode),clLime); end; for i:=1 to ir do begin x:=Trace_Train[indexTCO].Train[train].route[i].x; y:=Trace_Train[indexTCO].Train[train].route[i].y; + bimage:=tco[indextco,x,y].BImage; + cant:=IsCanton(Bimage); { if debugTCO then begin @@ -9168,13 +10175,55 @@ begin end; } tco[Indextco,x,y].mode:=mode; //mode; // pour la couleur - TCO[IndexTCO,x,y].train:=index_couleur; // = numéro du train - //Affiche(intToSTR(x)+' '+intToSTR(y),clorange); + idTrain:=0; + if mode>0 then Idtrain:=index_couleur // = numéro du train + else IdTrain:=0; // efface train + + //Affiche('Affiche_trajet: Affecte '+intToSTR(IdTrain)+' au TCO '+intToSTR(indexTCO)+' '+intToSTR(x)+' '+intToSTR(y),clWhite); + // si pas canton, affectation du train--------------------------- + if not(cant) then TCO[IndexTCO,x,y].train:=IdTrain + else + begin + IdCanton:=index_canton_numero(TCO[indexTCO,x,y].PiedFeu); // index canton + if idTrain<>0 then // si plus de train en xy tco , on raze + begin + if idcanton<>0 then // si canton + begin + if canton[IdCanton].indexTrain<>0 then //si train dans canton + begin + if AdrTrain<>0 then canton[idCanton].indexTrain:=Index_Train_Adresse(AdrTrain); + IdTrain:=canton[IdCanton].indexTrain; + //Affiche('Affecte train '+intToSTR(adrTrain)+' au canton n°'+intToSTR(index_canton_numero(TCO[indexTCO,x,y].PiedFeu)),clred); + affecte_train_canton(AdrTrain,IdCanton); + end; + end; + end + end; + + //Affiche(intToSTR(x)+' '+intToSTR(y)+' '+intToSTR(TCO[IndexTCO,x,y].train),clorange); + - bimage:=tco[indextco,x,y].BImage; adresse:=tco[indextco,x,y].Adresse; tco[indextco,x,y].trajet:=0; + // pour les cantons, mettre à jour les cantons + if (cant) then + begin + if idcanton<>0 then + begin + if idTrain<=Ntrains then // dans le cas de la libération d'un canton par un train qui avance, + begin // IdTrain=0 + AncTrain:=canton[IdCanton].indexTrain; + if (idTrain<>0) and (AncTrain=0) and (adrtrain=0) then adrTrain:=9999; // adresse train inconnue + if (idTrain=0) and (AncTrain=9999) and (adrtrain=0) then adrTrain:=0; + //if (ancTrain=0) or (IdTrain=0) then // si le canton est déja affecté à un train et que le nouveau train<>0, on ne réaffecte pas le train qui arrive + //if idTrain=0 then AdrTrain:=0; + //Affiche('Affecte train '+intToSTR(adrTrain)+' au canton n°'+intToSTR(index_canton_numero(TCO[indexTCO,x,y].PiedFeu)),clorange); + affecte_Train_canton(AdrTrain,IdCanton); + end; + end; + end; + // pour les croisements il faut mettre à jour la variable "trajet" pour l'affichage dans la cellule if (bimage=21) and (i>1) then begin @@ -9203,15 +10252,17 @@ begin sx:=Trace_Train[indexTCO].Train[train].route[i+1].x; sy:=Trace_Train[indexTCO].Train[train].route[i+1].y; tco[indextco,x,y].trajet:=0; - if (ax-x=-1) and (ay-y=0) and (sx-x=1) and (sy-y=0) then tco[indextco,x,y].trajet:=1; // de gauche à droite - if (ax-x=1) and (ay-y=0) and (sx-x=-1) and (sy-y=0) then tco[indextco,x,y].trajet:=1; // de droite à gauche - if (ax-x=-1) and (ay-y=-1) and (sx-x=1) and (sy-y=1) then tco[indextco,x,y].trajet:=2; // de haut gauche vers bas droit - if (ax-x=1) and (ay-y=1) and (sx-x=-1) and (sy-y=-1) then tco[indextco,x,y].trajet:=2; // de bas droit vers haut gauche - if (ax-x=1) and (ay-y=0) and (sx-x=-1) and (sy-y=-1) then tco[indextco,x,y].trajet:=3; // de droit vers en haut à gauche - if (ax-x=-1) and (ay-y=-1) and (sx-x=1) and (sy-y=0) then tco[indextco,x,y].trajet:=3; // de haut à gauche vers droit - if (ax-x=1) and (ay-y=1) and (sx-x=-1) and (sy-y=0) then tco[indextco,x,y].trajet:=4; // de bas à droite vers gauche + if (ax-x=-1) and (ay-y=0) and (sx-x=1) and (sy-y=0) then tco[indextco,x,y].trajet:=1; // 1 de gauche à droite + if (ax-x=1) and (ay-y=0) and (sx-x=-1) and (sy-y=0) then tco[indextco,x,y].trajet:=1; // 2 de droite à gauche + if (ax-x=-1) and (ay-y=-1) and (sx-x=1) and (sy-y=1) then tco[indextco,x,y].trajet:=2; // 3 de haut gauche vers bas droit + if (ax-x=1) and (ay-y=1) and (sx-x=-1) and (sy-y=-1) then tco[indextco,x,y].trajet:=2; // 4 de bas droit vers haut gauche + if (ax-x=1) and (ay-y=0) and (sx-x=-1) and (sy-y=-1) then tco[indextco,x,y].trajet:=3; // 5 de droit vers en haut à gauche + if (ax-x=-1) and (ay-y=-1) and (sx-x=1) and (sy-y=0) then tco[indextco,x,y].trajet:=3; // 6 de haut à gauche vers droit + if (ax-x=1) and (ay-y=1) and (sx-x=-1) and (sy-y=0) then tco[indextco,x,y].trajet:=4; // 7 de bas à droite vers gauche if (ax-x=-1) and (ay-y=0) and (sx-x=1) and (sy-y=1) then tco[indextco,x,y].trajet:=4; // de gauche vers en bas a droite - if tco[indextco,x,y].trajet=0 then affiche('Erreur 71 TCO - Cellule '+intToSTR(x)+','+intToSTR(y),clred); + if tco[indextco,x,y].trajet=0 then + affiche('Erreur 71 TCO'+intToSTR(indexTCO)+' - Ax='+intToSTR(ax)+' Ay='+intToSTR(Ay)+' Cellule '+intToSTR(x)+','+intToSTR(y) + +' Sx='+intToSTR(sx)+'Sy='+intToSTR(sy),clred); end; // croisement @@ -9261,10 +10312,15 @@ end; // si mode=0 : éteint // =1 : couleur détecteur allumé // =2 : couleur de l'index train -// Ne nécessite pas que les aiguillages aoient bien positionnés entre det1 et det2 +// =10 : arrêt sur trouvé canton, et renvoie le x,y du canton dans les variables globales xCanton,yCanton +// =11 : det1=indexcanton det2=direction - renvoie les éléments adjacent du canton dans la direction indiquée dans xCanton +// =12 : det1 = détecteur de départ - renvoie l'élément sursuivant (peut être un aiguillage)dans la direction demandée +// Ne nécessite pas que les aiguillages en talon soient bien positionnés entre det1 et det2 +// passe par les aiguillages en pointe positionnés. Ne passe pas par un aiguillage en pointe inconnu. // procédure récursive quand on passe par un aiguillage en pointe pour explorer les éléments opposés -procedure zone_tco(indexTCO,det1,det2,train,mode: integer); -var i,ir,adresse,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iteration,indexIr : integer; +procedure zone_tco(indexTCO,det1,det2,train,adrTrain,mode: integer); +var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iteration,indexIr,AdrTr, + NbTrouve,AdrTr1,adrTr2 : integer; memtrouve,sortir,casok,indextrouve : boolean; s : string; @@ -9325,15 +10381,38 @@ var i,ir,adresse,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iteratio end; Bimage:=tco[indextco,x,y].Bimage; + if adresse=det1 then ir:=1; // index de stockage de trace if debugTCO then begin - s:='X='+intToSTR(x)+' y='+intToSTR(y)+' Elément='+intToSTR(Bimage); + s:='x='+intToSTR(x)+' y='+intToSTR(y)+' Elément='+intToSTR(Bimage); if adresse<>0 then s:=s+' Adresse='+intToSTR(adresse); + if adresse=det1 then s:=s+' il s''agit du det1'; AfficheDebug(s,clyellow); end; casok:=false; // vers case suivante: trouver le trajet pour rejoindre det1 à det2 + + if (Bimage>=id_cantonH) and (Bimage<=id_cantonH+9) then + begin + //if mode=10 then trouveCanton:=true; + if (Bimage=id_cantonH) and (mode=10) then + begin + Xcanton:=x-(Bimage-Id_cantonH); + Ycanton:=y; // variable globale + end; + Bimage:=1; + end; + if (Bimage>=id_cantonV) and (Bimage<=id_cantonV+9) then + begin + if (Bimage=Id_cantonV) and (mode=10) then + begin + Xcanton:=x; + Ycanton:=y-(Bimage-Id_cantonH); + end; + Bimage:=20; + end; + case Bimage of // voie @@ -9537,7 +10616,7 @@ var i,ir,adresse,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iteratio 17 : if ancienY0 then s:=s+'adr='+intToStr(adresse); @@ -9984,93 +11063,200 @@ var i,ir,adresse,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iteratio end; end; + but:=tco[indexTCO,x,y].buttoir; + inc(i); + //if (mode=11) and ( (adresse<>0) and ((Bimage=1) or (Bimage=20)) or (tco[indexTCO,x,y].buttoir<>0)) then + if (mode=11) and ( (adresse<>0) and (not(isAigTCO(Bimage)) ) or (tco[indexTCO,x,y].buttoir<>0)) then sortir:=true; + if (mode=12) and ( ((adresse<>0) and (adresse<>det1)) or (tco[indexTCO,x,y].buttoir<>0)) then sortir:=true; + if (adresse=det2) and (adresse<>0) then memTrouve:=true; - if (adresse=0) and (det2=0) and (tco[indexTCO,x,y].buttoir<>0) then memTrouve:=true; + if (adresse=0) and (det2=0) and (but<>0) then memTrouve:=true; if ((Bimage=1) or (Bimage=20) or (Bimage=10) or (Bimage=11)) and ((adresse<>det2) and (adresse<>det1) and (adresse<>0)) then sortirBoucle:=true; if (i>200) or (iteration>200) then sortir:=true; Maj_coords(AncienX,AncienY,x,y); until sortir or memtrouve or SortirBoucle; - if DebugTCO and not(memtrouve) then AfficheDebug('Fin de boucle dét '+intToSTR(det2)+' non trouvé',clOrange); + if DebugTCO and not(memtrouve) and not(sortir) then AfficheDebug('Fin de boucle dét '+intToSTR(det2)+' non trouvé',clOrange); //mémoriser l'index de route si on a trouvé det2, et uniquement sur la première itération quand on l'a trouvé if memTrouve and not(indextrouve) then begin - if debugTCO then AfficheDebug('Trouvé '+intToSTR(det2),clLime); + if debugTCO and (mode<>10) then AfficheDebug('Trouvé '+intToSTR(det2),clLime); indexTrouve:=true; indexIr:=ir-1; end; + if sortir and ((mode=11) or (mode=12)) and debugTCO then AfficheDebug('Trouvé '+intToSTR(det2),clLime); + if i>200 then AfficheDebug('Erreur 487 : limite d''itérations TCO'+intToSTR(indexTCO)+' trajet de '+intToSTR(det1)+' à '+intToSTR(det2)+' x='+intToSTR(x)+' y='+intToSTR(y),clred); if iteration>200 then AfficheDebug('Erreur 488 : limite de récursivité TCO'+intToSTR(indexTCO)+'trajet de '+intToSTR(det1)+' à '+intToSTR(det2)+' x='+intToSTR(x)+' y='+intToSTR(y),clred); end; -// Début de la procédure zone_tco +// Début de la procédure zone_tco, qui affiche le tracé begin - if debugTCO then AfficheDebug('Zone_TCO'+intToSTR(indexTCO)+' det1='+intToSTR(det1)+' det2='+intToSTR(det2)+' Train'+intToSTR(Train)+' mode='+intToSTR(mode),clWhite); - if PcanvasTCO[indexTCO]=nil then exit; - trouve_det(indexTCO,det1,Xdet1,Ydet1); - if (Xdet1=0) or (Ydet1=0) then exit; + if debugTCO then + begin + if mode<>11 then AfficheDebug('Zone_TCO'+intToSTR(indexTCO)+' det1='+intToSTR(det1)+' det2='+intToSTR(det2)+' Train'+intToSTR(Train)+' mode='+intToSTR(mode),clWhite); + if mode=11 then AfficheDebug('Zone_TCO'+intToSTR(indexTCO)+' canton='+intToSTR(det1)+' dir='+intToSTR(det2)+' mode='+intToSTR(mode),clWhite); + end; + if (IndexTCO<1) or (IndexTCO>NbreTCO) or (PcanvasTCO[indexTCO]=nil) then exit; + + if (mode<=10) then + begin + // départ aux coordonnées X1 Y1 + trouve_el(indexTCO,det1,det,Xdet1,Ydet1); + if (Xdet1=0) or (Ydet1=0) then exit; + end; + + AdrTr1:=Detecteur[det1].AdrTrain; + AdrTr2:=Detecteur[det2].AdrTrain; memtrouve:=false; + NbTrouve:=0; indextrouve:=false; - Direction:=1; // on teste 4 directions: 1=SE 2=NO 3=SO 4=NE + if mode<=10 then Direction:=1 // on teste 4 directions: 1=SE 2=NO 3=SO 4=NE + else + begin + Direction:=det2; + end; repeat // boucle de test de direction sortir:=false; - x:=xDet1;y:=Ydet1; + if mode<=10 then + begin + // départ + x:=xDet1; + y:=Ydet1; + end; + if mode=11 then + begin + if det1=0 then + begin + Affiche('Erreur 122 ',clred); + exit; + end; + x:=canton[det1].x; + y:=canton[det1].y; + end; + if mode=12 then + begin + trouve_El(indexTCO,det1,det,x,y); + end; + xn:=x;yn:=y; ir:=1; // index de la route du tco i:=0; // itérations if debugTCO then afficheDebug('Direction '+intToSTR(direction),clOrange); // initialiser les points d'où l'on vient - if direction=1 then - begin - // vers SE - ancieny:=ydet1+1; - ancienx:=xdet1+1; + case direction of + 1 : begin + // du SE + if mode<=10 then + begin ancieny:=ydet1+1;ancienx:=xdet1+1;end + else + begin ancieny:=det2+1; ancienx:=det1+1; end; end; - if direction=2 then - begin - // vers NO - ancieny:=ydet1-1; - ancienx:=xdet1-1; + 2 : begin + // du NO + if mode<=10 then + begin ancieny:=ydet1-1;ancienx:=xdet1-1;end + else + begin ancieny:=det2-1; ancienx:=det1-1; end; end; - if direction=3 then - begin - // SO - ancieny:=ydet1+1; - ancienx:=xdet1-1; + 3 : begin + // du SO + if mode<=10 then + begin ancieny:=ydet1+1;ancienx:=xdet1-1;end + else + begin ancieny:=det2+1; ancienx:=det1-1; end; end; - if direction=4 then - begin - // vers NE - ancieny:=ydet1-1; - ancienx:=xdet1+1; + 4 : begin + // du NE + if mode<=10 then + begin ancieny:=ydet1-1;ancienx:=xdet1+1;end + else + begin ancieny:=det2-1; ancienx:=det1+1; end; end; + // uniquement modes 11/12: recherche élément à gauche + 5 : begin + ancienx:=x+1; ancieny:=y; + end; + // uniquement mode 11/12: recherche élément à droite + 6 : begin + ancienx:=x-1; ancieny:=y; + end; + // uniquement mode 11: recherche élément en haut + 7 : begin + ancienx:=x; ancieny:=y+1; + end; + // uniquement mode 11: recherche élément en bas + 8 : begin + ancienx:=x; ancieny:=y-1; + end; + end; if debugTCO then AfficheDebug('X='+intToSTR(x)+' Y='+IntToSTR(Y)+' AncienX='+intToSTR(ancienX)+' AncienY='+IntToSTR(ancienY),clyellow); // Affiche la cellule en fonction du mode iteration:=0; ir:=1; - El_tco(x,y,train,ir); // trouve l'élément suivant, et explore les ports de l'aiguillage en récursif + if mode=10 then + begin + xCanton:=0; + ycanton:=0; + end; + + El_tco(x,y,train,ir); // *********** trouve l'élément suivant, et explore les ports de l'aiguillage en récursif + + if (mode=11) and ((adresse<>0) or (but<>0) or sortir) then + begin + MemTrouve:=true; + Xcanton:=adresse; + if isAigTCO(Bimage) then Tel1:=aig else tel1:=det; + if but<>0 then tel1:=Buttoir; + end; + if (mode=12) and (adresse<>det1) then + begin + Xcanton:=adresse; + Memtrouve:=true; + end; + if debugTCO then AfficheDebug('retour',clWhite); inc(i); if (adresse=det2) then memTrouve:=true; - if ((Bimage=1) or (Bimage=20) or (Bimage=10) or (Bimage=11)) and ((adresse<>det2) and (adresse<>det1) and (adresse<>0)) then sortir:=true; + if (mode<=10) and ((Bimage=1) or (Bimage=20) or (Bimage=10) or (Bimage=11)) and ((adresse<>det2) and (adresse<>det1) and (adresse<>0)) then sortir:=true; + //if (mode>10) and ((Bimage=1) or (Bimage=20) or (Bimage=10) or (Bimage=11)) and ((adresse<>det2) and (adresse<>det1) and (adresse<>0)) then sortir:=true; if (i>NbCellulesTCO[indexTCO]) then AfficheDebug('Erreur 1000 TCO'+intToSTR(indexTCO)+' : dépassement d''itérations - Route de '+IntToSTR(det1)+' à '+IntToSTR(det2),clred); inc(direction) - until (direction=5) or memtrouve ; + until ((direction=5) and (mode<=10)) or ((direction=9) and (mode>=11)) or memtrouve ; if memTrouve then begin - if debugTco then afficheDebug('TCO: Trouvé route de '+intToSTR(det1)+' à '+intToSTR(det2)+' en '+intToSTR(x)+','+intToSTR(y),clLime); - Affiche_trajet(indexTCO,train,indexIr,mode); // affiche le trajet dans le TCO + if debugTco then + begin + afficheDebug('TCO: Trouvé route de '+intToSTR(det1)+' à '+intToSTR(det2),clLime); + if (mode=10) and (xCanton<>0) and (ycanton<>0) then afficheDebug('TCO: Trouvé canton en '+intToSTR(xCanton)+','+intToSTR(yCanton),clLime); + if (mode=11) then AfficheDebug('Trouvé1='+intToSTR(xcanton),clLime); + end; + if mode<3 then + begin + if AdrTr1<>0 then + begin + AdrTr:=AdrTr1; + //Affiche(intToSTR(det1)+' '+intToSTR(det2)+' Mode '+intToSTR(mode)+' Le détecteur1 '+intToSTR(Det1)+ ' est affecté au train @'+intToSTR(AdrTr1),clYellow); + end; + if AdrTr2<>0 then + begin + AdrTr:=Adrtr2; + //Affiche(intToSTR(det1)+' '+intToSTR(det2)+' Mode '+intToSTR(mode)+' Le détecteur2 '+intToSTR(Det2)+ ' est affecté au train @'+intToSTR(AdrTr2),clYellow); + end; + //Affiche_trajet(indexTCO,train,AdrTr,indexIr,mode); // affiche le trajet dans le TCO + Affiche_trajet(indexTCO,train,AdrTrain,indexIr,mode); // affiche le trajet dans le TCO + end; end; end; @@ -10156,7 +11342,7 @@ begin end; end; -// dessine les icones du tco et les aligne +// dessine les icones du bandeau du tco et les aligne procedure dessine_icones(indexTCO : integer); var ancH,ancW,i,lf,hf,sauv_ep: integer; ip : TImage; @@ -10195,6 +11381,12 @@ begin ip:=findComponent('ImagePalette'+intToSTR(i)) as Timage; lbl:=findComponent('Label'+intToSTR(i)) as Tlabel; positionne_icone_G2(IndexTCO,ip,lbl,i); + i:=Id_canton; + ip:=findComponent('ImagePalette'+intToSTR(i)) as Timage; + lbl:=findComponent('Label'+intToSTR(i)) as Tlabel; + positionne_icone_G2(IndexTCO,ip,lbl,i); + + // signal ip:=findComponent('ImagePalette51') as Timage; @@ -10253,6 +11445,8 @@ begin dessin_Quai(indexTCO,ImagePalette51.canvas,1,1,0); //quai dessin_Action(indexTCO,ImagePalette52.canvas,1,1,0); //action + dessin_icone_canton(indexTCO,ImagePalette53.canvas,1,1,0); //action + LargeurCell[indexTCO]:=20; @@ -10290,7 +11484,7 @@ begin with ScrollBox do begin Width:=clLarge-55; // laisser 50 pixels pour la trackbarzoom + scrollBar - //Width:=clLarge-300; // mode pour voir les imageTemp +// Width:=clLarge-400; // &&& mode pour voir les imageTemp top:=0; left:=0; end; @@ -10359,7 +11553,9 @@ begin positionne(indexTCO); + renseigne_tous_cantons; FormInit[indexTCO]:=true; + end; if indexTCO=NbreTCO then TCOActive:=true; end; @@ -10515,9 +11711,53 @@ begin result:=res; end; +// supprime le canton index et efface son dessin, le remplace par des voies +procedure supprime_remplace_canton(index : integer); +var el,i,n,xc,yc,idT : integer; +begin + if (index<1) or (index>ncantons) then exit; + n:=canton[index].Nelements; + xc:=canton[index].x; + yc:=canton[index].y; + idT:=canton[index].Ntco; + El:=tco[idt,xc,yc].BImage; + + if isCantonH(El) then + begin + for i:=xc to xc+n-1 do + begin + tco[idT,i,yc].BImage:=1; + tco[idT,i,yc].Texte:=''; + tco[idT,i,yc].PiedFeu:=0; + tco[idT,i,yc].FeuOriente:=0; + end; + end + else + if isCantonV(El) then + begin + for i:=yc to yc+n-1 do + begin + tco[idT,xc,i].BImage:=20; + tco[idT,xc,i].Texte:=''; + tco[idT,xc,i].PiedFeu:=0; + tco[idT,xc,i].FeuOriente:=0; + end; + end; + + supprime_canton(index); +end; + // efface le contenu de la cellule, sauf le fond procedure raz_cellule(indexTCO,x,y : integer); +var bim : integer; begin + bim:=tco[indexTCO,x,y].BImage; + if iscanton(bim) then + begin + bim:=index_canton(indexTCO,x,y); + if bim<>0 then supprime_canton(bim); + end; + tco[indextco,x,y].Adresse:=0; tco[indextco,x,y].Mode:=0; tco[indextco,x,y].Trajet:=0; @@ -10640,6 +11880,8 @@ begin screen.cursor:=crDefault; end; + + procedure grille(indexTCO : integer); var x,y : integer; begin @@ -10722,7 +11964,7 @@ begin end; procedure couper(indexTCO: integer); -var x,y,xMax,Ymax,XCell1,YCell1,xCell2,yCell2,haut,larg : integer; +var x,y,xMax,Ymax,XCell1,YCell1,xCell2,yCell2,haut,larg,Bim : integer; begin larg:=largeurCell[indexTCO]; haut:=hauteurCell[indexTCO]; @@ -10740,6 +11982,7 @@ begin EditTexte.Text:=''; end; + // couper par la fenetre graphique if FormTCO[indexTCO].RadioGroupSel.ItemIndex=1 then begin @@ -10772,6 +12015,14 @@ begin // couper sans sélection : on coupe une seule cellule if not(SelectionAffichee[indexTCO]) then begin + // si c'est un canton, le supprimer en remplacent par les voies + Bim:=tco[indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]].BImage; + if isCanton(Bim) then + begin + bim:=index_canton(indexTCO,XclicCell[indexTCO],YclicCell[indexTCO]); + supprime_remplace_canton(bim); + end; + tampontco[XclicCell[indexTCO],YclicCell[indexTCO]]:=tco[indextco,XclicCell[indexTCO],YclicCell[indexTCO]]; // pour pouvoir faire annuler couper TamponTCO_org.x1:=XclicCell[indexTCO];TamponTCO_org.y1:=YclicCell[indexTCO]; TamponTCO_org.x2:=XclicCell[indexTCO];TamponTCO_org.y2:=YclicCell[indexTCO]; @@ -10790,6 +12041,18 @@ begin TCO_modifie:=true; + // avant de faire copier, supprimer les cantons + for y:=yminiSel to ymaxiSel do + for x:=XminiSel to XmaxiSel do + begin + Bim:=tco[indexTCO,x,y].BImage; + if isCanton(Bim) then + begin + bim:=index_canton(indexTCO,x,y); + supprime_remplace_canton(bim); + end; + end; + copier(indexTCO); SelectionAffichee[indexTCO]:=false; @@ -11052,10 +12315,45 @@ begin end; end; +procedure Debut_drag_train(IndexTCO,x,y : integer); +var n,iD,xg,yg : integer; + horizontal : boolean; +begin + if affevt then affiche('Debut_drag_train',clYellow); + Id:=Index_canton_numero(Tco[indexTCO,x,y].PiedFeu); + if id=0 then exit; + n:=canton[Id].Nelements; + horizontal:=canton[Id].horizontal; + + PImageTCO[indexTCO].BeginDrag(true); + + IdCantonDragOrg:=Id; + lDrag:=canton[id].Licone-1; + hDrag:=canton[id].Hicone-1; + xg:=canton[id].Xicone+1; + yg:=canton[id].Yicone+1; + + // ImageTemp <- image du canton du tco + BitBlt(formTCO[indexTCO].ImageTemp.canvas.Handle,0,0,lDrag,hDrag, + PcanvasTCO[indexTCO].Handle,xg,yg,srcCopy); + + //formTCO[indexTCO].ImageTemp.Repaint; + + // OldBMP<-ImageTCO ; sauve le bitmap sous le pointeur de la souris + BitBlt(OldBmp.Canvas.Handle,0,0,lDrag,hDRag, + FormTCO[IndexTCO].ImageTCO.Canvas.Handle,offsetSourisX,offsetSourisY,SRCCOPY); + + drag:=2; // drag train d'un canton + TCODrag:=indexTCO; + oldx:=offsetSourisX; + oldy:=offsetSourisY; +end; + procedure debut_drag(image : TImage); var h,l,indexTCO : integer; c : Tcomponent; begin + if affevt then affiche('Debut_drag',clYellow); image.BeginDrag(true); c:=image.GetParentComponent; c:=c.GetparentComponent; @@ -11064,16 +12362,14 @@ begin l:=image.Width; h:=image.height; - // ImageTemp <- imageicone + // ImageTemp <- imageicone StretchBlt(formTCO[indexTCO].ImageTemp.canvas.Handle,0,0,LargeurCell[indexTCO],hauteurCell[indexTCO], // destination avec mise à l'échelle image.Canvas.Handle,0,0,l,h,srccopy); - //dessin_1(indexTCO,formTCO[indexTCO].ImageTemp.Canvas ,1,1,0); - // OldBMP<-ImageTCO ; sauve le bitmap sous le pointeur de la souris BitBlt(OldBmp.Canvas.Handle,0,0,LargeurCell[indexTCO],hauteurCell[indexTCO],FormTCO[IndexTCO].ImageTCO.Canvas.Handle,offsetSourisX,offsetSourisY,SRCCOPY); - drag:=true; + drag:=1; // drag train d'une icone de tco TCODrag:=indexTCO; oldx:=offsetSourisX; oldy:=offsetSourisY; @@ -11084,8 +12380,8 @@ procedure TFormTCO.ImageTCODragOver(Sender, Source: TObject; X, Y: Integer;State var indexTCO,xl,yl : integer; begin indexTCO:=Index_tco(sender); - if affevt then Affiche('TCO'+intToSTR(IndexTCO)+' DragOver',clyellow); - if TCODrag<>indexTCO then + + if (TCODrag<>indexTCO) then begin accept:=false; exit; // le drag source et destination sont différents @@ -11093,17 +12389,30 @@ begin xl:=x+offsetSourisX; yl:=y+offsetSourisY; Accept:=source is TImage; - if drag then + if drag=1 then begin + if affevt then Affiche('TCO'+intToSTR(IndexTCO)+' DragOver type1',clyellow); // canvasTCO<-oldBMP restitue l'ancien en oldx,oldy fond avant le nouveau BitBlt(PImageTCO[indexTCO].canvas.handle,oldx,oldy,LargeurCell[indexTCO],hauteurCell[indexTCO],oldbmp.canvas.handle,0,0,SRCCOPY); // remettre la sauvegarde du bitmap à l'ancienne position souris // oldbmp(0,0)<-canvasTCO(x1,y1) sauve le nouveau bitmap en x1,y1 BitBlt(oldbmp.canvas.handle,0,0,LargeurCell[indexTCO],hauteurCell[indexTCO],PImageTCO[IndexTCO].canvas.handle,xl,yl,SRCCOPY); // sauvegarder le bitmap actuel sous la souris oldx:=xl; oldy:=yl; // canvasTCO(x1,y1)<-ImageTemp(0,0) - BitBlt(PImageTCO[indexTCO].canvas.handle,xl,yl,LargeurCell[indexTCO],hauteurCell[indexTCO],formTCO[indexTCO].ImageTemp.canvas.handle,0,0,SRCCOPY); // copier l'icone vers la souris + BitBlt(PImageTCO[indexTCO].canvas.handle,xl,yl,LargeurCell[indexTCO],hauteurCell[indexTCO],FormTCO[indexTCO].imagetemp.canvas.handle,0,0,SRCCOPY); // copier l'icone vers la souris PImageTCO[IndexTCO].Repaint; end; + if drag=2 then + begin + if affevt then Affiche('TCO'+intToSTR(IndexTCO)+' DragOver type2',clyellow); + // canvasTCO<-oldBMP restitue l'ancien en oldx,oldy fond avant le nouveau + BitBlt(PCanvasTCO[indexTCO].handle,oldx,oldy,LDrag,hDRag,oldbmp.canvas.handle,0,0,SRCCOPY); // remettre la sauvegarde du bitmap à l'ancienne position souris + // oldbmp(0,0)<-canvasTCO(x1,y1) sauve le nouveau bitmap en x1,y1 + BitBlt(oldbmp.canvas.handle,0,0,LDrag,hDrag,PCanvasTCO[IndexTCO].handle,xl,yl,SRCCOPY); // sauvegarder le bitmap actuel sous la souris + oldx:=xl; oldy:=yl; + // canvasTCO(x1,y1)<-ImageTemp(0,0) + BitBlt(PcanvasTCO[indexTCO].handle,xl,yl,Ldrag,hDrag,FormTCO[indexTCO].imagetemp.canvas.handle,0,0,SRCCOPY); // copier l'icone vers la souris + PImageTCO[IndexTCO].Repaint; + end; end; @@ -11137,16 +12446,14 @@ end; procedure end_Drag(icone,x,y : integer;Sender, Target: TObject); var s : string; - indexTCO,xclic,Yclic : integer; +indexTCO,i,xclic,Yclic,bim,nc,maxi : integer; begin if not(Target is TImage) then exit; s:=(Target as TImage).Name; if copy(s,1,8)<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; - + drag:=0; indexTCO:=Index_tco(sender); - //Xclic:=XclicCell[indexTCO]; - //Yclic:=YClicCell[indexTCO]; BitBlt(formTCO[indexTCO].imageTCO.canvas.handle,oldx,oldy,LargeurCell[indexTCO],hauteurCell[indexTCO],oldbmp.canvas.handle,0,0,SRCCOPY); efface_entoure(indexTCO); @@ -11157,7 +12464,10 @@ begin XclicCell[indexTCO]:=Xclic; YClicCell[indexTCO]:=Yclic; - if not(verif_cellule(indexTCO,Xclic,Yclic,icone)) then exit; + //if not(verif_cellule(indexTCO,Xclic,Yclic,icone)) then exit; + // interdit de déposer sur un canton + if isCanton(tco[IndexTCO,Xclic,Yclic].BImage) then exit; + efface_cellule(IndexTCO,formTCO[indexTCO].ImageTCO.Canvas,Xclic,YClic,PmCopy); TCO_modifie:=true; @@ -11196,11 +12506,69 @@ begin 34 : dessin_34(indexTCO,FormTCO[indexTCO].ImageTCO.Canvas,XClic,YClic,0); id_Quai : dessin_Quai(indexTCO,FormTCO[indexTCO].ImageTCO.Canvas,XClic,YClic,0); id_action : dessin_Action(indexTCO,FormTCO[indexTCO].ImageTCO.Canvas,XClic,YClic,0); + id_canton : + + // autorisé à déposer que sur les icones 1 et 20 + begin + bim:=tco[indextco,XClic,YClic].BImage; // icone d'origine + if ((bim<>1) and (bim<>20)) or (Ncantons>=MaxCantons) then + begin + Affiche_TCO(indexTCO); + exit; + end; + + for i:=0 to 2 do + begin + if Bim=1 then // Horizontal + begin + if (tco[indexTCO,Xclic+i,Yclic].BImage<>1) or (tco[indexTCO,Xclic+i,Yclic].Adresse<>0) then + begin + Affiche_TCO(indexTCO); + exit; + end; + end; + if Bim=20 then // Vertical + begin + if (tco[indexTCO,Xclic,Yclic+i].BImage<>20) or (tco[indexTCO,Xclic,Yclic+i].Adresse<>0) then + begin + Affiche_TCO(indexTCO); + exit; + end; + end; + end; + + //pour le numéro de canton, + maxi:=0; + for nc:=1 to nCantons do + begin + if canton[nc].numero>maxi then maxi:=canton[nc].numero; + end; + inc(maxi); + + inc(Ncantons); + + canton[Ncantons].horizontal:=Bim=1; + canton[Ncantons].numero:=Maxi; + canton[Ncantons].Nelements:=3; + canton[Ncantons].x:=Xclic; + canton[Ncantons].y:=Yclic; + canton[Ncantons].nom:=''; + canton[Ncantons].Ntco:=indexTCO; + canton[Ncantons].indexTrain:=0; + tco[indextco,XClic,YClic].Texte:=''; + tco[indexTCO,XClic,YClic].FeuOriente:=3; // nbre éléments du canton + tco[indexTCO,XClic,YClic].PiedFeu:=Maxi; + + if Bim=1 then for i:=1 to 3 do tco[indextco,XClic+i-1,YClic].BImage:=id_cantonH+i-1; + if Bim=20 then for i:=1 to 3 do tco[indextco,Xclic,YClic+i-1].BImage:=id_cantonV+i-1; + dessin_canton(Ncantons,0,0); + renseigne_canton(Ncantons); + end; end; stocke_undo(indexTCO,1,XClic,YClic); maj_undo(1); - tco[indextco,XClic,YClic].BImage:=icone; // Image de la cellule + if icone<>id_canton then tco[indextco,XClic,YClic].BImage:=icone; // Image de la cellule tco[indextco,XClic,YClic].liaisons:=liaisons[icone]; // liaisons des voies tco[indextco,xClic,YClic].CoulFonte:=clYellow; tco[indextco,XClicCell[indexTCO],YClicCell[indexTCO]].Repr:=2; @@ -11932,11 +13300,95 @@ begin end; end; +function passe_bouton_canton(IndexTCO,x,y : integer) : integer; +var Xc,Yc,i,IdCanton,larg,haut,n : integer; + trouve : boolean; +begin + larg:=largeurCell[IndexTCO]; + haut:=HauteurCell[IndexTCO]; + //xt:=(x div larg)+1; // coords cellule de la souris + //yt:=(y div Haut)+1; + IdCanton:=1; + i:=1; + //Affiche('--------',clYellow); + repeat + Xc:=canton[i].x; + Yc:=canton[i].y; + n:=canton[i].Nelements; + if Canton[i].horizontal then + begin + yc:=(yc-1)*haut; + Xc:=Xc+n-1; + xc:=(xc-1)*larg; + end + else + begin + Xc:=(Xc-1)*larg; + Yc:=Yc+n-1; + yc:=(yc-1)*Haut; + end; + inc(i); + + //Affiche(INtToSTR(x)+' '+intToSTR(xc)+' '+intToSTR(xc+larg)+'/'+INtToSTR(y)+' '+intToSTR(yc)+' '+intToSTR(yc+Haut),clred); + trouve:=(x>Xc+4) and (xYc+4) and (ynCantons); + if trouve then result:=i-1 + else result:=0; +end; + +// sélectionne le canton du tco, qui a été cliqué à la souris +procedure selec_canton(indexTCO : integer); +var i,idTrain,Bimage,xt,yt,xclic,yclic : integer; + s : string; +begin + xclic:=XclicCell[indexTCO]; + yclic:=YclicCell[indexTCO]; + + Bimage:=tco[indextco,xclic,yclic].BImage; + efface_entoure(indexTCO); + if IscantonH(Bimage) then + begin + xt:=xClic-(Bimage-Id_cantonH); + yt:=yClic; + IdCantonSelect:=index_canton_numero(TCO[IndexTCO,xt,yt].PiedFeu); + end; + if IscantonV(Bimage) then + begin + yt:=yClic-(Bimage-Id_cantonV); + xt:=xClic; + IdCantonSelect:=index_canton_numero(TCO[IndexTCO,xt,yt].PiedFeu); + end; + //Affiche('Selection canton id='+intToSTR(IdCantonSelect)+' num='+intToSTR(TCO[IndexTCO,xt,yt].PiedFeu),clYellow); + if (IdCantonSelect<1) or (IdCantonSelect>ncantons) then begin Affiche('Anomalie 5 : '+intToSTR(IdCantonSelect),clred);exit;end; + // provoque l'affichage du canton en mode sélection (1) + Dessin_canton(IdCantonSelect,1,0); + + canton[IdCantonSelect].maxi:=99999; // limites d'autorisation de glissage des poignées au maxi + canton[IdCantonSelect].mini:=0; + deja_calcule:=false; + //adresse:=index_canton_numero(TCO[IndexTCO,xt,yt].PiedFeu); //??? + idTrain:=canton[IdCantonSelect].IndexTrain; + + actualise_seltrains; + + s:='Canton '; + if IdCantonSelect<>0 then + begin + s:=s+intToSTR(canton[IdCantonSelect].numero); + i:=canton[IdCantonSelect].indexTrain; + if i<>0 then + begin + s:=s+#13+'Occupé par le train n°'+intToSTR(i)+' '+canton[IdCantonSelect].NomTrain+' '+ #13; + s:=s+'Adresse='+intToSTR(trains[i].adresse); + end; + end; + formTCO[indexTCO].imageTCO.hint:=s; +end; // évènement qui se produit quand on clique gauche ou droit procedure TFormTCO.ImageTCOMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer); var position : Tpoint; - indexTCO,i,n,adresse,Bimage,xt,yt,xf,yf,xclic,yclic : integer; + xt,yt,bt,indexTCO,i,n,adresse,Bimage,xf,yf,xclic,yclic,IdCanton : integer; s : string; begin indexTCO:=index_tco(sender); @@ -11952,17 +13404,59 @@ begin if affEvt then Affiche('TCO'+intToSTR(i)+' souris clicG enfoncée',clYellow); if dbleClicTCO then begin dbleClicTCO:=false;exit;end; - // coordonnées grille + // coordonnées grille AncienXclic:=XclicCell[indexTCO]; AncienYclic:=YclicCell[indexTCO]; - XclicCell[indexTCO]:=Xclic; YclicCell[indexTCO]:=Yclic; - auto_tcurs:=true; clicsouris:=true; - Bimage:=tco[indextco,xclic,yclic].BImage; + + // ------------------ si clic sur bouton canton + IdCanton:=passe_bouton_canton(indexTCO,x,y); + if Idcanton>0 then + begin + //Affiche('Clic'+IntToSTR(IdCanton),clYellow); + bt:=canton[IdCanton].bouton; + case bt of + 0 : bt:=1; + 1 : bt:=2; + 2 : bt:=0; + end; + canton[IdCanton].bouton:=bt; + Dessin_canton(Idcanton,0,bt); + exit; + end + else + + // ------------------ traitement clic sur canton sélectionné : le désélectionner + if IdCantonSelect<>0 then + begin + if accroche_canton(indexTCO,IdCantonSelect,x,y) then exit; // on a pas cliqué sur les poignées + begin + // sinon, désélect le canton + IndexTCO:=canton[IdCantonSelect].Ntco; // reprendre l'index du TCO depuis le canton car on a peut etre cliqué sur un autre TCO + //Affiche('Desel',clred); + xt:=canton[IdCantonSelect].x; + yt:=canton[IdCantonSelect].y; + IdCanton:=index_canton_numero(TCO[IndexTCO,xt,yt].PiedFeu); + Affiche_rectangle_canton(indexTCO,IdCantonSelect); // efface la sélection + Dessin_canton(Idcanton,0,bt); + IdCantonSelect:=0; + end; + end; + + // ------------------ traitement clic sur canton non sélectionné : le sélectionner + begin + if IsCanton(Bimage) then + begin + selec_canton(indexTCO); + actualise(indexTCO); // actualise la fenetre de paramétrage + exit; + end; + end; + // action if (Bimage=id_action) and not(ConfCellTCO) then begin @@ -12181,7 +13675,6 @@ begin end else begin - // Affiche('HAHA',clred); // xMiniSel:=99999;yMiniSel:=99999; // xMaxiSel:=0;yMaxiSel:=0; @@ -12203,6 +13696,7 @@ begin // clic gauche, gestion des Hints clicTCO:=true; //Affiche('xcliccell='+IntToSTR(XclicCell[indexTCO])+' ycliccell='+IntToSTR(YclicCell[indexTCO]),clyellow); + if Bimage=id_signal then begin adresse:=tco[IndexTCO,xClic,yClic].Adresse; @@ -12254,7 +13748,7 @@ begin if Xclic>NbreCellX[indexTCO] then exit; if Yclic>NbreCellY[indexTCO] then exit; - + //if cantonSelect<>0 then exit; if not(selectionaffichee[indexTCO]) then _entoure_cell_clic(indexTCO); actualise(indexTCO); // actualise la fenetre de config cellule end; @@ -12271,7 +13765,8 @@ begin XclicCell[indexTCO]:=Xclic; YclicCell[indexTCO]:=Yclic; - _entoure_cell_clic(indexTCO); + Bimage:=tco[indexTCO,xclic,yclic].BImage; + if not(isCanton(Bimage)) then _entoure_cell_clic(indexTCO); auto_tcurs:=true; if modetrace[indexTCO] then begin @@ -12282,75 +13777,79 @@ begin screen.cursor:=crUpArrow; exit; end; - XclicCellInserer:=XClic; YclicCellInserer:=YClic; + clicTCO:=true; EditAdrElement.Text:=IntToSTR(tco[indextco,XClicCellInserer,YClicCellInserer].Adresse); EditTypeImage.Text:=IntToSTR(tco[indextco,XClicCellInserer,YClicCellInserer].Bimage); CheckPinv.Checked:=tco[indextco,XClicCellInserer,YClicCellInserer].inverse; + clicTCO:=false; end; end; procedure TFormTCO.ImageTCOMouseMove(Sender: TObject; Shift: TShiftState;X, Y: Integer); var r : Trect; - indexTCO,xMiniSelP,yMiniSelP,xMaxiSelP,yMaxiSelP,larg,haut : integer; + idTrain,indexTCO,xMiniSelP,yMiniSelP,xMaxiSelP,yMaxiSelP,larg,haut,IdCanton : integer; ok : boolean; begin - if affevt then Affiche('ImageTCOMouseMove',clLime); +// if affevt then Affiche('ImageTCOMouseMove',clLime); if dbleClicTCO then begin dbleClicTCO:=false;exit;end; //Affiche(IntToSTR(tempoSouris),clred); indexTCO:=index_tco(sender); + cellX:=x div LargeurCell[indexTCO]+1; // variables globales + cellY:=y div hauteurCell[indexTCO]+1; //Affiche(intToSTR(x)+','+intToSTR(y),clYellow); // exécuté uniquement si changement position souris - if (ax<>x) or (ay<>y) then + if (aSourisx<>x) or (aSourisy<>y) then begin + aSourisx:=x; + aSourisy:=y; if (radioGroupSel.ItemIndex=1) then begin //Affiche(IntToSTR(tick),clred); Accroche_Rectangle_selection(indexTCO,x,y); exit; end; - { - if (radioGroupSel.ItemIndex=0) then + + // vérifier si sélection canton + if IdCantonSelect<>0 then + begin + if Accroche_canton(IndexTCO,IdCantonSelect,x,y) then exit; + + idTrain:=canton[IdCantonSelect].indexTrain; + if clicSouris and (idTrain<>0) then if (trains[IdTrain].icone<>nil) and (trains[IdTrain].icone.width<>0) then begin - //if not(clicsouris) then affiche('non',clred); - if clicsouris and SelecBouge then - begin - // - x0:=(xMiniSel-1)*LargeurCell[indexTCO]; - y0:=(yMiniSel-1)*hauteurCell[indexTCO]; - larg:=((xMaxiSel-xMiniSel)+1)*LargeurCell[indexTCO]; - haut:=((yMaxiSel-yMiniSel)+1)*HauteurCell[indexTCO]; - //Affiche(intToSTR(xMiniSel)+',BUBU'+intToSTR(xMaxiSel),clred); - BitBlt(formTCO[indexTCO].ImageTCO.canvas.Handle,ax,ay,larg,haut,oldbmp.canvas.handle,0,0,SRCCOPY); // restitue l'ancien - BitBlt(oldbmp.canvas.handle,0,0,larg,haut,FormTCO[IndexTCO].ImageTCO.Canvas.Handle,x,y,SRCCOPY); //copier le nouveau - formTCO[indexTCO].ImageTCO.Repaint; + debut_drag_train(IndexTCO,canton[IdCantonSelect].x,canton[IdCantonSelect].y); + exit; + end; + exit; - //bitBlt(FormTCO[IndexTCO].ImageTemp.canvas.handle,0,0,larg,haut,FormTCO[IndexTCO].ImageTCO.Canvas.Handle,x,y,SRCCOPY); - //formTCO[indexTCO].ImageTemp.Repaint; + end; + // vérifier si on passe au dessus d'un bouton canton + IdCanton:=passe_bouton_canton(indexTCO,x,y); + if idCanton<>0 then + begin + PimageTCO[indexTCO].Cursor:=crHandPoint; + end + else PimageTCO[indexTCO].Cursor:=CrDefault; - ax:=x; - ay:=y; - - exit; - end; } end; - ax:=x; - ay:=y; + aSourisx:=x; + aSourisy:=y; + if selecBouge then exit; if Temposouris>0 then exit; // Affiche('*',cllime); //affiche(intToSTR(y),clorange); - cellX:=x div LargeurCell[indexTCO]+1; // variables globales - cellY:=y div hauteurCell[indexTCO]+1; + if (AncienXClicCell=CellX) and (AncienYClicCell=CellY) then exit; - PimageTCO[indexTCO].Hint:=''; + //PimageTCO[indexTCO].Hint:=''; AncienXClicCell:=CellX; AncienYClicCell:=CellY; @@ -12449,13 +13948,90 @@ begin end; procedure TFormTCO.ImageTCOMouseUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer); -var indexTCO,lg,ht,xo,yo : integer; +var An,Nouvx,Nouvy,xc,yc,n,indexTCO,lg,ht,xo,yo,larg,haut,i : integer; begin if affevt then Affiche('Souris clic relachée',clyellow); clicsouris:=false; SelecBouge:=false; indextco:=index_TCO(sender); + if IdCantonSelect<>0 then + begin + larg:=LargeurCell[indexTCO]; + haut:=HauteurCell[indexTCO]; + screen.cursor:=crDefault; + + // relache la souris sur sélection canton + if prise_droit or prise_gauche then + begin + with canton[IdCantonSelect] do + begin + xc:=x; + yc:=y; // évite la confusion entre canton[].x et le x de l'entrée de procédure + An:=Nelements; // ancien nombre d'éléments + n:=round(abs(gd.Left-gd.Right)/ larg); // nouveau nombre d'éléments + if prise_droit then + begin + NouvX:=xc; + for i:=1 to n do Tco[indexTCO,xc+i-1,yc].BImage:=Id_CantonH+(i-1); + if n0) then + //if ((Bimage=1) or (Bimage=20) or (Bimage=10) or (Bimage=11)) and (adresse<>0) then + if not(isAigTCO(Bimage)) and (adresse<>0) then begin if EvtClicDet then event_detecteur(adresse,not(detecteur[adresse].etat),'') else detecteur[adresse].etat:=not(detecteur[adresse].etat); @@ -13049,6 +14620,19 @@ begin piloteAig:=true; end; + if isCanton(Bimage) then + begin + if IdCantonSelect>0 then + begin + IndexTCO:=canton[IdCantonSelect].Ntco; // reprendre l'index du TCO depuis le canton car on a peut etre cliqué sur un autre TCO + xt:=canton[IdCantonSelect].x; + yt:=canton[IdCantonSelect].y; + IdCanton:=TCO[IndexTCO,xt,yt].PiedFeu; + formSelTrain.Show; + exit; + end; + end; + // commande de signal if Bimage=Id_signal then begin @@ -13422,7 +15006,6 @@ var oriente,piedFeu,indexTCO : integer; c : Tcomponent; begin if affevt then Affiche('on popup',clyellow); - c:=popupmenu1.PopupComponent ; // imageTCO c:=c.GetParentComponent; // scrollBox c:=c.GetParentComponent; // formTCO @@ -13781,7 +15364,8 @@ begin LineTo( round((x+LargeurCell[indexTCO])),round(y+hauteurCell[indexTCO]*ratioC/10) ); end; Affiche(formatfloat('0.000000',frxGlob[indexTCO]),clyellow); - dessin_Action(1,PcanvasTCO[1],3,3,1); + //dessin_Action(1,PcanvasTCO[1],3,3,1); + end; procedure change_couleur_fond(indexTCO : integer); @@ -14086,7 +15670,7 @@ begin auto_tcurs:=false; end; -procedure TFormTCO.ImagePalette52DragOver(Sender, Source: TObject; X, +procedure TFormTCO.ImagePalette53DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin accept:=true; @@ -14095,13 +15679,13 @@ end; procedure TFormTCO.ImagePalette52EndDrag(Sender, Target: TObject; X, Y: Integer); begin - end_drag(id_action,x,y,sender,target); + end_drag(id_Action,x,y,sender,target); end; -procedure TFormTCO.ImagePalette52MouseDown(Sender: TObject; +procedure TFormTCO.ImagePalette53MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - debut_drag(ImagePalette52); + debut_drag(ImagePalette53); end; procedure TFormTCO.ButtonAffSCClick(Sender: TObject); @@ -14229,14 +15813,153 @@ begin if TCO_modifie then begin res:=MessageDlg('Un des TCO a été modifié. '+#13+'Voulez-vous recharger le TCO : '+nomfichierTCO[indexTCO],mtConfirmation,[mbYes,mbNo,mbCancel],0); - if res=mrYes then - begin - lire_fichier_tco(indexTCO); - Affiche_TCO(indexTCO); - end; - if res=mrCancel then abort; + if res=mrNo then exit; end; + TCO_modifie:=false; + lire_fichier_tco(indexTCO); + Affiche_TCO(indexTCO); +end; + +procedure TFormTCO.Supprimercanton1Click(Sender: TObject); +var c : tcomponent; + index,El,indexTCO,xc,yc : integer; + s : string; +begin + c:=popupmenu1.PopupComponent ; // imageTCO + c:=c.GetParentComponent; // scrollBox + c:=c.GetParentComponent; // formTCO + indexTCO:=index_tco(c); + xc:=xClicCell[indexTCO]; + yc:=yClicCell[indexTCO]; + El:=tco[indexTCO,xc,yc].BImage; + + if isCanton(El) then + begin + s:='Voulez vous supprimer le canton '; + if isCantonH(El) then xc:=xc-(El-Id_cantonH); + if isCantonV(El) then yc:=yc-(El-Id_cantonV); + + index:=index_canton(indexTCO,xc,yc); + if index<>0 then s:=s+intToSTR(index)+' '+canton[index].nom; + s:=s+' ?'; + if Application.MessageBox(pchar(s),pchar('confirm'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then exit; + end; + + supprime_remplace_canton(index); + tco_modifie:=true; + Affiche_tco(indexTCO); + end; +procedure TFormTCO.Affecterlocomotiveaucanton1Click(Sender: TObject); +var c : tcomponent; + El,indexTCO,xc,yc : integer; +begin + c:=popupmenu1.PopupComponent ; // imageTCO + c:=c.GetParentComponent; // scrollBox + c:=c.GetParentComponent; // formTCO + indexTCO:=index_tco(c); + xc:=xClicCell[indexTCO]; + yc:=yClicCell[indexTCO]; + El:=tco[indexTCO,xc,yc].BImage; + if ((El>=Id_CantonH) and (El<=Id_CantonH+9)) or ((El>=Id_CantonV) and (El<=Id_CantonV+9)) then + begin + formSelTrain.Show; + end; +end; + +procedure TFormTCO.ImagePalette52MouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + debut_drag(ImagePalette52); +end; + +procedure TFormTCO.ImagePalette52DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette53EndDrag(Sender, Target: TObject; X, + Y: Integer); +begin + end_drag(53,x,y,Sender,Target); +end; + +// fin de drag des trains dans le canton destination +procedure TFormTCO.ImageTCOEndDrag(Sender, Target: TObject; X, Y: Integer); +var s : string; + Sens,idCantondest,IdTrain,Bim,xdest,ydest,xOrg,Yorg,indexTCO,prec,suiv,el1,el2: integer; + tel1,tel2 : tequipement; +begin + if not(Target is TImage) then exit; + s:=(Target as TImage).Name; + if copy(s,1,8)<>'ImageTCO' then exit; + if (x=0) and (y=0) then exit; + indexTCO:=Index_tco(sender); + Drag:=0; + + // origine + xOrg:=canton[IdCantonDragOrg].x; + yOrg:=canton[IdCantonDragOrg].y; + + xdest:=(x div largeurCell[indexTCO])+1; + ydest:=(y div largeurCell[indexTCO])+1; + Bim:=tco[indexTCO,xdest,ydest].BImage; + if not(IsCanton(Bim)) then + begin + Affiche_TCO(indexTCO); + exit; + end; + BitBlt(PcanvasTCO[indexTCO].handle,oldx,oldy,LIcone,hIcone,oldbmp.canvas.handle,0,0,SRCCOPY); + + if IscantonH(Bim) then + begin + xdest:=xdest-(Bim-Id_cantonH); + ydest:=ydest; + end; + if IscantonV(Bim) then + begin + xdest:=xdest; + ydest:=ydest-(Bim-Id_cantonV); + end; + IdCantonDest:=index_canton_numero(tco[IndexTCO,xdest,ydest].PiedFeu); + + sens:=canton[IdCantonDragOrg].Sens; // copier le sens + // raz train canton d'origine + IdTrain:=canton[IdCantonDragOrg].indexTrain; + + init_route_canton(idCantonDragOrg,idTrain,false); // raz de la route + Raz_trains_idcanton(IdCantonDragOrg); // raz su train du canton + + // affectation train canton destination + affecte_Train_canton(trains[idTrain].adresse,IdCantonDest); + + // sens source et dest = identiques + if canton[idCantondest].Sens=canton[idCantonDragOrg].Sens then + canton[IdCantonDest].Sens:=sens + else + begin + // si différents + if canton[IdCantonDest].horizontal then canton[IdCantonDest].Sens:=SensGauche + else canton[IdCantonDest].Sens:=SensHaut; + end; + + // initialise sa route + init_route_canton(IdCantonDest,idTrain,true); + + Affiche_TCO(indexTCO); + XclicCell[indexTCO]:=xDest; + YclicCell[indexTCO]:=yDest; + + // activer la route +// init_route_canton(idcantonDest,idtrain,true); + + + actualise_seltrains; +end; + + + end. diff --git a/Unitplace.dfm b/Unitplace.dfm index 4037fb9..2173465 100644 --- a/Unitplace.dfm +++ b/Unitplace.dfm @@ -1,9 +1,9 @@ -object FormPlace: TFormPlace +object FormRoulage: TFormRoulage Left = 368 Top = 142 BorderStyle = bsDialog - Caption = 'Placement des trains' - ClientHeight = 485 + Caption = 'Roulage des trains' + ClientHeight = 275 ClientWidth = 307 Color = clBtnFace Font.Charset = DEFAULT_CHARSET @@ -20,11 +20,11 @@ object FormPlace: TFormPlace PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel - Left = 40 + Left = 96 Top = 8 - Width = 229 + Width = 116 Height = 20 - Caption = 'Placement des trains pour le roulage' + Caption = 'Roulage des trains' Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -16 @@ -32,101 +32,16 @@ object FormPlace: TFormPlace Font.Style = [fsBold] ParentFont = False end - object LabelTrain1: TLabel - Left = 8 - Top = 64 - Width = 30 - Height = 13 - Caption = 'Train1' - end - object LabelTrain2: TLabel - Left = 8 - Top = 88 - Width = 30 - Height = 13 - Caption = 'Train2' - end - object LabelTrain3: TLabel - Left = 8 - Top = 112 - Width = 30 - Height = 13 - Caption = 'Train3' - end - object LabelTrain4: TLabel - Left = 8 - Top = 136 - Width = 30 - Height = 13 - Caption = 'Train4' - end - object LabelTrain5: TLabel - Left = 8 - Top = 160 - Width = 30 - Height = 13 - Caption = 'Train5' - end - object LabelTrain6: TLabel - Left = 8 - Top = 184 - Width = 30 - Height = 13 - Caption = 'Train6' - end - object Label2: TLabel - Left = 91 - Top = 32 - Width = 70 - Height = 26 - Alignment = taRightJustify - Caption = 'D'#233'tecteurs de placement' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'MS Sans Serif' - Font.Style = [] - ParentFont = False - WordWrap = True - end object LabelTexte: TLabel - Left = 9 - Top = 232 + Left = 17 + Top = 32 Width = 120 Height = 13 Caption = '. ' end - object Label3: TLabel - Left = 8 - Top = 208 - Width = 293 - Height = 13 - Caption = 'Pour ne pas placer un train, mettre 0 en face de son d'#233'tecteur' - end - object Label4: TLabel - Left = 168 - Top = 32 - Width = 54 - Height = 26 - Caption = 'D'#233'tecteurs destinataire' - WordWrap = True - end - object Label5: TLabel - Left = 8 - Top = 40 - Width = 73 - Height = 13 - Caption = 'Nom du train' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'MS Sans Serif' - Font.Style = [fsBold] - ParentFont = False - end object ButtonInitAig: TButton Left = 16 - Top = 248 + Top = 56 Width = 273 Height = 25 Caption = 'Positionner les aiguillages en position initiale' @@ -135,7 +50,7 @@ object FormPlace: TFormPlace end object ButtonSauve: TButton Left = 16 - Top = 408 + Top = 184 Width = 273 Height = 25 Hint = @@ -147,84 +62,9 @@ object FormPlace: TFormPlace TabOrder = 1 OnClick = ButtonSauveClick end - object Edit1: TEdit - Left = 128 - Top = 64 - Width = 33 - Height = 21 - Hint = 'D'#233'tecteur recevant le train 1' - ParentShowHint = False - ShowHint = True - TabOrder = 2 - OnChange = Edit1Change - end - object Edit2: TEdit - Left = 128 - Top = 88 - Width = 33 - Height = 21 - Hint = 'D'#233'tecteur recevant le train 2' - ParentShowHint = False - ShowHint = True - TabOrder = 3 - OnChange = Edit2Change - end - object Edit3: TEdit - Left = 128 - Top = 112 - Width = 33 - Height = 21 - Hint = 'D'#233'tecteur recevant le train 3' - ParentShowHint = False - ShowHint = True - TabOrder = 4 - OnChange = Edit3Change - end - object Edit4: TEdit - Left = 128 - Top = 136 - Width = 33 - Height = 21 - Hint = 'D'#233'tecteur recevant le train 4' - ParentShowHint = False - ShowHint = True - TabOrder = 5 - OnChange = Edit4Change - end - object Edit5: TEdit - Left = 128 - Top = 160 - Width = 33 - Height = 21 - Hint = 'D'#233'tecteur recevant le train 5' - ParentShowHint = False - ShowHint = True - TabOrder = 6 - OnChange = Edit5Change - end - object Edit6: TEdit - Left = 128 - Top = 184 - Width = 33 - Height = 21 - Hint = 'D'#233'tecteur recevant le train 6' - ParentShowHint = False - ShowHint = True - TabOrder = 7 - OnChange = Edit6Change - end - object ButtonPlace: TButton - Left = 16 - Top = 280 - Width = 273 - Height = 25 - Caption = 'Placer les trains sur les d'#233'tecteurs ci-dessus' - TabOrder = 8 - OnClick = ButtonPlaceClick - end object ButtonLanceRoutage: TButton Left = 16 - Top = 312 + Top = 88 Width = 273 Height = 25 Caption = 'Lancer le roulage' @@ -234,187 +74,49 @@ object FormPlace: TFormPlace Font.Name = 'MS Sans Serif' Font.Style = [fsBold] ParentFont = False - TabOrder = 9 + TabOrder = 2 OnClick = ButtonLanceRoutageClick end object Button1: TButton - Left = 208 - Top = 448 + Left = 216 + Top = 240 Width = 81 Height = 25 Caption = 'Config trains' - TabOrder = 10 + TabOrder = 3 OnClick = Button1Click end object ButtonArretroutage: TButton Left = 16 - Top = 376 + Top = 152 Width = 273 Height = 25 Hint = 'Arr'#234't des trains et lib'#232're les r'#233'servations' Caption = 'Arr'#234't du roulage' ParentShowHint = False ShowHint = True - TabOrder = 11 + TabOrder = 4 OnClick = ButtonArretroutageClick end - object CheckInverse1: TCheckBox - Left = 208 - Top = 64 - Width = 89 - Height = 17 - Hint = 'Pilotage en sens inverse' - Caption = 'sens inverse' - ParentShowHint = False - ShowHint = True - TabOrder = 12 - OnClick = CheckInverse1Click - end - object CheckInverse2: TCheckBox - Left = 208 - Top = 88 - Width = 89 - Height = 17 - Hint = 'Pilotage en sens inverse' - Caption = 'sens inverse' - ParentShowHint = False - ShowHint = True - TabOrder = 13 - OnClick = CheckInverse2Click - end - object CheckInverse3: TCheckBox - Left = 208 - Top = 112 - Width = 89 - Height = 17 - Hint = 'Pilotage en sens inverse' - Caption = 'sens inverse' - ParentShowHint = False - ShowHint = True - TabOrder = 14 - OnClick = CheckInverse3Click - end - object CheckInverse4: TCheckBox - Left = 208 - Top = 136 - Width = 89 - Height = 17 - Hint = 'Pilotage en sens inverse' - Caption = 'sens inverse' - ParentShowHint = False - ShowHint = True - TabOrder = 15 - OnClick = CheckInverse4Click - end - object CheckInverse5: TCheckBox - Left = 208 - Top = 160 - Width = 89 - Height = 17 - Hint = 'Pilotage en sens inverse' - Caption = 'sens inverse' - ParentShowHint = False - ShowHint = True - TabOrder = 16 - OnClick = CheckInverse5Click - end - object CheckInverse6: TCheckBox - Left = 208 - Top = 184 - Width = 89 - Height = 17 - Hint = 'Pilotage en sens inverse' - Caption = 'sens inverse' - ParentShowHint = False - ShowHint = True - TabOrder = 17 - OnClick = CheckInverse6Click - end - object EditDir1: TEdit - Left = 168 - Top = 64 - Width = 33 - Height = 21 - Hint = 'D'#233'tecteur suivant vers lequel doit se diriger le train 1' - ParentShowHint = False - ShowHint = True - TabOrder = 18 - OnChange = EditDir1Change - end - object EditDir2: TEdit - Left = 168 - Top = 88 - Width = 33 - Height = 21 - Hint = 'D'#233'tecteur suivant vers lequel doit se diriger le train 2' - ParentShowHint = False - ShowHint = True - TabOrder = 19 - OnChange = EditDir2Change - end - object EditDir3: TEdit - Left = 168 - Top = 112 - Width = 33 - Height = 21 - Hint = 'D'#233'tecteur suivant vers lequel doit se diriger le train 3' - ParentShowHint = False - ShowHint = True - TabOrder = 20 - OnChange = EditDir3Change - end - object EditDir4: TEdit - Left = 168 - Top = 136 - Width = 33 - Height = 21 - Hint = 'D'#233'tecteur suivant vers lequel doit se diriger le train 4' - ParentShowHint = False - ShowHint = True - TabOrder = 21 - OnChange = EditDir4Change - end - object EditDir5: TEdit - Left = 168 - Top = 160 - Width = 33 - Height = 21 - Hint = 'D'#233'tecteur suivant vers lequel doit se diriger le train 5' - ParentShowHint = False - ShowHint = True - TabOrder = 22 - OnChange = EditDir5Change - end - object EditDir6: TEdit - Left = 168 - Top = 184 - Width = 33 - Height = 21 - Hint = 'D'#233'tecteur suivant vers lequel doit se diriger le train 6' - ParentShowHint = False - ShowHint = True - TabOrder = 23 - OnChange = EditDir6Change - end object BitBtn1: TBitBtn - Left = 16 - Top = 448 + Left = 8 + Top = 240 Width = 73 Height = 25 - TabOrder = 24 + TabOrder = 5 OnClick = BitBtn1Click Kind = bkClose end object ButtonArretTrains: TButton Left = 16 - Top = 344 + Top = 120 Width = 273 Height = 25 Hint = 'Arr'#234'te tous les trains' Caption = 'Arr'#234't des trains' ParentShowHint = False ShowHint = True - TabOrder = 25 + TabOrder = 6 OnClick = ButtonArretTrainsClick end end diff --git a/Unitplace.pas b/Unitplace.pas index 01d58b7..5b20ada 100644 --- a/Unitplace.pas +++ b/Unitplace.pas @@ -1,637 +1,264 @@ -unit Unitplace; -interface - -uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, StdCtrls, unitprinc, unitpilote , unitDebug, Buttons; - -type - TFormPlace = class(TForm) - Label1: TLabel; - ButtonInitAig: TButton; - ButtonSauve: TButton; - LabelTrain1: TLabel; - LabelTrain2: TLabel; - LabelTrain3: TLabel; - LabelTrain4: TLabel; - LabelTrain5: TLabel; - Edit1: TEdit; - Edit2: TEdit; - Edit3: TEdit; - Edit4: TEdit; - Edit5: TEdit; - LabelTrain6: TLabel; - Edit6: TEdit; - Label2: TLabel; - ButtonPlace: TButton; - LabelTexte: TLabel; - Label3: TLabel; - ButtonLanceRoutage: TButton; - Button1: TButton; - ButtonArretroutage: TButton; - CheckInverse1: TCheckBox; - CheckInverse2: TCheckBox; - CheckInverse3: TCheckBox; - CheckInverse4: TCheckBox; - CheckInverse5: TCheckBox; - CheckInverse6: TCheckBox; - EditDir1: TEdit; - Label4: TLabel; - EditDir2: TEdit; - EditDir3: TEdit; - EditDir4: TEdit; - EditDir5: TEdit; - EditDir6: TEdit; - Label5: TLabel; - BitBtn1: TBitBtn; - ButtonArretTrains: TButton; - procedure ButtonInitAigClick(Sender: TObject); - procedure FormActivate(Sender: TObject); - procedure ButtonPlaceClick(Sender: TObject); - procedure Edit1Change(Sender: TObject); - procedure Edit2Change(Sender: TObject); - procedure Edit3Change(Sender: TObject); - procedure Edit4Change(Sender: TObject); - procedure Edit5Change(Sender: TObject); - procedure Edit6Change(Sender: TObject); - procedure Button1Click(Sender: TObject); - procedure ButtonSauveClick(Sender: TObject); - procedure FormKeyPress(Sender: TObject; var Key: Char); - procedure ButtonLanceRoutageClick(Sender: TObject); - procedure CheckInverse1Click(Sender: TObject); - procedure CheckInverse2Click(Sender: TObject); - procedure CheckInverse3Click(Sender: TObject); - procedure CheckInverse4Click(Sender: TObject); - procedure CheckInverse5Click(Sender: TObject); - procedure CheckInverse6Click(Sender: TObject); - procedure EditDir1Change(Sender: TObject); - procedure EditDir2Change(Sender: TObject); - procedure EditDir3Change(Sender: TObject); - procedure EditDir4Change(Sender: TObject); - procedure EditDir5Change(Sender: TObject); - procedure EditDir6Change(Sender: TObject); - procedure FormCreate(Sender: TObject); - procedure BitBtn1Click(Sender: TObject); - procedure ButtonArretTrainsClick(Sender: TObject); - procedure ButtonArretroutageClick(Sender: TObject); - private - { Déclarations privées } - public - { Déclarations publiques } - end; - -var - FormPlace: TFormPlace; - -procedure couleurs_place; -function demarre_index_train(indexTrain : integer) : boolean; - -implementation - -uses UnitConfig, UnitTCO , UnitHorloge, unitFicheHoraire; - -{$R *.dfm} - - - -procedure TFormPlace.ButtonInitAigClick(Sender: TObject); -begin - if cdm_connecte then - begin - Affiche('Placement des trains incompatible en mode CDM rail',clOrange); - exit; - end; - ButtonLanceRoutage.Enabled:=false; - init_aiguillages; - ButtonLanceRoutage.Enabled:=true; -end; - -procedure TFormPlace.FormActivate(Sender: TObject); -begin - if affevt then affiche('FormPlace activate',clLime); - LabelTrain1.Caption:=trains[1].nom_train; - Edit1.text:=intToSTR(placement[1].detecteur); - EditDir1.Text:=IntToSTR(placement[1].detdir); - CheckInverse1.Checked:=placement[1].inverse; - LabelTrain2.Caption:=trains[2].nom_train; - EditDir2.Text:=IntToSTR(placement[2].detdir); - CheckInverse2.Checked:=placement[2].inverse; - Edit2.text:=intToSTR(placement[2].detecteur); - CheckInverse3.Checked:=placement[3].inverse; - EditDir3.Text:=IntToSTR(placement[3].detdir); - LabelTrain3.Caption:=trains[3].nom_train; - Edit3.text:=intToSTR(placement[3].detecteur); - LabelTrain4.Caption:=trains[4].nom_train; - EditDir4.Text:=IntToSTR(placement[4].detdir); - Edit4.text:=intToSTR(placement[4].detecteur); - CheckInverse4.Checked:=placement[4].inverse; - LabelTrain5.Caption:=trains[5].nom_train; - EditDir5.Text:=IntToSTR(placement[5].detdir); - Edit5.text:=intToSTR(placement[5].detecteur); - CheckInverse5.Checked:=placement[5].inverse; - LabelTrain6.Caption:=trains[6].nom_train; - EditDir6.Text:=IntToSTR(placement[6].detdir); - Edit6.text:=intToSTR(placement[6].detecteur); - CheckInverse6.Checked:=placement[6].inverse; - defocusControl(ButtonInitAig,false); -end; - -procedure TFormPlace.ButtonPlaceClick(Sender: TObject); -var Suiv,prec,detect,erreur,i,it,indexTCO : integer; - s,Ssuiv,NomTrain : string; -begin - if cdm_connecte then - begin - Affiche('Placement des trains incompatible en mode CDM rail',clOrange); - exit; - end; - - raz_tout; - for detect:=1 to NbMaxDet do - begin - detecteur[detect].train:=''; - detecteur[detect].AdrTrain:=0; - detecteur[detect].IndexTrain:=0; - detecteur[detect].etat:=false; - end; - - it:=0; - for i:=1 to 6 do - begin - case i of - 1 : begin s:=edit1.Text;Ssuiv:=EditDir1.Text;end; - 2 : begin s:=edit2.Text;Ssuiv:=EditDir2.Text;end; - 3 : begin s:=edit3.Text;Ssuiv:=EditDir3.Text;end; - 4 : begin s:=edit4.Text;Ssuiv:=EditDir4.Text;end; - 5 : begin s:=edit5.Text;Ssuiv:=EditDir5.Text;end; - 6 : begin s:=edit6.Text;Ssuiv:=EditDir6.Text;end; - end; - - if (s<>'') and (Ssuiv<>'') then - begin - val(s,detect,erreur); - val(Ssuiv,Suiv,erreur); - NomTrain:=trains[i].nom_train; - if (detect>NbMaxDet )then LabelTexte.caption:='Erreur détecteur train '+intToSTR(i); - if detect<>0 then - begin - prec:=det_suiv_cont(Suiv,detect,1); // détecteur précédent (d'ou vient la loco) arret sur suivant - if (prec<9990) then - begin - inc(it); - - detecteur[detect].etat:=true; - detecteur[detect].AdrTrain:=trains[i].adresse; - detecteur[detect].train:=placement[i].train; - detecteur[detect].IndexTrain:=i; - - // valider zone précédente - MemZone[prec,detect].etat:=true; - MemZone[prec,detect].train:=placement[i].train; - MemZone[prec,detect].Adrtrain:=trains[i].adresse; - MemZone[prec,detect].IndexTrain:=i; - //Affiche(inttostr(prec)+' '+intToSTR(detect),clorange); - - // remplir 1er élément du tableau - event_det_train[it].NbEl:=1 ; - event_det_train[it].AdrTrain:=trains[i].adresse; - event_det_train[it].det[1].adresse:=prec; - event_det_train[it].det[1].etat:=false; - event_det_train[it].nom_train:=placement[i].train; +unit Unitplace; +interface - inc(N_trains); +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, unitprinc, unitpilote , unitDebug, Buttons, ExtCtrls; - // essai------------------------- - Event_Detecteur(detect,true,nomtrain); - detecteur[detect].AdrTrain:=trains[i].adresse; - // ----------------------------- +type + TFormRoulage = class(TForm) + Label1: TLabel; + ButtonInitAig: TButton; + ButtonSauve: TButton; + LabelTexte: TLabel; + ButtonLanceRoutage: TButton; + Button1: TButton; + ButtonArretroutage: TButton; + BitBtn1: TBitBtn; + ButtonArretTrains: TButton; + procedure ButtonInitAigClick(Sender: TObject); + procedure FormActivate(Sender: TObject); + procedure Button1Click(Sender: TObject); + procedure ButtonSauveClick(Sender: TObject); + procedure FormKeyPress(Sender: TObject; var Key: Char); + procedure ButtonLanceRoutageClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure BitBtn1Click(Sender: TObject); + procedure ButtonArretTrainsClick(Sender: TObject); + procedure ButtonArretroutageClick(Sender: TObject); + private + { Déclarations privées } + public + { Déclarations publiques } + end; - Affiche('Positionnement train '+detecteur[detect].train+' sur détecteur '+intToSTR(detect)+' vers '+Ssuiv,clLime); +var + FormRoulage: TFormRoulage; + +procedure couleurs_place; +function demarre_index_train(indexTrain : integer) : boolean; +procedure init_route(indexeventdet,prec,detect,indextrain : integer); +procedure raz_route(indexeventdet,prec,detect,indextrain : integer); + +implementation + +uses UnitConfig, UnitTCO , UnitHorloge, unitFicheHoraire, Selection_Train; + +{$R *.dfm} - end - else - begin - s:='Train '+nomtrain +' non positionné car détecteurs '+IntToSTR(detect)+' '+intToSTR(suiv)+' non consécutifs'; - Affiche(s,clred); - detecteur[detect].etat:=false; - detecteur[detect].train:=''; - detecteur[detect].adrTrain:=0; - end; - end - else - begin - detecteur[detect].etat:=false; - detecteur[detect].train:=''; - detecteur[detect].adrTrain:=0; - end; - end; - end; - - indexTCO:=1; - if formTCO[indexTCO].Showing then - begin - affiche_tco(1); - end; - Maj_Signaux(true); - Maj_Signaux(true); -end; - -procedure TFormPlace.Edit1Change(Sender: TObject); -var i,erreur : integer; -begin - val(edit1.Text,i,erreur); - if (erreur<>0) or (i<0) then - begin - LabelTexte.caption:='Erreur détecteur 1'; - exit; - end; - if index_adresse_detecteur(i)=0 then - begin - LabelTexte.caption:='Détecteur '+intToSTR(i)+' inexistant'; - exit; - end; - labelTexte.caption:=''; - placement[1].train:=trains[1].nom_train; - placement[1].detecteur:=i; -end; - -procedure TFormPlace.Edit2Change(Sender: TObject); -var i,erreur : integer; -begin - val(edit2.Text,i,erreur); - if (erreur<>0) or (i<0) then - begin - LabelTexte.caption:='Erreur détecteur 2'; - exit; - end; - if index_adresse_detecteur(i)=0 then - begin - LabelTexte.caption:='Détecteur '+intToSTR(i)+' inexistant'; - exit; - end; - labelTexte.caption:=''; - placement[2].train:=trains[2].nom_train; - placement[2].detecteur:=i; -end; - -procedure TFormPlace.Edit3Change(Sender: TObject); -var i,erreur : integer; -begin - val(edit3.Text,i,erreur); - if (erreur<>0) or (i<0) then - begin - LabelTexte.caption:='Erreur détecteur 3'; - exit; - end; - if index_adresse_detecteur(i)=0 then - begin - LabelTexte.caption:='Détecteur '+intToSTR(i)+' inexistant'; - exit; - end; - labelTexte.caption:=''; - placement[3].train:=trains[3].nom_train; - placement[3].detecteur:=i; -end; - -procedure TFormPlace.Edit4Change(Sender: TObject); -var i,erreur : integer; -begin - val(edit4.Text,i,erreur); - if (erreur<>0) or (i<0) then - begin - LabelTexte.caption:='Erreur détecteur 4'; - exit; - end; - if index_adresse_detecteur(i)=0 then - begin - LabelTexte.caption:='Détecteur '+intToSTR(i)+' inexistant'; - exit; - end; - labelTexte.caption:=''; - placement[4].train:=trains[4].nom_train; - placement[4].detecteur:=i; -end; - -procedure TFormPlace.Edit5Change(Sender: TObject); -var i,erreur : integer; -begin - val(edit5.Text,i,erreur); - if (erreur<>0) or (i<0) then - begin - LabelTexte.caption:='Erreur détecteur 5'; - exit; - end; - if index_adresse_detecteur(i)=0 then - begin - LabelTexte.caption:='Détecteur '+intToSTR(i)+' inexistant'; - exit; - end; - labelTexte.caption:=''; - placement[5].train:=trains[5].nom_train; - placement[5].detecteur:=i; -end; - -procedure TFormPlace.Edit6Change(Sender: TObject); -var i,erreur : integer; -begin - val(edit6.Text,i,erreur); - if (erreur<>0) or (i<0) then - begin - LabelTexte.caption:='Erreur détecteur 6'; - exit; - end; - if index_adresse_detecteur(i)=0 then - begin - LabelTexte.caption:='Détecteur '+intToSTR(i)+' inexistant'; - exit; - end; - labelTexte.caption:=''; - placement[6].train:=trains[6].nom_train; - placement[6].detecteur:=i; -end; - -procedure TFormPlace.Button1Click(Sender: TObject); -begin - formconfig.PageControl.ActivePage:=formconfig.TabSheetTrains; - formconfig.showmodal; - formconfig.Close; -end; - -procedure TFormPlace.ButtonSauveClick(Sender: TObject); -begin - sauve_config; -end; - -procedure TFormPlace.FormKeyPress(Sender: TObject; var Key: Char); -begin - if key=chr(27) then close; -end; - -// démarre un train si le signal n'est pas au rouge -function demarre_index_train(indexTrain : integer) : boolean; -var det,vitesse,AdrTrain,i,indexPlace,adrSignal,id,a : integer; - trouve,rouge : boolean; - Train,s : string; - -begin - // si il y a un signal sur le détecteur de démarrage du train est il au rouge? - i:=1; - AdrTrain:=Trains[indexTrain].adresse; - Train:=Trains[indexTrain].nom_train; - - det:=0; - while (iN_trains then exit; + Affiche('RAZ route',clyellow); + detecteur[detect].etat:=false; + detecteur[detect].AdrTrain:=0; + detecteur[detect].train:=''; + detecteur[detect].IndexTrain:=0; + + // dévalider zone + MemZone[prec,detect].etat:=false; + MemZone[prec,detect].train:=''; + MemZone[prec,detect].Adrtrain:=0; + MemZone[prec,detect].IndexTrain:=0; + //Affiche(inttostr(prec)+' '+intToSTR(detect),clorange); + + // raz 1er élément du tableau + event_det_train[indexeventdet].NbEl:=0 ; + event_det_train[indexeventdet].AdrTrain:=0; + event_det_train[indexeventdet].det[1].adresse:=0; + event_det_train[indexeventdet].det[1].etat:=false; + event_det_train[indexeventdet].nom_train:=''; + + // il faudrait supprimer et décaler indexeventdet + + detecteur[detect].AdrTrain:=0; + +end; + + +// monte le détecteur detect, affecte son train, valide la zone +// remplit le tableau event_det_train +procedure init_route(indexeventdet,prec,detect,indextrain : integer); +begin + if indexeventdet>N_trains then exit; + + detecteur[detect].etat:=true; + detecteur[detect].AdrTrain:=trains[indextrain].adresse; + detecteur[detect].train:=trains[indextrain].nom_train; + detecteur[detect].IndexTrain:=indextrain; + + // valider zone précédente + MemZone[prec,detect].etat:=true; + MemZone[prec,detect].train:=trains[indextrain].Nom_train; + MemZone[prec,detect].Adrtrain:=trains[indextrain].adresse; + MemZone[prec,detect].IndexTrain:=indextrain; + //Affiche(inttostr(prec)+' '+intToSTR(detect),clorange); + + // remplir 1er élément du tableau + event_det_train[indexeventdet].NbEl:=1 ; + event_det_train[indexeventdet].AdrTrain:=trains[indextrain].adresse; + event_det_train[indexeventdet].det[1].adresse:=prec; + event_det_train[indexeventdet].det[1].etat:=false; + event_det_train[indexeventdet].nom_train:=trains[indextrain].nom_train; + + Event_Detecteur(detect,true,trains[indexTrain].nom_train); + detecteur[detect].AdrTrain:=trains[indexTrain].adresse; + +end; + + +procedure TFormRoulage.ButtonInitAigClick(Sender: TObject); +begin + if cdm_connecte then begin - Det:=Adresse_detecteur[i]; - trouve:=detecteur[i].AdrTrain=AdrTrain; - inc(i); - end; - - // le train est sur un détecteur ? - if trouve then - begin - AdrSignal:=signal_detecteur(det); // trouve l'adresse du signal correspondant au détecteur - if AdrSignal<>0 then - begin - id:=index_Signal(AdrSignal); - a:=Signaux[id].EtatSignal; - // si signal n'est pas rouge, ok - rouge:=(a=semaphore_F) or (a=carre_F) and (a=violet_F); - if rouge then - begin - Affiche('Le signal '+intToSTR(AdrSignal)+' étant rouge, le train '+train+' @'+intToSTR(AdrTrain)+' ne démarre pas',clyellow); - result:=false; - exit; - end; - end; - end; - - vitesse:=trains[indexTrain].VitNominale; - if roulage then - begin - // trouver le train dans le tableau de placement des trains - indexPlace:=1; - trouve:=false; - while (indexPlace<6) and not(trouve)do + Affiche('Placement des trains incompatible en mode CDM rail',clOrange); + exit; + end; + ButtonLanceRoutage.Enabled:=false; + init_aiguillages; + ButtonLanceRoutage.Enabled:=true; +end; + +procedure TFormRoulage.FormActivate(Sender: TObject); +begin + if affevt then affiche('FormPlace activate',clLime); + defocusControl(ButtonInitAig,false); +end; + + +procedure TFormRoulage.Button1Click(Sender: TObject); +begin + formconfig.PageControl.ActivePage:=formconfig.TabSheetTrains; + formconfig.showmodal; + formconfig.Close; +end; + +procedure TFormRoulage.ButtonSauveClick(Sender: TObject); +begin + sauve_config; +end; + +procedure TFormRoulage.FormKeyPress(Sender: TObject; var Key: Char); +begin + if key=chr(27) then close; +end; + +// démarre un train si le signal n'est pas au rouge +function demarre_index_train(indexTrain : integer) : boolean; +var det,vitesse,AdrTrain,i,adrSignal,id,a,idcanton,sens : integer; + trouve,rouge : boolean; + Train,s : string; + +begin + // si il y a un signal sur le détecteur de démarrage du train est il au rouge? + i:=1; + AdrTrain:=Trains[indexTrain].adresse; + Train:=Trains[indexTrain].nom_train; + det:=0; + + vitesse:=trains[indexTrain].VitNominale; + if roulage then + begin + if trains[indexTrain].inverse then vitesse:=-vitesse; + Idcanton:=trains[indexTrain].canton; + {if idcanton>0 then begin - trouve:=placement[indexPlace].train=train; - inc(indexPlace); - end; - if not(trouve) then - begin - Affiche('Erreur 280 : Train '+train+' non trouvé en placement',clred); - result:=false; - exit; - end; - dec(indexPlace); - if (placement[indexPlace].inverse) then vitesse:=-vitesse; - end; - - if horloge then - begin - // trouver le train dans la grille horaire - i:=1; - trouve:=false; - while (i0 then s:=s+' depuis détecteur '+intToSTR(Det); - Affiche(s,clYellow); - if traceListe then AfficheDebug(s,clyellow); - if roulage then reserve_canton(Det,placement[indexPlace].detdir,adrtrain,0,nCantonsRes); -end; - - -procedure TFormPlace.ButtonLanceRoutageClick(Sender: TObject); -var i,j,adrDet,AdrTrain : integer; - trouve,demarre : boolean; -begin - if cdm_connecte then - begin - Affiche('Le placement des trains incompatible en mode CDM rail',clOrange); - exit; - end; - - trouve:=false; - // explorer les détecteurs pour lancer les trains si le détecteur est affecté à un train - for i:=1 to NDetecteurs do - begin - adrDet:=Adresse_detecteur[i]; - AdrTrain:=detecteur[AdrDet].AdrTrain; - j:=index_train_adresse(AdrTrain); + end; + dec(i); + vitesse:=GrilleHoraire[i].vitesse; + vitesse_loco(train,indextrain,adrTrain,vitesse,true); + exit; + end; - if Detecteur[adrDet].etat and (detecteur[adrDet].train<>'') then - begin - trouve:=true; - roulage:=true; - avecResa:=false; // pour adrTrain ou NumTrain - - - trains[j].roulage:=true; - - demarre:=demarre_index_train(j); - end - else - trains[j].roulage:=false; - end; - - // au moins un train démarre - if trouve then - begin - Maj_Signaux(true); - Formprinc.LabelTitre.caption:=titre+' - Mode roulage en cours'; - with Formprinc.SBMarcheArretLoco do - begin - Visible:=true; - end; - end; - if not(trouve) then Affiche('Pas de train placé',clOrange); -end; - -procedure TFormPlace.ButtonArretTrainsClick(Sender: TObject); -var i : integer; -begin - roulage:=false; - avecRESA:=formConfig.CheckBoxRESA.Checked; - Affiche('Arrêt du roulage de tous les trains',clorange); - Formprinc.LabelTitre.caption:=titre+' '; - for i:=1 to ntrains do - vitesse_loco('',i,trains[i].adresse,0,true); -end; - -procedure TFormPlace.CheckInverse1Click(Sender: TObject); -begin - placement[1].inverse:=CheckInverse1.Checked; -end; - -procedure TFormPlace.CheckInverse2Click(Sender: TObject); -begin - placement[2].inverse:=CheckInverse2.Checked; -end; - -procedure TFormPlace.CheckInverse3Click(Sender: TObject); -begin - placement[3].inverse:=CheckInverse3.Checked; -end; - -procedure TFormPlace.CheckInverse4Click(Sender: TObject); -begin - placement[4].inverse:=CheckInverse4.Checked; -end; - -procedure TFormPlace.CheckInverse5Click(Sender: TObject); -begin - placement[5].inverse:=CheckInverse4.Checked; -end; - -procedure TFormPlace.CheckInverse6Click(Sender: TObject); -begin - placement[6].inverse:=CheckInverse6.Checked; -end; - -procedure TFormPlace.EditDir1Change(Sender: TObject); -var i,erreur : integer; -begin - val(editDir1.Text,i,erreur); - if (erreur<>0) or (i<0) then exit; - if index_adresse_detecteur(i)=0 then - begin - LabelTexte.caption:='Détecteur '+intToSTR(i)+' inexistant'; - exit; - end; - labelTexte.caption:=''; - placement[1].detdir:=i; -end; - -procedure TFormPlace.EditDir2Change(Sender: TObject); -var i,erreur : integer; -begin - val(editDir2.Text,i,erreur); - if (erreur<>0) or (i<0) then exit; - if index_adresse_detecteur(i)=0 then - begin - LabelTexte.caption:='Détecteur '+intToSTR(i)+' inexistant'; - exit; - end; - labelTexte.caption:=''; - placement[2].detdir:=i; -end; - -procedure TFormPlace.EditDir3Change(Sender: TObject); -var i,erreur : integer; -begin - val(editDir3.Text,i,erreur); - if (erreur<>0) or (i<0) then exit; - if index_adresse_detecteur(i)=0 then - begin - LabelTexte.caption:='Détecteur '+intToSTR(i)+' inexistant'; - exit; - end; - labelTexte.caption:=''; - placement[3].detdir:=i; -end; - -procedure TFormPlace.EditDir4Change(Sender: TObject); -var i,erreur : integer; -begin - val(editDir4.Text,i,erreur); - if (erreur<>0) or (i<0) then exit; - if index_adresse_detecteur(i)=0 then - begin - LabelTexte.caption:='Détecteur '+intToSTR(i)+' inexistant'; - exit; - end; - labelTexte.caption:=''; - placement[4].detdir:=i; -end; - -procedure TFormPlace.EditDir5Change(Sender: TObject); -var i,erreur : integer; -begin - val(editDir5.Text,i,erreur); - if (erreur<>0) or (i<0) then exit; - if index_adresse_detecteur(i)=0 then - begin - LabelTexte.caption:='Détecteur '+intToSTR(i)+' inexistant'; - exit; - end; - labelTexte.caption:=''; - placement[5].detdir:=i; -end; - -procedure TFormPlace.EditDir6Change(Sender: TObject); -var i,erreur : integer; -begin - val(editDir6.Text,i,erreur); - if (erreur<>0) or (i<0) then exit; - if index_adresse_detecteur(i)=0 then - begin - LabelTexte.caption:='Détecteur '+intToSTR(i)+' inexistant'; - exit; - end; - labelTexte.caption:=''; - placement[6].detdir:=i; -end; - -procedure couleurs_place; + + // vitesse_loco('',adrTrain,j,trains[j].VitNominale,not(placement[j].inverse),true); + vitesse_loco('',indextrain,adrTrain,vitesse,true); + Maj_Signaux(true); // avec détecteurs + s:='Lancement du train '+train; + if det<>0 then s:=s+' depuis détecteur '+intToSTR(Det); + Affiche(s,clYellow); + if traceListe then AfficheDebug(s,clyellow); + + + //if roulage then reserve_canton(Det,suivant,adrtrain,0,nCantonsRes); +end; + + +procedure TFormRoulage.ButtonLanceRoutageClick(Sender: TObject); +var i,j,adrDet,AdrTrain : integer; + trouve,demarre : boolean; +begin + if cdm_connecte then + begin + Affiche('Le placement des trains incompatible en mode CDM rail',clOrange); + exit; + end; + + trouve:=false; + + for i:=1 to ncantons do + begin + adrTrain:=canton[i].adresseTrain; + if adrTrain<>0 then + begin + trouve:=true; + roulage:=true; + j:=index_train_adresse(AdrTrain); + demarre:=demarre_index_train(j); + + end; + + + end; + + + // au moins un train démarre + if trouve then + begin + Maj_Signaux(true); + Formprinc.LabelTitre.caption:=titre+' - Mode roulage en cours'; + with Formprinc.SBMarcheArretLoco do + begin + Visible:=true; + end; + end; + if not(trouve) then Affiche('Pas de train placé sur les cantons du TCO',clOrange); +end; + +procedure TFormRoulage.ButtonArretTrainsClick(Sender: TObject); +var i : integer; +begin + roulage:=false; + avecRESA:=formConfig.CheckBoxRESA.Checked; + Affiche('Arrêt du roulage de tous les trains',clorange); + Formprinc.LabelTitre.caption:=titre+' '; + for i:=1 to ntrains do + vitesse_loco('',i,trains[i].adresse,0,true); +end; + +procedure couleurs_place; var i : integer; c : tComponent; begin - if sombre then with formPlace do + if sombre then with formRoulage do begin color:=couleurFond; for i:=0 to ComponentCount-1 do @@ -640,33 +267,33 @@ begin composant(c,couleurFond,couleurTexte); end; end; -end; - -procedure TFormPlace.FormCreate(Sender: TObject); -begin - if affevt then affiche('FormPlace Create',clLime); - if debug=1 then Affiche('Début création fenetre Place',clLime); - position:=poMainFormCenter; - PlaceAffiche:=true; - couleurs_place; - if debug=1 then Affiche('Fin création fenetre Place',clLime); -end; - -procedure TFormPlace.BitBtn1Click(Sender: TObject); -begin - close; -end; - -procedure TFormPlace.ButtonArretroutageClick(Sender: TObject); -var i : integer; -begin - roulage:=false; - Affiche('Arrêt du roulage de tous les trains et libération des aiguillages',clorange); - Formprinc.LabelTitre.caption:=titre+' '; - for i:=1 to ntrains do - vitesse_loco('',i,trains[i].adresse,0,true); - raz_tout; -end; - -begin -end. +end; + +procedure TFormRoulage.FormCreate(Sender: TObject); +begin + if affevt then affiche('FormPlace Create',clLime); + if debug=1 then Affiche('Début création fenetre Place',clLime); + position:=poMainFormCenter; + PlaceAffiche:=true; + couleurs_place; + if debug=1 then Affiche('Fin création fenetre Place',clLime); +end; + +procedure TFormRoulage.BitBtn1Click(Sender: TObject); +begin + close; +end; + +procedure TFormRoulage.ButtonArretroutageClick(Sender: TObject); +var i : integer; +begin + roulage:=false; + Affiche('Arrêt du roulage de tous les trains et libération des aiguillages',clorange); + Formprinc.LabelTitre.caption:=titre+' '; + for i:=1 to ntrains do + vitesse_loco('',i,trains[i].adresse,0,true); + raz_tout; +end; + +begin +end. diff --git a/selection_train.dfm b/selection_train.dfm new file mode 100644 index 0000000..1055a13 --- /dev/null +++ b/selection_train.dfm @@ -0,0 +1,363 @@ +object FormSelTrain: TFormSelTrain + Left = 198 + Top = 117 + BorderIcons = [biSystemMenu] + BorderStyle = bsDialog + Caption = 'S'#233'lection train' + ClientHeight = 311 + ClientWidth = 745 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + OldCreateOrder = False + OnActivate = FormActivate + OnCreate = FormCreate + DesignSize = ( + 745 + 311) + PixelsPerInch = 96 + TextHeight = 13 + object LabelInfo: TLabel + Left = 176 + Top = 280 + Width = 44 + Height = 13 + Caption = 'LabelInfo' + end + object Label1: TLabel + Left = 16 + Top = 12 + Width = 34 + Height = 13 + Caption = 'Canton' + end + object ImageBas: TImage + Left = 488 + Top = 8 + Width = 41 + Height = 41 + Picture.Data = { + 07544269746D6170F6070000424DF60700000000000076000000280000003C00 + 00003C0000000100040000000000800700000000000000000000100000000000 + 0000000000000000800000800000008080008000000080008000808000008080 + 8000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF + FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF88FFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF008FFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF800008FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF0000008FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF000000008FFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFF0000000000FFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFF700000000000FFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFF70000000000000FFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFF7000000000000007FFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFF700000000000000007FFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFF70000000000000000007FFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFF7000000000000000000007FFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFF700000000000000000000007FFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFF70077778F70000007F87777007FFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFF8FFFFFFFF80000007FFFFFFFF8FFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF87777778FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000} + end + object ImageHaut: TImage + Left = 536 + Top = 8 + Width = 60 + Height = 60 + Picture.Data = { + 07544269746D6170F6070000424DF60700000000000076000000280000003C00 + 00003C000000010004000000000080070000C30E0000C30E0000100000000000 + 0000000000000000800000800000008080008000000080008000808000008080 + 8000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF + FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF87777778FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF70000007FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFF8FFFFFFFF70000008FFFFFFFF8FFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFF70077778F70000007F87777007FFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFF700000000000000000000007FFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFF7000000000000000000007FFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFF70000000000000000007FFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFF700000000000000007FFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFF7000000000000007FFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFF00000000000007FFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFF000000000007FFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFF0000000000FFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFF800000000FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF8000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF800008FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF88FFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000} + end + object Imagegauche: TImage + Left = 608 + Top = 8 + Width = 57 + Height = 49 + Picture.Data = { + 07544269746D6170F6070000424DF60700000000000076000000280000003C00 + 00003C000000010004000000000080070000C30E0000C30E0000100000000000 + 0000000000000000800000800000008080008000000080008000808000008080 + 8000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF + FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFF78FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFF70FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFF700FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFF7007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFF70007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFF700007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFF0000007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFF00000008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFF800000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFF8000000000777777777777777777777777777777778FFFFFFF + 0000FFFFFFFFF80000000000000000000000000000000000000000007FFFFFFF + 0000FFFFFFFF800000000000000000000000000000000000000000007FFFFFFF + 0000FFFFFFF8000000000000000000000000000000000000000000007FFFFFFF + 0000FFFFFFF8000000000000000000000000000000000000000000007FFFFFFF + 0000FFFFFFFFF00000000000000000000000000000000000000000007FFFFFFF + 0000FFFFFFFFF80000000000000000000000000000000000000000007FFFFFFF + 0000FFFFFFFFFFF000000000787777777777777777777777777777778FFFFFFF + 0000FFFFFFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFF70000008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFF7000007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFF700007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFF70007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFF7007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFF700FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFF70FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFF78FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000} + end + object ImageDroite: TImage + Left = 672 + Top = 8 + Width = 57 + Height = 57 + Picture.Data = { + 07544269746D6170F6070000424DF60700000000000076000000280000003C00 + 00003C000000010004000000000080070000C30E0000C30E0000100000000000 + 0000000000000000800000800000008080008000000080008000808000008080 + 8000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF + FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF87FFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF07FFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF007FFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7007FFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF70007FFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF700007FFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7000007FFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80000007FFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFF + 0000FFFFFFF877777777777777777777777777777787000000000FFFFFFFFFFF + 0000FFFFFFF70000000000000000000000000000000000000000008FFFFFFFFF + 0000FFFFFFF70000000000000000000000000000000000000000000FFFFFFFFF + 0000FFFFFFF7000000000000000000000000000000000000000000008FFFFFFF + 0000FFFFFFF7000000000000000000000000000000000000000000008FFFFFFF + 0000FFFFFFF700000000000000000000000000000000000000000008FFFFFFFF + 0000FFFFFFF70000000000000000000000000000000000000000008FFFFFFFFF + 0000FFFFFFF8777777777777777777777777777777770000000008FFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000008FFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80000000FFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7000000FFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF700007FFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF70007FFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7007FFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF007FFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF07FFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF87FFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000} + end + object LabelCanton: TLabel + Left = 264 + Top = 12 + Width = 3 + Height = 13 + end + object ButtonOK: TButton + Left = 74 + Top = 280 + Width = 75 + Height = 24 + Anchors = [akTop, akRight] + Caption = 'Ok' + TabOrder = 0 + OnClick = ButtonOKClick + end + object StringGridTrains: TStringGrid + Left = 8 + Top = 40 + Width = 721 + Height = 225 + ColCount = 6 + Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor] + ScrollBars = ssVertical + TabOrder = 1 + OnDrawCell = StringGridTrainsDrawCell + OnKeyDown = StringGridTrainsKeyDown + OnSelectCell = StringGridTrainsSelectCell + end + object ComboBoxCanton: TComboBox + Left = 64 + Top = 8 + Width = 169 + Height = 21 + ItemHeight = 13 + TabOrder = 2 + OnChange = ComboBoxCantonChange + end +end diff --git a/selection_train.pas b/selection_train.pas new file mode 100644 index 0000000..a0ee4d6 --- /dev/null +++ b/selection_train.pas @@ -0,0 +1,823 @@ +unit selection_train; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, Grids, ExtCtrls; + +type + TFormSelTrain = class(TForm) + ButtonOK: TButton; + StringGridTrains: TStringGrid; + LabelInfo: TLabel; + ComboBoxCanton: TComboBox; + Label1: TLabel; + ImageBas: TImage; + ImageHaut: TImage; + Imagegauche: TImage; + ImageDroite: TImage; + LabelCanton: TLabel; + procedure ButtonOKClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure StringGridTrainsDrawCell(Sender: TObject; ACol, + ARow: Integer; Rect: TRect; State: TGridDrawState); + procedure StringGridTrainsSelectCell(Sender: TObject; ACol, + ARow: Integer; var CanSelect: Boolean); + procedure FormActivate(Sender: TObject); + procedure StringGridTrainsKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure ComboBoxCantonChange(Sender: TObject); + private + { Déclarations privées } + public + { Déclarations publiques } + end; + +var + FormSelTrain: TFormSelTrain; + x,y,El,largC,hautC,indexTrainClic : Integer; + +procedure actualise_seltrains; +procedure affecte_Train_canton(AdrTrain,idcanton : integer); +procedure raz_trains_Idcanton(idc : integer); +procedure raz_cantons_train(AdrTrain : integer); +procedure init_route_canton(idcanton,IdTrain : integer;init : boolean); + +implementation + +uses UnitPrinc,UnitConfigCellTCO,UnitTCO,UnitPlace,unitconfig,unitDebug; + +{$R *.dfm} + +// supprime une entrée du tableau event_det_train contenant l'adresse du train +procedure supprime_route(adresse : integer); +var index,i,j : integer; + trouve : boolean; +begin + i:=1; + repeat + trouve:=event_det_train[i].AdrTrain=adresse; + inc(i); + until (trouve) or (i>n_trains); + + if trouve then + begin + //Affiche('Raz route train @'+intToSTR(adresse),clyellow); + dec(i); + for j:=i to n_trains-1 do + begin + event_det_train[j]:=event_det_train[j+1]; + end; + dec(n_trains); + end; +end; + +// initialise (init=true) ou raze (init=false) la route d'un train qui a été affectée au canton +procedure init_route_canton(idcanton,IdTrain : integer;init : boolean); +var horz : boolean; + el1,el2,suiv,prec,sens,t : integer; + tel1,tel2 : tequipement; + s : string; +begin + //Affiche('Init_route_canton '+intToSTR(idcanton)+' '+inttoSTR(idtrain),clYellow); + renseigne_canton(idcanton); + sens:=canton[IdCanton].Sens; // direction du train sur le canton + horz:=canton[idcanton].horizontal; + if horz then + begin + if sens=SensDroit then //------------------------------- + begin + el1:=canton[idCanton].el1; // gauche + tel1:=canton[idCanton].typ1; + el2:=canton[idCanton].el2; // droit + tel2:=canton[idCanton].typ2; + // si le suivant n'est pas un détecteur, le trouver + if (tel2<>det) and (tel1<>buttoir) then + begin + suiv:=detecteur_suivant_El(el1,tel1,el2,tel2,1); // arrêt sur suivant + el2:=suiv; + end; + // si le précédent n'est pas un détecteur, le trouver + if (tel1<>det) and (tel1<>buttoir) then + begin + prec:=detecteur_suivant_El(el2,tel2,el1,tel1,1); // arrêt sur suivant + el2:=prec; + end; + if init then + begin + //Affiche('nouvelle route vers droit',clYellow); + inc(n_trains); + s:=trains[idtrain].nom_train; + event_det_train[n_trains].NbEl:=1 ; + event_det_train[n_trains].AdrTrain:=trains[idtrain].adresse; + event_det_train[n_trains].det[1].adresse:=el2; + event_det_train[n_trains].det[1].etat:=false; + event_det_train[n_trains].nom_train:=s; + event_det_train[n_trains].NbEl:=1; + + MemZone[el1,el2].etat:=true; + MemZone[el1,el2].train:=s; + MemZone[el1,el2].AdrTrain:=trains[idtrain].adresse; + maj_signaux(true); + + Affiche_Evt('1-0. Tampon train @'+intToStr(trains[idtrain].adresse)+' '+event_det_train[n_trains].nom_train+'--------',clWhite); + Affiche_Evt(intToSTR(event_det_train[n_trains].det[1].adresse),clwhite); + + // réserver le canton + if roulage then + begin + t:=canton[idcanton].ntco; + zone_tco(t,el2,6,0,0,12); // élément contigu à droite (6) du canton + reserve_canton(el2,xcanton,trains[idtrain].adresse,0,nCantonsRes); + end; + end + else + begin + // supprimer les 2 sens + MemZone[el1,el2].etat:=false; + MemZone[el1,el2].train:=''; + MemZone[el1,el2].AdrTrain:=0; + MemZone[el2,el1].etat:=false; + MemZone[el2,el1].train:=''; + MemZone[el2,el1].AdrTrain:=0; + + maj_signaux(true); + supprime_route(trains[idTrain].adresse); + end; + end; + if Sens=SensGauche then //------------------------------- + begin + el2:=canton[idCanton].el1; // gauche dans el2 + tel2:=canton[idCanton].typ1; + el1:=canton[idCanton].el2; // droit dans el1 + tel1:=canton[idCanton].typ2; + // si le suivant n'est pas un détecteur, le trouver + if (tel1<>det) and (tel1<>buttoir) then + begin + suiv:=detecteur_suivant_El(el1,tel1,el2,tel2,1); // arrêt sur suivant + el2:=suiv; + end; + // si le précédent n'est pas un détecteur, le trouver + if (tel2<>det) and (tel1<>buttoir) then + begin + prec:=detecteur_suivant_El(el2,tel2,el1,tel1,1); // arrêt sur suivant + el2:=prec; + end; + if init then + begin + //Affiche('nouvelle route vers gauche',clYellow); + inc(n_trains); + //init_route(n_trains,el2,el1,idtrain); + s:=trains[idtrain].nom_train; + event_det_train[n_trains].NbEl:=1 ; + event_det_train[n_trains].AdrTrain:=trains[idtrain].adresse; + event_det_train[n_trains].det[1].adresse:=el2; + event_det_train[n_trains].det[1].etat:=false; + event_det_train[n_trains].nom_train:=s; + event_det_train[n_trains].NbEl:=1; + + MemZone[el1,el2].etat:=true; + MemZone[el1,el2].train:=s; + MemZone[el1,el2].AdrTrain:=trains[idtrain].adresse; + maj_signaux(true); + + // réserver le canton + if roulage then + begin + t:=canton[idcanton].ntco; + zone_tco(t,el2,5,0,0,12); // élément contigu à gauche (5) du canton + reserve_canton(el2,xcanton,trains[idtrain].adresse,0,nCantonsRes); + end; + end + else + begin + // supprimer les 2 sens + MemZone[el2,el1].etat:=false; + MemZone[el2,el1].train:=''; + MemZone[el2,el1].AdrTrain:=0; + + MemZone[el1,el2].etat:=false; + MemZone[el1,el2].train:=''; + MemZone[el1,el2].AdrTrain:=0; + maj_signaux(true); + supprime_route(trains[idTrain].adresse); + end; + end; + end + else + // canton vertical + begin + if Sens=SensBas then + begin + el1:=canton[idCanton].el1; // haut + tel1:=canton[idCanton].typ1; + el2:=canton[idCanton].el2; // bas + tel2:=canton[idCanton].typ2; + // si le suivant n'est pas un détecteur, le trouver + if (tel2<>det) and (tel1<>buttoir) then + begin + suiv:=detecteur_suivant_El(el1,tel1,el2,tel2,1); // arrêt sur suivant + el2:=suiv; + end; + // si le précédent n'est pas un détecteur, le trouver + if (tel1<>det) and (tel1<>buttoir) then + begin + prec:=detecteur_suivant_El(el2,tel2,el1,tel1,1); // arrêt sur suivant + el2:=prec; + end; + if init then + begin + //Affiche('nouvelle route vers bas',clYellow); + inc(n_trains); + s:=trains[idtrain].nom_train; + event_det_train[n_trains].NbEl:=1 ; + event_det_train[n_trains].AdrTrain:=trains[idtrain].adresse; + event_det_train[n_trains].det[1].adresse:=el2; + event_det_train[n_trains].det[1].etat:=false; + event_det_train[n_trains].nom_train:=s; + event_det_train[n_trains].NbEl:=1; + + MemZone[el1,el2].etat:=true; + MemZone[el1,el2].train:=s; + MemZone[el1,el2].AdrTrain:=trains[idtrain].adresse; + maj_signaux(true); + + // réserver le canton + if roulage then + begin + t:=canton[idcanton].ntco; + zone_tco(t,el2,8,0,0,12); // élément contigu en bas (8) du canton + reserve_canton(el2,xcanton,trains[idtrain].adresse,0,nCantonsRes); + end; + end + else + begin + // supprimer les 2 sens + MemZone[el1,el2].etat:=false; + MemZone[el1,el2].train:=''; + MemZone[el1,el2].AdrTrain:=0; + + MemZone[el2,el1].etat:=false; + MemZone[el2,el1].train:=''; + MemZone[el2,el1].AdrTrain:=0; + maj_signaux(true); + supprime_route(trains[idTrain].adresse); + end; + end; + if Sens=SensHaut then + begin + el2:=canton[idCanton].el1; // haut dans el2 + tel2:=canton[idCanton].typ1; + el1:=canton[idCanton].el2; // bas dans el1 + tel1:=canton[idCanton].typ2; + // si le suivant n'est pas un détecteur, le trouver + if (tel1<>det) and (tel1<>buttoir) then + begin + suiv:=detecteur_suivant_El(el1,tel1,el2,tel2,1); // arrêt sur suivant + el2:=suiv; + end; + // si le précédent n'est pas un détecteur, le trouver + if (tel2<>det) and (tel1<>buttoir) then + begin + prec:=detecteur_suivant_El(el2,tel2,el1,tel1,1); // arrêt sur suivant + el2:=prec; + end; + if init then + begin + //Affiche('nouvelle route vers haut',clYellow); + inc(n_trains); + //init_route(n_trains,el2,el1,idtrain); + s:=trains[idtrain].nom_train; + event_det_train[n_trains].NbEl:=1 ; + event_det_train[n_trains].AdrTrain:=trains[idtrain].adresse; + event_det_train[n_trains].det[1].adresse:=el2; + event_det_train[n_trains].det[1].etat:=false; + event_det_train[n_trains].nom_train:=s; + event_det_train[n_trains].NbEl:=1; + + MemZone[el2,el1].etat:=false; + MemZone[el2,el1].train:=''; + MemZone[el2,el1].AdrTrain:=0; + + MemZone[el1,el2].etat:=true; + MemZone[el1,el2].train:=s; + MemZone[el1,el2].AdrTrain:=trains[idtrain].adresse; + maj_signaux(true); + + // réserver le canton + if roulage then + begin + t:=canton[idcanton].ntco; + zone_tco(t,el2,7,0,0,12); // élément contigu en haut (7) du canton + reserve_canton(el2,xcanton,trains[idtrain].adresse,0,nCantonsRes); + end; + end + else + begin + // supprimer les 2 sens + MemZone[el1,el2].etat:=false; + MemZone[el1,el2].train:=''; + MemZone[el1,el2].AdrTrain:=0; + + MemZone[el2,el1].etat:=false; + MemZone[el2,el1].train:=''; + MemZone[el2,el1].AdrTrain:=0; + maj_signaux(true); + supprime_route(trains[idTrain].adresse); + end; + end; + end; +end; + +// supprime le train AdrTrain de tous les cantons, et réaffiche les cantons effacés concernés +procedure raz_cantons_train(AdrTrain : integer); +var i,t,idcanton,idTCO,x,y : integer; +begin + if (AdrTrain=0) then exit; + //Affiche('Raz_cantons_train(Adr='+intToSTR(AdrTrain)+')',clyellow); + if adrTrain<>0 then + begin + for i:=1 to Ncantons do + begin + if canton[i].adresseTrain=AdrTrain then + begin + t:=canton[i].indexTrain; + trains[t].canton:=0; + + canton[i].indexTrain:=0; + canton[i].adresseTrain:=0; + canton[i].NomTrain:=''; + idTCO:=canton[i].Ntco; + x:=canton[i].x; + y:=canton[i].y; + tco[idTCO,x,y].train:=0; + tco[idTCO,x,y].mode:=0; + Dessin_canton(idTCO,pcanvasTCO[idTCO],x,y,0,0); + end; + end; + exit; + end; + { + if indexTrain<>0 then + begin + for i:=1 to Ncantons do + begin + if canton[i].indexTrain=IndexTrain then + begin + t:=canton[i].indexTrain; + trains[t].canton:=0; + + canton[i].indexTrain:=0; + canton[i].adresseTrain:=0; + canton[i].NomTrain:=''; + idTCO:=canton[i].Ntco; + x:=canton[i].x; + y:=canton[i].y; + tco[idTCO,x,y].train:=0; + tco[idTCO,x,y].mode:=0; + Dessin_canton(idTCO,pcanvasTCO[idTCO],x,y,0,0); + end; + end; + end; + } + +end; + + +// affecte le train id train ou adresse au canton et au TCO. +// désaffecte ce train pour tous les autres canton +// si adrTrain=9999 , train inconnu +// si adrTrain=0 ; efface +// et les pointeurs de trains de l'idTrain sont razés +procedure affecte_Train_canton(AdrTrain,idcanton : integer); +var idTrain,t,i : integer; +begin + //Affiche('Affecte_train_canton: IdTrain='+intToSTR(idTrain)+' @='+intToSTR(AdrTrain)+' canton='+intToSTR(idcanton),clorange); + if (IdCanton>0) and (idCanton<=nCantons) then + begin + if (AdrTrain<>0) and (adrTrain<>9999) then + begin + idTrain:=Index_train_adresse(adrTrain); + + raz_cantons_train(AdrTrain); // efface tous les cantons affichant le train Adrtrain + + trains[idTrain].canton:=canton[idcanton].numero; + canton[Idcanton].indexTrain:=idTrain; + canton[Idcanton].NomTrain:=trains[idTrain].nom_train; + canton[IdCanton].adresseTrain:=AdrTrain; + end; + if AdrTrain=9999 then + begin + idTrain:=9999; + canton[Idcanton].NomTrain:=''; + canton[Idcanton].indexTrain:=9999; + canton[IdCanton].adresseTrain:=0; + end; + if AdrTrain=0 then + begin + idTrain:=0; + canton[Idcanton].NomTrain:=''; + canton[Idcanton].indexTrain:=0; + canton[IdCanton].adresseTrain:=0; + end; + + t:=canton[IdCanton].Ntco; + if (t>0) and (t<=nbreTCO) then TCO[t,canton[idCanton].x,canton[idCanton].y].train:=idTrain; + end; +end; + +// renvoie x,y El et indexCanton en variable globale +procedure quel_canton; +begin + if IdCantonSelect=0 then exit; + x:=canton[IdCantonSelect].x; + y:=canton[IdCantonSelect].y; + El:=tco[indexTCOCourant,x,y].BImage; +end; + +procedure Dessine_fleche(ligne : integer;r : Trect); +var indexTrain,IdCanton : integer; + Image : TImage; +begin + if (ligne>0) then + with FormSelTrain do + begin + indexTrain:=ligne; + Idcanton:=index_canton_numero(trains[indexTrain].canton); + if (idcanton<1) or (idcanton>ncantons) then exit; + + with StringGridTrains do + begin + case canton[idcanton].Sens of + 1 : Image:=ImageGauche; + 2 : Image:=ImageDroite; + 3 : Image:=ImageHaut; + 4 : Image:=ImageBas; + else exit; + end; + StretchBlt(canvas.Handle,r.left,r.Top,ColWidths[6],RowHeights[6], // destination avec mise à l'échelle + image.Canvas.Handle,0,0,FormSelTrain.imageHaut.Width,FormSelTrain.imageHaut.Height,srccopy); + end; + end; +end; + +procedure maj_stringGrig; +var i,ic,t,NumCanton : integer; + s : string; +begin + // maj de la stringGrig + if IdCantonSelect>0 then + begin + s:='Canton '+intToSTR(IdCantonSelect)+' encadré par '+intToSTR(canton[IdCantonSelect].el1); + i:=canton[IdCantonSelect].Sens1; + case i of + SensHaut : s:=s+' haut '; + SensBas : s:=s+' bas '; + SensGauche : s:=s+' gauche '; + SensDroit : s:=s+' droit '; + end; + s:=s+' '+intToSTR(canton[IdCantonSelect].el2); + + i:=canton[IdCantonSelect].Sens2; + case i of + SensHaut : s:=s+' haut '; + SensBas : s:=s+' bas '; + SensGauche : s:=s+' gauche '; + SensDroit : s:=s+' droit '; + end; + + s:=s+' loco vers '; + i:=canton[IdCantonSelect].Sens; + case i of + SensHaut : s:=s+' haut '; + SensBas : s:=s+' bas '; + SensGauche : s:=s+' gauche '; + SensDroit : s:=s+' droit '; + end; + formSelTrain.LabelCanton.caption:=s; + end; + + for i:=1 to ntrains do + begin + NumCanton:=trains[i].canton; // numéro de canton + ic:=index_canton_numero(NumCanton); + if ic<=ncantons then + begin + with FormSelTrain.StringGridTrains do + begin + if Ic<>0 then //canton ic affecté au train i + begin + cells[3,i]:=IntToSTR(NumCanton); + cells[4,i]:=canton[Ic].nom; + t:=canton[Ic].Ntco; + s:='N°'+intToSTR(t)+' '; + if t<>0 then s:=s+NomfichierTCO[t]; + cells[5,i]:=s; + end + else + begin + cells[3,i]:=''; cells[4,i]:=''; cells[5,i]:=''; + cells[6,i]:=''; // efface la fleche + end; + end; + end; + end; + FormSelTrain.StringGridTrains.Repaint; // pour afficher correctement la fleche +end; + +procedure TFormSelTrain.ButtonOKClick(Sender: TObject); +begin + close; +end; + +procedure TFormSelTrain.FormCreate(Sender: TObject); +var i,x,y : integer; +begin +{ SetWindowPos(Handle,HWND_TOPMOST,0,0,0,0,SWP_NoMove or SWP_NoSize); + Canton[3].indexTrain:=1; + TCO[1,canton[3].x,canton[3].y].train:=1; + trains[1].canton:=3; + } + + with ImageHaut do begin Width:=60;Height:=60;visible:=false; end; + with ImageBas do begin Width:=60;Height:=60;visible:=false; end; + with ImageDroite do begin Width:=60;Height:=60;visible:=false; end; + with ImageGauche do begin Width:=60;Height:=60;visible:=false; end; + + hautC:=25; + largC:=130; + LabelInfo.caption:=''; + with StringGridTrains do + begin + //Options:=StringGridTrains.Options+[goEditing]; + Hint:='Sélection d''un train'; + ShowHint:=true; + ColCount:=7; + RowCount:=Ntrains+1; + Options := StringGridTrains.Options + [goEditing]; + ColWidths[0]:=30; + ColWidths[1]:=200; // icone + ColWidths[2]:=150; // nom du train + ColWidths[3]:=60; // canton + ColWidths[4]:=100; + ColWidths[5]:=100; + ColWidths[6]:=30; + + + Cells[1,0]:='Icône'; + Cells[2,0]:='Nom du train'; + Cells[3,0]:='N°canton'; + Cells[4,0]:='Nom du canton'; + Cells[5,0]:='TCO'; + Cells[6,0]:='Sens'; + + RowHeights[0]:=22; + end; + + for i:=1 to ntrains do + begin + with StringGridTrains do + begin + cells[2,i]:=trains[i].nom_train; + end; + end; + + // interdit la modification des cellules au clavier + with StringGridTrains do + begin + for x:=0 to RowCount-1 do + for y:=0 to ColCount-1 do + StringGridTrains.Options := StringGridTrains.Options - [goEditing] - [goRangeSelect]; + end; +end; + + +procedure TFormSelTrain.StringGridTrainsDrawCell(Sender: TObject; ACol,ARow: Integer; Rect: TRect; State: TGridDrawState); +var indextrain,l,h,hautdest,largdest : integer; + rd : double; +begin + // Affiche('DrawCell '+intToSTR(Acol)+'x'+intToSTR(Arow),clred); + + // affiche l'icone du train + if (Acol=1) and (Arow>0) then + with StringGridTrains do + begin + + // dessine le train dans la colonne 1 + indextrain:=Arow; + if trains[indexTrain].icone<>nil then + begin + // source + //Affiche(intToSTR(Acol)+' '+intToSTR(Arow),clred); + + l:=Trains[indextrain].Icone.width; + h:=Trains[indextrain].Icone.Height; + if h=0 then exit; + rd:=l/h; + //Affiche(FloatToSTR(rd),clred); + // destination : la hauteur est fixée + HautDest:=rect.bottom-rect.top; //round(ImageTrain.Height); + LargDest:=round(Hautdest*rd); + + // si la largeur > que l'image, on fixe la largeur + if LargDest>rect.right-rect.left then //ImageTrain.Width then + begin + LargDest:=rect.right-rect.left; // ImageTrain.Width; + HautDest:=round(LargDest/rd); + end; + + //y:=rect.bottom-rect.top-HautDest; + TransparentBlt(canvas.Handle,rect.Left+2,rect.Top,largDest,hautDest, + Trains[indexTrain].Icone.canvas.Handle,0,0,l,h,clWhite); + end; + end; + + // dessine les fleches + if (Acol=6) and (Arow>0) then + dessine_fleche(Arow,rect); +end; + +// c = numéro de canton +procedure xxraz_trains_canton(c : integer); +var ax,ay,i,ic : integer; +begin + + for i:=1 to Ntrains do + begin + ic:=trains[i].canton; + if ic=c then + begin + trains[i].canton:=0; + if ic<>0 then + begin + ax:=canton[Ic].x; + ay:=canton[Ic].y; + tco[IndexTCOCourant,ax,ay].train:=0; + canton[Ic].indexTrain:=0; + canton[Ic].adresseTrain:=0; + canton[Ic].NomTrain:=''; + end; + end; + end; +end; + +// raz des trains affectés au canton d'index "idc" +procedure raz_trains_idcanton(idc : integer); +var ax,ay,i,ic : integer; +begin + for i:=1 to Ntrains do + begin + ic:=index_canton_numero(trains[i].canton); + if ic=idc then + begin + trains[i].canton:=0; + if ic<>0 then + begin + ax:=canton[Ic].x; + ay:=canton[Ic].y; + tco[IndexTCOCourant,ax,ay].train:=0; + canton[Ic].indexTrain:=0; + canton[Ic].adresseTrain:=0; + canton[Ic].NomTrain:=''; + end; + end; + end; +end; + +// cliqué sur cellule pour changer la sélection du train ou la flèche +procedure TFormSelTrain.StringGridTrainsSelectCell(Sender: TObject; ACol, + ARow: Integer; var CanSelect: Boolean); +var f,AutreTrain,AutreCanton,idAutrecanton,i : integer; + faire : boolean; +begin + if affevt then Affiche('FormSelTrain.StringGridTrainsSelectCell '+intToSTR(ACol)+' '+intToSTR(ARow),clYellow); + if (Arow>nTrains) or (IdCantonSelect<1) then exit; + + //------------change la sélection du train + if (Arow>=1) and (ACol<=5) then + begin + indexTrainClic:=Arow; + // Affiche('ligne='+intToSTR(Arow)+' col='+intToSTR(Acol),clyellow); + + quel_canton; // x,y El et indexCanton du canton activé + + faire:=true; + LabelInfo.caption:=''; + // vérifier si le train est affecté à un autre canton + AutreCanton:=trains[indexTrainClic].canton; + idAutrecanton:=index_canton_numero(autreCanton); + if (IdAutrecanton<>0) and (IdAutreCanton<>IdCantonSelect) then + begin + LabelInfo.caption:='Le train '+intToSTR(IndexTrainClic)+' est affecté au canton '+intToSTR(AutreCanton); + exit; + end; + + if faire then + begin + // vérifier si un autre train est affecté au canton + AutreTrain:=canton[IdCantonSelect].indexTrain; + if autreTrain<>0 then + begin + LabelInfo.caption:='Le train '+intToSTR(AutreTrain)+' est déjà affecté au canton - Effacement'; + faire:=true; + if trains[indexTrainClic].canton=canton[IdCantonSelect].numero then faire:=false ; // ne pas faire l'affectaction, c'est une désaffectaction + raz_trains_idcanton(IdCantonSelect); + //Affiche('Et 1',clYellow); + init_route_canton(IdCantonSelect,indexTrainClic,false); // raz du placement du train et de sa route + end; + + // affecter le train, le canton et le TCO + if faire then + begin + if canton[IdCantonSelect].horizontal then canton[IdCantonSelect].Sens:=SensDroit else canton[IdCantonSelect].Sens:=SensBas; + //Affiche('Et 2',clYellow); + affecte_Train_canton(trains[indexTrainClic].adresse,IdCantonSelect); + init_route_canton(IdCantonSelect,indexTrainClic,true); // placement du train + end; + end; + end; + + // change le sens---------------------------- + if Acol=6 then + begin + // si on a cliqué sur un train affecté, on procède + IdAutreCanton:=index_canton_numero(trains[Arow].canton); + if IdAutreCanton>0 then + begin + f:=canton[IdAutreCanton].Sens; + + inc(f); + if canton[IdAutreCanton].horizontal then + begin + if (f<1) or (f>SensDroit) then f:=SensGauche; + end + else + begin + if (f=5) or (f0 then s:=s+' au canton '+intToSTR(IdCantonSelect)+' : '+canton[IdCantonSelect].nom; + FormSelTrain.caption:=s; + + with formSelTrain.ComboBoxCanton do + begin + clear; + for i:=1 to nCantons do items.add('Canton n°'+IntToSTR(canton[i].numero)+' '+canton[i].nom); + ItemIndex:=IdCantonSelect-1; + end; + + if IdCantonSelect=0 then formSelTrain.labelInfo.caption:='Sélectionnez un canton'; + + maj_stringGrig; // change indexcanton +end; + +procedure TFormSelTrain.FormActivate(Sender: TObject); +begin + actualise_Seltrains; +end; + + + +procedure TFormSelTrain.StringGridTrainsKeyDown(Sender: TObject; + var Key: Word; Shift: TShiftState); +begin + key:=0; // évite le mouvement de sélection par les touches +end; + +procedure TFormSelTrain.ComboBoxCantonChange(Sender: TObject); +begin + IdCantonSelect:=ComboBoxCanton.itemIndex+1; + maj_stringGrig; + Affiche_TCO(indexTCOCourant); +end; + + + +end. + diff --git a/verif_version.pas b/verif_version.pas index 6e8198f..a1aec86 100644 --- a/verif_version.pas +++ b/verif_version.pas @@ -26,7 +26,7 @@ var chemin_Dest,chemin_src,date_creation,nombre_tel : string; f : text; -Const VersionSC ='8.7'; // sert à la comparaison de la version publiée +Const VersionSC ='8.8'; // sert à la comparaison de la version publiée SousVersion=' '; // A B C ... en cas d'absence de sous version mettre un espace // pour unzip SHCONTCH_NOPROGRESSBOX = 4; @@ -149,9 +149,7 @@ end; // dézipe copie les fichiers et lance la nouvelle version // s : chemin et fichier à déziper procedure dezipe_copie_lance(s : string); -var - i : integer; - +var i : integer; begin // Vérifier si répertoire dest existe chemin_Dest:=CheminProgrammes+'\Signaux_complexes'; @@ -204,7 +202,7 @@ begin end else begin - Affiche('Erreur '+intToSTR(i)+' au lancement de copie_sc.exe ',clred); + Affiche('Erreur '+intToSTR(i)+' au lancement de installeur.exe ',clred); end; end; diff --git a/versions.txt b/versions.txt index 0f3c8b1..db9d232 100644 --- a/versions.txt +++ b/versions.txt @@ -248,7 +248,9 @@ version 8.54 : Ajout du choix de pilotage des trains par CDM par adresse ou par version 8.6 : Gestion des démarrages des trains sur horaire, en fonction d'une horloge paramétrable. Amélioration de l'importation du réseau depuis CDM Rail. Création d'actionneurs "horloge" et "vitesse train". -version 8.7 : les actionneurs deviennent les actions, et un déclencheur peut déclencher plusieurs opérations - - +version 8.7 : Les actionneurs deviennent les actions, et un déclencheur peut déclencher plusieurs opérations +version 8.8 : Création des cantons dans les TCO qui reçoivent une icone de train. + Création des icônes de trains -> recopiez le repertoire [icones] dans celui de signaux_commplexes + Création de nouveaux déclencheurs, conditions et opérations. +