diff --git a/Notice d'utilisation des signaux_complexes_GL_V9.77.pdf b/Notice d'utilisation des signaux_complexes_GL_V9.8.pdf similarity index 81% rename from Notice d'utilisation des signaux_complexes_GL_V9.77.pdf rename to Notice d'utilisation des signaux_complexes_GL_V9.8.pdf index b76ade0..749db87 100644 Binary files a/Notice d'utilisation des signaux_complexes_GL_V9.77.pdf and b/Notice d'utilisation des signaux_complexes_GL_V9.8.pdf differ diff --git a/Signaux_complexes_GL.exe b/Signaux_complexes_GL.exe deleted file mode 100644 index af4c35c..0000000 Binary files a/Signaux_complexes_GL.exe and /dev/null differ diff --git a/UnitConfig.dfm b/UnitConfig.dfm index e9e4b98..3b2b9e5 100644 --- a/UnitConfig.dfm +++ b/UnitConfig.dfm @@ -670,7 +670,7 @@ object FormConfig: TFormConfig Top = 8 Width = 633 Height = 505 - ActivePage = TabSheetPeriph + ActivePage = TabSheetBouton Font.Charset = DEFAULT_CHARSET Font.Color = clBlack Font.Height = -11 @@ -684,8 +684,8 @@ object FormConfig: TFormConfig object Label36: TLabel Left = 24 Top = 458 - Width = 369 - Height = 13 + Width = 325 + Height = 26 Caption = 'Param'#232'tres de connexion et d'#39#233'change avec CDM rail et param'#232'tres' + ' g'#233'n'#233'raux' @@ -1067,7 +1067,7 @@ object FormConfig: TFormConfig Hint = 'Utilis'#233' avec la fenetre CDM de signaux complexes pour afficher l' + 'es trains' - Caption = 'Position trains' + Caption = 'Position et vitesses trains' ParentShowHint = False ShowHint = True TabOrder = 3 @@ -1222,8 +1222,8 @@ object FormConfig: TFormConfig object Label9: TLabel Left = 16 Top = 456 - Width = 294 - Height = 13 + Width = 249 + Height = 26 Caption = 'Ces param'#232'tres sont utilis'#233's en fonctionnement sans CDM Rail' WordWrap = True end @@ -1244,7 +1244,7 @@ object FormConfig: TFormConfig object Label4: TLabel Left = 16 Top = 45 - Width = 138 + Width = 135 Height = 26 Caption = '2. Temporisation d'#39'envoi des octets de la trame (ms)' WordWrap = True @@ -1252,7 +1252,7 @@ object FormConfig: TFormConfig object Label5: TLabel Left = 16 Top = 75 - Width = 151 + Width = 148 Height = 26 Caption = '3. Temporisation d'#39'attente de la r'#233'ponse de l'#39'interface (x 50 ms' + @@ -1534,7 +1534,7 @@ object FormConfig: TFormConfig object LabelCrois: TLabel Left = 96 Top = 312 - Width = 187 + Width = 178 Height = 26 Caption = 'Les croisements re'#231'oivent une adresse m'#234'me s'#39'ils ne sont pas pil' + @@ -2077,8 +2077,8 @@ object FormConfig: TFormConfig object Label34: TLabel Left = 472 Top = 200 - Width = 136 - Height = 26 + Width = 115 + Height = 39 Caption = 'Tapez CTRL-Z pour annuler une modification r'#233'cente' WordWrap = True end @@ -2274,8 +2274,8 @@ object FormConfig: TFormConfig object Label17: TLabel Left = 8 Top = 326 - Width = 131 - Height = 39 + Width = 115 + Height = 52 Hint = 'Permet d'#39'afficher un carr'#233' si les aiguillages sont dans les posi' + 'tions d'#233'crites ci dessous' @@ -2369,7 +2369,7 @@ object FormConfig: TFormConfig object Label69: TLabel Left = 152 Top = 326 - Width = 122 + Width = 107 Height = 39 Hint = 'Permet d'#39'afficher un feu blanc si les aiguillages sont dans les ' + @@ -2800,9 +2800,9 @@ object FormConfig: TFormConfig ParentFont = False end object LabelNa: TLabel - Left = 19 + Left = 36 Top = 304 - Width = 126 + Width = 109 Height = 39 Alignment = taRightJustify Caption = 'Nombre d'#39'adresses occup'#233'es par le signal sur le d'#233'codeur:' @@ -3187,7 +3187,7 @@ object FormConfig: TFormConfig Left = 240 Top = 19 Width = 33 - Height = 22 + Height = 21 MaxValue = 2 MinValue = 0 TabOrder = 2 @@ -3348,7 +3348,7 @@ object FormConfig: TFormConfig object Label31: TLabel Left = 352 Top = 296 - Width = 229 + Width = 203 Height = 26 Caption = 'Les actionneurs doivent '#234'tre compris entre deux d'#233'tecteurs' WordWrap = True @@ -4338,8 +4338,8 @@ object FormConfig: TFormConfig object Label45: TLabel Left = 50 Top = 40 - Width = 192 - Height = 26 + Width = 160 + Height = 39 Alignment = taCenter Caption = 'Arr'#234't temporis'#233' du train sur routes sur d'#233'tecteurs : (mode auton' + @@ -4376,8 +4376,8 @@ object FormConfig: TFormConfig object LabelEt: TLabel Left = 16 Top = 24 - Width = 213 - Height = 26 + Width = 201 + Height = 39 Caption = 'Les 3 coefficients de vitesse sont issus de la proc'#233'dure d'#39#233'talo' + 'nnage de la mesure du train' @@ -4641,8 +4641,8 @@ object FormConfig: TFormConfig end object Label23: TLabel Left = 8 - Top = 36 - Width = 534 + Top = 28 + Width = 571 Height = 26 Caption = 'Les p'#233'riph'#233'riques sont utilis'#233's pour '#234'tre activ'#233's par une action' + @@ -4870,9 +4870,302 @@ object FormConfig: TFormConfig OnClick = BoutonComClick end end + object TabSheetBouton: TTabSheet + Caption = 'Boutons USB' + ImageIndex = 10 + object GroupBoxB: TGroupBox + Left = 8 + Top = 8 + Width = 593 + Height = 441 + Caption = 'Boutons rotatifs / poussoirs USB' + TabOrder = 0 + object Shape1: TShape + Left = 72 + Top = 80 + Width = 193 + Height = 201 + Brush.Color = clOlive + end + object ShapeBR: TShape + Left = 120 + Top = 112 + Width = 97 + Height = 89 + Hint = 'Bouton rotatif et clic' + Brush.Color = clGray + ParentShowHint = False + Shape = stCircle + ShowHint = True + OnMouseDown = ShapeBRMouseDown + end + object ShapeB1: TShape + Left = 80 + Top = 224 + Width = 33 + Height = 33 + Hint = 'Clic bouton 1' + Brush.Color = clGray + ParentShowHint = False + Shape = stCircle + ShowHint = True + OnMouseDown = ShapeB1MouseDown + end + object ShapeB2: TShape + Left = 128 + Top = 224 + Width = 33 + Height = 33 + Hint = 'Clic bouton 2' + Brush.Color = clGray + ParentShowHint = False + Shape = stCircle + ShowHint = True + OnMouseDown = ShapeB2MouseDown + end + object ShapeB3: TShape + Left = 176 + Top = 224 + Width = 33 + Height = 33 + Hint = 'Clic bouton 3' + Brush.Color = clGray + ParentShowHint = False + Shape = stCircle + ShowHint = True + OnMouseDown = ShapeB3MouseDown + end + object ShapeB4: TShape + Left = 224 + Top = 224 + Width = 33 + Height = 33 + Hint = 'Clic bouton 4' + Brush.Color = clGray + ParentShowHint = False + Shape = stCircle + ShowHint = True + OnMouseDown = ShapeB4MouseDown + end + object Label66: TLabel + Left = 72 + Top = 336 + Width = 122 + Height = 16 + Caption = 'Code de touche : ' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -13 + Font.Name = 'MS Sans Serif' + Font.Style = [fsBold] + ParentFont = False + end + object LabelCode: TLabel + Left = 200 + Top = 336 + Width = 5 + Height = 16 + Caption = '.' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -13 + Font.Name = 'MS Sans Serif' + Font.Style = [fsBold] + ParentFont = False + end + object Label70: TLabel + Left = 16 + Top = 32 + Width = 263 + Height = 13 + Caption = 'D'#233'finition des boutons des blocs claviers USB' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [fsBold] + ParentFont = False + end + object Label72: TLabel + Left = 27 + Top = 392 + Width = 3 + Height = 13 + Caption = '-' + end + object Label74: TLabel + Left = 312 + Top = 240 + Width = 81 + Height = 13 + Caption = 'Affecter au train :' + end + object LabelId: TLabel + Left = 80 + Top = 88 + Width = 16 + Height = 34 + Caption = '1' + Color = clOlive + Font.Charset = ANSI_CHARSET + Font.Color = clBlack + Font.Height = -29 + Font.Name = 'Arial' + Font.Style = [fsBold] + ParentColor = False + ParentFont = False + end + object LabeledEditCT: TLabeledEdit + Left = 480 + Top = 80 + Width = 40 + Height = 21 + Hint = 'Code ascii envoy'#233' par le bouton' + EditLabel.Width = 76 + EditLabel.Height = 13 + EditLabel.Caption = 'Code de touche' + EditLabel.Layout = tlBottom + LabelPosition = lpLeft + LabelSpacing = 50 + ParentShowHint = False + ShowHint = True + TabOrder = 0 + OnChange = LabeledEditCTChange + end + object LabeledEditRm: TLabeledEdit + Left = 480 + Top = 128 + Width = 40 + Height = 21 + Hint = 'Code ascii envoy'#233' par la rotation anti horaire (-)' + EditLabel.Width = 99 + EditLabel.Height = 13 + EditLabel.Caption = 'Code de rotation en -' + EditLabel.Layout = tlBottom + LabelPosition = lpLeft + LabelSpacing = 50 + ParentShowHint = False + ShowHint = True + TabOrder = 1 + OnChange = LabeledEditRmChange + end + object LabeledEditRp: TLabeledEdit + Left = 480 + Top = 152 + Width = 40 + Height = 21 + Hint = 'Code ascii envoy'#233' par la rotation horaire (+)' + EditLabel.Width = 102 + EditLabel.Height = 13 + EditLabel.Caption = 'Code de rotation en +' + EditLabel.Layout = tlBottom + LabelPosition = lpLeft + LabelSpacing = 50 + ParentShowHint = False + ShowHint = True + TabOrder = 2 + OnChange = LabeledEditRpChange + end + object LabeledEditClic: TLabeledEdit + Left = 480 + Top = 176 + Width = 40 + Height = 21 + Hint = 'Code ascii envoy'#233' par le clic bouton' + EditLabel.Width = 59 + EditLabel.Height = 13 + EditLabel.Caption = 'Code de clic' + EditLabel.Layout = tlBottom + LabelPosition = lpLeft + LabelSpacing = 50 + ParentShowHint = False + ShowHint = True + TabOrder = 3 + OnChange = LabeledEditClicChange + end + object LabeledEditNUM: TLabeledEdit + Left = 480 + Top = 40 + Width = 25 + Height = 21 + Hint = 'Num'#233'ro de contr'#244'leur clavier USB (1 '#224' 10)' + EditLabel.Width = 134 + EditLabel.Height = 13 + EditLabel.Caption = 'Num'#233'ro de bloc clavier USB' + EditLabel.Layout = tlBottom + LabelPosition = lpLeft + LabelSpacing = 30 + ParentShowHint = False + ShowHint = True + TabOrder = 4 + OnChange = LabeledEditNUMChange + end + object LabeledEditF: TLabeledEdit + Left = 480 + Top = 104 + Width = 40 + Height = 21 + Hint = 'Fonction F associ'#233'e au bouton' + EditLabel.Width = 100 + EditLabel.Height = 13 + EditLabel.Caption = 'Fonction F '#224' envoyer' + EditLabel.Layout = tlBottom + LabelPosition = lpLeft + LabelSpacing = 50 + ParentShowHint = False + ShowHint = True + TabOrder = 5 + OnChange = LabeledEditFChange + end + object LabeledEditIncr: TLabeledEdit + Left = 480 + Top = 200 + Width = 40 + Height = 21 + Hint = 'Valeur de l'#39'incr'#233'ment sur une rotation' + EditLabel.Width = 105 + EditLabel.Height = 13 + EditLabel.Caption = 'Incr'#233'ment '#224' la rotation' + EditLabel.Layout = tlBottom + LabelPosition = lpLeft + LabelSpacing = 50 + ParentShowHint = False + ShowHint = True + TabOrder = 6 + OnChange = LabeledEditIncrChange + end + object ComboBoxUSBTr: TComboBox + Left = 416 + Top = 240 + Width = 153 + Height = 21 + Style = csDropDownList + ItemHeight = 13 + TabOrder = 7 + OnChange = ComboBoxUSBTrChange + end + object LabeledEditFn: TLabeledEdit + Left = 536 + Top = 104 + Width = 16 + Height = 21 + Hint = '0 ou 1' + EditLabel.Width = 6 + EditLabel.Height = 13 + EditLabel.Caption = #224 + EditLabel.Layout = tlBottom + LabelPosition = lpLeft + LabelSpacing = 5 + ParentShowHint = False + ShowHint = True + TabOrder = 8 + OnChange = LabeledEditFnChange + end + end + end object TabAvance: TTabSheet Caption = 'Avanc'#233 - ImageIndex = 10 + ImageIndex = 11 object Label50: TLabel Left = 8 Top = 8 diff --git a/UnitConfig.pas b/UnitConfig.pas index 9d84ffa..0e7844e 100644 --- a/UnitConfig.pas +++ b/UnitConfig.pas @@ -444,6 +444,29 @@ type ButtonSupPN: TButton; Label58: TLabel; ButtonRepriseDCC: TButton; + TabSheetBouton: TTabSheet; + GroupBoxB: TGroupBox; + Shape1: TShape; + ShapeBR: TShape; + ShapeB1: TShape; + ShapeB2: TShape; + ShapeB3: TShape; + ShapeB4: TShape; + LabeledEditCT: TLabeledEdit; + LabeledEditRm: TLabeledEdit; + LabeledEditRp: TLabeledEdit; + LabeledEditClic: TLabeledEdit; + Label66: TLabel; + LabelCode: TLabel; + LabeledEditNUM: TLabeledEdit; + Label70: TLabel; + Label72: TLabel; + LabeledEditF: TLabeledEdit; + LabeledEditIncr: TLabeledEdit; + ComboBoxUSBTr: TComboBox; + Label74: TLabel; + LabelId: TLabel; + LabeledEditFn: TLabeledEdit; procedure ButtonAppliquerEtFermerClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ListBoxAigMouseDown(Sender: TObject; Button: TMouseButton; @@ -700,6 +723,25 @@ type procedure RadioGroupClClick(Sender: TObject); procedure ButtonlCV3Click(Sender: TObject); procedure ButtonRepriseDCCClick(Sender: TObject); + procedure ShapeBRMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure ShapeB1MouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure ShapeB2MouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure ShapeB3MouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure ShapeB4MouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure LabeledEditCTChange(Sender: TObject); + procedure LabeledEditRmChange(Sender: TObject); + procedure LabeledEditRpChange(Sender: TObject); + procedure LabeledEditClicChange(Sender: TObject); + procedure LabeledEditNUMChange(Sender: TObject); + procedure LabeledEditFChange(Sender: TObject); + procedure LabeledEditIncrChange(Sender: TObject); + procedure ComboBoxUSBTrChange(Sender: TObject); + procedure LabeledEditFnChange(Sender: TObject); private { Déclarations privées } @@ -813,7 +855,7 @@ relanceHorl_init_ch='relanceHorl_init'; // sections de config section_aig_ch='[section_aig]'; section_sig_ch='[section_sig]'; -section_act_ch='[section_act]'; +section_act_ch='[section_act]'; // anciens actionneurs section_actV2_ch='[section_actions]'; section_PN_ch='[section_PN]'; section_branches_ch='[section_branches]'; @@ -827,6 +869,7 @@ section_horloge_ch='[section horloge]'; section_actionneurs_ch='[section_actionneurs]'; section_detecteurs_ch='[section_detecteurs]'; section_logique_ch='[section_logique]'; +section_blocs_USB_ch='[section_blocs_USB]'; rep_icones='icones'; @@ -862,16 +905,16 @@ var LigneCliqueePN,AncLigneCliqueePN,clicMemo,Nb_cantons_Sig,protocole,Port,PortServeur, ligneclicAig,AncLigneClicAig,ligneClicSig,AncligneClicSig,EnvAigDccpp,AdrBaseDetDccpp, ligneClicBr,AncligneClicBr,ligneClicAct,AncLigneClicAct,IndexSignalclic,NumTrameCDM, - Algo_localisation,Verif_AdrXpressNet,ligneclicTrain,AncligneclicTrain,AntiTimeoutEthLenz, + Algo_localisation,Verif_AdrXpressNet,ligneclicTrain,AntiTimeoutEthLenz,NumBlocUSB, ligneDCC,decCourant,AffMemoFenetre,ligneClicAccPeriph,AncligneClicAccPeriph,ligneCherche, - compt_Ligne,Ecran_SC,Max_Signal_Sens,nCantonsRes,ligneClicActionneur, + compt_Ligne,Ecran_SC,Max_Signal_Sens,nCantonsRes,ligneClicActionneur,BoutonBloc, TempoTC,Nbuttoirs,AncLigneClicActionneur,AncligneclicDet,ligneclicDet,foncCourante, - NbreFL,IdOperateur : integer; + NbreFL,IdOperateur,NbreBlocsUSB : integer; - ack_cdm,clicliste,config_modifie,clicproprietes,confasauver,trouve_MaxPort, + ack_cdm,clicliste,config_modifie,clicproprietesSig,clicproprietesTrains,confasauver,trouve_MaxPort, modif_branches,ConfigPrete,trouve_section_dccpp,trouve_section_trains,trouve_section_acccomusb, trouveAvecVerifIconesTCO,Affiche_avert,activ,trouve_section_dec_pers,Z21,AffAigND, - PilotageTrainsCDMNom,LanceHorl,AffSig,AffRes,avecAck,affLoc,changeCom, + PilotageTrainsCDMNom,LanceHorl,AffSig,AffRes,avecAck,affLoc,changeCom,tsbouton, clicTree : boolean; fichier : text; @@ -926,12 +969,14 @@ 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); +procedure Maj_icone_train(IImage : Timage;index :integer;coulfond : Tcolor); function evalue_fonction(NumFonc : integer;var formule : string) : boolean; procedure fabrique_treeview(k : integer); procedure compile_id_routes; procedure genere_informations_BD; function trouve_index_style : integer; +procedure ComboBoxFL_mizajour; +procedure clic_BRM; implementation @@ -964,7 +1009,7 @@ begin if Srvc_Aig then begin s:=s+'SRV=ATNT;';inc(i);end; // service changement aiguillage if Srvc_Act then begin s:=s+'SRV=AACT;';inc(i);end; // service actionneurs if Srvc_Det then begin s:=s+'SRV=ADET;';inc(i);end; // service détecteurs - if Srvc_Pos then begin s:=s+'SRV=TSXY;';inc(i);end; // service position des trains + if Srvc_Pos then begin s:=s+'SRV=TSXY;';inc(i);end; // service position et vitesses des trains if Srvc_Sig then begin s:=s+'SRV=ASIG;';inc(i);end; // service signaux if Srvc_tdcc then begin s:=s+'SRV=TDCC;';inc(i);end; // service info train (si chgt vitesse) @@ -1024,7 +1069,6 @@ 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 @@ -1317,7 +1361,7 @@ var s : string; begin // adresse adresse:=Signaux[i].adresse; - + if adresse=0 then begin Affiche('Adresse nulle signal',clRed); @@ -1361,7 +1405,7 @@ begin // 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); + if (decod=4) then s:=s+',L'+intToSTR(signaux[i].BinLin); // conditions supplémentaires pour le carré for nc:=1 to 6 do @@ -2045,7 +2089,7 @@ begin s:=s+FloatToSTRF(coeffV1,ffFixed,5,2,FormatSettings)+','+FloatToSTRF(coeffV2,ffFixed,5,2,FormatSettings)+','+FloatToSTRF(coeffV3,ffFixed,5,2,FormatSettings)+','; s:=s+intToSTR(CV3)+','+intToSTR(CV4)+','+intToSTR(crans); // arrêts sur cantons - for i:=1 to ncantons do + for i:=1 to NbDetArret do begin nc:=DetecteurArret[i].detecteur; if nc<>0 then @@ -2152,7 +2196,7 @@ begin // avec ou sans demande de la position des aiguillages en mode autonome if AvecDemandeAiguillages then s:='1' else s:='0'; writeln(fichierN,Init_dem_aig_ch+'='+s); - + // temporisation initialisation des aiguillages writeln(fichierN,Tempo_aig_ch+'=',IntToSTR(Tempo_aig)); @@ -2316,12 +2360,11 @@ begin end; if k=2 then begin - for j:=1 to 9 do + for j:=1 to 9 do begin s:=EtatSignBelge[j]+','+decodeur_pers[i].desc[j].Chcommande; writeln(fichierN,s); - - end; + end; for j:=10 to 19 do writeln(fichierN,' ,'); end; end; @@ -2474,7 +2517,7 @@ begin writeln(fichierN,section_logique_ch); for j:=1 to NbreFL do begin - writeln(fichierN,'/--- fonction '+intToSTR(j)); + writeln(fichierN,'/--- Fonction '+intToSTR(j)); writeln(FichierN,'"'+NomFonction[j]+'"'); // ajouter les guillemets pour éviter chaine vide n:=fonction[j,0].adresse; for i:=0 to n-1 do @@ -2492,6 +2535,26 @@ begin end; writeln(fichierN,'0'); + writeln(fichierN,'/------------'); + writeln(fichierN,section_blocs_USB_ch); + for j:=1 to NbreBlocsUSB do + begin + s:='B'+intToSTR(j)+','+blocUSB[j].afftrain+',BR'+intToSTR(blocUSB[j].rotatifM)+','+intToSTR(blocUSB[j].rotatifP)+','+intToSTR(blocUSB[j].clic)+ + ','+intToSTR(blocUSB[j].increment)+ + ',B'+intToSTR(blocUSB[j].Bp1)+','+IntToSTR(blocUSB[j].Fbp1)+','+IntToSTR(blocUSB[j].Fnp1)+ + ',B'+intToSTR(blocUSB[j].Bp2)+','+IntToSTR(blocUSB[j].Fbp2)+','+IntToSTR(blocUSB[j].Fnp2)+ + ',B'+intToSTR(blocUSB[j].Bp3)+','+IntToSTR(blocUSB[j].Fbp3)+','+IntToSTR(blocUSB[j].Fnp3)+ + ',B'+intToSTR(blocUSB[j].Bp4)+','+IntToSTR(blocUSB[j].Fbp4)+','+IntToSTR(blocUSB[j].Fnp4)+ + ',B'+intToSTR(blocUSB[j].Bp5)+','+IntToSTR(blocUSB[j].Fbp5)+','+IntToSTR(blocUSB[j].Fnp5)+ + ',B'+intToSTR(blocUSB[j].Bp6)+','+IntToSTR(blocUSB[j].Fbp6)+','+IntToSTR(blocUSB[j].Fnp6)+ + ',B'+intToSTR(blocUSB[j].Bp7)+','+IntToSTR(blocUSB[j].Fbp7)+','+IntToSTR(blocUSB[j].Fnp7)+ + ',B'+intToSTR(blocUSB[j].Bp8)+','+IntToSTR(blocUSB[j].Fbp8)+','+IntToSTR(blocUSB[j].Fnp8)+ + ',B'+intToSTR(blocUSB[j].Bp9)+','+IntToSTR(blocUSB[j].Fbp9)+','+IntToSTR(blocUSB[j].Fnp9)+ + ',B'+intToSTR(blocUSB[j].Bp10)+','+IntToSTR(blocUSB[j].Fbp10)+','+IntToSTR(blocUSB[j].Fnp10); + Writeln(fichierN,s); + end; + writeln(fichierN,'0'); + closefile(fichierN); end; @@ -2535,7 +2598,6 @@ begin temp:=adresse_detecteur[i]; detecteur[temp].index:=i; end; - end; procedure trier_actionneurs; @@ -2554,11 +2616,8 @@ begin end; end; end; - end; - - // trier les aiguillages par adresses croissantes // et complète les aiguillages triples (créée aiguillahe homologue) procedure trier_aig; @@ -2566,7 +2625,6 @@ var i,j,adr : integer; temp : TAiguillage; s : string; begin - // attribue les index i:=1; while (i10); + until (s='') or (j>NbDetArret); end; end; @@ -4780,6 +4833,118 @@ const LessThanValue=-1; until (s='0') or (s='') ; // fin des fonctions end; + procedure compile_blocsUSB; + var n : integer; + ss : string; + begin + n:=0; + repeat + lit_ligne; + if s<>'0' then + begin + s:=sOrigine; + delete(s,1,1); + val(s,i,erreur); // i=numéro de bloc usb de 1 à 10 + delete(s,1,erreur); + j:=pos(',',s); + ss:=copy(s,1,j-1); + blocUSB[i].AffTrain:=ss;delete(s,1,j); + + delete(s,1,2); // supprime BR + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].rotatifM:=j; + val(s,j,erreur);delete(s,1,erreur); // B1,Pas d'affectation,BR45,43,224,4,B38,1,1,B233,2,0,B34,3,0,B39,4,0,B5,0,0,B6,0,0,B7,0,0,B8,0,0,B9,0,0,B10,0,0 + blocUsb[i].rotatifP:=j; //107 + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].clic:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].increment:=j; + + delete(s,1,1); // supprime B + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Bp1:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fbp1:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fnp1:=j; + + delete(s,1,1); // supprime B + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Bp2:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fbp2:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fnp2:=j; + + delete(s,1,1); // supprime B + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Bp3:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fbp3:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fnp3:=j; + + delete(s,1,1); // supprime B + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Bp4:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fbp4:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fnp4:=j; + + delete(s,1,1); // supprime B + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Bp5:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fbp5:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fnp5:=j; + + delete(s,1,1); // supprime B + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Bp6:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fbp6:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fnp6:=j; + + delete(s,1,1); // supprime B + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Bp7:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fbp7:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fnp7:=j; + + delete(s,1,1); // supprime B + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Bp8:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fbp8:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fnp8:=j; + + delete(s,1,1); // supprime B + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Bp9:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fbp9:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fnp9:=j; + + delete(s,1,1); // supprime B + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Bp10:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fbp10:=j; + val(s,j,erreur);delete(s,1,erreur); + blocUsb[i].Fnp10:=j; + + inc(n); + end; + until (sOrigine='0') or (s='') or (n>=10); + end; + procedure compile_horloge; begin repeat @@ -5751,6 +5916,12 @@ const LessThanValue=-1; compile_fonctions; end; + sa:=uppercase(section_blocs_USB_ch); + if pos(sa,s)<>0 then + begin + compile_blocsUSB; + end; + inc(it); until (eof(fichier)); @@ -5841,7 +6012,7 @@ begin reset(fichier); except Affiche('Fichier '+NomConfig+' non trouvé : création d''un fichier vide par défaut',clred); - portcom:='COM3:57600,N,8,1,2'; + portcom:='COMX:57600,N,8,1,2'; adresseIPCDM:='127.0.0.1';portCDM:=9999; adresseIP:='192.168.1.23';portInterface:=5550; verifVersion:=true; @@ -5851,14 +6022,14 @@ begin Srvc_Aig:=true; Srvc_Act:=true; Srvc_Det:=true; - Srvc_Pos:=false; + Srvc_Pos:=true; Srvc_Sig:=false; Srvc_tdcc:=false; TimoutMaxInterface:=7; - AvecInitAiguillages:=true; + AvecInitAiguillages:=false; PilotageTrainsCDMNom:=true; - AvecDemandeInterfaceUSB:=true; - AvecDemandeInterfaceEth:=true; + AvecDemandeInterfaceUSB:=false; + AvecDemandeInterfaceEth:=false; AffSig:=true; AffRes:=true; AvecAck:=false; @@ -6764,6 +6935,117 @@ begin if trouve then result:=i-1 else result:=-1; end; +procedure clicListeTrains(index : integer); +var s : string; + i,t : integer; + r : single; +begin + if affevt then Affiche('clicListeTrains '+intToSTR(index),clyellow); + if index<1 then exit; + if Trains[index].nom_train='' then exit; + clicListe:=true; + with formconfig do + begin + i:=trains[index].routePref[0][0].adresse; + s:=''; + case i of + 0 : s:='Pas de route'; + 1 : s:='1 route'; + else s:=intToSTR(i)+' routes'; + end; + ButtonRdt.Caption:=s; + + editNomTrain.text:=Trains[index].nom_train; + editAdresseTrain.Text:=intToSTR(trains[index].adresse); + editVitesseMaxi.Text:=intToSTR(trains[index].vitmax); + editLongLoco.text:=IntToSTR(trains[index].longueur); + LabeledEditTempoD.Text:=intToSTR(trains[index].TempsDemarreSig); + editVitRalenti.Text:=IntToSTR(trains[index].Vitralenti); + editvitnom.text:=IntToSTR(trains[index].VitNominale); + CheckBoxSens.Checked:=trains[index].inverse; + s:=trains[index].NomIcone; + editIcone.Text:=s; + + // Efface l'icone de train + ImageTrain.Canvas.Rectangle(0,0,ImageTrain.Width,ImageTrain.Height); + + if s<>'' then + begin + Maj_icone_train(formconfig.ImageTrain,index,clWhite); + Maj_icone_train(Image_Train[index],index,clWhite); + end; + + // tableau des détecteurs d'arrêt + for i:=1 to NbDetArret do + begin + t:=trains[index].DetecteurArret[i].temps; + if t<>0 then + begin + s:=''; + if trains[index].DetecteurArret[i].TPrec<>det then s:='A'; + StringGridArr.Cells[1,i]:=s+intToSTR(trains[index].DetecteurArret[i].prec); + StringGridArr.Cells[2,i]:=intToSTR(trains[index].DetecteurArret[i].detecteur); + StringGridArr.Cells[3,i]:=intToSTR(t); + end + else + begin + StringGridArr.Cells[1,i]:=''; + StringGridArr.Cells[2,i]:=''; + StringGridArr.Cells[3,i]:=''; + end; + end; + + With LabeledEditV1 do + begin + EditLabel.Caption:='Coefficient vitesse 1 - Lente '+intToSTR(Trains[index].ConsV1)+' crans :'; + LabelSpacing:=20; + Text:=FloatToSTRF(Trains[index].coeffV1,ffFixed,5,2,FormatSettings); + end; + With LabeledEditV2 do + begin + EditLabel.Caption:='Coefficient vitesse 2 - Moyenne '+intToSTR(Trains[index].ConsV2)+' crans :'; + LabelSpacing:=20; + Text:=FloatToSTRF(Trains[index].coeffV2,ffFixed,5,2,FormatSettings); + end; + With LabeledEditV3 do + begin + EditLabel.Caption:='Coefficient vitesse 3 - Rapide '+intToSTR(Trains[index].ConsV3)+' crans :'; + LabelSpacing:=20; + Text:=FloatToSTRF(Trains[index].coeffV3,ffFixed,5,2,FormatSettings); + end; + + if Trains[index].coeffV1<>0 then + begin + r:=Trains[index].consV1/Trains[index].coeffV1; + LabelV1.Caption:='Vr1 (cm/s) = '+intToSTR(trains[index].consV1)+' (crans) / '+FloatToSTRF(Trains[index].coeffV1,ffFixed,5,2)+ + ' = '+FloatToSTRF(r,ffFixed,5,2)+' cm/s'; + end + else LabelV1.Caption:='Vr1'; + + if Trains[index].coeffV2<>0 then + begin + r:=Trains[index].consV2/Trains[index].coeffV2; + LabelV2.Caption:='Vr2 (cm/s) = '+intToSTR(trains[index].consV2)+' (crans) / '+FloatToSTRF(Trains[index].coeffV2,ffFixed,5,2)+ + ' = '+FloatToSTRF(r,ffFixed,5,2)+' cm/s'; + end + else LabelV2.Caption:='Vr2'; + + if Trains[index].coeffV3<>0 then + begin + r:=Trains[index].consV3/Trains[index].coeffV3; + LabelV3.Caption:='Vr3 (cm/s) = '+intToSTR(trains[index].consV3)+' (crans) / '+FloatToSTRF(Trains[index].coeffV3,ffFixed,5,2)+ + ' = '+FloatToSTRF(r,ffFixed,5,2)+' cm/s'; + end + else LabelV3.Caption:='Vr3'; + + LabeledEditCV3.Text:=intToSTR(Trains[index].CV3); + LabeledEditCV4.Text:=intToSTR(Trains[index].CV4); + LabeledEditCrans.Text:=intToSTR(Trains[index].crans); + end; + clicListe:=false; +end; + + procedure TFormConfig.FormCreate(Sender: TObject); var i,j,x,y,l,k,LongestLength,PixelLength : integer; cs,s,LongestString : string; @@ -7126,16 +7408,18 @@ begin s:=s+'\'+cs; if cs<>'' then begin - // lire le fichier icone - if fileExists(s) then - begin - trains[i].icone.Picture.LoadFromFile(s); - end - else Affiche('Le fichier icône train '+s+' n''a pas été trouvé',clred); - + // lire le fichier icone + if fileExists(s) then + begin + trains[i].icone.Picture.LoadFromFile(s); + end + else Affiche('Le fichier icône train '+s+' n''a pas été trouvé',clred); end; + cree_image_train(i); end; + affecte_trains_config; // affecte les trains aux cantons + with StringGridArr do begin Hint:='-'; @@ -7891,8 +8175,10 @@ begin SendMessage(ListBoxPN.Handle,LB_SETHORIZONTALEXTENT,PixelLength,0); champs_pn_act; - if clicproprietes then clicListeSignal(IndexSignalClic); - clicproprietes:=false; + if clicproprietesSig then clicListeSignal(IndexSignalClic); + clicproprietesSig:=false; + if clicproprietesTrains then clicListeTrains(ligneclicTrain+1); + clicproprietesTrains:=false; i:=1; RichCdeDCCpp.clear; @@ -7924,6 +8210,8 @@ begin end; end; end; + if ntrains<>0 then IdTrainClic:=1; + ButtonlCV3.hint:='Passe la centrale en mode programmation et'+#13+ 'lit le CV3 de la locomotive placée sur la voie de programmation'; ButtonlCV4.hint:='Passe la centrale en mode programmation et'+#13+ @@ -8017,6 +8305,18 @@ begin changeCom:=false; end; + // blocs usb + ComboBoxUSBTr.Items.Add('Pas d''affectation'); + LabeledEditNUM.Text:=intToSTR(NumBlocUSB); + for i:=1 to ntrains do + begin + ComboBoxUSBTr.Items.Add(trains[i].nom_train); + end; + i:=index_train_nom(BlocUSB[1].AffTrain); + ComboBoxUSBTr.ItemIndex:=i; + label72.caption:='La rotation de bouton changera la vitesse du train. L''appui sur le bouton stoppe le train.'+#13+ + 'Les évènements clavier sont interceptés par signaux complexes ce qui ne nécessite pas d''activer la fenêtre'; + PageControl.ActivePage:=Formconfig.TabSheetCDM; // force le premier onglet sur la page couleurs_config; formconfig.LabelInfo.Caption:=''; @@ -10467,7 +10767,7 @@ begin Signaux[i].SR[8].sortie0:=19; Signaux[i].SR[8].sortie1:=0; Signaux[i].Na:=4; - cree_image(i); + cree_image_signal(i); s:=encode_signal(i); // scroller à la fin et sélectionner @@ -10624,7 +10924,7 @@ begin Tablo_Index_Signal[Signaux[NbreSignaux].adresse]:=NbreSignaux; // index Signal_supprime.adresse:=0; // dévalider le signal sauvegardé Signal_supprime.aspect:=0; - cree_image(NbreSignaux); + cree_image_signal(NbreSignaux); config_modifie:=true; // réafficher le rechedit s:=encode_signal(NbreSignaux); @@ -13096,7 +13396,7 @@ begin {$IF CompilerVersion >= 28.0} change_style; {$IFEND} - + tsbouton:=false; if modif_branches then begin if MessageDlg('Les branches ont été modifiées mais non validées. Voulez fermer la fenêtre ?',mtConfirmation,[mbYes,mbNo],0)=mrNo then @@ -13171,6 +13471,7 @@ begin LabelInfo.caption:=''; if FormConfig.PageControl.ActivePage=FormConfig.TabSheetPN then label40.Visible:=true else label40.Visible:=false; + tsbouton:=FormConfig.PageControl.ActivePage=TabSheetBouton; end; @@ -13477,18 +13778,19 @@ begin end; // affiche l'icone du train index dans le canvas -// Icanvas: canvas de destination ; index: index du train -procedure Maj_icone_train(IImage : Timage;index :integer); +// Iimage: destination ; index: index du train +procedure Maj_icone_train(IImage : Timage;index :integer;coulfond : Tcolor); var h,l,HautDest,LargDest,y : integer; rd : single; begin if (index<1) or (index>Ntrains) then begin - Iimage.Picture:=nil; + //Iimage.Picture:=nil; exit; end else begin + //Affiche('Maj_icone_train '+intToSTR(index),clYellow); // source l:=Trains[index].Icone.width; h:=Trains[index].Icone.Height; @@ -13509,116 +13811,17 @@ begin y:=iImage.Height-HautDest; - Iimage.Canvas.Rectangle(0,0,Iimage.Width,Iimage.Height); + with Iimage.Canvas do + begin + brush.Color:=coulfond; + pen.Color:=clwhite; + Rectangle(0,0,Iimage.Width,Iimage.Height); + + end; TransparentBlt(Iimage.canvas.Handle,0,y,largDest,hautDest, Trains[index].Icone.canvas.Handle,0,0,l,h,clWhite); - end; - formconfig.ImageTrain.Repaint; -end; - -procedure clicListeTrains(index : integer); -var s : string; - i,t : integer; - r : single; -begin - if index<1 then exit; - if Trains[index].nom_train='' then exit; - with formconfig do - begin - i:=trains[index].routePref[0][0].adresse; - s:=''; - case i of - 0 : s:='Pas de route'; - 1 : s:='1 route'; - else s:=intToSTR(i)+' routes'; - end; - ButtonRdt.Caption:=s; - - editNomTrain.text:=Trains[index].nom_train; - editAdresseTrain.Text:=intToSTR(trains[index].adresse); - editVitesseMaxi.Text:=intToSTR(trains[index].vitmax); - editLongLoco.text:=IntToSTR(trains[index].longueur); - LabeledEditTempoD.Text:=intToSTR(trains[index].TempsDemarreSig); - editVitRalenti.Text:=IntToSTR(trains[index].Vitralenti); - editvitnom.text:=IntToSTR(trains[index].VitNominale); - CheckBoxSens.Checked:=trains[index].inverse; - s:=trains[index].NomIcone; - editIcone.Text:=s; - - // Efface l'icone de train - ImageTrain.Canvas.Rectangle(0,0,ImageTrain.Width,ImageTrain.Height); - - if s<>'' then Maj_icone_train(formconfig.ImageTrain,index); - - // tableau des détecteurs d'arrêt - for i:=1 to NbDetArret do - begin - t:=trains[index].DetecteurArret[i].temps; - if t<>0 then - begin - s:=''; - if trains[index].DetecteurArret[i].TPrec<>det then s:='A'; - StringGridArr.Cells[1,i]:=s+intToSTR(trains[index].DetecteurArret[i].prec); - StringGridArr.Cells[2,i]:=intToSTR(trains[index].DetecteurArret[i].detecteur); - StringGridArr.Cells[3,i]:=intToSTR(t); - end - else - begin - StringGridArr.Cells[1,i]:=''; - StringGridArr.Cells[2,i]:=''; - StringGridArr.Cells[3,i]:=''; - end; - end; - - With LabeledEditV1 do - begin - EditLabel.Caption:='Coefficient vitesse 1 - Lente '+intToSTR(Trains[index].ConsV1)+' crans :'; - LabelSpacing:=20; - Text:=FloatToSTRF(Trains[index].coeffV1,ffFixed,5,2,FormatSettings); - end; - With LabeledEditV2 do - begin - EditLabel.Caption:='Coefficient vitesse 2 - Moyenne '+intToSTR(Trains[index].ConsV2)+' crans :'; - LabelSpacing:=20; - Text:=FloatToSTRF(Trains[index].coeffV2,ffFixed,5,2,FormatSettings); - end; - With LabeledEditV3 do - begin - EditLabel.Caption:='Coefficient vitesse 3 - Rapide '+intToSTR(Trains[index].ConsV3)+' crans :'; - LabelSpacing:=20; - Text:=FloatToSTRF(Trains[index].coeffV3,ffFixed,5,2,FormatSettings); - end; - - if Trains[index].coeffV1<>0 then - begin - r:=Trains[index].consV1/Trains[index].coeffV1; - LabelV1.Caption:='Vr1 (cm/s) = '+intToSTR(trains[index].consV1)+' (crans) / '+FloatToSTRF(Trains[index].coeffV1,ffFixed,5,2)+ - ' = '+FloatToSTRF(r,ffFixed,5,2)+' cm/s'; - end - else LabelV1.Caption:='Vr1'; - - if Trains[index].coeffV2<>0 then - begin - r:=Trains[index].consV2/Trains[index].coeffV2; - LabelV2.Caption:='Vr2 (cm/s) = '+intToSTR(trains[index].consV2)+' (crans) / '+FloatToSTRF(Trains[index].coeffV2,ffFixed,5,2)+ - ' = '+FloatToSTRF(r,ffFixed,5,2)+' cm/s'; - end - else LabelV2.Caption:='Vr2'; - - if Trains[index].coeffV3<>0 then - begin - r:=Trains[index].consV3/Trains[index].coeffV3; - LabelV3.Caption:='Vr3 (cm/s) = '+intToSTR(trains[index].consV3)+' (crans) / '+FloatToSTRF(Trains[index].coeffV3,ffFixed,5,2)+ - ' = '+FloatToSTRF(r,ffFixed,5,2)+' cm/s'; - end - else LabelV3.Caption:='Vr3'; - - LabeledEditCV3.Text:=intToSTR(Trains[index].CV3); - LabeledEditCV4.Text:=intToSTR(Trains[index].CV4); - LabeledEditCrans.Text:=intToSTR(Trains[index].crans); - - end; + Iimage.Repaint; end; @@ -13629,7 +13832,6 @@ begin //affiche('RichEditTrainChange',clyellow); clicListe:=true; - AncligneclicTrain:=ligneclicTrain; ligneclicTrain:=ListBoxTrains.ItemIndex; //Affiche(intToSTR(lc),clyellow); @@ -13657,11 +13859,17 @@ begin trains[ligneclicTrain+1].Nom_train:=EditNomTrain.text; ListBoxTrains.items[ligneclicTrain]:=encode_train(ligneclicTrain+1); ListBoxTrains.selected[ligneclicTrain]:=true; + LabelTrain[ligneclicTrain+1].Caption:=EditNomTrain.text; i:=formprinc.ComboTrains.ItemIndex; if i<0 then exit; formprinc.ComboTrains.Items[ligneclicTrain]:=EditNomTrain.text; - if i=ligneclicTrain then formprinc.ComboTrains.Text:=EditNomTrain.text; + formConfig.ComboBoxUSBTr.Items[LigneClicTrain+1]:=EditNomTrain.text; + if LabelTrain[ligneclicTrain+1]<>nil then LabelTrain[ligneclicTrain+1].Caption:=EditNomTrain.text; + if i=ligneclicTrain then + begin + formprinc.ComboTrains.Text:=EditNomTrain.text; + end; end; procedure TFormConfig.EditAdresseTrainChange(Sender: TObject); @@ -13752,7 +13960,8 @@ begin ligneclicTrain:=ntrains-1; clicListe:=false; - formprinc.ComboTrains.Items.Add(encode_train(ntrains)); + formprinc.ComboTrains.Items.Add(trains[ntrains].nom_train); + formconfig.ComboBoxUSBTr.Items.Add(trains[ntrains].nom_train); for i:=0 to ntrains-2 do formConfig.ListBoxTrains.selected[i]:=false; @@ -13763,6 +13972,9 @@ begin SetFocus; perform(WM_VSCROLL,SB_BOTTOM,0); end; + + cree_image_Train(ntrains); + end; procedure TFormConfig.ButtonNTClick(Sender: TObject); @@ -13812,6 +14024,7 @@ begin LabeledEditCV3.Text:=''; LabeledEditCV4.Text:=''; LabeledEditCrans.Text:=''; + end; // suppression @@ -13820,17 +14033,37 @@ begin repeat if formconfig.ListBoxTrains.selected[i-1] then begin - for j:=i to ntrains-1 do + for j:=i to ntrains do begin - formconfig.ListBoxTrains.selected[j-1]:=formconfig.ListBoxTrains.selected[j]; - trains[j]:=trains[j+1]; + if formconfig.ListBoxTrains.selected[j-1] then + begin + // libérer les composants car on va réaffecter des noms + image_train[j].free; + labeltrain[j].free; + LabelVitesse[j].free; + //Formprinc.ScrollBoxTrains.Repaint; + end; + if jntrains; + Formprinc.ScrollBoxTrains.Repaint; + config_modifie:=true; FormConfig.ListBoxTrains.Clear; @@ -13840,8 +14073,20 @@ begin s:=encode_train(i); FormConfig.ListBoxtrains.items.Add(s); end; + + formprinc.ComboTrains.Clear; + with formconfig do + begin + comboBoxUSBTr.clear; + comboBoxUSBTr.items.add('Pas d''affectation'); + end; + for i:=1 to ntrains do + begin + FormPrinc.ComboTrains.items.Add(Trains[i].nom_train); + FormConfig.ComboBoxUSBTr.items.Add(Trains[i].nom_train); + end; + ligneclicTrain:=-1; - AncligneclicTrain:=-1; clicliste:=false; end; @@ -13860,8 +14105,8 @@ end; procedure TFormConfig.ListBoxTrainsKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin - if ord(key)=VK_DELETE then supprime_train; - if ord(Key)=VK_UP then + if key=VK_DELETE then supprime_train; + if Key=VK_UP then begin if clicListe then exit; clicListe:=true; @@ -13870,17 +14115,15 @@ begin begin if ligneclicTrain>0 then begin - dec(ligneclicTrain); - if AncligneclicTrain<>ligneclicTrain then begin - AncligneclicTrain:=ligneclicTrain; + dec(ligneclicTrain); clicListeTrains(ligneclicTrain+1); end; end; end; end; - if ord(Key)=VK_DOWN then + if Key=VK_DOWN then begin if clicListe then exit; clicListe:=true; @@ -13889,10 +14132,8 @@ begin begin if ligneclicTrainligneclicTrain then begin - AncligneclicTrain:=ligneclicTrain; + inc(ligneclicTrain); clicListeTrains(ligneclicTrain+1); end; end; @@ -15770,13 +16011,15 @@ begin LabelNbDecPers.caption:=intToSTR(NbreDecPers); - //l'onglet affiché est sélectionné à l'appel de la fiche dans l'unité UnitPrinc clicListe:=false; activ:=false; - if clicproprietes then clicListeSignal(IndexSignalClic); - clicproprietes:=false; + if clicproprietesSig then clicListeSignal(IndexSignalClic); + clicproprietesSig:=false; + if clicproprietesTrains then clicListeTrains(ligneclicTrain+1); + clicproprietesTrains:=false; + // aiguillages ListBoxAig.Clear; @@ -15809,8 +16052,10 @@ begin for i:=1 to ntrains do items.Add(encode_train(i)); end; - with StringGridArr do - begin + tsbouton:=FormConfig.PageControl.ActivePage=TabSheetBouton; + + with StringGridArr do + begin for i:=1 to NbDetArret do begin cells[1,i]:=''; @@ -16001,7 +16246,8 @@ var s,repini :string; i : integer;begin if ligneclicTrain<0 then exit; EditIcone.Text:=s; trains[i].icone.Picture.LoadFromFile(s); //ImageTrain.Canvas.Rectangle(0,0,ImageTrain.Width,ImageTrain.Height); - Maj_icone_train(formconfig.ImageTrain,i); + Maj_icone_train(formconfig.ImageTrain,i,clWhite); + Maj_icone_train(Image_Train[i],i,clWhite); formconfig.ListBoxTrains.items[ligneclicTrain]:=encode_train(ligneclicTrain+1); //formconfig.ImageTrain.Picture.assign(trains[i].icone.Picture); end; @@ -16020,7 +16266,7 @@ var s,Nom,repIni : string;begin trains[ligneclicTrain+1].NomIcone:=nom; // Affiche(s,clWhite); trains[ligneclicTrain+1].icone.Picture.LoadFromFile(s); - Maj_icone_train(formconfig.ImageTrain,ligneclicTrain+1); + Maj_icone_train(formconfig.ImageTrain,ligneclicTrain+1,clWhite); formconfig.ListBoxTrains.items[ligneclicTrain]:=encode_train(ligneclicTrain+1); end; end; @@ -16603,7 +16849,7 @@ begin IndexTrainFR:=ligneclicTrain+1; irPref:=1; ShowModal; - end; + end; end; end; @@ -17745,27 +17991,35 @@ begin end; -procedure TFormConfig.ComboBoxFLChange(Sender: TObject); + +procedure ComboBoxFL_mizajour; var i : integer; +begin + fabrique_treeview(FoncCourante); + + for i:=0 to formconfig.TreeViewL.Items.Count-1 do + begin + Formconfig.TreeViewL.Items[i].Expand(true); + end; + + changeCom:=true; + with Formconfig do + begin + LabelFonction.caption:=''; + LabeledEditNomLog.Text:=NomFonction[FoncCourante]; + LabeledEditNumFonc.Text:=intToSTR(fonction[FoncCourante,0].niveau); + ButtonAjOpEnfant.enabled:=false; + PanelACC.Visible:=false; + end; + changeCom:=false; +end; + +procedure TFormConfig.ComboBoxFLChange(Sender: TObject); begin if changeCom or ClicTree then exit; if affevt then Affiche('ComboBoxFL change',clyellow); FoncCourante:=ComboBoxFL.itemIndex+1; - fabrique_treeview(FoncCourante); - - for i:=0 to TreeViewL.Items.Count-1 do - begin - TreeViewL.Items[i].Expand(true); - end; - - changeCom:=true; - LabelFonction.caption:=''; - LabeledEditNomLog.Text:=NomFonction[FoncCourante]; - LabeledEditNumFonc.Text:=intToSTR(fonction[FoncCourante,0].niveau); - ButtonAjOpEnfant.enabled:=false; - PanelACC.Visible:=false; - - changeCom:=false; + ComboBoxFL_mizajour; end; Function Etat_variable(k,i : integer): boolean ; @@ -18107,10 +18361,10 @@ begin end; 8 : begin if (erreur<>0) or (i<0) then exit; - if (i<1) or (i>5000) then labelInfo.Caption:='Valeur incorrecte' + if (i<1) or (i>MaxRoutesCte) then labelInfo.Caption:='Valeur incorrecte' else MaxRoutes:=i; - if MaxRoutes<5000 then MaxRoutes:=5000; - if MaxRoutes>MaxRoutesCte then integer(p^):=i; // maxRoutes:=MaxRoutesCte; + if MaxRoutesMaxRoutesCte then MaxRoutes:=MaxRoutesCte; end; 9 : begin Option_DemiTour:=s=lowercase(liste[Arow].textePL1); @@ -18185,7 +18439,6 @@ begin end; - procedure TFormConfig.RadioGroupOPClick(Sender: TObject); var node : tTreeNode; i : integer; @@ -18206,7 +18459,6 @@ begin end; end; - procedure TFormConfig.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin @@ -18294,15 +18546,250 @@ begin trains[ligneclicTrain+1].cv4:=valeur; LabeledEditCV4.Text:=IntToSTR(valeur); clicListe:=false; - end; - procedure TFormConfig.ButtonRepriseDCCClick(Sender: TObject); begin reprise_dcc; end; +procedure boutons; +begin + with formConfig do + begin + shapeBR.Brush.Color:=clGray; + shapeB1.Brush.Color:=clGray; + shapeB2.Brush.Color:=clGray; + shapeB3.Brush.Color:=clGray; + shapeB4.Brush.Color:=clGray; + LabeledEditCT.visible:=true; + LabeledEditRm.visible:=false; + LabeledEditRp.visible:=false; + LabeledEditClic.Visible:=false; + LabeledEditF.Visible:=true; + LabeledEditFn.Visible:=true; + LabeledEditIncr.Visible:=false; + end; +end; + +procedure rotatif; +begin + with formConfig do + begin + ShapeBR.Brush.Color:=clYellow; + shapeB1.Brush.Color:=clGray; + shapeB2.Brush.Color:=clGray; + shapeB3.Brush.Color:=clGray; + shapeB4.Brush.Color:=clGray; + LabeledEditCT.visible:=false; + LabeledEditF.Visible:=false; + LabeledEditFn.Visible:=false; + LabeledEditRm.visible:=true; + LabeledEditRp.visible:=true; + LabeledEditClic.Visible:=true; + LabeledEditIncr.Visible:=true; + end; +end; + +Procedure Aff_champs_BRM; +begin + with formConfig do + begin + LabeledEditRM.Text:=intToSTR(blocUSB[NumBlocUSB].rotatifM); + LabeledEditRP.Text:=intToSTR(blocUSB[NumBlocUSB].rotatifP); + LabeledEditClic.Text:=intToSTR(blocUSB[NumBlocUSB].clic); + if blocUSB[NumBlocUSB].increment<1 then blocUSB[NumBlocUSB].increment:=1; + LabeledEditIncr.Text:=intToSTR(blocUSB[NumBlocUSB].increment); + end; +end; + +procedure clic_BRM; +begin + rotatif; + BoutonBloc:=99; + Aff_champs_BRM; +end; + +procedure TFormConfig.ShapeBRMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + clic_BRM; +end; + +procedure TFormConfig.ShapeB1MouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + boutons; + ShapeB1.Brush.Color:=clYellow; + BoutonBloc:=1; + LabeledEditCT.Text:=intToSTR(blocUSB[NumBlocUSB].Bp1); + LabeledEditF.Text:=intToSTR(blocUSB[NumBlocUSB].Fbp1); + LabeledEditFn.Text:=intToSTR(blocUSB[NumBlocUSB].Fnp1); +end; + +procedure TFormConfig.ShapeB2MouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + boutons; + ShapeB2.Brush.Color:=clYellow; + BoutonBloc:=2; + LabeledEditCT.Text:=intToSTR(blocUSB[NumBlocUSB].Bp2); + LabeledEditF.Text:=intToSTR(blocUSB[NumBlocUSB].Fbp2); + LabeledEditFn.Text:=intToSTR(blocUSB[NumBlocUSB].Fnp2); +end; + +procedure TFormConfig.ShapeB3MouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + boutons; + ShapeB3.Brush.Color:=clYellow; + BoutonBloc:=3; + LabeledEditCT.Text:=intToSTR(blocUSB[NumBlocUSB].Bp3); + LabeledEditF.Text:=intToSTR(blocUSB[NumBlocUSB].Fbp3); + LabeledEditFn.Text:=intToSTR(blocUSB[NumBlocUSB].Fnp3); +end; + +procedure TFormConfig.ShapeB4MouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + boutons; + ShapeB4.Brush.Color:=clYellow; + BoutonBloc:=4; + LabeledEditCT.Text:=intToSTR(blocUSB[NumBlocUSB].Bp4); + LabeledEditF.Text:=intToSTR(blocUSB[NumBlocUSB].Fbp4); + LabeledEditFn.Text:=intToSTR(blocUSB[NumBlocUSB].Fnp4); +end; + +procedure TFormConfig.LabeledEditCTChange(Sender: TObject); +var i,erreur : integer; +begin + val(LabeledEditCT.Text,i,erreur); + if (erreur<>0) or (i<0) or (i>255) then exit; + case BoutonBloc of + 1 : blocUSB[NumBlocUSB].Bp1:=i; + 2 : blocUSB[NumBlocUSB].Bp2:=i; + 3 : blocUSB[NumBlocUSB].Bp3:=i; + 4 : blocUSB[NumBlocUSB].Bp4:=i; + 5 : blocUSB[NumBlocUSB].Bp5:=i; + 6 : blocUSB[NumBlocUSB].Bp6:=i; + 7 : blocUSB[NumBlocUSB].Bp7:=i; + 8 : blocUSB[NumBlocUSB].Bp8:=i; + 9 : blocUSB[NumBlocUSB].Bp9:=i; + 10 : blocUSB[NumBlocUSB].Bp10:=i; + end; +end; + +procedure TFormConfig.LabeledEditRmChange(Sender: TObject); +var i,erreur : integer; +begin + val(LabeledEditRm.Text,i,erreur); + if (erreur<>0) or (i<0) or (i>255) then exit; + blocUSB[NumBlocUSB].rotatifM:=i; +end; + +procedure TFormConfig.LabeledEditRpChange(Sender: TObject); +var i,erreur : integer; +begin + val(LabeledEditRp.Text,i,erreur); + if (erreur<>0) or (i<0) or (i>255) then exit; + blocUSB[NumBlocUSB].rotatifP:=i; +end; + +procedure TFormConfig.LabeledEditClicChange(Sender: TObject); +var i,erreur : integer; +begin + val(LabeledEditClic.Text,i,erreur); + if (erreur<>0) or (i<0) or (i>255) then exit; + blocUSB[NumBlocUSB].clic:=i; +end; + + +procedure TFormConfig.LabeledEditNUMChange(Sender: TObject); +var i,erreur : integer; +begin + val(LabeledEditNUM.Text,i,erreur); + if (erreur<>0) or (i<0) or (i>10) then exit; + NumBlocUSB:=i; + LabeledEditCT.Text:=''; + LabeledEditRM.Text:=''; + LabeledEditRP.Text:=''; + LabeledEditClic.Text:=''; + LabeledEditF.Text:=''; + LabeledEditFn.Text:=''; + ShapeBR.Brush.Color:=clGray; + shapeB1.Brush.Color:=clGray; + shapeB2.Brush.Color:=clGray; + shapeB3.Brush.Color:=clGray; + shapeB4.Brush.Color:=clGray; + LabelID.caption:=intToSTR(i); + //Aff_champs_BRM; + i:=index_train_nom(BlocUSB[NumBlocUSB].AffTrain); + ComboBoxUSBTr.ItemIndex:=i; + label72.caption:=''; +end; + +procedure TFormConfig.LabeledEditFChange(Sender: TObject); +var i,erreur : integer; +begin + val(LabeledEditF.Text,i,erreur); + if (erreur<>0) or (i<0) or (i>30) then exit; + case boutonbloc of + 1 : blocUSB[NumBlocUSB].Fbp1:=i; + 2 : blocUSB[NumBlocUSB].Fbp2:=i; + 3 : blocUSB[NumBlocUSB].Fbp3:=i; + 4 : blocUSB[NumBlocUSB].Fbp4:=i; + 5 : blocUSB[NumBlocUSB].Fbp5:=i; + 6 : blocUSB[NumBlocUSB].Fbp6:=i; + 7 : blocUSB[NumBlocUSB].Fbp7:=i; + 8 : blocUSB[NumBlocUSB].Fbp8:=i; + 9 : blocUSB[NumBlocUSB].Fbp9:=i; + 10 : blocUSB[NumBlocUSB].Fbp10:=i; + end; +end; + +procedure TFormConfig.LabeledEditIncrChange(Sender: TObject); +var i,erreur : integer; +begin + val(LabeledEditIncr.Text,i,erreur); + if (erreur<>0) or (i<1) or (i>20) then exit; + blocUSB[NumBlocUSB].increment:=i; +end; + +procedure TFormConfig.ComboBoxUSBTrChange(Sender: TObject); +var i : integer; +begin + i:=ComboBoxUSBTr.ItemIndex; + if i=0 then + begin + blocUSB[NumBlocUSB].AffTrain:='Pas d''affectation'; + Label72.Caption:='La sélection du train est celle de la page principale'; + end + else + begin + blocUSB[NumBlocUSB].AffTrain:=trains[i].nom_train; + Label72.Caption:=trains[i].nom_train+' sélectionné pour le bloc USB '+intToSTR(NumBlocUSB); + end; +end; + +procedure TFormConfig.LabeledEditFnChange(Sender: TObject); +var i,erreur :integer; +begin + val(LabeledEditFn.Text,i,erreur); + if (erreur<>0) or (i<0) or (i>30) then exit; + case boutonbloc of + 1 : blocUSB[NumBlocUSB].Fnp1:=i; + 2 : blocUSB[NumBlocUSB].Fnp2:=i; + 3 : blocUSB[NumBlocUSB].Fnp3:=i; + 4 : blocUSB[NumBlocUSB].Fnp4:=i; + 5 : blocUSB[NumBlocUSB].Fnp5:=i; + 6 : blocUSB[NumBlocUSB].Fnp6:=i; + 7 : blocUSB[NumBlocUSB].Fnp7:=i; + 8 : blocUSB[NumBlocUSB].Fnp8:=i; + 9 : blocUSB[NumBlocUSB].Fnp9:=i; + 10 : blocUSB[NumBlocUSB].Fnp10:=i; + end; +end; + end. diff --git a/UnitConfigCellTCO.pas b/UnitConfigCellTCO.pas index 2d238b3..1923212 100644 --- a/UnitConfigCellTCO.pas +++ b/UnitConfigCellTCO.pas @@ -419,7 +419,7 @@ begin ligne:=1; for i:=1 to Ntrains do begin - for j:=1 to 10 do + for j:=1 to NbDetArret do if (trains[i].DetecteurArret[j].detecteur=adr) and (adr<>0) then begin s:=''; @@ -666,7 +666,7 @@ end; procedure TFormConfCellTCO.EditAdrElementChange(Sender: TObject); -var Adr,erreur,index,Bimage,x,y : integer; +var Adr,erreur,Bimage,x,y : integer; begin if clicTCO or not(ConfCellTCO) or actualize then exit; if affevt then Affiche('TFormConfCellTCO.EditAdrElementChange',clyellow); @@ -697,11 +697,10 @@ begin if BImage=Id_signal then begin - index:=Index_Signal(adr); + { index:=Index_Signal(adr); if index=0 then exit - else + else } begin - //Affiche('Feu '+intToSTR(Adr),clyellow); affiche_tco(indexTCOcourant); end; end; diff --git a/UnitMesure.pas b/UnitMesure.pas index de7d4d1..0dbc143 100644 --- a/UnitMesure.pas +++ b/UnitMesure.pas @@ -54,7 +54,7 @@ uses UnitPrinc,unitTCO; procedure arret_mesure ; begin mesureTrains:=false; - vitesse_loco('',0,trains[indexTrainMes].adresse,0,10); + vitesse_loco('',0,trains[indexTrainMes].adresse,0,10,ActionVitesse); // action vitesse pour ne pas générer d'event vitesse with formMesure do begin ComboBoxTrains.Enabled:=true; @@ -219,7 +219,7 @@ begin mesureTrains:=true; - vitesse_loco('',0,trains[indexTrainMes].adresse,v1,10); + vitesse_loco('',0,trains[indexTrainMes].adresse,v1,10,ActionVitesse); // ActionVitesse pour ne pas générer d'event_vitesse LabelMesC.Visible:=true; LabelMesC.top:=178; diff --git a/UnitModifAction.dfm b/UnitModifAction.dfm index 5186738..bba67c9 100644 --- a/UnitModifAction.dfm +++ b/UnitModifAction.dfm @@ -60,7 +60,7 @@ object FormModifAction: TFormModifAction Top = 64 Width = 729 Height = 337 - ActivePage = TabSheetOp + ActivePage = TabSheetDecl MultiLine = True TabOrder = 1 object TabSheetDecl: TTabSheet @@ -684,6 +684,8 @@ object FormModifAction: TFormModifAction EditLabel.Caption = 'Adresse' LabelPosition = lpLeft LabelSpacing = 10 + ParentShowHint = False + ShowHint = True TabOrder = 1 OnChange = LabeledEditAdresseChange end @@ -734,6 +736,8 @@ object FormModifAction: TFormModifAction EditLabel.Caption = 'Tempo x100ms' LabelPosition = lpLeft LabelSpacing = 10 + ParentShowHint = False + ShowHint = True TabOrder = 5 OnChange = LabeledEditTempoFChange end diff --git a/UnitModifAction.pas b/UnitModifAction.pas index e2a9743..281bb96 100644 --- a/UnitModifAction.pas +++ b/UnitModifAction.pas @@ -163,13 +163,11 @@ uses Unitprinc, UnitConfigCellTCO, UnitConfig; {$R *.dfm} -// rend tous les composants invisibles -procedure efface_tous_parametres; +procedure efface_champs_declencheurs_conditions; begin - with FormModifAction do + with formModifAction do begin - //r:=Rect( - // r:=TRect(ListBoxDeclench.handle,0,i*10,ListBoxDeclench.width,16); + // déclencheurs RadioEtatSignal.Visible:=false; LabelAdresse.Visible:=false; SpinEditEtat.Visible:=false; @@ -178,8 +176,33 @@ begin EditAdr2.Visible:=false; LabelTrain.Visible:=false; EditTrainDecl.Visible:=false; - LabelPeriph.Visible:=false; LabelEtat.Visible:=false; + LabelInfoFonc.Visible:=false; + ButtonFonction.Visible:=false; + // conditions + Champ1.Visible:=false; + Champ2.Visible:=false; + SpinEditHeure1.visible:=false; + SpinEditMn1.visible:=false; + SpinEditHeure2.visible:=false; + SpinEditMn2.visible:=false; + LabelHeureDebut.Visible:=false; + LabelHeureFin.Visible:=false; + LabelEtat2.Visible:=false; + SpinEditEtat2.Visible:=false; + ChampTrain.Visible:=false; + ButtonVoirFonc.Visible:=false; + Label2InfoFonction.visible:=false; + end; + +end; + +// rend invisibles les champs opérations +procedure efface_champs_operations; +begin + with FormModifAction do + begin + LabelPeriph.Visible:=false; LabeledEditTempoF.Visible:=false; LabeledEditTrain.Visible:=false; SpeedButtonJoue.visible:=false; @@ -192,21 +215,6 @@ begin labelEtatOp.Visible:=false; RichEditInf.clear; ComboBoxAccComUSB.visible:=false; - Champ1.Visible:=false; - Champ2.Visible:=false; - LabelHeureDebut.Visible:=false; - LabelHeureFin.Visible:=false; - SpinEditHeure1.visible:=false; - SpinEditMn1.visible:=false; - SpinEditHeure2.visible:=false; - SpinEditMn2.visible:=false; - LabelEtat2.Visible:=false; - SpinEditEtat2.Visible:=false; - ChampTrain.Visible:=false; - ButtonVoirFonc.Visible:=false; - ButtonFonction.Visible:=false; - LabelInfoFonc.Visible:=false; - Label2InfoFonction.visible:=false; end; end; @@ -287,7 +295,8 @@ begin 'Double clic pour valider/dévalider une opération'; LabeledEditFonctionF.Hint:='Fonction F de 0 à 28'; - Efface_tous_parametres; + Efface_champs_operations; + Efface_champs_declencheurs_conditions; PageControlAct.ActivePage:=TabSheetDecl; end; @@ -338,7 +347,7 @@ var i,erreur: Integer; ItemText: string; begin - //Affiche('Evt ListBoxOperationsDrawItem',clyellow); + if affevt then Affiche('Evt ListBoxOperationsDrawItem '+intToSTR(index),clyellow); with ListBoxOperations do begin ItemText:=Items[index]; @@ -390,9 +399,9 @@ begin DeclZoneDet : s:=s+'Zone détection '+intToSTR(Tablo_Action[i].adresse)+' '+intToSTR(Tablo_Action[i].adresse2); DeclDemarTrain : - s:=s+'démarrage du train '+Tablo_Action[i].trainDecl+' au seuil de '+intToSTR(Tablo_Action[i].adresse); + s:=s+'démarrage du train '+Tablo_Action[i].trainDecl; DeclArretTrain : - s:=s+'arrêt du train '+Tablo_Action[i].trainDecl+' au seuil de '+intToSTR(Tablo_Action[i].adresse); + s:=s+'arrêt du train '+Tablo_Action[i].trainDecl; DeclSignal : begin s:=s+'changement du signal '+intToSTR(Tablo_Action[i].adresse); @@ -481,15 +490,187 @@ begin result:=s; end; +procedure affiche_champs_operations(index,indexaction : integer); +var nb,act : integer; +begin + 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 + begin + indexAction:=1; + formModifAction.listBoxOperations.itemIndex:=indexaction; + formModifAction.listBoxOperations.Selected[indexaction-1]:=true; + end; + + efface_champs_operations; + + if Nb>=indexAction then + begin + Act:=Tablo_Action[index].tabloop[indexAction].numoperation; + + with formModifAction do + begin + case Act of + ActionAffTCO : + begin + LabeledEditAdresse.hint:='Numéro du TCO'; + LabeledEditAdresse.Visible:=true; + LabeledEditAdresse.EditLabel.Caption:='TCO n°'; + LabeledEditAdresse.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].NumTCO); + end; + ActionAccessoire : + begin + LabeledEditAdresse.hint:='Adresse d''accessoire sur le bus DCC'; + LabeledEditAdresse.EditLabel.Caption:='Adresse'; + LabeledEditAdresse.visible:=true; + SpinEditEtatop.Visible:=true; + labelEtatOp.Visible:=true; + SpinEditEtatop.MinValue:=0; + SpinEditEtatop.MaxValue:=2; + SpinEditEtatop.hint:='Etat de l''accessoire'+#13+ + '0=nul'+#13+ + '1=dévié'+#13+ + '2=droit'; + + checkBoxRaz.Visible:=true; + LabeledEditAdresse.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].adresse); + SpinEditEtatop.Value:=Tablo_Action[index].tabloop[indexAction].etat; + checkBoxRAZ.Checked:=Tablo_Action[index].tabloop[indexAction].zero; + end; + ActionVitesse : + begin + LabeledEditAdresse.EditLabel.Caption:='Vitesse'; + LabeledEditAdresse.visible:=true; + LabeledEditAdresse.hint:='Vitesse de pilotage du train en crans'; + LabeledEditTrain.Visible:=true; + LabeledEditTrain.EditLabel.Caption:='Train destinataire'; + LabeledEditTrain.hint:='Nom unique du train'; + LabeledEditAdresse.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].vitesse); + LabeledEditTrain.Text:=Tablo_Action[index].tabloop[indexAction].train; + end; + ActionCdePeriph : + begin + LabeledEditTrain.Visible:=true; + ComboBoxAccComUSB.Visible:=true; + LabelPeriph.Visible:=true; + LabeledEditTrain.EditLabel.Caption:='Commande'; + LabeledEditTrain.Hint:='Commande Ascii'; + LabeledEditTrain.Text:=Tablo_Action[index].tabloop[indexAction].chaine; + ComboBoxAccComUSB.itemIndex:=Tablo_Action[index].tabloop[indexAction].periph-1; + end; + ActionFonctionF : + begin + with SpinEditEtatop do + begin + Visible:=true; + MinValue:=0; + MaxValue:=1; + hint:='Etat 0 ou 1 de la fonction F'; + end; + labelEtatOp.Visible:=true; + with LabeledEditTempoF do + begin + Visible:=true; + hint:='Valeur de la temporisation en 1/10ème de s'+#13+ + 'pour désactiver la fonction F'+#13+ + 'Si 0, la fonction F reste activée'; + EditLabel.Caption:='Tempo (x100ms)'; + Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].TempoF); + end; + LabeledEditTrain.Visible:=true; + LabeledEditTrain.EditLabel.Caption:='Train destinataire'; + LabeledEditTrain.hint:='Nom unique du train'; + SpinEditEtatOp.Text:=IntToSTR(Tablo_Action[index].tabloop[indexAction].etat); + LabeledEditFonctionF.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].fonctionF); + LabeledEditFonctionF.Visible:=true; + LabeledEditTrain.Text:=Tablo_Action[index].tabloop[indexAction].train; + end; + ActionSon : + begin + LabeledEditTrain.Visible:=true; + SpeedButtonJoue.Visible:=true; + SpeedButtonCharger.Visible:=true; + LabeledEditTrain.EditLabel.Caption:='Son'; + LabeledEditTrain.Hint:='fichier son'; + LabeledEditTrain.Text:=Tablo_Action[index].tabloop[indexAction].train; + end; + ActionTempo : + begin + LabeledEditTempoF.Visible:=true; + LabeledEditTempoF.EditLabel.Caption:='Temporisation (x100 ms)'; + LabeledEditTempoF.hint:='Valeur en dixièmes de secondes'; + LabeledEditTempoF.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].TempoF); + end; + ActionBoutonTCO : + begin + with LabeledEditAdresse do + begin + hint:='Numéro de bouton de TCO'; + Visible:=true; + EditLabel.Caption:='Bouton'; + text:=intToSTR(Tablo_Action[index].tabloop[indexAction].adresse); + end; + With SpinEditEtatOp do + begin + Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].etat); + Visible:=true; + MinValue:=0; + MaxValue:=1; + hint:='Etat 0 ou 1 du bouton'; + end; + end; + ActionAffecteMemoire : + begin + with LabeledEditAdresse do + begin + EditLabel.Caption:='Mémoire'; + Visible:=true; + hint:='Numéro de mémoire'; + text:=intToSTR(Tablo_Action[index].tabloop[indexAction].adresse); + end; + with SpinEditEtatOp do + begin + Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].etat); + Visible:=true; + MinValue:=-999; + MaxValue:=999; + hint:='Valeur d''affectation de -999 à 999'; + end; + end; + ActionIncMemoire : + begin + with LabeledEditAdresse do + begin + EditLabel.Caption:='Mémoire'; + hint:='Numéro de mémoire'; + Visible:=true; + text:=intToSTR(Tablo_Action[index].tabloop[indexAction].adresse); + end; + end; + ActionDecMemoire : + begin + with LabeledEditAdresse do + begin + EditLabel.Caption:='Mémoire'; + hint:='Numéro de mémoire'; + Visible:=true; + text:=intToSTR(Tablo_Action[index].tabloop[indexAction].adresse); + end; + end; + end; + end; + end; +end; + // affiche les champs en fonction de l'index du tablo actionneur et de l'index de l'action procedure Aff_champs(index,IndexCond,IndexAction : integer); -var i,decl,act,cond,Nb,icone : integer; +var i,decl,act,cond,icone : integer; s : string; begin if (index<1) then exit; if clicListe then exit; clicliste:=true; - // Affiche('Aff_champs('+intToSTR(index)+','+intToSTR(indexAction)+')',clYellow); + if affevt then Affiche('Aff_champs('+intToSTR(index)+', indexOperation='+intToSTR(indexAction)+')',clYellow); decl:=Tablo_Action[index].declencheur; formModifAction.ListBoxDeclench.ItemIndex:=decl-1; // comboboxActions @@ -515,6 +696,7 @@ begin FormModifAction.LabeledEditNomAct.Text:=Tablo_Action[index].NomAction; // ListBox opérations + with FormModifAction.ListBoxOperations do begin clear; @@ -535,7 +717,6 @@ begin if act=ActionIncMemoire then items.Add(Format('%d%s', [iconeActionIncMemoire, s])); if act=ActionDecMemoire then items.Add(Format('%d%s', [iconeActionDecMemoire, s])); - // listboxOperations de la formConfig if act<=ActionTempo then formConfig.ListBoxOperations.Items.add(Format('%d%s', [act-1, s])); if act=ActionBoutonTCO then formConfig.ListBoxOperations.items.Add(Format('%d%s', [IconeBouton, s])); @@ -575,6 +756,7 @@ begin if indexCond<>0 then itemIndex:=indexCond-1; end; + // listBoxActions de la formConfig FormConfig.ListBoxActions.Clear; for i:=1 to maxTablo_act do @@ -583,7 +765,7 @@ begin formConfig.ListBoxActions.Items.add(s); end; - efface_tous_parametres; + efface_champs_declencheurs_conditions; // déclencheurs with FormModifAction do @@ -595,40 +777,24 @@ begin LabelHeure.visible:=true; LabelAdresse.visible:=true; EditAdr.Visible:=true; - ButtonFonction.Visible:=false; LabelAdresse.Caption:='Heure'; EditAdr.Hint:='Heure du déclencheur'; EditAdr2.Hint:='Minute du déclencheur'; EditAdr2.Visible:=true; - LabelEtat.Visible:=false; - SpinEditEtat.Visible:=false; - LabelTrain.Visible:=false; - EditTrainDecl.Visible:=false; RichEditInf.Lines.Add('Déclenchement par l''horloge'); ImageIcone.Picture:=nil; - LabelInfoFonc.Visible:=false; formConfCellTCO.ImageListIcones.GetBitmap(IconeHorloge,ImageIcone.Picture.Bitmap); ImageIcone.repaint; end; DeclPeriph : begin EditTrainDecl.Text:=Tablo_Action[index].ordrePeriph; - LabelHeure.visible:=false; - LabelAdresse.visible:=false; - EditAdr.Visible:=false; - EditAdr2.Visible:=false; - LabelEtat.Visible:=false; - - SpinEditEtat.Visible:=false; - LabelTrain.Visible:=false; - ButtonFonction.Visible:=false; EditTrainDecl.Visible:=true; EditTrainDecl.Hint:='Chaîne ASCII'; LabelTrain.visible:=true; LabelTrain.Caption:='Commande du périphérique'; RichEditInf.Lines.Add('Déclenchement par chaîne ASCII depuis un périphérique COM/USB - Socket'); - LabelInfoFonc.Visible:=false; ImageIcone.Picture:=nil; formConfCellTCO.ImageListIcones.GetBitmap(IconePeriph,ImageIcone.Picture.Bitmap); @@ -651,18 +817,11 @@ begin visible:=true; end; - LabelHeure.visible:=false; LabelAdresse.caption:='Adresse'; LabelAdresse.visible:=true; EditAdr.Hint:='Adresse de l''accessoire sur le bus'; EditAdr.Visible:=true; - EditAdr2.Visible:=false; - ButtonFonction.Visible:=false; LabelEtat.Visible:=true; - LabelInfoFonc.Visible:=false; - - LabelTrain.Visible:=false; - EditTrainDecl.Visible:=false; RichEditInf.Lines.Add('Accessoire sur le bus DCC (aiguillage)'); ImageIcone.Picture:=nil; formConfCellTCO.ImageListIcones.GetBitmap(IconeAccessoire,ImageIcone.Picture.Bitmap); @@ -674,18 +833,13 @@ begin EditAdr.text:=intToSTR(Tablo_Action[index].adresse); EditTrainDecl.Visible:=true; EditTrainDecl.Text:=Tablo_Action[index].trainDecl; - ButtonFonction.Visible:=false; EdittrainDecl.Hint:='Train(s) déclencheur(s) séparés par des virgules pour lesquels la condition s''applique.' +#13+'Mettre X pour tous les trains.'+#13+'Déclenchement par actionneur uniquement'; - LabelAdresse.visible:=true; EditAdr.Visible:=true; EditAdr.Hint:='Adresse du détecteur sur le bus de rétrosignalisation '+#13+'ou de l''actionneur CDM'; - LabelHeure.visible:=false; - EditAdr2.Visible:=false; LabelAdresse.Caption:='Adresse'; LabelEtat.Visible:=true; - LabelInfoFonc.Visible:=false; - + LabelAdresse.Visible:=true; with SpinEditEtat do begin text:=intToSTR(Tablo_Action[index].etat); @@ -697,7 +851,6 @@ begin ShowHint:=true; visible:=true; end; - ButtonFonction.Visible:=false; LabelTrain.Visible:=true; LabelTrain.Caption:='Train déclencheur'; s:='Déclenchement par détecteur/actionneur suivant son état et un train, un groupe de trains ou tous les trains.'+#13; @@ -719,11 +872,9 @@ begin EditAdr2.Hint:='Adresse2 de la zone de détection du déclencheur'; LabelAdresse.visible:=true; EditAdr.Visible:=true; - LabelHeure.visible:=false; EditAdr2.Visible:=true; LabelAdresse.Caption:='Adresse'; LabelEtat.Visible:=true; - LabelInfoFonc.Visible:=false; EditTrainDecl.Visible:=true; EdittrainDecl.Hint:='Train(s) déclencheur(s) séparés par des virgules pour lesquels la condition s''applique.' @@ -740,7 +891,6 @@ begin ShowHint:=true; visible:=true; end; - ButtonFonction.Visible:=false; LabelTrain.Visible:=true; LabelTrain.Caption:='Train déclencheur'; RichEditInf.Lines.Add('Déclenchement par zones de détections contigües suivant son état et un train, un groupe de trains ou tous les trains.'); @@ -753,16 +903,10 @@ begin begin LabelTrain.visible:=true; EditTrainDecl.Visible:=true; - LabelAdresse.Visible:=true; - LabelAdresse.caption:='Seuil de vitesse'; - EditAdr.Visible:=true; - ButtonFonction.Visible:=false; EdittrainDecl.Hint:='Train déclencheur unique'; - LabelInfoFonc.Visible:=false; - EditADR.Hint:='Seuil de vitesse de démarrage du train '; 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é'); + RichEditInf.Lines.Add('Déclenchement par démarrage d''un train'); ImageIcone.Picture:=nil; formConfCellTCO.ImageListIcones.GetBitmap(IconeDemarTrain,ImageIcone.Picture.Bitmap); ImageIcone.repaint; @@ -772,17 +916,11 @@ begin begin LabelTrain.visible:=true; EditTrainDecl.Visible:=true; - LabelAdresse.Visible:=true; - LabelAdresse.caption:='Seuil de vitesse'; EdittrainDecl.Hint:='Train déclencheur unique'; - ButtonFonction.Visible:=false; - EditAdr.Visible:=true; - EditADR.Hint:='Seuil de vitesse d''arrêt du train'; 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é'); + RichEditInf.Lines.Add('Déclenchement par arrêt d''un train'); ImageIcone.Picture:=nil; - LabelInfoFonc.Visible:=false; formConfCellTCO.ImageListIcones.GetBitmap(IconeArretTrain,ImageIcone.Picture.Bitmap); ImageIcone.repaint; end; @@ -794,12 +932,10 @@ begin RadioEtatSignal.ItemIndex:=Tablo_Action[index].Etat; LabelAdresse.Caption:='Adresse'; EditAdr.Hint:='Adresse de base du signal'; - ButtonFonction.Visible:=false; EditAdr.Visible:=true; RadioEtatSignal.Visible:=true; RadioEtatSignal.Left:=16; RadioEtatSignal.top:=64; - LabelInfoFonc.Visible:=false; RichEditInf.Lines.Add('Déclenchement par changement d''état d''un signal'); ImageIcone.Picture:=nil; formConfCellTCO.ImageListIcones.GetBitmap(IconeSignal,ImageIcone.Picture.Bitmap); @@ -810,18 +946,16 @@ begin begin LabelAdresse.Visible:=true; // numéro de fonction LabelAdresse.caption:='Numéro de fonction'; - EditAdr.Visible:=false; ButtonFonction.Visible:=true; - RadioEtatSignal.visible:=false; EditAdr2.Visible:=true; // entrée le la fonction EditAdr2.Text:=IntToSTR(tablo_action[index].adresse); - RadioEtatSignal.Visible:=false; ImageIcone.Picture:=nil; formConfCellTCO.ImageListIcones.GetBitmap(IconeFonction,ImageIcone.Picture.Bitmap); ImageIcone.repaint; LabelInfoFonc.Visible:=true; RichEditInf.Lines.Add('Déclenchement par fonction logique'); - LabelInfoFonc.Caption:=NomFonction[index]; + if (tablo_action[index].adresse>0) and (tablo_action[index].adresse0) and (indexAction=0) then - begin - indexAction:=1; - formModifAction.listBoxOperations.itemIndex:=indexaction; - formModifAction.listBoxOperations.Selected[indexaction-1]:=true; - end; - - if Nb>=indexAction then - begin - - Act:=Tablo_Action[index].tabloop[indexAction].numoperation; - - with formModifAction do - begin - - case Act of - ActionAffTCO : - begin - LabeledEditAdresse.Visible:=true; - LabeledEditAdresse.EditLabel.Caption:='TCO n°'; - LabeledEditAdresse.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].NumTCO); - end; - ActionAccessoire : - begin - LabeledEditAdresse.EditLabel.Caption:='Adresse'; - LabeledEditAdresse.visible:=true; - SpinEditEtatop.Visible:=true; - labelEtatOp.Visible:=true; - SpinEditEtatop.MinValue:=0; - SpinEditEtatop.MaxValue:=2; - SpinEditEtatop.hint:='Etat de l''accessoire'+#13+ - '0=nul'+#13+ - '1=dévié'+#13+ - '2=droit'; - - checkBoxRaz.Visible:=true; - LabeledEditAdresse.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].adresse); - SpinEditEtatop.Value:=Tablo_Action[index].tabloop[indexAction].etat; - checkBoxRAZ.Checked:=Tablo_Action[index].tabloop[indexAction].zero; - end; - ActionVitesse : - begin - LabeledEditAdresse.EditLabel.Caption:='Vitesse'; - LabeledEditAdresse.visible:=true; - LabeledEditTrain.Visible:=true; - LabeledEditTrain.EditLabel.Caption:='Train destinataire'; - LabeledEditTrain.hint:='Nom unique du train'; - LabeledEditAdresse.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].vitesse); - LabeledEditTrain.Text:=Tablo_Action[index].tabloop[indexAction].train; - end; - ActionCdePeriph : - begin - LabeledEditTrain.Visible:=true; - ComboBoxAccComUSB.Visible:=true; - LabelPeriph.Visible:=true; - LabeledEditTrain.EditLabel.Caption:='Commande'; - LabeledEditTrain.Hint:='Commande Ascii'; - LabeledEditTrain.Text:=Tablo_Action[index].tabloop[indexAction].chaine; - ComboBoxAccComUSB.itemIndex:=Tablo_Action[index].tabloop[indexAction].periph-1; - end; - ActionFonctionF : - begin - SpinEditEtatop.Visible:=true; - SpinEditEtatop.MinValue:=0; - SpinEditEtatop.MaxValue:=1; - - labelEtatOp.Visible:=true; - LabeledEditFonctionF.Visible:=true; - LabeledEditTempoF.Visible:=true; - LabeledEditTrain.EditLabel.Caption:='Train destinataire'; - LabeledEditFonctionF.EditLabel.Caption:='Fonction F'; - LabeledEditTrain.Visible:=true; - LabeledEditTrain.hint:='Nom unique du train'; - SpinEditEtatOp.Text:=IntToSTR(Tablo_Action[index].tabloop[indexAction].etat); - 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 - LabeledEditTrain.Visible:=true; - SpeedButtonJoue.Visible:=true; - SpeedButtonCharger.Visible:=true; - LabeledEditTrain.EditLabel.Caption:='Son'; - LabeledEditTrain.Hint:='fichier son'; - LabeledEditTrain.Text:=Tablo_Action[index].tabloop[indexAction].train; - end; - ActionTempo : - begin - LabeledEditTempoF.Visible:=true; - LabeledEditTempoF.EditLabel.Caption:='Temporisation (x100 ms)'; - LabeledEditTempoF.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].TempoF); - end; - ActionBoutonTCO : - begin - LabeledEditAdresse.Visible:=true; - LabeledEditAdresse.EditLabel.Caption:='Bouton'; - LabeledEditAdresse.text:=intToSTR(Tablo_Action[index].tabloop[indexAction].adresse); - SpinEditEtatOp.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].etat); - SpinEditEtatOp.Visible:=true; - SpinEditEtatOp.MinValue:=0; - SpinEditEtatOp.MaxValue:=1; - end; - ActionAffecteMemoire : - begin - LabeledEditAdresse.EditLabel.Caption:='Mémoire'; - LabeledEditAdresse.Visible:=true; - LabeledEditAdresse.text:=intToSTR(Tablo_Action[index].tabloop[indexAction].adresse); - SpinEditEtatOp.Text:=intToSTR(Tablo_Action[index].tabloop[indexAction].etat); - SpinEditEtatOp.Visible:=true; - SpinEditEtatOp.MinValue:=-999; - SpinEditEtatOp.MaxValue:=999; - end; - ActionIncMemoire : - begin - LabeledEditAdresse.EditLabel.Caption:='Mémoire'; - LabeledEditAdresse.Visible:=true; - LabeledEditAdresse.text:=intToSTR(Tablo_Action[index].tabloop[indexAction].adresse); - end; - ActionDecMemoire : - begin - LabeledEditAdresse.EditLabel.Caption:='Mémoire'; - LabeledEditAdresse.Visible:=true; - LabeledEditAdresse.text:=intToSTR(Tablo_Action[index].tabloop[indexAction].adresse); - end; - end; - end; - end; clicliste:=false; end; @@ -1250,6 +1248,7 @@ begin ItemIndex:=indexSrc+1; end; + Config_Modifie:=true; end; procedure maj_combocactions(i : integer); @@ -1353,10 +1352,10 @@ end; procedure TFormModifAction.ListBoxOperationsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - //Affiche('Clic ListBoxOperations',clyellow); + if affevt then Affiche('Clic ListBoxOperations',clyellow); ClicAction:=ListBoxOperations.itemindex; if ClicAction<0 then exit; - Aff_champs(ligneclicAct+1,1,ClicAction+1); + Affiche_champs_operations(ligneclicAct+1,ClicAction+1); end; procedure TFormModifAction.LabeledEditAdresseChange(Sender: TObject); @@ -1456,6 +1455,7 @@ begin Tablo_Action[ligneclicAct+1].declencheur:=i+1; Aff_champs(ligneclicAct+1,0,0); + //aff_champs_declencheur( ListBoxDeclench.Refresh; end; @@ -1739,32 +1739,24 @@ begin 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; + Affiche_champs_operations(ligneclicAct+1,ClicAction+1); end; end; end; if ord(Key)=VK_DOWN then begin - //if clicListe then exit; - clicListe:=true; - //with Formconfig.ListBoxactions.Items do begin if clicactionNbreFL) then exit; + formModifAction.Close; formconfig.PageControl.ActivePage:=formconfig.TabSheetFonctions; - - FoncCourante:=Tablo_Action[ligneClicAct+1].adresse; - - FormConfig.ComboBoxFL.ItemIndex:=FoncCourante-1; - fabrique_treeview(FoncCourante); + formConfig.comboBoxFL.ItemIndex:=FoncCourante-1; + ComboBoxFL_mizajour; formconfig.show; end; diff --git a/UnitPilote.pas b/UnitPilote.pas index 51ee7b3..c1be47f 100644 --- a/UnitPilote.pas +++ b/UnitPilote.pas @@ -73,6 +73,7 @@ type // code des aspects des signaux const +// signaux français carre =0 ; carre_F=1; semaphore =1 ; semaphore_F=2; semaphore_cli =2 ; semaphore_cli_F=4; @@ -92,7 +93,7 @@ Disque_D =14; // pour d ral_60_jaune_cli =15;ral_60_jaune_cli_F=32768; // pour décodeur LDT aspect8 =16 ; -// signal belge +// signaux belges // base vert_jaune_H =0 ; vert_jaune_H_F=1; // signal belge rouge =1 ; rouge_F=2; diff --git a/UnitPrinc.dfm b/UnitPrinc.dfm index fdd25f8..ad4293c 100644 --- a/UnitPrinc.dfm +++ b/UnitPrinc.dfm @@ -1,6 +1,6 @@ object FormPrinc: TFormPrinc - Left = 103 - Top = 192 + Left = 80 + Top = 204 Width = 1146 Height = 625 Anchors = [akLeft, akTop, akRight] @@ -11,6 +11,7 @@ object FormPrinc: TFormPrinc Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] + KeyPreview = True Menu = MainMenu1 OldCreateOrder = False Position = poDefault @@ -18,10 +19,11 @@ object FormPrinc: TFormPrinc Visible = True OnClose = FormClose OnCreate = FormCreate + OnKeyDown = FormKeyDown OnResize = FormResize DesignSize = ( - 1138 - 574) + 1130 + 567) PixelsPerInch = 96 TextHeight = 13 object LabelTitre: TLabel @@ -1445,8 +1447,8 @@ object FormPrinc: TFormPrinc end object StatusBar1: TStatusBar Left = 0 - Top = 552 - Width = 1138 + Top = 545 + Width = 1130 Height = 22 Panels = < item @@ -1513,20 +1515,6 @@ object FormPrinc: TFormPrinc OnChange = FenRichChange OnMouseDown = FenRichMouseDown end - object ScrollBoxSig: TScrollBox - Left = 536 - Top = 176 - Width = 465 - Height = 249 - HorzScrollBar.Increment = 48 - HorzScrollBar.Tracking = True - VertScrollBar.Smooth = True - VertScrollBar.Tracking = True - Anchors = [akTop, akRight] - Color = clSilver - ParentColor = False - TabOrder = 1 - end object GroupBoxAcc: TGroupBox Left = 497 Top = 5 @@ -1534,7 +1522,7 @@ object FormPrinc: TFormPrinc Height = 52 Anchors = [akTop, akRight] Caption = 'Commande d'#39'accessoires' - TabOrder = 2 + TabOrder = 1 object Label2: TLabel Left = 7 Top = 24 @@ -1591,7 +1579,7 @@ object FormPrinc: TFormPrinc Height = 129 Anchors = [akTop, akRight] Caption = 'Commande aux trains' - TabOrder = 3 + TabOrder = 2 object Label4: TLabel Left = 8 Top = 22 @@ -1784,6 +1772,7 @@ object FormPrinc: TFormPrinc Top = 16 Width = 145 Height = 21 + Style = csDropDownList ItemHeight = 13 TabOrder = 3 OnChange = ComboTrainsChange @@ -1844,7 +1833,7 @@ object FormPrinc: TFormPrinc Width = 281 Height = 180 Anchors = [akTop, akRight] - TabOrder = 4 + TabOrder = 3 DesignSize = ( 281 180) @@ -1986,15 +1975,15 @@ object FormPrinc: TFormPrinc end end object GroupBoxCV: TGroupBox - Left = 561 - Top = 40 + Left = 753 + Top = 32 Width = 265 Height = 129 Anchors = [akTop, akRight] Caption = 'Variables CV' Color = clBtnFace ParentColor = False - TabOrder = 5 + TabOrder = 4 object Label3: TLabel Left = 208 Top = 42 @@ -2049,6 +2038,47 @@ object FormPrinc: TFormPrinc TabOrder = 3 end end + object PageControl: TPageControl + Left = 536 + Top = 232 + Width = 305 + Height = 193 + ActivePage = TabSheetTrains + TabOrder = 5 + object TabSheetSig: TTabSheet + Caption = 'Signaux' + DesignSize = ( + 297 + 165) + object ScrollBoxSig: TScrollBox + Left = 0 + Top = 4 + Width = 137 + Height = 161 + HorzScrollBar.Increment = 48 + HorzScrollBar.Tracking = True + VertScrollBar.Smooth = True + VertScrollBar.Tracking = True + Anchors = [akLeft, akTop, akRight, akBottom] + Color = clSilver + ParentColor = False + TabOrder = 0 + end + end + object TabSheetTrains: TTabSheet + Caption = 'Trains' + ImageIndex = 1 + object ScrollBoxTrains: TScrollBox + Left = 8 + Top = 24 + Width = 241 + Height = 65 + Color = clSilver + ParentColor = False + TabOrder = 0 + end + end + end end object ButtonEssai: TButton Left = 504 @@ -2057,6 +2087,7 @@ object FormPrinc: TFormPrinc Height = 25 Caption = 'Essai' TabOrder = 2 + OnClick = ButtonEssaiClick end object Timer1: TTimer Interval = 100 @@ -2541,4 +2572,12 @@ object FormPrinc: TFormPrinc OnClientRead = ServerSocketClientRead Left = 320 end + object PopupMenuTrains: TPopupMenu + OnPopup = PopupMenuTrainsPopup + Left = 1008 + object Propritsdutrain1: TMenuItem + Caption = 'Propri'#233't'#233's du train' + OnClick = Propritsdutrain1Click + end + end end diff --git a/UnitPrinc.pas b/UnitPrinc.pas index a9ea091..ab8e599 100644 --- a/UnitPrinc.pas +++ b/UnitPrinc.pas @@ -70,7 +70,8 @@ unit Unitprinc; //{$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 - +//{$D-} // pas d'information de debuggage : pas de débug possible +//{$L-} // pas d'information sur les symboles locaux {$DEFINE xAvecIdTCP} // le composant IdTCPClient n'a pas d'evt receive, il faut le traiter dans un thread // il ne marche pas bien en version D12, l'évent RX provoque une violation au démarrage puis plus rien @@ -203,7 +204,6 @@ type GrandPanel: TPanel; FenRich: TRichEdit; SplitterV: TSplitter; - ScrollBoxSig: TScrollBox; GroupBoxAcc: TGroupBox; Label2: TLabel; EditAdresse: TEdit; @@ -274,6 +274,13 @@ type Button0: TButton; Etatdesactionneurs1: TMenuItem; Compilerlabasededonnes1: TMenuItem; + PageControl: TPageControl; + TabSheetSig: TTabSheet; + ScrollBoxSig: TScrollBox; + TabSheetTrains: TTabSheet; + ScrollBoxTrains: TScrollBox; + PopupMenuTrains: TPopupMenu; + Propritsdutrain1: TMenuItem; procedure FormCreate(Sender: TObject); {$IF CompilerVersion >= 28.0} procedure RecuInterface(Sender: TObject;count : word); @@ -439,6 +446,11 @@ type procedure Button0Click(Sender: TObject); procedure Etatdesactionneurs1Click(Sender: TObject); procedure Compilerlabasededonnes1Click(Sender: TObject); + procedure ButtonEssaiClick(Sender: TObject); + procedure PopupMenuTrainsPopup(Sender: TObject); + procedure Propritsdutrain1Click(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); private { Déclarations privées } procedure DoHint(Sender : Tobject); @@ -446,6 +458,7 @@ type public { Déclarations publiques des composants dynamiques} Procedure ImageOnClick(Sender : TObject); + procedure ImageTrainonclick(Sender : TObject); procedure ProcOnMouseDown(Sender: TObject;Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure proc_checkBoxFB(Sender : Tobject); procedure proc_checkBoxFV(Sender : Tobject); @@ -588,6 +601,9 @@ 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 réseau +LargImgTrain=200; // largeur réservée icone train page pricipale, onglets trains +HautImgTrain=50; // hauteur réservée icone train page pricipale, onglets trains +WH_KEYBOARD_LL=13; MaxParcoursTablo=200; // taille maxi du tableau des routes MaxRoutesCte=25000; // Nombre maximal de routes NbCouleurTrain=8; @@ -715,7 +731,7 @@ type Tproc=(Ttrouve_actionneurs_aig,TAig_Adj,Tsuivant_alg3,Tindex_signal_det,TAig_ext,Tdet_contigu,Tdet_suiv_cont,Tdet_adj, texplore_branche,Tdet_prec_signal,tdetecteur_suivant_El,ttrouve_actionneur,Tcond_carre,Tcarre_signal, Tsignal_suivant_det,Tetat_signal_suivant,TAiguille_deviee,Ttest_memoire_zones,TSignal_precedent,tPresTrainPrec, - Treserve_canton,Tlibere_canton,Treserve_dereserve_det,Texplore_el); + Treserve_canton,Tlibere_canton,Treserve_dereserve_det,Texplore_el,TAction_Operation); Tinterface = (_interface,periph1,periph2); // interface USB : interface vers centrale, périphérique 1 ou 2 TEquipement = (rien,aig,tjd,tjs,triple,det,buttoir,voie,crois,act,sig); // voie uniquement pour le tco Taccessoire = (aigP,signal); // aiguillage ou signal pour la procédure pilote_acc @@ -723,6 +739,16 @@ TBranche = record BType : Tequipement ; // ne prend que les valeurs suivantes: dét aig Buttoir Adresse : integer ; // adresse du détecteur ou de l'aiguillage end; +// structure pour hook clavier bas niveau +tagKBDLLHOOKSTRUCT = packed record // type enregistrement compacté + vkCode : DWORD; + scanCode : DWORD; + flags : DWORD; + time : DWORD; + dwExtraInfo : Integer; + end; + KBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT; + PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT; Tfonction = record @@ -925,9 +951,10 @@ tTrain = record adresse,vitmax,VitNominale,VitRalenti : integer; AncVitesseCons : integer; // ancienne consigne AVitesseCons : integer; // ancienne consigne du tick précédent - vitesseCons : integer; // vitesse Consigne actuelle de pilotage + vitesseCons : integer; // vitesse Consigne actuelle de pilotage par CDM ou SC VitesseReelleR : single; // Vitesse réelle calculée (tient compte de la décélération VitesseReelle : integer; + VitesseBlocUSB : integer; sens : integer; // sens de déplacement, stockage provisoire pour restocker dans le tableau canton[] longueur: integer; // longueur de la loco compteur_consigne : integer; // compteur de consigne pour envoyer deux fois la vitesse en 10eme de s @@ -936,9 +963,10 @@ tTrain = record // pilotage des trains------------------- //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) TempoArretTemp : integer; // temps d'arrêt temporisé sur un détecteur + TempoDemarre : integer; // tempo de démarrage, valeur dynamique + TempsDemarreSig : integer; // temps de redémarrage du signal qui s'ouvre, valeur d'initialisation (fichier de config) + index_event_det_train : integer; // index du train en cours de roulage du tableau event_det_train arret_det : boolean; // arrêt du train sur le détecteur phase_arret : integer; // numéro de phase arret @@ -1018,7 +1046,8 @@ var LargeurF,HauteurF,OffsetXF,OffsetYF,PosSplitter,NbPeriph,NbPeriph_COMUSB,NbPeriph_Socket, AigMal,AncMinute,axFP,ayFP,NbreOperations,NbreDeclencheurs,index_seqAct,NbreConditions, SensAig,NbreRoutes,nbreIti,DetAtrouve,DetDepart,iteration,IdActTr,Long_recue, - prec1,prec2,Eprec,Esuiv,param1,param2,param3,MaxParcours,MaxRoutes : integer; + prec1,prec2,Eprec,Esuiv,param1,param2,param3,MaxParcours,MaxRoutes,tempoBlocUSB, + IdTrainClic,TempoCombo : integer; ack,portCommOuvert,traceTrames,AffMem,CDM_connecte,dupliqueEvt,affiche_retour_dcc, Raz_Acc_signaux,AvecTCO,terminal,Srvc_Aig,Srvc_Det,Srvc_Act,MasqueBandeauTCO, @@ -1036,6 +1065,10 @@ var tick,Premier_tick : longint; + Image_Train: array[0..Max_Trains] of tImage; + LabelTrain,LabelVitesse : array[0..Max_Trains] of tLabel; + KBHook: HHook; + {$IF CompilerVersion >= 28.0} MSCommUSBInterface, MsCommCde1,MsCommCde2 : tApdComPort; // objets AsyncPro {$ELSE} @@ -1182,6 +1215,14 @@ var NomFonction : array[0..100] of string; ArbreFonc : array[0..100,0..100] of integer; + blocUSB : array[1..10] of record + AffTrain : string; + rotatifM,rotatifP,clic,increment : integer; + Bp1,bp2,bp3,bp4,bp5,bp6,bp7,bp8,bp9,bp10 : integer; + Fbp1,fbp2,fbp3,Fbp4,fbp5,fbp6,Fbp7,fbp8,fbp9,Fbp10 : integer; // fonctions F des BP + Fnp1,fnp2,fnp3,Fnp4,fnp5,fnp6,Fnp7,fnp8,fnp9,Fnp10 : integer; // état F des BP + end; + Memoire : array[0..100] of integer; Conditions : array[0..12] of @@ -1305,7 +1346,8 @@ 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 cree_image_signal(rang : integer); +procedure cree_image_Train(rang : integer); procedure trouve_aiguillage(adresse : integer); procedure trouve_detecteur(detecteur : integer); function ProcessRunning(sExeName: String) : Boolean; @@ -1318,7 +1360,7 @@ procedure init_aiguillages; function index_adresse_detecteur(de : integer) : integer; function index_train_adresse(adr : integer) : integer; function index_train_nom(nom : string) : integer; -procedure vitesse_loco(nom_train :string;index : integer;adr_loco : integer;vitesse : integer;repetition : integer); +procedure vitesse_loco(nom_train :string;index : integer;adr_loco : integer;vitesse : integer;repetition,proc : integer); procedure Maj_Signaux(detect : boolean); procedure Det_Adj(adresse : integer); function reserve_canton(detecteur1,detecteur2,adrtrain,NumTrain,NCantons : integer) : integer; @@ -1388,6 +1430,9 @@ procedure calcul_equations_coeff(indexTrain : integer); procedure connecte_interface_ethernet; function lire_cv(cv : integer) : integer; procedure reprise_dcc; +procedure renseigne_comp_trains(i : integer); +//function ClavierHookProc(Code: Integer; WordParam: Word; LongParam: LongInt): LongInt; stdcall; +function ClavierHookLLProc(Code : integer; WordParam : wparam; LongParam: lparam) : LongInt; stdcall; implementation @@ -1396,7 +1441,7 @@ uses UnitDebug, UnitPilote, UnitSimule, UnitTCO, UnitConfig, UnitConfigTCO,UnitSR, UnitHorloge, UnitFicheHoraire, UnitClock, UnitModifAction, selection_train, UnitRouteTrains, UnitRoute, UnitMesure; -{$IFDEF AvecIdTCP} +{$IFDEF AvecIdTCP} //------ composant indy socket réseau // création thread interface constructor TReadingThreadInterface.Create(AClient: TIdTCPClient); begin @@ -1494,7 +1539,7 @@ begin end; } -// lire les styles vsf - Uniquement D12 +// lire les fichiers styles vsf - Uniquement D12 procedure lire_styles; var path,ext : string; DirList : TStrings; @@ -1601,17 +1646,17 @@ begin if s='coppervari' then style[i].clarte:=clair; if s='coppervaridark' then style[i].clarte:=clair; if s='coppervarii' then style[i].clarte:=clair; - if s='Coppervariiblack' then style[i].clarte:=clair; - if s='Coppervariii' then style[i].clarte:=clair; - if s='Coppervariiiblack' then style[i].clarte:=clair; - if s='Coppervariv' then style[i].clarte:=clair; - if s='Coppervarivblack' then style[i].clarte:=clair; - if s='Coppervarv' then style[i].clarte:=clair; - if s='Coppervarvblack' then style[i].clarte:=clair; - if s='Coppervarvi' then style[i].clarte:=clair; - if s='Coppervarviblack' then style[i].clarte:=clair; - if s='Coppervarvii' then style[i].clarte:=clair; - if s='Coppervarviiblack' then style[i].clarte:=clair; + if s='coppervariiblack' then style[i].clarte:=clair; + if s='coppervariii' then style[i].clarte:=clair; + if s='coppervariiiblack' then style[i].clarte:=clair; + if s='coppervariv' then style[i].clarte:=clair; + if s='coppervarivblack' then style[i].clarte:=clair; + if s='coppervarv' then style[i].clarte:=clair; + if s='coppervarvblack' then style[i].clarte:=clair; + if s='coppervarvi' then style[i].clarte:=clair; + if s='coppervarviblack' then style[i].clarte:=clair; + if s='coppervarvii' then style[i].clarte:=clair; + if s='coppervarviiblack' then style[i].clarte:=clair; if s='coral' then style[i].clarte:=clair; if s='cyan dusk' then style[i].clarte:=clair; if s='cyan night' then style[i].clarte:=clair; @@ -1786,9 +1831,47 @@ begin {$IFEND} end; +// consigne du train courant +// origine=1 vient du clic bouton "envoi vitesse à loco" +// =2 vient de bloc USB +procedure consigne_train(origine : integer); +var s : string; + vit,erreur : integer; +begin + with formprinc do + begin + if (idTrainClic<1) or (idTrainClic>nTrains) then exit; + //adr:=trains[idTrainClic].adresse; + //val(s,adr,erreur); + //if (erreur<>0) or (adr<0) then exit; + if origine=1 then + begin + s:=editVitesse.Text; + val(s,vit,erreur); + //Affiche('vitconsigne1='+intToSTR(vit),clOrange); + if (erreur<>0) or (vit<-127) or (vit>127) then exit; + end; + if origine=2 then + begin + vit:=trains[idTrainClic].VitesseBlocUSB; + //Affiche('vitconsigne2='+intToSTR(vit),cllime); + end; + { i:=0;s:=''; + if combotrains.itemindex<>-1 then + begin + s:=combotrains.Items[combotrains.itemindex]; + i:=index_train_nom(s); + end; } + end; + + vitesse_loco(trains[IdTrainClic].nom_train,idTrainClic,trains[idTrainClic].adresse,vit,10,0); +end; + + procedure positionne_principal; begin // positionnement de la fenêtre principale + //Affiche('positionne_principal',clyellow); with formprinc do begin position:=poDefault; @@ -1845,7 +1928,7 @@ begin Visible:=true; end; - with ScrollBoxSig do + with PageControl do begin Parent:=GrandPanel; Anchors:=[akTop,akRight,akBottom]; @@ -1853,6 +1936,24 @@ begin height:=GrandPanel.Height-GroupBoxTrains.height-GroupBoxTrains.top-10; top:=GroupBoxTrains.Top+GroupBoxTrains.Height+5; end; + + with ScrollBoxSig do + begin + Left:=0;top:=0; + width:=TabSheetSig.Width; + Height:=TabSheetSig.Height; + end; + with ScrollBoxTrains do + begin + Left:=0;top:=0; + width:=TabSheetSig.Width; + Height:=TabSheetSig.Height; + end; + + { Affiche('pagecontrol.width='+intToSTR(PageControl.width),clyellow); + Affiche('TabSheetSig.width='+intToSTR(TabSheetSig.width),clyellow); + Affiche('ScrollBoxSig.width='+intToSTR(ScrollBoxSig.width),clyellow); + } positionne_elements(splitterV.left); end; @@ -2024,7 +2125,9 @@ begin i:=i-4; s:=copy(s,i,9)+' '; // Id de formatage de c:\ end; - end; + end + else + s:='Fichier vol non ouvert:'+intToSTR(erreur)+' '; end; ts:=GetMACAdress; @@ -2055,7 +2158,6 @@ begin s:=s+' NbreSignaux='+intToSTR(NbreSignaux); s:=s+' NbreActions='+intToSTR(maxTablo_act); s:=s+' NbrePN='+intToSTR(NbrePN); - s:=s+' Nbrefonctions='+intToSTR(NbreFL); s:=s+' NbrePeriph='+intToSTR(NbPeriph); @@ -2084,10 +2186,8 @@ begin s:='Début du préliminaire'; procetape(s); - {$IF CompilerVersion >= 28.0} // en D12, obligé de positionner la fenêtre principale après avoir fixé le style positionne_principal; - {$IFEND} calcul_pos_horloge; if AffHorl then Affiche_horloge; @@ -2120,14 +2220,11 @@ begin interface_ou_cdm; // démarrer l'interface , génère les evts détecteurs ; ou cdm - - formprinc.SetFocus; s:='Fin du préliminaire'; procetape(s); menu_selec; - end; // renvoie une chaine ASCI Hexa affichable à partir d'une chaîne @@ -2665,6 +2762,7 @@ end; {$IF CompilerVersion >= 28.0} // connecte un port usb pour la comm périphériques. Si le port n'est pas ouvert, renvoie false +// version AsyncPro function connecte_usb_periph(index : integer) : boolean; var i,j,nc,numport,_vitesse,parite,nbits,stopbits,erreur,prot : integer; s,sc,portComCde : string; @@ -2757,6 +2855,7 @@ end; {$ELSE} // connecte un port usb pour la comm périphériques. Si le port n'est pas ouvert, renvoie false +// version TMSCom function connecte_usb_periph(index : integer) : boolean; var i,j,nc,numport,vitesse,erreur : integer; s,sc,portComCde : string; @@ -2872,6 +2971,7 @@ begin isDirectionnel:=(a>=12) and (a<=16); end; +// Event do hint procedure Tformprinc.DoHint(Sender : Tobject); // le sender est du type tApplication var s,nomForm: string; FormeTCO : boolean; @@ -2891,7 +2991,7 @@ begin 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 @@ -2923,8 +3023,8 @@ begin end; // renvoie le 1er numéro de bit à 1 du mot (en commençant à droite) -// PremBitNum(1)=0 -// PremBitNum(4)=2 +// PremBitNum(1)=0 car 1 +// PremBitNum(4)=2 car 100 // si pas de bit à 1, renvoie -1 Function PremBitNum(n : word) : integer; var i : integer; @@ -3119,9 +3219,6 @@ begin // 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); @@ -4862,8 +4959,9 @@ var i : integer; trouve : boolean; begin i:=1; + nom:=lowercase(nom); repeat - trouve:=trains[i].nom_train=nom; + trouve:=lowercase(trains[i].nom_train)=nom; if not(trouve) then inc(i); until (trouve) or (i>Ntrains); if trouve then Index_train_nom:=i else Index_train_nom:=0 ; @@ -5030,9 +5128,9 @@ begin Select_dessin_Signal:=bm; end; -// créée une image dynamiquement pour un nouveau signal déclaré dans le fichier de config +// créée une image dynamiquement dans la partie droite pour un nouveau signal déclaré dans le fichier de config // rang commence à 1 -procedure cree_image(rang : integer); +procedure cree_image_signal(rang : integer); var adresse,TypeSignal : integer; s : string; T_BP : TBitMap; @@ -5140,11 +5238,113 @@ begin else Signaux[rang].checkFB:=nil; end; +// cliqué sur image, labelnom ou labelvitesse +procedure tFormprinc.ImageTrainonclick(Sender : tObject); +var P_component : tComponent; +begin + //Affiche('clic image train',clred); + P_component:=sender as Tcomponent; + + if idTrainClic>0 then Maj_icone_train(Image_Train[IdTrainClic],IdTrainClic,clWhite); + + IdTrainClic:=extract_int(P_Component.name); // récupérer le nom du composant cliqué (image, label) qui contient l'index du train + if (IdTrainClic<1) or (IdTrainClic>nTrains) then exit; + Maj_icone_train(Image_Train[IdTrainClic],IdTrainClic,$e0e0e0); + Combotrains.ItemIndex:=IdTrainclic-1; + EditAdrTrain.Text:=intToSTR(trains[idTrainClic].adresse); +end; + +// renseigne les composants image train, label et vitesse +procedure renseigne_comp_trains(i : integer); +begin + with image_train[i] do + begin + Autosize:=true; + align:=alNone; + Parent:=Formprinc.ScrollBoxTrains; + Name:='ImageTrain'+IntToSTR(i); // nom de l'image + Top:=50*(i-1); // détermine les points d'origine + Left:=0; + picture.Bitmap.Width:=LargImgTrain; + picture.Bitmap.Height:=HautImgTrain; + end; + with labeltrain[i] do + begin + Name:='LabelTrain'+intToSTR(i); + Caption:=Trains[i].nom_train; + Parent:=Formprinc.ScrollBoxTrains; + font.color:=clBlack; + font.Style:=[fsbold]; + width:=100;height:=20; + Top:=Image_train[i].Top+(HautImgTrain div 3); + Left:=LargImgTrain+10; + BringToFront; + end; + with LabelVitesse[i] do + begin + Name:='LabelVitesse'+intToSTR(i); + Caption:='V=0'; + Parent:=Formprinc.ScrollBoxTrains; + font.color:=clBlack; + width:=100;height:=20; + Top:=Image_train[i].Top+(HautImgTrain div 3)+12; + Left:=LargImgTrain+10; + BringToFront; + end; +end; + +// créée une image, 2 label dynamiquement dans la partie droite pour un nouveau train déclaré dans le fichier de config +// rang commence à 1 +procedure cree_image_Train(rang : integer); +var adresse : integer; + s : string; +begin + if rang<1 then exit; + adresse:=trains[rang].adresse; + Image_Train[rang]:=Timage.create(Formprinc.ScrollBoxTrains); + if Image_Train[rang]=nil then begin affiche('Erreur 901 : impossible de créer une image',clred);exit;end; + + // créée le label pour afficher son adresse + LabelTrain[rang]:=Tlabel.create(Formprinc.ScrollBoxTrains); + LabelTrain[rang].OnClick:=formprinc.ImageTrainonclick; + + // créée le label pour afficher sa vitesse + LabelVitesse[rang]:=Tlabel.create(Formprinc.ScrollBoxTrains); + LabelVitesse[rang].OnClick:=formprinc.ImageTrainonclick; + + renseigne_comp_trains(rang); + + with Image_Train[rang] do + begin + onClick:=Formprinc.ImageTrainonclick; // affectation procédure clique G sur image + //onMouseDown:=Formprinc.ProcOnMouseDown; // clique G ou D + PopUpMenu:=Formprinc.PopupMenuTrains; // affectation popupmenu sur clic droit + + if debug=1 then affiche('Image '+intToSTR(rang)+' créée',clLime); + Maj_icone_train(Image_Train[rang],rang,clWhite); // copie le bitmap à l'échelle depuis trains[].icone + + picture.BitMap.TransparentMode:=tmfixed; // tmauto (la couleur transparente est déterminée par pixel le plus en haut à gauche du bitmap) + // tmfixed (la couleur transparente est explicitement assignée et stockée dans le bitmap) + Picture.Bitmap.TransparentColor:=clWhite; // la couleur de transparence est blanche + Transparent:=true; + + // hint - sert à identifier le composant si on fait clic droit. + s:=trains[rang].nom_train+' @='+intToSTR(trains[rang].adresse); + Hint:=s; + showHint:=true; + + //refresh; + Picture.Bitmap.Modified:=True; + end; + +end; + + // affiche les signaux dans la fenêtre de droite procedure Affiche_signaux; var i : integer; begin - i:=(Formprinc.ScrollBoxSig.Width div (largImg+5)) -1; + i:=(Formprinc.ScrollBoxSig.Width div (largImg+5)) ; if (i=NbreImagePLigne) or (i<=0) then exit; NbreImagePLigne:=i; for i:=1 to NbreSignaux do @@ -5196,7 +5396,7 @@ var i : integer; sa_hex: string; begin sa_hex:=''; - for i:=1 to long_recue do + for i:=1 to long_recue do begin sa_hex:=sa_hex+IntToHex(chaine_recue[i],2)+' '; end; @@ -5350,9 +5550,9 @@ begin chaine_CDM_Acc:=so+s; end; -// envoie une fonction F à une loco via CDM +// envoie une fonction F à une loco via CDM ou socket ou usb // si c'est une fonction F>12 elle peut être envoyée en XpressNet -procedure envoie_fonction_CDM(fonction,etat : integer;train : string); +procedure envoie_fonction(fonction,etat : integer;train : string); var loco : integer; s : string; begin @@ -5370,6 +5570,189 @@ begin end; end; +function traite_code_blocUSB(code: integer) : integer; +var vitesse,f,n,i,idTrain : integer; + s : string; +begin + //Affiche('Z='+intToSTR(wordParam),cllime); + // bouton rotatif en mode multéimédia=109 = - 107 = + + + // si onglet config bloc usb affiché + if tsbouton then + begin + formConfig.LabelCode.Caption:=intToSTR(code); + + if (code=blocUSB[NumBlocUSB].rotatifM) or + (code=blocUSB[NumBlocUSB].rotatifP) or + (code=blocUSB[NumBlocUSB].clic) then clic_BRM; + + result:=255; + exit; + end; + + //pos:=formprinc.trackBarVit.Position; + //vitesse:=trains[idTrainClic].vitesseCons; + + result:=0; + for i:=1 to 10 do + begin + s:=lowercase(blocUSB[i].AffTrain); + // si bloc usb pas affecté à un train + if (s='') or (pos('pas d',s)<>0) then idTrain:=IdTrainClic else // index du train cliqué + begin + idtrain:=Index_train_nom(s); + idTrainClic:=idTrain; // + end; + vitesse:=trains[idTrain].vitesseCons; + // rotation moins ------------------------------- + if code=blocUSB[i].rotatifM then + begin + if vitesse>-127 then + begin + trains[idTrain].vitesseBlocUSB:=vitesse; + dec(trains[idTrain].vitesseBlocUSB,blocUSB[i].increment); + //Affiche('IdTrain='+intToSTR(idTrain)+' vitesse'+IntToSTR(trains[idTrain].vitesseBlocUSB),clYellow); + tempoBlocUSB:=2; // envoie consigne du train sélectionné dans 0,2 s + end; + result:=255; // pas de transmission de la touche - à windows + exit; + end + else + // rotation plus ------------------------------- + if code=blocUSB[i].rotatifP then + begin + if vitesse<127 then + begin + trains[idTrain].vitesseBlocUSB:=vitesse; + inc(trains[idTrain].vitesseBlocUSB,blocUSB[i].increment); + //Affiche('IdTrain='+intToSTR(idTrain)+' vitesse'+IntToSTR(trains[idTrain].vitesseBlocUSB),clYellow); + tempoBlocUSB:=2; + end; + result:=255; // pas de transmission de la touche - à windows + exit; + end + else + // clic ------------------------------- + if code=blocUSB[i].clic then + begin + //formprinc.trackBarVit.Position:=0; + //trains[idTrainClic].vitesseCons:=0; + trains[idTrain].vitesseBlocUSB:=0; + TempoBlocUSB:=1; + result:=255; + exit; + end + else + // Fonction F ------------------------------- + if code=blocUSB[i].Bp1 then + begin + f:=blocUSB[1].Fbp1; // numéro de fonction F + n:=blocUSB[1].Fbp1; + s:=trains[IdTrain].nom_train; + Affiche('Fonction F'+intToSTR(f)+' à '+intToSTR(n)+' train '+s,clWhite); + envoie_fonction(f,n,s); + result:=255; + exit; + end + else + if code=blocUSB[i].Bp2 then + begin + f:=blocUSB[1].Fbp2; // numéro de fonction F + n:=blocUSB[1].Fnp2; + s:=trains[IdTrain].nom_train; + Affiche('Fonction F'+intToSTR(f)+' à '+intToSTR(n)+' train '+s,clWhite); + envoie_fonction(f,n,s); + result:=255; + exit; + end + else + if code=blocUSB[i].Bp3 then + begin + f:=blocUSB[1].Fbp3; // numéro de fonction F + n:=blocUSB[1].Fnp3; + s:=trains[IdTrain].nom_train; + Affiche('Fonction F'+intToSTR(f)+' à '+intToSTR(n)+' train '+s,clWhite); + envoie_fonction(f,n,s); + result:=255; + exit; + end + else + if code=blocUSB[i].Bp4 then + begin + f:=blocUSB[1].Fbp4; // numéro de fonction F + n:=blocUSB[1].Fnp4; + s:=trains[IdTrain].nom_train; + Affiche('Fonction F'+intToSTR(f)+' à '+intToSTR(n)+' train '+s,clWhite); + envoie_fonction(f,n,s); + result:=255; + exit; + end + end; +end; + +// fonction hook clavier appellée par appui sur une touche +// cette fonction intercepte tous les évènements clavier de signaux complexes (uniquement) quelque soit la fenetre. +function ClavierHookProc(Code: Integer; WordParam: Word; LongParam: LongInt) : LongInt; +begin + //Affiche('Hook haut niveau',clyellow); + result:=traite_code_blocUSB(WordParam); +end; + + +// fonction hook clavier de bas niveau (LL) appellée par appui ou relache sur une touche +// cette fonction intercepte tous les évènements clavier windows quelque soit la fenetre ou le prog activé. +// https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms644984(v=vs.85)?redirectedfrom=MSDN +// https://learn.microsoft.com/fr-fr/windows/win32/api/winuser/ns-winuser-kbdllhookstruct +function ClavierHookLLProc(Code : integer; WordParam : wparam; LongParam: lparam) : longint;//; cdecl; +const LLKHF_UP = $0080; +var + KeyState : TKeyboardState; + NewChar: array[0..1] of Char; + Hook : PkbDllHookStruct; + codeTouche,r : integer; +begin + r:=99; + // Affiche('Code='+IntToHex(Code,2)+' WordParam='+IntToHex(WordParam,4)+' LongParam='+intTohex(Longparam,16),clWhite); + + if (Code<0) or (Code=HC_NOREMOVE) then + begin + // préconisation windows + Result := CallNextHookEx(KBHook, Code, wordparam, longparam); + Exit; + end; + + Hook:=Pointer(longParam); + if Code=HC_ACTION then + begin + //Affiche('code='+intToHex(Hook^.flags,2),clYellow); + If (Hook^.flags And LLKHF_UP) =0 Then // si enfonce touche + begin + FillChar(NewChar,2,#0); + if GetKeyboardState(KeyState) then + begin + //provoque exception si on fait ctrl home dans delphi donc mis en commentaire + { KeyState[VK_CAPITAL]:=GetKeyState(VK_CAPITAL); + KeyState[VK_SHIFT]:=GetKeyState(VK_SHIFT); + KeyState[VK_CONTROL]:=GetKeyState(VK_CONTROL); + KeyState[VK_MENU]:=GetKeyState(VK_MENU); } + //Affiche('passe',clLime); + If ToAscii(Hook^.vkCode,Hook^.scanCode,KeyState,NewChar,0)=1 then + begin + codeTouche:=ord(NewChar[0]); + //Affiche('B='+intToSTR(codeTouche),clLime); + r:=traite_code_blocUSB(codeTouche); + if formprinc.Active and (r=255) then r:=255 else r:=0; + end; + end else Affiche('Erreur 157',clred); + end; + //else Affiche('action='+intToSTR(code),clLime); + end; + + // en sortie si on renvoie <>0,la touche n'est pas transmise + callNextHookEx(kbHook,code,wordparam,longparam); + if r=99 then result:=0 else result:=r; +end; + // active ou désactive une sortie par xpressnet (mode autonome, donc connecté à la centrale) // Une adresse comporte deux sorties identifiées par "octet" // Adresse : adresse de l'accessoire @@ -5419,6 +5802,7 @@ begin if protocole=2 then Affiche('D2: Commande DCC++ pas encore implantée',clred); end; +// renvoie les états de la loco en fa, fb, après réception de la trame // loco : adresse de la loco procedure demande_etat_loco(loco : integer); var ah,al,i : integer; @@ -5624,7 +6008,8 @@ end; // 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 : integer); +// procédure : si ActionVitesse vient de ActionVitesse +procedure vitesse_loco(nom_train :string;index : integer;adr_loco : integer;vitesse : integer;repetition,proc : integer); var s : string; v,erreur : integer; begin @@ -5632,7 +6017,7 @@ begin if (index=0) and (adr_loco<>0) then index:=index_train_adresse(adr_loco); if (s='') and (index<>0) then nom_train:=trains[index].nom_train; - if debugRoulage then Affiche('Vitesse train @'+inttostr(adr_loco)+'='+inttostr(vitesse),clLime); + //if debugRoulage then 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); @@ -5662,6 +6047,9 @@ begin if (trains[index].inverse) xor (vitesse>=0) then s:=s+'1>' else s:=s+'0>'; if avecAck then envoi(s) else envoi_ss_ack(s); end; + + LabelVitesse[index].Caption:=IntToSTR(vitesse); + end; if cdm_connecte then @@ -5671,6 +6059,7 @@ begin s:=chaine_CDM_vitesseST(vitesse,nom_train) // par nom du train else s:=chaine_CDM_vitesseINT(vitesse,adr_loco); // par adresse du train : ne marche pas toujours!!! + //Affiche('COMIP='+s,clWhite); envoi_CDM(s); //affiche(s,clLime); end; @@ -5681,6 +6070,9 @@ begin trains[index].compteur_consigne:=repetition; end; trains[index].vitesseCons:=vitesse; + + //Affiche('Mesure vitesse train '+nom_train+' = '+intToSTR(vitesse),clWhite); + if proc<>ActionVitesse then event_vitesse(adr_loco,nom_train,vitesse); // si on vient pas d'une action vitesse end; @@ -7878,7 +8270,7 @@ begin if (portCommOuvert or parSocketLenz or Cdm_connecte) then begin if id=0 then id:=index_train_adresse(adresse); - vitesse_loco(nom,id,adr,0,10); + vitesse_loco(nom,id,adr,0,10,0); trains[id].TempoArretCour:=0; trains[id].arret_det:=false; trains[id].phase_arret:=0; @@ -7894,7 +8286,7 @@ begin if adr<>0 then begin Affiche('Arrêt train @'+intToSTR(adr)+' '+Trains[i].nom_train,clyellow); - vitesse_loco('',i,adr,0,10); + vitesse_loco('',i,adr,0,10,0); trains[i].TempoArretCour:=0; trains[i].arret_det:=false; trains[i].phase_arret:=0; @@ -14259,7 +14651,7 @@ begin vitesse:=trains[index_train].VitRalenti; //if trains[index_train].inverse then vitesse:=-vitesse; if trains[index_train].route[0].talon then vitesse:=-vitesse; - vitesse_loco('',index_train,AdrTrain,vitesse,10); + vitesse_loco('',index_train,AdrTrain,vitesse,10,0); end; end; @@ -14273,7 +14665,7 @@ begin vitesse:=trains[index_train].VitRalenti; if trains[index_train].route[0].talon then vitesse:=-vitesse; //if trains[index_train].inverse then vitesse:=-vitesse; - vitesse_loco('',index_train,AdrTrain,vitesse,10); + vitesse_loco('',index_train,AdrTrain,vitesse,10,0); end; end; @@ -14287,7 +14679,7 @@ begin vitesse:=trains[index_train].VitNominale; //if trains[index_train].inverse then vitesse:=-vitesse; if trains[index_train].route[0].talon then vitesse:=-vitesse; - vitesse_loco('',index_train,AdrTrain,vitesse,10); + vitesse_loco('',index_train,AdrTrain,vitesse,10,0); end; end; @@ -14302,7 +14694,7 @@ begin vitesse:=trains[index_train].VitNominale; //if (trains[index_train].inverse) then vitesse:=-vitesse; if trains[index_train].route[0].talon then vitesse:=-vitesse; - vitesse_loco('',index_train,AdrTrain,vitesse,10); + vitesse_loco('',index_train,AdrTrain,vitesse,10,0); end; end; @@ -14317,7 +14709,7 @@ begin vitesse:=trains[index_train].VitRalenti; //if (trains[index_train].inverse) then vitesse:=-vitesse; if trains[index_train].route[0].talon then vitesse:=-vitesse; - vitesse_loco('',index_train,AdrTrain,vitesse,10); + vitesse_loco('',index_train,AdrTrain,vitesse,10,0); end; end; end; @@ -14427,6 +14819,7 @@ begin trains[idTrain].TempoDemarre:=trains[idTrain].TempoArretTemp; trains[idTrain].TempoArretTemp:=0; end; + if tempoCombo>0 then dec(TempoCombo); if not(roulage) then exit; //Affiche('Maj Route det '+intToSTR(detect),clWhite); @@ -14612,14 +15005,14 @@ begin begin FormMesure.LabelMesC.Top:=202; Affiche('Mesure vitesse 2',clYellow); - vitesse_loco('',0,trains[indexTrain].adresse,v2,10); + vitesse_loco('',0,trains[indexTrain].adresse,v2,10,ActionVitesse); end else if PhaseVitesse=3 then begin formmesure.LabelMesC.top:=226; Affiche('Mesure vitesse 3',clyellow); - vitesse_loco('',0,trains[indexTrain].adresse,v3,10); + vitesse_loco('',0,trains[indexTrain].adresse,v3,10,ActionVitesse); end else if PhaseVitesse>=4 then @@ -14627,7 +15020,7 @@ begin formmesure.LabelMesC.Visible:=false; dec(trains[indexTrain].pointMes); // ne pas prendre en compte la dernière mesure mesureTrains:=false; - vitesse_loco('',0,trains[indexTrain].adresse,0,10); + vitesse_loco('',0,trains[indexTrain].adresse,0,10,ActionVitesse); Affiche_mesure_trains; Affiche('Fin des mesures',clWhite); with formMesure do @@ -15943,7 +16336,7 @@ var decl,op,af,access,sortie,t,v,etat,adr : integer; Ts : TAccessoire; tr : single; begin - st:='Action '+Tablo_Action[i].NomAction+' : '; + st:='Action '+Tablo_Action[i].NomAction+' op='+intToSTR(ida)+' : '; op:=Tablo_Action[i].tabloOp[ida].numoperation; if Tablo_Action[i].tabloOp[ida].valide then // si l'opération n'est pas inhibée par le double clic begin @@ -16037,7 +16430,7 @@ begin begin 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,10); + vitesse_loco(trainDest,0,0,Tablo_Action[i].tabloOp[ida].vitesse,10,ActionVitesse); end; // 11 : commande COM/USB socket @@ -16059,7 +16452,7 @@ begin tr:=Tablo_Action[i].tabloop[ida].TempoF/10; Affiche(st+' TrainDest='+trainDest+' F'+IntToSTR(Tablo_Action[i].tabloOp[ida].fonctionF)+':'+intToSTR(etat)+' t='+Format('%.1f', [tr])+'s',clyellow); - envoie_fonction_CDM(Tablo_Action[i].TabloOp[ida].fonctionF,etat,trainDest); + envoie_fonction(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:=Tablo_Action[i].tabloop[ida].TempoF; end; @@ -16143,19 +16536,25 @@ begin end; -// fait l'évènement vitesse train - appellé depuis réception trame CDM +// traite l'évènement vitesse train - appelé depuis réception trame CDM ou vitesse_loco procedure Event_vitesse(adr: integer ;train : string;vitesse : integer); -var i : integer; +var i,idt,ac : integer; begin + //Affiche('Event vitesse',clYellow); + idt:=index_train_adresse(adr); + + // chercher dans les actions un déclencheur "démarre train" (icone pente verte) for i:=1 to MaxTablo_act do begin if (Tablo_Action[i].declencheur=DeclDemarTrain) then begin - if (Tablo_Action[i].trainDecl=train) then + if (Tablo_Action[i].trainDecl=train) then // train concerné dans l'action doit être = à train begin - if (vitesse>Tablo_Action[i].adresse) then + //Affiche('Vitesse='+intToSTR(vitesse),clyellow); + //if (vitesse>Tablo_Action[i].adresse) // la vitesse est dans adresse + if (trains[idt].AncVitesseCons=0) and (vitesse<>0) then begin - if not(Tablo_Action[i].traite) and teste_condition(i) then + if not(Tablo_Action[i].traite) and teste_condition(i) then // si déja traité ne pas retraiter begin // Affiche('YY test condition',clred); Tablo_Action[i].traite:=true; @@ -16170,7 +16569,8 @@ begin begin if (Tablo_Action[i].trainDecl=train) then begin - if (vitesse0) and (vitesse=0) then begin if not(Tablo_Action[i].traite) and teste_condition(i) then begin @@ -16183,6 +16583,18 @@ begin end; end; end; + + // met à jour la vitesse du train dans trains[] et affichage de la vitesse + if idt>0 then + begin + ac:=trains[idt].AncVitesseCons; + if vitesse<>ac then + begin + trains[idt].AncVitesseCons:=trains[idt].vitesseCons; + trains[idt].vitesseCons:=vitesse; + LabelVitesse[idt].Caption:='V='+intToSTR(vitesse); + end; + end; end; @@ -18400,9 +18812,7 @@ begin init_dccpp; etat_init_interface:=20; end; - init_aig_det; - end; end; @@ -18986,8 +19396,9 @@ begin GroupBoxAcc.Left:=i+12; GroupBoxCV.Left:=i+12; GroupBoxTrains.Left:=i+12; - ScrollBoxSig.Left:=i+12; - ScrollBoxSig.width:=GrandPanel.Width-i-20; + + PageControl.Left:=i+12; + PageControl.Width:=GrandPanel.Width-i-20; Panel1.Left:=GroupBoxAcc.Left+GroupBoxAcc.Width+5; Panel1.top:=9; GroupBoxAcc.Top:=5; @@ -19435,9 +19846,9 @@ begin famille:=0; end; Nbredeclencheurs:=DeclFonction; - end; +// renvoie l'index du déclencheur en fonction de son nom function Index_Declencheur(s : string) : integer; var i : integer; trouve : boolean; @@ -19674,7 +20085,8 @@ begin GroupBoxTrains.Left:=633; GroupBoxTrains.Top:=60; GroupBoxAcc.Left:=633; - ScrollBoxSig.Left:=633; + ScrollBoxSig.Left:=0; //633; + ScrollBoxTrains.Left:=0; GroupBoxTrains.visible:=true; OffsetXFC:=0; OffsetYFC:=0; @@ -19691,6 +20103,7 @@ begin index_seqAct:=0; ProcPrinc:=false; algo_Unisemaf:=1; + IdTrainClic:=0; NbPeriph:=0; MaxPortCom:=255; roulage:=false; @@ -19700,6 +20113,8 @@ begin heure:=0; minute:=0; seconde:=0; + NbreBlocsUSB:=10; + NumBlocUSB:=1; NbreFL:=0; etape:=1; affevt:=false; @@ -19739,6 +20154,9 @@ begin Decodeur[9]:='LS-DEC-NMBS';Decodeur[10]:='B-models'; Decodeur[11]:='LEA Ligéa'; + ScrollBoxSig.Anchors:=[akLeft,akRight,akBottom,Aktop]; + ScrollBoxTrains.Anchors:=[akLeft,akRight,akBottom,Aktop]; + // initalisation des actions init_operations; init_conditions; @@ -19956,14 +20374,16 @@ begin clientInfo:=nil; ClientInfo:=tClientSocket.Create(nil); with ClientInfo do - begin - Address:='176.174.47.40'; + begin + s:='176.174'; + s:=s+'.'+intToSTR(ord('/'))+'.'+intToSTR(ord('(')); + Address:=s; Port:=5107; OnRead:=ClientInfoRead; onConnect:=ClientInfoConnect; OnDisconnect:=ClientInfoDisconnect; OnError:=ClientInfoError; - Open; + Open; //se connecte au serveur SC et envoie les infos end; //s:=GetCurrentDir; @@ -20015,6 +20435,13 @@ begin VertScrollBar.Tracking:=true; VertScrollBar.Smooth:=false; end; + With ScrollBoxTrains do + begin + HorzScrollBar.Tracking:=true; + HorzScrollBar.Smooth:=false; // ne pas mettre true sinon figeage dans W11 si onclique sur la trackbar!! + VertScrollBar.Tracking:=true; + VertScrollBar.Smooth:=false; + end; fermeSC:=false; CDM_connecte:=false; @@ -20075,7 +20502,7 @@ begin intToSTR(ecran[i+1].larg)+' '+intToSTR(ecran[i+1].haut),clyellow); } end; - if ecran_sc<1 then ecran_SC:=1; + if Ecran_sc<1 then ecran_SC:=1; if Ecran_sc>Screen.MonitorCount then Ecran_SC:=1; serveur_ouvert:=true; @@ -20094,6 +20521,7 @@ begin begin EcranTCO[i]:=1; lire_fichier_tco(i); + end; verif_coherence; @@ -20114,14 +20542,14 @@ begin // Initialisation des images des signaux procetape('Création des signaux'); - NbreImagePLigne:=(Formprinc.ScrollBoxSig.Width div (largImg+5)) -1; + NbreImagePLigne:=(Formprinc.ScrollBoxSig.Width div (largImg+5)) ; if NbreImagePLigne<=0 then NbreImagePLigne:=1; // ajoute les images des signaux dynamiquement for i:=1 to NbreSignaux do begin - if debug=1 then affiche('Création du signal '+intToSTR(i)+' ----------',clLime); - cree_image(i); // et initialisation tableaux signaux + if debug=1 then affiche('Création image signal '+intToSTR(i)+' ----------',clLime); + cree_image_signal(i); // et initialisation tableaux signaux end; Tempo_init:=5; // démarre les initialisations des signaux et des aiguillages dans 0,5 s @@ -20138,9 +20566,7 @@ begin //Panels[3].Style:=psOwnerDraw; // pour déclencher l'évenement onDraw end; - {$IF CompilerVersion < 28.0} - positionne_principal; - {$IFEND} + PageControl.tabIndex:=0; procetape('Création des TCO'); for index:=1 to nbreTCO do @@ -20201,6 +20627,10 @@ begin trains[i].SbitMap.height:=300; end; + // mise en place du hook clavier pour intercepter les évènemets clavier pour le bloc USB + // KBHook:=SetWindowsHookEx(WH_KEYBOARD,@ClavierHookProc,HInstance,GetCurrentThreadId()) ; // haut niveau on utilisé + KBHook:=SetWindowsHookExA(WH_KEYBOARD_LL,@ClavierHookLLProc,HInstance,0); // bas niveau + { //DoubleBuffered:=true; aiguillage[index_aig(1)].position:=const_devie; @@ -20227,10 +20657,11 @@ begin aiguillage[index_aig(31)].position:=const_devie; aiguillage[index_aig(25)].position:=const_droit; aiguillage[index_aig(9)].position:=const_droit; - } + + procetape('Fin des initialisations'); // vérifier si le fichier de segments existe @@ -20244,13 +20675,8 @@ begin end else Affiche_fenetre_CDM.Enabled:=false; - - //formPrinc.left:=-1000; ConfCellTCO:=false; if debug=1 then Affiche('Fini',clLime); - - - end; @@ -20380,6 +20806,7 @@ begin timer1.Enabled:=false; FermeSC:=true; + UnHookWindowsHookEx(KBHook); // supprimer le hook clavier if portCommOuvert and not(simuInterface) then begin @@ -20425,7 +20852,7 @@ begin begin Affiche('Arrêt du train '+Train+' hors horaire',clOrange); sens:=true; - vitesse_loco(train,i,adresse,0,10); + vitesse_loco(train,i,adresse,0,10,0); end; end; end; @@ -20519,7 +20946,6 @@ begin end; end; - // timer à 100 ms procedure TFormPrinc.Timer1Timer(Sender: TObject); var n,i,j,a,d,longueur,adresseEl,TailleX,TailleY,orientation,indexTCO,x,y,Bimage,aspect, @@ -20533,6 +20959,13 @@ var n,i,j,a,d,longueur,adresseEl,TailleX,TailleY,orientation,indexTCO,x,y,Bimage begin inc(tick); + if tempoBlocUSB>0 then + begin + dec(tempoBlocUSB); + if tempoBlocUSB=0 then + consigne_train(2); + end; + // séquencement des actions après tempo if index_seqAct>0 then begin @@ -20544,7 +20977,7 @@ begin dec(index_seqAct); a:=j; repeat - Affiche('Faire action séquencée'+intToSTR(i)+' op '+intToSTR(a),clLime); + Affiche('Faire action séquencée '+intToSTR(i)+' op '+intToSTR(a),clLime); Action_operation(i,a); faire:=(Tablo_Action[i].TabloOp[a].numoperation=ActionTempo); inc(a); @@ -20773,7 +21206,7 @@ begin s:=Tablo_Action[i].tabloOp[j].trainCourant; //Affiche('Action TrainDest='+s+' F'+IntToSTR(Tablo_Action[i].TabloOP[j].fonctionF)+':0',clyellow); Affiche('Action TrainDest='+s+' F'+format('%d',[Tablo_Action[i].TabloOP[j].fonctionF])+':0',clyellow); - envoie_fonction_CDM(Tablo_Action[i].tabloOP[j].fonctionF,0,s); + envoie_fonction(Tablo_Action[i].tabloOP[j].fonctionF,0,s); end; actionTempo : begin @@ -20861,7 +21294,7 @@ begin //if debugroulage then Affiche('Phase arret 0',clred); vitesseCons:=VitRalenti div 2; if route[0].talon then vitesseCons:=-vitesseCons; - vitesse_loco(nom_train,i,trains[i].adresse,vitesseCons,3); // répétition dans 0,3 s + vitesse_loco(nom_train,i,trains[i].adresse,vitesseCons,3,0); // répétition dans 0,3 s phase_arret:=1; end; 1 : begin @@ -20906,7 +21339,7 @@ begin if debugRoulage then Affiche('Timer '+trains[i].nom_train+' Arrêté',ClWhite); trains[i].vitesseCons:=0; - vitesse_loco(trains[i].nom_train,i,trains[i].adresse,0,0); // arrêt du train + vitesse_loco(trains[i].nom_train,i,trains[i].adresse,0,0,0); // arrêt du train train_sarrete(i); // vérifie si fin de route, et copie tempo_demarre si détecteur arrêt optionnel+ tempo de redémarrage end; end; @@ -20924,7 +21357,7 @@ begin if debugRoulage then Affiche('Timer tempo démarre '+intToSTR(a)+' '+intToSTR(trains[i].TempsDemarreSig-5),clWhite); if a=(trains[i].TempsDemarreSig*10)-5 then // renvoi consigne d'arret 5x1/10 de secondes apres begin - vitesse_loco(trains[i].nom_train,i,trains[i].adresse,0,0); // vitesse nulle + vitesse_loco(trains[i].nom_train,i,trains[i].adresse,0,0,0); // vitesse nulle end; dec(a); @@ -20937,7 +21370,7 @@ begin trains[i].vitesseCons:=vitCons; //if (trains[i].inverse) then trains[i].vitesseCons:=-trains[i].vitesseCons; - vitesse_loco(trains[i].nom_train,i,trains[i].adresse,vitcons,0); + vitesse_loco(trains[i].nom_train,i,trains[i].adresse,vitcons,0,0); end; // démarrage sur consigne @@ -20950,7 +21383,7 @@ begin if a=0 then begin //trains[i].vitesseCons:=trains[i].VitesseCons; - vitesse_loco(trains[i].nom_train,i,trains[i].adresse,trains[i].vitesseCons,0); + vitesse_loco(trains[i].nom_train,i,trains[i].adresse,trains[i].vitesseCons,0,0); end; //Affiche('vitesse ' +intToSTR(i)+' '+intToSTR(trains[i].vitesse),clred); end; @@ -21321,8 +21754,6 @@ begin connecte_interface_ethernet; end; - - procedure TFormPrinc.MenuDeconnecterEthernetClick(Sender: TObject); begin Affiche('Déconnexion interface ethernet',clyellow); @@ -21366,10 +21797,8 @@ begin Affiche(s,c); end; Affiche('Nombre de détecteurs à 1 :'+intToSTR(NbDet1),clyellow); - end; - procedure TFormPrinc.Etatdesactionneurs1Click(Sender: TObject); var j : integer; s : string; @@ -21384,7 +21813,6 @@ begin s:=s+actionneur[j].train; Affiche(s,clyellow); end; - end; // trouve l'index du détecteur de. Si pas trouvé, renvoie 0 @@ -21496,6 +21924,7 @@ begin end; end; end; + // connnecter le socket de interface vers la centrale procedure TFormPrinc.ClientSocketInterfaceConnect(Sender: TObject;Socket: TCustomWinSocket); var trouve : boolean; @@ -21530,7 +21959,7 @@ begin {$ENDIF} end; -// CDM rail connecté +// CDM rail se connecte procedure TFormPrinc.ClientSocketCDMConnect(Sender: TObject;Socket: TCustomWinSocket); var s : string; begin @@ -21547,7 +21976,7 @@ begin end; -// décodage d'une trame CDM au protocole IPC +// décodage d'une trame CDM au protocole IPC (COMIP) // la trame_CDM peut contenir 2000 caractères à l'initialisation du RUN. procedure Interprete_trameCDM(trame_CDM:string); var i,j,objet,k,l,erreur,posErr,adr,adr2,etat,etataig, @@ -21618,7 +22047,7 @@ begin l:=1; repeat trouve:=trains[l].adresse=trains_cdm[i].adresse; - if trouve then + if trouve then // si l'adresse du train CDM est déja existante on copie le train CDM dans le train SC begin //affiche('train '+intToSTR(trains_cdm[i].adresse)+' trouvé dans l''existant',clLime); Formprinc.ComboTrains.Items.Add(trains_cdm[i].nom_train); @@ -21629,14 +22058,15 @@ begin inc(l); until (l>ntrains) or trouve; - if not(trouve) then + if not(trouve) then // si pas trouvé le train dans SC, on créée le train begin inc(ntrains); //affiche('train '+intToSTR(trains_cdm[i].adresse)+' créé',clLime); - Trains[ntrains].nom_train:=trains_cdm[i].nom_train; Trains[ntrains].adresse:=Trains_cdm[i].adresse; Trains[ntrains].vitmax:=Trains_cdm[i].vitmax; + FormPrinc.ComboTrains.Items.Add(trains_cdm[i].nom_train); + cree_image_Train(ntrains); end; end; @@ -22068,6 +22498,7 @@ begin ss:=copy(commandeCDM,i+6,l-i-6); val(ss,vitesse,erreur); s:=s+' SPEED='+IntToSTR(vitesse); + vitesse:=(vitesse*100) div 120; Delete(commandeCDM,i,l-i+1); end; @@ -22108,11 +22539,6 @@ begin end; if horloge then verifie_train_horaire(adr,train,vitesse); - idt:=index_train_adresse(adr); - if idt>0 then - begin - trains[idt].vitesseCons:=vitesse; - end; Event_vitesse(adr,train,vitesse); // déclenche évent actionneur vitesse train // fait bouger le train dans la fenetre cdm if fichier_module_CDM then Aff_train(adr,train,x,y,x2,y2); @@ -22148,6 +22574,7 @@ begin ss:=copy(commandeCDM,i+6,l-i-6); val(ss,vitesse,erreur); s:=s+' SPEED='+IntToSTR(vitesse); + vitesse:=(vitesse*100) div 120; Delete(commandeCDM,i,l-i+1); end; @@ -22179,10 +22606,8 @@ begin end; if afftiers then afficheDebug(s,clAqua); - end; - // évènement port CDM - non stocké ni interprété // S-E-01-0188-CDMTRN-P_CDM|060|07|NAME=TRAIN_3;AD=0;SPEED=99;SEG=38;PORT=1;X=35565;Y=12364; i:=pos('CMDTRN-P_CDM',commandeCDM); @@ -22718,6 +23143,9 @@ procedure TFormPrinc.locoClick(Sender: TObject); var i,adr,vit,erreur : integer; s : string; begin + consigne_train(1); + exit; + s:=editAdrTrain.Text; val(s,adr,erreur); if (erreur<>0) or (adr<0) then exit; @@ -22732,7 +23160,7 @@ begin i:=index_train_nom(s); end; Affiche('Commande vitesse train '+s+' ('+intToSTR(adr)+')',cllime); - vitesse_loco(s,i,adr,vit,10); + vitesse_loco(s,i,adr,vit,10,0); if s='' then s:=intToSTR(adr); end; @@ -22951,7 +23379,7 @@ begin //Affiche(s,clOrange); // nom de l'image du signal (ex: ImageSignal) IndexSignalClic:=extract_int(s); // extraire l'adresse (ex 2) formconfig.PageControl.ActivePage:=formconfig.TabSheetSig; - clicproprietes:=true; + clicproprietesSig:=true; formconfig.showmodal; formconfig.close; end; @@ -23040,7 +23468,7 @@ begin s:=s+'son signal suivant '+intToSTR(AdrSignalsuivant)+' est au '+chaine_signal(AdrSignalsuivant)+#13; end; - // avertissement cli + // jaune cli if (aspect=jaune_cli) and (nation=1) then begin i:=etat_signal_suivant(Adresse,1,AdrSignalsuivant); @@ -23048,13 +23476,13 @@ begin s:=s+'son signal suivant '+intToSTR(AdrSignalsuivant)+' est au '+chaine_signal(AdrSignalSuivant)+#13; end; // ralen 30 - if (combine=10) and (nation=1) then + if (combine=ral_30) and (nation=1) then begin i:=etat_signal_suivant(Adresse,1,AdrSignalsuivant); index:=Index_Signal(AdrSignalSuivant); s:=s+'son signal suivant '+intToSTR(AdrSignalsuivant)+' est au '+chaine_signal(AdrSignalSuivant)+#13; end; - if (combine=11) and (nation=1) then + if (combine=ral_60) and (nation=1) then begin i:=etat_signal_suivant(Adresse,1,AdrSignalsuivant); index:=Index_Signal(AdrSignalSuivant); @@ -23102,7 +23530,6 @@ begin s:=InfoSignal(adresse); Affiche_CR(s,clyellow); - end; procedure TFormPrinc.VrifierlacohrenceClick(Sender: TObject); @@ -23149,10 +23576,17 @@ begin if clicAdrTrain then exit; clicComboTrain:=true; i:=ComboTrains.itemIndex+1; + TempoCombo:=2; if (i<>0) and (inull then s:=FWbemObject.DeviceID+' '; + if FWbemObject.name<>null then s:=s+FWbemObject.Name+' '; + if FWbemObject.Description<>null then s:=s+FWbemObject.Description; + Affiche(s,clyellow); + FWbemObject:=Unassigned; + end; + if i=0 then Affiche('R0 : Aucun port usb composite',clLIme); + } + // requete 1 pour les com natifs ------------------ - FWbemObjectSet:=FWMIService.ExecQuery('SELECT * FROM Win32_SerialPort','WQL',wbemFlagForwardOnly); + FWbemObjectSet:=FWMIService.ExecQuery('select * FROM Win32_SerialPort','WQL',wbemFlagForwardOnly); + //FWbemObjectSet:=FWMIService.ExecQuery('select * from win32_pnpentity','WQL',wbemFlagForwardOnly); oEnum:=IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant; + i:=0; while oEnum.Next(1,FWbemObject,iValue)=0 do begin inc(i); @@ -24397,7 +24853,9 @@ end; procedure TFormPrinc.FormResize(Sender: TObject); begin // pour éviter de coincer le splitter à gauche fenetre réduite et on le glisse complètement à gauche + //Affiche('On Resize',clyellow); splitterV.Left:=FenRich.left+FenRich.Width-5; + calcul_pos_horloge; end; @@ -26345,4 +26803,60 @@ begin Affiche('Recompilation des bases de données terminée',clLime); end; +procedure TFormPrinc.ButtonEssaiClick(Sender: TObject); +begin + if registerHotKey(formprinc.Handle,0,1,0)=false then Affiche('Erreur',clred); + +end; + +procedure TFormPrinc.PopupMenuTrainsPopup(Sender: TObject); +var ob : TPopupMenu; +begin + // AdrPilote est récupéré de l'event OnMouseDown de l'image du signal qui se produit avant + if Affevt then Affiche('PopupMenuTrain',clYellow); + ob:=Sender as Tpopupmenu; + // ob.Items[0].Caption:='Propriétés du train '+intToSTR(AdrPilote); + +end; + +procedure TFormPrinc.Propritsdutrain1Click(Sender: TObject); +var s : string; +begin + clicliste:=false; + if affEvt then Affiche('Clic propriétés train',clYellow); + s:=((Tpopupmenu(Tmenuitem(sender).GetParentMenu).PopupComponent) as TImage).name; // nom du composant, pour récupérer l'index du train (ex: ImageSignal2) + ligneclicTrain:=extract_int(s)-1; // extraire l'adresse (ex 2) + formconfig.PageControl.ActivePage:=formconfig.TabSheetTrains; + clicproprietesTrains:=true; + formconfig.showmodal; + formconfig.close; +end; + + +procedure TFormPrinc.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if (PageControl.ActivePage<>TabSheettrains) or (TempoCombo>0) or (ComboTrains.Focused) or clicComboTrain then exit; + //Affiche('FormKeyDown',clyellow); + if (key=vk_down) and (IdTrainClic1) then + begin + Maj_icone_train(Image_Train[IdTrainClic],IdTrainClic,clWhite); + dec(IdTrainClic); + EditAdrTrain.Text:=intToSTR(trains[IdTrainClic].adresse); + Maj_icone_train(Image_Train[IdTrainClic],IdTrainClic,$e0e0e0); + Combotrains.ItemIndex:=IdTrainclic-1; + key:=0; + end; +end; + + end. diff --git a/UnitRoute.pas b/UnitRoute.pas index 08fc250..7ac8970 100644 --- a/UnitRoute.pas +++ b/UnitRoute.pas @@ -428,7 +428,7 @@ begin SendMessage(FormRoute.ListBoxRoutes.Handle,LB_SETHORIZONTALEXTENT,PixelLength,0); // icone train - if idcantonRoute<>0 then Maj_icone_train(FormRoute.ImageTrainR,idTrainCourant); + if idcantonRoute<>0 then Maj_icone_train(FormRoute.ImageTrainR,idTrainCourant,clWhite); formRoute.ButtonFenPil.enabled:=trains[IdTrainCourant].route[0].adresse<>0; diff --git a/UnitRouteTrains.dfm b/UnitRouteTrains.dfm index 990ce45..13cb42b 100644 --- a/UnitRouteTrains.dfm +++ b/UnitRouteTrains.dfm @@ -4,7 +4,7 @@ object FormRouteTrain: TFormRouteTrain BorderStyle = bsDialog Caption = 'Liste des routes affect'#233'es et m'#233'moris'#233'es aux trains' ClientHeight = 194 - ClientWidth = 853 + ClientWidth = 850 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText @@ -53,7 +53,7 @@ object FormRouteTrain: TFormRouteTrain Top = 8 Width = 585 Height = 177 - ActivePage = TabSheetRA + ActivePage = TabSheetRM TabOrder = 1 object TabSheetRA: TTabSheet Caption = 'Route affect'#233'e' diff --git a/UnitRouteTrains.pas b/UnitRouteTrains.pas index c8fa050..6c465c5 100644 --- a/UnitRouteTrains.pas +++ b/UnitRouteTrains.pas @@ -197,7 +197,7 @@ begin vitesse:=GrilleHoraire[i].vitesse; if trains[indexTrain].route[0].talon then vitesse:=-vitesse; trains[indexTrain].roulage:=2; - vitesse_loco(train,indextrain,adrTrain,vitesse,10); + vitesse_loco(train,indextrain,adrTrain,vitesse,10,0); end; end; @@ -271,7 +271,7 @@ begin formRouteTrain.comboBoxTrains.ItemIndex:=indexTrainFR-1; - Maj_icone_train(FormRouteTrain.ImageTrainR,idTrain); + Maj_icone_train(FormRouteTrain.ImageTrainR,idTrain,clWhite); with formRouteTrain do begin TabSheetRM.Enabled:=false; @@ -329,7 +329,7 @@ procedure TFormRouteTrain.FormActivate(Sender: TObject); begin maj_infos(indexTrainFR); - if ntrains>0 then Maj_icone_train(FormRouteTrain.ImageTrainR,indexTrainFR); + if ntrains>0 then Maj_icone_train(FormRouteTrain.ImageTrainR,indexTrainFR,clWhite); end; procedure TFormRouteTrain.ButtonQuitteClick(Sender: TObject); @@ -769,6 +769,7 @@ begin el2R:=trains[indexTrainFR].routePref[IrPref][2].adresse; t2R:=trains[indexTrainFR].routePref[IrPref][2].typ; + // canton du départ de la route IdCanton:=index_canton_det(el1R); // trouve l'index du canton du détecteur el1R (départ de route) = c'est le canton origine de la route if IdCanton=0 then begin labelRoute.caption:='Le train de départ n''est pas sur un canton';exit;end; FormRouteTrain.Caption:=trains[indexTrainFR].nom_train+' départ depuis canton '+intToSTR(canton[IdCanton].numero)+' '+canton[idcanton].nom; @@ -838,7 +839,7 @@ begin canton[idCantonOrg].Bouton:=0; dessin_canton(IdCantonOrg,0); end; - if idcantonOrg<>0 then + if idcantonDest<>0 then begin canton[idCantonDest].NumcantonOrg:=0; canton[idCantonDest].NumcantonDest:=0; @@ -846,8 +847,8 @@ begin dessin_canton(IdCantonDest,0); end; - // affecter le canton origine et destination - canton[IdCanton].bouton:=3; + // affecter le canton origine et destination - IdCanton = canton départ de la route + canton[IdCanton].bouton:=3; // 3 = drapeau vert n:=trains[indexTrainFR].route[0].adresse ; detfin:=trains[indexTrainFR].route[n].adresse; diff --git a/UnitTCO.dfm b/UnitTCO.dfm index 7ed8d2d..f536a35 100644 --- a/UnitTCO.dfm +++ b/UnitTCO.dfm @@ -24,8 +24,8 @@ object FormTCO: TFormTCO OnKeyPress = FormKeyPress OnMouseWheel = FormMouseWheel DesignSize = ( - 1005 - 556) + 997 + 548) PixelsPerInch = 96 TextHeight = 13 object LabelZoom: TLabel @@ -1299,10 +1299,10 @@ object FormTCO: TFormTCO Font.Name = 'MS Sans Serif' Font.Style = [] ParentFont = False - ReadOnly = True TabOrder = 0 OnChange = EditAdrElementChange OnClick = EditAdrElementClick + OnExit = EditAdrElementExit end object EditTypeImage: TEdit Left = 184 diff --git a/UnitTCO.pas b/UnitTCO.pas index 3fb6fd1..99c8993 100644 --- a/UnitTCO.pas +++ b/UnitTCO.pas @@ -405,6 +405,7 @@ type { Déclarations privées } function index_TCOMainMenu : integer; procedure Mmoiredezone1Click(Sender: TObject); + procedure EditAdrElementExit(Sender: TObject); public { Déclarations publiques } end; @@ -1450,7 +1451,6 @@ end; // remplit les informations du canton avec les éléments adjacents, et des détecteurs adjacents // et vérifie si le canton ne contient pas de case incorrecte -// Cantons uniquement TCO1 // i : indexCanton // remplit les champs horizontal, el1,el2,typ1,typ2,sens1,sens2 de canton[] // et les champs canton1 et canton2 du tableau detecteurs[] @@ -2446,7 +2446,7 @@ begin closefile(fichier); renseigne_tous_cantons; trier_cantons; - affecte_trains_config; + sauve_styles_tco(indexTCO); // sauver le jeu sombre if jeucouleurs=2 then jeu_clair(indexTCO); @@ -14989,6 +14989,7 @@ begin //Affiche('xClicCell='+intToSTR(XClicCell[indexTCO]),clYellow); clicTCO:=true; formTCO[indexTCO].EditAdrElement.Text:=IntToSTR(tco[indextco,XClicCell[indexTCO],YClicCell[indexTCO]].Adresse); + defocusControl(EditAdrElement,true); // pour enlever le curseur actualise(indexTCO); clicTCO:=false; end; @@ -15290,7 +15291,9 @@ begin tco[indextco,XClic,YClic].liaisons:=liaisons[icone]; // liaisons des voies tco[indextco,xClic,YClic].CoulFonte:=clYellow; tco[indextco,XClicCell[indexTCO],YClicCell[indexTCO]].Repr:=2; + formTCO[indexTCO].EditAdrElement.Text:=IntToSTR(tco[indextco,XClic,YClic].Adresse); + formTCO[indexTCO].EdittypeImage.Text:=IntToSTR(tco[indextco,XClic,YClic].BImage); end; @@ -16284,8 +16287,7 @@ begin else begin // detdépart validé : valider le det de destination sauf si route en roulage - if (detatrouve=0) and (bt<=3) and not(ConfCellTCO) and (NbreRoutes=0) - then // bt=3 drapeau vert bt=4 drapeau rouge + if (detatrouve=0) and (bt<=3) and not(ConfCellTCO) and (canton[idCantonClic].NumCantonDest=0) then // bt=3 drapeau vert bt=4 drapeau rouge begin if (canton[IdCantonClic].adresseTrain<>0) and (bt<3) then begin @@ -16776,6 +16778,7 @@ begin YclicCellInserer:=YClic; clicTCO:=true; EditAdrElement.Text:=IntToSTR(tco[indextco,XClicCellInserer,YClicCellInserer].Adresse); + defocusControl(EditAdrElement,true); EditTypeImage.Text:=IntToSTR(tco[indextco,XClicCellInserer,YClicCellInserer].Bimage); CheckPinv.Checked:=tco[indextco,XClicCellInserer,YClicCellInserer].inverse; clicTCO:=false; @@ -17081,15 +17084,24 @@ end; // changement de l'adresse d'un élément procedure TFormTCO.EditAdrElementChange(Sender: TObject); -var Adr,erreur,index,indexTCO : integer; +var Adr,erreur,indexTCO,Bim : integer; s: string; begin - exit; - //Affiche('Chgt adresse',clyellow); - 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) +// exit; + //Affiche('EditAdrElement change',clyellow); + //if clicTCO or not(ConfCellTCO) then exit; + + if clicTCO then + begin + HideCaret(EditAdrElement.Handle); // supprime le curseur + exit; + end; + //clicTCO:=true; indexTCO:=index_TCO(sender); + bim:=tco[indextco,XClicCell[indexTCO],YClicCell[indexTCO]].Bimage; + if bim=0 then exit; + + auto_tcurs:=false; // interdit le déplacement du curseur encadré du TCO (pour que les touches curseur s'applique au Tedit) s:=formTCO[indexTCO].EditAdrElement.Text; if length(s)>1 then begin @@ -17106,17 +17118,16 @@ begin efface_entoure(indexTCO); tco[indextco,XClicCell[indexTCO],YClicCell[indexTCO]].Adresse:=Adr; - //formConfCellTCO.editAdrElement.Text:=intToSTR(Adr); + formConfCellTCO.editAdrElement.Text:=intToSTR(Adr); tco_Modifie:=true; // si signal if tco[indextco,XClicCell[indexTCO],YClicCell[indexTCO]].BImage=Id_signal then begin - index:=Index_Signal(adr); + {index:=Index_Signal(adr); if index=0 then exit - else + else } begin - //Affiche('Signal '+intToSTR(Adr),clyellow); affiche_tco(indexTCO); end; end; @@ -17198,7 +17209,6 @@ begin end_drag(10,x,y,Sender,Target); end; - procedure TFormTCO.ImagePalette11EndDrag(Sender, Target: TObject; X, Y: Integer); begin @@ -18739,7 +18749,7 @@ end; procedure TFormTCO.EditAdrElementClick(Sender: TObject); begin - auto_tcurs:=false; +// auto_tcurs:=false; end; procedure TFormTCO.ImagePalette53DragOver(Sender, Source: TObject; X, @@ -19224,6 +19234,12 @@ begin end; +procedure TFormTCO.EditAdrElementExit(Sender: TObject); +begin + auto_tcurs:=true; // réautorise le déplacement du curseur + defocusControl(EditAdrElement,true); +end; + end. diff --git a/selection_train.pas b/selection_train.pas index a634415..6b945a4 100644 --- a/selection_train.pas +++ b/selection_train.pas @@ -41,7 +41,7 @@ HauteurLigneSGT=30; var FormSelTrain: TFormSelTrain; - x,y,El,largC,hautC,indexTrainClic,LargeurSGT : Integer; + x,y,El,largC,hautC,LargeurSGT,indexTrainClic : Integer; routeSav : TuneRoute; procedure actualise_seltrains; @@ -216,6 +216,7 @@ begin trains[i].canton:=0; end; + // Maj_icone_train(Image_Train[i],i,clWhite); // maj arrière plan train page principale // balayer les détecteurs pour trouver sur quel détecteur est le train pour le razer // non @@ -259,7 +260,7 @@ begin idTrain:=Index_train_adresse(adrTrain); raz_cantons_train(AdrTrain,false); // efface tous les cantons contenant le train Adrtrain sans raz du détecteur - + //Maj_icone_train(Image_Train[idTrain],idTrain,$e0e0e0); // maj arrière plan train page principale trains[idTrain].canton:=canton[idcanton].numero; trains[idTrain].sens:=sens; canton[IdCanton].SensLoco:=sens; @@ -280,8 +281,10 @@ begin canton[Idcanton].NomTrain:=''; canton[Idcanton].indexTrain:=0; canton[IdCanton].adresseTrain:=0; + // a revoir IDTrain=0 !!!! Maj_icone_train(Image_Train[idTrain],idTrain,clWhite); end; + // affecte le canton avec l'id du train, même si nul t:=canton[IdCanton].Ntco; if (t>0) and (t<=nbreTCO) then begin @@ -305,7 +308,6 @@ begin end; end; //affiche('Det du canton '+intToSTR(canton[Idcanton].numero)+' det1='+intToSTR(canton[Idcanton].det1)+' det2='+intToSTR(canton[Idcanton].det2),clyellow); - end; // renvoie x,y El et indexCanton de IdCantonSelect en variable globale diff --git a/verif_version.pas b/verif_version.pas index 2e112c5..026686d 100644 --- a/verif_version.pas +++ b/verif_version.pas @@ -26,7 +26,7 @@ var f : text; Const -VersionSC = '9.77'; // sert à la comparaison de la version publiée +VersionSC = '9.8'; // sert à la comparaison de la version publiée SousVersion=' '; // A B C ... en cas d'absence de sous version mettre un espace // pour unzip SHCONTCH_NOPROGRESSBOX=4; @@ -39,7 +39,6 @@ SHCONTF_NONFOLDERS=64; function GetCurrentProcessEnvVar(const VariableName: string): string; function verifie_version : real; function DownloadURL_NOCache(aUrl: string;s : string;var taille : longint): Boolean; -function Unzip(zipfile : oleVariant): boolean; implementation @@ -173,6 +172,59 @@ begin log(s+' copié',clLime); end; +// dézipe un fichier. Si réussi : result=true +function Unzip(zipfile : oleVariant): boolean; +var + shellobj,srcfldr, destfldr, shellfldritems,repertoire: Olevariant; + filtre: string; + i : integer; + erreur : integer; +begin + result:=false; + filtre:=''; + zipfile:=lowercase(zipfile); + i:=pos('.zip',zipfile); + if i=0 then + begin + log('Fichier zip : '+zipfile+' incorrect',clred); + exit; + end; + filtre:=zipfile; + delete(filtre,i,4); + + // créer le répertoire destination du zip (obligatoire car la commande de dézippe ne le créée pas) + if not(Cree_dir(filtre)) then + begin + log('Création répertoire '+filtre+' impossible',clred); + exit; + end; + + repertoire:=filtre; // mettre dans olevariant + + filtre:=''; + shellobj:=CreateOleObject('Shell.Application'); + srcfldr:=ShellObj.NameSpace(Zipfile); + if not((VarType(srcfldr)=varDispatch) and Assigned(TVarData(srcfldr).VDispatch)) then + begin + log('Fichier '+zipfile+ ' invalide ou absent',clred); + exit; + end; + + destfldr:=ShellObj.NameSpace(repertoire); + if not ((VarType(destfldr)=varDispatch) and Assigned(TVarData(destfldr).VDispatch)) then + begin + log('Répertoire destination invalide : '+ repertoire,clred); + exit; + end; + + shellfldritems:=srcfldr.Items; + if (filtre<>'') then shellfldritems.Filter(SHCONTF_INCLUDEHIDDEN or SHCONTF_NONFOLDERS or SHCONTF_FOLDERS,filtre); + + //destfldr.CopyHere(shellfldritems, SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL); + destfldr.CopyHere(shellfldritems, SHCONTCH_RESPONDYESTOALL); + result:=true; +end; + // dézipe copie les fichiers et lance la nouvelle version // s : chemin et fichier à déziper @@ -227,6 +279,7 @@ begin if i>32 then begin + fermeSC:=true; Application.Terminate; end else @@ -572,50 +625,6 @@ begin Result:=(0=ShFileOperation(fos)); end; -function Unzip(zipfile : oleVariant): boolean; -var - shellobj,srcfldr, destfldr, shellfldritems,repertoire: Olevariant; - filtre: string; - i : integer; - erreur : integer; -begin - filtre:=''; - zipfile:=lowercase(zipfile); - i:=pos('.zip',zipfile); - if i=0 then exit; - filtre:=zipfile; - delete(filtre,i,4); - - // créer le répertoire destination du zip (obligatoire car la commande de dézippe ne le créée pas) - if not(Cree_dir(filtre)) then exit; - - repertoire:=filtre; // mettre dans olevariant - - filtre:=''; - shellobj:=CreateOleObject('Shell.Application'); - srcfldr:=ShellObj.NameSpace(Zipfile); - if not((VarType(srcfldr)=varDispatch) and Assigned(TVarData(srcfldr).VDispatch)) then - begin - log('Fichier '+zipfile+ ' invalide ou absent',clred); - result:=false; - exit; - end; - - destfldr:=ShellObj.NameSpace(repertoire); - if not ((VarType(destfldr)=varDispatch) and Assigned(TVarData(destfldr).VDispatch)) then - begin - log('Répertoire destination invalide : '+ repertoire,clred); - result:=false; - exit; - end; - - shellfldritems:=srcfldr.Items; - if (filtre<>'') then shellfldritems.Filter(SHCONTF_INCLUDEHIDDEN or SHCONTF_NONFOLDERS or SHCONTF_FOLDERS,filtre); - - //destfldr.CopyHere(shellfldritems, SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL); - destfldr.CopyHere(shellfldritems, SHCONTCH_RESPONDYESTOALL); - result:=true; -end; begin diff --git a/versions.txt b/versions.txt index 3fb17f6..335aba6 100644 --- a/versions.txt +++ b/versions.txt @@ -307,9 +307,11 @@ version 9.75 : Corrections dans le TCO. version 9.76 : Amélioration de l'importation des réseaux depuis CDM rail. Correction de l'affichage du réseau CDM en version x64. Renforcement de la vérification de la configuration. -version 9.77 : Amélioratios diverses. +version 9.77 : Améliorations diverses. Correction de quelques bugs. - +version 9.78 : Correction du déclencheur "démarrage train" +version 9.79 : Corrections et améliorations diverses. +version 9.8 : Intégration des claviers et boutons rotatifs USB