3: begin
//XK3190-D2+
j:=0;//判断标志字节位置
j:=Pos ('=',read_buffer2);
if j<=0 then
//没有标志字节,则退出
begin
if read_count2>=datalength then
//完整的数据字节数;没有标志
begin
//Mscomm1.InBufferCount:=0;
read_buffer2:='';
read_count2:=0;
exit;
end;
end
else
begin
//有标志,数据完整
// j:=i;
if j<>1 then
//第一字节不是标志字节
begin
delete(read_buffer2,1,j-1);
read_count2:=length(read_buffer2);
// read_buffer1[0]:=$00;
end;
end;
// end;
// edit_shengyu.Text:=inttostr(read_count2);
if read_count2<datalength then
exit;
//完整的数据字节数;
if read_buffer2[1]<>'=' then
exit;
shape2.Brush.Color:=shape2.Brush.Color xor $00ffffff;//接受指示灯
read_buffer2[1]:=chr(10);
{ if (Pos (CHR(13) , read_buffer2)<>0) then
begin
shape2.Brush.Color:=shape2.Brush.Color xor $00ffffff;//接受指示灯
//接受的重量信息;
scurstr:=trim(COPY(read_buffer2 ,1,Pos(CHR(13) ,read_buffer2 )));
delete(read_buffer2,1,Pos (CHR(13) ,read_buffer2 ));
com_notworktime:=0 ;//清楚串口超时接受时间记数
if length(scurstr)<>(datalength-1) then
begin
//SHOWMESSAGE('WEISHU BU GOU');
exit;
//判断接受数据是否完整,别的datalength:integer;//磅秤发送数据的长度
end;
}
// danwei:=copy(scurstr,Nposition1[3,1],Nposition1[3,2]);
//单位=kg, t,lb;
fushu:=copy(scurstr,Nposition1[1,1],Nposition1[1,2]);//数据符号:+,-
// mao:=copy(scurstr,4,1);
scurstr:=trim(copy(scurstr,Nposition1[2,1],Nposition1[2,2]));
//数据
ss:='';
for i:=Nposition1[2,2]do
wnto 1 do
ss:=ss+copy(scurstr,i,1);
scurstr:=trim(ss);
j:=length(scurstr);
for i:=j to 1do
//删除不合法的字符
if ((copy(scurstr,i,1)<'0') or(copy(scurstr,i,1)>'9'))and (copy(scurstr,i,1)<>'.') then
delete(scurstr,i,1);
fuhao:=chr(32);
if fushu='-' then
begin
scurstr:=fuhao+scurstr;
fuhao:=chr(45);
end;
if not check_ZL(scurstr)then
begin
comworking:=false;
exit;
//无效数据则丢弃
end;
// if (danwei='kg')OR(danwei='KG') then
// begin
chengzhong[wen_count]:=TRUNC(strtofloat(scurstr))/1000;
//接受的重量存入最后;
// end
// else
// begin
// chengzhong[wen_count]:=strtofloat(scurstr);
//接受吨,不用除
// end;
for i:=1 to wen_count-1do
begin
chengzhong:=chengzhong[i+1];
//数据区上移;
end;
if mao='GS' then
maozhong:=true else
maozhong:=false;
// end;
end ;