dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
telemetryparser.cpp
Go to the documentation of this file.
1 
12 /*
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  * for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, see <http://www.gnu.org/licenses/>
25  */
26 
27 #include "telemetryparser.h"
30 #include <math.h>
31 #include <QDebug>
32 #include <QStringList>
33 
38  : GPSParser(parent)
39 {
40  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
41  UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
42  UAVDataObject *gpsObj = dynamic_cast<UAVDataObject *>(objManager->getObject("GPSPosition"));
43  if (gpsObj != NULL) {
44  connect(gpsObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateGPS(UAVObject *)));
45  } else {
46  qDebug() << "Error: Object is unknown (GPSPosition).";
47  }
48 
49  gpsObj = dynamic_cast<UAVDataObject *>(objManager->getObject("GPSTime"));
50  if (gpsObj != NULL) {
51  connect(gpsObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateTime(UAVObject *)));
52  } else {
53  qDebug() << "Error: Object is unknown (GPSTime).";
54  }
55 
56  gpsObj = dynamic_cast<UAVDataObject *>(objManager->getObject("GPSSatellites"));
57  if (gpsObj != NULL) {
58  connect(gpsObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateSats(UAVObject *)));
59  }
60 }
61 
63 {
64 }
65 
67 {
68  UAVObjectField *field = object1->getField(QString("Satellites"));
69  emit sv(field->getValue().toInt());
70 
71  double lat = object1->getField(QString("Latitude"))->getDouble();
72  double lon = object1->getField(QString("Longitude"))->getDouble();
73  double alt = object1->getField(QString("Altitude"))->getDouble();
74  lat *= 1E-7;
75  lon *= 1E-7;
76  emit position(lat, lon, alt);
77 
78  double hdg = object1->getField(QString("Heading"))->getDouble();
79  double spd = object1->getField(QString("Groundspeed"))->getDouble();
80  emit speedheading(spd, hdg);
81 
82  QString fix = object1->getField(QString("Status"))->getValue().toString();
83  emit fixtype(fix);
84 
85  double hdop = object1->getField(QString("HDOP"))->getDouble();
86  double vdop = object1->getField(QString("VDOP"))->getDouble();
87  double pdop = object1->getField(QString("PDOP"))->getDouble();
88  emit dop(hdop, vdop, pdop);
89 }
90 
92 {
93  double hour = object1->getField(QString("Hour"))->getDouble();
94  double minute = object1->getField(QString("Minute"))->getDouble();
95  double second = object1->getField(QString("Second"))->getDouble();
96  double time = second + minute * 100 + hour * 10000;
97  double year = object1->getField(QString("Year"))->getDouble();
98  double month = object1->getField(QString("Month"))->getDouble();
99  double day = object1->getField(QString("Day"))->getDouble();
100  double date = day + month * 100 + year * 10000;
101  emit datetime(date, time);
102 }
103 
112 {
113  UAVObjectField *prn = object1->getField(QString("PRN"));
114  UAVObjectField *elevation = object1->getField(QString("Elevation"));
115  UAVObjectField *azimuth = object1->getField(QString("Azimuth"));
116  UAVObjectField *snr = object1->getField(QString("SNR"));
117 
118  for (auto i = 0; i < prn->getNumElements(); i++) {
119  emit satellite(i, prn->getValue(i).toInt(), elevation->getValue(i).toInt(),
120  azimuth->getValue(i).toInt(), snr->getValue(i).toInt());
121  }
122 
123  emit satellitesDone();
124 }
void updateGPS(UAVObject *object1)
void position(double, double, double)
void satellitesDone()
void fixtype(QString)
TelemetryParser(QObject *parent=nullptr)
double getDouble(int index=0) const
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
QVariant getValue(int index=0) const
int getNumElements() const
for i
Definition: OPPlots.m:140
void datetime(double, double)
void dop(double, double, double)
void speedheading(double, double)
void sv(int)
UAVObjectField * getField(const QString &name)
Definition: uavobject.cpp:236
void satellite(int, int, int, int, int)
UAVObject * getObject(const QString &name, quint32 instId=0)
void updateTime(UAVObject *object1)
void updateSats(UAVObject *object1)