Home > Back-end >  DELPHI CLIENTSOCKET don't send data of the next day, look (with code)
DELPHI CLIENTSOCKET don't send data of the next day, look (with code)

Time:09-29

Procedure TForm1. Timer1Timer (Sender: TObject);
Var
T1, t2, t3, t4, t5, t6, t7 has: word;
DataTime, str2, str3, Slen, S_CRC: string;
The begin
DecodeDateTime (now, t1, t2, t3, t4, t5, t6, t7 has);
QN:=inttostr (t1);
If t2 & lt; 10 then QN:=QN + '0' + inttostr (t2) else QN:=QN + inttostr (t2);
If t3 & lt; 10 then QN:=QN + '0' + inttostr (t3) else QN:=QN + inttostr (t3);
If t4 & lt; 10 then QN:=QN + '0' + inttostr (t4) else QN:=QN + inttostr (t4);
If t5 & lt; 10 then QN:=QN + '0' + inttostr (t5) else QN:=QN + inttostr (t5);
If t6 & lt; 10 then QN:=QN + '0' + inttostr (t6) else QN:=QN + inttostr (t6);
DataTime:=QN;
QN:=QN + inttostr (t7 has);
If ((t4=strtoint (trim (Edit3. Text))) and (ZDFlag<> 1)) then
The begin
With CSPZ2 do
The begin
The ConnectionString:='. The Provider=Microsoft Jet. The OLEDB. 4.0. The Data Source=D: \ table 1. MDB. Persist Security Info=False ';
The close;
SQL. The Clear;
SQL. The Add (' select * from YSPZ ');
The open;
First;
Str2:='ST=32; CN=2021; QN='+ QN +'; PW='+ Edt_PW +'; MN='+ Edt_MN +'; Flag=1; CP=& amp; & DataTime='+ DataTime +'; ';
Str2:=str2 + + FieldByName '002 - SLP=' (' SO2XL). AsString + ', '
='+ +' 002 - INT FieldByName (' SO2JJ). AsString + ', '
='+ +' 002 - URV FieldByName (' SO2SX). AsString + ', '
='+ +' 002 - LRV FieldByName (' SO2XX). AsString + '; '//SO2 slope, intercept, ceiling, floor
='+ +' 003 - SLP FieldByName (' NOXXL). AsString + ', '
='+ +' 003 - INT FieldByName (' NOXJJ). AsString + ', '
='+ +' 003 - URV FieldByName (' NOXSX). AsString + ', '
='+ +' 003 - LRV FieldByName (' NOXXX). AsString + '; '//NOX slope, intercept, ceiling, floor
='+ +' 001 - SLP FieldByName (' DUSTXL). AsString + ', '
='+ +' 001 - INT FieldByName (' DUSTJJ). AsString + ', '
='+ +' 001 - URV FieldByName (' DUSTSX). AsString + ', '
='+ +' 001 - LRV FieldByName (' DUSTXX). AsString + '; '//DUST slope, intercept, ceiling, floor
='+ +' S01 - SLP FieldByName (' O2XL). AsString + ', '
+ + FieldByName 'S01 - INT=' (' O2JJ). AsString + ', '
='+ +' S01 - URV FieldByName (' O2SX). AsString + ', '
='+ +' S01 - LRV FieldByName (' O2XX). AsString + '; '//oxygen in the slope, intercept, ceiling, floor
='+ +' S05 - SLP FieldByName (' TEMPXL). AsString + ', '
+ + FieldByName 'S05 - INT=' (' TEMPJJ). AsString + ', '
='+ +' S05 - URV FieldByName (' TEMPSX). AsString + ', '
='+ +' S05 - LRV FieldByName (' TEMPXX). AsString + '; '//smoke temperature slope, intercept, ceiling, floor
='+ +' S08 - SLP FieldByName (' PRESXL). AsString + ', '
+ + FieldByName 'S08 - INT=' (' PRESJJ). AsString + ', '
='+ +' S08 - URV FieldByName (' PRESSX). AsString + ', '
='+ +' S08 - LRV FieldByName (' PRESXX). AsString + '; '//pressure slope, intercept, ceiling, floor
='+ +' S02 - SLP FieldByName (' VELOXL). AsString + ', '
+ + FieldByName 'S02 - INT=' (' VELOJJ). AsString + ', '
='+ +' S02 - URV FieldByName (' VELOSX). AsString + ', '
='+ +' S02 - LRV FieldByName (' VELOXX). AsString + '; '//velocity of slope, intercept, ceiling, floor
='+ +' 301 - Rtd FieldByName (' AREA). AsString + '; '//flue area
='+ +' 302 - Rtd FieldByName (' SDCXS). AsString + '; '
//velocity field coefficient='+ +' 303 - Rtd FieldByName (' KQGSXS). AsString + '; '//air surplus coefficient
='+ +' 304 - Rtd FieldByName (' PTGXS). AsString + '& amp; & ';//pitot coefficient
end;///read the data
Slen:=inttostr (length (str2));
S_CRC:=inttohex4 (CalcCRC (pchar (str2), length (str2)));
If strlen (pchar (Slen))=2 then Slen:='00' + Slen
Else if length (Slen)=3 then Slen:='0' + Slen;
Str2:='# #' + Slen + str2 + S_CRC + # 13 # 10;////////CRC check
If not SendCS. Active then SendCS. Active:=true;
SendCS. Host:=trim (Edit1. Text);
SendCS. Port:=strtoint (Edit2. Text);
Try
SendCS. Open;
SendCS. Socket. SendText (str2);
Mm_send. Lines. The Add (datetimetostr (now) + 'to' + SendCS. Address + + str2 ':');
Except,
Edit4. Text:='1 client and server connection error! ';
end;

End
The else
The begin
If (t4 & lt;> Strtoint (trim (Edit3. Text))) then ZDFlag:=0;
end;

end;

Procedure TForm1. FormCreate (Sender: TObject);
The begin
Filename:=ExtractFilePath (Paramstr (0)) + 'syscfg. Ini';
Myinifile:=Tinifile. Create (filename);
Edt_MN:=myinifile ReadString (' DSC_CONFIG ', 'mn', '000000000000000');
Edt_PW:=myinifile ReadString (' DSC_CONFIG ', 'pw', '123456');
Edt_DS:=myinifile ReadString (' DSC_CONFIG ', 'DSFS', '23');
Edit1. Text:='10.41.100.58';
Edit2. Text:='6008';
Edit3. Text:=Edt_DS;
Myinifile. Destroy;
ZDFlag:=0;
BHFlag:=0;
SendCS. Active:=true;
end;




Procedure TForm1. SendCSRead (Sender: TObject; Sockets: TCustomWinSocket);
Var
GetStr, s1, s2, s3, s4: string;
I, j, a, b: integer;
The begin
GetStr:=socket. ReceiveText;
I:=length (Getstr);
If i<> 0 then ZDFlag:=1;
Mm_send. Lines. The Add (GetStr);
end;

end

CodePudding user response:

Best ZDFlag under Timer1Timer detection: the value of the write a log file it was clear to see

CodePudding user response:

On the first day, the second day not hair, explanation to restart or restart the computer program, caused by the
Agree with the upstairs said, plus detailed logs, output to the local, to find the reason why it is good to the change

CodePudding user response:

Relatively simple is to increase a test processing button (getlasterror () to obtain Error number), when the second day not hair information, click this button to see what is the return value, your network communication control is also built with API, so getlasterror () can get Error messages, according to the Error Lookup check what is wrong description,
  • Related