大
大老虎
Unregistered / Unconfirmed
GUEST, unregistred user!
加黑的部分,另外请您说一下算法最好详细一些谢了[]
procedure TfG2_GimunCtl.BkRequestDataClick(Sender: TObject);
var
RecvBuff, SendBuff, WrkBuff : String;
CheckSum : WORD;
CrcHi, CrcLo : Byte;
Tot, Sv, StrAddr, LenCnt : SmallInt;
IndexEdt : String[4];
KyeStr : String[2];
KyeValue : Integer;
PointerDa : Pointer;
ByteArrayDa : ^SBuffer;
begin
if IndexNo.text = '' then
begin
Application.MessageBox(GimunIndexNot, SysErrID, MB_OK or MB_ICONINFORMATION);
IndexNo.SetFocus;
Exit;
end
else begin
FileFlag := FileNameHakIn (IndexNo.text + '.Sjp');
if FileFlag then
begin
if Application.MessageBox(GimunDataHkOk, SysErrID,
MB_OKCANCEL or MB_ICONINFORMATION) = IDOK then
begin
FileNameCopy (IndexNo.text + '.Sjp');
FileNameDelete(IndexNo.text + '.Sjp');
end
else Exit;
end;
end;
IndexEdt := IndexNo.text;
PointerDa := Addr(IndexEdt[1]);
ByteArrayDa := PointerDa;
KyeStr := '';
KyeValue := ((ByteArrayDa^[1] SHL 4) OR (ByteArrayDa^[2] AND $0F));
KyeStr := KyeStr + Char(KyeValue);
KyeValue := ((ByteArrayDa^[3] SHL 4) OR (ByteArrayDa^[4] AND $0F));
KyeStr := KyeStr + Char(KyeValue);
GridClear; ReadCnt := 0;
ButtonEnableFalse;
if (HamoNo.text = '') or (HamoNo.text = 'XX') then
begin
StrAddr := HamoAddr;
Tot := (StrAddr + HamoCnt) - 1;
end
else begin
Tot := StrToInt(HamoNo.text);
StrAddr := Tot;
end;
nWhile := 1;
for Sv := StrAddr to Tot do
begin
if nWhile = 2 then Break;
StatusBar1.Panels[1].Text := FormatFloat('00', Sv) + '锅 窍葛滴狼' + IndexNo.text + ' Seching data';
SendBuff := ''; RecvBuff := ''; WrkBuff := ''; CheckSum := 0;
WrkBuff := RStxHead + Chr($00) + TData[Sv]+ Chr($41) + KyeStr + REtxHead;
//WrkBuff := RStxHead + Chr($00) + TData[Sv]+ Chr($18) + KyeStr + REtxHead;
LenCnt := Length(WrkBuff);
SendBuff := RStxHead + TData[LenCnt+3] + copy(WrkBuff, 2, LenCnt-1);
CalcSjCcitt(Addr(SendBuff[1]), Length(SendBuff), CheckSum);
CrcHi := Hi(CheckSum); CrcLo := Lo(CheckSum);
SendBuff := RStxHead + TData[LenCnt+3] + copy(WrkBuff, 2, LenCnt-1) + Chr(CrcLo) + Chr(CrcHi);
_QCCom321.Write (SendBuff);
Delay(2500);
RecvBuff := _QCCom321.CcittRead;
WrkBuff := '';
WrkBuff := GimunDataReadControl(Sv, RecvBuff);
ReadGridSet (WrkBuff);
end;
StatusBar1.Panels[1].Text := '';
ButtonEnableTrue;
end;
procedure TfG2_GimunCtl.BkRequestDataClick(Sender: TObject);
var
RecvBuff, SendBuff, WrkBuff : String;
CheckSum : WORD;
CrcHi, CrcLo : Byte;
Tot, Sv, StrAddr, LenCnt : SmallInt;
IndexEdt : String[4];
KyeStr : String[2];
KyeValue : Integer;
PointerDa : Pointer;
ByteArrayDa : ^SBuffer;
begin
if IndexNo.text = '' then
begin
Application.MessageBox(GimunIndexNot, SysErrID, MB_OK or MB_ICONINFORMATION);
IndexNo.SetFocus;
Exit;
end
else begin
FileFlag := FileNameHakIn (IndexNo.text + '.Sjp');
if FileFlag then
begin
if Application.MessageBox(GimunDataHkOk, SysErrID,
MB_OKCANCEL or MB_ICONINFORMATION) = IDOK then
begin
FileNameCopy (IndexNo.text + '.Sjp');
FileNameDelete(IndexNo.text + '.Sjp');
end
else Exit;
end;
end;
IndexEdt := IndexNo.text;
PointerDa := Addr(IndexEdt[1]);
ByteArrayDa := PointerDa;
KyeStr := '';
KyeValue := ((ByteArrayDa^[1] SHL 4) OR (ByteArrayDa^[2] AND $0F));
KyeStr := KyeStr + Char(KyeValue);
KyeValue := ((ByteArrayDa^[3] SHL 4) OR (ByteArrayDa^[4] AND $0F));
KyeStr := KyeStr + Char(KyeValue);
GridClear; ReadCnt := 0;
ButtonEnableFalse;
if (HamoNo.text = '') or (HamoNo.text = 'XX') then
begin
StrAddr := HamoAddr;
Tot := (StrAddr + HamoCnt) - 1;
end
else begin
Tot := StrToInt(HamoNo.text);
StrAddr := Tot;
end;
nWhile := 1;
for Sv := StrAddr to Tot do
begin
if nWhile = 2 then Break;
StatusBar1.Panels[1].Text := FormatFloat('00', Sv) + '锅 窍葛滴狼' + IndexNo.text + ' Seching data';
SendBuff := ''; RecvBuff := ''; WrkBuff := ''; CheckSum := 0;
WrkBuff := RStxHead + Chr($00) + TData[Sv]+ Chr($41) + KyeStr + REtxHead;
//WrkBuff := RStxHead + Chr($00) + TData[Sv]+ Chr($18) + KyeStr + REtxHead;
LenCnt := Length(WrkBuff);
SendBuff := RStxHead + TData[LenCnt+3] + copy(WrkBuff, 2, LenCnt-1);
CalcSjCcitt(Addr(SendBuff[1]), Length(SendBuff), CheckSum);
CrcHi := Hi(CheckSum); CrcLo := Lo(CheckSum);
SendBuff := RStxHead + TData[LenCnt+3] + copy(WrkBuff, 2, LenCnt-1) + Chr(CrcLo) + Chr(CrcHi);
_QCCom321.Write (SendBuff);
Delay(2500);
RecvBuff := _QCCom321.CcittRead;
WrkBuff := '';
WrkBuff := GimunDataReadControl(Sv, RecvBuff);
ReadGridSet (WrkBuff);
end;
StatusBar1.Panels[1].Text := '';
ButtonEnableTrue;
end;