dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
loggingplugin.h
Go to the documentation of this file.
1 
11 /*
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20  * for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, see <http://www.gnu.org/licenses/>
24  */
25 
26 #ifndef LOGGINGPLUGIN_H_
27 #define LOGGINGPLUGIN_H_
28 
29 #include <coreplugin/icore.h>
32 #include <coreplugin/iconnection.h>
35 #include "gcstelemetrystats.h"
36 #include "loggingdevice.h"
37 #include <uavtalk/uavtalk.h>
38 #include <logfile.h>
39 
40 #include <QThread>
41 #include <QQueue>
42 #include <QReadWriteLock>
43 
44 class LoggingPlugin;
46 
53 {
54  Q_OBJECT
55 public:
57  virtual ~LoggingConnection();
58 
60  virtual QIODevice *openDevice(Core::IDevice *deviceName);
61  virtual void closeDevice(const QString &deviceName);
62 
63  virtual QString connectionName();
64  virtual QString shortName();
65 
66  bool deviceOpened() { return m_deviceOpened; }
67  LogFile *getLogfile() { return &logFile; }
68 
69 private:
70  LogFile logFile;
71  LoggingDevice logDevice;
72 
73 protected slots:
74  void onEnumerationChanged();
75  void startReplay(QString file);
76 
77 protected:
79 };
80 
81 class LoggingThread : public QThread
82 {
83  Q_OBJECT
84 public:
86  bool openFile(QString file, LoggingPlugin *parent);
87 
88 private slots:
89  void objectUpdated(UAVObject *obj);
90  void transactionCompleted(UAVObject *obj, bool success);
91 
92 public slots:
93  void stopLogging();
94 
95 protected:
96  void run();
97  QReadWriteLock lock;
100 
101 private:
102  QQueue<UAVDataObject *> queue;
103 
104  void retrieveSettings();
105  void retrieveNextObject();
106 };
107 
109 {
110  Q_OBJECT
111  Q_PLUGIN_METADATA(IID "org.dronin.plugins.LoggingGadget")
112 
113 public:
114  LoggingPlugin();
115  ~LoggingPlugin();
116 
117  void extensionsInitialized();
118  bool initialize(const QStringList &arguments, QString *errorString);
119  void shutdown();
120 
121  LoggingConnection *getLogConnection() { return logConnection; }
122  LogFile *getLogfile() { return logConnection->getLogfile(); }
123  void setLogMenuTitle(QString str);
124 
125 signals:
126  void stopLoggingSignal(void);
127  void stopReplaySignal(void);
128  void stateChanged(QString);
129 
130 protected:
131  enum { IDLE, LOGGING, REPLAY } state;
133 
134  // These are used for replay, logging in its own thread
136 
137 private slots:
138  void downloadLog();
139  void toggleLogging();
140  void startLogging(QString file);
141  void stopLogging();
142  void loggingStopped();
143  void replayStarted();
144  void replayStopped();
145 
146 private:
148  Core::Command *cmdLogging;
149  Core::Command *cmdDownload;
150 };
151 #endif /* LoggingPLUGIN_H_ */
152 
~LoggingThread()
LoggingThread::~LoggingThread Destructor.
virtual QList< Core::IDevice * > availableDevices()
virtual QIODevice * openDevice(Core::IDevice *deviceName)
LogFile logFile
Definition: loggingplugin.h:98
void stateChanged(QString)
LoggingThread * loggingThread
void startReplay(QString file)
Plugin for generating a logfile.
UAVTalk * uavTalk
Definition: loggingplugin.h:99
virtual QString shortName()
enum LoggingPlugin::@8 state
Parse log file
virtual void closeDevice(const QString &deviceName)
LogFile * getLogfile()
Definition: loggingplugin.h:67
void stopLoggingSignal(void)
void stopReplaySignal(void)
LoggingConnection * logConnection
QReadWriteLock lock
Definition: loggingplugin.h:97
virtual QString connectionName()
virtual ~LoggingConnection()
bool openFile(QString file, LoggingPlugin *parent)
The class Command represents an action like a menu item, tool button, or shortcut. You don't create Command objects directly, instead use {ActionManager::registerAction()} to register an action and retrieve a Command. The Command object represents the user visible action and its properties. If multiple actions are registered with the same ID (but different contexts) the returned Command is the shared one between these actions.
Definition: command.h:43
Base class for all plugins.
Definition: iplugin.h:45