logger.hh
Go to the documentation of this file.
1 
9 #pragma once
10 
11 
12 // stdlib
13 #include <vector>
14 // 3rd party
15 #include <QDateTime>
16 #include <QDebug>
17 #include <QFile>
18 #include <QObject>
19 #include <QProcess>
20 #include <QTextStream>
21 #include <QTimer>
22 // dfti
23 #include "autopilot/autopilot.hh"
24 #include "core/consts.hh"
25 #include "core/qptrutil.hh"
26 #include "rio/rio.hh"
27 #include "settings/settings.hh"
28 #include "uadc/uadc.hh"
29 #include "util/util.hh"
30 #include "vn200/vn200.hh"
31 
32 
33 namespace dfti {
34 
35 
37 class Logger : public QObject
38 {
39  Q_OBJECT;
40 
41 public:
43 
47  explicit Logger(Settings *_settings, QObject* _parent = nullptr);
48 
50  ~Logger();
51 
53 
56  void enableAutopilot(Autopilot *ap);
57 
59 
62  void enableUADC(uADC *adc);
63 
65 
68  void enableRIO(RIO *rio);
69 
71 
74  void enableVN200(VN200 *ins);
75 
77 
80  void start(void);
81 
82 public slots:
84  void flush(void);
85 
87  void getAPData(APData data);
88 
90  void getRIOData(RIOData data);
91 
93  void getUADCData(uADCData data);
94 
96  void getVN200Data(VN200Data data);
97 
99  void gpsAvailable(bool flag);
100 
102  void writeData(void);
103 
104 private:
106 
112  void openLogFile(QFile &fd, bool &flag, QString type, QString timestamp);
113 
115  bool logAP(void);
116 
118  bool logRIO(void);
119 
121  bool logUADC(void);
122 
124  bool logVN200(void);
125 
127  QPointer<Settings> settings{nullptr};
128 
130  QPointer<QTimer> writeTimer{nullptr};
131 
133  QPointer<QTimer> flushTimer{nullptr};
134 
136  QString timestamp{""};
137 
139  const QString delim{","};
140 
142  bool haveAP{false};
143 
145  bool haveRIO{false};
146 
148  bool haveUADC{false};
149 
151  bool haveVN200{false};
152 
154  bool apLogFileOpen{false};
155 
157  bool rioLogFileOpen{false};
158 
160  bool uADCLogFileOpen{false};
161 
163  bool vn200LogFileOpen{false};
164 
166  bool firstWrite{true};
167 
169  bool newAPData{false};
170 
172  bool newRIOData{false};
173 
175  bool newUADCData{false};
176 
178  bool newVN200Data{false};
179 
181  bool haveGPS{false};
182 
184  bool setSystemTime{false};
185 
187  QFile apLogFile;
188 
190  QFile rioLogFile;
191 
193  QFile uADCLogFile;
194 
196  QFile vn200LogFile;
197 
199  quint32 rcInTime{0};
200 
202  quint16 rcIn1{0};
203 
205  quint16 rcIn2{0};
206 
208  quint16 rcIn3{0};
209 
211  quint16 rcIn4{0};
212 
214  quint16 rcIn5{0};
215 
217  quint16 rcIn6{0};
218 
220  quint16 rcIn7{0};
221 
223  quint16 rcIn8{0};
224 
226  quint32 rcOutTime{0};
227 
229  quint16 rcOut1{0};
230 
232  quint16 rcOut2{0};
233 
235  quint16 rcOut3{0};
236 
238  quint16 rcOut4{0};
239 
241  quint16 rcOut5{0};
242 
244  quint16 rcOut6{0};
245 
247  quint16 rcOut7{0};
248 
250  quint16 rcOut8{0};
251 
253  std::vector<float> rioData;
254 
256 
259  quint32 uadcId{0};
260 
262 
267  float iasMps{0};
268 
270 
273  float aoaDeg{0};
274 
276 
279  float aosDeg{0};
280 
282  quint16 altM{0};
283 
285  quint32 ptPa{0};
286 
288  quint32 psPa{0};
289 
291 
295  quint64 gpsTimeNs{0};
296 
298 
302  float eulerDeg[3] = {0};
303 
305 
312  float quaternion[4]{0};
313 
315 
319  float angularRatesRPS[3]{0};
320 
322 
329  float posDegDegM[3]{0};
330 
332 
336  float velNedMps[3]{0};
337 
339 
343  float accelMps2[3]{0};
344 };
345 
346 
347 }; // namespace dfti
Logger(Settings *_settings, QObject *_parent=nullptr)
Constructor.
Definition: logger.cc:18
void flush(void)
Slot to flush the data buffer.
Definition: logger.cc:90
DFTI constants.
~Logger()
Dtor.
Definition: logger.cc:31
void getAPData(APData data)
Slot to receive data from the autopilot.
Definition: logger.cc:108
Structure to hold uADC data.
Definition: uadc.hh:68
MAVLink-supporting autopilot interface.
void start(void)
Start logging.
Definition: logger.cc:76
Aeroprobe Micro Air Data Computer interface.
void gpsAvailable(bool flag)
Slot to see if GPS is available.
Definition: logger.cc:184
QPointer Utility functions.
Definition: autopilot.cc:12
void getRIOData(RIOData data)
Slot to receive data from the RIO.
Definition: logger.cc:136
Receives data and logs to file.
Definition: logger.hh:37
void enableVN200(VN200 *ins)
Enable VN-200 INS Sensor.
Definition: logger.cc:66
void writeData(void)
Slot to write data.
Definition: logger.cc:221
Settings manager.
Definition: settings.hh:30
Serial driver to acquire data from a generic Remote I/O device.
Definition: rio.hh:67
Serial driver to acquire data from a VN-200 Inertial Navigation System.
Definition: vn200.hh:115
Structure to hold control effector data.
Definition: rio.hh:52
void enableRIO(RIO *rio)
Enable Remote I/O unit.
Definition: logger.cc:48
Structure to hold autopilot data.
Definition: autopilot.hh:32
VectorNav VN-200 Inertial Navigation System interface.
void getUADCData(uADCData data)
Slot to receive data from the Micro Air Data Computer.
Definition: logger.cc:147
Structure to hold VN-200 data.
Definition: vn200.hh:38
DFTI settings manager interface.
Serial driver to acquire data from a MAVLink-based autopilot.
Definition: autopilot.hh:74
void enableAutopilot(Autopilot *ap)
Enable Autopilot Sensor.
Definition: logger.cc:39
void enableUADC(uADC *adc)
Enable Micro Air Data Computer Sensor.
Definition: logger.cc:57
void getVN200Data(VN200Data data)
Slot to receive data from the VN-200 INS.
Definition: logger.cc:164
Utility functions.
Remote I/O logging interface.
Serial driver to acquire data from a Micro Air Data Computer.
Definition: uadc.hh:115