diff --git a/Notice d'utilisation des signaux_complexes_GL_V6.4.pdf b/Notice d'utilisation des signaux_complexes_GL_V7.0.pdf similarity index 75% rename from Notice d'utilisation des signaux_complexes_GL_V6.4.pdf rename to Notice d'utilisation des signaux_complexes_GL_V7.0.pdf index 928c79d..d183472 100644 Binary files a/Notice d'utilisation des signaux_complexes_GL_V6.4.pdf and b/Notice d'utilisation des signaux_complexes_GL_V7.0.pdf differ diff --git a/UnitConfig.dfm b/UnitConfig.dfm index 8209bbd..30c557e 100644 --- a/UnitConfig.dfm +++ b/UnitConfig.dfm @@ -1570,8 +1570,8 @@ object FormConfig: TFormConfig Left = 8 Top = 8 Width = 633 - Height = 505 - ActivePage = TabSheetSig + Height = 497 + ActivePage = TabSheetDecodeurs Font.Charset = DEFAULT_CHARSET Font.Color = clBlack Font.Height = -11 @@ -3158,7 +3158,7 @@ object FormConfig: TFormConfig Width = 129 Height = 21 Style = csDropDownList - ItemHeight = 13 + ItemHeight = 0 TabOrder = 1 OnChange = ComboBoxDecChange end @@ -3262,22 +3262,9 @@ object FormConfig: TFormConfig Width = 129 Height = 21 Style = csDropDownList - ItemHeight = 13 + ItemHeight = 0 TabOrder = 2 OnChange = ComboBoxAspChange - Items.Strings = ( - '2 feux' - '3 feux' - '4 feux' - '5 feux' - '7 feux' - '9 feux' - 'Directionnel 2 feux' - 'Directionnel 3 feux' - 'Directionnel 4 feux' - 'Directionnel 5 feux' - 'Directionnel 6 feux' - 'Signal belge type 1') end object EditSpecUni: TEdit Left = 8 @@ -3437,6 +3424,169 @@ object FormConfig: TFormConfig OnChange = EditTempoFeuChange end end + object TabSheetDecodeurs: TTabSheet + Caption = 'D'#233'codeurs' + ImageIndex = 8 + object Label61: TLabel + Left = 13 + Top = 4 + Width = 284 + Height = 19 + Caption = 'D'#233'codeurs personnalis'#233's de signaux' + Font.Charset = ANSI_CHARSET + Font.Color = clBlack + Font.Height = -16 + Font.Name = 'Arial' + Font.Style = [fsBold] + ParentFont = False + end + object Label62: TLabel + Left = 24 + Top = 40 + Width = 36 + Height = 16 + Caption = 'Etats' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -13 + Font.Name = 'MS Sans Serif' + Font.Style = [fsBold] + ParentFont = False + end + object Label63: TLabel + Left = 160 + Top = 24 + Width = 73 + Height = 32 + Caption = 'D'#233'calage d'#39'adresse' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -13 + Font.Name = 'MS Sans Serif' + Font.Style = [fsBold] + ParentFont = False + WordWrap = True + end + object Label66: TLabel + Left = 256 + Top = 40 + Width = 50 + Height = 16 + Caption = 'Sorties' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -13 + Font.Name = 'MS Sans Serif' + Font.Style = [fsBold] + ParentFont = False + WordWrap = True + end + object GroupBox26: TGroupBox + Left = 376 + Top = 64 + Width = 241 + Height = 393 + Caption = 'Commandes' + TabOrder = 0 + object Label67: TLabel + Left = 22 + Top = 24 + Width = 195 + Height = 20 + Caption = 'Nom du d'#233'codeur personnalis'#233 + Font.Charset = ANSI_CHARSET + Font.Color = clBlack + Font.Height = -16 + Font.Name = 'Arial Narrow' + Font.Style = [fsBold] + ParentFont = False + end + object Label65: TLabel + Left = 19 + Top = 96 + Width = 126 + Height = 39 + Alignment = taRightJustify + Caption = 'Nombre d'#39'adresses occup'#233'es par le signal sur le d'#233'codeur:' + WordWrap = True + end + object Label64: TLabel + Left = 64 + Top = 160 + Width = 105 + Height = 13 + Caption = 'Signalisation nationale' + end + object Label68: TLabel + Left = 23 + Top = 356 + Width = 178 + Height = 13 + Caption = 'Nombre de d'#233'codeurs personnalis'#233's :' + end + object LabelNbDecPers: TLabel + Left = 208 + Top = 356 + Width = 6 + Height = 13 + Caption = '0' + end + object ComboBoxDecodeurPerso: TComboBox + Left = 24 + Top = 56 + Width = 193 + Height = 21 + ItemHeight = 13 + TabOrder = 0 + OnChange = ComboBoxDecodeurPersoChange + end + object EditNbreAdr: TEdit + Left = 168 + Top = 104 + Width = 49 + Height = 21 + TabOrder = 1 + Text = '2' + OnChange = EditNbreAdrChange + end + object ComboBoxNation: TComboBox + Left = 48 + Top = 176 + Width = 145 + Height = 21 + ItemHeight = 13 + TabOrder = 2 + OnChange = ComboBoxNationChange + Items.Strings = ( + 'Fran'#231'aise' + 'Belge') + end + object BoutonNouveau: TButton + Left = 86 + Top = 216 + Width = 75 + Height = 25 + Hint = 'Ajouter un nouveau d'#233'codeur personnalis'#233 + Caption = 'Nouveau' + ParentShowHint = False + ShowHint = True + TabOrder = 3 + OnClick = BoutonNouveauClick + end + object ButtonSup: TButton + Left = 86 + Top = 248 + Width = 75 + Height = 25 + Hint = 'Supprimer le d'#233'codeur personnalis'#233 + Caption = 'Supprimer' + ParentShowHint = False + ShowHint = True + TabOrder = 4 + OnClick = ButtonSupClick + end + end + end object TabSheetAct: TTabSheet Caption = 'Actionneurs/D'#233'tecteurs' ImageIndex = 5 diff --git a/UnitConfig.pas b/UnitConfig.pas index 030720b..ca4931f 100644 --- a/UnitConfig.pas +++ b/UnitConfig.pas @@ -340,6 +340,22 @@ type CheckBoxContreVoie: TCheckBox; RadioButtonSpecifique: TRadioButton; EditSpecifique: TEdit; + TabSheetDecodeurs: TTabSheet; + Label61: TLabel; + Label62: TLabel; + Label63: TLabel; + Label66: TLabel; + GroupBox26: TGroupBox; + Label67: TLabel; + ComboBoxDecodeurPerso: TComboBox; + Label65: TLabel; + EditNbreAdr: TEdit; + Label64: TLabel; + ComboBoxNation: TComboBox; + BoutonNouveau: TButton; + ButtonSup: TButton; + Label68: TLabel; + LabelNbDecPers: TLabel; procedure ButtonAppliquerEtFermerClick(Sender: TObject); procedure FormActivate(Sender: TObject); procedure FormCreate(Sender: TObject); @@ -506,10 +522,18 @@ type procedure CheckBoxVersContrevoieClick(Sender: TObject); procedure CheckBoxContreVoieClick(Sender: TObject); procedure EditSpecifiqueChange(Sender: TObject); + procedure BoutonNouveauClick(Sender: TObject); + procedure EditNbreAdrChange(Sender: TObject); + procedure ComboBoxDecodeurPersoChange(Sender: TObject); + procedure ButtonSupClick(Sender: TObject); + procedure ComboBoxNationChange(Sender: TObject); private { Déclarations privées } public { Déclarations publiques } + procedure modif_editT(Sender : TObject); + procedure modif_ComboTS(Sender : TObject); + procedure modif_ComboL(Sender : TObject); end; const @@ -564,7 +588,9 @@ section_dccpp_ch='[section_dcc++]'; section_initpp_ch='[init_dcc++]'; section_trains_ch='[section_trains]'; section_placement_ch='[section_placement]'; - +section_DecPers_ch='[section_decodeurs]'; +Nba_ch='NombreAdresses'; +nation_ch='Nation'; var FormConfig: TFormConfig; @@ -575,13 +601,17 @@ var ligneclicAig,AncLigneClicAig,ligneClicSig,AncligneClicSig,EnvAigDccpp,AdrBaseDetDccpp, ligneClicBr,AncligneClicBr,ligneClicAct,AncLigneClicAct,Adressefeuclic,NumTrameCDM, Algo_localisation,Verif_AdrXpressNet,ligneclicTrain,AncligneclicTrain,AntiTimeoutEthLenz, - ligneDCC : integer; + ligneDCC,decCourant,ligne_signal : integer; ack_cdm,clicliste,config_modifie,clicproprietes,confasauver,trouve_MaxPort, modif_branches,ConfigPrete,trouve_section_dccpp,trouve_section_trains, - trouveAvecVerifIconesTCO,Affiche_avert,activ : boolean; + trouveAvecVerifIconesTCO,Affiche_avert,activ,trouve_section_dec_pers : boolean; fichier : text; + EditT : Array[1..10] of Tedit; + ComboL1,ComboL2,ComboTS1,ComboTS2 : Array[1..10] of TComboBox; + ShapeT : array[1..10] of TShape; + function config_com(s : string) : boolean; function envoi_CDM(s : string) : boolean; procedure connecte_CDM; @@ -634,14 +664,16 @@ begin place_id:=s; end; -procedure Maj_Hint_Signal(i : integer); +procedure Maj_Hint_Signal(indexFeu : integer); var s : string; begin // ne pas supprimer le @= qui sert de marqueur pour identifier le feu - s:='@='+inttostr(feux[i].Adresse)+' Decodeur='+intToSTR(feux[i].Decodeur)+' Adresse détecteur associé='+intToSTR(feux[i].Adr_det1)+ - ' Adresse élement suivant='+intToSTR(feux[i].Adr_el_suiv1); - if feux[i].Btype_suiv1=aig then s:=s+' (aig)'; - feux[i].Img.Hint:=s; + s:='Index='+IntToSTR(IndexFeu)+' @='+inttostr(feux[IndexFeu].Adresse)+' Décodeur='+decodeur[feux[IndexFeu].Decodeur]+ + ' Adresse détecteur associé='+intToSTR(feux[IndexFeu].Adr_det1)+ + ' Adresse élement suivant='+intToSTR(feux[IndexFeu].Adr_el_suiv1); + if feux[IndexFeu].Btype_suiv1=aig then s:=s+' (aig)'; + + feux[indexFeu].Img.Hint:=s; end; // demande les services Com-IP à CDM @@ -981,6 +1013,7 @@ begin s:=s+IntToSTR(feux[i].decodeur)+','; // detecteur et élement suivant (4 maxi) + // signal non directionnel if (aspect<10) or (aspect>=20) then begin s:=s+'('+IntToSTR(feux[i].Adr_det1)+','+TypeEl_To_char(feux[i].Btype_suiv1)+IntToSTR(feux[i].Adr_el_suiv1); @@ -1059,7 +1092,7 @@ begin for j:=1 to NfeuxDir+1 do begin s:=s+'('; - for k:=1 to Length(feux[i].AigDirection[j])-1 do + for k:=1 to Length(feux[i].AigDirection[j])-1 do // boum begin s:=s+'A'+IntToSTR(feux[i].AigDirection[j][k].adresse) + feux[i].AigDirection[j][k].posaig; if kNbDecodeur-1) then Affiche('Erreur 677 Ligne '+chaine_signal+' : erreur décodeur inconnu: '+intToSTR(Feux[i].decodeur),clred); + if (Feux[i].decodeur>NbDecodeurdeBase+NbreDecPers-1) then Affiche('Erreur 677 Ligne '+chaine_signal+' : erreur décodeur inconnu: '+intToSTR(Feux[i].decodeur),clred); if j<>0 then delete(s,1,j); feux[i].Adr_el_suiv1:=0;feux[i].Adr_el_suiv2:=0;feux[i].Adr_el_suiv3:=0;feux[i].Adr_el_suiv4:=0; feux[i].Btype_Suiv1:=rien;feux[i].Btype_Suiv2:=rien;feux[i].Btype_Suiv3:=rien;feux[i].Btype_Suiv4:=rien; @@ -1516,7 +1549,7 @@ end; procedure genere_config; var s: string; fichierN : text; - i : integer; + i,j,n : integer; begin assign(fichierN,NomConfig); rewrite(fichierN); @@ -1658,6 +1691,30 @@ begin end; writeln(fichierN,'0'); + writeln(fichierN,'/------------'); + + // décodeurs de signaux personnalisés (sauver avant les signaux pour avoir la liste des décodeurs personnalisés + writeln(fichierN,section_DecPers_ch); + for i:=1 to NbreDecPers do + begin + writeln(fichierN,decodeur_pers[i].nom); + n:=decodeur_pers[i].NbreAdr; + s:='NombreAdresses='+intToSTR(n); + writeln(fichierN,s); + n:=decodeur_pers[i].nation; + s:='Nation='+intToSTR(n); + writeln(fichierN,s); + + for j:=1 to decodeur_pers[i].NbreAdr do + begin + s:=intToSTR(decodeur_pers[i].desc[j].etat1)+','+intToSTR(decodeur_pers[i].desc[j].etat2)+','+ + intToSTR(decodeur_pers[i].desc[j].offsetAdresse)+','+intToSTR(decodeur_pers[i].desc[j].sortie1)+','+ + intToSTR(decodeur_pers[i].desc[j].sortie2); + writeln(fichierN,s); + end; + end; + writeln(fichierN,'0'); + writeln(fichierN,'/------------'); writeln(fichierN,section_sig_ch); // feux @@ -1727,6 +1784,9 @@ begin end; writeln(fichierN,'0'); + + + closefile(fichierN); end; @@ -2280,10 +2340,10 @@ begin virgule:=pos(',',enregistrement);if virgule=0 then virgule:=length(s)+1; delete(enregistrement,1,virgule); end; - + // si vitesse définie if (length(enregistrement)<>0) then - if enregistrement[1]='V' then + if enregistrement[1]='V' then begin inc(num_champ); delete(enregistrement,1,1); @@ -2296,7 +2356,7 @@ begin // TJS et L if (length(enregistrement)<>0) then - if enregistrement[1]='L' then + if enregistrement[1]='L' then begin if not(tjsC) then begin Affiche('Erreur paramètre L ligne: '+sOrigine,clred);exit;end; inc(num_champ); @@ -2351,6 +2411,73 @@ begin until (sOrigine='0'); end; +// compile les décodeurs personnalisés +procedure compile_dec_pers; +var nv,i,j,k,l,adr : integer; +begin + Nligne:=1; + nv:=0; + repeat + s:=lit_ligne; + inc(Nligne); + if s<>'0' then + begin + if NbreDecPers2) then k:=1; + decodeur_pers[NbreDecPers].Nation:=k; + end; + + adr:=1; + repeat + s:=lit_ligne; + k:=pos(',',s); + val(s,l,erreur); + delete(s,1,k); + decodeur_pers[NbreDecPers].desc[adr].etat1:=l; + k:=pos(',',s); + val(s,l,erreur); + delete(s,1,k); + decodeur_pers[NbreDecPers].desc[adr].etat2:=l; + k:=pos(',',s); + val(s,l,erreur); + delete(s,1,k); + decodeur_pers[NbreDecPers].desc[adr].offsetadresse:=l; + k:=pos(',',s); + val(s,l,erreur); + delete(s,1,k); + decodeur_pers[NbreDecPers].desc[adr].sortie1:=l; + k:=pos(',',s); + val(s,l,erreur); + delete(s,1,k); + decodeur_pers[NbreDecPers].desc[adr].sortie2:=l; + s:=''; + inc(adr); + until (adr>j); + end; + end; + until eof(fichier) or (s='0'); +end; + procedure compile_dccpp; var nv,i : integer; begin @@ -2455,6 +2582,12 @@ begin editadrtrain.Text:=inttostr(trains[1].adresse); end; until (sOrigine='0') or (ntrains>=Max_Trains); + for i:=1 to ntrains do + begin + trains[i].x:=-999999; + trains[i].y:=-999999; + end; + end; procedure lit_flux; @@ -2951,6 +3084,15 @@ begin compile_trains; end; + // section dédodeurs + sa:=uppercase(section_DecPers_ch); + if pos(sa,s)<>0 then + begin + trouve_section_dec_pers:=true; + compile_dec_pers; + end; + + // section placement sa:=uppercase(section_placement_ch); if pos(sa,s)<>0 then @@ -3353,7 +3495,7 @@ var AncAdresse,index,adresse,erreur : integer; begin index:=index_feu(lc)-1; s:=Uppercase(FormConfig.RichSig.Lines[index]); // ligne cliquée - if s='' then + if s='' then begin RE_ColorLine(Formconfig.RichSig,ligneclicSig,ClAqua); ligneclicSig:=-1; @@ -3482,6 +3624,7 @@ begin RadioButtonXpress.Checked:=protocole=1; RadioButtonDcc.Checked:=protocole=2; + clicListe:=true; // empeche le traitement de l'evt text EditDroit_BD.Text:=''; EditPointe_BG.Text:=''; @@ -3532,10 +3675,23 @@ begin // signaux RichSig.clear; ComboBoxDec.items.Clear; + + for i:=0 to 11 do + begin + ComboBoxAsp.items.add(Aspects[i]); + end; + // décodeurs de base for i:=1 to NbDecodeur do begin ComboBoxDec.items.add(decodeur[i-1]); end; + // décodeurs personalisés + for i:=1 to NbreDecPers do + begin + s:=decodeur_pers[i].nom; + formconfig.ComboBoxDec.Items.add(s); + end; + for i:=1 to NbreFeux do begin @@ -3613,14 +3769,83 @@ begin Lines.Add(Train_tablo(i)); end; end; - + LabelNbDecPers.caption:=intToSTR(NbreDecPers); //l'onglet affiché est sélectionné à l'appel de la fiche dans l'unité UnitPrinc clicListe:=false; activ:=false; end; +// met à jour le décodeur courant dans le tableau de config +procedure maj_decodeurs; +var nAdr,i,j,a,nation : integer; +begin + begin + // si pas de décodeur courant, on rend invisible toutes les adresses + if decCourant=0 then nAdr:=0 else + begin + formConfig.ComboBoxNation.itemindex:=decodeur_pers[decCourant].nation-1; + nAdr:=decodeur_pers[decCourant].NbreAdr; + FormConfig.EditNbreAdr.Text:=intToSTR(decodeur_pers[decCourant].NbreAdr); + nation:=decodeur_pers[decCourant].nation; + end; + + for i:=1 to nAdr do + begin + + comboL1[i].Items.Clear; + comboL2[i].Items.Clear; + if nation=1 then + begin + for j:=0 to 20 do + begin + comboL1[i].Items.add(Etats[j]); + comboL2[i].Items.add(Etats[j]); + end; + end + else + for j:=0 to 9 do + begin + begin + comboL1[i].Items.add(EtatSignBelge[j]); + comboL2[i].Items.add(EtatSignBelge[j]); + end; + end; + a:=decodeur_pers[decCourant].desc[i].etat1; + ComboL1[i].itemIndex:=a; + ComboL1[i].Visible:=true; + + a:=decodeur_pers[decCourant].desc[i].etat2; + ComboL2[i].Itemindex:=a; + ComboL2[i].Visible:=true; + + EditT[i].Text:=intToSTR(decodeur_pers[decCourant].desc[i].offsetAdresse); + EditT[i].Visible:=true; + a:=decodeur_pers[decCourant].desc[i].sortie1; + ComboTS1[i].Itemindex:=a-1; + ComboTS1[i].Visible:=true; + a:=decodeur_pers[decCourant].desc[i].sortie2; + ComboTS2[i].Itemindex:=a-1; + ComboTS2[i].Visible:=true; + ShapeT[i].Visible:=true; + + end; + for i:=nADr+1 to 10 do + begin + ComboL1[i].Visible:=false; + ComboL2[i].Visible:=false; + EditT[i].Visible:=false; + ComboTS1[i].Visible:=false; + ComboTS2[i].Visible:=false; + ShapeT[i].Visible:=false; + + end; + end; +end; + procedure TFormConfig.FormCreate(Sender: TObject); +var i,j,y : integer; + s : string; begin if debug=1 then Affiche('Création fenêtre config',clLime); clicListe:=true; @@ -3637,6 +3862,119 @@ begin groupBox21.Top:=304; GroupBox21.Left:=8; if debug=1 then Affiche('Fin création fenêtre config',clLime); + + EditNbreAdr.Text:='2'; + + // création des champs dynamiques de l'onglet décodeurs + for i:=1 to 10 do + begin + y:=i*40+20; + + // rectangle + ShapeT[i]:=Tshape.create(FormConfig.TabSheetDecodeurs); + with ShapeT[i] do + begin + name:='Ligne'+intToSTR(i); + left:=5;width:=350; top:=y;height:=42; + brush.Style:=bsSolid; + brush.Color:=clBtnFace; + pen.color:=clBlack; + shape:=stRectangle; + parent:=TabSheetDecodeurs; + end; + + ComboL1[i]:=TcomboBox.create(FormConfig.TabSheetDecodeurs); + with ComboL1[i] do + begin + Name:='ComboL1'+intToSTR(i); + text:=''; + left:=10;Top:=y;Width:=150;Height:=15; + parent:=TabSheetDecodeurs; + itemIndex:=-1; + for j:=0 to 19 do items.add(etats[j]); + onChange:=formConfig.modif_ComboL; + Style:=csDropDownList; + visible:=false; + end; + + ComboL2[i]:=Tcombobox.create(FormConfig.TabSheetDecodeurs); + with ComboL2[i] do + begin + Name:='ComboL2'+intToSTR(i); + text:=''; + left:=10;Top:=y+20;Width:=150;Height:=15; + parent:=TabSheetDecodeurs; + itemIndex:=-1; + for j:=0 to 19 do items.add(etats[j]); + onChange:=formConfig.modif_ComboL; + Style:=csDropDownList; + visible:=false; + end; + + EditT[i]:=TEdit.create(FormConfig.TabSheetDecodeurs); + with EditT[i] do + begin + Name:='EditT'+intToSTR(i); + left:=180;Top:=y+10;Width:=30;Height:=15; + text:=''; + parent:=TabSheetDecodeurs; + visible:=false; + Text:=intToSTR(i-1); + onChange:=formConfig.modif_editT; + end; + + ComboTS1[i]:=TComboBox.create(FormConfig.TabSheetDecodeurs); + with ComboTS1[i] do + begin + Name:='ComboTS1'+intToSTR(i); + left:=240;Top:=y;Width:=110;Height:=13; + text:=''; + parent:=TabSheetDecodeurs; + itemIndex:=-1; + items.add('- 1 rouge dévié'); + items.add('+ 2 vert droit'); + if (i-1) mod 2=0 then s:='Sortie 1' else s:='Sortie 2'; + Hint:=s; + ShowHint:=true; + visible:=false; + Style:=csDropDownList; + onChange:=formConfig.modif_ComboTS; + end; + + ComboTS2[i]:=TComboBox.create(FormConfig.TabSheetDecodeurs); + with ComboTS2[i] do + begin + Name:='ComboBoxTS2'+intToSTR(i); + left:=240;Top:=y+20;Width:=110;Height:=13; + text:=''; + parent:=TabSheetDecodeurs; + itemIndex:=-1; + items.add('- 1 rouge dévié'); + items.add('+ 2 vert droit'); + if (i-1) mod 2=0 then s:='Sortie 1' else s:='Sortie 2'; + Hint:=s; + ShowHint:=true; + visible:=false; + Style:=csDropDownList; + onChange:=formConfig.modif_ComboTS; + end; + + + end; + + for i:=1 to NbreDecPers do + begin + s:=decodeur_pers[i].nom; + formconfig.ComboBoxDecodeurPerso.Items.add(s); + end; + if NbreDecPers>0 then + begin + decCourant:=1; + formconfig.ComboBoxDecodeurPerso.ItemIndex:=0; + ComboBoxNation.ItemHeight:=decodeur_pers[decCourant].nation; + end + else formconfig.ComboBoxDecodeurPerso.ItemIndex:=-1; + maj_decodeurs; end; @@ -4096,7 +4434,7 @@ var i,j,l,d,p,k,nc,decodeur : integer; s : string; begin if Affevt then affiche('Aff_champs_sig_feux('+intToSTR(index)+')',clyellow); - if index<0 then exit; + if index<1 then exit; clicListe:=true; i:=index; FormConfig.EditAdrSig.text:=InttoSTr(feux[i].adresse); @@ -4299,6 +4637,9 @@ begin MemoCarre.Perform(EM_SCROLLCARET,0,0); end; end; + + // vérifier les incompatibilités + clicListe:=false; end; @@ -5148,11 +5489,72 @@ begin begin aiguillage[Index].vitesse:=60; aiguillage[Index].modifie:=true; - end; + end; s:=encode_aig(index); formconfig.RichAig.Lines[ligneclicAig]:=s; end; +function verif_dec_sig(aff : boolean) : boolean; +var Adr,i,dec,aspect,indexAspect : integer; +begin + result:=true; // ok + for i:=1 to NbreFeux do + begin + dec:=feux[i].decodeur; + aspect:=feux[i].aspect; + case aspect of + 2 : indexAspect:=0; + 3 : indexAspect:=1; + 4 : indexAspect:=2; + 5 : indexAspect:=3; + 7 : indexAspect:=4; + 9 : indexAspect:=5; + 12 : indexAspect:=6; + 13 : indexAspect:=7; + 14 : indexAspect:=8; + 15 : indexAspect:=9; + 16 : indexAspect:=10; + 20 : indexAspect:=11; + end; + Adr:=feux[i].adresse; + //Affiche(IntToSTR(i)+' '+intToSTR(indexAspect)+' '+inttoSTR(dec),clred); + case dec of + // digital bahn + 1: if aspect=20 then begin result:=false;if aff then Affiche('Erreur 340 : Signal '+intToSTR(Adr)+': Combinaison décodeur '+decodeur[dec]+' et aspect '+aspects[indexAspect]+' incompatibles',clred);end; + // cdf + 2: if (aspect>10) and (aspect<20) then begin result:=false;if aff then Affiche('Erreur 341 : Signal '+intToSTR(Adr)+': Combinaison décodeur '+decodeur[dec]+' et aspect '+aspects[indexAspect]+' incompatibles',clred);end; + // ls dec sncf + 3 : if (aspect>10) then begin result:=false;if aff then Affiche('Erreur 342 : Signal '+intToSTR(Adr)+': Combinaison décodeur '+decodeur[dec]+' et aspect '+aspects[indexAspect]+' incompatibles',clred);end; + // LEB + 4 : if aspect>10 then begin result:=false;if aff then Affiche('Erreur 343 : Signal '+intToSTR(Adr)+': Combinaison décodeur '+decodeur[dec]+' et aspect '+aspects[indexAspect]+' incompatibles',clred);end; + // dijikeijs + 5 : if aspect>10 then begin result:=false;if aff then Affiche('Erreur 344 : Signal '+intToSTR(Adr)+': Combinaison décodeur '+decodeur[dec]+' et aspect '+aspects[indexAspect]+' incompatibles',clred);end; + // paco unisemaf + 6 : if aspect>10 then begin result:=false;if aff then Affiche('Erreur 345 : Signal '+intToSTR(Adr)+': Combinaison décodeur '+decodeur[dec]+' et aspect '+aspects[indexAspect]+' incompatibles',clred);end; + // Stéphane ravaux + 7 : if aspect>10 then begin result:=false;if aff then Affiche('Erreur 346 : Signal '+intToSTR(Adr)+': Combinaison décodeur '+decodeur[dec]+' et aspect '+aspects[indexAspect]+' incompatibles',clred);end; + // Arcomora + 8 : if aspect>10 then begin result:=false;if aff then Affiche('Erreur 347 : Signal '+intToSTR(Adr)+': Combinaison décodeur '+decodeur[dec]+' et aspect '+aspects[indexAspect]+' incompatibles',clred);end; + // LS DEC NMBS + 9 : if aspect<>20 then begin result:=false;if aff then Affiche('Erreur 348 : Signal '+intToSTR(Adr)+': Combinaison décodeur '+decodeur[dec]+' et aspect '+aspects[indexAspect]+' incompatibles',clred);end; + // B-models + 10 : if aspect<>20 then begin result:=false;if aff then Affiche('Erreur 349 : Signal '+intToSTR(Adr)+': Combinaison décodeur '+decodeur[dec]+' et aspect '+aspects[indexAspect]+' incompatibles',clred);end; + end; + // personnalisé + if (dec>=NbDecodeurdeBase) then + begin + // nationalité du décodeur + if ((decodeur_pers[dec-NbDecodeurdeBase+1].nation=2) and (aspect<>20)) or + ((decodeur_pers[dec-NbDecodeurdeBase+1].nation=1) and (aspect=20)) then + begin + result:=false; + if aff then Affiche('Erreur 350 : Signal '+intToSTR(Adr)+': Combinaison décodeur '+decodeur[dec]+' et aspect '+aspects[indexAspect]+' incompatibles',clred); + end; + end; + end; +end; + + procedure TFormConfig.ComboBoxDecChange(Sender: TObject); var s: string; i,decodeur : integer; @@ -5162,9 +5564,21 @@ begin if NbreFeuxNbDecodeur+NbreDecPers then exit; + feux[i].decodeur:=decodeur; + Maj_Hint_Signal(i); case decodeur of @@ -5187,6 +5601,8 @@ begin s:=encode_sig_feux(i); formconfig.RichSig.Lines[ligneclicSig]:=s; aff_champs_sig_feux(i); + if not(verif_dec_sig(false)) then FormConfig.labelInfo.Caption:='Combinaison décodeur / aspect incompatible'; + if affevt then Affiche('Evt ComboBox Decodeur',clOrange); end; @@ -5197,11 +5613,12 @@ var lc,i : integer; begin clicliste:=true; raz_champs_sig; - + with Formconfig.RichSig do begin i:=Selstart; lc:=Perform(EM_LINEFROMCHAR,i,0); // numéro de la lignée cliquée + ligne_signal:=lc; clicListeSignal(feux[lc+1].adresse); end; @@ -5248,7 +5665,7 @@ procedure Suiv1; begin if clicliste or (ligneClicSig<0) then exit; if affevt then Affiche('Evt Element suivant1',clOrange); - + if FormConfig.PageControl.ActivePage=FormConfig.TabSheetSig then with Formconfig do begin @@ -5944,7 +6361,7 @@ begin LabelInfo.caption:=' '; aiguillage[index].adresse:=i; aiguillage[index].modifie:=true; - s:=encode_aig(index); + s:=encode_aig(index); formconfig.RichAig.Lines[ligneclicAig]:=s; end; if (modele=tjd) or (modele=tjs) then @@ -5995,15 +6412,25 @@ begin else aspect:=i+6; end; index:=ligneClicSig+1; // index du feu - if index<1 then exit; + if index<1 then + begin + ComboBoxAsp.ItemIndex:=-1; + if NbreFeux=0 then s:='Crééz un signal ou '; + s:='sélectionnez un signal dans la liste'; + LabelInfo.Caption:=s; + exit; + end; if NbreFeux0 then + begin + labelInfo.caption:='Erreur adresse'; + exit; + end; + labelInfo.caption:=''; + decodeur_pers[deccourant].desc[adr].offsetAdresse:=i; +end; + +// changement combobox choix sorties 1 ou 2 +procedure Tformconfig.modif_ComboTS(Sender : TObject); +var co : tComboBox; + i,idx,adresse,erreur : integer; + s : string; +begin + if deccourant=0 then exit; + co:=Sender as TCombobox; + //i:=co.itemIndex; + i:=extract_int(co.name); + s:=intToSTR(i); + idx:=co.itemIndex; + + val(s[1],i,erreur); // rang + delete(s,1,1); + val(s,adresse,erreur); // adresse + + if i=1 then decodeur_pers[deccourant].desc[adresse].sortie1:=idx+1; + if i=2 then decodeur_pers[deccourant].desc[adresse].sortie2:=idx+1; +end; + +// changement combobox Etats +procedure Tformconfig.modif_ComboL(Sender : TObject); +var co : tComboBox; + idx,i,adresse,erreur : integer; + s : string; +begin + if deccourant=0 then exit; + co:=Sender as TCombobox; + //i:=co.itemIndex; + i:=extract_int(co.name); + s:=intToSTR(i); + idx:=co.itemIndex; + val(s[1],i,erreur); // rang + delete(s,1,1); + val(s,adresse,erreur); // adresse + + if i=1 then decodeur_pers[deccourant].desc[adresse].etat1:=idx; + if i=2 then decodeur_pers[deccourant].desc[adresse].etat2:=idx; +end; + + +procedure rend_visible; +var i,erreur,nombre : integer; +begin + val(formconfig.EditNbreAdr.Text,nombre,erreur); + if (erreur<>0) or (nombre>10) then exit; + + decCourant:=formconfig.ComboBoxDecodeurPerso.ItemIndex+1; + if decCourant<1 then exit; + decodeur_pers[decCourant].nbreAdr:=nombre; + + decodeur_pers[decCourant].nom:=formconfig.ComboBoxDecodeurPerso.items[decCourant-1]; + + maj_decodeurs; + exit; + + for i:=1 to nombre do + begin + ComboTS1[i].Visible:=true; + ComboTS2[i].Visible:=true; + EditT[i].visible:=true; + ComboL1[i].Visible:=true; + ComboL2[i].Visible:=true; + end; + + for i:=nombre+1 to 10 do + begin + ComboTS1[i].Visible:=false; + ComboTS2[i].Visible:=false; + EditT[i].visible:=false; + ComboL1[i].Visible:=false; + ComboL2[i].Visible:=false; end; +end; + +// nouveau décodeur personnalisé + procedure TFormConfig.BoutonNouveauClick(Sender: TObject); + var s: string; + cb : TcomboBox; + te : Tedit; + i,nombre,erreur,decCourant : integer; + begin + if NbreDecPers>=NbreMaxiDecPers then exit; + inc(NbreDecPers); + s:='Personnalisé '+intToSTR(NbreDecPers); + decodeur_pers[NbreDecPers].nom:=s; + decodeur_pers[NbreDecPers].Nation:=1; + nombre:=4; + decodeur_pers[NbreDecPers].NbreAdr:=nombre; + formconfig.EditNbreAdr.Text:=intToSTR(nombre); + + ComboBoxDecodeurPerso.Items.Add(s); + ComboBoxDecodeurPerso.ItemIndex:=NbreDecPers-1; + + decCourant:=formconfig.ComboBoxDecodeurPerso.ItemIndex+1; + + for i:=1 to Nombre do + begin + editT[i].Text:=IntToSTR(i-1); + decodeur_pers[decCourant].desc[i].offsetAdresse:=i-1; + end; + + rend_visible; + // ajouter aux décodeurs personalisés + s:=decodeur_pers[decCourant].nom; + formconfig.ComboBoxDec.Items.add(s); + config_modifie:=true; + // ajouter aux décodeurs + inc(NbDecodeur); + decodeur[NbDecodeur]:=s; + LabelNbDecPers.caption:=intToSTR(NbreDecPers); + + //vérifier si le décodeur est utilisé dans les signaux pour changer son hint + for i:=1 to NbreFeux do + begin + if feux[i].decodeur=NbDecodeurdeBase+decCourant-1 then Maj_Hint_Signal(i); + end; +end; + +procedure TFormConfig.EditNbreAdrChange(Sender: TObject); +var i,erreur : integer; +begin + val(EditNbreAdr.text,i,erreur); + if (erreur<>0) or (i<1) or (i>10) then + begin + LabelInfo.Caption:='Nombre d''adresses valides de 1 à 10'; + exit; + end; + LabelInfo.Caption:=''; + rend_visible; +end; + + +procedure TFormConfig.ComboBoxDecodeurPersoChange(Sender: TObject); +var i,nAdr,a : integer; + s: string; +begin + if affevt then Affiche('Evt ComboBoxDecodeurPerso',clyellow); + + a:=ComboBoxDecodeurPerso.ItemIndex; + if a=-1 then + begin + // changement du nom + if decCourant=0 then exit; + s:=ComboBoxDecodeurPerso.Text; + ComboBoxDecodeurPerso.items[decCourant-1]:=s; + decodeur_pers[decCourant].nom:=s; + decodeur[NbDecodeurdeBase+DecCourant-1]:=s; + ComboBoxDec.Items[NbDecodeurdeBase+DecCourant-1]:=s; + + //vérifier si le décodeur est utilisé dans les signaux pour changer son hint + for i:=1 to NbreFeux do + begin + if feux[i].decodeur=NbDecodeurdeBase+decCourant-1 then Maj_Hint_Signal(i); + end; + + exit; + end; + decCourant:=a+1; + EditNbreAdr.Text:=intToSTR(decodeur_pers[decCourant].NbreAdr); + //Affiche('Décodeur courant = '+intToSTR(decCourant),clyellow); + maj_decodeurs; end; +// renvoie vrai si chaine est dans le combobox 'combo' et renvoie son index +function trouve_entree_combo(combo : Tcombobox;chaine : string;var index : integer) : boolean; +var i,maxi : integer; + trouve : boolean; +begin + i:=0; + maxi:=combo.items.Count; + repeat + trouve:=combo.Items[i]=chaine; + inc(i); + until trouve or (i=maxi); + result:=trouve; + index:=i-1; +end; + +procedure TFormConfig.ButtonSupClick(Sender: TObject); +var s : string; + i,ma,deco,supp : integer; + aff : boolean; +begin + // supprimer des décodeurs personalisés + if decCourant=0 then exit; + + s:='Voulez vous supprimer le décodeur personnalisé '#13+decodeur_pers[decCourant].nom+' ?'; + if Application.MessageBox(pchar(s),pchar('confirm'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then exit; + + //supprimer de la liste des décodeurs peronnalisés + s:=decodeur_pers[decCourant].nom; + if trouve_entree_combo(ComboBoxDec,s,i) then ComboBoxDec.Items.Delete(i) + else exit; - + supp:=i; + Affiche('Suppression décodeur '+intToSTR(supp-1)+' '+s,clOrange); + + //supprimer de la liste des décodeurs si elle est affectée + if trouve_entree_combo(ComboBoxDecodeurPerso,s,i) then ComboBoxDecodeurPerso.Items.Delete(i) + else affiche('Anomalie 1',clred); + + //if decCourant>0 then dec(decCourant); + decCourant:=0; + ComboBoxDecodeurPerso.ItemIndex:=-1; + + inc(i); + ma:=i; + // et supprimer la base + for i:=ma to NbreDecPers-1 do + begin + decodeur_pers[i]:=decodeur_pers[i+1]; + end; + dec(NbreDecPers); + if NbreDecPers=0 then ComboBoxDecodeurPerso.Text:=''; + config_modifie:=true; + maj_decodeurs; + + // supprimer des décodeurs + decodeur[NbDecodeur]:=''; + dec(NbDecodeur); + LabelNbDecPers.caption:=intToSTR(NbreDecPers); + + // si le décodeur est attribué aux signaux, les passer en rien + aff:=false; + for i:=1 to NbreFeux do + begin + deco:=feux[i].decodeur; + if deco=supp then + begin + Affiche('Le décodeur du signal '+intToSTR(Feux[i].adresse)+' a été réaffacté à rien',clOrange); + feux[i].decodeur:=0; + if i=ligne_signal+1 then aff_champs_sig_feux(ligne_signal+1); + aff:=true; + end; + if deco>supp then + begin + dec(feux[i].decodeur); // et décrémenter les autres décodeurs personnalisés de rang supérieur + aff:=true; + end; + + end; + + // réafficher le richedit des signaux + if aff then + begin + richSig.Clear; + for i:=1 to NbreFeux do + begin + s:=encode_sig_feux(i); // encode la ligne depuis le tableau feux + if s<>'' then + begin + RichSig.Lines.Add(s); + RE_ColorLine(RichSig,RichSig.lines.count-1,ClAqua); + Feux[i].modifie:=false; + end; + end; + end; +end; + +procedure TFormConfig.ComboBoxNationChange(Sender: TObject); +var nation : integer; +begin + if deccourant=0 then exit; + nation:=ComboBoxNation.itemIndex+1; + decodeur_pers[decCourant].nation:=nation; + maj_decodeurs; +end; + +begin end. diff --git a/UnitDebug.dfm b/UnitDebug.dfm index 48b34a1..2360597 100644 --- a/UnitDebug.dfm +++ b/UnitDebug.dfm @@ -20,8 +20,8 @@ object FormDebug: TFormDebug OnCreate = FormCreate OnKeyPress = FormKeyPress DesignSize = ( - 831 - 749) + 839 + 757) PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel diff --git a/UnitPilote.dfm b/UnitPilote.dfm index db551de..2f00f66 100644 --- a/UnitPilote.dfm +++ b/UnitPilote.dfm @@ -50,10 +50,11 @@ object FormPilote: TFormPilote Caption = 'Nombre de feux '#224' allumer' end object LabelDec: TLabel - Left = 208 + Left = 200 Top = 192 - Width = 72 + Width = 129 Height = 19 + Alignment = taCenter Caption = 'LabelDec' Font.Charset = ANSI_CHARSET Font.Color = clWindowText @@ -61,6 +62,7 @@ object FormPilote: TFormPilote Font.Name = 'Arial' Font.Style = [fsBold] ParentFont = False + Layout = tlCenter end object Label1: TLabel Left = 240 @@ -126,7 +128,7 @@ object FormPilote: TFormPilote Top = 96 Width = 161 Height = 17 - Caption = 'S'#233'maphore clignotant' + Caption = 'Rouge cli' TabOrder = 5 OnClick = RadioRougeCliClick end @@ -239,8 +241,8 @@ object FormPilote: TFormPilote OnClick = CheckVerrouCarreClick end object GroupBox3: TGroupBox - Left = 8 - Top = 224 + Left = 120 + Top = 40 Width = 193 Height = 73 Caption = 'Signalisation combin'#233'e' diff --git a/UnitPilote.pas b/UnitPilote.pas index 03907ce..681cc05 100644 --- a/UnitPilote.pas +++ b/UnitPilote.pas @@ -72,43 +72,36 @@ type const carre =0 ; carre_F=1; -vert_jaune_H =0 ; vert_jaune_H_F=1; // signal belge - semaphore =1 ; semaphore_F=2; semaphore_cli =2 ; semaphore_cli_F=4; - vert =3 ; vert_F=8; vert_cli =4 ; vert_cli_F=16; - violet =5 ; violet_F=32; -vert_jaune_V =5 ; vert_jaune_V_F=32; - blanc =6 ; blanc_F=64; -rouge_blanc =6 ; rouge_blanc_F=64; // signal belge blanc_cli =7 ; blanc_cli_F=128; - jaune =8 ; jaune_F=256; -deux_jaunes =8 ; deux_jaunes_F=256; // signal belge jaune_cli =9 ; jaune_cli_F=512; - ral_30 =10; ral_30_F=1024; -chiffre =10; chiffre_F=1024; - ral_60 =11; ral_60_F=2048; -chevron =11; chevron_F=2048; - rappel_30 =12; rappel_30_F=4096; -clign =12 ; clign_F=4096; - rappel_60 =13; rappel_60_F=8192; - Disque_D =14; // pour décodeur LDT - ral_60_jaune_cli =15;ral_60_jaune_cli_F=32768; // pour décodeur LDT -SetRaz =15;SetRaz_F=32768; // pour belge - aspect8 =16 ; +// signal belge +// base +vert_jaune_H =0 ; vert_jaune_H_F=1; // signal belge +rouge =1 ; rouge_F=2; +vertB =2 ; vertB_F=4; +vert_jaune_V =3 ; vert_jaune_V_F=8; +rouge_blanc =4 ; rouge_blanc_F=16; // signal belge +deux_jaunes =5 ; deux_jaunes_F=32; // signal belge +// combinée +chiffre =6; chiffre_F=64; +chevron =7; chevron_F=128; +clignote =8; clignote_F=256; +Bita1 =15; Bita1_F=32768; // mise à 1 de bit signal combiné pour belge var FormPilote: TFormPilote; @@ -131,7 +124,7 @@ begin //ImagePilote.Picture.Bitmap:=FormPilote.ImagePilote.picture.bitmap; EtatFeuPilote:=feux[0].EtatSignal; Vcanvas:=FormPilote.ImagePilote.picture.bitmap.Canvas; - + case feux[i].aspect of // feux de signalisation 2 : dessine_feu2(Vcanvas,0,0,1,1,EtatFeupilote,1); @@ -150,9 +143,26 @@ begin end; end; +// renvoie la nation du signal 0 +function nation : integer; +var i,dec,asp : integer; +begin + i:=1; + dec:=feux[0].decodeur; + asp:=feux[0].aspect; + if asp=20 then i:=2; + // si décodeur personalisé + if (dec>=NbDecodeurdeBase) and (dec20 then + if n<>20 then begin + groupBox3.Visible:=false; Radiocarre.Caption:='Carré'; Radioviolet.Caption:='Violet'; RadioJauneCli.Caption:='Avertissement clignotant'; @@ -325,6 +337,7 @@ begin radioJaunecli.visible:=true; radioRougecli.visible:=true; radioBlanccli.visible:=true; + end; @@ -383,19 +396,19 @@ end; procedure TFormPilote.CheckChiffreClick(Sender: TObject); begin - if checkChiffre.Checked then Maj_Etat_Signal(0,chiffre) else Maj_Etat_Signal(0,chiffre or SetRaz_F); + if checkChiffre.Checked then Maj_Etat_Signal_belge(0,chiffre_F or bita1_F) else Maj_Etat_Signal_belge(0,chiffre_F); dessine_feu_pilote; end; procedure TFormPilote.CheckChevronClick(Sender: TObject); begin - if checkChevron.Checked then Maj_Etat_Signal(0,chevron) else Maj_Etat_Signal(0,chevron or setRaz_F); + if checkChevron.Checked then Maj_Etat_Signal(0,chevron_F or bita1_F) else Maj_Etat_Signal(0,chevron_F ); dessine_feu_pilote; end; procedure TFormPilote.CheckClignoteClick(Sender: TObject); begin - if checkclignote.Checked then Maj_Etat_Signal(0,clign) else Maj_Etat_Signal(0,clign or setRaz_F); + if checkclignote.Checked then Maj_Etat_Signal(0,clignote_F or bita1_F) else Maj_Etat_Signal(0,clignote_F ); dessine_feu_pilote; end; diff --git a/UnitPrinc.dfm b/UnitPrinc.dfm index c6776ab..ed21de2 100644 --- a/UnitPrinc.dfm +++ b/UnitPrinc.dfm @@ -2224,8 +2224,8 @@ object FormPrinc: TFormPrinc Top = 65528 end object SaveDialog: TSaveDialog - Left = 888 - Top = 16 + Left = 832 + Top = 65528 end object PopupMenuFenRich: TPopupMenu Left = 208 diff --git a/UnitPrinc.pas b/UnitPrinc.pas index 4371cc7..32ffea1 100644 --- a/UnitPrinc.pas +++ b/UnitPrinc.pas @@ -1,10 +1,10 @@ Unit UnitPrinc; -// 8/7 17h +// 30/7 11 (******************************************** programme signaux complexes Graphique Lenz Delphi 7 + activeX Tmscomm + clientSocket ou RadStudio - option de compilations: options du debugger/exception du langage : décocher "arreter sur execeptions delphi" + option de compilations: options du debugger/exception du langage : décocher "arreter sur exceptions delphi" sinon une exception surgira au moment de l'ouverture du com Dans projet/option/fiches : fiches disponibles : formtco uniquement ******************************************** @@ -285,6 +285,7 @@ MaxBranches=100; MaxElBranches=200; NbreMaxiAiguillages=200; NbreMaxiSignaux=200; +NbreMaxiDecPers=10; // nombre maxi de décodeurs personnalisés LargImg=50;HtImg=91; // Dimensions image des feux const_droit=2; // positions aiguillages transmises par la centrale LENZ const_devie=1; // positions aiguillages transmises par la centrale LENZ @@ -305,17 +306,35 @@ Max_Simule=10000; Max_Event_det_tick=30000; EtatSign : array[0..13] of string[20] =('carré','sémaphore','sémaphore cli','vert','vert cli','violet', 'blanc','blanc cli','jaune','jaune cli','ral 30','ral 60','rappel 30','rappel 60'); -EtatSignBelge: array[0..11] of string[30]= - ('vert jaune horizontal','rouge','rouge cli','vert','vert cli','vert jaune vertical','rouge blanc','rouge blanc cli', - 'deux jaunes','deux jaunes cli','Chiffre','Chevron'); +// texte de la combo box - attention ce n'est pas l'index de feux[x].aspect!! +Aspects : array[0..11] of string[20]=('2 feux','3 feux','4 feux','5 feux','7 feux','9 feux','Directionnel 2 feux','Directionnel 3 feux','Directionnel 4 feux', + 'Directionnel 5 feux','Directionnel 6 feux','Signal belge type 1'); + +// conversion index et feux[aspect] +// index aspect +// 2feux 0 2 +// 3feux 1 3 +// 4feux 2 4 +// 5feux 3 5 +// 7feux 4 7 +// 9feux 5 9 +// dir2 feux 6 12 +// dir3 feux 7 13 +// dir4 feux 8 14 +// dir5 feux 9 15 +// dir6 feux 10 16 +// belge 11 20 + -NbDecodeur = 11; -decodeur : array[0..NbDecodeur-1] of string[20] =('rien','Digital Bahn','CDF','LS-DEC-SNCF','LEB','Digikeijs 4018','Unisemaf Paco','Stéphane Ravaut', - 'Arcomora','LS-DEC-NMBS','B-models'); -Etats : array[0..19] of string[30]=('Non commandé', +Etats : array[0..20] of string[30]=('Non commandé', 'carré','sémaphore','sémaphore cli','vert','vert cli','violet','blanc','blanc cli','jaune','jaune cli', - 'ralen 30','ralen 60','ralen 60 + jaune cli','rappel 30','rappel 60','rappel 30 + jaune','rappel 30 + jaune cli','rappel 60 + jaune','rappel 60 + jaune cli'); + 'ralen 30','ralen 60','rappel 30','rappel 60','ralen 60 + jaune cli','rappel 30 + jaune','rappel 30 + jaune cli', + 'rappel 60 + jaune','rappel 60 + jaune cli','reserve'); + +EtatSignBelge: array[0..9] of string[30]= + ('Non commandé','vert jaune horizontal','rouge','vert','vert jaune vertical','rouge blanc', + 'deux jaunes','Chiffre','Chevron','Clignote'); type Taccessoire = (aigP,feu); // aiguillage ou feu @@ -365,7 +384,7 @@ Taiguillage = record end; TSignal = record - adresse, aspect : integer; // adresse du signal, aspect (2 feux..9 feux 12=direction 2 feux .. 16=direction 6 feux) (20=signal belge 1) + adresse, aspect : integer; // adresse du signal, aspect (2 feux..9 feux 12=direction 2 feux .. 16=direction 6 feux) (11=signal belge 1) Img : TImage; // Pointeur sur structure TImage du feu Lbl : TLabel; // pointeur sur structure Tlabel du feu checkFB : TCheckBox; // pointeur sur structure Checkbox "demande feu blanc" @@ -421,7 +440,7 @@ var Nbre_recu_cdm,Tempo_chgt_feux,Adj1,Adj2,NbrePN,ServeurInterfaceCDM,index_couleur, ServeurRetroCDM,TailleFonte,Nb_Det_Dist,Tdoubleclic,algo_Unisemaf,fA,fB, etape,idEl,avecRoulage,intervalle_courant,filtrageDet0,SauvefiltrageDet0, - TpsTimeoutSL,formatY,OsBits : integer; + TpsTimeoutSL,formatY,OsBits,NbreDecPers,NbDecodeur,NbDecodeurdeBase : integer; ack,portCommOuvert,traceTrames,AffMem,CDM_connecte,dupliqueEvt,affiche_retour_dcc, Raz_Acc_signaux,AvecInit,AvecTCO,terminal,Srvc_Aig,Srvc_Det,Srvc_Act,MasqueBandeauTCO, @@ -509,6 +528,17 @@ var FichierSon,trainDecl,TrainDest,TrainCourant : string; end; + decodeur_pers : array[1..NbreMaxiDecPers] of + record + nom : string; + NbreAdr,nation : integer; + desc : array[1..10] of //index=adresse d'offset + record + etat1,etat2,offsetAdresse,sortie1,sortie2 : integer; + end; + end; + + Ancien_actionneur : array[0..1024] of integer; KeyInputs: array of TInput; @@ -590,6 +620,10 @@ var etat : boolean; end; end; + + + decodeur : array[0..30] of string[20]; + Feu_supprime,Feu_sauve : TSignal; Aig_supprime,Aig_sauve : TAiguillage; BrancheN : array[1..MaxBranches,1..MaxElBranches] of TBranche; @@ -608,6 +642,7 @@ procedure dessine_feu9(Acanvas : Tcanvas;x,y : integer;frX,frY : real;etatsignal procedure dessine_feu20(Acanvas : Tcanvas;x,y : integer;frX,frY : real;etatsignal : word;orientation : integer;adresse : integer); procedure dessine_dirN(Acanvas : Tcanvas;x,y : integer;frX,frY : real;EtatSignal : word;orientation,N : integer); procedure Maj_Etat_Signal(adresse,aspect : integer); +procedure Maj_Etat_Signal_Belge(adresse,aspect : integer); procedure Affiche(s : string;lacouleur : TColor); procedure envoi_signal(Adr : integer); procedure pilote_direction(Adr,nbre : integer); @@ -651,6 +686,7 @@ function testBit(n : word;position : integer) : boolean; procedure det_contigu(det1,det2 : integer;var suivant : integer;var ElSuiv : TEquipement); Function SetBit(n : word;position : integer) : word; procedure inverse_image(imageDest,ImageSrc : Timage) ; +function extract_int(s : string) : integer; implementation @@ -702,7 +738,7 @@ begin SetBit:=n or (1 shl position); end; -// renvoie le 1er numéro de bit à 1 du mot +// renvoie le 1er numéro de bit à 1 du mot (en commençant à droite) // PremBitNum(1)=0 // PremBitNum(4)=2 // si pas de bit à 1, renvoie -1 @@ -1294,12 +1330,12 @@ var xblanc,xvert,xrouge,Yblanc,xjauneBas,xJauneHaut,yJauneBas,yJauneHaut,YVert,Y inverse,etatChevron,EtatChiffre,codeClignote : boolean; r : Trect; begin - code_to_aspect(Etatsignal,code,combine); // et aspect - combine:=etatSignal and $fc00; + code:=etatSignal and $3f; + combine:=etatSignal and $1c0; // LDT-DEC-NMBS ou b-model etatChiffre:=testBit(combine,chiffre); etatChevron:=testBit(combine,chevron); - CodeClignote:=testBit(combine,clign); + CodeClignote:=testBit(combine,clignote); largeur:=57; rayon:=round(6*frX); @@ -1335,6 +1371,7 @@ begin x3:=largeur-x3; Xchiffre:=32; Xfin:=44; + codeclignote:=true; end; if XChiffre>Xfin then echange(Xchiffre,Xfin); @@ -1389,24 +1426,24 @@ begin x3:=round(X3*frx)+x; y3:=round(y3*fry)+y; // extinctions - if not((code=vert) and codeclignote and clignotant) then cercle(ACanvas,xvert,yvert,rayon,GrisF); - if not((code=semaphore) and codeclignote and clignotant) then cercle(ACanvas,xrouge,yrouge,rayon,GrisF); - if not((code=rouge_blanc) and codeclignote and clignotant) then + if not((code=vertB_F) and codeclignote and clignotant) then cercle(ACanvas,xvert,yvert,rayon,GrisF); + if not((code=rouge_F) and codeclignote and clignotant) then cercle(ACanvas,xrouge,yrouge,rayon,GrisF); + if not((code=rouge_blanc_F) and codeclignote and clignotant) then begin cercle(ACanvas,xBlanc,yBlanc,rayon,GrisF); cercle(ACanvas,xRouge,yRouge,rayon,GrisF); end; - if not((code=deux_jaunes) and codeclignote and clignotant) then + if not((code=deux_jaunes_F) and codeclignote and clignotant) then begin cercle(ACanvas,xjaunebas,yjauneBas,rayon,GrisF); cercle(ACanvas,xjaunehaut,yjauneHaut,rayon,GrisF); end; - if not((code=vert_jaune_H) and codeclignote and clignotant) then + if not((code=vert_jaune_H_F) and codeclignote and clignotant) then begin cercle(ACanvas,xjauneHaut,yjauneHaut,rayon,grisF); cercle(ACanvas,xvert,yvert,rayon,grisF); end; - if not((code=vert_jaune_V) and codeclignote and clignotant) then + if not((code=vert_jaune_V_F) and codeclignote and clignotant) then begin cercle(ACanvas,xjauneBas,yjauneBas,rayon,grisF); cercle(ACanvas,xvert,yvert,rayon,grisF); @@ -1414,24 +1451,24 @@ begin //allumages - if ((code=vert) and codeClignote and clignotant) or ((code=vert) and not(codeclignote)) then cercle(ACanvas,xvert,yvert,rayon,clGreen); - if ((code=semaphore) and codeClignote and clignotant) or ((code=semaphore) and not(codeclignote)) then cercle(ACanvas,xrouge,yrouge,rayon,clRed); - if ((code=rouge_blanc) and codeClignote and clignotant) or ((code=rouge_blanc) and not(codeclignote)) then + if ((code=vertB_F) and codeClignote and clignotant) or ((code=vertB_F) and not(codeclignote)) then cercle(ACanvas,xvert,yvert,rayon,clGreen); + if ((code=rouge_F) and codeClignote and clignotant) or ((code=rouge_F) and not(codeclignote)) then cercle(ACanvas,xrouge,yrouge,rayon,clRed); + if ((code=rouge_blanc_F) and codeClignote and clignotant) or ((code=rouge_blanc_F) and not(codeclignote)) then begin cercle(ACanvas,xblanc,yblanc,rayon,clWhite); cercle(ACanvas,xrouge,yrouge,rayon,clred); end; - if ((code=deux_jaunes) and codeClignote and clignotant) or ((code=deux_jaunes) and not(codeclignote)) then + if ((code=deux_jaunes_F) and codeClignote and clignotant) or ((code=deux_jaunes_F) and not(codeclignote)) then begin cercle(ACanvas,xjauneBas,yjauneBas,rayon,clOrange); cercle(ACanvas,xjauneHaut,yjauneHaut,rayon,clOrange); end; - if ((code=vert_jaune_H) and codeClignote and clignotant) or ((code=vert_jaune_H) and not(codeclignote)) then + if ((code=vert_jaune_H_F) and codeClignote and clignotant) or ((code=vert_jaune_H_F) and not(codeclignote)) then begin cercle(ACanvas,xjauneHaut,yjauneHaut,rayon,clorange); cercle(ACanvas,xvert,yvert,rayon,clgreen); end; - if ((code=vert_jaune_V) and codeClignote and clignotant) or ((code=vert_jaune_V) and not(codeclignote)) then + if ((code=vert_jaune_V_F) and codeClignote and clignotant) or ((code=vert_jaune_V_F) and not(codeclignote)) then begin cercle(ACanvas,xjaunebas,yjaunebas,rayon,clorange); cercle(ACanvas,xvert,yvert,rayon,clgreen); @@ -1872,7 +1909,7 @@ begin if feux[rang].contrevoie then begin inverse_image(Feux[rang].Img,Formprinc.ImageSignal20); - feux[rang].EtatSignal:=feux[rang].EtatSignal+clign_F; + feux[rang].EtatSignal:=feux[rang].EtatSignal+clignote_F; end; end; dessine_feu_mx(Feux[rang].Img.Canvas,0,0,1,1,feux[rang].adresse,1); @@ -2399,27 +2436,44 @@ begin end; // renvoie la chaîne de l'état du signal -function chaine_signal(etat,decodeur : word) : string; -var aspect,combine : integer; +function chaine_signal(etat,adresse : word) : string; +var a,i,aspect,combine,nation : integer; s : string; begin - if decodeur>=9 then + i:=index_feu(adresse); + nation:=1; + a:=feux[i].aspect; + if a=20 then nation:=2; + + if nation=2 then begin // en signalisation belge, on peut avoir plusieurs bits à 1 simultanément en combine - code_to_aspect(etat,aspect,combine); - combine:=etat and $fc00; - // LDT-DEC-NMBS ou b-model - s:=EtatSignBelge[Aspect]; + aspect:=etat and $3f; + combine:=etat and $1c0; + aspect:=PremBitNum(aspect) ; + s:=EtatSignBelge[Aspect+1]; if combine<>0 then begin - if testBit(combine,chiffre) then s:=s+'+'+EtatSignBelge[chiffre]; // bit 10 - if testBit(combine,chevron) then s:=s+'+'+EtatSignBelge[chevron]; // bit 11 + if testBit(combine,chiffre) then s:=s+'+'+EtatSignBelge[chiffre+1]; + if testBit(combine,chevron) then s:=s+'+'+EtatSignBelge[chevron+1]; end; result:=s; exit; end; + + // signalisation française + if (a>10) and (a<17) then + begin + // directionnel + s:=intToSTR(etat)+' feu'; + if etat>1 then s:=s+'x'; + result:=s; + exit; + end; + code_to_aspect(etat,aspect,combine); s:=''; + if (aspect=16) then s:='' else begin if aspect<>-1 then s:=etatSign[aspect];end; if combine<>16 then begin @@ -2437,34 +2491,39 @@ var i,code,combine : integer; etats : word; // La signalisation combinée est à partir du bit 10 (chiffre, chevron) begin - if debug=3 then formprinc.Caption:='Maj_Etat_Signal '+IntToSTR(adresse); + if debug=3 then formprinc.Caption:='Maj_Etat_Signal '+IntToSTR(adresse)+' '+intToSTR(aspect); i:=index_feu(adresse); // if testBit(feux[i].EtatSignal,aspect)=false then // si le bit dans l'état du signal n'est pas allumé, procéder. begin // signalisation de base - if aspect<=9 then + + if aspect<=$3f then begin - // razer tous les bits non combinés (de 0 à 9) - etats:=feux[i].EtatSignal and not($03FF); + // razer tous les bits non combinés + etats:=feux[i].EtatSignal and not($3F); // et allumer le nouveau etats:=setbit(etats,aspect); feux[i].EtatSignal:=etats; end; // signalisation combinée - if aspect>=10 then + if (aspect and $1C0)<>0 then begin etats:=feux[i].EtatSignal; - //si le bit 15 est à 1, c'est l'indicateur de raz - if testBit(aspect,setraz) then + //si le bit 15 est à 1, c'est l'indicateur de mise à 1 + if testBit(aspect,bita1) then begin - etats:=Razbit(etats,setraz); - etats:=RazBit(etats,aspect); + etats:=etats or (aspect and $1C0); + feux[i].EtatSignal:=feux[i].EtatSignal or etats; end - else etats:=setBit(etats,aspect); + else + begin + etats:=etats and not(aspect and $1c0); + feux[i].EtatSignal:=feux[i].EtatSignal and etats; + end; - feux[i].EtatSignal:=etats; end; end; + end; // mise à jour état signal complexe francais dans le tableau de bits du signal EtatSignalCplx @@ -2531,7 +2590,7 @@ var i,d : integer; begin i:=index_feu(adresse); d:=feux[i].aspect; - if d=20 then Maj_Etat_Signal_belge(adresse,aspect) + if d=20 then Maj_Etat_Signal_belge(adresse,aspect) else Maj_Etat_Signal_fr(adresse,aspect); end; @@ -2800,12 +2859,12 @@ begin code:=feux[i].EtatSignal; nombre:=feux[i].Na; // nombre d'adresses occupées par le signal code_to_aspect(code,aspect,combine); - s:='Signal CDF: ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[i].decodeur); + s:='Signal CDF: ad'+IntToSTR(adresse)+'='+chaine_signal(code,adresse); if traceSign then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin - s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,feux[i].decodeur); + s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,adresse); AfficheDebug(s,clyellow); end; @@ -2855,12 +2914,12 @@ begin begin code:=feux[index].EtatSignal; //code_to_aspect(code,aspect,combine); - s:='Signal SR: ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[index].decodeur); + s:='Signal SR: ad'+IntToSTR(adresse)+'='+chaine_signal(code,adresse); if traceSign then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin - s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[index].EtatSignal,feux[index].decodeur); + s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[index].EtatSignal,adresse); AfficheDebug(s,clyellow); end; @@ -2921,12 +2980,12 @@ begin begin code:=feux[index].EtatSignal; code_to_aspect(code,aspect,combine); - s:='Signal LEB: ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[index].decodeur); + s:='Signal LEB: ad'+IntToSTR(adresse)+'='+chaine_signal(code,adresse); if traceSign then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin - s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[index].EtatSignal,feux[index].decodeur); + s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[index].EtatSignal,adresse); AfficheDebug(s,clyellow); end; @@ -2975,12 +3034,12 @@ begin code:=feux[index].EtatSignal; asp:=feux[index].aspect; code_to_aspect(code,aspect,combine); - s:='Signal Arcomora: ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[index].decodeur); + s:='Signal Arcomora: ad'+IntToSTR(adresse)+'='+chaine_signal(code,adresse); if traceSign then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin - s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[index].EtatSignal,feux[index].decodeur); + s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[index].EtatSignal,adresse); AfficheDebug(s,clyellow); end; @@ -3094,12 +3153,12 @@ begin begin code:=feux[i].EtatSignal; code_to_aspect(code,aspect,combine); - s:='Signal NMRA: ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[i].decodeur); + s:='Signal NMRA: ad'+IntToSTR(adresse)+'='+chaine_signal(code,adresse); if traceSign then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin - s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,feux[i].decodeur); + s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,adresse); AfficheDebug(s,clyellow); end; @@ -3144,12 +3203,12 @@ begin begin code:=feux[index].EtatSignal; code_to_aspect(code,aspect,combine); - s:='Signal Unisemaf: ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[index].decodeur); + s:='Signal Unisemaf: ad'+IntToSTR(adresse)+'='+chaine_signal(code,adresse); if traceSign then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin - s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[index].EtatSignal,feux[index].decodeur); + s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[index].EtatSignal,adresse); AfficheDebug(s,clyellow); end; // pour Unisemaf, la cible est définie dans le champ Unisemaf de la structure feux @@ -3644,84 +3703,118 @@ begin end; end; +// décodeur b-models +// l'adresse du signal doit être un multiple de 8 +1 +// un signal peut occuper 1 3 4 ou 5 adresses procedure envoi_b_models(adresse : integer); var na,code,aspect,combine,mode : integer; afb,recht,i : integer; s : string; begin i:=index_feu(adresse); - if (feux[i].AncienEtat<>feux[i].EtatSignal) then //; && (stop_cmd==FALSE)) + if (feux[i].AncienEtat<>feux[i].EtatSignal) then begin code:=feux[i].EtatSignal; code_to_aspect(code,aspect,combine); - s:='Signal b_models: ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[i].decodeur); + combine:=code and $fc00; + s:='Signal b_models: ad'+IntToSTR(adresse)+'='+chaine_signal(code,adresse); if traceSign then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin - s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,feux[i].decodeur); + s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,adresse); AfficheDebug(s,clyellow); end; - na:=feux[i].Na; + na:=feux[i].Na; // nombre d'adresses // doc VB 5 lampes + chiffre + V // marqué recht et Afb dans la doc !! - afb:=1; // afb - recht:=2; // recht + afb:=1; // afb rouge + recht:=2; // recht vert if aspect=semaphore then begin pilote_acc(adresse,afb,feu); - if (na>=4) and (combine=chiffre) then pilote_acc(adresse+3,afb,feu); // chiffre - if (na>=5) and (combine=chevron) then pilote_acc(adresse+4,afb,feu); // chevron - end; - if aspect=rouge_blanc then - begin - pilote_acc(adresse+2,recht,feu); - if na>=4 then pilote_acc(adresse+3,afb,feu); - if na>=5 then pilote_acc(adresse+4,afb,feu); + if (na>=4) then + begin + // chiffre allume éteint + if testbit(combine,chiffre) then pilote_acc(adresse+3,recht,feu) else pilote_acc(adresse+3,afb,feu) + end; + if (na>=5) then + begin + // chevron + if testbit(combine,chevron) then pilote_acc(adresse+4,recht,feu) else pilote_acc(adresse+4,afb,feu) + end; end; if aspect=vert then begin pilote_acc(adresse,recht,feu); - if (na>=4) and (combine=chiffre) then pilote_acc(adresse+3,afb,feu); - if (na>=5) and (combine=chevron) then pilote_acc(adresse+4,afb,feu); + if (na>=4) then + begin + // chiffre + if testbit(combine,chiffre) then pilote_acc(adresse+3,recht,feu) else pilote_acc(adresse+3,afb,feu) + end; + if (na>=5) then + begin + // chevron + if testbit(combine,chevron) then pilote_acc(adresse+4,recht,feu) else pilote_acc(adresse+4,afb,feu) + end; end; - if aspect=deux_jaunes then + if na=1 then exit; + if aspect=deux_jaunes then begin pilote_acc(adresse+1,afb,feu); - if na>=4 then pilote_acc(adresse+3,afb,feu); - if na>=5 then pilote_acc(adresse+4,afb,feu); + if (na>=4) then + begin + // chiffre + if testbit(combine,chiffre) then pilote_acc(adresse+3,recht,feu) else pilote_acc(adresse+3,afb,feu) + end; + if (na>=5) then + begin + // chevron + if testbit(combine,chevron) then pilote_acc(adresse+4,recht,feu) else pilote_acc(adresse+4,afb,feu) + end; end; if aspect=vert_jaune_H then begin pilote_acc(adresse+1,recht,feu); - if na>=4 then pilote_acc(adresse+3,afb,feu); - if na>=5 then pilote_acc(adresse+4,afb,feu); - end; - if (aspect=vert) and (combine=chiffre) then - begin - pilote_acc(adresse,recht,feu) ; - if na>=4 then pilote_acc(adresse+3,recht,feu); - if na>=5 then pilote_acc(adresse+4,afb,feu); - end; - if (aspect=deux_jaunes) then - begin - pilote_acc(adresse+1,afb,feu) ; - if na>=4 then pilote_acc(adresse+3,recht,feu); - if na>=5 then pilote_acc(adresse+4,afb,feu); - end; - if aspect=vert_jaune_H then - begin - pilote_acc(adresse+1,recht,feu); - if na>=4 then pilote_acc(adresse+3,recht,feu); - if na>=5 then pilote_acc(adresse+4,afb,feu); + if (na>=4) then + begin + // chiffre + if testbit(combine,chiffre) then pilote_acc(adresse+3,recht,feu) else pilote_acc(adresse+3,afb,feu) + end; + if (na>=5) then + begin + // chevron + if testbit(combine,chevron) then pilote_acc(adresse+4,recht,feu) else pilote_acc(adresse+4,afb,feu) + end; end; if aspect=vert_jaune_V then begin - pilote_acc(adresse+1,afb,feu) ; - if na>=4 then pilote_acc(adresse+3,afb,feu); - if na>=5 then pilote_acc(adresse+4,recht,feu); + pilote_acc(adresse+2,afb,feu) ; + if (na>=4) then + begin + // chiffre + if testbit(combine,chiffre) then pilote_acc(adresse+3,recht,feu) else pilote_acc(adresse+3,afb,feu) + end; + if (na>=5) then + begin + // chevron + if testbit(combine,chevron) then pilote_acc(adresse+4,recht,feu) else pilote_acc(adresse+4,afb,feu) + end; + end; + if aspect=rouge_blanc then + begin + pilote_acc(adresse+2,recht,feu); + if (na>=4) then + begin + // chiffre + if testbit(combine,chiffre) then pilote_acc(adresse+3,recht,feu) else pilote_acc(adresse+3,afb,feu) + end; + if (na>=5) then + begin + // chevron + if testbit(combine,chevron) then pilote_acc(adresse+4,recht,feu) else pilote_acc(adresse+4,afb,feu) + end; end; - end; end; @@ -3743,12 +3836,12 @@ begin begin code:=feux[i].EtatSignal; code_to_aspect(code,aspect,combine); - s:='Signal LDT_NMBS: ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[i].decodeur); + s:='Signal LDT_NMBS: ad'+IntToSTR(adresse)+'='+chaine_signal(code,adresse); if traceSign then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin - s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,feux[i].decodeur); + s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,adresse); AfficheDebug(s,clyellow); end; if aspect=vert then begin pilote_acc(adresse,2,feu);end; @@ -3778,12 +3871,12 @@ begin begin code:=feux[i].EtatSignal; code_to_aspect(code,aspect,combine); - s:='Signal LDT: ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[i].decodeur); + s:='Signal LDT: ad'+IntToSTR(adresse)+'='+chaine_signal(code,NbDecodeurdeBase+NbreDecPers-1); if traceSign then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin - s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,feux[i].decodeur); + s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,adresse); AfficheDebug(s,clyellow); end; @@ -3835,7 +3928,7 @@ begin begin code:=feux[i].EtatSignal; code_to_aspect(code,aspect,combine); - s:='Signal virtuel: ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[i].decodeur); + s:='Signal virtuel: ad'+IntToSTR(adresse)+'='+chaine_signal(code,adresse); if traceSign then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); end; @@ -3924,12 +4017,12 @@ begin code:=feux[i].EtatSignal; nombre:=feux[i].Na; // nombre d'adresses occupées par le signal code_to_aspect(code,aspect,combine); - s:='Signal digikeijs 4018: ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[i].decodeur); + s:='Signal digikeijs 4018: ad'+IntToSTR(adresse)+'='+chaine_signal(code,adresse); if traceSign then affiche(s,clOrange); if Affsignal then afficheDebug(s,clOrange); if AffDetSig then begin - s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,feux[i].decodeur); + s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,adresse); AfficheDebug(s,clyellow); end; @@ -3982,12 +4075,12 @@ begin begin code:=feux[i].EtatSignal; code_to_aspect(code,aspect,combine); - s:='Signal Bahn: ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[i].decodeur); + s:='Signal Bahn: ad'+IntToSTR(adresse)+'='+chaine_signal(code,adresse); if traceSign then affiche(s,clOrange); if Affsignal or traceListe then afficheDebug(s,clOrange); if AffDetSig then begin - s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,feux[i].decodeur); + s:='Tick='+IntToSTR(tick)+' Signal '+IntToSTR(adresse)+'='+chaine_signal(feux[i].EtatSignal,adresse); AfficheDebug(s,clyellow); end; //Affiche(IntToSTR(aspect)+' '+inttoSTR(combine),clOrange); @@ -4030,6 +4123,100 @@ begin end; end; +procedure envoi_decodeur_pers(Adresse : integer); +var s : string; + d,dp,i,j,etat,asp,combine,aspect,nAdresses : integer; + trouve1,trouve2,trouve3,trouve4 : boolean; +begin + i:=index_feu(adresse); + etat:=feux[i].EtatSignal; + if (feux[i].AncienEtat<>etat) then //; && (stop_cmd==FALSE)) + begin + d:=feux[i].decodeur; + dp:=d-NbDecodeurdeBase+NbreDecPers-1; + if dp<0 then exit; + s:='Signal '+decodeur_pers[dp].nom+' : ad'+IntToSTR(adresse)+'='+chaine_signal(etat,adresse); + Affiche(s,clOrange); + + asp:=feux[i].aspect; + if asp<>20 then + // français + begin + if decodeur_pers[dp].nation<>1 then + begin + Affiche('Erreur 380 : le signal '+IntToSTR(adresse)+' est français mais un décodeur belge',clred); + exit; + end; + j:=1; + code_to_aspect(etat,aspect,combine); + nAdresses:=decodeur_pers[dp].NbreAdr; + // trouver l'état dans le décodeur + repeat + if (aspect<>-1) and (combine=-1) then + begin + // base + trouve1:=decodeur_pers[dp].desc[j].etat1=aspect+1; + trouve2:=decodeur_pers[dp].desc[j].etat2=aspect+1; + end; + if (aspect=-1) and (combine<>-1) then + begin + // signalisation non combinée (ralen30,60 rappel 30,60) + trouve3:=decodeur_pers[dp].desc[j].etat1=combine+1; + trouve4:=decodeur_pers[dp].desc[j].etat2=combine+1; + end; + // combinée + if (combine<>-1) and (aspect<>-1) then + begin + // ral_60+jaune cli + trouve3:=false;trouve4:=false; + if (aspect=jaune_cli) and (combine=ral_60) then + begin + trouve3:=(decodeur_pers[dp].desc[j].etat1=15); + trouve4:=(decodeur_pers[dp].desc[j].etat2=15); + end; + // rappel_30+jaune + if (aspect=jaune) and (combine=rappel_30) then + begin + trouve3:=(decodeur_pers[dp].desc[j].etat1=16); + trouve4:=(decodeur_pers[dp].desc[j].etat2=16); + end; + // rappel_30+jaune cli + if (aspect=jaune_cli) and (combine=rappel_30) then + begin + trouve3:=(decodeur_pers[dp].desc[j].etat1=17); + trouve4:=(decodeur_pers[dp].desc[j].etat2=17); + end; + // rappel_60+jaune + if (aspect=jaune) and (combine=rappel_60) then + begin + trouve3:=(decodeur_pers[dp].desc[j].etat1=18); + trouve4:=(decodeur_pers[dp].desc[j].etat2=18); + end; + // rappel_60+jaune cli + if (aspect=jaune_cli) and (combine=rappel_60) then + begin + trouve3:=(decodeur_pers[dp].desc[j].etat1=19); + trouve4:=(decodeur_pers[dp].desc[j].etat2=19); + end; + end; + inc(j); + until trouve1 or trouve2 or trouve3 or trouve4 or (j>nAdresses) or (j=11); + dec(j); + if trouve1 or trouve3 then + begin + pilote_ACC(adresse+decodeur_pers[dp].desc[j].offsetAdresse,decodeur_pers[dp].desc[j].sortie1,feu) ; + // Affiche(intToSTR(adresse+decodeur_pers[dp].desc[j].offsetAdresse)+' '+intToSTR(decodeur_pers[dp].desc[j].sortie1),clYellow); + end; + if trouve2 or trouve4 then + begin + pilote_ACC(adresse+decodeur_pers[dp].desc[j].offsetAdresse,decodeur_pers[dp].desc[j].sortie2,feu) ; + // Affiche(intToSTR(adresse+decodeur_pers[dp].desc[j].offsetAdresse)+' '+intToSTR(decodeur_pers[dp].desc[j].sortie2),clYellow); + end; + end; + end; +end; + + // renvoie l'adresse du détecteur suivant des deux éléments contigus // TypeElprec/actuel: 1= détecteur 2= aiguillage 4=Buttoir // algo= type d'algorithme pour suivant_alg3 @@ -4081,7 +4268,7 @@ end; // pilotage d'un signal, et mise à jour du graphisme du feu dans les 3 fenetres procedure envoi_signal(Adr : integer); -var i,it,j,index_train,adresse,detect,detsuiv,a,b,aspect,x,y,TailleX,TailleY,Orientation,AdrTrain : integer; +var i,it,j,index_train,adresse,detect,detsuiv,a,b,aspect,x,y,TailleX,TailleY,Orientation,AdrTrain,dec : integer; ImageFeu : TImage; frX,frY : real; s : string; @@ -4100,8 +4287,9 @@ begin begin if (feux[i].aspect<10) or (feux[i].aspect>=20) then // si signal non directionnel begin + dec:=feux[i].decodeur; // envoie la commande au décodeur - case feux[i].decodeur of + case dec of 0 : envoi_virtuel(Adr); 1 : envoi_signalBahn(Adr); 2 : envoi_CDF(Adr); @@ -4115,6 +4303,10 @@ begin 10 : envoi_b_models(adr); end; + if (dec>=NbDecodeurdeBase) then + if (dec0 then Maj_Etat_Signal_belge(AdrFeu,chiffre) + if feux[index].verscontrevoie then Maj_Etat_Signal_belge(AdrFeu,chevron_F or bita1_F) else Maj_Etat_Signal_belge(AdrFeu,chevron_F); + if aiguillage[indexAig].vitesse<>0 then Maj_Etat_Signal_belge(AdrFeu,chiffre_F or bita1_F) // allumer le chiffre else - Maj_Etat_Signal_belge(AdrFeu,chiffre or setRaz_F); + Maj_Etat_Signal_belge(AdrFeu,chiffre_F); // effacer le chiffre end - else begin Maj_Etat_Signal_belge(AdrFeu,chiffre or setRaz_F); Maj_Etat_Signal_belge(AdrFeu,chevron or setRaz_F);end; + else begin Maj_Etat_Signal_belge(AdrFeu,chiffre_F); Maj_Etat_Signal_belge(AdrFeu,chevron_F);end; end; + // rouge etat:=etat_signal_suivant(AdrFeu,1,AdrSignalsuivant) ; // état du signal suivant + adresse du signal suivant dans Signal_Suivant if adrSignalSuivant=0 then Maj_Etat_Signal_belge(AdrFeu,semaphore) else begin + if TestBit(etat,semaphore) or TestBit(etat,carre) or TestBit(etat,rouge_blanc) then Maj_Etat_Signal_belge(AdrFeu,deux_jaunes) else begin @@ -7362,12 +7554,11 @@ begin //if affsignal then AfficheDebug('test 406',clyellow); if feux[index].checkFB.Checked then Maj_Etat_Signal_belge(AdrFeu,rouge_blanc) - else Maj_Etat_Signal_belge(AdrFeu,vert); + else Maj_Etat_Signal_belge(AdrFeu,vertB); end else begin - if feux[index].checkFV then Maj_Etat_Signal_belge(AdrFeu,vert_cli) - else Maj_Etat_Signal_belge(AdrFeu,vert); + Maj_Etat_Signal_belge(AdrFeu,vertB); //if affsignal then AfficheDebug('Mise du feu au vert',clyellow); end; end; @@ -11717,6 +11908,12 @@ begin roulage1.visible:=false; FenRich.MaxLength:=$7FFFFFF0; + NbDecodeur:= 11; + NbDecodeurdeBase:=NbDecodeur; + Decodeur[0]:='rien';Decodeur[1]:='Digital Bahn 10';Decodeur[2]:='CDF';Decodeur[3]:='LS-DEC-SNCF';Decodeur[4]:='LEB'; + Decodeur[5]:='Digikeijs 4018';Decodeur[6]:='Unisemaf Paco';Decodeur[7]:='Stéphane Ravaut';Decodeur[8]:='Arcomora'; + Decodeur[9]:='LS-DEC-NMBS';Decodeur[10]:='B-models'; + OsBits:=0; if IsWow64Process then begin @@ -12110,7 +12307,7 @@ begin if MessageDlg('Le TCO a été modifié. Voulez vous le sauvegarder ?',mtConfirmation,[mbYes,mbNo],0)=mrYes then sauve_fichier_tco; if config_modifie then - if MessageDlg('La configuration a été modifiée. Voulez vous la sauvegarder ?',mtConfirmation,[mbYes,mbNo],0)=mrYes then + if MessageDlg('La configuration a été modifiée. Voulez-vous la sauvegarder ?',mtConfirmation,[mbYes,mbNo],0)=mrYes then sauve_config; if confasauver then sauve_config; if sauve_tco then sauve_fichier_tco; @@ -12163,7 +12360,7 @@ begin if feux[i].aspect=20 then begin // signal belge - if TestBit(a,clign) then + if TestBit(a,clignote) or feux[i].contrevoie then begin Dessine_feu_mx(Feux[i].Img.Canvas,0,0,1,1,adresse,1); end; @@ -12201,7 +12398,7 @@ begin else begin combine:=a and $fc00; - faire:=testBit(combine,clign); + faire:=testBit(combine,clignote); end; if faire then begin @@ -12243,7 +12440,7 @@ begin if feux[0].aspect=20 then begin // signal belge - if TestBit(a,clign) then Dessine_feu_pilote; + if TestBit(a,clignote) or feux[0].contrevoie then Dessine_feu_pilote; end; end; @@ -13554,7 +13751,7 @@ begin end; procedure TFormPrinc.CodificationdessignauxClick(Sender: TObject); -var i,j,k,l,NfeuxDir,nc : integer; +var nation,i,j,k,l,NfeuxDir,nc,asp : integer; s,s2 : string; begin Affiche('Codification interne des signaux:',ClYellow); @@ -13564,10 +13761,15 @@ begin // feu de signalisation s:=IntToSTR(i)+' Adr='+IntToSTR(feux[i].Adresse); s:=s+' décodeur='+IntToStr(feux[i].decodeur); + asp:=feux[i].aspect; + if asp<>20 then nation:=1 else nation:=2; - if feux[i].aspect<10 then + // non directionnel + if (asp<10) or (asp>=20) then begin - s:=s+' SIG Nbrefeux='+IntToSTR(feux[i].aspect)+' '; + l:=feux[i].aspect; + if asp=20 then l:=5; + s:=s+' SIG Nbrefeux='+intToSTR(l)+' '; s:=s+' Det='+IntToSTR(feux[i].Adr_det1); s:=s+' El_Suiv1='+IntToSTR(feux[i].Adr_el_suiv1)+' Type suiv1='+BTypeToChaine(feux[i].Btype_suiv1); case feux[i].Btype_suiv1 of @@ -13603,7 +13805,7 @@ begin end; end; if (feux[i].decodeur=2) or (feux[i].decodeur=5) then - begin + begin s:=s+' MOT('; for l:=1 to 19 do begin @@ -13824,7 +14026,7 @@ begin begin formconfig.showmodal; // ne pas faire close : déja provoqué par le self de la fermeture - end; + end; end; procedure TFormPrinc.Codificationdesactionneurs1Click(Sender: TObject); @@ -13993,7 +14195,7 @@ end; procedure TFormPrinc.Etatdessignaux1Click(Sender: TObject); var Adr,etat,i : integer; - aspect,combine : integer; + aspect,combine,nation : integer; s : string; begin for i:=1 to NbreFeux do @@ -14001,13 +14203,7 @@ begin Adr:=Feux[i].Adresse; Etat:=Feux[i].EtatSignal; s:='Signal '+IntToSTR(Adr)+' Etat='; - code_to_aspect(Etat,aspect,combine); - s:=s+IntToSTR(etat); - if Feux[i].aspect<10 then - begin - if aspect<>-1 then s:=s+' '+EtatSign[aspect]; - if combine<>-1 then s:=s+' '+EtatSign[combine]; - end; + s:=s+chaine_signal(etat,adr); Affiche(s,clYellow); end; end; @@ -14143,7 +14339,7 @@ end; procedure TFormPrinc.Informationsdusignal1Click(Sender: TObject); var s: string; - etat,index,i,k,aspect,n,combine,adresse,aig,trainReserve,AdrSignalsuivant,voie : integer; + nation,etat,index,i,k,aspect,n,combine,adresse,aig,trainReserve,AdrSignalsuivant,voie : integer; reserveTrainTiers : boolean; code : word; begin @@ -14155,16 +14351,17 @@ begin i:=index_feu(Adresse); n:=feux[i].aspect; if (n>10) and (n<20) then exit; + if n=20 then nation:=2 else nation:=1; code:=feux[i].EtatSignal; code_to_aspect(code,aspect,combine); - s:='Signal ad'+IntToSTR(adresse)+'='+chaine_signal(code,feux[i].decodeur); + s:='Signal ad'+IntToSTR(adresse)+'='+chaine_signal(code,adresse); Affiche(s,clYellow); //Affiche(IntToSTR(aspect),clred); //Affiche(IntToSTR(combine),clred); - s:='Le signal '+intToSTR(adresse)+' présente '+chaine_signal(code,feux[i].decodeur)+' car '; + s:='Le signal '+intToSTR(adresse)+' présente '+chaine_signal(code,adresse)+' car '; // carré - if (aspect=carre) and (n<>20) then + if (aspect=carre) and (nation=1) then begin Affiche(s,clyellow); if carre_signal(Adresse,trainreserve,reserveTrainTiers) then affiche('les aiguillages en aval du signal sont mal positionnés ou leur positions inconnues',clyellow) ; @@ -14175,7 +14372,7 @@ begin if feux[i].VerrouilleCarre then affiche('le signal est verrouillé au carré dans la fenêtre de pilotage',clYellow); end; - if (aspect=vert_jaune_H) and (n=20) then + if (aspect=vert_jaune_H) and (nation=2) then begin etat:=etat_signal_suivant(Adresse,1,AdrSignalsuivant) ; // état du signal suivant + adresse du signal suivant dans Signal_Suivant if testbit(etat,chiffre) then @@ -14185,8 +14382,7 @@ begin end; end; - - if aspect=semaphore then + if ((aspect=semaphore) and (nation=1)) or ((aspect=rouge) and (nation=2)) then begin Affiche(s,clyellow); if test_memoire_zones(Adresse) then affiche_suivi('présence train dans canton après le signal',clyellow); @@ -14202,33 +14398,33 @@ begin end; end; // avertissement ou deux-jaunes (belge) - if aspect=jaune then + if ((aspect=jaune) and (n<>20)) or ((aspect=deux_jaunes) and (n=20)) then begin i:=etat_signal_suivant(Adresse,1,AdrSignalsuivant); - index:=index_feu(AdrSignalSuivant); - Affiche(s+'son signal suivant '+intToSTR(AdrSignalsuivant)+' est au '+chaine_signal(i,feux[index].decodeur),clyellow); + Affiche(s+'son signal suivant '+intToSTR(AdrSignalsuivant)+' est au '+chaine_signal(i,AdrSignalsuivant),clyellow); end; - // avertissement cli - if aspect=jaune_cli then + + // avertissement cli + if (aspect=jaune_cli) and (nation=1) then begin i:=etat_signal_suivant(Adresse,1,AdrSignalsuivant); index:=index_feu(AdrSignalSuivant); - Affiche(s+'son signal suivant '+intToSTR(AdrSignalsuivant)+' est au '+chaine_signal(i,feux[index].decodeur),clyellow); + Affiche(s+'son signal suivant '+intToSTR(AdrSignalsuivant)+' est au '+chaine_signal(i,adresse),clyellow); end; // ralen 30 - if (combine=10) and (n<>20) then + if (combine=10) and (nation=1) then begin i:=etat_signal_suivant(Adresse,1,AdrSignalsuivant); index:=index_feu(AdrSignalSuivant); - Affiche(s+'son signal suivant '+intToSTR(AdrSignalsuivant)+' est au '+chaine_signal(i,feux[index].decodeur),clyellow); + Affiche(s+'son signal suivant '+intToSTR(AdrSignalsuivant)+' est au '+chaine_signal(i,adresse),clyellow); end; - if (combine=11) and (n<>20) then + if (combine=11) and (nation=1) then begin i:=etat_signal_suivant(Adresse,1,AdrSignalsuivant); index:=index_feu(AdrSignalSuivant); - Affiche(s+'car son signal suivant '+intToSTR(AdrSignalsuivant)+' est au '+chaine_signal(i,feux[index].decodeur),clyellow); + Affiche(s+'car son signal suivant '+intToSTR(AdrSignalsuivant)+' est au '+chaine_signal(i,adresse),clyellow); end; - if ((combine=12) or (combine=13)) and (n<>20) then + if ((combine=rappel_30) or (combine=rappel_60)) and (nation=1) then begin Aig:=Aiguille_deviee(Adresse); // si aiguille locale déviée @@ -14236,11 +14432,21 @@ begin end; // chiffre et signal belge - if (combine=10) and (n=20) then + if nation=2 then begin - aig:=feux[i].Adr_el_suiv1; - aig:=index_aig(aig); - Affiche(s+'le signal doit être franchi à <'+intToSTR(aiguillage[aig].vitesse)+'km/h',clyellow); + combine:=code and $1C0; + if testbit(combine,chiffre) then + begin + aig:=feux[i].Adr_el_suiv1; + aig:=index_aig(aig); + Affiche(s+'le signal doit être franchi à <'+intToSTR(aiguillage[aig].vitesse)+'km/h',clyellow); + end; + if testbit(combine,chevron) then + begin + aig:=feux[i].Adr_el_suiv1; + aig:=index_aig(aig); + Affiche(s+'l''aiguillage mène à une voie en contresens',clyellow); + end; end; end; @@ -14692,5 +14898,6 @@ end; + end. diff --git a/UnitTCO.pas b/UnitTCO.pas index 121fd1c..6beb920 100644 --- a/UnitTCO.pas +++ b/UnitTCO.pas @@ -5215,7 +5215,7 @@ begin begin HorzScrollBar.Range:=DimX; HorzScrollBar.Tracking:=true; - HorzScrollBar.Smooth:=false; // ne pas mettre true sinon figeage dans W11 si onclique sur la trackbar!! + HorzScrollBar.Smooth:=false; // ne pas mettre true sinon figeage dans W11 si on clique sur la trackbar!! VertScrollBar.Range:=DimY; VertScrollBar.Tracking:=true; VertScrollBar.Smooth:=false; @@ -5243,9 +5243,7 @@ begin r:=rect(x1,y1,x1+LargeurCell,y1+HauteurCell); FillRect(r); - end; - end; //afficher les cellules sauf les signaux @@ -5293,7 +5291,6 @@ begin offsetSourisY:=-10; offsetSourisX:=-10; caption:='TCO'; - AvecGrille:=true; TCO_modifie:=false; rangUndo:=1; XclicCell:=1; diff --git a/verif_version.dcu b/verif_version.dcu new file mode 100644 index 0000000..fc0034f Binary files /dev/null and b/verif_version.dcu differ diff --git a/versions.txt b/versions.txt index 278f41a..bcf536c 100644 --- a/versions.txt +++ b/versions.txt @@ -170,7 +170,9 @@ version 6.1 : Am version 6.2 : Déplacement du curseur du TCO avec les touches curseur. Dessin du TCO à la souris. version 6.3 : Choix du graphisme du TCO en lignes brisées ou courbes. -version 7.0 : Gestion des signaux belges (avec chevron et réduction de vitesse). +version 6.4 : Gestion des signaux belges (avec chevron et réduction de vitesse). +version 7.0 : Possibilité de créer des décodeurs spécifiques de signaux. +