?? sampthread.cpp
字號:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "sampthread.h"
#include "Gps_interface.h"
#include "display.h"
#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 Unit1::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//---------------------------------------------------------------------------
__fastcall SamplingThread::SamplingThread(bool CreateSuspended, void* p)
: TThread(CreateSuspended)
{
p_interface = reinterpret_cast<IoInterface*> (p);
FreeOnTerminate = false;
Priority = tpTimeCritical; // this thread has highest priority
}
//---------------------------------------------------------------------------
void __fastcall SamplingThread::Execute()
{
unsigned char flag;
//---- Place thread code here ----
flag = p_interface->get_pp_flag();
// p_interface->control_gp2021(START_TIMER); // start timer
Sleep(1000);
while(!Terminated)
{
if(p_interface->WriteReadGP2021( flag ))
{
// every time we shift working buffer to another one
flag = p_interface->toggle_pp_flag();
SetEvent(newdataEvent);
}
}
}
//---------------------------------------------------------------------------
void __fastcall SamplingThread::DoTerminate()
{
p_interface->SetThrdStatus(true);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -