if PPICom.Open then PPICom.Open :=false;
portOpened:=false;
result:=true;
end;
procedure TfrmPPI.PPIComTrigger(CP: TObject; Msg, TriggerHandle, Data: Word);
var
I : Word;
c :char;
begin
case Msg of
APW_TRIGGERDATA :
begin
//overTimeFlag:=false;
end;
APW_TRIGGERAVAIL :
begin
for I := 1 to Data do begin
c:= PPICom.GetChar;
retStr := retStr+c;
byteBuffer[realCharNo]:=ord(c);
realCharNo:=realCharNo+1;
end;
if expectCharNo=realCharNo then begin
ppiCom.RemoveTrigger(timerHandle);
waitData:=false;
end;
end;
APW_TRIGGERTIMER :
begin
waitData:=false;
PPICom.RemoveTrigger(timerHandle);
end;
end;
end;
function TfrmPPI.ReadVB(const Station :byte; const Addr : Word; var valueWord): boolean;
var
I,K : Byte;
sStr,qStr: string;
begin
Result := false;
if (not portOpened) or waitData then exit;
K:=0;
s7GetVW[4]:=station;
S7GetVW[22]:=2;
S7GetVW[24]:=1; //读取字节数
S7GetVW[26]:=1;
S7GetVW[27]:=$84;
S7GetVW[29]:=Hi(Addr*8);
S7GetVW[30]:=Lo(Addr*8);
for I:=4 to 30 do
K:=K + S7GetVW[I];
S7GetVW[31]:=K;
sStr:='';
for i:=0 to sizeof(s7GetVW)-1 do sStr:=sStr+char(S7GetVW[I]);
PPICom.PutString(sStr);
function TfrmPPI.writeVB (const Station :byte; const Addr : Word; const Value : Dword): Boolean;
var
I,K : Byte;
sStr,qStr: string;
begin
Result := false;
if (not portOpened) or waitData then exit;