This commit is contained in:
f1iwq2
2020-12-28 11:07:33 +01:00
parent db036a7bd8
commit 344b86a9c5
17 changed files with 579 additions and 9212 deletions

View File

@@ -27,8 +27,6 @@ type
GroupBox1: TGroupBox;
EditAdresse: TEdit;
Label2: TLabel;
Editval: TEdit;
Label3: TLabel;
MainMenu1: TMainMenu;
Interface1: TMenuItem;
MenuConnecterUSB: TMenuItem;
@@ -37,7 +35,6 @@ type
MenuConnecterEthernet: TMenuItem;
MenuDeconnecterEthernet: TMenuItem;
StatusBar1: TStatusBar;
Label4: TLabel;
MSCommUSBLenz: TMSComm;
Afficher1: TMenuItem;
Etatdesdtecteurs1: TMenuItem;
@@ -62,7 +59,6 @@ type
Divers1: TMenuItem;
ClientSocketCDM: TClientSocket;
FichierSimu: TMenuItem;
ButtonEcrCV: TButton;
OpenDialog: TOpenDialog;
N1: TMenuItem;
LireunfichierdeCV1: TMenuItem;
@@ -70,7 +66,6 @@ type
N5: TMenuItem;
Quitter1: TMenuItem;
Config: TMenuItem;
ButtonLitCV: TButton;
Codificationdesactionneurs1: TMenuItem;
OuvrirunfichiertramesCDM1: TMenuItem;
Panel1: TPanel;
@@ -81,7 +76,7 @@ type
ButtonReprise: TButton;
ButtonTest: TButton;
ButtonArretSimu: TButton;
ButtonCommande: TButton;
ButtonDroit: TButton;
Panel2: TPanel;
Label1: TLabel;
LabelNbTrains: TLabel;
@@ -94,12 +89,22 @@ type
PopupMenuFenRich: TPopupMenu;
Copier1: TMenuItem;
Etatdessignaux1: TMenuItem;
N6: TMenuItem;
Apropos1: TMenuItem;
ButtonDevie: TButton;
GroupBox2: TGroupBox;
ButtonEcrCV: TButton;
ButtonLitCV: TButton;
EditCV: TEdit;
Label3: TLabel;
LabelVCV: TLabel;
EditVal: TEdit;
procedure FormCreate(Sender: TObject);
procedure MSCommUSBLenzComm(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Timer1Timer(Sender: TObject);
procedure BoutVersionClick(Sender: TObject);
procedure ButtonCommandeClick(Sender: TObject);
procedure ButtonDroitClick(Sender: TObject);
procedure EditvalEnter(Sender: TObject);
procedure BoutonRafClick(Sender: TObject);
procedure ClientSocketLenzError(Sender: TObject; Socket: TCustomWinSocket;
@@ -147,6 +152,8 @@ type
procedure FenRichChange(Sender: TObject);
procedure Copier1Click(Sender: TObject);
procedure Etatdessignaux1Click(Sender: TObject);
procedure Apropos1Click(Sender: TObject);
procedure ButtonDevieClick(Sender: TObject);
private
{ Déclarations privées }
procedure DoHint(Sender : Tobject);
@@ -166,6 +173,7 @@ const_droit=2;const_devie=1; // positions aiguillages transmises par la central
const_devieG_CDM=3; // positions aiguillages transmises par cdm
const_devieD_CDM=2; // positions aiguillages transmises par cdm
const_droit_CDM=0; // positions aiguillages transmises par cdm
const_inconnu=9; // position inconnue
ClBleuClair=$FF7070 ;
Cyan=$FF6060;
clviolet=$FF00FF;
@@ -226,14 +234,14 @@ TMA = (valide,devalide);
var
ancien_tablo_signalCplx,EtatsignalCplx : array[0..MaxAcc] of word;
AvecInitAiguillages,tempsCli,NbreFeux,pasreponse,AdrDevie,fenetre,
tempsCli,NbreFeux,pasreponse,AdrDevie,fenetre,
NombreImages,signalCpx,branche_trouve,Indexbranche_trouve,Actuel,Signal_suivant,
Nbre_recu_cdm,Tempo_chgt_feux,Adj1,Adj2,NbrePN,ServeurInterfaceCDM,
ServeurRetroCDM,TailleFonte,Nb_Det_Dist : integer;
Hors_tension2,traceSign,TraceZone,Ferme,parSocketLenz,ackCdm,PremierFD,
NackCDM,MsgSim,succes,recu_cv,AffActionneur,AffAigDet,Option_demarrage,
TraceListe,clignotant,nack,Maj_feux_cours,configNulle,LanceCDM : boolean;
TraceListe,clignotant,nack,Maj_feux_cours,configNulle,LanceCDM,AvecInitAiguillages : boolean;
CDMhd : THandle;
branche : array [1..100] of string;
@@ -360,6 +368,7 @@ function test_memoire_zones(adresse : integer) : boolean;
function PresTrainPrec(AdrFeu : integer) : boolean;
function cond_carre(adresse : integer) : boolean;
function carre_signal(adresse : integer) : boolean;
procedure Event_Detecteur(Adresse : integer;etat : boolean;train : string);
implementation
@@ -1468,70 +1477,6 @@ begin
end;
// pilotage d'un accessoire (décodeur d'aiguillage, de signal)
// octet = 0 ou 1 ou 2
// la sortie "octet" est mise à 1 puis à 0
// acc = aig ou feu
procedure pilote_acc(adresse : integer;octet : byte;Acc : TAccessoire);
var groupe,temps : integer ;
fonction : byte;
s : string;
begin
//Affiche(IntToSTR(adresse)+' '+intToSTr(octet),clYellow);
// pilotage par CDM rail
if CDM_connecte then
begin
//AfficheDebug(intToSTR(adresse),clred);
if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' '+intToSTR(octet),clorange);
s:=chaine_CDM_Acc(adresse,octet);
envoi_CDM(s);
if (acc=feu) and not(Raz_Acc_signaux) then exit;
if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' 0',clorange);
s:=chaine_CDM_Acc(adresse,0);
envoi_CDM(s);
exit;
end;
// pilotage par USB ou par éthernet de la centrale
// Affiche('Accessoire '+intToSTR(adresse),clLime);
if (hors_tension2=false) and (portCommOuvert or parSocketLenz) then
begin
// test si pilotage aiguillage inversé
if aiguillage[adresse].inversion=1 then
begin
if octet=1 then octet:=2 else octet:=1;
end;
if (octet=0) or (octet>2) then exit;
//if (octet>2) then exit;
groupe:=(adresse-1) div 4;
fonction:=((adresse-1) mod 4)*2 + (octet-1);
// pilotage à 1
s:=#$52+Char(groupe)+char(fonction or $88); // activer la sortie
s:=checksum(s);
if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' '+intToSTR(octet),clorange);
envoi(s); // envoi de la trame et attente Ack
// si l'accessoire est un feu et sans raz des signaux, sortir
if (acc=feu) and not(Raz_Acc_signaux) then exit;
// si aiguillage, faire une temporisation
//if (index_feu(adresse)=0) or (Acc=aig) then
if Acc=Aig then
begin
temps:=aiguillage[adresse].temps;if temps=0 then temps:=4;
if portCommOuvert or parSocketLenz then tempo(temps);
end;
sleep(50);
// pilotage à 0 pour éteindre le pilotage de la bobine du relais
s:=#$52+Char(groupe)+char(fonction or $80); // désactiver la sortie
s:=checksum(s);
if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' 0',clorange);
envoi(s); // envoi de la trame et attente Ack
end;
end;
// pilote accessoire en entrée 0->2 1->1
procedure pilote_acc01(adresse : integer;octet : byte);
@@ -3486,7 +3431,7 @@ var s,sa,chaine,SOrigine: string;
begin
//initialisation aiguillages
repeat
s:=lit_ligne;
s:=lit_ligne;
j:=pos(',',s);
if j>1 then
begin
@@ -3534,7 +3479,7 @@ begin
trouve_fenetre:=false;
trouve_verif_version:=false;
trouve_Fonte:=false;
Nb_Det_Dist:=3;
// initialisation des aiguillages avec des valeurs par défaut
for i:=1 to MaxAcc do
@@ -3664,7 +3609,7 @@ begin
// avec ou sans initialisation des aiguillages
sa:=uppercase(INIT_AIG_ch)+'=';
i:=pos(sa,s);
i:=pos(sa,s);
if i<>0 then
begin
trouve_init_aig:=true;
@@ -4763,9 +4708,9 @@ begin
exit;
end;
goto recommence;
end;
end;
Affiche('44 - éléments non consécutifs: Prec='+intToSTR(prec)+' Actuel='+intTostr(Actuel),clred);
Affiche('44 - éléments non consécutifs: Prec='+intToSTR(prec)+' Actuel='+intTostr(Actuel),clred);
if NivDebug=3 then AfficheDebug('44 - éléments non consécutifs: Prec='+intToSTR(prec)+' Actuel='+intTostr(Actuel),clred);
end;
@@ -4816,14 +4761,16 @@ begin
if A='Z' then TypeEl:=1 else TypeEL:=2; //TypeEL=(1=détécteur 2=aig 3=aig Bis)
trouve_element(adr,TypeEl,1); // branche_trouve IndexBranche_trouve
typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].Btype;
suivant_alg3:=adr;exit;
suivant_alg3:=adr;exit;
end;
end
else
begin
if NivDebug=3 then AfficheDebug('135 - aiguillage '+intToSTR(Adr)+' Pris en talon',clyellow);
if (alg=2) then // on demande d'arreter si l'aiguillage en talon est mal positionné
begin
if alg=2 then // on demande d'arreter si l'aiguillage en talon est mal positionné
begin
if aiguillage[adr].position=const_droit then
begin
// si TJD (modele=2) sur le précédent, alors substituer avec la 2eme adresse de la TJD
if aiguillage[prec].modele=2 then prec:=aiguillage[prec].DDroit;
if prec<>aiguillage[Adr].Adroit then
@@ -5155,7 +5102,7 @@ begin
if NivDebug=3 then AfficheDebug('Aiguillage triple dévié2 (à droite)',clYellow);
A:=aiguillage[Adr].Adevie2B;
Adr:=aiguillage[Adr].Adevie2;
if A='Z' then TypeEl:=1 else TypeEL:=2; //TypeEL=(1=détécteur 2=aig 3=aig Bis)
if A='Z' then TypeEl:=1 else TypeEL:=2; //TypeEL=(1=détécteur 2=aig 3=aig Bis)
trouve_element(Adr,TypeEl,1); // branche_trouve IndexBranche_trouve
typeGen:=BrancheN[branche_trouve,IndexBranche_trouve].BType;
suivant_alg3:=adr;exit;
@@ -5397,6 +5344,10 @@ begin
j:=1; // J=1 test en incrément J=2 test en décrément
// étape 1 : trouver le sens de progression (en incrément ou en décrément)
repeat
//préparer les variables
AdrPrec:=el1;TypePrec:=typeDet1;
if j=1 then i1:=IndexBranche_det1+1;
if j=2 then i1:=IndexBranche_det1-1;
// les suivants dansla branche sont:
@@ -5405,17 +5356,17 @@ begin
if NivDebug=3 then
begin
s:='Test en ';
if (j=1) then s:=s+'incrément ' else s:=s+'décrément ';
s:=s+'- départ depuis élément '+IntToSTR(el1)+' trouvé en index='+intToSTR(IndexBranche_det1)+' Branche='+intToSTR(branche_trouve_det1);
AfficheDebug(s,clyellow);
s:='Test en ';
if (j=1) then s:=s+'incrément ' else s:=s+'décrément ';
s:=s+'- départ depuis élément '+IntToSTR(el1)+' trouvé en index='+intToSTR(IndexBranche_det1)+' Branche='+intToSTR(branche_trouve_det1);
AfficheDebug(s,clyellow);
end;
i:=0;N_Det:=0;
i:=0;N_Det:=0;
if AdrFonc<>El2 then // si pas déja trouvé le sens de progression
begin
repeat
//AfficheDebug('Engage '+IntToSTR(AdrPrec)+','+IntToSTR(typePrec)+'/'+IntToSTR(AdrFonc)+','+IntToSTR(typeFonc),clyellow);
if nivDebug=3 then AfficheDebug('i='+IntToSTR(i)+' NDet='+IntToSTR(N_det),clyellow);
if (AdrFonc<>0) or (TypeFonc<>0) then Adr:=suivant_alg3(AdrPrec,TypePrec,AdrFonc,TypeFonc,1) else
begin
@@ -5594,7 +5545,7 @@ begin
if (AdrSuiv>500) then
begin
AdrFeu:=index_feu_det(AdrSuiv);
//Affiche(IntToSTR(AdrFeu),clOrange);
//Affiche(IntToSTR(AdrFeu),clOrange);
end;
sort:=(j=10) or (AdrFeu<>0) or (AdrSuiv=9998) or (AdrSuiv=0); // arret si aiguillage en talon ou buttoir
until (sort);
@@ -5851,7 +5802,8 @@ end;
pilote_direction(Adr,i);
end;
end;
end;
// renvoie vrai si une mémoire de zone est occupée du signal courant au signal suivant
// adresse=adresse du signal
function test_memoire_zones(adresse : integer) : boolean;
@@ -5868,6 +5820,7 @@ begin
Affiche('Erreur 650 - feu non trouvé',clred);
AfficheDebug('Erreur 650 - feu non trouvé',clred);
test_memoire_zones:=false;
end;
Pres_train:=FALSE;
ife:=1; // index feu de 1 à 4 pour explorer les 4 détecteurs d'un feu
@@ -5926,7 +5879,7 @@ begin
// et chaîner mémoire de zone
if (j=1) and (Typeactuel=1) then // si détecteur
begin
Pres_train:=MemZone[Prec,actuel];
Pres_train:=MemZone[Prec,actuel];
if Pres_Train and (NivDebug=3) then Affiche('Présence train de '+intToSTR(prec)+' à '+intToSTR(actuel),clyellow);
end
else
@@ -5936,7 +5889,7 @@ begin
prec:=actuel;TypePrec:=TypeActuel;
actuel:=AdrSuiv;TypeActuel:=typeGen;
if AdrSuiv>9990 then
begin
begin
test_memoire_zones:=false;exit;
end;
@@ -5948,7 +5901,7 @@ begin
// si c'est un buttoir
test_memoire_zones:=false;
if NivDebug=3 then AfficheDebug('sortie car buttoir',clyellow);
exit;
exit;
end;
// si le suivant est un détecteur ; contrôler mémoire de zone et comporte t-il un signal?
AdrFeu:=0;
@@ -5966,8 +5919,8 @@ begin
if (AdrFeu=adresse) then // si on ne reboucle sur le même signal dont on cherche le suivant
begin
AdrFeu:=0;j:=10; // on ne trouve pas de suivant
end;
if (AdrFeu<>0) then // si l'adresse est <>0
end;
if (AdrFeu<>0) then // si l'adresse est <>0
begin
if (feux[i].Adr_el_suiv1<>prec) then // le feu est-il dans le bon sens de progression?
begin
@@ -5987,11 +5940,11 @@ begin
begin
//if (traceDet) {sprintf(Affiche,"Trouvé détecteur %d mais sans signal\r\n",AdrSuiv,Etat);Display(Affiche);
AdrFeu:=0;
end;
end;
end
else
begin
if (NivDebug=3) then AfficheDebug('Trouvé aiguillage '+intToSTR(AdrSuiv),clyellow);
if (NivDebug=3) then AfficheDebug('Trouvé aiguillage '+intToSTR(AdrSuiv),clyellow);
end;
sort:=(j=10) or (AdrFeu<>0) or (N_Det>=Nb_det_dist);
until (sort); // on arrete jusqu'à trouver un signal ou si on va trop loin (10 itérations)
@@ -6127,18 +6080,22 @@ begin
begin
det_initial:=feux[i].Adr_det4;Adr_El_Suiv:=feux[i].Adr_el_suiv4;
if feux[i].Btype_suiv4=1 then Btype_el_suivant:=1;
if feux[i].Btype_suiv4=2 then Btype_el_suivant:=2;
if feux[i].Btype_suiv4=4 then Btype_el_suivant:=2;
if feux[i].Btype_suiv4=4 then Btype_el_suivant:=2;
end;
end;
if (det_initial<>0) then
begin
DetPrec1:=detecteur_suivant(Adr_El_Suiv,Btype_el_suivant,det_initial,1,2); // 2= algo2 = arret sur aiguillage en talon mal positionné
if nivdebug=3 then afficheDebug('detPrec1='+intToSTR(DetPrec1),clorange);
DetPrec1:=detecteur_suivant(Adr_El_Suiv,Btype_el_suivant,det_initial,1,2); // 2= algo2 = arret sur aiguillage en talon mal positionné
if DetPrec1<1024 then // route bloquée par aiguillage mal positionné
begin
if detPrec1<>0 then DetPrec2:=detecteur_suivant_El(det_initial,1,DetPrec1,1) else DetPrec2:=0;
if nivdebug=3 then afficheDebug('detPrec2='+intToSTR(DetPrec2),clorange);
DetPrec2:=detecteur_suivant_El(det_initial,1,DetPrec1,1);
if DetPrec2<1024 then
begin
if detPrec2<>0 then DetPrec3:=detecteur_suivant_El(DetPrec1,1,DetPrec2,1) else DetPrec3:=0;
if nivdebug=3 then afficheDebug('detPrec3='+intToSTR(DetPrec3),clorange);
DetPrec3:=detecteur_suivant_El(DetPrec1,1,DetPrec2,1);
if DetPrec3<1024 then
begin
if detPrec3<>0 then DetPrec4:=detecteur_suivant_El(DetPrec2,1,DetPrec3,1) else DetPrec4:=0;
if nivdebug=3 then afficheDebug('detPrec4='+intToSTR(DetPrec4),clorange);
@@ -6175,7 +6132,7 @@ var i,j,k1,k2,BtypeSuiv,Adr_det,etat,Adr,Aig,Adr_El_Suiv,
// mise à jour de l'état d'un feu en fontion de son environnement et affiche le feu
procedure Maj_Feu(Adrfeu : integer);
var i,j,k1,k2,BtypeSuiv,Adr_det,etat,Adr,Aig,Adr_El_Suiv,
Btype_el_suivant,det_initial,bt,el_suiv,modele : integer ;
Btype_el_suivant,det_initial,bt,el_suiv,modele : integer ;
PresTrain,Aff_semaphore,car : boolean;
code,combine : word;
s : string;
@@ -6227,6 +6184,7 @@ begin
Maj_Etat_Signal(AdrFeu,blanc) else Maj_Etat_Signal(AdrFeu,violet);
envoi_LEB(AdrFeu);
exit;
end;
}
// signal à 2 feux = carré violet+blanc
@@ -6236,7 +6194,9 @@ begin
// si aiguillage après signal mal positionnées
if carre_signal(AdrFeu) then
begin
Maj_Etat_Signal(AdrFeu,violet);
Maj_Etat_Signal(AdrFeu,violet);
Envoi_signauxCplx;
exit;
end
else
begin
@@ -6385,6 +6345,16 @@ begin
//affiche(inttostr(ai+1),clOrange);
//affiche('------------------------',clWhite);
recherche;
//affiche('------------------------',clGreen);
if trouve then index2_det:=i else index2_det:=0;
//affiche('index2='+IntToSTR(index2_det),clWhite);
end;
// trouve si le détecteur adr est contigu à un buttoir
function buttoir_adjacent(adr : integer) : boolean;
begin
trouve_element(adr,1,1); // branche_trouve IndexBranche_trouve
if Branche_trouve=0 then begin buttoir_adjacent:=false;exit;end;
buttoir_adjacent:=( (BrancheN[branche_trouve,IndexBranche_trouve+1].Adresse=0) and (BrancheN[branche_trouve,IndexBranche_trouve+1].BType=4) or
(BrancheN[branche_trouve,IndexBranche_trouve-1].Adresse=0) and (BrancheN[branche_trouve,IndexBranche_trouve-1].BType=4) )
@@ -6494,13 +6464,15 @@ begin
AfficheDebug('Nouveau Tampon train '+intToStr(i)+'--------',clyellow);
AfficheDebug(intToSTR(event_det_train[i].det[1]),clyellow );
AfficheDebug(intToSTR(event_det_train[i].det[2]),clyellow );
end;
end;
exit; // sortir absolument
end;
end;
end;
// Nombre d'éléments à 0 : ici c'est un nouveau train donc créer un train, donc un tableau
if N_Trains>=Max_Trains then
begin
Affiche('Erreur nombre de train maximal atteint',clRed);
end;
Inc(N_trains);
@@ -6515,7 +6487,7 @@ begin
if (AdrDetFeu=Det3) and (feux[i].aspect<10) then
begin
AdrSuiv:=Feux[i].Adr_el_suiv1;TypeSuiv:=Feux[i].Btype_suiv1;
AdrPrec:=detecteur_suivant(AdrSuiv,typeSuiv,AdrDetFeu,1,1) ; // détecteur précédent le feu ; algo 1
AdrPrec:=detecteur_suivant(AdrSuiv,typeSuiv,AdrDetFeu,1,1) ; // détecteur précédent le feu ; algo 1
if AdrPrec=0 then
begin
if TraceListe then Affiche('FD - Le feu '+IntToSTR(AdrFeu)+' est précédé d''un buttoir',clyellow);
@@ -6523,18 +6495,36 @@ begin
//NivDebug:=3;
//AffSignal:=true;
maj_feu(AdrFeu);
end;
end;
end;
end;
end;
end;
if TraceListe then AfficheDebug('Création Train n°'+intToSTR(i),clyellow);
Formprinc.LabelNbTrains.caption:=IntToSTR(N_trains);
event_det_train[N_trains].det[1]:=det3;
event_det_train[N_trains].NbEl:=1;
if TraceListe then AfficheDebug('Création Train n°'+intToSTR(i),clyellow);
Formprinc.LabelNbTrains.caption:=IntToSTR(N_trains);
// si on démarre d'un buttoir
if buttoir_adjacent(det3) then
begin
if TraceListe then AfficheDebug('detection démarrage depuis détecteur '+IntToSTR(det3)+' buttoir',clyellow);
event_det_train[N_trains].det[1]:=0;
event_det_train[N_trains].det[2]:=det3;
event_det_train[N_trains].NbEl:=2;
with FormDebug.MemoEvtDet do
begin
lines.add('Nouveau Tampon train '+intToStr(N_Trains)+'--------');
begin
lines.add('Nouveau Tampon train '+intToStr(N_trains)+'--------');
lines.add(intToSTR(event_det_train[N_trains].det[1]));
lines.add(intToSTR(event_det_train[N_Trains].det[1]));
lines.add(intToSTR(event_det_train[N_Trains].det[2]));
end;
end
else
begin
event_det_train[N_trains].det[1]:=det3;
event_det_train[N_trains].NbEl:=1;
with FormDebug.MemoEvtDet do
begin
lines.add('Nouveau Tampon train '+intToStr(N_trains)+'--------');
lines.add(intToSTR(event_det_train[N_trains].det[1]));
end;
if TraceListe then
begin
AfficheDebug('Nouveau Tampon train '+intToStr(N_trains)+'--------',clyellow);
@@ -6759,7 +6749,7 @@ begin
inc(N_event_det);
event_det[N_event_det]:=Adresse;
// vérification de la connaissance de la position de tous les aiguillages au premier évènement FD détecteur
if not(PremierFD) then
if not(PremierFD) then
begin
for i:=1 to MaxAiguillage do
begin
@@ -6789,18 +6779,18 @@ begin
// Mettre à jour le TCO
if AvecTCO then
begin
begin
formTCO.Maj_TCO(Adresse);
end;
end;
// évènement d'aiguillage
// évènement d'aiguillage
procedure Event_Aig(adresse,pos : integer);
var s: string;
faire_event: boolean;
begin
// ------------------- traitement du numéro d'objet -------------------------
// init objet
{ init objet
if aiguillage[adresse].objet=0 then
begin
aiguillage[adresse].objet:=objet;
@@ -6816,7 +6806,7 @@ begin
if (N_Event_tick>=Max_Event_det_tick) then
begin
N_Event_tick:=0;
Affiche('Raz Evts détecteurs',clLime);
Affiche('Raz Evts détecteurs',clLime);
end;
s:='Tick='+IntToSTR(tick)+' Evt Aig '+intToSTR(adresse)+'='+intToSTR(pos);
if pos=const_droit then s:=s+' droit' else s:=s+' dévié';
@@ -6826,7 +6816,7 @@ begin
Affiche(s,clyellow);
AfficheDebug(s,clyellow);
end;
FormDebug.MemoEvtDet.lines.add(s) ;
FormDebug.MemoEvtDet.lines.add(s) ;
if (n_Event_tick mod 10) =0 then affiche_memoire;
inc(N_Event_tick);
event_det_tick[N_event_tick].tick:=tick;
@@ -6838,6 +6828,75 @@ begin
if AvecTCO then
begin
formTCO.Maj_TCO(Adresse);
end;
// l'évaluation des routes est à faire selon conditions
if faire_event then evalue;
end;
// pilotage d'un accessoire (décodeur d'aiguillage, de signal)
// octet = 0 ou 1 ou 2
// la sortie "octet" est mise à 1 puis à 0
// acc = aig ou feu
procedure pilote_acc(adresse : integer;octet : byte;Acc : TAccessoire);
var groupe,temps : integer ;
fonction : byte;
s : string;
begin
//Affiche(IntToSTR(adresse)+' '+intToSTr(octet),clYellow);
// pilotage par CDM rail
if CDM_connecte then
begin
//AfficheDebug(intToSTR(adresse),clred);
if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' '+intToSTR(octet),clorange);
s:=chaine_CDM_Acc(adresse,octet);
envoi_CDM(s);
if (acc=feu) and not(Raz_Acc_signaux) then exit;
if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' 0',clorange);
s:=chaine_CDM_Acc(adresse,0);
envoi_CDM(s);
exit;
end;
// pilotage par USB ou par éthernet de la centrale
// Affiche('Accessoire '+intToSTR(adresse),clLime);
if (hors_tension2=false) and (portCommOuvert or parSocketLenz) then
begin
// test si pilotage aiguillage inversé
if aiguillage[adresse].inversion=1 then
begin
if octet=1 then octet:=2 else octet:=1;
end;
if (octet=0) or (octet>2) then exit;
//if (octet>2) then exit;
groupe:=(adresse-1) div 4;
fonction:=((adresse-1) mod 4)*2 + (octet-1);
// pilotage à 1
s:=#$52+Char(groupe)+char(fonction or $88); // activer la sortie
s:=checksum(s);
if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' '+intToSTR(octet),clorange);
envoi(s); // envoi de la trame et attente Ack
// si l'accessoire est un feu et sans raz des signaux, sortir
if (acc=feu) and not(Raz_Acc_signaux) then exit;
// si aiguillage, faire une temporisation
//if (index_feu(adresse)=0) or (Acc=aig) then
if Acc=Aig then
begin
temps:=aiguillage[adresse].temps;if temps=0 then temps:=4;
if portCommOuvert or parSocketLenz then tempo(temps);
end;
sleep(50);
// pilotage à 0 pour éteindre le pilotage de la bobine du relais
s:=#$52+Char(groupe)+char(fonction or $80); // désactiver la sortie
s:=checksum(s);
if debug_dec_sig and (acc=feu) then AfficheDebug('Tick='+IntToSTR(Tick)+' signal '+intToSTR(adresse)+' 0',clorange);
envoi(s); // envoi de la trame et attente Ack
exit;
end;
// pas de centrale et pas CDM connecté: on change la position de l'aiguillage
@@ -6888,22 +6947,22 @@ begin
end;
end;
// état de l'aiguillage
// état de l'aiguillage
if bitsITT=$00 then // module d'aiguillages, N=1
begin
adraig:=((adresse * 4)+1 ); // *4 car N=1, c'est le "poids fort"
if (valeur and $C)=$8 then
begin
begin
Event_Aig(adraig+3,const_droit);
if traceTrames then begin s:='accessoire '+intToSTR(adraig+3)+'=2';AfficheDebug(s,clYellow);end;
end;
if (valeur and $C)=$4 then
begin
begin
Event_Aig(adraig+3,const_devie);
if traceTrames then begin s:='accessoire '+intToSTR(adraig+3)+'=1';AfficheDebug(s,clYellow);end;
end;
if (valeur and $3)=$2 then
begin
begin
Event_Aig(adraig+2,const_droit);
if traceTrames then begin s:='accessoire '+intToSTR(adraig+2)+'=2';AfficheDebug(s,clYellow);end;
end;
@@ -6944,22 +7003,22 @@ begin
Event_detecteur(i,(valeur and $1) = $1,'');
end;
end;
end;
if bitsITT=$00 then // module d'aiguillages
begin
adraig:=(adresse * 4)+1;
if (valeur and $C)=$8 then
begin
begin
Event_Aig(adraig+1,const_droit);
if traceTrames then begin s:='accessoire '+intToSTR(adraig+1)+'=2';AfficheDebug(s,clYellow);end;
end;
if (valeur and $C)=$4 then
begin
begin
Event_Aig(adraig+1,const_devie);
if traceTrames then begin s:='accessoire '+intToSTR(adraig+1)+'=1';AfficheDebug(s,clYellow);end;
end;
if (valeur and $3)=$2 then
begin
begin
Event_Aig(adraig,const_droit);
if traceTrames then begin s:='accessoire '+intToSTR(adraig)+'=2';AfficheDebug(s,clYellow);end;
end;
@@ -7621,7 +7680,7 @@ begin
ButtonLitCV.Enabled:=false;
LireunfichierdeCV1.enabled:=false;
end ;
// Initialisation des images des signaux
NbreImagePLigne:=Formprinc.ScrollBox1.Width div (largImg+5);
@@ -7653,15 +7712,21 @@ begin
// TCO
if avectco then
begin
begin
//créée la fenêtre TCO non modale
FormTCO:=TformTCO.Create(nil);
FormTCO.show;
end;
//essai &&&&&&&&&&
Affiche('Fin des initialisations',clyellow);
LabelEtat.Caption:=' ';
Affiche('Fin des initialisations',clyellow);
LabelEtat.Caption:=' ';
Affiche_memoire;
//---------------------------------
{
aiguillage[6].position:=const_devie;
aiguillage[4].position:=const_droit;
aiguillage[3].position:=const_droit;
aiguillage[1].position:=const_devie;
aiguillage[26].position:=const_droit;
aiguillage[28].position:=const_devie;
@@ -7740,13 +7805,13 @@ begin
var index,aspect,i,a,x,y,x0,y0,Bimage,adresse,TailleX,TailleY,orientation : integer;
imageFeu : Timage;
frx,fry : real;
s : string;
s : string;
begin
inc(tick);
if Tempo_init>0 then dec(Tempo_init);
if (Tempo_init=1) and AvecInit then
begin
if not(ConfigNulle) and not(ferme) and (AvecInitAiguillages=1) then
if not(ConfigNulle) and not(ferme) and (AvecInitAiguillages) then
begin
Affiche('Positionnement des feux',clYellow);
envoi_signauxCplx; // initialisation des feux
@@ -7827,9 +7892,9 @@ begin
begin
a:=EtatsignalCplx[0];
if TestBit(a,jaune_cli) or TestBit(a,ral_60) or
TestBit(a,rappel_60) or testBit(a,semaphore_cli) or
TestBit(a,rappel_60) or testBit(a,semaphore_cli) or
testBit(a,vert_cli) or testbit(a,blanc_cli) then
Dessine_feu_pilote; // dessiner le feu en fonction du bit "clignotant"
Dessine_feu_pilote; // dessiner le feu en fonction du bit "clignotant"
end;
end;
@@ -7850,13 +7915,7 @@ begin
end;
end;
//simulation
if (index_simule<>0) then
begin
if not(MsgSim) then
begin
Affiche('Simulation en cours ',Cyan);MsgSim:=true;
N_Event_tick:=0;
//simulation
if (index_simule<>0) then
begin
if not(MsgSim) then
@@ -7876,7 +7935,7 @@ begin
s:='Simulation '+intToSTR(I_simule)+' Tick='+IntToSTR(tick)+' det='+intToSTR(Tablo_simule[i_simule].detecteur)+'='+IntToSTR(Tablo_simule[i_simule].etat);
Event_Detecteur(Tablo_simule[i_simule].detecteur, Tablo_simule[i_simule].etat=1,''); // créer évt détecteur
StaticText.caption:=s;
end;
end;
// evt aiguillage ?
if Tablo_simule[i_simule].aiguillage<>0 then
@@ -7892,7 +7951,7 @@ begin
begin
Index_Simule:=0; // fin de simulation
I_Simule:=0;
MsgSim:=false;
MsgSim:=false;
Affiche('Fin de simulation',Cyan);
StaticText.caption:='';
end;
@@ -7925,8 +7984,9 @@ begin
procedure TFormPrinc.BoutVersionClick(Sender: TObject);
var s : string;
begin
s:=#$f0;
s:=checksum(s);
s:=#$f0;
s:=checksum(s);
envoi(s);
end;
// bouton de commande d'un accessoire
@@ -7935,14 +7995,26 @@ begin
s : string;
begin
val(EditAdresse.text,adr,erreur);
if (erreur<>0) or (adr<1) or (adr>2048) then
begin
EditAdresse.text:='1';
exit;
end;
if (erreur<>0) or (adr<1) or (adr>2048) then
begin
EditAdresse.text:='1';
exit;
end;
if (erreur<>0) or (valeur<0) or (valeur>255) then
pilote_acc(adr,const_droit,aig);
s:='accessoire '+IntToSTR(adr)+' droit';
Affiche(s,clyellow);
end;
procedure TFormPrinc.ButtonDevieClick(Sender: TObject);
var adr,erreur : integer;
s : string;
begin
val(EditAdresse.text,adr,erreur);
if (erreur<>0) or (adr<1) or (adr>2048) then
begin
EditAdresse.text:='1';
exit;
end;
@@ -8120,7 +8192,7 @@ begin
begin
for i:=1 to MaxAcc do
begin
model:=aiguillage[i].modele ;
model:=aiguillage[i].modele ;
if model<>0 then
begin
s:='Aiguillage '+IntToSTR(i)+' : '+intToSTR(aiguillage[i].position);
@@ -8303,7 +8375,7 @@ begin
//Affiche('Aig '+inttostr(adr)+' pos='+IntToSTR(etat),clyellow);
//Affiche(commandeCDM,clyellow);
// aiguillage normal
if aiguillage[adr].modele=1 then
begin
@@ -8323,8 +8395,8 @@ begin
0 : begin etatAig:=2;EtatAig2:=2;end;
end;
if (aiguillage[adr].inversionCDM=1) or (aiguillage[adr2].inversionCDM=1) then
begin
//Affiche('inverse',clyellow);
begin
//Affiche('inverse',clyellow);
prv:=adr;
adr:=adr2;
adr2:=prv;
@@ -8336,8 +8408,8 @@ begin
begin
//Affiche('Triple',clyellow);
// état de l'aiguillage 1
if (etat=0) or (etat=2) then etatAig:=2;
if etat=3 then etatAig:=1;
if (etat=0) or (etat=2) then etatAig:=2;
if etat=3 then etatAig:=1;
// état de l'aiguillage 2
adr2:=aiguillage[adr].AdrTriple;
if (etat=0) or (etat=3) then etatAig2:=2;
@@ -8598,17 +8670,17 @@ var adr,valeur,erreur : integer;
begin
FormSimulation.showModal;
end;
procedure TFormPrinc.ButtonEcrCVClick(Sender: TObject);
var adr,valeur,erreur : integer;
s : string;
s : string;
begin
// doc XpressNet page 55
val(EditCV.text,adr,erreur);
if (erreur<>0) or (Adr>255) or (Adr<0) then
begin
EditCV.Text:='1';
exit;
exit;
end;
val(EditVal.Text,valeur,erreur);
@@ -8695,10 +8767,10 @@ begin
fte : textfile;
i,cv,valeur,erreur : integer;
begin
s:=GetCurrentDir;
s:=GetCurrentDir;
//s:='C:\Program Files (x86)\Borland\Delphi7\Projects\Signaux_complexes_GL';
N_Cv:=0; // nombre de CV recus à 0
sa:='';
sa:='';
Affiche('Lecture CV',clyellow);
val(EditCV.Text,cv,erreur);
@@ -8904,8 +8976,19 @@ begin
Etat:=Feux[i].EtatSignal;
s:='Feu '+IntToSTR(Adr)+' Etat=';
code_to_aspect(Etat,aspect,combine);
s:=s+IntToSTR(etat)+'='+EtatSign[aspect]+' '+EtatSign[combine];
Affiche(s,clYellow);
end;
end;
procedure TFormPrinc.Apropos1Click(Sender: TObject);
begin
Affiche(' ',clyellow);
Affiche('Signaux complexes GL version '+version+' (C) 2020 F1IWQ Gily TDR',clWhite);
Affiche('http://cdmrail.free.fr/ForumCDR/viewtopic.php?f=77&t=3906',clWhite);
Affiche('https://github.com/f1iwq2/Signaux_complexes_GL',clWhite);
Affiche(' ',clyellow);
end;