diff --git a/Notice d'utilisation des signaux_complexes_GL_V5.74.pdf b/Notice d'utilisation des signaux_complexes_GL_V6.0.pdf similarity index 75% rename from Notice d'utilisation des signaux_complexes_GL_V5.74.pdf rename to Notice d'utilisation des signaux_complexes_GL_V6.0.pdf index 6f1e8dc..981483a 100644 Binary files a/Notice d'utilisation des signaux_complexes_GL_V5.74.pdf and b/Notice d'utilisation des signaux_complexes_GL_V6.0.pdf differ diff --git a/Signaux_complexes_GL.dpr b/Signaux_complexes_GL.dpr index d3b06af..d9ee19f 100644 --- a/Signaux_complexes_GL.dpr +++ b/Signaux_complexes_GL.dpr @@ -15,7 +15,8 @@ uses UnitConfigCellTCO in 'UnitConfigCellTCO.pas' {FormConfCellTCO}, UnitCDF in 'UnitCDF.pas' {FormCDF}, Unitplace in 'Unitplace.pas' {FormPlace}, - UnitPareFeu in 'UnitPareFeu.pas'; + UnitPareFeu in 'UnitPareFeu.pas', + UnitAnalyseSegCDM in 'UnitAnalyseSegCDM.pas' {FormAnalyseCDM}; {$R *.res} @@ -33,5 +34,6 @@ begin Application.CreateForm(TFormCDF, FormCDF); Application.CreateForm(TFormPlace, FormPlace); Application.CreateForm(TFormDebug, FormDebug); + Application.CreateForm(TFormAnalyseCDM, FormAnalyseCDM); Application.Run; end. diff --git a/UnitAnalyseSegCDM.dfm b/UnitAnalyseSegCDM.dfm new file mode 100644 index 0000000..d5096ec --- /dev/null +++ b/UnitAnalyseSegCDM.dfm @@ -0,0 +1,124 @@ +object FormAnalyseCDM: TFormAnalyseCDM + Left = 216 + Top = 23 + Hint = '(aiguillages uniquement)' + Anchors = [akLeft, akTop, akRight, akBottom] + AutoScroll = False + Caption = 'FormAnalyseCDM' + ClientHeight = 660 + ClientWidth = 1032 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + OldCreateOrder = False + ShowHint = True + OnCreate = FormCreate + OnResize = FormResize + DesignSize = ( + 1032 + 660) + PixelsPerInch = 96 + TextHeight = 13 + object ScrollBox1: TScrollBox + Left = 8 + Top = 16 + Width = 977 + Height = 553 + HorzScrollBar.Tracking = True + Anchors = [akLeft, akTop, akRight, akBottom] + AutoScroll = False + Color = clBlack + ParentColor = False + TabOrder = 0 + object ImageCDM: TImage + Left = 0 + Top = 0 + Width = 937 + Height = 512 + end + end + object GroupBox1: TGroupBox + Left = 16 + Top = 576 + Width = 457 + Height = 73 + Anchors = [akLeft, akBottom] + Caption = 'Affichages ' + TabOrder = 1 + object Label1: TLabel + Left = 216 + Top = 16 + Width = 81 + Height = 13 + Caption = 'Afficher le port n'#176 + end + object CheckConnexions: TCheckBox + Left = 24 + Top = 16 + Width = 97 + Height = 17 + Caption = 'Connexions' + TabOrder = 0 + OnClick = CheckConnexionsClick + end + object CheckAdresses: TCheckBox + Left = 24 + Top = 32 + Width = 97 + Height = 17 + Caption = 'Adresses' + TabOrder = 1 + OnClick = CheckAdressesClick + end + object CheckSegments: TCheckBox + Left = 112 + Top = 16 + Width = 81 + Height = 17 + Caption = 'segments' + TabOrder = 2 + OnClick = CheckSegmentsClick + end + object CheckPorts: TCheckBox + Left = 112 + Top = 32 + Width = 121 + Height = 17 + Caption = 'Ports' + TabOrder = 3 + OnClick = CheckSegmentsClick + end + object EditPort: TEdit + Left = 304 + Top = 16 + Width = 57 + Height = 21 + TabOrder = 4 + end + object ButtonAffPort: TButton + Left = 368 + Top = 16 + Width = 73 + Height = 25 + Caption = 'Afficher le port' + TabOrder = 5 + OnClick = ButtonAffPortClick + end + end + object TrackBar1: TTrackBar + Left = 992 + Top = 16 + Width = 37 + Height = 553 + Anchors = [akTop, akRight] + Max = 200 + Min = 50 + Orientation = trVertical + Position = 200 + TabOrder = 2 + OnChange = TrackBar1Change + end +end diff --git a/UnitAnalyseSegCDM.pas b/UnitAnalyseSegCDM.pas new file mode 100644 index 0000000..61b234e --- /dev/null +++ b/UnitAnalyseSegCDM.pas @@ -0,0 +1,1405 @@ +unit UnitAnalyseSegCDM; +// attention manque aiguillage triple +// les Tjs ne sont pas traitées, de même que les bretelles double jonction, ni les tables tournantes. +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, UnitPrinc, ExtCtrls, StdCtrls, ComCtrls, UnitDebug, UnitConfig; + +const + cadre=30; + +type + TFormAnalyseCDM = class(TForm) + ScrollBox1: TScrollBox; + ImageCDM: TImage; + GroupBox1: TGroupBox; + CheckConnexions: TCheckBox; + CheckAdresses: TCheckBox; + CheckSegments: TCheckBox; + TrackBar1: TTrackBar; + CheckPorts: TCheckBox; + Label1: TLabel; + EditPort: TEdit; + ButtonAffPort: TButton; + procedure FormResize(Sender: TObject); + procedure CheckSegmentsClick(Sender: TObject); + procedure CheckConnexionsClick(Sender: TObject); + procedure CheckAdressesClick(Sender: TObject); + procedure TrackBar1Change(Sender: TObject); + procedure ButtonAffPortClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + private + { Déclarations privées } + public + { Déclarations publiques } + end; + + TAig_CDM = record + adresse,temps : integer; + modele : TEquipement ; + ADroit : integer ; // (TJD:identifiant extérieur) connecté sur la position droite en talon + ADroitB : char ; // P D S Z + + ADevie : integer ; // (TJD:identifiant extérieur) adresse de l'élément connecté en position déviée + ADevieB : char; // caractère (D ou S)si aiguillage de l'élément connecté en position déviée + APointe : integer; // adresse de l'élément connecté en position droite ; + APointeB : char; + DDroit : integer; // destination de la TJD en position droite + DDroitB : char ; + DDevie : integer; // destination de la TJD en position déviée + DDevieB : char ; + + Adevie2 : integer; + Adevie2B : char ; + // états d'une TJD (2 ou 4, 4 par défaut) + EtatTJD : integer; + + end; + +// structure segment, port et periph de CDM + TInter = + record + x,y,z : integer; + typ : string[20]; + MirrorZ : integer; + MirrorParent : integer; + end; + + Tport = + record + numero : integer; // numéro du port + typ : string[20]; + x,y,z,angle : integer; + local : integer; // numéro de port local + connecte : boolean; + ConnecteAuPort : integer; // connecté au port + ConnecteAuSeg : integer; // connecté au segment + end; + + TPeriph = + record + numero : integer; // numéro du port + typ : string[20]; + pere : integer; + x,y,z,angle : integer; + bright,bdown : integer;// sens et position par rapport à la voie + location : integer; // ?? en % + adresse : integer; + status : integer; + end; + + Tsegment = + record + numero : integer; + typ : string[20]; // arc aiguillage,... + nport,nperiph,nInter : integer; // nombre de ports et de peripheriques et d'intersections + port : array of TPort; + periph : array of TPeriph; + inter : array of TInter; + XMin,Ymin,XMax,Ymax,StartAngle,ArcAngle,Rayon,radius0,angle0,angle,lengthdev,deltadev0 : integer; + lXc,lYc : integer; + // turnout + longueur,longueurDev,DeltaDev,Curveoffset : integer; + // turnout curve + xc0,yc0,DeltaDev2,xc,yc : integer; + // pour signaux complexes + adresse,adresse2,duree : integer; + end; + + +var Segment : array of Tsegment; + nInter,nPeriph,nSeg,nPort,nligne,XminiCDM,XmaxiCDM,YminiCDM,YmaxiCDM,NAig_CDM : integer; + lignes : TStrings; + reducX,reducY : double; + FormAnalyseCDM: TFormAnalyseCDM; + NomModule : string; + + Aig_CDM : array[0..NbreMaxiAiguillages] of TAig_CDM; + +procedure Analyse_seg; + +implementation + +{$R *.dfm} + +function isole_valeur(var s : string; chercher : string) : string; +var i : integer; +begin + i:=pos(chercher,s); + if i=0 then begin Affiche('Erreur : pas de chaine '+chercher+' dans '+s,clred);exit;end; + delete(s,1,i+length(chercher)-1); + + repeat + if s[1]=' ' then delete(s,1,1); + until (s[1]<>' ') or (length(s)=0); + + i:=pos(' ',s); + if i<>0 then isole_valeur:=copy(s,1,i-1) else isole_valeur:=s; +end; + +procedure compile_periph; +var i,erreur : integer; + s,s2: string; +begin + //------------------------Lecture periph---------------------------- + + inc(nPeriph); + segment[nSeg-1].nPeriph:=nPeriph; + setlength(segment[nSeg-1].Periph,nPeriph); + + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'periph #'); + val(s2,i,erreur); + Segment[nSeg-1].periph[nperiph-1].numero:=i; + if debugAnalyse then AfficheDebug('Compile periph '+intToSTR(i),clYellow); + + s2:=isole_valeur(s,'obj type'); + Segment[nSeg-1].periph[nperiph-1].typ:=s2; + inc(nLigne); + + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'father #'); + val(s2,i,erreur); + Segment[nSeg-1].periph[nperiph-1].pere:=i; + inc(nLigne); + + s:=AnsiLowerCase(lignes[nligne]); + inc(nLigne); + s2:=isole_valeur(s,'x='); + val(s2,i,erreur); + Segment[nSeg-1].periph[nperiph-1].x:=i; + + s2:=isole_valeur(s,'y='); + val(s2,i,erreur); + Segment[nSeg-1].periph[nperiph-1].y:=i; + + s2:=isole_valeur(s,'z='); + val(s2,i,erreur); + Segment[nSeg-1].periph[nperiph-1].z:=i; + + s2:=isole_valeur(s,'angle='); + val(s2,i,erreur); + Segment[nSeg-1].periph[nperiph-1].angle:=i; + + s:=AnsiLowerCase(lignes[nligne]); + inc(nLigne); + s2:=isole_valeur(s,'bright ='); + val(s2,i,erreur); + Segment[nSeg-1].periph[nperiph-1].bRight:=i; + + s2:=isole_valeur(s,'bdown ='); + val(s2,i,erreur); + Segment[nSeg-1].periph[nperiph-1].bDown:=i; + + s2:=isole_valeur(s,'location ='); + val(s2,i,erreur); + Segment[nSeg-1].periph[nperiph-1].location:=i; + + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'address'); + val(s2,i,erreur); + Segment[nSeg-1].periph[nperiph-1].Adresse:=i; + + s2:=isole_valeur(s,'status'); + val(s2,i,erreur); + Segment[nSeg-1].periph[nperiph-1].status:=i; +end; + +procedure compile_inter; +var i,erreur : integer; + s,s2: string; +begin + //------------------------Lecture inter---------------------------- + if debugAnalyse then AfficheDebug('Compile inter',clWhite); + inc(nInter); + segment[nSeg-1].ninter:=nInter; + setlength(segment[nSeg-1].inter,ninter); + + s:=AnsiLowerCase(lignes[nligne]); + inc(nLigne); + s2:=isole_valeur(s,'x='); + val(s2,i,erreur); + Segment[nSeg-1].inter[nInter-1].x:=i; + + s2:=isole_valeur(s,'y='); + val(s2,i,erreur); + Segment[nSeg-1].inter[nInter-1].y:=i; + + s2:=isole_valeur(s,'z='); + val(s2,i,erreur); + Segment[nSeg-1].inter[nInter-1].z:=i; + + s2:=isole_valeur(s,'type:'); + Segment[nSeg-1].inter[nInter-1].typ:=s2; + + s:=AnsiLowerCase(lignes[nligne]); + inc(nLigne); + s2:=isole_valeur(s,'z='); + val(s2,i,erreur); + Segment[nSeg-1].inter[nInter-1].MirrorZ:=i; + +end; + +procedure compile_port; +var i,erreur : integer; + s,s2: string; +begin + //------------------------Lecture port---------------------------- + inc(nport); + segment[nSeg-1].nport:=nport; + setlength(segment[nSeg-1].port,nport); + + s:=AnsiLowerCase(lignes[nligne]); + i:=pos('#',s); + if i=0 then begin Affiche('Erreur structure n°12',clOrange);exit;end; + delete(s,1,i); + val(s,i,erreur); + Segment[nSeg-1].port[nPort-1].numero:=i; + if debugAnalyse then AfficheDebug('Compile port '+intToSTR(i),clLime); + + s2:=isole_valeur(s,'obj type'); + Segment[nSeg-1].port[nPort-1].typ:=s2; // port dummy_port + + s2:=isole_valeur(s,'local #'); + if s2='' then begin Affiche('Erreur structure n°14',clOrange);exit;end; + val(s,i,erreur); + Segment[nSeg-1].port[nPort-1].local:=i; + inc(nligne,2); + + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'x='); + val(s2,i,erreur); + Segment[nSeg-1].port[nPort-1].x:=i; + + s2:=isole_valeur(s,'y='); + val(s2,i,erreur); + Segment[nSeg-1].port[nPort-1].y:=i; + + s2:=isole_valeur(s,'z='); + val(s2,i,erreur); + Segment[nSeg-1].port[nPort-1].z:=i; + + s2:=isole_valeur(s,'angle='); + val(s2,i,erreur); + Segment[nSeg-1].port[nPort-1].angle:=i; + + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'connect status:'); + Segment[nSeg-1].port[nPort-1].connecte:=s2='connected'; + + if Segment[nSeg-1].port[nPort-1].typ='dummy_port' then + exit; + + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'connected to port #'); + val(s2,i,erreur); + Segment[nSeg-1].port[nPort-1].ConnecteAuPort:=i; + + s2:=isole_valeur(s,'segment #'); + val(s2,i,erreur); + Segment[nSeg-1].port[nPort-1].ConnecteAuSeg:=i; +end; + +procedure compile_segment; +var i,erreur : integer; + s,s2,segType: string; +begin + //------------------------Lecture segment---------------------------- + nport:=0; + nperiph:=0; + nInter:=0; + inc(nSeg); + setlength(segment,nSeg); + + Segment[nSeg-1].nport:=0; + Segment[nSeg-1].nperiph:=0; + Segment[nSeg-1].nInter:=0; + s:=AnsiLowerCase(lignes[nligne]); + i:=pos('#',s); + if i=0 then begin Affiche('Erreur structure n°2',clOrange);exit;end; + delete(s,1,i); + val(s,i,erreur); + segment[nSeg-1].numero:=i; + + if debugAnalyse then AfficheDebug('Compile segment '+intToSTR(i),claqua); + + delete(s,1,erreur); + + s2:=isole_valeur(s,'obj type: '); + if s2<>'segment' then begin Affiche('Erreur structure n°3',clOrange);exit;end; + s2:=isole_valeur(s,'seg type: '); + if s2='' then begin Affiche('Erreur structure n°4',clOrange);exit;end; + segType:=s2; + segment[nSeg-1].typ:=s2; // ARC TURNOUT(champ suppl) + inc(nligne); + + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'module :'); + inc(nligne); + + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'nb ports:'); + val(s2,i,erreur); + segment[nSeg-1].nport:=i; + + s:=lignes[nligne]; + s2:=isole_valeur(s,'nb periphs:'); + val(s2,i,erreur); + segment[nSeg-1].nperiph:=i; + inc(nligne); + + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'zone[0]:'); + s2:=isole_valeur(s,'zone[1]:'); + inc(nligne,2); + + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'xmin ='); + val(s2,i,erreur); + segment[nSeg-1].XMin:=i; + if ixMaxiCDM then xMaxiCDM:=i; + + s2:=isole_valeur(s,'ymax ='); + val(s2,i,erreur); + segment[nSeg-1].Ymax:=i; + if i>yMaxiCDM then yMaxiCDM:=i; + + if segType='turntable' then + begin + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'start angle:'); + val(s2,i,erreur); + segment[nSeg-1].startangle:=i; + s2:=isole_valeur(s,'length:'); + val(s2,i,erreur); + segment[nSeg-1].longueur:=i; + s2:=isole_valeur(s,'lengthdev:'); + val(s2,i,erreur); + segment[nSeg-1].lengthdev:=i; + + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'xc0:'); + val(s2,i,erreur); + segment[nSeg-1].xc0:=i; + s2:=isole_valeur(s,'yc0:'); + val(s2,i,erreur); + segment[nSeg-1].yc0:=i; + s2:=isole_valeur(s,'xc:'); + val(s2,i,erreur); + segment[nSeg-1].xc:=i; + s2:=isole_valeur(s,'yc:'); + val(s2,i,erreur); + segment[nSeg-1].yc:=i; + exit; + end; + + // modif pour signaux complexes + if (segType='turnout') or (segType='turnout_3way') or (segType='dbl_slip_switch') then + begin + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'adresse ='); + val(s2,i,erreur); + segment[nSeg-1].adresse:=i; + + if (segType='dbl_slip_switch') then + begin + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'adresse2 ='); + val(s2,i,erreur); + segment[nSeg-1].adresse2:=i; + end; + + s2:=isole_valeur(s,'duree ='); + val(s2,i,erreur); + segment[nSeg-1].duree:=i; + exit; + end; + + if segType='straight' then exit; + if segType='pre_curve' then exit; + if segType='bumper_stop' then exit; + + // les autres aiguillages + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'start angle:'); + val(s2,i,erreur); + segment[nSeg-1].StartAngle:=i; + + s2:=isole_valeur(s,'arc angle:'); + val(s2,i,erreur); + segment[nSeg-1].ArcAngle:=i; + + if segType='crossing' then + begin + s2:=isole_valeur(s,'radius:'); + val(s2,i,erreur); + segment[nSeg-1].Rayon:=i; + + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'length:'); + val(s2,i,erreur); + segment[nSeg-1].longueur:=i; + + s2:=isole_valeur(s,'lengthdev:'); + val(s2,i,erreur); + segment[nSeg-1].longueurDev:=i; + + s2:=isole_valeur(s,'deltadev:'); + val(s2,i,erreur); + segment[nSeg-1].deltadev:=i; + + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'curve offset:'); + val(s2,i,erreur); + segment[nSeg-1].curveoffset:=i; + exit; + end; + + //turnout_3way + + if segType='turnout_sym' then + begin + s2:=isole_valeur(s,'radius:'); + val(s2,i,erreur); + segment[nSeg-1].Rayon:=i; + + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'lengthdev:'); + val(s2,i,erreur); + segment[nSeg-1].longueur:=i; + s2:=isole_valeur(s,'deltadev:'); + val(s2,i,erreur); + segment[nSeg-1].DeltaDev:=i; + + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'curve offset:'); + val(s2,i,erreur); + segment[nSeg-1].Curveoffset:=i; + + // signaux complexes + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + + s2:=isole_valeur(s,'adresse ='); + val(s2,i,erreur); + segment[nSeg-1].adresse:=i; + s2:=isole_valeur(s,'duree ='); + val(s2,i,erreur); + segment[nSeg-1].duree:=i; + exit; + end; + + if segType='turnout_curved_2r' then + begin + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'radius0:'); + val(s2,i,erreur); + segment[nSeg-1].radius0:=i; + s2:=isole_valeur(s,'radius:'); + val(s2,i,erreur); + segment[nSeg-1].rayon:=i; + + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'angle0:'); + val(s2,i,erreur); + segment[nSeg-1].angle0:=i; + s2:=isole_valeur(s,'angle:'); + val(s2,i,erreur); + segment[nSeg-1].angle:=i; + + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'length:'); + val(s2,i,erreur); + segment[nSeg-1].longueur:=i; + s2:=isole_valeur(s,'deltadev0:'); + val(s2,i,erreur); + segment[nSeg-1].deltadev0:=i; + s2:=isole_valeur(s,'xc0:'); + val(s2,i,erreur); + segment[nSeg-1].xc0:=i; + s2:=isole_valeur(s,'yc0:'); + val(s2,i,erreur); + segment[nSeg-1].yc0:=i; + + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'lengthdev:'); + val(s2,i,erreur); + segment[nSeg-1].lengthdev:=i; + s2:=isole_valeur(s,'deltadev:'); + val(s2,i,erreur); + segment[nSeg-1].deltadev:=i; + s2:=isole_valeur(s,'xc:'); + val(s2,i,erreur); + segment[nSeg-1].xc:=i; + s2:=isole_valeur(s,'yc:'); + val(s2,i,erreur); + segment[nSeg-1].yc:=i; + exit; + end; + + + + if segType='turnout_curved' then + begin + s2:=isole_valeur(s,'radius:'); + val(s2,i,erreur); + segment[nSeg-1].Rayon:=i; + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + + s2:=isole_valeur(s,'length:'); + val(s2,i,erreur); + segment[nSeg-1].longueur:=i; + + s2:=isole_valeur(s,'deltadev:'); + val(s2,i,erreur); + segment[nSeg-1].DeltaDev:=i; + + s2:=isole_valeur(s,'xc0:'); + val(s2,i,erreur); + segment[nSeg-1].xc0:=i; + + s2:=isole_valeur(s,'yc0:'); + val(s2,i,erreur); + segment[nSeg-1].yc0:=i; + + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + + s2:=isole_valeur(s,'lengthdev:'); + val(s2,i,erreur); + segment[nSeg-1].longueurDev:=i; + + s2:=isole_valeur(s,'deltadev:'); + val(s2,i,erreur); + segment[nSeg-1].DeltaDev2:=i; + + s2:=isole_valeur(s,'xc:'); + val(s2,i,erreur); + segment[nSeg-1].xc:=i; + + s2:=isole_valeur(s,'yc:'); + val(s2,i,erreur); + segment[nSeg-1].yc:=i; + + // signaux complexes + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + + s2:=isole_valeur(s,'adresse ='); + val(s2,i,erreur); + segment[nSeg-1].adresse:=i; + s2:=isole_valeur(s,'duree ='); + val(s2,i,erreur); + segment[nSeg-1].duree:=i; + exit; + end; + + s2:=isole_valeur(s,'radius:'); + val(s2,i,erreur); + segment[nSeg-1].Rayon:=i; + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + + if segment[nseg-1].typ='turnout' then + begin + s2:=isole_valeur(s,'length:'); + val(s2,i,erreur); + segment[nSeg-1].longueur:=i; + + s2:=isole_valeur(s,'lengthdev:'); + val(s2,i,erreur); + segment[nSeg-1].longueurDev:=i; + + s2:=isole_valeur(s,'deltadev:'); + val(s2,i,erreur); + segment[nSeg-1].DeltaDev:=i; + + inc(nligne); + s:=AnsiLowerCase(lignes[nligne]); + s2:=isole_valeur(s,'curve offset:'); + val(s2,i,erreur); + segment[nSeg-1].CurveOffset:=i; + end; + + if segment[nseg-1].typ='arc' then + begin + s2:=isole_valeur(s,'lxc:'); + val(s2,i,erreur); + segment[nSeg-1].lXc:=i; + + s2:=isole_valeur(s,'lyc:'); + val(s2,i,erreur); + segment[nSeg-1].lYc:=i; + end; +end; + +procedure Coords(var x,y : integer); +begin + x:=round( ((x - xMiniCDM) ) * reducX )+(cadre div 2); + y:=round( (((yMaxiCDM-y) ) - yMiniCDM) * reducY )+(cadre div 2); + //y:=round((y - yMiniCDM)*reducY); +end; + +function degtoRad(angle : double) : double; +begin + degtoRad:=angle*pi/180; +end; + +procedure D_Arc(Canvas: TCanvas; CenterX,CenterY: integer; + Radius: Integer; StartDegrees, StopDegrees: Double); + //Get it in http://delphidabbler.com/tips/148 +const + Offset = 90; +var + X1, X2, X3, X4: Integer; + Y1, Y2, Y3, Y4: Integer; +begin + X1 := CenterX - Radius; + Y1 := CenterY - Radius; + X2 := CenterX + Radius; + Y2 := CenterY + Radius; + X4 := CenterX + Round(Radius * Cos(DegToRad(Offset + StartDegrees))); + Y4 := Centery - Round(Radius * Sin(DegToRad(Offset + StartDegrees))); + X3 := CenterX + Round(Radius * Cos(DegToRad(Offset + StopDegrees))); + Y3 := Centery - Round(Radius * Sin(DegToRad(Offset + StopDegrees))); + Canvas.Arc(X1, Y1, X2, Y2, X3, Y3, X4, Y4); +end; + +procedure affiche_port(indexSeg,IndexPort: integer); +var x,y : integer; + s : string; +begin + x:=segment[indexSeg].port[indexport].X; y:=segment[indexSeg].port[IndexPort].y; + s:=intToSTR(segment[indexSeg].port[IndexPort].numero); + coords(x,y); + with FormAnalyseCdm.ImageCDM.canvas do + begin + pen.Color:=ClLime; + TextOut(x,y,s); + Moveto(0,0); + LineTo(x,y); + end; +end; + +procedure affichage; +var r : Trect; + i,j,x1,x2,y1,y2,largeur,hauteur,cx,cy,rayon : integer; + startAngle,arcAngle,lxc,lyc : integer; + SegType,s,s2 : string; + Zoom : double; + portsSeg : array[0..10] of record x,y : integer; end; +begin + if (xMaxiCDM-xminiCDM=0) or (yMaxiCDM-yminiCDM=0) then exit; + with formAnalyseCDM do + begin + largeur:=3000;hauteur:=1000; + largeur:=(XmaxiCDM-XminiCDM) div 20; + hauteur:=(YmaxiCDM-YminiCDM) div 20; + //largeur:=ScrollBox1.Width; + //hauteur:=ScrollBox1.Height; + + ImageCDM.Width:=largeur; + ImageCDM.Height:=hauteur; + ImageCDM.Picture.Bitmap.Width:=largeur; + ImageCDM.Picture.Bitmap.height:=hauteur; + + with scrollBox1 do + begin + HorzScrollBar.Range:=largeur; + HorzScrollBar.Tracking:=true; + HorzScrollBar.Smooth:=false; // ne pas mettre true sinon figeage dans W11 si onclique sur la trackbar!! + VertScrollBar.Range:=hauteur; + VertScrollBar.Tracking:=true; + VertScrollBar.Smooth:=false; + end; + //largeur:=ScrollBox1.Width; + //hauteur:=ScrollBox1.Height; + end; + + Zoom:=(270-formAnalyseCDM.TrackBar1.Position)/100; + reducX:=Zoom*(largeur-2*cadre)/(XmaxiCDM-XminiCDM); + reducY:=Zoom*(hauteur-2*cadre)/(YmaxiCDM-YminiCDM); + + with FormAnalyseCDM.ImageCDM.Canvas do + begin + //effacer tout + Pen.width:=1; + Brush.Style:=bsSolid; + Brush.Color:=clblack; + pen.color:=clyellow; + r:=rect(0,0,FormAnalyseCDM.ImageCDM.width,FormAnalyseCDM.ImageCDM.height); + FillRect(r); + x1:=xminiCDM;y1:=yminiCDM; + coords(x1,y1); + x2:=xmaxiCDM;y2:=ymaxiCDM; + coords(x2,y2); + end; + + // balayage ... + for i:=0 to nSeg-1 do + begin + SegType:=Segment[i].typ; + FormAnalyseCDM.ImageCDM.Canvas.Pen.Color:=claqua; + FormAnalyseCDM.ImageCDM.Canvas.Font.Color:=claqua; + + s:='S'+intToSTR(Segment[i].numero); //+' '+SegType; + if (SegType='turnout') or (SegType='dbl_slip_switch') then + begin + s2:=intToSTR(Segment[i].adresse); + s:=s+' @='+s2; + end; + + begin + x1:=segment[i].XMin;y1:=segment[i].YMin; coords(x1,y1); + x2:=segment[i].XMax;y2:=segment[i].Ymax; coords(x2,y2); + with FormAnalyseCDM.ImageCDM.Canvas do + begin + if formAnalyseCDM.CheckSegments.checked then + begin + Textout(x1,y1,s); + PolyGon([point(x1,y1),Point(x2,y2)]); + end; + if SegType='straight' then + begin + // x1:=segment[i].xc0; + // affiche(intToSTR(x1),clyellow); + end; + end; + end; + //Affiche(s,ClAqua); + + // ports en vert -------------------------------------- + nport:=Segment[i].nport; + FormAnalyseCDM.ImageCDM.Canvas.Pen.Color:=clLime; + FormAnalyseCDM.ImageCDM.Canvas.Font.Color:=clLime; + for j:=0 to nPort-1 do + begin + //Affiche_port(i,j); + + //s:='Port '+intToSTR(Segment[i].port[j].numero)+' '+Segment[i].port[j].typ; + s:='P'+intToSTR(Segment[i].port[j].numero); + x1:=segment[i].port[j].X; y1:=segment[i].port[j].y; + + with FormAnalyseCDM.ImageCDM.Canvas do + begin + //Affiche('I='+intToSTR(i)+' '+intToSTR(x1)+' '+intToSTR(y1),clred); + coords(x1,y1); + if formAnalyseCDM.CheckConnexions.checked then Ellipse(x1-5,y1-5,x1+5,y1+5); + portsSeg[j].x:=x1; + portsSeg[j].y:=y1; + if formAnalyseCDM.CheckPorts.checked then Textout(x1,y1,s); + end; + //Affiche(s,ClYellow); + end; + // relier les ports en vert &&& + if formAnalyseCDM.CheckPorts.checked then + with FormAnalyseCDM.ImageCDM.Canvas do + begin + moveto(portsSeg[0].x,portsSeg[0].y); + for j:=1 to nPort-1 do + LineTo(portsSeg[j].x,portsSeg[j].y); + { if segment[i].typ='arc' then + begin // D_Arc(Canvas: TCanvas; CenterX,CenterY: integer;Radius: Integer; StartDegrees, StopDegrees: Double); + rayon:=segment[i].Rayon; + StartAngle:=segment[i].StartAngle; + ArcAngle:=segment[i].ArcAngle; + lxc:=segment[i].lXc;lyc:=segment[i].lyc; + coords(lxc,lyc); + D_arc(FormAnalyseCDM.ImageCDM.Canvas,lxc,lyc,rayon,startAngle,ArcAngle); + end; } + end; + + // périphériques en jaune -------------------------- + nperiph:=Segment[i].nperiph; + FormAnalyseCDM.ImageCDM.Canvas.Pen.Color:=clYellow; + FormAnalyseCDM.ImageCDM.Canvas.Font.Color:=clYellow; + //nperiph:=0; //&&& + + for j:=0 to nPeriph-1 do + begin + s:='Periph '+intToSTR(Segment[i].periph[j].numero)+' '+Segment[i].periph[j].typ; + s2:=intToSTR(Segment[i].periph[j].adresse); + s:=s+' Adresse='+s2; + x1:=segment[i].periph[j].X; y1:=segment[i].periph[j].y ; + with FormAnalyseCDM.ImageCDM.Canvas do + begin + coords(x1,y1); + if formAnalyseCDM.CheckConnexions.checked then Ellipse(x1-5,y1-5,x1+5,y1+5); + if formAnalyseCDM.CheckAdresses.checked then textout(x1,y1,s2); + end; + //Affiche(s,clOrange); + end; + + nInter:=Segment[i].nInter; + for j:=0 to nInter-1 do + begin + s:='Inter '+Segment[i].Inter[j].typ; + //Affiche(s,ClYellow); + end; + end; + //if i=0 then exit; +end; + // FormAnalyseCDM.ImageCDM.Canvas.Refresh; + +function Supprime_espaces(s : string) : string; +var faire : boolean; +begin + s:=AnsiLowerCase(s); + faire:=s<>''; + while faire do + begin + if s[1]=' ' then delete(s,1,1); + if length(s)<>0 then faire:=s[1]=' ' else faire:=false; + end; + result:=s; +end; + +procedure liste_liens; +var i,j,connecteAuPort,ConnecteAuSeg,numPort: integer; + segType : string; +begin + for i:=0 to nSeg-1 do + begin + SegType:=Segment[i].typ; + nport:=Segment[i].nport; + for j:=0 to nPort-1 do + begin + connecteAuPort:=Segment[i].port[j].ConnecteAuPort; + connecteAuSeg:=Segment[i].port[j].ConnecteAuSeg; + NumPort:=Segment[i].port[j].numero; + Affiche('Le port '+intToSTR(NumPort)+' est connecté au port '+intToSTR(connecteAuPort)+' segment '+intToSTR(ConnecteAuSeg),clyellow); + end; + end; +end; + +procedure trouve_IndexSegPort(seg,port : integer;var indexSeg,indexPort : integer); +var i,j,p,np,ns : integer; + trouve : boolean; +begin + i:=0; + repeat + j:=0; + np:=segment[i].nport; + ns:=segment[i].numero; + repeat + p:=segment[i].port[j].numero; + //Affiche(intToSTR(p),clwhite); + trouve:=(port=p) and (seg=ns); + inc(j); + until (j>np-1) or trouve; + inc(i); + until (i>nSeg-1) or trouve; + dec(i);dec(j); + if trouve then + begin + indexSeg:=i; + indexPort:=j; + end + else + begin + indexSeg:=-1; + indexPort:=-1; + end +end; + +// trouve les index du port +procedure trouve_IndexPort(port : integer;var indexSeg,indexPort : integer); +var i,j,p,np,ns : integer; + trouve : boolean; +begin + i:=0; + repeat + j:=0; + np:=segment[i].nport; + ns:=segment[i].numero; + repeat + p:=segment[i].port[j].numero; + //Affiche(intToSTR(p),clwhite); + trouve:=(port=p) ; + inc(j); + until (j>np-1) or trouve; + inc(i); + until (i>nSeg-1) or trouve; + dec(i);dec(j); + if trouve then + begin + indexSeg:=i; + indexPort:=j; + end + else + begin + indexSeg:=-1; + indexPort:=-1; + end +end; + +function segment_aig(s : string) : boolean; +begin + segment_aig:=(s='turnout') or (s='dbl_slip_switch') or (s='turnout_sym') or + (s='turnout_curved') or (s='turnout_curved_2r') or (s='turnout_3way'); +end; + +// explore le port,segment jusqu'a trouver une adresse d'aiguillage ou de détecteur +function explore_port(seg,port : integer;var c : string) : integer; +var ns,i,IdSeg,IdPort,np,adresse,port1,port2,portSuivant,segSuivant,portLocal,portLocSuiv : integer; + typeP : string; + trouve : boolean; +begin + trouve_IndexSegPort(seg,port,idSeg,IdPort); + if idseg=-1 then + begin + Affiche('Erreur 1 pas trouvé le port '+intToSTR(port),clred); + explore_port:=0; + c:=''; + exit; + end; + + // trouver le segment contigu connecté au port de connexion + segSuivant:=segment[idseg].port[idport].ConnecteAuSeg; + portSuivant:=segment[idseg].port[idport].ConnecteAuPort; + trouve_IndexSegPort(segSuivant,portSuivant,idSeg,IdPort); + //Affiche('segsuiv='+intToSTr(segsuivant),clred); + if idSeg=-1 then + begin + Affiche('Erreur 2 pas trouvé le port '+intToSTR(port),clred); + c:=''; + explore_port:=0; + exit; + end; + + + // remonter au segment pour voir si c'est un aiguillage + typeP:=segment[idSeg].typ; + if segment_aig(typeP) then // est-ce un aig + //------------- aiguillage + begin + portlocal:=segment[idSeg].port[idport].local; + case portlocal of + 0 : c:='P'; + 1 : c:='D'; + 2 : c:='S'; + end; + explore_port:=segment[idSeg].adresse; + exit; + end; + // --- croisement + if typeP='crossing' then + begin + portLocal:=segment[idSeg].port[idport].local; // port local + // port d'en face + case portLocal of + 0 : portLocSuiv:=2; + 1 : portLocSuiv:=3; + 2 : portLocSuiv:=0; + 3 : portLocSuiv:=1; + end; + i:=explore_port(segSuivant,segment[idSeg].port[PortLocSuiv].numero,c); + explore_port:=i; + exit; + end; + + // y a t-il des periph + np:=segment[idSeg].nperiph; + if np<>0 then + begin + // présence de péripéhiques + i:=0; + repeat + typeP:=segment[idSeg].periph[i].typ; + adresse:=segment[idSeg].periph[i].adresse; + trouve:=(typeP='detector') and (adresse<>0); + inc(i); + until (i>np-1) or trouve; + if trouve then + begin + c:=''; + explore_port:=adresse; + exit; + end; + end; + + // trouver l'autre port du segment idseg + // sur 2 ports + np:=segment[idSeg].nport; + if np=0 then + begin + c:=''; + explore_port:=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(SegSuivant,port1,c); + if (port2<>portSuivant) and (segment[idSeg].port[1].connecte) then i:=explore_port(SegSuivant,port2,c); + explore_port:=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(SegSuivant,port1,c); + if port2<>portSuivant then i:=explore_port(SegSuivant,port2,c); + c:=''; + explore_port:=i; + exit; + end; + + Affiche('Segment '+typeP+' non trouvé',clred); + + explore_Port:=0; + +end; + +procedure cree; + var i,j,connecteAuPort,ConnecteAuSeg,numPort,NumSegment,IndexSegment,IndexPort, + nport,adresse,adresse2,element,DernAdrAig : integer; + s,segType,c : string; +begin + // 1er segment, 1er port + IndexSegment:=0;IndexPort:=0; + + { + for i:=1 to 10 do + begin + numSegment:=segment[IndexSegment].numero; + NumPort:=segment[IndexSegment].port[IndexPort].numero; + connecteAuPort:=segment[IndexSegment].port[IndexPort].ConnecteAuPort; + connecteAuSeg:=segment[IndexSegment].port[IndexPort].ConnecteAuSeg; + Affiche('le segment '+intToSTR(NumSegment)+' port '+intToSTR(NumPort)+' est connecté au S'+intToSTR(connecteAUSeg)+' P'+intToSTR(connecteAuPort),clyellow); + trouve_IndexSegPort(connecteAuPort,IndexSegment,IndexPort); + end; + } + + DernAdrAig:=0; + // liste les segments avec des aiguillages + if debugAnalyse then + begin + AfficheDebug('Liste des aiguillages',clWhite); + AfficheDebug('--------------------------------',clWhite); + end; + NAig_CDM:=0; + for i:=0 to nseg-1 do + begin + segType:=segment[i].typ; + if segment_aig(segtype) then + begin + numSegment:=segment[i].numero; + adresse:=segment[i].adresse; + if DernAdrAig0 then + begin + inc(nAig_CDM); // attention deux adresses!! + // remplissage 2eme adresse + Aig_CDM[nAig_CDM].adresse:=adresse2; + Aig_CDM[nAig_CDM].temps:=segment[i].duree; + Aig_CDM[nAig_CDM].modele:=tjd; + Aig_CDM[nAig_CDM].ddroit:=Adresse; + Aig_CDM[nAig_CDM].ddroitB:='D'; + Aig_CDM[nAig_CDM].dDevie:=Adresse; + Aig_CDM[nAig_CDM].dDevieB:='S'; + Aig_CDM[nAig_CDM].etatTJD:=4; + end; + + end; + + if (SegType='turnout') or (SegType='turnout_sym') or (SegType='turnout_curved') or (SegType='turnout_curved_2r') then Aig_CDM[nAig_CDM].modele:=aig; + if (SegType='turnout_3way') then Aig_CDM[nAig_CDM].modele:=triple; + + for j:=0 to segment[i].nport-1 do + begin + s:=' Port '+intToSTR(j)+' '; + if (SegType<>'dbl_slip_switch') and (Segtype<>'turnout_3way') then + case j of + 0 : s:=s+'P'; + 1 : s:=s+'D'; + 2 : s:=s+'S'; + end; + + if (SegType='dbl_slip_switch') then + begin + + case j of + 0 : s:=s+'D'; + 1 : s:=s+'S'; + 2 : s:=s+'D'; + 3 : s:=s+'S'; + end; + end; + + if (SegType='turnout_3way') then + case j of + 0 : s:=s+'P'; + 1 : s:=s+'D'; + 2 : s:=s+'S'; + 3 : s:=s+'S2'; + end; + + // explorer les ports de l'aiguillage + element:=explore_port(numsegment,segment[i].port[j].numero,c); + s:=s+' Element : '+intToStr(element)+c; + if debugAnalyse then AfficheDebug(s,clorange); + + if (SegType='dbl_slip_switch') then + begin + if j=0 then begin Aig_CDM[nAig_CDM-1].Adroit:=element;if length(c)<>0 then Aig_CDM[nAig_CDM-1].AdroitB:=c[1];end; + if j=1 then begin Aig_CDM[nAig_CDM-1].Adevie:=element;if length(c)<>0 then Aig_CDM[nAig_CDM-1].AdevieB:=c[1];end; + if j=2 then begin Aig_CDM[nAig_CDM].Adroit:=element;if length(c)<>0 then Aig_CDM[nAig_CDM].AdroitB:=c[1];end; + if j=3 then begin Aig_CDM[nAig_CDM].Adevie:=element;if length(c)<>0 then Aig_CDM[nAig_CDM].AdevieB:=c[1];end; + end + else + begin + // autre aiguillage que tjd (3 ou 4 ports pour les tri) + if j=0 then begin Aig_CDM[nAig_CDM].APointe:=element;if length(c)<>0 then Aig_CDM[nAig_CDM].APointeB:=c[1];end; + if j=1 then begin Aig_CDM[nAig_CDM].ADroit:=element; if length(c)<>0 then Aig_CDM[nAig_CDM].ADroitB:=c[1];end; + if j=2 then begin Aig_CDM[nAig_CDM].ADevie:=element; if length(c)<>0 then Aig_CDM[nAig_CDM].ADevieB:=c[1];end; + if j=3 then begin Aig_CDM[nAig_CDM].ADevie:=element; if length(c)<>0 then Aig_CDM[nAig_CDM].ADevieB:=c[1];end; + end + end; + // exit; + end; + end; + + if debugAnalyse then + begin + AfficheDebug(' ',clwhite); + AfficheDebug('Liste des croisements',clWhite); + AfficheDebug('--------------------------------',clWhite); + end; + for i:=0 to nseg-1 do + begin + segType:=segment[i].typ; + if segType='crossing' then + begin + numSegment:=segment[i].numero; + adresse:=segment[i].adresse; + + inc(nAig_CDM); + inc(dernAdrAig); + Aig_CDM[nAig_CDM].adresse:=DernAdrAig; //&&&& + + Aig_CDM[nAig_CDM].modele:=crois; + + s:='Segment '+intToSTR(numSegment)+' type='+segtype+' Adresse='+intToSTR(DernAdrAig); + if debugAnalyse then AfficheDebug(s,clorange); + + + for j:=0 to segment[i].nport-1 do + begin + s:=' Port '+intToSTR(j)+' '; + + + // explorer les ports de l'aiguillage + element:=explore_port(numsegment,segment[i].port[j].numero,c); + + case j of + 0 : begin s:=s+'D';Aig_cdm[nAig_cdm].ddroit:=element;if length(c)<>0 then Aig_cdm[nAig_cdm].ddroitB:=c[1];end; + 1 : begin s:=s+'S';Aig_cdm[nAig_cdm].dDevie:=element;if length(c)<>0 then Aig_cdm[nAig_cdm].ddevieB:=c[1];end; + 2 : begin s:=s+'D';Aig_cdm[nAig_cdm].ADroit:=element;if length(c)<>0 then Aig_cdm[nAig_cdm].aDroitB:=c[1];end; + 3 : begin s:=s+'S';Aig_cdm[nAig_cdm].aDevie:=element;if length(c)<>0 then Aig_cdm[nAig_cdm].aDevieB:=c[1];end; + end; + + s:=s+' Element : '+intToStr(element)+c; + if debugAnalyse then afficheDebug(s,clorange); + + end; + end; + end; + +end; + +procedure Analyse_seg; +var s,s2,ch,SegType: string; + i,nombre,position : integer; + +begin + Lignes:=Formprinc.FenRich.Lines; + nligne:=0; nSeg:=0; + xminiCDM:=0;yMiniCDM:=0;xmaxiCDM:=0;yMaxiCDM:=0; + nombre:=Formprinc.FenRich.Lines.Count; + NomModule:=Lignes[0]; + formAnalyseCDM.Caption:='Squelette du réseau '+NomModule; + + Affiche('Compilation en cours',clWhite); + + repeat + s:=supprime_espaces(lignes[nligne]); + position:=pos('segment #',s) ; if position=1 then + begin + //affiche(s,clred); + compile_segment; + end; + position:=pos('port #',s) ; if position=1 then + begin + //affiche(s,clred); + compile_port; + end; + position:=pos('inter:',s) ; if position=1 then + begin + //affiche(s,clred); + compile_inter; + end; + position:=pos('periph #',s) ; if position=1 then + begin + //affiche(s,clred); + compile_periph; + end; + inc(nligne); + until (nligne>nombre); // or (nligne=1311) ; + //Affiche('fin de la compilation',cllime); + + Affichage; + + formAnalyseCDM.Show; + formprinc.ButtonAffAnalyseCDM.Visible:=true; + Affiche('Compilation terminée',clWhite); + // crée + cree; + + if MaxAiguillage<>0 then + begin + if MessageDlg('Une configuration de réseau existe dans signaux complexes.'+#10+#13+ + 'Si vous importez le réseau CDM, la configuration des aiguillages de signaux complexes sera écrasée.'+#10+#13+ + 'Voulez vous continuer l''importation? (aiguillages)',mtConfirmation,[mbyes,mbNo],0)=mrNo then + begin + Affiche('Importation annulée',clOrange); + exit; + end; + end; + + MaxAiguillage:=0; + + Affiche('Importation en cours',clWhite); + // recopier les aiguillages + for i:=1 to NAig_CDM do + begin + Aiguillage[i].adresse:=Aig_CDM[i].adresse; + Aiguillage[i].modele:=Aig_Cdm[i].modele; + Aiguillage[i].temps:=Aig_cdm[i].temps; + Aiguillage[i].ADroit:=Aig_Cdm[i].ADroit; + Aiguillage[i].ADroitB:=Aig_Cdm[i].ADroitB; + Aiguillage[i].ADevie:=Aig_Cdm[i].ADevie; + Aiguillage[i].ADevieB:=Aig_Cdm[i].ADevieB; + Aiguillage[i].APointe:=Aig_Cdm[i].Apointe; + Aiguillage[i].APointeB:=Aig_Cdm[i].ApointeB; + Aiguillage[i].DDroit:=Aig_Cdm[i].DDroit; + Aiguillage[i].DDroitB:=Aig_Cdm[i].DDroitB; + Aiguillage[i].DDevie:=Aig_CDM[i].DDevie; + Aiguillage[i].DDevieB:=Aig_CDM[i].DDevieB; + Aiguillage[i].EtatTJD:=Aig_CDM[i].EtatTJD; + + Aiguillage[i].posInit:=9; + aiguillage[i].InversionCDM:=0; + aiguillage[i].vitesse:=0; + end; + MaxAiguillage:=NAig_CDM; + + Affiche('Importation terminée',clWhite); + Affiche('Vérification de la cohérence :',clWhite); + if verif_coherence then Affiche('Configuration cohérente',clLime); + +end; + + +procedure TFormAnalyseCDM.FormResize(Sender: TObject); +begin + affichage; +end; + +procedure TFormAnalyseCDM.CheckSegmentsClick(Sender: TObject); +begin + affichage; +end; + +procedure TFormAnalyseCDM.CheckConnexionsClick(Sender: TObject); +begin + Affichage; +end; + +procedure TFormAnalyseCDM.CheckAdressesClick(Sender: TObject); +begin + Affichage; +end; + +procedure TFormAnalyseCDM.TrackBar1Change(Sender: TObject); +begin + Affichage; +end; + +procedure TFormAnalyseCDM.ButtonAffPortClick(Sender: TObject); +var i,j,port,numport,erreur : integer; + trouve : boolean; +begin + val(editPort.text,numport,erreur); + trouve_IndexPort(numport,i,j); + if i=-1 then exit; + Affiche_port(i,j); + +end; + +procedure TFormAnalyseCDM.FormCreate(Sender: TObject); +begin + checkPorts.Checked:=true; +end; + + + +end. + diff --git a/UnitCDF.dcu b/UnitCDF.dcu deleted file mode 100644 index 050ba44..0000000 Binary files a/UnitCDF.dcu and /dev/null differ diff --git a/UnitConfig.dcu b/UnitConfig.dcu deleted file mode 100644 index ac1e362..0000000 Binary files a/UnitConfig.dcu and /dev/null differ diff --git a/UnitConfig.dfm b/UnitConfig.dfm index 51773b8..9d20d29 100644 --- a/UnitConfig.dfm +++ b/UnitConfig.dfm @@ -1571,7 +1571,7 @@ object FormConfig: TFormConfig Top = 8 Width = 633 Height = 505 - ActivePage = TabSheetCDM + ActivePage = TabSheetSig Font.Charset = DEFAULT_CHARSET Font.Color = clBlack Font.Height = -11 @@ -3128,7 +3128,7 @@ object FormConfig: TFormConfig Width = 129 Height = 21 Style = csDropDownList - ItemHeight = 0 + ItemHeight = 13 TabOrder = 1 OnChange = ComboBoxDecChange end diff --git a/UnitConfig.pas b/UnitConfig.pas index f4f6b02..f4a30f6 100644 --- a/UnitConfig.pas +++ b/UnitConfig.pas @@ -840,25 +840,37 @@ begin end; end; - // tjd 2/4 états ou tjs + // tjd 2/4 états ou tjs if (tjdC or tjsC) then begin s:=s+'D('+intToSTR(aiguillage[index].Adroit); - c:=aiguillage[index].AdroitB;if c<>'Z' then s:=s+c; - s:=s+','+intToSTR(aiguillage[index].DDroit)+aiguillage[index].DDroitB+'),'; + + c:=aiguillage[index].AdroitB;if (c<>'Z') and (c<>#0) then s:=s+c; + s:=s+','+intToSTR(aiguillage[index].DDroit); + + c:=aiguillage[index].DDroitB;if (c<>'Z') and (c<>#0) then s:=s+c; + s:=s+'),'; s:=s+'S('+intToSTR(aiguillage[index].Adevie); - c:=aiguillage[index].AdevieB;if c<>'Z' then s:=s+c; - s:=s+','+intToSTR(aiguillage[index].DDevie)+aiguillage[index].DDevieB+')'; + + c:=aiguillage[index].AdevieB;if (c<>'Z') and (c<>#0) then s:=s+c; + s:=s+','+intToSTR(aiguillage[index].DDevie); + + c:=aiguillage[index].DDevieB;if (c<>'Z') and (c<>#0) then s:=s+c; + s:=s+')'; end; if croi then - begin + begin s:=s+'D('+intToSTR(aiguillage[index].Adroit); - c:=aiguillage[index].AdroitB;if c<>'Z' then s:=s+c; - s:=s+','+intToSTR(aiguillage[index].DDroit)+aiguillage[index].DDroitB+'),'; + c:=aiguillage[index].AdroitB;if (c<>'Z') and (c<>#0) then s:=s+c; + s:=s+','+intToSTR(aiguillage[index].DDroit); + c:=aiguillage[index].DDroitB;if (c<>'Z') and (c<>#0) then s:=s+c; + s:=s+'),'; s:=s+'S('+intToSTR(aiguillage[index].Adevie); - c:=aiguillage[index].AdevieB;if c<>'Z' then s:=s+c; - s:=s+','+intToSTR(aiguillage[index].DDevie)+aiguillage[index].DDevieB+')'; + c:=aiguillage[index].AdevieB;if (c<>'Z') and (c<>#0) then s:=s+c; + s:=s+','+intToSTR(aiguillage[index].DDevie); + c:=aiguillage[index].DDevieB;if (c<>'Z') and (c<>#0) then s:=s+c; + s:=s+')'; end; if tjsC then @@ -874,20 +886,20 @@ begin if aiguillage[index].vitesse=60 then s:=s+',V60'; if aiguillage[index].inversionCDM=1 then s:=s+',I1' else s:=s+',I0'; end; - + // valeur d'initialisation if not(croi) then begin s:=s+',INIT('; s:=s+IntToSTR(aiguillage[index].posInit)+','; - s:=s+IntToSTR(aiguillage[index].temps)+')'; + s:=s+IntToSTR(aiguillage[index].temps)+')'; end; - + if tjdC then begin if aiguillage[index].EtatTJD=2 then s:=s+',E2' else s:=s+',E4'; end; - + encode_aig:=s; end; diff --git a/UnitConfigCellTCO.dcu b/UnitConfigCellTCO.dcu deleted file mode 100644 index ec52de5..0000000 Binary files a/UnitConfigCellTCO.dcu and /dev/null differ diff --git a/UnitConfigTCO.dcu b/UnitConfigTCO.dcu deleted file mode 100644 index 05cff3e..0000000 Binary files a/UnitConfigTCO.dcu and /dev/null differ diff --git a/UnitDebug.dcu b/UnitDebug.dcu deleted file mode 100644 index 09d8e94..0000000 Binary files a/UnitDebug.dcu and /dev/null differ diff --git a/UnitDebug.dfm b/UnitDebug.dfm index 7155b9d..128dec1 100644 --- a/UnitDebug.dfm +++ b/UnitDebug.dfm @@ -1,6 +1,6 @@ object FormDebug: TFormDebug - Left = 306 - Top = 21 + Left = 209 + Top = 192 Width = 864 Height = 788 VertScrollBar.Increment = 67 @@ -482,6 +482,22 @@ object FormDebug: TFormDebug TabOrder = 10 OnClick = CheckDetSIgClick end + object CheckImporteCDM: TCheckBox + Left = 256 + Top = 96 + Width = 129 + Height = 17 + Alignment = taLeftJustify + Caption = 'Importation CDM Rail' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentFont = False + TabOrder = 11 + OnClick = CheckImporteCDMClick + end end object RichDebug: TRichEdit Left = 8 diff --git a/UnitDebug.pas b/UnitDebug.pas index 6ef5695..3fb39eb 100644 --- a/UnitDebug.pas +++ b/UnitDebug.pas @@ -63,6 +63,7 @@ type Button0: TButton; MemoEvtDet: TRichEdit; CheckDetSIg: TCheckBox; + CheckImporteCDM: TCheckBox; procedure FormCreate(Sender: TObject); procedure ButtonEcrLogClick(Sender: TObject); procedure EditNivDebugKeyPress(Sender: TObject; var Key: Char); @@ -101,6 +102,7 @@ type procedure FormActivate(Sender: TObject); procedure MemoEvtDetChange(Sender: TObject); procedure CheckDetSIgClick(Sender: TObject); + procedure CheckImporteCDMClick(Sender: TObject); private { Déclarations privées } public @@ -110,7 +112,7 @@ type var FormDebug: TFormDebug; NivDebug,signalDebug,compt_erreur,positionErreur,LigneErreur : integer; - AffSignal,AffAffect,initform,AffFD,debug_dec_sig,debugTCO,DebugAffiche,AFfDetSIg : boolean; + AffSignal,AffAffect,initform,AffFD,debug_dec_sig,debugTCO,DebugAffiche,AFfDetSIg,debugAnalyse : boolean; N_event_det : integer; // index du dernier évènement (de 1 à 20) N_Event_tick : integer ; // dernier index @@ -625,5 +627,9 @@ begin AFfDetSIg:=checkDetSig.checked; end; +procedure TFormDebug.CheckImporteCDMClick(Sender: TObject); begin + debugAnalyse:=checkImporteCDM.checked; +end; + end. diff --git a/UnitPareFeu.dcu b/UnitPareFeu.dcu deleted file mode 100644 index 00a84f3..0000000 Binary files a/UnitPareFeu.dcu and /dev/null differ diff --git a/UnitPilote.dcu b/UnitPilote.dcu deleted file mode 100644 index 81ac3d5..0000000 Binary files a/UnitPilote.dcu and /dev/null differ diff --git a/UnitPrinc.dcu b/UnitPrinc.dcu deleted file mode 100644 index 663d36f..0000000 Binary files a/UnitPrinc.dcu and /dev/null differ diff --git a/UnitPrinc.dfm b/UnitPrinc.dfm index 011b07d..fa7d616 100644 --- a/UnitPrinc.dfm +++ b/UnitPrinc.dfm @@ -1,8 +1,8 @@ object FormPrinc: TFormPrinc - Left = 66 - Top = 209 - Width = 1213 - Height = 670 + Left = 68 + Top = 194 + Width = 1227 + Height = 671 Caption = 'Signaux complexes' Color = clBtnFace Font.Charset = DEFAULT_CHARSET @@ -17,8 +17,8 @@ object FormPrinc: TFormPrinc OnClose = FormClose OnCreate = FormCreate DesignSize = ( - 1197 - 611) + 1211 + 612) PixelsPerInch = 96 TextHeight = 13 object LabelTitre: TLabel @@ -35,7 +35,7 @@ object FormPrinc: TFormPrinc ParentFont = False end object Image9feux: TImage - Left = 384 + Left = 416 Top = 0 Width = 57 Height = 105 @@ -815,7 +815,7 @@ object FormPrinc: TFormPrinc Visible = False end object Image3Dir: TImage - Left = 968 + Left = 928 Top = 168 Width = 49 Height = 25 @@ -981,8 +981,8 @@ object FormPrinc: TFormPrinc Visible = False end object Image5Dir: TImage - Left = 1096 - Top = 120 + Left = 960 + Top = 0 Width = 65 Height = 25 Picture.Data = { @@ -1187,7 +1187,7 @@ object FormPrinc: TFormPrinc Visible = False end object LabelEtat: TLabel - Left = 440 + Left = 454 Top = 8 Width = 152 Height = 18 @@ -1203,13 +1203,13 @@ object FormPrinc: TFormPrinc object SplitterH: TSplitter Left = 0 Top = 0 - Height = 589 + Height = 590 end object ScrollBox1: TScrollBox - Left = 632 + Left = 646 Top = 200 Width = 546 - Height = 391 + Height = 392 HorzScrollBar.Increment = 48 HorzScrollBar.Tracking = True VertScrollBar.Smooth = True @@ -1220,7 +1220,7 @@ object FormPrinc: TFormPrinc TabOrder = 0 end object GroupBox1: TGroupBox - Left = 632 + Left = 646 Top = 5 Width = 266 Height = 52 @@ -1268,8 +1268,8 @@ object FormPrinc: TFormPrinc end object StatusBar1: TStatusBar Left = 0 - Top = 589 - Width = 1197 + Top = 590 + Width = 1211 Height = 22 Panels = <> SimplePanel = True @@ -1285,22 +1285,22 @@ object FormPrinc: TFormPrinc 00020000802500000000080000000000000000003F00000011000000} end object Panel1: TPanel - Left = 904 - Top = 13 + Left = 918 + Top = 5 Width = 282 - Height = 108 + Height = 148 Anchors = [akTop, akRight] TabOrder = 4 object Label1: TLabel - Left = 56 - Top = 88 + Left = 64 + Top = 128 Width = 89 Height = 13 Caption = 'Nombre de trains : ' end object LabelNbTrains: TLabel Left = 240 - Top = 84 + Top = 124 Width = 9 Height = 19 Caption = '0' @@ -1376,10 +1376,30 @@ object FormPrinc: TFormPrinc WordWrap = True OnClick = BoutonRazTrainsClick end + object ButtonAffAnalyseCDM: TButton + Left = 184 + Top = 88 + Width = 89 + Height = 33 + Caption = 'Affiche fen'#234'tre analyse CDM' + TabOrder = 6 + Visible = False + WordWrap = True + OnClick = ButtonAffAnalyseCDMClick + end + object Button2: TButton + Left = 48 + Top = 96 + Width = 75 + Height = 25 + Caption = 'Button2' + TabOrder = 7 + OnClick = Button2Click + end end object StaticText: TStaticText Left = 16 - Top = 567 + Top = 568 Width = 14 Height = 17 Anchors = [akLeft, akBottom] @@ -1387,7 +1407,7 @@ object FormPrinc: TFormPrinc TabOrder = 5 end object GroupBox2: TGroupBox - Left = 633 + Left = 647 Top = 64 Width = 265 Height = 105 @@ -1449,7 +1469,7 @@ object FormPrinc: TFormPrinc end end object GroupBox3: TGroupBox - Left = 632 + Left = 646 Top = 64 Width = 265 Height = 129 @@ -1685,8 +1705,8 @@ object FormPrinc: TFormPrinc end end object ButtonEnv: TButton - Left = 1064 - Top = 144 + Left = 1078 + Top = 160 Width = 113 Height = 33 Anchors = [akTop, akRight] @@ -1696,8 +1716,8 @@ object FormPrinc: TFormPrinc OnClick = ButtonEnvClick end object EditEnvoi: TEdit - Left = 936 - Top = 152 + Left = 950 + Top = 168 Width = 121 Height = 21 Anchors = [akTop, akRight] @@ -1705,7 +1725,7 @@ object FormPrinc: TFormPrinc Text = '<1>' end object Button1: TButton - Left = 360 + Left = 494 Top = 0 Width = 75 Height = 25 @@ -1914,6 +1934,14 @@ object FormPrinc: TFormPrinc object N1: TMenuItem Caption = '-' end + object Analyser1: TMenuItem + Caption = 'Importer le r'#233'seau CDM Rail' + Hint = 'Importer le r'#233'seau CDM rail (aiguillages)' + OnClick = Analyser1Click + end + object N9: TMenuItem + Caption = '-' + end object LireunfichierdeCV1: TMenuItem Caption = 'Lire un fichier de CV vers un accessoire' Hint = @@ -1953,7 +1981,7 @@ object FormPrinc: TFormPrinc OnDisconnect = ClientSocketCDMDisconnect OnRead = ClientSocketCDMRead OnError = ClientSocketCDMError - Left = 352 + Left = 344 end object OpenDialog: TOpenDialog Left = 944 @@ -1970,6 +1998,10 @@ object FormPrinc: TFormPrinc Caption = 'Copier' OnClick = Copier1Click end + object Coller1: TMenuItem + Caption = 'Coller' + OnClick = Coller1Click + end end object PopupMenuFeu: TPopupMenu OnPopup = PopupMenuFeuPopup diff --git a/UnitPrinc.pas b/UnitPrinc.pas index 36483f6..408412a 100644 --- a/UnitPrinc.pas +++ b/UnitPrinc.pas @@ -47,7 +47,7 @@ uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, OleCtrls, ExtCtrls, jpeg, ComCtrls, ShellAPI, TlHelp32, ImgList, ScktComp, StrUtils, Menus, ActnList, MSCommLib_TLB, MMSystem , registry, - Buttons; + Buttons, NB30 ; type TFormPrinc = class(TForm) @@ -164,6 +164,11 @@ type FenRich: TRichEdit; SplitterV: TSplitter; Vrifiernouvelleversion1: TMenuItem; + N9: TMenuItem; + Analyser1: TMenuItem; + Coller1: TMenuItem; + ButtonAffAnalyseCDM: TButton; + Button2: TButton; procedure FormCreate(Sender: TObject); procedure MSCommUSBLenzComm(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); @@ -243,6 +248,10 @@ type procedure SplitterVMoved(Sender: TObject); procedure PopupMenuFeuPopup(Sender: TObject); procedure Vrifiernouvelleversion1Click(Sender: TObject); + procedure Analyser1Click(Sender: TObject); + procedure Coller1Click(Sender: TObject); + procedure ButtonAffAnalyseCDMClick(Sender: TObject); + procedure Button2Click(Sender: TObject); private { Déclarations privées } procedure DoHint(Sender : Tobject); @@ -624,7 +633,7 @@ function testBit(n : word;position : integer) : boolean; implementation uses UnitDebug, UnitPilote, UnitSimule, UnitTCO, UnitConfig, - Unitplace, verif_version , UnitCDF; + Unitplace, verif_version , UnitCDF, UnitAnalyseSegCDM; { procedure menu_interface(MA : TMA); @@ -720,7 +729,7 @@ begin if aspect=8 then result:=9; // jaune if aspect=9 then result:=10; // jaune cli end; - if aspect=-1 then + if aspect=-1 then begin if combine=10 then result:=11; // ralen 30 if combine=11 then result:=12; // ralen 60 @@ -3694,7 +3703,7 @@ begin Dessine_feu_mx(Feux[i].Img.Canvas,0,0,1,1,adr,1); // allume les signaux du feu dans le TCO - if TCOouvert then + if TCOACtive then begin for y:=1 to NbreCellY do for x:=1 to NbreCellX do @@ -7437,7 +7446,7 @@ begin AfficheDebug(intToSTR(event_det_train[i].det[1].adresse),couleur); AfficheDebug(intToSTR(event_det_train[i].det[2].adresse),couleur); end; - if TCOouvert then + if TCOActive then begin zone_TCO(det2,det3,0); // désactivation // activation @@ -7636,7 +7645,7 @@ begin Affiche_evt(s,couleur); if dupliqueEvt or traceliste then AfficheDebug(s,clyellow); - if TCOouvert then + if TCOActive then begin // activation if ModeCouleurCanton=0 then zone_TCO(det3,AdrSuiv,1) @@ -7698,7 +7707,7 @@ begin if det_suiv<9990 then reserve_canton(det3,det_suiv,AdrTrainLoc); s:='route ok de '+intToSTR(det1)+' à '+IntToSTR(det3)+' pour train '+intToSTR(i); Affiche_Evt(s,clWhite); - if TCOouvert then + if TCOActive then begin // activation if ModeCouleurCanton=0 then zone_TCO(det1,det3,1) @@ -7883,7 +7892,7 @@ begin AfficheDebug(intToSTR(event_det_train[i].det[1].adresse),couleur); AfficheDebug(intToSTR(event_det_train[i].det[2].adresse),couleur); end; - if TCOouvert then + if TCOActive then begin zone_TCO(det2,det3,0); // désactivation // activation @@ -7998,7 +8007,7 @@ begin Affiche_evt(s,couleur); if traceListe then AfficheDebug(s,Couleur); if AffAigDet then AfficheDebug(s,couleur); - if TCOouvert then + if TCOActive then begin zone_TCO(det1,det2,0); // désactivation // activation @@ -8315,7 +8324,7 @@ begin Affiche_evt(s,couleur); if dupliqueEvt or traceliste then AfficheDebug(s,clyellow); - if TCOouvert then + if TCOActive then begin // activation if ModeCouleurCanton=0 then zone_TCO(det3,AdrSuiv,1) @@ -8377,7 +8386,7 @@ begin if det_suiv<9990 then reserve_canton(det3,det_suiv,AdrTrainLoc); s:='route ok de '+intToSTR(det1)+' à '+IntToSTR(det3)+' pour train '+intToSTR(i); Affiche_Evt(s,clWhite); - if TCOouvert then + if TCOActive then begin // activation if ModeCouleurCanton=0 then zone_TCO(det1,det3,1) @@ -8547,7 +8556,7 @@ begin AfficheDebug(intToSTR(event_det_train[i].det[1].adresse),couleur); AfficheDebug(intToSTR(event_det_train[i].det[2].adresse),couleur); end; - if TCOouvert then + if TCOActive then begin zone_TCO(det2,det3,0); // désactivation // activation @@ -8675,7 +8684,7 @@ begin Affiche_evt(s,couleur); if traceListe then AfficheDebug(s,Couleur); if AffAigDet then AfficheDebug(s,couleur); - if TCOouvert then + if TCOActive then begin zone_TCO(det1,det2,0); // désactivation // activation @@ -9315,7 +9324,7 @@ begin // attention à partir de cette section le code est susceptible de ne pas être exécuté?? // Mettre à jour le TCO - if TcoOuvert then + if TcoActive then begin formTCO.Maj_TCO(Adresse); end; @@ -9378,7 +9387,7 @@ begin event_det_tick[N_event_tick].etat:=pos; // Mettre à jour le TCO - if TCOouvert then formTCO.Maj_TCO(Adresse); + if TCOActive then formTCO.Maj_TCO(Adresse); // l'évaluation des routes est à faire selon conditions if faire_event and not(confignulle) then begin evalue;evalue;end; @@ -10617,8 +10626,8 @@ begin convert_VK:=s; end; -// Lance et connecte CDM rail. en sortie si CDM est lancé Lance_CDM=true, -function Lance_CDM : boolean; +// Lance et connecte CDM rail si avecsocket=true. en sortie si CDM est lancé Lance_CDM=true, +function Lance_CDM(avecSocket : boolean) : boolean; var i,retour : integer; repertoire,s : string; cdm_lanceLoc : boolean; @@ -10659,7 +10668,7 @@ begin exit; end; - if cdm_lanceLoc then + if AvecSocket and cdm_lanceLoc then begin Formprinc.caption:=af+' - '+lay; // On a lancé CDM, déconnecter l'USB @@ -10786,6 +10795,7 @@ begin detecteur[i].etat:=false; detecteur[i].train:=''; detecteur[i].adrTrain:=0; + detecteur[i].IndexTrain:=0; ancien_detecteur[i]:=false; end; for i:=1 to NbMemZone do @@ -10831,6 +10841,10 @@ begin Tablo_Pn[i].compteur:=0; end; + for i:=1 to NbreCellx do + for j:=1 to NbreCelly do tco[i,j].mode:=0; + if TCOActive then affiche_TCO; + { ralentit au démarrage for i:=1 to NbreFeux do begin @@ -10897,6 +10911,125 @@ begin init_aig_cours:=false; end; +// renvoyer date heure, MAC, version SC , verif_version, avec_roulage + +// ex 1 +function GetMACAdress: string; +var + NCB: PNCB; + Adapter: PAdapterStatus; + + URetCode: PChar; + RetCode: char; + I: integer; + Lenum: PlanaEnum; + _SystemID: string; + TMPSTR: string; +begin + Result := ''; + _SystemID := ''; + Getmem(NCB, SizeOf(TNCB)); + Fillchar(NCB^, SizeOf(TNCB), 0); + + Getmem(Lenum, SizeOf(TLanaEnum)); + Fillchar(Lenum^, SizeOf(TLanaEnum), 0); + + Getmem(Adapter, SizeOf(TAdapterStatus)); + Fillchar(Adapter^, SizeOf(TAdapterStatus), 0); + + Lenum.Length := chr(0); + NCB.ncb_command := chr(NCBENUM); + NCB.ncb_buffer := Pointer(Lenum); + NCB.ncb_length := SizeOf(Lenum); + RetCode := Netbios(NCB); + + i := 0; + repeat + Fillchar(NCB^, SizeOf(TNCB), 0); + Ncb.ncb_command := chr(NCBRESET); + Ncb.ncb_lana_num := lenum.lana[I]; + RetCode := Netbios(Ncb); + + Fillchar(NCB^, SizeOf(TNCB), 0); + Ncb.ncb_command := chr(NCBASTAT); + Ncb.ncb_lana_num := lenum.lana[I]; + // Must be 16 + Ncb.ncb_callname := '* '; + + Ncb.ncb_buffer := Pointer(Adapter); + + Ncb.ncb_length := SizeOf(TAdapterStatus); + RetCode := Netbios(Ncb); + //---- calc _systemId from mac-address[2-5] XOR mac-address[1]... + if (RetCode = chr(0)) or (RetCode = chr(6)) then + begin + _SystemId := IntToHex(Ord(Adapter.adapter_address[0]), 2) + '-' + + IntToHex(Ord(Adapter.adapter_address[1]), 2) + '-' + + IntToHex(Ord(Adapter.adapter_address[2]), 2) + '-' + + IntToHex(Ord(Adapter.adapter_address[3]), 2) + '-' + + IntToHex(Ord(Adapter.adapter_address[4]), 2) + '-' + + IntToHex(Ord(Adapter.adapter_address[5]), 2); + end; + Inc(i); + until (I >= Ord(Lenum.Length)) or (_SystemID <> '00-00-00-00-00-00'); + FreeMem(NCB); + FreeMem(Adapter); + FreeMem(Lenum); + GetMacAdress := _SystemID; +end; + +// ex2 +function GetAdapterInfo(Lana: Char): String; +var + Adapter: TAdapterStatus; + NCB: TNCB; +begin + FillChar(NCB, SizeOf(NCB), 0); + NCB.ncb_command := Char(NCBRESET); + NCB.ncb_lana_num := Lana; + if Netbios(@NCB) <> Char(NRC_GOODRET) then + begin + Result := 'mac not found'; + Exit; + end; + + FillChar(NCB, SizeOf(NCB), 0); + NCB.ncb_command := Char(NCBASTAT); + NCB.ncb_lana_num := Lana; + NCB.ncb_callname := '*'; + + FillChar(Adapter, SizeOf(Adapter), 0); + NCB.ncb_buffer := @Adapter; + NCB.ncb_length := SizeOf(Adapter); + if Netbios(@NCB) <> Char(NRC_GOODRET) then + begin + Result := 'mac not found'; + Exit; + end; + Result := + IntToHex(Byte(Adapter.adapter_address[0]), 2) + '-' + + IntToHex(Byte(Adapter.adapter_address[1]), 2) + '-' + + IntToHex(Byte(Adapter.adapter_address[2]), 2) + '-' + + IntToHex(Byte(Adapter.adapter_address[3]), 2) + '-' + + IntToHex(Byte(Adapter.adapter_address[4]), 2) + '-' + + IntToHex(Byte(Adapter.adapter_address[5]), 2); +end; + +function GetMACAddress: string; +var + AdapterList: TLanaEnum; + NCB: TNCB; +begin + FillChar(NCB, SizeOf(NCB), 0); + NCB.ncb_command := Char(NCBENUM); + NCB.ncb_buffer := @AdapterList; + NCB.ncb_length := SizeOf(AdapterList); + Netbios(@NCB); + if Byte(AdapterList.length) > 0 then + Result := GetAdapterInfo(AdapterList.lana[0]) + else + Result := 'mac not found'; +end; // démarrage principal du programme signaux_complexes procedure TFormPrinc.FormCreate(Sender: TObject); @@ -10963,6 +11096,7 @@ begin AvecInit:=true; // &&&& avec initialisation des aiguillages ou pas Diffusion:=AvecInit; // mode diffusion publique roulage1.visible:=false; + FenRich.MaxLength:=$7FFFFFF0; OsBits:=0; if IsWow64Process then @@ -11140,7 +11274,7 @@ begin repeat application.processmessages; inc(i); - until (TcoOuvert) or (i>20); + until (TcoCree) or (i>20); Application.processmessages; if avecTCO then FormTCO.show; // créer fiche dynamique (projet/fichier) end; @@ -11160,11 +11294,10 @@ begin // lancer CDM rail et le connecte si on le demande ; à faire après la création des feux et du tco procetape('Test CDM et son lancement'); - if LanceCDM then Lance_CDM; + 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; @@ -11250,6 +11383,17 @@ begin decode_chaine_retro_dcc(''); } procetape('Terminé !!'); Maj_feux(false); + + { With FenRich do + begin + ReadOnly:=false; + clear; + Affiche('',clYellow); + PasteFromClipboard; + SetFocus; + ReadOnly:=true; + end; } + //Affiche(GetMACAddress,clred); end; @@ -11377,7 +11521,7 @@ begin end; // signaux du TCO - if TCOouvert then // évite d'accéder à la variable FormTCO si elle est pas encore ouverte + if TCOActive then // évite d'accéder à la variable FormTCO si elle est pas encore ouverte begin // parcourir les feux du TCO for y:=1 to NbreCellY do @@ -13127,7 +13271,7 @@ end; procedure TFormPrinc.ButtonLanceCDMClick(Sender: TObject); begin - Lance_CDM; + Lance_CDM(true); end; procedure TFormPrinc.Affichefentredebug1Click(Sender: TObject); @@ -13534,7 +13678,7 @@ end; procedure TFormPrinc.LancerCDMrail1Click(Sender: TObject); begin - Lance_CDM ; + Lance_CDM(true) ; end; procedure TFormPrinc.TrackBarVitChange(Sender: TObject); @@ -13749,5 +13893,94 @@ begin else Affiche('Site CDM-Rail inateignable',clred); end; +procedure TFormPrinc.Analyser1Click(Sender: TObject); +var s1,s2 : string; + i : integer; +begin + s1:=lowercase(fenRich.Lines[0]); + if pos('module',s1)=0 then + begin + Affiche('Pas de module détecté',clyellow); + Affiche('Procédure: dans CDM RAIL ouvrez votre réseau ; Menu ... / TrackDrawing / Module Display',clLime); + Affiche('Cela ouvre une fenêtre DEBUG dans cdm',clLime); + Affiche('Dans cette fenêtre, faire Clic droit puis "sélectionner tout" et "copier"',clLime); + Affiche('Dans Signaux complexes, clic droit et "coller ; puis menu divers / Analyse des modules ',clLime); + + if lance_cdm(false) then + begin + sleep(400); + s2:='CDR'; + ProcessRunning(s2); // récupérer le handle de CDM + SetForegroundWindow(CDMhd); + Application.ProcessMessages; + sleep(300); + + KeybdInput(VK_MENU,0); // enfonce Alt + KeybdInput(vk_decimal,0); + KeybdInput(vk_decimal,KEYEVENTF_KEYUP); + KeybdInput(VK_MENU,KEYEVENTF_KEYUP); // relache ALT + + KeybdInput(VK_DOWN,0); + KeybdInput(VK_DOWN,KEYEVENTF_KEYUP); + KeybdInput(VK_RETURN,0); + KeybdInput(VK_RETURN,KEYEVENTF_KEYUP); + KeybdInput(VK_RETURN,0); // valide le menu "track drawing" + KeybdInput(VK_RETURN,KEYEVENTF_KEYUP); + + // envoie les touches + i:=SendInput(Length(KeyInputs),KeyInputs[0],SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); // la fenetre serveur démarré est affichée + Sleep(500); + Application.ProcessMessages; + + // clic droit valider le menu + KeybdInput(VK_RBUTTON,0); // VK_APPS = menu droit + KeybdInput(VK_RBUTTON,KEYEVENTF_KEYUP); + i:=SendInput(Length(KeyInputs),KeyInputs[0],SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); + Application.ProcessMessages; + end; + exit; + + end; + Analyse_seg; + +end; + +procedure TFormPrinc.Coller1Click(Sender: TObject); +begin + With FenRich do + begin + ReadOnly:=false; + clear; + Affiche('',clYellow); + PasteFromClipboard; + SetFocus; + ReadOnly:=true; + end; +end; + +procedure TFormPrinc.ButtonAffAnalyseCDMClick(Sender: TObject); +begin + formAnalyseCDM.Show; +end; + +procedure TFormPrinc.Button2Click(Sender: TObject); +var i : integer; +begin + i:=index_aig(26); + Affiche(intToSTR(aiguillage[i].ADroit)+aiguillage[i].AdroitB,clred); + Affiche(intToSTR(aiguillage[i].ADevie)+aiguillage[i].AdevieB,clred); + Affiche(intToSTR(aiguillage[i].DDroit)+aiguillage[i].DDroitB,clred); + Affiche(intToSTR(aiguillage[i].Ddevie)+aiguillage[i].DdevieB,clred); + + i:=index_aig(28); + Affiche(intToSTR(aiguillage[i].ADroit)+aiguillage[i].AdroitB,clorange); + Affiche(intToSTR(aiguillage[i].ADevie)+aiguillage[i].AdevieB,clorange); + Affiche(intToSTR(aiguillage[i].DDroit)+aiguillage[i].DDroitB,clorange); + Affiche(intToSTR(aiguillage[i].Ddevie)+aiguillage[i].DDevieB,clorange); + + + +end; + end. diff --git a/UnitSR.dcu b/UnitSR.dcu deleted file mode 100644 index 6a218d1..0000000 Binary files a/UnitSR.dcu and /dev/null differ diff --git a/UnitSimule.dcu b/UnitSimule.dcu deleted file mode 100644 index b2f8c8c..0000000 Binary files a/UnitSimule.dcu and /dev/null differ diff --git a/UnitTCO.dcu b/UnitTCO.dcu deleted file mode 100644 index 83c5ef2..0000000 Binary files a/UnitTCO.dcu and /dev/null differ diff --git a/UnitTCO.dfm b/UnitTCO.dfm index 49a161a..32f3124 100644 --- a/UnitTCO.dfm +++ b/UnitTCO.dfm @@ -1,6 +1,6 @@ object FormTCO: TFormTCO - Left = 82 - Top = 129 + Left = 155 + Top = 53 Width = 1142 Height = 678 VertScrollBar.Visible = False diff --git a/UnitTCO.pas b/UnitTCO.pas index 62be19d..21d8d3b 100644 --- a/UnitTCO.pas +++ b/UnitTCO.pas @@ -384,8 +384,8 @@ var FormTCO: TFormTCO; Forminit,sourisclic,SelectionAffichee,TamponAffecte,entoure,Diffusion,TCO_modifie, - clicTCO,piloteAig,BandeauMasque,eval_format,TCOouvert,sauve_tco,formConfCellTCOAff, - drag : boolean; + clicTCO,piloteAig,BandeauMasque,eval_format,sauve_tco,formConfCellTCOAff, + drag,TCOActive,TCOCree : boolean; HtImageTCO,LargImageTCO,XclicCell,YclicCell,XminiSel,YminiSel,XCoupe,Ycoupe,Temposouris, XmaxiSel,YmaxiSel,AncienXMiniSel,AncienXMaxiSel ,AncienYMiniSel,AncienYMaxiSel, @@ -3657,7 +3657,7 @@ begin oldbmp.width:=100; oldbmp.Height:=100; //controlStyle:=controlStyle+[csOpaque]; - + TCOCree:=true; end; @@ -4320,7 +4320,7 @@ begin ScrollBox.Height:=ClientHeight-Panel1.Height-30; end; end; - TCOouvert:=true; + TCOActive:=true; end; // evt qui se produit quand on clic droit dans l'image diff --git a/Unitplace.dcu b/Unitplace.dcu deleted file mode 100644 index 504d575..0000000 Binary files a/Unitplace.dcu and /dev/null differ diff --git a/verif_version.dcu b/verif_version.dcu deleted file mode 100644 index 8cc7f62..0000000 Binary files a/verif_version.dcu and /dev/null differ diff --git a/verif_version.pas b/verif_version.pas index 191a0db..40a9b6f 100644 --- a/verif_version.pas +++ b/verif_version.pas @@ -23,7 +23,7 @@ var Lance_verif : integer; verifVersion,notificationVersion : boolean; -Const Version='5.75'; // sert à la comparaison de la version publiée +Const Version='6.0'; // sert à la comparaison de la version publiée SousVersion=' '; // A B C ... en cas d'absence de sous version mettre un espace function GetCurrentProcessEnvVar(const VariableName: string): string; diff --git a/versions.txt b/versions.txt index ddbeef6..b290cf7 100644 --- a/versions.txt +++ b/versions.txt @@ -162,5 +162,6 @@ version 5.73 : Ajout d'un bouton d'autorisation pour le pare-feu windows. version 5.74 : Correction bug création nouveau TCO. Nouvel installeur-> Signaux complexes s'installe dans c:\programmes\signaux_complexes. avec un raccourci sur le bureau. -version : Gestion du décodeur de signaux Arcomora. - +version 6.0 : Gestion du décodeur de signaux Arcomora. + Importation des aiguillages depuis CDM Rail. + Nécessite la version >=23.04 de CDM rail.