2 ******************************************************************************
3 * @file loggingplugin.h
4 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
5 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @see The GNU Public License (GPL) Version 3
7 * @addtogroup GCSPlugins GCS Plugins
9 * @addtogroup loggingplugin
11 *****************************************************************************/
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.
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
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef LOGGINGPLUGIN_H_
29 #define LOGGINGPLUGIN_H_
31 #include <coreplugin/icore.h>
32 #include <coreplugin/coreconstants.h>
33 #include <coreplugin/iconnection.h>
34 #include <extensionsystem/iplugin.h>
35 #include <utils/logfile.h>
39 #include <QReadWriteLock>
45 class LoggingGadgetFactory
;
52 * Define a connection via the IConnection interface
53 * Plugin will add a instance of this class to the pool,
54 * so the connection manager can use it.
56 class LoggingConnection
: public Core::IConnection
{
60 virtual ~LoggingConnection();
62 virtual QList
<Core::IConnection::device
> availableDevices();
64 virtual QIODevice
*openDevice(const QString
&deviceName
);
65 virtual void closeDevice(const QString
&deviceName
);
67 virtual QString
connectionName();
68 virtual QString
shortName();
72 return m_deviceOpened
;
84 class LoggingThread
: public QThread
{
88 virtual ~LoggingThread();
90 bool openFile(QString file
);
100 void objectUpdated(UAVObject
*obj
);
101 void transactionCompleted(UAVObject
*obj
, bool success
);
105 QQueue
<UAVDataObject
*> queue
;
109 void retrieveSettings();
110 void retrieveNextObject();
113 class LoggingPlugin
: public ExtensionSystem::IPlugin
{
115 Q_PLUGIN_METADATA(IID
"OpenPilot.Logging")
117 friend class LoggingConnection
;
120 enum State
{ IDLE
, LOGGING
, REPLAY
};
125 void extensionsInitialized();
126 bool initialize(const QStringList
& arguments
, QString
*errorString
);
129 LogFile
*getLogfile()
131 return logConnection
->getLogfile();
140 void stateChanged(State
);
143 void toggleLogging();
144 void startLogging(QString file
);
146 void loggingStarted();
147 void loggingStopped();
148 void replayStarted();
149 void replayStopped();
152 Core::Command
*loggingCommand
;
154 // These are used for replay, logging in its own thread
155 LoggingThread
*loggingThread
;
156 LoggingConnection
*logConnection
;
158 #endif /* LoggingPLUGIN_H_ */