V1.74
This commit is contained in:
380
UnitPrinc.pas
380
UnitPrinc.pas
@@ -61,7 +61,6 @@ type
|
||||
Image6Dir: TImage;
|
||||
Codificationdesfeux1: TMenuItem;
|
||||
Divers1: TMenuItem;
|
||||
Versions1: TMenuItem;
|
||||
ChronoDetect: TMenuItem;
|
||||
ClientSocketCDM: TClientSocket;
|
||||
FichierSimu: TMenuItem;
|
||||
@@ -78,7 +77,6 @@ type
|
||||
OuvrirunfichiertramesCDM1: TMenuItem;
|
||||
Panel1: TPanel;
|
||||
BoutonRaf: TButton;
|
||||
ButtonAffDebug: TButton;
|
||||
BoutVersion: TButton;
|
||||
loco: TButton;
|
||||
ButtonInfo: TButton;
|
||||
@@ -92,6 +90,7 @@ type
|
||||
LabelEtat: TLabel;
|
||||
ButtonAffTCO: TButton;
|
||||
ButtonLanceCDM: TButton;
|
||||
Affichefentredebug1: TMenuItem;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure MSCommUSBLenzComm(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
@@ -124,13 +123,11 @@ type
|
||||
Socket: TCustomWinSocket);
|
||||
procedure ClientSocketCDMRead(Sender: TObject;
|
||||
Socket: TCustomWinSocket);
|
||||
procedure ButtonAffDebugClick(Sender: TObject);
|
||||
procedure ConnecterCDMrailClick(Sender: TObject);
|
||||
procedure DeconnecterCDMRailClick(Sender: TObject);
|
||||
procedure ClientSocketCDMDisconnect(Sender: TObject;
|
||||
Socket: TCustomWinSocket);
|
||||
procedure Codificationdesfeux1Click(Sender: TObject);
|
||||
procedure Versions1Click(Sender: TObject);
|
||||
procedure ClientSocketLenzDisconnect(Sender: TObject;
|
||||
Socket: TCustomWinSocket);
|
||||
procedure ChronoDetectClick(Sender: TObject);
|
||||
@@ -146,6 +143,7 @@ type
|
||||
procedure OuvrirunfichiertramesCDM1Click(Sender: TObject);
|
||||
procedure ButtonAffTCOClick(Sender: TObject);
|
||||
procedure ButtonLanceCDMClick(Sender: TObject);
|
||||
procedure Affichefentredebug1Click(Sender: TObject);
|
||||
private
|
||||
{ Déclarations privées }
|
||||
procedure DoHint(Sender : Tobject);
|
||||
@@ -176,7 +174,8 @@ NbCouleurTrain=8;
|
||||
couleurTrain : array[1..NbCouleurTrain] of Tcolor = (clYellow,clLime,clOrange,clAqua,clFuchsia,clLtGray,clred,clWhite);
|
||||
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');
|
||||
|
||||
decodeur : array[0..6] of string[20] =('rien','digital Bahn','CDF','LDT','LEB','NMRA','Unisemaf');
|
||||
|
||||
type TBranche = record
|
||||
BType : integer ; // 1= détecteur 2= aiguillage 3=bis 4=Buttoir
|
||||
Adresse : integer ; // adresse du détecteur ou de l'aiguillage
|
||||
@@ -228,11 +227,10 @@ var ancien_tablo_signalCplx,EtatsignalCplx : array[0..MaxAcc] of word;
|
||||
TraceListe,clignotant,nack,Maj_feux_cours,configNulle,LanceCDM : boolean;
|
||||
|
||||
CDMhd : THandle;
|
||||
|
||||
branche : array [1..100] of string;
|
||||
|
||||
FormPrinc: TFormPrinc;
|
||||
ack,portCommOuvert,trace,AffMem,AfficheDet,CDM_connecte,parSocketCDM,
|
||||
ack,portCommOuvert,trace,AffMem,AfficheDet,CDM_connecte,SocketCDM_connecte,
|
||||
DebugOuv,Raz_Acc_signaux,AvecInit,AvecTCO,terminal,Srvc_Aig,Srvc_Det,Srvc_Act,
|
||||
Srvc_PosTrain,Srvc_Sig : boolean;
|
||||
tablo : array of byte; // tableau rx usb
|
||||
@@ -257,7 +255,7 @@ var ancien_tablo_signalCplx,EtatsignalCplx : array[0..MaxAcc] of word;
|
||||
actionneur,etat,fonction,tempo : integer;
|
||||
train : string;
|
||||
end;
|
||||
|
||||
KeyInputs: array of TInput;
|
||||
Tablo_PN : array[1..20] of
|
||||
record
|
||||
AdresseFerme : integer; // adresse de pilotage DCC pour la fermeture
|
||||
@@ -311,8 +309,6 @@ var ancien_tablo_signalCplx,EtatsignalCplx : array[0..MaxAcc] of word;
|
||||
VerrouCarre : boolean ; // si vrai, le feu se verrouille au carré si pas de train avant le signal
|
||||
EtatSignal : word ; // comme EtatSignalCplx
|
||||
UniSemaf : integer ; // définition supplémentaire de la cible pour les décodeurs UNISEMAF
|
||||
// pour TCO
|
||||
indexTCO : integer ; // index du feu dans le tableau FeuTCO
|
||||
AigDirection : array[1..6] of array of record // pour les signaux directionnels : contient la liste des aiguillages associés
|
||||
Adresse : integer; // 6 feux max associés à un tableau dynamique décrivant les aiguillages
|
||||
posAig : char;
|
||||
@@ -345,6 +341,7 @@ procedure connecte_USB;
|
||||
procedure deconnecte_usb;
|
||||
function IsWow64Process: Boolean;
|
||||
procedure Dessine_feu_mx(CanvasDest : Tcanvas;x,y : integer;FrX,frY : real;adresse : integer;orientation : integer);
|
||||
procedure pilote_acc(adresse : integer;octet : byte;Acc : TAccessoire);
|
||||
|
||||
implementation
|
||||
|
||||
@@ -425,6 +422,8 @@ begin
|
||||
end;
|
||||
|
||||
// dessine les feux sur une cible à 2 feux
|
||||
// x,y : offset en pixels du coin supérieur gauche du feu
|
||||
// frX, frY : facteurs de réduction
|
||||
procedure dessine_feu2(Acanvas : Tcanvas;x,y : integer;frX,frY : real;EtatSignal : word;orientation : integer);
|
||||
var Temp,rayon,xViolet,YViolet,xBlanc,yBlanc,
|
||||
LgImage,HtImage : integer;
|
||||
@@ -1415,7 +1414,6 @@ procedure envoie_fonction_CDM(fonction,etat : integer;train : string);
|
||||
var s : string;
|
||||
begin
|
||||
s:=chaine_CDM_Func(fonction,etat,train);
|
||||
if trace then affiche(s,clLime);
|
||||
envoi_cdm(s);
|
||||
end;
|
||||
|
||||
@@ -3207,7 +3205,7 @@ end; // de la proc
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end; // de la procédure pilote signaux
|
||||
|
||||
@@ -3231,13 +3229,14 @@ begin
|
||||
6 : envoi_UniSemaf(Adr);
|
||||
end;
|
||||
|
||||
// allume les signaux du feu dans la fenêtre de droite
|
||||
Dessine_feu_mx(Feux[i].Img.Canvas,0,0,1,1,adr,1);
|
||||
|
||||
// allume les signaux du feu dans le TCO
|
||||
if AvecTCO then
|
||||
begin
|
||||
for i:=1 to NbFeuTCO do
|
||||
// allume les signaux du feu dans la fenêtre de droite
|
||||
Dessine_feu_mx(Feux[i].Img.Canvas,0,0,1,1,adr,1);
|
||||
|
||||
// allume les signaux du feu dans le TCO
|
||||
if AvecTCO then
|
||||
begin
|
||||
for y:=1 to NbreCellY do
|
||||
for x:=1 to NbreCellX do
|
||||
begin
|
||||
if TCO[x,y].Bimage=30 then
|
||||
begin
|
||||
@@ -3247,25 +3246,26 @@ begin
|
||||
case aspect of
|
||||
2 : ImageFeu:=Formprinc.Image2feux;
|
||||
3 : ImageFeu:=Formprinc.Image3feux;
|
||||
4 : ImageFeu:=Formprinc.Image4feux;
|
||||
5 : ImageFeu:=Formprinc.Image5feux;
|
||||
4 : ImageFeu:=Formprinc.Image4feux;
|
||||
5 : ImageFeu:=Formprinc.Image5feux;
|
||||
7 : ImageFeu:=Formprinc.Image7feux;
|
||||
9 : ImageFeu:=Formprinc.Image9feux;
|
||||
else ImageFeu:=Formprinc.Image3feux;
|
||||
else ImageFeu:=Formprinc.Image3feux;
|
||||
end;
|
||||
x0:=(tco[x,y].x-1)*LargeurCell; // coordonnées XY du feu
|
||||
y0:=(tco[x,y].y-1)*HauteurCell;
|
||||
TailleY:=ImageFeu.picture.BitMap.Height; // taille du feu d'origine (verticale)
|
||||
TailleX:=ImageFeu.picture.BitMap.Width;
|
||||
Orientation:=TCO[x,y].FeuOriente;
|
||||
// réduction variable en fonction de la taille des cellules
|
||||
calcul_reduction(frx,fry,round(TailleX*LargeurCell/ZoomMax),round(tailleY*HauteurCell/ZoomMax),TailleX,TailleY);
|
||||
|
||||
// décalage en X pour mettre la tete du feu alignée sur le bord droit de la cellule pour les feux tournés à 90G
|
||||
if orientation=2 then
|
||||
begin
|
||||
// réduction variable en fonction de la taille des cellules
|
||||
calcul_reduction(frx,fry,round(TailleX*LargeurCell/ZoomMax),round(tailleY*HauteurCell/ZoomMax),TailleX,TailleY);
|
||||
|
||||
// décalage en X pour mettre la tete du feu alignée sur le bord droit de la cellule pour les feux tournés à 90G
|
||||
if orientation=2 then
|
||||
begin
|
||||
if aspect=9 then x0:=x0+round(10*frX);
|
||||
if aspect=7 then x:=x+round(10*frX);
|
||||
if aspect=7 then x0:=x0+round(10*frX);
|
||||
if aspect=5 then begin x0:=x0+round(10*frX);y0:=y0+HauteurCell-round(tailleX*frY); end;
|
||||
if aspect=4 then begin x0:=x0+round(10*frX);y0:=y0+HauteurCell-round(tailleX*frY); end;
|
||||
if aspect=3 then begin x0:=x0+round(10*frX);y0:=y0+HauteurCell-round(tailleX*frY); end;
|
||||
if aspect=2 then begin x0:=x0+round(10*frX);y0:=y0+HauteurCell-round(tailleX*frY); end;
|
||||
@@ -4156,6 +4156,7 @@ begin
|
||||
if s[1]='-' then Tablo_PN[NbrePN].CommandeFerme:=1;
|
||||
Delete(s,1,2); // supprime +,
|
||||
|
||||
val(s,j,erreur);
|
||||
Tablo_PN[NbrePN].AdresseOuvre:=j;
|
||||
Delete(s,1,erreur-1);
|
||||
if s[1]='+' then Tablo_PN[NbrePN].CommandeOuvre:=2;
|
||||
@@ -6756,6 +6757,22 @@ begin
|
||||
CDMhd:=GetWindowFromID(processID);
|
||||
Affiche('CDM rail processID='+IntToSTR(ProcessID)+' handle='+IntToSTR(CDMhd),clOrange);
|
||||
Result:=true;
|
||||
Break;
|
||||
end;
|
||||
until (Process32Next(hSnapShot,ProcessEntry32)=false);
|
||||
CloseHandle(hSnapShot);
|
||||
end;
|
||||
|
||||
|
||||
// préparation du tampon pour SendInput
|
||||
procedure KeybdInput(VKey: Byte; Flags: DWORD);
|
||||
begin
|
||||
SetLength(KeyInputs, Length(KeyInputs)+1);
|
||||
KeyInputs[high(KeyInputs)].Itype := INPUT_KEYBOARD;
|
||||
with KeyInputs[high(KeyInputs)].ki do
|
||||
begin
|
||||
wVk:=VKey;
|
||||
wScan:=MapVirtualKey(wVk, 0);
|
||||
dwFlags:=Flags;
|
||||
end;
|
||||
end;
|
||||
@@ -6771,7 +6788,7 @@ begin
|
||||
MA:=Hi(GetAsyncKeyState(VK_MENU))>127;
|
||||
MS:=Hi(GetAsyncKeyState(VK_SHIFT))>127;
|
||||
|
||||
// Simulation des touches de contrôle
|
||||
// Simulation des touches de contrôle
|
||||
if Ctrl<>MC then keybd_event(VK_CONTROL,0,Byte(MC)*KEYEVENTF_KEYUP,0);
|
||||
if Alt<>MA then keybd_event(VK_MENU,0,Byte(MA)*KEYEVENTF_KEYUP,0);
|
||||
if Shift<>MS then keybd_event(VK_SHIFT,0,Byte(MS)*KEYEVENTF_KEYUP,0);
|
||||
@@ -6814,7 +6831,7 @@ begin
|
||||
'8' : s:=s+'h';
|
||||
'9' : s:=s+'i';
|
||||
'*' : s:=s+#$6a;
|
||||
'+' : s:=s+#$6b;
|
||||
'+' : s:=s+#$6b;
|
||||
// ' ' : s:=s+#$6c;
|
||||
'-' : s:=s+#$6d;
|
||||
'.' : s:=s+#$6e;
|
||||
@@ -6823,111 +6840,138 @@ begin
|
||||
// '\' : s:=s+#$e2;
|
||||
'a'..'z' : s:=s+Upcase(lay[i]);
|
||||
' ','A'..'Z',#8..#$D : s:=s+lay[i];
|
||||
else Affiche('Erreur de conversion VK : '+lay,clred);
|
||||
else Affiche('Erreur de conversion VK : '+lay,clred);
|
||||
end;
|
||||
end;
|
||||
convert_VK:=s;
|
||||
end;
|
||||
|
||||
// Lance et connecte CDM rail. en sortie si CDM est lancé Lance_CDM=true,
|
||||
// en sortie si Lance_CDM=true, il a été lancé, sinon il était déja lancé.
|
||||
function Lance_CDM : boolean;
|
||||
var i : integer;
|
||||
s : string;
|
||||
cdm_lanceLoc : boolean;
|
||||
begin
|
||||
s:='CDR';
|
||||
if (ProcessRunning(s)) then
|
||||
begin
|
||||
// CDM déja lancé;
|
||||
Lance_CDM:=true;
|
||||
if CDM_connecte then exit;
|
||||
deconnecte_USB;
|
||||
connecte_CDM;
|
||||
exit;
|
||||
end;
|
||||
s:='CDR';
|
||||
|
||||
Affiche('Lancement de CDM '+lay,clyellow);
|
||||
|
||||
Affiche('Lancement de CDM '+lay,clyellow);
|
||||
if ShellExecute(Formprinc.Handle,
|
||||
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'),
|
||||
Pchar('-f '+lay), // paramètre
|
||||
PChar('C:\Program Files (x86)\CDM-Rail\') // répertoire
|
||||
,SW_SHOWNORMAL)>32 then
|
||||
cdm_lanceLoc:=true;
|
||||
PChar('C:\Program Files (x86)\CDM-Rail\') // répertoire
|
||||
|
||||
if not(cdm_lanceLoc) then
|
||||
begin
|
||||
// si çà marche pas essayer depuis l'autre répertoire
|
||||
if ShellExecute(Formprinc.Handle,
|
||||
'open',PChar('C:\Program Files\CDM-Rail\cdr.exe'),
|
||||
Pchar('-f '+lay), // paramètre
|
||||
PChar('C:\Program Files\CDM-Rail\') // répertoire
|
||||
,SW_SHOWNORMAL)<=32 then
|
||||
begin
|
||||
begin
|
||||
// si çà marche pas essayer depuis le répertoire de base sur un OS32
|
||||
if ShellExecute(Formprinc.Handle,
|
||||
'open',PChar('C:\Program Files\CDM-Rail\cdr.exe'),
|
||||
Pchar('-f '+lay), // paramètre
|
||||
PChar('C:\Program Files\CDM-Rail\') // répertoire
|
||||
,SW_SHOWNORMAL)<=32 then
|
||||
begin
|
||||
ShowMessage('répertoire CDM rail introuvable');
|
||||
lance_CDM:=false;exit;
|
||||
Lance_CDM:=false;exit;
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
begin
|
||||
Sleep(2000);
|
||||
Application.ProcessMessages;
|
||||
// démarre le serveur IP : Alt C , return 2 fois
|
||||
SendKey(CDMHd,ord('C'),false,true,false);
|
||||
end;
|
||||
cdm_lanceLoc:=false;
|
||||
end;
|
||||
|
||||
if cdm_lanceLoc then
|
||||
begin
|
||||
// On a lancé CDM, déconnecter l'USB
|
||||
deconnecte_USB;
|
||||
Sleep(200); // attend l'ouverture de la fenêtre
|
||||
SendKey(CDMHd,VK_RETURN,false,false,false); // sélectionne le menu démarre le serveur IP
|
||||
SendKey(CDMHd,VK_RETURN,false,false,false); // acquitte la fentêtre
|
||||
Sleep(200);
|
||||
Application.ProcessMessages;
|
||||
|
||||
if false then
|
||||
begin
|
||||
// Ouvre le fichier réseau : Alt F , Return, O, return
|
||||
SendKey(CDMHd,ord('F'),false,true,false);
|
||||
SendKey(CDMHd,VK_RETURN,false,false,false);
|
||||
Affiche('lance les fonctions automatiques de CDM',clyellow);
|
||||
Sleep(3000);
|
||||
ProcessRunning(s); // récupérer le handle de CDM
|
||||
SetForegroundWindow(CDMhd);
|
||||
Application.ProcessMessages;
|
||||
SendKey(CDMHd,VK_RETURN,false,false,false);
|
||||
Sleep(500); // attendre ouverture de la fenêtre
|
||||
Application.ProcessMessages;
|
||||
|
||||
// ouvre le fichier réseau
|
||||
|
||||
Affiche('Ouvre '+Lay,clyellow);
|
||||
s:=convert_VK(LAY);
|
||||
Sleep(1000);
|
||||
|
||||
// démarre le serveur IP ------------------------------------
|
||||
SendKey(CDMHd,ord(s[i]),false,false,false);
|
||||
KeybdInput(VK_MENU,0); // enfonce Alt
|
||||
KeybdInput(Ord('C'),0); // enfonce C
|
||||
KeybdInput(Ord('C'),KEYEVENTF_KEYUP); // relache C
|
||||
|
||||
KeybdInput(VK_MENU,KEYEVENTF_KEYUP); // relache ALT
|
||||
|
||||
KeybdInput(Ord('C'),0);
|
||||
KeybdInput(Ord('C'),KEYEVENTF_KEYUP);
|
||||
|
||||
KeybdInput(VK_RETURN,0);
|
||||
KeybdInput(VK_RETURN,KEYEVENTF_KEYUP);
|
||||
KeybdInput(VK_RETURN,0);
|
||||
KeybdInput(VK_RETURN,KEYEVENTF_KEYUP);
|
||||
|
||||
i:=SendInput(Length(KeyInputs),KeyInputs[0],SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); // la fenetre serveur démarré est affichée
|
||||
Sleep(300);
|
||||
|
||||
KeybdInput(VK_RETURN,0);
|
||||
KeybdInput(VK_RETURN,KEYEVENTF_KEYUP);
|
||||
SendInput(Length(KeyInputs),KeyInputs[0],SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); //fermer la fenetre
|
||||
Sleep(500);
|
||||
|
||||
connecte_CDM;
|
||||
Application.ProcessMessages;
|
||||
end;
|
||||
|
||||
// Serveur d'interface
|
||||
if ServeurInterfaceCDM>0 then
|
||||
begin
|
||||
// ALT I 2 fois , Return
|
||||
SendKey(CDMHd,ord('I'),false,true,false); // Avec Alt
|
||||
Sleep(400);
|
||||
Application.processMessages;
|
||||
|
||||
// Serveur d'interface --------------------------------------
|
||||
if ServeurInterfaceCDM>0 then
|
||||
begin
|
||||
KeybdInput(VK_MENU,0); // enfonce ALT
|
||||
KeybdInput(Ord('I'),0); // I
|
||||
KeybdInput(Ord('I'),KEYEVENTF_KEYUP);
|
||||
|
||||
KeybdInput(VK_MENU,KEYEVENTF_KEYUP); // relache ALT
|
||||
KeybdInput(Ord('I'),0);
|
||||
KeybdInput(Ord('I'),KEYEVENTF_KEYUP);
|
||||
|
||||
KeybdInput(VK_RETURN,0);
|
||||
KeybdInput(VK_RETURN,KEYEVENTF_KEYUP);
|
||||
KeybdInput(VK_RETURN,0);
|
||||
KeybdInput(VK_RETURN,KEYEVENTF_KEYUP);
|
||||
SendKey(CDMHd,VK_RETURN,false,false,false); // Affiche le serveur d'interfaces
|
||||
SendInput(Length(KeyInputs), KeyInputs[0], SizeOf(KeyInputs[0]));SetLength(KeyInputs,0); // affiche la fenetre d'interface
|
||||
Sleep(300);
|
||||
|
||||
// descendre le curseur n fois pour sélectionner le serveur
|
||||
// descendre le curseur n fois
|
||||
for i:=1 to ServeurInterfaceCDM-1 do
|
||||
begin
|
||||
SendKey(CDMHd,VK_DOWN,false,false,false);
|
||||
end;
|
||||
// 2x TAB pour pointer sur OK
|
||||
for i:=1 to ServeurInterfaceCDM-1 do
|
||||
begin
|
||||
KeybdInput(VK_DOWN, 0);
|
||||
KeybdInput(VK_DOWN, KEYEVENTF_KEYUP);
|
||||
end;
|
||||
// 2x TAB pour pointer sur OK
|
||||
KeybdInput(VK_TAB, 0);KeybdInput(VK_TAB, KEYEVENTF_KEYUP);
|
||||
KeybdInput(VK_TAB, 0);KeybdInput(VK_TAB, KEYEVENTF_KEYUP);
|
||||
KeybdInput(VK_SPACE, 0);KeybdInput(VK_SPACE, KEYEVENTF_KEYUP);
|
||||
SendInput(Length(KeyInputs), KeyInputs[0], SizeOf(KeyInputs[0]));SetLength(KeyInputs,0);
|
||||
Sleep(200);
|
||||
|
||||
|
||||
// Interface
|
||||
if (ServeurInterfaceCDM=1) or (ServeurInterfaceCDM=7) then
|
||||
if (ServeurInterfaceCDM=1) or (ServeurInterfaceCDM=7) then
|
||||
begin
|
||||
for i:=1 to ServeurRetroCDM-1 do
|
||||
begin
|
||||
SendKey(CDMHd,VK_DOWN,false,false,false);
|
||||
end;
|
||||
begin
|
||||
for i:=1 to ServeurRetroCDM-1 do
|
||||
begin
|
||||
KeybdInput(VK_DOWN,0);KeybdInput(VK_DOWN,KEYEVENTF_KEYUP);
|
||||
SendInput(Length(KeyInputs),KeyInputs[0],SizeOf(KeyInputs[0]));SetLength(KeyInputs,0);
|
||||
end;
|
||||
// 2x TAB pour pointer sur OK
|
||||
KeybdInput(VK_TAB,0);KeybdInput(VK_TAB, KEYEVENTF_KEYUP);
|
||||
KeybdInput(VK_TAB,0);KeybdInput(VK_TAB, KEYEVENTF_KEYUP);
|
||||
KeybdInput(VK_SPACE,0);KeybdInput(VK_SPACE, KEYEVENTF_KEYUP); // valide la fenetre d'interface
|
||||
SendKey(CDMHd,VK_TAB,false,false,false);
|
||||
SendKey(CDMHd,VK_TAB,false,false,false);
|
||||
SendKey(CDMHd,VK_TAB,false,false,false);
|
||||
SendKey(CDMHd,VK_RETURN,false,false,false);
|
||||
Sleep(100);
|
||||
end;
|
||||
end;
|
||||
SendInput(Length(KeyInputs), KeyInputs[0], SizeOf(KeyInputs[0]));SetLength(KeyInputs,0);
|
||||
|
||||
Sleep(200);
|
||||
KeybdInput(VK_RETURN,0);KeybdInput(VK_RETURN, KEYEVENTF_KEYUP); // valide la fenetre finale
|
||||
SendInput(Length(KeyInputs), KeyInputs[0], SizeOf(KeyInputs[0]));SetLength(KeyInputs,0);
|
||||
end;
|
||||
end;
|
||||
@@ -6968,8 +7012,9 @@ begin
|
||||
// créée la fenetre debug
|
||||
FormDebug:=TFormDebug.Create(Self);
|
||||
FormDebug.Caption:=AF+' debug';
|
||||
N_Trains:=0;
|
||||
NivDebug:=0;
|
||||
N_Trains:=0;
|
||||
NivDebug:=0;
|
||||
TempoAct:=0;
|
||||
DebugOuv:=True;
|
||||
|
||||
AvecInit:=true; //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
|
||||
@@ -6984,17 +7029,19 @@ begin
|
||||
pasreponse:=0;
|
||||
Nbre_recu_cdm:=0;
|
||||
AffMem:=true;
|
||||
N_routes:=0;
|
||||
N_routes:=0;
|
||||
N_trains:=0;
|
||||
Application.HintHidePause:=30000;
|
||||
|
||||
|
||||
// Train[1].index:=0;
|
||||
|
||||
// lecture fichiers de configuration client_GL.cfg et config.cfg
|
||||
lit_config;
|
||||
lit_config;
|
||||
|
||||
// lancer CDM rail si on le demande
|
||||
if LanceCDM then Lance_CDM;
|
||||
|
||||
// lancer CDM rail et le connecte si on le demande
|
||||
if LanceCDM then Lance_CDM;
|
||||
ButtonAffTCO.visible:=AvecTCO;
|
||||
Loco.Visible:=not(Diffusion);
|
||||
|
||||
// tenter la liaison vers CDM rail
|
||||
if not(CDM_connecte) then connecte_CDM;
|
||||
@@ -7130,7 +7177,7 @@ end;
|
||||
with formprinc do
|
||||
begin
|
||||
//Menu_interface(valide);
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
@@ -7156,12 +7203,12 @@ begin
|
||||
begin
|
||||
demande_etat_acc; // demande l'état des accessoires (position des aiguillages)
|
||||
end;
|
||||
LabelEtat.Caption:=' ';
|
||||
LabelEtat.Caption:=' ';
|
||||
Menu_interface(valide);
|
||||
end;
|
||||
|
||||
if temps>0 then dec(temps);
|
||||
|
||||
|
||||
// gestion du clignotant des feux de la page principale
|
||||
if tempsCli>0 then dec(tempsCli);
|
||||
if tempsCli=0 then
|
||||
@@ -7170,57 +7217,47 @@ begin
|
||||
clignotant:=not(clignotant); // inversion du clignotant
|
||||
//tester chaque feu pour voir s'il y a un code de clignotement
|
||||
for i:=1 to NbreFeux do
|
||||
begin
|
||||
adresse:=feux[i].adresse;
|
||||
a:=EtatsignalCplx[adresse]; // a = état binaire du feu
|
||||
if TestBit(a,jaune_cli) or TestBit(a,ral_60) or
|
||||
begin
|
||||
adresse:=feux[i].adresse;
|
||||
a:=EtatsignalCplx[adresse]; // a = état binaire du feu
|
||||
if TestBit(a,jaune_cli) or TestBit(a,ral_60) or
|
||||
TestBit(a,rappel_60) or testBit(a,semaphore_cli) or
|
||||
testBit(a,vert_cli) or testbit(a,blanc_cli) then
|
||||
begin
|
||||
//Affiche(IntToSTR(adresse),clOrange);
|
||||
Dessine_feu_mx(Feux[i].Img.Canvas,0,0,1,1,adresse,1);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// feux du TCO
|
||||
// feux du TCO
|
||||
if avecTCO then
|
||||
if avecTCO then
|
||||
begin
|
||||
// parcourir les feux du TCO
|
||||
for y:=1 to NbreCellY do
|
||||
for x:=1 to NbreCellX do
|
||||
begin
|
||||
PcanvasTCO.pen.mode:=pmCOpy;
|
||||
BImage:=TCO[x,y].bImage;
|
||||
if Bimage=30 then
|
||||
begin
|
||||
begin
|
||||
a:=EtatsignalCplx[adresse]; // a = état binaire du feu
|
||||
if TestBit(a,jaune_cli) or TestBit(a,ral_60) or
|
||||
TestBit(a,rappel_60) or testBit(a,semaphore_cli) or
|
||||
testBit(a,vert_cli) or testbit(a,blanc_cli) then
|
||||
begin
|
||||
aspect:=feuTCO[i].aspect;
|
||||
case aspect of
|
||||
2 : ImageFeu:=Formprinc.Image2feux;
|
||||
3 : ImageFeu:=Formprinc.Image3feux;
|
||||
4 : ImageFeu:=Formprinc.Image4feux;
|
||||
5 : ImageFeu:=Formprinc.Image5feux;
|
||||
7 : ImageFeu:=Formprinc.Image7feux;
|
||||
9 : ImageFeu:=Formprinc.Image9feux;
|
||||
else ImageFeu:=Formprinc.Image3feux;
|
||||
end;
|
||||
|
||||
x:=(FeuTCO[i].x-1)*LargeurCell; // coordonnées XY et feu
|
||||
y:=(FeuTCO[i].y-1)*HauteurCell;
|
||||
TailleY:=ImageFeu.picture.BitMap.Height; // taille du feu d'origine (verticale)
|
||||
TailleX:=ImageFeu.picture.BitMap.Width;
|
||||
Orientation:=FeuTCO[i].FeuOriente;
|
||||
// réduction variable en fonction de la taille des cellules
|
||||
calcul_reduction(frx,fry,round(TailleX*LargeurCell/ZoomMax),round(tailleY*HauteurCell/ZoomMax),TailleX,TailleY);
|
||||
|
||||
// décalage en X pour mettre la tete du feu alignée sur le bord droit de la cellule pour les feux tournés à 90G
|
||||
if orientation=2 then
|
||||
begin
|
||||
if aspect=9 then x:=x+round(10*frX);
|
||||
if aspect=7 then x:=x+round(10*frX);
|
||||
adresse:=TCO[x,y].adresse;
|
||||
a:=EtatsignalCplx[adresse]; // a = état binaire du feu
|
||||
if TestBit(a,jaune_cli) or TestBit(a,ral_60) or
|
||||
TestBit(a,rappel_60) or testBit(a,semaphore_cli) or
|
||||
testBit(a,vert_cli) or testbit(a,blanc_cli) then
|
||||
begin
|
||||
aspect:=TCO[x,y].aspect;
|
||||
case aspect of
|
||||
2 : ImageFeu:=Formprinc.Image2feux;
|
||||
3 : ImageFeu:=Formprinc.Image3feux;
|
||||
4 : ImageFeu:=Formprinc.Image4feux;
|
||||
5 : ImageFeu:=Formprinc.Image5feux;
|
||||
7 : ImageFeu:=Formprinc.Image7feux;
|
||||
9 : ImageFeu:=Formprinc.Image9feux;
|
||||
else ImageFeu:=Formprinc.Image3feux;
|
||||
end;
|
||||
|
||||
TailleY:=ImageFeu.picture.BitMap.Height; // taille du feu d'origine (verticale)
|
||||
TailleX:=ImageFeu.picture.BitMap.Width;
|
||||
Orientation:=TCO[x,y].FeuOriente;
|
||||
// réduction variable en fonction de la taille des cellules
|
||||
@@ -7442,11 +7479,11 @@ end;
|
||||
|
||||
procedure TFormPrinc.MenuConnecterUSBClick(Sender: TObject);
|
||||
begin
|
||||
Hors_tension2:=false;
|
||||
connecte_USB;
|
||||
Hors_tension2:=false;
|
||||
connecte_USB;
|
||||
end;
|
||||
procedure deconnecte_usb;
|
||||
|
||||
procedure deconnecte_usb;
|
||||
begin
|
||||
if portCommOuvert then
|
||||
begin
|
||||
@@ -7457,7 +7494,7 @@ begin
|
||||
|
||||
portCommOuvert:=false;
|
||||
with formprinc do
|
||||
begin
|
||||
begin
|
||||
ClientSocketLenz.close;
|
||||
MenuConnecterUSB.enabled:=true;
|
||||
DeConnecterUSB.enabled:=false;
|
||||
@@ -7602,7 +7639,7 @@ begin
|
||||
end;
|
||||
|
||||
procedure TFormPrinc.ClientSocketCDMConnect(Sender: TObject;Socket: TCustomWinSocket);
|
||||
var s : string;
|
||||
var s : string;
|
||||
begin
|
||||
s:='Socket CDM rail connecté';
|
||||
LabelTitre.caption:=titre+' '+s;
|
||||
@@ -7810,18 +7847,13 @@ procedure TFormPrinc.ClientSocketCDMRead(Sender: TObject;Socket: TCustomWinSocke
|
||||
Nbre_recu_cdm:=0;
|
||||
end;
|
||||
|
||||
// réception d'un message de CDM rail
|
||||
// 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;
|
||||
Interprete_trameCDM(recuCDM);
|
||||
end;
|
||||
|
||||
recuCDM:=ClientSocketCDM.Socket.ReceiveText;
|
||||
if trace then begin Affiche('recu de CDM:',clWhite);Affiche(recuCDM,clWhite);end;
|
||||
Interprete_trameCDM(recuCDM);
|
||||
@@ -7838,6 +7870,7 @@ begin
|
||||
deconnecte_CDM;
|
||||
end;
|
||||
|
||||
procedure TFormPrinc.ClientSocketCDMDisconnect(Sender: TObject; Socket: TCustomWinSocket);
|
||||
begin
|
||||
LabelTitre.caption:=Titre;
|
||||
Affiche('CDM rail déconnecté',Cyan);
|
||||
@@ -7888,10 +7921,6 @@ begin
|
||||
s:=s+IntToSTR(feux[i].AigDirection[j][k].adresse) + feux[i].AigDirection[j][k].posaig+' ';
|
||||
end;
|
||||
s:=s+')';
|
||||
end;
|
||||
end;
|
||||
Affiche(s,clYellow);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Affiche(s,clYellow);
|
||||
@@ -8112,9 +8141,9 @@ begin
|
||||
|
||||
|
||||
procedure TFormPrinc.Codificationdesactionneurs1Click(Sender: TObject);
|
||||
var i,adr,etatAct,v,aO,aF : integer;
|
||||
s,s2 : string;
|
||||
begin
|
||||
begin
|
||||
if (maxTablo_act=0) and (NbrePN=0) then
|
||||
begin
|
||||
Affiche('Aucun actionneur déclaré',clYellow);
|
||||
@@ -8190,16 +8219,15 @@ end;
|
||||
var hd : THandle;
|
||||
begin
|
||||
formTCO.windowState:=wsNormal; //Maximized;
|
||||
formTCO.BringToFront;
|
||||
formTCO.BringToFront;
|
||||
end;
|
||||
|
||||
|
||||
procedure TFormPrinc.ButtonLanceCDMClick(Sender: TObject);
|
||||
begin
|
||||
Lance_CDM ;
|
||||
end;
|
||||
|
||||
procedure TFormPrinc.Affichefentredebug1Click(Sender: TObject);
|
||||
begin
|
||||
end;
|
||||
|
||||
|
||||
begin
|
||||
|
||||
formDebug.show;
|
||||
|
||||
Reference in New Issue
Block a user