📄 hexcomtt.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "hexcomtt.h"
#pragma hdrstop
#pragma package(smart_init)
//---------------------------------------------------------------------------
// 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 hexcomtt::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//---------------------------------------------------------------------------
__fastcall hexcomtt::hexcomtt(bool CreateSuspended)
: TThread(CreateSuspended)
{
hexcom1 =new hexcom;
}
//---------------------------------------------------------------------------
void __fastcall hexcomtt::Execute()
{
//---- Place thread code here ----
while(!Terminated){
union Fdata a;
char *sp;
unsigned long lrc;
String buf;
char inbuff[100],i;
DWORD nByteRead,dwEvent,dwError;
COMSTAT cs;
ClearCommError(hexcom1->hComm,&dwError,&cs);
if(cs.cbInQue>0){
if(cs.cbInQue>sizeof(inbuff)){
PurgeComm(hexcom1->hComm,PURGE_RXCLEAR);
return;}
ReadFile(hexcom1->hComm,inbuff,cs.cbInQue,&nByteRead,NULL);
for(i=0;i<cs.cbInQue;i++)
switch (hexcom1->getbyte(inbuff[i])){
case 1:
{
hexcom1->time2->Enabled=FALSE;
sp=hexcom1->TXdata;
WriteFile(hexcom1->hComm,sp,hexcom1->startdata(),&lrc,NULL);
hexcom1->time2->Enabled=TRUE;
hexcom1->eventok=0;
}break;
case 2:
{
hexcom1->time2->Enabled=FALSE;
hexcom1->eventtemp.comnum=hexcom1->thecomnum;
(*hexcom1->eopsp)(&hexcom1->eventtemp,1); //_____________________________________________
hexcom1->eventok=1;
}break;
case 0:
{
hexcom1->time2->Enabled=TRUE;
hexcom1->eventok=0;
}break;
case 3:
{
hexcom1->time2->Enabled=FALSE;
hexcom1->eventok=1;
}break;
}
}
if(hexcom1->eventok==1&&hexcom1->headSP!=hexcom1->lastSP)
{ hexcom1->time2->Enabled=false;
hexcom1->eventtemp=*hexcom1->headSP;
hexcom1->Myaddr=hexcom1->headSP->Addr;
hexcom1->WorR=hexcom1->headSP->eWorR;
hexcom1->ReadType=hexcom1->headSP->DataType;
hexcom1->TempAddr=hexcom1->headSP->DataAddr;
hexcom1->ReadNum=hexcom1->headSP->DataNum;
hexcom1->outtimenum=hexcom1->headSP->OTnum;
hexcom1->eopsp=hexcom1->headSP->opsp; //___________________________________________________
hexcom1->headSP=hexcom1->headSP->next;
hexcom1->startchange();
}
Sleep(10);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -