📄 gps loggerview.cpp
字号:
// GPS LoggerView.cpp : implementation of the CGPSLoggerView class
//
#include "stdafx.h"
#include "GPS Logger.h"
#include "GPS LoggerDoc.h"
#include "GPS LoggerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define ID_TIMER 99001
/////////////////////////////////////////////////////////////////////////////
// CGPSLoggerView
IMPLEMENT_DYNCREATE(CGPSLoggerView, CFormView)
BEGIN_MESSAGE_MAP(CGPSLoggerView, CFormView)
//{{AFX_MSG_MAP(CGPSLoggerView)
ON_COMMAND(ID_TOOLS_STARTSTOP, OnToolsStartStop)
ON_UPDATE_COMMAND_UI(ID_TOOLS_STARTSTOP, OnUpdateToolsStartStop)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTON_START, OnButtonStart)
ON_BN_CLICKED(IDC_BUTTON_STOP, OnButtonStop)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGPSLoggerView construction/destruction
CGPSLoggerView::CGPSLoggerView()
: CFormView(CGPSLoggerView::IDD)
{
//{{AFX_DATA_INIT(CGPSLoggerView)
m_strAltitude = _T("0.000000");
m_strLatitude = _T("0.000000");
m_strLongitude = _T("0.000000");
m_strNumSentences = _T("0");
m_strSignalQuality = _T("Unknown");
m_strSatelitesInUse = _T("");
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CGPSLoggerView::~CGPSLoggerView()
{
}
void CGPSLoggerView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGPSLoggerView)
DDX_Control(pDX, IDC_BUTTON_STOP, m_buttonStop);
DDX_Control(pDX, IDC_BUTTON_START, m_buttonStart);
DDX_Text(pDX, IDC_ALTITUDE, m_strAltitude);
DDX_Text(pDX, IDC_LATITUDE, m_strLatitude);
DDX_Text(pDX, IDC_LONGITUDE, m_strLongitude);
DDX_Text(pDX, IDC_NUM_SENTENCES, m_strNumSentences);
DDX_Text(pDX, IDC_SIGNAL_QUALITY, m_strSignalQuality);
DDX_Text(pDX, IDC_SATELITES_IN_USE, m_strSatelitesInUse);
//}}AFX_DATA_MAP
}
BOOL CGPSLoggerView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CGPSLoggerView diagnostics
#ifdef _DEBUG
void CGPSLoggerView::AssertValid() const
{
CFormView::AssertValid();
}
void CGPSLoggerView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CGPSLoggerDoc* CGPSLoggerView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGPSLoggerDoc)));
return (CGPSLoggerDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CGPSLoggerView message handlers
void CGPSLoggerView::OnToolsStartStop()
{
// TODO: Add your command handler code here
if( GetDocument()->IsRunning() )
{
GetDocument()->Stop();
KillTimer(ID_TIMER);
}
else
{
GetDocument()->Start();
SetTimer(ID_TIMER, 1000, NULL);
}
}
void CGPSLoggerView::OnUpdateToolsStartStop(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetText( GetDocument()->IsRunning() ?
_T("Stop") : _T("Start") );
}
void CGPSLoggerView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(nIDEvent == ID_TIMER)
{
GetDocument()->Timer();
UpdateDialogControls(this, FALSE);
}
CFormView::OnTimer(nIDEvent);
}
void CGPSLoggerView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
m_strAltitude.Format(_T("%f"), GetDocument()->GetActualGPSInfo().m_altitude);
m_strLatitude.Format(_T("%f"), GetDocument()->GetActualGPSInfo().m_latitude);
m_strLongitude.Format(_T("%f"), GetDocument()->GetActualGPSInfo().m_longitude);
m_strNumSentences.Format(_T("%d"), GetDocument()->GetActualGPSInfo().m_nSentences);
switch(GetDocument()->GetActualGPSInfo().m_signalQuality)
{
case 0 : m_strSignalQuality = "Fix not available"; break;
case 1 : m_strSignalQuality = "GPS sps mode"; break;
case 2 : m_strSignalQuality = "Differential GPS, SPS mode, fix valid"; break;
case 3 : m_strSignalQuality = "GPS PPS mode, fix valid"; break;
default : m_strSignalQuality = "Unknown"; break;
}
m_strSatelitesInUse.Format(_T("%d"), GetDocument()->GetActualGPSInfo().m_satelitesInUse);
UpdateData (FALSE);
CView::OnUpdate(pSender, lHint, pHint);
}
void CGPSLoggerView::OnButtonStart()
{
// TODO: Add your control notification handler code here
GetDocument()->Start();
SetTimer(ID_TIMER, 1000, NULL);
m_buttonStart.EnableWindow(FALSE);
m_buttonStop.EnableWindow();
}
void CGPSLoggerView::OnButtonStop()
{
// TODO: Add your control notification handler code here
GetDocument()->Stop();
KillTimer(ID_TIMER);
m_buttonStart.EnableWindow();
m_buttonStop.EnableWindow(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -