c++ builder的Tchart控件怎样实现自左往右刷屏展示实时波形
c++ builder的Tchart控件怎样实现自左往右刷屏显示实时波形
各位大侠,我是个刚学C++ BUILDER的菜鸟,我有个问题一直搞不了想请教你帮我指点迷津。怎么让Tchart控件能够实现自左往右刷屏显示实时波形呀?每次接收固定个数据后就画不了,十万火急,谢谢!我的程序如下:(我的程序是接收39个字符,只有第一个是"A"才显示,否则清除不显示,程序很繁琐只因水平问题别见怪。)
void __fastcall TForm1::MSComm1Comm(TObject *Sender)
{
OleVariant s;//声明一个用于接收数据的OleVariant变量。
if(MSComm1->CommEvent==comEvReceive)// 接收缓冲区中是否收到Rthreshold个字符。
{
Memo1->Clear();
Memo2->Clear();
Memo3->Clear();
Memo4->Clear();
Memo5->Clear();
Memo6->Clear();
Memo7->Clear();
Memo8->Clear();
Memo9->Clear();
Memo10->Clear();
Memo11->Clear();
Memo12->Clear();
Memo13->Clear();
Memo14->Clear();
Memo15->Clear();
Memo16->Clear();
Memo17->Clear();
Memo18->Clear();
Memo19->Clear();
while(MSComm1->InBufferCount) //是否有字符驻留在接收缓冲区等待被取出
{
s=MSComm1->Input;//接收数据
str=s.AsType(varString);//把接收到的OleVariant变量转换成AnsiString类型
ShowMessage(str); //显示str中的值
str0=str.SubString(1,1).c_str();
ShowMessage(str0);
str1=str.SubString(2,2).c_str();
str2=str.SubString(4,2).c_str();
str3=str.SubString(6,2).c_str();
str4=str.SubString(8,2).c_str();
str5=str.SubString(10,2).c_str();
str6=str.SubString(12,2).c_str();
str7=str.SubString(14,2).c_str();
str8=str.SubString(16,2).c_str();
str9=str.SubString(18,2).c_str();
str10=str.SubString(20,2).c_str();
str11=str.SubString(22,2).c_str();
str12=str.SubString(24,2).c_str();
str13=str.SubString(26,2).c_str();
str14=str.SubString(28,2).c_str();
str15=str.SubString(30,2).c_str();
str16=str.SubString(32,2).c_str();
str17=str.SubString(34,2).c_str();
str18=str.SubString(36,2).c_str();
str19=str.SubString(38,2).c_str();
if(str0=="A")
{
str1="0x"+str1;
str2="0x"+str2;
str3="0x"+str3;
str4="0x"+str4;
str5="0x"+str5;
str6="0x"+str6;
str7="0x"+str7;
str8="0x"+str8;
str9="0x"+str9;
str10="0x"+str10;
str11="0x"+str11;
str12="0x"+str12;
str13="0x"+str13;
str14="0x"+str14;
str15="0x"+str15;
str16="0x"+str16;
str17="0x"+str17;
str18="0x"+str18;
str19="0x"+str19;
temp1=StrToInt(str1);
temp2=StrToInt(str2);
temp3=StrToInt(str3);
temp4=StrToInt(str4);
temp5=StrToInt(str5);
temp6=StrToInt(str6);
temp7=StrToInt(str7);
temp8=StrToInt(str8);
temp9=StrToInt(str9);
temp10=StrToInt(str10);
temp11=StrToInt(str11);
temp12=StrToInt(str12);
temp13=StrToInt(str13);
temp14=StrToInt(str14);
temp15=StrToInt(str15);
temp16=StrToInt(str16);
temp17=StrToInt(str17);
temp18=StrToInt(str18);
temp19=StrToInt(str19);
temp1=temp1/10.0;
temp2=temp2/10.0;
temp3=temp3/10.0;
temp4=temp4/10.0;
temp5=temp5/10.0;
temp6=temp6/10.0;
temp7=temp7/10.0;
temp8=temp8/10.0;
temp9=temp9/10.0;
temp10=temp10/10.0;
temp11=temp11/10.0;
temp12=temp12/10.0;
temp13=temp13/10.0;
temp14=temp14/10.0;
temp15=temp15/10.0;
temp16=temp16/10.0;
temp17=temp17/10.0;
temp18=temp18/10.0;
各位大侠,我是个刚学C++ BUILDER的菜鸟,我有个问题一直搞不了想请教你帮我指点迷津。怎么让Tchart控件能够实现自左往右刷屏显示实时波形呀?每次接收固定个数据后就画不了,十万火急,谢谢!我的程序如下:(我的程序是接收39个字符,只有第一个是"A"才显示,否则清除不显示,程序很繁琐只因水平问题别见怪。)
void __fastcall TForm1::MSComm1Comm(TObject *Sender)
{
OleVariant s;//声明一个用于接收数据的OleVariant变量。
if(MSComm1->CommEvent==comEvReceive)// 接收缓冲区中是否收到Rthreshold个字符。
{
Memo1->Clear();
Memo2->Clear();
Memo3->Clear();
Memo4->Clear();
Memo5->Clear();
Memo6->Clear();
Memo7->Clear();
Memo8->Clear();
Memo9->Clear();
Memo10->Clear();
Memo11->Clear();
Memo12->Clear();
Memo13->Clear();
Memo14->Clear();
Memo15->Clear();
Memo16->Clear();
Memo17->Clear();
Memo18->Clear();
Memo19->Clear();
while(MSComm1->InBufferCount) //是否有字符驻留在接收缓冲区等待被取出
{
s=MSComm1->Input;//接收数据
str=s.AsType(varString);//把接收到的OleVariant变量转换成AnsiString类型
ShowMessage(str); //显示str中的值
str0=str.SubString(1,1).c_str();
ShowMessage(str0);
str1=str.SubString(2,2).c_str();
str2=str.SubString(4,2).c_str();
str3=str.SubString(6,2).c_str();
str4=str.SubString(8,2).c_str();
str5=str.SubString(10,2).c_str();
str6=str.SubString(12,2).c_str();
str7=str.SubString(14,2).c_str();
str8=str.SubString(16,2).c_str();
str9=str.SubString(18,2).c_str();
str10=str.SubString(20,2).c_str();
str11=str.SubString(22,2).c_str();
str12=str.SubString(24,2).c_str();
str13=str.SubString(26,2).c_str();
str14=str.SubString(28,2).c_str();
str15=str.SubString(30,2).c_str();
str16=str.SubString(32,2).c_str();
str17=str.SubString(34,2).c_str();
str18=str.SubString(36,2).c_str();
str19=str.SubString(38,2).c_str();
if(str0=="A")
{
str1="0x"+str1;
str2="0x"+str2;
str3="0x"+str3;
str4="0x"+str4;
str5="0x"+str5;
str6="0x"+str6;
str7="0x"+str7;
str8="0x"+str8;
str9="0x"+str9;
str10="0x"+str10;
str11="0x"+str11;
str12="0x"+str12;
str13="0x"+str13;
str14="0x"+str14;
str15="0x"+str15;
str16="0x"+str16;
str17="0x"+str17;
str18="0x"+str18;
str19="0x"+str19;
temp1=StrToInt(str1);
temp2=StrToInt(str2);
temp3=StrToInt(str3);
temp4=StrToInt(str4);
temp5=StrToInt(str5);
temp6=StrToInt(str6);
temp7=StrToInt(str7);
temp8=StrToInt(str8);
temp9=StrToInt(str9);
temp10=StrToInt(str10);
temp11=StrToInt(str11);
temp12=StrToInt(str12);
temp13=StrToInt(str13);
temp14=StrToInt(str14);
temp15=StrToInt(str15);
temp16=StrToInt(str16);
temp17=StrToInt(str17);
temp18=StrToInt(str18);
temp19=StrToInt(str19);
temp1=temp1/10.0;
temp2=temp2/10.0;
temp3=temp3/10.0;
temp4=temp4/10.0;
temp5=temp5/10.0;
temp6=temp6/10.0;
temp7=temp7/10.0;
temp8=temp8/10.0;
temp9=temp9/10.0;
temp10=temp10/10.0;
temp11=temp11/10.0;
temp12=temp12/10.0;
temp13=temp13/10.0;
temp14=temp14/10.0;
temp15=temp15/10.0;
temp16=temp16/10.0;
temp17=temp17/10.0;
temp18=temp18/10.0;