unit2.cpp
来自「LMS软件是用来进行自适应滤波的最小均方误差算法」· C++ 代码 · 共 61 行
CPP
61 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#pragma package(smart_init)
#include "unit2.h"
#include "file1.h"
//---------------------------------------------------------------------------
// 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 Unit2::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//---------------------------------------------------------------------------
extern int Port;
extern bool readend;
extern bool StopRead;
extern bool ChangePortStart;
extern bool ChangePortEnd;
extern Ch *head;
extern Ch *trail;
extern long RXcount;
__fastcall ReadPort::ReadPort(bool CreateSuspended)
: TThread(CreateSuspended)
{
}
//---------------------------------------------------------------------------
void __fastcall ReadPort::Execute()
{ unsigned char ch;
Ch *Temp;
while(1)
{ if(readend) break;
if(ChangePortStart)
{
ChangePortStart=false;
while(!ChangePortEnd){}
}
if((FileRead(Port,&ch,1)==1)&&(!StopRead))
{
Temp=new Ch;
RXcount++;
if(Temp!=NULL)
{
Temp->Char=ch;
Temp->Next=NULL;
if(head==NULL) head=trail=Temp; else trail=trail->Next=Temp;
}
}
}
//---- Place thread code here ----
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?