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

📄 getinfodlg.cpp

📁 对于给定的一组未向信号
💻 CPP
字号:
// GetInfoDlg.cpp : implementation file
//

#include "stdafx.h"
#include "GetInfo.h"
#include "GetInfoDlg.h"
#include "GPS.h"
#include "SplitStr.h"
#include <windows.h>

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

/////////////////////////////////////////////////////////////////////////////
// CGetInfoDlg dialog

CGetInfoDlg::CGetInfoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CGetInfoDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CGetInfoDlg)
	m_GPSInfo = _T("");
	m_GPSLat = _T("");
	m_GPSLong = _T("");
	m_GPSState = _T("");
	m_GPSTime = _T("");
	m_LatState = _T("");
	m_LongState = _T("");
	m_Corse = _T("");
	m_InfoStyle = _T("");
	m_Model = _T("");
	m_LocStyle = _T("");
	m_StatNum = _T("");
	m_PDOP = _T("");
	m_HDOP = _T("");
	m_VDOP = _T("");
	m_TotalNum = _T("");
	m_GSVIndex = _T("");
	m_SatTotalNum = _T("");
	m_PRN = _T("");
	m_SatAngle = _T("");
	m_Azimuth = _T("");
	m_SNR = _T("");
	m_GPSLat1 = _T("");
	m_GPSLong1 = _T("");
	m_GPSTime1 = _T("");
	m_GPSTime2 = _T("");
	m_GPSLat2 = _T("");
	m_GPSLong2 = _T("");
	m_GPSState2 = _T("");
	m_Time = _T("");
	m_Time1 = _T("");
	m_Time2 = _T("");
	m_LatState2 = _T("");
	m_LongState2 = _T("");
	m_Lat2 = _T("");
	m_Long2 = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CGetInfoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CGetInfoDlg)
	DDX_Text(pDX, IDC_INFO, m_GPSInfo);
	DDX_Text(pDX, IDC_LAT, m_GPSLat);
	DDX_Text(pDX, IDC_LONG, m_GPSLong);
	DDX_Text(pDX, IDC_STATE, m_GPSState);
	DDX_Text(pDX, IDC_TIME, m_GPSTime);
	DDX_Text(pDX, IDC_EDIT1, m_LatState);
	DDX_Text(pDX, IDC_EDIT2, m_LongState);
	DDX_Text(pDX, IDC_COURSE, m_Corse);
	DDX_Text(pDX, IDC_EDIT3, m_InfoStyle);
	DDX_Text(pDX, IDC_EDIT4, m_Model);
	DDX_Text(pDX, IDC_EDIT5, m_LocStyle);
	DDX_Text(pDX, IDC_EDIT6, m_StatNum);
	DDX_Text(pDX, IDC_EDIT7, m_PDOP);
	DDX_Text(pDX, IDC_EDIT8, m_HDOP);
	DDX_Text(pDX, IDC_EDIT9, m_VDOP);
	DDX_Text(pDX, IDC_EDIT10, m_TotalNum);
	DDX_Text(pDX, IDC_EDIT11, m_GSVIndex);
	DDX_Text(pDX, IDC_EDIT12, m_SatTotalNum);
	DDX_Text(pDX, IDC_EDIT13, m_PRN);
	DDX_Text(pDX, IDC_EDIT14, m_SatAngle);
	DDX_Text(pDX, IDC_EDIT15, m_Azimuth);
	DDX_Text(pDX, IDC_EDIT16, m_SNR);
	DDX_Text(pDX, IDC_GPSLAT1, m_GPSLat1);
	DDX_Text(pDX, IDC_GPSLONG1, m_GPSLong1);
	DDX_Text(pDX, IDC_TIME1, m_GPSTime1);
	DDX_Text(pDX, IDC_TIME2, m_GPSTime2);
	DDX_Text(pDX, IDC_GPSLAT2, m_GPSLat2);
	DDX_Text(pDX, IDC_GPSLONG2, m_GPSLong2);
	DDX_Text(pDX, IDC_STATE2, m_GPSState2);
	DDX_Text(pDX, IDC_TIME3, m_Time);
	DDX_Text(pDX, IDC_TIME4, m_Time1);
	DDX_Text(pDX, IDC_TIME5, m_Time2);
	DDX_Text(pDX, IDC_EDIT17, m_LatState2);
	DDX_Text(pDX, IDC_EDIT18, m_LongState2);
	DDX_Text(pDX, IDC_LAT2, m_Lat2);
	DDX_Text(pDX, IDC_LONG2, m_Long2);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CGetInfoDlg, CDialog)
	//{{AFX_MSG_MAP(CGetInfoDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_SHOW, OnShow)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_STOP, OnStop)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGetInfoDlg message handlers

