這是我的一個多緒程式請問各位高手為何我可以通過Compiler但開啟這一個多序卻會出現錯誤呢?且錯誤都是出現在存檔的那一行。
#include
#pragma hdrstop
#include "Main.h"
#include "Login.h"
#include "ReceiveData.h"
#include "Monitor.h"
#include "stdio.h"
#pragma package(smart_init)
FILE *TFile,*ECGFile,*SPO2RFile,*SPO2GFile;
//--------------------------------------------------------------------------- // Important: Methods and properties of objects in VCL can only be
// used in a method called using Synchronize, for example:
//
// Synchronize(UpdateCaption);
//
// where UpdateCaption could look like:
//
// void __fastcall TReceiveData::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//--------------------------------------------------------------------------- __fastcall TReceiveData::TReceiveData(bool CreateSuspended)
: TThread(CreateSuspended)
{
FreeOnTerminate=true;
}
//---------------------------------------------------------------------------
void __fastcall TReceiveData::Execute()
{
//---- Place thread code here ----
while(1)
{
Synchronize(File_Store);
Synchronize(Receive);
Sleep(1);
}
}
//---------------------------------------------------------------------------
void _fastcall TReceiveData::Receive()
{
if (Count == 2000)
{
MonitorForm->ECGChart->Series[0]->Clear();
MonitorForm->TemperatureChart->Series[0]->Clear();
MonitorForm->SPO2Chart->Series[0]->Clear();
MonitorForm->SPO2Chart->Series[1]->Clear();
Count = 0;
}
int Channel;
ClearCommError(MainForm->hComm1,&dwError,&cs);
if (cs.cbInQue > sizeof(inbuff))
{
PurgeComm(MainForm->hComm1, PURGE_RXCLEAR);
return;
}
if(cs.cbInQue>100)
{
ReadFile(MainForm->hComm1,inbuff,100,&nBytesRead,NULL); if(inbuff[0]>=64)
{
for(int j=0 ; j<100 ;j=j 2)
{
Buff1=inbuff[j 1] ((inbuff[j]&7)*64);
Channel=(inbuff[j]>>3)& 7;
if (Channel == 0)
{
MonitorForm->ECGChart->Series[0]->AddXY(Count,Buff1,"",clTeeColor);
//fprintf(ECGFile,"%d",Buff1);
}
if(Channel==1)
{
MonitorForm->TemperatureChart->Series[0]->AddXY(Count,(MainForm->Temperature[Buff1]/100),"",clTeeColor);
//fprintf(TFile,"%d",Buff1);
}
if (Channel == 2)
{
MonitorForm->SPO2Chart->Series[0]->AddXY(Count,Buff1,"",clTeeColor);
//fprintf(SPO2RFile,"%d",Buff1);
}
if (Channel == 3)
{
MonitorForm->SPO2Chart->Series[1]->AddXY(Count,Buff1,"",clTeeColor);
//fprintf(SPO2GFile,"%d",Buff1);
}
Count ;
}
}
else
{
for(int j=1 ; j<100 ;j=j 2)
{ if (Channel == 0)
{
MonitorForm->ECGChart->Series[0]->AddXY(Count,Buff1,"",clTeeColor);
//fprintf(ECGFile,"%d",Buff1);
}
if(Channel==1)
{
MonitorForm->TemperatureChart->Series[0]->AddXY(Count,(MainForm->Temperature[Buff1]/100)*2,"",clTeeColor);
//fprintf(TFile,"%d",Buff1);
}
if (Channel == 2)
{
MonitorForm->SPO2Chart->Series[0]->AddXY(Count,Buff1,"",clTeeColor);
//fprintf(SPO2RFile,"%d",Buff1);
}
if (Channel == 3)
{
MonitorForm->SPO2Chart->Series[1]->AddXY(Count,Buff1,"",clTeeColor);
//fprintf(SPO2GFile,"%d",Buff1);
}
Count ;
}
ReadFile(MainForm->hComm1,inbuff1,1,&nBytesRead,NULL);
}
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------
void _fastcall TReceiveData::File_Store()
{
AnsiString Time1,Date1,Temp;
Date1=Date().FormatString("YYYYMMDD");
Time1=Time().FormatString("HHMMSS");
AnsiString ID=LoginForm->IDEdit->Text "_" Date1 "_" Time1;
AnsiString TFileName,EFileName,SRFileName,SGFileName; TFileName="C:\\Project\\File_Store\\" ID "Tem.Tps";
TFile=fopen(TFileName.c_str(),"w ");
EFileName="C:\\Project\\File_Store\\" ID "ECG.Eps";
ECGFile=fopen(EFileName.c_str(),"w ");
SRFileName="C:\\Project\\File_Store\\" ID "SPO2R.Sps";
SPO2RFile=fopen(SRFileName.c_str(),"w ");
SGFileName="C:\\Project\\File_Store\\" ID "SPO2G.Sps";
SPO2GFile=fopen(SGFileName.c_str(),"w "); }