V2.21
This commit is contained in:
153
UnitPrinc.pas
153
UnitPrinc.pas
@@ -163,7 +163,7 @@ 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
|
||||
ClBleuClair=$FF7070 ;
|
||||
Cyan=$FFA0A0;
|
||||
Cyan=$FF6060;
|
||||
clviolet=$FF00FF;
|
||||
GrisF=$414141;
|
||||
clOrange=$0077FF;
|
||||
@@ -225,7 +225,7 @@ var ancien_tablo_signalCplx,EtatsignalCplx : array[0..MaxAcc] of word;
|
||||
AvecInitAiguillages,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 : integer;
|
||||
ServeurRetroCDM,TailleFonte,Nb_Det_Dist : integer;
|
||||
|
||||
Hors_tension2,traceSign,TraceZone,Ferme,parSocket,ackCdm,PremierFD,
|
||||
NackCDM,MsgSim,succes,recu_cv,AffActionneur,AffAigDet,Option_demarrage,
|
||||
@@ -404,23 +404,6 @@ begin
|
||||
combine:=BitNum(CodeBin and $fc00);
|
||||
end;
|
||||
|
||||
procedure Xcode_to_aspect(codebin : word;var premierbit,combine : word) ;
|
||||
var i,mot : word;
|
||||
begin
|
||||
mot:=codebin;
|
||||
i:=0;premierbit:=0;Combine:=0;
|
||||
|
||||
while (i<15) do
|
||||
begin
|
||||
if (mot and 1)=1 then // si bit 0 du mot est à 1
|
||||
begin
|
||||
if (premierbit=0) then premierbit:=i+1 else Combine:=i+1;
|
||||
end;
|
||||
mot:=mot shr 1; //décaler à droite
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
// dessine un cercle plein dans le feu
|
||||
procedure cercle(ACanvas : Tcanvas;x,y,rayon : integer;couleur : Tcolor);
|
||||
begin
|
||||
@@ -433,7 +416,7 @@ begin
|
||||
//Affiche(IntToSTR(y),clyellow);
|
||||
end;
|
||||
|
||||
// dessine les feux sur une cible à 2 feux
|
||||
// dessine les feux sur une cible à 2 feux dans le canvas spécifié
|
||||
// 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);
|
||||
@@ -442,7 +425,7 @@ var Temp,rayon,xViolet,YViolet,xBlanc,yBlanc,
|
||||
ech : real;
|
||||
code,combine : word;
|
||||
begin
|
||||
code_to_aspect(Etatsignal,code,combine); // et aspect
|
||||
code_to_aspect(Etatsignal,code,combine);
|
||||
rayon:=round(6*frX);
|
||||
|
||||
// récupérer les dimensions de l'image d'origine du feu
|
||||
@@ -3476,7 +3459,7 @@ end;
|
||||
branche_trouve:=NBranche;
|
||||
IndexBranche_trouve:=i;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
procedure lit_config;
|
||||
@@ -3524,6 +3507,8 @@ var s,sa,chaine,SOrigine: string;
|
||||
aiguillage[adresse].inversion:=invers;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
until (adresse=0);
|
||||
end;
|
||||
|
||||
begin
|
||||
@@ -3751,12 +3736,28 @@ begin
|
||||
if i<>0 then
|
||||
begin
|
||||
inc(nv);
|
||||
delete(s,i,length(sa));
|
||||
i:=0;
|
||||
val(s,i,erreur);
|
||||
ServeurRetroCDM:=i;
|
||||
end;
|
||||
|
||||
sa:='NB_DET_DIST=';
|
||||
i:=pos(sa,s);
|
||||
if i<>0 then
|
||||
begin
|
||||
inc(nv);
|
||||
trouve_NbDetDist:=true;
|
||||
delete(s,i,length(sa));
|
||||
i:=0;
|
||||
val(s,i,erreur);
|
||||
ServeurRetroCDM:=i;
|
||||
end;
|
||||
|
||||
val(s,i,erreur);
|
||||
if i<2 then i:=2;
|
||||
Nb_Det_Dist:=i;
|
||||
end;
|
||||
inc(it);
|
||||
|
||||
until (Nv>=18) or (it>30);
|
||||
//affiche(IntToSTR(Nv)+' variables',cyan);
|
||||
if (it>30) then
|
||||
begin
|
||||
s:='ERREUR: manque variables dans config-gl.cfg';
|
||||
@@ -5242,7 +5243,7 @@ begin
|
||||
((aiguillage[actuel].modele=2) or (aiguillage[Actuel].modele=3)) then
|
||||
begin
|
||||
if nivDebug=3 then AfficheDebug('501 - Détection Précédent=TJD/S Suivant=TJD/S',clyellow);
|
||||
// subsituer la pointe
|
||||
// subsituer la pointe
|
||||
actuel:=aiguillage[Actuel].APointe;
|
||||
end;
|
||||
end;
|
||||
@@ -5345,7 +5346,7 @@ begin
|
||||
AfficheDebug(s,clOrange);
|
||||
end;
|
||||
detecteur_suivant_El:=9999;exit;
|
||||
end;
|
||||
end;
|
||||
IndexBranche_det2:=IndexBranche_trouve;
|
||||
branche_trouve_det2:=branche_trouve;
|
||||
j:=1; // J=1 test en incrément J=2 test en décrément
|
||||
@@ -5386,10 +5387,10 @@ begin
|
||||
2 : s:=s+' aiguillage';
|
||||
3 : s:=s+' aiguillage bis';
|
||||
end;
|
||||
AfficheDebug(s,clorange);
|
||||
AfficheDebug(s,clorange);
|
||||
end;
|
||||
|
||||
AdrPrec:=AdrFonc;TypePrec:=TypeFonc;
|
||||
AdrPrec:=AdrFonc;TypePrec:=TypeFonc;
|
||||
AdrFonc:=Adr;TypeFonc:=typeGen;
|
||||
inc(i);
|
||||
sortie:=((typeDet2=TypeGen) and (Adr=el2)) or (Adr=0) or (Adr>=9996) or (i=15) or (N_Det=Nb_det_dist);
|
||||
@@ -5397,7 +5398,7 @@ begin
|
||||
if (i=15) and (Nivdebug=3) then afficheDebug('Pas trouvé',clyellow);
|
||||
if (N_det=Nb_det_dist) and (Nivdebug=3) then afficheDebug('Détecteurs trop distants',clyellow);
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
begin
|
||||
// déja trouvé
|
||||
@@ -5422,6 +5423,7 @@ begin
|
||||
end;
|
||||
AfficheDebug(s,clorange);
|
||||
end;
|
||||
|
||||
AdrPrec:=AdrFonc;TypePrec:=TypeFonc;
|
||||
AdrFonc:=Adr;TypeFonc:=typeGen;
|
||||
inc(i);
|
||||
@@ -5437,6 +5439,7 @@ begin
|
||||
end;
|
||||
detecteur_suivant_el:=Adr;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
if (i=10) then if NivDebug=3 then AfficheDebug('201 : Itération trop longue',clred);
|
||||
inc(j);
|
||||
@@ -6045,12 +6048,20 @@ function PresTrainPrec(AdrFeu : integer) : boolean;
|
||||
end;
|
||||
test_route_valide:=10 ;
|
||||
end;
|
||||
|
||||
|
||||
// présence train 3 détecteurs avant le feu
|
||||
function PresTrainPrec(AdrFeu : integer) : boolean;
|
||||
var PresTrain : boolean;
|
||||
j,i,Det_initial,Adr_El_Suiv,Btype_el_suivant,DetPrec1,DetPrec2,DetPrec3,DetPrec4 : integer;
|
||||
begin
|
||||
i:=index_feu(Adrfeu);
|
||||
if i=0 then
|
||||
begin
|
||||
Affiche('Erreur 602 - feu '+IntToSTR(adrFeu)+' non trouvé',clred);
|
||||
if NivDebug=3 then AfficheDebug('Erreur 602 - feu '+IntToSTR(adrFeu)+' non trouvé',clred);
|
||||
PresTrainPrec:=false;
|
||||
exit;
|
||||
begin
|
||||
end;
|
||||
|
||||
// **** un feu peut être associé à 4 détecteurs (pour 4 voies convergentes) *****
|
||||
// il faut donc explorer les 4 détecteurs probables
|
||||
@@ -6084,25 +6095,28 @@ begin
|
||||
begin
|
||||
det_initial:=feux[i].Adr_det4;Adr_El_Suiv:=feux[i].Adr_el_suiv4;
|
||||
if feux[i].Btype_suiv1=1 then Btype_el_suivant:=1;
|
||||
if feux[i].Btype_suiv1=2 then Btype_el_suivant:=2;
|
||||
if feux[i].Btype_suiv1=2 then Btype_el_suivant:=2;
|
||||
if feux[i].Btype_suiv1=4 then Btype_el_suivant:=2;
|
||||
end;
|
||||
if (det_initial<>0) then
|
||||
if (det_initial<>0) then
|
||||
begin
|
||||
DetPrec1:=detecteur_suivant(Adr_El_Suiv,Btype_el_suivant,det_initial,1);
|
||||
if DetPrec1<9996 then // route bloquée par aiguillage mal positionné
|
||||
if DetPrec1<1024 then // route bloquée par aiguillage mal positionné
|
||||
begin
|
||||
DetPrec2:=detecteur_suivant_El(det_initial,1,DetPrec1,1);
|
||||
if DetPrec2<9996 then
|
||||
begin
|
||||
DetPrec3:=detecteur_suivant_El(DetPrec1,1,DetPrec2,1);
|
||||
if DetPrec3<9996 then
|
||||
if DetPrec2<1024 then
|
||||
begin
|
||||
DetPrec4:=detecteur_suivant_El(DetPrec2,1,DetPrec3,1);
|
||||
if AffSignal or (NivDebug=3) then AfficheDebug('les détecteurs précédents au feu '+IntToSTR(Adrfeu)+' sont:'+intToSTR(Det_initial)+' '+intToSTR(DetPrec1)+' '+intToSTR(DetPrec2)+' '+intToSTR(DetPrec3)+' '+intToSTR(DetPrec4),clyellow);
|
||||
PresTrain:=MemZone[DetPrec4,detPrec3] or
|
||||
MemZone[DetPrec3,detPrec2] or MemZone[DetPrec2,detPrec1] or MemZone[DetPrec1,Det_initial] or presTrain ;
|
||||
if AffSignal or (NivDebug=3) then
|
||||
DetPrec3:=detecteur_suivant_El(DetPrec1,1,DetPrec2,1);
|
||||
if DetPrec3<1024 then
|
||||
begin
|
||||
DetPrec4:=detecteur_suivant_El(DetPrec2,1,DetPrec3,1);
|
||||
if DetPrec4<1024 then
|
||||
begin
|
||||
if AffSignal or (NivDebug=3) then AfficheDebug('les détecteurs précédents au feu '+IntToSTR(Adrfeu)+' sont:'+intToSTR(Det_initial)+' '+intToSTR(DetPrec1)+' '+intToSTR(DetPrec2)+' '+intToSTR(DetPrec3)+' '+intToSTR(DetPrec4),clyellow);
|
||||
PresTrain:=MemZone[DetPrec4,detPrec3] or
|
||||
MemZone[DetPrec3,detPrec2] or MemZone[DetPrec2,detPrec1] or MemZone[DetPrec1,Det_initial] or presTrain ;
|
||||
if AffSignal or (NivDebug=3) then
|
||||
begin
|
||||
if MemZone[DetPrec4,detPrec3] then AfficheDebug('0.présence train '+IntToSTR(DetPrec4)+' '+IntToSTR(detPrec3),clyellow);
|
||||
if MemZone[DetPrec3,detPrec2] then AfficheDebug('1.présence train '+IntToSTR(DetPrec3)+' '+IntToSTR(detPrec2),clyellow);
|
||||
if MemZone[DetPrec2,detPrec1] then AfficheDebug('2.présence train '+IntToSTR(DetPrec2)+' '+IntToSTR(detPrec1),clyellow);
|
||||
@@ -6676,10 +6690,6 @@ begin
|
||||
if (AdrDetFeu=Adresse) and (feux[i].aspect<10) then
|
||||
begin
|
||||
AdrSuiv:=Feux[i].Adr_el_suiv1;TypeSuiv:=Feux[i].Btype_suiv1;
|
||||
if AffSignal then AfficheDebug('Pour Feu '+intToSTR(AdrFeu)+' detecteursuivant('+intToSTR(AdrSuiv)+','+IntToSTR(typeSuiv)+','+intToSTR(AdrDetFeu)+',1)',clyellow);
|
||||
AdrPrec:=detecteur_suivant(AdrSuiv,typeSuiv,AdrDetFeu,1) ; // détecteur précédent le feu
|
||||
if AdrPrec=0 then
|
||||
begin
|
||||
if AffSignal then AfficheDebug('Pour Feu '+intToSTR(AdrFeu)+' detecteursuivant('+intToSTR(AdrSuiv)+','+IntToSTR(typeSuiv)+','+intToSTR(AdrDetFeu)+',1)',clyellow);
|
||||
AdrPrec:=detecteur_suivant(AdrSuiv,typeSuiv,AdrDetFeu,1) ; // détecteur précédent le feu
|
||||
if AdrPrec=0 then
|
||||
@@ -7204,29 +7214,27 @@ var
|
||||
|
||||
// renvoie si un process EXE tourne. Renvoie le Handle du process dans CDMHd et l'Id du process dans ProcessID
|
||||
// sExeName : Nom de l'EXE sans le chemin, et sans EXE }
|
||||
function ProcessRunning(sExeName: String) : Boolean;
|
||||
function ProcessRunning(sExeName: String) : Boolean;
|
||||
var
|
||||
hSnapShot : THandle;
|
||||
ProcessEntry32 : TProcessEntry32; // pointeur sur la structure ProcessEntry32
|
||||
hSnapShot : THandle;
|
||||
ProcessEntry32 : TProcessEntry32; // pointeur sur la structure ProcessEntry32
|
||||
processID : DWord;
|
||||
begin
|
||||
Result:=false;
|
||||
hSnapShot:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
|
||||
begin
|
||||
Result:=false;
|
||||
|
||||
hSnapShot:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
|
||||
Win32Check(hSnapShot <> INVALID_HANDLE_VALUE);
|
||||
|
||||
sExeName:=LowerCase (sExeName);
|
||||
|
||||
FillChar(ProcessEntry32,SizeOf(TProcessEntry32),#0);
|
||||
ProcessEntry32.dwSize:=SizeOf(TProcessEntry32); // contient la structure de tous les process
|
||||
|
||||
if (Process32First(hSnapShot,ProcessEntry32)) then
|
||||
repeat
|
||||
//Affiche(ProcessEntry32.szExeFile,ClYellow);
|
||||
if (Pos(sExeName,LowerCase(ProcessEntry32.szExeFile))=1) then
|
||||
begin
|
||||
processID:=ProcessEntry32.th32ProcessID;
|
||||
CDMhd:=GetWindowFromID(processID);
|
||||
Win32Check(hSnapShot <> INVALID_HANDLE_VALUE);
|
||||
|
||||
sExeName:=LowerCase (sExeName);
|
||||
FillChar(ProcessEntry32,SizeOf(TProcessEntry32),#0);
|
||||
ProcessEntry32.dwSize:=SizeOf(TProcessEntry32); // contient la structure de tous les process
|
||||
|
||||
if (Process32First(hSnapShot,ProcessEntry32)) then
|
||||
repeat
|
||||
//Affiche(ProcessEntry32.szExeFile,ClYellow);
|
||||
if (Pos(sExeName,LowerCase(ProcessEntry32.szExeFile))=1) then
|
||||
begin
|
||||
processID:=ProcessEntry32.th32ProcessID;
|
||||
CDMhd:=GetWindowFromID(processID);
|
||||
Affiche('CDM rail processID='+IntToSTR(ProcessID)+' handle='+IntToSTR(CDMhd),clOrange);
|
||||
Result:=true;
|
||||
Break;
|
||||
@@ -7460,10 +7468,9 @@ var
|
||||
|
||||
procedure TFormPrinc.FormCreate(Sender: TObject);
|
||||
var
|
||||
i,j : integer;
|
||||
i,j : integer;
|
||||
s,s2,Url,LocalFile : string;
|
||||
V_utile : real;
|
||||
trouve,AvecMaj : Boolean;
|
||||
V_utile : real;
|
||||
CibleHandle : Thandle;
|
||||
begin
|
||||
@@ -7573,8 +7580,6 @@ begin
|
||||
begin
|
||||
cree_image(i); // et initialisation tableaux signaux
|
||||
end;
|
||||
Tempo_init:=10; // démarre les initialisation des signaux et des aiguillages dans 1 s
|
||||
|
||||
Tempo_init:=10; // démarre les initialisation des signaux et des aiguillages dans 1 s
|
||||
|
||||
// initialisation de la chronologie des évènements détecteurs
|
||||
|
||||
Reference in New Issue
Block a user