S
simulink
Unregistered / Unconfirmed
GUEST, unregistred user!
用socket接受很多数据包,将其中的数据解包之后在chart上显示,不同的chart根据协议中数据包的标志位不同而显示不同种类的数据(用的是if then
操作,定时接受数据,大约20ms一个左右,在if then
函数中分配其应在哪个chart上显示)
程序如下:
procedure TForm1.tsttimerTimer(Sender: TObject);
var
l:integer;
b:RSndBuf;
c:integer;
d:TByteBuf;
e:word;
ByteSingleData:array[1..2] of byte absolute e;
begin
c:=ncRead(@b);
d:=b.buf;
if(d[1]=255) and (d[2]=255)then
begin
if (d[8]and $0f)=11 then
begin
application.ProcessMessages;
edit3.Text:= inttostr(netReciveCount2)+' '+inttostr(netReciveCount3);
Mw_netBuf:=UnloadNetPacket_TargetMeasure(d);
inc(netReciveCount2);
chart1.Series[0].AddXY((netReciveCount2)*0.02,ThreeDir_netProl_X_Position1,'');
chart1.Series[1].AddXY((netReciveCount2)*0.02,ThreeDir_netProl_X_speed1,'');
if(netReciveCount2>chart1.BottomAxis.Maximum*50) then
begin
chart1.BottomAxis.Automatic:=true;
chart1.Series[0].Delete(0);
chart1.Series[1].Delete(0);
end;
end
else
if(d[8]and $0f)=3 then
begin
application.ProcessMessages;
Mw_netBuf1:=unloadNetPacket_threeDir(d);
inc(netReciveCount3);
Chart2.Series[0].AddXY((netReciveCount3)*0.02,ThreeDir_netProl_X_Position,'');
Chart2.Series[1].AddXY((netReciveCount3)*0.02,ThreeDir_netProl_X_speed,'');
if(netReciveCount3>chart2.BottomAxis.Maximum*50) then
begin
chart2.BottomAxis.Automatic:=true;
chart2.Series[0].Delete(0);
chart2.Series[1].Delete(0);
end;
end;
有几个问题
1 当用鼠标移动到其他tab页时,曲线变化很大且不规则
2 当一个chart显示4组数据即四个图形时,本应都是正弦的曲线,但有的曲线会出现分叉现象,即四条曲线不重合。
请问各位大虾是怎么回事?
操作,定时接受数据,大约20ms一个左右,在if then
函数中分配其应在哪个chart上显示)
程序如下:
procedure TForm1.tsttimerTimer(Sender: TObject);
var
l:integer;
b:RSndBuf;
c:integer;
d:TByteBuf;
e:word;
ByteSingleData:array[1..2] of byte absolute e;
begin
c:=ncRead(@b);
d:=b.buf;
if(d[1]=255) and (d[2]=255)then
begin
if (d[8]and $0f)=11 then
begin
application.ProcessMessages;
edit3.Text:= inttostr(netReciveCount2)+' '+inttostr(netReciveCount3);
Mw_netBuf:=UnloadNetPacket_TargetMeasure(d);
inc(netReciveCount2);
chart1.Series[0].AddXY((netReciveCount2)*0.02,ThreeDir_netProl_X_Position1,'');
chart1.Series[1].AddXY((netReciveCount2)*0.02,ThreeDir_netProl_X_speed1,'');
if(netReciveCount2>chart1.BottomAxis.Maximum*50) then
begin
chart1.BottomAxis.Automatic:=true;
chart1.Series[0].Delete(0);
chart1.Series[1].Delete(0);
end;
end
else
if(d[8]and $0f)=3 then
begin
application.ProcessMessages;
Mw_netBuf1:=unloadNetPacket_threeDir(d);
inc(netReciveCount3);
Chart2.Series[0].AddXY((netReciveCount3)*0.02,ThreeDir_netProl_X_Position,'');
Chart2.Series[1].AddXY((netReciveCount3)*0.02,ThreeDir_netProl_X_speed,'');
if(netReciveCount3>chart2.BottomAxis.Maximum*50) then
begin
chart2.BottomAxis.Automatic:=true;
chart2.Series[0].Delete(0);
chart2.Series[1].Delete(0);
end;
end;
有几个问题
1 当用鼠标移动到其他tab页时,曲线变化很大且不规则
2 当一个chart显示4组数据即四个图形时,本应都是正弦的曲线,但有的曲线会出现分叉现象,即四条曲线不重合。
请问各位大虾是怎么回事?