首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

c++ builder的Tchart控件怎样实现自左往右刷屏显示实时波形,该怎么处理

2012-02-24 
c++ builder的Tchart控件怎样实现自左往右刷屏显示实时波形各位大侠,我是个刚学C++ BUILDER的菜鸟,我有个

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;
  temp19=temp19/10.0;


  Memo1->Text=Memo1->Text+temp1;
  Memo2->Text=Memo2->Text+temp2;
  Memo3->Text=Memo3->Text+temp3;
  Memo4->Text=Memo4->Text+temp4;
  Memo5->Text=Memo5->Text+temp5;
  Memo6->Text=Memo6->Text+temp6;
  Memo7->Text=Memo7->Text+temp7;
  Memo8->Text=Memo8->Text+temp8;
  Memo9->Text=Memo9->Text+temp9;
  Memo10->Text=Memo10->Text+temp10;
  Memo11->Text=Memo11->Text+temp11;
  Memo12->Text=Memo12->Text+temp12;
  Memo13->Text=Memo13->Text+temp13;
  Memo14->Text=Memo14->Text+temp14;
  Memo15->Text=Memo15->Text+temp15;
  Memo16->Text=Memo16->Text+temp16;
  Memo17->Text=Memo17->Text+temp17;
  Memo18->Text=Memo18->Text+temp18;
  Memo19->Text=Memo19->Text+temp19;

  Timer1->Enabled=true;
  }
  else
  {
  str0=0;
  str1=0;
  str2=0;
  str3=0;
  str4=0;
  str5=0;
  str6=0;
  str7=0;
  str8=0;
  str9=0;
  str10=0;
  str11=0;
  str12=0;
  str13=0;
  str14=0;
  str15=0;
  str16=0;
  str17=0;
  str18=0;
  str19=0;

  s=0;
  }
}
}
}
//---------------------------------------


void __fastcall TForm1::Button6Click(TObject *Sender)
{
  Close();  
}
//---------------------------------------


void __fastcall TForm1::Timer1Timer(TObject *Sender)
{


  Series3->AddY(temp1);
  Series2->AddY(temp2);
  Series1->AddY(temp3);
  Series6->AddY(temp4);
  Series5->AddY(temp5);
  Series4->AddY(temp6);
  Series9->AddY(temp7);
  Series8->AddY(temp8);
  Series7->AddY(temp9);
  Chart1-> Refresh();//因为看到很多人说加这么一句就可以刷新,但为啥我的没反应呀?????
  Chart2-> Refresh();
  Chart3-> Refresh();
   
}
//---------------------------------------


[解决办法]
这么有规律的东西。为什么不定义数组?
[解决办法]
这样:Chart1->Series[0]->AddXY(x, y, "", clTeeColor);横坐标x估计你是时间

热点排行