⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sampthread.cpp

📁 基于USB接口的GPS应用程序
💻 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 + -