23 #include <QDomElement>
25 #include <QXmlStreamWriter>
30 #ifndef STATUS_DGPS_FIX
31 #define STATUS_DGPS_FIX 2
48 , qsHost(
"127.0.0.1" )
52 , pqSocketNotifier( 0 )
69 switch( _eOperatingMode )
88 qCritical(
"ERROR[%s]: Failed to switch operating mode; host=%s, port=%d", Q_FUNC_INFO, qPrintable(
qsHost ),
iPort );
104 if( __poDeviceGpsdGpsEditView->exec() == QDialog::Accepted )
showDetail();
105 delete __poDeviceGpsdGpsEditView;
110 QDomElement __qDomElement = _rqDomElement.firstChildElement(
"Configuration" );
111 if( __qDomElement.isNull() )
return;
112 qsHost = __qDomElement.attribute(
"host",
"127.0.0.1" );
113 iPort = __qDomElement.attribute(
"port",
"2947" ).toInt();
114 qsSource = __qDomElement.attribute(
"source" );
120 _rqXmlStreamWriter.writeStartElement(
"Device" );
122 _rqXmlStreamWriter.writeAttribute(
"name",
qsName );
123 _rqXmlStreamWriter.writeAttribute(
"driver",
"gpsd_gps" );
125 _rqXmlStreamWriter.writeStartElement(
"Configuration" );
126 _rqXmlStreamWriter.writeAttribute(
"host",
qsHost );
127 _rqXmlStreamWriter.writeAttribute(
"port", QString::number(
iPort ) );
128 if( !
qsSource.isEmpty() ) _rqXmlStreamWriter.writeAttribute(
"source",
qsSource );
129 _rqXmlStreamWriter.writeEndElement();
131 _rqXmlStreamWriter.writeEndElement();
146 __pqMutexDataChange->lock();
155 #if GPSD_API_MAJOR_VERSION >= 7
156 __iStatus = gps_read(
psGpsData, NULL, 0 );
157 #elif GPSD_API_MAJOR_VERSION >= 5
162 if( __iStatus == 0 )
break;
165 qCritical(
"ERROR[%s]: Failed to read data from device; status=%d", Q_FUNC_INFO, __iStatus );
166 emit
signalError( QString( tr(
"Failed to read data from device")+
"; status=%1" ).arg( __iStatus ) );
177 if( !(
psGpsData->set & PACKET_SET ) )
continue;
182 if(
psGpsData->dev.path[0] ==
'\0' )
continue;
183 QString __qsSource = QString::fromLatin1(
psGpsData->dev.path );
190 if(
psGpsData->set & (TIME_SET|LATLON_SET|ALTITUDE_SET|TRACK_SET|SPEED_SET|CLIMB_SET) )
201 #if GPSD_API_MAJOR_VERSION >= 10
213 if(
psGpsData->fix.mode != MODE_NOT_SEEN )
224 __oDeviceDataFix.
setType( __eFixType );
228 #if GPSD_API_MAJOR_VERSION >= 9
235 if( !std::isnan(
psGpsData->fix.longitude ) && !std::isnan(
psGpsData->fix.latitude ) )
279 #if GPSD_API_MAJOR_VERSION >= 9
286 for(
int __i = 0; __i <
psGpsData->satellites_visible; __i++ )
288 #if GPSD_API_MAJOR_VERSION >= 6
289 int __iPRN =
psGpsData->skyview[ __i ].PRN;
301 bool __bUsed =
false;
302 for(
int __j = 0; __j <
psGpsData->satellites_used; __j++ )
304 #if GPSD_API_MAJOR_VERSION >= 6
305 if(
psGpsData->skyview[ __j ].used == __iPRN )
314 __oDeviceDataSatellite.
setUsed( __bUsed );
315 __oDeviceDataSkyView.append( __oDeviceDataSatellite );
335 __pqMutexDataChange->unlock();
355 gps_stream(
psGpsData, WATCH_DISABLE, NULL );
359 qDebug(
"DEBUG[%s]: Device successfully stopped", Q_FUNC_INFO );
370 qDebug(
"DEBUG[%s]: Device successfully paused", Q_FUNC_INFO );
384 #if GPSD_API_MAJOR_VERSION >= 5
385 __iStatus = gps_open(
qsHost.toLocal8Bit().constData(), QString::number(
iPort ).toLocal8Bit().constData(), &
sGpsData );
388 psGpsData = gps_open(
qsHost.toLocal8Bit().constData(), QString::number(
iPort ).toLocal8Bit().constData() );
394 qCritical(
"ERROR[%s]: Failed to open device; status=%d", Q_FUNC_INFO, __iStatus );
395 emit
signalError( QString( tr(
"Failed to open device")+
"; status=%1" ).arg( __iStatus ) );
400 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
420 __iStatus = gps_stream(
psGpsData, WATCH_ENABLE|WATCH_NEWSTYLE, NULL );
423 qCritical(
"ERROR[%s]: Failed to stream data from device; status=%d", Q_FUNC_INFO, __iStatus );
424 emit
signalError( QString( tr(
"Failed to stream data from device")+
"; status=%1" ).arg( __iStatus ) );
436 qDebug(
"DEBUG[%s]: Device successfully started; socket=%d", Q_FUNC_INFO,
psGpsData->gps_fd );
438 qDebug(
"DEBUG[%s]: Device successfully started; socket=%p", Q_FUNC_INFO,
psGpsData->gps_fd );
void setBearing(double _fdBearing)
Sets this course's bearing, in degrees.
void setSpeed(double _fdSpeed, double _fdSpeedVertical=UNDEFINED_SPEED)
Sets this course's horizontal speed, in meters per second.
void setSpeedVertical(double _fdSpeedVertical)
Sets this course's vertical speed, in meters per second.
void setPosition(double _fdLongitude, double _fdLatitude, double _fdElevation=UNDEFINED_ELEVATION)
Sets new coordinates.
static constexpr double UNDEFINED_ELEVATION
Specific value for an undefined elevation.
void setTime(double _fdTime)
Sets the time, in seconds from Unix epoch.
static constexpr double UNDEFINED_VALUE
void setDopTime(double _fdDopTime)
Sets the time Dilution-of-Precision (TDOP)
void setDopPosition(double _fdDopHorizontal, double _fdDopVertical=UNDEFINED_VALUE)
Sets the position Dilution-of-Precision (HDOP, VDOP)
static const double UNDEFINED_VALUE
Specific value for an undefined component.
Fix data [source,time,position,course,DOPs,...].
void setErrorPosition(double _fdErrorHorizontal, double _fdErrorVertical=CDataValidity::UNDEFINED_VALUE)
Sets the (horizontal and vertical) position error, in meters.
void setErrorSpeed(double _fdErrorSpeed, double _fdErrorSpeedVertical=CDataValidity::UNDEFINED_VALUE)
Sets the (horizontal and vertical) speed error, in meters per second.
void setErrorBearing(double _fdErrorBearing)
Sets the bearing error, in degrees.
void setType(int _eType)
Sets the fix type.
void setErrorTime(double _fdErrorTime)
Sets the time error, in seconds.
void setSources(int _iSourcesSeen, int _iSourcesUsed)
Sets the sources count (most likely satellites)
Satellite data [PRN,signal,azimuth,elevation,etc.].
void setUsed(bool _bUsed)
Sets the satellite usage status.
void setElevation(double _fdElevation)
Sets the satellite elevation, in degrees.
void setAzimuth(double _fdAzimuth)
Sets the satellite azimuth, in degrees.
void setSignal(double _fdSignal)
Sets the satellite signal-to-noise ratio, in decibels.
Sky view data (satellites details)
void setSourceType(EType _eType)
Sets the source type.
virtual void refreshContent()
Refreshes the content of the underlying widget.
[UI] Route container's edit view
struct gps_data_t sGpsData
GPSD data.
bool bPaused
Pause status.
void parseQVCT(const QDomElement &_rqDomElement)
Retrieves the device's configuration from the given QVCT source (file)
CDeviceGpsdGps(const QString &_rqsName)
virtual ~CDeviceGpsdGps()
QVCT::EStatus setOperatingMode(CDevice::EOperatingMode _eOperatingMode)
Sets the device's operating mode.
QString qsSource
Source (filter)
QVCT::EStatus start()
Stop the device.
struct gps_data_t * psGpsData
GPSD data pointer.
virtual void showDetail()
Displays the device's details (in the appropriate widget/view)
QString qsHost
Network host.
virtual void showEdit()
Displays the device's edit (configuration) widget/view.
QVCT::EStatus stop()
Start the device.
QVCT::EStatus pause()
Pause the device.
void dumpQVCT(QXmlStreamWriter &_rqXmlStreamWriter) const
Stores the device's configuration to the given QVCT destination (file)
QSocketNotifier * pqSocketNotifier
Socket notifier.
CDevice::EOperatingMode status()
Returns the device's status (operating mode)
void slotProcessData(int)
Slots to process device data.
Generic navigation device (GPS, speedometer, compass, etc.)
void signalDataFix(const CDeviceDataFix &_roDeviceDataFix)
Signal emitted by the device when an updated fix is available.
void signalActivity()
Signal emitted by the device when activity occures.
EOperatingMode
Device operating mode (stop, start, pause)
void signalDataSkyView(const CDeviceDataSkyView &_roDeviceDataSkyView)
Signal emitted by the device when an updated sky view is available.
void signalError(const QString &_rqsErrorMessage)
Signal emitted by the device when an error occured.
void signalOperatingMode(CDevice::EOperatingMode _eOperatingMode)
Signal emitted by the device when its operating mode changed.
void switchView(EView eView)
Displays the requested container/item details (switching to the appropriate widget)
void switchView(EView eView)
Displays the requested overlay (switching to the appropriate tab)
void setOverlayObject(COverlayObject *_poOverlayObject)
Sets the overlay object to be displayed (and refreshes the underlying widget)
QString qsName
Object name.
static COverlayDetailView * useOverlayDetailView()
static CDeviceDetailView * useDeviceDetailView()
static QMutex * useMutexDataChange()
static COverlayListView * useOverlayListView()