diff --git a/MSCommLib_TLB.dcu b/MSCommLib_TLB.dcu index dd6f44c..707fabd 100644 Binary files a/MSCommLib_TLB.dcu and b/MSCommLib_TLB.dcu differ diff --git a/Notice d'utilisation des signaux_complexes_GL_V8.8.pdf b/Notice d'utilisation des signaux_complexes_GL_V9.0.pdf similarity index 73% rename from Notice d'utilisation des signaux_complexes_GL_V8.8.pdf rename to Notice d'utilisation des signaux_complexes_GL_V9.0.pdf index 9d06c66..0e66b51 100644 Binary files a/Notice d'utilisation des signaux_complexes_GL_V8.8.pdf and b/Notice d'utilisation des signaux_complexes_GL_V9.0.pdf differ diff --git a/Signaux_complexes_GL.cfg b/Signaux_complexes_GL.cfg index 326b5d5..2d571d5 100644 --- a/Signaux_complexes_GL.cfg +++ b/Signaux_complexes_GL.cfg @@ -14,8 +14,8 @@ -$N+ -$O- -$P- --$Q- --$R- +-$Q+ +-$R+ -$S- -$T- -$U- diff --git a/Signaux_complexes_GL.dof b/Signaux_complexes_GL.dof index 96f1ba5..290450a 100644 --- a/Signaux_complexes_GL.dof +++ b/Signaux_complexes_GL.dof @@ -17,8 +17,8 @@ M=0 N=1 O=0 P=0 -Q=0 -R=0 +Q=1 +R=1 S=0 T=0 U=0 @@ -130,5 +130,3 @@ OriginalFilename= ProductName= ProductVersion=8.1.0.0 Comments= -[Excluded Packages] -c:\program files (x86)\borland\delphi7\Projects\Bpl\DsgnCPort8.bpl=ComPort Library diff --git a/Signaux_complexes_GL.dpr b/Signaux_complexes_GL.dpr index a480465..9eab824 100644 --- a/Signaux_complexes_GL.dpr +++ b/Signaux_complexes_GL.dpr @@ -14,7 +14,6 @@ uses Unit_Pilote_aig in 'Unit_Pilote_aig.pas' {FormAig}, UnitConfigCellTCO in 'UnitConfigCellTCO.pas' {FormConfCellTCO}, UnitCDF in 'UnitCDF.pas' {FormCDF}, - Unitplace in 'Unitplace.pas' {FormRoulage}, UnitPareFeu in 'UnitPareFeu.pas', UnitAnalyseSegCDM in 'UnitAnalyseSegCDM.pas' {FormAnalyseCDM}, Importation in 'Importation.pas' {FormImportation}, @@ -23,7 +22,10 @@ uses UnitFicheHoraire in 'UnitFicheHoraire.pas' {FormFicheHoraire}, UnitClock in 'UnitClock.pas' {FormClock}, UnitModifAction in 'UnitModifAction.pas' {FormModifAction}, - selection_train in 'selection_train.pas' {FormSelTrain}; + selection_train in 'selection_train.pas' {FormSelTrain}, + UnitRoute in 'UnitRoute.pas' {FormRoute}, + UnitRouteTrains in 'UnitRouteTrains.pas' {FormRouteTrain}, + UnitInfo in 'UnitInfo.pas' {FormInfo}; {$R *.res} @@ -41,7 +43,6 @@ begin Application.CreateForm(TFormAig, FormAig); Application.CreateForm(TFormConfCellTCO, FormConfCellTCO); Application.CreateForm(TFormCDF, FormCDF); - Application.CreateForm(TFormRoulage, FormRoulage); Application.CreateForm(TFormAnalyseCDM, FormAnalyseCDM); Application.CreateForm(TFormImportation, FormImportation); Application.CreateForm(TFormFicheHoraire, FormFicheHoraire); @@ -50,6 +51,9 @@ begin Application.CreateForm(TFormHorloge, FormHorloge); Application.CreateForm(TFormModifAction, FormModifAction); Application.CreateForm(TFormSelTrain, FormSelTrain); + Application.CreateForm(TFormRoute, FormRoute); + Application.CreateForm(TFormRouteTrain, FormRouteTrain); + Application.CreateForm(TFormInfo, FormInfo); fin_preliminaire; Application.Run; end. diff --git a/Signaux_complexes_GL.exe b/Signaux_complexes_GL.exe deleted file mode 100644 index f68ed16..0000000 Binary files a/Signaux_complexes_GL.exe and /dev/null differ diff --git a/Signaux_complexes_GL.map b/Signaux_complexes_GL.map index 883f76c..010dfe7 100644 --- a/Signaux_complexes_GL.map +++ b/Signaux_complexes_GL.map @@ -1,8 +1,8 @@ Start Length Name Class - 0001:00000000 001D1334H .text CODE - 0002:00000000 00002D60H .data DATA - 0002:00002D60 04660941H .bss BSS + 0001:00000000 001E689CH .text CODE + 0002:00000000 00002E04H .data DATA + 0002:00002E04 06950F41H .bss BSS Detailed map of segments @@ -15,97 +15,101 @@ Detailed map of segments 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 + 0001:0000EBCC 0000806E C=CODE S=.text G=(none) M=Variants ACBP=A9 + 0001:00016C3C 000001A0 C=CODE S=.text G=(none) M=RTLConsts ACBP=A9 + 0001:00016DDC 0000083C C=CODE S=.text G=(none) M=TypInfo ACBP=A9 + 0001:00017618 00000368 C=CODE S=.text G=(none) M=ActiveX ACBP=A9 + 0001:00017980 0000A7FE C=CODE S=.text G=(none) M=Classes ACBP=A9 + 0001:00022180 00000378 C=CODE S=.text G=(none) M=Consts ACBP=A9 + 0001:000224F8 00009DC7 C=CODE S=.text G=(none) M=Graphics ACBP=A9 + 0001:0002C2C0 00000124 C=CODE S=.text G=(none) M=Math ACBP=A9 + 0001:0002C3E4 000002B8 C=CODE S=.text G=(none) M=Contnrs ACBP=A9 + 0001:0002C69C 00000198 C=CODE S=.text G=(none) M=CommCtrl ACBP=A9 + 0001:0002C834 00000787 C=CODE S=.text G=(none) M=MultiMon ACBP=A9 + 0001:0002CFBC 00000038 C=CODE S=.text G=(none) M=Imm ACBP=A9 + 0001:0002CFF4 00000FF8 C=CODE S=.text G=(none) M=HelpIntfs ACBP=A9 + 0001:0002DFEC 00000058 C=CODE S=.text G=(none) M=WinSpool ACBP=A9 + 0001:0002E044 000010C8 C=CODE S=.text G=(none) M=Printers ACBP=A9 + 0001:0002F10C 0000031F C=CODE S=.text G=(none) M=FlatSB ACBP=A9 + 0001:0002F42C 000003F0 C=CODE S=.text G=(none) M=SyncObjs ACBP=A9 + 0001:0002F81C 000009BB C=CODE S=.text G=(none) M=UxTheme ACBP=A9 + 0001:000301D8 00000038 C=CODE S=.text G=(none) M=RichEdit ACBP=A9 + 0001:00030210 00000038 C=CODE S=.text G=(none) M=ToolWin ACBP=A9 + 0001:00030248 00000040 C=CODE S=.text G=(none) M=ShellAPI ACBP=A9 + 0001:00030288 00000038 C=CODE S=.text G=(none) M=RegStr ACBP=A9 + 0001:000302C0 00000058 C=CODE S=.text G=(none) M=WinInet ACBP=A9 + 0001:00030318 00000038 C=CODE S=.text G=(none) M=UrlMon ACBP=A9 + 0001:00030350 000000EC C=CODE S=.text G=(none) M=ShlObj ACBP=A9 + 0001:0003043C 00000060 C=CODE S=.text G=(none) M=CommDlg ACBP=A9 + 0001:0003049C 00000038 C=CODE S=.text G=(none) M=Dlgs ACBP=A9 + 0001:000304D4 000036D1 C=CODE S=.text G=(none) M=Dialogs ACBP=A9 + 0001:00033BA8 0000602A C=CODE S=.text G=(none) M=ExtCtrls ACBP=A9 + 0001:00039BD4 00000090 C=CODE S=.text G=(none) M=ComStrs ACBP=A9 + 0001:00039C64 000007A0 C=CODE S=.text G=(none) M=Clipbrd ACBP=A9 + 0001:0003A404 00000128 C=CODE S=.text G=(none) M=StrUtils ACBP=A9 + 0001:0003A52C 00003821 C=CODE S=.text G=(none) M=Buttons ACBP=A9 + 0001:0003DD50 00000038 C=CODE S=.text G=(none) M=ExtDlgs ACBP=A9 + 0001:0003DD88 00000068 C=CODE S=.text G=(none) M=IniFiles ACBP=A9 + 0001:0003DDF0 00000068 C=CODE S=.text G=(none) M=Registry ACBP=A9 + 0001:0003DE58 0000006C C=CODE S=.text G=(none) M=Mapi ACBP=A9 + 0001:0003DEC4 00000058 C=CODE S=.text G=(none) M=ExtActns ACBP=A9 + 0001:0003DF1C 00000038 C=CODE S=.text G=(none) M=ListActns ACBP=A9 + 0001:0003DF54 00009948 C=CODE S=.text G=(none) M=ComCtrls ACBP=A9 + 0001:0004789C 00000EA0 C=CODE S=.text G=(none) M=Themes ACBP=A9 + 0001:0004873C 0000C698 C=CODE S=.text G=(none) M=StdCtrls ACBP=A9 + 0001:00054DD4 00000168 C=CODE S=.text G=(none) M=StdActns ACBP=A9 + 0001:00054F3C 00000D1F C=CODE S=.text G=(none) M=WinHelpViewer ACBP=A9 + 0001:00055C5C 00011403 C=CODE S=.text G=(none) M=Controls ACBP=A9 + 0001:00067060 00001292 C=CODE S=.text G=(none) M=ActnList ACBP=A9 + 0001:000682F4 00001C04 C=CODE S=.text G=(none) M=ImgList ACBP=A9 + 0001:00069EF8 000066E1 C=CODE S=.text G=(none) M=Menus ACBP=A9 + 0001:000705DC 0000CF8C C=CODE S=.text G=(none) M=Forms ACBP=A9 + 0001:0007D568 00000050 C=CODE S=.text G=(none) M=JConsts ACBP=A9 + 0001:0007D5B8 000133EC C=CODE S=.text G=(none) M=jpeg ACBP=A9 + 0001:000909A4 00000060 C=CODE S=.text G=(none) M=ComConst ACBP=A9 + 0001:00090A04 00001259 C=CODE S=.text G=(none) M=ComObj ACBP=A9 + 0001:00091C60 00000038 C=CODE S=.text G=(none) M=StdVCL ACBP=A9 + 0001:00091C98 00001793 C=CODE S=.text G=(none) M=AxCtrls ACBP=A9 + 0001:0009342C 00000060 C=CODE S=.text G=(none) M=OleConst ACBP=A9 + 0001:0009348C 00003519 C=CODE S=.text G=(none) M=OleCtrls ACBP=A9 + 0001:000969A8 00000314 C=CODE S=.text G=(none) M=TlHelp32 ACBP=A9 + 0001:00096CBC 00000128 C=CODE S=.text G=(none) M=WinSock ACBP=A9 + 0001:00096DE4 00003A78 C=CODE S=.text G=(none) M=ScktComp ACBP=A9 + 0001:0009A85C 000008EA C=CODE S=.text G=(none) M=OleServer ACBP=A9 + 0001:0009B148 000005A0 C=CODE S=.text G=(none) M=MSCommLib_TLB ACBP=A9 + 0001:0009B6E8 00000040 C=CODE S=.text G=(none) M=MMSystem ACBP=A9 + 0001:0009B728 00000038 C=CODE S=.text G=(none) M=Nb30 ACBP=A9 + 0001:0009B760 00000038 C=CODE S=.text G=(none) M=DateUtils ACBP=A9 + 0001:0009B798 00000A18 C=CODE S=.text G=(none) M=MaskUtils ACBP=A9 + 0001:0009C1B0 00002108 C=CODE S=.text G=(none) M=Mask ACBP=A9 + 0001:0009E2B8 000092A4 C=CODE S=.text G=(none) M=Grids ACBP=A9 + 0001:000A755C 00001BFC C=CODE S=.text G=(none) M=Spin ACBP=A9 + 0001:000A9158 00003762 C=CODE S=.text G=(none) M=UnitPilote ACBP=A9 + 0001:000AC8BC 0000057C C=CODE S=.text G=(none) M=Importation ACBP=A9 + 0001:000ACE38 000196A8 C=CODE S=.text G=(none) M=UnitAnalyseSegCDM ACBP=A9 + 0001:000C64E0 00002E3F C=CODE S=.text G=(none) M=UnitConfigTCO ACBP=A9 + 0001:000C9320 00000D84 C=CODE S=.text G=(none) M=Unit_Pilote_aig ACBP=A9 + 0001:000CA0A4 000011F4 C=CODE S=.text G=(none) M=UnitFicheHoraire ACBP=A9 + 0001:000CB298 00000038 C=CODE S=.text G=(none) M=ShellConsts ACBP=A9 + 0001:000CB2D0 000004E0 C=CODE S=.text G=(none) M=ShellCtrls ACBP=A9 + 0001:000CB7B0 00001A0C C=CODE S=.text G=(none) M=UnitRoute ACBP=A9 + 0001:000CD1BC 00002134 C=CODE S=.text G=(none) M=UnitRouteTrains ACBP=A9 + 0001:000CF2F0 00000298 C=CODE S=.text G=(none) M=UnitInfo ACBP=A9 + 0001:000CF588 00002D68 C=CODE S=.text G=(none) M=selection_train ACBP=A9 + 0001:000D22F0 00006230 C=CODE S=.text G=(none) M=UnitConfigCellTCO ACBP=A9 + 0001:000D8520 00001908 C=CODE S=.text G=(none) M=UnitClock ACBP=A9 + 0001:000D9E28 00051884 C=CODE S=.text G=(none) M=UnitTCO ACBP=A9 + 0001:0012B6AC 000039DC C=CODE S=.text G=(none) M=UnitSR ACBP=A9 + 0001:0012F088 00002BF8 C=CODE S=.text G=(none) M=UnitCDF ACBP=A9 + 0001:00131C80 000088F8 C=CODE S=.text G=(none) M=UnitModifAction ACBP=A9 + 0001:0013A578 00000F64 C=CODE S=.text G=(none) M=UnitHorloge ACBP=A9 + 0001:0013B4DC 000025FB C=CODE S=.text G=(none) M=verif_version ACBP=A9 + 0001:0013DAD8 00001190 C=CODE S=.text G=(none) M=UnitPareFeu ACBP=A9 + 0001:0013EC68 00000F6C C=CODE S=.text G=(none) M=UnitSimule ACBP=A9 + 0001:0013FBD4 00057434 C=CODE S=.text G=(none) M=Unitprinc ACBP=A9 + 0001:00197008 0004C358 C=CODE S=.text G=(none) M=UnitConfig ACBP=A9 + 0001:001E3360 00002F78 C=CODE S=.text G=(none) M=UnitDebug ACBP=A9 + 0001:001E62D8 000005C4 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 @@ -136,8 +140,9 @@ 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 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:00001C4C 00000068 C=DATA S=.data G=DGROUP M=ShellCtrls ACBP=A9 + 0002:00001CB4 000000D8 C=DATA S=.data G=DGROUP M=UnitTCO ACBP=A9 + 0002:00001D8C 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 @@ -215,27 +220,31 @@ Detailed map of segments 0002:00003E60 00000004 C=BSS S=.bss G=DGROUP M=Mask ACBP=A9 0002:00003E64 00000004 C=BSS S=.bss G=DGROUP M=Grids ACBP=A9 0002:00003E68 00000004 C=BSS S=.bss G=DGROUP M=Spin ACBP=A9 - 0002:00003E6C 00000010 C=BSS S=.bss G=DGROUP M=UnitPilote ACBP=A9 - 0002:00003E7C 00000010 C=BSS S=.bss G=DGROUP M=Importation ACBP=A9 - 0002:00003E8C 000148B0 C=BSS S=.bss G=DGROUP M=UnitAnalyseSegCDM ACBP=A9 - 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 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 + 0002:00003E6C 00002494 C=BSS S=.bss G=DGROUP M=UnitPilote ACBP=A9 + 0002:00006300 00000010 C=BSS S=.bss G=DGROUP M=Importation ACBP=A9 + 0002:00006310 000148B0 C=BSS S=.bss G=DGROUP M=UnitAnalyseSegCDM ACBP=A9 + 0002:0001ABC0 00000014 C=BSS S=.bss G=DGROUP M=UnitConfigTCO ACBP=A9 + 0002:0001ABD4 00000014 C=BSS S=.bss G=DGROUP M=Unit_Pilote_aig ACBP=A9 + 0002:0001ABE8 0000190C C=BSS S=.bss G=DGROUP M=UnitFicheHoraire ACBP=A9 + 0002:0001C4F4 00000004 C=BSS S=.bss G=DGROUP M=ShellConsts ACBP=A9 + 0002:0001C4F8 0000001C C=BSS S=.bss G=DGROUP M=ShellCtrls ACBP=A9 + 0002:0001C514 00000CA4 C=BSS S=.bss G=DGROUP M=UnitRoute ACBP=A9 + 0002:0001D1B8 00000008 C=BSS S=.bss G=DGROUP M=UnitRouteTrains ACBP=A9 + 0002:0001D1C0 0000000C C=BSS S=.bss G=DGROUP M=UnitInfo ACBP=A9 + 0002:0001D1CC 00000CB0 C=BSS S=.bss G=DGROUP M=selection_train ACBP=A9 + 0002:0001DE7C 00000020 C=BSS S=.bss G=DGROUP M=UnitConfigCellTCO ACBP=A9 + 0002:0001DE9C 00000034 C=BSS S=.bss G=DGROUP M=UnitClock ACBP=A9 + 0002:0001DED0 0048FB5C C=BSS S=.bss G=DGROUP M=UnitTCO ACBP=A9 + 0002:004ADA2C 00000010 C=BSS S=.bss G=DGROUP M=UnitSR ACBP=A9 + 0002:004ADA3C 00000014 C=BSS S=.bss G=DGROUP M=UnitCDF ACBP=A9 + 0002:004ADA50 0000001C C=BSS S=.bss G=DGROUP M=UnitModifAction ACBP=A9 + 0002:004ADA6C 00000038 C=BSS S=.bss G=DGROUP M=UnitHorloge ACBP=A9 + 0002:004ADAA4 000001EC C=BSS S=.bss G=DGROUP M=verif_version ACBP=A9 + 0002:004ADC90 00000004 C=BSS S=.bss G=DGROUP M=UnitPareFeu ACBP=A9 + 0002:004ADC94 0000000C C=BSS S=.bss G=DGROUP M=UnitSimule ACBP=A9 + 0002:004ADCA0 064A5CAC C=BSS S=.bss G=DGROUP M=Unitprinc ACBP=A9 + 0002:0695394C 000005C8 C=BSS S=.bss G=DGROUP M=UnitConfig ACBP=A9 + 0002:06953F14 0000002C C=BSS S=.bss G=DGROUP M=UnitDebug ACBP=A9 Bound resource files @@ -248,11 +257,13 @@ Importation.dfm UnitAnalyseSegCDM.dfm UnitConfigTCO.dfm Unit_Pilote_aig.dfm -UnitConfigCellTCO.dfm UnitFicheHoraire.dfm -UnitClock.dfm -Unitplace.dfm +UnitRoute.dfm +UnitRouteTrains.dfm +UnitInfo.dfm selection_train.dfm +UnitConfigCellTCO.dfm +UnitClock.dfm UnitTCO.dfm UnitSR.dfm UnitCDF.dfm @@ -260,11 +271,11 @@ UnitModifAction.dfm UnitHorloge.dfm verif_version.dfm UnitSimule.dfm -UnitPrinc.dfm +Unitprinc.dfm UnitConfig.dfm UnitDebug.dfm Signaux_complexes_GL.res Signaux_complexes_GL.drf -Program entry point at 0001:001D1108 +Program entry point at 0001:001E6640 diff --git a/UnitAnalyseSegCDM.pas b/UnitAnalyseSegCDM.pas index a86b088..d23de1c 100644 --- a/UnitAnalyseSegCDM.pas +++ b/UnitAnalyseSegCDM.pas @@ -78,7 +78,7 @@ type { Déclarations publiques } end; - // tableau des détecteurs sur un segment + // tableau des détecteurs ou actionneurs sur un segment TdetSeg= array[1..10] of record index,periph : integer; end; @@ -180,6 +180,8 @@ procedure Aff_train(adr: integer;train:string;x1,y1,x2,y2 :integer); procedure D_Arc(Canvas: TCanvas; CenterX,CenterY: integer; rayon: Integer; StartDegres, StopDegres: Double); function point_Sur_Segment(x,y,x1,y1,x2,y2 : integer): Boolean; +function explore_port_det(seg,port : integer) : integer; +function index_segment_act(Adresse : integer;var TabloDetSeg : TdetSeg;var nombre : integer) : boolean; implementation @@ -2117,8 +2119,7 @@ begin exit; end; - - // le port a il t-il des périphériques portant des détecteurs + // le port demandé a t-il déja des périphériques portant des détecteurs NombrePeriph:=segment[idSeg].nperiph; if NombrePeriph<>0 then begin @@ -2128,9 +2129,12 @@ begin begin if segment[idSeg].periph[i].OnDevicePort=Idport then // le port du périphérique correspond au port exploré begin - result:=segment[idSeg].periph[i].adresse; - c:='Z'; - exit; + if segment[idSeg].periph[i].adresse<>0 then + begin + result:=segment[idSeg].periph[i].adresse; + c:='Z'; + exit; + end; end; end; inc(i); @@ -2153,7 +2157,7 @@ begin // remonter au segment pour voir si c'est un aiguillage typeP:=segment[idSeg].typ; - if typeP='dbl_slip_switch' then + if typeP='dbl_slip_switch' then // tjd begin portlocal:=segment[idSeg].port[idport].local; case portlocal of @@ -2283,6 +2287,190 @@ begin end; +// fonction récursive +// explore le port,segment jusqu'à trouver une adresse de détecteur +// un détecteur peut être sur un port de l'aiguillage +// renvoie l'adresse de l'aiguillage ou du détecteur et dans C le port (P D S ou Z pour un détecteur) +function explore_port_det(seg,port : integer) : integer; +var i,j,IdSeg,IdPort,NombrePeriph,port1,port2,portSuivant,segSuivant,portLocal, + xp,yp,xd,yd,detect,nb_det : integer; + typeP,serr : string; + sdetect : Tdetect_cdm; + trouveDet : boolean; +begin + if seg=0 then + begin + explore_port_det:=0; + exit; // laisser sinon mauvais transfert de variable dans la pile dans l'itération suivante!! + end; + if not(trouve_IndexSegPort(seg,port,idSeg,IdPort)) then + begin + serr:='Erreur 1 pas trouvé le port '+intToSTR(port)+' dans la liste des segments'; + Affiche(serr,clred); + AfficheDebug(serr,clred); + explore_port_det:=0; + exit; + end; + + // le port a t-il des périphériques portant des détecteurs + NombrePeriph:=segment[idSeg].nperiph; + if NombrePeriph<>0 then + begin + i:=0; + repeat + if segment[idSeg].periph[i].typ='detector' then + begin + if segment[idSeg].periph[i].OnDevicePort=Idport then // le port du périphérique correspond au port exploré + begin + if segment[idSeg].periph[i].adresse<>0 then + begin + result:=segment[idSeg].periph[i].adresse; + exit; + end; + end; + end; + inc(i); + until (i>NombrePeriph-1) or (trouveDet); + end; + + // trouver le segment contigu connecté au port de connexion + segSuivant:=segment[idseg].port[idport].ConnecteAuSeg; + portSuivant:=segment[idseg].port[idport].ConnecteAuPort; + if not(trouve_IndexSegPort(segSuivant,portSuivant,idSeg,IdPort)) then + begin + serr:='Erreur 2 pas trouvé le port '+intToSTR(port)+' dans la liste des segments'; + Affiche(serr,clred); + AfficheDebug(serr,clred); + explore_port_det:=0; + exit; + end; + + // remonter au segment pour voir si c'est un aiguillage + typeP:=segment[idSeg].typ; + + if typeP='dbl_slip_switch' then + begin + portlocal:=segment[idSeg].port[idport].local; + + // tjd 2 ou 4 états + if (portlocal=0) or (portlocal=1) then + begin + explore_port_det(SegSuivant,segment[idseg].port[2].numero); + explore_port_det(SegSuivant,segment[idseg].port[3].numero); + end; + if (portlocal=2) or (portlocal=3) then + begin + explore_port_det(SegSuivant,segment[idseg].port[0].numero); + explore_port_det(SegSuivant,segment[idseg].port[1].numero); + end; + exit; + end; + + if segment_aig(typeP) then // est-ce un aig + //------------- aiguillage + begin + portlocal:=segment[idSeg].port[idport].local; + case portlocal of + // port 0 : pris en pointe, explorer les deux autres ports + 0 : begin + explore_port_det(SegSuivant,segment[idseg].port[1].numero); // explore droit + explore_port_det(SegSuivant,segment[idseg].port[2].numero); // explore dévié + end; + 1,2 : explore_port_det(SegSuivant,segment[idseg].port[0].numero); + end; + exit; + end; + + // --- croisement + if typeP='crossing' then + begin + portlocal:=segment[idSeg].port[idport].local; + case portLocal of + 0 : explore_port_det(SegSuivant,segment[idseg].port[2].numero); + 1 : explore_port_det(SegSuivant,segment[idseg].port[3].numero); + 2 : explore_port_det(SegSuivant,segment[idseg].port[0].numero); + 3 : explore_port_det(SegSuivant,segment[idseg].port[1].numero); + end; + exit; + end; + + // trouver le détecteur le plus proche. + NombrePeriph:=segment[idSeg].nperiph; + j:=0;detect:=0;nb_det:=0; + if NombrePeriph<>0 then + begin + raz_detect(sDetect); // on peut rencontrer des détecteurs non appairés: ex ; 514 522 514 522 + repeat + if segment[idSeg].periph[j].typ='detector' then + begin + detect:=segment[idSeg].periph[j].adresse; + if detect<>0 then + begin + //if NivDebug=3 then Affichedebug('Détecteur '+inttoStr(detect),clyellow); + // incrémenter le compteur du détecteur rencontré + inc(nb_det); + Affiche('trouvé détecteur '+intToSTR(detect),clYellow); + sDetect[nb_det].adresse:=detect ; + // coordonnées du port + xp:=segment[idSeg].Port[idPort].x; + yp:=segment[idSeg].Port[idPort].y; + // coordonnées du détecteur + xd:=segment[idSeg].periph[j].x; + yd:=segment[idSeg].periph[j].y; + // calculer la distance du détecteur au port + sDetect[nb_det].distance:=round( sqrt( sqr(xp-xd)+sqr(yp-yd) )); + end; + end; + inc(j); + until (j>NombrePeriph-1) ; + // trier les détecteurs du segment dans l'ordre de la distance de la plus + // courte à la plus grande au port + if nb_det<>0 then + begin + trier(Sdetect,nb_det); + + // on prend le premier!! + explore_port_det:=sDetect[1].adresse; + exit; + end; + end; + + // trouver l'autre port du segment idseg + // sur 2 ports + NombrePeriph:=segment[idSeg].nport; + if NombrePeriph=0 then + begin + explore_port_det:=0; + exit; + end; + port1:=segment[idSeg].port[0].numero; + port2:=segment[idSeg].port[1].numero; + i:=0; + if (port1<>portSuivant) and (segment[idSeg].port[0].connecte) then i:=explore_port_det(SegSuivant,port1); + if (port2<>portSuivant) and (segment[idSeg].port[1].connecte) then i:=explore_port_det(SegSuivant,port2); + + explore_port_det:=i; + exit; + + typeP:=segment[idSeg].typ; + // explorer l'autre port + if (typeP='straight') or (typeP='arc') or (typeP='curve') or (typeP='pre_curve') then + begin + port1:=segment[idSeg].port[0].numero; + port2:=segment[idSeg].port[1].numero; + if port1<>portSuivant then i:=explore_port_det(SegSuivant,port1); + if port2<>portSuivant then i:=explore_port_det(SegSuivant,port2); + explore_port_det:=i; + exit; + end; + + Affiche('Segment '+typeP+' non trouvé',clred); + + explore_Port_det:=0; +end; + + + // stocke les aiguillages et les croisement dans le tableau Aig_CDM procedure remplit_Aig_cdm; var i,j,NumSegment,IndexSegment,IndexPort,index,index2,g, @@ -2974,17 +3162,6 @@ begin if debugBranche then Affichedebug('Détecteur '+intToSTR(j)+'/'+intToSTR(nb_det)+': non pris en compte : '+intToSTR(detecteur),clOrange); end; - { ss:=dernier_champ(sbranche); - k:=0; - val(ss,k,erreur); - if ss<>'' then if not(ss[1] in['0'..'9']) then k:=0; - // vérifier si le détecteur est déja en fin de branche et que si on est au 2eme élément du tableau, on ne doit pas rencontrer le meme détecteur - if (k<>detecteur) then - begin - sbranche:=sbranche+','+intToSTR(detecteur); - if debugBranche then Affichedebug('Détecteur '+intToSTR(j)+'/'+intToSTR(nb_det)+': pris en compte : '+intToSTR(detecteur),clyellow); - end; } - inc(indexElBranche); end; end; @@ -3243,7 +3420,7 @@ begin until trouve or (i>MaxAiguillage); // puis créer les branches depuis les positions déviées --------------------- - if debugBranche then AfficheDebug('Etape 3.2 création des branches de dévié d''aiguillage',clwhite); + if debugBranche then AfficheDebug('Etape 3.2 création des branches depuis dévié d''aiguillage',clwhite); i:=1; repeat c:=aiguillage[i].AdevieB; @@ -3271,6 +3448,7 @@ begin trouve:=false; until trouve or (i>MaxAiguillage); + if debugBranche then AfficheDebug('Etape 3.3 Liste de détecteurs absents des branches pour constituer les branches manquantes',clwhite); // regarder la liste des détecteurs de CDM qui sont absents des branches-------------------- for i:=1 to Ndet_cdm do @@ -3302,6 +3480,7 @@ begin end; end; + // recopier le tampon des branches dans le richedit de l'onglet branches de la config with formconfig do begin @@ -4612,9 +4791,60 @@ begin SelectionAffichee:=false;} end; -// trouve les index du segment qui contiennent le détecteur Adresse + +// trouve les index du segment qui contiennent l'actionneur Adresse // renvoie dans index les index, et dans periph les numéros de périphériques dans lesquels ils se trouvent -function index_segment_det(Adresse : integer;var TabloDetSeg : TdetSeg; nombre : integer) : boolean; +function index_segment_act(Adresse : integer;var TabloDetSeg : TdetSeg;var nombre : integer) : boolean; +var i,n,ip,itablo : integer; +begin + //trouver les deux segments de l'actionneur + if adresse=0 then + begin + nombre:=0; + result:=false; + exit; + end; + for i:=1 to 10 do + begin + TabloDetSeg[i].index:=-1; + TabloDetSeg[i].periph:=-1; + end; + + i:=0; + itablo:=0; + repeat + n:=segment[i].nperiph; + if n<>0 then + begin + for ip:=0 to n-1 do + begin + if segment[i].periph[ip].typ='actuator' then + begin + if segment[i].periph[ip].adresse=adresse then + begin + inc(itablo); + if itablo>10 then + begin + AfficheDebug('Erreur 857 : Nbre périphériques>10 Segment '+intToSTR(segment[i].numero),clred); + exit; + end; + TabloDetSeg[itablo].index:=i; + TabloDetSeg[itablo].periph:=ip; + end; + end; + end; + end; + inc(i); + until (i>nseg-1); + nombre:=itablo; + result:=itablo>0; +end; + + +// trouve les index du segment qui contiennent le détecteur Adresse +// renvoie l'index du segment dans TabloDetSeg[].index et l'index du périphérique dans TabloDetSeg[].periph +// leur nombre dans Nombre +function index_segment_det(Adresse : integer;var TabloDetSeg : TdetSeg;var nombre : integer) : boolean; var i,n,ip,itablo : integer; begin //trouver les deux segments du détecteurs diff --git a/UnitCDF.dfm b/UnitCDF.dfm index 40c70a8..ced4cf8 100644 --- a/UnitCDF.dfm +++ b/UnitCDF.dfm @@ -221,7 +221,7 @@ object FormCDF: TFormCDF object Label24: TLabel Left = 48 Top = 124 - Width = 121 + Width = 24 Height = 13 Caption = '1 '#224' 4' end diff --git a/UnitCDF.pas b/UnitCDF.pas index e0668eb..ead8b15 100644 --- a/UnitCDF.pas +++ b/UnitCDF.pas @@ -186,8 +186,6 @@ begin Edit19.Text:=intToSTR(Signaux[index].SR[19].sortie1); editNadresses.text:=intToSTR(Signaux[index].NA); - - end; procedure dessine_signal_CDF; @@ -263,7 +261,7 @@ begin begin val(Edit3.Text,i,erreur); if (i<0) or (i>255) or (erreur<>0) then exit; - Signaux[index].SR[2].sortie1:=i; + Signaux[index].SR[3].sortie1:=i; Maj_DB; if label3.Caption=etats[3] then Maj_Etat_Signal(0,semaphore_cli); dessine_signal_CDF; diff --git a/UnitClock.pas b/UnitClock.pas index fe7fd32..0733636 100644 --- a/UnitClock.pas +++ b/UnitClock.pas @@ -7,7 +7,7 @@ unit UnitClock; DrawArrow dessine les aiguilles dans ABitmap: - le crée, dessine - Abitmap.canvas.copyrect( + Abitmap.canvas.copyrect() - copie dans horloge : canvas.draw(0,0,ABitMap) } @@ -155,7 +155,7 @@ end; function TClock.HourAngle( Hou, Min : word) : real; begin - HourAngle:=(Hou MOD 12) * pisur6 + (Min*pisur360); + HourAngle:=(Hou mod 12) * pisur6 + (Min*pisur360); end; procedure Tclock.TickerCall; @@ -241,7 +241,7 @@ begin dec(Radius,LapStepW+2); end; -// Dessine le fond (le tour) de l'horloge sur FbitMap +// Dessine le fond Fbitmap (le tour) de l'horloge sur FbitMap procedure TClock.DrawClockBkg; // Dessine les tirets minute sur FBitMap @@ -360,6 +360,7 @@ end; procedure TFormClock.FormCreate(Sender: TObject); +var off : integer; begin // inits // Affiche('FormClock create',clYellow); @@ -377,17 +378,48 @@ begin clock.ClkFaceColor:=$e0e0e0; clock.ClkArrowColor:=clBlack; + off:=36; + {$IF CompilerVersion >= 28.0} + off:=40; + {$IFEND} + ImageList24x24.GetBitmap(0,BitBtnMarHor.Glyph); - BitBtnMarHor.Height:=26; - BitBtnMarHor.Width:=26; + with BitBtnMarHor do + begin + Height:=26; + Width:=26; + Top:=formClock.Height-BitBtnMarHor.Height-off; + end; ImageList24x24.GetBitmap(1,BitBtnArrHorl.Glyph); - BitBtnMarHor.Height:=26; - BitBtnMarHor.Width:=26; + with BitBtnArrHorl do + begin + Height:=26; + Width:=26; + Top:=formClock.Height-BitBtnMarHor.Height-off; + end; ImageList24x24.GetBitmap(2,BitBtnInitHor.Glyph); - BitBtnMarHor.Height:=26; - BitBtnMarHor.Width:=26; + with BitBtnInitHor do + begin + Height:=26; + Width:=26; + Top:=formClock.Height-BitBtnMarHor.Height-off; + end; + + with ButtonParametres do + begin + Height:=26; + Width:=26; + Top:=formClock.Height-BitBtnMarHor.Height-off; + end; + + with ButtonGH do + begin + Height:=26; + Width:=26; + Top:=formClock.Height-BitBtnMarHor.Height-off; + end; color:=clock.ClkFaceColor; SecThick:=2; MinThick:=10; diff --git a/UnitConfig.dfm b/UnitConfig.dfm index 27c4ac3..2a588f3 100644 --- a/UnitConfig.dfm +++ b/UnitConfig.dfm @@ -1,6 +1,6 @@ object FormConfig: TFormConfig - Left = 323 - Top = 128 + Left = 281 + Top = 137 Hint = 'Modifie la configuration selon les s'#233'lections choisies' BorderStyle = bsDialog Caption = 'Configuration g'#233'n'#233'rale' @@ -682,7 +682,7 @@ object FormConfig: TFormConfig Top = 8 Width = 633 Height = 505 - ActivePage = TabSheet1 + ActivePage = TabSheetTrains Font.Charset = DEFAULT_CHARSET Font.Color = clBlack Font.Height = -11 @@ -1405,31 +1405,6 @@ object FormConfig: TFormConfig ShowHint = True TabOrder = 4 end - object CheckRoulage: TCheckBox - Left = 16 - Top = 120 - Width = 169 - Height = 17 - Hint = 'Permet le roulage des trains en mode autonome' - Caption = 'Option roulage des trains' - ParentShowHint = False - ShowHint = True - TabOrder = 5 - end - object CheckBoxResa: TCheckBox - Left = 16 - Top = 136 - Width = 265 - Height = 17 - Hint = - 'Permet de r'#233'server les aiguillages, les TJD/S et les croisements' + - ' sur le parcours d'#39'un train' - Caption = 'Mode r'#233'servation des aiguillages par les trains' - ParentShowHint = False - ShowHint = True - TabOrder = 6 - OnClick = CheckBoxResaClick - end end object GroupBox22: TGroupBox Left = 312 @@ -2144,9 +2119,9 @@ object FormConfig: TFormConfig end object Memo5: TMemo Left = 464 - Top = 240 + Top = 296 Width = 153 - Height = 201 + Height = 145 Lines.Strings = ( 'Une ligne doit commencer par ' 'un aiguillage (ou un buttoir) et ' @@ -2157,12 +2132,7 @@ object FormConfig: TFormConfig '' 'Un aiguillage peut se retrouver ' #224' plusieurs endroits de cette ' - 'section, mais pas un d'#233'tecteur. ' - '' - 'Tous les aiguillages d'#233'clar'#233's ' - 'doivent appara'#238'tre au moins ' - 'une fois dans les branches.' - '') + 'section, mais pas un d'#233'tecteur. ') ReadOnly = True TabOrder = 2 end @@ -2315,7 +2285,7 @@ object FormConfig: TFormConfig end object LabelUni: TLabel Left = 8 - Top = 184 + Top = 176 Width = 72 Height = 13 Caption = 'Spec Unisemaf' @@ -2447,9 +2417,9 @@ object FormConfig: TFormConfig OnChange = EditSuiv4Change end object CheckVerrouCarre: TCheckBox - Left = 120 + Left = 136 Top = 216 - Width = 145 + Width = 137 Height = 17 Hint = 'Passe le signal au carr'#233' ci aucun train n'#39'est pr'#233'sent 3 cantons ' + @@ -2483,7 +2453,7 @@ object FormConfig: TFormConfig end object EditSpecUni: TEdit Left = 8 - Top = 200 + Top = 192 Width = 33 Height = 21 TabOrder = 14 @@ -2491,8 +2461,8 @@ object FormConfig: TFormConfig OnChange = EditSpecUniChange end object Buttonrestaure: TButton - Left = 8 - Top = 224 + Left = 24 + Top = 272 Width = 75 Height = 25 Hint = 'Restaure la configuration du feu d'#39'avant sa modification' @@ -2503,17 +2473,17 @@ object FormConfig: TFormConfig OnClick = ButtonrestaureClick end object CheckBoxFB: TCheckBox - Left = 120 + Left = 136 Top = 264 - Width = 153 + Width = 145 Height = 17 Caption = 'Avec demande feu blanc' TabOrder = 15 OnClick = CheckBoxFBClick end object ButtonConfigSR: TButton - Left = 8 - Top = 256 + Left = 24 + Top = 296 Width = 75 Height = 25 Caption = 'Configuration' @@ -2522,9 +2492,9 @@ object FormConfig: TFormConfig OnClick = ButtonConfigSRClick end object CheckFVC: TCheckBox - Left = 120 + Left = 136 Top = 232 - Width = 145 + Width = 121 Height = 17 Hint = 'Remplace le feu vert par un feu vert clignotant' Caption = 'Feu vert clignotant' @@ -2534,9 +2504,9 @@ object FormConfig: TFormConfig OnClick = CheckFVCClick end object CheckFRC: TCheckBox - Left = 120 + Left = 136 Top = 248 - Width = 145 + Width = 129 Height = 17 Hint = 'Remplace le s'#233'maphore par un feu rouge clignotant' Caption = 'Feu rouge clignotant' @@ -2546,7 +2516,7 @@ object FormConfig: TFormConfig OnClick = CheckFRCClick end object CheckBoxVersContrevoie: TCheckBox - Left = 120 + Left = 136 Top = 280 Width = 137 Height = 17 @@ -2558,9 +2528,9 @@ object FormConfig: TFormConfig OnClick = CheckBoxVersContrevoieClick end object CheckBoxContreVoie: TCheckBox - Left = 120 + Left = 136 Top = 296 - Width = 137 + Width = 129 Height = 17 Hint = 'Signal clignotant' Caption = 'Signal de contrevoie' @@ -2584,6 +2554,21 @@ object FormConfig: TFormConfig TabOrder = 21 OnChange = MemoBlancChange end + object RadioGroupLEB: TRadioGroup + Left = 8 + Top = 224 + Width = 105 + Height = 41 + Caption = 'Pilotage' + Items.Strings = ( + 'Mode binaire' + 'Mode lin'#233'aire') + ParentShowHint = False + ShowHint = True + TabOrder = 22 + Visible = False + OnClick = RadioGroupLEBClick + end end object ButtonNouvFeu: TButton Left = 0 @@ -2841,7 +2826,7 @@ object FormConfig: TFormConfig end end end - object TabSheet1: TTabSheet + object TabSheetActions: TTabSheet Caption = 'Actions' ImageIndex = 6 object Label44: TLabel @@ -2863,7 +2848,7 @@ object FormConfig: TFormConfig Left = 0 Top = 32 Width = 609 - Height = 425 + Height = 433 Caption = 'Actions' TabOrder = 0 object Label48: TLabel @@ -2976,6 +2961,163 @@ object FormConfig: TFormConfig end end end + object TabSheetActionneurs: TTabSheet + Caption = 'Actionneurs' + ImageIndex = 7 + object Label30: TLabel + Left = 8 + Top = 8 + Width = 143 + Height = 13 + Caption = 'Actionneurs de CDM Rail' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [fsBold] + ParentFont = False + end + object Label31: TLabel + Left = 352 + Top = 296 + Width = 229 + Height = 26 + Caption = 'Les actionneurs doivent '#234'tre compris entre deux d'#233'tecteurs' + WordWrap = True + end + object ListBoxActionneurs: TListBox + Left = 0 + Top = 56 + Width = 321 + Height = 361 + Color = clBlack + Font.Charset = DEFAULT_CHARSET + Font.Color = clAqua + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ItemHeight = 13 + MultiSelect = True + ParentFont = False + TabOrder = 0 + OnMouseDown = ListBoxActionneursMouseDown + end + object ButtonImRCDM: TButton + Left = 8 + Top = 432 + Width = 81 + Height = 25 + Hint = + 'Importe les actionneurs depuis le fichier d'#39'importation de CDM r' + + 'ail' + Caption = 'Importer' + ParentShowHint = False + ShowHint = True + TabOrder = 1 + WordWrap = True + OnClick = ButtonImRCDMClick + end + object ButtonNouvAct: TButton + Left = 0 + Top = 32 + Width = 65 + Height = 17 + Caption = 'Nouveau' + TabOrder = 2 + OnClick = ButtonNouvActClick + end + object ButtonSupAct: TButton + Left = 72 + Top = 32 + Width = 65 + Height = 17 + Caption = 'Supprime' + TabOrder = 3 + OnClick = ButtonSupActClick + end + object GroupBoxAct: TGroupBox + Left = 336 + Top = 56 + Width = 273 + Height = 153 + Caption = 'Description de l'#39'actionneur ' + TabOrder = 4 + object LabeledEditAdrActionneur: TLabeledEdit + Left = 190 + Top = 40 + Width = 40 + Height = 21 + EditLabel.Width = 38 + EditLabel.Height = 13 + EditLabel.Caption = 'Adresse' + EditLabel.Layout = tlBottom + LabelPosition = lpLeft + LabelSpacing = 140 + TabOrder = 0 + OnChange = LabeledEditAdrActionneurChange + end + end + end + object TabSheetDet: TTabSheet + Caption = 'D'#233'tecteurs' + ImageIndex = 13 + object Label42: TLabel + Left = 8 + Top = 8 + Width = 63 + Height = 13 + Caption = 'D'#233'tecteurs' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [fsBold] + ParentFont = False + end + object ListBoxDet: TListBox + Left = 0 + Top = 56 + Width = 321 + Height = 361 + Color = clBlack + Font.Charset = DEFAULT_CHARSET + Font.Color = clAqua + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ItemHeight = 13 + MultiSelect = True + ParentFont = False + TabOrder = 0 + OnMouseDown = ListBoxDetMouseDown + end + object Button4: TButton + Left = 0 + Top = 32 + Width = 65 + Height = 17 + Caption = 'Nouveau' + TabOrder = 1 + OnClick = Button4Click + end + object Button5: TButton + Left = 72 + Top = 32 + Width = 65 + Height = 17 + Caption = 'Supprime' + TabOrder = 2 + OnClick = Button5Click + end + object GroupBoxDet: TGroupBox + Left = 336 + Top = 56 + Width = 265 + Height = 161 + Caption = 'Description' + TabOrder = 3 + end + end object TabSheetPN: TTabSheet Caption = 'PN' ImageIndex = 6 @@ -2988,7 +3130,7 @@ object FormConfig: TFormConfig TabOrder = 0 object GroupBoxPNA: TGroupBox Left = 8 - Top = 224 + Top = 240 Width = 249 Height = 121 Caption = 'Actionneurs PN simples' @@ -2996,7 +3138,7 @@ object FormConfig: TFormConfig end object GroupBoxPNZ: TGroupBox Left = 8 - Top = 352 + Top = 368 Width = 249 Height = 65 Caption = 'Zones de d'#233'tection' @@ -3004,30 +3146,30 @@ object FormConfig: TFormConfig end object GroupBoxPN: TGroupBox Left = 8 - Top = 24 + Top = 16 Width = 249 - Height = 193 + Height = 217 Caption = 'Action gestion passage '#224' niveau' ParentShowHint = False ShowHint = False TabOrder = 2 object Label21: TLabel Left = 8 - Top = 84 + Top = 92 Width = 100 Height = 13 Caption = 'Adresse de fermeture' end object Label22: TLabel Left = 8 - Top = 108 + Top = 116 Width = 94 Height = 13 Caption = 'Adresse d'#39'ouverture' end object EditAdrFerme: TEdit Left = 120 - Top = 80 + Top = 88 Width = 41 Height = 21 TabOrder = 0 @@ -3035,7 +3177,7 @@ object FormConfig: TFormConfig end object EditAdrOuvre: TEdit Left = 120 - Top = 104 + Top = 112 Width = 41 Height = 21 TabOrder = 2 @@ -3043,7 +3185,7 @@ object FormConfig: TFormConfig end object EditCdeFerme: TEdit Left = 168 - Top = 80 + Top = 88 Width = 25 Height = 21 Hint = 'Commande de fermeture (0 '#224' 2)' @@ -3054,7 +3196,7 @@ object FormConfig: TFormConfig end object EditCdeOuvre: TEdit Left = 168 - Top = 104 + Top = 112 Width = 25 Height = 21 Hint = 'Commande d'#39'ouverture (0 '#224' 2)' @@ -3065,7 +3207,7 @@ object FormConfig: TFormConfig end object ButtonTestFerme: TButton Left = 208 - Top = 80 + Top = 88 Width = 27 Height = 21 Hint = 'Test de fermeture (mode CDM ou connect'#233' '#224' l'#39'interface)' @@ -3077,7 +3219,7 @@ object FormConfig: TFormConfig end object ButtonTestOuvre: TButton Left = 208 - Top = 104 + Top = 112 Width = 27 Height = 21 Hint = 'Test d'#39'ouverture (mode CDM ou connect'#233' '#224' l'#39'interface)' @@ -3089,7 +3231,7 @@ object FormConfig: TFormConfig end object CheckPnPulse: TCheckBox Left = 8 - Top = 128 + Top = 136 Width = 97 Height = 17 Hint = @@ -3103,7 +3245,7 @@ object FormConfig: TFormConfig end object RadioButtonSimple: TRadioButton Left = 24 - Top = 152 + Top = 174 Width = 113 Height = 17 Hint = 'PN command'#233' par actionneurs' @@ -3115,7 +3257,7 @@ object FormConfig: TFormConfig end object RadioButtonZone: TRadioButton Left = 24 - Top = 168 + Top = 192 Width = 113 Height = 17 Hint = 'PN command'#233' par m'#233'moires de zone' @@ -3127,7 +3269,7 @@ object FormConfig: TFormConfig end object RadioGroupActPN: TRadioGroup Left = 8 - Top = 16 + Top = 24 Width = 233 Height = 57 Hint = 'action par accessoire DCC ou commande COM/USB' @@ -3141,8 +3283,8 @@ object FormConfig: TFormConfig OnClick = RadioGroupActPNClick end object ComboBoxPNCom: TComboBox - Left = 88 - Top = 128 + Left = 8 + Top = 152 Width = 145 Height = 21 Hint = 'Nom de l'#39'accessoire d'#233'fini dans l'#39'onglet "p'#233'riph'#233'riques COM/USB"' diff --git a/UnitConfig.pas b/UnitConfig.pas index 0294ecb..3fdaaab 100644 --- a/UnitConfig.pas +++ b/UnitConfig.pas @@ -228,7 +228,6 @@ type EditVitRalenti: TEdit; Label57: TLabel; EditVitNom: TEdit; - CheckRoulage: TCheckBox; CheckBoxVerifXpressNet: TCheckBox; PopupMenuRichedit: TPopupMenu; Copier1: TMenuItem; @@ -301,7 +300,6 @@ type ButtonCherche: TButton; SBMonte: TSpeedButton; SBDesc: TSpeedButton; - CheckBoxResa: TCheckBox; Label23: TLabel; Label28: TLabel; EditPortServeur: TEdit; @@ -316,7 +314,7 @@ type TabAvance: TTabSheet; Label39: TLabel; CheckBoxMsgAigInc: TCheckBox; - TabSheet1: TTabSheet; + TabSheetActions: TTabSheet; GroupBox15: TGroupBox; ListBoxActions: TListBox; ListBoxOperations: TListBox; @@ -335,6 +333,22 @@ type SpeedButtonOuvre: TSpeedButton; LabeledEditTempoD: TLabeledEdit; CheckBoxSens: TCheckBox; + TabSheetActionneurs: TTabSheet; + ListBoxActionneurs: TListBox; + Label30: TLabel; + ButtonImRCDM: TButton; + ButtonNouvAct: TButton; + ButtonSupAct: TButton; + GroupBoxAct: TGroupBox; + LabeledEditAdrActionneur: TLabeledEdit; + Label31: TLabel; + TabSheetDet: TTabSheet; + ListBoxDet: TListBox; + Label42: TLabel; + Button4: TButton; + Button5: TButton; + GroupBoxDet: TGroupBox; + RadioGroupLEB: TRadioGroup; procedure ButtonAppliquerEtFermerClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ListBoxAigMouseDown(Sender: TObject; Button: TMouseButton; @@ -476,7 +490,6 @@ type procedure EditChercherChange(Sender: TObject); procedure SBMonteClick(Sender: TObject); procedure SBDescClick(Sender: TObject); - procedure CheckBoxResaClick(Sender: TObject); procedure EditPortServeurExit(Sender: TObject); procedure EditPortServeurChange(Sender: TObject); procedure EditAdrSigChange(Sender: TObject); @@ -507,6 +520,17 @@ type procedure EditIconeChange(Sender: TObject); procedure LabeledEditTempoDChange(Sender: TObject); procedure CheckBoxSensClick(Sender: TObject); + procedure ButtonImRCDMClick(Sender: TObject); + procedure ButtonSupActClick(Sender: TObject); + procedure ListBoxActionneursMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + procedure LabeledEditAdrActionneurChange(Sender: TObject); + procedure ButtonNouvActClick(Sender: TObject); + procedure ListBoxDetMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure Button4Click(Sender: TObject); + procedure Button5Click(Sender: TObject); + procedure RadioGroupLEBClick(Sender: TObject); private { Déclarations privées } @@ -519,6 +543,7 @@ type procedure tb_onChange(sender : TObject); procedure Bt_onclick(sender : Tobject); procedure tbCde_onchange(Sender : Tobject); + procedure modif_Labeled(Sender : Tobject); {$IF CompilerVersion >= 28.0} procedure modif_ComboStyle(Sender : Tobject); {$IFEND} @@ -539,8 +564,6 @@ Filtrage_det_ch='Filtrage_det'; nCantons_Res_ch='nCantonsRes'; MaxSignalSens_ch='Max_Signal_Sens'; Algo_localisation_ch='Algo_localisation'; -mode_reserve_ch='Mode_reservation'; -Avec_roulage_ch='Avec_roulage'; nb_det_dist_ch='nb_det_dist'; IpV4_PC_ch='IpV4_PC'; ServicesCDM_ch='ServicesCDM'; @@ -581,12 +604,16 @@ AdrBaseDetDccpp_ch='AdrBaseDetDccpp'; AvecVerifIconesTCO_ch='AvecVerifIconesTCO'; NomModuleCDM_ch='NomModuleCDM'; Style_ch='Style'; +cbAffSig_ch='AffSig'; +cbAck_ch='AvecAck'; +cbRes_ch='AffRes'; Nba_ch='NombreAdresses'; nation_ch='Nation'; Periph_ch='Periph'; comm_ch='Commande'; nom_dec_pers_ch='Nom_dec_pers'; Nom_fich_TCO_ch='Nom_fichier_TCO'; +CheminProgWin_ch='Chemin_progWin'; LargeurF_ch='LargeurF'; // largeur de la fenêtre principale HauteurF_ch='HauteurF'; OffsetXF_ch='OffsetX'; // .Left de la fenêtre principale @@ -621,6 +648,8 @@ section_placement_ch='[section_placement]'; section_DecPers_ch='[section_decodeurs]'; section_accCOM_ch='[section_accCOMUSB]'; section_horloge_ch='[section horloge]'; +section_actionneurs_ch='[section_actionneurs]'; +section_detecteurs_ch='[section_detecteurs]'; rep_icones='icones'; @@ -634,20 +663,20 @@ 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, - TempoTC,Nbuttoirs : integer; + compt_Ligne,Style_aff,Ancien_Style,Ecran_SC,Max_Signal_Sens,nCantonsRes,ligneClicActionneur, + TempoTC,Nbuttoirs,AncLigneClicActionneur,AncligneclicDet,ligneclicDet : integer; ack_cdm,clicliste,config_modifie,clicproprietes,confasauver,trouve_MaxPort,fermeSC, modif_branches,ConfigPrete,trouve_section_dccpp,trouve_section_trains,trouve_section_acccomusb, trouveAvecVerifIconesTCO,Affiche_avert,activ,trouve_section_dec_pers,Z21,AffAigND, - PilotageTrainsCDMNom,LanceHorl : boolean; + PilotageTrainsCDMNom,LanceHorl,AffSig,AffRes,avecAck : boolean; fichier : text; // composants dynamiques - Gp1,GroupBoxAvance,GroupBoxExpert : TGroupBox; + Gp1,GroupBoxAvance,GroupBoxExpert,GroupBoxChemin,GroupBoxAff : TGroupBox; - CheckBoxCR,Cb1,Cb2,Cb3,CbVis,cbDTR,cbRTS : TCheckBox; + CheckBoxCR,Cb1,Cb2,Cb3,CbVis,cbDTR,cbRTS,cbAffSig,cbres,cbAck : TCheckBox; MemoPeriph : Tmemo; @@ -657,7 +686,7 @@ var EditZdet1V3F,EditZdet2V3F,EditZdet1V3O,EditZdet2V3O, EditZdet1V4F,EditZdet2V4F,EditZdet1V4O,EditZdet2V4O, EditZdet1V5F,EditZdet2V5F,EditZdet1V5O,EditZdet2V5O,EditOuvreEcran, - EditNbDetDist,EditNbCantons,EditFiltrDet,EditAlgo, + EditNbDetDist,EditNbCantons,EditFiltrDet,EditAlgo,EditChemin, EditMaxSignalSens,EditnCantonsRes,EditAntiTO,EditRep,EditTempoTC : Tedit; EditT : Array[1..10] of Tedit; @@ -665,8 +694,9 @@ 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,LabelTempoTC : Tlabel; + LabelStyle,LabelOuvreEcran,LabelAvance1,LabelAvance2,LabelAntiTO,LabelCDM, + LabelTD,LabelNC,LabelFiltre,LabelAlgo,LabelNbSignBS,LabelnCantonsRes,LabelTempoTC, + LabelChemin : Tlabel; RadioReserve,RadioServeurCDM,rgPilTrains : TradioGroup; @@ -680,6 +710,8 @@ var ComboL1,ComboL2,ComboTS1,ComboTS2 : Array[1..10] of TComboBox; ComboStyle : TcomboBox; + Prox1,prox2,LEAdrDet,LElongDet : TlabeledEdit; + function config_com(s : string) : boolean; function connecte_CDM : boolean; procedure decodeAig(s : string;var adr : integer;var B : char); @@ -692,6 +724,7 @@ function encode_signal(i : integer): string; procedure valide_branches; procedure trier_aig; procedure trier_detecteurs; +procedure trier_actionneurs; function decodeDCC(s : string) : string; function encode_aig(index : integer): string; function Ipok(s : string) : boolean; @@ -701,11 +734,12 @@ function encode_act_pn(i : integer) : string; function encode_Periph(index : integer) : string; procedure ajoute_champs_combos(i : integer); function verif_trains : boolean; +procedure Maj_icone_train(IImage : Timage;index :integer); implementation uses UnitDebug,UnitTCO, UnitSR, UnitCDF,UnitAnalyseSegCDM, unitPilote, unitclock, - UnitModifAction, UnitConfigCellTCO; + UnitModifAction,UnitConfigCellTCO; {$R *.dfm} @@ -713,7 +747,7 @@ uses UnitDebug,UnitTCO, UnitSR, UnitCDF,UnitAnalyseSegCDM, unitPilote, unitclock procedure Maj_Hint_Signal(indexSignal : integer); var s : string; begin - // ne pas supprimer le @= qui sert de marqueur pour identifier le feu + // ne pas supprimer le @= qui sert de marqueur pour identifier le signal s:='Index='+IntToSTR(indexSignal)+' @='+inttostr(Signaux[indexSignal].Adresse)+' Décodeur='+decodeur[Signaux[indexSignal].Decodeur]+ ' Adresse détecteur associé='+intToSTR(Signaux[indexSignal].Adr_det1)+ ' Adresse élement suivant='+intToSTR(Signaux[indexSignal].Adr_el_suiv1); @@ -769,6 +803,7 @@ end; function connecte_CDM : boolean; var s : string; i,erreur : integer; + savack: boolean; begin result:=false; // déconnexion de l'ancienne liaison éventuelle @@ -794,6 +829,9 @@ begin //if i>10 then affiche('Timeout',clred); if not(CDM_connecte) then begin Affiche('Socket CDM non connecté',clOrange);exit;end; + + savAck:=avecAckCDM; // sauver l'état avecou sans ack + avecAckCDM:=true; // il faut l'ack pour la phase de connexion avec cdm // connexion à CDM rail recuCDM:=''; s:='C-C-00-0001-CMDGEN-_CNCT|000|'; @@ -827,6 +865,7 @@ begin cdm_connecte:=false; result:=false; end; + avecAckCDM:=savACK; end else begin @@ -1078,7 +1117,7 @@ end; // transforme le signal du tableau Signaux[] en texte function encode_signal(i : integer): string; var s : string; - adresse,aspect,j,k,NfeuxDir,CondCarre,CondFeuBlanc,nc : integer; + decod,adresse,aspect,j,k,NfeuxDir,CondCarre,CondFeuBlanc,nc : integer; begin // adresse adresse:=Signaux[i].adresse; @@ -1089,13 +1128,14 @@ begin s:=IntToSTR(adresse)+','; // forme - D=directionnel ajouter 10 aspect:=Signaux[i].aspect; - if isDirectionnel(i) then s:=s+'D'+intToSTR(aspect-10)+',' else s:=s+IntToSTR(aspect)+','; + if isDirectionnel(i) then s:=s+'D'+intToSTR(aspect-10)+',' else s:=s+IntToSTR(aspect)+','; // bouton feu blanc, n'existe pas pour un feu directionnel (aspect>10) if not(isDirectionnel(i)) then begin if Signaux[i].feublanc then s:=s+'1,' else s:=s+'0,';end; // décodeur - s:=s+IntToSTR(Signaux[i].decodeur)+','; + decod:=Signaux[i].decodeur; + s:=s+IntToSTR(decod)+','; // detecteur et élement suivant (4 maxi) // signal non directionnel @@ -1117,8 +1157,10 @@ begin // feu rouge cli if Signaux[i].checkFR then s:=s+',FRC1' else s:=s+',FRC0'; - // si unisemaf, paramètre supplémentaire - if (Signaux[i].decodeur=6) then s:=s+',U'+intToSTR(Signaux[i].unisemaf); + // si unisemaf ou LEB, paramètre supplémentaire + if (decod=4) or (decod=6) then s:=s+',U'+intToSTR(Signaux[i].unisemaf); + + if decod=4 then s:=s+',L'+intToSTR(signaux[i].BinLin); // conditions supplémentaires pour le carré for nc:=1 to 6 do @@ -1211,7 +1253,7 @@ end; // sortie vrai si le signal a été stocké - faux si doublon function decode_ligne_signal(chaine_signal : string;i : integer) : boolean; var s,chaine,sa : string; - j,k,l,t,id,adresse,adr,erreur ,asp,bd: integer; + j,k,l,t,id,adresse,adr,erreur ,asp,bd,decod: integer; c : char; multiple,fini : boolean; begin @@ -1453,22 +1495,37 @@ begin end; end; if length(s)>0 then if s[1]='U' then delete(s,1,1); - // si décodeur UniSemaf (6) champ supplémentaire U - if (Signaux[i].decodeur=6) then + // si décodeur UniSemaf (6) ou LEB (4) champ supplémentaire U + decod:=Signaux[i].decodeur; + if (decod=4) or (decod=6) then begin Val(s,k,erreur); delete(s,1,erreur); if k=0 then begin - if Signaux[i].decodeur=6 then begin Affiche('Erreur 680 : '+chaine_signal+' Manque définition décodeur UniSemaf signal '+intToSTR(adresse),clred);end; + if decod=4 then + begin + Signaux[i].UniSemaf:=100 ; // passer en ancien pilotage + Affiche('Erreur 679 : '+chaine_signal+' Manque définition cible signal LEB '+intToSTR(adresse),clred); + end; + if decod=6 then begin Affiche('Erreur 680 : '+chaine_signal+' Manque définition décodeur UniSemaf signal '+intToSTR(adresse),clred);end; end else begin Signaux[i].UniSemaf:=k; - if Signaux[i].decodeur=6 then + if decod=4 then + begin + erreur:=verif_LEB(adresse,k); + if erreur=1 then begin Affiche('Erreur 681 : '+chaine_signal+' Erreur code cible LEB',clred);end; + if erreur=2 then + begin + Affiche('Erreur 682 : '+chaine_signal+' Erreur cohérence signal (Adresse='+intToSTR(adresse)+' Aspect='+intToSTR(asp)+' et code cible LEB=('+intToSTR(k)+')',clred); + end; + end; + if decod=6 then begin erreur:=verif_UniSemaf(adresse,k); - if erreur=1 then begin Affiche('Erreur 681 : '+chaine_signal+' Erreur code Unisemaf',clred);end; + if erreur=1 then begin Affiche('Erreur 682 : '+chaine_signal+' Erreur code Unisemaf',clred);end; if erreur=2 then begin Affiche('Erreur 682 : '+chaine_signal+' Erreur cohérence signal (Adresse='+intToSTR(adresse)+' Aspect='+intToSTR(asp)+' et code Unisemaf=('+intToSTR(k)+')',clred); @@ -1477,6 +1534,18 @@ begin end; end; end; + + if length(s)>0 then if s[1]='L' then + begin + delete(s,1,1); + // si décodeur LEB (4) champ supplémentaire L : binaire ou linéaire + Val(s,k,erreur); + delete(s,1,erreur); + if (k<0) or (k>1) then k:=0; + signaux[i].BinLin:=k; + end; + + // voir si conditions supplémentaires de carré l:=1; // nombre de parenthèses repeat @@ -1535,7 +1604,7 @@ begin val(chaine,adresse,erreur); Signaux[i].condFeuBlanc[l][bd].Adresse:=adresse; if erreur<>0 then Signaux[i].condFeuBlanc[l][bd].PosAig:=chaine[erreur] else - Affiche('Erreur 683 Définition du signal '+IntToSTR(Signaux[i].adresse)+': Manque D ou S dans les conditions de feu blanc des aiguillages',clred); + Affiche('Erreur 684 Définition du signal '+IntToSTR(Signaux[i].adresse)+': Manque D ou S dans les conditions de feu blanc des aiguillages',clred); end; k:=pos(',',sa);if k<>0 then delete(sa,1,k); until k=0; @@ -1601,6 +1670,25 @@ begin end; end; +// transforme le détecteur en chaine +function encode_detecteur(i : integer) : string; +var adr : integer; +begin + adr:=Adresse_detecteur[i]; + result:=intToSTR(adr)+','+intToSTR(detecteur[adr].longueur); +end; + +// transforme l'actionneur en chaine +function encode_actionneur(i : integer) : string; +begin + if (i<1) or (i>nActionneurs) then + begin + result:=''; + end; + result:=intToSTR(actionneur[i].adresse)+','+intToSTR(actionneur[i].prox1)+','+intToSTR(actionneur[i].prox2); +end; + + // transforme l'action en chaine function encode_actions(i : integer) : string; var s : string; @@ -1612,58 +1700,58 @@ begin exit; end; - s:=Tablo_Actionneur[i].NomAction+','; + s:=Tablo_Action[i].NomAction+','; - decl:=Tablo_Actionneur[i].declencheur; + decl:=Tablo_Action[i].declencheur; s:=s+'D'+intToSTR(decl)+','; case decl of - declHorloge : s:=s+intToSTR(Tablo_Actionneur[i].heure)+','+intToSTR(Tablo_Actionneur[i].minute)+','; - declPeriph : s:=s+intToSTR(Tablo_Actionneur[i].NumPeriph)+','+Tablo_Actionneur[i].ordrePeriph+','; - 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)+','; + declHorloge : s:=s+intToSTR(Tablo_Action[i].heure)+','+intToSTR(Tablo_Action[i].minute)+','; + declPeriph : s:=s+intToSTR(Tablo_Action[i].NumPeriph)+','+Tablo_Action[i].ordrePeriph+','; + DeclAccessoire : s:=s+intToSTR(Tablo_Action[i].adresse)+','+intToSTR(Tablo_Action[i].etat)+','; + DeclDetAct : s:=s+intToSTR(Tablo_Action[i].adresse)+','+intToSTR(Tablo_Action[i].etat)+','+Tablo_Action[i].trainDecl+','; + DeclZoneDet : s:=s+intToSTR(Tablo_Action[i].adresse)+','+intToSTR(Tablo_Action[i].adresse2)+','+intToSTR(Tablo_Action[i].etat)+','+Tablo_Action[i].trainDecl+','; + DeclDemarTrain : s:=s+intToSTR(Tablo_Action[i].adresse)+','+Tablo_Action[i].trainDecl+','; + DeclArretTrain : s:=s+intToSTR(Tablo_Action[i].adresse)+','+Tablo_Action[i].trainDecl+','; + DeclSignal : s:=s+intToSTR(Tablo_Action[i].adresse)+','+intToSTR(Tablo_Action[i].etat)+','; end; // conditions - Nb:=Tablo_Actionneur[i].NbCond; + Nb:=Tablo_Action[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) + action:=Tablo_Action[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+','; + condVitTrain : s:=s+intToSTR(Tablo_Action[i].TabloCond[j].vitmini)+','+intToSTR(Tablo_Action[i].TabloCond[j].vitmaxi)+','+Tablo_Action[i].TabloCond[j].train+','; + condPosAcc : s:=s+intToSTR(Tablo_Action[i].TabloCond[j].accessoire)+','+intToSTR(Tablo_Action[i].TabloCond[j].etat)+','; + condHorl : s:=s+intToSTR(Tablo_Action[i].TabloCond[j].HeureMin)+','+intToSTR(Tablo_Action[i].TabloCond[j].MinuteMin)+','+ + intToSTR(Tablo_Action[i].TabloCond[j].HeureMax)+','+intToSTR(Tablo_Action[i].TabloCond[j].MinuteMax)+','; + condTrainSig : s:=s+intToSTR(Tablo_Action[i].TabloCond[j].adresse)+','+Tablo_Action[i].TabloCond[j].train+','; end; end; - Nb:=Tablo_Actionneur[i].NbOperations; + Nb:=Tablo_Action[i].NbOperations; s:=s+'N'+intToSTR(nb)+','; for j:=1 to Nb do begin - action:=Tablo_Actionneur[i].TabloOp[j].numoperation; + action:=Tablo_Action[i].TabloOp[j].numoperation; s:=s+'A'+intToSTR(action); - if Tablo_Actionneur[i].TabloOp[j].valide then s:=s+',1' else s:=s+',0'; + if Tablo_Action[i].TabloOp[j].valide then s:=s+',1' else s:=s+',0'; case action of - ActionAffTCO : s:=s+','+intToSTR(Tablo_Actionneur[i].tabloOp[j].NumTCO); + ActionAffTCO : s:=s+','+intToSTR(Tablo_Action[i].tabloOp[j].NumTCO); ActionAccessoire: begin - s:=s+','+intToSTR(Tablo_Actionneur[i].tabloOp[j].adresse)+','+intToSTR(Tablo_Actionneur[i].tabloOp[j].etat)+','; - if tablo_Actionneur[i].tabloOp[j].zero then s:=s+'Z' else s:=s+'S'; + s:=s+','+intToSTR(Tablo_Action[i].tabloOp[j].adresse)+','+intToSTR(Tablo_Action[i].tabloOp[j].etat)+','; + if Tablo_Action[i].tabloOp[j].zero then s:=s+'Z' else s:=s+'S'; end; - ActionVitesse : s:=s+','+intToSTR(Tablo_Actionneur[i].tabloOp[j].vitesse)+','+Tablo_Actionneur[i].tabloOp[j].train; - ActionCdePeriph : s:=s+','+intToSTR(Tablo_Actionneur[i].tabloOp[j].periph)+','+Tablo_Actionneur[i].tabloOp[j].chaine; - ActionFonctionF : s:=s+','+intToSTR(Tablo_Actionneur[i].tabloOp[j].fonctionF)+','+intToSTR(Tablo_Actionneur[i].tabloOp[j].TempoF)+','+Tablo_Actionneur[i].tabloOp[j].train; - ActionSon : s:=s+','+Tablo_Actionneur[i].tabloOp[j].train; // nom du fichier - ActionTempo : s:=s+','+intToSTR(Tablo_Actionneur[i].tabloOp[j].TempoF); + ActionVitesse : s:=s+','+intToSTR(Tablo_Action[i].tabloOp[j].vitesse)+','+Tablo_Action[i].tabloOp[j].train; + ActionCdePeriph : s:=s+','+intToSTR(Tablo_Action[i].tabloOp[j].periph)+','+Tablo_Action[i].tabloOp[j].chaine; + ActionFonctionF : s:=s+','+intToSTR(Tablo_Action[i].tabloOp[j].fonctionF)+','+intToSTR(Tablo_Action[i].tabloOp[j].TempoF)+','+Tablo_Action[i].tabloOp[j].train; + ActionSon : s:=s+','+Tablo_Action[i].tabloOp[j].train; // nom du fichier + ActionTempo : s:=s+','+intToSTR(Tablo_Action[i].tabloOp[j].TempoF); end; if j0 then s:=s+intToSTR(canton[j].Sens)+',' else s:=s+'0,'; + if j<>0 then s:=s+intToSTR(canton[j].SensLoco)+',' else s:=s+'0,'; if trains[i].inverse then s:=s+'1' else s:=s+'0'; writeln(fichierN,s); end; @@ -2155,13 +2251,33 @@ begin writeln(fichierN,s); s:=RetourHeure_ch+'='+intToSTR(RetourHeure); writeln(fichierN,s); - s:=RetourMinute_ch+'='+intToSTR(RetourMinute); + s:=RetourMinute_ch+'='+intToSTR(RetourMinute); writeln(fichierN,s); s:=DureeMinute_ch+'='+intToSTR(DureeMinute); writeln(fichierN,s); writeln(fichierN,'0'); + // actionneurs CDM + writeln(fichierN,'/------------'); + writeln(fichierN,section_actionneurs_ch); + for i:=1 to Nactionneurs do + begin + s:=encode_actionneur(i); + writeln(fichierN,s); + end; + writeln(fichierN,'0'); + + // détecteurs + writeln(fichierN,'/------------'); + writeln(fichierN,section_detecteurs_ch); + for i:=1 to NDetecteurs do + begin + s:=encode_detecteur(i); + writeln(fichierN,s); + end; + writeln(fichierN,'0'); + closefile(fichierN); end; @@ -2183,7 +2299,26 @@ begin end; end; -// trier les aiguillages +procedure trier_actionneurs; +var i,j : integer; + temp : Tactionneur; +begin + for i:=1 to Nactionneurs-1 do + begin + for j:=i+1 to Nactionneurs do + begin + if actionneur[i].adresse>actionneur[j].adresse then + begin + temp:=actionneur[i]; + actionneur[i]:=actionneur[j]; + actionneur[j]:=temp; + end; + end; + end; + +end; + +// trier les aiguillages par adresses croissantes procedure trier_aig; var i,j : integer; temp : TAiguillage; @@ -2219,7 +2354,7 @@ begin end; end; -// trie les signaux +// trie les signaux par adresses croissantes procedure trier_sig; var i,j,l,longestLength,pixelLength : integer; s,LongestString : string; @@ -2380,7 +2515,7 @@ var train,s,sa,SOrigine: string; begin if pos('PN',uppercase(s))<>0 then begin - //if k>0 then Tablo_actionneur[maxTablo_act].TabloOp[k].numoperation:=ActionPN; + //if k>0 then Tablo_Action[maxTablo_act].TabloOp[k].numoperation:=ActionPN; inc(NbrePN); NbreVoies:=0; repeat @@ -2483,20 +2618,20 @@ var train,s,sa,SOrigine: string; end; // anciens - procedure compile_actionneurs; + procedure compile_anciens_actionneurs; var i : integer; begin NbrePN:=0; confasauver:=true; // raz des actionneurs - for i:=1 to Max_actionneurs do + for i:=1 to Max_action do begin - Tablo_actionneur[i].trainDecl:=''; - Tablo_actionneur[i].etat:=0; - Tablo_actionneur[i].adresse:=0; - Tablo_actionneur[i].adresse2:=0; - Tablo_actionneur[i].trainDecl:=''; - Tablo_actionneur[i].declencheur:=0; + Tablo_Action[i].trainDecl:=''; + Tablo_Action[i].etat:=0; + Tablo_Action[i].adresse:=0; + Tablo_Action[i].adresse2:=0; + Tablo_Action[i].trainDecl:=''; + Tablo_Action[i].declencheur:=0; end; maxTablo_act:=1; @@ -2515,23 +2650,23 @@ var train,s,sa,SOrigine: string; // MEM = zone // Aaiguillage = aiguillage s:=sOrigine; // travailler en min/maj - Tablo_actionneur[maxtablo_act].NomAction:='Action '+intToSTR(maxtablo_act); + Tablo_Action[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; + setlength(Tablo_Action[maxtablo_act].TabloCond,2); + Tablo_Action[maxtablo_act].NbCond:=1; + Tablo_Action[maxtablo_act].TabloCond[1].numcondition:=CondVrai; // évènement actionneur par horloge if (upcase(s[1])='H') then begin - Tablo_actionneur[maxtablo_act].declencheur:=DeclHorloge; + Tablo_Action[maxtablo_act].declencheur:=DeclHorloge; Delete(s,1,1); val(s,j,erreur); - Tablo_actionneur[maxtablo_act].heure:=j; //heure + Tablo_Action[maxtablo_act].heure:=j; //heure delete(s,1,erreur); val(s,j,erreur); - Tablo_actionneur[maxtablo_act].minute:=j; // minute + Tablo_Action[maxtablo_act].minute:=j; // minute delete(s,1,erreur); i:=pos(',',s); delete(s,1,i); @@ -2543,49 +2678,49 @@ var train,s,sa,SOrigine: string; // évènement actionneur par accessoire if (upcase(s[1])='A') then begin - Tablo_actionneur[maxtablo_act].declencheur:=DeclAccessoire; + Tablo_Action[maxtablo_act].declencheur:=DeclAccessoire; Delete(s,1,1); val(s,j,erreur); - Tablo_actionneur[maxtablo_act].adresse:=j; + Tablo_Action[maxtablo_act].adresse:=j; delete(s,1,erreur); val(s,j,erreur); - Tablo_actionneur[maxtablo_act].etat:=j; + Tablo_Action[maxtablo_act].etat:=j; delete(s,1,erreur); i:=pos(',',s); - //Tablo_actionneur[maxtablo_act].traindecl:=copy(s,1,i-1); // inutile mais stocké + //Tablo_Action[maxtablo_act].traindecl:=copy(s,1,i-1); // inutile mais stocké delete(s,1,i); end else if upcase(s[1])='M' then //MEM[ begin - Tablo_actionneur[maxtablo_act].declencheur:=DeclZoneDet; + Tablo_Action[maxtablo_act].declencheur:=DeclZoneDet; Delete(s,1,4); val(s,j,erreur); - Tablo_actionneur[maxtablo_act].adresse:=j; + Tablo_Action[maxtablo_act].adresse:=j; i:=pos(',',s);delete(s,1,i); val(s,j,erreur); i:=pos(',',s); - Tablo_actionneur[maxtablo_act].adresse2:=j; + Tablo_Action[maxtablo_act].adresse2:=j; delete(s,1,i); val(s,j,erreur); - Tablo_actionneur[maxtablo_act].etat:=j; + Tablo_Action[maxtablo_act].etat:=j; delete(s,1,erreur); i:=pos(',',s); - //Tablo_actionneur[maxtablo_act].traindecl:=copy(s,1,i-1); // inutile mais stocké + //Tablo_Action[maxtablo_act].traindecl:=copy(s,1,i-1); // inutile mais stocké delete(s,1,i); end else if (s[1]<>'(') then begin // nombre - Tablo_actionneur[maxtablo_act].declencheur:=DeclDetAct; + Tablo_Action[maxtablo_act].declencheur:=DeclDetAct; val(s,j,erreur); - Tablo_actionneur[maxtablo_act].adresse:=j; + Tablo_Action[maxtablo_act].adresse:=j; delete(s,1,erreur); val(s,j,erreur); delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].etat:=j; + Tablo_Action[maxtablo_act].etat:=j; i:=pos(',',s); // encadre le nom du train - Tablo_actionneur[maxtablo_act].TrainDecl:=copy(s,1,i-1); + Tablo_Action[maxtablo_act].TrainDecl:=copy(s,1,i-1); delete(s,1,i); end; @@ -2594,25 +2729,25 @@ var train,s,sa,SOrigine: string; // A,etat,X // "fichierson" // ACCnum - setlength(tablo_actionneur[maxtablo_act].TabloOp,2); - tablo_actionneur[maxtablo_act].NbOperations:=1; - tablo_actionneur[maxtablo_act].TabloOp[1].valide:=true; + setlength(Tablo_Action[maxtablo_act].TabloOp,2); + Tablo_Action[maxtablo_act].NbOperations:=1; + Tablo_Action[maxtablo_act].TabloOp[1].valide:=true; if upcase(s[1])='F' then begin // -----------------fonction loco - Tablo_actionneur[maxTablo_act].TabloOp[1].numoperation:=ActionFonctionF; + Tablo_Action[maxTablo_act].TabloOp[1].numoperation:=ActionFonctionF; delete(s,1,1); val(s,j,erreur); - Tablo_actionneur[maxTablo_act].TabloOp[1].fonctionF:=j; + Tablo_Action[maxTablo_act].TabloOp[1].fonctionF:=j; Delete(s,1,erreur); val(s,j,erreur); - Tablo_actionneur[maxTablo_act].TabloOp[1].TempoF:=j div 100; + Tablo_Action[maxTablo_act].TabloOp[1].TempoF:=j div 100; Delete(s,1,erreur); - Tablo_actionneur[maxTablo_act].TabloOp[1].train:=s; + Tablo_Action[maxTablo_act].TabloOp[1].train:=s; inc(maxTablo_act); end @@ -2621,17 +2756,17 @@ var train,s,sa,SOrigine: string; if upcase(s[1])='V' then begin // -----------------vitesse - Tablo_actionneur[maxTablo_act].TabloOp[1].numoperation:=ActionVitesse; + Tablo_Action[maxTablo_act].TabloOp[1].numoperation:=ActionVitesse; delete(s,1,1); i:=pos(',',s); if i=0 then sa:=s; sa:=copy(s,1,i-1); val(sa,j,erreur); - Tablo_actionneur[maxTablo_act].TabloOp[1].vitesse:=j; + Tablo_Action[maxTablo_act].TabloOp[1].vitesse:=j; Delete(s,1,i); - Tablo_actionneur[maxTablo_act].TabloOp[1].train:=s; + Tablo_Action[maxTablo_act].TabloOp[1].train:=s; inc(maxTablo_act); end @@ -2640,14 +2775,14 @@ var train,s,sa,SOrigine: string; if uppercase(copy(s,1,3))='ACC' then begin // -----------------fonction commande périphérique com usb - Tablo_actionneur[maxTablo_act].TabloOp[1].numoperation:=ActionCdePeriph; + Tablo_Action[maxTablo_act].TabloOp[1].numoperation:=ActionCdePeriph; delete(s,1,3); val(s,j,erreur); - Tablo_actionneur[maxTablo_act].TabloOp[1].periph:=j; + Tablo_Action[maxTablo_act].TabloOp[1].periph:=j; Delete(s,1,erreur); - Tablo_actionneur[maxTablo_act].TabloOp[1].chaine:=s; + Tablo_Action[maxTablo_act].TabloOp[1].chaine:=s; { @@ -2656,7 +2791,7 @@ var train,s,sa,SOrigine: string; i:=posEx(',',sOrigine,i+1); i:=posEx(',',sOrigine,i+1); Delete(sOrigine,1,i); - tablo_actionneur[maxTablo_act].trainDest:=sOrigine;} + Tablo_Action[maxTablo_act].trainDest:=sOrigine;} inc(maxTablo_act); // incrémenter index de stockage du tableau des actionneurs s:=''; end @@ -2665,13 +2800,13 @@ var train,s,sa,SOrigine: string; if s[1]='"' then begin // -----------------son - Tablo_actionneur[maxTablo_act].TabloOp[1].numoperation:=ActionSon; + Tablo_Action[maxTablo_act].TabloOp[1].numoperation:=ActionSon; delete(s,1,1); i:=pos('"',s); s:=copy(s,1,i-1); - Tablo_actionneur[maxTablo_act].TabloOp[1].train:=s; + Tablo_Action[maxTablo_act].TabloOp[1].train:=s; s:=''; inc(maxTablo_act); end @@ -2679,18 +2814,18 @@ var train,s,sa,SOrigine: string; // accessoire if length(s)>0 then if (upcase(s[1])='A') and (upcase(s[2])<>'C') then begin - Tablo_actionneur[maxTablo_act].TabloOp[1].numoperation:=ActionAccessoire; + Tablo_Action[maxTablo_act].TabloOp[1].numoperation:=ActionAccessoire; delete(s,1,1); val(s,j,erreur); - Tablo_actionneur[maxTablo_act].TabloOp[1].adresse:=j; + Tablo_Action[maxTablo_act].TabloOp[1].adresse:=j; delete(s,1,erreur); val(s,j,erreur); - Tablo_actionneur[maxTablo_act].TabloOp[1].etat:=j; + Tablo_Action[maxTablo_act].TabloOp[1].etat:=j; Delete(s,1,erreur); - Tablo_actionneur[maxTablo_act].TabloOp[1].zero:=s[1]='Z'; + Tablo_Action[maxTablo_act].TabloOp[1].zero:=s[1]='Z'; inc(maxTablo_act); s:=''; @@ -2809,7 +2944,7 @@ var train,s,sa,SOrigine: string; // nouveaux procedure compile_actions; - var n,k,l,c : integer; + var n,k,l : integer; begin maxTablo_act:=1; Nligne:=1; @@ -2823,88 +2958,88 @@ var train,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; + Tablo_Action[maxtablo_act].traite:=false; + Tablo_Action[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; + Tablo_Action[maxtablo_act].NbCond:=1; + Setlength(Tablo_Action[maxtablo_act].TabloCond,2); + Tablo_Action[maxtablo_act].TabloCond[1].numcondition:=CondVrai; Delete(s,1,i); // déclencheur delete(s,1,1); Val(s,n,erreur); - Tablo_actionneur[maxtablo_act].declencheur:=n; + Tablo_Action[maxtablo_act].declencheur:=n; Delete(s,1,erreur); case n of Declhorloge : begin Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].heure:=i; + Tablo_Action[maxtablo_act].heure:=i; Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].minute:=i; + Tablo_Action[maxtablo_act].minute:=i; end; DeclPeriph : begin Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].NumPeriph:=i; + Tablo_Action[maxtablo_act].NumPeriph:=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].ordrePeriph:=sa; + Tablo_Action[maxtablo_act].ordrePeriph:=sa; end; DeclAccessoire : begin Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].adresse:=i; + Tablo_Action[maxtablo_act].adresse:=i; Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].etat:=i; + Tablo_Action[maxtablo_act].etat:=i; end; DeclDetAct : begin Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].adresse:=i; + Tablo_Action[maxtablo_act].adresse:=i; Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].etat:=i; + Tablo_Action[maxtablo_act].etat:=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; + Tablo_Action[maxtablo_act].trainDecl:=sa; end; DeclZoneDet : begin Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].adresse:=i; + Tablo_Action[maxtablo_act].adresse:=i; Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].adresse2:=i; + Tablo_Action[maxtablo_act].adresse2:=i; Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].etat:=i; + Tablo_Action[maxtablo_act].etat:=i; i:=pos(',',s); sa:=copy(s,1,i-1);delete(s,1,i); - Tablo_actionneur[maxtablo_act].trainDecl:=sa; + Tablo_Action[maxtablo_act].trainDecl:=sa; end; DeclDemarTrain : begin Val(s,i,erreur);Delete(s,1,erreur); // seuil de vitesse - Tablo_actionneur[maxtablo_act].adresse:=i; + Tablo_Action[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; + Tablo_Action[maxtablo_act].trainDecl:=sa; end; DeclArretTrain : begin Val(s,i,erreur);Delete(s,1,erreur); // seuil de vitesse - Tablo_actionneur[maxtablo_act].adresse:=i; + Tablo_Action[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; + Tablo_Action[maxtablo_act].trainDecl:=sa; end; DeclSignal : begin Val(s,i,erreur);Delete(s,1,erreur); // adresse - Tablo_actionneur[maxtablo_act].adresse:=i; + Tablo_Action[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; + Tablo_Action[maxtablo_act].Etat:=i; end; end; @@ -2915,9 +3050,9 @@ var train,s,sa,SOrigine: string; delete(s,1,1); // nombre de conditions Val(s,n,erreur); - Tablo_actionneur[maxtablo_act].NbCond:=n; + Tablo_Action[maxtablo_act].NbCond:=n; Delete(s,1,erreur); - setlength(Tablo_actionneur[maxtablo_act].TabloCond,n+1); + setlength(Tablo_Action[maxtablo_act].TabloCond,n+1); for k:=1 to n do begin delete(s,1,1); @@ -2927,51 +3062,51 @@ var train,s,sa,SOrigine: string; 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; + Tablo_Action[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; + Tablo_Action[maxtablo_act].tabloCond[k].vitmini:=j; val(s,j,erreur); delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].tabloCond[k].vitmaxi:=j; + Tablo_Action[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; + Tablo_Action[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; + Tablo_Action[maxtablo_act].tabloCond[k].accessoire:=j; val(s,j,erreur); delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].tabloCond[k].etat:=j; + Tablo_Action[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; + Tablo_Action[maxtablo_act].tabloCond[k].HeureMin:=j; val(s,j,erreur); delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].tabloCond[k].MinuteMin:=j; + Tablo_Action[maxtablo_act].tabloCond[k].MinuteMin:=j; val(s,j,erreur); delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].tabloCond[k].HeureMax:=j; + Tablo_Action[maxtablo_act].tabloCond[k].HeureMax:=j; val(s,j,erreur); delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].tabloCond[k].MinuteMax:=j; + Tablo_Action[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; + Tablo_Action[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; + Tablo_Action[maxtablo_act].tabloCond[k].train:=sa; end; end; end; @@ -2980,10 +3115,10 @@ var train,s,sa,SOrigine: string; // nombre d'actions delete(s,1,1); Val(s,n,erreur); - Tablo_actionneur[maxtablo_act].NbOperations:=n; + Tablo_Action[maxtablo_act].NbOperations:=n; Delete(s,1,erreur); - setlength(Tablo_actionneur[maxtablo_act].TabloOp,n+1); + setlength(Tablo_Action[maxtablo_act].TabloOp,n+1); for k:=1 to n do begin delete(s,1,1); @@ -2993,21 +3128,21 @@ var train,s,sa,SOrigine: string; begin 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; + Tablo_Action[maxtablo_act].tabloOP[k].numoperation:=j; // 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; + Tablo_Action[maxtablo_act].tabloOP[k].valide:=l=1; + end else Tablo_Action[maxtablo_act].tabloOP[k].valide:=true; // paramètres des opérations case j of ActionAffTCO : begin Val(s,i,erreur); - Tablo_actionneur[maxtablo_act].tabloOp[k].NumTCO:=i; + Tablo_Action[maxtablo_act].tabloOp[k].NumTCO:=i; end; ActionAffSC : begin end; ActionAffCDM : begin end; @@ -3015,16 +3150,16 @@ var train,s,sa,SOrigine: string; ActionAccessoire : begin Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].tabloOp[k].adresse:=i; + Tablo_Action[maxtablo_act].tabloOp[k].adresse:=i; Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].tabloOp[k].etat:=i; + Tablo_Action[maxtablo_act].tabloOp[k].etat:=i; 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].tabloOp[k].zero:=sa='Z'; + Tablo_Action[maxtablo_act].tabloOp[k].zero:=sa='Z'; delete(s,1,1); end; ActionArretTrains : begin end; @@ -3035,41 +3170,41 @@ var train,s,sa,SOrigine: string; ActionVitesse : begin Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].tabloOp[k].vitesse:=i; + Tablo_Action[maxtablo_act].tabloOp[k].vitesse:=i; 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].tabloOp[k].train:=sa; + Tablo_Action[maxtablo_act].tabloOp[k].train:=sa; end; ActionCdePeriph : begin Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].tabloOp[k].periph:=i; + Tablo_Action[maxtablo_act].tabloOp[k].periph:=i; 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].tabloOp[k].chaine:=sa; + Tablo_Action[maxtablo_act].tabloOp[k].chaine:=sa; end; ActionFonctionF : begin Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].tabloOp[k].fonctionF:=i; + Tablo_Action[maxtablo_act].tabloOp[k].fonctionF:=i; Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].tabloOp[k].TempoF:=i; + Tablo_Action[maxtablo_act].tabloOp[k].TempoF:=i; 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].tabloOp[k].train:=sa; + Tablo_Action[maxtablo_act].tabloOp[k].train:=sa; end; ActionSon : begin @@ -3079,17 +3214,17 @@ var train,s,sa,SOrigine: string; sa:=copy(s,1,i-1);delete(s,1,i); end else sa:=s; - Tablo_actionneur[maxtablo_act].tabloOp[k].train:=sa; + Tablo_Action[maxtablo_act].tabloOp[k].train:=sa; end; actionTempo : begin Val(s,i,erreur);Delete(s,1,erreur); - Tablo_actionneur[maxtablo_act].tabloOp[k].TempoF:=i; + Tablo_Action[maxtablo_act].tabloOp[k].TempoF:=i; end; else begin if sOrigine<>'' then Affiche('Erreur 83: Action '+intToSTR(j)+' inconnue '+sOrigine,clred); - Tablo_actionneur[maxtablo_act].TabloOp[k].numoperation:=0; + Tablo_Action[maxtablo_act].TabloOp[k].numoperation:=0; end; end; end; @@ -3699,6 +3834,42 @@ var train,s,sa,SOrigine: string; until (sOrigine='0') or (NbPeriph>=NbMaxi_Periph); end; + procedure compile_actionneurs; + begin + Nactionneurs:=0; + repeat + lit_ligne; + if s<>'0' then + begin + inc(Nactionneurs); + val(s,i,erreur); + actionneur[Nactionneurs].adresse:=i; + delete(s,1,erreur); + val(s,i,erreur); + actionneur[Nactionneurs].prox1:=i; + delete(s,1,erreur); + val(s,i,erreur); + actionneur[Nactionneurs].prox2:=i; + end; + until (sOrigine='0') or (s=''); + trier_actionneurs; + end; + + procedure compile_detecteurs; + begin + repeat + lit_ligne; + if s<>'0' then + begin + val(s,j,erreur); + delete(s,1,erreur); + val(s,i,erreur); + detecteur[j].longueur:=i; + end; + until (sOrigine='0') or (s=''); + end; + + procedure compile_horloge; begin repeat @@ -3868,6 +4039,14 @@ var train,s,sa,SOrigine: string; if (i>0) and (i<11) then NomfichierTCO[i]:=s; end; + sa:=uppercase(CheminProgWin_ch)+'='; + i:=pos(sa,s); + if i=1 then + begin + delete(sOrigine,1,length(sa)); + CheminProgrammes:=sOrigine; + end; + sa:=uppercase(LargeurF_ch)+'='; i:=pos(sa,s); if i=1 then @@ -3992,26 +4171,6 @@ var train,s,sa,SOrigine: string; val(s,Max_Signal_Sens,erreur); end; - - sa:=uppercase(mode_reserve_ch)+'='; - i:=pos(sa,s); - if i=1 then - begin - delete(s,i,length(sa)); - if (i<0) or (i>1) then i:=0; - val(s,mode_reserve,erreur); - end; - - - sa:=uppercase(Avec_roulage_ch)+'='; - i:=pos(sa,s); - if i=1 then - begin - delete(s,i,length(sa)); - val(s,AvecRoulage,erreur); - if avecRoulage=1 then Formprinc.roulage1.visible:=true; - end; - sa:=uppercase(Style_ch)+'='; i:=pos(sa,s); if i=1 then @@ -4240,6 +4399,33 @@ var train,s,sa,SOrigine: string; if (Nb_cantons_Sig<3) or (Nb_cantons_Sig>5) then Nb_cantons_Sig:=3; end; + sa:=uppercase(cbAffSig_ch)+'='; + i:=pos(sa,s); + if i=1 then + begin + inc(nv); + delete(s,i,length(sa)); + AffSig:=s='1'; + end; + + sa:=uppercase(cbRes_ch)+'='; + i:=pos(sa,s); + if i=1 then + begin + inc(nv); + delete(s,i,length(sa)); + AffRes:=s='1'; + end; + + sa:=uppercase(cback_ch)+'='; + i:=pos(sa,s); + if i=1 then + begin + inc(nv); + delete(s,i,length(sa)); + AvecAck:=s='1'; + end; + // temporisation aiguillages sa:=uppercase(Tempo_Aig_ch)+'='; i:=pos(sa,s); @@ -4375,15 +4561,6 @@ var train,s,sa,SOrigine: string; NomModuleCDM:=s; end; - sa:=uppercase(ModeResa_ch)+'='; - i:=pos(sa,s); - if i=1 then - begin - inc(nv); - delete(s,1,length(sa)); - AvecResa:=s='1' - end; - sa:=uppercase(SERVEUR_INTERFACE_ch)+'='; i:=pos(sa,s); if i=1 then @@ -4471,7 +4648,7 @@ var train,s,sa,SOrigine: string; trier_aig; end ; - // section branche + // section branche sa:=uppercase(section_branches_ch); if pos(sa,s)<>0 then begin @@ -4494,7 +4671,7 @@ var train,s,sa,SOrigine: string; if pos(sa,s)<>0 then begin trouve_section_act:=true; - compile_actionneurs; + compile_anciens_actionneurs; end; // section PN @@ -4538,6 +4715,7 @@ var train,s,sa,SOrigine: string; end; // section placement : mis dans les trains + // "train",numéro du canton,sens,pilotage inverse (inutile) sa:=uppercase(section_placement_ch); if pos(sa,s)<>0 then begin @@ -4593,6 +4771,20 @@ var train,s,sa,SOrigine: string; compile_horloge; end; + // section actionneurs CDM + sa:=uppercase(section_actionneurs_ch); + if pos(sa,s)<>0 then + begin + compile_actionneurs; + end; + + // section detecteurs + sa:=uppercase(section_detecteurs_ch); + if pos(sa,s)<>0 then + begin + compile_detecteurs; + end; + inc(it); until (eof(fichier)); @@ -4670,7 +4862,7 @@ begin Detecteur[i].train:=''; Detecteur[i].AdrTrain:=0; Detecteur[i].tempo0:=0; - Detecteur[i].IndexTrain:=0; + Detecteur[i].IndexTrainRoulant:=0; Ancien_detecteur[i]:=false; end; @@ -4701,6 +4893,9 @@ begin PilotageTrainsCDMNom:=true; AvecDemandeInterfaceUSB:=true; AvecDemandeInterfaceEth:=true; + AffSig:=true; + AffRes:=true; + AvecAck:=false; lay:=''; Tempo_Aig:=100; Tempo_Signal:=100; @@ -4788,7 +4983,6 @@ begin det_prec_signal(adr,TabloDet); Signaux[i].DetAmont:=TabloDet; end; - end; @@ -4842,17 +5036,6 @@ begin if (i<1) or (i>65535) then i:=4500; portServeur:=i; - if checkRoulage.Checked then - begin - AvecRoulage:=1; - Formprinc.roulage1.visible:=true; - end - else - begin - AvecRoulage:=0; - Formprinc.roulage1.visible:=false; - end; - // contrôle adresse IP interface s:=EditIPLenz.text; if s='' then s:='0'; @@ -4989,6 +5172,9 @@ begin AvecDemandeAiguillages:=checkPosAig.checked; AvecDemandeInterfaceUSB:=CheckBoxDemarUSB.checked; AvecDemandeInterfaceEth:=CheckBoxDemarEth.checked; + AffSig:=cbAffSig.Checked; + AffRes:=cbRes.checked; + AvecAck:=cbAck.Checked; sombre:=CheckBoxSombre.Checked; protocole:=1; if RadioButtonXpress.Checked then @@ -5008,7 +5194,6 @@ begin val(EditBase.Text,AdrBaseDetDccpp,erreur); if (AdrBaseDetDccpp<0) or (AdrBaseDetDccpp>2048) then AdrBaseDetDccpp:=513; - mode_Reserve:=RadioReserve.ItemIndex; // 0 = par canton - 1=par détecteurs serveurIPCDM_Touche:=radioServeurCDM.ItemIndex=0; val(EditAlgo.Text,i,erreur); @@ -5018,6 +5203,7 @@ begin val(EditMaxSignalSens.Text,i,erreur); Max_Signal_Sens:=i; + cheminProgrammes:=editchemin.Text; end; if change_srv then services_CDM; @@ -5177,7 +5363,7 @@ begin end; end; -// met à jour le décodeur courant dans le tableau de config +// met à jour l'affichage du décodeur courant depuis le tableau de config procedure maj_decodeurs; var nAdr,i,j,a,nation,typ : integer; begin @@ -5316,6 +5502,7 @@ var op,j,n : integer; begin s:=Tablo_periph[i].nom; j:=com_socket(i); + if j=0 then exit; if (j<1) or (j>2) then begin Affiche('Erreur 170 : type périphérique inconnu='+intToSTR(j),clred); @@ -5337,8 +5524,8 @@ begin formModifAction.ComboBoxAccComUSB.Items[i-1]:=s; // réaffiche le champ modifié dans le comboboxAccComUSB - for op:=1 to Tablo_Actionneur[ligneclicAct+1].NbOperations do - if Tablo_Actionneur[ligneclicAct+1].tabloop[op].numoperation=ActionCdePeriph then if tablo_actionneur[ligneclicAct+1].tabloOp[op].periph=i then formModifAction.ComboBoxAccComUSB.ItemIndex:=i-1; + for op:=1 to Tablo_Action[ligneclicAct+1].NbOperations do + if Tablo_Action[ligneclicAct+1].tabloop[op].numoperation=ActionCdePeriph then if Tablo_Action[ligneclicAct+1].tabloOp[op].periph=i then formModifAction.ComboBoxAccComUSB.ItemIndex:=i-1; ComboBoxPNCom.items[i-1]:=s; if tablo_PN[lignecliqueePN+1].TypeCde=1 then if tablo_PN[lignecliqueePN+1].AdresseFerme=i then @@ -5357,21 +5544,21 @@ var i,op : integer; begin i:=1; repeat - for op:=1 to tablo_actionneur[i].NbOperations do + for op:=1 to Tablo_Action[i].NbOperations do begin - if tablo_actionneur[i].TabloOp[op].numoperation=ActionCdePeriph then + if Tablo_Action[i].TabloOp[op].numoperation=ActionCdePeriph then begin - if tablo_actionneur[i].TabloOp[op].periph=ancien1 then + if Tablo_Action[i].TabloOp[op].periph=ancien1 then begin - tablo_actionneur[i].tabloOp[op].periph:=nouveau1; + Tablo_Action[i].tabloOp[op].periph:=nouveau1; s:=encode_actions(i); formConfig.ListBoxActions.Items[i-1]:=s; inc(i); end else - if tablo_actionneur[i].TabloOp[op].periph=ancien2 then + if Tablo_Action[i].TabloOp[op].periph=ancien2 then begin - tablo_actionneur[i].TabloOp[op].periph:=nouveau2; + Tablo_Action[i].TabloOp[op].periph:=nouveau2; s:=encode_actions(i); formConfig.ListBoxActions.Items[i-1]:=s; inc(i); @@ -5555,7 +5742,105 @@ begin i:=extract_int(s); if (i<1) or (i>19) or (decCourant<1) then exit; decodeur_pers[decCourant].desc[i].Chcommande:=te; +end; +procedure raz_champs_pn; +begin + with formconfig do + begin + editAdrFerme.Text:='';EditCdeFerme.text:=''; + editAdrOuvre.Text:='';EditCdeOuvre.text:=''; + editV1F.Text:='';editV1O.Text:=''; + editV2F.Text:='';editV2O.Text:=''; + editV3F.Text:='';editV3O.Text:=''; + editV4F.Text:='';editV4O.Text:=''; + editV5F.Text:='';editV5O.Text:=''; + EditZdet1V1F.text:='';EditZdet2V1F.text:='';EditZdet1V1O.text:='';EditZdet2V1O.text:=''; + EditZdet1V2F.text:='';EditZdet2V2F.text:='';EditZdet1V2O.text:='';EditZdet2V2O.text:=''; + EditZdet1V3F.text:='';EditZdet2V3F.text:='';EditZdet1V3O.text:='';EditZdet2V3O.text:=''; + EditZdet1V4F.text:='';EditZdet2V4F.text:='';EditZdet1V4O.text:='';EditZdet2V4O.text:=''; + EditZdet1V5F.text:='';EditZdet2V5F.text:='';EditZdet1V5O.text:='';EditZdet2V5O.text:=''; + end; +end; + +procedure champs_pn_act; +begin + with formConfig do + begin + comboBoxPNCom.Visible:=false; + EditCdeOuvre.width:=25; + editCdeFerme.Width:=25; + editCdeOuvre.width:=25; + editCdeFerme.top:=EditAdrFerme.Top; + editCdeOuvre.top:=EditAdrOuvre.Top; + ButtonTestFerme.Top:=EditAdrFerme.Top; + ButtonTestOuvre.Top:=EditAdrOuvre.Top; + + editCdeFerme.Left:=168; + editCdeOuvre.Left:=168; + + EditCdeOuvre.Hint:='Commande d''ouverture (0 à 2)'; + EditCdeFerme.Hint:='Commande de fermeture (0 à 2)'; + ButtonTestFerme.Hint:='Test de fermeture (mode CDM ou connecté à l''interface)'; + ButtonTestOuvre.Hint:='Test d''ouverture (mode CDM ou connecté à l''interface)'; + + editCdeOuvre.Visible:=true; + editAdrOuvre.Visible:=true; + EditAdrFerme.Visible:=true; + Label22.visible:=true; + CheckPnPulse.Visible:=true; + CheckPnPulse.top:=140; + Label21.Caption:='Adresse de fermeture'; + EditAdrFerme.text:=IntToSTR(Tablo_PN[lignecliqueePN+1].AdresseFerme); + EditAdrOuvre.text:=IntToSTR(Tablo_PN[lignecliqueePN+1].AdresseOuvre); + EditCdeFerme.text:=intToSTR(Tablo_PN[lignecliqueePN+1].CommandeFerme); + EditCdeOuvre.text:=intToSTR(Tablo_PN[lignecliqueePN+1].CommandeOuvre); + end; +end; + +procedure champs_pn_COMUSBSockets; +begin + with formConfig do + begin + comboBoxPNCom.Visible:=true; + ComboBoxPNCom.Width:=150; + ComboBoxPNCom.Left:=4; + ComboBoxPNCom.top:=120; + EditAdrFerme.visible:=false; + editAdrOuvre.Visible:=false; + CheckPnPulse.Visible:=false; + EditCdeOuvre.width:=50; + editCdeFerme.width:=50; + editCdeFerme.top:=120;ButtonTestFerme.Top:=120;ButtonTestFerme.Top:=120; + editCdeOuvre.top:=150;ButtonTestOuvre.Top:=150;ButtonTestOuvre.Top:=150; + editCdeFerme.Left:=160; + editCdeOuvre.Left:=160; + ButtonTestFerme.Hint:='Test de fermeture (par interface COM/USB)'; + ButtonTestOuvre.Hint:='Test d''ouverture (par interface COM/USB)'; + editcdeFerme.Hint:='Commande ASCII de fermeture'; + EditCdeOuvre.Hint:='Commande ASCII d''ouverture'; + Label22.visible:=false; + Label21.Caption:='Périphérique COM/USB/Socket Commandes'; + EditCdeFerme.Text:=Tablo_PN[lignecliqueePN+1].CommandeF; + EditCdeOuvre.Text:=Tablo_PN[lignecliqueePN+1].CommandeO; + ComboBoxPnCom.ItemIndex:=Tablo_PN[lignecliqueePN+1].AdresseFerme-1; + CheckPNPulse.Visible:=false; + end; +end; + +procedure raz_champs_aig; +begin + with formConfig do + begin + LabelInfo.caption:=''; + EditAdrAig.Text:=''; + EditAigTriple.Text:=''; + Edit_HG.text:=''; + editDevie_HD.Text:=''; + editDroit_BD.Text:=''; + editPointe_BG.Text:=''; + EditTempo10.text:=''; + end; end; procedure TFormConfig.FormCreate(Sender: TObject); @@ -5564,6 +5849,8 @@ var i,j,x,y,l,LongestLength,PixelLength : integer; begin if AffEvt or (debug=1) then Affiche('Création fenêtre config',clLime); + TabSheetActionneurs.TabVisible:=not(diffusion); // invisible / visible + s:=GetCurrentDir; if not(directoryExists(rep_icones)) then CreateDir(rep_icones); ChDir(s); // revient au rep initial @@ -5571,6 +5858,7 @@ begin visible:=false; clicListe:=true; position:=poMainFormCenter; + RadioGroupLEB.Hint:='Mode binaire : CV12=0 '+#13+'Mode linéaire : CV12<>0'; cs:='ColorA='+IntToHex(couleurFond,6); // pour rajouter aux couleurs personnalisées de la fenetre couleur colorDialogFond.CustomColors.Add(cs); ButtonCouleur.Hint:='Change la couleur de fond de toutes les fenêtres de Signaux_Complexes.'+#13+ @@ -5580,10 +5868,12 @@ begin Affiche_avert:=false; if affevt then affiche('FormConfig create',clLime); PageControl.ActivePage:=Formconfig.TabSheetCDM; // force le premier onglet sur la page + ButtonImRCDM.Hint:='Importation des actionneurs depuis le fichier '+#13+NomModuleCDM; Aig_supprime.Adresse:=0; Signal_Supprime.Adresse:=0; Signal_sauve.adresse:=0; AncLigneCliqueePN:=-1; + lignecliqueePN:=-1; clicListe:=false; ligneCherche:=0; Compt_ligne:=0; @@ -5790,7 +6080,7 @@ begin Left:=8; top:=GroupBoxPN.Top+GroupBoxPN.Height+5; width:=GroupBoxPN.Width; - height:=200; + height:=190; visible:=true; end; with GroupBoxPNZ do @@ -5798,7 +6088,7 @@ begin Left:=8; top:=GroupBoxPN.Top+GroupBoxPN.Height+5; width:=GroupBoxPN.Width; - height:=200; + height:=190; visible:=false; end; @@ -6258,6 +6548,72 @@ begin onChange:=formConfig.modif_editT; end; + // actionneurs + Prox1:=TlabeledEdit.Create(FormConfig.GroupBoxAct); + with Prox1 do + begin + Name:='Prox1'; + left:=190;Top:=68;Width:=40;Height:=21; + text:=''; + parent:=GroupBoxAct; + hint:='Adresse du détecteur 1 encadrant'; + showhint:=true; + onChange:=formConfig.modif_Labeled; + LabelSpacing:=20; + editLabel.Caption:='Adresse du détecteur 1 encadrant'; + editLabel.Layout:=tlBottom; + LabelPosition:=lpLeft; + end; + // actionneurs + Prox2:=TlabeledEdit.Create(FormConfig.GroupBoxAct); + with Prox2 do + begin + Name:='Prox2'; + left:=190;Top:=90;Width:=40;Height:=21; + text:=''; + parent:=GroupBoxAct; + hint:='Adresse du détecteur 2 encadrant'; + showhint:=true; + onChange:=formConfig.modif_Labeled; + LabelSpacing:=20; + editLabel.Caption:='Adresse du détecteur 2 encadrant'; + editLabel.Layout:=tlBottom; + LabelPosition:=lpLeft; + end; + + // onglet détecteurs + LEAdrDet:=TlabeledEdit.Create(FormConfig.GroupBoxAct); + with LEAdrDet do + begin + Name:='LEAdrDet'; + left:=200;Top:=40;Width:=40;Height:=21; + text:=''; + parent:=GroupBoxDet; + hint:='Adresse du détecteur'; + showhint:=true; + onChange:=formConfig.modif_Labeled; + LabelSpacing:=80; + editLabel.Caption:='Adresse du détecteur'; + editLabel.Layout:=tlBottom; + LabelPosition:=lpLeft; + end; + LElongDet:=TlabeledEdit.Create(FormConfig.GroupBoxAct); + with LElongDet do + begin + Name:='LElongDet'; + left:=200;Top:=70;Width:=40;Height:=21; + text:=''; + parent:=GroupBoxDet; + hint:='Longueur du détecteur (cm)'; + showhint:=true; + onChange:=formConfig.modif_Labeled; + LabelSpacing:=50; + editLabel.Caption:='Longueur du détecteur (cm)'; + editLabel.Layout:=tlBottom; + LabelPosition:=lpLeft; + end; + + // remplit les 5 fenêtres de config des aiguillages branches signaux, actionneurs, accessoires comusb formconfig.ComboBoxDecodeurPerso.AutoComplete:=false; // mettre absolument à false sinon remplissage auto quand on tape et l'index sélec peut changer!!! for i:=1 to NbreDecPers do @@ -6386,7 +6742,7 @@ begin PixelLength:=ListboxPN.Canvas.TextWidth(LongestString)+8; // positionne une scrollbar dans la listbox - pour l'enlever, envoyer 0 dans pixelLength SendMessage(ListBoxPN.Handle,LB_SETHORIZONTALEXTENT,PixelLength,0); - + champs_pn_act; if clicproprietes then clicListeSignal(IndexSignalClic); clicproprietes:=false; @@ -6411,6 +6767,20 @@ begin for i:=1 to ntrains do items.Add(Train_tablo(i)); end; + // actionneurs + with ListBoxActionneurs do + begin + clear; + for i:=1 to Nactionneurs do items.add(encode_actionneur(i)); + end; + + // détecteurs + with ListBoxDet do + begin + clear; + for i:=1 to NDetecteurs do items.add(encode_detecteur(i)); + end; + // composants dynamiques car on ne peut plus ajouter de composants en mode conception! // onglet périphériques COM/USB/Socket //--------- groupbox @@ -6770,6 +7140,7 @@ begin ShowHint:=true; end; + { RadioReserve:=TRadioGroup.Create(TabAvance); with RadioReserve do begin @@ -6782,13 +7153,13 @@ begin ShowHint:=true; items.Add('Réservation par canton'); items.Add('Réservation par détecteurs'); - end; + end;} GroupBoxExpert:=TGroupBox.Create(FormConfig.TabAvance); with GroupBoxExpert do begin - Left:=GroupBoxAvance.Left;Width:=GroupBoxAvance.width;Height:=100; // maxi=580 - Top:=RadioReserve.Top+RadioReserve.Height+10 ; + Left:=GroupBoxAvance.Left;Width:=GroupBoxAvance.width;Height:=110; // maxi=580 + Top:=GroupBoxAvance.top+GroupBoxAvance.Height+10 ; caption:='Jeu de paramètres experts'; name:='GroupBoxExpert'; parent:=TabAvance; @@ -6833,9 +7204,20 @@ begin hint:='Nombre maxi d''éléments de recherche lors d''un signal dans le bon sens'; ShowHint:=true; end; + cbAck:=tCheckBox.Create(FormConfig.TabAvance); + with cbAck do + begin + Left:=10;Top:=85;Width:=200;Height:=15; + name:='cbAck'; + caption:='Attendre ACK de la centrale'; + parent:=GroupBoxExpert; + hint:='Attendre l''accusé de réception de la centrale lors du pilotage des accessoires'; + ShowHint:=true; + end; + RadioServeurCDM:=TRadioGroup.Create(TabAvance); - with RadioServeurCDM do + with RadioServeurCDM do begin Left:=GroupBoxAvance.Left;Top:=GroupBoxExpert.top+GroupBoxExpert.Height+10;Width:=GroupBoxAvance.width;Height:=60; name:='RadioServeurCDM'; @@ -6845,7 +7227,73 @@ begin ShowHint:=true; items.Add('Par simulation de touches'); items.Add('Par ligne de commande'); + end; + GroupBoxChemin:=TGroupBox.Create(FormConfig.TabAvance); + with GroupBoxChemin do + begin + Left:=310;Top:=40;Width:=300;Height:=100; + caption:='Chemins de fichiers'; + name:='GroupBoxChemin'; + parent:=TabAvance; + end; + LabelChemin:=TLabel.Create(FormConfig.TabAvance); + with LabelChemin do + begin + Left:=10;Top:=30;Width:=90;Height:=12; + caption:='Chemin Win CDM'; + name:='LabelChemin'; + Font.Size:=9; + parent:=GroupBoxChemin; + end; + EditChemin:=TEdit.Create(FormConfig.TabAvance); + with EditChemin do + begin + Left:=100;Top:=28;Width:=180;Height:=15; + name:='EditChemin'; + text:=''; + parent:=GroupBoxChemin; + hint:='Chemin windows d''installation de CDM'; + ShowHint:=true; + end; + LabelCDM:=TLabel.Create(FormConfig.TabAvance); + with LabelCDM do + begin + Left:=10;Top:=60;Width:=90;Height:=12; + caption:='Ce chemin sera suivi de "\CDM-Rail"'; + name:='LabelCDM'; + Font.Size:=9; + parent:=GroupBoxChemin; + end; + + // groupBox affichages + GroupBoxAff:=TGroupBox.Create(FormConfig.TabAvance); + with GroupBoxAff do + begin + Left:=310;Top:=GroupBoxChemin.top+GroupBoxChemin.height+8;Width:=300;Height:=160; + caption:='Affichages de la fenêtre principale'; + name:='GroupBoxAff'; + parent:=TabAvance; + end; + cbAffSig:=TcheckBox.Create(formconfig.TabAvance); + with cbAffSig do + begin + Left:=15;Top:=30;Width:=200;Height:=17; + caption:='Evènements signaux'; + name:='cbAffSig'; + hint:='Affiche l''état des signaux lors de leur changement'; + showHint:=true; + parent:=GroupBoxAff; + end; + cbres:=TcheckBox.Create(formconfig.TabAvance); + with cbres do + begin + Left:=15;Top:=50;Width:=200;Height:=17; + caption:='Réservation/libération des cantons'; + name:='cbRes'; + hint:='Affiche les réservations/libération des cantons lors du roulage des trains'; + showHint:=true; + parent:=GroupBoxAff; end; ImageSignaux.picture.Assign(formpilote.ImageSignaux.Picture); @@ -6921,17 +7369,17 @@ begin s:=s+'------------------------'+#13; for i:=1 to maxTablo_act do begin - for op:=1 to tablo_actionneur[i].NbOperations do + for op:=1 to Tablo_Action[i].NbOperations do begin - if tablo_actionneur[i].tabloOp[op].numoperation=ActionCdePeriph then + if Tablo_Action[i].tabloOp[op].numoperation=ActionCdePeriph then begin for j:=0 to NbPeriph-1 do begin if formconfig.ListBoxPeriph.selected[j] then - if tablo_actionneur[i].TabloOp[op].periph=j+1 then + if Tablo_Action[i].TabloOp[op].periph=j+1 then begin inc(n); - s:=s+'Le périphérique '+intToSTR(j+1)+' est utilisé par l''actionneur '+intToSTR(tablo_actionneur[i].adresse)+#13; + s:=s+'Le périphérique '+intToSTR(j+1)+' est utilisé par l''actionneur '+intToSTR(Tablo_Action[i].adresse)+#13; end; end; end; @@ -7308,6 +7756,16 @@ begin case decodeur of 2 : if not(isDirectionnel(index)) then ButtonConfigSR.Visible:=true; //cdf + 4 : begin + EditSpecUni.Visible:=true; + LabelUni.Caption:='Cible LEB'; + LabelUni.Visible:=true; + EditSpecUni.Text:=IntToSTR(Signaux[index].Unisemaf); + editSpecUni.Hint:='Paramètre de description de la cible LEB'+#13+'Mettre 100 pour les anciens décodeurs (mode binaire uniquement)'; + editSpecUni.ShowHint:=true; + RadioGroupLEB.Visible:=true; + RadioGroupLEB.ItemIndex:=signaux[index].BinLin; + end; 7 : ButtonConfigSR.Visible:=true; 5 : ButtonConfigSR.Visible:=true ; // digikeijs 6 : begin @@ -7318,11 +7776,11 @@ begin editSpecUni.Hint:='Paramètre de description supplémentaire du décodeur Unisemaf'; editSpecUni.ShowHint:=true; end; - 9 : begin + 9 : begin s:='Décodeur pour signaux belges SNCB - 4 aspects uniquement: '; labelInfo.Caption:=s+'vert - rouge - double jaune - rouge blanc'; end; - 10 : begin + 10 : begin s:='Décodeur pour signaux belges SNCB - 6 aspects + chiffre + V '; labelInfo.Caption:=s; labelUni.Caption:='Nombre d''adresses';LabelUni.Visible:=true; @@ -7334,9 +7792,9 @@ begin else labelInfo.Caption:=''; end; - if (decodeur<>6) and (decodeur<>10) then + if (decodeur<>4) and (decodeur<>6) and (decodeur<>10) then begin EditSpecUni.Visible:=false;LabelUni.Visible:=false;end; - + if decodeur<>4 then RadioGroupLEB.Visible:=false; // plus tard !! if decodeur>=11 then ButtonConfigSR.Visible:=true; @@ -7389,7 +7847,7 @@ begin CheckBoxversContrevoie.Hint:=s; CheckBoxFB.caption:='Avec demande Blanc rouge'; checkVerrouCarre.Caption:='verrouillable au rouge'; - checkVerrouCarre.Hint:='Positionne le feu au rouge si aucun train n''est présent 3 cantons avant le signal'; + checkVerrouCarre.Hint:='Positionne le signal au rouge si aucun train n''est présent 3 cantons avant le signal'; checkFVC.visible:=false; checkFRC.visible:=false; end @@ -7399,7 +7857,7 @@ begin CheckBoxContrevoie.Visible:=false; CheckBoxFB.caption:='Avec demande feu blanc'; checkVerrouCarre.Caption:='verrouillable au carré'; - checkVerrouCarre.Hint:='Positionne le feu au carré si aucun train n''est présent 3 cantons avant le signal'; + checkVerrouCarre.Hint:='Positionne le signal au carré si aucun train n''est présent 3 cantons avant le signal'; end; // signal normal @@ -7519,100 +7977,7 @@ end; clicListe:=false; end; -procedure raz_champs_pn; -begin - with formconfig do - begin - editAdrFerme.Text:='';EditCdeFerme.text:=''; - editAdrOuvre.Text:='';EditCdeOuvre.text:=''; - editV1F.Text:='';editV1O.Text:=''; - editV2F.Text:='';editV2O.Text:=''; - editV3F.Text:='';editV3O.Text:=''; - editV4F.Text:='';editV4O.Text:=''; - editV5F.Text:='';editV5O.Text:=''; - EditZdet1V1F.text:='';EditZdet2V1F.text:='';EditZdet1V1O.text:='';EditZdet2V1O.text:=''; - EditZdet1V2F.text:='';EditZdet2V2F.text:='';EditZdet1V2O.text:='';EditZdet2V2O.text:=''; - EditZdet1V3F.text:='';EditZdet2V3F.text:='';EditZdet1V3O.text:='';EditZdet2V3O.text:=''; - EditZdet1V4F.text:='';EditZdet2V4F.text:='';EditZdet1V4O.text:='';EditZdet2V4O.text:=''; - EditZdet1V5F.text:='';EditZdet2V5F.text:='';EditZdet1V5O.text:='';EditZdet2V5O.text:=''; - end; -end; -procedure champs_pn_act; -begin - with formConfig do - begin - comboBoxPNCom.Visible:=false; - EditCdeOuvre.width:=25; - editCdeFerme.Width:=25; - editCdeOuvre.width:=25; - editCdeFerme.top:=80; - editCdeFerme.Left:=168; - editCdeOuvre.Left:=168; - - EditCdeOuvre.Hint:='Commande d''ouverture (0 à 2)'; - EditCdeFerme.Hint:='Commande de fermeture (0 à 2)'; - ButtonTestFerme.Hint:='Test de fermeture (mode CDM ou connecté à l''interface)'; - ButtonTestOuvre.Hint:='Test d''ouverture (mode CDM ou connecté à l''interface)'; - - editCdeOuvre.Visible:=true; - editAdrOuvre.Visible:=true; - EditAdrFerme.Visible:=true; - Label22.visible:=true; - CheckPnPulse.Visible:=true; - Label21.Caption:='Adresse de fermeture'; - ButtonTestFerme.Top:=80; - EditAdrFerme.text:=IntToSTR(Tablo_PN[lignecliqueePN+1].AdresseFerme); - EditAdrOuvre.text:=IntToSTR(Tablo_PN[lignecliqueePN+1].AdresseOuvre); - EditCdeFerme.text:=intToSTR(Tablo_PN[lignecliqueePN+1].CommandeFerme); - EditCdeOuvre.text:=intToSTR(Tablo_PN[lignecliqueePN+1].CommandeOuvre); - - end; -end; - -procedure champs_pn_COMUSBSockets; -begin - with formConfig do - begin - comboBoxPNCom.Visible:=true; - ComboBoxPNCom.Width:=150; - ComboBoxPNCom.Left:=4; - EditAdrFerme.visible:=false; - editAdrOuvre.Visible:=false; - CheckPnPulse.Visible:=false; - EditCdeOuvre.width:=50; - editCdeFerme.width:=50; - editCdeFerme.top:=128; - editCdeFerme.Left:=160; - editCdeOuvre.Left:=160; - ButtonTestFerme.Hint:='Test de fermeture (par interface COM/USB)'; - ButtonTestOuvre.Hint:='Test d''ouverture (par interface COM/USB)'; - editcdeFerme.Hint:='Commande ASCII de fermeture'; - EditCdeOuvre.Hint:='Commande ASCII d''ouverture'; - Label22.visible:=false; - ButtonTestFerme.Top:=128; - Label21.Caption:='Périphérique COM/USB/Socket Commandes'; - EditCdeFerme.Text:=Tablo_PN[lignecliqueePN+1].CommandeF; - EditCdeOuvre.Text:=Tablo_PN[lignecliqueePN+1].CommandeO; - ComboBoxPnCom.ItemIndex:=Tablo_PN[lignecliqueePN+1].AdresseFerme-1; - - end; -end; - -procedure raz_champs_aig; -begin - with formConfig do - begin - LabelInfo.caption:=''; - EditAdrAig.Text:=''; - EditAigTriple.Text:=''; - Edit_HG.text:=''; - editDevie_HD.Text:=''; - editDroit_BD.Text:=''; - editPointe_BG.Text:=''; - EditTempo10.text:=''; - end; -end; procedure raz_champs_sig; begin @@ -8256,6 +8621,11 @@ begin Maj_Hint_Signal(i); case decodeur of + 4 : begin + labelUni.Caption:='Cible LEB';LabelUni.Visible:=true; + EditSpecUni.Visible:=true; + RadioGroupLEB.Visible:=true; + end; 6 : begin labelUni.Caption:='Spec Unisemaf';LabelUni.Visible:=true; EditSpecUni.Visible:=true; @@ -8668,7 +9038,7 @@ begin s:=encode_signal(index); ListBoxSig.Items[ligneClicSig]:=s; - aff_champs_signaux(index); // redessine les champs et le feu + aff_champs_signaux(index); // redessine les champs et le signal if not(verif_dec_sig(false)) then labelInfo.Caption:='Combinaison décodeur / aspect incompatible'; @@ -8715,6 +9085,14 @@ begin Val(s,Adr,erreur); // Adresse signal // vérification code unisemaf decodeur:=Signaux[ligneClicSig+1].decodeur; + if decodeur=4 then // LEB + begin + erreur:=verif_LEB(Adr,i); + if erreur=1 then begin LabelInfo.caption:='Erreur code cible LEB';exit;end; + if erreur=2 then begin LabelInfo.caption:='Erreur cohérence aspect signal';exit;end; + LabelInfo.caption:=' '; + Signaux[ligneClicSig+1].Unisemaf:=i; + end; if decodeur=6 then begin erreur:=verif_unisemaf(Adr,i); @@ -8851,7 +9229,7 @@ var s: string; i : integer; begin if affevt then affiche('Evt bouton nouveau acc',clyellow); - if maxtablo_act>=Max_actionneurs then + if maxtablo_act>=Max_action then begin Affiche('Nombre maximal d''actionneurs atteint',clred); exit; @@ -8865,16 +9243,16 @@ begin // désactiver la ligne PN lignecliqueePN:=-1; - Tablo_actionneur[maxtablo_act].NomAction:='ACTION'+intToSTR(maxtablo_act); + Tablo_Action[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; + SetLength(Tablo_Action[maxtablo_act].TabloOp,2); + SetLength(Tablo_Action[maxtablo_act].TabloCond,2); + Tablo_Action[maxtablo_act].NbCond:=1; + Tablo_Action[maxtablo_act].NbOperations:=0; + Tablo_Action[maxtablo_act].TabloCond[1].numcondition:=CondVrai; + Tablo_Action[maxtablo_act].TabloOP[1].numoperation:=0; + s:=encode_actions(MaxTablo_act); with formconfig.listBoxActions do begin @@ -8916,12 +9294,12 @@ begin lignecliqueePN:=-1; formconfig.radioButtonLoc.Checked:=true; - Tablo_actionneur[maxtablo_act].act:=false; - Tablo_actionneur[maxtablo_act].loco:=true; + Tablo_Action[maxtablo_act].act:=false; + Tablo_Action[maxtablo_act].loco:=true; - SetLength(Tablo_actionneur[maxtablo_act].TabloOp,2); + SetLength(Tablo_Action[maxtablo_act].TabloOp,2); - Tablo_actionneur[maxtablo_act].NbOperations:=1; + Tablo_Action[maxtablo_act].NbOperations:=1; // ajouter et scroller en fin s:=encode_act_loc_son(MaxTablo_act); @@ -9095,7 +9473,7 @@ var s: string; i,j : integer; begin if affevt then affiche('Evt bouton nouveau PN',clyellow); - if maxtablo_act>=Max_actionneurs then + if maxtablo_act>=Max_action then begin Affiche('Nombre maximal d''actionneurs atteint',clred); exit; @@ -9173,7 +9551,7 @@ begin begin if formconfig.ListBoxActions.selected[i] then begin - ss:=ss+Tablo_actionneur[i+1].NomAction+' '; + ss:=ss+Tablo_Action[i+1].NomAction+' '; inc(n); end; end; @@ -9197,7 +9575,7 @@ begin for j:=i to maxTablo_act-1 do begin formconfig.ListBoxActions.selected[j-1]:=formconfig.ListBoxActions.selected[j]; - tablo_actionneur[j]:=tablo_actionneur[j+1]; + Tablo_Action[j]:=Tablo_Action[j+1]; end; dec(maxTablo_act); i:=0; @@ -9422,7 +9800,7 @@ begin formconfig.ListBoxSig.Items.Delete(i-1); - Signaux[i].Img.free; // supprime l'image, ce qui efface le feu du tableau graphique + Signaux[i].Img.free; // supprime l'image, ce qui efface le signal du tableau graphique Signaux[i].Lbl.free; // supprime le label Tablo_Index_Signal[Signaux[i].adresse]:=0; if Signaux[i].checkFB<>nil then @@ -9497,7 +9875,7 @@ begin Supprime_sig; end; -// Ajouter le feu supprimé +// Ajouter le signal supprimé procedure TFormConfig.ButtonInsFeuClick(Sender: TObject); var s : string; begin @@ -9507,7 +9885,7 @@ begin inc(NbreSignaux); Signaux[NbreSignaux]:=Signal_supprime; Tablo_Index_Signal[Signaux[NbreSignaux].adresse]:=NbreSignaux; // index - Signal_supprime.adresse:=0; // dévalider le feu sauvegardé + Signal_supprime.adresse:=0; // dévalider le signal sauvegardé Signal_supprime.aspect:=0; cree_image(NbreSignaux); config_modifie:=true; @@ -9517,7 +9895,7 @@ begin begin with ListBoxSig.Items do begin - ButtonInsFeu.Caption:='Ajouter le feu supprimé'; + ButtonInsFeu.Caption:='Ajouter le signal supprimé'; Add(s); ligneClicSig:=NbreSignaux-1; AncligneClicSig:=-1; @@ -9580,7 +9958,7 @@ begin if dec=1 then nc:=14; // digitalbahn if dec=2 then nc:=signaux[i].Na; // cdf if dec=3 then nc:=8; // ldt LS dec sncf - if dec=4 then nc:=5; // leb + if dec=4 then nc:=8; // leb if dec=5 then nc:=Signaux[i].Na; // digikeijs if dec=6 then // paco unisemaf begin @@ -9628,11 +10006,16 @@ begin 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; - + if trains[j].Adresse=adr then + begin + Affiche('Les trains '+intToSTR(i)+' et '+intToSTR(j)+' ont la même adresse : '+intToSTR(adr),clred); + result:=false; + end; + if trains[j].nom_train=nom then + begin + Affiche('Les trains '+intToSTR(i)+' et '+intToSTR(j)+' ont le même nom : '+nom,clred); + result:=false; + end; end; end; end; @@ -9640,11 +10023,12 @@ end; function verif_coherence : boolean; var AncAdr,i,j,k,l,Indexaig,adr,adr2,extr,detect,condcarre,nc,index2,SuivAdr,indexTCO,AdrAig, - x,y,extr2,adr3,index3,det1Br,det2Br,det1index,det2index,adresse,Adresse2,dec,nc2,op : integer; - modAig,AncModel,model,km,SuivModel,model2: TEquipement; + x,y,extr2,adr3,index3,det1Br,det2Br,det1index,det2index,adresse,Adresse2,dec,nc2,op, + delta : integer; + modAig,AncModel,model,km,SuivModel,model2,t1,t2: TEquipement; c : char; vitesse : longint; - OkSignal,ok,trouveSuiv,TrouvePrec,AdrOk : boolean; + sort,OkSignal,ok,trouveSuiv,TrouvePrec,AdrOk : boolean; s : string; begin // validation des index signaux et détecteurs @@ -9695,6 +10079,7 @@ begin // vérification de la cohérence2 // parcoure les aiguillages pour voir si les détecteurs sont en branches des détecteurs + // et s'ils sont dans les branches // et les tjd pour voir si pb de cohérence for Indexaig:=1 to maxaiguillage do begin @@ -9716,16 +10101,18 @@ begin end; end; - // vérifier si l'aiguillage est dans les branches inutile - {if aiguillage[Indexaig].modele<>rien then + // vérifier si l'aiguillage est dans les branches + { non c'est autorisé! + if aiguillage[Indexaig].modele<>rien then begin trouve_aiguillage(aiguillage[Indexaig].adresse); // passe l'adresse de l'aiguillage à trouver if (IndexBranche_trouve=0) then begin - Affiche('Avertissement 6: aiguillage '+intToSTR(aiguillage[Indexaig].adresse)+' décrit dans les aiguillages ; absent dans la description des branches',clOrange); + Affiche('Erreur 6: aiguillage '+intToSTR(aiguillage[Indexaig].adresse)+' décrit dans les aiguillages ; absent dans la description des branches',clRed); ok:=false; end; - end;} + end; + } // exclure les TJD/S if (modAig<>tjd) and (modAig<>tjs) then @@ -9743,10 +10130,16 @@ begin else begin AdrAig:=aiguillage[IndexAig].Adresse; - if indexBranche_Trouve>1 then det1br:=brancheN[branche_trouve,indexBranche_trouve-1].Adresse // adresse avant détecteur + if indexBranche_Trouve>1 then + begin + det1br:=brancheN[branche_trouve,indexBranche_trouve-1].Adresse; // adresse avant détecteur + t1:=brancheN[branche_trouve,indexBranche_trouve-1].BType; + end else det1br:=0; det2br:=brancheN[branche_trouve,indexBranche_trouve+1].Adresse; // adresse après détecteur - if (det1br<>AdrAig) and (det2br<>AdrAig) and (adr<>0) then + t2:=brancheN[branche_trouve,indexBranche_trouve+1].Btype; + + if (det1br<>AdrAig) and (t1=det) and (det2br<>AdrAig) and (t2=det) and (adr<>0) then begin Affiche('Erreur 21.2: Le détecteur '+intToSTR(adr)+' est décrit dans l''aiguillage '+intToSTR(aiguillage[Indexaig].adresse)+' mais déclaré dans la ',clred); s:='branche '+intToSTR(Branche_trouve)+' entre'; @@ -9775,9 +10168,19 @@ begin else begin AdrAig:=aiguillage[IndexAig].Adresse; - if indexBranche_trouve>1 then det1br:=brancheN[branche_trouve,indexBranche_trouve-1].Adresse // adresse avant détecteur + delta:=0; + repeat + inc(delta); + until (brancheN[branche_trouve,indexBranche_trouve-delta].BType<>act) or (indexBranche_trouve-delta=0); // pour passer un actionneur éventuel + if indexBranche_trouve-delta>0 then det1br:=brancheN[branche_trouve,indexBranche_trouve-delta].Adresse // adresse avant détecteur else det1br:=0; - det2br:=brancheN[branche_trouve,indexBranche_trouve+1].Adresse; // adresse après détecteur + + delta:=0; + repeat + inc(delta); + until (brancheN[branche_trouve,indexBranche_trouve+delta].BType<>act); // pour passer un actionneur éventuel + det2br:=brancheN[branche_trouve,indexBranche_trouve+delta].Adresse; // adresse après détecteur + if (det1br<>AdrAig) and (det2br<>AdrAig) and (adr<>0) then begin Affiche('Erreur 22.2: Le détecteur '+intToSTR(adr)+' est décrit dans l''aiguillage '+intToSTR(aiguillage[Indexaig].adresse)+' mais déclaré dans la ',clred); @@ -10018,7 +10421,17 @@ begin trouve_detecteur(l); det2Br:=branche_trouve; det2Index:=IndexBranche_trouve; - if (det1Br<>Det2Br) or (abs(det1Index-det2Index)>1) then + + if det1Index>det2Index then echange(det1Index,det2Index); + delta:=1; + k:=1; + repeat + t1:=brancheN[det1Br,det1Index+k].BType; + if t1<>act then inc(delta); + inc(k); + until t1<>act; + + if (det1Br<>Det2Br) or (abs(det1Index-det2Index)>delta) then begin ok:=false; Affiche('Erreur 9.12: signal '+intToSTR(Signaux[j].adresse)+' : détecteurs '+intToSTR(i)+' et '+intToSTR(l)+' non contigüs ',clred); @@ -10179,17 +10592,29 @@ begin if c='D' then begin extr:=aiguillage[index2].ADroit; - if adr<>extr then Affiche('Erreur 10.23: Discordance de déclaration aiguillages '+intToSTR(adr)+'D: '+intToSTR(adr2)+'D différent de '+intToSTR(extr),clred); + if adr<>extr then + begin + Affiche('Erreur 10.23: Discordance de déclaration aiguillages '+intToSTR(adr)+'D: '+intToSTR(adr2)+'D différent de '+intToSTR(extr),clred); + ok:=false; + end; end; if c='S' then begin extr:=aiguillage[index2].ADevie; - if adr<>extr then Affiche('Erreur 10.24: Discordance de déclaration aiguillages '+intToSTR(adr)+'D: '+intToSTR(adr2)+'S différent de '+intToSTR(extr),clred); + if adr<>extr then + begin + Affiche('Erreur 10.24: Discordance de déclaration aiguillages '+intToSTR(adr)+'D: '+intToSTR(adr2)+'S différent de '+intToSTR(extr),clred); + ok:=false; + end; end; if c='P' then begin extr:=aiguillage[index2].APointe; - if adr<>extr then Affiche('Erreur 10.25: Discordance de déclaration aiguillages '+intToSTR(adr)+'D: '+intToSTR(adr2)+'P différent de '+intToSTR(extr),clred); + if adr<>extr then + begin + Affiche('Erreur 10.25: Discordance de déclaration aiguillages '+intToSTR(adr)+'D: '+intToSTR(adr2)+'P différent de '+intToSTR(extr),clred); + ok:=false; + end; end; end; end; @@ -10311,6 +10736,8 @@ begin // cohérence 8 // parcoure les branches pour voir si les aiguillages aux extrémités sont cohérentes avec leurs déclarations + // problème : un aiguillage peut être a plusieurs endroits dans les branches + { for i:=1 to NbreBranches do begin j:=1; // on vérifie entre j-1 et j+1 @@ -10321,7 +10748,7 @@ begin detect:=BrancheN[i][j].Adresse; SuivAdr:=BrancheN[i][j+1].Adresse; SuivModel:=BrancheN[i][j+1].Btype; - model:=BrancheN[i][j].BType; // 1= détecteur 2= aiguillage 4=Buttoir + model:=BrancheN[i][j].BType; trouvePrec:=false; if (model=aig) then @@ -10331,7 +10758,7 @@ begin if k<>0 then begin if j=1 then trouvePrec:=true; - if (j>1) then + if (j>1) and (ancModel<>act) then begin if aiguillage[k].modele=Aig then begin @@ -10382,7 +10809,7 @@ begin TrouveSuiv:=false; // comparer au suivant - if SuivModel<>rien then + if (SuivModel<>rien) and (SuivModel<>act) then begin if aiguillage[k].modele=Aig then begin @@ -10430,14 +10857,42 @@ begin Affiche('Erreur 12: La description de l''aiguillage '+intToSTR(detect)+' ne correspond pas à son élément contigu ('+intToStr(SuivAdr)+') en branche '+intToSTR(i),clred); ok:=false; end; - end; + end; end; end; inc(j); until((model=rien) and (detect=0)) ; end; + } - // 9. vérifier la cohérence TCO + // 9. vérifier les détecteurs s'ils apparaissent plusieurs fois + for i:=1 to NDetecteurs do + begin + l:=0; // compteur détecteur + for j:=1 to NbreBranches do + begin + detect:=Adresse_detecteur[i]; + + k:=1; + repeat + sort:=false; + adr:=BrancheN[j,k].Adresse; + Model:=BrancheN[j,k].BType; + if ((adr=0) and (model=rien)) then sort:=true; + inc(k); + sort:=sort or ((adr=detect) and (model=det)); + until (sort); + + if adr=detect then inc(l); + end; + if l>1 then + begin + Affiche('Erreur 13: Le détecteur '+intToSTR(detect)+' apparaît '+intToSTR(l)+' fois dans les branches',clred); + ok:=false; + end; + end; + + // 10. vérifier la cohérence TCO for indexTCO:=1 to NbreTCO do begin begin @@ -10562,11 +11017,11 @@ begin // actions for i:=1 to maxTablo_act do begin - for op:=1 to tablo_actionneur[i].NbOperations do + for op:=1 to Tablo_Action[i].NbOperations do begin - if Tablo_actionneur[i].tabloOp[op].numoperation=ActionAccessoire then + if Tablo_Action[i].tabloOp[op].numoperation=ActionAccessoire then begin - adresse:=Tablo_actionneur[i].tabloOp[op].adresse; + adresse:=Tablo_Action[i].tabloOp[op].adresse; for k:=1 to NDetecteurs do begin adr:=((adresse_detecteur[k]-1) div 2) +1; // transforme l'adresse du détecteur en accessoire (ex 513 devient 257) @@ -10575,19 +11030,19 @@ begin begin AdrOk:=false; ok:=false; - Affiche('Erreur 15: l''action '+IntToSTR(Tablo_actionneur[i].adresse)+' enclenche l''accessoire '+intToSTR(adresse),clred); + Affiche('Erreur 15: l''action '+IntToSTR(Tablo_Action[i].adresse)+' enclenche l''accessoire '+intToSTR(adresse),clred); Affiche('et chevauche le détecteur '+intToStr(adresse_detecteur[k])+' interdit en XpressNet',clred); end; end; - if Tablo_actionneur[i].tabloop[op].NumOperation=ActionCdePeriph then + if Tablo_Action[i].tabloop[op].NumOperation=ActionCdePeriph then begin - j:=Tablo_actionneur[i].tabloOp[op].periph; - if j>10 then begin Affiche('Erreur 15.1 pilotage action '+intToSTR(Tablo_actionneur[i].adresse),clred);ok:=false;end; - if j=0 then begin Affiche('Erreur 15.2 L''action '+intToSTR(Tablo_actionneur[i].adresse)+' n''a pas d''accessoire COM/USB d''affecté',clRed);ok:=false;end; + j:=Tablo_Action[i].tabloOp[op].periph; + if j>10 then begin Affiche('Erreur 15.1 pilotage action '+intToSTR(Tablo_Action[i].adresse),clred);ok:=false;end; + if j=0 then begin Affiche('Erreur 15.2 L''action '+intToSTR(Tablo_Action[i].adresse)+' n''a pas d''accessoire COM/USB d''affecté',clRed);ok:=false;end; if (j>0) and (j<11) and (Tablo_periph[j].NumCom=0) then begin - Affiche('Erreur 15.3 L''action '+intToSTR(Tablo_actionneur[i].adresse)+' n''a pas d''accessoire COM/USB d''affecté',clRed); + Affiche('Erreur 15.3 L''action '+intToSTR(Tablo_Action[i].adresse)+' n''a pas d''accessoire COM/USB d''affecté',clRed); ok:=false; end; end; @@ -10611,29 +11066,29 @@ begin // actionneurs for i:=1 to maxTablo_act do begin - for op:=1 to tablo_actionneur[i].NbOperations do + for op:=1 to Tablo_Action[i].NbOperations do begin - if tablo_actionneur[i].TabloOp[op].numoperation=ActionCdePeriph then + if Tablo_Action[i].TabloOp[op].numoperation=ActionCdePeriph then begin - adresse:=tablo_actionneur[i].TabloOp[op].periph; + adresse:=Tablo_Action[i].TabloOp[op].periph; if adresse>NbPeriph then begin - Affiche('Erreur 18 : l''action '+intToSTR(tablo_actionneur[i].adresse)+' est liée à un périphérique n°'+intToSTR(adresse)+' COM/USB/Socket inexistant',clred); + Affiche('Erreur 18 : l''action '+intToSTR(Tablo_Action[i].adresse)+' est liée à un périphérique n°'+intToSTR(adresse)+' COM/USB/Socket inexistant',clred); ok:=false; end; end; end; - if Tablo_actionneur[i].declencheur=DeclZoneDet then // si actionneur de zone + if Tablo_Action[i].declencheur=DeclZoneDet then // si actionneur de zone begin - adresse:=Tablo_actionneur[i].Adresse; - adresse2:=Tablo_actionneur[i].Adresse2; + adresse:=Tablo_Action[i].Adresse; + adresse2:=Tablo_Action[i].Adresse2; //Affiche('Det_contigu '+intToSTR(adresse)+' '+intToSTR(adresse2),clred); det_contigu(adresse,adresse2,suivant,SuivModel); if (suivant=0) or (suivant>9995) then begin ok:=false; - s:='Erreur 19: l''action '+IntToSTR(Tablo_actionneur[i].adresse)+' est enclenchée par les détecteurs '+intToSTR(adresse)+' ' +intToSTR(adresse2)+' qui ne sont pas contigus'; + s:='Erreur 19: l''action '+IntToSTR(Tablo_Action[i].adresse)+' est enclenchée par les détecteurs '+intToSTR(adresse)+' ' +intToSTR(adresse2)+' qui ne sont pas contigus'; Affiche(s,clred); end; end; @@ -10737,7 +11192,6 @@ begin aiguillage[i].position:=const_inconnu; aiguillage[i].InversionCDM:=0; aiguillage[i].vitesse:=0; - aiguillage[i].IndexBranche:=0; // encoder l'index tablo_index_aiguillage[aiguillage[i].Adresse]:=i; @@ -10759,8 +11213,6 @@ begin clicliste:=false; config_modifie:=true; Aig_sauve.Adresse:=0; - - end; procedure TFormConfig.ButtonNouvAigClick(Sender: TObject); @@ -11466,6 +11918,7 @@ begin begin c:=enregistrement[1]; delete(enregistrement,1,1); + if c='A' then begin Val(enregistrement,adresse,erreur2); @@ -11482,22 +11935,43 @@ begin end; BrancheN[i,j].adresse:=adresse; BrancheN[i,j].btype:=aig; // ident aiguillage - aiguillage[index_aig(adresse)].NumBranche:=i; // aiguillage[] est indexé par un index - aiguillage[index_aig(adresse)].IndexBranche:=j; end else + + if c='T' then begin - Affiche('Erreur 19 champ '+se+' ligne '+s,clred); + Val(enregistrement,adresse,erreur2); + if (adresse=0) or (erreur2<>0) then + begin + Affiche('Erreur 19 champ '+se+' ligne '+s,clred); + code:=false; + end; + if adresse>max_actionneurs then + begin + Affiche('Erreur 20 ligne '+s+' : adresse actionneur trop grand: '+intToSTR(adresse),clred); + adresse:=NbMaxDet; + code:=false; + end; + BrancheN[i,j].adresse:=adresse; + BrancheN[i,j].btype:=act; // ident actionneur + actionneur[adresse].NumBranche:=i; + actionneur[adresse].IndexBranche:=j; + end + else + + begin + Affiche('Erreur 21 champ '+se+' ligne '+s,clred); code:=false; erreur:=0; // forcer erreur à 0 pour obliger à passer sur un détecteur end; end; + // détecteur if erreur=0 then begin if (detect>NbMaxDet) and (detect<10000) then begin - Affiche('Erreur 20 ligne '+s+' : adresse détecteur trop grand: '+intToSTR(detect),clred); + Affiche('Erreur 22 ligne '+s+' : adresse détecteur trop grand: '+intToSTR(detect),clred); detect:=NbMaxDet; code:=false; end; @@ -11505,12 +11979,13 @@ begin BrancheN[i,j].btype:=det; // ident détecteur detecteur[detect].NumBranche:=i; // detecteur[] est indexé par le détecteur detecteur[detect].IndexBranche:=j; + detecteur[detect].canton1:=0; + detecteur[detect].canton2:=0; - if (detect=0) or (detect>10000) then + if (detect=0) 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é @@ -12208,11 +12683,12 @@ begin end; // affiche l'icone du train index dans le canvas -procedure Maj_icone_train(Icanvas : Tcanvas;index :integer); +// Icanvas: canvas de destination ; index: index du train +procedure Maj_icone_train(IImage : Timage;index :integer); var h,l,HautDest,LargDest,y : integer; rd : double; begin - with formConfig do + if (index<1) or (index>Ntrains) then exit; begin // source l:=Trains[index].Icone.width; @@ -12222,19 +12698,20 @@ begin //Affiche(FloatToSTR(rd),clred); // destination : la hauteur est fixée - HautDest:=round(ImageTrain.Height); + HautDest:=round(iImage.Height); LargDest:=round(Hautdest*rd); // si la largeur > que l'image, on fixe la largeur - if LargDest>ImageTrain.Width then + if LargDest>iImage.Width then begin - LargDest:=ImageTrain.Width; + LargDest:=iImage.Width; HautDest:=round(LargDest/rd); end; - y:=ImageTrain.Height-HautDest; + y:=iImage.Height-HautDest; - TransparentBlt(Icanvas.Handle,0,y,largDest,hautDest, + Iimage.Canvas.Rectangle(0,0,Iimage.Width,Iimage.Height); + TransparentBlt(Iimage.canvas.Handle,0,y,largDest,hautDest, Trains[index].Icone.canvas.Handle,0,0,l,h,clWhite); end; @@ -12243,7 +12720,6 @@ end; procedure clicListeTrains(index : integer); var s : string; - begin if index<1 then exit; if Trains[index].nom_train='' then exit; @@ -12259,9 +12735,10 @@ begin s:=trains[index].NomIcone; editIcone.Text:=s; + // Efface l'icone de train ImageTrain.Canvas.Rectangle(0,0,ImageTrain.Width,ImageTrain.Height); - - if s<>'' then Maj_icone_train(formconfig.ImageTrain.Canvas,index); + + if s<>'' then Maj_icone_train(formconfig.ImageTrain,index); end; end; @@ -12659,10 +13136,10 @@ begin ListBoxSig.selected[ligneClicSig]:=true; Signaux[ligneClicSig+1].modifie:=true; - aff_champs_signaux(ligneClicSig+1); // redessine les champs et le feu - contient l'inversion de l'image + aff_champs_signaux(ligneClicSig+1); // redessine les champs et le signal - contient l'inversion de l'image // maj le signal dans la fenetre principale - Signaux[ligneClicSig+1].Img.picture.Bitmap:=ImageSIgnal.Picture.Bitmap; // et recopie le feu + Signaux[ligneClicSig+1].Img.picture.Bitmap:=ImageSIgnal.Picture.Bitmap; // et recopie le signal adr:=Signaux[ligneClicSig+1].adresse; if Signaux[ligneClicSig+1].contrevoie then Maj_Etat_Signal(adr,clignote_f or bita1_F) else Maj_Etat_Signal(adr,clignote_F); dessine_signal_mx(Signaux[ligneClicSig+1].Img.Canvas,0,0,1,1,Signaux[ligneClicSig+1].adresse,1); // dessine les feux du signal @@ -12881,6 +13358,75 @@ begin end; end; + +procedure TformConfig.modif_Labeled(Sender : Tobject); +var te : tLabeledEdit; + s,sb : string; + i,r,erreur : integer; +begin + // actionneurs + if clicListe then exit; + + te:=Sender as TLabelededit; + s:=lowercase(te.Name); + sb:=te.Text; + + if pos('prox',s)<>0 then + begin + val(sb,i,erreur); + if (erreur<>0) or (i<1) then + begin + labelInfo.caption:='Erreur'; + exit; + end; + labelInfo.caption:=''; + r:=extract_int(s); + case r of + 1 : actionneur[ligneclicActionneur+1].prox1:=i; + 2 : actionneur[ligneclicActionneur+1].prox2:=i; + end; + s:=encode_actionneur(ligneclicActionneur+1); + formconfig.ListBoxActionneurs.items[ligneclicActionneur]:=s; + formconfig.ListBoxActionneurs.selected[ligneclicActionneur]:=true; + + exit; + end; + + if pos('leadrdet',s)<>0 then + begin + val(sb,i,erreur); + if (erreur<>0) or (i<1) then + begin + labelInfo.caption:='Erreur'; + exit; + end; + labelInfo.caption:=''; + Adresse_detecteur[ligneclicDet+1]:=i; + s:=encode_detecteur(ligneclicDet+1); + formconfig.ListBoxDet.items[ligneclicDet]:=s; + formconfig.ListBoxDet.selected[ligneclicDet]:=true; + exit; + end; + + if pos('lelongdet',s)<>0 then + begin + val(sb,i,erreur); + if (erreur<>0) or (i<1) then + begin + labelInfo.caption:='Erreur'; + exit; + end; + labelInfo.caption:=''; + r:=adresse_detecteur[ligneclicDet+1]; + detecteur[r].longueur:=i; + s:=encode_detecteur(ligneclicDet+1); + formconfig.ListBoxDet.items[ligneclicDet]:=s; + formconfig.ListBoxDet.selected[ligneclicDet]:=true; + exit; + end; +end; + + // changement combobox choix sorties 1 ou 2 procedure Tformconfig.modif_ComboTS(Sender : TObject); var co : tComboBox; @@ -13104,7 +13650,8 @@ begin // et supprimer la base for i:=ma to NbreDecPers-1 do begin - decodeur_pers[i]:=decodeur_pers[i+1]; + Affiche('traitement décodeur '+inttoSTR(i),clyellow); + decodeur_pers[i]:=decodeur_pers[i+1]; end; dec(NbreDecPers); if NbreDecPers=0 then ComboBoxDecodeurPerso.Text:=''; @@ -13632,8 +14179,6 @@ begin end; - - procedure TFormConfig.ButtonSupAccComClick(Sender: TObject); begin supprime_periph; @@ -13690,8 +14235,7 @@ begin end; clicListe:=false; - -end; + end; procedure TFormConfig.RadioButtonSimpleClick(Sender: TObject); begin @@ -13732,8 +14276,7 @@ var s : string; end; s:=encode_act_PN(lignecliqueePN+1); ListBoxPN.items[lignecliqueePN]:=s; - - end; + end; end; procedure TFormConfig.ComboBoxPNComChange(Sender: TObject); @@ -13802,7 +14345,6 @@ procedure TFormConfig.ButtonChercheClick(Sender: TObject); LigneCherche:=0; end; end; - end; procedure TFormConfig.EditChercherChange(Sender: TObject); @@ -13928,13 +14470,8 @@ begin end; -procedure TFormConfig.CheckBoxResaClick(Sender: TObject); - begin - avecResa:=CheckBoxResa.Checked; -end; - - -procedure TFormConfig.EditPortServeurExit(Sender: TObject); + + procedure TFormConfig.EditPortServeurExit(Sender: TObject); var i,erreur : integer; begin Val(EditPortServeur.Text,i,erreur); @@ -13993,8 +14530,7 @@ procedure TFormConfig.EditP2Exit(Sender: TObject); adresse_P2; end; - - procedure TFormConfig.ButtonCouleurClick(Sender: TObject); +procedure TFormConfig.ButtonCouleurClick(Sender: TObject); begin if colorDialogFond.execute then begin @@ -14354,7 +14890,6 @@ begin editdebug.Text:=IntToSTR(debug); CheckBoxVerifXpressNet.Checked:=Verif_AdrXpressNet=1; editPortServeur.Text:=intToSTR(portServeur); - checkRoulage.Checked:=AvecRoulage=1; EditTempoOctetUSB.text:=IntToSTR(TempoOctet); EditTempoReponse.Text:=IntToSTR(TimoutMaxInterface); RadioButton1.checked:=false; @@ -14364,7 +14899,6 @@ begin LabelInfo.Width:=240;LabelInfo.Height:=65;LabelInfo.AutoSize:=false; LabelResult.width:=137;LabelResult.Height:=25; - CheckBoxResa.Checked:=AvecResa; CheckVerifVersion.Checked:=verifVersion; CheckFenEt.Checked:=Fenetre=1; CheckInfoVersion.Checked:=notificationVersion; @@ -14402,6 +14936,9 @@ begin CheckPosAig.checked:=AvecDemandeAiguillages; CheckBoxDemarUSB.checked:=AvecDemandeInterfaceUSB; CheckBoxDemarEth.checked:=AvecDemandeInterfaceEth; + cbAffSig.Checked:=AffSig; + cbRes.Checked:=affRes; + cbAck.Checked:=avecAck; CheckBoxSombre.Checked:=sombre; RadioButtonXpress.Checked:=protocole=1; @@ -14433,21 +14970,19 @@ begin end; ListBoxAig.itemindex:=0; - RadioReserve.ItemIndex:=mode_Reserve; if serveurIPCDM_Touche then RadioServeurCDM.ItemIndex:=0 else RadioServeurCDM.ItemIndex:=1; editAlgo.Text:=intToSTR(Algo_localisation); EditMaxSignalSens.Text:=intToSTR(Max_Signal_Sens); + EditChemin.text:=cheminProgrammes; + // trains with ListBoxTrains do begin clear; for i:=1 to ntrains do items.Add(Train_tablo(i)); end; - end; - - procedure TFormConfig.ButtonModActionClick(Sender: TObject); begin @@ -14464,11 +14999,11 @@ begin with FormConfig.ListBoxOperations do begin clear; - for i:=1 to Tablo_Actionneur[ligneclicAct+1].NbOperations do + for i:=1 to Tablo_Action[ligneclicAct+1].NbOperations do begin - j:=Tablo_Actionneur[ligneclicAct+1].tabloOp[i].numoperation; + j:=Tablo_Action[ligneclicAct+1].tabloOp[i].numoperation; s:=operations[j].nom; - if not(Tablo_Actionneur[ligneclicact+1].tabloOp[i].valide) then s:=s+' [dévalidé]'; + if not(Tablo_Action[ligneclicact+1].tabloOp[i].valide) then s:=s+' [dévalidé]'; if j<1 then items.Add(Format('%d%s', [0, 'aucune opération'])) @@ -14479,7 +15014,7 @@ begin end; formConfig.RichEditInfo.clear; - decl:=Tablo_Actionneur[ligneclicAct+1].declencheur; + decl:=Tablo_Action[ligneclicAct+1].declencheur; if decl>Nbredeclencheurs then begin clicListe:=false; @@ -14594,23 +15129,21 @@ begin begin ListBoxActions.SelectAll; end; - clicListe:=false; - -end; +end; procedure TFormConfig.ListBoxOperationsDblClick(Sender: TObject); var s : string; op,icone : integer; begin if (clicAction<0) or (ligneclicAct<0) or clicliste then exit; - Tablo_Actionneur[ligneclicAct+1].tabloOp[clicaction+1].valide:=not(Tablo_Actionneur[ligneclicAct+1].tabloOp[clicaction+1].valide); + Tablo_Action[ligneclicAct+1].tabloOp[clicaction+1].valide:=not(Tablo_Action[ligneclicAct+1].tabloOp[clicaction+1].valide); - op:=Tablo_Actionneur[ligneclicact+1].tabloOp[clicaction+1].numoperation; + op:=Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].numoperation; if op<1 then icone:=0 else icone:=op-1; s:=operations[op].nom; - if not(Tablo_Actionneur[ligneclicact+1].tabloOp[clicaction+1].valide) then s:=s+' [dévalidé]'; + if not(Tablo_Action[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; @@ -14635,17 +15168,31 @@ end; 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); + //ImageTrain.Canvas.Rectangle(0,0,ImageTrain.Width,ImageTrain.Height); + Maj_icone_train(formconfig.ImageTrain,i); + formconfig.ListBoxTrains.items[ligneclicTrain]:=Train_tablo(ligneclicTrain+1); //formconfig.ImageTrain.Picture.assign(trains[i].icone.Picture); end; chDir(RepIni); end; procedure TFormConfig.EditIconeChange(Sender: TObject); - begin + var s,Nom,repIni : string; + +begin if ligneclicTrain<0 then exit; - trains[ligneclicTrain+1].NomIcone:=EditIcone.Text; + if clicliste then exit; + repIni:=GetCurrentDir; + Nom:=EditIcone.Text; + s:=repIni+'\'+rep_icones+'\'+Nom; + if fileExists(s) then + begin + trains[ligneclicTrain+1].NomIcone:=nom; + // Affiche(s,clWhite); + trains[ligneclicTrain+1].icone.Picture.LoadFromFile(s); + Maj_icone_train(formconfig.ImageTrain,ligneclicTrain+1); + formconfig.ListBoxTrains.items[ligneclicTrain]:=Train_tablo(ligneclicTrain+1); + end; end; procedure TFormConfig.LabeledEditTempoDChange(Sender: TObject); @@ -14673,7 +15220,423 @@ procedure TFormConfig.CheckBoxSensClick(Sender: TObject); end; - + procedure TFormConfig.ButtonImRCDMClick(Sender: TObject); + var nPeriph,ia,i,j,adr : integer; + ctyp : string; +begin + if nSeg=0 then begin LabelInfo.caption:='Pas de structure réseau CDM trouvée';exit;end + else LabelInfo.caption:=''; + + if Nactionneurs<>0 then + begin + j:=MessageDlg('Voulez-vous supprimer les actionneurs existants?' + ,mtConfirmation,[mbNo,mbYes],0) ; + if j=mrNo then exit; + end; + + ia:=1; + for i:=0 to nSeg-1 do + begin + nperiph:=Segment[i].nperiph; + for j:=0 to nPeriph-1 do + begin + ctyp:=Segment[i].periph[j].typ; + if ctyp='actuator' then + begin + adr:=Segment[i].periph[j].adresse; + if adr<>0 then + begin + actionneur[ia].adresse:=adr; + actionneur[ia].prox1:=0; + actionneur[ia].prox2:=0; + inc(ia); + end; + end; + end; + end; + + dec(ia); + Nactionneurs:=ia; + + trier_actionneurs; + + clicListe:=true; + listBoxActionneurs.Clear; + for i:=1 to Nactionneurs do + begin + ListBoxActionneurs.Items.Add(encode_actionneur(i)); + end; + clicListe:=false; +end; + +procedure supprime_detecteur; +var n,i,j : integer; + s,ss : string; +begin + ss:=''; + n:=0; + for i:=0 to nDetecteurs-1 do + begin + if formconfig.ListBoxDet.selected[i] then + begin + ss:=ss+ intToSTR(adresse_detecteur[i+1])+' '; + inc(n); + end; + end; + if ss='' then exit; + + s:='Voulez-vous supprimer '; + if n=1 then s:=s+' le détecteur ' else s:=s+' les détecteurs '; + s:=s+ss+' ?'; + + if Application.MessageBox(pchar(s),pchar('confirm'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then exit; + + clicliste:=true; + + // suppression + n:=0; + i:=1; + repeat + if formconfig.ListBoxDet.selected[i-1] then + begin + Affiche('Supprime le détecteur '+intToSTR(adresse_detecteur[i]),clOrange); + + for j:=i to nDetecteurs-1 do + begin + formconfig.ListBoxDet.selected[j-1]:=formconfig.ListBoxDet.selected[j]; + Adresse_Detecteur[j]:=Adresse_detecteur[j+1]; + end; + dec(nDetecteurs); + i:=0; + end; + inc(i); + until i>nDetecteurs; + + config_modifie:=true; + FormConfig.ListBoxDet.Clear; + + // réafficher la liste + for i:=1 to nDetecteurs do + begin + s:=encode_detecteur(i); + if s<>'' then + begin + FormConfig.ListBoxDet.items.Add(s); + end; + end; + ligneClicDet:=-1; + AncligneClicDet:=-1; + clicliste:=false; +end; + + + +procedure supprime_actionneur; +var n,i,j : integer; + s,ss : string; +begin + ss:=''; + n:=0; + for i:=0 to nActionneurs-1 do + begin + if formconfig.ListBoxActionneurs.selected[i] then + begin + ss:=ss+ intToSTR(actionneur[i+1].adresse)+' '; + inc(n); + end; + end; + if ss='' then exit; + + s:='Voulez-vous supprimer '; + if n=1 then s:=s+' l''actionneur ' else s:=s+' les actionneurs '; + s:=s+ss+' ?'; + + if Application.MessageBox(pchar(s),pchar('confirm'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then exit; + + clicliste:=true; + + // suppression + n:=0; + i:=1; + repeat + if formconfig.ListBoxActionneurs.selected[i-1] then + begin + Affiche('Supprime l''actionneur '+intToSTR(actionneur[i].Adresse),clOrange); + + for j:=i to nActionneurs-1 do + begin + formconfig.ListBoxActionneurs.selected[j-1]:=formconfig.ListBoxActionneurs.selected[j]; + actionneur[j]:=actionneur[j+1]; + end; + dec(nActionneurs); + i:=0; + end; + inc(i); + until i>nActionneurs; + + config_modifie:=true; + FormConfig.ListBoxActionneurs.Clear; + + // réafficher la liste + for i:=1 to nActionneurs do + begin + s:=encode_actionneur(i); + if s<>'' then + begin + FormConfig.ListBoxActionneurs.items.Add(s); + end; + end; + trier_actionneurs; // recalcule les index + ligneClicActionneur:=-1; + AncligneClicActionneur:=-1; + clicliste:=false; +end; + +procedure TFormConfig.ButtonSupActClick(Sender: TObject); + begin + supprime_actionneur; +end; + +procedure aff_champs_Detecteurs(i : integer); +var adr : integer; +begin + inc(i); + with formConfig do + begin + adr:=Adresse_detecteur[i]; + LEAdrDet.text:=intToSTR(adr); + LELongDet.Text:=IntToSTR(detecteur[adr].longueur); + end; +end; + +procedure aff_champs_Actionneurs(i : integer); +begin + inc(i); + with formConfig do + begin + LabeledEditAdrActionneur.text:=intToSTR(actionneur[i].adresse); + prox1.Text:=intToSTR(actionneur[i].prox1); + prox2.Text:=intToSTR(actionneur[i].prox2); + end; +end; + +procedure TFormConfig.ListBoxActionneursMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +var i,lc,adresse,erreur : integer; + s : string; +begin + if nActionneurs<1 then exit; + + clicListe:=true; + //raz_champs_aig; + + with Formconfig.ListBoxActionneurs do + begin + i:=0; + lc:=itemindex; + //Affiche('numéro de la ligne cliquée '+intToStr(lc),clyellow); + s:=Uppercase(items[lc]); // ligne cliquée + if s='' then + begin + ligneclicActionneur:=-1; + clicListe:=false; + exit; + end; + + AncligneclicActionneur:=ligneclicActionneur; + ligneclicActionneur:=lc; + end; + + Val(s,Adresse,erreur); // Adresse de l'aguillage + if adresse=0 then + begin + clicListe:=false; + exit; + end; + + aff_champs_Actionneurs(lc); + clicliste:=false; +end; + +procedure TFormConfig.LabeledEditAdrActionneurChange(Sender: TObject); + var adr,i,erreur : integer; + trouve : boolean; + begin + if clicliste then exit; + if (ligneclicActionneur<0) or (ligneclicActionneur>=nActionneurs) or (nactionneurs<1) then exit; + val(LabeledEditAdrActionneur.text,adr,erreur); + + i:=1; + repeat + trouve:=actionneur[i].adresse=adr; + inc(i); + until trouve or (i>nActionneurs); + if trouve then + begin + LabelInfo.Caption:='L''actionneur '+intToSTR(adr)+' existe déja'; + exit; + end; + LabelInfo.Caption:=''; + + if adr<0 then exit; + actionneur[ligneclicActionneur+1].adresse:=adr; + formconfig.ListBoxActionneurs.items[ligneclicActionneur]:=encode_actionneur(ligneclicactionneur+1); + formconfig.ListBoxActionneurs.selected[ligneclicActionneur]:=true; +end; + +Procedure ajoute_detecteur; +var s: string; + i : integer; +begin + if Ndetecteurs>=NbMaxDet then + begin + Affiche('Nombre maximal de détecteurs atteint',clred); + exit; + end; + clicliste:=true; + + // désélectionne tout + with formconfig.ListBoxDet do + for i:=0 to items.Count-1 do Selected[i]:=false; + + inc(nDetecteurs); + { + i:=nDetecteurs; + Detecteur[i].Adresse:=0; + Detecteur[i].longueur:=0; + Detecteur[i].Etat:=false; + Detecteur[i].Train:=''; + Detecteur[i].AdrTrain:=0; + Detecteur[i].AdrTrainRes:=0; + Detecteur[i].IndexTrainRoulant:=0; + Detecteur[i].Tempo0:=0; + Detecteur[i].NumBranche:=0; + Detecteur[i].IndexBranche:=0; + Detecteur[i].index:=0; + Detecteur[i].temps:=0; + Detecteur[i].distanceTr:=0; + Detecteur[i].suivant:=0; + Detecteur[i].precedent:=0; + Detecteur[i].TypSuivant:=rien; + Detecteur[i].TypPrecedent:=rien;} + + s:=encode_Detecteur(0); + // scroller à la fin et sélectionner + with formconfig.ListBoxDet do + begin + items.add(s); + selected[i-1]:=true; + SetFocus; + perform(WM_VSCROLL,SB_BOTTOM,0); + end; + + formconfig.LabelInfo.caption:='Detecteur 0 créé'; + ligneClicDet:=i-1; + AncligneClicDet:=ligneClicDet; + aff_champs_Detecteurs(0); + clicliste:=false; + config_modifie:=true; +end; + + +procedure ajoute_actionneur; +var i : integer; + s : string; +begin + if nActionneurs>=Max_actionneurs then + begin + Affiche('Nombre maximal d''actionneurs atteint',clRed); + exit; + end; + clicliste:=true; + + // désélectionne tout + with formconfig.ListBoxActionneurs do + for i:=0 to items.Count-1 do Selected[i]:=false; + + inc(nActionneurs); + i:=nActionneurs; + actionneur[i].Adresse:=0; + actionneur[i].prox1:=0; + actionneur[i].prox2:=0; + + s:=encode_Actionneur(i); + // scroller à la fin et sélectionner + with formconfig.ListBoxActionneurs do + begin + items.add(s); + selected[i-1]:=true; + SetFocus; + perform(WM_VSCROLL,SB_BOTTOM,0); + end; + + formconfig.LabelInfo.caption:='Actionneur '+intToSTR(actionneur[i].Adresse)+' créé'; + ligneClicActionneur:=i-1; + AncligneClicActionneur:=ligneClicActionneur; + aff_champs_Actionneurs(i); + clicliste:=false; + config_modifie:=true; +end; + + + +procedure TFormConfig.ButtonNouvActClick(Sender: TObject); + begin + ajoute_actionneur; +end; + +procedure TFormConfig.ListBoxDetMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +var i,lc,adresse,erreur : integer; + s : string; +begin + if nDetecteurs<1 then exit; + + clicListe:=true; + + with Formconfig.ListBoxDet do + begin + i:=0; + lc:=itemindex; + //Affiche('numéro de la ligne cliquée '+intToStr(lc),clyellow); + s:=Uppercase(items[lc]); // ligne cliquée + if s='' then + begin + ligneclicDet:=-1; + clicListe:=false; + exit; + end; + + AncligneclicDet:=ligneclicDet; + ligneclicDet:=lc; + end; + + Val(s,Adresse,erreur); // Adresse de l'aguillage + + aff_champs_Detecteurs(lc); + clicliste:=false; +end; + +procedure TFormConfig.Button4Click(Sender: TObject); + begin + Ajoute_detecteur; +end; + +procedure TFormConfig.Button5Click(Sender: TObject); + begin + supprime_detecteur; +end; + +procedure TFormConfig.RadioGroupLEBClick(Sender: TObject); + begin + if clicliste or (ligneClicSig<0) then exit; + if affevt then Affiche('Evt RadioGroupLEB',clOrange); + + if FormConfig.PageControl.ActivePage=FormConfig.TabSheetSig then + Signaux[ligneClicSig+1].BinLin:=radioGroupLEB.ItemIndex; + +end; + end. diff --git a/UnitConfigCellTCO.dfm b/UnitConfigCellTCO.dfm index 9c97809..c03503b 100644 --- a/UnitConfigCellTCO.dfm +++ b/UnitConfigCellTCO.dfm @@ -1,6 +1,6 @@ object FormConfCellTCO: TFormConfCellTCO - Left = 570 - Top = 171 + Left = 572 + Top = 151 BorderStyle = bsDialog Caption = 'FormConfCellTCO' ClientHeight = 473 @@ -19,6 +19,152 @@ object FormConfCellTCO: TFormConfCellTCO OnKeyPress = FormKeyPress PixelsPerInch = 96 TextHeight = 13 + object ImageGD: TImage + Left = 96 + Top = 408 + Width = 57 + Height = 57 + Picture.Data = { + 07544269746D6170F6070000424DF60700000000000076000000280000003C00 + 00003C000000010004000000000080070000C20E0000C20E0000100000000000 + 0000000000000000800000800000008080008000000080008000808000008080 + 8000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF + FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFF0FFFFFFFFFFFFFFFFFFFF0FFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFF00000FFFFFFFFFFFFFFFFFFFF00000FFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFF + 0000FFFFFFFFFFFFF0000000FFFFFFFFFFFFFFFFFFFF0000000FFFFFFFFFFFFF + 0000FFFFFFFFFFFF00000000FFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFF + 0000FFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFF + 0000FFFFFFFFFF0000000000FFFFFFFFFFFFFFFFFFFF0000000000FFFFFFFFFF + 0000FFFFFFFFF000000000000000000000000000000000000000000FFFFFFFFF + 0000FFFFFFFF00000000000000000000000000000000000000000000FFFFFFFF + 0000FFFFFFF0000000000000000000000000000000000000000000000FFFFFFF + 0000FFFFFFF0000000000000000000000000000000000000000000000FFFFFFF + 0000FFFFFFFF00000000000000000000000000000000000000000000FFFFFFFF + 0000FFFFFFFFF000000000000000000000000000000000000000000FFFFFFFFF + 0000FFFFFFFFFF0000000000FFFFFFFFFFFFFFFFFFFF0000000000FFFFFFFFFF + 0000FFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFF + 0000FFFFFFFFFFFF00000000FFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFF + 0000FFFFFFFFFFFFF0000000FFFFFFFFFFFFFFFFFFFF0000000FFFFFFFFFFFFF + 0000FFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFF00000FFFFFFFFFFFFFFFFFFFF00000FFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFF0FFFFFFFFFFFFFFFFFFFF0FFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000} + Visible = False + end + object ImageHB: TImage + Left = 152 + Top = 408 + Width = 57 + Height = 57 + Picture.Data = { + 07544269746D6170F6070000424DF60700000000000076000000280000003C00 + 00003C000000010004000000000080070000C20E0000C20E0000100000000000 + 0000000000000000800000800000008080008000000080008000808000008080 + 8000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF + FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFF0000000000FFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFF000000000000FFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFF00000000000000FFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFF000000000000000000FFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFF00000000000000000000FFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFF0000000000000000000000FFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFF000000000000000000000000FFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFF00000000000000000000000000FFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFF00000000000000000000000000FFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFF000000000000000000000000FFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFF0000000000000000000000FFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFF00000000000000000000FFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFF000000000000000000FFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFF00000000000000FFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFF000000000000FFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFF0000000000FFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + 0000} + Visible = False + end object GroupBox1: TGroupBox Left = 8 Top = 304 @@ -92,6 +238,8 @@ object FormConfCellTCO: TFormConfCellTCO Font.Name = 'MS Sans Serif' Font.Style = [] ParentFont = False + ParentShowHint = False + ShowHint = False TabOrder = 1 object Label15: TLabel Left = 8 @@ -108,7 +256,7 @@ object FormConfCellTCO: TFormConfCellTCO end object Label2: TLabel Left = 192 - Top = 14 + Top = 6 Width = 53 Height = 20 Caption = 'Adresse : ' @@ -121,7 +269,7 @@ object FormConfCellTCO: TFormConfCellTCO end object ImagePaletteCC: TImage Left = 128 - Top = 24 + Top = 16 Width = 41 Height = 41 OnMouseDown = ImagePaletteCCMouseDown @@ -144,8 +292,8 @@ object FormConfCellTCO: TFormConfCellTCO OnChange = EditTypeImageChange end object GroupBoxOrientation: TGroupBox - Left = 0 - Top = 192 + Left = 8 + Top = 152 Width = 273 Height = 57 Caption = 'Orientation du signal' @@ -257,7 +405,7 @@ object FormConfCellTCO: TFormConfCellTCO end object EditAdrElement: TEdit Left = 200 - Top = 40 + Top = 38 Width = 33 Height = 24 Hint = 'Adresse DCC de l'#39#233'l'#233'ment' @@ -268,7 +416,7 @@ object FormConfCellTCO: TFormConfCellTCO end object ButtonFond: TButton Left = 8 - Top = 96 + Top = 88 Width = 97 Height = 33 Caption = 'Couleur de fond de la cellule' @@ -284,7 +432,7 @@ object FormConfCellTCO: TFormConfCellTCO end object RadioGroupSel: TRadioGroup Left = 128 - Top = 80 + Top = 72 Width = 153 Height = 57 Caption = 'S'#233'lection clic ic'#244'ne ci-dessus' @@ -299,6 +447,24 @@ object FormConfCellTCO: TFormConfCellTCO ParentFont = False TabOrder = 5 end + object CheckBoxEncadre: TCheckBox + Left = 16 + Top = 134 + Width = 161 + Height = 17 + Hint = 'Ajoute un cadre autour des textes' + Caption = 'Cellule(s) encadr'#233'es sur texte' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentFont = False + ParentShowHint = False + ShowHint = True + TabOrder = 6 + OnClick = CheckBoxEncadreClick + end end object CheckPinv: TCheckBox Left = 8 @@ -393,35 +559,84 @@ object FormConfCellTCO: TFormConfCellTCO end object GroupBoxCanton: TGroupBox Left = 16 - Top = 152 + Top = 160 Width = 281 Height = 129 Caption = 'Canton' TabOrder = 6 object LabelNumC: TLabel - Left = 19 - Top = 17 + Left = 11 + Top = 20 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') + object LabelInfo: TLabel + Left = 160 + Top = 20 + Width = 10 + Height = 13 + Caption = 'xx' + end + object ImageSens: TImage + Left = 232 + Top = 80 + Width = 33 + Height = 33 + Stretch = True + end + object Label4: TLabel + Left = 8 + Top = 52 + Width = 249 + Height = 13 + Caption = 'Sens impos'#233' de circulation dans le canton :' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [fsBold] + ParentFont = False + end + object EditCanton: TEdit + Left = 112 + Top = 16 + Width = 33 + Height = 21 TabOrder = 0 - OnClick = RadioGroupAlignClick + OnChange = EditCantonChange + OnExit = EditCantonExit + end + object RadioButtonGH: TRadioButton + Left = 48 + Top = 72 + Width = 177 + Height = 17 + Caption = 'Sens gauche/haut uniquement' + TabOrder = 1 + OnClick = RadioButtonGHClick + end + object RadioButtonDB: TRadioButton + Left = 48 + Top = 88 + Width = 177 + Height = 17 + Caption = 'Sens droit/bas uniquement' + TabOrder = 2 + OnClick = RadioButtonDBClick + end + object RadioButtonDS: TRadioButton + Left = 48 + Top = 104 + Width = 113 + Height = 17 + Caption = 'Double sens' + TabOrder = 3 + OnClick = RadioButtonDSClick end end object ImageListIcones: TImageList Left = 160 - Top = 8 Bitmap = { 494C010118001D00040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 0000000000003600000028000000400000008000000001002000000000000080 diff --git a/UnitConfigCellTCO.pas b/UnitConfigCellTCO.pas index a456081..a87dac8 100644 --- a/UnitConfigCellTCO.pas +++ b/UnitConfigCellTCO.pas @@ -42,7 +42,16 @@ type BitBtnAnnule: TBitBtn; GroupBoxCanton: TGroupBox; LabelNumC: TLabel; - RadioGroupAlign: TRadioGroup; + EditCanton: TEdit; + LabelInfo: TLabel; + CheckBoxEncadre: TCheckBox; + RadioButtonGH: TRadioButton; + RadioButtonDB: TRadioButton; + RadioButtonDS: TRadioButton; + ImageSens: TImage; + ImageGD: TImage; + ImageHB: TImage; + Label4: TLabel; procedure EditAdrElementChange(Sender: TObject); procedure EditTexteCCTCOChange(Sender: TObject); procedure ButtonFonteClick(Sender: TObject); @@ -72,7 +81,12 @@ type procedure BitBtnAnnuleClick(Sender: TObject); procedure ListBoxActionKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); - procedure RadioGroupAlignClick(Sender: TObject); + procedure EditCantonExit(Sender: TObject); + procedure EditCantonChange(Sender: TObject); + procedure CheckBoxEncadreClick(Sender: TObject); + procedure RadioButtonGHClick(Sender: TObject); + procedure RadioButtonDBClick(Sender: TObject); + procedure RadioButtonDSClick(Sender: TObject); private { Déclarations privées } public @@ -100,14 +114,12 @@ procedure actualise(indexTCO : integer); implementation -uses UnitPrinc,UnitAnalyseSegCDM,UnitConfigTCO,UnitTCO; +uses UnitPrinc,UnitAnalyseSegCDM,UnitConfigTCO,UnitTCO,selection_train; {$R *.dfm} //https://codes-sources.commentcamarche.net/forum/affich-1015879-ajouter-un-icon-dans-un-listbox - - // procédure qui met la bd à jour, et réactualise la cellule, ce qui appelle "select elements" procedure stocke_bd; var Bim,x,y,act : integer; @@ -123,7 +135,6 @@ begin affiche_cellule(IndexTCOCourant,x,Y); actualise(indexTCOCourant); end; - end; // affiche les élements de l'index dans la fenetre @@ -190,13 +201,13 @@ begin end; end; -// actualise le contenu de la fenetre et de la zone tco +// actualise le contenu de la fenetre et de la zone tco par rapport à la cellule cliquée procedure actualise(indexTCO : integer); -var i,Bimage,oriente,piedFeu,act : integer; +var i,Bimage,oriente,piedFeu,act,sens : integer; s : string; ip : Timage; r : trect; - sauvConfcellTCO : boolean; + sauvConfcellTCO,H : boolean; begin if (indexTCO=0) or (formConfCellTCO=nil) then exit; if affevt then affiche('FormConfigCellTCO actualise',clyellow); @@ -206,61 +217,128 @@ begin //with FormConfCellTCO.ImagePaletteCC.Picture.Bitmap do with FormConfCellTCO.ImagePaletteCC do begin - // efface l'icone - Picture.Bitmap.width:=iconeX; - Picture.bitmap.height:=iconeY; - // effacer l'icone - r:=Rect(0,0,iconeX,iconeY); - //with FormConfCellTCO.ImagePaletteCC.canvas do - with Picture.Bitmap.Canvas do - // with Picture.Bitmap.Canvas do - begin - Pen.Mode:=pmCopy; - Pen.Width:=1; - Pen.color:=tco[indexTCO,XclicC,YclicC].CouleurFond; - Brush.Color:=tco[indexTCO,XclicC,YclicC].couleurFond; - Brush.style:=bsSolid; - fillRect(r); - end; + // efface l'icone + Picture.Bitmap.width:=iconeX; + Picture.bitmap.height:=iconeY; + // effacer l'icone + r:=Rect(0,0,iconeX,iconeY); + //with FormConfCellTCO.ImagePaletteCC.canvas do + with Picture.Bitmap.Canvas do + // with Picture.Bitmap.Canvas do + begin + Pen.Mode:=pmCopy; + Pen.Width:=1; + 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,XClicC,YClicC].Bimage; + FormConfCellTCO.CheckBoxEncadre.visible:=Bimage=0; + + formConfCellTCO.GroupBox1.caption:='Texte'; 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); + if (Bimage>=Id_cantonH) and (Bimage<=Id_cantonH+9) then + begin + H:=true; + xClicC:=xClicC-(Bimage-Id_cantonH); + end; + if (Bimage>=Id_cantonV) and (Bimage<=Id_cantonV+9) then + begin + H:=false; + yClicC:=yClicC-(Bimage-Id_cantonV); + end; XclicCell[indexTCO]:=XclicC; YclicCell[indexTCO]:=YclicC; GroupBoxOrientation.visible:=false; GroupBoxImplantation.visible:=false; GroupBoxAction.Visible:=false; + + sens:=tco[indexTCO,xClicC,yClicC].SensCirc; with GroupBoxCanton do begin visible:=true; left:=16; - top:=152; + top:=158; width:=280; height:=130; EditTypeImage.Enabled:=false; - with RadioGroupAlign do + GroupBox1.caption:='Nom du canton'; + end; + + with RadioButtonGH do // gauche ou haut + begin + if H then begin - ItemIndex:=TCO[indexTCO,Xclicc,YClicC].pont; // Alignement - if isCantonH(Bimage) then + Caption:='Sens gauche'; + if sens=SensGauche then begin - items[1]:='Aligné à gauche'; - items[2]:='Aligné à droite'; + ImageSens.Picture:=FormSelTrain.ImageGauche.Picture; + checked:=true; end else begin - items[1]:='Aligné en haut'; - items[2]:='Aligné en bas'; + checked:=false; end; - end; + end + else + // vertical + begin + Caption:='Sens haut'; + if sens=SensHaut then + begin + ImageSens.Picture:=FormSelTrain.ImageHaut.Picture; + checked:=true; + end + else + begin + checked:=false; + end; + end + end; + + with RadioButtonDB do // droit ou bas + begin + if H then + begin + Caption:='Sens droit'; + if sens=SensDroit then + begin + ImageSens.Picture:=FormSelTrain.ImageDroite.Picture; + checked:=true; + end + else checked:=false; + end + else + begin + Caption:='Sens bas'; + if sens=SensBas then + begin + ImageSens.Picture:=FormSelTrain.ImageBas.Picture; + checked:=true; + end + else checked:=false; + end + end; + with RadioButtonDS do + begin + if Sens=0 then + begin + checked:=true; + if H then + ImageSens.Picture:=FormConfCellTCO.ImageGD.Picture + else + ImageSens.Picture:=FormConfCellTCO.ImageHB.Picture; + end + else checked:=false; end; end; end @@ -300,6 +378,7 @@ begin begin with formConfCellTCO do begin + CheckBoxEncadre.checked:=tco[indexTCO,XclicC,YclicC].Buttoir=1; with GroupBoxOrientation do begin visible:=true; @@ -313,7 +392,6 @@ begin end; end; - if (Bimage=1) or (Bimage=10) or (Bimage=11) or (Bimage=20) then begin if tco[indexTCO,XclicC,YclicC].buttoir<>0 then @@ -548,7 +626,7 @@ begin 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) + if i>0 then FormConfCellTCO.EditCanton.text:=intToSTR(canton[i].numero); end else FormConfCellTCO.LabelNumC.caption:='Elément de canton'; end; @@ -604,6 +682,7 @@ procedure TFormConfCellTCO.EditTexteCCTCOChange(Sender: TObject); var i,El,x,y : integer; begin if clicTCO or not(ConfCellTCO) or actualize then exit; + if affevt then Affiche('EditTexteCCTCOChange',clyellow); PCanvasTCO[indexTCOCourant].Brush.Color:=clfond[indexTCOCourant]; x:=XclicCell[indexTCOCourant]; y:=YclicCell[indexTCOCourant]; @@ -622,7 +701,7 @@ 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); + Dessin_canton(indexTCOCourant,PcanvasTCO[indexTCOCourant],x,y,0); end else affiche_texte(indexTCOCourant,x,y); @@ -631,6 +710,7 @@ begin if not(selectionaffichee[indexTCOcourant]) then _entoure_cell_clic(indexTCOCourant); end; + procedure TFormConfCellTCO.ButtonFonteClick(Sender: TObject); begin change_fonte(indexTCOcourant); @@ -640,6 +720,10 @@ procedure TFormConfCellTCO.FormCreate(Sender: TObject); var i : integer; c : tcomponent; begin + //RadioButtonGH.Visible:=not(diffusion); + //RadioButtonDB.Visible:=not(diffusion); + //RadioButtonDS.Visible:=not(diffusion); + // fenetre toujours dessus position:=poMainFormCenter; if affevt then Affiche('FormConfCellTCO create',clLime); @@ -732,6 +816,7 @@ end; procedure TFormConfCellTCO.CheckPinvClick(Sender: TObject); var Bimage : integer; begin + if affevt then Affiche('CheckPinvClick',clyellow); if (XclicCell[indexTCOcourant]=0) or (XclicCell[indexTCOcourant]>NbreCellX[indexTCOcourant]) or (YclicCell[indexTCOcourant]=0) or (YclicCell[indexTCOcourant]>NbreCelly[indexTCOcourant]) then exit; Bimage:=tco[indexTCOcourant,XclicCell[indexTCOcourant],YclicCell[indexTCOcourant]].Bimage; if (bimage=2) or (bimage=3) or (bimage=4) or (bimage=5) or (bimage=12) or (bimage=13) or @@ -954,7 +1039,7 @@ begin end; // traitement des buttoirs : mode buttoir supporté par les éléments 1 10 11 20 - if ((element=1) or (element=10) or (element=11) or (element=20)) and (FormConfCellTCO.RadioGroupSel.Itemindex=1) then + if ((element=1) or (element=10) or (element=11) or (element=20)) and (FormConfCellTCO.RadioGroupSel.Itemindex=1) then begin efface_entoure(IndexTCOCourant); if not(testbit(tco[IndexTCOCourant,XclicCell[indexTCOCourant],YclicCell[indexTCOCourant]].buttoir,c)) then @@ -1004,16 +1089,12 @@ begin end; end; - - procedure TFormConfCellTCO.FormHide(Sender: TObject); begin if affevt then Affiche('FormFoncCellTCO hide',clyellow); ConfCellTCO:=false; end; - - procedure TFormConfCellTCO.ListBoxActionMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin @@ -1079,16 +1160,14 @@ begin if clicTCO then exit; act:=ligneclicAction+1; - case act of - AcActSortie : - begin - val(EditParam2.Text,i,erreur); - if erreur<>0 then exit; - tco[IndexTCOCourant,XclicCell[indexTCOCourant],YclicCell[indexTCOCourant]].sortie:=i; - Affiche_cellule(IndexTCOCourant,XclicCell[indexTCOCourant],YclicCell[indexTCOCourant]); - end; - + AcActSortie : + begin + val(EditParam2.Text,i,erreur); + if erreur<>0 then exit; + tco[IndexTCOCourant,XclicCell[indexTCOCourant],YclicCell[indexTCOCourant]].sortie:=i; + Affiche_cellule(IndexTCOCourant,XclicCell[indexTCOCourant],YclicCell[indexTCOCourant]); + end; end; end; @@ -1111,13 +1190,122 @@ 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); + +procedure TFormConfCellTCO.EditCantonExit(Sender: TObject); +var NumC,i,erreur :integer; + trouve : boolean; +begin + val(editcanton.Text,NumC,erreur); + if erreur<>0 then exit; + i:=1; + repeat + trouve:=canton[i].numero=NumC; + inc(i); + until trouve or (i>nCantons); + if trouve then + begin + LabelInfo.caption:='Le canton '+intToSTR(NumC)+' existe déja'; + exit; + end; + LabelInfo.caption:=''; + + erreur:=index_canton(indexTCOcourant,xclicC,yclicC); + canton[erreur].numero:=NumC; +end; + +procedure TFormConfCellTCO.EditCantonChange(Sender: TObject); +var x,y,NumC,i,erreur :integer; + trouve : boolean; +begin + val(editcanton.Text,NumC,erreur); + if erreur<>0 then exit; + i:=1; + repeat + trouve:=canton[i].numero=NumC; + inc(i); + until trouve or (i>nCantons); + if trouve then + begin + LabelInfo.caption:='Le canton '+intToSTR(NumC)+' existe déja'; + exit; + end; + LabelInfo.caption:=''; + + erreur:=index_canton(indexTCOcourant,xclicC,yclicC); + canton[erreur].numero:=NumC; + x:=canton[erreur].x; + y:=canton[erreur].y; + TCO[indexTCOCourant,x,y].NumCanton:=NumC; // mettre à jour le numéro de canton +end; + +procedure TFormConfCellTCO.RadioButtonGHClick(Sender: TObject); +var idc,x,y,sens : integer; + H : boolean; +begin + Idc:=index_canton(indexTCOcourant,xclicC,yclicC); + x:=canton[Idc].x; + y:=canton[Idc].y; + H:=IsCantonH(IndexTCOCourant,x,y); + if H then + begin + ImageSens.Picture:=FormSelTrain.ImageGauche.Picture; + sens:=SensGauche; + end + else + begin + ImageSens.Picture:=FormSelTrain.ImageHaut.Picture; + sens:=SensHaut; + end; + TCO[indexTCOCourant,x,y].SensCirc:=Sens; +end; + +procedure TFormConfCellTCO.RadioButtonDBClick(Sender: TObject); +var idc,x,y,sens : integer; + H : boolean; +begin + Idc:=index_canton(indexTCOcourant,xclicC,yclicC); + x:=canton[Idc].x; + y:=canton[Idc].y; + H:=IsCantonH(IndexTCOCourant,x,y); + if H then + begin + ImageSens.Picture:=FormSelTrain.ImageDroite.Picture; + sens:=SensDroit + end + else + begin + ImageSens.Picture:=FormSelTrain.ImageBas.Picture; + sens:=SensBas; + end; + TCO[indexTCOCourant,x,y].SensCirc:=Sens; +end; + +procedure TFormConfCellTCO.RadioButtonDSClick(Sender: TObject); +var idc,x,y: integer; + h : boolean; +begin + Idc:=index_canton(indexTCOcourant,xclicC,yclicC); + x:=canton[Idc].x; + y:=canton[Idc].y; + H:=IsCantonH(IndexTCOCourant,x,y); + if H then + ImageSens.Picture:=ImageGD.Picture + else + ImageSens.Picture:=ImageHB.Picture; + TCO[indexTCOCourant,x,y].SensCirc:=0; +end; + +procedure TFormConfCellTCO.CheckBoxEncadreClick(Sender: TObject); +var i : integer; +begin + if clicTCO or not(ConfCellTCO) or actualize then exit; + if checkBoxEncadre.Checked then i:=1 else i:=0; + tco[indexTCOcourant,XclicCell[indexTCOcourant],YclicCell[indexTCOcourant]].Buttoir:=i; + efface_entoure(indexTCOcourant); + SelectionAffichee[indexTCOcourant]:=false; + //affiche_cellule(XclicCell[indexTCO],YclicCell[indexTCO]); + affiche_tco(indexTCOcourant); end; end. diff --git a/UnitDebug.pas b/UnitDebug.pas index acadec0..0fe97b3 100644 --- a/UnitDebug.pas +++ b/UnitDebug.pas @@ -464,7 +464,7 @@ begin if (erreur<>0) or (adr<1) then exit; ancdebug:=NivDebug; NivDebug:=3; - if PresTrainPrec(Adr,Nb_cantons_Sig,false,voie,adrtrain) then AfficheDebug('Présence train '+intToSTR(AdrTrain),clYellow) else + if PresTrainPrec(Adr,Nb_cantons_Sig,false,adrtrain,voie) then AfficheDebug('Présence train '+intToSTR(AdrTrain),clYellow) else AfficheDebug('Absence train',clyellow); NivDebug:=AncDebug; end; diff --git a/UnitFicheHoraire.dfm b/UnitFicheHoraire.dfm index 70abdf9..ee84533 100644 --- a/UnitFicheHoraire.dfm +++ b/UnitFicheHoraire.dfm @@ -32,6 +32,13 @@ object FormFicheHoraire: TFormFicheHoraire Width = 3 Height = 13 end + object Label2: TLabel + Left = 208 + Top = 328 + Width = 296 + Height = 13 + Caption = 'Les horaires sont sauvegard'#233's dans le fichier '#39'FicheHoraire.txt"' + end object ButtonOk: TButton Left = 16 Top = 304 diff --git a/UnitFicheHoraire.pas b/UnitFicheHoraire.pas index 1716f31..2147d15 100644 --- a/UnitFicheHoraire.pas +++ b/UnitFicheHoraire.pas @@ -12,6 +12,7 @@ type StringGridFO: TStringGrid; Label1: TLabel; LabelErreur: TLabel; + Label2: TLabel; procedure ButtonOkClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormActivate(Sender: TObject); @@ -201,7 +202,6 @@ begin if champ<>0 then delete(s,1,champ); end; - inc(col); until (col>stringGridFO.ColCount-1) or (pos(',',s)=0); diff --git a/UnitHorloge.dfm b/UnitHorloge.dfm index 53b40c9..29a0519 100644 --- a/UnitHorloge.dfm +++ b/UnitHorloge.dfm @@ -579,12 +579,30 @@ object FormHorloge: TFormHorloge end object ButtonAh: TButton Left = 312 - Top = 224 - Width = 75 + Top = 176 + Width = 81 Height = 33 Caption = 'Afficher l'#39'horloge' TabOrder = 5 WordWrap = True OnClick = ButtonAhClick end + object ButtonLance: TButton + Left = 312 + Top = 216 + Width = 81 + Height = 33 + Caption = 'Lancer l'#39'horloge' + TabOrder = 6 + OnClick = ButtonLanceClick + end + object ButtonArrete: TButton + Left = 312 + Top = 256 + Width = 81 + Height = 33 + Caption = 'Arr'#234'te l'#39'horloge' + TabOrder = 7 + OnClick = ButtonArreteClick + end end diff --git a/UnitHorloge.pas b/UnitHorloge.pas index 460f619..fe2a17b 100644 --- a/UnitHorloge.pas +++ b/UnitHorloge.pas @@ -34,6 +34,8 @@ type ButtonAh: TButton; CheckBoxAffiche: TCheckBox; SpinEditHInit: TSpinEdit; + ButtonLance: TButton; + ButtonArrete: TButton; procedure ButtonOkClick(Sender: TObject); procedure FormActivate(Sender: TObject); procedure TrackBarTempsChange(Sender: TObject); @@ -50,6 +52,8 @@ type procedure ButtonAhClick(Sender: TObject); procedure CheckBoxAfficheClick(Sender: TObject); procedure SpinEditHInitChange(Sender: TObject); + procedure ButtonLanceClick(Sender: TObject); + procedure ButtonArreteClick(Sender: TObject); private { Déclarations privées } public @@ -304,4 +308,14 @@ begin end; +procedure TFormHorloge.ButtonLanceClick(Sender: TObject); +begin + Demarre_horloge; +end; + +procedure TFormHorloge.ButtonArreteClick(Sender: TObject); +begin + horloge:=false; +end; + end. diff --git a/UnitInfo.dfm b/UnitInfo.dfm new file mode 100644 index 0000000..f10ca64 --- /dev/null +++ b/UnitInfo.dfm @@ -0,0 +1,39 @@ +object FormInfo: TFormInfo + Left = 310 + Top = 250 + BorderIcons = [biMaximize, biHelp] + BorderStyle = bsNone + Caption = 'FormInfo' + ClientHeight = 50 + ClientWidth = 575 + Color = clBackground + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + OldCreateOrder = False + OnActivate = FormActivate + OnCreate = FormCreate + PixelsPerInch = 96 + TextHeight = 13 + object LabelInfo: TLabel + Left = 8 + Top = 16 + Width = 54 + Height = 20 + Caption = 'LabelInfo' + Font.Charset = ANSI_CHARSET + Font.Color = clYellow + Font.Height = -16 + Font.Name = 'Arial Narrow' + Font.Style = [] + ParentFont = False + WordWrap = True + end + object Timerinfo: TTimer + OnTimer = TimerinfoTimer + Left = 8 + Top = 8 + end +end diff --git a/UnitInfo.pas b/UnitInfo.pas new file mode 100644 index 0000000..14360e0 --- /dev/null +++ b/UnitInfo.pas @@ -0,0 +1,49 @@ +unit UnitInfo; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, ExtCtrls, StdCtrls; + +type + TFormInfo = class(TForm) + Timerinfo: TTimer; + LabelInfo: TLabel; + procedure TimerinfoTimer(Sender: TObject); + procedure FormActivate(Sender: TObject); + procedure FormCreate(Sender: TObject); + private + { Déclarations privées } + public + { Déclarations publiques } + end; + +var + FormInfo: TFormInfo; + TickInfo : integer; + +implementation + +{$R *.dfm} + +procedure TFormInfo.TimerinfoTimer(Sender: TObject); +begin + if TickInfo>0 then + begin + dec(TickInfo); + if TickInfo=0 then close; + end; +end; + +procedure TFormInfo.FormActivate(Sender: TObject); +begin + TickInfo:=5; +end; + +procedure TFormInfo.FormCreate(Sender: TObject); +begin + labelInfo.Width:=formInfo.Width-20; +end; + +end. diff --git a/UnitModifAction.dfm b/UnitModifAction.dfm index 7e21da1..aea7fa1 100644 --- a/UnitModifAction.dfm +++ b/UnitModifAction.dfm @@ -60,7 +60,7 @@ object FormModifAction: TFormModifAction Top = 64 Width = 729 Height = 337 - ActivePage = TabSheet1 + ActivePage = TabSheetDecl MultiLine = True TabOrder = 2 object TabSheetDecl: TTabSheet @@ -195,7 +195,7 @@ object FormModifAction: TFormModifAction Left = 224 Top = 216 Width = 481 - Height = 65 + Height = 73 ReadOnly = True TabOrder = 2 end @@ -229,7 +229,7 @@ object FormModifAction: TFormModifAction ParentFont = False end object Shape2: TShape - Left = 216 + Left = 232 Top = 8 Width = 3 Height = 293 @@ -258,9 +258,9 @@ object FormModifAction: TFormModifAction OnDrawItem = ListBoxCondTotDrawItem end object ListBoxConditions: TListBox - Left = 232 + Left = 248 Top = 28 - Width = 217 + Width = 201 Height = 201 Hint = 'Condition de r'#233'alisation du d'#233'clencheur' ItemHeight = 13 @@ -271,9 +271,9 @@ object FormModifAction: TFormModifAction OnMouseDown = ListBoxConditionsMouseDown end object GroupBox1: TGroupBox - Left = 464 + Left = 488 Top = 24 - Width = 249 + Width = 225 Height = 265 Caption = 'Param'#232'tres de la condition' TabOrder = 2 @@ -329,7 +329,7 @@ object FormModifAction: TFormModifAction OnChange = Champ1Change end object Champ2: TLabeledEdit - Left = 176 + Left = 168 Top = 40 Width = 41 Height = 21 @@ -420,7 +420,7 @@ object FormModifAction: TFormModifAction Caption = 'Op'#233'rations' ImageIndex = 2 object Shape1: TShape - Left = 216 + Left = 232 Top = 8 Width = 3 Height = 293 @@ -481,7 +481,7 @@ object FormModifAction: TFormModifAction object ComboBoxFamille: TComboBox Left = 0 Top = 32 - Width = 201 + Width = 217 Height = 21 ItemHeight = 0 TabOrder = 0 @@ -490,7 +490,7 @@ object FormModifAction: TFormModifAction object ListBoxOper: TListBox Left = 0 Top = 60 - Width = 201 + Width = 217 Height = 185 Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText @@ -503,9 +503,9 @@ object FormModifAction: TFormModifAction OnDrawItem = ListBoxOperDrawItem end object ListBoxOperations: TListBox - Left = 232 + Left = 248 Top = 28 - Width = 217 + Width = 225 Height = 201 Hint = 'Liste chronologique des op'#233'rations '#224' effectuer' ItemHeight = 13 @@ -514,12 +514,13 @@ object FormModifAction: TFormModifAction TabOrder = 2 OnDblClick = ListBoxOperationsDblClick OnDrawItem = ListBoxOperationsDrawItem + OnKeyDown = ListBoxOperationsKeyDown OnMouseDown = ListBoxOperationsMouseDown end object GroupBoxParam: TGroupBox - Left = 464 + Left = 488 Top = 24 - Width = 249 + Width = 225 Height = 265 Caption = 'Param'#232'tres de l'#39'op'#233'ration' TabOrder = 3 @@ -627,7 +628,7 @@ object FormModifAction: TFormModifAction Caption = 'Etat' end object LabeledEditTrain: TLabeledEdit - Left = 24 + Left = 16 Top = 184 Width = 161 Height = 21 @@ -676,7 +677,7 @@ object FormModifAction: TFormModifAction OnClick = CheckBoxRAZClick end object ComboBoxAccComUSB: TComboBox - Left = 24 + Left = 16 Top = 144 Width = 201 Height = 21 diff --git a/UnitModifAction.pas b/UnitModifAction.pas index 02c4c77..da00d88 100644 --- a/UnitModifAction.pas +++ b/UnitModifAction.pas @@ -124,6 +124,8 @@ type procedure SpinEditEtat2Change(Sender: TObject); procedure RadioEtatSignalClick(Sender: TObject); procedure SpinEditEtatopChange(Sender: TObject); + procedure ListBoxOperationsKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); private { Déclarations privées } public @@ -327,30 +329,30 @@ var nop,op,top,decl : integer; r : double; s :string; begin - decl:=Tablo_Actionneur[i].declencheur; + decl:=Tablo_Action[i].declencheur; s:='Le déclencheur '; case decl of DeclHorloge : - s:=s+'horloge à '+format('%.2d',[Tablo_Actionneur[i].heure])+'h'+format('%.2d',[Tablo_Actionneur[i].minute]); + s:=s+'horloge à '+format('%.2d',[Tablo_Action[i].heure])+'h'+format('%.2d',[Tablo_Action[i].minute]); DeclPeriph : - s:=s+'périphérique : '+Tablo_Actionneur[i].ordrePeriph; + s:=s+'périphérique : '+Tablo_Action[i].ordrePeriph; DeclAccessoire : - s:=s+'accessoire '+intToSTR(Tablo_Actionneur[i].adresse); + s:=s+'accessoire '+intToSTR(Tablo_Action[i].adresse); DeclDetAct : begin - s:=s+'détecteur/Actionneur '+intToSTR(Tablo_Actionneur[i].adresse); - s:=s+' par le train "'+Tablo_Actionneur[i].trainDecl+'"'; + s:=s+'détecteur/Actionneur '+intToSTR(Tablo_Action[i].adresse); + s:=s+' par le train "'+Tablo_Action[i].trainDecl+'"'; end; DeclZoneDet : - s:=s+'Zone détection '+intToSTR(Tablo_Actionneur[i].adresse)+' '+intToSTR(Tablo_Actionneur[i].adresse2); + s:=s+'Zone détection '+intToSTR(Tablo_Action[i].adresse)+' '+intToSTR(Tablo_Action[i].adresse2); DeclDemarTrain : - s:=s+'démarrage du train '+Tablo_Actionneur[i].trainDecl+' au seuil de '+intToSTR(Tablo_Actionneur[i].adresse); + s:=s+'démarrage du train '+Tablo_Action[i].trainDecl+' au seuil de '+intToSTR(Tablo_Action[i].adresse); DeclArretTrain : - s:=s+'arrêt du train '+Tablo_Actionneur[i].trainDecl+' au seuil de '+intToSTR(Tablo_Actionneur[i].adresse); + s:=s+'arrêt du train '+Tablo_Action[i].trainDecl+' au seuil de '+intToSTR(Tablo_Action[i].adresse); DeclSignal : begin - s:=s+'changement du signal '+intToSTR(Tablo_Actionneur[i].adresse); - case Tablo_Actionneur[i].etat of + s:=s+'changement du signal '+intToSTR(Tablo_Action[i].adresse); + case Tablo_Action[i].etat of 0 : s:=s+' sur ouverture'; 1 : s:=s+' sur voie libre'; 2 : s:=s+' sur ouverture restreinte'; @@ -361,25 +363,25 @@ begin // conditions s:=s+#13; - nop:=tablo_actionneur[i].NbCond; + nop:=Tablo_Action[i].NbCond; for op:=1 to nop do begin s:=s+'condition '; - top:=tablo_actionneur[i].tabloCond[op].numcondition; + top:=Tablo_Action[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); + CondVitTrain : s:=s+'vitesse train '+Tablo_Action[i].tabloCond[op].train+' '+intToSTR(Tablo_Action[i].tabloCond[op].vitmini)+ + ' '+intToSTR(Tablo_Action[i].tabloCond[op].vitMaxi); + CondPosAcc : s:=s+' position d''accessoire '+intToSTR(Tablo_Action[i].tabloCond[op].accessoire)+' état '+intToSTR(Tablo_Action[i].tabloCond[op].etat); + CondHorl : s:=s+' horloge '+intToSTR(Tablo_Action[i].tabloCond[op].HeureMin)+'h'+intToSTR(Tablo_Action[i].tabloCond[op].MinuteMin)+' à '+ + intToSTR(Tablo_Action[i].tabloCond[op].HeureMax)+'h'+intToSTR(Tablo_Action[i].tabloCond[op].MinuteMax)+' '; + condTrainSig : s:=s+'train '+Tablo_Action[i].tabloCond[op].train+' arrêté au signal '+intToSTR(Tablo_Action[i].tabloCond[op].Adresse); end; s:=s+#13; end; - nop:=Tablo_Actionneur[i].NbOperations; + nop:=Tablo_Action[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; @@ -389,29 +391,29 @@ begin for op:=1 to nop do begin - top:=Tablo_Actionneur[i].tabloop[op].numoperation; + top:=Tablo_Action[i].tabloop[op].numoperation; case top of - ActionAffTCO : s:=s+'Affiche TCO '+intToSTR(Tablo_Actionneur[i].tabloop[op].NumTCO)+#13; + ActionAffTCO : s:=s+'Affiche TCO '+intToSTR(Tablo_Action[i].tabloop[op].NumTCO)+#13; ActionAffSC : s:=s+'Affiche signaux_complexes'+#13; ActionAffCDM : s:=s+'Affiche CDM rail'+#13; ActionAccessoire : begin - s:=s+'Pilote l''accessoire '+intToSTR(Tablo_Actionneur[i].tabloop[op].adresse)+ - ' à '+intToSTR(Tablo_Actionneur[i].tabloop[op].etat); - if Tablo_Actionneur[i].tabloop[op].zero then s:=s+' impulsionnel'+#13 else s:=s+' maintenu'+#13; + s:=s+'Pilote l''accessoire '+intToSTR(Tablo_Action[i].tabloop[op].adresse)+ + ' à '+intToSTR(Tablo_Action[i].tabloop[op].etat); + if Tablo_Action[i].tabloop[op].zero then s:=s+' impulsionnel'+#13 else s:=s+' maintenu'+#13; end; ActionArretTRains : s:=s+'Arrêt des trains'+#13; ActionLanceHorl : s:=s+'Lance l''horloge'+#13; ActionArretHorl : s:=s+'Arrête l''horloge'+#13; ActionInitHorl : s:=s+'Initialise l''horloge'+#13; ActionAffHorl : s:=s+'Affiche l''horloge'+#13; - ActionVitesse : s:=s+'Modifie la vitesse du train '+Tablo_Actionneur[i].tabloop[op].train+' à '+intToSTR(Tablo_Actionneur[i].tabloop[op].vitesse)+#13; - ActionCdePeriph : s:=s+'Pilote le périphérique '+intToSTR(Tablo_Actionneur[i].tabloop[op].periph)+' chaîne : '+Tablo_Actionneur[i].tabloop[op].chaine+#13; - ActionFonctionF : s:=s+'Fonction F'+intToSTR(Tablo_Actionneur[i].tabloop[op].fonctionF)+' train dest='+Tablo_Actionneur[i].tabloop[op].train+#13; - ActionSon : s:=s+'Son '+Tablo_Actionneur[i].tabloop[op].train+#13; + ActionVitesse : s:=s+'Modifie la vitesse du train '+Tablo_Action[i].tabloop[op].train+' à '+intToSTR(Tablo_Action[i].tabloop[op].vitesse)+#13; + ActionCdePeriph : s:=s+'Pilote le périphérique '+intToSTR(Tablo_Action[i].tabloop[op].periph)+' chaîne : '+Tablo_Action[i].tabloop[op].chaine+#13; + ActionFonctionF : s:=s+'Fonction F'+intToSTR(Tablo_Action[i].tabloop[op].fonctionF)+' train dest='+Tablo_Action[i].tabloop[op].train+#13; + ActionSon : s:=s+'Son '+Tablo_Action[i].tabloop[op].train+#13; ActionTempo : begin - nop:=Tablo_Actionneur[i].tabloop[op].tempoF; + nop:=Tablo_Action[i].tabloop[op].tempoF; r:=nop/10; s:=s+'Temporisation '+intToSTR(nop)+' ('+Format('%.1f', [r])+'s)'#13; end; @@ -427,10 +429,11 @@ 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; + if (index<1) then exit; + if clicListe then exit; clicliste:=true; // Affiche('Aff_champs('+intToSTR(index)+','+intToSTR(indexAction)+')',clYellow); - decl:=Tablo_Actionneur[index].declencheur; + decl:=Tablo_Action[index].declencheur; formModifAction.ListBoxDeclench.ItemIndex:=decl-1; // comboboxActions @@ -453,20 +456,20 @@ begin Lines.Add(s); end; - FormModifAction.LabeledEditNomAct.Text:=Tablo_Actionneur[index].NomAction; + FormModifAction.LabeledEditNomAct.Text:=Tablo_Action[index].NomAction; // ListBox opérations with FormModifAction.ListBoxOperations do begin clear; formConfig.ListBoxOperations.Clear; - for i:=1 to Tablo_Actionneur[index].NbOperations do + for i:=1 to Tablo_Action[index].NbOperations do begin - act:=Tablo_Actionneur[index].tabloOp[i].numoperation; + act:=Tablo_Action[index].tabloOp[i].numoperation; if act<=NbreOperations then begin s:=operations[act].nom; - if not(Tablo_Actionneur[index].tabloOp[i].valide) then s:=s+' [dévalidé]'; + if not(Tablo_Action[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 @@ -474,18 +477,20 @@ begin // listboxOperations de la formConfig formConfig.ListBoxOperations.Items.add(Format('%d%s', [act-1, s])); itemHeight:=17; - end; + 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 + for i:=1 to Tablo_Action[index].NbCond do begin - cond:=Tablo_Actionneur[index].tabloCond[i].numcondition; + cond:=Tablo_Action[index].tabloCond[i].numcondition; s:=conditions[cond].nom; case cond of CondVrai : icone:=iconeVrai; @@ -511,7 +516,7 @@ begin formConfig.ListBoxActions.Items.add(s); end; - + efface_tous_parametres; // déclencheurs @@ -519,8 +524,8 @@ begin case decl of DeclHorloge : begin - EditAdr.text:=intToSTR(Tablo_Actionneur[index].heure); - EditAdr2.text:=intToSTR(Tablo_Actionneur[index].minute); + EditAdr.text:=intToSTR(Tablo_Action[index].heure); + EditAdr2.text:=intToSTR(Tablo_Action[index].minute); LabelHeure.visible:=true; LabelAdresse.visible:=true; EditAdr.Visible:=true; @@ -539,7 +544,7 @@ begin end; DeclPeriph : begin - EditTrainDecl.Text:=Tablo_Actionneur[index].ordrePeriph; + EditTrainDecl.Text:=Tablo_Action[index].ordrePeriph; LabelHeure.visible:=false; LabelAdresse.visible:=false; EditAdr.Visible:=false; @@ -562,11 +567,11 @@ begin end; DeclAccessoire : begin - EditAdr.text:=intToSTR(Tablo_Actionneur[index].adresse); + EditAdr.text:=intToSTR(Tablo_Action[index].adresse); with SpinEditEtat do begin - text:=intToSTR(Tablo_Actionneur[index].etat); + text:=intToSTR(Tablo_Action[index].etat); MaxValue:=2; Hint:='Etat de l''accessoire'+#13+ '0=nul'+#13+ @@ -595,9 +600,9 @@ begin DeclDetAct : begin - EditAdr.text:=intToSTR(Tablo_Actionneur[index].adresse); + EditAdr.text:=intToSTR(Tablo_Action[index].adresse); EditTrainDecl.Visible:=true; - EditTrainDecl.Text:=Tablo_Actionneur[index].trainDecl; + EditTrainDecl.Text:=Tablo_Action[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'; @@ -611,7 +616,7 @@ begin with SpinEditEtat do begin - text:=intToSTR(Tablo_Actionneur[index].etat); + text:=intToSTR(Tablo_Action[index].etat); MaxValue:=1; Hint:='Etat du détecteur/actionneur'+#13+ '0=désactivé'+#13+ @@ -633,10 +638,10 @@ begin DeclZoneDet : begin - EditAdr.text:=intToSTR(Tablo_Actionneur[index].adresse); - EditAdr2.text:=intToSTR(Tablo_Actionneur[index].adresse2); + EditAdr.text:=intToSTR(Tablo_Action[index].adresse); + EditAdr2.text:=intToSTR(Tablo_Action[index].adresse2); - EditTrainDecl.Text:=Tablo_Actionneur[index].trainDecl; + EditTrainDecl.Text:=Tablo_Action[index].trainDecl; EditAdr.Hint:='Adresse1 de la zone de détection du déclencheur'; EditAdr2.Hint:='Adresse2 de la zone de détection du déclencheur'; LabelAdresse.visible:=true; @@ -652,7 +657,7 @@ begin with SpinEditEtat do begin - text:=intToSTR(Tablo_Actionneur[index].etat); + text:=intToSTR(Tablo_Action[index].etat); MaxValue:=1; Hint:='Etat de la zone de détection'+#13+ '0=désactivé'+#13+ @@ -680,8 +685,8 @@ begin 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); + EditTrainDecl.Text:=Tablo_Action[index].trainDecl; + EditAdr.Text:=IntToSTR(Tablo_Action[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); @@ -698,8 +703,8 @@ begin 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); + EditTrainDecl.Text:=Tablo_Action[index].trainDecl; + EditAdr.Text:=IntToSTR(Tablo_Action[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); @@ -709,8 +714,8 @@ begin DeclSignal : begin LabelAdresse.Visible:=true; - EditAdr.text:=intToSTR(Tablo_Actionneur[index].adresse); - RadioEtatSignal.ItemIndex:=Tablo_Actionneur[index].Etat; + EditAdr.text:=intToSTR(Tablo_Action[index].adresse); + RadioEtatSignal.ItemIndex:=Tablo_Action[index].Etat; LabelAdresse.Caption:='Adresse'; EditAdr.Hint:='Adresse de base du signal'; EditAdr.Visible:=true; @@ -727,15 +732,15 @@ begin // conditions if indexCond>0 then begin - cond:=Tablo_Actionneur[index].tablocond[indexCond].numcondition; + cond:=Tablo_Action[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.Text:=intToSTR(Tablo_Action[index].tabloCond[indexCond].vitmini); + champ2.Text:=intToSTR(Tablo_Action[index].tabloCond[indexCond].vitmaxi); + ChampTrain.text:=Tablo_Action[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'; @@ -747,9 +752,9 @@ begin end; CondPosAcc : begin - champ1.Text:=intToSTR(Tablo_actionneur[index].tabloCond[indexCond].accessoire); + champ1.Text:=intToSTR(Tablo_Action[index].tabloCond[indexCond].accessoire); Champ1.Hint:='Adresse DCC de l''accessoire pour la condition'; - SpinEditEtat2.Value:=Tablo_actionneur[index].tabloCond[indexCond].etat; + SpinEditEtat2.Value:=Tablo_Action[index].tabloCond[indexCond].etat; SpinEditEtat2.visible:=true; SpinEditEtat2.hint:='Etat de l''accessoire'+#13+ '0=nul'+#13+ @@ -763,10 +768,10 @@ begin 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.Value:=Tablo_Action[index].tabloCond[indexCond].HeureMin; + SpinEditmn1.Value:=Tablo_Action[index].tabloCond[indexCond].MinuteMin; + SpinEditHeure2.Value:=Tablo_Action[index].tabloCond[indexCond].HeureMax; + SpinEditmn2.Value:=Tablo_Action[index].tabloCond[indexCond].MinuteMax; SpinEditHeure1.visible:=true; SpinEditHeure2.visible:=true; @@ -777,9 +782,9 @@ begin end; condTrainSig : begin - champ1.Text:=intToSTR(Tablo_actionneur[index].tabloCond[indexCond].adresse); + champ1.Text:=intToSTR(Tablo_Action[index].tabloCond[indexCond].adresse); champ1.editLabel.Caption:='Adresse du signal'; - champTrain.Text:=Tablo_actionneur[index].tabloCond[indexCond].train; + champTrain.Text:=Tablo_Action[index].tabloCond[indexCond].train; champ1.Visible:=true; champTrain.Visible:=true; end; @@ -788,7 +793,7 @@ begin end; - Nb:=Tablo_Actionneur[index].NbOperations; + Nb:=Tablo_Action[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 @@ -801,7 +806,7 @@ begin if Nb>=indexAction then begin - Act:=Tablo_actionneur[index].tabloop[indexAction].numoperation; + Act:=Tablo_Action[index].tabloop[indexAction].numoperation; with formModifAction do begin @@ -811,7 +816,7 @@ begin begin LabeledEditAdresse.Visible:=true; LabeledEditAdresse.EditLabel.Caption:='TCO n°'; - LabeledEditAdresse.Text:=intToSTR(Tablo_actionneur[index].tabloop[indexAction].NumTCO); + LabeledEditAdresse.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].NumTCO); end; ActionAccessoire : begin @@ -827,9 +832,9 @@ begin '2=droit'; checkBoxRaz.Visible:=true; - LabeledEditAdresse.Text:=intToSTR(Tablo_actionneur[index].tabloop[indexAction].adresse); - SpinEditEtatop.Value:=Tablo_actionneur[index].tabloop[indexAction].etat; - checkBoxRAZ.Checked:=Tablo_actionneur[index].tabloop[indexAction].zero; + LabeledEditAdresse.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].adresse); + SpinEditEtatop.Value:=Tablo_Action[index].tabloop[indexAction].etat; + checkBoxRAZ.Checked:=Tablo_Action[index].tabloop[indexAction].zero; end; ActionVitesse : begin @@ -838,8 +843,8 @@ begin LabeledEditTrain.Visible:=true; LabeledEditTrain.EditLabel.Caption:='Train destinataire'; LabeledEditTrain.hint:='Nom unique du train'; - LabeledEditAdresse.Text:=intToSTR(Tablo_actionneur[index].tabloop[indexAction].vitesse); - LabeledEditTrain.Text:=Tablo_actionneur[index].tabloop[indexAction].train; + LabeledEditAdresse.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].vitesse); + LabeledEditTrain.Text:=Tablo_Action[index].tabloop[indexAction].train; end; ActionCdePeriph : begin @@ -848,8 +853,8 @@ begin 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; + LabeledEditTrain.Text:=Tablo_Action[index].tabloop[indexAction].chaine; + ComboBoxAccComUSB.itemIndex:=Tablo_Action[index].tabloop[indexAction].periph-1; end; ActionFonctionF : begin @@ -859,9 +864,9 @@ begin LabeledEditFonctionF.EditLabel.Caption:='Fonction F'; LabeledEditTrain.Visible:=true; LabeledEditTrain.hint:='Nom unique du train'; - LabeledEditFonctionF.Text:=intToSTR(Tablo_actionneur[index].tabloop[indexAction].fonctionF); - LabeledEditTempoF.Text:=intToSTR(Tablo_actionneur[index].tabloop[indexAction].TempoF); - LabeledEditTrain.Text:=Tablo_actionneur[index].tabloop[indexAction].train; + LabeledEditFonctionF.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].fonctionF); + LabeledEditTempoF.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].TempoF); + LabeledEditTrain.Text:=Tablo_Action[index].tabloop[indexAction].train; end; ActionSon : begin @@ -870,13 +875,13 @@ begin SpeedButtonCharger.Visible:=true; LabeledEditTrain.EditLabel.Caption:='Son'; LabeledEditTrain.Hint:='fichier son'; - LabeledEditTrain.Text:=Tablo_actionneur[index].tabloop[indexAction].train; + LabeledEditTrain.Text:=Tablo_Action[index].tabloop[indexAction].train; end; ActionTempo : begin LabeledEditTempoF.Visible:=true; LabeledEditTempoF.EditLabel.Caption:='Temporisation (x100 ms)'; - LabeledEditTempoF.Text:=intToSTR(Tablo_actionneur[index].tabloop[indexAction].TempoF); + LabeledEditTempoF.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].TempoF); end; end; end; @@ -934,7 +939,7 @@ begin i:=Index_Operation(s); if (IndexDest<0) then IndexDest:=0; - Tablo_Actionneur[ligneClicAct+1].TabloOp[IndexDest+1].numoperation:=i; + Tablo_Action[ligneClicAct+1].TabloOp[IndexDest+1].numoperation:=i; listboxoperations.Items[indexDest]:=ListBoxOper.Items[indexSrc]; @@ -954,14 +959,14 @@ begin if i=0 then exit; idBD:=ligneClicAct+1; - NbOp:=Tablo_Actionneur[idBD].NbOperations; - NbCond:=Tablo_Actionneur[idBD].NbCond; + NbOp:=Tablo_Action[idBD].NbOperations; + NbCond:=Tablo_Action[idBD].NbCond; inc(NbOp); - Tablo_Actionneur[idBD].NbOperations:=NbOp; - Setlength(Tablo_Actionneur[idBD].tabloOp,NbOp+1); + Tablo_Action[idBD].NbOperations:=NbOp; + Setlength(Tablo_Action[idBD].tabloOp,NbOp+1); // le nouveau numéro d'opération c'est l'index de la listboxOper - Tablo_Actionneur[idBD].tabloOp[NbOp].numoperation:=i; - Tablo_Actionneur[idBD].tabloOp[NbOp].valide:=true; + Tablo_Action[idBD].tabloOp[NbOp].numoperation:=i; + Tablo_Action[idBD].tabloOp[NbOp].valide:=true; Aff_champs(idbd,nbCond,Nbop); clicAction:=NbOp-1; @@ -969,43 +974,48 @@ begin end; -procedure TFormModifAction.SpeedButtonSupprimeClick(Sender: TObject); + + +procedure supprime_operation; var i,indexSrc,idBD,NbOp,NumOp : integer; s : string; begin - indexSrc:=listboxOperations.ItemIndex; + indexSrc:=formModifaction.listboxOperations.ItemIndex; if indexSrc<0 then exit; idBD:=ligneClicAct+1; - NbOp:=Tablo_Actionneur[idBD].NbOperations; + NbOp:=Tablo_Action[idBD].NbOperations; if NbOp<1 then exit; - NumOp:=Tablo_Actionneur[idBD].TabloOp[indexSrc+1].numoperation; - s:='Voulez vous supprimer l''action '+#13+operations[NumOp].Nom+' ?'; + NumOp:=Tablo_Action[idBD].TabloOp[indexSrc+1].numoperation; + s:='Voulez vous supprimer l''opération '+#13+operations[NumOp].Nom+' ?'; if Application.MessageBox(pchar(s),pchar('confirm'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then exit; // supprimer - listboxoperations.Items.Delete(indexSrc); + FormModifAction.listboxoperations.Items.Delete(indexSrc); for i:=IndexSrc+1 to NbOp-1 do begin - Tablo_Actionneur[idBD].TabloOp[i]:=Tablo_Actionneur[idBD].TabloOp[i+1]; + Tablo_Action[idBD].TabloOp[i]:=Tablo_Action[idBD].TabloOp[i+1]; end; dec(NbOp); - Tablo_Actionneur[idBD].NbOperations:=NbOp; - Setlength(Tablo_Actionneur[idBD].tabloOp,NbOp+1); + Tablo_Action[idBD].NbOperations:=NbOp; + Setlength(Tablo_Action[idBD].tabloOp,NbOp+1); Aff_champs(idBD,1,IndexSrc+1); exit; - - - // réencoder la ligne + // réencoder la ligne s:=encode_actions(idBD); // maj combobox - ComboBoxActions.Items[idBD-1]:=s; - ComboBoxActions.ItemIndex:=idbd-1; + FormModifAction.ComboBoxActions.Items[idBD-1]:=s; + FormModifAction.ComboBoxActions.ItemIndex:=idbd-1; +end; + +procedure TFormModifAction.SpeedButtonSupprimeClick(Sender: TObject); +begin + supprime_operation; end; procedure TFormModifAction.SpinButton1UpClick(Sender: TObject); @@ -1020,9 +1030,9 @@ begin if (indexSrc<1) then exit; - top:=Tablo_Actionneur[idBD].TabloOp[idOp-1]; - Tablo_Actionneur[idBD].TabloOp[idOp-1]:=Tablo_Actionneur[idBD].TabloOp[idOp]; - Tablo_Actionneur[idBD].TabloOp[idOp]:=top; + top:=Tablo_Action[idBD].TabloOp[idOp-1]; + Tablo_Action[idBD].TabloOp[idOp-1]:=Tablo_Action[idBD].TabloOp[idOp]; + Tablo_Action[idBD].TabloOp[idOp]:=top; // réencoder la ligne s:=encode_actions(idBD); @@ -1034,9 +1044,9 @@ begin with FormModifAction.ListBoxOperations do begin clear; - for i:=1 to Tablo_Actionneur[idBD].NbOperations do + for i:=1 to Tablo_Action[idBD].NbOperations do begin - no:=Tablo_Actionneur[idBD].tabloOp[i].numoperation; + no:=Tablo_Action[idBD].tabloOp[i].numoperation; items.Add(Format('%d%s', [no-1, operations[no].nom])); // valeur d'index de l'icone dans la ImagelistIcones itemHeight:=17; end; @@ -1060,12 +1070,12 @@ begin idop:=indexSrc+1; - no:=Tablo_Actionneur[idBD].NbOperations; + no:=Tablo_Action[idBD].NbOperations; if (indexSrc+1>=No) then exit; - top:=Tablo_Actionneur[idBD].TabloOp[idOp+1]; - Tablo_Actionneur[idBD].TabloOp[idOp+1]:=Tablo_Actionneur[idBD].TabloOp[idOp]; - Tablo_Actionneur[idBD].TabloOp[idOp]:=top; + top:=Tablo_Action[idBD].TabloOp[idOp+1]; + Tablo_Action[idBD].TabloOp[idOp+1]:=Tablo_Action[idBD].TabloOp[idOp]; + Tablo_Action[idBD].TabloOp[idOp]:=top; // réencoder la ligne @@ -1078,9 +1088,9 @@ begin with FormModifAction.ListBoxOperations do begin clear; - for i:=1 to Tablo_Actionneur[idBD].NbOperations do + for i:=1 to Tablo_Action[idBD].NbOperations do begin - no:=Tablo_Actionneur[idBD].tabloOp[i].numoperation; + no:=Tablo_Action[idBD].tabloOp[i].numoperation; items.Add(Format('%d%s', [no-1, operations[no].nom])); // valeur d'index de l'icone dans la ImagelistIcones itemHeight:=17; end; @@ -1111,16 +1121,16 @@ begin index:=ligneclicAct+1; if affevt then Affiche('EditAdrChange',clyellow); - decl:=Tablo_actionneur[ligneclicAct+1].declencheur; + decl:=Tablo_Action[ligneclicAct+1].declencheur; val(editAdr.Text,i,erreur); if (i<0) or (erreur<>0) then exit; if decl=DeclHorloge then begin if (i>23) then exit; - Tablo_actionneur[index].heure:=i; + Tablo_Action[index].heure:=i; end - else Tablo_actionneur[index].adresse:=i; + else Tablo_Action[index].adresse:=i; maj_combocactions(ligneclicAct); end; @@ -1130,7 +1140,7 @@ begin if (ligneclicAct<0) or clicliste then exit; index:=ligneclicAct+1; - decl:=Tablo_actionneur[ligneclicAct+1].declencheur; + decl:=Tablo_Action[ligneclicAct+1].declencheur; if (decl<>DeclZoneDet) and (decl<>DeclHorloge) then exit; @@ -1140,9 +1150,9 @@ begin if decl=DeclHorloge then begin if (i>59) then exit; - Tablo_actionneur[index].minute:=i; + Tablo_Action[index].minute:=i; end; - if decl=DeclZoneDet then Tablo_actionneur[index].adresse2:=i; + if decl=DeclZoneDet then Tablo_Action[index].adresse2:=i; maj_combocactions(ligneclicAct); end; @@ -1152,12 +1162,12 @@ begin if (ligneclicAct<0) or clicliste then exit; index:=ligneclicAct+1; - decl:=Tablo_actionneur[ligneclicAct+1].declencheur; + decl:=Tablo_Action[ligneclicAct+1].declencheur; if (decl<>declAccessoire) and (decl<>DeclDetAct) and (decl<>DeclZoneDet) then exit; val(SpinEditEtat.Text,i,erreur); if (i<0) or (i>2) or (erreur<>0) then exit; - Tablo_actionneur[index].etat:=i; + Tablo_Action[index].etat:=i; maj_combocactions(ligneclicAct); end; @@ -1169,13 +1179,13 @@ begin if affevt then Affiche('EditTrainDeclChange',clyellow); index:=ligneclicAct+1; - decl:=Tablo_actionneur[ligneclicAct+1].declencheur; + decl:=Tablo_Action[ligneclicAct+1].declencheur; if (decl<>declDetAct) and (decl<>DeclZoneDet) and (decl<>DeclPeriph) and (decl<>DeclDemarTrain) and (decl<>DeclArretTrain) then exit; 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; + then Tablo_Action[index].trainDecl:=EditTrainDecl.text; + if decl=DeclPeriph then Tablo_Action[index].ordrePeriph:=EditTrainDecl.text; maj_combocactions(ligneclicAct); end; @@ -1195,11 +1205,11 @@ var i,erreur,op : integer; begin if (ligneclicAct<0) or clicliste then exit; val(LabeledEditAdresse.Text,i,erreur); - op:=Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].numoperation; + op:=Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].numoperation; case op of - ActionAffTCO : Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].numTCO:=i; - ActionAccessoire: Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].adresse:=i; - ActionVitesse : Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].vitesse:=i; + ActionAffTCO : Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].numTCO:=i; + ActionAccessoire: Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].adresse:=i; + ActionVitesse : Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].vitesse:=i; end; maj_combocactions(ligneclicAct); end; @@ -1210,10 +1220,10 @@ begin if clicAction<0 then exit; if (ligneclicAct<0) or clicliste then exit; val(LabeledEditFonctionF.Text,i,erreur); - op:=Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].numoperation; + op:=Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].numoperation; case op of - ActionFonctionF : Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].FonctionF:=i; - ActionTempo : Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].TempoF:=i; + ActionFonctionF : Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].FonctionF:=i; + ActionTempo : Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].TempoF:=i; end; maj_combocactions(ligneclicAct); end; @@ -1223,7 +1233,7 @@ var op : integer; s : string; begin if (clicAction<0) or clicListe then exit; - op:=Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].numoperation; + op:=Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].numoperation; if (op=ActionFonctionF) or (op=ActionVitesse) or (op=ActionSon) then begin s:=LabeledEditTrain.Text; @@ -1233,9 +1243,9 @@ begin exit; end; labelInfo.Caption:=''; - Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].train:=s; + Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].train:=s; end; - if op=ActionCdePeriph then Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].chaine:=LabeledEditTrain.Text; + if op=ActionCdePeriph then Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].chaine:=LabeledEditTrain.Text; maj_combocactions(ligneclicact); end; @@ -1260,8 +1270,8 @@ begin begin s:=openDialogSon.FileName; LabeledEditTrain.Text:=s; - op:=Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].numoperation; - if op=ActionSon then Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].train:=s; + op:=Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].numoperation; + if op=ActionSon then Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].train:=s; end; maj_combocactions(ligneclicAct); end; @@ -1270,8 +1280,8 @@ procedure TFormModifAction.CheckBoxRAZClick(Sender: TObject); var op : integer; begin if clicAction<0 then exit; - op:=Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].numoperation; - if (op=ActionAccessoire) then Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].zero:=CheckBoxRaz.Checked; + op:=Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].numoperation; + if (op=ActionAccessoire) then Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].zero:=CheckBoxRaz.Checked; maj_combocactions(ligneclicAct); end; @@ -1417,7 +1427,7 @@ begin ClicDeclenche:=ListBoxdeclench.itemindex; if clicDeclenche<0 then exit; i:=Clicdeclenche+1; - Tablo_actionneur[ligneclicAct+1].declencheur:=i; + Tablo_Action[ligneclicAct+1].declencheur:=i; Aff_champs(ligneclicAct+1,0,0); end; @@ -1428,7 +1438,7 @@ begin if (ligneclicAct<0) or clicliste then exit; index:=ligneclicAct+1; - Tablo_actionneur[index].NomAction:=LabeledEditNomAct.text; + Tablo_Action[index].NomAction:=LabeledEditNomAct.text; Aff_champs(index,0,0); end; @@ -1441,7 +1451,7 @@ begin if (ligneclicAct<0) or clicliste then exit; index:=ligneclicAct+1; if affevt then affiche('Evt ComboBox Change',clyellow); - Tablo_Actionneur[ligneClicAct+1].TabloOp[clicaction+1].periph:=formModifAction.ComboBoxAccComUSB.ItemIndex+1; + Tablo_Action[ligneClicAct+1].TabloOp[clicaction+1].periph:=formModifAction.ComboBoxAccComUSB.ItemIndex+1; Aff_champs(index,0,clicaction+1); end; @@ -1451,14 +1461,14 @@ begin if clicAction<0 then exit; if (ligneclicAct<0) or clicliste then exit; val(LabeledEditTempoF.Text,i,erreur); - Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].TempoF:=i; + Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].TempoF:=i; maj_combocactions(ligneclicAct); end; procedure TFormModifAction.ListBoxOperationsDblClick(Sender: TObject); begin if (clicAction<0) or (ligneclicAct<0) or clicliste then exit; - Tablo_Actionneur[ligneclicAct+1].tabloOp[clicaction+1].valide:=not(Tablo_Actionneur[ligneclicAct+1].tabloOp[clicaction+1].valide); + Tablo_Action[ligneclicAct+1].tabloOp[clicaction+1].valide:=not(Tablo_Action[ligneclicAct+1].tabloOp[clicaction+1].valide); maj_combocactions(ligneclicAct); end; @@ -1520,7 +1530,7 @@ begin i:=Index_Condition(s); if (IndexDest<0) then IndexDest:=0; - Tablo_Actionneur[ligneClicAct+1].TabloCond[IndexDest+1].numCondition:=i; + Tablo_Action[ligneClicAct+1].TabloCond[IndexDest+1].numCondition:=i; listboxConditions.Items[indexDest]:=ListBoxCondTot.Items[indexSrc]; @@ -1535,11 +1545,11 @@ 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; + cond:=Tablo_Action[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; + CondVitTrain : Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].vitmini:=i; + CondPosAcc : Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].accessoire:=i; + CondTrainSig : Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].adresse:=i; end; maj_combocactions(ligneclicAct); end; @@ -1549,9 +1559,9 @@ 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; + cond:=Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].numcondition; case cond of - CondVitTrain : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].vitmaxi:=i; + CondVitTrain : Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].vitmaxi:=i; end; maj_combocactions(ligneclicAct); end; @@ -1561,9 +1571,9 @@ var cond,i : integer; begin if (ligneclicAct<0) or clicliste then exit; i:=SpinEditHeure1.Value; - cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + cond:=Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].numcondition; case cond of - CondHorl : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].HeureMin:=i; + CondHorl : Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].HeureMin:=i; end; maj_combocactions(ligneclicAct); end; @@ -1574,9 +1584,9 @@ var cond,i : integer; begin if (ligneclicAct<0) or clicliste then exit; i:=SpinEditMn1.Value; - cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + cond:=Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].numcondition; case cond of - CondHorl : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].MinuteMin:=i; + CondHorl : Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].MinuteMin:=i; end; maj_combocactions(ligneclicAct); end; @@ -1586,9 +1596,9 @@ var cond,i : integer; begin if (ligneclicAct<0) or clicliste then exit; i:=SpinEditHeure2.Value; - cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + cond:=Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].numcondition; case cond of - CondHorl : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].HeureMax:=i; + CondHorl : Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].HeureMax:=i; end; maj_combocactions(ligneclicAct); end; @@ -1598,9 +1608,9 @@ var cond,i : integer; begin if (ligneclicAct<0) or clicliste then exit; i:=SpinEditMn2.Value; - cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + cond:=Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].numcondition; case cond of - CondHorl : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].MinuteMax:=i; + CondHorl : Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].MinuteMax:=i; end; maj_combocactions(ligneclicAct); @@ -1610,9 +1620,9 @@ 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; + cond:=Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].numcondition; case cond of - CondVitTrain,CondTrainSig : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].train:=ChampTrain.Text; + CondVitTrain,CondTrainSig : Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].train:=ChampTrain.Text; end; maj_combocactions(ligneclicAct); @@ -1623,9 +1633,9 @@ var cond,i : integer; begin if (ligneclicAct<0) or clicliste then exit; i:=SpinEditEtat2.Value; - cond:=Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].numcondition; + cond:=Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].numcondition; case cond of - CondPosAcc : Tablo_actionneur[ligneclicact+1].tabloCond[cliccond+1].etat:=i; + CondPosAcc : Tablo_Action[ligneclicact+1].tabloCond[cliccond+1].etat:=i; end; maj_combocactions(ligneclicAct); end; @@ -1637,21 +1647,69 @@ begin index:=ligneclicAct+1; if affevt then Affiche('EditAdrChange',clyellow); - Tablo_actionneur[index].etat:=RadioEtatSignal.ItemIndex; + Tablo_Action[index].etat:=RadioEtatSignal.ItemIndex; maj_combocactions(ligneclicAct); end; procedure TFormModifAction.SpinEditEtatopChange(Sender: TObject); -var i,erreur,op : integer; +var i,op : integer; begin if (ligneclicAct<0) or clicliste then exit; i:=SpinEditEtatop.Value; - op:=Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].numoperation; + op:=Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].numoperation; case op of - ActionAccessoire : Tablo_actionneur[ligneclicact+1].tabloOp[clicaction+1].etat:=i; + ActionAccessoire : Tablo_Action[ligneclicact+1].tabloOp[clicaction+1].etat:=i; end; maj_combocactions(ligneclicAct); end; +procedure TFormModifAction.ListBoxOperationsKeyDown(Sender: TObject; + var Key: Word; Shift: TShiftState); +var nb : integer; +begin + nb:=Tablo_Action[ligneclicAct+1].NbOperations; + if (nb<1) or clicliste then exit; + if key=VK_delete then supprime_operation; + + exit; // interfére,ce avec montée baisse + if ord(Key)=VK_UP then + begin + clicListe:=true; + //with FormModifAction.ListBoxOperations.Items do + begin + if clicAction>0 then + begin + dec(clicaction); + Aff_champs(ligneclicAct+1,ClicCond+1,ClicAction+1); + Formconfig.ListBoxactions.Itemindex:=clicaction; + end; + end; + end; + + if ord(Key)=VK_DOWN then + begin + //if clicListe then exit; + clicListe:=true; + //with Formconfig.ListBoxactions.Items do + begin + if clicaction OnDrawPanel = StatusBar1DrawPanel end - object Button1: TButton - Left = 1023 - Top = 0 - Width = 75 - Height = 25 - Anchors = [akTop, akRight] - Caption = 'Button1' - TabOrder = 1 - Visible = False - OnClick = Button1Click - end object GrandPanel: TPanel Left = 8 Top = 48 Width = 1057 Height = 484 - TabOrder = 2 + TabOrder = 1 DesignSize = ( 1057 484) @@ -1518,7 +1507,6 @@ object FormPrinc: TFormPrinc Font.Style = [] ParentFont = False PopupMenu = PopupMenuFenRich - ReadOnly = True ScrollBars = ssBoth TabOrder = 0 WordWrap = False @@ -2048,24 +2036,13 @@ 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 + Left = 504 Top = 8 Width = 75 Height = 25 - Caption = 'Button3' - TabOrder = 4 - Visible = False + Caption = 'Route' + TabOrder = 2 OnClick = Button3Click end object Timer1: TTimer @@ -2144,6 +2121,10 @@ object FormPrinc: TFormPrinc Caption = 'Codification des cantons' OnClick = Codificationdescantons1Click end + object Codificationdestrains1: TMenuItem + Caption = 'Codification des trains' + OnClick = Codificationdestrains1Click + end object N5: TMenuItem Caption = '-' end @@ -2432,8 +2413,19 @@ object FormPrinc: TFormPrinc end object Roulage1: TMenuItem Caption = 'Roulage' + object Routes1: TMenuItem + Caption = 'Fen'#234'tre des routes' + OnClick = Routes1Click + end + object Afficheroutespartrain1: TMenuItem + Caption = 'Affiche les routes par train' + OnClick = Afficheroutespartrain1Click + end + object N17: TMenuItem + Caption = '-' + end object OpRoulage: TMenuItem - Caption = 'Op'#233'rations de roulage' + Caption = 'Positionner les aiguillages en position initiale' OnClick = OpRoulageClick end object RazResa: TMenuItem diff --git a/UnitPrinc.pas b/UnitPrinc.pas index 964a71c..0bab3aa 100644 --- a/UnitPrinc.pas +++ b/UnitPrinc.pas @@ -1,12 +1,23 @@ -Unit UnitPrinc; -// 06/04/2024 22h +unit Unitprinc; +// 01/07/2024 14h (******************************************** Programme signaux complexes Graphique Lenz - Delphi 7 + activeX Tmscomm + clientSocket - ou RadStudio - options de compilation: options du debugger/exception du langage : décocher "arreter sur exceptions delphi" + [Delphi 7 ou RadStudio (Delphi 11)] + activeX Tmscomm + clientSocket + + Options de compilation: options du debugger/exception du langage : décocher "arreter sur exceptions delphi" sinon une exception surgira au moment de l'ouverture du com Dans projet/option/fiches : fiches disponibles : formtco uniquement + En cas d'erreur interne L1333, supprimer les fichiers DCU ou simplement faire construire + + Notes pour compilation sous Embarcadero : -------------------------------------------------- + Pour compilation avec Rad Studio (Delphi11): Projet / Options // Application / Apparence / + Embarcadero technologies / coher tous les thèmes : carbon Auric etc / et choisir le sytle par défaut : windows sinon plantage + + Pour le mode sombre sous Embarcadero, il faut sélectionner: + Projet / Options // Application / manifeste / fichier manifeste : personnaliser + à la sauvegarde, ce champ appraitra sous "générer automatiquement" + et : décocher "activer les thèmes d'exécution" + ******************************************** Pour TMSCOM : il est nécessaire d'avoir le fichier mscomm32.ocx dans le repertoire system de windows @@ -14,21 +25,20 @@ Unit UnitPrinc; et que ce composant soit enregistré (avec regsvr32) Attention si le répertoire d'install n'est pas autorisé, windows10-11 va sauver les fichiers dans - C:\Users\moi\AppData\Local\VirtualStore\Program Files (x86)\Signaux_complexes + C:\Users\Nom_utilisateur\AppData\Local\VirtualStore\Program Files (x86)\Signaux_complexes il faut autoriser l'utilisateur: Utilisateurs (nom\utilisateurs) - Pilotage des accessoires: raquette octet sortie + 2 = vert = aiguillage droit = sortie 2 de l'adresse d'accessoire - 1 = rouge = aiguillage dévié = sortie 1 de l'adresse d'accessoire - vitesse port com lenz par défaut=57600 + vitesse port com interface lenz LI-USB-ETH par défaut=57600 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, ou pendant le RUN // les noms des trains sont bien renvoyés sur les actionneurs à 1 @@ -40,7 +50,7 @@ Unit UnitPrinc; // 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 -// sur le réseau. +// sur le réseau. Les aiguillages oui // // En simulation: // CDM Rail ne renvoie pas les états des aiguillages en début de simu @@ -50,16 +60,9 @@ Unit UnitPrinc; // En mode centrale connectée à signaux complexes (autonome) // si on bouge un aiguillage à la raquette, on récupère bien sa position par XpressNet. // Une loco sur un détecteur au lancement ne renvoie pas son état statique. Seuls les changements -// d'état sont renvoyés par la centrale. +// d'état sont renvoyés par la centrale. Ou alors il faut demander explicitement les états des détecteurs +// à la centrale par le menu "interface / demander état détecteurs" // -// Notes pour compilation sous Embarcadero : -------------------------------------------------- -// Pour compilation avec Rad Studio (Delphi11): Projet / Options // Application / Apparence / -// Embarcadero technologies / carbon ou Auric / et choisir le sytle par défaut : windows -// -// Pour le mode sombre sous embarcadero, il faut sélectionner: -// Projet / Options // Application / manifeste / fichier manifeste : personnaliser -// à la sauvegarde, ce champ appraitra sous "générer automatiquement" -// et : décocher "activer les thèmes d'exécution" //{$Q-} // pas de vérification du débordement des opérations de calcul //{$R-} // pas de vérification des limites d'index du tableau et des variables @@ -71,7 +74,7 @@ uses ImgList, ScktComp, StrUtils, Menus, ActnList, MSCommLib_TLB, MMSystem , Buttons, NB30, comObj, activeX ,DateUtils {$IF CompilerVersion >= 28.0} // si delphi>=11 - ,Vcl.Themes + ,Vcl.Themes // pour les thèmes d'affichage (auric etc) {$IFEND} ; @@ -140,7 +143,6 @@ type OpRoulage: TMenuItem; Demandetatdtecteurs1: TMenuItem; Informationsdusignal1: TMenuItem; - Button1: TButton; Evenementsdetecteurspartrain1: TMenuItem; RazResa: TMenuItem; Vrifiernouvelleversion1: TMenuItem; @@ -242,8 +244,11 @@ type N16: TMenuItem; Afficherlhorloge1: TMenuItem; Codificationdescantons1: TMenuItem; - Button2: TButton; Button3: TButton; + Routes1: TMenuItem; + N17: TMenuItem; + Codificationdestrains1: TMenuItem; + Afficheroutespartrain1: TMenuItem; procedure FormCreate(Sender: TObject); procedure RecuInterface(Sender: TObject); procedure RecuPeriph1(Sender: TObject); @@ -315,7 +320,6 @@ type procedure ButtonEnvClick(Sender: TObject); procedure OpRoulageClick(Sender: TObject); procedure Demandetatdtecteurs1Click(Sender: TObject); - procedure Button1Click(Sender: TObject); procedure Informationsdusignal1Click(Sender: TObject); procedure Evenementsdetecteurspartrain1Click(Sender: TObject); procedure RazResaClick(Sender: TObject); @@ -389,8 +393,10 @@ type procedure Ini1Click(Sender: TObject); procedure Afficherlhorloge1Click(Sender: TObject); procedure Codificationdescantons1Click(Sender: TObject); - procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); + procedure Routes1Click(Sender: TObject); + procedure Codificationdestrains1Click(Sender: TObject); + procedure Afficheroutespartrain1Click(Sender: TObject); private { Déclarations privées } procedure DoHint(Sender : Tobject); @@ -408,7 +414,7 @@ type const titre='Signaux complexes GL '; -itMaxi=50; // itérations maxi pour les recherches +itMaxi=70; // 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 @@ -416,7 +422,8 @@ MaxZones=250; // nombre de zones de d MaxTrainZone=40; // nombre maximal de trains pour le tableau d'historique des zones Mtd=128; // nombre maxi de détecteurs précédents stockés Max_event_det=4000; // nombre maximal d'évenements détecteurs -Max_actionneurs=100; // nombre maximal d'actionneurs +Max_action=100; // nombre maximal d'actions +Max_actionneurs=2048; Maxelements=100; // nombre maxi d'éléments scannés/réservés MaxBranches=200; // nombre maxi de branches MaxElBranches=200; // nombre maxi d'éléments par branche @@ -433,7 +440,11 @@ const_devieG_CDM=3; // positions aiguillages transmises par cdm const_devieD_CDM=2; // positions aiguillages transmises par cdm const_droit_CDM=0; // positions aiguillages transmises par cdm const_inconnu=9; // position inconnue +const_pointe=10; // aiguillage pris en pointe +const_talon=11; // aiguillage pris en talon IdClients=10; // Index maxi de clients +MaxParcours=200; +MaxRoutes=3000; NbCouleurTrain=8; MaxCdeDccpp=20; couleurTexte=$A0FFFF; @@ -446,7 +457,7 @@ couleurTrain : array[0..NbCouleurTrain] of Tcolor = (clRose,clYellow,clLime,ClCy Max_Simule=10000; Max_Event_det_tick=30000; EtatSign : array[0..13] of string[20] =('carré','sémaphore','sémaphore cli','vert','vert cli','violet', - 'blanc','blanc cli','jaune','jaune cli','ral 30','ral 60','rappel 30','rappel 60'); + 'blanc','blanc cli','avertissement','jaune cli','ral 30','ral 60','rappel 30','rappel 60'); // texte de la combo box des signaux - attention ce n'est pas l'index de Signaux[x].aspect!! Aspects : array[0..11] of string[20]=('2 feux','3 feux','4 feux','5 feux','7 feux','9 feux','Directionnel 2 feux','Directionnel 3 feux','Directionnel 4 feux', @@ -454,7 +465,7 @@ Aspects : array[0..11] of string[20]=('2 feux','3 feux','4 feux','5 feux','7 feu // combinaisons possibles des états français Etats : array[0..20] of string[30]=('Non commandé', - 'carré','sémaphore','sémaphore cli','vert','vert cli','violet','blanc','blanc cli','jaune','jaune cli', + 'carré','sémaphore','rouge cli','vert','vert cli','violet','blanc','blanc cli','avertissement','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','reserve'); @@ -549,7 +560,7 @@ Taiguillage = record Adresse : integer; // adresse de l'aiguillage AncienAdresse : integer; modele : TEquipement; // rien, aig, tjd ... - position, // position actuelle : 1=dévié 2=droit (centrale LENZ) + position,AncPos, // position actuelle : 1=dévié 2=droit (centrale LENZ) , position ancienne posInit, // position d'initialisation 1=dévié 2=droit 9=non positionné Adrtriple, // 2eme adresse pour un aiguillage triple temps, // temps de pilotage (durée de l'impulsion en x 100 ms @@ -576,10 +587,9 @@ Taiguillage = record // si modifié en mode config modifie : boolean ; - NumBranche,IndexBranche : integer; // index dans les branches AdrCDM : integer; // adresse de l'aiguillage dans CDM, si c'est une BDJ (bretelle double jonction) end; -TtabloDet = array[1..Mtd] of integer; +TtabloDet = array[0..MaxParcours] of integer; TSignal = record adresse, aspect : integer; // adresse du signal, aspect (2 feux..9 feux 12=direction 2 feux .. 16=direction 6 feux) (11=signal belge 1) Img : TImage; // Pointeur sur structure TImage du feu @@ -606,12 +616,13 @@ 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 AncienAff : word ; // état ancien affichage - UniSemaf : integer ; // définition supplémentaire de la cible pour les décodeurs UNISEMAF + UniSemaf : integer ; // définition supplémentaire de la cible pour les décodeurs UNISEMAF + BinLin : integer; // Binaire=0 ou Linéaire décodeur LEB AigDirection : array[1..7] of array of record // pour les signaux directionnels : contient la liste des aiguillages associés Adresse : integer; // 6 feux max associés à un tableau dynamique décrivant les aiguillages +1 position 0 posAig : char; @@ -694,8 +705,28 @@ Taction = TabloOp : array of Toperation; end; -var +Tactionneur = + record + adresse, + prox1,prox2 : integer; + NumBranche,IndexBranche : integer; + end; +TelementRoute=record // l'index 0 contient le nombre d'éléments + adresse : integer; + typ : tequipement; + pos : integer; + talon : boolean; + traite : boolean; // traité ou non par la procédure aig_canton + end; + +TUneRoute=array[0..MaxParcours] of TelementRoute; + +TElroute=array[1..MaxRoutes] of TUneroute; + +Tparcours=array[1..MaxParcours] of integer; + +var maxaiguillage,detecteur_chgt,Temps,Tempo_init,Suivant,ntrains,MaxPortCom, N_Cv,index_simule,NDetecteurs,N_Trains,N_routes,espY,Tps_affiche_retour_dcc, NbreImagePligne,NbreBranches,Index2_aig,branche_det,ntrains_cdm, @@ -704,20 +735,22 @@ var NombreImages,signalCpx,branche_trouve,Indexbranche_trouve,Actuel,Signal_suivant, Nbre_recu_cdm,Tempo_chgt_feux,Adj1,Adj2,NbrePN,ServeurInterfaceCDM,index_couleur, ServeurRetroCDM,TailleFonte,Nb_Det_Dist,Tdoubleclic,algo_Unisemaf,fA,fB, - etape,idEl,avecRoulage,intervalle_courant,filtrageDet0, + etape,idEl,intervalle_courant,filtrageDet0,Nactionneurs, TpsTimeoutSL,formatY,OsBits,NbreDecPers,NbDecodeur,NbDecodeurdeBase, LargeurF,HauteurF,OffsetXF,OffsetYF,PosSplitter,NbPeriph,NbPeriph_COMUSB,NbPeriph_Socket, - AigMal,AncMinute,axFP,ayFP,NbreOperations,NbreDeclencheurs,index_seqAct,NbreConditions : integer; + AigMal,AncMinute,axFP,ayFP,NbreOperations,NbreDeclencheurs,index_seqAct,NbreConditions, + SensAig,NbreRoutes,nbreIti,DetAtrouve,DetDepart,iteration,IdActTr, + prec1,prec2,Eprec,Esuiv : integer; ack,portCommOuvert,traceTrames,AffMem,CDM_connecte,dupliqueEvt,affiche_retour_dcc, Raz_Acc_signaux,AvecInit,AvecTCO,terminal,Srvc_Aig,Srvc_Det,Srvc_Act,MasqueBandeauTCO, Srvc_Pos,Srvc_Sig,debugtrames,LayParParam,AvecFVR,InverseMotif,Srvc_tdcc, - Hors_tension,traceSign,TraceZone,parSocketLenz,ackCdm,PremierFD,doubleclic, + Hors_tension,TraceZone,parSocketLenz,ackCdm,PremierFD,doubleclic, NackCDM,MsgSim,StopSimu,succes,recu_cv,AffAigDet,AffTiers,AvecDemandeAiguillages, TraceListe,clignotant,nack,Maj_signaux_cours,configNulle,LanceCDM,AvecInitAiguillages, AvecDemandeInterfaceUSB,AvecDemandeInterfaceEth,aff_acc,affiche_aigdcc,modeStkRetro, retEtatDet,roulage,init_aig_cours,affevt,placeAffiche,clicComboTrain,clicAdrTrain, - fichier_module_cdm,Diffusion,cdmDevant,avecRESA,serveurIPCDM_Touche, + fichier_module_cdm,Diffusion,cdmDevant,serveurIPCDM_Touche,avecAckCDM, sombre,serveur_ouvert,pasChgTBV,FpBouge,debugPN : boolean; tick,Premier_tick : longint; @@ -735,12 +768,20 @@ var detecteur : array[0..NbMaxDet] of // détecteurs indexés par l'adresse record - Etat : boolean; // état 0/1 du détecteur - Train : string; // nom du train ayant enclenché le détecteur (CDM - pas fiable) - AdrTrain : integer; // adresse du train "train" - IndexTrain : integer; // index du train - Tempo0 : integer; // tempo de retombée à 0 du détecteur (filtrage) + Etat : boolean; // état 0/1 du détecteur + Train : string; // nom du train ayant enclenché le détecteur (CDM - pas fiable) + AdrTrain : integer; // adresse du train sur le détecteur + AdrTrainRes : integer; // adresse du train qui réserve le détecteur + IndexTrainRoulant : integer; // index du train placé (généré dans calcul_zones_V1F) + Tempo0 : integer; // tempo de retombée à 0 du détecteur (filtrage) NumBranche,IndexBranche : integer; // où se trouve le détecteur dans les branches + index : integer; + canton1,canton2 : integer; // Numéro (pas index) des deux cantons adjacents (1 ou 2) + longueur : integer; // longueur en cm + temps : integer; // temps depuis détecteur à 1 ou à 0 + distanceTr : integer; // distance du train au fd du détecteur + suivant,precedent : integer; // éléments suivants/précédents pour le sens de circulation en cours + TypSuivant,TypPrecedent : Tequipement; end; Adresse_detecteur : array[0..NbMaxDet] of integer; // adresses des détecteurs par index @@ -753,7 +794,9 @@ var PortDistant,PortLocal : integer; end; - TypeGen : TEquipement; + Actionneur_trouve : array[1..10] of integer; + + TypeGen,t1,t2,tprec,tsuiv : TEquipement; // Historique des zones d'occupation par train TrainZone : array[1..MaxTrainZone] of // train, index @@ -786,11 +829,14 @@ var record etat : boolean; // mémoires de zones des détecteurs train : string; - IndexTrain, // index du tableau de tous les trains + IndexTrainRoulant, // index du train placé (généré dans calcul_zones_V1) AdrTrain : integer; + Prev : integer ; // détecteur suivant prévisionnel end; - Tablo_actionneur : array[0..Max_actionneurs] of Taction; + Tablo_action : array[0..Max_action] of Taction; + + Actionneur : array[0..Max_actionneurs] of Tactionneur; // décodeurs personnalisés de signaux decodeur_pers : array[1..NbreMaxiDecPers] of @@ -812,7 +858,7 @@ var Ancien_actionneur : array[0..MaxAcc] of integer; KeyInputs: array of TInput; - Tablo_PN : array[0..Max_actionneurs] of TPn; + Tablo_PN : array[0..Max_action] of TPn; Tablo_Simule : array[0..Max_Simule] of record @@ -874,22 +920,27 @@ var trains : array[0..Max_Trains] of record nom_train : string; inverse : boolean; // placement + detecteurSuiv : integer; // détecteur vers lequel se dirige le train adresse,vitmax,VitNominale,VitRalenti : integer; vitesse : integer; // vitesse actuelle de pilotage 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 + TempoArretCour : integer; // valeur dynamique 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; - //----------------------------------- + // icone sur fenetre cdm (FormAnalyseCDM)--- 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 x0,y0,x1,y1 : integer; // ancien contour du tampon, pour l'animation dans la fenêtre cdm + // route ----------------------------------- + roulage : integer; // =1 train en roulage mais arrêté pour réservation par tiers =2 en roulage effectif + dernierDet : integer; // dernier détecteur traité + route : TuneRoute; // tableau de la route end; // éléments scannés et/ou verrouillés @@ -899,6 +950,9 @@ var typ : Tequipement; end; + TabloParcours,TabloRoute,TabloItin : TelRoute; + + // liste des évènements détecteurs event_det : array[1..Max_event_det] of record @@ -951,8 +1005,8 @@ procedure deconnecte_usb; function IsWow64Process: Boolean; procedure Dessine_signal_mx(CanvasDest : Tcanvas;x,y : integer;FrX,frY : real;adresse : integer;orientation : integer); procedure Pilote_acc0_X(adresse : integer;octet : byte); -Function pilote_acc(adresse : integer;octet : byte;Acc : TAccessoire) : boolean; -function etat_signal_suivant(Adresse,rang : integer;var AdrSignalsuivant : integer) : integer; +Function pilote_acc(adresse : integer;octet : byte;Acc : TAccessoire) : boolean; overload; +Function pilote_acc(adresse : integer;octet : byte;adrTrain : integer) : boolean; overload; function suivant_alg3(prec : integer;typeELprec : TEquipement;actuel : integer;typeElActuel : TEquipement;alg : integer) : integer; function detecteur_suivant_El(el1: integer;TypeDet1 : TEquipement;el2 : integer;TypeDet2 : TEquipement;alg : integer) : integer ; function test_memoire_zones(adresse : integer) : boolean; @@ -962,6 +1016,7 @@ function carre_signal(adresse,TrainReserve : integer;var reserveTrainTiers : boo procedure Event_Detecteur(Adresse : integer;etat : boolean;train : string); procedure Event_act(adr,adr2,etat : integer;trainDecl : string); function verif_UniSemaf(adresse,UniSem : integer) : integer; +function verif_LEB(adresse,UniSem : integer) : integer; function Select_dessin_Signal(TypeSignal : integer) : TBitmap; procedure cree_image(rang : integer); procedure trouve_aiguillage(adresse : integer); @@ -979,8 +1034,7 @@ 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); -procedure reserve_canton(detecteur1,detecteur2,adrtrain,NumTrain,NCantons : integer); -function signal_detecteur(detecteur : integer) : integer; +function reserve_canton(detecteur1,detecteur2,adrtrain,NumTrain,NCantons : integer) : integer; function det_suiv_cont(det1,det2,alg : integer) : integer; function BTypeToChaine(BT : TEquipement) : string; function testBit(n : word;position : integer) : boolean; @@ -1000,13 +1054,22 @@ function com_socket(i : integer) : integer; procedure liste_portcom; procedure mosaiqueH; procedure mosaiqueV; +// procédures signaux +function etat_signal_suivant(Adresse,rang : integer;var AdrSignalsuivant : integer) : integer; function InfoSignal(adresse : integer) : string; procedure det_prec_signal(adresse : integer;var tabloDet : TTabloDet); +function signal_sens(adrSig,det1,det2 : integer) : boolean; +procedure index_signal_det(adr : integer;var voie1,index1,voie2,index2 : integer); +function Signal_precedent(adresse : integer) : integer; +function signal_rouge(adresse : word) : boolean; +function chaine_signal(adresse : word) : string; +function signal_suivant_det(det1,det2 : integer) : integer; + procedure composant(c : tComponent;fond,texte : tColor); procedure maj_couleurs; procedure AffTexteIncliBordeTexture(c : TCanvas; x,y : integer; Fonte : tFont; clBord : TColor; EpBord : integer; PenMode : TPenMode; - Texture : tBitMap; texte : string; AngleDD : longint); + clfond : tColor; texte : string; AngleDD : longint); procedure change_style; function isDirectionnel(index : integer) : boolean; procedure stop_trains; @@ -1018,18 +1081,24 @@ 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 interface_ou_cdm; 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 ; +procedure prepare_route(depart,arrivee,sens : integer); +function route_to_string(tablo : tUneRoute) : string; +procedure supprime_route_train(idtrain : integer); +procedure trouve_element_V1(el: integer; TypeEl : TEquipement; Offset,branche_pref : integer); +procedure procetape(s : string); implementation uses UnitDebug, UnitPilote, UnitSimule, UnitTCO, UnitConfig, - Unitplace, verif_version , UnitCDF, UnitAnalyseSegCDM, UnitConfigCellTCO, + verif_version , UnitCDF, UnitAnalyseSegCDM, UnitConfigCellTCO, UnitConfigTCO,UnitSR, UnitHorloge, UnitFicheHoraire, UnitClock, UnitModifAction, - selection_train; + selection_train, UnitRouteTrains, + UnitRoute; { procedure menu_interface(MA : TMA); @@ -1189,8 +1258,11 @@ begin FormTCO[i].Visible:=false; Affiche_Fenetre_TCO(i,avecTCO); end; - renseigne_tous_cantons; - + renseigne_tous_cantons; // les cantons doivent être renseignés pour les evts détecteurs + + interface_ou_cdm; // démarrer l'interface , génère les evts détecteurs ; ou cdm + + maj_signaux(true); // si trains placés, mettre les signaux à jour formprinc.SetFocus; end; @@ -1241,7 +1313,7 @@ end; procedure procetape(s : string); begin if debug<>2 then exit; - MessageDlg('Etape '+intToSTR(etape)+' '+s,mtInformation,[mbOk],0); + MessageDlg('Etape '+intToSTR(etape)+#13+s,mtInformation,[mbOk],0); inc(etape); end; @@ -1260,18 +1332,19 @@ begin s:=Application.Hint; // texte du hint StatusBar1.Panels[0].text:=s; + formeTCO:=false; // détection d'un hint provoqué dans formtco if Screen.ActiveForm<>nil then begin NomForm:=uppercase(Screen.activeform.Name); formeTCO:=copy(NomForm,1,7)='FORMTCO'; - end; + 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 begin // hints des colonnes - if (s=s101) or (s=s93) or (s=s94) then + if (s=s101) or (s=s93) or (s=s94) then begin if not(colonneAffiche) then encadre_colonne; end @@ -1569,7 +1642,6 @@ begin if (code=jaune_cli) and not(clignotant) then Affiche('efface jaune',clred); if (code=semaphore_cli) and not(clignotant) then Affiche('efface rouge',clred); - // allumages if ((code=vert_cli) and (clignotant)) or (code=vert) then cercle(ACanvas,xVert,yVert,rayon,clGreen); if ((code=jaune_cli) and (clignotant)) or (code=jaune) then cercle(Acanvas,xJaune,yJaune,rayon,clOrange); @@ -1671,7 +1743,7 @@ begin if (orientation=2) then begin - //rotation 90° vers la gauche des feux + // rotation 90° vers la gauche des feux ech:=frY;frY:=frX;FrX:=ech; Temp:=HtImage-yjaune; YJaune:=XJaune;Xjaune:=Temp; Temp:=HtImage-ycarre; Ycarre:=Xcarre;Xcarre:=Temp; @@ -1692,7 +1764,7 @@ begin if (orientation=4) then begin - //rotation 180° + // rotation 180° Xjaune:=LgImage-Xjaune;YJaune:=HtImage-YJaune; XSem:=LgImage-XSem; YSem:=HtImage-YSem; XVert:=LgImage-Xvert; Yvert:=HtImage-Yvert; @@ -1767,7 +1839,7 @@ begin if (orientation=4) then begin - //rotation 180° + // rotation 180° Xjaune:=LgImage-Xjaune;YJaune:=HtImage-YJaune; XSem:=LgImage-XSem; YSem:=HtImage-YSem; XVert:=LgImage-Xvert; Yvert:=HtImage-Yvert; @@ -1788,7 +1860,7 @@ begin if not((code=semaphore_cli) and clignotant) then cercle(ACanvas,xSem,ySem,rayon,GrisF); if not((code=jaune_cli) and clignotant) then cercle(ACanvas,xjaune,yjaune,rayon,GrisF); - //allumages + // allumages if ((code=semaphore_cli) and (clignotant)) or (code=semaphore) then cercle(ACanvas,xsem,ysem,rayon,clRed); if ((code=blanc_cli) and (clignotant)) or (code=blanc) then cercle(ACanvas,xblanc,yblanc,rayon,clWhite); if (code=violet) then cercle(ACanvas,xblanc,yblanc,rayon,clViolet); @@ -1825,7 +1897,7 @@ begin end; if (orientation=2) then begin - //rotation 90° vers la gauche des feux + // rotation 90° vers la gauche des feux // calcul des facteurs de réduction pour la rotation ech:=frY;frY:=frX;FrX:=ech; Temp:=HtImage-yjaune;YJaune:=XJaune;Xjaune:=Temp; @@ -1839,7 +1911,7 @@ begin if (orientation=3) then begin - //rotation 90° vers la droite des feux + // rotation 90° vers la droite des feux // calcul des facteurs de réduction pour la rotation ech:=frY;frY:=frX;FrX:=ech; Temp:=LgImage-Xjaune;XJaune:=YJaune;Yjaune:=Temp; @@ -2026,21 +2098,29 @@ end; // clBord = Couleur de la bordure. // EpBord = Epaisseur de la bordure. // PenMode = TPenMode : utiliser en général pmCopy. -// Texture = BitMap de texture : Si Texture = Nil alors la face sera de la couleur de Fonte avec un contour de clBord si EpBord > 0. +// si Clfond=clback, on écrit en transparent // Texte = Texte à écrire. // AngleDD = Angle d'inclinaison en Dixièmes de degré. procedure AffTexteIncliBordeTexture(c : TCanvas; x,y : integer; Fonte : tFont; clBord : TColor; EpBord : integer; PenMode : TPenMode; - Texture : tBitMap; texte : string; AngleDD : longint); + clfond : tColor; texte : string; AngleDD : longint); var dc : Hdc; lgFont : Logfont; // structure d'attributs de police AncFonte,NouvFonte : Hfont; AncPen,NouvPen : Hpen; AncBrush,NouvBrush : Hbrush; + i : integer; begin C.Pen.Mode:=PenMode; dc:=C.Handle; + c.pen.Mode:=PmCopy; + c.pen.Color:=clfond; //clfond; + c.Brush.color:=clfond; + c.pen.width:=1; + i:=round(length(texte)*0.5*abs(fonte.size)); + c.Rectangle(x+2,y,x+15,y-i); + // Initialisation de la fonte zeroMemory(@lgFont,sizeOf(lgFont)); // remplit la structure de 0 strPCopy(lgFont.lfFaceName,Fonte.Name); // copie la chaîne dans le nom de la fonte depuis le paramètre @@ -2063,12 +2143,16 @@ begin AncPen:= SelectObject(dc,NouvPen); // Initialisation de la couleur de la police ou de la Texture : - if Texture=nil then NouvBrush := CreateSolidBrush(Fonte.color) - else NouvBrush := CreatePatternBrush(Texture.Handle); + //if Texture=nil then + NouvBrush := CreateSolidBrush(Fonte.color); + // else NouvBrush := CreatePatternBrush(Texture.Handle); AncBrush:=SelectObject(dc,NouvBrush); // Le contexte doit être transparent SetBkMode(dc,TRANSPARENT); + + + // Dessin du texe : BeginPath(dc); TextOut(dc,X,Y,PChar(Texte),length(texte)); //<- au lieu de TextOut(dc,X,Y,PansiChar(Texte),length(texte)) pour rendre le code compatible avec toutes les versions de Delphi (de D2 à XE2); @@ -2082,8 +2166,7 @@ begin DeleteObject(NouvPen); SelectObject(dc,AncBrush); DeleteObject(NouvBrush); -end; - +end; // inverse une image (miroir horizontal) et la met dans dest // Utilisé pour les signaux belges, et les trains procedure inverse_image(imageDest,ImageSrc : Timage); @@ -2310,7 +2393,7 @@ begin 3 : angle:=900; 4 : angle:=1800; end; - AffTexteIncliBordeTexture(Acanvas,XTexte,YTexte,Acanvas.Font,clYellow,0,pmcopy,nil,intToSTR(vitesse),angle); + AffTexteIncliBordeTexture(Acanvas,XTexte,YTexte,Acanvas.Font,clYellow,0,pmcopy,clblack,intToSTR(vitesse),angle); end; end; end @@ -2363,7 +2446,7 @@ begin begin LgImage:=Width; HtImage:=Height; - end; + end; end; if (orientation=2) then @@ -2627,7 +2710,7 @@ begin 5 : dessine_signal5(CanvasDest,x,y,frx,fry,Signaux[i].EtatSignal,orientation); 7 : dessine_signal7(CanvasDest,x,y,frx,fry,Signaux[i].EtatSignal,orientation); 9 : dessine_signal9(CanvasDest,x,y,frx,fry,Signaux[i].EtatSignal,orientation); - 20 : dessine_signal20(CanvasDest,x,y,frx,fry,Signaux[i].EtatSignal,orientation,Signaux[i].adresse); + 20 : dessine_signal20(CanvasDest,x,y,frx,fry,Signaux[i].EtatSignal,orientation,Signaux[i].adresse); // signal belge // indicateurs de direction 12..16 : dessine_dirN(CanvasDest,x,y,frx,fry,Signaux[i].EtatSignal,orientation,aspect-10); end; @@ -2651,7 +2734,7 @@ begin begin s:=copy(s,1,i-1); val(s,AdrPilote,erreur); - end; + end; end; end; @@ -2690,7 +2773,7 @@ begin 5 : Bm:=Formprinc.Image5feux.picture.Bitmap; 7 : Bm:=Formprinc.Image7feux.picture.Bitmap; 9 : Bm:=Formprinc.Image9feux.picture.Bitmap; - 20 : Bm:=Formprinc.ImageSignal20.picture.Bitmap; + 20 : Bm:=Formprinc.ImageSignal20.picture.Bitmap; // belge // signaux directionnels 12 : Bm:=Formprinc.Image2Dir.picture.Bitmap; @@ -3046,7 +3129,8 @@ begin 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;; + +//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; @@ -3337,16 +3421,23 @@ end; // envoie une vitesse à une loco par XpressNet/Dcc++ ou par CDM // index=index du train dans le tableau trains[] -// vitesse positive ou négative +// sens en fonction du sens dans le tableau train ou vitesse positive ou négative // répétition=avec répétition de la commande dans 1s +// +// Pilotage de l'inversion de vitesse (or 128) +// +// vitesse vitesse +// trains[].inverse <0 >=0 +// faux non oui +// vrai oui non +// inversion train[].inverse xor (vitesse>=0) procedure vitesse_loco(nom_train :string;index : integer;adr_loco : integer;vitesse : integer;repetition : boolean); var s : string; - sens : boolean; v,erreur : integer; begin if not(hors_tension) and ((portCommOuvert or parSocketLenz)) then begin - Affiche('vitesse train '+inttostr(adr_loco)+' '+inttostr(vitesse),clLime); + //Affiche('vitesse train '+inttostr(adr_loco)+' '+inttostr(vitesse),clLime); // mettre à jour la trackBar si le train sélectionné=editAdrTrain val(Formprinc.EditAdrTrain.Text,v,erreur); @@ -3356,14 +3447,14 @@ begin Formprinc.TrackBarVit.Position:=vitesse; pasChgTBV:=false; end; + if protocole=1 then begin //AfficheDebug('X9 train '+inttostr(loco)+' '+inttostr(vitesse),clOrange); - sens:=vitesse>0; vitesse:=abs(vitesse); if vitesse>127 then vitesse:=127; v:=vitesse; - if (sens) then v:=v or 128; + if (trains[index].inverse) xor (vitesse>=0) then v:=v or 128; s:=#$e4+#$13+#$0+char(adr_loco)+char(v); s:=checksum(s); envoi(s); @@ -3371,7 +3462,7 @@ begin if protocole=2 then begin s:='' else s:=s+'0>'; + if (trains[index].inverse) xor (vitesse>=0) then s:=s+'1>' else s:=s+'0>'; envoi(s); end; end; @@ -3390,13 +3481,10 @@ begin // répétition de la consigne dans 1 s if repetition then begin - // trains[index].nom_train:=Nom_train; - // trains[index].adresse:=adr_loco; trains[index].vitesse:=vitesse; - // trains[index].sens:=sens; trains[index].compteur_consigne:=10; end; - + trains[index].vitesse:=vitesse; end; @@ -3516,7 +3604,7 @@ begin i:=Index_Signal(adr); if (Signaux[i].EtatSignal<>code) then begin - if (traceSign) then Affiche('Signal directionnel: ad'+IntToSTR(adr)+'='+intToSTR(code),clOrange); + if (AffSig) then Affiche('Signal directionnel: ad'+IntToSTR(adr)+'='+intToSTR(code),clOrange); if AffSignal then AfficheDebug('Signal directionnel: ad'+IntToSTR(adr)+'='+intToSTR(code),clOrange); case code of @@ -3565,7 +3653,7 @@ begin i:=Index_Signal(adr); if (Signaux[i].EtatSignal<>code) then begin - if traceSign then Affiche('signal directionnel CDF: '+IntToSTR(adr)+' '+intToSTR(code),ClOrange); + if AffSig then Affiche('signal directionnel CDF: '+IntToSTR(adr)+' '+intToSTR(code),ClOrange); if AffSignal then AfficheDebug('signal directionnel CDF: '+IntToSTR(adr)+' '+intToSTR(code),ClOrange); case code of @@ -3603,7 +3691,7 @@ begin i:=Index_Signal(i); if Signaux[i].EtatSignal<>code then begin - if traceSign then Affiche('signal directionnel LEB: '+IntToSTR(adr)+' '+intToSTR(code),ClOrange); + if AffSig then Affiche('signal directionnel LEB: '+IntToSTR(adr)+' '+intToSTR(code),ClOrange); if affsignal then AfficheDebug('signal directionnel LEB: '+IntToSTR(adr)+' '+intToSTR(code),ClOrange); case code of @@ -3625,10 +3713,11 @@ var i,nombre : integer; s : string; + // envoi les bits 0 à 3 procedure ecrire(v : integer); var j : integer; begin - // bit 0 + // bit 0 à 3 if nombre>0 then begin if (v and 1)=0 then j:=1 else j:=2; @@ -3657,6 +3746,7 @@ var end; end; + // envoi les bits 0 à 7 procedure ecrire_2(v : integer); var bit2 : integer; begin @@ -3716,6 +3806,7 @@ var end; end; + // envoie les bits 0 à n en fonction du nombre maxi 7 procedure ecrire_3(v : integer); var bit2 : integer; begin @@ -3735,7 +3826,7 @@ var begin bit2:=v and $c; //0000 1100 if bit2<>0 then - begin + begin pilote_acc(adresse+1,bit2 shr 2,signal); exit; end; @@ -3771,7 +3862,7 @@ begin nombre:=Signaux[i].Na; // nombre d'adresses occupées par le signal code_to_aspect(code,aspect,combine); s:='Signal CDF: ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); - if traceSign then affiche(s,clOrange); + if AffSig then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin @@ -3779,7 +3870,6 @@ begin AfficheDebug(s,clyellow); end; - if combine=-1 then case aspect of carre : ecrire_3(Signaux[i].SR[1].sortie1); @@ -3827,7 +3917,7 @@ begin code:=Signaux[index].EtatSignal; //code_to_aspect(code,aspect,combine); s:='Signal SR: ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); - if traceSign then affiche(s,clOrange); + if AffSig then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin @@ -3890,26 +3980,27 @@ begin end; end; - {========================================================================== envoie les données du signal au décodeur LEB ===========================================================================*} procedure envoi_LEB(adresse : integer); -var code,aspect,combine : integer; - index : integer; +var index,mode,code,aspect,cible,combine,offset,sortie : integer; s : string; + + // pour le mode binaire procedure envoi5_LEB(selection :byte); var i : integer; octet : byte; begin - s:=''; for i:=0 to 4 do begin - if (testBit(selection,i)) then begin octet:=1;s:=s+'1';end - else begin octet:=2 ; s:=s+'0';end; + if (testBit(selection,i)) then begin octet:=1;end + else begin octet:=2 ;end; Pilote_acc(adresse+i,octet,signal); // le décodeur LEB nécessite qu'on envoie 0 après son pilotage ; si on est en mode usb ou ethernet + //sleep(100); if (portCommOuvert or parSocketLenz) then Pilote_acc0_X(adresse+i,octet); + //sleep(100); end; //Affiche(inttoStr(selection),clOrange); //Affiche(s,clOrange); @@ -3920,47 +4011,107 @@ begin if (Signaux[index].AncienEtat<>Signaux[index].EtatSignal) then //; && (stop_cmd==FALSE)) begin code:=Signaux[index].EtatSignal; + mode:=Signaux[index].BinLin; + cible:=Signaux[index].UniSemaf; // numéro de cible LEB code_to_aspect(code,aspect,combine); - s:='Signal LEB: ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); - if traceSign then affiche(s,clOrange); + + Sleep(60); // si le signal se met à jour à la suite d'un positionnement d'aiguillage, on peut avoir le message station occupée + //Affiche('Aspect='+IntToSTR(aspect)+' Combine='+inttoSTR(combine),clOrange); + + // mode binaire ancien + if (cible=100) then + begin + s:='Signal LEB (binaire) : ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); + if (aspect<>-1) and (combine=-1) then + begin + if (aspect=carre) then envoi5_LEB(0); + if (aspect=violet) then envoi5_LEB(1); + if (aspect=blanc_cli) then envoi5_LEB(2); + if (aspect=blanc) then envoi5_LEB(3); + if (aspect=semaphore) then envoi5_LEB(4); + if (aspect=semaphore_cli) then envoi5_LEB(5); + if (aspect=jaune) then envoi5_LEB(8); + if (aspect=jaune_cli) then envoi5_LEB($a); + if (aspect=vert_cli) then envoi5_LEB($c); + if (aspect=vert) then envoi5_LEB($d); + if (aspect=rappel_30) then envoi5_LEB(6); + if (aspect=rappel_60) then envoi5_LEB(7); + if (aspect=ral_30) then envoi5_LEB(9); + if (aspect=ral_60) then envoi5_LEB($b); + end; + if (combine<>-1) and (aspect=-1) then + begin + if (Combine=rappel_30) then envoi5_LEB(6); + if (Combine=rappel_60) then envoi5_LEB(7); + if (Combine=ral_30) then envoi5_LEB(9); + if (Combine=ral_60) then envoi5_LEB($b); + end; + if ((Combine=rappel_30) and (aspect=jaune)) then envoi5_LEB($e); + if ((Combine=rappel_30) and (aspect=jaune_cli)) then envoi5_LEB($f); + if ((Combine=rappel_60) and (aspect=jaune)) then envoi5_LEB($10); + if ((Combine=rappel_60) and (aspect=jaune_cli)) then envoi5_LEB($11); + if ((Combine=ral_60) and (aspect=jaune_cli)) then envoi5_LEB($12); + end; + + // linéaire ou nouveau binaire + if (cible>0) and (cible<100) then + begin + begin + if (aspect<>-1) and (combine=-1) then + begin + case aspect of + carre : begin offset:=tableLEB[cible,CarreLEB].offset;sortie:=tableLEB[cible,CarreLEB].sortie;code:=tableLEB[cible,CarreLEB].code; end; + violet : begin offset:=tableLEB[cible,VioletLEB].offset;sortie:=tableLEB[cible,VioletLEB].sortie;code:=tableLEB[cible,VioletLEB].code; end; + semaphore : begin offset:=tableLEB[cible,SemaphoreLEB].offset;sortie:=tableLEB[cible,SemaphoreLEB].sortie;code:=tableLEB[cible,SemaphoreLEB].code; end; + jaune : begin offset:=tableLEB[cible,AvertissementLEB].offset;sortie:=tableLEB[cible,AvertissementLEB].sortie;code:=tableLEB[cible,AvertissementLEB].code; end; + blanc : begin offset:=tableLEB[cible,BlancLEB].offset;sortie:=tableLEB[cible,BlancLEB].sortie;code:=tableLEB[cible,BlancLEB].code; end; + vert : begin offset:=tableLEB[cible,VoieLibreLEB].offset;sortie:=tableLEB[cible,VoieLibreLEB].sortie;code:=tableLEB[cible,VoieLibreLEB].code; end; + semaphore_cli : begin offset:=tableLEB[cible,RougeCliLEB].offset; sortie:=tableLEB[cible,RougeCliLEB].sortie;code:=tableLEB[cible,RougeCliLEB].code; end; + jaune_cli : begin offset:=tableLEB[cible,JauneCliLEB].offset; sortie:=tableLEB[cible,JauneCliLEB].sortie;code:=tableLEB[cible,JauneCliLEB].code; end; + blanc_cli : begin offset:=tableLEB[cible,BlancCliLEB].offset; sortie:=tableLEB[cible,BlancCliLEB].sortie;code:=tableLEB[cible,BlancCliLEB].code; end; + vert_cli : begin offset:=tableLEB[cible,VertCliLEB].offset; sortie:=tableLEB[cible,VertCliLEB].sortie;code:=tableLEB[cible,VertCliLEB].code; end; + end; + end; + if (aspect=-1) and (combine<>-1) then + begin + case combine of + rappel_30 : begin offset:=tableLEB[cible,Rappel30LEB].offset; sortie:=tableLEB[cible,Rappel30LEB].sortie;code:=tableLEB[cible,Rappel30LEB].code;end; + rappel_60 : begin offset:=tableLEB[cible,Rappel60LEB].offset; sortie:=tableLEB[cible,Rappel60LEB].sortie;code:=tableLEB[cible,Rappel60LEB].code;end; + ral_30 : begin offset:=tableLEB[cible,Ralen30LEB].offset; sortie:=tableLEB[cible,Ralen30LEB].sortie;code:=tableLEB[cible,Ralen30LEB].code; end; + ral_60 : begin offset:=tableLEB[cible,Ralen60LEB].offset; sortie:=tableLEB[cible,Ralen60LEB].sortie;code:=tableLEB[cible,Ralen60LEB].code; end; + end; + end; + if (aspect<>-1) and (combine<>-1) then + begin + if (aspect=jaune) and (combine=rappel_30) then begin offset:=tableLEB[cible,AvertissementRappel30LEB].offset; sortie:=tableLEB[cible,AvertissementRappel30LEB].sortie;code:=tableLEB[cible,AvertissementRappel30LEB].code;end; + if (aspect=jaune_cli) and (combine=rappel_30) then begin offset:=tableLEB[cible,JauneCliRappel30LEB].offset; sortie:=tableLEB[cible,JauneCliRappel30LEB].sortie;code:=tableLEB[cible,JauneCliRappel30LEB].code;end; + if (aspect=jaune) and (combine=rappel_60) then begin offset:=tableLEB[cible,AvertissementRappel60LEB].offset; sortie:=tableLEB[cible,AvertissementRappel60LEB].sortie;code:=tableLEB[cible,AvertissementRappel60LEB].code;end; + if (aspect=jaune_cli) and (combine=rappel_60) then begin offset:=tableLEB[cible,JauneCliRappel60LEB].offset; sortie:=tableLEB[cible,JauneCliRappel60LEB].sortie;code:=tableLEB[cible,JauneCliRappel60LEB].code;end; + if (aspect=jaune_cli) and (combine=ral_60) then begin offset:=tableLEB[cible,JauneCliRalen60LEB].offset; sortie:=tableLEB[cible,JauneCliRalen60LEB].sortie;code:=tableLEB[cible,JauneCliRalen60LEB].code;end; + end; + + if mode=0 then + begin + s:='Signal LEB (binaire) : ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); + envoi5_LEB(code); + end; + + if mode=1 then + begin + s:='Signal LEB (linéaire) : ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); + pilote_acc(adresse+offset,sortie,aigP); + end; + + end; + end; + + if AffSig then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(adresse); AfficheDebug(s,clyellow); end; - - Sleep(60); // si le signal se met à jour à la suite d'un positionnement d'aiguillage, on peut avoir le message station occupée - //Affiche(IntToSTR(aspect)+' '+inttoSTR(combine),clOrange); - if (aspect<>-1) and (combine=-1) then - begin - if (aspect=carre) then envoi5_LEB(0); - if (aspect=violet) then envoi5_LEB(1); - if (aspect=blanc_cli) then envoi5_LEB(2); - if (aspect=blanc) then envoi5_LEB(3); - if (aspect=semaphore) then envoi5_LEB(4); - if (aspect=semaphore_cli) then envoi5_LEB(5); - if (aspect=jaune) then envoi5_LEB(8); - if (aspect=jaune_cli) then envoi5_LEB($a); - if (aspect=vert_cli) then envoi5_LEB($c); - if (aspect=vert) then envoi5_LEB($d); - if (aspect=rappel_30) then envoi5_LEB(6); - if (aspect=rappel_60) then envoi5_LEB(7); - if (aspect=ral_30) then envoi5_LEB(9); - if (aspect=ral_60) then envoi5_LEB($b); - end; - if (combine<>-1) and (aspect=-1) then - begin - if (Combine=rappel_30) then envoi5_LEB(6); - if (Combine=rappel_60) then envoi5_LEB(7); - if (Combine=ral_30) then envoi5_LEB(9); - if (Combine=ral_60) then envoi5_LEB($b); - end; - if ((Combine=rappel_30) and (aspect=jaune)) then envoi5_LEB($e); - if ((Combine=rappel_30) and (aspect=jaune_cli)) then envoi5_LEB($f); - if ((Combine=rappel_60) and (aspect=jaune)) then envoi5_LEB($10); - if ((Combine=rappel_60) and (aspect=jaune_cli)) then envoi5_LEB($11); - if ((Combine=ral_60) and (aspect=jaune_cli)) then envoi5_LEB($12); end; end; @@ -3976,7 +4127,7 @@ begin asp:=Signaux[index].aspect; code_to_aspect(code,aspect,combine); s:='Signal Arcomora: ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); - if traceSign then affiche(s,clOrange); + if AffSig then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin @@ -4095,7 +4246,7 @@ begin code:=Signaux[i].EtatSignal; code_to_aspect(code,aspect,combine); s:='Signal NMRA: ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); - if traceSign then affiche(s,clOrange); + if AffSig then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin @@ -4145,7 +4296,7 @@ begin code:=Signaux[index].EtatSignal; code_to_aspect(code,aspect,combine); s:='Signal Unisemaf: ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); - if traceSign then affiche(s,clOrange); + if AffSig then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin @@ -4653,7 +4804,7 @@ begin code_to_aspect(code,aspect,combine); combine:=code and $01c0; s:='Signal b_models: ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); - if traceSign then affiche(s,clOrange); + if AffSig then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin @@ -4772,7 +4923,7 @@ begin code:=Signaux[i].EtatSignal; code_to_aspect(code,aspect,combine); s:='Signal LDT_NMBS: ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); - if traceSign then affiche(s,clOrange); + if AffSig then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin @@ -4807,7 +4958,7 @@ begin code:=Signaux[i].EtatSignal; code_to_aspect(code,aspect,combine); s:='Signal LDT: ad'+IntToSTR(adresse)+'='+chaine_signal(NbDecodeurdeBase+NbreDecPers-1); - if traceSign then affiche(s,clOrange); + if AffSig then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin @@ -4864,7 +5015,7 @@ begin code:=Signaux[i].EtatSignal; code_to_aspect(code,aspect,combine); s:='Signal virtuel: ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); - if traceSign then affiche(s,clOrange); + if AffSig then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); end; end; @@ -4954,7 +5105,7 @@ begin nombre:=Signaux[i].Na; // nombre d'adresses occupées par le signal code_to_aspect(code,aspect,combine); s:='Signal digikeijs 4018: ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); - if traceSign then affiche(s,clOrange); + if AffSig then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin @@ -5012,7 +5163,7 @@ begin code:=Signaux[i].EtatSignal; code_to_aspect(code,aspect,combine); s:='Signal Bahn: ad'+IntToSTR(adresse)+'='+chaine_signal(adresse); - if traceSign then affiche(s,clOrange); + if AffSig then affiche(s,clOrange); if Affsignal or traceListe then afficheDebug(s,clOrange); if AffDetSig then begin @@ -5303,11 +5454,11 @@ begin end; -// renvoie l'adresse du détecteur suivant des deux éléments contigus +// renvoie l'adresse du détecteur suivant des deux éléments **contigus** // 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,ia : integer; +var actuelCalc,PrecCalc,j,AdrSuiv,ia : integer; TypeprecCalc,TypeActuelCalc : TEquipement; begin if NivDebug>=2 then @@ -5352,6 +5503,7 @@ begin 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 begin AdrSuiv:=suivant_alg3(prec,TypeElPrec,actuel,TypeElActuel,1); // suivant immédiat @@ -5367,18 +5519,18 @@ var condValide : boolean; begin // 1 condition - pas de chaînage avec 1 seule condition condValide:=false; - n:=Tablo_actionneur[action].NbCond; + n:=Tablo_Action[action].NbCond; for ncond:=1 to n do begin - cond:=Tablo_actionneur[action].tabloCond[ncond].numcondition; + cond:=Tablo_Action[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; + tr:=Tablo_Action[action].tabloCond[ncond].train; + vit1:=Tablo_Action[action].tabloCond[ncond].vitmini; + vit2:=Tablo_Action[action].tabloCond[ncond].vitmaxi; it:=index_train_nom(tr); if it>0 then begin @@ -5388,8 +5540,8 @@ begin end; CondPosAcc : begin - vit1:=Tablo_actionneur[action].tabloCond[ncond].accessoire; - vit2:=Tablo_actionneur[action].tabloCond[ncond].etat; + vit1:=Tablo_Action[action].tabloCond[ncond].accessoire; + vit2:=Tablo_Action[action].tabloCond[ncond].etat; it:=index_aig(vit1); if it>0 then begin @@ -5400,10 +5552,10 @@ begin 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:=Tablo_Action[action].tabloCond[ncond].HeureMin*60; + vit2:=Tablo_Action[action].tabloCond[ncond].HeureMax*60; + m1:=Tablo_Action[action].tabloCond[ncond].MinuteMin; + m2:=Tablo_Action[action].tabloCond[ncond].MinuteMax; vit1:=vit1+m1; vit2:=vit2+m2; hc:=heure*60+minute; @@ -5411,8 +5563,8 @@ begin end; condTrainSig : begin - vit1:=Tablo_actionneur[action].tabloCond[ncond].adresse; - tr:=Tablo_actionneur[action].tabloCond[ncond].train; + vit1:=Tablo_Action[action].tabloCond[ncond].adresse; + tr:=Tablo_Action[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; @@ -5431,11 +5583,11 @@ var i : integer; begin for i:=1 to MaxTablo_act do begin - if (Tablo_actionneur[i].declencheur=DeclSignal) then + if (Tablo_Action[i].declencheur=DeclSignal) then begin - if (Tablo_actionneur[i].adresse=signaux[idSignal].adresse) then + if (Tablo_Action[i].adresse=signaux[idSignal].adresse) then begin - if (Tablo_actionneur[i].etat=niveau) then + if (Tablo_Action[i].etat=niveau) then begin if teste_condition(i) then begin @@ -5466,7 +5618,7 @@ end; // pilotage d'un signal, et mise à jour du graphisme du signal dans les 3 fenetres procedure envoi_signal(Adr : integer); -var i,it,index_train,adresse,detect,detsuiv,a,b,aspect,x,y,TailleX,TailleY,Orientation, +var i,it,index_train,adresse,detect,a,b,aspect,x,y,TailleX,TailleY,Orientation, indexTCO,AdrTrain,dec,td : integer; etatAvert,etatBvert,etatArouge,etatBrouge : boolean; ImageSignal : TImage; @@ -5509,6 +5661,7 @@ begin else Affiche('Erreur 192 : décodeur '+IntToSTR(dec)+' non défini',clred); // Gestion démarrage temporisé des trains si on quitte le rouge + if roulage then begin a:=Signaux[i].AncienEtat; b:=Signaux[i].EtatSignal; @@ -5538,10 +5691,11 @@ begin if index_train<>0 then it:=trains[index_train].index_event_det_train; if it<>0 then event_det_train[it].signal_rouge:=0; // faire la réservation du canton + { 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 td:=trains[index_train].TempsDemarreSig; if td<>0 then @@ -5746,6 +5900,8 @@ begin IndexBranche_trouve:=i; end; + + // vérifie la configuration du décodeur Unisemaf // si 0 = OK // si 1 = erreur code Unisemaf @@ -5778,11 +5934,44 @@ begin end; end; +// vérifie la configuration du décodeur LEB +// si 0 = OK +// si 1 = erreur code cible LEB +// si 2 = erreur cohérence entre code cible et aspect +// si 3 = signal inconnu +function verif_LEB(adresse,UniSem : integer) : integer; +var aspect,i : integer; +begin + if UniSem=0 then begin result:=1;exit;end; + if ((UniSem<0) or (UniSem>29)) and (UniSem<>41) and (UniSem<>100) then begin result:=1;exit;end; + + i:=Index_Signal(adresse); + if i<>0 then + begin + aspect:=Signaux[i].aspect; + if ((aspect=2) and ((UniSem=1) or (UniSem=2) or (UniSem=4) or (UniSem=21) or (UniSem=29))) or + ((aspect=3) and ((UniSem=3) or (UniSem=5) or (UniSem=22))) or + ((aspect=4) and ((UniSem=6) or (UniSem=23) or (UniSem=27) or (UniSem=28))) or + ((aspect=5) and ((UniSem=7) or (UniSem=8))) or + ((aspect=7) and (((UniSem>=9) and (UniSem<=13)) or (UniSem=24) or (UniSem=25) or (UniSem=26))) or + ((aspect=9) and (((UniSem>=14) and (UniSem<=20)) or (UniSem=41))) or + (UniSem=100) + then result:=0 + else result:=2; + end + else + begin + Affiche('Erreur 395 : Signal '+intToSTR(adresse)+' inconnu',clred); + result:=3; + end; +end; + + // trouve un élément en balayant les branches à partir de la branche offset renvoie branche_trouve IndexBranche_trouve // el : adresse de l'élément TypeEL=(1=détécteur 2=aig 3=aig Bis 4=aig triple - Buttoir) // explore les branches // si pas trouvé, Branche_trouve=0 IndexBranche_trouve=0 -procedure trouve_element_V1(el: integer; TypeEl : TEquipement; Offset : integer); +procedure trouve_element_V1(el: integer; TypeEl : TEquipement; Offset,branche_pref : integer); var i,adr,Branche : integer ; s : string; BT : TEquipement; @@ -5790,16 +5979,23 @@ var i,adr,Branche : integer ; begin if debug=3 then formprinc.Caption:='Trouve_element '+IntToSTR(el); - Branche:=Offset; + if (typeEL=triple) or (typeEL=tjd) or (typeEL=tjs) or (typeEL=crois) then TypeEL:=aig; + + i:=1; branche_trouve:=0; IndexBranche_trouve:=0; - i:=1; + if branche_pref<>0 then branche:=Branche_Pref else Branche:=offset; repeat + sort:=false; adr:=BrancheN[Branche,i].Adresse; Bt:=BrancheN[Branche,i].BType; - if ((adr=0) and (Bt=rien)) then begin inc(Branche);i:=0;end; + if ((adr=0) and (Bt=rien)) then + begin + inc(Branche);i:=0; + if branche_pref<>0 then sort:=true; + end; inc(i); - sort:=(Branche>NbreBranches) or ((adr=el) and (TypeEL=Bt)); + sort:=sort or ((Branche>NbreBranches) or ((adr=el) and (TypeEL=Bt))); until (sort); if (adr=el) then begin @@ -5819,8 +6015,9 @@ end; // trouve un élément dans les branches depuis les index. // Plus rapide que la procédure précédente. Renvoie branche_trouve IndexBranche_trouve // el : adresse de l'élément TypeEL=(1=détécteur 2=aig 3=aig Bis 4=aig triple - Buttoir) -// avec cet algorithme, un détecteur et un aiguillage ne peut se trouver qu'à un seul endroit dans les branches -procedure trouve_element(el: integer; TypeEl : TEquipement); +// avec cet algorithme, un détecteur ne peut se trouver qu'à un seul endroit dans les branches +// si branche_Pref<>0 : recherche un aig sur la branche_Pref +procedure trouve_element(el: integer; TypeEl : TEquipement;Branche_pref : integer); overload; var s : string; begin if debug=3 then formprinc.Caption:='Trouve_element '+IntToSTR(el); @@ -5850,11 +6047,9 @@ begin indexBranche_trouve:=detecteur[el].IndexBranche; // NumBranche et Indexbranche - detecteur[] sont indexés par l'adresse end; - if typeEL=aig then + if (TypeEl=triple) or (typeEL=aig) or (typeEL=crois) or (typeEL=tjd) or (typeEL=tjs) then begin - //Affiche('aig ',clred); - branche_trouve:=aiguillage[index_aig(el)].NumBranche; // l'aiguillage aig se trouve dans - indexBranche_trouve:=aiguillage[index_aig(el)].IndexBranche; // NumBranche et Indexbranche aiguillage[] sont indexés par un index + Trouve_element_V1(el,TypeEl,1,branche_pref); end; if typeEL=buttoir then @@ -5863,25 +6058,156 @@ begin indexBranche_trouve:=detecteur[el].IndexBranche; end; + if typeEL=act then + begin + branche_trouve:=actionneur[el].NumBranche; + indexBranche_trouve:=actionneur[el].IndexBranche; + end; + + //Affiche_Suivi(intToSTR(el),clred); if IndexBranche_trouve=0 then begin s:='Erreur 176 : élément '+intToSTR(el)+' '; s:=s+BTypeToChaine(TypeEl); - s:=s+' non trouvé';Affiche(s,clred); + s:=s+' non trouvé dans les branches';Affiche(s,clred); branche_trouve:=0; IndexBranche_trouve:=0; AfficheDebug(s,clred); end; if debug=3 then formprinc.Caption:=''; +end; + +procedure trouve_element(el: integer; TypeEl : TEquipement); overload; +begin + trouve_element(el,TypeEl,0); +end; + + +// trouve actionneur_aig +// trouve les actionneurs de l'aiguillage "index" au suivant +// index = index aiguillage - suivant +procedure trouve_actionneurs_aig(index,suivant : integer;tsuiv : tequipement); +var i,adrAig,indexBranche_aig,branche_trouve_aig,indexBranche_Suiv,branche_trouve_Suiv : integer; + typ : tequipement; +begin + adrAig:=aiguillage[index].Adresse; + typ:=aiguillage[index].modele; + if nivDebug=3 then AfficheDebug('trouve_actionneurs_aig '+intToSTR(adrAig)+' '+intToSTR(suivant),clCyan); + if suivant=0 then // possible sur buttoir + begin + exit; + end; + // si suivant est un détecteur la recherche de l'aig se fera dans la même branche + if tSuiv=det then + begin + trouve_element(suivant,tSuiv); // branche_trouve IndexBranche_trouve + if IndexBranche_trouve=0 then + begin + if NivDebug=3 then AfficheDebug('33. Element '+intToSTR(suivant)+' non trouvé',clred); + exit; + end; + indexBranche_Suiv:=IndexBranche_trouve; + branche_trouve_Suiv:=branche_trouve; + + // chercher l'aig dans la même branche + trouve_element(AdrAig,typ,Branche_trouve_Suiv); + if IndexBranche_trouve=0 then + begin + if NivDebug=3 then AfficheDebug('34. Element '+intToSTR(adrAig)+' non trouvé',clred); + exit; + end; + indexBranche_aig:=IndexBranche_trouve; + branche_trouve_aig:=branche_trouve; + end + + else + + // si le suivant est un aiguillage + if tSuiv=aig then + begin + if nivDebug=3 then AfficheDebug('SuivAig',clred); + suivant_alg3(adraig,typ,suivant,tsuiv,1); + exit; + end; + + // mettre aig avant det + if indexBranche_aig>indexBranche_suiv then + begin + i:=indexBranche_aig; + indexBranche_aig:=indexBranche_suiv; + indexBranche_suiv:=i; + end; + + if nivDebug=3 then AfficheDebug('Det en branche'+intToSTR(branche_trouve_Suiv)+' Aig en branche'+intToSTR(branche_trouve_Suiv),clYellow); + if branche_trouve_Suiv=branche_trouve_Suiv then + begin + for i:=indexBranche_aig to indexBranche_suiv do + begin + //AfficheDebug(intToSTR(index)+' '+intToSTR(suivant),clWhite); + if BrancheN[branche_trouve_suiv,i].BType=act then + begin + //AfficheDebug(IntToSTR(BrancheN[branche_trouve_det,i].Adresse),clwhite); + inc(idActTr); + if idActTr<11 then Actionneur_trouve[idActTr]:=BrancheN[branche_trouve_suiv,i].Adresse; + end; + end; + exit; + end; + + //suivant_alg3(adresse,typ,suivant,tsuiv,1); + AfficheDebug('cas non prévu',clred); + exit; + + end; + +// renvoie les adresses des 2 aiguillages adjacents au détecteur "adresse" (avant, après) +// résultat dans var1 et var2 +procedure Aig_Adj(adresse : integer;var adr1: integer;var adr2 : integer); +var Branche,IndexBranche,i : integer; + sortie : boolean; + Bt : TEquipement; + s : string; +begin + trouve_element(adresse,det); // branche_trouve IndexBranche_trouve + if (IndexBranche_trouve=0) then + begin + s:='Erreur 380 : élément '+IntToSTR(adresse)+' det non trouvé'; + Affiche(s,clred); + AfficheDebug(s,clred); + exit; + end; + IndexBranche:=IndexBranche_trouve; + branche:=branche_trouve; + + i:=indexBranche; + repeat + bt:=brancheN[branche,i].BType; + inc(i); + until bt=aig; + adr1:=brancheN[branche,i-1].Adresse; + + i:=indexBranche; + repeat + bt:=brancheN[branche,i].BType; + dec(i); + sortie:=bt=aig; + until (i=0) or (bt=aig); + adr2:=brancheN[branche,i+1].Adresse; + +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 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 +// : SensAig = sens de prise de l'aiguillage (const_pointe, const_talon) +// remplit le tableau Actionneur_trouve[] entre actuel et suivant. // alg= algorithme 1 à 8 sous forme de bits fonctionnels: // bit0 (1)=arret sur suivant qu'il soit un détecteur ou un aiguillage // bit1 (2)=arret sur aiguillage en talon mal positionné @@ -5899,10 +6225,10 @@ end; // 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,k : integer; + tjsc1,tjsc2,AdrTjdP,Adr2,N_iteration,index,NetatTJD,index2,k,delta : integer; tjscourbe1,tjscourbe2,tjdC,tjsC,id : boolean; A,Aprec,tjsc1B,tjsc2B,typeprec: char; - Md,BT,BtypePrec,TypeEL : TEquipement; + TypeGenS,Md,BT,BtypePrec,TypeEL : TEquipement; s : string; label recommence; @@ -5938,7 +6264,6 @@ begin if NivDebug=3 then AfficheDebug('Element '+intToSTR(actuel)+' non trouvé',clred); suivant_alg3:=9999;exit; end; - indexBranche_actuel:=IndexBranche_trouve; branche_trouve_actuel:=branche_trouve; @@ -5948,44 +6273,110 @@ begin if nivDebug=3 then AfficheDebug('Btype='+BTypeToChaine(Bt)+' Actuel='+inTToSTR(actuel),clyellow); id:=false; - if Bt=det then // l'élément actuel est un détecteur + if (Bt=det) or (bt=act) then // l'élément actuel est un détecteur ou un actionneur begin - // on part de l'actuel pour retomber sur le précédent - if BrancheN[branche_trouve_actuel,indexBranche_actuel-1].Adresse=prec then // c'est l'autre sens + if bt=act then + begin + if (NivDebug=3) then AfficheDebug('40 - Trouvé actionneur '+intToSTR(brancheN[branche_trouve_actuel,indexBranche_actuel].Adresse),clLime); + inc(IdActTr); + if idActTr<10 then actionneur_trouve[IdActTr]:=brancheN[branche_trouve_actuel,indexBranche_actuel].Adresse; + end; + + // on part de l'actuel en - pour retomber sur le précédent + delta:=0; + repeat + inc(delta); + md:=brancheN[branche_trouve_actuel,indexBranche_actuel-delta].BType; + if md=act then + begin + if (NivDebug=3) then AfficheDebug('41 - Trouvé actionneur '+intToSTR(brancheN[branche_trouve_actuel,indexBranche_actuel-delta].Adresse),clLime); + inc(IdActTr); + if idActTr<10 then actionneur_trouve[IdActTr]:=brancheN[branche_trouve_actuel,indexBranche_actuel-delta].Adresse; + end; + until (md<>act); + + if BrancheN[branche_trouve_actuel,indexBranche_actuel-delta].Adresse=prec then // c'est l'autre sens begin id:=true; - if NivDebug=3 then AfficheDebug('40 - trouvé détecteur '+intToSTR(adr)+' en + ',clwhite); + //if NivDebug=3 then AfficheDebug('42 - trouvé '+intToSTR(adr)+' en - et RAZ du pointeur d''actionneurs',clwhite); + //IdActTr:=0; Prec:=Adr; Aprec:=a; A:='Z'; - Adr:=BrancheN[branche_trouve_actuel,indexBranche_actuel+1].Adresse; - typeGen:=BrancheN[branche_trouve_actuel,indexBranche_actuel+1].Btype; + delta:=1; + repeat + Adr:=BrancheN[branche_trouve_actuel,indexBranche_actuel+delta].Adresse; + typeGen:=BrancheN[branche_trouve_actuel,indexBranche_actuel+delta].Btype; + if (typeGen=act) then + begin + if nivDebug=3 then AfficheDebug('43 - Trouvé actionneur '+intToSTR(adr),clLime); + inc(IdActTr); + if idActTr<10 then actionneur_trouve[IdActTr]:=adr; + end; + inc(delta); + until (typeGen<>act) ; + if NivDebug=3 then begin - s:='41 - Le suivant est :'+intToSTR(adr); + s:='44 - Le suivant est :'+intToSTR(adr); AfficheDebug(s,clwhite); end; suivant_alg3:=adr; exit; end; - if BrancheN[branche_trouve_actuel,indexBranche_actuel+1].Adresse=prec then + + // maintenant en + + delta:=0; + repeat + inc(delta); + md:=brancheN[branche_trouve_actuel,indexBranche_actuel+delta].BType; + + if md=act then + begin + if (NivDebug=3) then AfficheDebug('45 - Trouvé actionneur '+intToSTR(BrancheN[branche_trouve_actuel,indexBranche_actuel+delta].adresse),clLime); + inc(IdActTr); + if idActTr<10 then actionneur_trouve[IdActTr]:=BrancheN[branche_trouve_actuel,indexBranche_actuel+delta].adresse; + end; + until (md<>act); + + if BrancheN[branche_trouve_actuel,indexBranche_actuel+delta].Adresse=prec then begin id:=true; - if NivDebug=3 then AfficheDebug('42 - trouvé détecteur '+intToSTR(adr)+' en - ',clwhite); + //IdActTr:=0; + if NivDebug=3 then AfficheDebug('46 - trouvé dét/act '+intToSTR(adr)+' en - et RAZ du pointeur d''actionneurs',clwhite); + if bt=act then + begin + if (NivDebug=3) then AfficheDebug('47 - Trouvé actionneur '+intToSTR(adr),clLime); + inc(IdActTr); + if idActTr<10 then actionneur_trouve[IdActTr]:=adr; + end; + Prec:=Adr; Aprec:=a; A:='Z'; - Adr:=BrancheN[branche_trouve_actuel,indexBranche_actuel-1].Adresse; - typeGen:=BrancheN[branche_trouve_actuel,indexBranche_actuel-1].Btype; + delta:=1; + repeat + Adr:=BrancheN[branche_trouve_actuel,indexBranche_actuel-delta].Adresse; + typeGen:=BrancheN[branche_trouve_actuel,indexBranche_actuel-delta].Btype; + if (typeGen=act) then + begin + if nivDebug=3 then AfficheDebug('48 - Trouvé actionneur '+intToSTR(adr),clLime); + inc(IdActTr); + if idActTr<10 then actionneur_trouve[IdActTr]:=adr; + end; + inc(delta); + until (typeGen<>act) ; + if NivDebug=3 then begin - s:='43 - Le suivant est :'+intToSTR(adr); + s:='49 - Le suivant est :'+intToSTR(adr); AfficheDebug(s,clwhite); end; suivant_alg3:=adr; exit; end; - // ici, les éléments sont non consécutifs. voir si l'un des deux est une TJD/TJS + + // ici, les éléments dans des branches différentes. if (btypePrec=aig) then // car btype dans les branches vaut det, aig, buttoir mais jamais tjd ni tjs begin id:=true; @@ -6002,7 +6393,7 @@ begin end; if not(id) then begin - Affiche('Erreur 780 alg3: '+intToSTR(prec)+' '+intToSTR(actuel)+' non consécutifs',clRed); + AfficheDebug('Erreur 780 alg3: '+intToSTR(prec)+' '+intToSTR(actuel)+' non consécutifs',clRed); result:=9993; exit; end; @@ -6023,6 +6414,25 @@ begin if (Bt=aig) or (Bt=buttoir) then // aiguillage ou buttoir begin + // si le prec est un actionneur, remonter au détecteur + if TypeElPrec=act then + begin + delta:=0; + repeat + inc(delta); + k:=brancheN[branche_trouve_prec,indexBranche_prec+delta].Adresse; + until (k=actuel) or (k=0); + if k=actuel then prec:=brancheN[branche_trouve_prec,indexBranche_prec-1].Adresse + else + begin + delta:=0; + repeat + inc(delta); + k:=brancheN[branche_trouve_prec,indexBranche_prec-delta].Adresse; + until (k=actuel) or (k=0); + if k=actuel then prec:=brancheN[branche_trouve_prec,indexBranche_prec+1].Adresse; + end; + end; //V1 index:=index_aig(adr); index:=tablo_index_aiguillage[adr]; if index=0 then @@ -6052,6 +6462,7 @@ begin // aiguillage index (adr) pris en pointe if (aiguillage[index].Apointe=prec) then begin + SensAig:=const_pointe; if aiguillage[index].position=const_droit then begin if NivDebug=3 then AfficheDebug('130 - aiguillage '+intToSTR(Adr)+' Pris en pointe droit',clyellow); @@ -6068,11 +6479,14 @@ begin if (A='Z') or (a=#0) then TypeEl:=det else TypeEL:=aig; //TypeEL=(1=détécteur 2=aig trouve_element(adr,typeEl); // branche_trouve IndexBranche_trouve if branche_trouve=0 then begin suivant_alg3:=9999;exit;end; - typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].Btype; + typeGenS:=BrancheN[branche_trouve,IndexBranche_trouve].Btype; end else - typeGen:=buttoir; + typeGenS:=buttoir; suivant_alg3:=adr; + // trouver entre actuel et adr s'il y a des actionneurs + trouve_actionneurs_aig(index,adr,typeEl); + typeGen:=TypeGenS; exit; end; @@ -6100,9 +6514,12 @@ begin if (A='Z') or (a=#0) then TypeEl:=det else TypeEL:=aig; //TypeEL=(1=détécteur 2=aig) trouve_element(adr,TypeEl); // branche_trouve IndexBranche_trouve if branche_trouve=0 then begin suivant_alg3:=9999;exit;end; - typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].Btype; + typeGenS:=BrancheN[branche_trouve,IndexBranche_trouve].Btype; end - else typeGen:=buttoir; + else typeGenS:=buttoir; + // trouver entre actuel et adr s'il y a des actionneurs + trouve_actionneurs_aig(index,adr,typeEl); // attention écrase typegen + typeGen:=TypeGenS; suivant_alg3:=adr; exit; end; @@ -6119,49 +6536,57 @@ begin else begin // aiguillage index (adr) pris en talon - if NivDebug=3 then AfficheDebug('135 - aiguillage '+intToSTR(Adr)+' Pris en talon',clyellow); - if (alg and 2)=2 then // on demande d'arreter si l'aiguillage en talon est mal positionné + if (aiguillage[index].ADevie=prec) or (aiguillage[index].ADroit=prec) then begin - if aiguillage[index].position=const_droit then + SensAig:=const_talon; + if NivDebug=3 then AfficheDebug('135 - aiguillage '+intToSTR(Adr)+' Pris en talon',clyellow); + if (alg and 2)=2 then // on demande d'arreter si l'aiguillage en talon est mal positionné 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; - 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 + if aiguillage[index].position=const_droit then begin - if NivDebug=3 then AfficheDebug('135.1 - Aiguillage '+intToSTR(adr)+' mal positionné',clyellow); - suivant_alg3:=9998; - AigMal:=adr; - exit; + 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; + AigMal:=adr; + exit; + end + else + begin + if NivDebug=3 then AfficheDebug('135.2 - Aiguillage '+intToSTR(adr)+' bien positionné',clyellow); + end; end else begin - if NivDebug=3 then AfficheDebug('135.2 - Aiguillage '+intToSTR(adr)+' bien positionné',clyellow); - end; - end - else - begin - // si TJD (modele=2) sur le précédent, alors substituer avec la 2eme adresse de la TJD - if TypeElPrec<>det then - begin - md:=aiguillage[index_aig(prec)].modele; - if (md=tjd) or (md=tjs) then prec:=aiguillage[index_aig(prec)].Ddevie; - end; - if (prec<>aiguillage[index].Adevie) or (aiguillage[index].position=const_inconnu) then - begin - if NivDebug=3 then AfficheDebug('135.3 Aiguillage '+intToSTR(adr)+' mal positionné',clyellow); - suivant_alg3:=9998; - AigMal:=adr; - exit; - end - else - begin - if NivDebug=3 then AfficheDebug('135.4 Aiguillage '+intToSTR(adr)+' bien positionné',clyellow); + // si TJD (modele=2) sur le précédent, alors substituer avec la 2eme adresse de la TJD + if TypeElPrec<>det then + begin + md:=aiguillage[index_aig(prec)].modele; + if (md=tjd) or (md=tjs) then prec:=aiguillage[index_aig(prec)].Ddevie; + end; + if (prec<>aiguillage[index].Adevie) or (aiguillage[index].position=const_inconnu) then + begin + if NivDebug=3 then AfficheDebug('135.3 Aiguillage '+intToSTR(adr)+' mal positionné',clyellow); + suivant_alg3:=9998; + AigMal:=adr; + exit; + end + else + begin + if NivDebug=3 then AfficheDebug('135.4 Aiguillage '+intToSTR(adr)+' bien positionné',clyellow); + end; end; end; + end + else + begin + s:='Impossible de déterminer le passage de l''aiguillage '+intToSTR(adr); + if nivDebug=3 then AfficheDebug(s,clred); + Affiche(s,clred); + result:=9999; + exit; end; // AdrPrec:=Adr; @@ -6181,10 +6606,13 @@ begin if (A='Z') or (a=#0) then TypeEl:=det else TypeEL:=aig; //TypeEL=(1=détécteur 2=aig trouve_element(adr,TypeEl); // branche_trouve IndexBranche_trouve if branche_trouve=0 then begin suivant_alg3:=9999;exit;end; - typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].Btype; + typeGenS:=BrancheN[branche_trouve,IndexBranche_trouve].Btype; end - else TypeGen:=Buttoir; + else TypeGenS:=Buttoir; suivant_alg3:=adr; + // trouver entre actuel et adr s'il y a des actionneurs + trouve_actionneurs_aig(index,adr,typeEl); + typeGen:=TypeGenS; exit; end; if (NivDebug>1) or traceListe then @@ -6288,9 +6716,11 @@ begin end; end; - if (A='Z') or (a=#0) then typeGen:=det else typeGen:=aig; + if (A='Z') or (a=#0) then typeGenS:=det else typeGenS:=aig; suivant_alg3:=adr; if nivDebug=3 then Affichedebug('le port de destination de la tjd 2 états est '+IntToSTR(adr)+a,clyellow); + trouve_actionneurs_aig(index,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; @@ -6306,9 +6736,11 @@ begin Adr:=aiguillage[index].Ddevie; A:=aiguillage[index].DdevieB; end; - if (A='Z') or (a=#0) then typeGen:=det else typeGen:=aig; + if (A='Z') or (a=#0) then typeGenS:=det else typeGenS:=aig; suivant_alg3:=adr; if nivDebug=3 then Affichedebug('le port de destination de la tjd 2 états est '+IntToSTR(adr)+a,clyellow); + trouve_actionneurs_aig(index,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; end; @@ -6345,9 +6777,11 @@ begin end; end; - if (A='Z') or (a=#0) then typeGen:=det else typeGen:=aig; + if (A='Z') or (a=#0) then typeGenS:=det else typeGens:=aig; suivant_alg3:=adr; - if nivDebug=3 then Affichedebug('le port de destination de la tjd 2 états est '+IntToSTR(adr)+a,clyellow); + if nivDebug=3 then Affichedebug('A. le port de destination de la tjd 2 états est '+IntToSTR(adr)+a,clyellow); + trouve_actionneurs_aig(index,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; @@ -6363,9 +6797,11 @@ begin Adr:=aiguillage[index].Ddroit; A:=aiguillage[index].DdroitB; end; - if (A='Z') or (a=#0) then typeGen:=det else typeGen:=aig; + if (A='Z') or (a=#0) then typeGenS:=det else typeGenS:=aig; suivant_alg3:=adr; - if nivDebug=3 then Affichedebug('le port de destination de la tjd 2 états est '+IntToSTR(adr)+a,clyellow); + if nivDebug=3 then Affichedebug('B. le port de destination de la tjd 2 états est '+IntToSTR(adr)+a,clyellow); + trouve_actionneurs_aig(index,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; end; @@ -6427,10 +6863,12 @@ begin A:=aiguillage[index2].AdevieB; end; if NivDebug=3 then AfficheDebug('cas1.1 tjd/s: '+s+' Adr='+intToSTR(adr)+A,clYellow); - if (A='Z') or (a=#0) then typeGen:=det else typeGen:=aig; //TypeEL=(1=détécteur 2=aig + if (A='Z') or (a=#0) then typeGenS:=det else typeGenS:=aig; //TypeEL=(1=détécteur 2=aig suivant_alg3:=adr; Actuel:=aiguillage[index2].Adresse; // substitution de la TJS - if nivDebug=3 then Affichedebug('le port de destination de la tjd/s est '+IntToSTR(adr)+a,clyellow); + if nivDebug=3 then Affichedebug('A. le port de destination de la tjd/s est '+IntToSTR(adr)+a,clyellow); + trouve_actionneurs_aig(index,adr2,TypeGenS); + typeGen:=TypeGenS; exit; end; @@ -6507,10 +6945,12 @@ begin Adr:=aiguillage[index2].Adroit; A:=aiguillage[index2].AdroitB; end; - if (A='Z') or (a=#0) then typeGen:=det else typeGen:=aig; + if (A='Z') or (a=#0) then typeGenS:=det else typeGenS:=aig; Actuel:=aiguillage[index2].Adresse; suivant_alg3:=adr; - if nivDebug=3 then Affichedebug('le port de destination de la tjd 4 états est '+IntToSTR(adr)+a,clyellow); + if nivDebug=3 then Affichedebug('B. le port de destination de la tjd 4 états est '+IntToSTR(adr)+a,clyellow); + trouve_actionneurs_aig(index2,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; @@ -6586,10 +7026,12 @@ begin Adr:=aiguillage[index2].Adroit; A:=aiguillage[index2].AdroitB; end; - if (A='Z') or (a=#0) then typeGen:=det else typeGen:=aig; + if (A='Z') or (a=#0) then typeGenS:=det else typeGenS:=aig; Actuel:=aiguillage[index2].Adresse; suivant_alg3:=adr; - if nivDebug=3 then Affichedebug('Le port de destination de la tjd 4 états est '+IntToSTR(adr)+a,clyellow); + if nivDebug=3 then Affichedebug('C. Le port de destination de la tjd 4 états est '+IntToSTR(adr)+a,clyellow); + trouve_actionneurs_aig(index2,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; @@ -6626,7 +7068,7 @@ begin if (nivdebug>1) or traceliste then AfficheDebug('135.8- TJD '+intToSTR(adr)+' mal positionnée cas 4.2',clyellow); if (alg and 2)=2 then begin - suivant_alg3:=9998; + suivant_alg3:=9998; AigMal:=adr; exit; end; @@ -6645,10 +7087,12 @@ begin A:=aiguillage[index2].AdevieB; end; if NivDebug=3 then AfficheDebug('cas4.1 tjd: '+s+' Adr='+intToSTR(adr)+A,clYellow); - if (A='Z') or (a=#0) then typeGen:=det else typeGen:=aig; + if (A='Z') or (a=#0) then typeGenS:=det else typeGenS:=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); + trouve_actionneurs_aig(index2,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; @@ -6659,10 +7103,12 @@ begin if NivDebug=3 then AfficheDebug('cas tjs en courbe1',clYellow); A:=aiguillage[index_aig(AdrTjdP)].AdevieB; Adr:=aiguillage[index_aig(AdrTjdP)].Adevie; - if (A='Z') or (a=#0) then typeGen:=det else typeGen:=aig; + if (A='Z') or (a=#0) then typeGenS:=det else typeGenS:=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); + trouve_actionneurs_aig(index,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; @@ -6673,10 +7119,12 @@ begin if NivDebug=3 then AfficheDebug('cas1 tjs en courbe 2',clYellow); A:=aiguillage[index_aig(AdrTjdP)].AdevieB; Adr:=aiguillage[index_aig(AdrTjdP)].Adevie; - if (A='Z') or (a=#0) then typeGen:=det else typeGen:=aig; + if (A='Z') or (a=#0) then typeGenS:=det else typeGenS:=aig; suivant_alg3:=adr; Actuel:=aiguillage[index2].Adresse; - if nivDebug=3 then Affichedebug('le port de destination de la tjd est '+IntToSTR(adr)+a,clyellow); + if nivDebug=3 then Affichedebug('D. le port de destination de la tjd est '+IntToSTR(adr)+a,clyellow); + trouve_actionneurs_aig(index,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; if ((nivdebug>1) or traceliste) and not(init_aig_cours) then @@ -6705,12 +7153,14 @@ begin if aiguillage[index].Adevie=prec then begin adr:=aiguillage[index].Ddevie;A:=aiguillage[index].DdevieB;end; if aiguillage[index].Ddevie=prec then begin adr:=aiguillage[index].Adevie;A:=aiguillage[index].AdevieB;end; if aiguillage[index].Ddroit=prec then begin adr:=aiguillage[index].Adroit;A:=aiguillage[index].AdroitB;end; - if (A='Z') or (a=#0) then typeGen:=det else typeGen:=aig; + if (A='Z') or (a=#0) then typeGenS:=det else typeGenS:=aig; suivant_alg3:=adr; if a='' then a:=' '; if (nivdebug>1) then Affichedebug('le port de destination du croisement '+intToSTR(aiguillage[index].adresse)+' est '+IntToSTR(adr)+a,clyellow); // Affiche('croisement '+intToSTR(prec)+' '+intToSTR(actuel),clLime); // mémoriser dans un tableau l'entrée et la sortie du croisement + trouve_actionneurs_aig(index,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; @@ -6730,8 +7180,10 @@ begin if adr=0 then TypeEl:=buttoir; trouve_element(Adr,TypeEl); // branche_trouve IndexBranche_trouve if branche_trouve=0 then begin suivant_alg3:=9999;exit;end; - typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].BType; //?? + typeGenS:=BrancheN[branche_trouve,IndexBranche_trouve].BType; suivant_alg3:=adr; + trouve_actionneurs_aig(index,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; if (aiguillage[index].position<>const_droit) and (aiguillage[index_aig(Adr2)].position=const_droit) then @@ -6743,8 +7195,11 @@ begin if adr=0 then TypeEl:=buttoir; trouve_element(Adr,TypeEl); // branche_trouve IndexBranche_trouve if branche_trouve=0 then begin suivant_alg3:=9999;exit;end; - typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].BType; - suivant_alg3:=adr;exit; + typeGenS:=BrancheN[branche_trouve,IndexBranche_trouve].BType; + suivant_alg3:=adr; + trouve_actionneurs_aig(index,adr,TypeGenS); + typeGen:=TypeGenS; + exit; end; if (aiguillage[index].position=const_droit) and (aiguillage[index_aig(Adr2)].position<>const_droit) then begin @@ -6754,8 +7209,10 @@ begin if (A='Z') or (a=#0) then TypeEl:=det else TypeEL:=aig; trouve_element(Adr,TypeEl); // branche_trouve IndexBranche_trouve if branche_trouve=0 then begin suivant_alg3:=9999;exit;end; - typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].BType; + typeGenS:=BrancheN[branche_trouve,IndexBranche_trouve].BType; suivant_alg3:=adr; + trouve_actionneurs_aig(index,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; if aiguillage[index].position=const_inconnu then @@ -6824,8 +7281,10 @@ begin if (A='Z') or (a=#0) then TypeEl:=det else TypeEL:=aig; trouve_element(Adr,TypeEl); // branche_trouve IndexBranche_trouve if branche_trouve=0 then begin suivant_alg3:=9999;exit;end; - typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].BType; + typeGenS:=BrancheN[branche_trouve,IndexBranche_trouve].BType; suivant_alg3:=Adr; + trouve_actionneurs_aig(index,adr,TypeGenS); + typeGen:=TypeGenS; exit; end; end; @@ -6834,7 +7293,9 @@ begin end; // renvoie l'adresse du signal s'il est associé au détecteur "detecteur" +// supprimé // sinon renvoie 0 +// utilisé 10 fois function signal_detecteur(detecteur : integer) : integer; var trouve : boolean; i : integer; @@ -6848,18 +7309,19 @@ begin end; // trouve l'index du signal associé au détecteur adr -// renvoie dans voie le numéro de la voie (1 à 4) du signal sur lequel le détecteur se trouve -// attention , il peut y avoir plus d'un signal sur un detecteur (suivant le sens)! -// si 2eme signal, son index est dans index2 -function index_signal_det(adr : integer;var voie,index2 : integer) : integer ; -var trouve,i,index1 : integer; +// renvoie dans voie le numéro de la voie (1 à 4) du signal sur lequel le détecteur se trouve et son index +// attention , il peut y avoir deux signaux sur un detecteur (sens opposés) +// le 2eme signal est dans voie2,index2 +procedure index_signal_det(adr : integer;var voie1,index1,voie2,index2 : integer) ; +var trouve,i : integer; trouve1,trouve2,trouve3,trouve4 : boolean; begin i:=1; trouve:=0; index2:=0; index1:=0; - voie:=0; + voie1:=0; + voie2:=0; repeat trouve1:=Signaux[i].Adr_det1=adr; trouve2:=Signaux[i].Adr_det2=adr; @@ -6873,15 +7335,21 @@ begin if trouve=2 then index2:=i; if trouve=1 then // on ne mémorise la voie qu'à la premiere recherche begin - if trouve1 then voie:=1; - if trouve2 then voie:=2; - if trouve3 then voie:=3; - if trouve4 then voie:=4; + if trouve1 then voie1:=1; + if trouve2 then voie1:=2; + if trouve3 then voie1:=3; + if trouve4 then voie1:=4; + end; + if trouve=2 then + begin + if trouve1 then voie2:=1; + if trouve2 then voie2:=2; + if trouve3 then voie2:=3; + if trouve4 then voie2:=4; end; end; inc(i); until (trouve=2) or (i>NbreSignaux); - Index_signal_det:=index1; end; @@ -6950,7 +7418,7 @@ end; // si det1 et det2 sont contigus sans aiguillages entre eux, çà renvoie det1 sinon renvoie l'aiguillage entre les 2 // s'ils ne sont pas contigus, renvoie 0 // Si un élément est inconnu, renvoie 9999 -// si le suivant est un buttoir 9995 +// si le suivant est un buttoir 9995 // det_contigu(527,520: renvoie 7 dans suivant // det_contigu(514,522: renvoie 514 dans suivant // det_contigu(517,524: renvoie 30 @@ -7147,9 +7615,9 @@ var suiv1,indexBranche_det1,indexBranche_det2,branche_det2,branche_det1, begin // trouver les éléments du précédent if debug=3 then formprinc.Caption:='Det_contigu '+intToSTR(det1)+' '+intToSTr(det2); - afdeb:=false;//TraceListe ; + if NivDebug=3 then afdeb:=true else afdeb:=false; it:=0; - if afdeb then afficheDebug('Det_contigu '+intToSTR(det1)+' '+intToSTr(det2),clyellow); + if afdeb or (nivdebug=3) then afficheDebug('Det_contigu '+intToSTR(det1)+' '+intToSTr(det2),clyellow); if (det1>NbMaxDet) or (det2>NbMaxDet) then begin Affiche('Erreur 87 : Det_contigu '+intToSTR(det1)+' '+intToSTr(det2),clred); @@ -7195,7 +7663,7 @@ begin dernier:=0; // faire en incrément - if afdeb then afficheDebug('incrément',clcyan); + if afdeb or (nivDebug=3) then afficheDebug('incrément',clcyan); suiv1:=BrancheN[Branche_Det,indexBranche_det+1].adresse; type1:=BrancheN[Branche_Det,indexBranche_det+1].Btype; // det aig buttoir @@ -7222,7 +7690,7 @@ begin end; // faire en décrément - if afdeb then afficheDebug('décrément',clcyan); + if afdeb or (nivDebug=3) then afficheDebug('décrément',clcyan); if not(trouve) then begin suiv1:=BrancheN[Branche_Det,indexBranche_det-1].adresse; @@ -7247,7 +7715,6 @@ begin if afdeb then afficheDebug('ok4',ClLime); end; end; - end; //Affiche(intToSTR(dernier),clOrange); @@ -7283,9 +7750,10 @@ end; // renvoie les adresses des détecteurs adjacents au détecteur "adresse" (avant, après) // les aiguillages entre det1 et det2 doivent être positionnés -// résultat dans adj1 et adj2 en variable globale +// trouve aussi les premiers éléments contigus au détecteur "adresse" +// résultat dans adj1 et adj2 ; et prec1,t1 et prec2,t2 en variable globale procedure Det_Adj(adresse : integer); -var ia,Adr,AdrFonc,Branche,AdrPrec,IndexBranche,i,Dir : integer; +var ia,Adr,AdrFonc,Branche,AdrPrec,IndexBranche,i,Dir,delta : integer; sortie : boolean; BtypeFonc,BtypePrec : TEquipement; s : string; @@ -7300,16 +7768,21 @@ begin end; IndexBranche:=IndexBranche_trouve; branche:=branche_trouve; + prec1:=0;prec2:=0; Dir:=1 ; //test direction 1 ou 2 (incrément ou décrément) repeat - if (Dir=1) then i:=IndexBranche-1 else i:=IndexBranche+1; AdrPrec:=Adresse; BtypePrec:=det; - AdrFonc:=BrancheN[branche,i].Adresse; - BtypeFonc:=BrancheN[branche,i].BType; + delta:=1; + repeat + if Dir=1 then i:=IndexBranche-delta else i:=IndexBranche+delta; + AdrFonc:=BrancheN[branche,i].Adresse; + BtypeFonc:=BrancheN[branche,i].BType; + inc(delta); + until btypeFonc<>act; i:=0; repeat @@ -7334,164 +7807,327 @@ begin AdrPrec:=AdrFonc;BtypePrec:=BtypeFonc; AdrFonc:=Adr;BtypeFonc:=typeGen; - i:=i+1; + inc(i); sortie:=(i=itmaxi) or (Adr=0) or (Adr>=9990) or (TypeGen=det); + + // éléments contigus à "adresse" + if (dir=1) and (i=1) then begin prec1:=AdrPrec;t1:=BtypePrec;end; + if (dir=2) and (i=1) then begin prec2:=AdrPrec;t2:=BtypePrec;end; + 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; + if (typeGen=det) and (Dir=1) then Adj1:=Adr; + if (typeGen=det) and (Dir=2) then Adj2:=Adr; + inc(dir); until dir=3; end; -// renvoie l'adresse des détecteurs convergents précédents un signal après les aiguillages -// renvoie dans le tableau TabloDet -procedure det_prec_signal(adresse : integer;var tabloDet : TTabloDet); -var el1,el2,i,i2,index,it,voie : integer; - tq1,tq2 : tEquipement; - // explore les connexions d'un aiguillage - récursif - procedure explore_branche(prec,adrAig : integer); - var i,el1,el2 : integer; - c: char; - typ : tEquipement; - begin + +// explore les connexions d'un aiguillage - récursif +// prec : élément d'entrée de l'aiguillage, adrAig : adresse de l'aiguillage +// remplit le tableau des détecteurs tabloDet contigus à tous les aiguillages , quelles que soient leurs positions +// rempli le TabloParcours +// si débordement, resultat=faux +function explore_branche(prec,adrAig : integer;var it: integer;var tabloDet : TTabloDet;var index : integer;var Nparcours,idParcours: integer) : boolean; +var i,i2,el1,el2,erreur : integer; + c: char; + typ,tq1,tq2 : tEquipement; +begin + result:=true; inc(it); - if it>40 then begin Affiche('Erreur récursive 95',clred);exit;end; + erreur:=0; + if it>40 then begin Affiche('Erreur récursive 95',clred);result:=false;exit;end; i:=index_aig(adrAig); typ:=aiguillage[i].modele; + if erreur>0 then begin result:=false;exit;end + else + begin + inc(Idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + Tabloparcours[nparcours,idparcours].adresse:=AdrAig; + Tabloparcours[nparcours,idparcours].typ:=typ; + end; + if (typ=triple) then begin // pris en pointe? if aiguillage[i].APointe=prec then begin + //Affiche('Aig'+inttostr(adraig)+' pointe droit',clyellow); el1:=adraig;tq1:=typ; - // explore droit + // explore droit---------------- + if (idparcours>0) and (idparcours=MaxParcours) then Erreur:=521 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + TabloParcours[nparcours,idparcours].adresse:=el2; + TabloParcours[nparcours,idparcours].typ:=det; + TabloParcours[nparcours,idparcours].pos:=0; + // on a trouvé un détécteur, on change de tableau + if nparcours>=MaxRoutes then Erreur:=522 + else + begin + inc(nparcours);idparcours:=0; + end; + end; end; - //Affiche('Aig'+inttostr(adraig)+' pointe dévié',clyellow); - // explore dévié 1 + // explore dévié 1----------------- + if (idparcours>=MaxParcours) then Erreur:=523 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + Tabloparcours[nparcours,idparcours].adresse:=AdrAig; + Tabloparcours[nparcours,idparcours].typ:=aig; + Tabloparcours[nparcours,idparcours].pos:=const_devie; + end; i:=index_aig(adrAig); el2:=aiguillage[i].ADevie; c:=aiguillage[i].ADevieB; if (c='P') or (c='D') or (c='S') then begin - explore_branche(Adraig,el2); + explore_branche(Adraig,el2,it,tabloDet,index,nparcours,idparcours); + // stocke l'aig d'origine + tq2:=aiguillage[index_aig(el2)].modele; + if (tq2=aig) then + begin + if idparcours>=MaxParcours then Erreur:=524 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + Tabloparcours[nparcours,idparcours].adresse:=el2; + Tabloparcours[nparcours,idparcours].typ:=aig; + end; + end; end else begin //Affiche(IntToSTR(el2),clLime); tabloDet[index]:=el2;inc(index); + if (idparcours>=MaxParcours) then Erreur:=525 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + TabloParcours[nparcours,idparcours].adresse:=el2; + TabloParcours[nparcours,idparcours].typ:=det; + TabloParcours[nparcours,idparcours].pos:=0; + end; + // on a trouvé un détécteur, on change de tableau + if nparcours>=MaxRoutes then Erreur:=526 + else + begin + inc(nparcours);idparcours:=0; + end; end; // explore dévié 2 + if (idparcours>=MaxParcours) then Erreur:=527 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + Tabloparcours[nparcours,idparcours].adresse:=Adraig; + Tabloparcours[nparcours,idparcours].typ:=aig; + Tabloparcours[nparcours,idparcours].pos:=const_devie; + end; i:=index_aig(adrAig); el2:=aiguillage[i].ADevie2; c:=aiguillage[i].ADevie2B; if (c='P') or (c='D') or (c='S') then begin - explore_branche(Adraig,el2); + explore_branche(Adraig,el2,it,tabloDet,index,nparcours,idparcours); + // stocke l'aig d'origine + tq2:=aiguillage[index_aig(el2)].modele; + if (tq2=aig) then + begin + if (idparcours>=MaxParcours) then Erreur:=528 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + Tabloparcours[nparcours,idparcours].adresse:=el2; + Tabloparcours[nparcours,idparcours].typ:=aig; + end; + end; end else begin //Affiche(IntToSTR(el2),clLime); tabloDet[index]:=el2; inc(index); + if (idparcours>=MaxParcours) then Erreur:=529 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + TabloParcours[nparcours,idparcours].adresse:=el2; + TabloParcours[nparcours,idparcours].typ:=det; + TabloParcours[nparcours,idparcours].pos:=0; + end; + // on a trouvé un détécteur, on change de tableau + if nparcours>=MaxRoutes then Erreur:=530 + else + begin + inc(nparcours);idparcours:=0; + end; end; end else - // pris en talon + // triple pris en talon begin el1:=adraig;tq1:=typ; //Affiche('Aig'+inttostr(adraig)+' talon',clyellow); // pris en talon + if (idparcours>0) and (idparcours<100) then + begin + Tabloparcours[nparcours,idparcours].pos:=0; + end; el2:=aiguillage[i].APointe; c:=aiguillage[i].APointeB; if (c='P') or (c='D') or (c='S') then begin - explore_branche(Adraig,el2); + explore_branche(Adraig,el2,it,tabloDet,index,nparcours,idparcours); + exit; end else begin //Affiche(IntToSTR(el2),clLime); tabloDet[index]:=el2; inc(index); + if (idparcours>=MaxParcours) then Erreur:=531 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + TabloParcours[nparcours,idparcours].adresse:=el2; + TabloParcours[nparcours,idparcours].typ:=det; + TabloParcours[nparcours,idparcours].pos:=0; + end; + // on a trouvé un détécteur, on change de tableau + if nparcours>=MaxRoutes then Erreur:=532 + else + begin + inc(nparcours);idparcours:=0; + end; end; end; end; + // -- if (typ=tjd) or (typ=tjs) then begin - // 4 états + // 4 états ; c'est l'entrée de la TJD qui détermine ou on sort if index_aig(aiguillage[i].EtatTJD)=4 then begin i2:=index_aig(aiguillage[i].DDevie); // index de la tjd homologue - // provenance de la tjd - if (aiguillage[i].ADroit=prec) or (aiguillage[i].ADevie=prec) then - begin - // destination 1 de la tjd - el2:=aiguillage[i2].Adevie;c:=aiguillage[i2].ADevieB; - if (c='P') or (c='D') or (c='S') then - begin - explore_branche(Adraig,el2); - end - else - begin - //Affiche(IntToSTR(el2),clLime); - tabloDet[index]:=el2;inc(index); - end; + // explorer la position droite + Tabloparcours[nparcours,idparcours].pos:=const_droit; - // destination 2 de la tjd - el2:=aiguillage[i2].Adroit;c:=aiguillage[i2].ADroitB; - if (c='P') or (c='D') or (c='S') then - begin - explore_branche(Adraig,el2); - end + el2:=aiguillage[i2].ADroit; + c:=aiguillage[i2].ADroitB; + if (c='P') or (c='D') or (c='S') then // l'élément sur droit est un aig + begin + explore_branche(Adraig,el2,it,Tablodet,index,nparcours,idparcours); + end + else + begin // l'élément sur droit est un det + //Affiche(IntToSTR(el2),clLime); + tabloDet[index]:=el2; + inc(index); + + if (idparcours>=MaxParcours) then Erreur:=533 else begin - //Affiche(IntToSTR(el2),clLime); - tabloDet[index]:=el2;inc(index); - end; + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + TabloParcours[nparcours,idparcours].adresse:=el2; + TabloParcours[nparcours,idparcours].typ:=det; + TabloParcours[nparcours,idparcours].pos:=0; + // comme on a trouvé un détécteur, on change de tableau + if nparcours>=MaxRoutes then Erreur:=534 + else + begin + inc(nparcours);idparcours:=0; + end; + end; end; - { - // provenance 2 de la tjd - if (aiguillage[i].ADevie=prec) or (aiguillage[i].ADroit=prec) then + // explore dévié------------------- + if (idparcours>=MaxParcours) then Erreur:=535 + else begin - // destination 2 de la tjd - el2:=aiguillage[i2].Adevie;c:=aiguillage[i2].ADevieB; - if (c='P') or (c='D') or (c='S') then - begin - explore_branche(Adraig,el2); - end - else - begin - //Affiche(IntToSTR(el2),clLime); - tabloDet[index]:=el2;inc(index); - end; + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + Tabloparcours[nparcours,idparcours].adresse:=Adraig; + Tabloparcours[nparcours,idparcours].typ:=tjd; + Tabloparcours[nparcours,idparcours].pos:=const_devie; + end; - el2:=aiguillage[i2].Adroit;c:=aiguillage[i2].ADroitB; - if (c='P') or (c='D') or (c='S') then + //i:=index_aig(adrAig); + el2:=aiguillage[i2].ADevie; + c:=aiguillage[i2].ADevieB; + if (c='P') or (c='D') or (c='S') then + begin + explore_branche(Adraig,el2,it,TabloDet,index,nparcours,idparcours); + // stocke l'aig d'origine + tq2:=aiguillage[index_aig(el2)].modele; + if (tq2=aig) then begin - explore_branche(Adraig,el2); - end + if (idparcours>=MaxParcours) then Erreur:=536 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + Tabloparcours[nparcours,idparcours].adresse:=el2; + Tabloparcours[nparcours,idparcours].typ:=aig; + end; + end; + end + else + begin + //Affiche(IntToSTR(el2),clLime); + tabloDet[index]:=el2; + inc(index); + if (idparcours>=MaxParcours) then Erreur:=537 else begin - Affiche(IntToSTR(el2),clLime); - tabloDet[index]:=el2;inc(index); + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + TabloParcours[nparcours,idparcours].adresse:=el2; + TabloParcours[nparcours,idparcours].typ:=det; + TabloParcours[nparcours,idparcours].pos:=0; end; - end;} + // on a trouvé un détécteur, on change de tableau + if nparcours>=MaxRoutes then Erreur:=538 + else + begin + inc(nparcours);idparcours:=0; + end; + end; end; // 2 états @@ -7504,23 +8140,54 @@ var el1,el2,i,i2,index,it,voie : integer; el2:=aiguillage[i].Ddevie;c:=aiguillage[i].DDevieB; if (c='P') or (c='D') or (c='S') then begin - explore_branche(Adraig,el2); + explore_branche(Adraig,el2,it,TabloDet,index,nparcours,idparcours); end else begin //Affiche(IntToSTR(el2),clLime); tabloDet[index]:=el2;inc(index); + + if (idparcours>=MaxParcours) then Erreur:=539 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + TabloParcours[nparcours,idparcours].adresse:=el2; + TabloParcours[nparcours,idparcours].typ:=det; + TabloParcours[nparcours,idparcours].pos:=0; + // on a trouvé un détécteur, on change de tableau + if nparcours>=MaxRoutes then Erreur:=540 + else + begin + inc(nparcours);idparcours:=0; + end; + end; end; // destination 2 de la tjd el2:=aiguillage[i].Ddroit;c:=aiguillage[i].DDroitB; if (c='P') or (c='D') or (c='S') then begin - explore_branche(Adraig,el2); + explore_branche(Adraig,el2,it,TabloDet,index,nparcours,idparcours); end else begin //Affiche(IntToSTR(el2),clLime); tabloDet[index]:=el2;inc(index); + if (idparcours>=MaxParcours) then Erreur:=541 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + TabloParcours[nparcours,idparcours].adresse:=el2; + TabloParcours[nparcours,idparcours].typ:=det; + TabloParcours[nparcours,idparcours].pos:=0; + // on a trouvé un détécteur, on change de tableau + if nparcours>=MaxRoutes then Erreur:=542 + else + begin + inc(nparcours);idparcours:=0; + end; + end; end; end; @@ -7531,26 +8198,41 @@ var el1,el2,i,i2,index,it,voie : integer; el2:=aiguillage[i].Adroit;c:=aiguillage[i].ADroitB; if (c='P') or (c='D') or (c='S') then begin - explore_branche(Adraig,el2); + explore_branche(Adraig,el2,it,TabloDet,index,nparcours,idparcours); end else begin //Affiche(IntToSTR(el2),clLime); tabloDet[index]:=el2;inc(index); + if (idparcours>=MaxParcours) then Erreur:=543 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + Tabloparcours[nparcours,idparcours].adresse:=el2; + Tabloparcours[nparcours,idparcours].typ:=det; + end; end; // destination 2 de la tjd el2:=aiguillage[i].Adevie;c:=aiguillage[i].AdevieB; if (c='P') or (c='D') or (c='S') then begin - explore_branche(Adraig,el2); + explore_branche(Adraig,el2,it,TabloDet,index,nparcours,idparcours); end else begin //Affiche(IntToSTR(el2),clLime); tabloDet[index]:=el2;inc(index); + if (idparcours>=MaxParcours) then Erreur:=544 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + Tabloparcours[nparcours,idparcours].adresse:=el2; + Tabloparcours[nparcours,idparcours].typ:=det; + end; end; end; - end; end; @@ -7565,75 +8247,175 @@ var el1,el2,i,i2,index,it,voie : integer; begin //i:=index_aig(el2); //teq2:=aiguillage[i].modele; - explore_branche(Adraig,el2); + explore_branche(Adraig,el2,it,Tablodet,index,nparcours,idparcours); + exit; end else begin //Affiche(IntToSTR(el2),clLime); tabloDet[index]:=el2;inc(index); + if (idparcours>=MaxParcours) then Erreur:=545 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + TabloParcours[nparcours,idparcours].adresse:=el2; + TabloParcours[nparcours,idparcours].typ:=det; + TabloParcours[nparcours,idparcours].pos:=0; + end; + // on a trouvé un détécteur, on change de tableau + if nparcours>=MaxRoutes then Erreur:=546 + else + begin + inc(nparcours);idparcours:=0; + end; end; end; if typ=aig then begin - // pris en pointe? + // pris en pointe?----------------------- if aiguillage[i].APointe=prec then begin //Affiche('Aig'+inttostr(adraig)+' pointe droit',clyellow); el1:=adraig;tq1:=typ; - // explore droit + // explore droit------------- + if (idparcours>0) and (idparcours<100) then + begin + Tabloparcours[nparcours,idparcours].pos:=const_droit; + end; + el2:=aiguillage[i].ADroit; c:=aiguillage[i].ADroitB; - if (c='P') or (c='D') or (c='S') then + if (c='P') or (c='D') or (c='S') then // l'élément sur droit est un aig begin - explore_branche(Adraig,el2); + explore_branche(Adraig,el2,it,Tablodet,index,nparcours,idparcours); end else - begin + begin // l'élément sur droit est un det //Affiche(IntToSTR(el2),clLime); tabloDet[index]:=el2; inc(index); + + if (idparcours>=MaxParcours) then Erreur:=547 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + TabloParcours[nparcours,idparcours].adresse:=el2; + TabloParcours[nparcours,idparcours].typ:=det; + TabloParcours[nparcours,idparcours].pos:=0; + // on a trouvé un détécteur, on change de tableau + if nparcours>=MaxRoutes then Erreur:=548 + else + begin + inc(nparcours);idparcours:=0; + end; + end; + end; + + // explore dévié------------------- + if (idparcours>=MaxParcours) then Erreur:=549 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + Tabloparcours[nparcours,idparcours].adresse:=Adraig; + Tabloparcours[nparcours,idparcours].typ:=aig; + Tabloparcours[nparcours,idparcours].pos:=const_devie; end; - //Affiche('Aig'+inttostr(adraig)+' pointe dévié',clyellow); - // explore dévié i:=index_aig(adrAig); el2:=aiguillage[i].ADevie; c:=aiguillage[i].ADevieB; if (c='P') or (c='D') or (c='S') then begin - explore_branche(Adraig,el2); + explore_branche(Adraig,el2,it,TabloDet,index,nparcours,idparcours); + // stocke l'aig d'origine + tq2:=aiguillage[index_aig(el2)].modele; + if (tq2=aig) then + begin + if (idparcours>=MaxParcours) then Erreur:=550 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + Tabloparcours[nparcours,idparcours].adresse:=el2; + Tabloparcours[nparcours,idparcours].typ:=aig; + end; + end; end else begin //Affiche(IntToSTR(el2),clLime); tabloDet[index]:=el2; inc(index); + if (idparcours>=MaxParcours) then Erreur:=551 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + TabloParcours[nparcours,idparcours].adresse:=el2; + TabloParcours[nparcours,idparcours].typ:=det; + TabloParcours[nparcours,idparcours].pos:=0; + end; + // on a trouvé un détécteur, on change de tableau + if nparcours>=MaxRoutes then Erreur:=552 + else + begin + inc(nparcours);idparcours:=0; + end; end; end else - begin + begin // en talon el1:=adraig;tq1:=typ; //Affiche('Aig'+inttostr(adraig)+' talon',clyellow); // pris en talon + if (idparcours>0) and (idparcours<100) then + begin + Tabloparcours[nparcours,idparcours].pos:=0; + end; el2:=aiguillage[i].APointe; c:=aiguillage[i].APointeB; if (c='P') or (c='D') or (c='S') then begin - explore_branche(Adraig,el2); + explore_branche(Adraig,el2,it,TabloDet,index,nparcours,idparcours); + exit; end else begin //Affiche(IntToSTR(el2),clLime); tabloDet[index]:=el2;inc(index); + if (idparcours>=MaxParcours) then Erreur:=553 + else + begin + inc(idparcours); + Tabloparcours[nparcours,0].adresse:=idparcours; + TabloParcours[nparcours,idparcours].adresse:=el2; + TabloParcours[nparcours,idparcours].typ:=det; + TabloParcours[nparcours,idparcours].pos:=0; + end; + // on a trouvé un détécteur, on change de tableau + if nparcours>=MaxRoutes then Erreur:=554 + else + begin + inc(nparcours);idparcours:=0; + end; end; end; end; - end; +end; + +// renvoie l'adresse des détecteurs convergents précédents un signal après les aiguillages +// renvoie dans le tableau TabloDet +procedure det_prec_signal(adresse : integer;var tabloDet : TTabloDet); +var el1,el2,i,index,it,voie,Nparcours,IdParcours : integer; + tq1,tq2 : tEquipement; begin // trouver éléments avant le signal - for i:=1 to Mtd do tabloDet[i]:=0; + for i:=1 to MaxParcours do tabloDet[i]:=0; i:=index_signal(adresse); if i=0 then begin @@ -7641,6 +8423,8 @@ begin exit; end; index:=1; + nParcours:=1; + idParcours:=0; for voie:=1 to 4 do begin //Affiche('Voie '+intToStr(voie),clyellow); @@ -7677,11 +8461,11 @@ begin // élément avant le signal suivant:=suivant_alg3(el1,tq1,el2,det,0); //typeGen // si aiguillage - if (typeGen=aig) or (typeGen=tjd) or (typeGen=tjs) or (typeGen=triple) then explore_branche(el2,suivant); + if (typeGen=aig) or (typeGen=tjd) or (typeGen=tjs) or (typeGen=triple) then explore_branche(el2,suivant,it,TabloDet,index,nparcours,idparcours); if typeGen=det then begin tabloDet[1]:=suivant;index:=2;end; end; end; - if index<=Mtd then tabloDet[index]:=0 else Affiche('Dépassement TabloDet signal '+intToSTR(Adresse),clred); + if index<=MaxParcours then tabloDet[index]:=0 else Affiche('Dépassement TabloDet signal '+intToSTR(Adresse),clred); { for i:=1 to Index do begin @@ -7691,17 +8475,18 @@ begin end; +// Attention : confusion sur detecteur_suivant_el(525,101) renvoie 517 car on reboucle !! // renvoie l'adresse du détecteur suivant les deux éléments // les aiguillages doivent être correctement positionnés entre El1 et el2 -// El1 et El2 peuvent être séparés par des aiguillages, mais de pas plus de 3 détecteurs +// El1 et El2 peuvent être séparés par des aiguillages, mais de pas plus de 2 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é +// en sortie : 9999= det1 ou det2 non trouvé ; en variable globale : prec,tprec et suiv,tsuiv // 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,Ia : integer; + j,AdrPrec,Adr,AdrFonc,i1,N_det,Ia,delta : integer; Sortie : boolean; TypePrec,TypeFonc : Tequipement; s : string; @@ -7776,15 +8561,30 @@ begin repeat //préparer les variables AdrPrec:=el1;TypePrec:=typeDet1; + IdActTr:=0; // init pointeur des actionneurs + if nivDebug=3 then afficheDebug('Init pointeur actionneurs',clLime); // sens - if j=1 then i1:=IndexBranche_det1+1; - if j=2 then i1:=IndexBranche_det1-1; - // les suivants dansla branche sont: + delta:=1; + repeat + if j=1 then i1:=IndexBranche_det1+delta; + if j=2 then i1:=IndexBranche_det1-delta; + if i1=0 then begin result:=9999;exit;end; + + AdrFonc:=BrancheN[branche_trouve_det1,i1].adresse; + typeFonc:=BrancheN[branche_trouve_det1,i1].Btype; + elements[idEl].adresse:=adrFonc; + elements[idEl].typ:=TypeFonc; + inc(delta); + until typeFonc<>act ; + AdrFonc:=BrancheN[branche_trouve_det1,i1].adresse; typeFonc:=BrancheN[branche_trouve_det1,i1].Btype; elements[idEl].adresse:=adrFonc; elements[idEl].typ:=TypeFonc; + N_Det:=0; + if Typefonc=det then N_det:=1; + if NivDebug=3 then begin @@ -7794,23 +8594,20 @@ begin AfficheDebug(s,clyellow); end; - i:=0;N_Det:=0; + i:=0; if AdrFonc<>El2 then // si pas déja trouvé le sens de progression begin repeat - //AfficheDebug('Engage '+IntToSTR(AdrPrec)+','+IntToSTR(typePrec)+'/'+IntToSTR(AdrFonc)+','+IntToSTR(typeFonc),clyellow); if nivDebug=3 then AfficheDebug('i='+IntToSTR(i)+' NDet='+IntToSTR(N_det),clyellow); if (AdrFonc<>0) or (TypeFonc<>rien) then Adr:=suivant_alg3(AdrPrec,TypePrec,AdrFonc,TypeFonc,alg) else begin Adr:=9999; end; - //Affiche(intToSTR(Adr)+'=alg3('+intToSTR(Adrprec)+','+intToSTR(Adrfonc)+')',clyellow); - if TypeGen=det then inc(N_Det); if NivDebug=3 then begin - s:='613 : trouvé='+intToSTR(Adr)+BTypeToChaine(typeGen); + s:='613.1 : Suivant='+intToSTR(Adr)+BTypeToChaine(typeGen); AfficheDebug(s,clYellow); end; @@ -7822,7 +8619,7 @@ begin 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); + sortie:=((typeDet2=TypeGen) and (Adr=el2)) or (Adr=0) or (Adr>=9990) or (i=15) or (N_Det=2); until sortie ; if (i=itMaxi) and (Nivdebug=3) then afficheDebug('Pas trouvé',clyellow); if (N_det=Nb_det_dist) and (Nivdebug=3) then @@ -7838,21 +8635,221 @@ begin adr:=el2;typeGen:=TypeDet2; end; + // ---------- phase 2 + IdActTr:=0; // init pointeur des actionneurs + if nivDebug=3 then afficheDebug('Init pointeur actionneurs',clLime); idel:=1; if (typeDet2=TypeGen) and (Adr=el2) and (N_Det<>Nb_det_dist) then begin - if Nivdebug=3 then AfficheDebug('614 - Trouvé '+intToSTR(el2),clYellow); + if Nivdebug=3 then AfficheDebug('614 - Trouvé '+intToSTR(el2),clOrange); inc(idEl); elements[idEl].adresse:=el2; elements[idEl].typ:=Typedet2; i:=0; 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 + begin + s:='615 : trouvé='+intToSTR(Adr)+BTypeToChaine(typeGen); + AfficheDebug(s,clorange); + end; + inc(idEl); + elements[idEl].adresse:=adr; + elements[idEl].typ:=TypeGen; + + // 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>=itMaxi); + until sortie; + if i>=itMaxi then Affiche('Erreur 67 : Dépassement itérations',clred); + if (TypeGen=det) or (TypeGen=buttoir) then + begin + Eprec:=AdrPrec;tprec:=TypePrec; + Esuiv:=suivant_alg3(AdrPrec,TypePrec,AdrFonc,TypeFonc,alg); + tsuiv:=typegen; + if NivDebug=3 then + begin + AfficheDebug('Le détecteur suivant est le '+IntToSTR(Adr),clyellow); + affichedebug('------------------',clyellow); + end; + detecteur_suivant_el:=Adr; + if debug=3 then formprinc.Caption:=''; + exit; + end; + 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 + + detecteur_suivant_el:=9996; + if NivDebug=3 then affichedebug('------------------',clyellow); + if debug=3 then formprinc.Caption:=''; +end; + +// trouve les actionneurs entre el1 et el2 +procedure trouve_actionneur(el1,el2 : integer); +var IndexBranche_det1,IndexBranche_det2,branche_trouve_det1,branche_trouve_det2,i, + j,AdrPrec,Adr,AdrFonc,i1,N_det,Ia,delta : integer; + Sortie : boolean; + TypePrec,TypeFonc : Tequipement; + s : string; + label reprise; + +begin + if NivDebug>=2 then + AfficheDebug('trouve_actionneur '+intToSTR(el1)+','+intToSTR(el2)+','+'-------------------------',clLime); + if (el1>9000) or (el2>9000) then + begin + if NivDebug=3 then AfficheDebug('Paramètres incorrects >9000',clred); + exit; + end; + + if (el2=0) then + begin + exit; + end; + + // trouver détecteur 1 + trouve_element(el1,det); // branche_trouve IndexBranche_trouve + if (IndexBranche_trouve=0) then + begin + if NivDebug=3 then + begin + s:='611. '+IntToSTR(el1)+' non trouvé'; + AfficheDebug(s,clOrange); + end; + exit; + end; + IndexBranche_det1:=IndexBranche_trouve; + branche_trouve_det1:=branche_trouve; + + // trouver détecteur 2 + trouve_element(el2,det); // branche_trouve IndexBranche_trouve + if (IndexBranche_trouve=0) then + begin + if NivDebug=3 then + begin + s:='612. '+IntToSTR(el2)+' non trouvé'; + AfficheDebug(s,clred); + AfficheDebug(s,clOrange); + end; + exit; + end; + + IndexBranche_det2:=IndexBranche_trouve; + branche_trouve_det2:=branche_trouve; + j:=1; // J=1 test en incrément J=2 test en décrément + idEl:=1; + // étape 1 : trouver le sens de progression (en incrément ou en décrément) + + repeat + //préparer les variables + AdrPrec:=el1;TypePrec:=det; + IdActTr:=0; // init pointeur des actionneurs + if nivDebug=3 then afficheDebug('Init pointeur actionneurs',clLime); + // sens + //========================nouveau + delta:=1; + repeat + if j=1 then i1:=IndexBranche_det1+delta; + if j=2 then i1:=IndexBranche_det1-delta; + if i1=0 then begin exit;end; + + AdrFonc:=BrancheN[branche_trouve_det1,i1].adresse; + typeFonc:=BrancheN[branche_trouve_det1,i1].Btype; + + if typeFonc=act then + begin + if nivDebug=3 then AfficheDebug('Act='+intToSTR(AdrFonc),clLime); + inc(IdActTr); + Actionneur_trouve[IdActTr]:=adrFonc; + end; + + elements[idEl].adresse:=adrFonc; + elements[idEl].typ:=TypeFonc; + inc(delta); + until typeFonc<>act ; + //=============================== + + N_Det:=0; + if Typefonc=det then N_det:=1; + + + if NivDebug=3 then + begin + s:='------> Test en '; + if (j=1) then s:=s+'incrément ' else s:=s+'décrément '; + s:=s+'- départ depuis élément '+IntToSTR(el1)+' trouvé en index='+intToSTR(IndexBranche_det1)+' Branche='+intToSTR(branche_trouve_det1); + AfficheDebug(s,clyellow); + end; + + i:=0; + if AdrFonc<>El2 then // si pas déja trouvé le sens de progression + begin + repeat + if nivDebug=3 then AfficheDebug('i='+IntToSTR(i)+' NDet='+IntToSTR(N_det),clyellow); + if (AdrFonc<>0) or (TypeFonc<>rien) then Adr:=suivant_alg3(AdrPrec,TypePrec,AdrFonc,TypeFonc,1) else + begin + Adr:=9999; + end; + + if TypeGen=det then inc(N_Det); + if NivDebug=3 then + begin + s:='613.1 : Suivant='+intToSTR(Adr)+BTypeToChaine(typeGen); + AfficheDebug(s,clYellow); + if adr=el2 then exit; + 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=2); + until sortie ; + 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 + + else + begin + // déja trouvé + adr:=el2;typeGen:=det; + end; + + // ---------- phase 2 + IdActTr:=0; // init pointeur des actionneurs + if nivDebug=3 then afficheDebug('Init pointeur actionneurs',clLime); + idel:=1; + if (TypeGen=det) and (Adr=el2) and (N_Det<>Nb_det_dist) then + begin + if Nivdebug=3 then AfficheDebug('614 - Trouvé '+intToSTR(el2),clOrange); + exit; + inc(idEl); + elements[idEl].adresse:=el2; + elements[idEl].typ:=det; + + i:=0; + repeat + Adr:=suivant_alg3(AdrPrec,TypePrec,AdrFonc,TypeFonc,1); if NivDebug=3 then begin @@ -7882,7 +8879,6 @@ begin AfficheDebug('le détecteur suivant est le '+IntToSTR(Adr),clyellow); affichedebug('------------------',clyellow); end; - detecteur_suivant_el:=Adr; if debug=3 then formprinc.Caption:=''; exit; end; @@ -7892,203 +8888,11 @@ begin //AfficheDebug('j='+intToSTR(j),clyellow); until j=3; // boucle incrément/décrément - detecteur_suivant_el:=9996; if NivDebug=3 then affichedebug('------------------',clyellow); if debug=3 then formprinc.Caption:=''; 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,ia : integer; - Sortie : boolean; - TypePrec,TypeFonc : Tequipement; - s : string; - label reprise; -begin - s:='Reserve_dereserve_det '+intToSTR(det1)+' '+intToSTR(det2)+' pour train '; - if roulage then s:=s+'@'+intToSTR(adrtrain) - else if avecResa then s:=s+intToSTR(IndexTrain); - if traceliste or ProcPrinc then afficheDebug(s,clorange); - Affiche(s,ClOrange); - - if NivDebug>=2 then - if (det1>9000) or (det2>9000) then - begin - if NivDebug=3 then AfficheDebug('Paramètres incorrects >9000',clred); - reserve_dereserve_det:=9999; - exit; - end; - - if (det2=0) then - begin - reserve_dereserve_det:=9995; - exit; - end; - - // trouver détecteur 1 - trouve_element(det1,det); // branche_trouve IndexBranche_trouve - if (IndexBranche_trouve=0) then - begin - if NivDebug=3 then - begin - s:='611. '+IntToSTR(det1)+' non trouvé'; - AfficheDebug(s,clOrange); - end; - reserve_dereserve_det:=9999; - exit; - end; - IndexBranche_det1:=IndexBranche_trouve; - branche_trouve_det1:=branche_trouve; - - // trouver détecteur 2 - trouve_element(det2,det); // branche_trouve IndexBranche_trouve - if (IndexBranche_trouve=0) then - begin - if NivDebug=3 then - begin - s:='612. '+IntToSTR(det2)+' non trouvé'; - AfficheDebug(s,clred); - AfficheDebug(s,clOrange); - end; - reserve_dereserve_det:=9999;exit; - end; - - IndexBranche_det2:=IndexBranche_trouve; - branche_trouve_det2:=branche_trouve; - j:=1; // J=1 test en incrément J=2 test en décrément - - // étape 1 : trouver le sens de progression (en incrément ou en décrément) - - repeat - //préparer les variables - AdrPrec:=det1;TypePrec:=det; - if j=1 then i1:=IndexBranche_det1+1; - if j=2 then i1:=IndexBranche_det1-1; - // les suivants dansla branche sont: - AdrFonc:=BrancheN[branche_trouve_det1,i1].adresse; - typeFonc:=BrancheN[branche_trouve_det1,i1].Btype; - - if NivDebug=3 then - begin - s:='------> Test en '; - if (j=1) then s:=s+'incrément ' else s:=s+'décrément '; - s:=s+'- départ depuis élément '+IntToSTR(det1)+' trouvé en index='+intToSTR(IndexBranche_det1)+' Branche='+intToSTR(branche_trouve_det1); - AfficheDebug(s,clyellow); - end; - - i:=0;N_Det:=0; - if AdrFonc<>det2 then // si pas déja trouvé le sens de progression - begin - repeat - //AfficheDebug('Engage '+IntToSTR(AdrPrec)+','+IntToSTR(typePrec)+'/'+IntToSTR(AdrFonc)+','+IntToSTR(typeFonc),clyellow); - if nivDebug=3 then AfficheDebug('i='+IntToSTR(i)+' NDet='+IntToSTR(N_det),clyellow); - if (AdrFonc<>0) or (TypeFonc<>rien) then Adr:=suivant_alg3(AdrPrec,TypePrec,AdrFonc,TypeFonc,1) else - begin - Adr:=9999; - end; - //AfficheDebug('Sortie Alg3: '+IntToSTR(Adr)+'/'+intToSTR(typeGen),clyellow); - if TypeGen=det then inc(N_Det); - if NivDebug=3 then - begin - s:='613 : trouvé='+intToSTR(Adr)+BTypeToChaine(typeGen); - 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=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); - afficheDebug(s,clorange); - end; - end - - else - begin - // déja trouvé - adr:=det2;typeGen:=det; - end; - - idel:=1; - elements[idEl].adresse:=adrPrec; - elements[idEl].typ:=TypePrec; - - if (TypeGen=det) and (Adr=det2) and (N_Det<>Nb_det_dist) then - begin - - i:=0; - repeat - //AfficheDebug('Engage '+IntToSTR(AdrPrec)+','+IntToSTR(typePrec)+'/'+IntToSTR(AdrFonc)+','+IntToSTR(typeFonc),clyellow); - Adr:=suivant_alg3(AdrFonc,TypeFonc,AdrPrec,TypePrec,1); - //AfficheDebug('Sortie Alg3: '+IntToSTR(Adr)+'/'+intToSTR(typeGen),clyellow); - - if NivDebug=3 then - begin - s:='615 : trouvé='+intToSTR(Adr)+BTypeToChaine(typeGen); - AfficheDebug(s,clorange); - end; - inc(idEl); - 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>=itMaxi); - until sortie; - - if (TypeGen=det) or (TypeGen=buttoir) then - begin - for k:=1 to IdEl do - begin - j:=elements[k].adresse; - typePrec:=elements[k].typ; - if (typePrec=Aig) or (typePrec=tjd) or (typePrec=tjs) or (typePrec=crois) or (typePrec=triple) then - begin - if TraceListe then AfficheDebug_Suivi(intToSTR(k)+' ',clOrange); - if mode=0 then Aiguillage[index_aig(j)].AdrTrain:=0 - else - if (Aiguillage[index_aig(k)].AdrTrain=0) then - begin - if avecresa then Aiguillage[index_aig(j)].AdrTrain:=indexTrain; - if roulage then Aiguillage[index_aig(j)].AdrTrain:=AdrTrain; - end; - Texte_aig_fond(j); - end; - end; - reserve_dereserve_det:=0; - exit; - end; - 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 - - reserve_dereserve_det:=9996; - if NivDebug=3 then affichedebug('------------------',clyellow); - if debug=3 then formprinc.Caption:=''; -end; - // renvoie le nombre de croisements entre les détecteurs el1 et el2 // jamais utilisée ! function Test_croisement(el1,el2,alg: integer) : integer ; @@ -8331,7 +9135,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 - ia,i,j,k,prec,indexSignal,AdrSuiv,index2,voie,AdrSignal : integer; + ia,i,j,k,prec,AdrSuiv,indexSig1,indexSig2,voieSig1,voieSig2,AdrSignal,voie : integer; TypeELPrec,TypeElActuel : TEquipement; sort,prestrain : boolean; s : string; @@ -8419,6 +9223,7 @@ begin end; //Affiche(IntToSTR(actuel),clyellow); + sort:=false; repeat inc(j); AdrSuiv:=suivant_alg3(prec,typeElPrec,actuel,typeELActuel,2); // arret sur aiguille en talon mal positionéne @@ -8446,20 +9251,22 @@ begin end; // si le précédent est un détecteur comporte t-il un signal? - indexSignal:=0; + indexSig1:=0; + indexSig2:=0; + if (typeElPrec=det) then begin - indexSignal:=index_signal_det(prec,voie,index2); // trouve l'index du signal correspondant au détecteur AdrSuiv + index_signal_det(prec,voieSig1,indexSig1,voieSig2,indexSig2); // trouve l'index du signal correspondant au détecteur AdrSuiv - if indexSignal<>0 then + if indexSig1<>0 then begin - AdrSignal:=Signaux[indexSignal].adresse; + AdrSignal:=Signaux[indexSig1].adresse; if nivdebug=3 then s:='Trouvé signal '+intToSTR(AdrSignal); - if ((voie=1) and (Signaux[indexSignal].Adr_el_suiv1=AdrSuiv)) or - ((voie=2) and (Signaux[indexSignal].Adr_el_suiv2=AdrSuiv)) or - ((voie=3) and (Signaux[indexSignal].Adr_el_suiv3=AdrSuiv)) or - ((voie=4) and (Signaux[indexSignal].Adr_el_suiv4=AdrSuiv)) + if ((voieSig1=1) and (Signaux[indexSig1].Adr_el_suiv1=AdrSuiv)) or + ((voieSig1=2) and (Signaux[indexSig1].Adr_el_suiv2=AdrSuiv)) or + ((voieSig1=3) and (Signaux[indexSig1].Adr_el_suiv3=AdrSuiv)) or + ((voieSig1=4) and (Signaux[indexSig1].Adr_el_suiv4=AdrSuiv)) then // le signal est-il dans le bon sens de progression? begin if nivdebug=3 then begin s:=s+' dans le bon sens';AfficheDebug(s,clYellow);end; @@ -8471,28 +9278,27 @@ begin s:=s+' dans le mauvais sens'; AfficheDebug(s,clYellow); end; - indexSignal:=0; + indexSig1:=0; // 2eme signal? - if index2<>0 then + if indexSig2<>0 then begin // vérifier le 2eme signal - AdrSignal:=Signaux[index2].Adresse; + AdrSignal:=Signaux[indexSig2].Adresse; if (adrSignal=Adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant begin - IndexSignal:=0; - j:=10; // on ne trouve pas de suivant + IndexSig2:=0; + sort:=true; // on ne trouve pas de suivant end; - if (Signaux[index2].Adr_el_suiv1=AdrSuiv) then // le signal est-il dans le bon sens de progression? + if (Signaux[indexSig2].Adr_el_suiv1=AdrSuiv) then // le signal est-il dans le bon sens de progression? begin // oui if NivDebug=3 then AfficheDebug('Sur même détecteur, trouvé signal2 suivant Adr='+IntToSTR(AdrSignal)+': ',clYellow); - indexSignal:=index2; end else begin if NivDebug=3 then AfficheDebug('Sur même détecteur, trouvé signal2 '+intToSTR(AdrSignal)+' mais dans le mauvais sens',clYellow); - IndexSignal:=0; + IndexSig2:=0; end; end; end; @@ -8515,8 +9321,21 @@ begin end; end; end; + if (typeElActuel=det) and (AdrSignal=0) then + begin + // adresse + if detecteur[actuel].AdrTrainRes<>0 then + begin + AdrTrain:=detecteur[actuel].AdrTrainRes; + if adrTrain<>0 then + begin + reserveTrainTiers:=reserveTrainTiers or (AdrTrain<>Trainreserve); + if (nivdebug>=1) then AfficheDebug('Détecteur '+intToSTR(actuel)+' verrouillé par train @'+intToSTR(AdrTrain),clorange); + end; + end; + end; - sort:=(j>=itMaxi) or (indexSignal<>0) or (AdrSuiv=9998) or (AdrSuiv=0); // arret si aiguillage en talon ou buttoir + sort:=(j>=itMaxi) or (indexSig1<>0) or (indexSig2<>0) or (AdrSuiv=9998) or (AdrSuiv=0) or sort; // 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 @@ -8536,7 +9355,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,ia : integer; +var num_signal,AdrSignal,i,j,prec,AdrSuiv,indexSig1,indexSig2,voie1,voie2,ia : integer; Typ,TypePrec,TypeActuel : TEquipement; s : string; begin @@ -8620,10 +9439,12 @@ begin AdrSignal:=0; if (TypeActuel=det) then // détecteur? begin - i:=Index_signal_det(Actuel,voie,index2); // trouve l'index de signal affecté au détecteur "Actuel" - if i<>0 then + //i:=Index_signal_det(Actuel,voie,index2); // trouve l'index de signal affecté au détecteur "Actuel" + //Index_signal_det(Actuel,voie,index2); + index_signal_det(actuel,voie1,indexSig1,voie2,indexSig2); + if indexSig1<>0 then begin - AdrSignal:=Signaux[i].Adresse; + AdrSignal:=Signaux[indexSig1].Adresse; if (AdrSignal=det1) then // si on ne reboucle sur le même signal dont on cherche le suivant begin AdrSignal:=0;j:=10; // on ne trouve pas de suivant @@ -8631,11 +9452,11 @@ begin if (AdrSignal<>0) then // si l'adresse est <>0 begin AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,1); - if nivdebug=3 then afficheDebug('Trouvé signal='+IntToSTR(AdrSignal)+'sur det '+intToSTR(actuel)+' Suivant='+IntToSTR(AdrSuiv)+' sur voie='+IntToSTR(voie),clyellow ); - if ((voie=1) and (Signaux[i].Adr_el_suiv1=AdrSuiv)) or - ((voie=2) and (Signaux[i].Adr_el_suiv2=AdrSuiv)) or - ((voie=3) and (Signaux[i].Adr_el_suiv3=AdrSuiv)) or - ((voie=4) and (Signaux[i].Adr_el_suiv4=AdrSuiv)) + if nivdebug=3 then afficheDebug('Trouvé signal='+IntToSTR(AdrSignal)+'sur det '+intToSTR(actuel)+' Suivant='+IntToSTR(AdrSuiv)+' sur voie='+IntToSTR(voie1),clyellow ); + if ((voie1=1) and (Signaux[indexSig1].Adr_el_suiv1=AdrSuiv)) or + ((voie1=2) and (Signaux[indexSig1].Adr_el_suiv2=AdrSuiv)) or + ((voie1=3) and (Signaux[indexSig1].Adr_el_suiv3=AdrSuiv)) or + ((voie1=4) and (Signaux[indexSig1].Adr_el_suiv4=AdrSuiv)) then // le signal est-il dans le bon sens de progression? begin // oui @@ -8650,15 +9471,15 @@ begin begin if NivDebug=3 then AfficheDebug('Trouvé signal '+intToSTR(AdrSignal)+' mais dans le mauvais sens',clOrange); AdrSignal:=0; - if index2<>0 then + if indexSig2<>0 then begin // vérifier le 2eme signal - AdrSignal:=Signaux[index2].Adresse; + AdrSignal:=Signaux[indexSig2].Adresse; if (AdrSignal=det1) then // si on ne reboucle sur le même signal dont on cherche le suivant begin AdrSignal:=0;j:=10; // on ne trouve pas de suivant end; - if (Signaux[index2].Adr_el_suiv1=AdrSuiv) then // le signal est-il dans le bon sens de progression? + if (Signaux[indexSig2].Adr_el_suiv1=AdrSuiv) then // le signal est-il dans le bon sens de progression? begin // oui inc(num_signal); @@ -8705,7 +9526,7 @@ end; // remplit aussi les élements[] rencontrés // 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; +var index,num_signal,etat,AdrSignal,i,j,prec,AdrSuiv,indexSig1,indexSig2,voie1,voie2 : integer; aspect,combine,ia : integer; TypePrec,TypeActuel,typ : TEquipement; s : string; @@ -8747,8 +9568,9 @@ begin actuel:=Signaux[i].Adr_el_suiv1; typeActuel:=Signaux[i].Btype_suiv1; - elements[1].adresse:=actuel;elements[1].typ:=typeActuel; - idEl:=2; + elements[1].adresse:=prec;elements[1].typ:=typePrec; + elements[2].adresse:=actuel;elements[2].typ:=typeActuel; + idEl:=3; if nivDebug=3 then AfficheDebug('Actuel ='+IntToSTR(actuel),clyellow); repeat @@ -8818,10 +9640,11 @@ begin AdrSignal:=0; if (TypeActuel=det) then // détecteur? begin - i:=Index_signal_det(Actuel,voie,index2); // trouve l'index de signal affecté au détecteur "Actuel" - if i<>0 then + // i:=Index_signal_det(Actuel,voie,index2); // trouve l'index de signal affecté au détecteur "Actuel" + index_signal_det(actuel,voie1,indexSig1,voie2,indexSig2); + if indexSig1<>0 then begin - AdrSignal:=Signaux[i].Adresse; + AdrSignal:=Signaux[indexSig1].Adresse; if (AdrSignal=Adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant begin AdrSignal:=0;j:=10; // on ne trouve pas de suivant @@ -8829,16 +9652,17 @@ begin if (AdrSignal<>0) then // si l'adresse est <>0 begin AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,1); - if nivdebug=3 then afficheDebug('Trouvé signal='+IntToSTR(AdrSignal)+'sur det '+intToSTR(actuel)+' Suivant='+IntToSTR(AdrSuiv)+' sur voie='+IntToSTR(voie),clyellow ); - if ((voie=1) and (Signaux[i].Adr_el_suiv1=AdrSuiv)) or - ((voie=2) and (Signaux[i].Adr_el_suiv2=AdrSuiv)) or - ((voie=3) and (Signaux[i].Adr_el_suiv3=AdrSuiv)) or - ((voie=4) and (Signaux[i].Adr_el_suiv4=AdrSuiv)) - then // le signal est-il dans le bon sens de progression? + + if nivdebug=3 then afficheDebug('Trouvé signal='+IntToSTR(AdrSignal)+'sur det '+intToSTR(actuel)+' Suivant='+IntToSTR(AdrSuiv)+' sur voie='+IntToSTR(voie1),clyellow ); + if ((voie1=1) and (Signaux[indexSig1].Adr_el_suiv1=AdrSuiv)) or + ((voie1=2) and (Signaux[indexSig1].Adr_el_suiv2=AdrSuiv)) or + ((voie1=3) and (Signaux[indexSig1].Adr_el_suiv3=AdrSuiv)) or + ((voie1=4) and (Signaux[indexSig1].Adr_el_suiv4=AdrSuiv)) + then // le signal est-il dans le bon sens de progression? begin // oui inc(num_signal); - Etat:=Signaux[Index_Signal(AdrSignal)].EtatSignal; + Etat:=Signaux[IndexSig1].EtatSignal; code_to_aspect(Etat,aspect,combine); Signal_suivant:=AdrSignal; if NivDebug=3 then @@ -8852,20 +9676,20 @@ begin begin if NivDebug=3 then AfficheDebug('Trouvé signal '+intToSTR(AdrSignal)+' mais dans le mauvais sens',clOrange); AdrSignal:=0; - if index2<>0 then + if indexSig2<>0 then begin // vérifier le 2eme signal - AdrSignal:=Signaux[index2].Adresse; + AdrSignal:=Signaux[indexSig2].Adresse; if (AdrSignal=Adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant begin AdrSignal:=0;j:=10; // on ne trouve pas de suivant end; - if (Signaux[index2].Adr_el_suiv1=AdrSuiv) then // le signal est-il dans le bon sens de progression? + if (Signaux[indexSig2].Adr_el_suiv1=AdrSuiv) then // le signal est-il dans le bon sens de progression? begin // oui inc(num_signal); - Etat:=Signaux[Index_Signal(AdrSignal)].EtatSignal; + Etat:=Signaux[IndexSig2].EtatSignal; code_to_aspect(Etat,aspect,combine); Signal_suivant:=AdrSignal; if NivDebug=3 then @@ -8900,7 +9724,7 @@ end; // 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,ia : integer; +var AdrSignal,i,j,prec,AdrSuiv,Actuel,index,indexSig1,indexSig2,voie1,voie2,ia : integer; TypePrec,TypeActuel : TEquipement; s : string; begin @@ -8948,14 +9772,19 @@ begin AdrSignal:=0; if (TypeActuel=det) then // détecteur begin - i:=Index_signal_det(AdrSuiv,voie,index2); // trouve l'index de feu affecté au détecteur "AdrSuiv" - AdrSignal:=Signaux[i].Adresse; +// i:=Index_signal_det(AdrSuiv,voie,index2); // trouve l'index de feu affecté au détecteur "AdrSuiv" + index_signal_det(AdrSuiv,voie1,indexSig1,voie2,indexSig2); + + // à compléter par signal inverse + AdrSignal:=Signaux[indexSig1].Adresse; + + if NivDebug=3 then AfficheDebug('trouvé signal '+intToSTR(AdrSignal)+' associé au détecteur '+IntToSTR(AdrSuiv),clyellow); end; end; until (j>=itMaxi) or (AdrSuiv>=9990) or (AdrSignal<>0) or (AdrSuiv=0) ; - if j>=itMaxi then affiche('Erreur 79 : itération maximale',clred); + if j>=itMaxi then affiche('Erreur 79 : itération maximale Aiguille_deviee('+intToSTR(adresse)+')',clred); if (AdrSuiv=9997) then begin s:='Le signal '+intToSTR(adresse)+' doit afficher un rappel car l''aiguillage '+intToSTR(AdrDevie); @@ -9016,17 +9845,59 @@ begin dec(i,2); // i correspond au nombre de feux à allumer pilote_direction(Adr,i); end; - end; +// test si train dans le bon sens sur canton d'index idcanton , sur détecteur prec +// si pres=faux : teste le sens de la loco dans le canton +// si pres=true ne teste que la présence quelque soit le sens de la loco dans le canton +function Test_train_canton(prec : integer;typePrec : tequipement;actuel : integer;TypeActuel : tequipement;pres : boolean) : integer; +var AdrTr,sens,sens1,sens2,el1,el2,icanton : integer; + tel1,tel2 : tequipement; + tcanton : boolean; +begin + icanton:=1; + repeat + el1:=canton[iCanton].el1;tel1:=Canton[iCanton].typ1; + el2:=canton[iCanton].el2;tel2:=Canton[iCanton].typ2; + tCanton:=((el1=prec) and (tel1=TypePrec) and (el2=actuel) and (tel2=TypeActuel)) or + ((el1=actuel) and (tel1=TypeActuel) and (el2=prec) and (tel2=TypePrec)); + inc(icanton); + until tCanton or (icanton>nCantons); + dec(icanton); + if tcanton then + begin + AdrTr:=canton[icanton].adresseTrain; + sens:=canton[icanton].SensLoco; + sens1:=canton[icanton].SensEl1; + sens2:=canton[icanton].SensEl2; + + // vérifier si le train dans le canton est dans le bon sens + tcanton:= (sens=sensGauche) and (sens1=sensGauche) and (el1=prec) or + (sens=sensDroit) and (sens2=sensDroit) and (el2=prec) or + (sens=sensHaut) and (sens1=sensHaut) and (el1=prec) or + (sens=sensBas) and (sens2=sensBas) and (el2=prec) ; + tcanton:= tcanton or pres; + + if (adrTr<>0) and tcanton then + begin + if nivDebug=3 then AfficheDebug('Trouvé train sur canton '+intToSTR(canton[iCanton].numero),clYellow); + result:=AdrTr; + exit; + end; + end; + result:=0; +end; + + + // renvoie vrai si une mémoire de zone est occupée après le signal "adresse" jusqu'au // nombre de signaux suivants défini par NSigMax=1, 2 ou 3.. (=canton) // sort de suite si on trouve un train // adresse=adresse du signal function test_memoire_zones(adresse : integer) : boolean; var - AdrSuiv,prec,ife,actuel,i,j,it,isi, - dernierdet,AdrSignal,NSignaux,NSigMax,voie,index2,ia : integer; + AdrSuiv,prec,ife,actuel,i,j,it,AdrTr, + dernierdet,AdrSignal,NSignaux,NSigMax,voie1,voie2,indexSig2,indexSig1,ia : integer; TypePrec,TypeActuel : TEquipement; Pres_train : boolean; s : string; @@ -9042,6 +9913,7 @@ begin exit; end; + Pres_Train:=false; if debug=3 then formprinc.Caption:='Test_memoire_zones '+IntToSTR(adresse); NSigMax:=1; // nombre de feux à trouver (nombre de cantons) @@ -9086,7 +9958,7 @@ begin TypePrec:=det; dernierdet:=prec; - // purge les aiguillages après le feu + // purge les aiguillages après le signal it:=0; if TypeActuel=aig then repeat @@ -9106,8 +9978,12 @@ begin prec:=actuel;TypePrec:=TypeActuel; actuel:=AdrSuiv;TypeActuel:=typeGen; + + Adrtr:=Test_train_canton(prec,typePrec,actuel,TypeActuel,true); + pres_train:=(adrTr<>0) or pres_train; + inc(it); - until (typeactuel=det) or (it>100); + until (typeactuel=det) or pres_Train or (it>100); if it>100 then begin @@ -9144,10 +10020,11 @@ begin dernierdet:=actuel; - isi:=index_signal_det(Actuel,voie,index2); // renvoie l'index du signal se trouvant au détecteur "AdrSuiv": il peut y avoir 4 détecteurs par signal - if isi<>0 then +// isi:=index_signal_det(Actuel,voie,index2); // renvoie l'index du signal se trouvant au détecteur "AdrSuiv": il peut y avoir 4 détecteurs par signal + index_signal_det(actuel,voie1,indexSig1,voie2,indexSig2); + if indexSig1<>0 then begin - AdrSignal:=Signaux[isi].adresse; // adresse du feu + AdrSignal:=Signaux[indexSig1].adresse; // adresse du signal if (AdrSignal=adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant begin AdrSignal:=0;j:=10; // on ne trouve pas de suivant @@ -9157,7 +10034,7 @@ begin end; if (AdrSignal<>0) then // si l'adresse est <>0 begin - if (Signaux[isi].Adr_el_suiv1<>prec) then // le signal est-il dans le bon sens de progression? + if (Signaux[indexSig1].Adr_el_suiv1<>prec) then // le signal est-il dans le bon sens de progression? begin inc(NSignaux); j:=0; @@ -9260,8 +10137,8 @@ end; // les positions des aiguillages pris en pointe doivent être connus function Signal_precedent(adresse : integer) : integer; var - AdrSuiv,prec,ife,actuel,i,j,ifd,index, - dernierdet,AdrSignal,Nsignaux,voie,index2,ia : integer; + AdrSuiv,prec,ife,actuel,i,j,index, + dernierdet,AdrSignal,Nsignaux,voie1,voie2,indexSig1,indexSig2,ia : integer; TypePrec,TypeActuel : TEquipement; malpositionne : boolean; s : string; @@ -9320,6 +10197,10 @@ begin exit; end; + elements[idEl].adresse:=actuel; + elements[idEl].typ:=det; + inc(idEl); + dernierdet:=actuel; repeat @@ -9374,17 +10255,18 @@ begin begin dernierdet:=actuel; - ifd:=index_signal_det(Actuel,voie,index2); // renvoie l'index du signal se trouvant au détecteur "AdrSuiv": il peut y avoir 4 détecteurs par signal - if ifd<>0 then +// ifd:=index_signal_det(Actuel,voie,index2); // renvoie l'index du signal se trouvant au détecteur "AdrSuiv": il peut y avoir 4 détecteurs par signal + index_signal_det(actuel,voie1,indexSig1,voie2,indexSig2); + if indexSig1<>0 then begin - AdrSignal:=Signaux[ifd].adresse; // adresse du feu + AdrSignal:=Signaux[indexSig1].adresse; // adresse du feu if (AdrSignal=adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant begin Signal_precedent:=0; end; if (AdrSignal<>0) then // si l'adresse est <>0 begin - if (Signaux[ifd].Adr_el_suiv1=prec) then // le signal est-il dans le bon sens de progression? + if (Signaux[indexSig1].Adr_el_suiv1=prec) then // le signal est-il dans le bon sens de progression? begin inc(Nsignaux); s:='Trouvé signal '+IntToSTR(AdrSignal); @@ -9409,67 +10291,19 @@ begin Signal_precedent:=0; end; -// libère le canton avant detecteur2 comportant un signal et le signal précédent -// attention le détecteur 2 n'est pas forcément associé à un signal (et dans le bon sens) -Procedure libere_canton(detecteur1,detecteur2 : integer); -var sd2,i,j: integer; - typ : tEquipement; -begin - // mode_reserve 0 = par canton - 1=par détecteurs - if mode_reserve=1 then - begin - reserve_dereserve_det(detecteur1,detecteur2,0,0,0); - exit; - end; - - if not(roulage) and not(avecResa) then exit; - //if traceliste or ProcPrinc then - affiche('Libère_canton '+intToSTR(detecteur1)+' '+intToSTR(detecteur2),clLime); - if ProcPrinc or traceListe then AfficheDebug('Libère_Canton '+intToSTR(detecteur1)+' '+intToSTR(detecteur2),clLime); - // est-on en limite de canton du detecteur 2 pour le libérer? - sd2:=signal_detecteur(detecteur2); // trouve le signal associé au detecteur2 - if sd2=0 then - begin - if traceliste then affiche('le détecteur '+intToSTR(detecteur2)+' n''est pas pas associé à un signal - pas de libération du canton',clorange); - exit; // pas de signal associé - end; - // ce signal sd2 est il dans le bon sens - i:=signal_suivant_det(detecteur1,detecteur2); // adresse du signal dans le bon sens associé au détecteur - //if i<>sd2 then exit; - if i=0 then exit; - - // trouver le signal précédent - i:=Signal_precedent(i); // trouve les éléments entre les deux signaux - - if traceListe then AfficheDebug('Libération canton det '+IntToSTR(detecteur1)+' '+intToSTR(detecteur2)+' : ',clLime); - for i:=1 to idEl-1 do - begin - j:=elements[i].adresse; - typ:=elements[i].typ; - if (typ=Aig) or (typ=tjd) or (typ=tjs) or (typ=crois) or (typ=triple) then - begin - if traceListe then Affichedebug_Suivi('A'+intToSTR(j)+' ',clLime); - Aiguillage[index_aig(j)].AdrTrain:=0; // libère l'aiguillage - end; - end; - Maj_Signaux(false); -end; - - // présence train précédent les n (NbCtSig) cantons du signal Adresse, dans le sens d'avance vers le signal. // detect=true si on doit contrôler aussi sur les détecteurs // renvoie vrai si présence train -// dans AdrTrain: renvoie 0 si pas de train -// si on est en mode AvecRESA, renvoie l'index du train -// roulage, renvoie l'adresse du train +// dans AdrTr: renvoie 0 si pas de train +// en mode roulage, renvoie l'adresse du train // dans voie : numéro de la voie du signal sur laquelle on a trouvé le train function PresTrainPrec(Adresse,NbCtSig : integer;detect : boolean;var AdrTr,voie : integer) : boolean; var AdrSuiv,prec,ife,actuel,i,j,k,ifd,d,ia, - dernierdet,AdrSignal,Nsignaux,voieLoc,index2 : integer; + dernierdet,AdrSignal,Nsignaux,voieLoc,voie1,voie2,indexSig1,indexSig2 : integer; TypePrec,TypeActuel : TEquipement; - Pres_train,malpositionne,etat,etatDet,EtatZone : boolean; + Pres_train,malpositionne,etat,etatDet,EtatZone,tcanton : boolean; s : string; begin AdrTr:=0; @@ -9481,6 +10315,7 @@ begin else s:=s+'sur zones de détecteurs uniquement'; AfficheDebug(s,clyellow); end; + i:=Index_Signal(adresse); if (i=0) then begin @@ -9492,7 +10327,7 @@ begin exit; end; - ife:=1; // index voie de 1 à 4 pour explorer les 4 détecteurs d'un feu + ife:=1; // index voie de 1 à 4 pour explorer les 4 détecteurs d'un signal repeat if NivDebug=3 then AfficheDebug('Boucle de test signal '+intToSTR(ife)+'/4',clOrange); if (ife=1) then @@ -9531,7 +10366,6 @@ begin if pres_train and (AdrTr=0) then begin - if avecRESA then AdrTR:=Detecteur[actuel].IndexTrain; if roulage then AdrTr:=Detecteur[actuel].AdrTrain; end; if pres_train and (nivDebug=3) then AfficheDebug('Présence train '+intToSTR(AdrTr)+' sur dét '+intToSTR(actuel),clyellow); @@ -9539,7 +10373,7 @@ begin TypeActuel:=det; if actuel=0 then begin - // sortie si aucun détecteur déclaré sur le feu + // sortie si aucun détecteur déclaré sur le signal PresTrainPrec:=Pres_train; voie:=ife; if nivDebug=3 then AfficheDebug('Pas de détecteur sur voie '+intToSTR(ife)+' au signal '+IntToSTR(adresse),clyellow); @@ -9547,7 +10381,7 @@ begin exit; end; - // lire la mémoire de zone des détecteurs précédent le signal + // lire la mémoire de zone des détecteurs précédant le signal k:=1; repeat d:=Signaux[i].DetAmont[k]; @@ -9556,7 +10390,6 @@ begin pres_Train:=MemZone[d,actuel].etat or Pres_Train; if MemZone[d,actuel].etat and (adrTr=0) then begin - if avecRESA then AdrTR:=MemZone[d,actuel].indexTrain; if roulage then AdrTr:=MemZone[d,actuel].AdrTrain; end; if (NivDebug=3) and MemZone[d,actuel].etat then AfficheDebug('Trouvé train '+intToSTR(AdrTr)+' sur mémoire de zone '+intToSTR(d)+','+intToSTR(actuel),clyellow); @@ -9569,8 +10402,18 @@ begin Nsignaux:=0; repeat inc(j); - AdrSuiv:=suivant_alg3(prec,TypePrec,actuel,TypeActuel,2); // 2 car arrêt sur aiguille en talon mal positionnée + // et vérifier si canton + + if adrtr=0 then Adrtr:=Test_train_canton(prec,typePrec,actuel,TypeActuel,false); + if (adrTr<>0) then + begin + if nivDebug=3 then AfficheDebug('Trouvé train sur canton ',clYellow); + presTrainPrec:=true; + voie:=ife; + exit; + end; + malpositionne:=(AdrSuiv=0) or (AdrSuiv>9990); if malpositionne then begin @@ -9581,7 +10424,6 @@ begin if Pres_Train and (adrTr=0) then begin if roulage then AdrTr:=Detecteur[actuel].AdrTrain; - if avecResa then AdrTr:=Detecteur[actuel].indexTrain; end; end; @@ -9622,7 +10464,6 @@ begin if Pres_Train and (AdrTr=0) then begin if roulage then AdrTr:=MemZone[actuel,dernierdet].AdrTrain; // adresse - if AvecRESA then AdrTr:=MemZone[actuel,dernierdet].IndexTrain; // index if (nivDebug=3) then begin s:='Présence train '; @@ -9640,10 +10481,11 @@ begin dernierdet:=actuel; - ifd:=index_signal_det(Actuel,voie,index2); // renvoie l'index du signal se trouvant au détecteur "AdrSuiv": il peut y avoir 4 détecteurs par signal - if ifd<>0 then +// ifd:=index_signal_det(Actuel,voie,index2); // renvoie l'index du signal se trouvant au détecteur "AdrSuiv": il peut y avoir 4 détecteurs par signal + index_signal_det(actuel,voie1,indexSig1,voie2,indexSig2); + if indexSig1<>0 then begin - AdrSignal:=Signaux[ifd].adresse; // adresse du signal + AdrSignal:=Signaux[indexSig1].adresse; // adresse du signal if (AdrSignal=adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant begin AdrSignal:=0; // on ne trouve pas de suivant @@ -9655,11 +10497,11 @@ begin end; if (AdrSignal<>0) then // si l'adresse est <>0 begin - if (Signaux[ifd].Adr_el_suiv1=prec) then // le signal est-il dans le bon sens de progression? + if (Signaux[indexSig1].Adr_el_suiv1=prec) then // le signal est-il dans le bon sens de progression? begin inc(Nsignaux); j:=0; - s:='Trouvé signal '+intToStr(AdrSignal)+' ('+IntToSTR(Nsignaux)+'/'+intToSTR(NbCtSig)+') '+IntToSTR(AdrSignal); + s:='Trouvé signal '+intToStr(AdrSignal)+' ('+IntToSTR(Nsignaux)+'/'+intToSTR(NbCtSig)+') '; if (NivDebug=3) And Pres_Train then AfficheDebug(s+' et mémoire de zone à 1',clOrange); if (NivDebug=3) And (not(Pres_Train)) then AfficheDebug(s+' et mémoire de zone à 0',clOrange); if nSignaux=NbCtSig then // si atteint les 3 signaux (3 cantons) @@ -9673,14 +10515,13 @@ begin // lire la mémoire de zone des détecteurs n-2 précédent le signal k:=1; repeat - d:=Signaux[ifd].DetAmont[k]; - if d<>0 then + d:=Signaux[indexSig1].DetAmont[k]; + if (d<>0) and (d0 then + begin + // trouver le détecteur suivant + if Signaux[index].Btype_suiv1<>det then detSuiv:=detecteur_suivant(Signaux[index].Adr_det1,det,Signaux[index].Adr_el_suiv1,Signaux[index].Btype_suiv1,1) + else detSuiv:=Signaux[index].Adr_el_suiv1; + if detSuiv<9990 then + begin + if roulageTrain>0 then reserve_canton(Signaux[index].Adr_det1,detSuiv,AdrtrainLoc,0,nCantonsRes) else + end; + end; } + end; + end; + end; +end; + // met à jour l'état du signel belge selon l'environnement des aiguillages et des trains procedure signal_belge(AdrSignal : integer;detect : boolean); @@ -9832,26 +10712,7 @@ begin end; envoi_signal(AdrSignal); - // si le signal n'est pas rouge, réserver les aiguillages en aval - { - if (roulage or AvecResa) and (AdrTrainLoc<>0) then - begin - etat:=Signaux[index].EtatSignal; - if not(signal_rouge(AdrSignal)) then - begin - adr_Det:=Signaux[index].Adr_det1; - if detecteur[adr_det].Etat then - begin - if Signaux[index].Btype_suiv1<>det then detSuiv:=detecteur_suivant(Signaux[index].Adr_det1,det,Signaux[index].Adr_el_suiv1,Signaux[index].Btype_suiv1,1) - else detSuiv:=Signaux[index].Adr_el_suiv1; - if detSuiv<9990 then - begin - if roulage then reserve_canton(Signaux[index].Adr_det1,detSuiv,AdrtrainLoc,0,nCantonsRes) else - if AvecResa then reserve_canton(Signaux[index].Adr_det1,detSuiv,0,AdrtrainLoc,nCantonsRes) ; - end; - end; - end; - end; } + fin_maj_signal(AdrSignal); if signalDebug=AdrSignal then begin AffSignal:=false;nivDebug:=0;end; if debug=3 then formprinc.Caption:=''; @@ -9931,7 +10792,7 @@ begin else begin if not(cond_FeuBlanc(AdrSignal)) and test_memoire_zones(AdrSignal) then Maj_Etat_Signal(AdrSignal,violet) // test si présence train après signal - else Maj_Etat_Signal(AdrSignal,blanc); + else Maj_Etat_Signal(AdrSignal,blanc); // faire la réservation des aiguillages if debug=3 then formprinc.Caption:=''; end; @@ -9951,7 +10812,7 @@ begin if AffSignal and reserveTrainTiers then AfficheDebug('trouvé aiguillage réservé par autre train',clYellow); if AffSignal and car then AfficheDebug('le signal a des aiguilles en talon aval mal positionnées',clYellow); // En mode roulage, si la réservation est faite par le train détecté en étape A, ne pas verrouiller au carré - if avecRESA or roulage then car:=(reserveTrainTiers and Signaux[index].VerrouCarre) or car; // tenir compte de la réservation si on est en mode avec réservation des aiguillages + if roulage then car:=(reserveTrainTiers and Signaux[index].VerrouCarre) or car; // tenir compte de la réservation si on est en mode avec réservation des aiguillages // conditions supplémentaires de carré en fonction des aiguillages décrits car:=cond_carre(AdrSignal) or car; //if AffSignal and car then AfficheDebug('le signal a des aiguilles en talon aval mal positionnées',clYellow); @@ -10054,9 +10915,9 @@ begin end else begin - // si le signal suivant est jaune + // si le signal suivant est jaune ou ral_30 (et pas ral_60) //if affsignal then AfficheDebug('test 404',clyellow); - if TestBit(etat,jaune) or TestBit(etat,ral_30) or TestBit(etat,ral_60) then + if TestBit(etat,jaune) or TestBit(etat,ral_30) then begin Maj_Etat_Signal(AdrSignal,jaune_cli); //if affsignal then AfficheDebug('401.Mise du feu au jaune cli',clyellow); @@ -10093,34 +10954,14 @@ begin envoi_signal(AdrSignal); // si le signal n'est pas rouge avec un train sur le détecteur du signal, réserver les aiguillages en aval - { - if (roulage or AvecResa) and (AdrTrainLoc<>0) then - begin - etat:=Signaux[index].EtatSignal; - if not(signal_rouge(AdrSignal)) then - begin - adr_Det:=Signaux[index].Adr_det1; - if detecteur[adr_det].Etat then // détecteur doit être activé par loco - begin - // trouver si le signal est dans le bon sens - //id:=detecteur[adr_det].IndexTrain; - //det1:=event_det_train[id].Det[2].adresse; - //det2:=event_det_train[id].suivant; - //det3:=suivant_alg3(det1, - // trouver le détecteur suivant - if Signaux[index].Btype_suiv1<>det then detSuiv:=detecteur_suivant(Signaux[index].Adr_det1,det,Signaux[index].Adr_el_suiv1,Signaux[index].Btype_suiv1,1) - else detSuiv:=Signaux[index].Adr_el_suiv1; - if detSuiv<9990 then - begin - if roulage then reserve_canton(Signaux[index].Adr_det1,detSuiv,AdrtrainLoc,0,nCantonsRes) else - if AvecResa then reserve_canton(Signaux[index].Adr_det1,detSuiv,0,AdrtrainLoc,nCantonsRes) ; - end; - end; - end; - end; } + fin_maj_signal(AdrSignal); - if signalDebug=AdrSignal then begin AffSignal:=false;nivDebug:=0;end; + if signaldebug=AdrSignal then AfficheDebug(chaine_signal(adrSIgnal),clWhite); + + + if signalDebug=AdrSignal then begin + AffSignal:=false;nivDebug:=0;end; if debug=3 then formprinc.Caption:=''; end; @@ -10172,7 +11013,7 @@ end; // renvoie vrai si le signal adresse est dans le sens det1 det2 function signal_sens(adrSig,det1,det2 : integer) : boolean; -var i,it,suiv,succ,actuel,a,ia : integer; +var i,it,suiv,succ,actuel,ia : integer; typeAct,typSuiv : tEquipement; begin if debug=3 then formprinc.Caption:='Signal_sens '+IntToSTR(AdrSig); @@ -10218,33 +11059,37 @@ begin signal_sens:=succ=det2; end; -// réserve le nombre de cantons "nCantons" du detecteur1 (non compris) équipé du signal ou le prochain suivant si le signal n'est pas au rouge -// la réservation consiste à marquer un aiguillage avec l'adresse du train "adrTrain" ou "NumTrain" -// det1 et det2 sont contigus +// réserve le nombre de cantons "nCantons" du detecteur1 (non compris) au detecteur2 (compris) équipé du signal ou le prochain suivant si le signal n'est pas au rouge +// la réservation consiste à marquer un aiguillage ou un détecteur avec l'adresse du train "adrTrain" ou "NumTrain" +// La procédure vérifie si les aiguillages ou les détecteurs sont réservés par un autre train, dans ce cas en sortie, on a le train qui a réservé les aiguillages. +// la réservation est faite en direction des aiguillages déja positionnés. +// det1 et det2 doivent se suivre. // adrTrain = adresse du train (mode roulage uniquement) // NumTrain = index du train (pas mode roulage, avec CDM) -procedure reserve_canton(detecteur1,detecteur2,adrtrain,NumTrain,NCantons : integer); -var nc,AdrSig,i,j,etat,etatSuiv,AdrSignalsuivant : integer; +// met à jour le tableau en var globale "elements[]" Nombre : IdEl-1 +// en sortie : result=train qui a réservé les aiguillages +// ou -1 si pas de signal +function reserve_canton(detecteur1,detecteur2,adrtrain,NumTrain,NCantons : integer) : integer; +var nc,AdrSig,i,j,etat,etatSuiv,AdrSignalsuivant,TrainExistant : integer; rouge,cas2 : boolean; typ : tEquipement; s : string; begin - if not(roulage) and not(avecResa) then exit; - if (detecteur1=0) or (detecteur2=0) then + result:=0; + if not(roulage) then exit; + if (detecteur1=0) then begin s:='Erreur 62 : reserve_canton'; if detecteur1=0 then s:=s+' det1 nul'; - if detecteur2=0 then s:=s+' det2 nul'; Affiche(s,clred); exit; end; - begin - s:='Réservation '+intToSTR(nCantons)+' cantons après détecteur '+intToSTR(detecteur1)+' '+intToSTR(detecteur2)+' pour train '; - if roulage then s:=s+'@'+intToSTR(adrtrain) - else if avecResa then s:=s+intToSTR(NumTrain); - if traceliste or ProcPrinc then afficheDebug(s,clorange); - Affiche(s,ClOrange); - end; + if detecteur2=0 then exit; + + s:='Réservation '+intToSTR(nCantons)+' cantons après détecteur '+intToSTR(detecteur1)+' '+intToSTR(detecteur2)+' pour train '; + if roulage then s:=s+'@'+intToSTR(adrtrain) ; + if traceliste or ProcPrinc then afficheDebug(s,clorange); + if affres then Affiche(s,ClOrange); if (detecteur1>NbMaxDet) or (detecteur2>NbMaxDet) then begin @@ -10256,6 +11101,7 @@ begin // y a t-il un signal sur le détecteur1 cas2:=false; + AdrSig:=signal_detecteur(detecteur1); // trouve le signal associé au detecteur1 if adrSig<>0 then begin @@ -10276,8 +11122,9 @@ begin if adrSig=0 then begin //Affiche('Absence de signal après '+intToSTR(detecteur2)+', réservation pour train @'+intToStr(AdrTrain)+' '+intToSTR(detecteur1)+' '+intToSTR(detecteur2)+' impossible',clred); - i:=indexbrut_train_adresse(AdrTrain); // numéro de train - if i<>0 then reserve_dereserve_det(detecteur1,detecteur2,adrTrain,i,1); + // i:=indexbrut_train_adresse(AdrTrain); // numéro de train +// if i<>0 then reserve_dereserve_det(detecteur1,detecteur2,adrTrain,i,1); + result:=-1; exit; end; @@ -10289,11 +11136,18 @@ begin exit; end; - etatSuiv:=etat_signal_suivant(AdrSig,1,AdrSignalsuivant); //réserve le canton du signal AdrSig au suivant : AdresseSignalSuivant + etatSuiv:=etat_signal_suivant(AdrSig,1,AdrSignalsuivant); // remplit elements[] + + //réserve le canton du signal AdrSig au suivant : AdresseSignalSuivant // dans le bon sens // 1er canton // marquer les aiguillages réservés - if traceliste then AfficheDebug('A. Elements réservés: ',clOrange); + if roulage then result:=AdrTrain; + + + // balayer les éléments pour vérifier si un d'entre eux est réservé par un autre train + // si c'est le cas on sort. + // on ne réserve pas le premier détecteur ; exemple : reserve_canton(525,528) ne réserve pas 525 for i:=1 to idEl-1 do begin j:=elements[i].adresse; @@ -10302,20 +11156,67 @@ begin begin if TraceListe then AfficheDebug_Suivi(intToSTR(j)+' ',clOrange); // vérifier si l'aiguillage est libre - if AvecResa then + TrainExistant:=Aiguillage[index_aig(j)].AdrTrain; + if (trainexistant<>AdrTrain) and (TrainExistant<>0) then begin - if (Aiguillage[index_aig(j)].AdrTrain=0) then Aiguillage[index_aig(j)].AdrTrain:=numtrain; + result:=Aiguillage[index_aig(j)].AdrTrain; + if traceListe then AfficheDebug('Aiguillage '+intToSTR(j)+' réservé par autre train : @='+intToSTR(result),clyellow); + exit; end; - if roulage then + end; + if (typ=det) then + begin + TrainExistant:=detecteur[j].AdrTrainRes; + if (TrainExistant<>AdrTrain) and (trainExistant<>0) then begin - if (Aiguillage[index_aig(j)].AdrTrain)=0 then Aiguillage[index_aig(j)].AdrTrain:=AdrTrain; + result:=Detecteur[j].AdrTrainRes; + if traceListe then AfficheDebug('Détecteur '+intToSTR(j)+' réservé par autre train : @='+intToSTR(result),clyellow); + exit; end; - - // maj tco - Texte_aig_fond(j) ; end; end; + if traceliste then AfficheDebug('A. Elements réservés: ',clOrange); + + // 1er élément de detecteur[] : le déreserver si c'est le train demandé + j:=elements[1].adresse; + TrainExistant:=detecteur[j].AdrTrainRes; + if (TrainExistant<>AdrTrain) and (trainExistant<>0) then + begin + result:=Detecteur[1].AdrTrainRes; + if traceListe then AfficheDebug('Détecteur '+intToSTR(j)+' réservé par autre train : @='+intToSTR(result),clyellow); + exit; + end; + detecteur[j].AdrTrainRes:=0; + + + for i:=2 to idEl-1 do + begin + j:=elements[i].adresse; + typ:=elements[i].typ; + if (typ=Aig) or (typ=tjd) or (typ=tjs) or (typ=crois) or (typ=triple) then + begin + if TraceListe then AfficheDebug_Suivi(intToSTR(j)+' ',clOrange); + // vérifier si l'aiguillage est libre + if roulage then + begin + Aiguillage[index_aig(j)].AdrTrain:=AdrTrain; + result:=AdrTrain; + end; + end; + if (typ=det) then + begin + if roulage then + begin + Detecteur[j].AdrTrainRes:=AdrTrain; + result:=AdrTrain; + end; + end; + // maj tco + Texte_aig_fond(j) ; + end; + + // --------canton suivant rouge:=signal_rouge(AdrSignalSuivant); if rouge then @@ -10323,7 +11224,7 @@ begin if TraceListe then begin s:='Le signal sursuivant '+intToSTR(AdrSignalSuivant)+' étant rouge, pas de réservation aval pour le train @'; - if roulage then s:=s+'@'+intToSTR(adrtrain) else if avecResa then s:=s+intToSTR(NumTrain); + if roulage then s:=s+'@'+intToSTR(adrtrain); AfficheDebug(s,clyellow); end; exit; @@ -10343,10 +11244,9 @@ begin if TraceListe then begin s:='Le signal sursuivant '+intToSTR(AdrSignalSuivant)+' étant rouge, pas de réservation aval pour le train @'; - if roulage then s:=s+'@'+intToSTR(adrtrain) else if avecResa then s:=s+intToSTR(NumTrain); + if roulage then s:=s+'@'+intToSTR(adrtrain); AfficheDebug(s,clyellow); end; - exit; end; etat:=etat_signal_suivant(AdrSig,1,AdrSignalsuivant); //réserve le canton du signal @@ -10359,16 +11259,21 @@ begin if (typ=Aig) or (typ=tjd) or (typ=tjs) or (typ=crois) or (typ=triple) then begin if TraceListe then AfficheDebug_Suivi(intToSTR(j)+' ',clOrange); - if AvecResa then - begin - if (Aiguillage[index_aig(j)].AdrTrain=0) then Aiguillage[index_aig(j)].AdrTrain:=numtrain; - end; if roulage then begin if (Aiguillage[index_aig(j)].AdrTrain)=0 then Aiguillage[index_aig(j)].AdrTrain:=AdrTrain; + result:=Aiguillage[index_aig(j)].AdrTrain; end; - Texte_aig_fond(j); end; + if (typ=det) then + begin + if roulage then + begin + if (detecteur[j].AdrTrainRes=0) then Detecteur[j].AdrTrainRes:=AdrTrain; + result:=Detecteur[j].AdrTrainRes; + end; + end; + Texte_aig_fond(j); end; inc(nc); @@ -10377,33 +11282,322 @@ begin Maj_Signaux(false); // sans_maj end; + +// libère le canton avant detecteur2, qui doit être associé à un signal depuis la direction de detecteur1 +// detecteur1->detecteur2 +Procedure libere_canton(detecteur1,detecteur2 : integer); +var sd2,i,j: integer; + typ : tEquipement; +begin + if not(roulage) then exit; + if traceliste or ProcPrinc or affres then + affiche('Libère_canton '+intToSTR(detecteur1)+' '+intToSTR(detecteur2),clLime); + if ProcPrinc or traceListe then AfficheDebug('Libère_Canton '+intToSTR(detecteur1)+' '+intToSTR(detecteur2),clLime); + + // est-on en limite de canton du detecteur 2 pour le libérer? + sd2:=signal_detecteur(detecteur2); // trouve le signal associé au detecteur2 + if sd2=0 then + begin + if traceliste then affiche('le détecteur '+intToSTR(detecteur2)+' n''est pas pas associé à un signal - pas de libération du canton',clorange); + exit; // pas de signal associé + end; + // ce signal sd2 est il dans le bon sens + i:=signal_suivant_det(detecteur1,detecteur2); // adresse du signal dans le bon sens associé au détecteur + if i<>sd2 then + begin + if traceliste then affiche('Le signal '+intToSTR(sd2)+' n''est pas dans le bon sens',clOrange); + exit; + end; + if i=0 then exit; + + // trouver le signal précédent + i:=Signal_precedent(i); // trouve les éléments entre les deux signaux + + if traceListe then AfficheDebug('Libération canton det '+IntToSTR(detecteur1)+' '+intToSTR(detecteur2)+' : ',clLime); + for i:=1 to idEl-1 do + begin + j:=elements[i].adresse; + typ:=elements[i].typ; + if (typ=Aig) or (typ=tjd) or (typ=tjs) or (typ=crois) or (typ=triple) then + begin + if traceListe then Affichedebug_Suivi('A'+intToSTR(j)+' ',clLime); + Aiguillage[index_aig(j)].AdrTrain:=0; // libère l'aiguillage + Texte_aig_fond(j); + end; + if (typ=det) then + begin + if traceListe then Affichedebug_Suivi(intToSTR(j)+' ',clLime); + detecteur[j].AdrTrainRes:=0; // libère le détecteur + Texte_aig_fond(j); + end; + end; + Maj_Signaux(false); +end; + + +// mode=0 = libère 1=réserve reserve_dereserve_det(detecteur1,detecteur2,adrTrain,i,1); +// du détecteur1 au détecteur2 NON INCLUS +// résultat : 0 si ok sinon code de défaut +// ou adresse train +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,ia : integer; + Sortie : boolean; + TypePrec,TypeFonc : Tequipement; + s : string; + label reprise; +begin + s:='Reserve_dereserve_det '+intToSTR(det1)+' '+intToSTR(det2)+' pour train '; + if roulage then s:=s+'@'+intToSTR(adrtrain); + if traceliste or ProcPrinc then afficheDebug(s,clorange); + if affRes then Affiche(s,ClOrange); + + if NivDebug>=2 then + if (det1>9000) or (det2>9000) then + begin + if NivDebug=3 then AfficheDebug('Paramètres incorrects >9000',clred); + reserve_dereserve_det:=9999; + exit; + end; + + if (det2=0) then + begin + reserve_dereserve_det:=9995; + exit; + end; + + // trouver détecteur 1 + trouve_element(det1,det); // branche_trouve IndexBranche_trouve + if (IndexBranche_trouve=0) then + begin + if NivDebug=3 then + begin + s:='611. '+IntToSTR(det1)+' non trouvé'; + AfficheDebug(s,clOrange); + end; + reserve_dereserve_det:=9999; + exit; + end; + IndexBranche_det1:=IndexBranche_trouve; + branche_trouve_det1:=branche_trouve; + + // trouver détecteur 2 + trouve_element(det2,det); // branche_trouve IndexBranche_trouve + if (IndexBranche_trouve=0) then + begin + if NivDebug=3 then + begin + s:='612. '+IntToSTR(det2)+' non trouvé'; + AfficheDebug(s,clred); + AfficheDebug(s,clOrange); + end; + reserve_dereserve_det:=9999;exit; + end; + + IndexBranche_det2:=IndexBranche_trouve; + branche_trouve_det2:=branche_trouve; + j:=1; // J=1 test en incrément J=2 test en décrément + + // étape 1 : trouver le sens de progression (en incrément ou en décrément) + + repeat + //préparer les variables + AdrPrec:=det1;TypePrec:=det; + if j=1 then i1:=IndexBranche_det1+1; + if j=2 then i1:=IndexBranche_det1-1; + // les suivants dansla branche sont: + AdrFonc:=BrancheN[branche_trouve_det1,i1].adresse; + typeFonc:=BrancheN[branche_trouve_det1,i1].Btype; + + if NivDebug=3 then + begin + s:='------> Test en '; + if (j=1) then s:=s+'incrément ' else s:=s+'décrément '; + s:=s+'- départ depuis élément '+IntToSTR(det1)+' trouvé en index='+intToSTR(IndexBranche_det1)+' Branche='+intToSTR(branche_trouve_det1); + AfficheDebug(s,clyellow); + end; + + i:=0;N_Det:=0; + if AdrFonc<>det2 then // si pas déja trouvé le sens de progression + begin + repeat + //AfficheDebug('Engage '+IntToSTR(AdrPrec)+','+IntToSTR(typePrec)+'/'+IntToSTR(AdrFonc)+','+IntToSTR(typeFonc),clyellow); + if nivDebug=3 then AfficheDebug('i='+IntToSTR(i)+' NDet='+IntToSTR(N_det),clyellow); + if (AdrFonc<>0) or (TypeFonc<>rien) then Adr:=suivant_alg3(AdrPrec,TypePrec,AdrFonc,TypeFonc,1) else + begin + Adr:=9999; + end; + //AfficheDebug('Sortie Alg3: '+IntToSTR(Adr)+'/'+intToSTR(typeGen),clyellow); + if TypeGen=det then inc(N_Det); + if NivDebug=3 then + begin + s:='613.2 : trouvé='+intToSTR(Adr)+BTypeToChaine(typeGen); + 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=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); + afficheDebug(s,clorange); + end; + end + + else + begin + // déja trouvé + adr:=det2;typeGen:=det; + end; + + idel:=1; + elements[idEl].adresse:=adrPrec; + elements[idEl].typ:=TypePrec; + + if (TypeGen=det) and (Adr=det2) and (N_Det<>Nb_det_dist) then + begin + + i:=0; + repeat + //AfficheDebug('Engage '+IntToSTR(AdrPrec)+','+IntToSTR(typePrec)+'/'+IntToSTR(AdrFonc)+','+IntToSTR(typeFonc),clyellow); + Adr:=suivant_alg3(AdrFonc,TypeFonc,AdrPrec,TypePrec,1); + //AfficheDebug('Sortie Alg3: '+IntToSTR(Adr)+'/'+intToSTR(typeGen),clyellow); + + if NivDebug=3 then + begin + s:='615 : trouvé='+intToSTR(Adr)+BTypeToChaine(typeGen); + AfficheDebug(s,clorange); + end; + inc(idEl); + 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>=itMaxi); + until sortie; + + if (TypeGen=det) or (TypeGen=buttoir) then + begin + // Elements contient les éléments dans l'ordre inverse + for k:=1 to IdEl do + begin + j:=elements[k].adresse; + typePrec:=elements[k].typ; + if (typePrec=Aig) or (typePrec=tjd) or (typePrec=tjs) or (typePrec=crois) or (typePrec=triple) then + begin + if TraceListe then AfficheDebug_Suivi(intToSTR(k)+' ',clOrange); + if mode=0 then Aiguillage[index_aig(j)].AdrTrain:=0 + else + if (Aiguillage[index_aig(k)].AdrTrain=0) then + begin + if roulage then Aiguillage[index_aig(j)].AdrTrain:=AdrTrain; + result:=Aiguillage[index_aig(j)].AdrTrain; + end; + end; + if (typePrec=det) then + begin + if TraceListe then AfficheDebug_Suivi(intToSTR(k)+' ',clOrange); + if mode=0 then detecteur[j].AdrTrainRes:=0 + else + if detecteur[j].AdrTrainRes=0 then + begin + if roulage then detecteur[j].AdrTrainRes:=AdrTrain; + result:=detecteur[j].AdrTrainRes; + end; + end; + Texte_aig_fond(j); + end; + reserve_dereserve_det:=0; + exit; + end; + 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 + + reserve_dereserve_det:=9996; + if NivDebug=3 then affichedebug('------------------',clyellow); + if debug=3 then formprinc.Caption:=''; +end; + +// renvoie vrai si le signal est dans le bon sens suivant le marquage du sens du detecteur +{ +function signal_sens(IndexSignal,AdrDet : integer) : boolean; +begin + result:=signaux[indexSignal].Adr_det1=detecteur[AdrDet].suivant; +end; +} + // pilote le train sur le détecteur det2, d'adresse adrtrain // le det1 indique d'ou vient le train pour le bon sens du signal +// det2 est le détecteur sur lequel se trouve le train // le train est piloté si on trouve un signal dans le bon sens sur det2 // it : numéro du train du réseau (pour la couleur) procedure pilote_train(det1,det2,AdrTrain,it : integer); var entree_signal,jauneC,rappel30C,rappel60C,rouge : boolean; - i,index_train,adresse,adresse2,Etat,voie,i2,vitesse : integer; + index_train,adresse,adresse1,adresse2,Etat,voie1,voie2,indexSig,indexSig1,indexSig2, + n,vitesse,i2 : integer; couleur : TColor; - s : string; + s,nomTrain : string; begin if not(roulage) or (adrtrain=0) then exit; Affiche('Pilote train '+intToSTR(det1)+' '+intToSTR(det2),clYellow); - i:=index_signal_det(det2,voie,i2); // index du signal associé au det2 j:=signal_detecteur(det3); - if i=0 then exit; + index_train:=index_train_adresse(adrTrain); // index du tableau trains + nomTrain:=trains[Index_train].nom_train; i2:=((it-1) mod NbCouleurTrain) +1; couleur:=CouleurTrain[i2]; - index_train:=index_train_adresse(adrTrain); // index du tableau trains + n:=trains[index_train].route[0].adresse; - adresse:=Signaux[i].adresse; // voir si il est dans le bon sens + // si le détecteur est le dernier détecteur de la route + if (det2=trains[index_train].route[n].adresse) and (trains[index_train].route[n].typ=det) then + begin + s:='Fin de route '+nomTrain+' - Arrêt train '; + if traceListe then AfficheDebug(s,couleur); + Affiche(s,couleur); + //event_det_train[it].signal_rouge:=adresse; + //Affiche('*************AAAAAAAAAAAaaaaaaaaret train',clred); + if (index_train<>0) and (index_trainadresse2 then exit; // non pas dans le bon sens +// i:=index_signal_det(det2,voie,i2); // index du signal associé au det2 j:=signal_detecteur(det3); - etat:=Signaux[i].EtatSignal; + index_signal_det(det2,voie1,indexSig1,voie2,indexSig2); + if (indexSig1=0) and (indexSig2=0) then exit; - rouge:=signal_rouge(Signaux[i].adresse); + adresse:=0;adresse1:=0;Adresse2:=0;indexSig:=0; + if indexSig1<>0 then adresse1:=Signaux[indexSig1].adresse; + if indexSig2<>0 then adresse2:=Signaux[indexSig1].adresse; + + if signaux[indexSig1].Adr_el_suiv1=detecteur[det2].suivant then indexSig:=indexSig1; + if signaux[indexSig2].Adr_el_suiv1=detecteur[det2].suivant then indexSig:=indexSig2; + + if indexSig=0 then exit; // non pas dans le bon sens + adresse:=signaux[indexsig].adresse; + etat:=Signaux[indexSig].EtatSignal; + + rouge:=signal_rouge(Signaux[indexSig1].adresse); jauneC:=testbit(etat,jaune) or testbit(etat,blanc) or testbit(etat,blanc_cli); rappel30C:=testbit(etat,rappel_30); rappel60C:=testbit(etat,rappel_60); @@ -10413,12 +11607,16 @@ begin // si le signal est au rouge et qu'on entre dans son détecteur if rouge and entree_signal then begin - s:='Signal '+intToSTR(adresse)+' au rouge - Arrêt train @'+intToSTR(AdrTrain); + s:='Signal '+intToSTR(adresse)+' est au rouge - Arrêt train @'+intToSTR(AdrTrain); if traceListe then AfficheDebug(s,couleur); Affiche(s,couleur); event_det_train[it].signal_rouge:=adresse; - if (index_train<>0) and (index_train0) and (index_trainnTrains) then exit; + with trains[idTrain] do + begin + AdrTrain:=adresse; + for l:=1 to route[0].adresse do + begin + Adr:=route[l].adresse; + tz:=route[l].typ; + // désaffecter les aiguillages et les détecteurs affectés à ce train + + if tz=det then + begin + adrTrainLoc:=detecteur[adr].AdrTrainRes; + if (adrTrainLoc=AdrTrain) then detecteur[adr].AdrTrainRes:=0 + end; + if tz<>det then + begin + adrTrainLoc:=aiguillage[index_aig(adr)].AdrTrain; + if (adrTrainLoc=AdrTrain) then aiguillage[index_aig(adr)].AdrTrain:=0; + end; + + route[l].adresse:=0; + route[l].typ:=rien; + route[l].pos:=0; + route[l].talon:=false; + Texte_aig_fond(Adr); + end; + route[0].adresse:=0; + roulage:=0; + end; + + // désaffecter les cantons + l:=trains[idTrain].canton; + if l>0 then + begin + l:=index_canton_numero(l); + if l>0 then + begin + canton[l].bouton:=0; + dest:=canton[l].NumcantonDest; + org:=canton[l].NumcantonOrg; + if org>0 then + begin + org:=index_canton_numero(org); + canton[org].NumcantonOrg:=0; + canton[org].NumcantonDest:=0; + canton[org].bouton:=0; + canton[org].AdrTrainRoute:=0; + dessin_canton(org,0); + end; + if dest>0 then + begin + dest:=index_canton_numero(dest); + canton[dest].NumcantonOrg:=0; + canton[dest].NumcantonDest:=0; + canton[dest].bouton:=0; + canton[dest].AdrTrainRoute:=0; + dessin_canton(dest,0); + end; + end; + end; + detdepart:=0; + DetAtrouve:=0; + + // supprimer le tableau ParcoursDet[] + ParcoursDet[0].adresse:=0; +end; + +procedure Inverse_route(var A: TuneRoute); +var i,n: Integer; + Tmp: TelementROute; +begin + n:=a[0].adresse; + for i:=1 to n div 2 do + begin + Tmp:=A[i]; + A[i]:=A[n-i+1]; + A[n-i+1]:=Tmp; + end; +end; + + +// un train s'est arrêté après la tempo d'arret sur un détecteur en mode roulage +// appellé par le timer1 +procedure train_sarrete(idTrain : integer); +var finroute,trouve : boolean; + j,n,detect : integer; + t : tequipement; +begin + if not(roulage) then exit; + //Affiche('Maj Route det '+intToSTR(detect),clWhite); + finroute:=false; + trouve:=false; + begin + with trains[idTrain] do + begin + detect:=dernierDet; + if roulage<>0 then + begin + n:=route[0].adresse; + j:=0; + repeat + inc(j); + until (j>n) or (route[j].traite=false); + if (j>n) and (route[n].adresse=detect) then + begin + //Affiche('Route du train '+nom_train,clWhite); + Affiche('Route du train '+nom_train+' terminée.',clOrange); + + {trains[idTrain].TempoArretCour:=0; + trains[idTrain].TempoArret:=50; + } + // repartir à l'envers + if false then + begin + if not(diffusion) then Affiche('Route inverse',clWhite); + // inverser élement suivant et précédent du détecteur + echange(detecteur[detect].suivant,detecteur[detect].precedent); + t:=detecteur[detect].TypSuivant; + detecteur[detect].TypSuivant:=detecteur[detect].TypPrecedent; + detecteur[detect].TypPrecedent:=t; + + j:=trains[IdTrain].index_event_det_train; + event_det_train[j].NbEl:=0; + + Inverse_route(route); + for j:=1 to n do route[j].traite:=false; + + aig_canton(idTrain,trains[idTrain].route[1].adresse); + demarre_index_train(idTrain); // met la mémoire de roulage du train à 1 + // effacer le tracé du TCO + for j:=1 to NbreTCO do zone_tco(j,detect,trains[idTrain].detecteurSuiv,1,trains[idTrain].adresse,0,false); + end + else + supprime_route_train(idTrain); + + end; + end; + + end; + end; + + +end; + + +//--évolution de la route par train et mise à jour du pointeur +// doit être appellée sur un état à 0 ou 1 de detect +procedure maj_route(detect : integer); +var i : integer; +begin + if roulage then + begin + // explorer les autres trains pour libérer leurs routes + for i:=1 to ntrains do + begin + if trains[i].roulage<>0 then + begin + aig_canton(i,detect); + end; + end; + end; +end; + +procedure affiche_act_trouves; +var i : integer; +begin + if IdActTr>10 then IdActTr:=10; + for i:=1 to IdActTr do + AfficheDebug(intToSTR(Actionneur_trouve[i]),clWhite); +end; + // calcul des zones depuis le tableau des fronts montants ou descendants des évènements détecteurs // transmis dans le tableau Event_det // rattache le nouveau détecteur à un train // adresse: adresse du detecteur, front: état du détecteur +// les aiguillages doivent être positionnés procedure calcul_zones_V1(adresse: integer;etat : boolean); var m,AdrSignal,AdrDetSignal,AdrTrainLoc,Nbre,i,i2,j,k,l,n,det1,det2,det3,det4,AdrSuiv,AdrPrec,Prev, - id_couleur,det_suiv,nc,etatSig,ntco,d1,d2,sens : integer ; - traite,trouve,SuivOk,casaig,rebond : boolean; + id_couleur,det_suiv,nc,etatSig,ntco,d1,d2,sens,idT,sensTCO,suivant2,prec,indexTrain : integer ; + traite,trouve,SuivOk,casaig,rebond,finroute : boolean; couleur : tcolor; - TypeSuiv : tEquipement; + TypePrec,TypeSuiv : tEquipement; s,train_ch : string; begin det3:=adresse; // c'est le nouveau détecteur @@ -10530,6 +11906,7 @@ begin Affiche_evt(s,clwhite) ; if dupliqueEvt then Affiche(s,clyellow) ; + for i:=1 to N_trains do // nombre de trains détectés en circulation begin index_couleur:=((i - 1) mod NbCouleurTrain) +1; @@ -10537,6 +11914,10 @@ begin Nbre:=event_det_train[i].NbEl ; // Nombre d'éléments du tableau courant exploré det1:=event_det_train[i].det[1].adresse; det2:=event_det_train[i].det[2].adresse; + adrTrainLoc:=event_det_train[i].Adrtrain; + IndexTrain:=index_train_adresse(adrTrainLoc); + trains[indexTrain].dernierDet:=det3; + if ((det2=det3) and (nbre=2)) or ((det1=det3) and (nbre=1)) then begin @@ -10553,127 +11934,149 @@ begin if (nbre=1) and not(etat) then begin Det_Adj(det3); // renvoie les adresses des détecteurs adjacents au détecteur "det3" résultat dans adj1 et adj2 + // traiter pour les cas avec 1 élément + if traceListe or ProcPrinc then AfficheDebug('1-0 traitement Train n°'+intToSTR(i)+' 1 détecteur',clyellow); + + CasAig:=(MemZone[det1,det2].Prev=adj2) or (MemZone[det1,det2].Prev=adj1); + + // vérifier si l'élément du tableau et le précédent sont contigus + if (Adj1=det1) or (Adj2=det1) or casAig then begin - // traiter pour les cas avec 1 élément - if traceListe or ProcPrinc then AfficheDebug('1-0 traitement Train n°'+intToSTR(i)+' 1 détecteur',clyellow); - // vérifier si l'élément du tableau et le nouveau sont contigus - if (Adj1=det1) or (Adj2=det1) then + event_det_tick[N_event_tick].train:=i; + with event_det_train[i] do begin - event_det_tick[N_event_tick].train:=i; + det[2].adresse:=det3; + det[2].etat:=etat; + NbEl:=2; + end; + Train_ch:=event_det_train[i].nom_train; + if (AdrTrainLoc=0) and roulage then + begin + Affiche('Démarrage train non placé depuis détecteur '+intToSTR(det3),clred); + if TraceListe then AfficheDebug('Démarrage train non placé depuis détecteur '+intToSTR(det3),clred); + end; + // affecter le nouveau détecteur + detecteur[det3].train:=Train_ch; + detecteur[det3].AdrTrain:=AdrTrainLoc; + detecteur[det3].IndexTrainRoulant:=i; - with event_det_train[i] do - begin - det[2].adresse:=det3; - det[2].etat:=etat; - NbEl:=2; - end; - - adrTrainLoc:=event_det_train[i].Adrtrain; - Train_ch:=event_det_train[i].nom_train; - if (AdrTrainLoc=0) and roulage then - begin - Affiche('Démarrage train non placé depuis détecteur '+intToSTR(det3),clred); - if TraceListe then AfficheDebug('Démarrage train non placé depuis détecteur '+intToSTR(det3),clred); - 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 - begin - if adrsuiv=9996 then affiche_evt('Erreur position inconnue aiguillage ',clred) - else - Affiche_evt('Info 1-0 '+intToSTR(AdrSuiv)+' : pas de suivant detecteur_suivant_el '+intToSTR(det1)+' '+intToSTR(det3),clWhite); - exit; - end; - - //*** route validée *** - if (det1MaxZones then n:=1; - with TrainZone[i] do - begin - Nbre:=n; - Zone[n].det1:=det1; - Zone[n].det2:=det3; - train:=train_ch; - AdrTrain:=AdrTrainLoc - end; - end; - reserve_canton(det3,AdrSuiv,AdrTrainLoc,i,nCantonsRes); // si feu réserve canton courant - libere_canton(det1,det3); // on quitte det3 - Maj_Signaux(false); - Maj_Signaux(false); - det4:=detecteur_suivant_EL(det3,det,AdrSuiv,det,1); - if det4<9990 then reserve_canton(AdrSuiv,det4,AdrTrainLoc,i,nCantonsRes) // réserve canton suivant après maj signaux - else Affiche_evt('Réservation canton après '+intToSTR(det3)+' '+intToSTR(ADrSuiv)+' impossible (pos? aig)',clOrange); - - event_act(det1,det3,1,''); // évènement détecteur de zone - 1 - - // affichages - Affiche_Evt('1-0 route ok de '+intToSTR(det1)+' à '+IntToSTR(det3),clWhite); - if traceListe then AfficheDebug(s,clyellow); - //Affiche(s,CouleurTrain[index_couleur]); - if AffAigDet then AfficheDebug(s,clyellow); - - Affiche_Evt('1-0. Tampon train '+intToStr(i)+' '+event_det_train[i].nom_train+'--------',couleur); - s:=intToSTR(event_det_train[i].det[1].adresse); - Affiche_Evt(s,couleur); - if traceliste then AfficheDebug(s,clyellow); - if dupliqueEvt then Affiche(s,clyellow); - s:=intToSTR(event_det_train[i].det[2].adresse); - - if TraceListe then AfficheDebug(s,clyellow); - if dupliqueEvt then Affiche(s,clyellow); - for ntco:=1 to nbreTCO do - begin - if PcanvasTCO[ntco]<>nil then - begin - // désactivation - Zone_TCO(ntco,det1,det3,i,AdrTrainLoc,0); // tco,det1,det2,train, mode - // activation - 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 + if not(casAig) then + begin + AdrSuiv:=detecteur_suivant_el(det1,det,det3,det,1); // trouve les actionneurs end else begin - Affiche_evt('1-0 Train '+intToSTR(i)+' Eléments '+intToSTR(det1)+' et '+intToSTR(det3)+' non contigus',clyellow); - - for ntco:=1 to nbreTCO do - maj_tco(ntco,det3); - // det3 et det1 non adjacents + AdrSuiv:=MemZone[det1,det2].Prev; + det1:=event_det_train[i].det[1].adresse; end; + + if adrSuiv>NbMaxDet then + begin + if adrsuiv=9996 then affiche_evt('Erreur aiguillage '+intToSTR(AigMal)+' mal positionné',clred) + else + Affiche_evt('Info 1-0 '+intToSTR(AdrSuiv)+' : pas de suivant detecteur_suivant_el '+intToSTR(det1)+' '+intToSTR(det3),clWhite); + exit; + end + else + begin + idt:=Index_train_adresse(AdrTrainLoc); + if idt<>0 then trains[idt].detecteurSuiv:=AdrSuiv // affecter le détecteur suivant au train + else trains[i].detecteurSuiv:=AdrSuiv; + end; + //*** route validée *** + if (det1MaxZones then n:=1; + with TrainZone[i] do + begin + Nbre:=n; + Zone[n].det1:=det1; + Zone[n].det2:=det3; + train:=train_ch; + AdrTrain:=AdrTrainLoc + end; + end; + libere_canton(det1,det3); // on quitte det3 + Maj_Signaux(false); + Maj_Signaux(false); + event_act(det1,det3,1,''); // évènement détecteur de zone - 1 + // affichages + Affiche_Evt('1-0 route ok de '+intToSTR(det1)+' à '+IntToSTR(det3),clWhite); + if traceListe then AfficheDebug(s,clyellow); + //Affiche(s,CouleurTrain[index_couleur]); + if AffAigDet then AfficheDebug(s,clyellow); + + Affiche_Evt('1-0. Tampon train '+intToStr(i)+' '+event_det_train[i].nom_train+'--------',couleur); + s:=intToSTR(event_det_train[i].det[1].adresse); + Affiche_Evt(s,couleur); + if traceliste then AfficheDebug(s,clyellow); + if dupliqueEvt then Affiche(s,clyellow); + s:=intToSTR(event_det_train[i].det[2].adresse); + + if TraceListe then AfficheDebug(s,clyellow); + if dupliqueEvt then Affiche(s,clyellow); + maj_route(det3); // positionner les aiguillages avant d'afficher le tco + for ntco:=1 to nbreTCO do + begin + if PcanvasTCO[ntco]<>nil then + begin + // désactivation + Zone_TCO(ntco,det1,det3,i,AdrTrainLoc,0,true); // tco,det1,det2,train, mode + // activation + if ModeCouleurCanton=0 then zone_TCO(ntco,det3,AdrSuiv,i,AdrTrainLoc,1,true) + else zone_TCO(ntco,det3,adrSuiv,i,AdrTrainLoc,2,true); // affichage avec la couleur de index_couleur du train + end; + end; + exit; // sortir absolument + end + else + begin + Affiche_evt('1-0 Train '+intToSTR(i)+' Eléments '+intToSTR(det1)+' et '+intToSTR(det3)+' non contigus',clyellow); + AdrTrainLoc:=detecteur[det3].AdrTrain; + idt:=index_train_Adresse(AdrTrainLoc); + if idt<>0 then + begin + det_Suiv:=trains[idt].detecteurSuiv; + {event_det_train[i].NbEl:=2; + event_det_train[i].Det[1].adresse:=det3; + event_det_train[i].Det[1].etat:=false; + event_det_train[i].Det[2].adresse:=trains[idt].detecteurSuiv; + event_det_train[i].Det[2].etat:=false; + nbre:=2; } + MemZone[det3,det_suiv].etat:=true; + MemZone[det3,det_suiv].AdrTrain:=AdrTrainLoc; + for ntco:=1 to nbreTCO do + begin + raz_cantons_train(AdrTrainLoc); // efface tous les cantons contenant le train adrloc + if ModeCouleurCanton=0 then zone_TCO(ntco,det3,det_suiv,i,AdrTrainLoc,1,true) + else zone_TCO(ntco,det3,det_suiv,i,AdrTrainLoc,2,true); // affichage avec la couleur de index_couleur du train + end; + end; + for ntco:=1 to nbreTCO do + maj_tco(ntco,det3); + // det3 et det1 non adjacents end; end; @@ -10723,14 +12126,27 @@ begin detecteur[det3].train:=train_ch; // affecter le nom du train au détecteur detecteur[det3].AdrTrain:=AdrTrainLoc ; // affecter l'@ du train au détecteur + // mettre à jour éléments prec et suivant du nouveau détecteur + det_adj(det3); + if adj1=det1 then begin prec:=prec1;typePrec:=t1;end; // les variables sont renvoyée par detAdj + if adj2=det1 then begin prec:=prec2;typePrec:=t2;end; + + // affectation précédent au nouveau détecteur + detecteur[det3].precedent:=prec; + detecteur[det3].TypPrecedent:=TypePrec; + // affecter le suivant + detecteur[det3].suivant:=suivant_alg3(prec,typePrec,det3,det,1); + detecteur[det3].TypSuivant:=typeGen; + detecteur[det1].train:=''; // désaffecter le nom du train du détecteur précédent detecteur[det1].AdrTrain:=0; + detecteur[det1].IndexTrainRoulant:=0; //*** route validée *** MemZone[det1,det3].etat:=TRUE; // valide la nouvelle zone MemZone[det1,det3].train:=train_ch; MemZone[det1,det3].AdrTrain:=AdrTrainLoc; - MemZone[det1,det3].IndexTrain:=i; + MemZone[det1,det3].IndexTrainRoulant:=i; MemZone[det3,det1].etat:=False; // on dévalide la zone inverse @@ -10738,8 +12154,16 @@ begin event_det_train[i].Det[2].etat:=etat; // test si on peut réserver le canton suivant - det_suiv:=det_suiv_cont(det1,det3,1); - if det_suiv<9990 then reserve_canton(det3,det_suiv,AdrTrainLoc,i,nCantonsRes) else + //det_suiv:=det_suiv_cont(det1,det3,1); + det_suiv:=detecteur_suivant_el(det1,det,det3,det,1); + MemZone[det1,det3].Prev:=det_suiv; + if det_suiv<9990 then + begin + idt:=Index_train_adresse(AdrTrainLoc); + if idt<>0 then trains[idt].detecteurSuiv:=det_suiv // affecter le détecteur suivant au train + else trains[i].detecteurSuiv:=det_suiv; + end + else begin if det_suiv=9996 then affiche_evt('Erreur 1-1 position inconnue aiguillage ',clred) else Affiche_evt('Erreur 1-1 '+intToSTR(Det_Suiv)+' : pas de suivant detecteur_suivant_el '+intToSTR(det1)+' '+intToSTR(det3),clred); @@ -10751,8 +12175,8 @@ begin for ntco:=1 to nbreTCO do begin raz_cantons_train(AdrTrainLoc); // efface tous les cantons contenant le train adrloc - if ModeCouleurCanton=0 then zone_TCO(ntco,det1,det3,i,AdrTrainLoc,1) - else zone_TCO(ntco,det1,det3,i,AdrTrainLoc,2); // affichage avec la couleur de index_couleur du train + if ModeCouleurCanton=0 then zone_TCO(ntco,det1,det3,i,AdrTrainLoc,1,true) + else zone_TCO(ntco,det1,det3,i,AdrTrainLoc,2,true); // affichage avec la couleur de index_couleur du train end; end; end; @@ -10763,8 +12187,10 @@ begin // actualiser le signal du det3 j:=signal_detecteur(det3); if j<>0 then Maj_Signal_P(j,false); + maj_route(det3); exit; end; + if Traceliste then AfficheDebug(inttoSTR(det3)+' n''est pas contigu à '+intToSTR(det1)+' pour le train '+intToSTR(i),clyellow); traite:=true; // traiter le train suivant end; @@ -10774,7 +12200,8 @@ begin begin if TraceListe or ProcPrinc then AfficheDebug('2-0 traitement Train n°'+intToSTR(i)+' 2 détecteurs',couleur); // test si det1, det2 et det3 sont contigus malgré aig mal positionnés - det_suiv:=det_suiv_cont(det1,det2,1); // test si le suivant de det1 à det2 est bien le nouveau détecteur (det3) + //det_suiv:=det_suiv_cont(det1,det2,1); // test si le suivant de det1 à det2 est bien le nouveau détecteur (det3) + det_suiv:=detecteur_suivant_el(det1,det,det2,det,1); if traceliste then affichedebug('Le suivant aux '+intToSTR(det1)+' '+intToSTR(det2)+' est '+intToSTR(det_suiv),couleur); SuivOk:=(det_suiv=det3) and (det_suiv<9990); CasAig:=false; @@ -10801,7 +12228,8 @@ begin if TraceListe then AfficheDebug('Route est valide, dét '+intToSTR(det2)+' '+intToSTR(det3)+' contigus',couleur); // ici on cherche le suivant à det2 det3, algo=1 event_det_tick[N_event_tick].train:=i; - if not(casAig) then AdrSuiv:=detecteur_suivant_el(det2,det,det3,det,0); // dans le cas de CasAig, alors adrSuiv=9996 donc AdrSuiv est calculé plus haut + + if not(casAig) then AdrSuiv:=detecteur_suivant_el(det2,det,det3,det,0); // dans le cas de CasAig, alors adrSuiv=9996 donc AdrSuiv a été calculé plus haut (ligne -27) if AdrSuiv<9990 then event_det_train[i].suivant:=AdrSuiv; if TraceListe then AfficheDebug('le sursuivant est '+intToSTR(adrsuiv),couleur); if (Adrsuiv>=9990) and not(casaig) then @@ -10833,32 +12261,30 @@ begin MemZone[det2,det3].etat:=FALSE; MemZone[det2,det3].train:=''; MemZone[det2,det3].AdrTrain:=0; - MemZone[det2,det3].IndexTrain:=0; + MemZone[det2,det3].IndexTrainRoulant:=0; // on dévalide la zone inverse MemZone[det3,det2].etat:=False; MemZone[det3,det2].train:=''; MemZone[det3,det2].AdrTrain:=0; - MemZone[det3,det2].IndexTrain:=0; + MemZone[det3,det2].IndexTrainRoulant:=0; // valide la nouvelle zone MemZone[det3,AdrSuiv].etat:=TRUE; MemZone[det3,AdrSuiv].train:=train_ch; MemZone[det3,AdrSuiv].AdrTrain:=AdrTrainLoc; - MemZone[det3,AdrSuiv].IndexTrain:=i; + MemZone[det3,AdrSuiv].IndexTrainRoulant:=i; // on dévalide la zone inverse MemZone[AdrSuiv,det3].etat:=False; MemZone[AdrSuiv,det3].train:=''; MemZone[AdrSuiv,det3].AdrTrain:=0; - MemZone[AdrSuiv,det3].IndexTrain:=0; + MemZone[AdrSuiv,det3].IndexTrainRoulant:=0; detecteur[det3].train:=train_ch ; // affectation nom train au nouveau détecteur detecteur[det3].AdrTrain:=AdrTrainLoc; if detecteur[det2].train=train_ch then detecteur[det2].train:=''; // désaffectation du nom de train de l'ancien détecteur si le nom du train est égal if detecteur[det2].AdrTrain=AdrTrainLoc then detecteur[det2].AdrTrain:=0; // désaffectation du nom de train de l'ancien détecteur - //libere_canton(det2,det3); - reserve_dereserve_det(det2,det3,0,0,0); // libère - reserve_canton(det3,AdrSuiv,adrTrainLoc,i,nCantonsRes); + libere_canton(det2,det3); det4:=detecteur_suivant_EL(det3,det,AdrSuiv,det,1); if det4>9990 then begin @@ -10866,7 +12292,11 @@ begin else Affiche_evt('Info: 2-0 '+intToSTR(Det4)+' : pas de detecteur_suivant_el '+intToSTR(det3)+' '+intToSTR(AdrSuiv),clyellow); end else - reserve_canton(AdrSuiv,det4,adrTrainLoc,i,nCantonsRes); + begin + idt:=Index_train_adresse(AdrTrainLoc); + if idt<>0 then trains[idt].detecteurSuiv:=det4 // affecter le détecteur suivant au train + else trains[i].detecteurSuiv:=det4; + end; //Maj_Signaux(false); sans_maj // stockage dans historique de zones @@ -10941,12 +12371,12 @@ begin if PcanvasTCO[ntco]<>nil then begin Maj_Aig_TCO(ntco); - zone_TCO(ntco,det2,det3,i,AdrTrainLoc,0); // désactivation + zone_TCO(ntco,det2,det3,i,AdrTrainLoc,0,true); // désactivation // activation //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 + if ModeCouleurCanton=0 then zone_TCO(ntco,det3,AdrSuiv,i,AdrTrainLoc,1,true) + else zone_TCO(ntco,det3,AdrSuiv,i,AdrTrainLoc,2,true); // affichage avec la couleur de index_couleur du train end; end; @@ -10960,6 +12390,7 @@ begin etatSig:=Signaux[k].etatsignal; end; Maj_Signaux(false); // mise à jour générale + maj_route(det3); exit; // sortir absolument end; end @@ -10980,7 +12411,7 @@ begin begin if TraceListe or (NivDebug=3) or ProcPrinc then AfficheDebug('2-1 traitement Train n°'+intToSTR(i)+' 2 détecteurs',couleur); - det_suiv:=det_suiv_cont(det1,det2,1); // test si le suivant de det1 à det2 est bien le nouveau détecteur (det3) + det_suiv:=detecteur_suivant_el(det1,det,det2,det,1); 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 @@ -10998,23 +12429,35 @@ begin detecteur[det3].train:=Train_ch; // affectation nom train au nouveau détecteur detecteur[det3].AdrTrain:=AdrTrainLoc; // affectation train au nouveau détecteur - detecteur[det3].IndexTrain:=i; + detecteur[det3].IndexTrainRoulant:=i; + + detecteur[det3].suivant:=ESuiv; // variables globales venant de detecteur_suivant_el + detecteur[det3].TypSuivant:=tSuiv; + detecteur[det3].precedent:=Eprec; + detecteur[det3].TypPrecedent:=tPrec; detecteur[det2].train:=''; // désaffectation du nom de train de l'ancien détecteur detecteur[det2].AdrTrain:=0; - detecteur[det2].IndexTrain:=0; + detecteur[det2].IndexTrainRoulant:=0; i2:=index_train_adresse(AdrTrainLoc); if i2<>0 then trains[i2].index_event_det_train:=i; // lier l'index du train en circulation pilote_train(det2,det3,adrtrainLoc,i); // pilote le train sur det3 // test si on peut réserver le canton suivant - det_suiv:=det_suiv_cont(det2,det3,1); - if det_suiv<9990 then reserve_canton(det3,det_suiv,AdrTrainLoc,i,nCantonsRes) + //det_suiv:=det_suiv_cont(det2,det3,1); /// + det_suiv:=detecteur_suivant_el(det2,det,det3,det,1); + + if det_suiv<9990 then + begin + idt:=Index_train_adresse(AdrTrainLoc); + if idt<>0 then trains[idt].detecteurSuiv:=det_Suiv // affecter le détecteur suivant au train + else trains[i].detecteurSuiv:=det_Suiv; + end else begin if det_suiv=9996 then affiche_evt('Erreur 2-1 position inconnue aiguillage ',clred) - else Affiche_evt('Erreur 2-1 '+intToSTR(Det_Suiv)+' : pas de suivant detecteur_suivant_el '+intToSTR(det2)+' '+intToSTR(det3),clred); + else Affiche_evt('Erreur 2-1 '+intToSTR(Det_Suiv)+' : pas de suivant det_suiv_cont '+intToSTR(det2)+' '+intToSTR(det3),clred); end; end else @@ -11052,6 +12495,7 @@ begin // désactivation du morceau avant l'aiguillage efface_trajet(det3,i); end; + maj_route(det3); exit; // sortir absolument end else @@ -11128,9 +12572,6 @@ begin pilote_train(i2,det3,adrtrainLoc,i); // pilote le train sur det3 // test si on peut réserver le canton suivant det_suiv:=det_suiv_cont(i2,det3,1); - if det_suiv<9990 then reserve_canton(det3,det_suiv,AdrTrainLoc,i,nCantonsRes); - // libère canton - libere_canton(i2,det3); exit; end; end; @@ -11147,7 +12588,7 @@ begin N_trains:=0; end; Inc(N_trains); - event_det_tick[N_event_tick].train:=n_trains; + event_det_tick[N_event_tick].train:=n_trains; // numéro du train en circulation with event_det_train[N_trains] do begin @@ -11182,14 +12623,74 @@ begin if TraceListe then AfficheDebug('Création Train n°'+intToSTR(N_trains),clyellow); Formprinc.LabelNbTrains.caption:=IntToSTR(N_trains); - with event_det_train[N_trains] do + // vérifier si le train est démarré avec positionnement dans le canton + j:=1; + repeat + trouve_det_canton(j,det1,det2); + adrTrainLoc:=canton[j].adresseTrain; + if adrTrainLoc>9000 then + begin + Affiche('Anomalie 625 canton n°'+intToSTR(canton[j].numero),clred); + canton[j].indexTrain:=0; + AdrTrainLoc:=0; + MessageBeep(MB_ICONERROR); + end; + trouve:=((det1=det3) or (det2=det3)) and ((AdrTrainLoc<>0) and (AdrTrainLoc<>9999)); + inc(j); + until (j>nCantons) or trouve; + + if trouve then begin - det[1].adresse:=det3; - det[1].etat:=etat; - NbEl:=1; - nom_train:=detecteur[det3].train; - // Affiche('détecteur='+intToSTR(det3)+' '+nom_train,clWhite); - AdrTrain:=detecteur[det3].AdrTrain; + dec(j); + sens:=canton[j].SensLoco; + if sens=0 then + begin + Affiche('Anomalie 626 : Pas de sens train '+trains[canton[j].indexTrain].nom_train+' canton '+intToSTR(canton[j].numero),clred); + end; + // convertir en sens canton + case sens of + sensGauche : sensTCO:=5; + sensDroit : sensTCO:=6; + sensBas : sensTCO:=8; + sensHaut : sensTCO:=7; + end; + suivant:=trouve_det_suiv_canton(j,det3,sensTCO); + if suivant>9990 then exit; + adrTrainLoc:=canton[j].adresseTrain; + event_det_train[n_trains].suivant:=suivant; + + detecteur[det3].Train:=canton[j].NomTrain; + detecteur[det3].AdrTrain:=AdrTrainLoc; + detecteur[det3].IndexTrainRoulant:=n_trains; + + MemZone[det3,suivant].etat:=true; + MemZone[det3,suivant].train:=canton[j].NomTrain; + MemZone[det3,suivant].AdrTrain:=AdrTrainLoc; + MemZone[det3,suivant].IndexTrainRoulant:=n_trains; + suivant2:=detecteur_Suivant_el(det3,det,suivant,det,1); + MemZone[det3,suivant].Prev:=suivant2; + + index_couleur:=((n_trains - 1) mod NbCouleurTrain) +1; + for ntco:=1 to nbreTCO do + begin + raz_cantons_train(AdrTrainLoc); // efface tous les cantons contenant le train adrloc + if ModeCouleurCanton=0 then zone_TCO(ntco,det3,suivant,AdrTrainloc,0,1,true) + else zone_TCO(ntco,det3,suivant,n_trains,AdrTrainLoc,2,true); // affichage avec la couleur de index_couleur du train + end; + pilote_train(0,det3,adrtrainLoc,n_trains); // pilote le train sur det3 + + end; + begin + // si démarré sans positionnement dans canton + with event_det_train[N_trains] do + begin + det[1].adresse:=det3; + det[1].etat:=etat; + NbEl:=1; + nom_train:=detecteur[det3].train; + // Affiche('détecteur='+intToSTR(det3)+' '+nom_train,clWhite); + AdrTrain:=detecteur[det3].AdrTrain; + end; end; TrainZone[n_trains].train:=detecteur[det3].train; @@ -11244,8 +12745,7 @@ begin end; //if etat then detecteur[det3].IndexTrain:=1; - -end; + end; // affecte le détecteur "adresse" d'état "front" au train et met sa route à jour procedure calcul_zones(adresse: integer;front : boolean); @@ -11259,7 +12759,7 @@ end; // demande l'état d'un détecteur à la centrale. Le résultat sera réceptionné sur évènement des informations -// de rétrosignalisation. +// de rétrosignalisation : decode_retro_XpressNet procedure demande_info_det_XpressNet(adresse : integer); var s : string; n,module : byte; @@ -11313,9 +12813,10 @@ begin end; end; -// demande l'état de tous les détecteurs par l'interface +// demande l'état de tous les détecteurs par l'interface en XpressNet +// vérifie l'état des détecteurs en fonction de la déclaration des cantons procedure demande_etat_det; -var j,adr,t : integer; +var i,j,adr,t : integer; s : string; begin if portCommOuvert or parSocketLenz or (etat_init_interface>=11) then @@ -11342,6 +12843,22 @@ begin end; modeStkRetro:=false; // avec evt end; + for j:=1 to Ndetecteurs do + begin + adr:=Adresse_detecteur[j]; + for i:=1 to ncantons do + begin + if ((canton[i].el1=adr) and (canton[i].typ1=det)) or + ((canton[i].el2=adr) and (canton[i].typ2=det)) then + begin + if canton[i].adresseTrain=0 then + begin + s:='Le canton '+intToSTR(canton[i].numero)+' contigu au détecteur '+intToSTR(adr)+' à 1 ne contient pas de train'; + Affiche(s,clOrange); + end; + end; + end; + end; end; end; @@ -11465,7 +12982,7 @@ procedure envoi_periph_usb(i,j : integer); var numacc,v,cmd : integer; s : string; begin - numacc:=Tablo_actionneur[i].TabloOp[j].periph; // numéro de périphérique + numacc:=Tablo_Action[i].TabloOp[j].periph; // numéro de périphérique if (numAcc>NbMaxi_Periph) or (numacc=0) then begin Affiche('Erreur 58 : numéro de périphérique hors limite '+intToSTR(i),clred); @@ -11475,7 +12992,7 @@ begin if v=0 then exit; if tablo_periph[numacc].PortOuvert then begin - s:=Tablo_actionneur[i].TabloOp[j].chaine; + s:=Tablo_Action[i].TabloOp[j].chaine; if Tablo_periph[numacc].cr then s:=s+#13; cmd:=Tablo_periph[numacc].numComposant; if cmd=1 then envoi_usb_comp(MSCommCde1,s); @@ -11491,14 +13008,14 @@ procedure envoi_socket_periph_act(i,j : integer); var v,numacc : integer; s : string; begin - v:=Tablo_actionneur[i].tabloOp[j].periph; // numéro de périphérique + v:=Tablo_Action[i].tabloOp[j].periph; // numéro de périphérique numacc:=Tablo_periph[v].numComposant; //numéro de composant if (numAcc>NbMaxi_Periph) or (numacc=0) then begin Affiche('Erreur 59 : numéro de périphérique hors limite',clred); exit; end; - s:=Tablo_actionneur[i].TabloOp[j].chaine; + s:=Tablo_Action[i].TabloOp[j].chaine; if Tablo_periph[numacc].cr then s:=s+#13; if numacc=1 then Formprinc.ClientSocketCde1.socket.SendText(s); if numacc=2 then Formprinc.ClientSocketCde2.socket.SendText(s); @@ -11549,22 +13066,22 @@ var decl,op,af,access,sortie,t,v,etat : integer; Ts : TAccessoire; tr : double; begin - st:='Action '+Tablo_actionneur[i].NomAction+' : '; - op:=Tablo_actionneur[i].tabloOp[ida].numoperation; - if Tablo_actionneur[i].tabloOp[ida].valide then + st:='Action '+Tablo_Action[i].NomAction+' : '; + op:=Tablo_Action[i].tabloOp[ida].numoperation; + if Tablo_Action[i].tabloOp[ida].valide then begin - decl:=Tablo_actionneur[i].declencheur; + decl:=Tablo_Action[i].declencheur; if decl=DeclHorloge then begin st:=st+'Horaire '+format('%.2dh%.2d',[t,v]); - t:=Tablo_actionneur[i].heure; - v:=Tablo_actionneur[i].minute; + t:=Tablo_Action[i].heure; + v:=Tablo_Action[i].minute; end; // 1 : affiche TCO if (op=ActionAffTCO) then begin - af:=Tablo_actionneur[i].tabloOp[ida].NumTCO; + af:=Tablo_Action[i].tabloOp[ida].NumTCO; Affiche(st+' Affiche TCO'+intToSTR(af),clyellow); Affiche_Fenetre_TCO(af,true); end; @@ -11594,11 +13111,11 @@ begin // 4 : accessoire if (op=ActionAccessoire) then begin - access:=Tablo_actionneur[i].tabloOp[ida].adresse; - sortie:=Tablo_actionneur[i].tabloOp[ida].etat; + access:=Tablo_Action[i].tabloOp[ida].adresse; + sortie:=Tablo_Action[i].tabloOp[ida].etat; Affiche(st+' Accessoire '+IntToSTR(access)+':'+intToSTR(sortie),clyellow); // exécution la fonction accessoire vers CDM - if Tablo_actionneur[i].tabloOp[ida].zero then Ts:=aigP else Ts:=signal; + if Tablo_Action[i].tabloOp[ida].zero then Ts:=aigP else Ts:=signal; pilote_acc(access,sortie,Ts); end; @@ -11641,15 +13158,15 @@ begin // 10: vitesse if (op=ActionVitesse) then begin - traindest:=Tablo_actionneur[i].tabloOp[ida].train; - Affiche(st+' Vitesse train='+trainDest+' à '+IntToSTR(Tablo_actionneur[i].tabloOp[ida].vitesse),clyellow); - vitesse_loco(trainDest,0,0,Tablo_actionneur[i].tabloOp[ida].vitesse,true); + traindest:=Tablo_Action[i].tabloOp[ida].train; + Affiche(st+' Vitesse train='+trainDest+' à '+IntToSTR(Tablo_Action[i].tabloOp[ida].vitesse),clyellow); + vitesse_loco(trainDest,0,0,Tablo_Action[i].tabloOp[ida].vitesse,true); end; // 11 : commande COM/USB socket if (op=ActionCdePeriph) then begin - v:=tablo_actionneur[i].TabloOp[ida].periph; // numéro d'accessoire + v:=Tablo_Action[i].TabloOp[ida].periph; // numéro d'accessoire Affiche(st+' Envoi commande',clYellow); af:=com_socket(v); if af=1 then envoi_periph_usb(i,ida); // numéro d'actionneur @@ -11659,35 +13176,35 @@ begin // 12 actionneur pour fonction train if (op=ActionFonctionF) then begin - trainDest:=Tablo_actionneur[i].tabloOp[ida].train; + trainDest:=Tablo_Action[i].tabloOp[ida].train; // exécution de la fonction F vers CDM - etat:=tablo_actionneur[i].tabloop[ida].TempoF; + etat:=Tablo_Action[i].tabloop[ida].TempoF; tr:=etat/10; - Affiche(st+' TrainDest='+trainDest+' F'+IntToSTR(Tablo_actionneur[i].tabloOp[ida].fonctionF)+' t='+Format('%.1f', [tr])+'s',clyellow); - envoie_fonction_CDM(Tablo_actionneur[i].TabloOp[ida].fonctionF,etat,trainDest); - tablo_actionneur[i].tabloOp[ida].TrainCourant:=trainDest; // pour mémoriser le train pour la retombée de la fonction - tablo_actionneur[i].TabloOp[ida].TempoCourante:=etat; + Affiche(st+' TrainDest='+trainDest+' F'+IntToSTR(Tablo_Action[i].tabloOp[ida].fonctionF)+' t='+Format('%.1f', [tr])+'s',clyellow); + envoie_fonction_CDM(Tablo_Action[i].TabloOp[ida].fonctionF,etat,trainDest); + Tablo_Action[i].tabloOp[ida].TrainCourant:=trainDest; // pour mémoriser le train pour la retombée de la fonction + Tablo_Action[i].TabloOp[ida].TempoCourante:=etat; end; // 13 : son if (op=ActionSon) then //and ( test_train_decl(sDecl,trainDecl) or (sDecl='X') or (trainDecl='X') or (trainDecl='')) and (etatValide) then begin - Affiche(st+' son '+Tablo_actionneur[i].tabloop[ida].chaine,clyellow); - PlaySound(pchar(Tablo_actionneur[i].tabloop[ida].train),0,SND_ASYNC); + Affiche(st+' son '+Tablo_Action[i].tabloop[ida].chaine,clyellow); + PlaySound(pchar(Tablo_Action[i].tabloop[ida].train),0,SND_ASYNC); end; // 14 : tempo if op=ActionTempo then begin - etat:=tablo_actionneur[i].tabloop[ida].TempoF; + etat:=Tablo_Action[i].tabloop[ida].TempoF; tr:=etat/10; Affiche(st+' Tempo '+Format('%.1f', [tr])+'s',clyellow); - tablo_actionneur[i].TabloOp[ida].TempoCourante:=etat; + Tablo_Action[i].TabloOp[ida].TempoCourante:=etat; // si on a une tempo, passer la main au timer pour toutes les actions suivantes. - if (idanb) or sort; end; @@ -11719,35 +13236,35 @@ var i : integer; begin for i:=1 to MaxTablo_act do begin - if (Tablo_actionneur[i].declencheur=DeclDemarTrain) then + if (Tablo_Action[i].declencheur=DeclDemarTrain) then begin - if (Tablo_actionneur[i].trainDecl=train) then + if (Tablo_Action[i].trainDecl=train) then begin - if (vitesse>Tablo_actionneur[i].adresse) then + if (vitesse>Tablo_Action[i].adresse) then begin - if not(Tablo_actionneur[i].traite) and teste_condition(i) then + if not(Tablo_Action[i].traite) and teste_condition(i) then begin - Tablo_actionneur[i].traite:=true; + Tablo_Action[i].traite:=true; action(i); // exécute toutes les opérations de l'actionneur i end end - else Tablo_actionneur[i].traite:=false; + else Tablo_Action[i].traite:=false; end; end; - if (Tablo_actionneur[i].declencheur=DeclArretTrain) then + if (Tablo_Action[i].declencheur=DeclArretTrain) then begin - if (Tablo_actionneur[i].trainDecl=train) then + if (Tablo_Action[i].trainDecl=train) then begin - if (vitesseNbMaxDet then begin @@ -12085,8 +13603,6 @@ begin exit; end; - //if etat then Affiche(intToSTR(adresse)+' '+train,clWhite); - // vérifier si front descendant pour filtrage if (filtrageDet0<>0) and not(CDM_connecte) and (i_simule=0) then begin @@ -12112,7 +13628,7 @@ begin //if (train='') and (s<>'') then train:=s; if Etat then Etat01:=1 else Etat01:=0; - //Affiche('Event Det '+inTToSTR(adresse)+' '+IntToSTR(etat01),Cyan); + if traceliste then Affiche('Event Det '+inTToSTR(adresse)+' '+IntToSTR(etat01),ClCyan); // vérifier si l'état du détecteur est déja stocké, car on peut reçevoir plusieurs évènements pour le même détecteur dans le même état // on reçoit un doublon dans deux index consécutifs. (* @@ -12136,7 +13652,9 @@ begin ancien_detecteur[Adresse]:=detecteur[Adresse].etat; detecteur[Adresse].etat:=etat; - if train<>'_NONE' then + + // affecter le train s'il est non nul + if (train<>'_NONE') and (train<>'') then begin detecteur[Adresse].train:=train; detecteur[Adresse].AdrTrain:=index_train_nom(train); @@ -12156,6 +13674,53 @@ begin event_det_tick[N_event_tick].modele:=det; event_det_tick[N_event_tick].etat:=etat01; if (n_Event_tick mod 10) =0 then affiche_memoire; + + + // vérifier si le détecteur est attaché à un canton, pour voir si une loco y est affectée + // et affecter l'élément suivant et précédent au train + i:=1; + repeat + d1:=canton[i].el1;t1:=canton[i].typ1; + d2:=canton[i].el2;t2:=canton[i].typ2; + trouve:=(d1=adresse) or (d2=adresse); + inc(i); + until (i>Ncantons) or trouve; + if trouve then + begin + dec(i); + + sens:=0;suivant:=0; + sens:=canton[i].sensLoco; + AdrTrain:=canton[i].adresseTrain; + + case sens of + sensGauche,sensHaut : + begin + e1c:=canton[i].el2;t1:=canton[i].typ2; + e2c:=canton[i].el1;t2:=canton[i].typ1; + suivant:=suivant_alg3(e1c,t1,e2c,t2,1); + end; + sensDroit,sensBas : + begin + e1c:=canton[i].el1;t1:=canton[i].typ1; + e2c:=canton[i].el2;t2:=canton[i].typ2; + suivant:=suivant_alg3(e1c,t1,e2c,t2,1); + end; + end; + + detecteur[adresse].AdrTrain:=AdrTrain; + detecteur[adresse].Train:=canton[i].NomTrain; + if sens<>0 then + begin + detecteur[adresse].suivant:=suivant; + detecteur[adresse].TypSuivant:=TypeGen; + // le précédent + detecteur[adresse].precedent:=suivant_alg3(suivant,typeGen,adresse,det,1); + detecteur[adresse].TypPrecedent:=typegen; + end; + + end; + // Affiche('stockage de '+intToSTR(N_event_tick)+' '+IntToSTR(Adresse)+' à '+intToSTR(etat01),clyellow); // compter le nombre de détecteurs à 1 simultanément @@ -12236,6 +13801,7 @@ begin if not(confignulle) then calcul_zones(adresse,false); event_act(Adresse,0,i,train); end; + end; if (N_event_det>=Max_event_det) then @@ -12245,9 +13811,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); + + // calcul distance loco + // AdrTrain:=detecteur[Adresse].AdrTrain; + detecteur[adresse].temps:=0; // Envoyer évent vers périphériques si le service est demandé for i:=1 to NbPeriph do @@ -12355,14 +13922,14 @@ begin end else - if AffAigND then affiche('Avertissement 47 : un evt aiguillage '+intToSTR(adresse)+' non déclaré a été reçu',clOrange); + if AffAigND then affiche('Avertissement 47 : un evt accessoire '+intToSTR(adresse)+' non déclaré a été reçu',clOrange); // evt actionneur d'aiguillage for i:=1 to maxTablo_act do begin - etatAct:=Tablo_actionneur[i].etat ; - adr:=Tablo_actionneur[i].adresse; - typ:=Tablo_actionneur[i].declencheur; + etatAct:=Tablo_Action[i].etat ; + adr:=Tablo_Action[i].adresse; + typ:=Tablo_Action[i].declencheur; if (typ=DeclAccessoire) and (Adr=adresse) then event_act(Adresse,0,pos,''); // évent aig end; @@ -12447,33 +14014,27 @@ begin if traceTrames then afficheDebug(s,clLime); Formprinc.ClientSocketCDM.Socket.SendText(s); // attend l'ack - ackCDM:=false;nackCDM:=false; - temps:=0; - - repeat - inc(temps); - Sleep(50); - 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 + if avecAckCDM then begin - Affiche('Pas de réponse de CDM Rail',clRed); + ackCDM:=false;nackCDM:=false; + temps:=0; + repeat + inc(temps); + Sleep(50); + 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 + begin + Affiche('Pas de réponse de CDM Rail',clRed); + end; end; - envoi_CDM:=ackCDM; end; - -// pilotage d'un accessoire (décodeur d'aiguillage, de signal) et génère l'event aig -// par CDM ou interface -// octet = 1 (dévié) ou 2 (droit) si 0 on ne traite pas -// uniquement en mode autonome: -// si acc=Taig, alors la sortie "octet" est mise à 1 puis à 0 -// si acc=signal, alors la sortie "octet" est mise à 1 uniquement. -// Résultat true si ok -function pilote_acc(adresse : integer;octet : byte;Acc : TAccessoire): boolean; -var groupe,temp,indexAig,AdrTrain : integer ; +// pilote aiguillage avec condition : l'aiguillage doit être réservé par AdrTrain (adrTrain<>0) ou sans condition (adrTrain=0) +function pilote_acc_sc(adresse : integer;octet : byte;Acc : TAccessoire;adrTrain : integer) : boolean; +var groupe,temp,indexAig,AdrTrainLoc : integer ; fonction,pilotage,pilotageCDM : byte; s : string; begin @@ -12490,10 +14051,10 @@ begin indexAig:=index_aig(adresse); if indexAig<>0 then begin - AdrTrain:=aiguillage[indexAig].AdrTrain; - if AdrTrain<>0 then + AdrTrainLoc:=aiguillage[indexAig].AdrTrain; + if (AdrTrainLoc<>0) and (AdrTrain<>0) and (AdrTrainLoc<>AdrTrain) and (diffusion) then begin - Affiche('Pilotage impossible, l''aiguillage '+intToSTR(adresse)+' est réservé par le train @'+intToSTR(AdrTrain),clred); + Affiche('Pilotage impossible, l''aiguillage '+intToSTR(adresse)+' est réservé par le train @'+intToSTR(AdrTrainLoc),clred); Result:=false; exit; end; @@ -12516,7 +14077,7 @@ begin s:=chaine_CDM_Acc(adresse,pilotageCDM); envoi_CDM(s); - event_aig(adresse,pilotage); + if Acc<>Signal then event_aig(adresse,pilotage); result:=true; exit; end; @@ -12541,32 +14102,37 @@ begin s:=#$52+Char(groupe)+char(fonction or $88); // activer la sortie s:=checksum(s); if debug_dec_sig and (acc=signal) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' '+intToSTR(pilotage),clorange); - envoi(s); // envoi de la trame et attente Ack - event_aig(adresse,pilotage); + //affiche('1.Acc='+intToSTR(adresse)+' '+intToSTR(tick),clwhite); + if avecAck then envoi(s) else envoi_ss_ack(s); // envoi de la trame avec/sans attente Ack + //affiche('2.'+intToSTR(tick),clyellow); + if acc<>signal then event_aig(adresse,pilotage); + //affiche('3.'+intToSTR(tick),clyellow); // si l'accessoire est un signal et sans raz des signaux, sortir if (acc=signal) and not(Raz_Acc_signaux) then exit; // si aiguillage, faire une temporisation //if (Index_Signal(adresse)=0) or (Acc=aig) then + //Affiche('*',clyellow); if Acc=AigP then begin - temp:=aiguillage[indexAig].temps;if temp=0 then temp:=4; + temp:=aiguillage[indexAig].temps;if temp=0 then temp:=4; // mini pour pilotage en signaux LEB if portCommOuvert or parSocketLenz then tempo(temp); end; - //sleep(50); + // pilotage à 0 pour éteindre le pilotage de la bobine du relais s:=#$52+Char(groupe)+char(fonction or $80); // désactiver la sortie s:=checksum(s); if debug_dec_sig and (acc=signal) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' 0',clorange); - envoi(s); // envoi de la trame et attente Ack + if avecAck then envoi(s) else envoi_ss_ack(s); // envoi de la trame avec ou sans Ack + //affiche('5.'+intToSTR(tick),clyellow); result:=true; exit; end; if protocole=2 then // dcc++ begin - event_aig(adresse,pilotage); + if acc<>signal then event_aig(adresse,pilotage); // en pilotage, on envoie que l'ID cad l'adresse - 0=droit 1=dévié if pilotage=const_devie then fonction:=1; if pilotage=const_droit then fonction:=0; @@ -12586,6 +14152,26 @@ begin Envoi_serveur('T'+intToSTR(adresse)+','+intToSTR(octet)); result:=true; + +end; + +// pilotage d'un accessoire (décodeur d'aiguillage, de signal) et génère l'event aig +// par CDM ou interface +// octet = 1 (dévié) ou 2 (droit) si 0 on ne traite pas +// uniquement en mode autonome: +// si acc=Taig, alors la sortie "octet" est mise à 1 puis à 0 +// si acc=signal, alors la sortie "octet" est mise à 1 uniquement. +// Résultat true si ok +function pilote_acc(adresse : integer;octet : byte;Acc : TAccessoire): boolean; overload; +begin + pilote_acc_sc(adresse,octet,Acc,9999); +end; + + +// pilotage l'accessoire si l'accesoire est réservé par adrTrain ou non réservé +Function pilote_acc(adresse : integer;octet : byte;adrTrain : integer) : boolean; overload; +begin + pilote_acc_sc(adresse,octet,aigP,AdrTrain); end; @@ -13521,6 +15107,7 @@ begin end; if protocole=2 then s:=''; // dcc++ + application.processMessages; envoi_ss_ack(s); application.processMessages; @@ -13626,7 +15213,7 @@ begin if (vitesse<>300) and (vitesse<>1200) and (vitesse<>2400) and (vitesse<>4800) and (vitesse<>9600) and (vitesse<>19200) and (vitesse<>38400) and (vitesse<>57600) and (vitesse<>115200) and (vitesse<>128000) and (vitesse<>256000) then begin - Affiche('Vitesse périphérique COM ('+intToSTR(vitesse)+') incorrecte',clred); + Affiche('Vitesse périphérique COM'+intToSTR(port)+' ('+intToSTR(vitesse)+') incorrecte',clred); tablo_periph[index].PortOuvert:=false; result:=false; exit; @@ -13739,7 +15326,7 @@ var i,j : integer; begin result:=0; trouve:=false; - + application.processmessages; if MSCommUSBInterface=nil then begin Affiche('Erreur 6000: le composant interface n''est pas créé',clred); @@ -13860,6 +15447,7 @@ begin end; // connecte la centrale en USB/COM en explorant les ports USB/COM de 1 à MaxComPort +// et demande les états des détecteurs procedure connecte_usb; var numport,erreur : integer; s : string; @@ -13914,6 +15502,8 @@ begin init_dccpp; etat_init_interface:=20; end; + modeStkRetro:=false; // avec evt + demande_etat_det; end; end; @@ -14063,6 +15653,7 @@ begin else begin Affiche('CDM rail introuvable. Erreur='+intToSTR(retour),clred); + Affiche('Répertoire présumé de CDM='+repertoire,clWhite); lance_CDM:=false; exit; end; @@ -14221,11 +15812,15 @@ begin end; for i:=1 to NbMaxDet do begin - detecteur[i].etat:=false; + // detecteur[i].etat:=false; ne pas razer les états de détecteurs detecteur[i].train:=''; detecteur[i].adrTrain:=0; - detecteur[i].IndexTrain:=0; - ancien_detecteur[i]:=false; + detecteur[i].IndexTrainRoulant:=0; + detecteur[i].suivant:=0; + detecteur[i].TypSuivant:=rien; + detecteur[i].precedent:=0; + detecteur[i].TypPrecedent:=rien; + ancien_detecteur[i]:=detecteur[i].etat; end; for i:=1 to NbMaxDet do for j:=1 to NbMaxDet do @@ -14256,6 +15851,11 @@ begin begin aiguillage[i].AdrTrain:=0; end; + for j:=1 to NDetecteurs do + begin + i:=Adresse_detecteur[j]; + detecteur[i].AdrTrainRes:=0; + end; i_simule:=0; if DebugAffiche then @@ -14280,6 +15880,11 @@ begin for i:=1 to Ntrains do begin trains[i].canton:=0; + trains[i].detecteurSuiv:=0; + trains[i].TempoArret:=0; + trains[i].TempoArretCour:=0; + trains[i].TempoDemarre:=0; + trains[i].TempsDemarreSig:=0; end; for index:=1 to NbreTCO do @@ -14295,6 +15900,9 @@ begin if pCanvasTCO[index]<>nil then affiche_TCO(index); end; + RAZ_toutes_routes; + + actualise_seltrains; Maj_signaux(false); end; @@ -14306,7 +15914,7 @@ var i,pos : integer; begin // positionnement des aiguillages meme si pas connecté à la centrale ou à CDM // faire en 2 fois pour plus de rapidité - // 1 fois pour initialiser la position dans le tableau + // 1 fois pour initialiser la position dans le tableau des aig // 2eme fois pour positionner physiquement les aiguillages // et générer les evts de position // Affiche('Positionnement aiguillages',cyan); @@ -14619,7 +16227,6 @@ begin couleurs_debug; couleurs_SR; couleurs_cdf; - couleurs_place; couleurs_pilote; end; @@ -14879,6 +16486,70 @@ begin if trouve then result:=i-1; end; +// ouvre l'interface vers la centrale ou CDM rail +procedure interface_ou_cdm; +begin +// lancer CDM rail et le connecte si on le demande ; à faire après la création des signaux et du tco + if debug=1 then Affiche('Procédure CDM',clLime); + procetape('Test CDM et son lancement'); + if LanceCDM then Lance_CDM(true); + procetape('Fin cdm'); + formprinc.Loco.Visible:=true; + + // tenter la liaison vers CDM rail + procetape('Test connexion CDM'); + if not(CDM_connecte) then connecte_CDM; + + // si CDM n'est pas connecté, on regarde si on ouvre la liaison vers la centrale + if not(CDM_connecte) then + begin + procetape('Ouvertures COM/USB interface'); + // ouverture par USB + etat_init_interface:=1; // demande connexion usb + if AvecDemandeInterfaceUSB then connecte_USB; + if not(portCommOuvert) and AvecDemandeInterfaceEth then + begin + application.ProcessMessages; + connecte_interface_ethernet; // la connexion du socket ne se fait qu'à la sortie de cette procédure create + end; + end; + + if debug=1 then Affiche('Tentative ouverture liaison centrale',clLime); + if portCommOuvert or parSocketLenz then + With Formprinc do + begin + ButtonEcrCV.Enabled:=true; + LireunfichierdeCV1.enabled:=true; + ButtonLitCV.Enabled:=true; + end + else + With Formprinc do + begin + ButtonEcrCV.Enabled:=false; + ButtonLitCV.Enabled:=false; + LireunfichierdeCV1.enabled:=false; + end; + + if AvecInit then + begin + if not(ConfigNulle) and not(fermeSC) and (AvecInitAiguillages) then + begin + if maxaiguillage>0 then + begin + Affiche('Positionnement des aiguillages',clcyan); + init_aiguillages; // initialisation des aiguillages + end; + end; + + if not(AvecInitAiguillages) and not(fermeSC) and (parSocketLenz or portCommOuvert) + and AvecDemandeAiguillages then + begin + procetape('Demande etats accessoires'); + demande_etat_acc; // demande l'état des accessoires (position des aiguillages) + end; + //Menu_interface(valide); + end; +end; // démarrage principal du programme signaux_complexes procedure TFormPrinc.FormCreate(Sender: TObject); @@ -14888,7 +16559,7 @@ var n,t,i,index,OrgMilieu : integer; Sr : TSearchRec; tmP,tmA : tMenuItem; begin - af:='Client TCP-IP ou USB CDM Rail - système XpressNet DCC++ Version '+VersionSC+sousVersion; + af:='Client TCP-IP ou USB CDM Rail - Système XpressNet DCC++ Version '+VersionSC+sousVersion; {$IF CompilerVersion >= 28.0} af:=af+' D11'; {$IFEND} @@ -14897,19 +16568,18 @@ begin formTCO[index]:=nil; end; - BorderStyle:=bsSizeable; Caption:=af; - TraceSign:=True; configPrete:=false; // form config prete PremierFD:=false; sauve_tco:=false; pasChgTBV:=false; + AffSig:=true; horloge:=false; + avecAckCDM:=true; // attend ou non les ack de cdm (sauf à la connexion) ntrains:=0; TempoTC:=5; - mode_reserve:=0; // mode_reserve 0 = par canton - 1=par détecteurs ntrains_cdm:=0; protocole:=1; filtrageDet0:=3; @@ -14937,17 +16607,17 @@ begin GroupBoxCV.Left:=633; GroupBoxCV.Top:=60; GroupBoxCV.Visible:=false; - // box3=vitesses et fonctions F GroupBoxTrains.Left:=633; GroupBoxTrains.Top:=60; GroupBoxAcc.Left:=633; - GroupBoxTrains.visible:=true; ScrollBoxSig.Left:=633; + GroupBoxTrains.visible:=true; OffsetXFC:=0; OffsetYFC:=0; procetape(''); //0 NbreTCO:=0; N_Trains:=0; + IdActTr:=0; NivDebug:=0; ncrois:=0; EnvAigDccpp:=0; @@ -14973,19 +16643,23 @@ begin nCantonsRes:=2; AntiTimeoutEthLenz:=0; nCantons:=0; + DetDepart:=0; + DetAtrouve:=0; Verif_AdrXpressNet:=1; Max_Signal_Sens:=5; portServeur:=4500; - avecRoulage:=0; formatY:=-1; - avecResa:=false; // réservation des aiguillages en mode normal serveurIPCDM_Touche:=false; debugPN:=false; sombre:=false; - AvecInit:=true; // &&&& avec initialisation des aiguillages ou pas - Diffusion:=AvecInit; // mode diffusion publique + debug mise au point etc - Button1.Visible:=not(avecInit); - roulage1.visible:=false; + AvecInit:=true; // avec initialisation des aiguillages ou pas + + Diffusion:=true; // &&&& mode diffusion publique + debug mise au point etc + +// Afficheroutespartrain1.Visible:=not(diffusion); + Button3.Visible:=not(diffusion); + + FenRich.MaxLength:=$7FFFFFF0; NbDecodeur:=11; NbDecodeurdeBase:=NbDecodeur; @@ -14993,13 +16667,20 @@ begin Decodeur[5]:='Digikeijs 4018';Decodeur[6]:='Unisemaf Paco';Decodeur[7]:='Stéphane Ravaut';Decodeur[8]:='Arcomora'; Decodeur[9]:='LS-DEC-NMBS';Decodeur[10]:='B-models'; + // initalisation des actions init_operations; init_conditions; init_declencheurs; - // créer icones des trains + // créer icones des trains et raz champs for i:=1 to Max_Trains do begin + trains[i].canton:=0; + trains[i].detecteurSuiv:=0; + trains[i].TempoArret:=0; + trains[i].TempoArretCour:=0; + trains[i].TempoDemarre:=0; + trains[i].TempsDemarreSig:=0; Trains[i].icone:=Timage.create(self); with Trains[i].icone do begin @@ -15214,6 +16895,7 @@ begin Application.ProcessMessages; // Initialisation des images des signaux procetape('Création des signaux'); + NbreImagePLigne:=(Formprinc.ScrollBoxSig.Width div (largImg+5)) -1; if NbreImagePLigne=0 then NbreImagePLigne:=1; @@ -15225,22 +16907,28 @@ begin end; procetape('Mise à jour des trains cantons'); - // affecter les trains au cantons + + // affecter les trains au cantons d'après le placement du fichier de config 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 + ProcEtape('Début extraction train '+intToSTR(i)+' sur canton'); + n:=trains[i].canton; // numéro de canton (pas index) provient du placement du fichier de config + ProcEtape('Fin extraction train '+intToSTR(i)+' sur canton '+intToSTR(n)); + 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; + if t=0 then + begin + Affiche('Le train '+trains[i].nom_train+' est affecté à un canton '+intToSTR(n)+' qui est inexistant,',clOrange); + Affiche('Ceci a été corrigé en désaffectant le train.',clOrange); + trains[i].canton:=0; + end + else + begin + ProcEtape('Train '+intToSTR(i)+' canton numéro '+intToSTR(n)); + affecte_Train_canton(trains[i].adresse,t); + end; + end; end; procetape('Affecter les sens des trains aux cantons'); @@ -15248,14 +16936,14 @@ begin for i:=1 to nCantons do begin t:=canton[i].indexTrain; - if t>nTrains then + 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; + canton[i].SensLoco:=0; end else - canton[i].Sens:=trains[t].sens; + canton[i].SensLoco:=trains[t].sens; end; Tempo_init:=5; // démarre les initialisations des signaux et des aiguillages dans 0,5 s @@ -15277,6 +16965,7 @@ begin {$IFEND} if debug=1 then Affiche('Création TCO',clLime); + procetape('Création des TCO'); for index:=1 to nbreTCO do begin tcoCree:=false; @@ -15293,10 +16982,10 @@ begin begin Affiche('Erreur 850 : TCO non créé',clred); formTCO[index]:=nil; - end - else - + end; end; + renseigne_tous_cantons; // les form des TCO doivent être créés + // ouvre les périphériques commandes actionneurs, car on a lu les com dans la config for i:=1 to NbPeriph do @@ -15337,66 +17026,6 @@ begin end; - // lancer CDM rail et le connecte si on le demande ; à faire après la création des signaux et du tco - if debug=1 then Affiche('Procédure CDM',clLime); - procetape('Test CDM et son lancement'); - if LanceCDM then Lance_CDM(true); - procetape('Fin cdm'); - Loco.Visible:=true; - - // tenter la liaison vers CDM rail - procetape('Test connexion CDM'); - if not(CDM_connecte) then connecte_CDM; - - // si CDM n'est pas connecté, on regarde si on ouvre la liaison vers la centrale - if not(CDM_connecte) then - begin - procetape('Ouvertures COM/USB interface'); - // ouverture par USB - etat_init_interface:=1; // demande connexion usb - if AvecDemandeInterfaceUSB then connecte_USB; - if not(portCommOuvert) and AvecDemandeInterfaceEth then - begin - application.ProcessMessages; - connecte_interface_ethernet; // la connexion du socket ne se fait qu'à la sortie de cette procédure create - end; - end; - - if debug=1 then Affiche('Tentative ouverture liaison centrale',clLime); - if portCommOuvert or parSocketLenz then - With Formprinc do - begin - ButtonEcrCV.Enabled:=true; - LireunfichierdeCV1.enabled:=true; - ButtonLitCV.Enabled:=true; - end - else - With Formprinc do - begin - ButtonEcrCV.Enabled:=false; - ButtonLitCV.Enabled:=false; - LireunfichierdeCV1.enabled:=false; - end; - - if AvecInit then - begin - if not(ConfigNulle) and not(fermeSC) and (AvecInitAiguillages) then - begin - if maxaiguillage>0 then - begin - Affiche('Positionnement des aiguillages',clcyan); - init_aiguillages; // initialisation des aiguillages - end; - end; - - if not(AvecInitAiguillages) and not(fermeSC) and (parSocketLenz or portCommOuvert) - and AvecDemandeAiguillages then - begin - procetape('Demande etats accessoires'); - demande_etat_acc; // demande l'état des accessoires (position des aiguillages) - end; - //Menu_interface(valide); - end; { //DoubleBuffered:=true; @@ -15427,7 +17056,7 @@ begin } - procetape('Terminé !!'); + procetape('Fin des initialisations'); if debug=1 then Affiche('Positionnement des signaux',clLime); Maj_Signaux(false); @@ -15445,7 +17074,7 @@ begin //Affiche(GetMACAddress,clred); //formPrinc.left:=-1000; ConfCellTCO:=false; - if debug=1 then Affiche('Fini',clLime); + if debug=1 then Affiche('Fini',clLime); end; @@ -15517,6 +17146,8 @@ begin if confasauver then sauve_config; if sauve_tco then sauve_fichiers_tco; + for i:=1 to NbreTCO do FormTCO[i].Close; + timer1.Enabled:=false; FermeSC:=true; @@ -15566,6 +17197,7 @@ var i,indexTrain,vitesse : integer; traite : boolean; train : string; begin + // démarrage des trains à l'horaire for i:=1 to MaxHoraire do begin @@ -15577,7 +17209,7 @@ begin if roulage then begin indexTrain:=index_train_nom(train); - traite:=trains[indexTrain].roulage; + traite:=trains[indexTrain].roulage>0; end; if traite then @@ -15587,7 +17219,6 @@ begin 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; end; @@ -15596,10 +17227,10 @@ begin // évènements actionneurs horaires for i:=1 to maxTablo_act do begin - if Tablo_actionneur[i].declencheur=DeclHorloge then + if Tablo_Action[i].declencheur=DeclHorloge then begin -// affiche(intToSTR(Tablo_Actionneur[i].adresse)+' '+Tablo_Actionneur[i].,clLime); - if (Tablo_Actionneur[i].heure=heure) and (Tablo_Actionneur[i].minute=minute) then +// affiche(intToSTR(Tablo_Action[i].adresse)+' '+Tablo_Action[i].,clLime); + if (Tablo_Action[i].heure=heure) and (Tablo_Action[i].minute=minute) then begin action(i); end; @@ -15609,7 +17240,7 @@ end; // timer à 100 ms procedure TFormPrinc.Timer1Timer(Sender: TObject); -var n,vitesse,i,j,a,adresse,TailleX,TailleY,orientation,indexTCO,x,y,Bimage,aspect : integer; +var n,vitesse,i,j,a,d,longueur,adresse,TailleX,TailleY,orientation,indexTCO,x,y,Bimage,aspect : integer; imageSignal : Timage; frx,fry : real; faire : boolean; @@ -15618,20 +17249,43 @@ var n,vitesse,i,j,a,adresse,TailleX,TailleY,orientation,indexTCO,x,y,Bimage,aspe begin inc(tick); - // séquencement des actionneurs après tempo + {// si un détecteur comporte un train, calculer la distance du train au détecteur en fonction de la vitesse + if tick mod 4=0 then + begin + for i:=1 to NDetecteurs do + begin + adresse:=adresse_detecteur[i]; + AdrTrain:=detecteur[adresse].AdrTrain; + if adrTrain<>0 then + begin + j:=index_train_adresse(adrTrain); + vitesse:=trains[j].vitesse; + inc(detecteur[adresse].temps,4); // car modulo 4 + if vitesse<>0 then + begin + d:=round(detecteur[adresse].temps*100/vitesse); + detecteur[adresse].distanceTr:=d; + end; + if detecteur[adresse].etat then s:='1' else s:='0'; + //affiche(IntToSTR(adresse)+'='+s+' '+ intToSTR(d),clYellow); + end; + end; + end;} + + // séquencement des actions après tempo if index_seqAct>0 then begin if seq_actionneurs[index_seqAct].tick=tick then begin i:=seq_actionneurs[index_seqAct].indiceAction; j:=seq_actionneurs[index_seqAct].IndiceOp; - n:=tablo_actionneur[i].NbOperations; + n:=Tablo_Action[i].NbOperations; dec(index_seqAct); a:=j; repeat //Affiche('Faire action '+intToSTR(i)+' op '+intToSTR(a),clLime); Action_operation(i,a); - faire:=(tablo_actionneur[i].TabloOp[a].numoperation=ActionTempo); + faire:=(Tablo_Action[i].TabloOp[a].numoperation=ActionTempo); inc(a); until (a>n) or faire; end; @@ -15827,44 +17481,33 @@ begin // signal belge if TestBit(a,clignote) or Signaux[0].contrevoie then dessine_signal_pilote; end; - - end; - - // fenetre de config du signal CDF - if dessineCDF then - begin - a:=Signaux[0].EtatSignal; - if TestBit(a,jaune_cli) or TestBit(a,ral_60) or - TestBit(a,rappel_60) or testBit(a,semaphore_cli) or - testBit(a,vert_cli) or testbit(a,blanc_cli) then - Dessine_Signal_CDF; // dessiner le feu CDF en fonction du bit "clignotant" end; end; // tempo retombée actionneur for i:=1 to maxTablo_act do begin - n:=Tablo_actionneur[i].NbOperations; + n:=Tablo_Action[i].NbOperations; for j:=1 to n do begin - a:=Tablo_actionneur[i].TabloOp[j].TempoCourante; + a:=Tablo_Action[i].TabloOp[j].TempoCourante; if a<>0 then begin dec(a); - Tablo_actionneur[i].TabloOp[j].TempoCourante:=a; + Tablo_Action[i].TabloOp[j].TempoCourante:=a; if a=0 then begin - x:=Tablo_actionneur[i].TabloOp[j].numoperation; + x:=Tablo_Action[i].TabloOp[j].numoperation; case x of actionFonctionF : begin - s:=Tablo_actionneur[i].tabloOp[j].trainCourant; - Affiche('Action TrainDest='+s+' F'+IntToSTR(Tablo_actionneur[i].TabloOP[j].fonctionF)+':0',clyellow); - envoie_fonction_CDM(Tablo_actionneur[i].tabloOP[j].fonctionF,0,s); + s:=Tablo_Action[i].tabloOp[j].trainCourant; + Affiche('Action TrainDest='+s+' F'+IntToSTR(Tablo_Action[i].TabloOP[j].fonctionF)+':0',clyellow); + envoie_fonction_CDM(Tablo_Action[i].tabloOP[j].fonctionF,0,s); end; actionTempo : begin - Affiche('Fin temporisation action '+intToSTR(i)+' Op '+intToSTR(j)+' '+Tablo_actionneur[i].NomAction,clYellow); + Affiche('Fin temporisation action '+intToSTR(i)+' Op '+intToSTR(j)+' '+Tablo_Action[i].NomAction,clYellow); end; end; end; @@ -15873,28 +17516,92 @@ begin end; // pilotage des trains : + // arret loco sur n secondes // démarrage loco temporisé // renvoi de la consigne // l'index de train 0 est le train courant + //if (tick mod 10)=0 then Affiche(intToSTR(trains[4].TempoArretCour),clWhite); for i:=1 to ntrains do begin - a:=trains[i].TempoArret; + a:=trains[i].TempoArret; // la tempo d'arret est écrite par pilote_train() 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 + //Affiche(intToSTR(a),clOrange); + if trains[i].TempoArretCour=0 then + begin + trains[i].TempoArretCour:=a; + if not(diffusion) then Affiche('Vitesse train /2',clYellow); + vitesse:=trains[i].VitRalenti div 2; + trains[i].vitesse:=vitesse; + if (trains[i].inverse) then vitesse:=-vitesse; + vitesse_loco(trains[i].nom_train,i,trains[i].adresse,vitesse,true); + end; + + dec(trains[i].TempoArretCour); + a:=trains[i].TempoArretCour; + adresse:=trains[i].dernierDet; + + // si le train est sur un détecteur + if (adresse<>0) then + begin + longueur:=detecteur[adresse].longueur; // longueur du détecteur + + if detecteur[Adresse].Etat then begin - vitesse:=trains[i].VitRalenti div 2; - 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); + inc(detecteur[adresse].temps); + + vitesse:=trains[i].vitesse; + // Affiche('Vitesse='+intToSTR(vitesse),clred); + if vitesse<>0 then + d:=round(detecteur[adresse].temps*90/vitesse) + else d:=0; + + //Affiche('TempoarretCour='+intToSTR(a)+' train '+intToSTR(i)+' detecteur='+intToSTR(adresse)+' TpsDet='+intToSTR(detecteur[adresse].temps),clOrange); + // si la longueur déclarée du canton <>0 on s'arrete sur la longueur sinon on s'arrete sur la tempo d'arret. + if (a<>0) and (longueur<>0) then + begin + // arrêt + if not(diffusion) then Affiche('Dist='+intToSTR(d),clYellow); + if d>longueur-5 then + begin + a:=0; + trains[i].TempoArret:=0; + trains[i].TempoArretCour:=0; + if not(diffusion) then Affiche(trains[i].nom_train+' Arrêté',ClWhite); + vitesse:=0; + if (trains[i].inverse) then vitesse:=-vitesse; + vitesse_loco(trains[i].nom_train,i,trains[i].adresse,vitesse,false); // arrêt du train + train_sarrete(i); + end; + end; + + if a<>0 then + begin + if (longueur=0) then + begin + if not(diffusion) then Affiche('Cas longueur non déclarée',clWhite); + dec(a); + trains[i].TempoArretCour:=a; // il faut utiliser la tempo d'arret<>0 pour savoir que le train doit s'arrêter + if a=0 then + begin + //Affiche(trains[i].nom_train+' Arrêté',ClWhite); + vitesse_loco(trains[i].nom_train,i,trains[i].adresse,0,false); + train_sarrete(i); + end; + if (a mod 10)=0 then + begin + vitesse:=trains[i].VitRalenti div 2; + if (trains[i].inverse) then vitesse:=-vitesse; + vitesse_loco(trains[i].nom_train,i,trains[i].adresse,vitesse,true); + end; + end; + end; end; + end; end; + // démarrage sur tempo a:=trains[i].TempoDemarre; if a<>0 then begin @@ -15902,7 +17609,7 @@ begin 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_vitesseST(1,s); s:=chaine_CDM_StopTrainST(s); envoi_cdm(s); end; @@ -15917,6 +17624,7 @@ begin end; end; + // démarrage sur consigne a:=trains[i].compteur_consigne; if a<>0 then begin @@ -16291,6 +17999,7 @@ end; procedure TFormPrinc.AffEtatDetecteurs(Sender: TObject); var j,adr,adrTrain : integer; + c : tcolor; s : string; begin Affiche('Etat des détecteurs:',ClLime); @@ -16302,19 +18011,29 @@ begin if Detecteur[adr].etat then begin s:=s+'1 '; + c:=clWhite; inc(NbDet1); end - else s:=s+'0 '; + else + begin + s:=s+'0 '; + c:=clyellow; + end; s:=s+detecteur[adr].train; AdrTrain:=detecteur[adr].AdrTrain; if AdrTrain<>0 then s:=s+' @='+intToSTR(AdrTrain); - AdrTrain:=detecteur[adr].IndexTrain; + AdrTrain:=detecteur[adr].IndexTrainRoulant; if AdrTrain<>0 then s:=s+' IndexTrain='+intToSTR(AdrTrain); + s:=s+' Prec='+intToSTR(detecteur[adr].precedent); + s:=s+' Suiv='+intToSTR(detecteur[adr].suivant); - Affiche(s,clYellow); + AdrTrain:=detecteur[adr].AdrTrainRes; + if AdrTrain<>0 then s:=s+' @RES='+intToSTR(AdrTrain); + + Affiche(s,c); end; - Affiche('Nombre de détecteurs à 1 :'+intToSTR(NbDet1),clYellow); + Affiche('Nombre de détecteurs à 1 :'+intToSTR(NbDet1),clyellow); end; // trouve l'index du détecteur de. Si pas trouvé, renvoie 0 @@ -16438,7 +18157,7 @@ begin LabelTitre.caption:=titre+' Interface connectée par Ethernet'; Formprinc.StatusBar1.Panels[4].Text:=ClientSocketInterface.Address; etat_init_interface:=11; // socket connecté - trouve:=test_protocole; // appelle l'état des détécteurs + trouve:=test_protocole; // appelle l'état des détecteurs if trouve then // protocole reconnu begin @@ -17472,12 +19191,12 @@ begin begin //trace:=true; s:=#$22+#$15+Char(cv); //CV de 1 à 256 (V3.0) - //s:=#$22+#$18+Char(cv); //CV de 1 à 255 + 1024 (V3.6) + //s:=#$22+#$18+Char(cv); //CV de 1 à 255 + 1024 (V3.6) s:=checksum(s); // envoi de la trame : fait passer la centrale en mode programmation (service) envoi_ss_ack(s); - // attendre la trame 01 04 05 (env 1s) + // attendre la trame 01 04 05 "succès" (env 1s) succes:=false;i:=0; repeat Application.processMessages; @@ -17550,83 +19269,6 @@ begin end; end; -{ -procedure TFormPrinc.Codificationdesactionneurs1Click(Sender: TObject); -var i,decl,adract,etatAct,fonction,v,acc,sortie : integer; - s,s2 : string; -begin - if (maxTablo_act=0) and (NbrePN=0) then - begin - Affiche('Aucun actionneur déclaré',clCyan); - exit; - end; - - Affiche('Codification interne des actionneurs',clCyan); - for i:=1 to maxTablo_act do - begin - s:=Tablo_actionneur[i].trainDecl; - etatAct:=Tablo_actionneur[i].etat ; - AdrAct:=Tablo_actionneur[i].adresse; - s2:=Tablo_actionneur[i].trainDecl; - acc:=Tablo_actionneur[i].accessoire; - sortie:=Tablo_actionneur[i].sortie; - fonction:=Tablo_actionneur[i].fonction; - - decl:=Tablo_actionneur[i].typdeclenche; - - if decl=DeclZoneDet then s:='Mem '+intToSTR(adrAct)+' '+inttostr(Tablo_actionneur[i].Adresse2); - if decl=DeclDetAct then s:=intToSTR(adrAct); - if Decl=DeclAccessoire then s:='Acc '+intToSTR(AdrAct); - - if Decl=Action then - s:='FonctionF Déclencheur='+s+' :'+intToSTR(etatAct)+' TrainDécl='+s2+' TrainDest='+Tablo_actionneur[i].TrainDest+' F'+IntToSTR(fonction)+ - ' Temporisation='+intToSTR(tablo_actionneur[i].Tempo); - if act then - s:='Accessoire Déclencheur='+s+' :'+intToSTR(etatAct)+' TrainDécl='+s2+' Adresse='+IntToSTR(acc)+ - ' sortie='+intToSTR(sortie); - if son then - s:='Son Déclencheur='+s+' :'+intToSTR(etatAct)+' TrainDécl='+s2+ - ' Fichier:'+Tablo_actionneur[i].FichierSon; - - if periph then - s:='Périphérique Déclencheur='+s; - - Affiche(s,clYellow); - end; - - // dans le tableau des PN - for i:=1 to NbrePN do - begin - s:='PN'+intToSTR(i)+' Adresse fermeture PN='+IntToSTR(Tablo_PN[i].AdresseFerme); - s:=s+' Adresse ouverture PN='+IntToSTR(Tablo_PN[i].AdresseOuvre); - Affiche(s,clyellow); - s:=' Commande fermeture='+intToSTR(Tablo_PN[i].commandeFerme); - s:=s+' Commande ouverture='+intToSTR(Tablo_PN[i].commandeOuvre); - s:=s+' Nbre de voies='+intToSTR(Tablo_PN[i].nbVoies); - Affiche(s,clyellow); - s:=' Compteur trains engagés sur PN='+intToSTR(tablo_PN[i].compteur); - Affiche(s,clyellow); - - if tablo_PN[i].Voie[1].ActFerme<>0 then - // par actionneur - begin - for v:=1 to Tablo_PN[i].nbvoies do - begin - s:=' Voie '+IntToSTR(v)+': Actionneur de fermeture='+intToSTR(Tablo_PN[i].voie[v].ActFerme); - s:=s+' Actionneur d''ouverture='+intToSTR(Tablo_PN[i].voie[v].ActOuvre); - Affiche(s,clyellow); - end; - end - else - // par zone de détection - for v:=1 to Tablo_PN[i].nbvoies do - begin - s:=' Voie '+IntToSTR(v)+': Zones de fermeture='+intToSTR(tablo_PN[i].Voie[v].detZ1F)+'-'+intToSTR(tablo_PN[i].Voie[v].detZ2F); - s:=s+' Zones d''ouverture='+intToSTR(tablo_PN[i].Voie[v].detZ1O)+'-'+intToSTR(tablo_PN[i].Voie[v].detZ2O); - Affiche(s,clyellow); - end; - end; -end; } procedure TFormPrinc.ButtonArretSimuClick(Sender: TObject); begin @@ -17773,7 +19415,11 @@ begin aff:=MemZone[i,j].etat; if aff then begin - Affiche('MemZone['+intToSTR(i)+','+intToSTR(j)+'] '+MemZone[i,j].train+' @='+intToSTR(MemZone[i,j].AdrTrain)+' Train n°'+intToSTR(MemZone[i,j].IndexTrain),couleurTrain[MemZone[i,j].IndexTrain]); + s:='MemZone['+intToSTR(i)+','+intToSTR(j)+'] '+MemZone[i,j].train+' @='+intToSTR(MemZone[i,j].AdrTrain); + s:=s+' Train n°'+intToSTR(MemZone[i,j].IndexTrainRoulant); + s:=s+' PrevSuiv='+intToSTR(MemZone[i,j].Prev); + Affiche(s,couleurTrain[MemZone[i,j].IndexTrainRoulant]); + rien:=false; end; inc(j); @@ -17781,23 +19427,24 @@ begin inc(i); until (i>NbMaxDet); - Affiche('Derniers éléments scannés:',clWhite); + {Affiche('Derniers éléments scannés:',clWhite); for i:=1 to idEl do begin Affiche(IntToSTR(elements[i].adresse),clLime); - end; + end;} + Affiche(' ',clyellow); for i:=1 to n_trains do begin s:='Event det train '+intToSTR(i); n:=event_det_train[i].AdrTrain; if n<>0 then s:=s+' @'+intToSTR(n); ss:=event_det_train[i].nom_train; - if ss<>'' then s:=s+' '+ss; - Affiche(s,couleurTrain[i]); + if ss<>'' then s:=s+' '+ss+' '; n:=event_det_train[i].signal_rouge; - if n<>0 then Affiche('Arreté devant signal '+intToSTR(n),clyellow); + if n<>0 then s:=s+'Arreté devant signal '+intToSTR(n); + Affiche(s,clyellow); for j:=1 to event_det_train[i].NbEl do begin s:=intToSTR(event_det_train[i].Det[j].adresse); @@ -17805,6 +19452,13 @@ begin end; end; + Affiche(' ',clyellow); + + for i:=1 to ntrains do + begin + Affiche(trains[i].nom_train+' @='+intToSTR(trains[i].adresse)+' Det suiv='+intToSTR(trains[i].detecteurSuiv),clYellow); + end; + { Affiche('Evènements détecteurs par train',clWhite); for i:=1 to n_trains do @@ -17818,7 +19472,7 @@ begin end; end; } - if rien then Affiche('Aucune zone n''a été déclenchée',clOrange); + //if rien then Affiche('Aucune zone n''a été déclenchée',clOrange); end; procedure TFormPrinc.Apropos1Click(Sender: TObject); @@ -17867,7 +19521,7 @@ begin Affiche('Taille des aiguillages : '+intToSTR(SizeOf(aiguillage) )+' octets',clorange); Affiche('Taille des signaux : '+intToSTR(SizeOf(Signaux) )+' octets',clorange); Affiche('Taille des branches : '+intToSTR(SizeOf(brancheN) )+' octets',clorange); - Affiche('Taille des actionneurs standards: '+intToSTR(SizeOf(Tablo_actionneur))+' octets',clorange); + Affiche('Taille des actionneurs standards: '+intToSTR(SizeOf(Tablo_Action))+' octets',clorange); Affiche('Taille des actionneurs PN: '+intToSTR(SizeOf(Tablo_PN) )+' octets',clorange); Affiche('Taille du tableau d''évènements détecteurs '+intToSTR(SizeOf(event_det) )+' octets',clorange); Affiche(' ',clyellow); @@ -18235,15 +19889,7 @@ end; procedure TFormPrinc.OpRoulageClick(Sender: TObject); begin - if PlaceAffiche then - begin - if cdm_connecte then - begin - Affiche('Placement des trains incompatible en mode CDM rail',clOrange); - exit; - end; - formRoulage.showmodal; - end; + init_aiguillages; end; procedure TFormPrinc.Demandetatdtecteurs1Click(Sender: TObject); @@ -18256,56 +19902,6 @@ 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; - trouve : boolean; - s : string; -begin - trouve:=false; - for i:=1 to 6 do - begin - Adr:=trains[i].detecteur; - if adr<>0 then - begin - 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); - end; - end; - init_aiguillages; - - for i:=1 to NDetecteurs do - begin - adr:=Adresse_detecteur[i]; - if Detecteur[adr].etat and (detecteur[adr].train<>'') then - begin - s:='Lancement du train '+detecteur[adr].train+' depuis détecteur '+intToSTR(adr); - Affiche(s,clYellow); - if traceListe then AfficheDebug(s,clyellow); - AdrTrain:=detecteur[Adr].AdrTrain; - j:=index_train_adresse(AdrTrain); - - vitesse:=trains[j].VitNominale; - if (trains[j].inverse) then vitesse:=-vitesse; - vitesse_loco('',j,adrTrain,vitesse,true); - - trouve:=true; - roulage:=true; - end; - end; - if trouve then Maj_Signaux(true); -end; } - -procedure TFormPrinc.Button1Click(Sender: TObject); -begin - reserve_dereserve_det(888,561,1,1,0); - //libere_canton -end; - - procedure affiche_com(s : string;var n : integer); var i : integer; begin @@ -18454,6 +20050,8 @@ begin begin Affiche('Arrêt train @'+intToSTR(adr)+' '+Trains[i].nom_train,clyellow); vitesse_loco('',i,adr,0,true); + trains[i].TempoArretCour:=0; + trains[i].TempoArret:=0; end; end; end; @@ -18604,7 +20202,7 @@ end; procedure mosaiqueH; var NombreEcrans,e,i,largEcran,hautEcran,topEcran,LeftEcran,LargTCO,HautTCO : integer; nbTCOE : array[1..10] of integer; // nombre de TCO par écran - CeTCO : array[1..10] of integer; // nombre de TCO en cours d'affchage par écran + CeTCO : array[1..10] of integer; // nombre de TCO en cours d'affichage par écran begin for i:=1 to 10 do begin nbTCOE[i]:=0;CeTCO[i]:=0;end; for i:=1 to NbreTCO do @@ -19283,7 +20881,7 @@ begin begin if isCanton(tco[tcos,x,y].Bimage) then begin - c:=tco[tcos,x,y].PiedFeu; + c:=tco[tcos,x,y].NumCanton; if c<>0 then supprime_canton(c); end; end; @@ -19430,7 +21028,7 @@ begin sauve_config; end; -// change la couleur du texte du panel +// change la couleur du texte du panel dans la status bar procedure TFormPrinc.StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect); var RectForText: TRect; begin @@ -19445,10 +21043,8 @@ begin DrawText(StatusBar1.Canvas.Handle,PChar(Panel.Text),-1,RectForText,DT_SINGLELINE or DT_VCENTER or DT_LEFT); end; end; - end; - // réception COM/USB du périphérique 1 procedure TFormPrinc.RecuPeriph1(Sender: TObject); var s : string; @@ -19571,9 +21167,8 @@ begin telecommande(s); end; -procedure TFormPrinc.Copierltatdesaiguillageseninitialisation1Click( - Sender: TObject); -var i,p : integer; +procedure TFormPrinc.Copierltatdesaiguillageseninitialisation1Click(Sender: TObject); + var i,p : integer; tsi : boolean; begin tsi:=false; @@ -19699,7 +21294,7 @@ begin Affiche('Etat des cantons',clWhite); for i:=1 to ncantons do begin - s:=intToSTR(i)+' num='+IntToSTR(canton[i].numero); + s:=intToSTR(i)+' Canton '+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='+ @@ -19733,20 +21328,732 @@ begin end; end; -procedure TFormPrinc.Button2Click(Sender: TObject); -var s : string; +// copie le parcours source vers le fin de la route dest +function copie_route(source,dest : integer) : boolean; +var i,n,d : integer; begin - affiche_routes; + n:=tabloParcours[source,0].adresse; + d:=tabloRoute[dest,0].adresse; + for i:=1 to n do + begin + if d+i>MaxParcours then + begin + //Affiche('Erreur 187 : '+intToSTR(d+i),clred) + result:=false; + exit; + end + else + tabloroute[dest,d+i]:=tabloParcours[source,i]; + end; + if d+n<=MaxParcours then tabloroute[dest,0].adresse:=d+n; + result:=true; end; -procedure TFormPrinc.Button3Click(Sender: TObject); + +// trouve toutes les routes de prec à actuel et remplit le tableau tabloroute[route,i] (route=index de la route trouvée) +// on teste les aiguillages ou les tjs sur toutes leurs positions +// procédure récursive +// tabloroute[n,0].adresse contient le nombre d'éléments de la route n +// prec,typePrec ; actuel,TypActuel : éléments contigus à explorer ; nroute : numéro de la route , id=index dans la route; ir = n° de récursivité : départ,fin : détecteurs de départ et de fin cliqués. +// retourne: +// 0 si trouvé adresse 0 +// sorties anormale: ------ +// 1 si max Parcours +// 2 si max routes +// 3 si max itérations +// 4 si max récursivité +// sorties normales: ----- +// 5 si rebouclage sur départ +// 6 si rebouclage sur élément déja traité +// 7 fin exploration aiguillage +// 8 fin exploration TJD +// -------------- +// 9 demande sortie (trop de traitements); +// 10 si trouvé le détecteur "fin" +// 11 nouvelle route, vient après 10 +// 12 mauvais sens +function explore_el(prec : integer;typPrec : Tequipement;actuel : integer;TypActuel : Tequipement;var nroute : integer;id : integer;ir,depart,fin : integer;var ctot : integer) : integer; + + // copie la route dans la suivante + procedure copie; + var i : integer; + begin + if nroute+1<=Maxroutes then + begin + tabloroute[nroute+1,0].adresse:=id; // nombre d'éléments de la route + for i:=1 to id-1 do + tabloroute[nroute+1,i]:=tabloroute[nroute,i]; + end; + end; + + function test_reboucle : boolean; + var i : integer; + begin + // voir si on reboucle sur un élément déja traité + i:=1; + while (i200000 then + begin + result:=9; + if affRouteR then Affiche('Sortie totale',clred); + Affichedebug('Sortie totale Explore_el:'+intToSTR(prec)+' '+intToSTR(actuel),clred); + exit; + end; + + r:=0; + + if AffRouteR then Affiche('Explore_el '+intToSTR(prec)+' '+intToSTR(actuel)+' route='+intToSTR(nroute)+' id='+intToSTR(id)+' ir='+intToSTR(ir)+'----------------',clYellow); + it:=0; + inc(ir); + if ir>itMax then + begin + if affRouteR then + Affiche('MaxRecursivité recherche route',clred); + result:=4; + exit; + end; + + repeat + if affRouteR then Affiche(intToSTR(actuel),clyellow); + tabloroute[nRoute,id].adresse:=actuel; + tabloroute[nRoute,id].typ:=typActuel; + tabloRoute[nRoute,0].adresse:=id; + + // voir si le détecteur a un canton + // et si le canton contient un sens de circulation imposé : canton[].el1 ou el2 typ1 typ2 + // exit si pas le bon sens du canton avec le code 12 + if (TypActuel=det) then // un détecteur peut être jointif de 2 cantons + begin + NumCanton1:=detecteur[actuel].canton1; // numéro de canton 1 + if numCanton1<>0 then // il y a un canton + begin + c1:=Index_canton_numero(NumCanton1); + SensCirc1:=canton[c1].SensCirc; + el1:=canton[c1].el1; + tel1:=canton[c1].typ1; + el2:=canton[c1].el2; + tel2:=canton[c1].typ2; + sensEL1:=canton[c1].SensEl1; //( SensGauche SensDroit SensHaut SensBas) + sensEL2:=canton[c1].SensEl2; //( SensGauche SensDroit SensHaut SensBas) + Horz1:=canton[c1].horizontal; + end; + + NumCanton2:=detecteur[actuel].canton2; // numéro de canton 2 + if numcanton2<>0 then + begin + c2:=Index_canton_numero(NumCanton2); + SensCirc2:=canton[c2].SensCirc; + el1:=canton[c2].el1; + tel1:=canton[c2].typ1; + el2:=canton[c2].el2; + tel2:=canton[c2].typ2; + sensEL1:=canton[c2].SensEl1; //( SensGauche SensDroit SensHaut SensBas) + sensEL2:=canton[c2].SensEl2; //( SensGauche SensDroit SensHaut SensBas) + Horz2:=canton[c2].horizontal; + end; + + suivant:=suivant_alg3(prec,TypPrec,actuel,TypActuel,1); + + // le suivant doit être l'un des 2 éléments du canton + if (numcanton1<>0) and (sensCirc1<>0) and ((suivant=el1) or (suivant=el2)) then + begin + if horz1 then // si le canton 1 est horizontal + begin + ok:=(actuel=el2) and (sensEl2=sensDroit) and (SensCirc1=SensGauche) ; + ok:=((actuel=el2) and (sensEl2=sensGauche) and (SensCirc1=SensDroit)) or ok; + ok:=((actuel=el1) and (sensEl1=sensDroit) and (SensCirc1=SensGauche)) or ok ; + ok:=((actuel=el1) and (sensEl1=sensGauche) and (SensCirc1=SensDroit)) or ok ; + if not(ok) then begin + if affRouteR then + Affiche('1 Canton '+intToSTR(NumCanton1)+' sens nok',clLime); + result:=12;exit;end; + end + else + begin // le canton 1 est vertical + ok:=(actuel=el2) and (sensEl2=sensBas) and (SensCirc1=SensHaut) ; + ok:=((actuel=el2) and (sensEl2=sensHaut) and (SensCirc1=SensBas)) or ok; + ok:=((actuel=el1) and (sensEl1=sensBas) and (SensCirc1=SensHaut)) or ok; + ok:=((actuel=el1) and (sensEl1=sensHaut) and (SensCirc1=SensBas)) or ok; + if not(ok) then begin + if affRouteR then + Affiche('2 Canton '+intToSTR(NumCanton1)+' sens nok',clLime); + result:=12;exit;end; + end; + end; + + if (numcanton2<>0) and (sensCirc2<>0) and ((suivant=el1) or (suivant=el2)) then + begin + if horz2 then + begin + ok:=(actuel=el2) and (sensEl2=sensDroit) and (SensCirc2=SensGauche) ; + ok:=((actuel=el2) and (sensEl2=sensGauche) and (SensCirc2=SensDroit)) or ok; + ok:=((actuel=el1) and (sensEl1=sensDroit) and (SensCirc2=SensGauche)) or ok ; + ok:=((actuel=el1) and (sensEl1=sensGauche) and (SensCirc2=SensDroit)) or ok ; + if not(ok) then begin + if affRouteR then + Affiche('3 Canton '+intToSTR(NumCanton1)+' sens nok',clLime); + result:=12;exit;end; + end + else + begin + ok:=(actuel=el2) and (sensEl2=sensBas) and (SensCirc2=SensHaut) ; + ok:=((actuel=el2) and (sensEl2=sensHaut) and (SensCirc2=SensBas)) or ok; + ok:=((actuel=el1) and (sensEl1=sensBas) and (SensCirc2=SensHaut)) or ok; + ok:=((actuel=el1) and (sensEl1=sensHaut) and (SensCirc2=SensBas)) or ok; + if not(ok) then begin + if affRouteR then + Affiche('4 Canton '+intToSTR(NumCanton1)+' sens nok',clLime); + result:=12;exit;end; + end; + end; + end; + + if actuel=0 then + begin + if affRouteR then + Affiche('Trouvé 0',clred); + result:=0; + exit; + end; + if id>=MaxParcours then + begin + if affRouteR then + Affiche('MaxParcours',clred); + result:=1; + exit; + end; + if nroute>=(MaxRoutes) then + begin + if affRouteR then Affiche('MaxRoutes atteint',clred); + Affichedebug('Max routes atteint: '+intToSTR(prec)+' '+intToSTR(actuel),clred); + result:=2; + exit; + end; + if (actuel=depart) then + begin + if affRouteR then affiche('Rebouclage',clred); + result:=5; + exit; + end; + if (actuel=fin) then + begin + tabloroute[nRoute,id].typ:=det; + if affRouteR then Affiche('Trouvé détecteur final **********',clWhite); + result:=10; + copie; + inc(nRoute); + if nroute>NbreRoutes then NbreRoutes:=nroute; + exit; + end; + + taig:=(typactuel=Aig) or (typActuel=tjs) or (typactuel=crois) or (typActuel=tjd) or (typActuel=triple); + + if taig then + begin + // si aiguillage en pointe + indexAig:=index_aig(actuel); + // rechercher le type exact + typactuel:=aiguillage[indexAig].modele; + tabloroute[nRoute,id].typ:=typactuel; + + if (typactuel=aig) or (typactuel=triple) then + begin + if aiguillage[indexAig].APointe=prec then + begin + inc(id); + // faire droit + tabloroute[nroute,id-1].pos:=const_droit; + tabloroute[nroute,id-1].talon:=false; + + if affRouteR then Affiche('Faire droit aig'+intToSTR(actuel),clorange); + suivant:=aiguillage[indexAig].ADroit; + c:=aiguillage[indexAig].AdroitB; + if (c='S') or (c='D') or (c='P') then typSuiv:=aig else TypSuiv:=det; + if typSuiv=aig then + begin + indexAigSuiv:=index_aig(suivant); + TypSuiv:=aiguillage[indexAigSuiv].modele; + end; + if suivant=0 then TypSuiv:=buttoir; + + r:=explore_El(actuel,typActuel,Suivant,TypSuiv,nroute,id,ir,depart,fin,ctot); + if affrouteR then affiche('1.Retour explore_el de l''aig '+intToSTR(actuel)+' pos droit :'+intToSTR(r),clCyan); + if r=9 then + begin + result:=r; + exit; + end; + if r=10 then + begin + result:=11; + end; + // dévié + if affRouteR then Affiche('Faire dévié aig'+intToSTR(actuel),clorange); + suivant:=aiguillage[indexAig].ADevie; + c:=aiguillage[indexAig].AdevieB; + if (c='S') or (c='D') or (c='P') then typSuiv:=aig else TypSuiv:=det; + if typSuiv=aig then + begin + indexAigSuiv:=index_aig(suivant); + TypSuiv:=aiguillage[indexAigSuiv].modele; // trouver le type exact (aig tjd ...) + end; + if suivant=0 then TypSuiv:=buttoir; + + tabloroute[nroute,id-1].pos:=const_devie; + tabloroute[nroute,id-1].talon:=false; + + if nroute>NbreRoutes then NbreRoutes:=nroute; + r:=explore_El(actuel,typActuel,Suivant,TypSuiv,nroute,id,ir,depart,fin,ctot); + if affrouteR then affiche('2.Retour explore_el de l''aig '+intToSTR(actuel)+' pos dévié :'+intToSTR(r),clCyan); + if r=9 then + begin + result:=r; + exit; + end; + if r=10 then + begin + result:=11; + end; + + if typActuel<>triple then + begin + result:=7; // fin exploration aiguillage + exit; + end + else + begin + // dévié 2 du triple + if affRouteR then Affiche('Faire dévié2 aig'+intToSTR(actuel),clorange); + suivant:=aiguillage[indexAig].ADevie2; + c:=aiguillage[indexAig].Adevie2B; + if (c='S') or (c='D') or (c='P') then typSuiv:=aig else TypSuiv:=det; + if typSuiv=aig then + begin + indexAigSuiv:=index_aig(suivant); + TypSuiv:=aiguillage[indexAigSuiv].modele; + end; + if suivant=0 then TypSuiv:=buttoir; + tabloroute[nroute,id-1].pos:=const_devie; + tabloroute[nroute,id-1].talon:=false; + tabloroute[nroute,id-1].typ:=typsuiv; + + r:=explore_El(actuel,typActuel,Suivant,TypSuiv,nroute,id,ir,depart,fin,ctot); + if affrouteR then affiche('2.Retour explore_el de l''aig '+intToSTR(actuel)+' pos dévié2 :'+intToSTR(r),clCyan); + if r=9 then + begin + result:=r; + exit; + end; + if r=10 then + begin + result:=11; + end; + + result:=7; + exit; + end; + end + else + begin + // aig ou triple en talon + + //déterminer la position + if aiguillage[indexaig].Adevie=prec then tabloroute[nroute,id].pos:=const_devie; + if aiguillage[indexaig].Adroit=prec then tabloroute[nroute,id].pos:=const_droit; + tabloroute[nroute,id].talon:=true; + + if test_reboucle then + begin + result:=6; + if AffRouteR then Affiche('Reboucle sur '+intToSTR(actuel)+' élément déja traité ',clred); + exit; + end; + + suivant:=aiguillage[indexAig].APointe; + c:=aiguillage[indexAig].APointeB; + if (c='S') or (c='D') or (c='P') then typSuiv:=aig else TypSuiv:=det; + if typSuiv=aig then + begin + indexAigSuiv:=index_aig(suivant); + TypSuiv:=aiguillage[indexAigSuiv].modele; + end; + if suivant=0 then TypSuiv:=buttoir; + prec:=Actuel; + typPrec:=TypActuel; + actuel:=Suivant; + TypActuel:=TypSuiv; + end; + end + else + + if (typactuel=tjd) or (typactuel=tjs) then + begin + inc(id); + // faire droit + actuel:=aiguillage[indexAig].Ddroit; + indexAig:=index_aig(actuel); // homologue + + tabloroute[nroute,id-1].pos:=const_droit; + tabloroute[nroute,id-1].talon:=false; + if affRouteR then + Affiche('Faire droit tjd '+intToSTR(actuel),clorange); + suivant:=aiguillage[indexAig].ADroit; + c:=aiguillage[indexAig].AdroitB; + if (c='S') or (c='D') or (c='P') then typSuiv:=aig else TypSuiv:=det; + if typSuiv=aig then + begin + indexAigSuiv:=index_aig(suivant); + TypSuiv:=aiguillage[indexAigSuiv].modele; + end; + if suivant=0 then TypSuiv:=buttoir; + r:=explore_El(actuel,typActuel,Suivant,TypSuiv,nroute,id,ir,depart,fin,ctot); + if affrouteR then affiche('3.Retour explore_el de la tjd '+intToSTR(actuel)+' pos droit :'+intToSTR(r),clCyan); + if r=9 then + begin + result:=r; + exit; + end; + if r=10 then + begin + result:=11; + end; + + // dévié + //if (actuel=77) or (actuel=78) then AffRouteR:=true; + if affRouteR then + Affiche('Faire dévié tjd '+intToSTR(actuel),clorange); + suivant:=aiguillage[indexAig].ADevie; + c:=aiguillage[indexAig].AdevieB; + if (c='S') or (c='D') or (c='P') then typSuiv:=aig else TypSuiv:=det; + if typSuiv=aig then + begin + indexAigSuiv:=index_aig(suivant); + TypSuiv:=aiguillage[indexAigSuiv].modele; + end; + if suivant=0 then TypSuiv:=buttoir; + tabloroute[nroute,id-1].pos:=const_devie; + tabloroute[nroute,id-1].talon:=false; + + r:=explore_El(actuel,typActuel,Suivant,TypSuiv,nroute,id,ir,depart,fin,ctot); + if affrouteR then affiche('4.Retour explore_el de la tjd '+intToSTR(actuel)+' pos dévié :'+intToSTR(r),clCyan); + if r=9 then // demande sortie + begin + result:=r; + exit; + end; + if r=10 then // trouvé détecteur de fin + begin + result:=11; + end; + + result:=8; + exit; + end + else + + if (typActuel=crois) then + begin + indexAig:=index_aig(actuel); + if aiguillage[indexAig].Adroit=prec then begin suivant:=aiguillage[indexAig].Ddroit;c:=aiguillage[indexAig].DdroitB;end; + if aiguillage[indexAig].Adevie=prec then begin suivant:=aiguillage[indexAig].Ddevie;c:=aiguillage[indexAig].DdevieB;end; + if aiguillage[indexAig].Ddevie=prec then begin suivant:=aiguillage[indexAig].Adevie;c:=aiguillage[indexAig].AdevieB;end; + if aiguillage[indexAig].Ddroit=prec then begin suivant:=aiguillage[indexAig].Adroit;c:=aiguillage[indexAig].AdroitB;end; + if (c='S') or (c='D') or (c='P') then TypSuiv:=aig else typSuiv:=det; + if suivant=0 then typSuiv:=buttoir; + prec:=Actuel; + typPrec:=TypActuel; + actuel:=Suivant; + TypActuel:=TypSuiv; + end; + end + else + + if typActuel=det then + begin + // détecteur + tabloroute[nRoute,id].typ:=det; + + suivant:=suivant_alg3(prec,typPrec,actuel,TypActuel,1); + typSuiv:=typegen; + + prec:=Actuel; + typPrec:=TypActuel; + actuel:=Suivant; + TypActuel:=TypSuiv; + end; + inc(id); + inc(it); + until (it>50); + result:=3; + if affRouteR then Affiche('Max itérations',clred); +end; + +procedure supprime_route(route : integer); +var i : integer; +begin + if NbreRoutes+1>Maxroutes then NbreRoutes:=MaxRoutes-1; + for i:=route to NbreRoutes do + tabloRoute[i]:=tabloRoute[i+1]; + dec(NbreRoutes); +end; + +// trouve les routes des détecteurs départ à arrivée, selon le sens +procedure prepare_route(depart,arrivee,sens : integer); +var r,i,j,n,p,nroute,id,Suivant,ctot : integer; + s : string; + TypSuivant : tequipement; + tg,bouclage : boolean; + temp : Tuneroute; +begin + // initialisation de la route à 0 + TraceListe:=false; + for j:=1 to Maxroutes do + for i:=0 to MaxParcours do + begin + tabloRoute[j,i].adresse:=0; + tabloRoute[j,i].typ:=rien; + tabloRoute[j,i].pos:=0; + tabloRoute[j,i].traite:=false; + end; + + raz_route_fenetre; + + // trouver l'élément suivant au détecteur de départ + nroute:=1; + DetDepart:=depart; + detAtrouve:=arrivee; + + zone_tco(1,DetDepart,sens,0,0,12,false); // élément contigu à gauche(5) du détecteur / droite (6) / en bas (8) / haut (7) + // résultat de l'élément suivant dans xcanton et Tel1 + suivant:=Xcanton; + TypSuivant:=Tel1; + + // vérifier si le suivant est une TJD, et vérifier si c'est la bonne adresse de la TJD + if (TypSuivant=aig) or (TypSuivant=tjd) or (typSuivant=Triple) then + begin + i:=index_aig(suivant); + TypSuivant:=aiguillage[i].modele; + end; + if typSuivant=TJD then + begin + if (aiguillage[i].ADroit<>DetDepart) and (aiguillage[i].ADevie<>DetDepart) then + begin + // c'est l'autre + j:=index_aig(aiguillage[i].DDevie); + suivant:=aiguillage[j].Adresse; + end; + end; + + // stocker le départ + tabloroute[nroute,1].adresse:=detdepart; + tabloroute[nroute,1].typ:=det; + tabloroute[nroute,1].pos:=0; + tabloroute[nroute,1].talon:=false; + + id:=2; + + ctot:=0; + r:=explore_el(DetDepart,det,suivant,TypSuivant,nroute,id,0,DetDepart,detAtrouve,ctot); + + {for j:=1 to NbreRoutes do + begin + n:=tabloroute[j,0].adresse; + Affiche('Route '+intToSTR(j)+' n='+intToSTR(n),clwhite); + end; + } + if NbreRoutes>1 then Dec(NbreRoutes); // la dernière route est forcément mauvaise + if TraceListe then Affiche('Trouvé '+intToSTR(NbreRoutes)+' routes',clYellow); + // supprimer les routes inutiles : trop grandes ou qui se rebouclent + j:=1; + repeat + n:=tabloroute[j,0].adresse; + //if traceListe then Affiche('Route '+inttostr(j)+' Nbre='+inttostr(n),clWhite); + tg:=n>MaxParcours; + bouclage:=tabloroute[j,n].adresse<>DetAtrouve; + if tg or bouclage then + begin + {s:=' Supprime route '+intToSTR(j)+' '; + if tg then s:=s+' trop grande ;'; + if bouclage then s:=s+' pas trouvé ;'; + if traceListe then Affiche_suivi(s,clOrange); + } + supprime_route(j); + end + else inc(j); + until j>NbreRoutes; + + // trier les routes de l plus petite à la plus grande + tg:=true; + while tg do + begin + tg:=false; + for i:=1 to NbreRoutes-1 do + begin + //for j:=i+1 to NbreRoutes do + n:=tabloroute[i,0].adresse; + if n>tabloroute[i+1,0].adresse then + begin + temp:=tabloroute[i]; + tabloroute[i]:=tabloroute[i+1]; + tabloroute[i+1]:=temp; + tg:=true; + end; + end; + end; + + if traceListe then + for j:=1 to NbreRoutes do + begin + n:=tabloroute[j,0].adresse; + Affiche('Route '+intToSTR(j)+' ---------------n='+intToSTR(n),clwhite); + for i:=1 to n do + begin + s:=intToSTR(tabloroute[j,i].adresse)+' '+BTypeToChaine(tabloroute[j,i].typ)+' '; + p:=tabloRoute[j,i].pos; + case p of + const_droit : s:=s+'droit'; + const_devie : s:=s+'dev'; + 0 : s:=s+'talon'; + else s:=s+intToSTR(p); + end; + if tabloroute[j,i].talon then s:=s+' (talon)'; + Affiche(s,clyellow); + end; + end; + if traceListe then Affiche('il y a '+intToSTR(NbreRoutes)+' routes',clYellow); + +end; + +function route_to_string(tablo : tUneRoute) : string; +var i,p,n : integer; + typ : tequipement; + s : string; +begin + s:=''; + n:=tablo[0].adresse; + if n<>0 then + begin + s:=intToSTR(tablo[1].adresse)+'->'; // premier détecteur + for i:=1 to n do + begin + p:=tablo[i].pos; + typ:=tablo[i].typ; + if ((typ=aig) or (typ=tjd) or (typ=tjs) or (typ=triple)) and (not(tablo[i].talon)) then + begin + s:=s+intToSTR(tablo[i].adresse)+' '; + case p of + const_droit : s:=s+'droit'; + const_devie : s:=s+'dev'; + else s:=s+intToSTR(p); + end; + s:=s+'->'; + end; + end; + s:=s+intToSTR(tablo[n].adresse); // dernier détecteur + end; + result:=s; +end; + +procedure TFormPrinc.Button3Click(Sender: TObject); +begin +{ aiguillage[index_aig(30)].position:=const_devie; + aiguillage[index_aig(29)].position:=const_devie; + aiguillage[index_aig(10)].position:=const_droit; + aiguillage[index_aig(11)].position:=const_droit; + aiguillage[index_aig(18)].position:=const_devie; + aiguillage[index_aig(19)].position:=const_devie; + //debugTCO:=true; + } + Zone_TCO(1,519,517,1,4,1,true); + //formDebug.Show; +end; + + +procedure Affiche_routes_brut; +var i,j,n,p : integer; + s : string; + typ : tequipement; +begin +// Affiche_routes; + for i:=1 to Ntrains do + begin + with trains[i] do + begin + n:=route[0].adresse; + Affiche('Route du train '+Nom_Train+' ---------------n='+intToSTR(n),clwhite); + for j:=1 to n do + begin + s:=inttoSTR(j)+': '+intToSTR(route[j].adresse)+' '+BTypeToChaine(route[j].typ)+' '; + p:=Route[j].pos; + typ:=Route[j].typ; + if (typ=aig) or (typ=tjd) or (typ=tjs) or (typ=triple) then + begin + case p of + const_droit : s:=s+'droit'; + const_devie : s:=s+'dev'; + 0 : s:=s+'talon'; + else s:=s+intToSTR(p); + end; + if route[j].talon then s:=s+' (en talon)'; + end; + if route[j].traite then s:=s+' Traité' else s:=s+' Non traité'; + Affiche(s,clyellow); + end; + end; + end; +end; + +procedure TFormPrinc.Routes1Click(Sender: TObject); + begin + formRouteTrain.show; +end; + +procedure TFormPrinc.Codificationdestrains1Click(Sender: TObject); +var i : integer; +begin + for i:=1 to nTrains do + begin + Affiche('Train '+intToSTR(i)+' @='+intToSTR(trains[i].adresse)+' '+trains[i].nom_train+ + ' Roulage='+intToSTR(trains[i].roulage)+ + ' Vitesse='+intToSTR(trains[i].vitesse)+ + ' DernierDet='+intToSTR(trains[i].dernierDet) + ,clyellow); + // ' DetDepart='+intToSTR(trains[i].Det_depart)+' DetFin='+intToSTR(trains[i].Det_fin),clYellow); + end; +end; + +procedure TFormPrinc.Afficheroutespartrain1Click(Sender: TObject); +begin + Affiche_routes_brut; end; end. + diff --git a/UnitRoute.dfm b/UnitRoute.dfm new file mode 100644 index 0000000..2db6e73 --- /dev/null +++ b/UnitRoute.dfm @@ -0,0 +1,133 @@ +object FormRoute: TFormRoute + Left = 201 + Top = 182 + BorderStyle = bsDialog + Caption = 'Route' + ClientHeight = 257 + ClientWidth = 634 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + OldCreateOrder = False + OnActivate = FormActivate + OnClose = FormClose + OnCreate = FormCreate + PixelsPerInch = 96 + TextHeight = 13 + object LabelInfo: TLabel + Left = 16 + Top = 16 + Width = 324 + Height = 13 + Caption = + 'Cliquer sur une route pour la visualiser sur le TCO et l'#39'affecte' + + 'r au train' + end + object LabelNombre: TLabel + Left = 19 + Top = 192 + Width = 29 + Height = 13 + Caption = 'Route' + end + object ImageTrainR: TImage + Left = 376 + Top = 8 + Width = 241 + Height = 33 + ParentShowHint = False + ShowHint = False + end + object ListBoxRoutes: TListBox + Left = 16 + Top = 80 + Width = 609 + Height = 105 + Hint = 'S'#233'lectionne une route pour l'#39'affecter au train courant' + Color = clBlack + Font.Charset = DEFAULT_CHARSET + Font.Color = clYellow + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ItemHeight = 13 + ParentFont = False + ParentShowHint = False + ShowHint = True + TabOrder = 0 + OnKeyDown = ListBoxRoutesKeyDown + OnMouseDown = ListBoxRoutesMouseDown + end + object ButtonEfface: TButton + Left = 424 + Top = 216 + Width = 97 + Height = 33 + Hint = 'Efface la route du tco' + Caption = 'Efface route du TCO' + ParentShowHint = False + ShowHint = True + TabOrder = 1 + WordWrap = True + OnClick = ButtonEffaceClick + end + object ButtonQuitte: TButton + Left = 16 + Top = 216 + Width = 89 + Height = 33 + Caption = 'Quitter' + TabOrder = 2 + OnClick = ButtonQuitteClick + end + object ButtonDetail: TButton + Left = 320 + Top = 216 + Width = 97 + Height = 33 + Hint = 'D'#233'tail route' + Caption = 'D'#233'tail route' + ParentShowHint = False + ShowHint = True + TabOrder = 3 + OnClick = ButtonDetailClick + end + object ButtonRAZ: TButton + Left = 528 + Top = 216 + Width = 97 + Height = 33 + Hint = 'Annule toutes les routes pour ce train' + Caption = 'D'#233'valider routes' + ParentShowHint = False + ShowHint = True + TabOrder = 4 + OnClick = ButtonRAZClick + end + object ComboBoxTrains: TComboBox + Left = 16 + Top = 48 + Width = 601 + Height = 21 + Style = csDropDownList + ItemHeight = 13 + TabOrder = 5 + Visible = False + end + object ButtonFenPil: TButton + Left = 232 + Top = 216 + Width = 83 + Height = 33 + Hint = 'Ouvre la fen'#234'tre de pilotage des trains' + Caption = 'Fen'#234'tre de pilotage' + ParentShowHint = False + ShowHint = True + TabOrder = 6 + WordWrap = True + OnClick = ButtonFenPilClick + end +end diff --git a/UnitRoute.pas b/UnitRoute.pas new file mode 100644 index 0000000..55a3c58 --- /dev/null +++ b/UnitRoute.pas @@ -0,0 +1,421 @@ +unit UnitRoute; + +// choix des routes pour un train + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, ComCtrls, ShellCtrls, StdCtrls, ExtCtrls , UnitPrinc; + +type + TFormRoute = class(TForm) + ListBoxRoutes: TListBox; + ButtonEfface: TButton; + LabelInfo: TLabel; + ButtonQuitte: TButton; + LabelNombre: TLabel; + ButtonDetail: TButton; + ButtonRAZ: TButton; + ImageTrainR: TImage; + ComboBoxTrains: TComboBox; + ButtonFenPil: TButton; + procedure FormActivate(Sender: TObject); + procedure ListBoxRoutesMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure ButtonEffaceClick(Sender: TObject); + procedure ButtonQuitteClick(Sender: TObject); + procedure ButtonDetailClick(Sender: TObject); + procedure ButtonRAZClick(Sender: TObject); + procedure ListBoxRoutesKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure FormCreate(Sender: TObject); + procedure FormClose(Sender: TObject; var Action: TCloseAction); + procedure ButtonFenPilClick(Sender: TObject); + private + { Déclarations privées } + public + { Déclarations publiques } + end; + +var + FormRoute: TFormRoute; + parcoursDet : TUneroute; + AncLigneRoute,LigneRoute,IdTrainCourant : integer; + +procedure raz_route_fenetre; +procedure raz_toutes_routes; +procedure efface_route_tco; +function affiche_route_tco : boolean; +procedure Efface_Affiche_route; + +implementation + +uses UnitDebug,unitTCO,UnitConfig, UnitRouteTrains; + +{$R *.dfm} + +// efface la route parcoursDet[] +procedure efface_route_tco; +var n,det1,det2,i,indexAig : integer; + t : tequipement; +begin + n:=parcoursdet[0].adresse; + det1:=parcoursdet[1].adresse; + for i:=2 to n do + begin + det2:=parcoursdet[i].adresse; + t:=ParcoursDet[i].typ; + if (t=aig) or (t=tjd) or (t=triple) then + begin + indexaig:=index_aig(ParcoursDet[i].adresse); + aiguillage[indexAig].AncPos:=aiguillage[indexAig].position; // sauve position + aiguillage[indexAig].position:=parcoursDet[i].pos; + end; + if t=det then + begin + zone_tco(1,det1,det2,1,0,0,true); // mode "aiguillages mis" + det1:=det2; + end; + end; + // remettre les aiguillages + for i:=2 to n do + begin + t:=ParcoursDet[i].typ; + if (t=aig) or (t=tjd) or (t=triple) then + begin + indexaig:=index_aig(ParcoursDet[i].adresse); + aiguillage[indexAig].Position:=aiguillage[indexAig].AncPos; // restitue position + end; + end; +end; + +// efface la fenetre et la route du tco +procedure raz_route_fenetre; +begin + efface_route_tco; + + formRoute.ListBoxRoutes.Clear; + ligneroute:=-1; +end; + +// Affiche sans effacer l'ancienne, la route du TCO du tableau ParcoursDet[] +// détruit l'index du train dans le canton !!!! zizi +function Affiche_route_TCO : boolean ; +var i,n,det1,det2,indexAig : integer; + t :tequipement; + ok : boolean; +begin + //exit; + n:=ParcoursDet[0].adresse; + ok:=true; + det1:=parcoursDet[1].adresse; + for i:=2 to n do + begin + t:=ParcoursDet[i].typ; + if (t=aig) or (t=tjd) or (t=triple) then + begin + indexaig:=index_aig(ParcoursDet[i].adresse); + aiguillage[indexAig].AncPos:=aiguillage[IndexAig].position; // sauvegarder position + aiguillage[indexAig].position:=ParcoursDet[i].pos; // forcer la position de l'aiguillage sue le parcours + end; // car on utilise TRUE dans la fonction zone_tco + if t=det then + begin + det2:=ParcoursDet[i].adresse; + ok:=zone_tco(1,det1,det2,1,0,1,true) and ok; + det1:=det2; + end; + end; + + // remettre la position d'origine des aiguillages + for i:=1 to n do + begin + t:=ParcoursDet[i].typ; + if (t=aig) or (t=tjd) or (t=triple) then + begin + indexaig:=index_aig(ParcoursDet[i].adresse); + aiguillage[indexAig].Position:=aiguillage[IndexAig].AncPos; // remettre position + end; + end; + result:=ok; +end; + +// Efface, fabrique le tableau ParcoursDet[] depuis TabloRoute[id] affiche la route dans le TCO contenue dans ParcoursDet[] +procedure Efface_Affiche_route; +var n,id : integer; + ok : boolean; + s : string; +begin + AncLigneRoute:=LigneRoute; + + if LigneRoute<0 then exit; + id:=LigneRoute+1; + formRoute.ButtonDetail.caption:='Détail route '+intToSTR(id); + formRoute.ButtonEfface.caption:='Efface route '+intToSTR(id)+' du TCO'; + + efface_route_tco; + + // fabriquer le tableau parcoursDet[] depuis tabloRoute[] + parcoursDet:=tabloRoute[id]; + n:=ParcoursDet[0].adresse; + + // Affiche les routes + ok:=Affiche_route_tco; + + s:='Route '+intToSTR(id)+'/'+intToSTR(NbreRoutes)+' : '+intToSTR(n)+' éléments'; + //if not(ok) then s:=s+' - Route pas affichable car des éléments ne sont pas au TCO'; + formRoute.LabelNombre.Caption:=s; +end; + + +procedure clic_route(r : integer); +var idTrain : integer; +begin + LigneRoute:=r; + // copier la route au train + if (idcantonroute<1) or (ligneroute<0) then exit; + idTrain:=Index_Train_adresse(canton[idCantonRoute].AdrTrainRoute); + //IdTrain:=canton[idcantonRoute].indexTrain; + if idtrain<1 then + begin + // le train a été déplacé + affiche('Anomalie 50',clred); + exit; + end; + + trains[idTrain].route:=tabloroute[LigneRoute+1]; + + formRoute.ButtonFenPil.enabled:=trains[IdTrain].route[0].adresse<>0; + + Efface_affiche_route; + +end; + + +// affiche les routes du train courant +procedure maj_fenetre; +var l,pluslongue,n,j,pixelLength : integer; + s,chaineLongue : string; +begin + if (cantonorg=0) or (cantonDest=0) then FormRoute.caption:='Pas de canton depart/arrivée' else + formRoute.caption:='Liste des routes trouvées du train '+canton[idcantonRoute].NomTrain+' pour aller de '+intToSTR(DetDepart)+' (canton '+intToSTR(cantonOrg)+ + ') à '+intToSTR(DetaTrouve)+' (canton '+intToSTR(cantonDest)+')'; + plusLongue:=0; + + formRoute.ButtonDetail.caption:='Détail route '; + formRoute.ButtonEfface.caption:='Efface route '; + + if idcantonRoute<>0 then formRoute.ListBoxRoutes.Hint:='Sélectionne une route pour l''affecter au train '+canton[idcantonRoute].NomTrain; + formRoute.listBoxRoutes.Clear; + + // trouver le canton dest d'après le canton origine cliqué + if IdCantonClic=0 then exit; + idCantonRoute:=index_canton_numero(canton[idCantonClic].NumcantonOrg); + + if idcantonroute<>0 then + begin + IdTrainCourant:=canton[idcantonRoute].indexTrain; + if idTrainCourant>9000 then + begin + Affiche('Anomalie 626 ',clred); + messageBeep(Mb_iconError); + exit; + end; + end + else idtraincourant:=0; + + if NbreRoutes>0 then FormRoute.labelInfo.Caption:='Cliquer sur une route pour la visualiser sur le TCO et l''affecter au train'; + + for j:=1 to NbreRoutes do + begin + n:=tabloroute[j,0].adresse; + s:=intToSTR(j)+'. '; + s:=s+route_to_string(tabloroute[j]); + l:=Length(s); + if l>pluslongue then + begin + chainelongue:=s; + pluslongue:=l; + end; + + FormRoute.listBoxRoutes.Items.Add(s); + end; + + PixelLength:=FormRoute.ListboxRoutes.Canvas.TextWidth(chaineLongue)+30; + // positionne une scrollbar dans la listbox - pour l'enlever, envoyer 0 dans pixelLength + SendMessage(FormRoute.ListBoxRoutes.Handle,LB_SETHORIZONTALEXTENT,PixelLength,0); + + // icone train + if idcantonRoute<>0 then Maj_icone_train(FormRoute.ImageTrainR,idTrainCourant); + + formRoute.ButtonFenPil.enabled:=trains[IdTrainCourant].route[0].adresse<>0; + + if NbreRoutes=1 then clic_route(0); +end; + +procedure TFormRoute.FormActivate(Sender: TObject); +begin + maj_fenetre; +end; + +procedure TFormRoute.ListBoxRoutesMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + LigneRoute:=listBoxRoutes.Itemindex; + clic_route(ligneRoute); +end; + +procedure TFormRoute.ButtonEffaceClick(Sender: TObject); +begin + efface_route_tco; +end; + +procedure TFormRoute.ButtonQuitteClick(Sender: TObject); +begin + close; +end; + + +procedure TFormRoute.ButtonDetailClick(Sender: TObject); +var i,j,n,p : integer; + s : string; + typ : tequipement; +begin + if ligneroute<0 then exit; + with formprinc do + begin + windowState:=wsNormal; //Maximized; + show; + BringToFront; + end; + + j:=ligneroute+1; + n:=tabloroute[j,0].adresse; + Affiche('Route '+intToSTR(j)+' ---------------n='+intToSTR(n),clwhite); + for i:=1 to n do + begin + s:=intToSTR(tabloroute[j,i].adresse)+' '+BTypeToChaine(tabloroute[j,i].typ)+' '; + p:=tabloRoute[j,i].pos; + typ:=tabloRoute[j,i].typ; + if (typ=aig) or (typ=tjd) or (typ=tjs) or (typ=triple) then + begin + case p of + const_droit : s:=s+'droit'; + const_devie : s:=s+'dev'; + 0 : s:=s+'talon'; + else s:=s+intToSTR(p); + end; + if tabloroute[j,i].talon then s:=s+' (en talon)'; + end; + Affiche(s,clyellow); + end; +end; + +procedure RAZ_toutes_routes; +var i,idt : integer; +begin + efface_route_tco; + raz_route_fenetre; + + // raz état des boutons des cantons org et dest + if cantonOrg>0 then canton[cantonOrg].bouton:=0; + if cantonDest>0 then canton[cantonDest].bouton:=0; + + i:=index_canton_numero(cantonOrg); + if i>0 then + begin + canton[i].bouton:=0; + dessin_canton(i,0); // remet le bouton jaune du canton org + // raz la route du train + idt:=canton[i].indexTrain; + if idt>0 then + begin + trains[idt].route[0].adresse:=0; + end; + end; + + i:=index_canton_numero(cantonDest); + if i>0 then + begin + canton[i].bouton:=0; + dessin_canton(i,0); // remet le bouton jaune du canton dest + end; + + // efface icone train + with formRoute do + begin + ImageTrainR.Canvas.Rectangle(0,0,ImageTrainr.Width,ImageTrainr.Height); + labelNombre.caption:=''; + end; + + formRoute.ButtonFenPil.enabled:=false; + + formRoute.caption:='Routes'; + + NbreRoutes:=0; + detDepart:=0; + detAtrouve:=0; + cantonOrg:=0; + cantonDest:=0; +end; + +procedure TFormRoute.ButtonRAZClick(Sender: TObject); +begin + raz_toutes_routes; + close; +end; + +procedure TFormRoute.ListBoxRoutesKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if (ord(Key)=VK_UP) and (ligneroute>0) then + begin + dec(ligneRoute); + efface_affiche_route; + end; + if (ord(Key)=VK_DOWN) and (ligneroute+1nCantons) then exit; + IdTrain:=canton[idcantonRoute].indexTrain; + if idtrain>0 then + begin + caption:='Routes'; + if trains[idTrain].route[0].adresse<>0 then raz_route_fenetre; + // efface icone train + with formRoute do + begin + ImageTrainR.Canvas.Rectangle(0,0,ImageTrainr.Width,ImageTrainr.Height); + labelNombre.caption:=''; + end; + + end; + efface_route_tco; +end; + +procedure TFormRoute.ButtonFenPilClick(Sender: TObject); +begin + indexTrainFR:=canton[idcantonRoute].indexTrain; + FormRouteTrain.show; + close; +end; + +end. diff --git a/UnitRouteTrains.dfm b/UnitRouteTrains.dfm new file mode 100644 index 0000000..b5e1e18 --- /dev/null +++ b/UnitRouteTrains.dfm @@ -0,0 +1,121 @@ +object FormRouteTrain: TFormRouteTrain + Left = 518 + Top = 183 + BorderStyle = bsDialog + Caption = 'Liste des routes affect'#233'es aux trains' + ClientHeight = 156 + ClientWidth = 580 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + OldCreateOrder = False + OnActivate = FormActivate + OnClose = FormClose + PixelsPerInch = 96 + TextHeight = 13 + object ImageTrainR: TImage + Left = 328 + Top = 8 + Width = 241 + Height = 33 + ParentShowHint = False + ShowHint = False + end + object LabelRoute: TLabel + Left = 16 + Top = 48 + Width = 71 + Height = 13 + Caption = 'Route affect'#233'e' + end + object ComboBoxTrains: TComboBox + Left = 16 + Top = 16 + Width = 225 + Height = 21 + Style = csDropDownList + ItemHeight = 13 + TabOrder = 0 + OnChange = ComboBoxTrainsChange + end + object ButtonQuitte: TButton + Left = 8 + Top = 118 + Width = 89 + Height = 33 + Caption = 'Quitter' + TabOrder = 1 + OnClick = ButtonQuitteClick + end + object RichEditRoute: TRichEdit + Left = 8 + Top = 64 + Width = 569 + Height = 49 + Color = clNone + Font.Charset = DEFAULT_CHARSET + Font.Color = clYellow + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentFont = False + ReadOnly = True + TabOrder = 2 + OnMouseDown = RichEditRouteMouseDown + end + object ButtonEfface: TButton + Left = 480 + Top = 120 + Width = 97 + Height = 33 + Hint = 'Efface le trac'#233' du train s'#233'lectionn'#233' du TCO' + Caption = 'Efface route du TCO' + ParentShowHint = False + ShowHint = True + TabOrder = 3 + WordWrap = True + OnClick = ButtonEffaceClick + end + object ButtonSupprime: TButton + Left = 371 + Top = 120 + Width = 97 + Height = 33 + Hint = 'Supprime la route du train s'#233'lectionn'#233 + Caption = 'Supprimer la route du train' + ParentShowHint = False + ShowHint = True + TabOrder = 4 + WordWrap = True + OnClick = ButtonSupprimeClick + end + object ButtonRouler1Tr: TButton + Left = 256 + Top = 120 + Width = 107 + Height = 33 + Hint = 'Roule le train s'#233'lectionn'#233' s'#39'il dispose d'#39'une route' + Caption = 'Rouler le train' + ParentShowHint = False + ShowHint = True + TabOrder = 5 + WordWrap = True + OnClick = ButtonRouler1TrClick + end + object ButtonRoulerTsTrains: TButton + Left = 168 + Top = 120 + Width = 75 + Height = 33 + Hint = 'Roule tous les trains qui ont une route affect'#233'e' + Caption = 'Rouler tous les trains' + ParentShowHint = False + ShowHint = True + TabOrder = 6 + WordWrap = True + OnClick = ButtonRoulerTsTrainsClick + end +end diff --git a/UnitRouteTrains.pas b/UnitRouteTrains.pas new file mode 100644 index 0000000..13c0386 --- /dev/null +++ b/UnitRouteTrains.pas @@ -0,0 +1,472 @@ +unit UnitRouteTrains; + +// choix de la route pour tous les trains + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, ExtCtrls, ComCtrls; + +type + TFormRouteTrain = class(TForm) + ComboBoxTrains: TComboBox; + ImageTrainR: TImage; + ButtonQuitte: TButton; + RichEditRoute: TRichEdit; + LabelRoute: TLabel; + ButtonEfface: TButton; + ButtonSupprime: TButton; + ButtonRouler1Tr: TButton; + ButtonRoulerTsTrains: TButton; + procedure FormActivate(Sender: TObject); + procedure ButtonQuitteClick(Sender: TObject); + procedure ComboBoxTrainsChange(Sender: TObject); + procedure RichEditRouteMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure ButtonEffaceClick(Sender: TObject); + procedure FormClose(Sender: TObject; var Action: TCloseAction); + procedure ButtonSupprimeClick(Sender: TObject); + procedure ButtonRouler1TrClick(Sender: TObject); + procedure ButtonRoulerTsTrainsClick(Sender: TObject); + private + { Déclarations privées } + public + { Déclarations publiques } + end; + +var + FormRouteTrain: TFormRouteTrain; + +function aig_canton(idTrain,detect : integer) : integer; +function demarre_index_train(indexTrain : integer) : boolean; + +implementation + +uses unitprinc,UnitConfig,unitTCO,UnitHorloge,unitFicheHoraire,UnitDebug,UnitRoute; + +{$R *.dfm} + +// démarre un train si le signal n'est pas au rouge +// appelé par gestion des horaires dans le timer ou bouton rouler 1 train ou rouler tous les trains +function demarre_index_train(indexTrain : integer) : boolean; +var i,n,det1,el2,vitesse,AdrTrain,idcanton,voie1,voie2,indexSig1,indexSig2,AdrSig1,AdrSig2,AdrSig, + detect,indexSig : integer; + tel2 : tequipement; + trouve : boolean; + Train,s : string; + +begin + formprinc.SBMarcheArretLoco.Visible:=true; + //Affiche('demarre_index_Train',clWhite); + // 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; + + + detect:=trains[indexTrain].dernierdet; + index_signal_det(detect,voie1,indexSig1,voie2,indexSig2); + AdrSig1:=0;AdrSig2:=0; + if indexSig1<>0 then AdrSig1:=signaux[indexSig1].adresse; + if indexSig2<>0 then AdrSig2:=signaux[indexSig2].adresse; + + // si le détecteur sur le train au départ dispose d'un signal + if (AdrSig1<>0) or (AdrSig2<>0) then + begin + // trouver le premier détecteur de la route et son suivant non traité pour trouver le signal dans le bon sens + n:=trains[indexTrain].route[0].adresse; + i:=1;det1:=0;el2:=0;trouve:=false; + with trains[indexTrain] do + begin + repeat + if route[i].typ=det then + begin + det1:=route[i].adresse; + el2:=route[i+1].adresse;tel2:=route[i+1].typ; + trouve:=true + end; + inc(i); + until trouve or (i>n); + end; + + //trouve le signal dans le bon sens + IndexSig:=0; + if AdrSig1<>0 then + begin + if (signaux[indexSig1].Adr_el_suiv1=el2) and (signaux[indexSig1].Btype_suiv1=tel2) then IndexSig:=IndexSig1; + end; + if adrSig2<>0 then + begin + if (signaux[indexSig2].Adr_el_suiv1=el2) and (signaux[indexSig2].Btype_suiv1=tel2) then IndexSig:=IndexSig2; + end; + + AdrSig:=signaux[indexSig].adresse; + if traceliste then Affiche('Le signal dans le bon sens est '+intToSTR(AdrSig)+' '+chaine_signal(AdrSig),clOrange); + if signal_rouge(AdrSig) then + begin + s:='Le train '+train+' est arreté au signal '+intToSTR(signaux[IndexSig].adresse); + affiche(s,clyellow); + trains[indexTrain].roulage:=1; + exit; + end; + end; + + vitesse:=trains[indexTrain].VitNominale; + if roulage then + begin + if trains[indexTrain].inverse then vitesse:=-vitesse; + Idcanton:=trains[indexTrain].canton; + + //init_route_canton(idcanton,Indextrain,true); + + 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(Detect); + Affiche(s,clYellow); + AfficheDebug(s,clyellow); + trains[indexTrain].roulage:=2; + if traceListe then AfficheDebug(s,clyellow); + + trains[indextrain].TempoDemarre:=trains[indexTrain].TempsDemarreSig; +end; + + +procedure maj_infos(idtrain : integer); +var i : integer; + s : string; +begin + formRouteTrain.comboBoxTrains.Clear; + + for i:=1 to NTrains do + begin + s:=trains[i].nom_train; + if trains[i].route[0].adresse<>0 then s:=s+' [route affectée]'; + formRouteTrain.comboBoxTrains.items.add(s); + end; + + formRouteTrain.comboBoxTrains.ItemIndex:=indexTrainFR-1; + + Maj_icone_train(FormRouteTrain.ImageTrainR,idTrain); + with formRouteTrain do + begin + RicheditRoute.Clear; + RichEditRoute.Lines.Add(route_to_string(trains[idTrain].route)); + if trains[idtrain].route[0].adresse<>0 then + begin + labelroute.caption:='Route affectée au train '+trains[idtrain].nom_train; + ButtonRouler1tr.caption:='Rouler le train '+trains[idtrain].nom_train; + ButtonRouler1tr.enabled:=true; + end + else + begin + labelroute.caption:='Pas de route affectée au train '+trains[idtrain].nom_train; + ButtonRouler1tr.caption:=' '; + ButtonRouler1tr.enabled:=false; + end; + end; +end; + +procedure TFormRouteTrain.FormActivate(Sender: TObject); +begin + maj_infos(indexTrainFR); + + if ntrains>0 then Maj_icone_train(FormRouteTrain.ImageTrainR,indexTrainFR); +end; + +procedure TFormRouteTrain.ButtonQuitteClick(Sender: TObject); +begin + close; +end; + +procedure TFormRouteTrain.ComboBoxTrainsChange(Sender: TObject); +begin + indexTrainFR:=ComboBoxTrains.ItemIndex+1; + efface_route_tco; + maj_infos(indexTrainFR); +end; + +procedure TFormRouteTrain.RichEditRouteMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + // si le train de la route est en roulage, ne pas afficher la route car + // sinon les index des trains passent à 0 dans les cantons par la fonction zone_tco + if trains[indexTrainFR].roulage=0 then affiche_route_tco; +end; + +procedure TFormRouteTrain.ButtonEffaceClick(Sender: TObject); +begin + efface_route_tco; +end; + +procedure TFormRouteTrain.FormClose(Sender: TObject; + var Action: TCloseAction); +begin + efface_route_tco; +end; + +procedure TFormRouteTrain.ButtonSupprimeClick(Sender: TObject); +var r : integer; +begin + indexTrainFR:=ComboBoxTrains.ItemIndex+1; + if indexTrainFR<1 then exit; + if trains[indexTrainfr].route[0].adresse<1 then exit; + + r:=MessageDlg('Voulez-vous supprimer cette route du train '+Trains[indexTrainFR].nom_train+' ?' + ,mtConfirmation,[mbNo,mbYes],0) ; + if r=mrNo then exit; + + efface_route_tco; + + supprime_route_train(indexTrainFR); + maj_infos(indexTrainFR); +end; + +// Réserve les éléments s'ils ne sont pas déja réservés et positionne les aiguillages +// jusqu'au signal suivant (soit 1 canton) +// en entrée : index du train ; detect=détecteur à partir duquel faire la réservation et le positionnement des aiguillages +// en sortie : si erreur : -1 ou adresse du train qui a réservé le canton +// phase 0 : si le détecteur detect est en fin de route, alors on active l'arret du train +// phase 1 : tester si éléments réservés par train tiers jusqu'au signal suivant. Si oui, sortir. +// phase 2 : positionner les aiguillages +// phase 3 : réserver les aiguillages +function aig_canton(idTrain,detect : integer) : integer; +var AdrSig,n,i,ideb,iFin,AdrTrain,etat,pointeur,voie1,voie2,indexSig1,indexSig2, + Trainexistant,adr,pos,index,Ncanton,icanton : integer; + typ: tequipement; + trainTiers,SigBonSens : boolean; + s : string; +begin + //traceliste:=true; + result:=0; + + If traceliste then + begin + if detecteur[detect].Etat then etat:=1 else etat:=0; + affiche('Aig_canton Train id='+intToSTR(idtrain)+' '+intToSTR(detect)+' à '+intToSTR(etat)+'---------------Phase 1',clWhite); + end; + AdrTrain:=trains[idTrain].adresse; + + pointeur:=0; + n:=trains[idTrain].route[0].adresse; + repeat + inc(pointeur); + until (trains[idTrain].route[pointeur].traite=false) or (pointeur+1>=n); + + i:=pointeur-1; + if i=0 then i:=1; // on commence à 1 + + if traceListe then + begin + Affiche('AC train @'+intToSTR(AdrTrain)+'Detecteur='+intToSTR(detect)+' Pointeur'+intToSTR(pointeur)+' ->'+intToSTR(trains[idTrain].route[i].adresse),clOrange); + if i>=n then + begin + affiche('La route a été complètement traitée (réservation)',clOrange); + result:=0; + end; + end; + + if (detect=trains[idTrain].route[n].adresse) and (trains[idTrain].route[n].typ=det) then + begin + // route traitée , arrêter le train + trains[idTrain].TempoArretCour:=0; + trains[idTrain].TempoArret:=50; + end; + + traintiers:=false; + icanton:=0; + ncanton:=0; + TrainExistant:=0; + ideb:=i; + AdrSig:=0; + SigBonSens:=false; + if traceliste then Affiche('Aiguillages',clOrange); + with trains[idtrain] do + begin + // boucle de vérification de réservation des aiguillages par un train tiers, jusqu'à rencontrer n cantons + repeat + typ:=route[i].typ; + adr:=route[i].adresse; + typ:=route[i].typ; + if (typ=Aig) or (typ=tjd) or (typ=tjs) or (typ=crois) or (typ=triple) then + begin + if TraceListe then Affiche(intToSTR(adr)+' ',clOrange); + // vérifier si l'aiguillage est libre + TrainExistant:=Aiguillage[index_aig(adr)].AdrTrain; + if (trainexistant<>AdrTrain) and (TrainExistant<>0) then + begin + result:=TrainExistant; + trains[idtrain].roulage:=1; + trainTiers:=true; + if traceListe then Affiche('AC-Aiguillage '+intToSTR(adr)+' réservé par autre train : @='+intToSTR(result),clyellow); + end; + end; + if (typ=det) then + begin + TrainExistant:=detecteur[adr].AdrTrainRes; + if (TrainExistant<>AdrTrain) and (trainExistant<>0) then + begin + result:=TrainExistant; + trains[idtrain].roulage:=1; // le roulage est arrêté + traintiers:=true; + if traceListe then Affiche('AC-Détecteur '+intToSTR(adr)+' réservé par autre train : @='+intToSTR(result),clyellow); + //exit; + end; + // si détecteur comporte signal + index_signal_det(adr,voie1,indexSig1,voie2,indexSig2); + if indexSig1<>0 then + begin + AdrSig:=0; + // si le signal est dans le bon sens + if (i+1<=n) then // si on arrive pas en bout de route + begin + if (signaux[indexSig1].Adr_el_suiv1=route[i+1].adresse) then + begin + AdrSig:=signaux[indexSig1].adresse; + if TraceListe then Affiche('AC-Trouvé signal '+intToSTR(AdrSig)+' dans bon sens',clYellow); + inc(nCanton); + icanton:=i; + SigBonSens:=true; + end + else + begin + if TraceListe then Affiche('AC-Trouvé signal '+intToSTR(signaux[indexSig1].adresse)+' dans mauvais sens',clYellow); + end; + + if indexSig2<>0 then + begin + if (signaux[indexSig2].Adr_el_suiv1=route[i+1].adresse) then + begin + AdrSig:=signaux[indexSig2].adresse; + if TraceListe then Affiche('AC-Trouvé signal '+intToSTR(AdrSig)+' dans bon sens',clYellow); + inc(nCanton); + icanton:=i; + SigBonSens:=true; + end + else + begin + if TraceListe then Affiche('AC-Trouvé signal '+intToSTR(signaux[indexSig2].adresse)+' dans mauvais sens',clYellow); + end; + end; + end; + end; + end; + inc(i); + until (i>n) or (SigBonSens and (nCanton=nCantonsRes+1)) or (trainTiers); + + If traceliste then affiche('Phase 2-3',clWhite); + // phases 2 et 3 + trains[idtrain].roulage:=2; // roulage effectif + result:=AdrTrain; + if not(traintiers) then iFin:=i-1 else iFin:=icanton; + AdrTrain:=trains[idTrain].adresse; + + // balayage du (des) cantons libres + if traceListe then Affiche('Balayage de '+intToSTR(ideb)+' à '+intToSTR(ifin)+' pour positionner et réserver aiguillages',clYellow); + for i:=iDeb to iFin do + begin + route[i].traite:=true; + typ:=route[i].typ; + adr:=route[i].adresse; + if (typ=aig) or (typ=triple) or (typ=tjs) or (typ=tjd) or (typ=crois) then + begin + pos:=route[i].pos; + index:=index_aig(adr); + + if (typ=aig) or (typ=triple) or (typ=tjs) or (typ=tjd) then + begin + pilote_acc(adr,pos,AdrTrain); // pilote l'aig si il est reservé par le train ou non réservé + + s:='AC- Pilote aiguillage '+intToSTR(adr)+'='+intToSTR(pos); + case pos of + const_devie : s:=s+' (dévié)'; + const_droit : s:=s+' (droit)'; + else + s:=s+' non positionné'; + end; + if traceListe then Affiche(s,clWhite); + if portCommOuvert or parSocketLenz or CDM_connecte then sleep(Tempo_Aig); + end; + // réservation + aiguillage[index].adrTrain:=AdrTrain; + end; + if typ=det then detecteur[adr].AdrTrainRes:=adrTrain; + Texte_aig_fond(adr); + end; + end; + maj_signaux(false); +end; + +// bouton rouler 1 train +procedure TFormRouteTrain.ButtonRouler1TrClick(Sender: TObject); +var demarre : boolean; +begin + if (indexTrainFR<1) then exit; + roulage:=true; + efface_route_tco; + maj_signaux(true); + + // positionner les aiguillages de la route + // si le train est doté d'une route + if trains[indexTrainFR].route[0].adresse>0 then + begin + aig_canton(indexTrainFR,trains[indexTrainFR].route[1].adresse); + demarre:=demarre_index_train(indexTrainFR); // met la mémoire de roulage du train à 1 + end; + close; +end; + +// bouton rouler tous les trains +procedure TFormRouteTrain.ButtonRoulerTsTrainsClick(Sender: TObject); +var idtrain : integer; + demarre : boolean; +begin + if (indexTrainFR<1) then exit; + roulage:=true; + efface_route_tco; + maj_signaux(true); + maj_signaux(true); + + // positionner les aiguillages de la 1ère route + idtrain:=1; + repeat + //si le train est doté d'une route + if trains[idTrain].route[0].adresse>0 then + begin + aig_canton(idTrain,trains[idTrain].route[1].adresse); + end; + inc(idtrain); + until (idtrain>ntrains); + + for idtrain:=1 to ntrains do + begin + //si le train est doté d'une route + if trains[idTrain].route[0].adresse>0 then demarre:=demarre_index_train(idtrain); // met la mémoire de roulage du train à 1 + end; + close; +end; + +end. + diff --git a/UnitTCO.dfm b/UnitTCO.dfm index 6b98ae2..288d9a3 100644 --- a/UnitTCO.dfm +++ b/UnitTCO.dfm @@ -1,8 +1,8 @@ object FormTCO: TFormTCO - Left = 116 - Top = 138 - Width = 1219 - Height = 612 + Left = 229 + Top = 65 + Width = 1013 + Height = 607 VertScrollBar.Visible = False Caption = 'c' Color = clBtnFace @@ -24,12 +24,12 @@ object FormTCO: TFormTCO OnKeyPress = FormKeyPress OnMouseWheel = FormMouseWheel DesignSize = ( - 1211 - 561) + 1005 + 556) PixelsPerInch = 96 TextHeight = 13 object LabelZoom: TLabel - Left = 1169 + Left = 963 Top = 0 Width = 32 Height = 13 @@ -43,7 +43,7 @@ object FormTCO: TFormTCO ParentFont = False end object ImageTemp: TImage - Left = 1022 + Left = 816 Top = 8 Width = 121 Height = 121 @@ -53,17 +53,169 @@ object FormTCO: TFormTCO ShowHint = True end object ImageTemp2: TImage - Left = 894 + Left = 688 Top = 137 Width = 248 Height = 256 Anchors = [akTop, akRight] end + object ImageDrapVert: TImage + Left = 744 + Top = 0 + Width = 64 + Height = 64 + Picture.Data = { + 07544269746D617076080000424D760800000000000076000000280000004000 + 0000400000000100040000000000000800000000000000000000100000000000 + 0000000000000000800000800000008080008000000080008000808000008080 + 8000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF + FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFF8FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFF888FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFF00888FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFF0078FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFF0078FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFF00078FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFF8888FFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFF00078FFFFFFFFFFFFFFFFFF887778888FFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFF00788FFFFFFFFFFFFFFF887706777788888FFFFFFFFFFF + FFFFFFFFFFFFFFFFFF00788FFFFFFFFFFFFFF88AAAAAAA77777788FFFFFFFFFF + FFFFFFFFFFFFFFFFFF00778FFFFFFFFFFFFF87AAAAAAAAAAAAA778FFFFFFFFFF + FFFFFFFFFFFFFFFFFF000788FFFFFFFFFF887AAAAAAAAAAAAAA078FFFFFFFFFF + FFFFFFFFFFFFFFFFFFF00778FFFFFFFF8880AAAAAAAAAAAAAAA6778FFFFFFFFF + FFFFFFFFFFFFFFFFFFF0077788FFF88887AAAAAAAAAAAAAAAAAA778FFFFFFFFF + FFFFFFFFFFFFFFFFFFF00000778887770AAAAAAAAAAAAAAAAAAA078FFFFFFFFF + FFFFFFFFFFFFFFFFFFFF0060777770AAAAAAAAAAAAAAAAAAAAAA078FFFFFFFFF + FFFFFFFFFFFFFFFFFFFF006AAAAAAAAAAAAAAAAAAAAAAAAAAAAA078FFFFFFFFF + FFFFFFFFFFFFFFFFFFFF000AAAAAAAAAAAAAAAAAAAAAAAAAAAAA078FFFFFFFFF + FFFFFFFFFFFFFFFFFFFF000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA778FFFFFFFF + FFFFFFFFFFFFFFFFFFFFF00AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA778FFFFFFFF + FFFFFFFFFFFFFFFFFFFFF00AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA078FFFFFFFF + FFFFFFFFFFFFFFFFFFFFF000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA778FFFFFFF + FFFFFFFFFFFFFFFFFFFFFF00AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA778FFFFFFF + FFFFFFFFFFFFFFFFFFFFFF00AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0788FFFFFF + FFFFFFFFFFFFFFFFFFFFFF000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA778FFFFFF + FFFFFFFFFFFFFFFFFFFFFF000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA078FFFFFF + FFFFFFFFFFFFFFFFFFFFFFF00AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA778FFFFF + FFFFFFFFFFFFFFFFFFFFFFF000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA778FFFFF + FFFFFFFFFFFFFFFFFFFFFFF000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA88FFFFF + FFFFFFFFFFFFFFFFFFFFFFFF00AAAAAAAAAAAAAAAAAAAAAFFFFF8AAAA88FFFFF + FFFFFFFFFFFFFFFFFFFFFFFF00AAAAAAAAAAAAAAAAAAA8FFFFFFFFFF80FFFFFF + FFFFFFFFFFFFFFFFFFFFFFFF000AAAAAAAAAAAAAAAAA88FFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFF000AAAAAAAAAAAAAAAA88FFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFF00AAAAAAAAAAAAAAA78FFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFF000AAAAAAAAAAAAA08FFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFF000AAAAAAAAAAAAA88FFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFF00AAAAAAAAAAAA88FFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFF00AAAAAAAAAAA8FFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFF000AAAAAAAA88FFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFF0000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFF00088FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFFF08FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFF} + end + object ImageDrapRouge: TImage + Left = 744 + Top = 72 + Width = 64 + Height = 64 + Picture.Data = { + 07544269746D617076080000424D760800000000000076000000280000004000 + 0000400000000100040000000000000800000000000000000000100000000000 + 0000000000000000800000800000008080008000000080008000808000008080 + 8000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF + FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFF8FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFF888FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFF00888FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFF0078FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFF0078FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFF00078FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFF00788FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFF00778FFFFFFFFFFFFFFFFFFFF8888FFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFF00078FFFFFFFFFFFFFFFFFF887778888FFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFF00788FFFFFFFFFFFFFFF887706777788888FFFFFFFFFFF + FFFFFFFFFFFFFFFFFF00788FFFFFFFFFFFFFF88999999977777788FFFFFFFFFF + FFFFFFFFFFFFFFFFFF00778FFFFFFFFFFFFF879999999999999778FFFFFFFFFF + FFFFFFFFFFFFFFFFFF000788FFFFFFFFFF88799999999999999078FFFFFFFFFF + FFFFFFFFFFFFFFFFFFF00778FFFFFFFF88809999999999999996778FFFFFFFFF + FFFFFFFFFFFFFFFFFFF0077788FFF88887999999999999999999778FFFFFFFFF + FFFFFFFFFFFFFFFFFFF000007788877709999999999999999999078FFFFFFFFF + FFFFFFFFFFFFFFFFFFFF00607777709999999999999999999999078FFFFFFFFF + FFFFFFFFFFFFFFFFFFFF00699999999999999999999999999999078FFFFFFFFF + FFFFFFFFFFFFFFFFFFFF00099999999999999999999999999999078FFFFFFFFF + FFFFFFFFFFFFFFFFFFFF000999999999999999999999999999999778FFFFFFFF + FFFFFFFFFFFFFFFFFFFFF00999999999999999999999999999999778FFFFFFFF + FFFFFFFFFFFFFFFFFFFFF00999999999999999999999999999999078FFFFFFFF + FFFFFFFFFFFFFFFFFFFFF000999999999999999999999999999999778FFFFFFF + FFFFFFFFFFFFFFFFFFFFFF00999999999999999999999999999999778FFFFFFF + FFFFFFFFFFFFFFFFFFFFFF009999999999999999999999999999990788FFFFFF + FFFFFFFFFFFFFFFFFFFFFF000999999999999999999999999999999778FFFFFF + FFFFFFFFFFFFFFFFFFFFFF000999999999999999999999999999999078FFFFFF + FFFFFFFFFFFFFFFFFFFFFFF009999999999999999999999999999999778FFFFF + FFFFFFFFFFFFFFFFFFFFFFF000999999999999999999999999999999778FFFFF + FFFFFFFFFFFFFFFFFFFFFFF000999999999999999999999999999999988FFFFF + FFFFFFFFFFFFFFFFFFFFFFFF00999999999999999999999FFFFF8999988FFFFF + FFFFFFFFFFFFFFFFFFFFFFFF0099999999999999999998FFFFFFFFFF80FFFFFF + FFFFFFFFFFFFFFFFFFFFFFFF0009999999999999999988FFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFF000999999999999999988FFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFF0099999999999999978FFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFF000999999999999908FFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFF000999999999999988FFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFF0099999999999988FFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFF00999999999998FFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFF0009999999988FFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFF0000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFF00088FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFFF08FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFF} + end object ScrollBox: TScrollBox Left = 8 Top = 12 - Width = 691 - Height = 365 + Width = 485 + Height = 360 HorzScrollBar.Smooth = True HorzScrollBar.Tracking = True VertScrollBar.Smooth = True @@ -74,13 +226,14 @@ object FormTCO: TFormTCO ParentColor = False TabOrder = 1 DesignSize = ( - 687 - 361) + 481 + 356) object ImageTCO: TImage Left = 120 Top = 41 - Width = 490 - Height = 275 + Width = 284 + Height = 270 + Hint = 'Hint' Anchors = [akLeft, akTop, akRight, akBottom] AutoSize = True ParentShowHint = False @@ -95,7 +248,7 @@ object FormTCO: TFormTCO end end object TrackBarZoom: TTrackBar - Left = 1167 + Left = 961 Top = 15 Width = 41 Height = 311 @@ -113,8 +266,8 @@ object FormTCO: TFormTCO end object PanelBas: TPanel Left = 0 - Top = 413 - Width = 1203 + Top = 408 + Width = 997 Height = 140 Anchors = [akLeft, akRight, akBottom] Color = clActiveBorder @@ -127,7 +280,7 @@ object FormTCO: TFormTCO TabOrder = 2 OnDragOver = PanelBasDragOver DesignSize = ( - 1203 + 997 140) object Label1: TLabel Left = 240 @@ -935,7 +1088,7 @@ object FormTCO: TFormTCO ParentFont = False end object ButtonSauveTCO: TButton - Left = 1094 + Left = 888 Top = 8 Width = 96 Height = 33 @@ -947,7 +1100,7 @@ object FormTCO: TFormTCO OnClick = ButtonSauveTCOClick end object ButtonConfigTCO: TButton - Left = 1094 + Left = 888 Top = 48 Width = 96 Height = 33 @@ -958,7 +1111,7 @@ object FormTCO: TFormTCO OnClick = ButtonConfigTCOClick end object ButtonSimu: TButton - Left = 882 + Left = 676 Top = 80 Width = 113 Height = 25 @@ -1050,6 +1203,7 @@ object FormTCO: TFormTCO Font.Name = 'MS Sans Serif' Font.Style = [] ParentFont = False + ReadOnly = True TabOrder = 0 OnChange = EditAdrElementChange OnClick = EditAdrElementClick @@ -1151,7 +1305,7 @@ object FormTCO: TFormTCO end end object buttonRaz: TButton - Left = 1095 + Left = 889 Top = 88 Width = 97 Height = 33 @@ -1163,7 +1317,7 @@ object FormTCO: TFormTCO OnClick = buttonRazClick end object ButtonCalibrage: TButton - Left = 922 + Left = 716 Top = 56 Width = 75 Height = 25 @@ -1174,7 +1328,7 @@ object FormTCO: TFormTCO OnClick = ButtonCalibrageClick end object ButtonDessiner: TButton - Left = 991 + Left = 785 Top = 48 Width = 97 Height = 33 @@ -1190,7 +1344,7 @@ object FormTCO: TFormTCO OnClick = ButtonDessinerClick end object ButtonAffSC: TButton - Left = 991 + Left = 785 Top = 8 Width = 97 Height = 33 @@ -1202,7 +1356,7 @@ object FormTCO: TFormTCO OnClick = ButtonAffSCClick end object RadioGroupSel: TRadioGroup - Left = 843 + Left = 637 Top = 8 Width = 138 Height = 49 @@ -1221,12 +1375,14 @@ object FormTCO: TFormTCO OnClick = RadioGroupSelClick end object Button1: TButton - Left = 1032 - Top = 96 + Left = 800 + Top = 88 Width = 75 Height = 25 Caption = 'Button1' TabOrder = 9 + Visible = False + OnClick = Button1Click end end object PopupMenu1: TPopupMenu @@ -1399,7 +1555,7 @@ object FormTCO: TFormTCO Caption = 'Masquer bandeau' OnClick = BandeauClick end - object Affichage1: TMenuItem + object Affichage: TMenuItem Caption = 'Affichage' object Mosaquehorizontale1: TMenuItem Caption = 'Mosa'#239'que horizontale' @@ -1417,5 +1573,12 @@ object FormTCO: TFormTCO OnClick = AfficherSignauxComplexes1Click end end + object Routes: TMenuItem + Caption = 'Routes' + object AffRoutes: TMenuItem + Caption = 'Fen'#234'tre des routes' + OnClick = AffRoutesClick + end + end end end diff --git a/UnitTCO.pas b/UnitTCO.pas index 32c61a5..6fe8f0e 100644 --- a/UnitTCO.pas +++ b/UnitTCO.pas @@ -144,7 +144,7 @@ type DessinerleTCO1: TMenuItem; ConfigurationduTCO1: TMenuItem; Bandeau: TMenuItem; - Affichage1: TMenuItem; + Affichage: TMenuItem; Mosaquehorizontale1: TMenuItem; Mosaqueverticale1: TMenuItem; N10: TMenuItem; @@ -157,6 +157,10 @@ type Supprimercanton1: TMenuItem; N9: TMenuItem; Affecterlocomotiveaucanton1: TMenuItem; + Routes: TMenuItem; + AffRoutes: TMenuItem; + ImageDrapVert: TImage; + ImageDrapRouge: TImage; Button1: TButton; //TimerTCO: TTimer; procedure FormCreate(Sender: TObject); @@ -436,6 +440,8 @@ type procedure ImagePalette53EndDrag(Sender, Target: TObject; X, Y: Integer); procedure ImageTCOEndDrag(Sender, Target: TObject; X, Y: Integer); + procedure AffRoutesClick(Sender: TObject); + procedure Button1Click(Sender: TObject); private { Déclarations privées } @@ -446,6 +452,7 @@ type const MaxCantons=100; + // sens du train ou de circulation dans les cantons SensGauche=1; SensDroit=2; SensHaut=3; @@ -507,14 +514,16 @@ 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 OU numerocanton + PiedFeu : integer; // type de pied au signal : signal à gauche=1 ou à droite=2 de la voie OU si action: type d'action + NumCanton : integer; // numéro de canton, pas son index 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 / 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) OU si canton: alignement train - buttoir : integer; // définition des buttoirs : si le bit n°n est à 1 : buttoir + SensCirc : integer; // sens de la circulation des trains dans canton à la lecture du tco, copié dans canton au renseignement du canton tous sens=0 SensGauche=1 SensDroit=2 SensHaut=3 SensBas=4 + pont : integer; // définition du pont : si le bit n est à 1 : pont (bits symétriques) OU si canton: alignement train (0=centré 1=Gauche/haut 2=droite/bas) + buttoir : integer; // définition des buttoirs : si le bit n°n est à 1 : buttoir ; ou encadre cellule sortie : integer; // si action sortie : état end; @@ -531,7 +540,7 @@ var TamponAffecte,TCO_modifie,clicsouris,prise_N, 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, - TCOActive,TCOCree,ancienok,dbleClicTCO,auto_tcurs,EvtClicDet,SelecBouge : boolean; + TCOActive,TCOCree,ancienok,dbleClicTCO,auto_tcurs,EvtClicDet,SelecBouge,NB : boolean; HtImageTCO,LargImageTCO,XminiSel,YminiSel,Temposouris,ligne_supprime, XmaxiSel,YmaxiSel,AncienXMiniSel,AncienXMaxiSel,AncienYMiniSel,AncienYMaxiSel, @@ -540,8 +549,9 @@ var 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,couleurCanton,Ncantons,Xcanton,Ycanton,IdCantonSelect,AxSC,AySC,Drag, - Ldrag,Hdrag,IdCantonDragOrg : integer; + couleurAction,couleurCanton,Ncantons,Xcanton,Ycanton,IdCantonSelect,IdCantonClic,AxSC,AySC,Drag, + Ldrag,Hdrag,IdCantonDragOrg,sens,idcantonRoute,cantonOrg,cantonDest,AncienIdCantonSelect, + indexTrainFR : integer; Tel1,tel2 : Tequipement; @@ -552,27 +562,33 @@ var //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 + SensLoco : 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 + // éléments contigus el1,el2 : integer; // éléments contigus au canton el1=gauche/haut el2=droit/bas - typ1,typ2 : tEquipement; // type des éléments contigus au canton + typ1,typ2 : tEquipement; // type des éléments contigus au canton: un des deux doit être un détecteur 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 + SensEl1,SensEl2 : integer;// indique le sens de l'élément par rapport au canton + SensCirc : integer; // sens de la circulation des trains dans canton tous sens=0 SensGauche=1 SensDroit=2 SensHaut=3 SensBas=4 + // 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 + adresseTrain : integer; // adresse du train sur le canton + Gd : tRect; // rectangle de sélection (contour du canton) + rO,rE,rS,rN : tRect; // rectagles des 4 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 + bouton : integer; // état du bouton de commande du canton: 0=jaune 1=vert 2=bleu 3=drapeau vert 4=drapeau rouge 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 + NumcantonOrg,NumCantonDest + : integer; // canton origine et destination d'une route + AdrTrainRoute : integer; // adresse du train qui a une route, sur le canton départ ou arrivée end; // structure de tous les tco @@ -626,11 +642,15 @@ var NomFichierTCO : array[1..10] of string; AvecGrille,SelectionAffichee,forminit,modeTrace,entoure : array[1..10] of boolean; + {$IF CompilerVersion >= 28.0} + BallonHint : TballoonHint; + {$IFEND} + 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,adrTrain,mode: integer); +function zone_tco(indexTCO,det1,det2,train,adrTrain,mode: integer;posAig : boolean) : boolean; procedure _entoure_cell_clic(indexTCO: integer); procedure Affiche_TCO(indexTCO : integer) ; procedure affiche_cellule(indexTCO,x,y : integer); @@ -663,17 +683,20 @@ procedure encadre_colonne; function IsCanton(i : integer) : boolean; function index_canton(indexTCO,x,y : integer) : integer; function IsCantonH(i : integer) : boolean; overload; +function IsCantonH(indexTCO,x,y : 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; +function IsCantonV(indexTCO,x,y : integer) : boolean; overload; +procedure dessin_canton(indexTCO : integer;Canvas : Tcanvas;x,y,mode: integer); overload; +procedure dessin_canton(IdCanton : integer;mode : integer) ; overload; procedure supprime_canton(c : integer); procedure renseigne_tous_cantons; -procedure renseigne_canton(i : integer); +procedure renseigne_canton(i : integer); overload; function index_canton_numero(n : integer) : integer; implementation -uses UnitConfigTCO, Unit_Pilote_aig, UnitConfigCellTCO, UnitClock, selection_train , unitPlace ; +uses UnitConfigTCO, Unit_Pilote_aig, UnitConfigCellTCO, UnitClock, selection_train , + UnitRoute, UnitRouteTrains, UnitInfo; {$R *.dfm} @@ -689,13 +712,11 @@ begin end; end; -// renvoie l'index du canton en x,y -function index_canton(IndexTCO,x,y : integer) : integer; -var El,i : integer; - trouve : boolean; +// ramener les coordonnées à la première cellule du canton +procedure coord_canton(indexTCO : integer;var x,y : integer); +var el : integer; 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); @@ -704,6 +725,14 @@ begin begin y:=y-(el-Id_cantonV); end; +end; + +// renvoie l'index du canton en x,y +function index_canton(IndexTCO,x,y : integer) : integer; +var i : integer; + trouve : boolean; +begin + coord_canton(indexTCO,x,y); i:=1; repeat trouve:=(canton[i].x=x) and (canton[i].y=y); @@ -722,7 +751,7 @@ begin repeat trouve:=canton[i].numero=n; inc(i); - until (i=Ncantons+1) or trouve; + until (i>=Ncantons+1) or trouve; if trouve then result:=i-1; end; @@ -1086,7 +1115,6 @@ end; procedure Init_rectangle_canton(IndexTCO,indexCanton : integer); var xp,yp : integer; begin - with canton[indexcanton] do begin // poignée nord (haut) @@ -1137,7 +1165,7 @@ begin color:=clWhite; width:=1; end; - Brush.Color:=clblue; + Brush.Color:=clFondCantonV; Rectangle(canton[indexCanton].Gd); // Grand rectangle h:=canton[indexcanton].horizontal; @@ -1176,7 +1204,6 @@ begin // 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); @@ -1209,9 +1236,6 @@ begin AxSC:=x;AySC:=y; ok:=(Adr=0) and ( (Bim=1) or (Bim=20) or ((Bim>=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; @@ -1391,20 +1415,22 @@ begin 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); + + +// remplit les champs horizontal, el1,el2,typ1,typ2,sens1,sens2 de canton[] +// et les champs canton1 et canton2 du tableau detecteurs[] +procedure renseigne_canton(i : integer;Horz :boolean) ; overload; 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); + FormTCO[IndexTCO].Caption:='Erreur 32'; exit; end; x:=canton[i].x; @@ -1412,37 +1438,54 @@ begin t:=canton[i].Ntco; canton[i].horizontal:=tco[indexTCO,x,y].BImage=Id_cantonH; - Horz:=canton[i].horizontal; + canton[i].SensCirc:=tco[IndexTCO,x,y].SensCirc; 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 + zone_tco(t,i,5,0,0,11,false); // 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; + canton[i].SensEl1:=SensGauche; + if tel1=det then detecteur[xCanton].canton1:=canton[i].numero; - zone_tco(t,i,6,0,0,11); // demande éléments contigus à droite (6) du canton, résultats dans var globales xCanton et tel1 + zone_tco(t,i,6,0,0,11,false); // 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; - + canton[i].SensEl2:=SensDroit; + if tel1=det then detecteur[xCanton].canton2:=canton[i].numero; 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 + zone_tco(t,i,7,0,0,11,false); // 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; + canton[i].SensEl1:=SensHaut; + if tel1=det then detecteur[xCanton].canton1:=canton[i].numero; - 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 + zone_tco(t,i,8,0,0,11,false); // 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; + canton[i].SensEl2:=SensBas; + if tel1=det then detecteur[xCanton].canton2:=canton[i].numero; end; //Affiche(intToSTR(xCanton)+' '+intToStr(yCanton),clyellow); end; +// renseigne le canton index i avec les éléments contigus +procedure renseigne_canton(i : integer); overload; +var x,y,it : integer; + Horz : boolean; +begin + it:=canton[i].Ntco; + x:=canton[i].x; + y:=canton[i].y; + horz:=tco[it,x,y].BImage=Id_cantonH; + canton[i].horizontal:=horz; + Horz:=canton[i].horizontal; + renseigne_canton(i,Horz); +end; + procedure renseigne_tous_cantons; var i : integer; begin @@ -1488,12 +1531,15 @@ begin fonte:='Arial'; fontSTyle:=''; piedFeu:=0; + NumCanton:=0; x:=0; y:=0; FeuOriente:=0; Liaisons:=0; Epaisseur:=0; Buttoir:=0; + sortie:=0; + SensCirc:=0; end; end; @@ -1771,32 +1817,38 @@ begin if (NbreCellX[indexTCO]<20) or (NbreCellX[indexTCO]>MaxCellX) then begin NbreCellX[indexTCO]:=MaxCellX; - Affiche('TCO: le nombre de cellules X a été ramené à '+intToSTR(NbreCellX[indexTCO]),clred); + s:='TCO: le nombre de cellules X a été ramené à '+intToSTR(NbreCellX[indexTCO]); + Affiche(s,clred); + FormTCO[IndexTCO].Caption:=s; end; if (NbreCellY[indexTCO]<5) or (NbreCellY[indexTCO]>MaxCellY) then begin NbreCellY[indexTCO]:=MaxCellY; - Affiche('TCO: le nombre de cellules Y a été ramené à '+intToSTR(NbreCellX[indexTCO]),clred); + s:='TCO: le nombre de cellules Y a été ramené à '+intToSTR(NbreCellX[indexTCO]); + FormTCO[IndexTCO].Caption:=s; + Affiche(s,clred); end; try SetLength(TCO[indexTCO],MaxCellX+2,MaxCellY+2) except - Affiche('TCO:Mémoire insuffisante pour'+intToSTR(MaxCellX)+' '+intToSTR(MaxCellY),clred); + s:='TCO:Mémoire insuffisante pour'+intToSTR(MaxCellX)+' '+intToSTR(MaxCellY); + Affiche(s,clred); + FormTCO[IndexTCO].Caption:=s; NbreCellX[indexTCO]:=20;NbreCellY[indexTCO]:=12; SetLength(TCO[indexTCO],NbreCellX[indexTCO]+2,NbreCellY[indexTCO]+2); end; try - init_tampon_copiercoller; except - Affiche('TamponTCO:Mémoire insuffisante',clred); + s:='TamponTCO:Mémoire insuffisante'; + Affiche(s,clred); + FormTCO[IndexTCO].Caption:=s; NbreCellX[indexTCO]:=20;NbreCellY[indexTCO]:=12; init_tampon_copiercoller; end; - // lire la matrice while not eof(fichier) do begin @@ -1856,7 +1908,7 @@ begin begin cuc:=true; // id canton inc(nCantons); - // le numéro de canton est lu plus loin, variable PiedFeu + // le numéro de canton est lu plus loin canton[ncantons].x:=x; canton[ncantons].y:=y; canton[ncantons].indexTrain:=0; @@ -1898,7 +1950,7 @@ begin begin // affiche(inttostr(piedfeu),clyellow); //Affiche('indexcanton='+intToSTR(ncantons)+' numcanton lu='+intToSTR(piedFeu),clOrange); - tco[indexTCO,x,y].PiedFeu:=PiedFeu; + tco[indexTCO,x,y].NumCanton:=PiedFeu; if cuc then canton[ncantons].numero:=piedFeu; end; @@ -2018,6 +2070,16 @@ begin delete(s,1,erreur-1); end; + // 17 nouveau version 8.9 sens circulation du canton + if npar>=17 then + begin + delete(s,1,1); // supprimer la virgule + val(s,i,erreur); + if (i<0) or (i>4) then i:=0; + tco[indexTCO,x,y].SensCirc:=i; + delete(s,1,erreur-1); + end; + i:=pos(')',s); if i<>0 then delete(s,1,i); @@ -2060,7 +2122,7 @@ begin begin AssignFile(fichier,nomfichierTCO[i]); rewrite(fichier); - Writeln(fichier,'/ Définitions TCO version '+version+sousversion); + Writeln(fichier,'/ Définitions TCO version '+versionSC+sousversion); writeln(fichier,ZoomInit_ch+'=',ZoomInit[i]); writeln(fichier,XYInit_ch+'=',XInit[i],',',Yinit[i]); Writeln(fichier,clFond_ch+'='+IntToHex(clfond[i],6)); @@ -2085,7 +2147,7 @@ begin writeln(fichier,'/ Matrice TCO'); writeln(fichier,'[Matrice]'); writeln(fichier, - '/ couleur fond,adresse,image,inversion aiguillage,Orientation du signal, pied du signal , [texte], representation, fonte, taille fonte, couleur fonte, style, épaisseurs, pont, buttoir '); + '/ couleur fond,adresse,image,inversion aiguillage,Orientation du signal, pied du signal , [texte], representation, fonte, taille fonte, couleur fonte, style, épaisseurs, pont, buttoir, sortieAction, sensCirculation '); for y:=1 to NbreCellY[i] do begin s:=''; @@ -2101,10 +2163,12 @@ begin // 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); + s:=s+','; // piedFeu ou index canton + if (Bimage=Id_CantonH) or (Bimage=Id_cantonV) then s:=s+intToSTR(tco[i,x,y].NumCanton) + else s:=s+IntToSTR(tco[i,x,y].PiedFeu); s:=s+','; - s:=s+IntToSTR(tco[i,x,y].PiedFeu)+','; // texte s:=s+tco[i,x,y].Texte+','; @@ -2122,6 +2186,7 @@ begin s:=s+','+intToSTR(tco[i,x,y].pont); s:=s+','+intToSTR(tco[i,x,y].buttoir); s:=s+','+intToSTR(tco[i,x,y].sortie); + s:=s+','+intToSTR(tco[i,x,y].SensCirc); s:=s+')'; end; writeln(fichier,s); @@ -2326,6 +2391,7 @@ begin result:=((i>=Id_cantonH) and (i<=Id_CantonH+9)); end; +// 2eme forme function IsCantonH(indexTCO,x,y : integer) : boolean; overload; var b : integer; begin @@ -2334,11 +2400,12 @@ begin end; // renvoie vrai si l'élément i est un canton V -function IsCantonV(i : integer) : boolean; +function IsCantonV(i : integer) : boolean; overload; begin result:=((i>=Id_cantonV) and (iId_Quai) and (b<>Id_action) then s:=s+' '; if repr=4 then texte_reparti(s,indextco,x,y,tf) else c.Textout(x0+xt,y0+yt,s); + + + if tco[indextco,x,y].buttoir=1 then + begin + largCell:=LargeurCell[indexTCO]; + hautCell:=HauteurCell[indexTCO]; + + with PCanvasTCO[indexTCO] do + begin + pen.width:=(epaisseur div 2); + tf:=TextWidth(tco[indextco,x,y].Texte); + + tf:=(tf div largCell)*largCell+largCell; + pen.color:=clWhite; + moveTo(x0,y0);LineTo(x0+tf,y0); + LineTo(x0+tf,y0+hautCell); + LineTo(x0,y0+hautCell); + LineTo(x0,y0); + end; + end; end; procedure dessin_2L(indexTCO : integer;Canvas : Tcanvas;x,y : integer;Mode : integer); @@ -5693,10 +5779,10 @@ begin larg:=LargeurCell[indexTCO]; haut:=hauteurCell[indexTCO]; - x0:=(x-1)*Larg+2; - y0:=(y-1)*haut+2; - xf:=x0+Larg-4; - yf:=y0+Haut-4; + x0:=(x-1)*Larg; + y0:=(y-1)*haut; + xf:=x0+Larg; + yf:=y0+Haut; with canvas do @@ -5839,10 +5925,13 @@ begin 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; +// dessine le canton H +// mode=0 canton normal mode=1 : affiche le canton en mode rectangle de sélection avec les poignées +// =3 drapeau vert =4 drapeau rouge +procedure dessin_cantonH(indexTCO : integer;Canvas : Tcanvas;x,y,mode : integer); +var i,xi,yi,x0,y0,yf,yc,xt,yt,dx,dy,larg,haut,xr,xm,LargDest,Hautdest,indexTrain,NumC, + offsetY,xf,AdrTrain,Xcentre,yCentre,n,al,r,l,h,HautDestF,LargDestF,LargSrc,HautSrc,OffsetX, + bouton : integer; frX,frY,rd : real; coul : tcolor; p : array[0..2] of TPoint; @@ -5867,21 +5956,24 @@ begin 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; + NumC:=TCO[indexTCO,x,y].NumCanton; // 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; +{ 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; + //Affiche('Canton '+intToSTR(canton[i].numero)+' adrTrain='+intToSTR(AdrTrain),clLime); + if AdrTrain<>0 then indexTrain:=index_train_adresse(adrTrain); - if (AdrTrain<>0) or (indexTrain=9999) then Brush.Color:=clFondCantonR // couleurCanton - else Brush.Color:=clFondCantonV; + if (AdrTrain<>0) or (indexTrain=9999) then coul:=clFondCantonR // couleurCanton + else coul:=clFondCantonV; + Brush.Color:=coul; // mode=1 : représenter avec les poignées de sélection if mode=1 then @@ -5911,19 +6003,29 @@ begin Roundrect(x0,y0,xf,yf,15,15); // numéro de canton + font.color:=clYellow; Textout(x0+6,y0+2,intToSTR(canton[i].numero)); - + // bouton Xcentre:=Xf-(larg div 2); Ycentre:=Yc; r:=larg div 3; - + bouton:=canton[i].bouton; case bouton of 0 : couleur:=clyellow; 1 : couleur:=clLime; 2 : couleur:=clAqua; end; - cercle(PcanvasTCO[indexTCO],xCentre,ycentre,r,couleur); + if bouton<=2 then cercle(PcanvasTCO[indexTCO],xCentre,ycentre,r,couleur) + else + begin + if bouton=3 then + StretchBlt(PcanvasTCO[indexTCO].Handle,xf-larg,yf-haut,larg,haut, + FormTCO[indexTCO].ImageDrapVert.canvas.Handle,1,1,63,63,srccopy); + if bouton=4 then + StretchBlt(PcanvasTCO[indexTCO].Handle,xf-larg,yf-haut,larg,haut, + FormTCO[indexTCO].ImageDrapRouge.canvas.Handle,1,1,63,63,srccopy); + end; if (indexTrain=0) or (indexTrain=9999) then begin @@ -5931,42 +6033,51 @@ begin exit; end; - tailleX:=3*larg; - tailleY:=Haut; - if (trains[indexTrain].icone=nil) or (Trains[indexTrain].Icone.height=0) then exit; + //---redimensionnement 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; + offsetX:=15; // décalage X de la loco largDest:=round(HautDest*rd); - if largdest>n*larg then + if largdest>((n-1)*larg)-offsetX then // -1 pour le bouton begin - largdest:=n*larg; + largdest:=(n-1)*larg-offsetX; hautDest:=round(largdest/rd); end; - + // --------fin du redimensionnement 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 + sens:=canton[i].SensLoco; + case sens of + 0,sensGauche : xi:=x0+OffsetX; + sensDroit : xi:=xf-largdest-larg; + end; - Canton[i].Xicone:=x0; + // coordonnées du texte de la loco + if sens=sensGauche then begin xt:=xi+largDest+round(10*frx);yt:=y0+round(20*fry);dx:=xf-larg;dy:=yf;end; // espace restant + if sens=sensdroit then begin xt:=x0+round(20*frx);yt:=y0+round(20*fry);dx:=xi+largdest-larg;dy:=y0+offsety+hautdest;end; + + s:=canton[i].NomTrain; + l:=TextWidth(s); + if l0 then indexTrain:=index_train_adresse(adrTrain); - if (AdrTrain<>0) or (indexTrain=9999) then Brush.Color:=clFondCantonR // couleurCanton - else Brush.Color:=clFondCantonV; + if (AdrTrain<>0) or (indexTrain=9999) then coul:=clFondCantonR // couleurCanton + else coul:=clFondCantonV; + Brush.Color:=coul; // mode=1 représenter avec les poignées de sélection if mode=1 then @@ -6072,18 +6187,34 @@ begin Roundrect(x0,y0,xf,yf,15,15); // numéro de canton + pen.Mode:=pmcopy; + pen.color:=clyellow; + font.Color:=clyellow; Textout(x0+2,y0+6,intToSTR(canton[i].numero)); Xcentre:=Xc+1; Ycentre:=Yf-(haut div 2); r:=larg div 3; + bouton:=canton[i].bouton; 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 bouton<=2 then cercle(PcanvasTCO[indexTCO],xCentre,ycentre,r,couleur) + else + begin + if bouton=3 then // drapeau vert + begin + StretchBlt(PcanvasTCO[indexTCO].Handle,xf-larg,yf-haut,larg,haut, + FormTCO[indexTCO].ImageDrapVert.canvas.Handle,1,1,63,63,srccopy); + end; + if bouton=4 then // drapeau rouge + begin + StretchBlt(PcanvasTCO[indexTCO].Handle,xf-larg,yf-haut,larg,haut, + FormTCO[indexTCO].ImageDrapRouge.canvas.Handle,1,1,63,63,srccopy); + end; + end; if (indexTrain=0) or (indexTrain=9999) then @@ -6094,28 +6225,29 @@ begin // pas d'icone if (trains[indexTrain].icone=nil) or (Trains[indexTrain].Icone.height=0) then exit; + // ----- prépare l'icone du train 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; + rd:=LargSrc/HautSrc; + largDest:=round(hautdest*rd); echange(largDest,HautDest); - if HautDest>TailleY then + if hautdest>(n-1)*haut then begin - hautDest:=tailleY; - largDest:=round(HautDest/r); + hautdest:=(n-1)*haut; + largDest:=round(HautDest/rd); end; + //---- fin du redimensionnement - 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 + sens:=canton[i].SensLoco; + case sens of + 0,sensHaut : yi:=y0+10; + sensBas : yi:=yf-Hautdest-haut; end; Canton[i].Xicone:=x0+round(8*frx); @@ -6123,7 +6255,19 @@ begin Canton[i].Licone:=LargDest; Canton[i].Hicone:=HautDest; - if canton[i].Sens=SensHaut then + // coordonnées du texte de la loco + if sens=sensHaut then begin xt:=x0+round(40*frx);yt:=yi+hautdest+round(10*fry);dx:=xf;dy:=yf-haut;end; // espace restant + if sens=sensBas then begin xt:=x0+round(40*frx);yt:=y0+round(10*fry);dx:=x0+Largdest;dy:=yi-haut;end; + + //PCanvasTCO[indexTCO].font.Size:=PCanvasTCO[indexTCO].font.Size+1; + s:=canton[i].NomTrain; + l:=TextWidth(s); + Brush.Color:=coul; + if lnbreTCO then @@ -9503,7 +9646,7 @@ begin exit; end; if PcanvasTCO[indexTCO]=nil then exit; - if tco[indextco,x,y].BImage=0 then exit; + //Affiche('Affiche_cellule',clLime); PcanvasTCO[indexTCO].pen.Mode:=PmCopy; //pcanvasTCO.Brush.Style:=BsClear; @@ -9512,9 +9655,21 @@ begin mode:=tco[indextco,x,y].mode; // mode pour la couleur repr:=tco[indextco,x,y].repr; Epaisseur:=LargeurCell[indexTCO]*epaisseur_voies div 30; - + HautCell:=hauteurCell[indexTCO]; + largCell:=LargeurCell[indexTCO]; + clFond:=tco[indextco,x,y].CouleurFond; Xorg:=(x-1)*LargeurCell[indexTCO]; - Yorg:=(y-1)*hauteurCell[indexTCO]; + Yorg:=(y-1)*HautCell; + + with PCanvasTCO[indexTCO] do + begin + font.Size:=(LargeurCell[indexTCO] div 10)+4; + if NB then font.color:=clBlack else + Font.Color:=tco[indextco,x,y].coulFonte; + Font.Name:='Arial'; + Font.Style:=style(tco[indextco,x,y].FontStyle); + end; + // ------------- affichage de l'adresse ------------------ s:=IntToSTR(adresse); @@ -9523,9 +9678,9 @@ begin // dessin du train sur le canton - if (Bimage=Id_CantonH) or (Bimage=Id_CantonV) then dessin_canton(indexTCO,PCanvasTCO[indexTCO],x,y,0,0); + if (Bimage=Id_CantonH) or (Bimage=Id_CantonV) then dessin_canton(indexTCO,PCanvasTCO[indexTCO],x,y,0); + - PCanvasTCO[indexTCO].font.Size:=(LargeurCell[indexTCO] div 10)+4 ; //Affiche(intToSTR( (LargeurCell[indexTCO] div 30)+6),clyellow); // affiche le texte des aiguillages @@ -9543,7 +9698,7 @@ begin begin Brush.Color:=tco[indextco,x,y].CouleurFond; //SetBkMode(PCanvasTCO[indexTCO].Handle,TRANSPARENT); - if avecRESA or roulage then s:=s+' '; // efface l'adresse de réservation + if roulage then s:=s+' '; // efface l'adresse de réservation end else begin @@ -9555,9 +9710,7 @@ begin end; //Brush.Style:=Bsclear; - Font.Color:=tco[indextco,x,y].coulFonte; - Font.Name:='Arial'; - Font.Style:=style(tco[indextco,x,y].FontStyle); + xt:=0;yt:=0; if Bimage=2 then begin xt:=LargeurCell[indexTCO] div 2;yt:=1;end; if Bimage=3 then begin xt:=3;yt:=hauteurCell[indexTCO]-round(18*fryGlob[indexTCO]);end; @@ -9591,13 +9744,14 @@ begin with PCanvasTCO[indexTCO] do begin Brush.Color:=tco[indextco,x,y].CouleurFond; - Font.Color:=tco[indextco,x,y].coulFonte; + if NB then font.color:=clblack else + Font.Color:=tco[indextco,x,y].coulFonte; Font.Name:='Arial'; Font.Style:=style(tco[indextco,x,y].FontStyle); - xt:=round(15*frxGlob[indexTCO]); + xt:=round(4*frxGlob[indexTCO]); case repr of 1 : yt:=(hauteurCell[indexTCO] div 2)-round(7*fryGlob[indexTCO]); // milieu - 2 : yt:=1; // haut + 2 : yt:=2; // haut 3 : yt:=hauteurCell[indexTCO]-round(17*fryGlob[indexTCO]); // bas end; @@ -9619,21 +9773,85 @@ begin else if roulage then s:=s+' '; } //PCanvasTCO[indexTCO].font.Size:=(LargeurCell[indexTCO] div 13)+4 ; - TextOut(xOrg+xt,Yorg+yt,s+' '); + AdrTr:=detecteur[adresse].AdrTrainRes; + if AdrTr<>0 then + begin + Brush.style:=bsSolid; + Brush.Color:=clBlue; + s:=s+' '+intToSTR(AdrTr); + end + else + begin + Brush.style:=bsSolid; + Brush.Color:=clfond; + Pen.color:=clfond; + pen.mode:=PmCopy; + pen.Width:=1; + rectangle(xOrg+xt,Yorg+yt-1,xOrg+LargCell-1,Yorg+yt+round(17*fryGlob[indexTCO])); + end; + TextOut(xOrg+xt,Yorg+yt,s); end; end; + if ((Bimage=8) or (Bimage=10) ) and (adresse<>0) then + begin + with PCanvasTCO[indexTCO] do + begin + xt:=round(25*frxGlob[indexTCO]); + yt:=round(35*fryGlob[indexTCO]); + Font.Name:='Arial'; + Font.Style:=style(tco[indextco,x,y].FontStyle); + if NB then font.color:=clblack else + Font.Color:=tco[indextco,x,y].coulFonte; + AdrTr:=detecteur[adresse].AdrTrainRes; + if AdrTr<>0 then + begin + Brush.style:=bsSolid; + Brush.Color:=clBlue; + s:=s+' '+intToSTR(AdrTr); + end + else + begin + Brush.style:=bsSolid; + Brush.Color:=clfond; + Pen.color:=clfond; + pen.mode:=PmCopy; + pen.Width:=1; + rectangle(xOrg+xt,Yorg+yt,xOrg+LargCell,Yorg+yt+11); + end; + TextOut(xOrg+xt,yOrg+yt,s); + end; + end; + // autres détecteurs - if ((Bimage=7) or (Bimage=8) or (Bimage=9) or (Bimage=10) or (Bimage=17) ) and (adresse<>0) then + if ((Bimage=7) or (Bimage=9) or (Bimage=17) ) and (adresse<>0) then begin // Adresse de l'élément with PCanvasTCO[indexTCO] do begin - Brush.Color:=tco[indextco,x,y].CouleurFond; + xt:=round(2*frxGlob[indexTCO]); + yt:=round(2*fryGlob[indexTCO]); Font.Name:='Arial'; Font.Style:=style(tco[indextco,x,y].FontStyle); - Font.Color:=tco[indextco,x,y].coulFonte; - TextOut(xOrg+round(2*frxGlob[indexTCO]),yOrg+round(2*fryGlob[indexTCO]),s); + if NB then font.color:=clblack else + Font.Color:=tco[indextco,x,y].coulFonte; + AdrTr:=detecteur[adresse].AdrTrainRes; + if AdrTr<>0 then + begin + Brush.style:=bsSolid; + Brush.Color:=clBlue; + s:=s+' '+intToSTR(AdrTr); + end + else + begin + Brush.style:=bsSolid; + Brush.Color:=clfond; + Pen.color:=clfond; + pen.mode:=PmCopy; + pen.Width:=1; + rectangle(xOrg+xt,Yorg+yt,xOrg+LargCell,Yorg+yt+11); + end; + TextOut(xOrg+xt,yOrg+yt,s); end; end; @@ -9642,26 +9860,34 @@ begin begin with PCanvasTCO[indexTCO] do begin - Brush.Color:=tco[indextco,x,y].CouleurFond; Font.Name:='Arial'; Font.Style:=style(tco[indextco,x,y].FontStyle); - Font.Color:=tco[indextco,x,y].coulFonte; + if NB then font.color:=clblack else + Font.Color:=tco[indextco,x,y].coulFonte; + AdrTr:=detecteur[adresse].AdrTrainRes; + if (AdrTr<>0) then + begin + Brush.style:=bsSolid; + clfond:=clBlue; + s:=s+' '+intToSTR(AdrTr); + end; + PCanvasTCO[indexTCO].font.Size:=PCanvasTCO[indexTCO].font.Size+1; - //TextOut(xOrg+round(2*frxGlob[indexTCO]),yOrg+round(2*fryGlob[indexTCO]),s); - AffTexteIncliBordeTexture(PCanvasTCO[indexTCO],Xorg,yOrg+round(30*fryGlob[indexTCO]), - PCanvasTCO[indexTCO].Font,clYellow,0,pmcopy,nil,s,910); + AffTexteIncliBordeTexture(PCanvasTCO[indexTCO],Xorg,yOrg+HautCell-round(2*fryGlob[indexTCO]), + PCanvasTCO[indexTCO].Font,clYellow,0,pmcopy,clfond,s+' ',910); end; end; // autres détecteurs - if (Bimage=18) and (adresse<>0) then + if ((Bimage=18) or (Bimage=19)) and (adresse<>0) then begin // Adresse de l'élément with PCanvasTCO[indexTCO] do begin Brush.Color:=tco[indextco,x,y].CouleurFond; Font.Name:='Arial'; Font.Style:=style(tco[indextco,x,y].FontStyle); - Font.Color:=tco[indextco,x,y].coulFonte; + if NB then font.color:=clblack else + Font.Color:=tco[indextco,x,y].coulFonte; TextOut(xOrg+round(20*frxGlob[indexTCO]),yOrg+hauteurCell[indexTCO]-round(14*fryGlob[indexTCO]),s); end; end; @@ -9672,7 +9898,8 @@ begin with PCanvasTCO[indexTCO] do begin Brush.Color:=tco[indextco,x,y].CouleurFond; - Font.Color:=tco[indextco,x,y].coulFonte;; + if NB then font.color:=clblack else + Font.Color:=tco[indextco,x,y].coulFonte; Font.Style:=style(tco[indextco,x,y].FontStyle); Font.Name:='Arial'; TextOut(xOrg+round(28*frxGlob[indexTCO]),yOrg+round(2*fryGlob[indexTCO]),s); @@ -9761,7 +9988,8 @@ begin with PCanvasTCO[indexTCO] do begin Brush.Color:=tco[indextco,x,y].CouleurFond; - Font.Color:=tco[indextco,x,y].coulFonte; + if NB then font.color:=clblack else + Font.Color:=tco[indextco,x,y].coulFonte; Font.Style:=style(tco[indextco,x,y].FontStyle); Font.Name:='Arial'; TextOut(xOrg+xt,yOrg+yt,s); @@ -9957,6 +10185,14 @@ begin end; end; + //afficher les cellules vides qui ont un encadré + for y:=1 to NbreCellY[indexTCO] do + for x:=1 to NbreCellX[indexTCO] do + begin + Bim:=tco[indextco,x,y].BImage; + if (bim=0) and (tco[indextco,x,y].buttoir<>0) then affiche_cellule(indexTCO,x,y); + end; + // afficher les sélections si elles sont présentes if entoure[indexTCO] then Entoure_cell(indexTCO,Xentoure[indexTCO],Yentoure[indexTCO]); if (rect_select.NumTCO<>0) and (IndexTCO=rect_select.NumTCO) then Affiche_Rectangle(IndexTCO,Rect_select); // rectangle graphique @@ -9967,13 +10203,26 @@ end; procedure TFormTCO.FormCreate(Sender: TObject); var s : string; begin + NB:=false; if affevt or (debug=1) then Affiche('FormTCO'+intToSTR(indexTCOCreate)+' create',clLime); + procetape('Création fenêtre TCO'); //Screen.OnActiveControlChange := ActiveControlChanged; + + {$IF CompilerVersion >= 28.0} + BallonHint:=TballoonHint.Create(self); + with BallonHint do + begin + parent:=self; + name:='BallonHint'; + end; + {$IFEND} + visible:=false; // ne s'affiche pas par défaut et évite l'effet fenetre fantome. ClTexte:=$00FF00; clFondCantonV:=$206020; clFondCantonR:=$202060; IdCantonSelect:=0; + indexTrainFR:=0; PCanvasTCO[indexTCOCreate]:=nil; offsetSourisY:=-10; // permet de tenir l'icone au milieu quand on fait un glisser offsetSourisX:=-10; @@ -10026,7 +10275,6 @@ begin modeTrace[indexTCOCreate]:=false; // pour tracer les voies à la souris //controlStyle:=controlStyle+[csOpaque]; - s:='Voie'; ImagePalette6.Hint:=s;ImagePalette6.ShowHint:=true; ImagePalette7.Hint:=s;ImagePalette7.ShowHint:=true; @@ -10082,6 +10330,8 @@ begin s101:='Supprime la colonne pointée'; popupMenu1.Items[10][1].Hint:=s101; + if MasqueBandeauTCO then bandeauMasque:=true; + tcoCree:=true; if debug=1 then Affiche('Fin création fenêtre TCO',clLime); @@ -10169,56 +10419,44 @@ begin bimage:=tco[indextco,x,y].BImage; cant:=IsCanton(Bimage); - { if debugTCO then + if debugTCO then begin - AfficheDebug('x='+intToSTR(x)+' y='+intToSTR(y),clYellow); - end; } + AfficheDebug('x='+intToSTR(x)+' y='+intToSTR(y),clLime); + end; tco[Indextco,x,y].mode:=mode; //mode; // pour la couleur idTrain:=0; if mode>0 then Idtrain:=index_couleur // = numéro du train else IdTrain:=0; // efface train + adresse:=tco[indextco,x,y].Adresse; + tco[indextco,x,y].trajet:=0; + + //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 + // si canton + IdCanton:=index_canton_numero(TCO[indexTCO,x,y].NumCanton); // index canton + if (idTrain<>0) and (idcanton<>0) then begin - if idcanton<>0 then // si canton + if canton[IdCanton].indexTrain<>0 then //si train dans 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; + 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; - - //Affiche(intToSTR(x)+' '+intToSTR(y)+' '+intToSTR(TCO[IndexTCO,x,y].train),clorange); - - - 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=0) and (adrtrain=0) then adrTrain:=0; //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); + //Affiche('Affecte train '+intToSTR(adrTrain)+' au canton n°'+intToSTR(index_canton_numero(TCO[indexTCO,x,y].NumCanton)),clorange); affecte_Train_canton(AdrTrain,IdCanton); end; end; @@ -10241,7 +10479,8 @@ begin if (ax-x=1) and (ay-y=-1) and (sx-x=-1) and (sy-y=0) then tco[indextco,x,y].trajet:=4; // de haut droite vers 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 bas gauche vers droite if (ax-x=1) and (ay-y=0) and (sx-x=-1) and (sy-y=1) then tco[indextco,x,y].trajet:=3; // de gauche vers haut droite - if tco[indextco,x,y].trajet=0 then affiche('Erreur 70 TCO - Cellule '+intToSTR(x)+','+intToSTR(y),clred); + if tco[indextco,x,y].trajet=0 then + affiche('Erreur 70 TCO - Cellule '+intToSTR(x)+','+intToSTR(y),clred); end; // croisement @@ -10307,21 +10546,25 @@ begin end; // allume ou éteint (mode=0 ou 1) la voie du train "train", zone de det1 à det2 sur le TCO +// AdrTrain = adresse du train // train est l'index du train qui a été créé par le roulage (tableau event_det_train[train] ) // det1 et det2 doivent être consécutifs sur le TCO, mais peuvent être séparés par des aiguillages -// si mode=0 : éteint -// =1 : couleur détecteur allumé -// =2 : couleur de l'index train +// si mode=0 : éteint la voie +// =1 : allume la voie couleur détecteur allumé +// =2 : allume la voie couleur de l'index train // =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 +// =11 : det1=indexcanton det2=direction - renvoie les éléments adjacent du canton dans la direction indiquée dans xCanton et tel1 +// =12 : det1 = détecteur de départ - renvoie l'élément sursuivant (peut être un aiguillage)dans la direction demandée dans xCanton et tel1 +// direction: 1=gauche 2=droite 3=bas 4=haut // 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,adrTrain,mode: integer); +// PosAig = False:teste toutes les routes en récursif les aiguillages en pointe +// True: les aiguillages en pointe doivent être positionnés +// en sortie : true si det2 a été trouvé +// +function zone_tco(indexTCO,det1,det2,train,adrTrain,mode: integer;posAig : boolean) : boolean; 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; + memtrouve,sortir,indextrouve : boolean; s : string; // stocke la route dans le tableau, et incrémente l'index @@ -10335,6 +10578,8 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter exit; end; + // stocke le tracé + if debugTCO then AfficheDebug('Stocke en '+intToSTR(ir),clWhite); Trace_Train[indexTCO].train[train].route[ir].x:=x; Trace_Train[indexTCO].train[train].route[ir].y:=y; Trace_Train[indexTCO].train[train].Nombre:=ir; @@ -10353,14 +10598,13 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter // El_Tco : trouve l'élément en x,y et constuit la route à l'élément de destination suivant, suivant // les variables ancienX et ancienY - // x, y et ir sont locales pour des récursivités différentes, donc on les passe en paramètre pour transmettre à la + // AncienX,AncienY, x, y et ir sont locales pour des récursivités différentes, donc on les passe en paramètre pour transmettre à la // récursivité suivante leur valeur, mais elles reprennent leur valeurs initiales à la remontée vers la résursivité appellante. - Procedure El_tco(x,y,train : integer; ir : integer); + Procedure El_tco(AncienX,ancienY,x,y,train : integer; ir : integer); var mdl : Tequipement; i,j,index,position : integer; - posAig,SortirBoucle : boolean; + SortirBoucle,NePasfaire : boolean; begin - posAig:=true; // répète la route depuis un aiguillage inc(iteration); if DebugTCO then AfficheDebug('El_TCO',clorange); @@ -10381,7 +10625,7 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter end; Bimage:=tco[indextco,x,y].Bimage; - if adresse=det1 then ir:=1; // index de stockage de trace + //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); @@ -10389,10 +10633,10 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter 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 + // si canton, prendre les coordonnées du canton if (Bimage>=id_cantonH) and (Bimage<=id_cantonH+9) then begin //if mode=10 then trouveCanton:=true; @@ -10411,10 +10655,14 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter Ycanton:=y-(Bimage-Id_cantonH); end; Bimage:=20; - end; + end; + // spécial mode 11 et 12 + nepasfaire:=(mode=12) and (adresse<>0) and (adresse<>det1); + nepasfaire:=(mode=11) and (adresse<>0) or nepasfaire; + + if not(nepasFaire) then case Bimage of - // voie 1 : begin if debugTCO then @@ -10429,7 +10677,7 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter 2 : begin yn:=y; if (ancienXy) then begin xn:=x+1;xn:=x+1;end; + if (ancienXy) then begin xn:=x+1;yn:=y;end; if (ancienX>x) and (ancienY=Y) then begin if not(posAig) or (posAig and (position=const_droit)) then @@ -10437,7 +10685,7 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter ancienX:=x; ancienY:=y; dec(x); - el_tco(x,y,train,ir); // essaye droit + el_tco(AncienX,AncienY,x,y,train,ir); // essaye droit inc(x); end; // essayer dévié @@ -10445,20 +10693,20 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter begin AncienX:=x;AncienY:=y; dec(x);inc(y); - el_tco(x,y,train,ir); // nouvelle itération + el_tco(ancienx,ancienY,x,y,train,ir); // nouvelle itération end; if (position=const_inconnu) and posaig then sortir:=true; end; end; 3 : begin - if (ancienX>x) and (ancienY<=Y) then begin xn:=x-1;end; + if (ancienX>x) and (ancienY<=Y) then begin xn:=x-1;yn:=y;end; // pris en pointe if (ancienXx) and not(Memtrouve) then // on va à gauche @@ -10656,14 +10904,14 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter // essayer vers O ancienX:=x;ancienY:=y; x:=x-1; - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); if not(memtrouve) then begin // essai vers SO AncienY:=y; AncienX:=x+1; y:=y+1;x:=x; - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); end; end; end; @@ -10700,14 +10948,14 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter // essayer vers E ancienX:=x;ancienY:=y; x:=x+1; - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); if not(memtrouve) then begin // essai vers SE AncienY:=y; AncienX:=x-1; y:=y+1;x:=x; - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); end; end; if (ancienX>x) and not(Memtrouve) then // on va à gauche @@ -10715,14 +10963,14 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter // essayer vers O ancienX:=x;ancienY:=y; x:=x-1; - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); if not(memtrouve) then begin // essai vers NO AncienY:=y; AncienX:=x+1; y:=y-1;x:=x; - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); end; end; end; @@ -10732,10 +10980,10 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter // croisement begin if DebugTCO then AfficheDebug('croisement',clyellow); - if (ancienXx) and (ancienY=Y) then begin casok:=true;xn:=x-1;end; - if (ancienX>x) and (ancienY>Y) then begin casok:=true;xn:=x-1;yn:=y-1;end; - if (ancienXx) and (ancienY=Y) then begin xn:=x-1;end; + if (ancienX>x) and (ancienY>Y) then begin xn:=x-1;yn:=y-1;end; + if (ancienXy) and not(Memtrouve) then // on monte @@ -10776,14 +11024,14 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter // essayer vers N ancienX:=x;ancienY:=y; y:=y-1; - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); if not(memtrouve) then begin // essai vers NE AncienY:=y+1; AncienX:=x; x:=x+1; - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); end; end; end; @@ -10816,14 +11064,14 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter begin ancienX:=x;ancienY:=y; dec(y); - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); inc(y); end; if not(memtrouve) and not(sortir) and (not(posaig) or (posAig and (position=const_devie))) then begin ancienX:=x;ancienY:=y; dec(x);dec(y); - el_tco(x,y,train,ir); // nouvelle itération + el_tco(ancienx,ancienY,x,y,train,ir); // nouvelle itération end; if (position=const_inconnu) and posaig then sortir:=true; end; @@ -10844,14 +11092,14 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter // essayer vers S ancienX:=x;ancienY:=y; y:=y+1; - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); if not(memtrouve) then begin // essai vers SE AncienY:=y-1; AncienX:=x; x:=x+1; - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); end; end; if (ancienY>y) and not(Memtrouve) then // on monte @@ -10859,14 +11107,14 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter // essayer vers N ancienX:=x;ancienY:=y; y:=y-1; - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); if not(memtrouve) then begin // essai vers NO AncienY:=y+1; AncienX:=x; x:=x-1; - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); end; end; end; @@ -10897,14 +11145,14 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter begin ancienX:=x;ancienY:=y; dec(y); - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); inc(y); end; if not(memtrouve) and not(sortir) and (not(posaig) or (posAig and (position=const_devie))) then begin ancienX:=x;ancienY:=y; inc(x);dec(y); - el_tco(x,y,train,ir); // nouvelle itération + el_tco(ancienx,ancienY,x,y,train,ir); // nouvelle itération end; if (position=const_inconnu) and posaig then sortir:=true; end; @@ -10920,16 +11168,16 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter if not(posAig) or (posAig and (position=const_droit)) then begin ancienX:=x;ancienY:=y; - y:=y+1; + inc(y); // essayer droit - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); dec(y); end; if not(memtrouve) and not(sortir) and (not(posaig) or (posAig and (position=const_devie))) then begin ancienX:=x;ancienY:=y; dec(x);inc(y); - el_tco(x,y,train,ir); // nouvelle itération + el_tco(ancienx,ancienY,x,y,train,ir); // nouvelle itération end; if (position=const_inconnu) and posaig then sortir:=true; end; @@ -10945,14 +11193,14 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter begin ancienX:=x;ancienY:=y; inc(y); - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); dec(y); end; if not(memtrouve) and not(sortir) and (not(posaig) or (posAig and (position=const_devie))) then begin ancienX:=x;ancienY:=y; inc(x);inc(y); - el_tco(x,y,train,ir); // nouvelle itération + el_tco(ancienx,ancienY,x,y,train,ir); // nouvelle itération end; if (position=const_inconnu) and posaig then sortir:=true; end; @@ -10969,14 +11217,14 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter ancienX:=x;ancienY:=y; inc(x);inc(y); // essayer droit - el_tco(x,y,train,ir); + el_tco(ancienx,ancienY,x,y,train,ir); dec(x);dec(y); end; if not(memtrouve) and not(sortir) and (not(posaig) or (posAig and (position=const_devie))) then begin ancienX:=x;ancienY:=y; inc(y); - el_tco(x,y,train,ir); // nouvelle itération + el_tco(ancienx,ancienY,x,y,train,ir); // nouvelle itération end; if (position=const_inconnu) and posaig then sortir:=true; end; @@ -10993,15 +11241,15 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter if not(posAig) or (posAig and (position=const_droit)) then begin ancienX:=x;ancienY:=y; - y:=y+1;x:=x-1; - el_tco(x,y,train,ir); + dec(x);inc(y); + el_tco(ancienx,ancienY,x,y,train,ir); inc(x);dec(y); end; if not(memtrouve) and not(sortir) and (not(posaig) or (posAig and (position=const_devie))) then begin ancienX:=x;ancienY:=y; inc(y); - el_tco(x,y,train,ir); // nouvelle itération + el_tco(ancienx,ancienY,x,y,train,ir); // nouvelle itération end; if (position=const_inconnu) and posaig then sortir:=true; end; @@ -11017,15 +11265,15 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter if not(posAig) or (posAig and (position=const_droit)) then begin ancienX:=x;ancienY:=y; - y:=y-1;x:=x-1; - el_tco(x,y,train,ir); + dec(x);dec(y); + el_tco(ancienx,ancienY,x,y,train,ir); inc(x);inc(y); end; if not(memtrouve) and not(sortir) and (not(posaig) or (posAig and (position=const_devie))) then begin ancienX:=x;ancienY:=y; dec(y); - el_tco(x,y,train,ir); // nouvelle itération + el_tco(ancienx,ancienY,x,y,train,ir); // nouvelle itération end; if (position=const_inconnu) and posaig then sortir:=true; end; @@ -11039,15 +11287,15 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter if not(posAig) or (posAig and (position=const_droit)) then begin ancienX:=x;ancienY:=y; - y:=y-1;x:=x+1; - el_tco(x,y,train,ir); + inc(x);dec(y); + el_tco(ancienx,ancienY,x,y,train,ir); dec(x);inc(y); end; if not(memtrouve) and not(sortir) and (not(posaig) or (posAig and (position=const_devie))) then begin ancienX:=x;ancienY:=y; dec(y); - el_tco(x,y,train,ir); // nouvelle itération + el_tco(ancienx,ancienY,x,y,train,ir); // nouvelle itération end; if (position=const_inconnu) and posaig then sortir:=true; end; @@ -11059,15 +11307,15 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter // fausse route, sortir if DebugTCO then AfficheDebug('Sortie de calcul route TCO'+intToSTR(indexTCO)+' par élement '+intToSTR(Bimage)+' inconnu en x='+intToSTR(x)+' y='+intToSTR(y)+' sur route '+intToSTR(det1)+' à '+intToSTR(det2),clOrange); - sortir:=true; + sortirBoucle:=true; 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; + // éléments adj + if (mode=11) and ( (adresse<>0) 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; @@ -11076,7 +11324,9 @@ var i,ir,adresse,But,Bimage,direction,ancienX,ancienY,x,y,xn,yn,Xdet1,yDet1,iter 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) and not(sortir) then AfficheDebug('Fin de boucle dét '+intToSTR(det2)+' non trouvé',clOrange); + result:=memTrouve; + 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 @@ -11099,7 +11349,8 @@ 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 (IndexTCO<1) or (IndexTCO>NbreTCO) then exit; + if (PcanvasTCO[indexTCO]=nil) and (mode<10) then exit; if (mode<=10) then begin @@ -11156,28 +11407,32 @@ begin if mode<=10 then begin ancieny:=ydet1+1;ancienx:=xdet1+1;end else - begin ancieny:=det2+1; ancienx:=det1+1; end; + // vers gauche + begin ancieny:=y; ancienx:=x+1; end; end; 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; + // vers droite + begin ancieny:=y; ancienx:=x-1; end; end; 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; + // vers bas + begin ancieny:=y-1; ancienx:=x; end; end; 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; + // vers haut + begin ancieny:=y+1; ancienx:=x; end; end; // uniquement modes 11/12: recherche élément à gauche @@ -11209,7 +11464,7 @@ begin ycanton:=0; end; - El_tco(x,y,train,ir); // *********** trouve l'élément suivant, et explore les ports de l'aiguillage en récursif + el_tco(ancienx,ancienY,x,y,train,ir); // *********** trouve l'élément suivant, et explore les ports de l'aiguillage en récursif si posAig=true if (mode=11) and ((adresse<>0) or (but<>0) or sortir) then begin @@ -11221,6 +11476,7 @@ begin if (mode=12) and (adresse<>det1) then begin Xcanton:=adresse; + if isAigTCO(Bimage) then Tel1:=aig else tel1:=det; Memtrouve:=true; end; @@ -11254,7 +11510,6 @@ 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; @@ -11489,22 +11744,28 @@ begin left:=0; end; - if MasqueBandeauTCO then + // if MasqueBandeauTCO then + if bandeauMasque then begin - BandeauMasque:=true; + //BandeauMasque:=true; PanelBas.Hide; //ScrollBox.Height:=clientHeight; - ScrollBox.Height:=ClHaut-ScrollBox.Top-10; + ScrollBox.Height:=ClHaut-ScrollBox.Top-58; end else begin BandeauMasque:=false; PanelBas.show; - ScrollBox.Height:=ClHaut-PanelBas.Height-ScrollBox.Top-54; + ScrollBox.Height:=ClHaut-PanelBas.Height-ScrollBox.Top-58; end; end; end; +procedure titre_fenetre(indexTCO : integer); +begin + FormTCO[IndexTCO].Caption:='TCO'+intToSTR(indexTCO)+' : '+NomFichierTCO[indexTCO]; +end; + procedure TFormTCO.FormActivate(Sender: TObject); //procedure PFormTCO[indexTCO].FormActivate(Sender: TObject); var indextco : integer; @@ -11512,7 +11773,7 @@ begin indextco:=index_TCO(sender); IndexTCOCourant:=indexTCO; if affevt or (debug=1) then Affiche('Form TCO'+intToSTR(indexTCO)+' activate',clyellow); - Caption:='TCO'+intToSTR(indexTCO)+' : '+NomFichierTCO[indexTCO]; + titre_fenetre(indexTCO); if indexTCO=0 then exit; {initalisation des dimensions du tco - à ne faire qu'une fois} if not(Forminit[indexTCO]) then @@ -11527,7 +11788,6 @@ begin LargeurCelld2[indexTCO]:=LargeurCell[indexTCO] div 2;hauteurCelld2[indexTCO]:=hauteurCell[indexTCO] div 2; calcul_reduction(frxGlob[indexTCO],fryGlob[indexTCO],LargeurCell[indexTCO],hauteurCell[indexTCO]); - NbCellulesTCO[indexTCO]:=NbreCellX[indexTCO]*NbreCellY[indexTCO]; ImageTCO.Width:=LargeurCell[indexTCO]*NbreCellX[indexTCO]; ImageTCO.Height:=hauteurCell[indexTCO]*NbreCellY[indexTCO]; @@ -11569,7 +11829,7 @@ begin result:=true; verif:=false; if (bim>=Id_signal) or (AvecVerifIconesTCO=0) then exit; - //exit; + res:=true; bl:=liaisons[Bim]; for i:=0 to 7 do @@ -11728,7 +11988,7 @@ begin begin tco[idT,i,yc].BImage:=1; tco[idT,i,yc].Texte:=''; - tco[idT,i,yc].PiedFeu:=0; + tco[idT,i,yc].NumCanton:=0; tco[idT,i,yc].FeuOriente:=0; end; end @@ -11739,7 +11999,7 @@ begin begin tco[idT,xc,i].BImage:=20; tco[idT,xc,i].Texte:=''; - tco[idT,xc,i].PiedFeu:=0; + tco[idT,xc,i].NumCanton:=0; tco[idT,xc,i].FeuOriente:=0; end; end; @@ -11775,6 +12035,7 @@ begin tco[indextco,x,y].CoulFonte:=0; // tco[indextco,x,y].CouleurFond:=0; tco[indextco,x,y].PiedFeu:=0; + tco[indexTCO,x,y].NumCanton:=0; tco[indextco,x,y].x:=0; tco[indextco,x,y].y:=0; tco[indextco,x,y].xUndo:=0; @@ -11783,35 +12044,69 @@ begin end; procedure insere_colonne(indexTCO,colonne : integer); -var x,y : integer; +var x,y,i,Bim : integer; begin if NbreCellX[indexTCO]>=MaxCellX then exit; + + // balayer les cantons pour corriger leurs coordonnées + for i:=1 to nCantons do + begin + x:=canton[i].x; + if x>=colonne then + inc(canton[i].x); + end; + + // copie pour décaler for x:=NbreCellX[indexTCO] downto colonne do begin - for y:=1 to NbreCellY[indexTCO] do tco[indextco,x+1,y]:=tco[indextco,x,y]; + for y:=1 to NbreCellY[indexTCO] do + begin + Bim:=tco[indexTco,x,y].Bimage; + if not(isCantonH(Bim)) then tco[indextco,x+1,y]:=tco[indextco,x,y]; + end; end; + + // efface la nouvelle ligne for y:=1 to NbreCellY[indexTCO] do begin - raz_cellule(indextco,colonne,y); + Bim:=tco[indexTco,colonne,y].Bimage; + if not(isCantonH(Bim)) then raz_cellule(indextco,colonne,y); tco[indextco,colonne,y].Couleurfond:=Clfond[IndexTCO]; end; + inc(NbreCellX[indexTCO]); tco_modifie:=true; end; procedure insere_ligne(indexTCO,ligne : integer); -var x,y : integer; +var x,y,i,Bim : integer; begin if NbreCellY[indexTCO]>=MaxCellY then exit; - for y:=NbreCellY[indexTCO] downto ligne do - for x:=1 to NbreCellX[indexTCO] do tco[indextco,x,y+1]:=tco[indextco,x,y]; + // balayer les cantons pour corriger leurs coordonnées + for i:=1 to nCantons do + begin + y:=canton[i].y; + if y>=ligne then inc(canton[i].y); + end; + + // insère la ligne + for y:=NbreCellY[indexTCO] downto ligne do + for x:=1 to NbreCellX[indexTCO] do + begin + Bim:=tco[indexTco,x,y].Bimage; + if not(isCantonV(Bim)) then tco[indextco,x,y+1]:=tco[indextco,x,y]; + end; + + // efface la nouvelle ligne for x:=1 to NbreCellX[indexTCO] do begin - raz_cellule(indextco,x,ligne); + Bim:=tco[indexTco,x,ligne].Bimage; + if not(isCantonV(Bim)) then raz_cellule(indextco,x,ligne); tco[indextco,x,ligne].Couleurfond:=Clfond[IndexTCO]; end; inc(NbreCellY[indexTCO],1); + tco_modifie:=true; end; @@ -11867,7 +12162,6 @@ begin end; end; - procedure stop_modetrace(indexTCO : integer); begin modetrace[indexTCO]:=false; @@ -11880,8 +12174,6 @@ begin screen.cursor:=crDefault; end; - - procedure grille(indexTCO : integer); var x,y : integer; begin @@ -11965,23 +12257,25 @@ end; procedure couper(indexTCO: integer); var x,y,xMax,Ymax,XCell1,YCell1,xCell2,yCell2,haut,larg,Bim : integer; + raz_canton: boolean; begin larg:=largeurCell[indexTCO]; haut:=hauteurCell[indexTCO]; + raz_canton:=false; if (XclicCell[indexTCO]=0) or (YclicCell[indexTCO]=0) then exit; //Affiche(intToSTR(ancienXclic)+' '+intToSTR(XclicCell[indexTCO]),clred); //if (AncienXclic=XclicCell[indexTCO]) and (AncienYclic=YclicCell[indexTCO]) then exit; AncienXclic:=XclicCell[indexTCO]; AncienYclic:=YclicCell[indexTCO]; + { with formTCO[indexTCO] do begin EditAdrElement.Text:=''; EditTypeImage.Text:=''; EditTexte.Text:=''; - end; - + end; } // couper par la fenetre graphique if FormTCO[indexTCO].RadioGroupSel.ItemIndex=1 then @@ -12015,19 +12309,20 @@ 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 + // si c'est un canton, le supprimer en remplaçant 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); + raz_canton:=true; 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]; - raz_cellule(indextco,XclicCell[indexTCO],YClicCell[indexTCO]); + if not(raz_canton) then raz_cellule(indextco,XclicCell[indexTCO],YClicCell[indexTCO]); TamponTCO_org.numTCO:=indexTCO; efface_entoure(indexTCO); @@ -12320,7 +12615,7 @@ 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); + Id:=Index_canton_numero(Tco[indexTCO,x,y].NumCanton); if id=0 then exit; n:=canton[Id].Nelements; horizontal:=canton[Id].horizontal; @@ -12384,14 +12679,14 @@ begin if (TCODrag<>indexTCO) then begin accept:=false; - exit; // le drag source et destination sont différents + exit; // le drag tco source et destination sont différents end; xl:=x+offsetSourisX; yl:=y+offsetSourisY; Accept:=source is TImage; - if drag=1 then + if drag=1 then // icone de TCO begin - if affevt then Affiche('TCO'+intToSTR(IndexTCO)+' DragOver type1',clyellow); + if affevt then Affiche('TCO'+intToSTR(IndexTCO)+' DragOver type1 x='+intToSTR(x)+' y='+intToSTR(y),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 @@ -12401,9 +12696,10 @@ begin 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 + if drag=2 then // loco begin - if affevt then Affiche('TCO'+intToSTR(IndexTCO)+' DragOver type2',clyellow); + //if affevt then + //Affiche('TCO'+intToSTR(IndexTCO)+' DragOver type2 x='+intToSTR(x)+' y='+intToSTR(y),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 @@ -12412,6 +12708,7 @@ begin // 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; @@ -12514,8 +12811,15 @@ begin if ((bim<>1) and (bim<>20)) or (Ncantons>=MaxCantons) then begin Affiche_TCO(indexTCO); - exit; - end; + s:='Un canton doit être déposé sur un élément horizontal ou vertical d''au moins 3 cases'; + formTCO[indexTCO].Caption:=s; + Affiche_TCO(indexTCO); + FormInfo.LabelInfo.caption:=s; + FormInfo.Top:=Y+20; + FormInfo.Left:=X+50; + FormInfo.Show; + exit; + end; for i:=0 to 2 do begin @@ -12523,7 +12827,13 @@ begin begin if (tco[indexTCO,Xclic+i,Yclic].BImage<>1) or (tco[indexTCO,Xclic+i,Yclic].Adresse<>0) then begin - Affiche_TCO(indexTCO); + s:='Un canton doit être déposé sur un élément horizontal ou vertical d''au moins 3 cases'; + formTCO[indexTCO].Caption:=s; + Affiche_TCO(indexTCO); + FormInfo.LabelInfo.caption:=s; + FormInfo.Top:=Y+20; + FormInfo.Left:=X+50; + FormInfo.Show; exit; end; end; @@ -12531,13 +12841,37 @@ begin begin if (tco[indexTCO,Xclic,Yclic+i].BImage<>20) or (tco[indexTCO,Xclic,Yclic+i].Adresse<>0) then begin - Affiche_TCO(indexTCO); + s:='Un canton doit être déposé sur un élément horizontal ou vertical d''au moins 3 cases'; + formTCO[indexTCO].Caption:=s; + Affiche_TCO(indexTCO); + FormInfo.LabelInfo.caption:=s; + FormInfo.Top:=Y+20; + FormInfo.Left:=X+50; + FormInfo.Show; exit; end; end; end; - //pour le numéro de canton, + // l'un des deux éléments du canton doit être un détecteur + canton[Ncantons+1].Nelements:=3; + canton[Ncantons+1].x:=Xclic; + canton[Ncantons+1].y:=Yclic; + canton[Ncantons+1].Ntco:=indexTCO; + renseigne_canton(Ncantons+1,Bim=1); + if (canton[Ncantons+1].typ1<>det) and (canton[Ncantons+1].typ2<>det) then + begin + s:='Un canton doit avoir un détecteur comme élément adjacent'; + formTCO[indexTCO].Caption:=s; + Affiche_TCO(indexTCO); + FormInfo.LabelInfo.caption:=s; + FormInfo.Top:=Y+20; + FormInfo.Left:=X+50; + FormInfo.Show; + exit; + end; + + // pour le numéro de canton, maxi:=0; for nc:=1 to nCantons do begin @@ -12555,13 +12889,19 @@ begin canton[Ncantons].nom:=''; canton[Ncantons].Ntco:=indexTCO; canton[Ncantons].indexTrain:=0; + canton[Ncantons].adresseTrain:=0; + canton[Ncantons].NomTrain:=''; + canton[Ncantons].SensLoco:=0; + canton[Ncantons].NumcantonOrg:=0; + canton[Ncantons].NumCantonDest:=0; + canton[Ncantons].bouton:=0; tco[indextco,XClic,YClic].Texte:=''; tco[indexTCO,XClic,YClic].FeuOriente:=3; // nbre éléments du canton - tco[indexTCO,XClic,YClic].PiedFeu:=Maxi; + tco[indexTCO,XClic,YClic].NumCanton:=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); + dessin_canton(Ncantons,0); renseigne_canton(Ncantons); end; end; @@ -13339,7 +13679,7 @@ 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; + s,s1,s2 : string; begin xclic:=XclicCell[indexTCO]; yclic:=YclicCell[indexTCO]; @@ -13350,54 +13690,73 @@ begin begin xt:=xClic-(Bimage-Id_cantonH); yt:=yClic; - IdCantonSelect:=index_canton_numero(TCO[IndexTCO,xt,yt].PiedFeu); + IdCantonSelect:=index_canton_numero(TCO[IndexTCO,xt,yt].NumCanton); end; if IscantonV(Bimage) then begin yt:=yClic-(Bimage-Id_cantonV); xt:=xClic; - IdCantonSelect:=index_canton_numero(TCO[IndexTCO,xt,yt].PiedFeu); + IdCantonSelect:=index_canton_numero(TCO[IndexTCO,xt,yt].NumCanton); end; - //Affiche('Selection canton id='+intToSTR(IdCantonSelect)+' num='+intToSTR(TCO[IndexTCO,xt,yt].PiedFeu),clYellow); + //Affiche('Selection canton id='+intToSTR(IdCantonSelect)+' num='+intToSTR(TCO[IndexTCO,xt,yt].NumCanton),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); + Dessin_canton(IdCantonSelect,1); 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); //??? + //adresse:=index_canton_numero(TCO[IndexTCO,xt,yt].NumCanton); //??? idTrain:=canton[IdCantonSelect].IndexTrain; actualise_seltrains; + if idcantonSelect=0 then exit; s:='Canton '; - if IdCantonSelect<>0 then + s:=s+intToSTR(canton[IdCantonSelect].numero)+' '+canton[idcantonselect].nom; + s1:=s; + i:=canton[IdCantonSelect].indexTrain; + if (i>0) and (i<=Ntrains) 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; + s2:='Occupé par le train n°'+intToSTR(i)+' '+canton[IdCantonSelect].NomTrain+' '+ #13; + s2:=s2+'Adresse='+intToSTR(trains[i].adresse); end; - formTCO[indexTCO].imageTCO.hint:=s; + + {$IF CompilerVersion < 28.0} + formTCO[indexTCO].imageTCO.hint:=s1+#13+s2; + {$IFEND} + + {$IF CompilerVersion >= 28.0} + with formTCO[indexTCO] do + begin + BallonHint.Title:=s1; + BallonHint.Description:=s2; + BallonHint.Style:=bhsBalloon; + BallonHint.HideAfter:=4000; + x:=canton[IdCantonSelect].x*LargeurCell[indexTCO]; + y:=canton[IdCantonSelect].y*HauteurCell[indexTCO]-HauteurCell[indexTCO] div 2; + ballonhint.ShowHint(formTCO[indexTCO].ClientToScreen(point(x,y))); // affiche le ballonHint + end; + {$IFEND} 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; - xt,yt,bt,indexTCO,i,n,adresse,Bimage,xf,yf,xclic,yclic,IdCanton : integer; + Numcanton,xt,yt,bt,indexTCO,i,n,adresse,Bimage,xf,yf,xclic,yclic,el1,el2,senscanton,larg,haut, + indexTrain,idcantonOrg,AdrTrain : integer; + tel1,tel2 : tequipement; s : string; + presTrain : boolean; begin indexTCO:=index_tco(sender); GetCursorPos(Position); Position:=ImageTCO.screenToCLient(Position); + larg:=LargeurCell[indextco]; + haut:=HauteurCell[indextco]; Xclic:=position.X div LargeurCell[indexTCO] + 1; Yclic:=position.Y div hauteurCell[indexTCO] + 1; - if button=mbLeft then begin //Affiche('TCO'+intToSTR(indexTCO)+' souris clicG enfoncée',clYellow); @@ -13413,25 +13772,200 @@ begin clicsouris:=true; Bimage:=tco[indextco,xclic,yclic].BImage; + // clic sur canton + if isCanton(Bimage) then + begin + IdCantonClic:=index_canton(indexTCO,xclic,yclic); + if IdCantonClic>0 then + begin + s:='Canton '+intToSTR(canton[IdCantonClic].numero)+' '+canton[idcantonClic].nom+#13; + i:=canton[IdCantonClic].indexTrain; + if (i>0) and (i<=Ntrains) then + begin + s:=s+'Occupé par le train n°'+intToSTR(i)+' '+canton[IdCantonClic].NomTrain+' '+ #13; + s:=s+'Adresse='+intToSTR(trains[i].adresse); + end; + ImageTCO.hint:=s; + end; + end + + else + IdCantonSelect:=0; // pas cliqué sur un canton + + // ------------------ si clic sur bouton canton - IdCanton:=passe_bouton_canton(indexTCO,x,y); - if Idcanton>0 then + IdCantonClic:=passe_bouton_canton(indexTCO,x,y); + if (IdCantonClic>0) and not(ConfCellTCO) then begin //Affiche('Clic'+IntToSTR(IdCanton),clYellow); - bt:=canton[IdCanton].bouton; + bt:=canton[IdCantonClic].bouton; case bt of 0 : bt:=1; 1 : bt:=2; 2 : bt:=0; end; - canton[IdCanton].bouton:=bt; - Dessin_canton(Idcanton,0,bt); + canton[IdCantonClic].bouton:=bt; + Dessin_canton(IdCantonClic,0); // colore le bouton en bt + el1:=canton[IdCantonClic].el1;tel1:=canton[IdCantonClic].typ1; + el2:=canton[IdCantonClic].el2;tel2:=canton[IdCantonClic].typ2; + + // coordonnées du bouton en xt,yt + n:=canton[IdCantonClic].Nelements; + if canton[IdCantonClic].horizontal then + begin + xt:=(canton[IdCantonClic].x+n-2)*larg; + yt:=(canton[IdCantonClic].y-1)*Haut; + end + else + begin + xt:=(canton[IdCantonClic].x-1)*LargeurCell[indextco]; + yt:=(canton[IdCantonClic].y+n-2)*HauteurCell[indexTCO]; + end; + + // pas de départ en mode CDM + if Cdm_Connecte then + begin + FormTCO[IndexTCO].Caption:='Les routes sont incompatibles en mode CDM rail'; + exit; + end; + + // validation détecteur départ si pas de départ défini + if (detdepart=0) and (bt<3) and not(ConfCellTCO) then // bt=3 drapeau vert 4=drapeau rouge + begin + indexTrain:=canton[IdCantonClic].indexTrain; + if indexTrain=0 then exit; // si pas de train affecté au canton + if trains[indexTrain].roulage<>0 then + begin + ImageTCO.hint:='Canton occupé par train '+canton[IdCantonClic].NomTrain; + imageTCO.ShowHint:=true; + exit; // si route en cours, ne rien faire + end; + //voir si det1 ou det2 est occupé + titre_fenetre(indexTCO); + PresTrain:=false; + if tel1=det then presTrain:=detecteur[el1].Etat; + if tel2=det then presTrain:=detecteur[el2].Etat or PresTrain; + if not(PresTrain) then + begin + FormTCO[IndexTCO].Caption:='Attention, aucun train n''est physiquement présent dans le canton pour définir une route - Aucun des deux détecteurs encadrant le canton n''est à 1'; + exit; + end; + if tel1=det then detDepart:=el1; + if tel2=det then detDepart:=el2; + cantonOrg:=canton[IdCantonClic].numero; + canton[IdCantonClic].NumCantonOrg:=cantonOrg; + sensCanton:=canton[IdCantonClic].sensLoco; + case sensCanton of // sens de la loco dans le canton + sensGauche : begin sens:=5;end; + sensDroit : begin sens:=6;end; + SensHaut : begin sens:=7;end; + SensBas : begin sens:=8;end; + end; + //Affiche('Départ depuis '+intToSTR(detDepart),clLime); + formTCO[indexTCO].caption:='Route depuis détecteur '+intToSTR(detDepart); + idcantonRoute:=IdCantonClic; + ImageTCO.Hint:='Départ depuis canton '+intToSTR(canton[IdCantonClic].numero)+' dét='+intToSTR(detDepart); + Screen.Cursor:=crUpArrow; //crHourGlass; + + // image du drapeau vert + canton[IdCantonClic].bouton:=3; + dessin_canton(IdCantonClic,0); + canton[idCantonClic].AdrTrainRoute:=Trains[indexTrain].adresse; + //trains[IndexTrain].Det_depart:=DetDepart; + formroute.close; + end + else + begin + // detdépart validé : valider le det de destination + if (detatrouve=0) and (bt<3) and not(ConfCellTCO) then // bt=3 drapeau vert bt=4 drapeau rouge + begin + if canton[IdCantonClic].adresseTrain<>0 then + begin + ImageTCO.Hint:='Canton occupé par train '+canton[IdCantonClic].nomtrain; + exit; + end; + if tel1=det then detatrouve:=el1; + if tel2=det then detatrouve:=el2; + cantonDest:=canton[IdCantonClic].numero; + canton[IdCantonClic].NumCantonOrg:=cantonOrg; + canton[IdCantonClic].NumCantonDest:=cantonDest; // c'est lui meme + idcantonOrg:=index_canton_numero(cantonOrg); + canton[idcantonOrg].NumcantonOrg:=cantonOrg; + canton[idcantonOrg].NumcantonDest:=cantonDest; + + //Affiche('Arrivée en '+intToSTR(detatrouve),clLime); + ImageTCO.Cursor:=crDefault; + // trouve les routes - sens du canton d'origine + sensCanton:=canton[IdCantonOrg].sensLoco; + case sensCanton of // sens de la loco dans le canton + sensGauche : begin sens:=5;end; + sensDroit : begin sens:=6;end; + SensHaut : begin sens:=7;end; + SensBas : begin sens:=8;end; + end; + + // affiche la fenetre des routes ou de la route affectée au train, + indexTrain:=canton[IdCantonOrg].indexTrain; + if indexTrain>9000 then + begin + Affiche('Anomalie 627',clred); + messageBeep(Mb_iconError); + exit; + end; + + formTCO[indexTCO].Caption:='TCO'+intToSTR(indexTCO)+' : '+NomFichierTCO[indexTCO]; + Screen.cursor:=crDefault; + + // drapeau rouge : 4 + canton[IdCantonClic].bouton:=4; + canton[idCantonClic].AdrTrainRoute:=Trains[indexTrain].adresse; + dessin_canton(IdCantonClic,0); + FormTCO[IndexTCO].Caption:='Calcul des routes en cours.....................'; + application.processMessages; + prepare_route(detDepart,detAtrouve,sens); // à gauche(5) du détecteur / droite (6) / en bas (8) / haut (7) + if trains[indexTrain].route[0].adresse<>0 then formRouteTrain.show else formRoute.show; + titre_Fenetre(indexTCO); + detatrouve:=0; + detDepart:=0; + + exit; + end; + // on clique sur le drapeau vert ou rouge + if (bt>=3) then // canton de départ ou destination + begin + // est-ce un canton de destination? + Numcanton:=canton[IdCantonClic].numero; + if canton[IdCantonClic].NumCantonDest=NumCanton then + begin + Numcanton:=canton[IdCantonClic].NumcantonOrg; // revenir au canton origine de la route + IdCantonClic:=index_canton_numero(NumCanton); + end; + + // indexTrainFR:=canton[IdCantonClic].AdrTrainRoute; // train concerné par la route. Ne pas utiliser car si on clique sur + indexTrain:=canton[IdCantonClic].indexTrain; + // la route dans la fenêtre des routes alors que le train n'est pas dans le canton (la route est démarrée) alors le + // train disparaît du canton ( canton[].indexTrain repasse à 0) + //if indexTrainFR<>0 then + if indextrain<>0 then + begin + indexTrainFR:=IndexTrain; // la formRouteTrain utilise IndexTrainFR + if (trains[indexTrain].route[0].adresse<>0) then formRouteTrain.show else formRoute.show; + end; + AdrTrain:=canton[IdCantonClic].AdrTrainRoute; + if AdrTrain<>0 then + begin + IndexTrain:=index_train_adresse(AdrTrain); + ImageTCO.Hint:='Route affectée au train '+Trains[indexTrain].nom_train; + end + end; + end; exit; end else // ------------------ traitement clic sur canton sélectionné : le désélectionner - if IdCantonSelect<>0 then + titre_fenetre(indexTCO); + if (IdCantonSelect<>0) and not(ConfCellTCO) then begin if accroche_canton(indexTCO,IdCantonSelect,x,y) then exit; // on a pas cliqué sur les poignées begin @@ -13440,19 +13974,24 @@ begin //Affiche('Desel',clred); xt:=canton[IdCantonSelect].x; yt:=canton[IdCantonSelect].y; - IdCanton:=index_canton_numero(TCO[IndexTCO,xt,yt].PiedFeu); + IdCantonClic:=index_canton_numero(TCO[IndexTCO,xt,yt].NumCanton); Affiche_rectangle_canton(indexTCO,IdCantonSelect); // efface la sélection - Dessin_canton(Idcanton,0,bt); + Dessin_canton(IdCantonClic,0); + AncienIdCantonSelect:=IdCantonSelect; IdCantonSelect:=0; + exit; end; end; + // ne pas mettre de else sinon confusion entre le clic et le double clic du canton // ------------------ traitement clic sur canton non sélectionné : le sélectionner begin - if IsCanton(Bimage) then + if IsCanton(Bimage) and not(ConfCellTCO) then begin + formRoute.Close; selec_canton(indexTCO); actualise(indexTCO); // actualise la fenetre de paramétrage + ImageTCO.Hint:='canton '+intToSTR(canton[IdCantonSelect].numero); exit; end; end; @@ -13631,7 +14170,7 @@ begin end; // si clic souris en mode fenetre graphique: initialisation du rectangle bleu de sélection graphique - if (RadioGroupSel.ItemIndex=1) then + if (RadioGroupSel.ItemIndex=1) and not(ConfCellTCO) then begin if not(selectionAffichee[indexTCO]) then begin @@ -13708,7 +14247,7 @@ begin if IsAigTCO(Bimage) then begin adresse:=tco[IndexTCO,xClic,yClic].Adresse; - if adresse=0 then s:='Aiguillage sans adresse' + if adresse=0 then s:='Aiguillage sans adresse' else begin i:=index_aig(adresse); @@ -13741,16 +14280,16 @@ begin // réservation n:=aiguillage[i].AdrTrain; if n<>0 then s:=s+#13+'Réservé par train '+intToSTR(n); - end; - ImageTCO.Hint:=s; - end - else ImageTCO.Hint:=''; + end; + ImageTCO.Hint:=s; + end + else ImageTCO.Hint:=''; - 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 + 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; clicTCO:=false; @@ -13785,12 +14324,13 @@ begin CheckPinv.Checked:=tco[indextco,XClicCellInserer,YClicCellInserer].inverse; clicTCO:=false; end; + titre_fenetre(indexTCO); end; procedure TFormTCO.ImageTCOMouseMove(Sender: TObject; Shift: TShiftState;X, Y: Integer); var r : Trect; - idTrain,indexTCO,xMiniSelP,yMiniSelP,xMaxiSelP,yMaxiSelP,larg,haut,IdCanton : integer; + Bim,idTrain,indexTCO,xMiniSelP,yMiniSelP,xMaxiSelP,yMaxiSelP,larg,haut,IdCanton : integer; ok : boolean; begin // if affevt then Affiche('ImageTCOMouseMove',clLime); @@ -13817,6 +14357,7 @@ begin // vérifier si sélection canton if IdCantonSelect<>0 then begin + //Affiche('Acc',clOrange); if Accroche_canton(IndexTCO,IdCantonSelect,x,y) then exit; idTrain:=canton[IdCantonSelect].indexTrain; @@ -13826,7 +14367,6 @@ begin exit; end; exit; - end; // vérifier si on passe au dessus d'un bouton canton IdCanton:=passe_bouton_canton(indexTCO,x,y); @@ -13835,16 +14375,16 @@ begin PimageTCO[indexTCO].Cursor:=crHandPoint; end else PimageTCO[indexTCO].Cursor:=CrDefault; - end; + if idcantonselect<>0 then exit; + aSourisx:=x; aSourisy:=y; if selecBouge then exit; if Temposouris>0 then exit; - // Affiche('*',cllime); - //affiche(intToSTR(y),clorange); + //affiche(intToSTR(cellx),clorange); if (AncienXClicCell=CellX) and (AncienYClicCell=CellY) then exit; @@ -13858,6 +14398,7 @@ begin if CellX>NbreCellX[indexTCO] then exit; if CellY>NbreCellY[indexTCO] then exit; + // si dessin voies tco if modeTrace[indexTCO] then begin if indexTrace>0 then @@ -13902,7 +14443,11 @@ begin TpsBougeSouris:=5; if not(clicsouris) or (temposouris>0) then exit; - //Affiche('ajuste rect',clWhite); + + Bim:=Tco[IndexTCO,cellx,celly].Bimage; + //Affiche('ajuste rect '+intToSTR(Bim)+' '+intToSTR(cellx)+' '+intToSTR(celly),clWhite); + if isCanton(Bim) then exit; // évite de tirer une sélection bleue depuis un TCO + larg:=largeurCell[indexTCO]; haut:=hauteurCell[indexTCO]; @@ -13988,7 +14533,7 @@ begin Nelements:=n; tco[indexTCO,xc,yc].Texte:=''; tco[IndexTCO,NouvX,yc].FeuOriente:=n; // nouveau nombre d'éléments - tco[IndexTCO,NouvX,yc].piedFeu:=canton[IdCantonSelect].numero; + tco[IndexTCO,NouvX,yc].NumCanton:=canton[IdCantonSelect].numero; Tco[IndexTCO,NouvX,yc].texte:=Tco[IndexTCO,xc,yc].texte; Tco[IndexTCO,NouvX,yc].train:=Tco[IndexTCO,xc,yc].train; canton[IdCantonSelect].x:=NouvX; @@ -14022,7 +14567,7 @@ begin Nelements:=n; tco[indexTCO,xc,yc].Texte:=''; tco[IndexTCO,xc,NouvY].FeuOriente:=n; - tco[IndexTCO,xc,NouvY].piedFeu:=canton[IdCantonSelect].numero; + tco[IndexTCO,xc,NouvY].NumCanton:=canton[IdCantonSelect].numero; Tco[IndexTCO,xc,Nouvy].train:=Tco[IndexTCO,xc,yc].train; Tco[IndexTCO,xc,Nouvy].Texte:=Tco[IndexTCO,xc,yc].texte; canton[IdCantonSelect].y:=NouvY; @@ -14070,8 +14615,9 @@ procedure TFormTCO.EditAdrElementChange(Sender: TObject); var Adr,erreur,index,indexTCO : integer; s: string; begin + exit; //Affiche('Chgt adresse',clyellow); - if clicTCO or ConfCellTCO then exit; + if clicTCO or not(ConfCellTCO) then exit; clicTCO:=true; auto_tcurs:=false; // interdit le déplacement du curseur encadré du TCO (pour que les touches curseur s'applique au Tedit) indexTCO:=index_TCO(sender); @@ -14147,7 +14693,7 @@ begin end; end; -// affiche les cellules des tco dont l'adresse d'aiguillage est adresse +// affiche les cellules des tco dont l'adresse d'aiguillage/dét est adresse Procedure Texte_aig_fond(adresse : integer); var ntco,x,y,Bim : integer; begin @@ -14160,7 +14706,7 @@ begin for x:=1 to NbreCellX[ntco] do begin Bim:=TCO[ntco,x,y].BImage; - if IsAigTCO(Bim) then + //if IsAigTCO(Bim) then begin if TCO[ntco,x,y].Adresse=adresse then begin @@ -14481,6 +15027,7 @@ begin Affiche_TCO(indexTCO); SelectionAffichee[indexTCO]:=false; Rect_select.NumTCO:=0; + AncienIdCantonSelect:=IdCantonSelect; IdCantonSelect:=0; tabstop:=false; @@ -14542,7 +15089,7 @@ begin aiguillage[Index_Aig(117)].position:=const_devie; //debugTco:=true; - zone_tco(1,527,519,1,0,1); + zone_tco(1,527,519,1,0,1,false); // zone_tco(518,515,1); //zone_tco(522,514,1); @@ -14581,6 +15128,7 @@ begin clicsouris:=false; auto_tcurs:=true; // autorise le déplacement du des touches curseur encadré du TCO indexTCO:=index_TCO(sender); + Bimage:=tco[indextco,xClicCell[indexTCO],yClicCell[indexTCO]].BImage; Adresse:=tco[indextco,xClicCell[indexTCO],yClicCell[indexTCO]].Adresse; @@ -14627,7 +15175,7 @@ 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; + IdCanton:=TCO[IndexTCO,xt,yt].NumCanton; formSelTrain.Show; exit; end; @@ -15192,7 +15740,7 @@ end; procedure TFormTCO.SupprimeLigneClick(Sender: TObject); -var x,y,indexTCO : integer; +var x,y,i,indexTCO,n : integer; c : tcomponent; begin c:=popupmenu1.PopupComponent ; // imageTCO @@ -15216,7 +15764,7 @@ begin TamponTCO_org.xOrg:=1; TamponTCO_org.yOrg:=ligne_supprime; - // remplir tempon de sauvegarde + // remplir tampon de sauvegarde for y:=TamponTCO_Org.y1 to TamponTCO_Org.y2 do for x:=TamponTCO_Org.x1 to TamponTCO_Org.x2 do begin @@ -15224,6 +15772,20 @@ begin tampontco[x,y]:=tco[indextco,x,y]; end; + // balayer les cantons pour corriger leurs coordonnées + for i:=1 to nCantons do + begin + y:=canton[i].y; + n:=canton[i].numero; + if (canton[i].horizontal) and (y=ligne_Supprime) then + begin + //supprimer le canton + supprime_remplace_canton(i); + Affiche('canton '+intToSTR(n)+' supprimé',clOrange); + end + else if y>=ligne_Supprime then dec(canton[i].y); + end; + // supression ligne for y:=YClicCell[indexTCO] to NbreCellY[indexTCO]-1 do begin @@ -15239,11 +15801,9 @@ begin affiche_TCO(indexTCO); end; - - // suppression colonne procedure TFormTCO.ColonneClick(Sender: TObject); -var x,y,indexTCO : integer; +var x,y,i,indexTCO,n : integer; c : tcomponent; begin c:=popupmenu1.PopupComponent ; // imageTCO @@ -15272,6 +15832,21 @@ begin tampontco[x,y]:=tco[indextco,x,y]; // supression colonne + // balayer les cantons pour corriger leurs coordonnées + for i:=1 to nCantons do + begin + x:=canton[i].x; + n:=canton[i].numero; + if (not(canton[i].horizontal)) and (x=colonne_Supprime) then + begin + //supprimer le canton + supprime_remplace_canton(i); + Affiche('canton '+intToSTR(n)+' supprimé',clOrange); + end + else + if x>=colonne_supprime then dec(canton[i].x); + end; + for x:=xClicCell[indexTCO] to NbreCellx[indexTCO]-1 do begin for y:=1 to NbreCelly[indexTCO] do @@ -15765,6 +16340,17 @@ begin Affiche_TCO(indexTCO); end; +procedure masque_bandeau(indexTCO : integer); +begin + with formTCO[indexTCO] do + begin + PanelBas.Hide; + ScrollBox.Height:=ClientHeight; + BandeauMasque:=true; + Bandeau.Caption:='Afficher le bandeau'; + end; +end; + procedure TFormTCO.BandeauClick(Sender: TObject); var indexTCO : integer; begin @@ -15772,6 +16358,7 @@ begin if bandeauMasque then begin PanelBas.Show; + PanelBas.Visible:=true; BandeauMasque:=false; positionne(indexTCO); Bandeau.Caption:='Masquer le bandeau'; @@ -15779,10 +16366,7 @@ begin end else begin - PanelBas.Hide; - ScrollBox.Height:=ClientHeight; - BandeauMasque:=true; - Bandeau.Caption:='Afficher le bandeau'; + masque_bandeau(indexTCO); end; end; @@ -15840,7 +16424,7 @@ begin 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; + if index<>0 then s:=s+intToSTR(canton[index].numero)+' '+canton[index].nom; s:=s+' ?'; if Application.MessageBox(pchar(s),pchar('confirm'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then exit; end; @@ -15886,11 +16470,43 @@ begin end_drag(53,x,y,Sender,Target); end; -// fin de drag des trains dans le canton destination +procedure raz_canton_org_dest(idcantonDragOrg : integer); +var idtrain,Norg,Ndest : integer; +begin + idTrain:=canton[idcantonDragOrg].indexTrain; + trains[idtrain].canton:=0; + Trains[idtrain].route[0].adresse:=0; + canton[idcantonDragOrg].NomTrain:=''; + canton[idcantonDragOrg].indexTrain:=0; + canton[idcantonDragOrg].adresseTrain:=0; + Norg:=index_canton_numero(canton[idcantonDragOrg].NumcantonOrg); + Ndest:=index_canton_numero(canton[idcantonDragOrg].NumcantonDest); + canton[idcantonDragOrg].NumcantonOrg:=0; + canton[idcantonDragOrg].NumcantonDest:=0; + canton[idcantonDragOrg].bouton:=0; + if norg>0 then + begin + canton[Norg].bouton:=0; + canton[Norg].NumcantonOrg:=0; + canton[Norg].NumCantonDest:=0; + dessin_canton(Norg,0); + end; + if nDest>0 then + begin + canton[Ndest].bouton:=0; + canton[Ndest].NumcantonOrg:=0; + canton[Ndest].NumCantonDest:=0; + dessin_canton(Ndest,0); + end; + TCO[canton[idcantonDragOrg].Ntco,canton[idcantonDragOrg].x,canton[idcantonDragOrg].y].train:=0; +end; + +// fin de drag des trains dans le canton de dépose 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; + Sens,idCantondest,IdTrain,Bim,xdest,ydest,xOrg,Yorg,indexTCO,milieuX_pix,milieuY_pix, + xPix,yPix,adresse,AdrTrain,xDrag,yDrag : integer; + t : tequipement; begin if not(Target is TImage) then exit; s:=(Target as TImage).Name; @@ -15899,64 +16515,135 @@ begin indexTCO:=Index_tco(sender); Drag:=0; - // origine + xDrag:=x;yDrag:=y; + // canton origine xOrg:=canton[IdCantonDragOrg].x; yOrg:=canton[IdCantonDragOrg].y; + // coordonnnées cellules de la destination xdest:=(x div largeurCell[indexTCO])+1; ydest:=(y div largeurCell[indexTCO])+1; + x:=xdest; + y:=ydest; + coord_canton(indexTCO,x,y); // x et y deviennent les coordonnées origine du canton + Bim:=tco[indexTCO,xdest,ydest].BImage; + // si on dépose pas sur un canton if not(IsCanton(Bim)) then begin + s:='Voulez vous supprimer le train '+canton[idcantonDragOrg].NomTrain+' du canton '+intToSTR(canton[idcantonDragOrg].numero)+' ?'; + if Application.MessageBox(pchar(s),pchar('confirmation'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idYes then + begin + supprime_route_train(canton[idcantonDragOrg].indexTrain); + raz_canton_org_dest(idcantonDragOrg); + end; + 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); + // dessine le train sur le canton de destination + //BitBlt(PcanvasTCO[indexTCO].handle,oldx+50,oldy,LIcone,hIcone,oldbmp.canvas.handle,0,0,SRCCOPY); + + // ici on dépose sur un canton + IdCantonDest:=index_canton_numero(tco[IndexTCO,x,y].NumCanton); + + AdrTrain:=canton[IdCantonDragOrg].adresseTrain; // train sur le canton source + IdTrain:=index_train_adresse(AdrTrain); + // si le train du canton source a une route affectée + if Trains[IdTrain].route[0].adresse<>0 then + begin + s:='Le train '+Trains[idTrain].nom_train+' a une route affectée.'+#13; + if idcantonDest=idcantonDragOrg then s:=s+'Changer le sens de départ va détruire sa route.'+#13 + else s:=s+'Changer le train de canton va détruire sa route.'+#13; + s:=s+'Voulez vous continuer ?'; + if Application.MessageBox(pchar(s),pchar('Confirmation'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then + begin + Affiche_tco(indexTCO); + exit; + end; + supprime_route_train(idTrain); + end; + + // voir si gauche ou droit du canton + Xpix:=(x-1)*LargeurCell[indexTCO]; + Ypix:=(y-1)*HauteurCell[indexTCO]; + + milieuX_pix:=xpix+(canton[idcantonDest].Nelements*largeurCell[indexTCO] div 2); + milieuY_pix:=Ypix+(canton[idcantonDest].Nelements*HauteurCell[indexTCO] div 2); + + if canton[idcantonDest].horizontal then + begin + if xDrag>milieuX_pix then sens:=sensDroit + else sens:=sensGauche; + end + else + begin + if yDrag>milieuY_pix then sens:=sensBas + else sens:=sensHaut; + end; + + // vérifier si le sens de dépose est compatible avec le sens du canton + if (canton[idcantonDest].SensCirc<>0) and (canton[idcantonDest].SensCirc<>sens) then + begin + s:='Le sens de circulation du canton '+intToSTR(canton[idcantonDest].numero)+' ne permet pas de positionner le train dans ce sens'; + formTCO[indexTCO].Caption:=s; + Affiche_TCO(indexTCO); + FormInfo.LabelInfo.caption:=s; + FormInfo.Top:=Ypix; + FormInfo.Left:=Xpix; + + FormInfo.Show; + exit; + end; + + canton[IdCantonDest].SensLoco:=sens; - sens:=canton[IdCantonDragOrg].Sens; // copier le sens // raz train canton d'origine IdTrain:=canton[IdCantonDragOrg].indexTrain; + supprime_route_train(canton[idcantonDragOrg].indexTrain); + Raz_trains_idcanton(IdCantonDragOrg); // raz du train du canton - 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); + application.processMessages; Affiche_TCO(indexTCO); XclicCell[indexTCO]:=xDest; YclicCell[indexTCO]:=yDest; - // activer la route -// init_route_canton(idcantonDest,idtrain,true); + if idcantonDragOrg<>IdCantonDest then + begin + raz_canton_org_dest(idcantonDragOrg); + end; + actualise_seltrains; // actualise la fenetre FormSelTrains + + // Affecter le train au détecteur si l'élément concerné du canton est un détecteur + case sens of + SensGauche,SensHaut : begin adresse:=canton[idCantonDest].el1; t:=canton[idCantonDest].typ1;end; + SensDroit,sensBas : begin adresse:=canton[idCantonDest].el2; t:=canton[idCantonDest].typ2;end; + end; + if t=det then + begin + detecteur[adresse].AdrTrain:=canton[idCantonDest].adresseTrain; + detecteur[adresse].Train:=canton[idCantonDest].NomTrain; + end; + maj_signaux(true); +end; - actualise_seltrains; +procedure TFormTCO.AffRoutesClick(Sender: TObject); +begin + formrouteTrain.windowState:=wsNormal; //Maximized;; + //formroute.Create(self); + formRouteTrain.Show; +end; + + +procedure TFormTCO.Button1Click(Sender: TObject); +begin + zone_tco(1,523,518,1,0,1,false); end; diff --git a/Unit_Pilote_aig.dfm b/Unit_Pilote_aig.dfm index 288adc6..34455b5 100644 --- a/Unit_Pilote_aig.dfm +++ b/Unit_Pilote_aig.dfm @@ -1,6 +1,6 @@ object FormAig: TFormAig - Left = 630 - Top = 144 + Left = 496 + Top = 217 Width = 363 Height = 204 Caption = 'Pilotage de l'#39'aiguillage' diff --git a/Unit_Pilote_aig.pas b/Unit_Pilote_aig.pas index b10be06..1323a36 100644 --- a/Unit_Pilote_aig.pas +++ b/Unit_Pilote_aig.pas @@ -85,7 +85,7 @@ begin buttonDev2.Visible:=false; buttonDroit2.Visible:=false; LabelAdr2.Visible:=false; - exit; + if diffusion then exit; end; aigC:=(aiguillage[i].modele=aig); diff --git a/Unitplace.dfm b/Unitplace.dfm deleted file mode 100644 index 2173465..0000000 --- a/Unitplace.dfm +++ /dev/null @@ -1,122 +0,0 @@ -object FormRoulage: TFormRoulage - Left = 368 - Top = 142 - BorderStyle = bsDialog - Caption = 'Roulage des trains' - ClientHeight = 275 - ClientWidth = 307 - Color = clBtnFace - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'MS Sans Serif' - Font.Style = [] - KeyPreview = True - OldCreateOrder = False - Position = poMainFormCenter - OnActivate = FormActivate - OnCreate = FormCreate - OnKeyPress = FormKeyPress - PixelsPerInch = 96 - TextHeight = 13 - object Label1: TLabel - Left = 96 - Top = 8 - Width = 116 - Height = 20 - Caption = 'Roulage des trains' - Font.Charset = ANSI_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Arial Narrow' - Font.Style = [fsBold] - ParentFont = False - end - object LabelTexte: TLabel - Left = 17 - Top = 32 - Width = 120 - Height = 13 - Caption = '. ' - end - object ButtonInitAig: TButton - Left = 16 - Top = 56 - Width = 273 - Height = 25 - Caption = 'Positionner les aiguillages en position initiale' - TabOrder = 0 - OnClick = ButtonInitAigClick - end - object ButtonSauve: TButton - Left = 16 - Top = 184 - Width = 273 - Height = 25 - Hint = - 'Enregistre la configuration de placement dans le fichier de conf' + - 'iguration' - Caption = 'Enregistrer la configuration de placement' - ParentShowHint = False - ShowHint = True - TabOrder = 1 - OnClick = ButtonSauveClick - end - object ButtonLanceRoutage: TButton - Left = 16 - Top = 88 - Width = 273 - Height = 25 - Caption = 'Lancer le roulage' - Font.Charset = DEFAULT_CHARSET - Font.Color = clInfoText - Font.Height = -11 - Font.Name = 'MS Sans Serif' - Font.Style = [fsBold] - ParentFont = False - TabOrder = 2 - OnClick = ButtonLanceRoutageClick - end - object Button1: TButton - Left = 216 - Top = 240 - Width = 81 - Height = 25 - Caption = 'Config trains' - TabOrder = 3 - OnClick = Button1Click - end - object ButtonArretroutage: TButton - Left = 16 - 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 = 4 - OnClick = ButtonArretroutageClick - end - object BitBtn1: TBitBtn - Left = 8 - Top = 240 - Width = 73 - Height = 25 - TabOrder = 5 - OnClick = BitBtn1Click - Kind = bkClose - end - object ButtonArretTrains: TButton - Left = 16 - Top = 120 - Width = 273 - Height = 25 - Hint = 'Arr'#234'te tous les trains' - Caption = 'Arr'#234't des trains' - ParentShowHint = False - ShowHint = True - TabOrder = 6 - OnClick = ButtonArretTrainsClick - end -end diff --git a/Unitplace.pas b/Unitplace.pas deleted file mode 100644 index 5b20ada..0000000 --- a/Unitplace.pas +++ /dev/null @@ -1,299 +0,0 @@ -unit Unitplace; -interface - -uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, StdCtrls, unitprinc, unitpilote , unitDebug, Buttons, ExtCtrls; - -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; - -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} - - -procedure raz_route(indexeventdet,prec,detect,indextrain : integer); -begin - if indexeventdet>N_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 - 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 - sens:=canton[idcanton].Sens; - if (sens=sensdroit) or (sens=senshaut) then det:=canton[idcanton].el2; - if (sens=sensGauche) or (sens=sensbas) then det:=canton[idcanton].el1; - end;} - - init_route_canton(idcanton,Indextrain,true); - 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,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 formRoulage do - begin - color:=couleurFond; - for i:=0 to ComponentCount-1 do - begin - c:=Components[i]; - composant(c,couleurFond,couleurTexte); - end; - 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 index 1055a13..fc32661 100644 --- a/selection_train.dfm +++ b/selection_train.dfm @@ -5,7 +5,7 @@ object FormSelTrain: TFormSelTrain BorderStyle = bsDialog Caption = 'S'#233'lection train' ClientHeight = 311 - ClientWidth = 745 + ClientWidth = 768 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText @@ -16,13 +16,13 @@ object FormSelTrain: TFormSelTrain OnActivate = FormActivate OnCreate = FormCreate DesignSize = ( - 745 + 768 311) PixelsPerInch = 96 TextHeight = 13 object LabelInfo: TLabel - Left = 176 - Top = 280 + Left = 104 + Top = 288 Width = 44 Height = 13 Caption = 'LabelInfo' @@ -35,10 +35,10 @@ object FormSelTrain: TFormSelTrain Caption = 'Canton' end object ImageBas: TImage - Left = 488 + Left = 472 Top = 8 - Width = 41 - Height = 41 + Width = 57 + Height = 57 Picture.Data = { 07544269746D6170F6070000424DF60700000000000076000000280000003C00 00003C0000000100040000000000800700000000000000000000100000000000 @@ -329,7 +329,7 @@ object FormSelTrain: TFormSelTrain Height = 13 end object ButtonOK: TButton - Left = 74 + Left = 9 Top = 280 Width = 75 Height = 24 @@ -338,26 +338,38 @@ object FormSelTrain: TFormSelTrain TabOrder = 0 OnClick = ButtonOKClick end + object ComboBoxCanton: TComboBox + Left = 64 + Top = 8 + Width = 185 + Height = 21 + ItemHeight = 13 + TabOrder = 1 + OnChange = ComboBoxCantonChange + end object StringGridTrains: TStringGrid Left = 8 - Top = 40 - Width = 721 - Height = 225 + Top = 64 + Width = 753 + Height = 209 ColCount = 6 Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor] ScrollBars = ssVertical - TabOrder = 1 + TabOrder = 2 OnDrawCell = StringGridTrainsDrawCell OnKeyDown = StringGridTrainsKeyDown OnSelectCell = StringGridTrainsSelectCell end - object ComboBoxCanton: TComboBox - Left = 64 - Top = 8 - Width = 169 - Height = 21 - ItemHeight = 13 - TabOrder = 2 - OnChange = ComboBoxCantonChange + object ButtonSauve: TButton + Left = 624 + Top = 280 + Width = 129 + Height = 25 + Hint = 'Sauvegarde le placement des trains dans les cantons' + Caption = 'Sauvegarder' + ParentShowHint = False + ShowHint = True + TabOrder = 3 + OnClick = ButtonSauveClick end end diff --git a/selection_train.pas b/selection_train.pas index a0ee4d6..52161ff 100644 --- a/selection_train.pas +++ b/selection_train.pas @@ -4,12 +4,11 @@ interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, StdCtrls, Grids, ExtCtrls; + Dialogs, StdCtrls, Grids, ExtCtrls, UnitPrinc; type TFormSelTrain = class(TForm) ButtonOK: TButton; - StringGridTrains: TStringGrid; LabelInfo: TLabel; ComboBoxCanton: TComboBox; Label1: TLabel; @@ -18,6 +17,8 @@ type Imagegauche: TImage; ImageDroite: TImage; LabelCanton: TLabel; + StringGridTrains: TStringGrid; + ButtonSauve: TButton; procedure ButtonOKClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure StringGridTrainsDrawCell(Sender: TObject; ACol, @@ -28,6 +29,7 @@ type procedure StringGridTrainsKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure ComboBoxCantonChange(Sender: TObject); + procedure ButtonSauveClick(Sender: TObject); private { Déclarations privées } public @@ -37,22 +39,25 @@ type var FormSelTrain: TFormSelTrain; x,y,El,largC,hautC,indexTrainClic : Integer; + routeSav : TuneRoute; 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); +procedure trouve_det_canton(idcanton : integer;var el1,el2 : integer); +function trouve_det_suiv_canton(idcanton,detecteur,sensTCO : integer) : integer; implementation -uses UnitPrinc,UnitConfigCellTCO,UnitTCO,UnitPlace,unitconfig,unitDebug; +uses UnitConfigCellTCO,UnitTCO,unitconfig,unitDebug, UnitRouteTrains, + UnitInfo; {$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; +var i,j : integer; trouve : boolean; begin i:=1; @@ -69,273 +74,51 @@ begin begin event_det_train[j]:=event_det_train[j+1]; end; - dec(n_trains); + dec(n_trains); // nombre de trains en circulation 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; +// trouve les détecteurs contigus au canton en fonction des aiguillages positionnés +procedure trouve_det_canton(idcanton : integer;var el1,el2 : integer); +var suiv,prec :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 + 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 (tel2<>buttoir) 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; + suiv:=detecteur_suivant(el1,tel1,el2,tel2,1); // arrêt sur suivant + if suiv>9990 then suiv:=0; + 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(el2,tel2,el1,tel1,1); // arrêt sur suivant + if suiv>9990 then suiv:=0; + el1:=prec; + end; +end; + +// trouve le détecteur suivant sur le canton idcanton, au détecteur "détecteur" dans le sensTCO +function trouve_det_suiv_canton(idcanton,detecteur,sensTCO : integer) : integer; +var t : integer; +begin + t:=canton[idcanton].ntco; + zone_tco(t,detecteur,sensTCO,0,0,12,false); // élément contigu à droite (6) du canton , résultat dans xcanton , teste les 2 pos des aig + if tel1=Aig then xcanton:=detecteur_suivant(detecteur,det,xcanton,aig,1); + result:=xcanton; 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; +var i,t,idTCO,x,y : integer; begin if (AdrTrain=0) then exit; - //Affiche('Raz_cantons_train(Adr='+intToSTR(AdrTrain)+')',clyellow); + //Affiche('Raz_cantons_train @='+intToSTR(AdrTrain),clyellow); if adrTrain<>0 then begin for i:=1 to Ncantons do @@ -353,47 +136,23 @@ begin 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); + Dessin_canton(idTCO,pcanvasTCO[idTCO],x,y,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. +// affecte le train id train ou adresse à l'Index 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; +var idTrain,t : integer; begin - //Affiche('Affecte_train_canton: IdTrain='+intToSTR(idTrain)+' @='+intToSTR(AdrTrain)+' canton='+intToSTR(idcanton),clorange); + //Affiche('Affecte_train_canton: IdTrain='+intToSTR(idTrain)+' @='+intToSTR(AdrTrain)+' Idcanton='+intToSTR(idcanton),clorange); if (IdCanton>0) and (idCanton<=nCantons) then begin if (AdrTrain<>0) and (adrTrain<>9999) then @@ -427,7 +186,7 @@ begin end; end; -// renvoie x,y El et indexCanton en variable globale +// renvoie x,y El et indexCanton de IdCantonSelect en variable globale procedure quel_canton; begin if IdCantonSelect=0 then exit; @@ -436,6 +195,7 @@ begin El:=tco[indexTCOCourant,x,y].BImage; end; +// dessine la flèche dans la colonne 6 de la stringrid procedure Dessine_fleche(ligne : integer;r : Trect); var indexTrain,IdCanton : integer; Image : TImage; @@ -449,7 +209,7 @@ begin with StringGridTrains do begin - case canton[idcanton].Sens of + case canton[idcanton].SensLoco of 1 : Image:=ImageGauche; 2 : Image:=ImageDroite; 3 : Image:=ImageHaut; @@ -469,8 +229,12 @@ begin // maj de la stringGrig if IdCantonSelect>0 then begin - s:='Canton '+intToSTR(IdCantonSelect)+' encadré par '+intToSTR(canton[IdCantonSelect].el1); - i:=canton[IdCantonSelect].Sens1; + s:='Sélection d''un train'; + s:=s+' au canton '+intToSTR(canton[IdCantonSelect].numero)+' : '+canton[IdCantonSelect].nom; + FormSelTrain.caption:=s; + + s:='Canton '+intToSTR(canton[IdCantonSelect].numero)+' encadré par '+intToSTR(canton[IdCantonSelect].el1); + i:=canton[IdCantonSelect].SensEl1; case i of SensHaut : s:=s+' haut '; SensBas : s:=s+' bas '; @@ -479,7 +243,7 @@ begin end; s:=s+' '+intToSTR(canton[IdCantonSelect].el2); - i:=canton[IdCantonSelect].Sens2; + i:=canton[IdCantonSelect].SensEl2; case i of SensHaut : s:=s+' haut '; SensBas : s:=s+' bas '; @@ -488,7 +252,7 @@ begin end; s:=s+' loco vers '; - i:=canton[IdCantonSelect].Sens; + i:=canton[IdCantonSelect].SensLoco; case i of SensHaut : s:=s+' haut '; SensBas : s:=s+' bas '; @@ -514,11 +278,13 @@ begin s:='N°'+intToSTR(t)+' '; if t<>0 then s:=s+NomfichierTCO[t]; cells[5,i]:=s; + if trains[i].route[0].adresse<>0 then s:=' oui' else s:=''; + cells[7,i]:=s; end else begin cells[3,i]:=''; cells[4,i]:=''; cells[5,i]:=''; - cells[6,i]:=''; // efface la fleche + cells[6,i]:=''; // efface la flèche end; end; end; @@ -534,11 +300,6 @@ 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; @@ -553,7 +314,7 @@ begin //Options:=StringGridTrains.Options+[goEditing]; Hint:='Sélection d''un train'; ShowHint:=true; - ColCount:=7; + ColCount:=8; // nombre de colonnes RowCount:=Ntrains+1; Options := StringGridTrains.Options + [goEditing]; ColWidths[0]:=30; @@ -561,18 +322,19 @@ begin ColWidths[2]:=150; // nom du train ColWidths[3]:=60; // canton ColWidths[4]:=100; - ColWidths[5]:=100; + ColWidths[5]:=120; ColWidths[6]:=30; - + ColWidths[7]:=35; Cells[1,0]:='Icône'; Cells[2,0]:='Nom du train'; - Cells[3,0]:='N°canton'; + Cells[3,0]:='Affectation'+#13+'au canton'; Cells[4,0]:='Nom du canton'; Cells[5,0]:='TCO'; Cells[6,0]:='Sens'; + Cells[7,0]:='Route'; - RowHeights[0]:=22; + RowHeights[0]:=30; end; for i:=1 to ntrains do @@ -588,7 +350,7 @@ begin begin for x:=0 to RowCount-1 do for y:=0 to ColCount-1 do - StringGridTrains.Options := StringGridTrains.Options - [goEditing] - [goRangeSelect]; + StringGridTrains.Options:=StringGridTrains.Options - [goEditing] - [goRangeSelect]; end; end; @@ -596,21 +358,38 @@ end; procedure TFormSelTrain.StringGridTrainsDrawCell(Sender: TObject; ACol,ARow: Integer; Rect: TRect; State: TGridDrawState); var indextrain,l,h,hautdest,largdest : integer; rd : double; + r : trect; + coul: Tcolor; + s : string; begin // Affiche('DrawCell '+intToSTR(Acol)+'x'+intToSTR(Arow),clred); + // titres sur 2 lignes + if Arow=0 then + with StringGridTrains do + begin + if Pos(#13,Cells[ACol,ARow])>0 then + begin + Coul:=canvas.Pixels[5,5]; // trouver la couleur de la première ligne de la stringgrid, car elle change en fonction des styles + Canvas.Brush.Color:=coul; + Canvas.FillRect(Rect); // Efface la cellule qu'on va réécrire en mode WORDBREAK + + Inc(Rect.Left, 2); + Inc(Rect.Top, 2); + DrawText(Canvas.Handle,PChar(Cells[ACol, ARow]),-1,Rect,DT_NOPREFIX or DT_WORDBREAK); + end; + end; + // 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); - + //Affiche(intToSTR(Acol)+' '+intToSTR(Arow),clred); l:=Trains[indextrain].Icone.width; h:=Trains[indextrain].Icone.Height; if h=0 then exit; @@ -627,7 +406,6 @@ begin 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; @@ -636,27 +414,23 @@ begin // 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 + // le carré de route + if (acol=7) and (aRow>0) then begin - ic:=trains[i].canton; - if ic=c then + if trains[Arow].route[0].adresse<>0 then begin - trains[i].canton:=0; - if ic<>0 then + with StringGridTrains.Canvas do 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:=''; + pen.color:=clBlue; + pen.Width:=3; + rectangle(rect); + s:='route'; + r.Left:=rect.Left+2; + r.Top:=rect.Top+4; + r.Right:=rect.Right-2; + r.Bottom:=rect.Bottom-2; + DrawText(Handle,PChar(s), -1,r ,DT_VCENTER or DT_CENTER or dt_wordbreak); end; end; end; @@ -666,12 +440,15 @@ end; procedure raz_trains_idcanton(idc : integer); var ax,ay,i,ic : integer; begin + if traceliste then Affiche('Raz train affectés au canton index='+intToSTR(idc),clyellow); for i:=1 to Ntrains do begin ic:=index_canton_numero(trains[i].canton); if ic=idc then begin + routeSav:=trains[i].route; // sauvegarde la route trains[i].canton:=0; + trains[i].route[0].adresse:=0; if ic<>0 then begin ax:=canton[Ic].x; @@ -685,18 +462,23 @@ begin end; end; -// cliqué sur cellule pour changer la sélection du train ou la flèche + +// cliqué sur cellule pour changer la sélection du train ou voir la route ou la flèche procedure TFormSelTrain.StringGridTrainsSelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); -var f,AutreTrain,AutreCanton,idAutrecanton,i : integer; +var f,AutreTrain,AutreCanton,idAutrecanton,i,ancienSens,AdrTrain,IdTrain,sensloco : integer; faire : boolean; + s : string; begin + if IdCantonSelect=0 then IdCantonSelect:=AncienIdCantonSelect; if affevt then Affiche('FormSelTrain.StringGridTrainsSelectCell '+intToSTR(ACol)+' '+intToSTR(ARow),clYellow); if (Arow>nTrains) or (IdCantonSelect<1) then exit; + faire:=false; //------------change la sélection du train if (Arow>=1) and (ACol<=5) then begin + AncienSens:=0; indexTrainClic:=Arow; // Affiche('ligne='+intToSTR(Arow)+' col='+intToSTR(Acol),clyellow); @@ -709,43 +491,83 @@ begin 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); + LabelInfo.caption:='Le train '+intToSTR(IndexTrainClic)+' '+trains[IndexTrainClic].nom_train+' est affecté au canton '+intToSTR(AutreCanton); exit; end; + if Trains[IndexTrainClic].route[0].adresse<>0 then + begin + s:='Le train '+Trains[IndexTrainClic].nom_train+' a une route affectée.'+#13+ + 'Supprimer le train du canton va également supprimer sa route.'+#13+ + 'Voulez vous supprimer le train du canton ?'; + + if Application.MessageBox(pchar(s),pchar('Confirmation de suppression de train du canton '+intToSTR(canton[IdCantonSelect].numero)), + MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then exit; + + supprime_route_train(indextrainclic); + StringGridTrains.cells[7,ARow]:=''; + 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'; + LabelInfo.caption:='Le train '+intToSTR(AutreTrain)+' '+trains[AutreTrain].nom_train+' est déjà affecté au canton - Effacement'; + // affecter la route de l'ancien train au nouveau train + routeSav:=trains[AutreTrain].route; // sauve la route + trains[AutreTrain].route[0].adresse:=0; + StringGridTrains.Cells[7,AutreTrain]:=''; + trains[IndexTrainClic].route:=routeSav; + + AncienSens:=canton[idcantonSelect].SensLoco; 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); + + + raz_trains_idcanton(IdCantonSelect); // au retour, route contient la route du train razé du canton //Affiche('Et 1',clYellow); - init_route_canton(IdCantonSelect,indexTrainClic,false); // raz du placement du train et de sa route + maj_signaux(true); 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 + if anciensens=0 then if canton[IdCantonSelect].horizontal then SensLoco:=SensDroit else SensLoco:=SensBas; + if ancienSens<>0 then SensLoco:=ancienSens; + + if (canton[IdCantonSelect].sensCirc<>0) then sensLoco:=canton[IdCantonSelect].sensCirc ; + + canton[IdCantonSelect].SensLoco:=sensLoco; + affecte_Train_canton(trains[indexTrainClic].adresse,IdCantonSelect); // le train affecté contient la route du train razé + + maj_signaux(true); end; end; end; - // change le sens---------------------------- + // change le sens - (cliqué sur la flèche)--------------------------- 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; + AdrTrain:=canton[IdAutreCanton].adresseTrain; + IdTrain:=index_train_adresse(AdrTrain); + // si le train a une route affectée + if Trains[IdTrain].route[0].adresse<>0 then + begin + s:='Le train '+Trains[idTrain].nom_train+' a une route affectée.'+#13+ + 'Changer son sens de départ va détruire sa route.'+#13+ + 'Voulez vous changer le sens du train?'; + if Application.MessageBox(pchar(s),pchar('Confirmation pour changer le sens du train'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then exit; + supprime_route_train(idTrain); + end; + + f:=canton[IdAutreCanton].SensLoco; inc(f); if canton[IdAutreCanton].horizontal then @@ -756,14 +578,29 @@ begin begin if (f=5) or (f0) and (canton[IdAutreCanton].SensCirc<>f) then + begin + s:='Le sens de circulation du canton '+intToSTR(canton[IdAutreCanton].numero)+' ne permet pas de positionner le train dans ce sens'; + LabelInfo.Caption:=s; + FormInfo.LabelInfo.caption:=s; + FormInfo.Top:=top+10; + FormInfo.Left:=left+10; + FormInfo.Show; + exit; + end; renseigne_canton(IdAutreCanton); - canton[IdAutreCanton].Sens:=f; + canton[IdAutreCanton].SensLoco:=f; //Affiche('Et 3',clYellow); - init_route_canton(IdCantonSelect,indexTrainClic,false); // raz du placement du train et de sa route - init_route_canton(IdCantonSelect,indexTrainClic,true); // placement du train et de sa route + maj_signaux(true); + end; + end; - end; + // cliqué sur la route + if Acol=7 then + begin + indexTrainFR:=Arow; + formRouteTrain.show; end; maj_stringGrig; @@ -771,43 +608,97 @@ begin // met à jour les cantons for i:=1 to nCantons do begin - dessin_canton(i,0,0); + dessin_canton(i,0); end; end; + // actualise la fenetre procedure actualise_seltrains; var s : string; i : integer; begin + with formSelTrain.StringGridTrains do + begin + RowCount:=Ntrains+1; + for i:=1 to ntrains do + begin + cells[2,i]:=trains[i].nom_train; + end; + end; + Quel_canton; - s:='Sélection d''un train'; - if IdCantonSelect>0 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); + 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; + + +// positionne la VertscrollBar de la stringGrid +procedure Positionne_SG(n : integer); +var i : integer; + { + SB_LINEUP ; + SB_LINELEFT ; + SB_LINEDOWN ; + SB_LINERIGHT ; + SB_PAGEUP ; + SB_PAGELEFT ; + SB_PAGEDOWN ; + SB_PAGERIGHT ; + SB_THUMBPOSITION ; + SB_THUMBTRACK ; + SB_TOP ; + SB_LEFT ; + SB_BOTTOM ; + SB_RIGHT ; + SB_ENDSCROLL ; + } +begin + // Positionne la stringGrid + SendMessage(formSelTrain.StringGridTrains.Handle, WM_VScroll, SB_TOP, 0); // déplace en haut + for i:=1 to n-5 do // 7-2 c'est le nombre de lignes affichées par la stringgrid + SendMessage(formSelTrain.StringGridTrains.Handle, WM_VScroll, SB_LINEDOWN, 0); // déplace d'une ligne à la fois end; procedure TFormSelTrain.FormActivate(Sender: TObject); +var n,i,IndexTrain : integer; + trouve : boolean; + NomTrain : string; begin actualise_Seltrains; + if IdcantonSelect=0 then exit; + IndexTrain:=canton[IdCantonSelect].indexTrain; + NomTrain:=trains[indexTrain].nom_train; + // trouver si le train est dans la grille + with StringGridTrains do + begin + i:=1;n:=RowCount; + repeat + trouve:=cells[2,i]=nomTrain; + inc(i); + until trouve or (i>=n); + if trouve then + begin + Positionne_SG(i); + end; + end; end; - - procedure TFormSelTrain.StringGridTrainsKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin - key:=0; // évite le mouvement de sélection par les touches + key:=0; // empêche le mouvement de sélection par les touches end; procedure TFormSelTrain.ComboBoxCantonChange(Sender: TObject); @@ -818,6 +709,10 @@ begin end; +procedure TFormSelTrain.ButtonSauveClick(Sender: TObject); +begin + Sauve_config; +end; end. diff --git a/verif_version.pas b/verif_version.pas index a1aec86..32daf7e 100644 --- a/verif_version.pas +++ b/verif_version.pas @@ -1,6 +1,5 @@ unit verif_version; - interface uses @@ -26,7 +25,7 @@ var chemin_Dest,chemin_src,date_creation,nombre_tel : string; f : text; -Const VersionSC ='8.8'; // sert à la comparaison de la version publiée +Const VersionSC ='9.0'; // 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; @@ -171,7 +170,7 @@ begin AssignFile(f,chemin_dest+'log-install.txt'); Rewrite(f); - log('Mise à jour de signaux complexes V'+version+' le '+DateToStr(date)+' à '+TimeToStr(Time)+' ',clYellow); + log('Mise à jour de signaux complexes V'+versionSC+' le '+DateToStr(date)+' à '+TimeToStr(Time)+' ',clYellow); log('Téléchargement réussi, décompression',clyellow); formVersion.close; @@ -191,11 +190,12 @@ begin close(f); Affiche('Installation de la nouvelle version',clyellow); Sleep(2000); - i:=ShellExecute(Formprinc.Handle,'open', - Pchar('installeur.exe'), - Pchar(''), // paramètre - PChar('') // répertoire - ,SW_SHOWNORMAL); + i:=ShellExecute(Formprinc.Handle,pchar('runas'), // mode admin + Pchar('installeur.exe'), + Pchar(''), // paramètre + PChar(''), // répertoire + SW_SHOWNORMAL); + if i>32 then begin Application.Terminate; @@ -216,7 +216,7 @@ var description,s,s2,s3,Version_p,Url,LocalFile,nomfichier,date_creation_ang : s V_utile,V_publie : real; SV_publie : char; taille : longint; - comm : array[1..10] of string; + comm : array[1..20] of string; function supprime_anti(s : string) : string; var i : integer; @@ -276,8 +276,18 @@ begin Ncomm:=0; if DownloadURL_NOCache(Url,localFile,taille) then begin + if not(FileExists(localfile)) then + begin + Affiche('Erreur fichier dépot non écrit. Vérifiez les droits du répertoire ',clred); + Affiche(GetCurrentDir,clred); + Affiche('Voir la notice page 9 : Refus de modification des fichiers du dossier par Windows',clred); + result:=0; + exit; + end; + AssignFile(fichier,LocalFile); reset(fichier); + while not(eof(fichier)) and (not(trouve_version) or not(trouve_zip)) do begin readln(fichier,s); @@ -317,7 +327,7 @@ begin begin //description:=utf8Decode(description); i:=1 ; j:=1; - // couper en chaînes + // couper en chaînes et mettre dans comm[] repeat j:=pos('\r',description); if j<>0 then @@ -332,7 +342,7 @@ begin begin delete(description,j,2); end; - until j=0; + until (j=0) or (i>=20); // ncomm:=i; comm[i]:=supprime_anti(description); @@ -381,7 +391,7 @@ begin FormVersion.Top:=10; FormVersion.Left:=10; FormVersion.show; - s:='Vous utilisez la version '+version+SousVersion+' mais il existe la version '+Version_p+SV_publie; + s:='Vous utilisez la version '+versionSC+SousVersion+' mais il existe la version '+Version_p+SV_publie; if nComm>0 then begin FormVersion.Memo1.lines.Clear; diff --git a/versions.txt b/versions.txt index db9d232..8dae26b 100644 --- a/versions.txt +++ b/versions.txt @@ -250,7 +250,13 @@ version 8.6 : Gestion des d 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.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 des icônes de trains -> recopiez le repertoire [icones] dans celui de signaux_complexes Création de nouveaux déclencheurs, conditions et opérations. - - +version 8.82 : Ajout d'une zone d'entrée pour le répertoire d'installation de CDM. +version 8.83 : Améliorations diverses. +version 9.0 : Pilotage des nouveaux décodeurs de signaux LEB (mode binaire, linéaire) + En mode autonome: + Pilotage des trains depuis le TCO + Proposition des routes possibles depuis un train sur un détecteur de départ vers un détecteur d'arrivée sur le TCO. + Pilotage des accessoires sans accusé de réception, ce qui fluidifie le trafic XpressNet +