dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
telemetrymonitor.h
Go to the documentation of this file.
1 
16 /*
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation; either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful, but
23  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25  * for more details.
26  *
27  * You should have received a copy of the GNU General Public License along
28  * with this program; if not, see <http://www.gnu.org/licenses/>
29  *
30  * Additional note on redistribution: The copyright and license notices above
31  * must be maintained in each individual source file that is a derivative work
32  * of this source file; otherwise redistribution is prohibited.
33  */
34 
35 #ifndef TELEMETRYMONITOR_H
36 #define TELEMETRYMONITOR_H
37 
38 #include <queue>
39 
40 #include <QObject>
41 #include <QTimer>
42 #include <QTime>
44 #include "gcstelemetrystats.h"
45 #include "flighttelemetrystats.h"
46 #include "systemstats.h"
47 #include "telemetry.h"
50 
51 class TelemetryMonitor : public QObject
52 {
53  Q_OBJECT
54 
55 public:
56  struct objStruc
57  {
58  quint32 objID;
59  quint32 instID;
60  };
61 
64 
65 signals:
66  void connected();
67  void disconnected();
68  void telemetryUpdated(double txRate, double rxRate);
69 
70 public slots:
71  void transactionCompleted(UAVObject *obj, bool success, bool nacked);
72  void processStatsUpdates();
73  void flightStatsUpdated(UAVObject *obj);
74 private slots:
75  void objectRetrieveTimeoutCB();
76  void newInstanceSlot(UAVObject *);
77 
78 private:
79  static const int STATS_UPDATE_PERIOD_MS = 1600;
80  static const int STATS_CONNECT_PERIOD_MS = 350;
81  static const int CONNECTION_TIMEOUT_MS = 8000;
82  static const int MAX_REQUESTS_IN_FLIGHT = 3;
83  enum connectionStatusEnum {
84  CON_DISCONNECTED,
85  CON_INITIALIZING,
86  CON_RETRIEVING_OBJECTS,
87  CON_CONNECTED_MANAGED
88  };
89 
90  typedef bool (*queueCompareFunc)(UAVObject *, UAVObject *);
91  static bool queueCompare(UAVObject *left, UAVObject *right);
92  connectionStatusEnum connectionStatus;
93  UAVObjectManager *objMngr;
94  Telemetry *tel;
95  std::priority_queue<UAVObject *, std::vector<UAVObject *>, queueCompareFunc> queue;
96  GCSTelemetryStats *gcsStatsObj;
97  FlightTelemetryStats *flightStatsObj;
98  QTimer *statsTimer;
99  QTime *connectionTimer;
100  QTimer *objectRetrieveTimeout;
101  int requestsInFlight;
102 
103  void startRetrievingObjects();
104  void retrieveNextObject();
105 };
106 
107 #endif // TELEMETRYMONITOR_H
void transactionCompleted(UAVObject *obj, bool success, bool nacked)
TelemetryMonitor(UAVObjectManager *objMngr, Telemetry *tel)
void flightStatsUpdated(UAVObject *obj)
void telemetryUpdated(double txRate, double rxRate)