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

📄 gpstest1view.cpp

📁 自己封装的能解析出GPS数据中的$GPRMC数据
💻 CPP
字号:
// gpstest1View.cpp : implementation of the CGpstest1View class
//

#include "stdafx.h"
#include "gpstest1.h"

#include "gpstest1Doc.h"
#include "gpstest1View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CGpstest1View

IMPLEMENT_DYNCREATE(CGpstest1View, CView)

BEGIN_MESSAGE_MAP(CGpstest1View, CView)
	//{{AFX_MSG_MAP(CGpstest1View)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGpstest1View construction/destruction

CGpstest1View::CGpstest1View()
{
	// TODO: add construction code here

}

CGpstest1View::~CGpstest1View()
{
}

BOOL CGpstest1View::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CGpstest1View drawing

void CGpstest1View::OnDraw(CDC* pDC)
{
	CGpstest1Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here	
	strcpy(gps.gpsMessage,"$GPRMC,121252.000,A,3958.3032,N,11629.6046,E,15.15,359.95,070306,,,A*54");
//	CClientDC dc(this);	
//	pDC->TextOut(0,0,gps.gpsMessage);
/*	int n = 3;
	CString c;
	c.Format("id: %03d",n);
	gps.analyseGPSProc(NULL);
	pDC->TextOut(0,0,c);

	c.Format("Latitude: %s",gps.gpsMCSignal.latitude);
	pDC->TextOut(0,20,c);

	c.Format("Longitude: %s",gps.gpsMCSignal.longitude);
	pDC->TextOut(0,40,c);
	
	c.Format("Time: %s       %s", gps.gpsMCSignal.date,gps.gpsMCSignal.time);
	pDC->TextOut(0,60,c);

	int   Day,   Moon,   Year;
    int   hour,   minute,   second;   
    CString   str   =   gps.gpsMCSignal.date ; 
	CString   str1   =   gps.gpsMCSignal.time ; 
  
    Day   =   atoi(str.Mid(0,2));   
    Moon  =   atoi(str.Mid(2,2));   
    Year  =   atoi((const char   *)str.Mid(4,2)); 

	hour    =   atoi((const char   *)str1.Mid(0,2));   
    minute  =   atoi((const char   *)str1.Mid(2,2));   
    second  =   atoi((const char   *)str1.Mid(4,2)); 
 
   
  // c.Format("Time: %02d / %02d / 20%02d   %02d : %02d : %02d",Day,Moon,Year, hour,minute,second);
	c.Format("20%02d-%d-%d",Year,Moon,Day);
	strcpy(gps.gpsMCSignal.date,c);
    pDC->TextOut(0,80,gps.gpsMCSignal.date);
	
	c.Format("%d:%d:%d", hour,minute,second);
	strcpy(gps.gpsMCSignal.time,c);
	pDC->TextOut(0,100,gps.gpsMCSignal.time);*/
	gps.analyseDateTime();
	pDC->TextOut(0,20,gps.gpsMCSignal.latitude);
	pDC->TextOut(0,40,gps.gpsMCSignal.longitude);
	pDC->TextOut(0,60,gps.gpsMCSignal.statu);
	pDC->TextOut(0,80,gps.gpsMCSignal.date);
	pDC->TextOut(0,100,gps.gpsMCSignal.time);
}

/////////////////////////////////////////////////////////////////////////////
// CGpstest1View printing

BOOL CGpstest1View::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CGpstest1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CGpstest1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CGpstest1View diagnostics

#ifdef _DEBUG
void CGpstest1View::AssertValid() const
{
	CView::AssertValid();
}

void CGpstest1View::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CGpstest1Doc* CGpstest1View::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGpstest1Doc)));
	return (CGpstest1Doc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CGpstest1View message handlers

⌨️ 快捷键说明

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