Developmental Flight Test Instrumentation
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 "rio/rio.hh"
26 #include "settings/settings.hh"
27 #include "uadc/uadc.hh"
28 #include "util/util.hh"
29 #include "vn200/vn200.hh"
30 
31 
32 namespace dfti {
33 
34 
36 class Logger : public QObject
37 {
38  Q_OBJECT;
39 
40 public:
42 
46  explicit Logger(Settings *_settings, QObject* _parent = nullptr);
47 
49  ~Logger();
50 
52 
55  void enableAutopilot(Autopilot *ap);
56 
58 
61  void enableUADC(uADC *adc);
62 
64 
67  void enableRIO(RIO *rio);
68 
70 
73  void enableVN200(VN200 *ins);
74 
76 
79  void start(void);
80 
81 public slots:
83  void flush(void);
84 
86  void getAPData(APData data);
87 
89  void getRIOData(RIOData data);
90 
92  void getUADCData(uADCData data);
93 
95  void getVN200Data(VN200Data data);
96 
98  void gpsAvailable(bool flag);
99 
101  void writeData(void);
102 
103 private:
105 
111  void openLogFile(QFile &fd, bool &flag, QString type, QString timestamp);
112 
114  bool logAP(void);
115 
117  bool logRIO(void);
118 
120  bool logUADC(void);
121 
123  bool logVN200(void);
124 
126  Settings *settings{nullptr};
127 
129  QTimer *writeTimer{nullptr};
130 
132  QTimer *flushTimer{nullptr};
133 
135  QString timestamp{""};
136 
138  const QString delim{","};
139 
141  bool haveAP{false};
142 
144  bool haveRIO{false};
145 
147  bool haveUADC{false};
148 
150  bool haveVN200{false};
151 
153  bool apLogFileOpen{false};
154 
156  bool rioLogFileOpen{false};
157 
159  bool uADCLogFileOpen{false};
160 
162  bool vn200LogFileOpen{false};
163 
165  bool firstWrite{true};
166 
168  bool newAPData{false};
169 
171  bool newRIOData{false};
172 
174  bool newUADCData{false};
175 
177  bool newVN200Data{false};
178 
180  bool haveGPS{false};
181 
183  bool setSystemTime{false};
184 
186  QFile apLogFile;
187 
189  QFile rioLogFile;
190 
192  QFile uADCLogFile;
193 
195  QFile vn200LogFile;
196 
198  quint32 rcInTime{0};
199 
201  quint16 rcIn1{0};
202 
204  quint16 rcIn2{0};
205 
207  quint16 rcIn3{0};
208 
210  quint16 rcIn4{0};
211 
213  quint16 rcIn5{0};
214 
216  quint16 rcIn6{0};
217 
219  quint16 rcIn7{0};
220 
222  quint16 rcIn8{0};
223 
225  quint32 rcOutTime{0};
226 
228  quint16 rcOut1{0};
229 
231  quint16 rcOut2{0};
232 
234  quint16 rcOut3{0};
235 
237  quint16 rcOut4{0};
238 
240  quint16 rcOut5{0};
241 
243  quint16 rcOut6{0};
244 
246  quint16 rcOut7{0};
247 
249  quint16 rcOut8{0};
250 
252  std::vector<float> rioData;
253 
255 
258  quint32 uadcId{0};
259 
261 
266  float iasMps{0};
267 
269 
272  float aoaDeg{0};
273 
275 
278  float aosDeg{0};
279 
281  quint16 altM{0};
282 
284  quint32 ptPa{0};
285 
287  quint32 psPa{0};
288 
290 
294  quint64 gpsTimeNs{0};
295 
297 
301  float eulerDeg[3] = {0};
302 
304 
311  float quaternion[4]{0};
312 
314 
318  float angularRatesRPS[3]{0};
319 
321 
328  float posDegDegM[3]{0};
329 
331 
335  float velNedMps[3]{0};
336 
338 
342  float accelMps2[3]{0};
343 };
344 
345 
346 }; // 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:98
DFTI constants.
~Logger()
Dtor.
Definition: logger.cc:31
void getAPData(APData data)
Slot to receive data from the autopilot.
Definition: logger.cc:116
Structure to hold uADC data.
Definition: uadc.hh:69
MAVLink-supporting autopilot interface.
void start(void)
Start logging.
Definition: logger.cc:84
Aeroprobe Micro Air Data Computer interface.
void gpsAvailable(bool flag)
Slot to see if GPS is available.
Definition: logger.cc:192
Definition: autopilot.cc:12
void getRIOData(RIOData data)
Slot to receive data from the RIO.
Definition: logger.cc:144
Receives data and logs to file.
Definition: logger.hh:36
void enableVN200(VN200 *ins)
Enable VN-200 INS Sensor.
Definition: logger.cc:74
void writeData(void)
Slot to write data.
Definition: logger.cc:229
Settings manager.
Definition: settings.hh:30
Serial driver to acquire data from a generic Remote I/O device.
Definition: rio.hh:68
Serial driver to acquire data from a VN-200 Inertial Navigation System.
Definition: vn200.hh:116
Structure to hold control effector data.
Definition: rio.hh:53
void enableRIO(RIO *rio)
Enable Remote I/O unit.
Definition: logger.cc:56
Structure to hold autopilot data.
Definition: autopilot.hh:33
VectorNav VN-200 Inertial Navigation System interface.
void getUADCData(uADCData data)
Slot to receive data from the Micro Air Data Computer.
Definition: logger.cc:155
Structure to hold VN-200 data.
Definition: vn200.hh:39
DFTI settings manager interface.
Serial driver to acquire data from a MAVLink-based autopilot.
Definition: autopilot.hh:75
void enableAutopilot(Autopilot *ap)
Enable Autopilot Sensor.
Definition: logger.cc:47
void enableUADC(uADC *adc)
Enable Micro Air Data Computer Sensor.
Definition: logger.cc:65
void getVN200Data(VN200Data data)
Slot to receive data from the VN-200 INS.
Definition: logger.cc:172
Utility functions.
Remote I/O logging interface.
Serial driver to acquire data from a Micro Air Data Computer.
Definition: uadc.hh:116