?? dl645lib.~pas
字號:
if Length(Data) < (Idx -1+3) then begin
raise Exception.Create('長度錯');
exit;
end;
CopyMemory(@buf[0],@Data[5], 3);
tmp:= buf3toDword(buf)/10000;
case aFL of
FL_Z: result.Pm_Z:=tmp;
FL_P: result.Pm_P:=tmp;
FL_A: result.Pm_A:=tmp;
FL_B: result.Pm_B:=tmp;
FL_C: result.Pm_C:=tmp;
end;
end; //相
end;
///////////解析最大需量發生時間//////////////////////
Function PaserPmTime_Block(aFL:TFL;Data:String; Idx:Integer):TBlock_PmTime;
var buf:Tbuf4; tmp:TdateTime;
begin
result.PmTime_Z:=0; result.PmTime_P:=0; result.PmTime_A:=0;
result.PmTime_B:=0; result.PmTime_C:=0;
if aFL=FL_Block then begin //塊
if Length(Data) < (Idx -1+4* 5) then begin
raise Exception.Create('長度錯');
exit;
end;
CopyMemory(@buf[0],@Data[Idx], 4); //Idx=5
result.PmTime_Z:= Buf4ToDT(buf); Idx:=idx+4;
CopyMemory(@buf[0],@Data[Idx], 4); //Idx=9
result.PmTime_P:= Buf4ToDT(buf); Idx:=idx+4;
CopyMemory(@buf[0],@Data[Idx], 4); //Idx=14
result.PmTime_A:= Buf4ToDT(buf); Idx:=idx+4;
CopyMemory(@buf[0],@Data[Idx], 4); //Idx=17
result.PmTime_B:= Buf4ToDT(buf); Idx:=idx+4;
CopyMemory(@buf[0],@Data[Idx], 4); //Idx=21
result.PmTime_C:= Buf4ToDT(buf);
end else begin //塊 //相
//[C L DI0 DI1 mm HH DD MM CS]
if Length(Data) < (Idx -1+4*1) then begin
raise Exception.Create('長度錯');
exit;
end;
CopyMemory(@buf[0],@Data[5], 4);
tmp:= Buf4ToDT(buf);
case aFL of
FL_Z: result.PmTime_Z:=tmp;
FL_P: result.PmTime_P:=tmp;
FL_A: result.PmTime_A:=tmp;
FL_B: result.PmTime_B:=tmp;
FL_C: result.PmTime_C:=tmp;
end;
end; //相
end;
//////////////解析斷相發生次數//////////////////////////////
Function PaserDXCNT_Block(X:TBLX; Data:String; Idx:Integer):TBlock_DXCNT;
var buf:Tbuf2; tmp:Word;
begin
result.DXCNT_Z:=0;
result.DXCNT_A:=0;
result.DXCNT_B:=0;
result.DXCNT_C:=0;
if X= X_Block then begin
if Length(Data) < (Idx -1+2*4) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[Idx],2); //Idx=5
result.DXCNT_Z:=buf2ToWord(buf); Idx:=Idx+2;
copymemory(@buf[0],@Data[Idx],2); //Idx=7
result.DXCNT_A:=buf2ToWord(buf); Idx:=Idx+2;
copymemory(@buf[0],@Data[Idx],2); //Idx=9
result.DXCNT_B:=buf2ToWord(buf); Idx:=Idx+2;
copymemory(@buf[0],@Data[Idx],2); //Idx=11
result.DXCNT_C:=buf2ToWord(buf);
end else if X<>X_No then begin
if Length(Data) < (Idx -1+2*1) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[5],2);
tmp:=buf2ToWord(buf);
case X of
X_Z: result.DXCNT_Z:=tmp;
X_A: result.DXCNT_A:=tmp;
X_B: result.DXCNT_B:=tmp;
X_C: result.DXCNT_C:=tmp;
end;
end;
end;
/////////////解析斷相發生總時間////////////////////////
Function PaserDXT_Block(X:TBLX; Data:String; Idx:Integer):TBlock_DXT;
var buf:Tbuf3; tmp:Dword;
begin
result.DXT_Z:=0;
result.DXT_A:=0;
result.DXT_B:=0;
result.DXT_C:=0;
if X= X_Block then begin
if Length(Data) < (Idx -1+3*4) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[Idx],3); //Idx:=5
result.DXT_Z:=buf3ToDWord(buf); Idx:=Idx+3;
copymemory(@buf[0],@Data[Idx],3); //Idx:=8
result.DXT_A:=buf3ToDWord(buf); Idx:=Idx+3;
copymemory(@buf[0],@Data[Idx],3); //Idx:=11
result.DXT_B:=buf3ToDWord(buf); Idx:=Idx+3;
copymemory(@buf[0],@Data[Idx],3); //Idx:=14
result.DXT_C:=buf3ToDWord(buf);
end else if X<>X_No then begin
if Length(Data) < (Idx -1+3*1) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[5],3);
tmp:=buf3ToDWord(buf);
case X of
X_Z: result.DXT_Z:=tmp;
X_A: result.DXT_A:=tmp;
X_B: result.DXT_B:=tmp;
X_C: result.DXT_C:=tmp;
end;
end;
end;
/////////////解析最近斷相發生時間1 //////////////////
Function PaserDXT1_Block(X:TBLX; Data:String; Idx:Integer):TBlock_DXT1;
var buf: TBuf4; tmp: TDateTime ;
begin
result.DXT_Z:=0;
result.DXT_A:=0;
result.DXT_B:=0;
result.DXT_C:=0;
if X= X_Block then begin
if Length(Data) < (Idx -1+4*4) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[Idx],4); //Idx:=5
result.DXT_Z:=buf4ToDT(buf); Idx:=Idx+4;
copymemory(@buf[0],@Data[Idx],4); //Idx:=9
result.DXT_A:=buf4ToDT(buf); Idx:=Idx+4;
copymemory(@buf[0],@Data[Idx],4); //Idx:=13
result.DXT_B:=buf4ToDT(buf); Idx:=Idx+4;
copymemory(@buf[0],@Data[Idx],4); //Idx:=17
result.DXT_C:=buf4ToDT(buf);
end else if X<>X_No then begin
if Length(Data) < (Idx -1+4*1) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[5],4);
tmp:=buf4ToDT(buf);
case X of
X_Z: result.DXT_Z:=tmp;
X_A: result.DXT_A:=tmp;
X_B: result.DXT_B:=tmp;
X_C: result.DXT_C:=tmp;
end;
end;
end;
////////////解析最近斷相發生時間2 /////////////////////
Function PaserDXT2_Block(X:TBLX; Data:String; Idx:Integer):TBlock_DXT2;
var buf: TBuf4; tmp: TDateTime ;
begin
result.DXT_Z:=0;
result.DXT_A:=0;
result.DXT_B:=0;
result.DXT_C:=0;
if X= X_Block then begin
if Length(Data) < (Idx -1+4*4) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[Idx],4); //Idx:=5
result.DXT_Z:=buf4ToDT(buf); Idx:=Idx+4;
copymemory(@buf[0],@Data[Idx],4); //Idx:=9
result.DXT_A:=buf4ToDT(buf); Idx:=Idx+4;
copymemory(@buf[0],@Data[Idx],4); //Idx:=13
result.DXT_B:=buf4ToDT(buf); Idx:=Idx+4;
copymemory(@buf[0],@Data[Idx],4); //Idx:=17
result.DXT_C:=buf4ToDT(buf);
end else if X<>X_No then begin
if Length(Data) < (Idx -1+4*1) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[5],4);
tmp:=buf4ToDT(buf);
case X of
X_Z: result.DXT_Z:=tmp;
X_A: result.DXT_A:=tmp;
X_B: result.DXT_B:=tmp;
X_C: result.DXT_C:=tmp;
end;
end;
end;
//////////////////解析瞬時電壓 ////////////////
Function PaserXV_Block(X:TBLX; Data:String; Idx:Integer):TBlock_XV;
var buf:Tbuf2; tmp:word;
begin
result.X_A:=0;
result.X_B:=0;
result.X_C:=0;
if X= X_Block then begin
if Length(Data) < (Idx -1+2*3) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[Idx],2); //Idx:=5
result.X_A:=buf2ToWord(buf); Idx:=Idx+2;
copymemory(@buf[0],@Data[Idx],2); //Idx:=7
result.X_B:=buf2ToWord(buf); Idx:=Idx+2;
copymemory(@buf[0],@Data[Idx],2); //Idx:=9
result.X_C:=buf2ToWord(buf);
end else if X<>X_No then begin
if Length(Data) < (Idx -1+2*1) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[5],2);
tmp:=buf2ToWord(buf) ;
case X of
X_A: result.X_A:=tmp;
X_B: result.X_B:=tmp;
X_C: result.X_C:=tmp;
end;
end;
end;
//////////////////解析瞬時電流///////////
Function PaserXI_Block(X:TBLX; Data:String; Idx:Integer):TBlock_XI;
var buf:Tbuf2; tmp:double;
begin
result.X_A:=0;
result.X_B:=0;
result.X_C:=0;
if X= X_Block then begin
if Length(Data) < (Idx -1+2*3) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[Idx],2); // Idx=5
result.X_A:=buf2ToWord(buf)/100; Idx:=Idx+2;
copymemory(@buf[0],@Data[Idx],2); // Idx=7
result.X_B:=buf2ToWord(buf)/100; Idx:=Idx+2;
copymemory(@buf[0],@Data[Idx],2); // Idx=9
result.X_C:=buf2ToWord(buf)/100;
end else if X<>X_No then begin
if Length(Data) < (Idx -1+2*1) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[5],2);
tmp:=buf2ToWord(buf)/100;
case X of
X_A: result.X_A:=tmp;
X_B: result.X_B:=tmp;
X_C: result.X_C:=tmp;
end;
end;
end;
///////////////////解析瞬時有功功率/////////
Function PaserXP_Block(X:TBLX; Data:String; Idx:Integer):TBlock_XP;
var buf:Tbuf3; tmp:double;
begin
result.X_Z:=0;
result.X_A:=0;
result.X_B:=0;
result.X_C:=0;
if X= X_Block then begin
if Length(Data) < (Idx -1+3*4) then begin
raise Exception.Create('長度錯');
exit;
end;
CopyMemory(@buf[0],@Data[Idx], 3); // Idx=5
result.X_Z:= buf3toDword(buf)/10000; Idx:=Idx+3;
CopyMemory(@buf[0],@Data[Idx], 3); // Idx=8
result.X_A:= buf3toDword(buf)/10000; Idx:=Idx+3;
CopyMemory(@buf[0],@Data[Idx], 3); // Idx=11
result.X_B:= buf3toDword(buf)/10000; Idx:=Idx+3;
CopyMemory(@buf[0],@Data[Idx], 3); // Idx=514
result.X_C:= buf3toDword(buf)/10000;
end else if X<>X_No then begin
if Length(Data) < (Idx -1+3*1) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[5],3);
tmp:=buf3toDword(buf)/10000;
case X of
X_Z: result.X_Z:=tmp;
X_A: result.X_A:=tmp;
X_B: result.X_B:=tmp;
X_C: result.X_C:=tmp;
end;
end;
end;
////////////解析瞬時無功功率////////
Function PaserXQ_Block(X:TBLX; Data:String; Idx:Integer):TBlock_XQ;
var buf:TBuf2; tmp:Double;
begin
result.X_Z:=0;
result.X_A:=0;
result.X_B:=0;
result.X_C:=0;
if X= X_Block then begin
if Length(Data) < (Idx -1+2*4) then begin
raise Exception.Create('長度錯');
exit;
end;
CopyMemory(@buf[0],@Data[Idx], 2); //Idx=5
result.X_Z:= buf2toword(buf)/100; Idx:=Idx+2;
CopyMemory(@buf[0],@Data[Idx], 2); //Idx=7
result.X_A:= buf2toword(buf)/100; Idx:=Idx+2;
CopyMemory(@buf[0],@Data[Idx], 2); //Idx=9
result.X_B:= buf2toword(buf)/100; Idx:=Idx+2;
CopyMemory(@buf[0],@Data[Idx], 2); //Idx=11
result.X_C:= buf2toword(buf)/100;
end else if X<>X_No then begin
if Length(Data) < (Idx -1+2*1) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[5],2);
tmp:=buf2toword(buf)/100;
case X of
X_Z: result.X_Z:=tmp;
X_A: result.X_A:=tmp;
X_B: result.X_B:=tmp;
X_C: result.X_C:=tmp;
end;
end;
end;
/////////////////解析瞬時功率因數///////
Function PaserXCos_Block(X:TBLX; Data:String; Idx:Integer):TBlock_XCos;
var buf:TBuf2; tmp:Double;
begin
result.X_Z:=0;
result.X_A:=0;
result.X_B:=0;
result.X_C:=0;
if X= X_Block then begin
if Length(Data) < (Idx -1+2*4) then begin
raise Exception.Create('長度錯');
exit;
end;
CopyMemory(@buf[0],@Data[Idx], 2); //Idx=5
result.X_Z:= buf2toword(buf)/1000; Idx:=Idx+2;
CopyMemory(@buf[0],@Data[Idx], 2); //Idx=7
result.X_A:= buf2toword(buf)/1000; Idx:=Idx+2;
CopyMemory(@buf[0],@Data[Idx], 2); //Idx=9
result.X_B:= buf2toword(buf)/1000; Idx:=Idx+2;
CopyMemory(@buf[0],@Data[Idx], 2); //Idx=11
result.X_C:= buf2toword(buf)/1000;
end else if X<>X_No then begin
if Length(Data) < (Idx -1+2*1) then begin
raise Exception.Create('長度錯');
exit;
end;
copymemory(@buf[0],@Data[5],2);
tmp:=buf2toword(buf)/1000;
case X of
X_Z: result.X_Z:=tmp;
X_A: result.X_A:=tmp;
X_B: result.X_B:=tmp;
X_C: result.X_C:=tmp;
end;
end;
end;
////////////////////////////////////////////////////////////
Function PaserC01_(DI0L:char;Data:String):TC01_;
var buf4:TBuf4; buf3:Tbuf3;
Y,M,D:word;
H,F,S:word;
begin
result.D:=0;
result.W:=0;
result.T:=0;
if DI0L= 'F' then begin
if Length(Data) < (4+7) then begin
raise Exception.Create('長度錯');
exit;
end;
result.W:=buf1toByte(Data[5]);
D:=buf1toByte(Data[6]);
M:=buf1toByte(Data[7]);
Y:=buf1toByte(Data[8]);
result.D:=EncodeDate(y,m,d);
S:=buf1toByte(Data[9]);
F:=buf1toByte(Data[10]);
H:=buf1toByte(Data[11]);
result.T:=EncodeTime(h,f,s,0);
end else if DI0L= '0' then begin
if Length(Data) < (4+4) then begin
raise Exception.Create('長度錯');
exit;
end;
result.W:=buf1toByte(Data[5]);
D:=buf1toByte(Data[6]);
M:=buf1toByte(Data[7]);
Y:=buf1toByte(Data[8]);
result.D:=EncodeDate(y,m,d);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -