diff --git a/UnitConfig.dcu b/UnitConfig.dcu index d27ba28..719e451 100644 Binary files a/UnitConfig.dcu and b/UnitConfig.dcu differ diff --git a/UnitConfig.dfm b/UnitConfig.dfm index f6df718..5a4975b 100644 --- a/UnitConfig.dfm +++ b/UnitConfig.dfm @@ -1,6 +1,6 @@ object FormConfig: TFormConfig - Left = 230 - Top = 226 + Left = 384 + Top = 136 Hint = 'Modifie les fichiers de configuration selon les s'#233'lections chois' + 'ies' @@ -1578,7 +1578,7 @@ object FormConfig: TFormConfig Top = 8 Width = 633 Height = 497 - ActivePage = TabSheetBranches + ActivePage = TabSheetSig Font.Charset = DEFAULT_CHARSET Font.Color = clBlack Font.Height = -11 @@ -1858,7 +1858,7 @@ object FormConfig: TFormConfig Top = 18 Width = 215 Height = 13 - Caption = 'Liste des '#233'v'#232'nements envoy'#233's par CDM Rail:' + Caption = 'Liste des '#233'v'#232'nements demand'#233's '#224' CDM Rail:' end object CheckBoxServAig: TCheckBox Left = 8 @@ -2732,6 +2732,7 @@ object FormConfig: TFormConfig ScrollBars = ssBoth TabOrder = 1 WordWrap = False + OnKeyDown = RichBrancheKeyDown OnMouseDown = RichBrancheMouseDown end end diff --git a/UnitConfig.pas b/UnitConfig.pas index 9a3f57a..c3bddc5 100644 --- a/UnitConfig.pas +++ b/UnitConfig.pas @@ -347,6 +347,8 @@ type procedure RadioButtonZonesClick(Sender: TObject); procedure EditAct2Change(Sender: TObject); procedure SpeedButtonChargerClick(Sender: TObject); + procedure RichBrancheKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); private { Déclarations privées } public @@ -446,7 +448,8 @@ end; procedure Maj_Hint_feu(i : integer); var s : string; -begin +begin + // ne pas supprimer le @ espace et = 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)'; @@ -500,8 +503,8 @@ var s : string; begin // déconnexion de l'ancienne liaison éventuelle Formprinc.ClientSocketCDM.Close; - - if AdresseIPCDM<>'0' then + + if (AdresseIPCDM<>'0') and (ProcessRunning('CDR')) then begin // ouverture du socket CDM with Formprinc do @@ -553,7 +556,7 @@ begin end else begin - Affiche('La connexion à CDM n''est pas demandée car l''adresse IP est nulle dans '+NomConfig,cyan); + if adresseIPCDM='0' then Affiche('La connexion à CDM n''est pas demandée car l''adresse IP est nulle dans '+NomConfig,cyan); end; end; @@ -662,7 +665,6 @@ begin s:=s+','+intToSTR(aiguillage[index].DDevie)+aiguillage[index].DDevieB+')'; end; - if tjsC then begin s:=s+',L'+intToSTR(aiguillage[index].Tjsint)+aiguillage[index].TjsintB; @@ -941,9 +943,9 @@ begin until (fini) or (j>4); end; end; - if (j>4) or (not(multiple)) then - begin - Affiche('Erreur 678: fichier de configuration ligne erronnée : '+chaine_signal,clred); + if (j>4) or (not(multiple)) then + begin + Affiche('Erreur 678: fichier de configuration ligne erronnée : '+chaine_signal,clred); closefile(fichier); exit; end; @@ -957,11 +959,10 @@ begin if length(s)>0 then if s[1]=',' then delete(s,1,1); if length(s)>0 then if s[1]='U' then delete(s,1,1); - + // si décodeur UniSemaf (6) champ supplémentaire if Feux[i].decodeur=6 then begin - if k=0 then begin Affiche('Erreur 680 Ligne '+chaine_signal,clred);Affiche('Manque définition de la cible pour le décodeur UniSemaf',clred);end else begin @@ -969,11 +970,11 @@ begin Feux[i].UniSemaf:=k; erreur:=verif_UniSemaf(adresse,k); if erreur=1 then begin Affiche('Erreur 681 Ligne '+chaine_signal,clred);Affiche('Erreur code Unisemaf',clred);end; - if erreur=2 then - begin + if erreur=2 then + begin Affiche('Erreur 682 Ligne '+chaine_signal,clred);Affiche('Erreur cohérence aspect signal ('+intToSTR(asp)+') et code Unisemaf ('+intToSTR(k)+')',clred); end; - + end; end; end; @@ -982,19 +983,19 @@ begin l:=1; // nombre de parenthèses repeat t:=pos('(',s); - if t=1 then + if t=1 then begin //Affiche('Conditions supplémentaires pour le feu '+IntToSTR(adresse)+' parenthèse '+intToSTR(l),clyellow); k:=pos(')',s); sa:=copy(s,t+1,k-t-1); // contient l'intérieur des parenthèses sans les parenthèses delete(s,1,k);//Affiche(s,clYellow); - + // boucle dans la parenthèse bd:=0; repeat inc(bd); setlength(feux[i].condCarre[l],bd+1); // une condition en plus - k:=pos(',',sa); + k:=pos(',',sa); if k<>0 then chaine:=copy(sa,1,k-1) else @@ -1008,16 +1009,16 @@ begin if erreur<>0 then feux[i].condCarre[l][bd].PosAig:=chaine[erreur] else Affiche('Erreur 683 Définition du feu '+IntToSTR(feux[i].adresse)+': Manque D ou S dans les conditions de carré des aiguillages',clred); end; - + k:=pos(',',sa);if k<>0 then delete(sa,1,k); until k=0; inc(l); end; - until t<>1; + until t<>1; if length(s)>1 then if s[1]=',' then delete(s,1,1); // champ SR - if length(s)>2 then + if length(s)>2 then if copy(s,1,2)='SR' then begin delete(s,1,3); @@ -1034,7 +1035,7 @@ begin feux[i].SR[l].sortie0:=j; end; end; - + end; end; end; @@ -1272,7 +1273,7 @@ begin closefile(fichierN); deletefile(NomConfig); - renameFile('ConfigGenerale.tmp',NomConfig); + renameFile('ConfigGenerale.tmp',NomConfig); end; procedure lit_config; @@ -1306,7 +1307,7 @@ var s,sa,chaine,SOrigine: string; l1:=pos('"',s);l2:=posEx('"',s,l1+1); esp:=posEx(' ',s,Esp+1); if (esp<>0) and (espl2) then delete(s,esp,1); - until esp=0; + until esp=0; lit_ligne:=s; end; @@ -1314,19 +1315,19 @@ procedure compile_signaux; begin Affiche('Définition des signaux',clyellow); i:=1;Nligne:=1; - + NbreFeux:=0; repeat inc(Nligne); s:=lit_ligne; //affiche(s,clyellow); - if s<>'0' then - begin + if s<>'0' then + begin + inc(NbreFeux); decode_ligne_feux(s,i);inc(i); end; until (s='0') or eof(fichier); - NbreFeux:=i-1; if NbreFeux<0 then NbreFeux:=0; end; - + procedure compile_branches; begin // branches @@ -1346,7 +1347,8 @@ begin compile_branche(s,i); inc(i); end; - until (s='0') or eof(fichier); + until (s='0') or eof(fichier) or (i>=MaxBranches); + if i>MaxBranches then Affiche('Nombre maximal de branches atteint',clRed); NbreBranches:=i-1; end; @@ -1587,7 +1589,12 @@ begin if debugconfig then Affiche(s,ClLime); if (s<>'0') then begin - inc(maxaiguillage); + if MaxAiguillage>=MaxAcc then + begin + Affiche('Nombre maximal d''aiguillages atteint',clRed); + end + else + inc(maxaiguillage); virgule:=pos(',',s); enregistrement:=copy(s,1,virgule-1); // adresse de l'aiguillage [TRI] delete(s,1,virgule); @@ -1761,7 +1768,7 @@ begin aiguillage[maxaiguillage].vitesse:=adr; virgule:=pos(',',enregistrement);if virgule=0 then virgule:=length(s)+1; delete(enregistrement,1,virgule); - end; + end; // TJS et L if (length(enregistrement)<>0) then @@ -1820,11 +1827,10 @@ begin end; procedure lit_flux; - label ici1,ici2,ici3,ici4 ; var i : integer; -// début de la procédure lit_config +// début de la procédure lit_config begin nv:=0; it:=0; // taille de fonte @@ -1852,8 +1858,8 @@ begin trouve_ipv4_PC:=true; delete(s,i,length(sa)); i:=pos(':',s); - if i<>0 then - begin + if i<>0 then + begin adresseIPCDM:=copy(s,1,i-1);Delete(s,1,i); val(s,portCDM,erreur); if (portCDM=0) or (portCDM>65535) or (erreur<>0) then affiche('Erreur port CDM : '+s,clred); @@ -1870,8 +1876,8 @@ begin trouve_IPV4_INTERFACE:=true; delete(s,i,length(sa)); i:=pos(':',s); - if i<>0 then - begin + if i<>0 then + begin adresseIP:=copy(s,1,i-1);Delete(s,1,i);port:=StrToINT(s); if (adresseIP<>'0') and (port=0) then affiche('Erreur port nul : '+sOrigine,clRed); end @@ -1965,7 +1971,7 @@ begin delete(s,i,length(sa)); val(s,Tempo_Aig,erreur); end; - + // temporisation décodeurs de feux sa:=uppercase(Tempo_Feu_ch)+'='; i:=pos(sa,s); @@ -1979,7 +1985,7 @@ begin end; // algo unisemaf - sa:=uppercase(Algo_unisemaf_ch)+'='; + sa:=uppercase(Algo_unisemaf_ch)+'='; i:=pos(sa,s); if i<>0 then begin @@ -2175,28 +2181,29 @@ begin Ancien_detecteur[i]:=false; end; + { // vérifier si le fichier ConfigGenerale.cfg existe fichier_trouve:=true; {$I+} - try + + {try assign(fichier,NomConfig); reset(fichier); except fichier_trouve:=false; end; {$I-} + { if fichier_trouve then begin close(fichier); - end; + end; // si pas trouvé le fichier, lire les 2 anciens fichiers et les fusionner if not(fichier_trouve) then begin - Affiche('***Traitement de fusion des deux fichiers de config***',clAqua); - - Affiche('Lecture de l''ancien fichier de configuration client-GL.cfg',clyellow); {$I+} + { try assign(fichier,'client-GL.cfg'); reset(fichier); @@ -2205,25 +2212,29 @@ begin exit; end; {$I-} + {Affiche('Lecture de l''ancien fichier de configuration client-GL.cfg',clyellow); + lit_flux; closeFile(fichier); Affiche('Lecture de l''ancien fichier de configuration config.cfg',clyellow); {$I+} - try + {try assign(fichier,'config.cfg'); reset(fichier); except Affiche('Fichier config.cfg non trouvé',clred); exit; end; + Affiche('***Traitement de fusion des deux fichiers de config***',clAqua); + {$I-} - lit_flux; + {lit_flux; closeFile(fichier); // regénérer la config dans le fichier configgenerale.cfg assign(fichier,'client-gl.cfg'); reset(fichier); // pour les commentaires - genere_config; + genere_config; s:='------------------------------------------------------------------------------------------------------'; Affiche(s,clAqua); @@ -2233,24 +2244,23 @@ begin end else - begin - Affiche('Lecture du fichier de configuration '+NomConfig,clyellow); - {$I+} - try - assign(fichier,NomConfig); - reset(fichier); - except - Affiche('Fichier '+NomConfig+' non trouvé',clred); - exit; - end; - {$I-} - lit_flux; - close(fichier); + begin} + Affiche('Lecture du fichier de configuration '+NomConfig,clyellow); + {$I+} + try + assign(fichier,NomConfig); + reset(fichier); + except + Affiche('Fichier '+NomConfig+' non trouvé',clred); + exit; end; + {$I-} + lit_flux; + close(fichier); configNulle:=(maxAiguillage=0) and (NbreBranches=0) and (Nbrefeux=0); if configNulle then Affiche('Fonctionnement en config nulle',ClYellow); - + s:='';//Affiche(intToSTR(Nv),clred); if not(trouve_NbDetDist) then s:=nb_det_dist_ch; if not(trouve_ipv4_PC) then s:=IpV4_PC_ch; @@ -2265,15 +2275,17 @@ begin if not(trouve_Serveur_interface) then s:=Serveur_interface_ch; if not(trouve_fenetre) then s:=fenetre_ch; if not(trouve_tempo_aig) then s:=tempo_aig_ch; - if not(trouve_tempo_feu) then + if not(trouve_Algo_Uni) then s:=Algo_unisemaf_ch; + if not(trouve_tempo_feu) then begin s:=tempo_feu_ch; tempo_feu:=100; s:=''; - end; + end; if not(trouve_NOTIF_VERSION) then s:=NOTIF_VERSION_ch; if not(trouve_verif_version) then s:=verif_version_ch; if not(trouve_fonte) then s:=fonte_ch; + if s<>'' then affiche('ERREUR: manque variables dans '+NomConfig+' :'+s,clred); if not(trouve_section_aig) then Affiche('Manque section '+section_aig_ch,clred); if not(trouve_section_sig) then Affiche('Manque section '+section_sig_ch,clred); @@ -2307,7 +2319,7 @@ begin val(EditFonte.text,i,erreur); if (i<8) or (i>25) then i:=10; TailleFonte:=i; - + // contrôle adresse IP interface s:=EditIPLenz.text; if not(IpOk(s)) and (s<>'0') then begin labelInfo.Caption:='Adresse IP interface Xpressnet incorrecte';sauve_config:=false;exit;end; @@ -2323,23 +2335,23 @@ begin Val(editTempoAig.Text,i,erreur); if i>3000 then begin labelInfo.Caption:='Temporisation de séquencement incorrecte ';sauve_config:=false;exit;end; Tempo_Aig:=i; - + // contrôle protocole interface COM3:57600,N,8,1,2 s:=EditComUSB.Text; if not(config_com(s)) then begin labelInfo.Caption:='Protocole série USB Interface incorrect';sauve_config:=false;exit;end; changeUSB:=portcom<>s; portcom:=s; - + val(EditTempoOctetUSB.text,i,erreur); - if erreur<>0 then begin labelInfo.Caption:='Valeur temporisation octet incorrecte';sauve_config:=false;exit;end; + if erreur<>0 then begin labelInfo.Caption:='Valeur temporisation octet incorrecte';sauve_config:=false;exit;end; TempoOctet:=i; - + val(EditTempoReponse.text,i,erreur); - if erreur<>0 then begin labelInfo.Caption:='Valeur temporisation de réponse interface';sauve_config:=false;exit;end; + if erreur<>0 then begin labelInfo.Caption:='Valeur temporisation de réponse interface';sauve_config:=false;exit;end; TimoutMaxInterface:=i; val(EditNbDetDist.text,i,erreur); - if (erreur<>0) or (i<3) then begin labelInfo.Caption:='Valeur nombre de détecteurs trop distants incorrecte';sauve_config:=false;exit;end; + if (erreur<>0) or (i<3) then begin labelInfo.Caption:='Valeur nombre de détecteurs trop distants incorrecte';sauve_config:=false;exit;end; Nb_Det_Dist:=i; if RadioButton1.checked then Valeur_entete:=0; @@ -2352,7 +2364,7 @@ begin end; if changeCDM then connecte_CDM; - if changeInterface then + if changeInterface then begin if AdresseIP<>'0' then begin @@ -2362,11 +2374,11 @@ begin ClientSocketLenz.port:=port; ClientSocketLenz.Address:=AdresseIP; ClientSocketLenz.Open; - end; + end; end end; - if changeUSB then + if changeUSB then begin deconnecte_USB; connecte_USB; @@ -2377,7 +2389,7 @@ begin LanceCDM:=CheckLanceCDM.Checked; if CheckFenEt.checked then fenetre:=1 else fenetre:=0; - + AvecTCO:=CheckAvecTCO.checked; Lay:=EditNomLay.Text; if RadioButton4.Checked then ServeurInterfaceCDM:=0; @@ -2403,7 +2415,7 @@ begin change_srv:=Srvc_Act<>CheckBoxServAct.checked or change_srv; change_srv:=Srvc_PosTrain<>CheckServPosTrains.checked or change_srv; change_srv:=Srvc_Sig<>CheckBoxSrvSig.checked or change_srv; - + Srvc_Aig:=CheckBoxServAig.checked; Srvc_Det:=CheckBoxServDet.checked; Srvc_Act:=CheckBoxServAct.checked; @@ -2424,7 +2436,7 @@ begin Affiche('Fichier '+NomConfig+' non trouvé',clOrange); end; {$I-} - + genere_config; Affiche('Configuration sauvegardée dans le fichier',clLime); config_modifie:=false; @@ -2771,7 +2783,7 @@ begin EditP1.Visible:=true;EditP2.Visible:=true;EditP3.Visible:=true;EditP4.Visible:=true; LabelTJD1.Visible:=true;LabelTJD2.Visible:=true; end; - end; + end; if tjs then begin @@ -2800,7 +2812,7 @@ begin id2:=Index_Aig(adr2); // champ en haut à gauche - b:=aiguillage[Index_Aig(adresse)].ADroitB; + b:=aiguillage[Index_Aig(adresse)].ADroitB; if b='Z' then b:=#0; Edit_HG.Text:=intToSTR(aiguillage[index].ADroit)+b; Edit_HG.Hint:=TypeElAIg_to_char(aiguillage[index].Adroit,b); @@ -3032,7 +3044,7 @@ begin RadioButtonLoc.Checked:=false; RadioButtonAccess.Checked:=false; RadioButtonSon.checked:=true; - + GroupBoxAct.Visible:=true; GroupBoxPN.Visible:=false; end; @@ -3322,7 +3334,7 @@ begin editAct2.Visible:=true; LabelActionneur.Caption:='Mémoire de Zone'; end; - + etatAct:=Tablo_actionneur[i].etat ; Adresse:=Tablo_actionneur[i].adresse; s2:=Tablo_actionneur[i].train; @@ -3409,7 +3421,7 @@ begin CheckRaz.Checked:=false; end; end; - + procedure raz_champs_aig; begin with formConfig do @@ -3535,7 +3547,7 @@ begin // ne pas traiter si on a cliqué sur la liste if clicliste then exit; if affevt then affiche('Evt change dévié',clyellow); - + if FormConfig.PageControl.ActivePage=FormConfig.TabSheetAig then with Formconfig do begin @@ -3547,15 +3559,20 @@ begin index:=index_aig(adrAig); if index=0 then exit; modele:=aiguillage[index].modele; - + if (modele=aig) or (modele=triple) then begin - if ((B='S') or (B='P') or (B='D') or (B=#0) or (b='Z')) and (s<>'') then + if ((B='S') or (B='P') or (B='D') or (B=#0) or (b='Z')) and (s<>'') then begin // aiguillage normal ou triple + LabelInfo.caption:=''; + if (B='S') or (b='P') or (b='D') then + begin + if adr=AdrAig then LabelInfo.caption:='Un aiguillage ne peut pointer sur lui même '; + end; + RE_ColorLine(RichAig,ligneclicAig,ClWhite); Aiguillage[index].modifie:=true; - LabelInfo.caption:=''; // modifier la base de données de l'aiguillage if b=#0 then b:='Z'; Aiguillage[Index].ADevie:=adr; @@ -3608,7 +3625,7 @@ begin // ne pas traiter si on a cliqué sur la liste if clicliste then exit; if affevt then affiche('Evt change droit',clyellow); - + if FormConfig.PageControl.ActivePage=FormConfig.TabSheetAig then with Formconfig do begin @@ -3619,6 +3636,13 @@ begin decodeAig(s,adr,B); Index:=Index_Aig(AdrAig); if index=0 then exit; + + LabelInfo.caption:=''; + if (B='S') or (b='P') or (b='D') then + begin + if adr=AdrAig then LabelInfo.caption:='Un aiguillage ne peut pointer sur lui même '; + end; + modele:=aiguillage[index].modele; if (modele=aig) or (modele=triple) then begin @@ -3626,7 +3650,6 @@ begin begin RE_ColorLine(RichAig,ligneclicAig,ClWhite); Aiguillage[Index].modifie:=true; - LabelInfo.caption:=''; // modifier la base de données de l'aiguillage if b=#0 then b:='Z'; Aiguillage[index].ADroit:=adr; @@ -3663,7 +3686,7 @@ begin RE_ColorLine(Formconfig.RichAig,index-1,ClWhite); LabelInfo.caption:='Modification de la TJD homologe ('+IntToSTR(adr2)+')'; end; - end; + end; end; @@ -3677,27 +3700,33 @@ begin // ne pas traiter si on a cliqué sur la liste if clicliste then exit; if affevt then affiche('Evt change pointe',clyellow); - + if FormConfig.PageControl.ActivePage=FormConfig.TabSheetAig then with Formconfig do begin s:=formconfig.RichAig.Lines[ligneclicAig]; Val(s,adrAig,erreur); - + //vérifier la syntaxe de P s:=Editpointe_BG.text; decodeAig(s,adr,B); - if ((B='S') or (B='P') or (B='D') or (B=#0) or (b='Z')) and (s<>'') then + if ((B='S') or (B='P') or (B='D') or (B=#0) or (b='Z')) and (s<>'') then begin RE_ColorLine(RichAig,ligneclicAig,ClWhite); Index:=Index_Aig(AdrAig); + LabelInfo.caption:=''; + if (B='S') or (b='P') or (b='D') then + begin + if adr=AdrAig then LabelInfo.caption:='Un aiguillage ne peut pointer sur lui même '; + end; + normal:=aiguillage[index].modele=aig; tjdC:=aiguillage[index].modele=tjd; tjsC:=aiguillage[index].modele=tjs; triC:=aiguillage[index].modele=triple; - + Aiguillage[index].modifie:=true; - LabelInfo.caption:=''; + // modifier la base de données de l'aiguillage if b=#0 then b:='Z'; @@ -4204,7 +4233,7 @@ begin RichSig.Lines[ligneClicSig]:=s; feux[ligneClicSig+1].modifie:=true; end; -end; +end; procedure TFormConfig.EditDet4Change(Sender: TObject); begin @@ -4567,7 +4596,7 @@ begin begin s:=EditAdrAig.Text; Val(s,i,erreur); - if (erreur<>0) or (i<=0) or (i>MaxAcc) then + if (erreur<>0) or (i<=0) or (i>MaxAcc) then begin EditAdrAig.Color:=clred; LabelInfo.caption:='Erreur adresse Aiguillage ';exit; @@ -4929,7 +4958,7 @@ begin if affevt then affiche('Evt EditV1F Change',clyellow); if FormConfig.PageControl.ActivePage=FormConfig.TabSheetAct then with Formconfig do - begin + begin s:=EditV1F.Text; Val(s,act,erreur); if (erreur<>0) then @@ -5103,7 +5132,7 @@ begin LigneClicAct:=i-1; AncligneClicAct:=ligneClicAct; Aff_champs_Act(maxTablo_act-1); - clicliste:=false; + clicliste:=false; config_modifie:=true; end; @@ -5268,18 +5297,18 @@ begin s:='Voulez-vous supprimer le feu '+IntToSTR(feux[index].adresse)+'?'; if Application.MessageBox(pchar(s),pchar('confirm'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION)=idNo then exit; Affiche('Suppression du feu ='+IntToSTR(feux[index].adresse),clOrange); - + clicliste:=true; // évite les évènements Edit text Feu_supprime:=feux[index]; // sauvegarde le feu supprimé Feu_sauve.adresse:=0; // dévalider sa définition Feu_sauve.aspect:=0; // dévalider sa définition - + // supprime le feu du tableau ButtonInsFeu.Caption:='Ajouter le feu '+intToSTR(feux[index].adresse)+' supprimé'; feux[index].Img.free; // supprime l'image, ce qui efface le feu du tableau graphique - Feux[index].Lbl.Free; // supprime le label, ... + Feux[index].Lbl.free; // supprime le label, ... if Feux[index].check<>nil then begin Feux[index].check.Free;Feux[index].Check:=nil;end; // supprime le check du feu blanc s'il existait // décale le tableau de feux et recalcule les positions des images @@ -5290,13 +5319,13 @@ begin begin Top:=(HtImg+espY+20)*((i-1) div NbreImagePLigne); // détermine les points d'origine Left:=10+ (LargImg+5)*((i-1) mod (NbreImagePLigne)); - Name:='ImageFeu'+IntToSTR(i); + Name:='ImageFeu'+IntToSTR(i); s:='Index='+IntToSTR(i)+' @='+inttostr(feux[i].Adresse)+' Décodeur='+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)'; Hint:=s; - end; + end; with feux[i].Lbl do begin Top:=HtImg+((HtImg+EspY+20)*((i-1) div NbreImagePLigne)); @@ -5306,15 +5335,15 @@ begin if Feux[i].check<>nil then with Feux[i].Check do begin - Hint:=intToSTR(i); + Hint:=intToSTR(i); Top:=HtImg+15+((HtImg+EspY+20)*((i-1) div NbreImagePLigne)); Left:=10+ (LargImg+5)*((i-1) mod (NbreImagePLigne)); - end; - //Affiche('décale feu '+IntToSTR(i)+'<'+intToSTR(i+1),clorange); + end; + //Affiche('décale feu '+IntToSTR(i)+'<'+intToSTR(i+1),clorange); end; dec(NbreFeux); - + EditAdrSig.Text:=''; EditDet1.Text:='';EditDet2.Text:='';EditDet3.Text:='';EditDet4.Text:=''; EditSuiv1.Text:='';EditSuiv2.Text:='';EditSuiv3.Text:='';EditSuiv4.Text:=''; @@ -5331,9 +5360,9 @@ begin begin RichSig.Lines.Add(s); RE_ColorLine(RichSig,RichSig.lines.count-1,ClAqua); - end; - end; - ligneClicSig:=-1; + end; + end; + ligneClicSig:=-1; AncligneClicSig:=-1; raz_champs_sig; clicliste:=false; @@ -5350,7 +5379,7 @@ begin feux[NbreFeux]:=Feu_supprime; Feu_Supprime.adresse:=0; // dévalider le feu sauvegardé Feu_supprime.aspect:=0; - cree_image(nbrefeux); + cree_image(nbrefeux); config_modifie:=true; // réafficher le rechedit s:=encode_Sig_Feux(NbreFeux); @@ -5368,7 +5397,7 @@ begin Perform(EM_SCROLLCARET,0,0); end; Aff_champs_sig_feux(NbreFeux); - end; + end; clicListe:=false; end; end; @@ -5386,28 +5415,29 @@ begin repeat detect:=BrancheN[i][j].Adresse; AncModel:=model; - model:=BrancheN[i][j].BType; + model:=BrancheN[i][j].BType; if (j=1) and (model<>Aig) and (Model<>Buttoir) then - begin + begin Affiche('Erreur 3.1 branche '+intToSTR(i)+' : le premier élément d''une branche doit être un buttoir ou un aiguillage',clred); erreur:=i; - end; + end; inc(j); - until((model=rien) and (detect=0)); - if (Ancmodel<>Aig) and (AncModel<>Buttoir) then + until((model=rien) and (detect=0)); + if (Ancmodel<>Aig) and (AncModel<>Buttoir) then begin Affiche('Erreur 3.2 branche '+intToSTR(i)+' : le dernier élément d''une branche doit être un buttoir ou un aiguillage',clred); erreur:=i; - end; - end; - verif_extr_branches:=Erreur; + end; + end; + + verif_extr_branches:=Erreur; end; function verif_coherence : boolean; -var i,j,k,l,Indexaig,adr,adr2,detect,condcarre,nc,index2 : integer; - modAig,AncModel,model,km: TEquipement; +var AncAdr,i,j,k,l,Indexaig,adr,adr2,detect,condcarre,nc,index2,SuivAdr : integer; + modAig,AncModel,model,km,SuivModel: TEquipement; c : char; - ok : boolean; + ok,trouveSuiv,TrouvePrec : boolean; begin // vérification de la cohérence1 // parcoure les branches jusqu'à trouver un aiguillage pour voir s'il a été décrit @@ -5426,12 +5456,12 @@ begin AncModel:=model; model:=BrancheN[i][j].BType; // 1= détecteur 2= aiguillage 4=Buttoir - + if (model=aig) then begin //affiche('trouvé aig '+intToSTR(detect),clyellow); modAig:=aiguillage[Index_Aig(detect)].modele; - if (model=rien) then + if (modAig=rien) then begin Affiche('Erreur 2: Aiguillage '+intToStr(detect)+' non décrit mais présent en branche '+intToStr(i)+' pos. '+intToSTR(j),clred); ok:=false; @@ -5439,12 +5469,12 @@ begin end; j:=j+1; until((model=rien) and (detect=0)); - if (Ancmodel<>Aig) and (AncModel<>Buttoir) then + if (Ancmodel<>Aig) and (AncModel<>Buttoir) then Affiche('Erreur 3.2 branche '+intToSTR(i)+' : le dernier élément d''une branche doit être un buttoir ou un aiguillage',clred); end; if verif_extr_branches<>0 then ok:=false; - + // vérification de la cohérence2 // parcoure les aiguillages pour voir si les détecteurs sont en branches des détecteurs // et les tjd pour voir si pb de cohérence @@ -5527,7 +5557,7 @@ begin adr:=aiguillage[Indexaig].Adresse; if aiguillage[Indexaig].modele=triple then begin - if aiguillage[Indexaig].AdrTriple=0 then + if aiguillage[Indexaig].AdrTriple=0 then begin Affiche('Erreur 6.1: 2ème adresse de l''aiguillage triple '+intToSTR(adr)+' non définie',clred); ok:=false; @@ -5541,7 +5571,7 @@ begin ok:=false; end; end; - end; + end; // cohérence 4 : vérifie si doublon signal for j:=1 to NbreFeux do @@ -5552,9 +5582,9 @@ begin if adr=feux[i].Adresse then begin affiche('Erreur 7 : signal '+intToSTR(adr)+' défini deux fois',clred); - ok:=false; + ok:=false; end; - end; + end; end; // cohérence 5 ; vérifie si aiguillages définis en condition supplémentaires de carré existent @@ -5648,7 +5678,7 @@ begin if ((km=aig) or (km=tjs) or (km=tjd) or (km=triple)) then begin // aiguillage - if index_aig(i)=0 then + if index_aig(i)=0 then begin ok:=false; Affiche('Erreur 9.2: aiguillage '+intToSTR(i)+' non existant mais associé au signal '+IntToSTR(feux[j].adresse),clred); @@ -5779,6 +5809,102 @@ begin end; end; + // cohérence 8 + // parcoure les branches pour voir si les aiguillages aux extrémités sont cohérentes avec leurs déclarations + for i:=1 to NbreBranches do + begin + j:=1; // on vérifie entre j-1 et j+1 + detect:=BrancheN[i][1].Adresse; + model:=BrancheN[i][1].BType; + repeat + AncAdr:=detect;AncModel:=model; + detect:=BrancheN[i][j].Adresse; + SuivAdr:=BrancheN[i][j+1].Adresse; + SuivModel:=BrancheN[i][j+1].Btype; + model:=BrancheN[i][j].BType; // 1= détecteur 2= aiguillage 4=Buttoir + trouvePrec:=false; + + if (model=aig) or (model=Tjd) or (model=Tjs) then + begin + k:=index_aig(detect); + // comparer au précédent + if j=1 then trouvePrec:=true; + if (j>1) then + begin + if aiguillage[k].modele=Aig then + begin + if aiguillage[k].ADroit=AncAdr then trouvePrec:=true; + if aiguillage[k].ADevie=AncAdr then trouvePrec:=true; + if aiguillage[k].APointe=AncAdr then trouvePrec:=true; + end; + if (aiguillage[k].modele=Tjd) or (aiguillage[k].modele=TjS) then + begin + if aiguillage[k].EtatTJD=2 then + begin + if aiguillage[k].ADroit=AncAdr then trouvePrec:=true; + if aiguillage[k].ADevie=AncAdr then trouvePrec:=true; + if aiguillage[k].Ddroit=AncAdr then trouvePrec:=true; + if aiguillage[k].Ddevie=AncAdr then trouvePrec:=true; + end; + if aiguillage[k].EtatTJD=4 then + begin + l:=index_aig(aiguillage[k].Ddroit); // 2eme adresse de la TJD + if aiguillage[k].ADroit=AncAdr then trouvePrec:=true; + if aiguillage[k].ADevie=AncAdr then trouvePrec:=true; + if aiguillage[k].Ddroit=AncAdr then trouvePrec:=true; + if aiguillage[l].Adroit=AncAdr then trouvePrec:=true; + if aiguillage[l].Adevie=AncAdr then trouvePrec:=true; + if aiguillage[l].Ddevie=AncAdr then trouvePrec:=true; + end; + end; + if not(trouvePrec) then + begin + Affiche('La description de l''aiguillage '+intToSTR(detect)+' ne correspond pas à son élément contigu ('+intToStr(AncAdr)+') en branche '+intToSTR(i),clred); + ok:=false; + end; + end; + + TrouveSuiv:=false; + // comparer au suivant + if SuivModel<>rien then + begin + if aiguillage[k].modele=Aig then + begin + if aiguillage[k].ADroit=SuivAdr then trouveSuiv:=true; + if aiguillage[k].ADevie=SuivAdr then trouveSuiv:=true; + if aiguillage[k].APointe=SuivAdr then trouveSuiv:=true; + end; + if (aiguillage[k].modele=Tjd) or (aiguillage[k].modele=TjS) then + begin + if aiguillage[k].EtatTJD=2 then + begin + if aiguillage[k].ADroit=SuivAdr then trouveSuiv:=true; + if aiguillage[k].ADevie=SuivAdr then trouveSuiv:=true; + if aiguillage[k].Ddroit=SuivAdr then trouveSuiv:=true; + if aiguillage[k].Ddevie=SuivAdr then trouveSuiv:=true; + end; + if aiguillage[k].EtatTJD=4 then + begin + l:=index_aig(aiguillage[k].Ddroit); // 2eme adresse de la TJD + if aiguillage[k].ADroit=SuivAdr then trouveSuiv:=true; + if aiguillage[k].ADevie=SuivAdr then trouveSuiv:=true; + if aiguillage[k].Ddroit=SuivAdr then trouveSuiv:=true; + if aiguillage[l].Adroit=SuivAdr then trouveSuiv:=true; + if aiguillage[l].Adevie=SuivAdr then trouveSuiv:=true; + if aiguillage[l].Ddevie=SuivAdr then trouveSuiv:=true; + end; + end; + if not(trouveSuiv) then + begin + Affiche('La description de l''aiguillage '+intToSTR(detect)+' ne correspond pas à son élément contigu ('+intToStr(SuivAdr)+') en branche '+intToSTR(i),clred); + ok:=false; + end; + end; + end; + inc(j); + until((model=rien) and (detect=0)) ; + end; + verif_coherence:=ok; end; @@ -5786,6 +5912,11 @@ procedure TFormConfig.ButtonNouvAigClick(Sender: TObject); var i : integer; s : string; begin + if MaxAiguillage>=MaxAcc then + begin + Affiche('Nombre maximal d''aiguillages atteint',clRed); + exit; + end; clicliste:=true; inc(MaxAiguillage); i:=MaxAiguillage; @@ -5795,13 +5926,13 @@ begin aiguillage[i].DdroitB:='D'; aiguillage[i].DdevieB:='S'; // préparation pour TJD/S aiguillage[i].EtatTJD:=4; aiguillage[i].ApointeB:='Z'; - aiguillage[i].Adevie2B:='Z'; + aiguillage[i].Adevie2B:='Z'; aiguillage[i].tjsintB:='D'; - + aiguillage[i].posInit:=const_inconnu; aiguillage[i].Temps:=5; - - s:=encode_Aig(i); + + s:=encode_Aig(i); if ligneClicAig<>-1 then RE_ColorLine(RichAig,ligneClicAig,ClAqua); // scroller à la fin with richAig do @@ -5810,7 +5941,7 @@ begin SetFocus; Selstart:=RichAig.GetTextLen-1; Perform(EM_SCROLLCARET,0,0); - end; + end; LabelInfo.caption:='Aiguillage '+intToSTR(aiguillage[i].Adresse)+' créé'; ligneClicAig:=i-1; @@ -5847,14 +5978,14 @@ begin aiguillage[index].Ddevie:=0; aiguillage[index].APointe:=0; aiguillage[index].modifie:=false; - + // supprime l'aiguillage du tableau dec(MaxAiguillage); for i:=index to MaxAiguillage do begin Aiguillage[i]:=Aiguillage[i+1]; end; - + config_modifie:=true; RichAig.Clear; @@ -5866,8 +5997,8 @@ begin begin RichAig.Lines.Add(s); RE_ColorLine(RichAig,RichAig.lines.count-1,ClAqua); - end; - end; + end; + end; ligneClicAig:=-1; AncligneClicAig:=-1; clicliste:=false; @@ -6137,7 +6268,7 @@ var AdrAig,adr,adr2,erreur,index : integer; begin if clicliste or (ord(Key)<>VK_RETURN) then exit; if affevt then affiche('Evt change P4',clyellow); - + if FormConfig.PageControl.ActivePage=FormConfig.TabSheetAig then with Formconfig do begin @@ -6260,7 +6391,7 @@ begin clicliste:=true; Aff_champs_aig_tablo(i); clicliste:=false; -end; +end; procedure TFormConfig.ButtonValLigneClick(Sender: TObject); var s: string; @@ -6269,8 +6400,8 @@ var s: string; begin ligne:=1; ok:=true; - repeat - s:=RichBranche.Lines[ligne-1]; + repeat + s:=AnsiUpperCase(RichBranche.Lines[ligne-1]); if s<>'' then begin // supprime les espaces éventuels @@ -6278,7 +6409,7 @@ begin esp:=pos(' ',s); if esp<>0 then delete(s,esp,1); until esp=0; - if s<>'' then + if s<>'' then begin RichBranche.Lines[ligne-1]:=s; branche[ligne]:=s; // stocker la ligne dans la branche pour la compiler @@ -6286,19 +6417,20 @@ begin begin RE_ColorLine(RichBranche,Ligne-1,ClLime); end - else + else begin RE_ColorLine(RichBranche,Ligne-1,ClRed); ok:=false; - end; - inc(ligne); + end; + inc(ligne); end else RichBranche.Lines.Delete(ligne-1); end else RichBranche.Lines.Delete(ligne-1); - - until ligne>RichBranche.Lines.count; + + until (ligne>RichBranche.Lines.count) or (ligne>=MaxBranches); NbreBranches:=ligne-1; + if ligne>=MaxBranches then Affiche('Nombre maximal de branches atteint',clRed); ligne:=verif_extr_branches; if ligne<>0 then @@ -6421,21 +6553,23 @@ begin end; end; inc(j); + BrancheN[i,j].adresse:=0; // préparer le suivant à 0 BrancheN[i,j].BType:=rien; //Affiche('branche '+intToSTR(i)+' index='+intToStr(j),clGreen); - until (offset=0); + until (offset=0) or (j>=MaxElBranches); if j=2 then begin - Affiche('Une branche doit contenir au moins deux éléments',clred); + Affiche('Branche '+IntToSTR(i)+' : Une branche doit contenir au moins deux éléments',clred); code:=false; end; + if (j>=MaxElBranches) then Affiche('Nombre maximal d''élements dans une branche atteint',clred); compile_branche:=code; end; procedure TFormConfig.RichBrancheMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); -var curseur,lc : integer; +var curseur,lc : integer; begin if clicListe then exit; clicListe:=true; @@ -6447,16 +6581,16 @@ begin AncligneClicBr:=ligneClicBr; ligneClicBr:=lc; curseur:=SelStart; // position initiale du curseur - if AncligneClicBr<>ligneClicBr then + if AncligneClicBr<>ligneClicBr then begin - if AncligneClicBr<>-1 then + if AncligneClicBr<>-1 then begin RE_ColorLine(RichBranche,AncligneClicBr,ClAqua); end; RE_ColorLine(RichBranche,ligneClicBr,ClYellow); selStart:=curseur; // remettre le curseur en position initiale - end; - end; + end; + end; clicListe:=false; end; @@ -6676,7 +6810,7 @@ begin if affevt then affiche('Evt EditV4F Change',clyellow); if FormConfig.PageControl.ActivePage=FormConfig.TabSheetAct then with Formconfig do - begin + begin s:=EditV4F.Text; Val(s,act,erreur); if (erreur<>0) and (s<>'') then @@ -6820,7 +6954,7 @@ begin i:=ligneClicAct+1; if AffEvt then Affiche('RadioBoutonActDet '+IntToSTR(i),clyellow); Tablo_Actionneur[i].typActMemZone:=0; - LabelActionneur.Caption:='Actionneur DétecteurZ'; + LabelActionneur.Caption:='Actionneur DétecteurZ'; editAct2.Visible:=false; EditTrain.Visible:=true; LabelTrain.Visible:=true; @@ -6892,7 +7026,75 @@ begin end; end; +procedure TFormConfig.RichBrancheKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +var lc,curseur : integer; begin + if ord(Key)=VK_UP then + begin + if clicListe then exit; + clicListe:=true; + if affevt then affiche('Evt RichBranche keydown',clyellow); + with Formconfig.RichBranche do + begin + lc:=Perform(EM_LINEFROMCHAR,-1,0); // numéro de la lignée cliquée + if lc>0 then + begin + dec(lc); + LabelNumBranche.Caption:='Branche n°'+intToSTR(lc+1); + AncligneClicBr:=ligneClicBr; + ligneClicBr:=lc; + curseur:=SelStart; // position initiale du curseur + if AncligneClicBr<>ligneClicBr then + begin + if AncligneClicBr<>-1 then + begin + RE_ColorLine(RichBranche,AncligneClicBr,ClAqua); + end; + RE_ColorLine(RichBranche,ligneClicBr,ClYellow); + selStart:=curseur; // remettre le curseur en position initiale + end; + end; + end; + end; + + if ord(Key)=VK_DOWN then + begin + if clicListe then exit; + clicListe:=true; + if affevt then affiche('Evt RichBranche keydown',clyellow); + with Formconfig.RichBranche do + begin + lc:=Perform(EM_LINEFROMCHAR,-1,0); // numéro de la lignée cliquée + if lcligneClicBr then + begin + if AncligneClicBr<>-1 then + begin + RE_ColorLine(RichBranche,AncligneClicBr,ClAqua); + end; + RE_ColorLine(RichBranche,ligneClicBr,ClYellow); + selStart:=curseur; // remettre le curseur en position initiale + end; + end; + end; + end; + clicListe:=false; + +end; + + +begin + + + + end. diff --git a/UnitConfigTCO.dcu b/UnitConfigTCO.dcu index 8460aa8..1556e27 100644 Binary files a/UnitConfigTCO.dcu and b/UnitConfigTCO.dcu differ diff --git a/UnitDebug.dcu b/UnitDebug.dcu index 02b74b7..65e9f44 100644 Binary files a/UnitDebug.dcu and b/UnitDebug.dcu differ diff --git a/UnitPilote.dcu b/UnitPilote.dcu index e16471f..1919434 100644 Binary files a/UnitPilote.dcu and b/UnitPilote.dcu differ diff --git a/UnitPrinc.dcu b/UnitPrinc.dcu index ef59693..a824b1a 100644 Binary files a/UnitPrinc.dcu and b/UnitPrinc.dcu differ diff --git a/UnitPrinc.dfm b/UnitPrinc.dfm index 62eaa08..e4206cc 100644 --- a/UnitPrinc.dfm +++ b/UnitPrinc.dfm @@ -1374,7 +1374,7 @@ object FormPrinc: TFormPrinc object ButtonLocCV: TButton Left = 192 Top = 88 - Width = 81 + Width = 83 Height = 33 Caption = 'Trains / CVs' TabOrder = 8 diff --git a/UnitPrinc.pas b/UnitPrinc.pas index d772156..632bd65 100644 --- a/UnitPrinc.pas +++ b/UnitPrinc.pas @@ -3,7 +3,7 @@ Unit UnitPrinc; programme signaux complexes Graphique Lenz delphi 7 + activeX Tmscomm + clientSocket ******************************************** - 27/2/2022 10h + 6/3/2022 16h note sur le pilotage des accessoires: raquette octet sortie + 2 = aiguillage droit = sortie 2 de l'adresse d'accessoire @@ -198,6 +198,8 @@ NbMaxDet=100; // nombre maximal de d NbMemZone=2048; // adresse maximale des détecteurs Max_Trains=100; Max_event_det=400; +MaxBranches=100; +MaxElBranches=200; 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 @@ -286,7 +288,7 @@ TFeu = record Adr_el_suiv4 : integer; // adresse de l'élément4 suivant (si un signal est pour plusieurs voies) Btype_suiv1 : TEquipement ; // type de l'élément suivant ne prend que les valeurs rien, det ou aig Btype_suiv2 : TEquipement ; // - Btype_suiv3 : TEquipement ; // + Btype_suiv3 : TEquipement ; // Btype_suiv4 : TEquipement ; // VerrouCarre : boolean ; // si vrai, le feu se verrouille au carré si pas de train avant le signal modifie : boolean; // feu modifié @@ -397,7 +399,8 @@ var Aig_supprime,Aig_sauve : TAiguillage; Fimage : Timage; - BrancheN : array[1..100,1..200] of TBranche; + + BrancheN : array[1..MaxBranches,1..MaxElBranches] of TBranche; {$R *.dfm} @@ -440,6 +443,7 @@ procedure cree_image(rang : integer); procedure trouve_aiguillage(adresse : integer); procedure trouve_detecteur(detecteur : integer); function BTypeToNum(BT : TEquipement) : integer; +function ProcessRunning(sExeName: String) : Boolean; implementation @@ -494,8 +498,7 @@ begin until (i=16) or trouve; PremBitNum:=i; end; - - + // conversion du motif de bits (codebin) de la configuration du signal complexe en deux mots: // en sortie : // premierBit : code de la signalisation @@ -548,7 +551,6 @@ begin 16 17 18 19 } end; - // dessine un cercle plein dans le feu procedure cercle(ACanvas : Tcanvas;x,y,rayon : integer;couleur : Tcolor); begin @@ -3062,22 +3064,32 @@ end; // si 0 = OK // si 1 = erreur code Unisemaf // si 2 = erreur cohérence entre code et aspect +// si 3 = signal inconnu function verif_UniSemaf(adresse,UniSem : integer) : integer; -var aspect : integer; +var aspect,i : integer; begin if UniSem=0 then begin verif_unisemaf:=1;exit;end; if (UniSem<>2) and (UniSem<>3) and (UniSem<>4) and (UniSem<>51) and (UniSem<>52) and (UniSem<>71) and (UniSem<>72) and (UniSem<>73) and ((UniSem<90) or (UniSem>99)) then begin verif_UniSemaf:=1;exit;end; - aspect:=feux[index_feu(adresse)].aspect; - if ((aspect=2) and (UniSem=2)) or - ((aspect=3) and (UniSem=3)) or - ((aspect=4) and (UniSem=4)) or - ((aspect=5) and ((UniSem=51) or (UniSem=52))) or - ((aspect=7) and ((UniSem=71) or (UniSem=72) or (UniSem=73))) or - ((aspect=9) and ((UniSem>=90) or (UniSem<=99))) - then Verif_unisemaf:=0 - else Verif_Unisemaf:=2; + i:=index_feu(adresse); + if i<>0 then + begin + aspect:=feux[i].aspect; + if ((aspect=2) and (UniSem=2)) or + ((aspect=3) and (UniSem=3)) or + ((aspect=4) and (UniSem=4)) or + ((aspect=5) and ((UniSem=51) or (UniSem=52))) or + ((aspect=7) and ((UniSem=71) or (UniSem=72) or (UniSem=73))) or + ((aspect=9) and ((UniSem>=90) or (UniSem<=99))) + then Verif_unisemaf:=0 + else Verif_Unisemaf:=2; + end + else + begin + Affiche('Erreur Signal '+intToSTR(adresse)+' inconnu',clred); + Verif_Unisemaf:=3; + end; end; @@ -6386,13 +6398,13 @@ begin begin processID:=ProcessEntry32.th32ProcessID; CDMhd:=GetWindowFromID(processID); - Affiche('CDM rail processID='+IntToSTR(ProcessID)+' handle='+IntToSTR(CDMhd),clOrange); + //Affiche('CDM rail processID='+IntToSTR(ProcessID)+' handle='+IntToSTR(CDMhd),clOrange); Result:=true; Break; - end; + end; until (Process32Next(hSnapShot,ProcessEntry32)=false); CloseHandle(hSnapShot); -end; +end; // préparation du tampon pour SendInput procedure KeybdInput(VKey: Byte; Flags: DWORD); @@ -6492,7 +6504,6 @@ begin exit; end; - cdm_lanceLoc:=false; // lancement depuis le répertoire 32 bits d'un OS64 if ShellExecute(Formprinc.Handle,'open',PChar('C:\Program Files (x86)\CDM-Rail\cdr.exe'), @@ -6833,7 +6844,7 @@ begin begin pos:=aiguillage[index].posInit; s:='Init aiguillage '+intToSTR(i)+'='+intToSTR(pos); - if pos=1 then s:=s+' (dévié)' else s:=s+' (droit)'; + if pos=const_devie then s:=s+' (dévié)' else s:=s+' (droit)'; Affiche(s,cyan); pilote_acc(i,pos,aigP); sleep(Tempo_Aig); @@ -7349,7 +7360,7 @@ end; // décodage d'une trame CDM au protocole IPC // la trame_CDM peut contenir 2000 caractères à l'initialisation du RUN. procedure Interprete_trameCDM(trame_CDM:string); -var i,j,objet,posST,posAC,posDT,posSG,posXY,k,l,erreur, adr,adr2,etat,etataig, +var i,j,objet,posST,posAC,posDT,posSG,posXY,k,l,erreur,posErr, adr,adr2,etat,etataig, vitesse,etatAig2,name,prv,nbre,nbreVir,long,index,posDes,AncNumTrameCDM : integer ; x,y,x2,y2 : longint ; s,ss,train,commandeCDM : string; @@ -7372,13 +7383,16 @@ begin trame_cdm:=trame_cdm+'S-C-07-1373-DSCTRN-SPEED|029|03|NAME=CAMERA;AD=6;TMAX=120;' ; trame_cdm:=trame_cdm+'S-C-07-1374-DSCTRN-__END|000|' ; } + //affiche(trame_cdm,clLime); residuCDM:=''; AckCDM:=trame_CDM<>''; - if pos('ACK',trame_CDM)=0 then + + {if pos('ACK',trame_CDM)=0 then begin if pos('ERR=200',trame_CDM)<>0 then Affiche('Erreur CDM : réseau non chargé',clred); + if pos('ERR=500',trame_CDM)<>0 then Affiche('Erreur CDM : serveur DCC non lancé',clred); end; - + } k:=0; repeat {// inutile de vérifier les numéros de trames, elles peuvent ne pas être envoyées dans l'ordre!! @@ -7401,18 +7415,18 @@ begin val(copy(trame_CDM,i+1,j-1),NumTrameCDM,erreur); if AncNumTrameCDM=0 then AncNumTrameCDM:=NumTrameCDM-1; affiche(IntToSTR(NumTrameCDM),clLime); - if AncNumTrameCDM+1<>NumTrameCDM then + if AncNumTrameCDM+1<>NumTrameCDM then begin s:='Erreur trames CDM perdues: #dernière='+intToSTR(AncNumTrameCDM)+' #Nouvelle='+intToSTR(NumTrameCDM); Affiche(s,clred); AfficheDebug(s,clred); - end; + end; end; end; end; end; end;} - + // trouver la longueur de la chaîne de paramètres entre les 2 premiers |xxx| i:=pos('|',trame_CDM); if i=0 then @@ -7443,6 +7457,7 @@ begin goto reprise; end; + if long>l then begin if debugTrames then AfficheDebug('tronqué3 : '+trame_CDM,clyellow); @@ -7475,6 +7490,23 @@ begin //if debugTrames then AfficheDebug(commandeCDM,clorange); Delete(trame_CDM,1,i); + //Affiche('long chaine param='+intToSTR(long),clyellow); + if long=0 then + begin + //if debugTrames then Affiche('Longueur nulle',clYellow); + if pos('ACK',trame_cdm)<>0 then Ack_cdm:=true; + delete(trame_cdm,1,j); + goto reprise; + end; + + posERR:=pos('_ERR',commandeCDM); + if posErr<>0 then + begin + if pos('ERR=200',commandeCDM)<>0 then Affiche('Erreur CDM : réseau non chargé',clred); + //if pos('ERR=500',commandeCDM)<>0 then Affiche('Erreur CDM : serveur DCC non lancé',clred); + delete(commandeCDM,1,i); + end; + // description des trains 03|NAME=BB16024;AD=3;TMAX=120;' posDES:=pos('DSCTRN-SPEED',commandeCDM); if posDES<>0 then diff --git a/UnitSR.dcu b/UnitSR.dcu index 1b26ecb..ece9cc9 100644 Binary files a/UnitSR.dcu and b/UnitSR.dcu differ diff --git a/UnitSimule.dcu b/UnitSimule.dcu index ecbfd14..986672f 100644 Binary files a/UnitSimule.dcu and b/UnitSimule.dcu differ diff --git a/UnitTCO.dcu b/UnitTCO.dcu index 796ce98..c2c73f0 100644 Binary files a/UnitTCO.dcu and b/UnitTCO.dcu differ diff --git a/UnitTCO.dfm b/UnitTCO.dfm index 6e4b667..d480182 100644 --- a/UnitTCO.dfm +++ b/UnitTCO.dfm @@ -1,6 +1,6 @@ object FormTCO: TFormTCO - Left = 20 - Top = 203 + Left = 139 + Top = 146 Width = 1139 Height = 694 VertScrollBar.Visible = False @@ -110,6 +110,8 @@ object FormTCO: TFormTCO VertScrollBar.Tracking = True Anchors = [akLeft, akTop, akRight] BevelEdges = [beLeft, beTop, beRight] + Color = clBtnFace + ParentColor = False TabOrder = 0 DesignSize = ( 1032 @@ -117,8 +119,8 @@ object FormTCO: TFormTCO object ImageTCO: TImage Left = 0 Top = 0 - Width = 1012 - Height = 303 + Width = 1009 + Height = 353 Anchors = [akLeft, akTop, akRight, akBottom] PopupMenu = PopupMenu1 OnClick = ImageTCOClick @@ -157,44 +159,45 @@ object FormTCO: TFormTCO Font.Style = [] ParentFont = False TabOrder = 2 + OnDragOver = Panel1DragOver DesignSize = ( 1100 166) object Label4: TLabel Left = 8 - Top = 8 - Width = 137 - Height = 20 + Top = 16 + Width = 103 + Height = 16 Caption = 'Adresse de l'#39#233'l'#233'ment: ' Font.Charset = ANSI_CHARSET Font.Color = clWindowText - Font.Height = -16 + Font.Height = -13 Font.Name = 'Arial Narrow' Font.Style = [] ParentFont = False end object Label5: TLabel Left = 8 - Top = 32 - Width = 116 - Height = 20 + Top = 40 + Width = 89 + Height = 16 Caption = 'Type de l'#39#233'l'#233'ment: ' Font.Charset = ANSI_CHARSET Font.Color = clWindowText - Font.Height = -16 + Font.Height = -13 Font.Name = 'Arial Narrow' Font.Style = [] ParentFont = False end object Label15: TLabel Left = 8 - Top = 56 - Width = 123 - Height = 20 + Top = 64 + Width = 93 + Height = 16 Caption = 'Image de l'#39#233'l'#233'ment: ' Font.Charset = ANSI_CHARSET Font.Color = clWindowText - Font.Height = -16 + Font.Height = -13 Font.Name = 'Arial Narrow' Font.Style = [] ParentFont = False @@ -205,6 +208,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette5DragOver OnEndDrag = ImagePalette5EndDrag OnMouseDown = ImagePalette5MouseDown end @@ -227,6 +231,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette2DragOver OnEndDrag = ImagePalette2EndDrag OnMouseDown = ImagePalette2MouseDown end @@ -262,6 +267,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette1DragOver OnEndDrag = ImagePalette1EndDrag OnMouseDown = ImagePalette1MouseDown end @@ -271,6 +277,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette6DragOver OnEndDrag = ImagePalette6EndDrag OnMouseDown = ImagePalette6MouseDown end @@ -280,6 +287,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette7DragOver OnEndDrag = ImagePalette7EndDrag OnMouseDown = ImagePalette7MouseDown end @@ -289,6 +297,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette8DragOver OnEndDrag = ImagePalette8EndDrag OnMouseDown = ImagePalette8MouseDown end @@ -298,6 +307,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette9DragOver OnEndDrag = ImagePalette9EndDrag OnMouseDown = ImagePalette9MouseDown end @@ -359,6 +369,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette3DragOver OnEndDrag = ImagePalette3EndDrag OnMouseDown = ImagePalette3MouseDown end @@ -403,6 +414,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette10DragOver OnEndDrag = ImageDiag10EndDrag OnMouseDown = ImagePalette10MouseDown end @@ -425,6 +437,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette11DragOver OnEndDrag = ImageDiag11EndDrag OnMouseDown = ImagePalette11MouseDown end @@ -448,6 +461,7 @@ object FormTCO: TFormTCO Height = 41 DragMode = dmAutomatic Stretch = True + OnDragOver = ImagePalette30DragOver OnEndDrag = ImagePalette30EndDrag OnMouseDown = ImagePalette30MouseDown end @@ -470,6 +484,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette12DragOver OnEndDrag = ImagePalette12EndDrag OnMouseDown = ImagePalette12MouseDown end @@ -505,6 +520,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette13DragOver OnEndDrag = ImagePalette13EndDrag OnMouseDown = ImagePalette13MouseDown end @@ -527,6 +543,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette14DragOver OnEndDrag = ImagePalette14EndDrag OnMouseDown = ImagePalette14MouseDown end @@ -549,18 +566,19 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette15DragOver OnEndDrag = ImagePalette15EndDrag OnMouseDown = ImagePalette15MouseDown end object Label23: TLabel - Left = 8 - Top = 85 - Width = 33 - Height = 20 + Left = 56 + Top = 88 + Width = 27 + Height = 16 Caption = 'Texte' Font.Charset = ANSI_CHARSET Font.Color = clWindowText - Font.Height = -16 + Font.Height = -13 Font.Name = 'Arial Narrow' Font.Style = [] ParentFont = False @@ -571,6 +589,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette16DragOver OnEndDrag = ImagePalette16EndDrag OnMouseDown = ImagePalette16MouseDown end @@ -593,6 +612,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette17DragOver OnEndDrag = ImagePalette17EndDrag OnMouseDown = ImagePalette17MouseDown end @@ -615,6 +635,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette18DragOver OnEndDrag = ImagePalette18EndDrag OnMouseDown = ImagePalette18MouseDown end @@ -637,6 +658,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette19DragOver OnEndDrag = ImagePalette19EndDrag OnMouseDown = ImagePalette19MouseDown end @@ -659,6 +681,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette20DragOver OnEndDrag = ImagePalette20EndDrag OnMouseDown = ImagePalette20MouseDown end @@ -681,6 +704,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette21DragOver OnEndDrag = ImagePalette21EndDrag OnMouseDown = ImagePalette21MouseDown end @@ -703,6 +727,7 @@ object FormTCO: TFormTCO Width = 41 Height = 41 DragMode = dmAutomatic + OnDragOver = ImagePalette22DragOver OnEndDrag = ImagePalette22EndDrag OnMouseDown = ImagePalette22MouseDown end @@ -719,14 +744,27 @@ object FormTCO: TFormTCO Font.Style = [fsBold] ParentFont = False end + object Label1: TLabel + Left = 8 + Top = 112 + Width = 75 + Height = 16 + Caption = 'position du texte' + Font.Charset = ANSI_CHARSET + Font.Color = clBlack + Font.Height = -13 + Font.Name = 'Arial Narrow' + Font.Style = [] + ParentFont = False + end object EditAdrElement: TEdit - Left = 152 - Top = 8 + Left = 144 + Top = 16 Width = 33 - Height = 28 + Height = 24 Font.Charset = ANSI_CHARSET Font.Color = clWindowText - Font.Height = -16 + Font.Height = -13 Font.Name = 'Arial Narrow' Font.Style = [] ParentFont = False @@ -735,13 +773,13 @@ object FormTCO: TFormTCO OnKeyDown = EditAdrElementKeyDown end object EditTypeElement: TEdit - Left = 152 - Top = 32 + Left = 144 + Top = 40 Width = 33 - Height = 28 + Height = 24 Font.Charset = ANSI_CHARSET Font.Color = clWindowText - Font.Height = -16 + Font.Height = -13 Font.Name = 'Arial Narrow' Font.Style = [] ParentFont = False @@ -749,13 +787,13 @@ object FormTCO: TFormTCO TabOrder = 1 end object EditTypeImage: TEdit - Left = 152 - Top = 56 + Left = 144 + Top = 64 Width = 33 - Height = 28 + Height = 24 Font.Charset = ANSI_CHARSET Font.Color = clWindowText - Font.Height = -16 + Font.Height = -13 Font.Name = 'Arial Narrow' Font.Style = [] ParentFont = False @@ -812,7 +850,7 @@ object FormTCO: TFormTCO OnClick = ButtonConfigTCOClick end object EditTexte: TEdit - Left = 96 + Left = 88 Top = 88 Width = 89 Height = 21 @@ -830,7 +868,7 @@ object FormTCO: TFormTCO end object CheckPinv: TCheckBox Left = 16 - Top = 120 + Top = 144 Width = 161 Height = 17 Caption = 'aiguillage invers'#233 @@ -848,14 +886,19 @@ object FormTCO: TFormTCO WordWrap = True OnClick = ButtonMasquerClick end - object ButtonConstruit: TButton - Left = 880 - Top = 88 + object ComboRepr: TComboBox + Left = 88 + Top = 112 Width = 89 - Height = 33 - Caption = 'Construit TCO' + Height = 21 + ItemHeight = 13 TabOrder = 12 - OnClick = ButtonConstruitClick + OnChange = ComboReprChange + Items.Strings = ( + 'Sans' + 'Centrale' + 'Haut' + 'Bas') end end object ButtonAfficheBandeau: TButton @@ -872,7 +915,7 @@ object FormTCO: TFormTCO object PopupMenu1: TPopupMenu Left = 360 object MenuCouper: TMenuItem - Caption = 'Couper' + Caption = '-' OnClick = MenuCouperClick end object MenuCopier: TMenuItem @@ -894,15 +937,15 @@ object FormTCO: TFormTCO Caption = '-' end object Tourner90G: TMenuItem - Caption = 'Positionner 90'#176' '#224' gauche' + Caption = 'Positionner feu 90'#176' '#224' gauche' OnClick = Tourner90GClick end object Tourner90D: TMenuItem - Caption = 'Positionner 90'#176' '#224' droite' + Caption = 'Positionner feu 90'#176' '#224' droite' OnClick = Tourner90DClick end object Pos_vert: TMenuItem - Caption = 'Positionner verticalement' + Caption = 'Positionner feu verticalement' OnClick = Pos_vertClick end end diff --git a/UnitTCO.pas b/UnitTCO.pas index 64054f0..91fb91c 100644 --- a/UnitTCO.pas +++ b/UnitTCO.pas @@ -93,7 +93,8 @@ type Label29: TLabel; ImagePalette22: TImage; Label30: TLabel; - ButtonConstruit: TButton; + ComboRepr: TComboBox; + Label1: TLabel; procedure FormCreate(Sender: TObject); procedure ImageTCOClick(Sender: TObject); procedure FormActivate(Sender: TObject); @@ -246,9 +247,56 @@ type Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure EditAdrElementKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); - procedure ButtonConstruitClick(Sender: TObject); procedure ImageTCODblClick(Sender: TObject); - + procedure ComboReprChange(Sender: TObject); + procedure Colorer1Click(Sender: TObject); + procedure ImagePalette1DragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure ImagePalette2DragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure ImagePalette3DragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure ImagePalette5DragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure ImagePalette12DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette13DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette14DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette15DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette21DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette22DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette6DragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure ImagePalette7DragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure ImagePalette8DragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure ImagePalette9DragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure ImagePalette16DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette17DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette18DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette19DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette20DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette10DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette11DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure ImagePalette30DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); + procedure Panel1DragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + private { Déclarations privées } public @@ -258,21 +306,20 @@ type const - ZoomMax=50; MaxCellX=150;MaxCellY=70; - type // structure du TCO TTCO = array[1..MaxCellX] of array[1..MaxCellY] of record - BType : TEquipement ; + BType : TEquipement ; Adresse : integer ; // adresse du détecteur ou de l'aiguillage ou du feu BImage : integer ; // 0=rien 1=voie 2=aiguillage gauche gauche ... 30=feu mode : integer; // 0=éteint 1=allumé inverse : boolean; // aiguillage piloté inversé + repr : integer; // représentation 0 = rien 1=centrale 2=Haut 3=Bas Texte : string[30]; - couleurTexte : Tcolor; + Couleur : Tcolor; // couleur de fond de la cellule // pour les feux seulement PiedFeu : integer; // type de pied au feu x,y : integer ; // coordonnées pixels relativés du coin sup gauche pour le décalage par rapport à la cellule @@ -308,19 +355,18 @@ var procedure calcul_reduction(Var frx,fry : real;DimDestX,DimDestY,DimOrgX,DimOrgY : integer); procedure sauve_fichier_tco; procedure zone_TCO(det1,det2,mode : integer); - +procedure efface_entoure; + implementation -uses UnitConfigTCO; - +uses UnitConfigTCO, Unit_Pilote_aig; {$R *.dfm} - procedure lire_fichier_tco; var fichier : textfile; s : string; - x,y,i,j,adresse,Aspect,valeur,erreur,FeuOriente,PiedFeu : integer; + x,y,i,j,m,adresse,Aspect,valeur,erreur,FeuOriente,PiedFeu : integer; BT : TEquipement; function lit_ligne : string ; var c : char; @@ -344,7 +390,7 @@ begin exit; end; {$I-} - + x:=1;y:=1;NbreCellX:=0;NbreCellY:=0; // couleurs @@ -360,7 +406,6 @@ begin if pos(',',s)=0 then begin val('$'+s,cltexte,erreur);s:=lit_ligne;end; - // taille de la matrice Val(s,NbreCellX,erreur); delete(s,1,erreur); @@ -391,7 +436,7 @@ begin if valeur=1 then BT:=det; if valeur=2 then BT:=aig; if valeur=4 then BT:=buttoir; - + tco[x,y].BType:=BT; delete(s,1,i); @@ -408,14 +453,14 @@ begin val(copy(s,1,i-1),valeur,erreur);if erreur<>0 then begin closefile(fichier);exit;end; tco[x,y].Bimage:=valeur; delete(s,1,i); - + //Inverse i:=pos(',',s); if i=0 then begin closefile(fichier);exit;end; val(copy(s,1,i-1),valeur,erreur);if erreur<>0 then begin closefile(fichier);exit;end; tco[x,y].inverse:=valeur=1; delete(s,1,i); - + // FeuOriente (pas encore stocké) i:=pos(',',s); if i=0 then begin closefile(fichier);exit;end; @@ -423,40 +468,52 @@ begin delete(s,1,i); // PiedFeu (pas encore stocké) - i:=pos(',',s); j:=pos(')',s); - if j0 then begin closefile(fichier);exit;end; - if s[i]=',' then delete(s,1,i) else delete(s,1,i-1); - + i:=pos(',',s); //j:=pos(')',s); + //if j0 then + if i<>0 then begin aspect:=Feux[i].aspect; //Affiche('Feu '+IntToSTR(Adresse)+' aspect='+intToSTR(aspect),clyellow); tco[x,y].Aspect:=aspect; tco[x,y].FeuOriente:=FeuOriente; - tco[x,y].x:=0; + tco[x,y].x:=0; tco[x,y].y:=0; - TCO[x,y].PiedFeu:=PiedFeu; - end; - + TCO[x,y].PiedFeu:=PiedFeu; + end; + end; // texte optionnel j:=pos(')',s); + i:=pos(',',s); + tco[x,y].Texte:=''; + if j>1 then // le , est avant le ) donc il y a un texte begin - if j>1 then // le , est avant le ) donc il y a un peut-etre un texte - begin - tco[x,y].Texte:=copy(s,1,j-1) ; - end - else - tco[x,y].Texte:=''; - delete(s,1,j); + if j1 then begin // si la cellule au dessus contient un feu vertical, ne pas effacer la cellule - // if (tco[x,y-1].BImage=12) and (tco[x,y-1].FeuOriente=1) then exit; + // if (tco[x,y-1].BImage=12) and (tco[x,y-1].FeuOriente=1) then exit; end; if xMax then begin Max:=j-1;IndexMax:=i;end; - end; - Affiche('La branche la plus grande a pour index '+IntToSTR(IndexMax),clOrange); - - // stocker cette branche au milieu du TCO (en 5) - ligne:=5; - for i:=1 to Max do - begin - Adresse:=BrancheN[IndexMax,i].Adresse; - BT:=BrancheN[IndexMax,i].Btype; - TCO[i,ligne].Adresse:=Adresse; - TCO[i,ligne].Btype:=BT; - // Btype 1= détecteur 2= aiguillage 3=bis 4=Buttoir - if Bt=det then TCO[i,ligne].BImage:=1; - if Bt=aig then - begin - // A20,547,561,A22,A24,A26,515,518,A31,A29,A28,A30,539,522,A3,A1,A2,A4,A6B,545,A5B,A3 - //20,P8P,D547,S548 // 22,P24P,S561,D25S - // on se réfère au suivant - AdrSuiv:=BrancheN[IndexMax,i+1].Adresse; - index:=Index_aig(adresse); - // connecté sur position droite : la pointe est à gauche - if aiguillage[Index].Adroit=AdrSuiv then Bimage:=3; // ou 4 - // connecté sur position déviée : la pointe est à gauche, mais il faut changer de ligne - if aiguillage[Index].Adevie=AdrSuiv then Bimage:=4; // ou 4 - // connecté sur pointe : la pointe est à droite - if aiguillage[Index].Apointe=AdrSuiv then Bimage:=5; // ou 2 - TCO[i,ligne].BImage:=Bimage; - end; - end; end; - // affiche la cellule x et y en cases procedure TformTCO.affiche_cellule(x,y : integer); -var p,Xorg,Yorg,xt,yt,mode,adresse,Bimage,aspect,oriente,pos : integer; +var repr,p,Xorg,Yorg,xt,yt,mode,adresse,Bimage,aspect,oriente,pos : integer; Bt : TEquipement; s : string; begin @@ -2418,23 +2415,26 @@ begin bt:=tco[x,y].Btype; BImage:=tco[x,y].BImage; mode:=tco[x,y].mode; + repr:=tco[x,y].repr; // récupérer la position de l'aiguillage if (bImage>=2) then //????? and (btype<=15) begin if Adresse<>0 then pos:=Aiguillage[Index_Aig(adresse)].position else pos:=const_inconnu; - if TCO[x,y].inverse then + if TCO[x,y].inverse then begin p:=const_inconnu; if pos=const_devie then p:=const_droit; if pos=const_droit then p:=const_devie; pos:=p; end; - + end; Xorg:=(x-1)*LargeurCell; Yorg:=(y-1)*HauteurCell; + + // ------------- affichage de l'adresse ------------------ s:=IntToSTR(adresse); // pourquoi ? ? if y>1 then if (tco[x,y-1].Bimage=30) and (FeuTCO[i].FeuOriente=1) then exit; @@ -2501,12 +2501,19 @@ begin begin Brush.Color:=fond; Font.Color:=clWhite; - xt:=round(15*frXGlob);yt:=HauteurCell-round(17*frYGlob); - TextOut(xOrg+xt,yOrg+yt,s); - //exit; + xt:=round(15*frXGlob); + case repr of + 1 : yt:=(HauteurCell div 2)-round(7*fryGlob); // milieu + 2 : yt:=1; // haut + 3 : yt:=HauteurCell-round(17*frYGlob); // bas + end; + if repr<>0 then + begin + TextOut(xOrg+xt,Yorg+yt,s); + end; end; end; - + if ((Bimage=10) or (Bimage=20)) and (adresse<>0) then begin // Adresse de l'élément with PCanvasTCO do @@ -2515,10 +2522,10 @@ begin Font.Color:=clWhite; TextOut(xOrg+round(2*frXGlob),yOrg+round(2*fryGlob),s); //exit; - end; + end; end; - - if (Bimage=11) and (adresse<>0) then + + if (Bimage=11) and (adresse<>0) then begin // Adresse de l'élément with PCanvasTCO do begin @@ -2530,8 +2537,8 @@ begin end; // adresse des signaux - if (BImage=30) and (adresse<>0) then - begin + if (BImage=30) and (adresse<>0) then + begin aspect:=TCO[x,y].Aspect; oriente:=TCO[x,y].FeuOriente; xt:=0;yt:=0; @@ -2558,11 +2565,11 @@ begin Brush.Color:=fond; Font.Color:=clLime; TextOut(xOrg+xt,yOrg+yt,s); - end; + end; end; - entoure_cell_grille(x,y); - //canvasTCO.TextOut(xOrg+1,yOrg+1,IntToSTR(x)); + entoure_cell_grille(x,y); + //canvasTCO.TextOut(xOrg+1,yOrg+1,IntToSTR(x)); end; procedure Entoure_cell(x,y : integer); @@ -2612,7 +2619,7 @@ end; // affiche le tco suivant le tableau TCO procedure TformTCO.Affiche_TCO ; -var x,y,x0,y0,DimX,DimY : integer; +var x,y,x0,y0,DimX,DimY,repr,yt : integer; s : string; r : Trect; begin @@ -2621,15 +2628,14 @@ begin PImageTCO.Height:=DimY; PImageTCO.Width:=DimX; - + PBitMapTCO.Height:=DimY; PBitMapTCO.Width:=DimX; - + PScrollBoxTCO.HorzScrollBar.Range:=DimX; PScrollBoxTCO.VertScrollBar.Range:=DimY; calcul_reduction(frxGlob,fryGlob,LargeurCell,HauteurCell,ZoomMax,ZoomMax); - //Affiche(formatfloat('0.000000',frxGlob),clyellow); //effacer tout @@ -2638,7 +2644,7 @@ begin Brush.Color:=clWhite; Pen.width:=1; r:=rect(0,0,ImageTCO.Width,ImageTCO.height); - FillRect(r); + FillRect(r); Brush.Style:=bsSolid; Brush.Color:=fond; pen.color:=clyellow; @@ -2650,38 +2656,47 @@ begin for y:=1 to NbreCellY do for x:=1 to NbreCellX do begin - if TCO[x,y].BImage<>30 then + if TCO[x,y].BImage<>30 then begin affiche_cellule(x,y); - end; + end; end; - PCanvasTCO.Font.Size:=8; + PCanvasTCO.Font.Size:=8; //afficher les cellules des feux et les textes pour que les pieds recouvrent le reste et afficher les textes for y:=1 to NbreCellY do for x:=1 to NbreCellX do begin - if TCO[x,y].BImage=30 then affiche_cellule(x,y); + if TCO[x,y].BImage=30 then + begin + affiche_cellule(x,y); + end; s:=Tco[x,y].Texte; - if s<>'' then + if s<>'' then begin x0:=(x-1)*Largeurcell; y0:=(y-1)*hauteurcell; - //PCanvasTCO.Brush.Style:=bsSolid; + //PCanvasTCO.Brush.Style:=bsSolid; PCanvasTCO.Brush.Color:=fond; //PCanvasTCO.pen.color:=clyellow; PcanvasTCO.Font.Color:=clTexte; - PcanvasTCO.Textout(x0+2,y0+1,s); - end; + repr:=tco[x,y].repr; + case repr of + 1 : yt:=(HauteurCell div 2)-round(7*fryGlob); // milieu + 2 : yt:=1; // haut + 3 : yt:=HauteurCell-round(17*frYGlob); // bas + end; + PcanvasTCO.Textout(x0+2,y0+yt,s); + end; end; // afficher la grille - grille; - - if entoure then +// grille; + + if entoure then begin - Entoure_cell(Xentoure,Yentoure); - end; + Entoure_cell(Xentoure,Yentoure); + end; end; @@ -2705,8 +2720,9 @@ begin clVoies:=clOrange; clTexte:=ClLime; clGrille:=$404040; - // évite le clignotement pendant les affichages - DoubleBuffered:=true; + // évite le clignotement pendant les affichages mais ne marche pas + DoubleBuffered:=true; + comborepr.Enabled:=false; controlStyle:=controlStyle+[csOpaque]; end; @@ -2724,19 +2740,20 @@ begin // MenuItem.onclick:= MenuItem.Tag:=GetTickCount; popupMenu1.Items.Add(MenuItem); } - + Position:=ImageTCO.screenToCLient(Position); //Affiche(IntToSTR(position.x),clyellow); Xclic:=position.X;YClic:=position.Y; XclicCell:=Xclic div largeurCell +1; YclicCell:=Yclic div hauteurCell +1; - if XclicCell>NbreCellX then exit; + if XclicCell>NbreCellX then exit; if YclicCell>NbreCellY then exit; Bimage:=tco[XClicCell,YClicCell].Bimage; + // si aiguillage, mettre à jour l'option de pilotage inverse - if (bimage=2) or (bimage=3) or (bimage=4) or (bimage=5) or (bimage=12) or (bimage=13) - or (bimage=14) or (bimage=15) then + if (bimage=2) or (bimage=3) or (bimage=4) or (bimage=5) or (bimage=12) or (bimage=13) + or (bimage=14) or (bimage=15) then begin CheckPinv.enabled:=true ; CheckPinv.checked:=TCO[XClicCell,YClicCell].inverse; @@ -2744,14 +2761,16 @@ begin else CheckPinv.enabled:=false; if (Bimage=1) or (Bimage=0) then - begin + begin s:=Tco[XClicCell,YClicCell].Texte; - EditTexte.Text:=s; - EditTexte.Visible:=true - end + EditTexte.Text:=s; + EditTexte.Visible:=true + end else EditTexte.Visible:=false; - LabelX.caption:=IntToSTR(XclicCell); + if (Bimage=1) or (Bimage=0) then ComboRepr.Enabled:=true else comboRepr.Enabled:=false; + + LabelX.caption:=IntToSTR(XclicCell); LabelY.caption:=IntToSTR(YclicCell); XclicCellInserer:=XClicCell; YclicCellInserer:=YClicCell; @@ -2759,10 +2778,11 @@ begin EditAdrElement.Text:=IntToSTR(tco[XClicCellInserer,YClicCellInserer].Adresse); EdittypeElement.Text:=IntToSTR(BtypeToNum(tco[XClicCellInserer,YClicCellInserer].BType)); EdittypeImage.Text:=IntToSTR(BImage); + ComboRepr.ItemIndex:=tco[XClicCell,yClicCell].repr; - if not(selectionaffichee) then _entoure_cell_clic; + if not(selectionaffichee) then _entoure_cell_clic; end; - + // trouve le détecteur det dans le TCO et renvoie X et Y procedure trouve_det(det : integer;var x,y : integer); var xc,yc : integer; @@ -2791,7 +2811,7 @@ begin end; -// allume ou éteint (mode) la voie, zone de det1 à det2 sur le TCO +// allume ou éteint (mode=0 ou 1) la voie, zone de det1 à det2 sur le TCO procedure zone_TCO(det1,det2,mode : integer); var i,x,y,ancienY,ancien2Y,ancienX,ancien2X,Xdet1,Ydet1,Xdet2,Ydet2,Bimage,adresse, pos,pos2 : integer; @@ -2801,33 +2821,29 @@ begin // trouver le détecteur det1 trouve_det(det1,Xdet1,Ydet1); if (Xdet1=0) or (Ydet1=0) then exit; - - //Affiche('trouvé '+intToSTR(det1)+' en '+IntToSTR(xDet1)+'/'+intToSTR(ydet1),clyellow); + trouve_det(det2,Xdet2,Ydet2); if (Xdet2=0) or (Ydet2=0) then exit; - // inverser coordonnées et détecteurs si à l'envers - if xDet2det2) and memTrouve) or (i>40); - //Affiche(intToSTR(x),clLime); - if i>NbCellulesTCO then - begin + inc(i); + if adresse=det2 then memTrouve:=true; + until (x=1) or (x=NbreCellX) or (y=NbreCellY) or ((adresse<>det2) and memTrouve) or (i>NbCellulesTCO); + //Affiche(intToSTR(x),clLime); + if i>NbCellulesTCO then + begin s:='Erreur 1000 : dépassement d''itérations TCO: '+IntToSTR(det1)+' - '+IntToSTR(det2); - Affiche(s,clred); AfficheDebug(s,clred); end; -end; + Affiche(s,clred); AfficheDebug(s,clred); + end; +end; procedure TFormTCO.FormActivate(Sender: TObject); begin @@ -3022,16 +3039,16 @@ begin ImageTemp.Visible:=not(Diffusion); SourisX.Visible:=not(Diffusion); SourisY.Visible:=not(Diffusion); - ButtonConstruit.Visible:=not(Diffusion); ButtonAfficheBandeau.visible:=false; - + PScrollBoxTCO:=FormTCO.ScrollBox; lire_fichier_tco; + NbCellulesTCO:=NbreCellX*NbreCellY; - + calcul_reduction(frxGlob,fryGlob,LargeurCell,HauteurCell,ZoomMax,ZoomMax); - // dessiner les icônes + // dessiner les icônes dessin_AigPD_AD(ImagePalette5.Canvas,1,1,0,9); dessin_AigG_PD(ImagePalette2.Canvas,1,1,0,9); dessin_AigPG_AG(ImagePalette3.Canvas,1,1,0,9); @@ -3054,34 +3071,32 @@ begin dessin_20(ImagePalette20.canvas,1,1,0); dessin_21(ImagePalette21.canvas,1,1,0); dessin_22(ImagePalette22.canvas,1,1,0); - + ImageTCO.Width:=LargeurCell*NbreCellX; ImageTCO.Height:=HauteurCell*NbreCellY; - + ImageTCO.Picture.Create; ImageTCO.Picture.Bitmap.Height:=HauteurCell*NbreCellY; ImageTCO.Picture.BitMap.Width:=LargeurCell*NbreCellX; - - + PCanvasTCO:=FormTCO.ImageTCO.Picture.Bitmap.Canvas; PBitMapTCO:=FormTCO.ImageTCO.Picture.Bitmap; PImageTCO:=FormTCO.ImageTCO; PImageTemp:=FormTCO.ImageTemp; PImageTemp.Canvas.Rectangle(0,0,PImageTemp.Width,PimageTemp.Height); - + With ImagePalette30 do begin - Picture.Bitmap.TransparentMode:=tmAuto; + Picture.Bitmap.TransparentMode:=tmAuto; Picture.Bitmap.TransparentColor:=clblue; Transparent:=true; Picture.Bitmap:=Formprinc.Image9feux.Picture.Bitmap; - end; + end; - Affiche_tco; + //Affiche_tco; end; TrackBarZoom.Position:=ZoomMax-LargeurCell+20; - end; // evt qui se produit quand on clic droit dans l'image @@ -3168,13 +3183,13 @@ end; procedure TFormTCO.CourbeSupD1Click(Sender: TObject); var Position: TPoint; begin - // effacer le carré pointeur + // effacer le carré pointeur //Entoure_cell(XclicCell,YclicCell); // dessine le dessin dessin_SupD(ImageTCO.canvas,XClicCellInserer,YClicCellInserer,0); // remet le carré pointeur //Entoure_cell(XclicCell,YclicCell); - GetCursorPos(Position); + GetCursorPos(Position); end; procedure TFormTCO.CourbeSupG1Click(Sender: TObject); @@ -3193,11 +3208,10 @@ end; procedure TFormTCO.ImageTCODragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin -// Accept:=source is TImage; + // Accept:=source is TImage; end; - procedure TFormTCO.FormDockOver(Sender: TObject; Source: TDragDockObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin @@ -3213,6 +3227,8 @@ end; procedure TFormTCO.ImagePalette5EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3232,6 +3248,8 @@ end; procedure TFormTCO.ImagePalette2EndDrag(Sender,Target: TObject; X,Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3257,6 +3275,8 @@ end; procedure TFormTCO.ImagePalette3EndDrag(Sender, Target: TObject; X,Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3281,6 +3301,8 @@ end; procedure TFormTCO.ImagePalette4EndDrag(Sender, Target: TObject; X,Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3303,9 +3325,9 @@ begin ImagePalette4.BeginDrag(true); end; -procedure TFormTCO.ImagePalette1EndDrag(Sender, Target: TObject; X, - Y: Integer); +procedure TFormTCO.ImagePalette1EndDrag(Sender, Target: TObject; X,Y: Integer); begin + if not(target=ImageTCO) then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3332,6 +3354,8 @@ end; procedure TFormTCO.ImagePalette6EndDrag(Sender, Target: TObject; X,Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3357,6 +3381,8 @@ end; procedure TFormTCO.ImagePalette7EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3383,6 +3409,8 @@ end; procedure TFormTCO.ImagePalette8EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3485,6 +3513,8 @@ end; procedure TFormTCO.ImagePalette9EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3505,6 +3535,8 @@ end; procedure TFormTCO.ImagePalette12EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3527,6 +3559,8 @@ end; procedure TFormTCO.ImagePalette13EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3548,6 +3582,8 @@ end; procedure TFormTCO.ImagePalette14EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3568,6 +3604,8 @@ end; procedure TFormTCO.ImagePalette15EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3587,6 +3625,8 @@ end; procedure TFormTCO.ImagePalette16EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3607,6 +3647,8 @@ end; procedure TFormTCO.ImagePalette17EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3627,6 +3669,8 @@ end; procedure TFormTCO.ImagePalette18EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3647,6 +3691,8 @@ end; procedure TFormTCO.ImagePalette19EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3667,6 +3713,8 @@ end; procedure TFormTCO.ImagePalette20EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3687,6 +3735,8 @@ end; procedure TFormTCO.ImagePalette21EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3707,6 +3757,8 @@ end; procedure TFormTCO.ImagePalette22EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -3801,7 +3853,7 @@ begin for y:=1 to NbreCellY do for x:=1 to NbreCellX do begin - if TCO[x,y].BImage=30 then + if TCO[x,y].BImage=30 then begin Adresse:=TCO[x,y].adresse; j:=Index_feu(adresse); @@ -3823,7 +3875,7 @@ begin efface_cellule(ImageTCO.Canvas,XclicCell,YClicCell,fond,PmCopy); TamponAffecte:=true; xCoupe:=XclicCell;yCoupe:=YclicCell; - + Affiche_tco; exit; end; @@ -4023,12 +4075,12 @@ procedure TFormTCO.EditAdrElementChange(Sender: TObject); var Adr,erreur,index,aspect : integer; begin Val(EditAdrElement.Text,Adr,erreur); - if (erreur<>0) or (Adr<0) or (Adr>2048) then + if (erreur<>0) or (Adr<0) or (Adr>2048) then begin EditAdrElement.text:=intToSTR(tco[XClicCell,YClicCell].Adresse); exit; - end; - + end; + tco[XClicCell,YClicCell].Adresse:=Adr; //Affiche('Chgt adresse',clyellow); @@ -4042,8 +4094,7 @@ begin Aspect:=Feux[index].Aspect; tco[XClicCell,YClicCell].aspect:=aspect; affiche_tco; - //affiche_cellule(XClicCell,YClicCell,pmCopy); - end; + end; end; end; @@ -4115,6 +4166,8 @@ end; // dépose d'un feu sur le TCO procedure TFormTCO.ImageDiag10EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; TCO_modifie:=true; Xclic:=X;YClic:=Y; @@ -4144,6 +4197,8 @@ end; procedure TFormTCO.ImageDiag11EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; TCO_modifie:=true; Xclic:=X;YClic:=Y; @@ -4175,6 +4230,8 @@ end; procedure TFormTCO.ImagePalette30EndDrag(Sender, Target: TObject; X, Y: Integer); begin + if not(Target is TImage) then exit; + if (Target as TImage).Name<>'ImageTCO' then exit; if (x=0) and (y=0) then exit; efface_entoure; TCO_modifie:=true; @@ -4183,7 +4240,7 @@ begin YclicCell:=Yclic div hauteurCell +1; //PCanvasTCO.Draw((xClicCell-1)*LargeurCell,(yClicCell-1)*HauteurCell,ImageFeu.Picture.Bitmap); tco[XClicCell,YClicCell].BType:=rien; // rien - tco[XClicCell,YClicCell].BImage:=30; + tco[XClicCell,YClicCell].BImage:=30; tco[XClicCell,YClicCell].Adresse:=0; tco[XClicCell,YClicCell].FeuOriente:=1; tco[XClicCell,YClicCell].Aspect:=9; @@ -4195,9 +4252,9 @@ begin EdittypeImage.Text:=IntToSTR(tco[XClicCell,YClicCell].BImage); dessin_feu(PCanvasTCO,XclicCell,YClicCell); - entoure_cell_grille(XClicCell,YClicCell); + entoure_cell_grille(XClicCell,YClicCell); _entoure_cell_clic; - + end; @@ -4209,13 +4266,12 @@ end; procedure TFormTCO.Tourner90GClick(Sender: TObject); -var BImage,adresse : integer; +var BImage : integer; begin BImage:=TCO[XClicCell,YClicCell].Bimage; - if Bimage<>30 then exit; + if Bimage<>30 then exit; TCO_modifie:=true; - adresse:=TCO[XClicCell,YClicCell].Adresse; // effacement de l'ancien feu if tco[XClicCell,YClicCell].FeuOriente=3 then @@ -4238,8 +4294,7 @@ begin end; tco[XClicCell,YClicCell].FeuOriente:=2; // feu orienté à 90° gauche - - dessin_feu(PCanvasTCO,XclicCell,YClicCell); + Affiche_TCO; end; procedure TFormTCO.Tourner90DClick(Sender: TObject); @@ -4249,6 +4304,7 @@ begin if Bimage<>30 then exit; TCO_modifie:=true; + adresse:=TCO[XClicCell,YClicCell].Adresse; aspect:=tco[XClicCell,YClicCell].aspect; if aspect=0 then aspect:=9; @@ -4275,7 +4331,8 @@ begin end; tco[XClicCell,YClicCell].FeuOriente:=3; // feu orienté à 90° droit - dessin_feu(PCanvasTCO,XclicCell,YClicCell); + //dessin_feu(PCanvasTCO,XclicCell,YClicCell); + Affiche_TCO; end; @@ -4317,7 +4374,8 @@ begin end; tco[XClicCell,YClicCell].FeuOriente:=1; // feu orienté à 180° - dessin_feu(PCanvasTCO,XclicCell,YClicCell); + //dessin_feu(PCanvasTCO,XclicCell,YClicCell); + affiche_tco; end; @@ -4389,35 +4447,33 @@ begin ScrollBox.Height:=ClientHeight-Panel1.Height-40; end; -procedure TFormTCO.ButtonConstruitClick(Sender: TObject); -begin - construit_TCO; -end; procedure TFormTCO.ImageTCODblClick(Sender: TObject); var Bimage,Adresse,i : integer; + tjdC : boolean; Msgdlg: Tform; Result : TModalResult; begin Bimage:=Tco[xClicCell,yClicCell].BImage; Adresse:=TCO[xClicCell,yClicCell].Adresse; + if adresse=0 then exit; + + tjdC:=false; + if (Bimage=21) or (Bimage=22) then + begin + i:=Index_aig(Adresse); + tjdC:=(aiguillage[i].modele=tjd) or (aiguillage[i].modele=tjs); + end; // commande aiguillage if (Bimage=2) or (Bimage=3) or (Bimage=4) or (Bimage=5) or (Bimage=12) or - (Bimage=13) or (Bimage=14) or (Bimage=15) then + (Bimage=13) or (Bimage=14) or (Bimage=15) or TJDc then begin - Msgdlg:=createMessageDialog('Pilotage de l''aiguillage '+IntToSTR(Adresse), mtCustom,[MbYes,mbNo,MbCancel]); - with Msgdlg do - begin - caption:='Aiguillage'; - BiDiMode := bdRightToLeft; - ( FindComponent('Yes') as TButton).Caption:='droit'; - ( FindComponent('No') as TButton).Caption:='dévié'; - end; - Result:=Msgdlg.ShowModal; - if Result=MrYes then begin efface_entoure;SelectionAffichee:=false;pilote_acc(adresse,const_droit,aigP);end; // droit - if Result=MrNo then begin efface_entoure;SelectionAffichee:=false;pilote_acc(adresse,const_devie,aigP);end; // dévié + aiguille:=Adresse; + TformAig.create(nil); + formAig.showmodal; + formAig.close; sourisclic:=false; // évite de générer un cadre de sélection:=false; piloteAig:=true; end; @@ -4425,7 +4481,6 @@ begin // commande de signal if Bimage=30 then begin - if adresse=0 then exit; AdrPilote:=adresse; i:=Index_feu(adresse); if i=0 then exit; @@ -4446,20 +4501,166 @@ begin EditNbreFeux.Visible:=false; GroupBox1.Visible:=true; GroupBox2.Visible:=true; + efface_entoure;SelectionAffichee:=false; sourisclic:=false; // évite de générer un cadre de sélection end; end; end; +procedure TFormTCO.ComboReprChange(Sender: TObject); +begin + tco[XClicCell,YClicCell].Repr:=comborepr.ItemIndex; + efface_entoure;SelectionAffichee:=false; + sourisclic:=false; + //affiche_cellule(XClicCell,yClicCell); + affiche_tco; +end; + + +procedure TFormTCO.Colorer1Click(Sender: TObject); +begin + //BImage:=TCO[XClicCell,YClicCell].Bimage; +end; + +procedure TFormTCO.ImagePalette1DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette2DragOver(Sender, Source: TObject; X,Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette3DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette5DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette12DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette13DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette14DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette15DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette21DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette22DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette6DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette7DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette8DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette9DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette16DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette17DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette18DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette19DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette20DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette10DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette11DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.ImagePalette30DragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + +procedure TFormTCO.Panel1DragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); +begin + accept:=true; +end; + + begin - - - - - - - - end. diff --git a/Unit_Pilote_aig.dcu b/Unit_Pilote_aig.dcu new file mode 100644 index 0000000..98b22a3 Binary files /dev/null and b/Unit_Pilote_aig.dcu differ diff --git a/Unit_Pilote_aig.dfm b/Unit_Pilote_aig.dfm new file mode 100644 index 0000000..7731fc6 --- /dev/null +++ b/Unit_Pilote_aig.dfm @@ -0,0 +1,101 @@ +object FormAig: TFormAig + Left = 400 + Top = 204 + Width = 363 + Height = 204 + Caption = 'Pilotage de l'#39'aiguillage' + Color = clMaroon + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + OldCreateOrder = False + OnActivate = FormActivate + PixelsPerInch = 96 + TextHeight = 13 + object Label1: TLabel + Left = 80 + Top = 8 + Width = 173 + Height = 23 + Caption = 'Pilotage de l'#39'aiguillage' + Font.Charset = ANSI_CHARSET + Font.Color = clWindow + Font.Height = -19 + Font.Name = 'Arial Narrow' + Font.Style = [fsBold, fsItalic] + ParentFont = False + end + object LabelAdr1: TLabel + Left = 56 + Top = 56 + Width = 65 + Height = 16 + Caption = 'LabelAdr1' + Font.Charset = ANSI_CHARSET + Font.Color = clWindow + Font.Height = -13 + Font.Name = 'Arial' + Font.Style = [fsBold] + ParentFont = False + end + object LabelAdr2: TLabel + Left = 224 + Top = 56 + Width = 65 + Height = 16 + Caption = 'LabelAdr2' + Font.Charset = ANSI_CHARSET + Font.Color = clWindow + Font.Height = -13 + Font.Name = 'Arial' + Font.Style = [fsBold] + ParentFont = False + end + object ButtonOK: TButton + Left = 136 + Top = 128 + Width = 75 + Height = 25 + Caption = 'Ok' + ModalResult = 1 + TabOrder = 0 + end + object ButtonDev: TButton + Left = 8 + Top = 88 + Width = 75 + Height = 25 + Caption = 'D'#233'vi'#233 + TabOrder = 1 + OnClick = ButtonDevClick + end + object ButtonDroit: TButton + Left = 88 + Top = 88 + Width = 75 + Height = 25 + Caption = 'Droit' + TabOrder = 2 + OnClick = ButtonDroitClick + end + object ButtonDev2: TButton + Left = 184 + Top = 88 + Width = 75 + Height = 25 + Caption = 'D'#233'vi'#233 + TabOrder = 3 + OnClick = ButtonDev2Click + end + object ButtonDroit2: TButton + Left = 264 + Top = 88 + Width = 75 + Height = 25 + Caption = 'Droit' + TabOrder = 4 + OnClick = ButtonDroit2Click + end +end diff --git a/Unit_Pilote_aig.pas b/Unit_Pilote_aig.pas new file mode 100644 index 0000000..8bcf69d --- /dev/null +++ b/Unit_Pilote_aig.pas @@ -0,0 +1,130 @@ +unit Unit_Pilote_aig; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, UnitPrinc, UnitTCO; + +type + TFormAig = class(TForm) + ButtonOK: TButton; + Label1: TLabel; + ButtonDev: TButton; + ButtonDroit: TButton; + ButtonDev2: TButton; + ButtonDroit2: TButton; + LabelAdr1: TLabel; + LabelAdr2: TLabel; + procedure FormActivate(Sender: TObject); + procedure ButtonDevClick(Sender: TObject); + procedure ButtonDroitClick(Sender: TObject); + procedure ButtonDev2Click(Sender: TObject); + procedure ButtonDroit2Click(Sender: TObject); + private + { Déclarations privées } + public + { Déclarations publiques } + end; + +var + FormAig: TFormAig; + aiguille,aiguille2 : integer; + tjdC,aigC : boolean; +implementation + +{$R *.dfm} + +procedure commande_simple; +begin + with formAig do + begin + LabelAdr2.Visible:=false; + LabelAdr1.Visible:=false; + ButtonDev2.Visible:=false; + ButtonDroit2.Visible:=false; + ButtonOk.Visible:=false; + ButtonDev.Left:=48; + ButtonDroit.Left:=216; + end; +end; + +procedure TFormAig.FormActivate(Sender: TObject); +var i : integer; + s : string; +begin + i:=Index_aig(Aiguille); + aigC:=(aiguillage[i].modele=aig); + tjdC:=(aiguillage[i].modele=tjd) or (aiguillage[i].modele=tjs); + if aigC then + begin + s:='Pilotage de l''aiguillage '+intToSTR(aiguille); + commande_simple; + end; + if tjdC then + begin + s:='Pilotage de la TJD '+intToSTR(aiguille); + + if aiguillage[i].EtatTJD=4 then + begin + LabelAdr1.Caption:='Adresse1: '+intToSTR(aiguille); + aiguille2:=aiguillage[i].DDevie; + LabelAdr2.Caption:='Adresse2: '+intToSTR(aiguille2); + LabelAdr2.Visible:=true; + LabelAdr1.Visible:=true; + ButtonDev2.Visible:=true; + ButtonOk.Visible:=true; + ButtonDroit2.Visible:=true; + ButtonDev.Left:=8; + ButtonDroit.Left:=88; + end; + end; + if aiguillage[i].EtatTJD=2 then + begin + commande_simple; + end; + + Label1.Caption:=s; +end; + +procedure TFormAig.ButtonDevClick(Sender: TObject); +var s : string; +begin + efface_entoure;SelectionAffichee:=false; + pilote_acc(aiguille,const_devie,aigP); + s:='accessoire '+IntToSTR(aiguille)+' dévié'; + Affiche(s,clyellow); + if AigC then close; +end; + +procedure TFormAig.ButtonDroitClick(Sender: TObject); +var s : string; +begin + efface_entoure;SelectionAffichee:=false; + pilote_acc(aiguille,const_droit,aigP); + s:='accessoire '+IntToSTR(aiguille)+' droit'; + Affiche(s,clyellow); + if AigC then close; +end; + +procedure TFormAig.ButtonDev2Click(Sender: TObject); +var s : string; +begin + efface_entoure;SelectionAffichee:=false; + pilote_acc(aiguille2,const_devie,aigP); + s:='accessoire '+IntToSTR(aiguille2)+' dévié'; + Affiche(s,clyellow); + if AigC then close; +end; + +procedure TFormAig.ButtonDroit2Click(Sender: TObject); +var s : string; +begin + efface_entoure;SelectionAffichee:=false; + pilote_acc(aiguille2,const_droit,aigP); + s:='accessoire '+IntToSTR(aiguille2)+' droit'; + Affiche(s,clyellow); + if AigC then close; +end; + +end. diff --git a/verif_version.dcu b/verif_version.dcu index 3761799..851391a 100644 Binary files a/verif_version.dcu and b/verif_version.dcu differ diff --git a/verif_version.pas b/verif_version.pas index 099e741..fcee918 100644 --- a/verif_version.pas +++ b/verif_version.pas @@ -23,7 +23,7 @@ var Lance_verif : integer; verifVersion,notificationVersion : boolean; -Const Version='3.8'; // sert à la comparaison de la version publiée +Const Version='3.81'; // sert à la comparaison de la version publiée SousVersion=' '; // en cas d'absence de sous version mettre un espace implementation diff --git a/versions.txt b/versions.txt index 4ede101..ac8786e 100644 --- a/versions.txt +++ b/versions.txt @@ -87,8 +87,9 @@ version 3.71 : Suppression vitesse train Ajout d'un bouton de test des actionneurs dans la page de configuration des actionneurs. version 3.8 : Possibilité de déclencher les actions depuis une zone deux détecteurs contigus. Gestion des fonctions F de train de F0 à F28 en mode autonome. +version 3.81 : Pilotage des TJD depuis le TCO. + Améliorations diverses dans le TCO. -