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

📄 navthread.cpp

📁 基于USB接口的GPS应用程序
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "navthread.h"
#include "Gpsnav.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 NavThread::NavThread(bool CreateSuspended , void *p)
        : TThread(CreateSuspended)
{
 p_gpsnav = reinterpret_cast<GPS_Nav*> (p);
 FreeOnTerminate = false;
 Priority = tpTimeCritical;
}
//---------------------------------------------------------------------------
void __fastcall NavThread::Execute()
{
        //---- Place thread code here ----
 unsigned int count = 0;
 while(!Terminated)
 {
  WaitForSingleObject(newdataEvent, INFINITE);

  
  p_gpsnav->Get_oneframedata();
  if(p_gpsnav->ProcessData())    // process data and check if TIC happened
   count++;

  if( count == 3){     // every 3 tic trigger one display thread
    SetEvent(dispEvent);
    count = 0;
  }
 } // end of while(
}
//---------------------------------------------------------------------------
void __fastcall NavThread::DoTerminate()
{
 p_gpsnav->SetThrdStatus(true);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -