diff --git a/Notice d'utilisation des signaux_complexes_GL_V1.pdf b/Notice d'utilisation des signaux_complexes_GL_V1.pdf deleted file mode 100644 index 2541543..0000000 Binary files a/Notice d'utilisation des signaux_complexes_GL_V1.pdf and /dev/null differ diff --git a/Signaux_complexes_GL.cfg b/Signaux_complexes_GL.cfg index c22c47f..096ce3f 100644 --- a/Signaux_complexes_GL.cfg +++ b/Signaux_complexes_GL.cfg @@ -31,12 +31,12 @@ -M -$M16384,1048576 -K$00400000 --LE"c:\program files\borland\delphi7\Projects\Bpl" --LN"c:\program files\borland\delphi7\Projects\Bpl" --U"c:\program files\borland\delphi7\Lib\Debug" --O"c:\program files\borland\delphi7\Lib\Debug" --I"c:\program files\borland\delphi7\Lib\Debug" --R"c:\program files\borland\delphi7\Lib\Debug" +-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl" +-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl" +-U"c:\program files (x86)\borland\delphi7\Lib\Debug" +-O"c:\program files (x86)\borland\delphi7\Lib\Debug" +-I"c:\program files (x86)\borland\delphi7\Lib\Debug" +-R"c:\program files (x86)\borland\delphi7\Lib\Debug" -w-UNSAFE_TYPE -w-UNSAFE_CODE -w-UNSAFE_CAST diff --git a/Signaux_complexes_GL.dof b/Signaux_complexes_GL.dof index 428efc2..24aa8fd 100644 --- a/Signaux_complexes_GL.dof +++ b/Signaux_complexes_GL.dof @@ -111,7 +111,7 @@ AutoIncBuild=1 MajorVer=1 MinorVer=0 Release=0 -Build=2 +Build=3 Debug=0 PreRelease=0 Special=0 @@ -122,7 +122,7 @@ CodePage=1252 [Version Info Keys] CompanyName= FileDescription= -FileVersion=1.0.0.2 +FileVersion=1.0.0.3 InternalName= LegalCopyright= LegalTrademarks= diff --git a/Signaux_complexes_GL.dpr b/Signaux_complexes_GL.dpr index 7a04625..f6036e6 100644 --- a/Signaux_complexes_GL.dpr +++ b/Signaux_complexes_GL.dpr @@ -3,12 +3,14 @@ program Signaux_complexes_GL; uses Forms, UnitPrinc in 'UnitPrinc.pas' {FormPrinc}, - UnitDebug in 'UnitDebug.pas' {FormDebug}; + UnitDebug in 'UnitDebug.pas' {FormDebug}, + verif_version in 'verif_version.pas' {FormVersion}; {$R *.res} begin Application.Initialize; Application.CreateForm(TFormPrinc, FormPrinc); + Application.CreateForm(TFormDebug, FormDebug); Application.Run; end. diff --git a/Signaux_complexes_GL.exe b/Signaux_complexes_GL.exe index b3d0fa6..012d66e 100644 Binary files a/Signaux_complexes_GL.exe and b/Signaux_complexes_GL.exe differ diff --git a/Signaux_complexes_GL.res b/Signaux_complexes_GL.res index 94072b5..79d7e1b 100644 Binary files a/Signaux_complexes_GL.res and b/Signaux_complexes_GL.res differ diff --git a/UnitDebug.dcu b/UnitDebug.dcu index 3ca4aa8..1ded097 100644 Binary files a/UnitDebug.dcu and b/UnitDebug.dcu differ diff --git a/UnitPrinc.dcu b/UnitPrinc.dcu index f76fb21..736a173 100644 Binary files a/UnitPrinc.dcu and b/UnitPrinc.dcu differ diff --git a/UnitPrinc.pas b/UnitPrinc.pas index c3cabb7..709ee9a 100644 --- a/UnitPrinc.pas +++ b/UnitPrinc.pas @@ -16,7 +16,7 @@ interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, OleCtrls, ExtCtrls, jpeg, ComCtrls, - ImgList, ScktComp, StrUtils, Menus, ActnList, MSCommLib_TLB ; + ImgList, ScktComp, StrUtils, Menus, ActnList, MSCommLib_TLB; type TFormPrinc = class(TForm) @@ -121,7 +121,7 @@ type // L'oeilleton est cablé sur la sortie 4, il est géré directement par le décodeur. **/ // code des aspects des signaux const -AF='Client TCP-IP CDM Rail ou USB - système LENZ - Version 1.01'; + carre =0 ; carre_F=1; semaphore =1 ; semaphore_F=2; semaphore_cli =2 ; semaphore_cli_F=4; @@ -202,7 +202,7 @@ var ancien_tablo_signalCplx,EtatsignalCplx : array[0..MaxAcc] of word; event_det : array[1..20] of integer; branche : array [1..100] of string; parcours : array[1..MaxElParcours] of TBranche ; // parcours des locos en fonction des détecteurs - + const ClBleuClair=$FF7070 ; Cyan=$FFA0A0; @@ -215,7 +215,7 @@ var ack,portCommOuvert,trace,AffMem,AfficheDet,Bis,CDM_connecte,parSocketCDM, DebugOuv : boolean; tablo : array of byte; - Enregistrement,AdresseIP,chaine_Envoi,chaine_recue,AdresseIPCDM,recuCDM,Id_CDM : string; + Enregistrement,AdresseIP,chaine_Envoi,chaine_recue,AdresseIPCDM,recuCDM,Id_CDM,Af : string; maxaiguillage,detecteur_chgt,Temps,TpsRecuCom,NumPort,Tempo_init,Suivant, timerSimule,NbreImagePligne,Port,NbreBranches,Index2_det,branche_det,Index_det,portCDM : integer; Ancien_detecteur,detecteur : array[0..1024] of boolean; // anciens état des détecteurs et adresses des détecteurs et leur état @@ -265,7 +265,7 @@ var implementation -uses UnitDebug; +uses UnitDebug, verif_version; procedure menu_interface(MA : TMA); var val : boolean; @@ -637,6 +637,9 @@ begin until (temps<=0); end; + + + // envoi d'une chaîne à la centrale par USBLenz ou socket, puis attend l'ack ou le nack function envoi(s : string) : boolean; var temps : integer; @@ -1128,9 +1131,12 @@ envoie les donn 18. rappel 60 + avertissement clignotant /*===========================================================================*) -procedure envoi_NMRA(adresse,code : integer); -var valeur : integer ; +procedure envoi_NMRA(adresse: integer); +var valeur,index,code : integer ; 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 ancien_tablo_signalCplx[adresse]:=EtatSignalCplx[adresse]; @@ -1227,6 +1233,7 @@ begin aspect:=code_to_aspect(code); // transforme le motif de bits en numéro "code des aspects des signaux" if (tracesign) then Affiche('Signal virtuel: '+intToSTR(adresse)+' Etat '+etatSign[aspect],clyellow); end; + dessine_feu(adresse); end; (*========================================================================== @@ -2166,7 +2173,7 @@ begin 2 : envoi_CDF(signalCplx); 3 : envoi_LDT(signalCplx); 4 : envoi_LEB(signalCplx); - //5 : envoi_NMRA(SignalCplx); + 5 : envoi_NMRA(SignalCplx); end; end; end; @@ -4755,12 +4762,19 @@ begin end; {$J-} + + procedure TFormPrinc.FormCreate(Sender: TObject); var i : integer; - s : string; + s,s2,Url,LocalFile : string; + trouve,AvecMaj : Boolean; + V_utile,V_publie : real; begin + + AvecMaj:=false; TraceSign:=True; + AF:='Client TCP-IP CDM Rail ou USB - système LENZ - Version '+Version; Caption:=AF; avecMSCom:=false; Application.onHint:=doHint; @@ -4768,11 +4782,16 @@ begin Menu_interface(devalide); // ouvre la fenetre debug - FormDebug:=TFormDebug.Create(Application); + FormDebug:=TFormDebug.Create(Self); FormDebug.Caption:=AF+' debug'; - FormDebug.Show; + //FormDebug.Show; + DebugOuv:=True; + FormVersion:=TformVersion.Create(self); + //FormVersion.show; + //FormVersion.Hide; + if IsWow64Process then s:='OS 64 Bits' else s:='OS 32 Bits'; s:=DateToStr(date)+' '+TimeToStr(Time)+' '+s; @@ -4850,6 +4869,7 @@ begin //Affiche(IntToSTR(detecteur_suivant_El(531,false,518,false)),clyellow); //i:=Aiguille_deviee(176); + end; @@ -4877,10 +4897,9 @@ begin portCommOuvert:=false; ClientSocketCDM.close; ClientSocketLenz.close; - - end; + procedure init_aiguillages; var i,pos : integer; s : string; diff --git a/VerifVersion.dcu b/VerifVersion.dcu new file mode 100644 index 0000000..5e258cf Binary files /dev/null and b/VerifVersion.dcu differ diff --git a/VerifVersion.pas b/VerifVersion.pas new file mode 100644 index 0000000..ffa9909 --- /dev/null +++ b/VerifVersion.pas @@ -0,0 +1,130 @@ +unit VerifVersion; + +interface +//procedure verifie_version; + +uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls , ComCtrls ,WinInet; + +procedure verifie_version; + +implementation + +function GetCurrentProcessEnvVar(const VariableName: string): string; +var + nSize: DWord; +begin + nSize:= 0; + nSize:= GetEnvironmentVariable(PChar(VariableName), nil, nSize); + if nSize = 0 then + begin + result:= ''; + end + else + begin + SetLength(result, nSize - 1); + if GetEnvironmentVariable(PChar(VariableName), PChar(result), nSize) <> nSize - 1 then + raise Exception.Create(SysErrorMessage(GetlastError)) + end; +end; + + +function DownloadURL_NOCache(aUrl: string;s : string): Boolean; +var + hSession: HINTERNET; + hService: HINTERNET; + Fs:TFileStream; + lpBuffer: array[0..1024 + 1] of byte; + dwBytesRead: DWORD; +begin + Result := False; + + Try Fs := TFileStream.Create(s,fmCreate); + hSession := InternetOpen('MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); + try + if Assigned(hSession) then + begin + hService := InternetOpenUrl(hSession, PChar(aUrl), nil, 0, INTERNET_FLAG_RELOAD, 0); + if Assigned(hService) then + try + while True do + begin + dwBytesRead := 1024; + InternetReadFile(hService, @lpBuffer, 1024, dwBytesRead); + fs.WriteBuffer(lpBuffer, dwBytesRead); + if dwBytesRead = 0 then break; + end; + Result := True; + finally + InternetCloseHandle(hService); + end; + end; + finally + InternetCloseHandle(hSession); + end; + finally + fs.Free; + end; +end; + + +procedure verifie_version; +var s,s2,Url,LocalFile : string; + trouve : boolean; + fichier : text; + i : integer; + V_publie,V_utile : real; +begin + Url:='http://cdmrail.free.fr/ForumCDR/viewtopic.php?f=77&t=3906#p50499'; + LocalFile:='page.txt'; + trouve:=false; + if DownloadURL_NOCache(Url,localFile) then + begin + AssignFile(fichier,LocalFile); + reset(fichier); + while not(eof(fichier) or trouve) do + begin + readln(fichier,s); + s:=UpperCase(s); + //Affiche(s,clyellow); + i:=pos('VERSION ',s); + trouve:=i<>0; + end; + closefile(fichier); + if trouve then + begin + delete(s,1,i+7); + i:=pos('VERSION ',s); + i:=pos(' ',s); + s:=copy(s,1,i-1); + //Affiche('Version '+s,clgreen); + // changer le . en , + i:=pos('.',s);s[i]:=','; + s2:=version; + i:=pos('.',s2);s2[i]:=','; + + V_publie:=StrToFloat(s); + V_utile:=StrToFloat(s2); + if V_utile nSize - 1 then + raise Exception.Create(SysErrorMessage(GetlastError)) + end; +end; + + +function DownloadURL_NOCache(aUrl: string;s : string): Boolean; +var + hSession: HINTERNET; + hService: HINTERNET; + Fs:TFileStream; + lpBuffer: array[0..1024 + 1] of byte; + dwBytesRead: DWORD; +begin + Result:=False; + + Try Fs:=TFileStream.Create(s,fmCreate); + hSession:=InternetOpen('MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); + try + if Assigned(hSession) then + begin + hService:=InternetOpenUrl(hSession, PChar(aUrl), nil, 0, INTERNET_FLAG_RELOAD, 0); + if Assigned(hService) then + try + while True do + begin + dwBytesRead:=1024; + InternetReadFile(hService,@lpBuffer,1024,dwBytesRead); + fs.WriteBuffer(lpBuffer, dwBytesRead); + if dwBytesRead=0 then break; + end; + Result:=True; + finally + InternetCloseHandle(hService); + end; + end; + finally + InternetCloseHandle(hSession); + end; + finally + fs.Free; + end; +end; + + +procedure verifie_version; +var s,s2,s3,Version_p,Url,LocalFile : string; + trouve_version,trouve_zip : boolean; + fichier : text; + i,j : integer; + V_publie,V_utile : real; +begin + Url:='http://cdmrail.free.fr/ForumCDR/viewtopic.php?f=77&t=3906#p50499'; + LocalFile:='page.txt'; + trouve_version:=false; + trouve_zip:=false; + if DownloadURL_NOCache(Url,localFile) then + begin + AssignFile(fichier,LocalFile); + reset(fichier); + while not(eof(fichier)) and (not(trouve_version) or not(trouve_zip)) do + begin + readln(fichier,s); + s:=LowerCase(s); + if not(trouve_version) then + begin + i:=pos('version ',s); + trouve_version:=i<>0; + if trouve_version then s2:=s; + end; + if not(trouve_zip) then + begin + i:=pos('.zip',s); + trouve_zip:=i<>0; + if trouve_zip then s3:=s; + end; + // Aff(s) + end; + closefile(fichier); + if trouve_version then + begin + // isoler le champ version + i:=pos('version ',s2); + delete(s2,1,i+7); + j:=pos(' ',s2); + Version_p:=copy(s2,1,j-1); // version dans version_p + // isoler l'url du zip + i:=pos('href="',s3); + delete(s3,1,i+5); + j:=pos('"',s3); + s3:=copy(s3,1,j-1); + i:=pos('.',s3); + if i<>0 then delete(s3,i,1); // supprimer le . + s3:='http://cdmrail.free.fr/ForumCDR'+s3 ; + //aff(s3); // lien dans s3 + + // changer le . en , + s:=Version_p; + i:=pos('.',s);if i<>0 then s[i]:=','; + s2:=version; + i:=pos('.',s2);if i<>0 then s2[i]:=','; + + V_publie:=StrToFloat(s); + V_utile:=StrToFloat(s2); + if V_utile0 then dec(lance_verif); + if lance_verif=1 then verifie_version; + +end; + +end. + \ No newline at end of file