V1.441
This commit is contained in:
Binary file not shown.
BIN
UnitConfig.dcu
BIN
UnitConfig.dcu
Binary file not shown.
BIN
UnitDebug.dcu
BIN
UnitDebug.dcu
Binary file not shown.
@@ -114,6 +114,7 @@ object FormDebug: TFormDebug
|
||||
'MemoDebug')
|
||||
ScrollBars = ssVertical
|
||||
TabOrder = 3
|
||||
WordWrap = False
|
||||
end
|
||||
object CheckAffSig: TCheckBox
|
||||
Left = 448
|
||||
|
||||
@@ -72,6 +72,7 @@ var
|
||||
detecteur : integer ;
|
||||
Aiguillage : integer ;
|
||||
actionneur : integer;
|
||||
objet : integer; // numéro d'objet dans CDM
|
||||
etat : integer ; // état du détecteur de l'aiguillage ou de l'actionneur
|
||||
//train : integer ;
|
||||
//suivant : integer ; // d'ou vient le train
|
||||
@@ -102,14 +103,14 @@ begin
|
||||
//NivDebug:=0;
|
||||
end;
|
||||
|
||||
procedure RE_ColorLine(ARichEdit: TRichEdit; ARow: Integer; AColor: TColor);
|
||||
procedure RE_ColorLine(ARichEdit : TRichEdit;ARow : Integer;AColor : TColor);
|
||||
begin
|
||||
with ARichEdit do
|
||||
begin
|
||||
SelStart := SendMessage(Handle, EM_LINEINDEX, ARow - 1, 0);
|
||||
SelLength := Length(Lines[ARow - 1]);
|
||||
SelAttributes.Color := AColor;
|
||||
SelLength := 0;
|
||||
SelStart:=SendMessage(Handle,EM_LINEINDEX,ARow-1,0);
|
||||
SelLength:=Length(Lines[ARow-1]);
|
||||
SelAttributes.Color:=AColor;
|
||||
SelLength:=0;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -122,6 +123,7 @@ begin
|
||||
s:=s+'comportement du programme. Positionner le niveau de 1 à 3 pour';
|
||||
s:=s+' afficher des informations plus ou moins détaillées.';
|
||||
Label3.caption:=s;
|
||||
MemoDebug.WordWrap:=false; // interdit la coupure des chaînes en limite du composant
|
||||
MemoDebug.color:=$33;
|
||||
initform:=false;
|
||||
MemoDebug.clear;
|
||||
@@ -129,7 +131,6 @@ begin
|
||||
if IsWow64Process then s:=s+' OS 64 Bits' else s:=s+' OS 32 Bits';
|
||||
RichEdit.color:=$111122;
|
||||
MemoDebug.Lines.add(s);
|
||||
|
||||
end;
|
||||
|
||||
procedure TFormDebug.ButtonEcrLogClick(Sender: TObject);
|
||||
|
||||
BIN
UnitPrinc.dcu
BIN
UnitPrinc.dcu
Binary file not shown.
@@ -1539,6 +1539,10 @@ object FormPrinc: TFormPrinc
|
||||
'nctionnement'
|
||||
OnClick = FichierSimuClick
|
||||
end
|
||||
object OuvrirunfichiertramesCDM1: TMenuItem
|
||||
Caption = 'Ouvrir un fichier trames CDM'
|
||||
OnClick = OuvrirunfichiertramesCDM1Click
|
||||
end
|
||||
object Versions1: TMenuItem
|
||||
Caption = 'Versions'
|
||||
Hint = 'Versions'
|
||||
|
||||
312
UnitPrinc.pas
312
UnitPrinc.pas
@@ -1,7 +1,7 @@
|
||||
Unit UnitPrinc;
|
||||
(********************************************
|
||||
programme direct signaux complexes
|
||||
delphi 7 + activeX Tmscomm + clientSocket
|
||||
programme signaux complexes Graphique Lenz
|
||||
delphi 7 + activeX Tmscomm + clientSocket
|
||||
********************************************
|
||||
note sur le pilotage des accessoires:
|
||||
raquette octet sortie
|
||||
@@ -88,6 +88,7 @@ type
|
||||
ButtonLitCV: TButton;
|
||||
Codificationdesactionneurs1: TMenuItem;
|
||||
ButtonArretSimu: TButton;
|
||||
OuvrirunfichiertramesCDM1: TMenuItem;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure MSCommUSBLenzComm(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
@@ -140,6 +141,7 @@ type
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure Codificationdesactionneurs1Click(Sender: TObject);
|
||||
procedure ButtonArretSimuClick(Sender: TObject);
|
||||
procedure OuvrirunfichiertramesCDM1Click(Sender: TObject);
|
||||
|
||||
private
|
||||
{ Déclarations privées }
|
||||
@@ -156,13 +158,10 @@ titre='Signaux complexes GL ';
|
||||
tempoFeu = 100;
|
||||
MaxAcc = 2048;
|
||||
LargImg=50;HtImg=91;
|
||||
const_droit=2;const_devieD=1; // positions transmises par la centrale LENZ
|
||||
const_devieG_CDM=3; // positions transmises par cdm
|
||||
const_devieD_CDM=2; // positions transmises par cdm
|
||||
const_droit_CDM=0; // positions transmises par cdm
|
||||
|
||||
MaxElParcours=4000;
|
||||
|
||||
const_droit=2;const_devieD=1; // positions aiguillages transmises par la centrale LENZ
|
||||
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
|
||||
|
||||
EtatSign : array[0..13] of string[20] =('carré','sémaphore','sémaphore cli','vert','vert cli','violet',
|
||||
'blanc','blanc cli','jaune','jaune cli','ral 30','ral 60','rappel 30','rappel 60');
|
||||
@@ -173,6 +172,7 @@ type TBranche = record
|
||||
end;
|
||||
|
||||
Taiguillage = record
|
||||
objet : integer; // objet dans CDM rail
|
||||
modele : integer; // 0=n'existe pas 1=aiguillage 2=TJD 3=TJS 4=aiguillage triple
|
||||
position, // position actuelle : 1=dévié 2=droit
|
||||
Adrtriple, // 2eme adresse pour un aiguillage triple
|
||||
@@ -224,13 +224,14 @@ const
|
||||
clOrange=$0077FF;
|
||||
Feu_X=50;Feu_Y=91;
|
||||
Max_Simule=10000;
|
||||
couleurTrain : array[1..8] of Tcolor = (clYellow,clLime,clOrange,clAqua,clFuchsia,clLtGray,clred,clWhite);
|
||||
NbCouleurTrain=8;
|
||||
couleurTrain : array[1..NbCouleurTrain] of Tcolor = (clYellow,clLime,clOrange,clAqua,clFuchsia,clLtGray,clred,clWhite);
|
||||
|
||||
var
|
||||
FormPrinc: TFormPrinc;
|
||||
ack,portCommOuvert,trace,AffMem,AfficheDet,CDM_connecte,parSocketCDM,
|
||||
DebugOuv,Raz_Acc_signaux,AvecInit,AvecTCO,terminal : boolean;
|
||||
tablo : array of byte;
|
||||
tablo : array of byte; // tableau rx usb
|
||||
Enregistrement,chaine_Envoi,chaine_recue,Id_CDM,Af,
|
||||
entete,suffixe,ConfStCom : string;
|
||||
maxaiguillage,detecteur_chgt,Temps,TpsRecuCom,Tempo_init,Suivant,TypeGen,
|
||||
@@ -985,8 +986,6 @@ end;
|
||||
// ici on envoie pas à CDM
|
||||
procedure envoi_ss_ack(s : string);
|
||||
var i,timeout,valto : integer;
|
||||
com : Tobject;
|
||||
sa : string;
|
||||
begin
|
||||
// com:=formprinc.MSCommUSBLenz;
|
||||
s:=entete+s+suffixe;
|
||||
@@ -1564,7 +1563,7 @@ envoie les donn
|
||||
|
||||
/*===========================================================================*)
|
||||
procedure envoi_NMRA(adresse: integer);
|
||||
var valeur,index,code,codebin,aspect : integer ;
|
||||
var valeur,code,codebin,aspect : integer ;
|
||||
s : string;
|
||||
begin
|
||||
//index:=Index_feu(adresse); // tranforme l'adresse du feu en index tableau
|
||||
@@ -1627,11 +1626,10 @@ end;
|
||||
|
||||
// décodeur unisemaf (paco)
|
||||
procedure envoi_UniSemaf(adresse: integer);
|
||||
var modele,index,code,codebin,aspect : integer ;
|
||||
var modele,index,code,codebin : integer ;
|
||||
s : string;
|
||||
begin
|
||||
index:=Index_feu(adresse); // tranforme l'adresse du feu en index tableau
|
||||
//code:=feux[index].aspect; // aspect du feu;
|
||||
|
||||
if (ancien_tablo_signalCplx[adresse]<>EtatSignalCplx[adresse]) then
|
||||
begin
|
||||
@@ -3054,6 +3052,7 @@ begin
|
||||
begin
|
||||
debugConfig:=false;
|
||||
// initialisation des aiguillages avec des valeurs par défaut
|
||||
for i:=1 to MaxAcc do
|
||||
begin
|
||||
Aiguillage[i].modele:=0 ;// sans existence
|
||||
Aiguillage[i].position:=2; //droit
|
||||
@@ -3309,7 +3308,6 @@ begin
|
||||
if (S2) then delete(enregistrement,erreur,2);
|
||||
|
||||
erreur:=pos('S2',enregistrement); // description d'un rattachement à la branche S2 d'un aiguillage triple
|
||||
tec:=erreur<>0; // ne supprimer que le 2
|
||||
tec:=erreur<>0; // ne supprimer que le 2
|
||||
if (tec) then delete(enregistrement,erreur+1,1);
|
||||
|
||||
@@ -4423,7 +4421,7 @@ end;
|
||||
if not(trouve) then inc(i);
|
||||
until (trouve) or (i>=100);
|
||||
if trouve then Index_feu_det:=i else Index_feu_det:=0;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
// renvoie l'adresse du détecteur suivant des deux éléments contigus
|
||||
@@ -5318,8 +5316,9 @@ begin
|
||||
Train_courant:=N_trains;
|
||||
Formprinc.LabelNbTrains.caption:=IntToSTR(N_trains);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
With FormDebug.RichEdit do
|
||||
begin
|
||||
s:='train '+IntToSTR(Train_Courant)+' '+intToStr(det1)+' à '+intToStr(det2)+' => Mem '+IntToSTR(det2)+' à '+IntTOStr(AdrSuiv);
|
||||
Lines.Add(s);
|
||||
@@ -5698,22 +5697,25 @@ procedure demande_info_acc(adresse : integer);
|
||||
end;
|
||||
end;
|
||||
|
||||
// demande l'état d'un accessoire à la centrale. Le résultat sera réceptionné sur réception des informations
|
||||
// de rétrosignalisation.
|
||||
procedure demande_info_acc(adresse : integer);
|
||||
var s : string;
|
||||
n : integer;
|
||||
begin
|
||||
// envoyer 2 fois la commande, une fois avec N=0 pour récupérer le nibble bas,
|
||||
// demande l'état d'un accessoire à la centrale. Le résultat sera réceptionné sur réception des informations
|
||||
// de rétrosignalisation.
|
||||
procedure demande_info_acc(adresse : integer);
|
||||
var s : string;
|
||||
n : integer;
|
||||
begin
|
||||
if portCommOuvert or ParSocket then
|
||||
begin
|
||||
// envoyer 2 fois la commande, une fois avec N=0 pour récupérer le nibble bas,
|
||||
// une autre fois avec N=1 pour récupérer le nibble haut
|
||||
s:=#$42+char((adresse-1) div 4);
|
||||
n:=$80+((adresse-1) mod 4) div 2;
|
||||
s:=s+char(n); // N=0 (bit 0)
|
||||
s:=checksum(s);
|
||||
envoi(s);
|
||||
s:=#$42+char((adresse-1) div 4);
|
||||
n:=$80+((adresse-1) mod 4) div 2;
|
||||
s:=s+char(n); // N=0 (bit 0)
|
||||
s:=checksum(s);
|
||||
envoi(s);
|
||||
|
||||
s:=#$42+char((adresse-1) div 4);
|
||||
n:=$80+((adresse-1) mod 4) div 2;
|
||||
n:=$80+((adresse-1) mod 4) div 2;
|
||||
s:=s+char(n or 1); // N=1 (bit 0)
|
||||
s:=checksum(s);
|
||||
envoi(s);
|
||||
end;
|
||||
@@ -5809,14 +5811,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
if (aF=adr) and (etat=1) then // actionneur de fermeture
|
||||
if (aF=adr) and (etat=1) then // actionneur de fermeture
|
||||
begin
|
||||
Affiche('Fermeture PN'+IntToSTR(i)+' (train voie '+IntToSTR(v)+')',clOrange);
|
||||
pilote_acc(Tablo_PN[i].AdresseFerme,Tablo_PN[i].CommandeFerme,Aig);
|
||||
Tablo_PN[i].voie[v].PresTrain:=true;
|
||||
Affiche('Fermeture PN'+IntToSTR(i)+' (train voie '+IntToSTR(v)+')',clOrange);
|
||||
end;
|
||||
pilote_acc(Tablo_PN[i].AdresseFerme,Tablo_PN[i].CommandeFerme,Aig);
|
||||
end;
|
||||
end;
|
||||
@@ -5923,15 +5921,43 @@ begin
|
||||
afficheDebug(s,clyellow);
|
||||
end;
|
||||
event_det_tick[N_event_tick].train:=N_trains;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
}
|
||||
end;
|
||||
|
||||
// évènement d'aiguillage
|
||||
procedure Event_Aig(adresse,pos,objet : integer);
|
||||
var s: string;
|
||||
begin
|
||||
// ------------------- traitement du numéro d'objet -------------------------
|
||||
aiguillage[adresse].position:=pos;
|
||||
// il faut mémoriser le numéro d'objet le plus bas au détriment de celui qui a la même adresse
|
||||
// mais un numéro d'objet supérieur (bug CDM sur bretelles avec aiguillages à la même adresse)
|
||||
// init objet
|
||||
if aiguillage[adresse].objet=0 then
|
||||
begin
|
||||
aiguillage[adresse].objet:=objet;
|
||||
//affiche('stockage Aiguillage '+intToSTR(adresse)+' objet='+intToSTR(objet),clYellow);
|
||||
end;
|
||||
// si l'objet reçu < stocké, on met a jour
|
||||
if objet<aiguillage[adresse].objet then
|
||||
begin
|
||||
aiguillage[adresse].objet:=objet;
|
||||
//affiche('stockage Aiguillage '+intToSTR(adresse)+' objet='+intToSTR(objet),clYellow);
|
||||
end;
|
||||
if objet>aiguillage[adresse].objet then
|
||||
begin
|
||||
s:='Evt aiguillage rejeté: Adr='+intToSTR(adresse)+'='+intToSTR(pos);
|
||||
if pos=const_droit then s:=s+' droit' else s:=s+' dévié';
|
||||
s:=s+' Objet='+intToSTr(objet);
|
||||
Affiche(s,clOrange);
|
||||
AfficheDebug(s,clOrange);
|
||||
exit;
|
||||
end;
|
||||
begin
|
||||
|
||||
// ------------- stockage évènement aiguillage dans tampon event_det_tick -------------------------
|
||||
if (N_Event_tick<Max_Event_det_tick) then
|
||||
begin
|
||||
if AffAigDet then
|
||||
begin
|
||||
@@ -5939,6 +5965,7 @@ begin
|
||||
if pos=const_droit then s:=s+' droit' else s:=s+' dévié';
|
||||
if objet<>0 then s:=s+' objet='+IntToSTR(objet);
|
||||
Affiche(s,clyellow);
|
||||
AfficheDebug(s,clyellow);
|
||||
end;
|
||||
inc(N_Event_tick);
|
||||
event_det_tick[N_event_tick].tick:=tick;
|
||||
@@ -6027,7 +6054,6 @@ begin
|
||||
event_det_tick[index].suivant:=Adj1;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
end;
|
||||
}
|
||||
@@ -6077,22 +6103,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,2,0);
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig+3)+'=2';Affiche(s,clYellow);end;
|
||||
end;
|
||||
if (valeur and $C)=$4 then
|
||||
begin
|
||||
begin
|
||||
Event_Aig(adraig+3,1,0);
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig+3)+'=1';Affiche(s,clYellow);end;
|
||||
end;
|
||||
if (valeur and $3)=$2 then
|
||||
begin
|
||||
begin
|
||||
Event_Aig(adraig+2,2,0);
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig+2)+'=2';Affiche(s,clYellow);end;
|
||||
end;
|
||||
@@ -6133,88 +6159,28 @@ 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,2,0);
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig+1)+'=2';Affiche(s,clYellow);end;
|
||||
end;
|
||||
if (valeur and $C)=$4 then
|
||||
begin
|
||||
begin
|
||||
Event_Aig(adraig+1,1,0);
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig+1)+'=1';Affiche(s,clYellow);end;
|
||||
end;
|
||||
if (valeur and $3)=$2 then
|
||||
begin
|
||||
begin
|
||||
Event_Aig(adraig,2,0);
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig)+'=2';Affiche(s,clYellow);end;
|
||||
end;
|
||||
end;
|
||||
if (valeur and $3)=$1 then
|
||||
begin
|
||||
Event_Aig(adraig,1,0);
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function Xdecode_chaine_retro(s : string) : string;
|
||||
var i : integer;
|
||||
chaineInt : string;
|
||||
begin
|
||||
chaineInt:=s;
|
||||
|
||||
// réponse de l'information des accessoires
|
||||
if s[1]=#$42 then
|
||||
begin
|
||||
delete(chaineInt,1,1);
|
||||
//Xdecode_retro(ord(chaineInt[1]),ord(chaineInt[2]));
|
||||
delete(chaineInt,1,3);
|
||||
end
|
||||
else
|
||||
begin
|
||||
if s[1]=#$81 then
|
||||
begin
|
||||
delete(chaineInt,1,2);
|
||||
Affiche('Voie hors tension msg1',clRed);
|
||||
Hors_tension2:=true;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if s[1]=#$61 then
|
||||
begin
|
||||
delete(chaineInt,1,2);
|
||||
Affiche('Voie hors tension msg2',clRed);
|
||||
Hors_tension2:=false;
|
||||
end
|
||||
else
|
||||
begin
|
||||
i:=pos(#$46+#$43+#$40,chaineInt);
|
||||
if (i<>0) and (length(chaineInt)>=3) then
|
||||
begin
|
||||
delete(chaineInt,1,3);
|
||||
Affiche('Reprise msg 1',clOrange);
|
||||
Hors_tension2:=false;
|
||||
end
|
||||
else
|
||||
begin
|
||||
i:=pos(#$46+#$43+#$50,chaineInt);
|
||||
if (i<>0) and (length(chaineInt)>=3) then
|
||||
begin
|
||||
delete(chaineInt,1,3);
|
||||
Affiche('Reprise msg 2',clOrange);
|
||||
Hors_tension2:=false;
|
||||
end
|
||||
else
|
||||
begin
|
||||
affiche('Erreur 2, chaîne rétrosig. inconnue recue:',clRed);
|
||||
affiche(chaine_HEX(chaineInt),clred);
|
||||
chaineInt:='';
|
||||
end;
|
||||
if trace then begin s:='accessoire '+intToSTR(adraig)+'=1';Affiche(s,clYellow);end;
|
||||
end;
|
||||
end;
|
||||
@@ -6400,8 +6366,8 @@ begin
|
||||
procedure deconnecte_CDM;
|
||||
begin
|
||||
with Formprinc do
|
||||
begin
|
||||
begin
|
||||
ClientSocketCDM.close;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -6484,7 +6450,7 @@ var
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TFormPrinc.FormCreate(Sender: TObject);
|
||||
var
|
||||
i,j : integer;
|
||||
@@ -6508,12 +6474,9 @@ begin
|
||||
|
||||
// créée la fenetre debug
|
||||
FormDebug:=TFormDebug.Create(Self);
|
||||
FormDebug.Caption:=AF+' debug';
|
||||
N_Trains:=0;
|
||||
FormDebug.Caption:=AF+' debug';
|
||||
N_Trains:=0;
|
||||
NivDebug:=0;
|
||||
|
||||
TempoAct:=0;
|
||||
DebugOuv:=True;
|
||||
|
||||
@@ -6646,6 +6609,8 @@ begin
|
||||
//signal_direction(372);
|
||||
//FormDebug.show;
|
||||
//test_memoire_zones(218);
|
||||
//Det_Adj(520);
|
||||
//Affiche(' Adj1='+intToStr(Adj1)+' Adj2='+intToStr(Adj2),clyellow);
|
||||
//trace:=true;
|
||||
//TraceListe:=true;
|
||||
//interprete_reponse(#$FF+#$FD+#$46+#$43+#$40+#$41+#$40+#$40+#$49+#$4D);
|
||||
@@ -6820,7 +6785,7 @@ begin
|
||||
// end;
|
||||
|
||||
Affiche('Simulation '+intToSTR(I_simule)+' Tick='+IntToSTR(tick)+' det='+intToSTR(Tablo_simule[i_simule].detecteur)+'='+IntToSTR(Tablo_simule[i_simule].etat),Cyan);
|
||||
Event_Detecteur(Tablo_simule[i_simule].detecteur, Tablo_simule[i_simule].etat=1); // créer évt détecteur
|
||||
Event_Detecteur(Tablo_simule[i_simule].detecteur, Tablo_simule[i_simule].etat=1); // créer évt détecteur
|
||||
end;
|
||||
// evt aiguillage ?
|
||||
if Tablo_simule[i_simule].aiguillage<>0 then
|
||||
@@ -6926,6 +6891,7 @@ begin
|
||||
10053 : s:=s+': Connexion avortée - Timeout';
|
||||
10054 : s:=s+': Connexion avortée par tiers';
|
||||
10060 : s:=s+': Timeout';
|
||||
10061 : s:=s+': Connexion refusée';
|
||||
10065 : s:=s+': Port non connecté';
|
||||
end;
|
||||
affiche(s,ClRed);
|
||||
@@ -7043,7 +7009,7 @@ begin
|
||||
s:='Dét '+intToSTR(Adresse_detecteur[j])+'=';
|
||||
if Detecteur[adresse_detecteur[j]] then s:=s+'1' else s:=s+'0';
|
||||
//s:=s+' Mem=';
|
||||
//if Mem[adresse_detecteur[j]] then s:=s+'1' else s:=s+'0';
|
||||
//if Mem[adresse_detecteur[j]] then s:=s+'1' else s:=s+'0';
|
||||
Affiche(s,clYellow);
|
||||
end;
|
||||
end;
|
||||
@@ -7054,7 +7020,9 @@ begin
|
||||
begin
|
||||
Affiche('les positions des aiguillages BIS sont les mêmes que leurs homologues non bis',Cyan);
|
||||
for i:=1 to MaxAcc do
|
||||
begin
|
||||
begin
|
||||
model:=aiguillage[i].modele ;
|
||||
if model<>0 then
|
||||
begin
|
||||
s:='Aiguillage '+IntToSTR(i)+' : '+intToSTR(aiguillage[i].position);
|
||||
if aiguillage[i].position=1 then s:=s+' (dévié)' else s:=s+' (droit)';
|
||||
@@ -7134,15 +7102,11 @@ begin
|
||||
Affiche(s,clYellow);
|
||||
AfficheDebug(s,clYellow);
|
||||
parSocketCDM:=True;
|
||||
MenuConnecterUSB.enabled:=false;
|
||||
DeConnecterUSB.enabled:=false;
|
||||
ConnecterCDMRail.enabled:=false;
|
||||
MenuConnecterUSB.enabled:=false;
|
||||
DeConnecterUSB.enabled:=false;
|
||||
ConnecterCDMRail.enabled:=false;
|
||||
|
||||
end;
|
||||
// réception d'un message de CDM rail
|
||||
procedure TFormPrinc.ClientSocketCDMRead(Sender: TObject;Socket: TCustomWinSocket);
|
||||
var i,j,k,l,erreur, adr,adr2,etat,etataig,etatAig2,name : integer ;
|
||||
|
||||
procedure Interprete_trameCDM(recuCDM : string);
|
||||
var i,objet,posST,posAC,posDT,k,l,erreur, adr,adr2,etat,etataig,etatAig2,name : integer ;
|
||||
@@ -7151,30 +7115,36 @@ begin
|
||||
begin
|
||||
AckCDM:=recuCDM<>'';
|
||||
if pos('ACK',recuCDM)=0 then
|
||||
begin
|
||||
begin
|
||||
end;
|
||||
k:=0;
|
||||
if pos('ERR=200',recuCDM)<>0 then Affiche('Erreur CDM : réseau non chargé',clred);
|
||||
end;
|
||||
k:=0;
|
||||
repeat
|
||||
//Affiche(recuCDM,clwhite);
|
||||
// évènement aiguillage. Le champ AD2 n'est pas forcément présent
|
||||
//Affiche('K='+intToSTR(k)+' longueur='+intToSTR(length(recuCDM)),clyellow);
|
||||
// évènement aiguillage. Le champ AD2 n'est pas forcément présent
|
||||
posST:=pos('CMDACC-ST_TO',recuCDM);
|
||||
if posST<>0 then
|
||||
begin
|
||||
//Affiche(recuCDM,cllime);
|
||||
objet:=0;
|
||||
i:=posEx('OBJ=',recuCDM,posST);ss:=copy(recuCDM,i+4,10);
|
||||
if i<>0 then val(ss,objet,erreur) else
|
||||
Affiche('Erreur pas d''objet ',clred);
|
||||
|
||||
|
||||
i:=posEx('AD=',recuCDM,posST);ss:=copy(recuCDM,i+3,10); //Affiche('j='+IntToSTR(j)+' i='+intToSTR(i),clred);
|
||||
if i<posST then begin Affiche('Erreur 96',clred);exit;end;
|
||||
if i<j then begin Affiche('Erreur 96',clred);exit;end;
|
||||
val(ss,adr,erreur);
|
||||
val(ss,adr,erreur);
|
||||
|
||||
//Affiche(copy(recuCDM,j,i+80),clOrange);
|
||||
//i:=posEx('AD2=',recuCDM,i);ss:=copy(recuCDM,i+3,10); Affiche('j='+IntToSTR(j)+' i='+intToSTR(i),clred);
|
||||
//val(ss,adr2,erreur);
|
||||
//i:=posEx('AD2=',recuCDM,i);ss:=copy(recuCDM,i+3,10); Affiche('j='+IntToSTR(j)+' i='+intToSTR(i),clred);
|
||||
//val(ss,adr2,erreur);
|
||||
i:=posEx('STATE=',recuCDM,i);ss:=copy(recuCDM,i+6,10); //Affiche('j='+IntToSTR(j)+' i='+intToSTR(i),clred);
|
||||
if i<posST then begin Affiche('Erreur 97',clred);exit;end;
|
||||
if i+5-posST>0 then begin Delete(recuCDM,posST,i+5-posST) ;end else
|
||||
begin
|
||||
s:='Erreur 95 posST='+IntToSTR(posST)+' i='+intToSTR(i);
|
||||
Affiche('j='+IntToSTR(j)+' i='+intToSTR(i),clred);
|
||||
Affiche(s,clred);
|
||||
Nbre_recu_cdm:=0;
|
||||
Affiche(recuCDM,clred);
|
||||
exit;
|
||||
@@ -7184,7 +7154,7 @@ begin
|
||||
// conversion en position :
|
||||
// CDM: 0=droit 1=droite 3=gauche
|
||||
// logiciel : 1=dévié 2=droit
|
||||
|
||||
|
||||
// aiguillage normal
|
||||
if aiguillage[adr].modele=1 then
|
||||
begin
|
||||
@@ -7197,8 +7167,8 @@ begin
|
||||
begin
|
||||
//Affiche('TJDS',clyellow);
|
||||
adr2:=aiguillage[adr].Apointe; // 2eme adresse de la TJD
|
||||
case etat of
|
||||
1 : begin etatAig:=1;EtatAig2:=2;end;
|
||||
case etat of
|
||||
1 : begin etatAig:=1;EtatAig2:=2;end;
|
||||
4 : begin etatAig:=1;EtatAig2:=1;end;
|
||||
5 : begin etatAig:=2;EtatAig2:=1;end;
|
||||
0 : begin etatAig:=2;EtatAig2:=2;end;
|
||||
@@ -7210,8 +7180,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;
|
||||
@@ -7221,13 +7191,13 @@ begin
|
||||
end;
|
||||
|
||||
Tempo_chgt_feux:=10; // demander la mise à jour des feux
|
||||
|
||||
//Affiche(recuCDM,CLOrange);
|
||||
|
||||
//Affiche(recuCDM,CLOrange);
|
||||
//if length(recuCDM)>80 then Affiche(copy(recuCDM,80,length(recuCDM)-80),clOrange);
|
||||
end;
|
||||
end;
|
||||
|
||||
// évènement détecteur
|
||||
j:=pos('CMDACC-ST_DT',recuCDM);
|
||||
// évènement détecteur
|
||||
posDT:=pos('CMDACC-ST_DT',recuCDM);
|
||||
if posDT<>0 then
|
||||
begin
|
||||
i:=posEx('AD=',recuCDM,posDT);ss:=copy(recuCDM,i+3,10);
|
||||
@@ -7237,18 +7207,18 @@ begin
|
||||
val(ss,etat,erreur);
|
||||
Event_detecteur(Adr,etat=1);
|
||||
//Affiche(IntToSTR(adr)+' '+IntToSTR(etat),clyellow);
|
||||
if AfficheDet then Affiche('Rétro Détecteur '+intToSTR(adr)+'='+IntToStr(etat),clYellow);
|
||||
end ;
|
||||
if AfficheDet then Affiche('Rétro Détecteur '+intToSTR(adr)+'='+IntToStr(etat),clYellow);
|
||||
end ;
|
||||
|
||||
// évènement actionneur
|
||||
// évènement actionneur
|
||||
// attention un actionneur qui repasse à 0 ne contient pas de nom de train
|
||||
//S-E-03-0157-CMDACC-ST_AC|049|05|NAME=0;OBJ=7101;AD=815;TRAIN=CC406526;STATE=1;
|
||||
//S-E-03-0157-CMDACC-ST_AC|049|05|NAME=0;OBJ=7101;AD=815;TRAIN=CC406526;STATE=1;
|
||||
posAC:=pos('CMDACC-ST_AC',recuCDM);
|
||||
if j<>0 then
|
||||
if posAC<>0 then
|
||||
begin
|
||||
i:=posEx('AD=',recuCDM,j);ss:=copy(recuCDM,i+3,10);
|
||||
i:=posEx('AD=',recuCDM,posAC);ss:=copy(recuCDM,i+3,10);
|
||||
val(ss,adr,erreur);
|
||||
i:=posEx('NAME=',recuCDM,j);ss:=copy(recuCDM,i+5,10);
|
||||
i:=posEx('NAME=',recuCDM,posAC);ss:=copy(recuCDM,i+5,10);
|
||||
val(ss,name,erreur);
|
||||
i:=posEx('TRAIN=',recuCDM,posAC);l:=PosEx(';',recuCDM,i);
|
||||
train:=copy(recuCDM,i+6,l-i-6);
|
||||
@@ -7258,7 +7228,7 @@ begin
|
||||
i:=pos(';',recuCDM);
|
||||
if i<>0 then Delete(recuCDM,1,i);
|
||||
if AfficheDet then
|
||||
Affiche('Actionneur AD='+intToSTR(adr)+' Nom='+intToSTR(name)+' Train='+train+' Etat='+IntToSTR(etat),clyellow);
|
||||
Affiche('Actionneur AD='+intToSTR(adr)+' Nom='+intToSTR(name)+' Train='+train+' Etat='+IntToSTR(etat),clyellow);
|
||||
Event_act(adr,etat,train); // déclenche évent actionneur
|
||||
end;
|
||||
|
||||
@@ -7266,6 +7236,18 @@ begin
|
||||
//traite:=(k<30) or (pos('CMDACC-ST_TO',recuCDM)<>0) or (pos('CMDACC-ST_DT',recuCDM)<>0) ;
|
||||
sort:=(k>70) or (posST=0) and (posDT=0) and (posAC=0);
|
||||
until (sort);
|
||||
|
||||
//Affiche('Ligne traitée'+recuCDM,clLime);
|
||||
if k>=70 then begin Affiche('Erreur 90 : Longrestante='+IntToSTR(length(recuCDM)),clred); Affiche(recuCDM,clred); end;
|
||||
Nbre_recu_cdm:=0;
|
||||
end;
|
||||
|
||||
// réception d'un message de CDM rail
|
||||
procedure TFormPrinc.ClientSocketCDMRead(Sender: TObject;Socket: TCustomWinSocket);
|
||||
var i,j,k,l,erreur, adr,adr2,etat,etataig,etatAig2,name : integer ;
|
||||
s,ss,train : string;
|
||||
traite,sort : boolean;
|
||||
begin
|
||||
inc(Nbre_recu_cdm);
|
||||
recuCDM:=ClientSocketCDM.Socket.ReceiveText;
|
||||
if trace then begin Affiche('recu de CDM:',clWhite);Affiche(recuCDM,clWhite);end;
|
||||
@@ -7623,8 +7605,6 @@ begin
|
||||
for v:=1 to Tablo_PN[i].nbvoies do
|
||||
begin
|
||||
s:=' Voie '+IntToSTR(v)+': Actionneur de fermeture='+intToSTR(Tablo_PN[i].voie[v].ActFerme);
|
||||
s:=s+' Actionneur d''ouverture='+intToSTR(Tablo_PN[i].voie[v].ActOuvre);
|
||||
Affiche(s,clyellow);
|
||||
s:=s+' Actionneur d''ouverture='+intToSTR(Tablo_PN[i].voie[v].ActOuvre);
|
||||
Affiche(s,clyellow);
|
||||
end;
|
||||
@@ -7633,8 +7613,34 @@ begin
|
||||
|
||||
procedure TFormPrinc.ButtonArretSimuClick(Sender: TObject);
|
||||
begin
|
||||
Index_Simule:=0; // fin de simulation
|
||||
I_Simule:=0;
|
||||
MsgSim:=false;
|
||||
Affiche('Fin de simulation',Cyan);
|
||||
end;
|
||||
|
||||
procedure TFormPrinc.OuvrirunfichiertramesCDM1Click(Sender: TObject);
|
||||
var s : string;
|
||||
fte : textFile;
|
||||
begin
|
||||
s:=GetCurrentDir;
|
||||
s:='C:\Program Files (x86)\Borland\Delphi7\Projects\Signaux_complexes_GL';
|
||||
OpenDialog.InitialDir:=s;
|
||||
OpenDialog.DefaultExt:='txt';
|
||||
OpenDialog.Filter:='Fichiers texte (*.txt)|*.txt|Tous fichiers (*.*)|*.*';
|
||||
if openDialog.Execute then
|
||||
begin
|
||||
s:=openDialog.FileName;
|
||||
assignFile(fte,s);
|
||||
reset(fte);
|
||||
while not(eof(fte)) do
|
||||
begin
|
||||
readln(fte,s);
|
||||
Affiche(s,clLime);
|
||||
Interprete_trameCDM(s);
|
||||
end;
|
||||
closeFile(fte);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
Affiche('Fin de simulation',Cyan);
|
||||
end;
|
||||
|
||||
BIN
UnitSimule.dcu
BIN
UnitSimule.dcu
Binary file not shown.
@@ -14,3 +14,5 @@ Version 1.31 : Correction des positions aiguillages triples et TJD
|
||||
Version 1.4 : Gestion des Fonctions Fx vers les locomotives par actionneurs
|
||||
Version 1.41 : Gestion des passages à niveaux par actionneurs
|
||||
Version 1.42 : Correction erreur lecture signaux
|
||||
Version 1.43 : Correction erreur gestion sémaphore
|
||||
Version 1.44 : Gestion trains avec voitures éclairées
|
||||
|
||||
Reference in New Issue
Block a user