BOOL CGetInfoDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	m_bState=1;

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CGetInfoDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CGetInfoDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CGetInfoDlg::OnOK() 
{
	// TODO: Add extra validation here

	File.Close();      //关闭打开的文件
	CDialog::OnOK();
}

void CGetInfoDlg::OnShow() 
{
	// TODO: Add your control notification handler code here
	
	//启动延时
	SetTimer(1,250,NULL);               
	//判断是否是第一次读取
	if (m_bState==1)
	{
		File.Open("fakegpsdata.txt",CFile::modeReadWrite|CFile::modeNoTruncate);
	}
}


void CGetInfoDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	CSplitStr split;
	CString buffString;

	//读取文件里的内容,并存放在buffString中
	File.ReadString(buffString);              

	//CSplitStr类是用来分割字符串的,并将分割后的内容存放在array数组里
	split.SetSplitFlag(",");
	split.SetSequenceAsOne(TRUE);
	split.SetData(buffString);
	CStringArray array;
	split.GetSplitStrArray(array);
 	m_GPSInfo=buffString;
	//////////////////////////////////////////////////////////////////////////
	//判断读取的GPS信息是那种类型
	if (array[0]=="$GPRMC") 
	{
		m_InfoStyle="推荐定位信息";
		CString s;
		m_GPSTime=array[1].Left(2);
		s=array[1].Right(8);
		m_GPSTime1=s.Left(2);
		m_GPSTime2=s.Right(6);
		if (array[2]=="A")
		{
			m_GPSState="定位有效";
		}
		else
		{
			m_GPSState="定位无效";
		}
		//将纬度信息分割
		m_GPSLat=array[3].Left(2);
		m_GPSLat1=array[3].Right(7);
		if (array[4]=="N")
		{
			m_LatState="北纬";
		}
		else
		{
			m_LatState="南纬";
		}
		//将经度信息分割
		m_GPSLong=array[5].Left(3);
		m_GPSLong1=array[5].Right(7);
		if (array[6]=="W")
		{
			m_LongState="西经";
		}
		else
		{
			m_LongState="东经";
		}
		m_Corse=array[7];	
		UpdateData(FALSE);
	}
	//////////////////////////////////////////////////////////////////////////
	if (array[0]=="$GPGLL")
	{
		m_InfoStyle="定位地理信息";
		//将纬度信息分割
		m_Lat2=array[1].Left(2);
		m_GPSLat2=array[1].Right(7);
		if (array[2]=="N")
		{
			m_LatState2="北纬";
		}
		else
		{
			m_LatState2="南纬";
		}
		//将经度信息分割
		m_Long2=array[3].Left(3);
		m_GPSLong2=array[3].Right(7);
		if (array[4]=="W")
		{
			m_LongState2="西经";
		}
		else
		{
			m_LongState2="东经";
		}
		//对时间信息部分进行分割
		CString s;
		m_Time=array[5].Left(2);
		s=array[5].Right(8);
		m_Time1=s.Left(2);
		m_Time2=s.Right(6);
		if (array[6].Left(1)=="A")
		{
			m_GPSState2="有效定位";
		}
		if (array[6].Left(1)=="V")
		{
			m_GPSState2="无效定位";
		}
		UpdateData(FALSE);
	}
	//////////////////////////////////////////////////////////////////////////
	if (array[0]=="$GPGSA") 
	{
		m_InfoStyle="当前卫星信息";
		if (array[1]=="A")
		{
			m_Model="自动";
		}
		else
		{
			m_Model="手动";
		}
		if (array[2]=="1")
		{
			m_LocStyle="没有定位";
		}
		if (array[2]=="2") 
		{
			m_LocStyle="2D定位";
		}
		else
		{
			m_LocStyle="3D定位";
		}
		//进行卫星号的连接
		CString SatNum=array[3]+","+array[4]+","+array[5]+","+array[6]+","+array[7]+","+array[8];
		m_StatNum=SatNum;
		m_PDOP=array[9];
		m_HDOP=array[10];
		m_VDOP=array[11].Left(3);
		UpdateData(FALSE);		
	}
	//////////////////////////////////////////////////////////////////////////
	if (array[0]=="$GPGSV")
	{
		m_InfoStyle="可见卫星信息";
		m_TotalNum=array[1];
		m_GSVIndex=array[2];
		m_SatTotalNum=array[3];
		m_PRN=array[4];
		m_SatAngle=array[5];
		m_Azimuth=array[6];
		m_SNR=array[7].Left(2);
		UpdateData(FALSE);	 	
	}
	CDialog::OnTimer(nIDEvent);
}

void CGetInfoDlg::OnStop() 
{
	// TODO: Add your control notification handler code here
	//暂停信息的读取,并让打开文件状态设置为已经打开
	if (KillTimer(1))
	{
		m_bState++;
	}
}

⌨️ 快捷键说明

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