跪求各位大侠!帮帮小弟看看一个c++ builder程序,为啥小弟我的程序可以编译通过但界面没显示采集的数据也没显示实时波形呀?(刚学的初学者)
跪求各位大侠!帮帮小弟看看一个c++ builder程序,为啥我的程序可以编译通过但界面没显示采集的数据也没显示实时波形呀??(刚学的菜鸟)
//---------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------
#pragma package(smart_init)
#pragma link "MSCommLib_OCX"
#pragma resource "*.dfm"
TFormShow *FormShow;
int temp1=0,temp2=0,temp3=0,temp4=0,temp5=0,temp6=0,temp7=0,temp8=0,temp9=0;
//---------------------------------------
__fastcall TFormShow::TFormShow(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------
void __fastcall TFormShow::OpenPortClick(TObject *Sender)
{
try{
if(MSComm1->PortOpen!=true)
{
MSComm1->CommPort=StrToInt(PortSelect->Text);//选择串口号
MSComm1->Settings=BoudSelect->Text+","+"N"+","+"8"+","+"1";//设置串口的属性波特率、奇偶校验、数据位和停止位
MSComm1->InputMode=0;//设置传入数据的格式,0为文本形式
MSComm1->PortOpen=true;//打开串口
OpenPort->Enabled=false;
ClosePort->Enabled=true;
Show->Enabled=true;
Stop->Enabled=true;
}
}
catch(Exception&exception)
{
Application->ShowException(&exception);
}
StatusBar1->Panels->Items[0]->Text="端口状态:打开";
}
//---------------------------------------
void __fastcall TFormShow::ClosePortClick(TObject *Sender)
{
try
{
if(Timer1->Enabled)
Timer1->Enabled=false;//如果正在采集数据,则停止采集
if(MSComm1->PortOpen!=false)
{
MSComm1->PortOpen=false;
OpenPort->Enabled=true;
ClosePort->Enabled=false;
Show->Enabled=false;
Stop->Enabled=false;
}
else
{
OpenPort->Enabled=false;
ClosePort->Enabled=true;
//Shape1->Brush->Color=clRed;
}
for(int i=0;i<3;i++) //清除Chart空间里面原有的曲线
Chart1->Series[i]->Clear();
for(int i=0;i<3;i++)
Chart2->Series[i]->Clear();
for(int i=0;i<3;i++)
Chart3->Series[i]->Clear();
}
catch(Exception&exception)
{
Application->ShowException(&exception);
}
StatusBar1->Panels->Items[0]->Text="端口状态:关闭";
}
//---------------------------------------
void __fastcall TFormShow::FormCreate(TObject *Sender)
{
MSComm1->InputLen=0;//确定希望从接收缓冲区移出的字符数量,InputLen=0时一次把接收缓冲区的字符全部移出
MSComm1->InBufferSize=1024;
MSComm1->OutBufferSize=512;
MSComm1->SThreshold=0;//表示发送数据时不发生OnComm事件
MSComm1->RThreshold=18;//设定接收18个字符时触发OnComm事件
MSComm1->InputMode=1;//以二进制格式接受数据
/*chart控件初始化*/
for(int i=0;i<3;i++)
Chart1->Series[i]->Clear();
for(int i=0;i<3;i++)
Chart2->Series[i]->Clear();
for(int i=0;i<3;i++)
Chart3->Series[i]->Clear();
}
//---------------------------------------
//---------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------
#pragma package(smart_init)
#pragma link "MSCommLib_OCX"
#pragma resource "*.dfm"
TFormShow *FormShow;
int temp1=0,temp2=0,temp3=0,temp4=0,temp5=0,temp6=0,temp7=0,temp8=0,temp9=0;
//---------------------------------------
__fastcall TFormShow::TFormShow(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------
void __fastcall TFormShow::OpenPortClick(TObject *Sender)
{
try{
if(MSComm1->PortOpen!=true)
{
MSComm1->CommPort=StrToInt(PortSelect->Text);//选择串口号
MSComm1->Settings=BoudSelect->Text+","+"N"+","+"8"+","+"1";//设置串口的属性波特率、奇偶校验、数据位和停止位
MSComm1->InputMode=0;//设置传入数据的格式,0为文本形式
MSComm1->PortOpen=true;//打开串口
OpenPort->Enabled=false;
ClosePort->Enabled=true;
Show->Enabled=true;
Stop->Enabled=true;
}
}
catch(Exception&exception)
{
Application->ShowException(&exception);
}
StatusBar1->Panels->Items[0]->Text="端口状态:打开";
}
//---------------------------------------
void __fastcall TFormShow::ClosePortClick(TObject *Sender)
{
try
{
if(Timer1->Enabled)
Timer1->Enabled=false;//如果正在采集数据,则停止采集
if(MSComm1->PortOpen!=false)
{
MSComm1->PortOpen=false;
OpenPort->Enabled=true;
ClosePort->Enabled=false;
Show->Enabled=false;
Stop->Enabled=false;
}
else
{
OpenPort->Enabled=false;
ClosePort->Enabled=true;
//Shape1->Brush->Color=clRed;
}
for(int i=0;i<3;i++) //清除Chart空间里面原有的曲线
Chart1->Series[i]->Clear();
for(int i=0;i<3;i++)
Chart2->Series[i]->Clear();
for(int i=0;i<3;i++)
Chart3->Series[i]->Clear();
}
catch(Exception&exception)
{
Application->ShowException(&exception);
}
StatusBar1->Panels->Items[0]->Text="端口状态:关闭";
}
//---------------------------------------
void __fastcall TFormShow::FormCreate(TObject *Sender)
{
MSComm1->InputLen=0;//确定希望从接收缓冲区移出的字符数量,InputLen=0时一次把接收缓冲区的字符全部移出
MSComm1->InBufferSize=1024;
MSComm1->OutBufferSize=512;
MSComm1->SThreshold=0;//表示发送数据时不发生OnComm事件
MSComm1->RThreshold=18;//设定接收18个字符时触发OnComm事件
MSComm1->InputMode=1;//以二进制格式接受数据
/*chart控件初始化*/
for(int i=0;i<3;i++)
Chart1->Series[i]->Clear();
for(int i=0;i<3;i++)
Chart2->Series[i]->Clear();
for(int i=0;i<3;i++)
Chart3->Series[i]->Clear();
}
//---------------------------------------