📄 gpsinterface_simulated.cpp
字号:
/* * Roadnav * GPSInterface_Simulated.cpp * * Copyright (c) 2004 - 2007 Richard L. Lynch <rllynch@users.sourceforge.net> * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ ///////////////////////////////////////////////////////////////////////////////// \file////// Simulated gps interface module./////////////////////////////////////////////////////////////////////////////////#ifdef HAVE_CONFIG_H# include <config.h>#endif#ifdef _MSC_VER#pragma warning(disable: 4786)#pragma warning(disable: 4800)#endif#include <wx/wx.h>#include "libroadnav/MapSupport.h"#include "GPSInterface_Simulated.h"#ifdef HAVE_SIMULATED_GPS_SUPPORTusing namespace std;//////////////////////////////////////////////////////////////////////////////////// \brief Constructor - initialize all variables./////////////////////////////////////////////////////////////////////////////////GPSInterface_Simulated::GPSInterface_Simulated(){ m_ptGPS.m_fLong = -70.99; m_ptGPS.m_fLat = 43.004; m_fHeading = 0; m_fSpeed = 50;}//////////////////////////////////////////////////////////////////////////////////// \brief Destructor - do nothing/////////////////////////////////////////////////////////////////////////////////GPSInterface_Simulated::~GPSInterface_Simulated(){}//////////////////////////////////////////////////////////////////////////////////// \brief Returns name of this GPS module./////////////////////////////////////////////////////////////////////////////////wxString GPSInterface_Simulated::Name(){ return wxT("Simulated");}//////////////////////////////////////////////////////////////////////////////////// \brief Returns simulated gps data.////// \param pGPSEvent Receives updated gps data.////// \return Status - always returns GPSStatusOK./////////////////////////////////////////////////////////////////////////////////IGPSInterface::EGPSStatus GPSInterface_Simulated::GetData(wxGPSEvent * pGPSEvent){ wxString strFixType; long nSatellites = 0; wxThread::Sleep(1000); m_fHeading += rand() % 10 - 5; m_ptGPS.m_fLong += m_fSpeed / 1000000.0 * cos_deg(m_fHeading - 90); m_ptGPS.m_fLat -= m_fSpeed / 1000000.0 * sin_deg(m_fHeading - 90); while (m_fHeading < 0) m_fHeading += 360; while (m_fHeading >= 360) m_fHeading -= 360; strFixType = wxT("SPS"); nSatellites = 4; SSatelliteInfo sInfo[1]; sInfo[0].m_iID = 2; sInfo[0].m_fElevation = 42; sInfo[0].m_fAzimuth = 294; sInfo[0].m_fSNR = 45; *pGPSEvent = wxGPSEvent(true, true, true, m_ptGPS, m_fSpeed, m_fHeading, strFixType, nSatellites, sInfo, 1, wxT("")); return GPSStatusOK;}//////////////////////////////////////////////////////////////////////////////////// \brief Returns an explanation of the last error./////////////////////////////////////////////////////////////////////////////////wxString GPSInterface_Simulated::GetLastError(){ return m_strLastError;}//////////////////////////////////////////////////////////////////////////////////// \brief Always reports that autodetection is not supported.////// \param pThread Pointer to wxThread obtain this code is running/// in.////// \return Status - always returns /// GPSStatusAutoDetectionNotSupported./////////////////////////////////////////////////////////////////////////////////IGPSInterface::EGPSStatus GPSInterface_Simulated::AutoDetect(wxThread * pThread){ m_strLastError = wxT("Autodetection not supported"); return GPSStatusAutoDetectionNotSupported;}#endif // #ifdef HAVE_SIMULATED_GPS_SUPPORT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -