2010-08-31 11:09:16 +02:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* @file loggingplugin.h
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
* @addtogroup GCSPlugins GCS Plugins
|
|
|
|
* @{
|
|
|
|
* @addtogroup loggingplugin
|
|
|
|
* @{
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LOGGINGPLUGIN_H_
|
|
|
|
#define LOGGINGPLUGIN_H_
|
|
|
|
|
2011-03-13 22:23:26 +01:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2011-01-20 23:28:38 +01:00
|
|
|
#include <coreplugin/iconnection.h>
|
2010-08-31 11:09:16 +02:00
|
|
|
#include <extensionsystem/iplugin.h>
|
2011-01-22 18:38:22 +01:00
|
|
|
#include "uavobjectmanager.h"
|
|
|
|
#include "gcstelemetrystats.h"
|
2010-09-21 09:07:39 +02:00
|
|
|
#include <uavtalk/uavtalk.h>
|
|
|
|
#include <logfile.h>
|
|
|
|
|
2010-08-31 11:09:16 +02:00
|
|
|
#include <QThread>
|
2010-12-04 17:47:55 +01:00
|
|
|
#include <QQueue>
|
2010-08-31 11:09:16 +02:00
|
|
|
#include <QReadWriteLock>
|
|
|
|
|
|
|
|
class LoggingPlugin;
|
2010-09-21 23:43:23 +02:00
|
|
|
class LoggingGadgetFactory;
|
2010-08-31 11:09:16 +02:00
|
|
|
|
2011-01-20 23:28:38 +01:00
|
|
|
/**
|
|
|
|
* Define a connection via the IConnection interface
|
|
|
|
* Plugin will add a instance of this class to the pool,
|
|
|
|
* so the connection manager can use it.
|
|
|
|
*/
|
|
|
|
class LoggingConnection
|
|
|
|
: public Core::IConnection
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
LoggingConnection();
|
|
|
|
virtual ~LoggingConnection();
|
|
|
|
|
2011-03-29 20:25:24 +02:00
|
|
|
virtual QList <Core::IConnection::device> availableDevices();
|
2011-01-20 23:28:38 +01:00
|
|
|
virtual QIODevice *openDevice(const QString &deviceName);
|
|
|
|
virtual void closeDevice(const QString &deviceName);
|
|
|
|
|
|
|
|
virtual QString connectionName();
|
|
|
|
virtual QString shortName();
|
|
|
|
|
|
|
|
bool deviceOpened() {return m_deviceOpened;}
|
2011-01-22 09:37:25 +01:00
|
|
|
LogFile* getLogfile() { return &logFile;}
|
2011-01-20 23:28:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
LogFile logFile;
|
|
|
|
|
|
|
|
|
|
|
|
protected slots:
|
|
|
|
void onEnumerationChanged();
|
|
|
|
void startReplay(QString file);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_deviceOpened;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-31 11:09:16 +02:00
|
|
|
class LoggingThread : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
bool openFile(QString file, LoggingPlugin * parent);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void objectUpdated(UAVObject * obj);
|
2010-12-04 17:47:55 +01:00
|
|
|
void transactionCompleted(UAVObject* obj, bool success);
|
2010-08-31 11:09:16 +02:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void stopLogging();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void run();
|
|
|
|
QReadWriteLock lock;
|
2010-09-21 09:07:39 +02:00
|
|
|
LogFile logFile;
|
|
|
|
UAVTalk * uavTalk;
|
2010-12-04 17:47:55 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
QQueue<UAVDataObject*> queue;
|
|
|
|
|
|
|
|
void retrieveSettings();
|
|
|
|
void retrieveNextObject();
|
|
|
|
|
2010-08-31 11:09:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class LoggingPlugin : public ExtensionSystem::IPlugin
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
LoggingPlugin();
|
|
|
|
~LoggingPlugin();
|
|
|
|
|
|
|
|
void extensionsInitialized();
|
|
|
|
bool initialize(const QStringList & arguments, QString * errorString);
|
|
|
|
void shutdown();
|
|
|
|
|
2011-01-22 09:37:25 +01:00
|
|
|
LoggingConnection* getLogConnection() { return logConnection; };
|
|
|
|
LogFile* getLogfile() { return logConnection->getLogfile();}
|
2011-03-13 22:23:26 +01:00
|
|
|
void setLogMenuTitle(QString str);
|
2011-01-22 09:37:25 +01:00
|
|
|
|
2010-09-21 23:43:23 +02:00
|
|
|
|
2010-08-31 11:09:16 +02:00
|
|
|
signals:
|
|
|
|
void stopLoggingSignal(void);
|
2010-09-21 21:28:01 +02:00
|
|
|
void stopReplaySignal(void);
|
2010-09-21 23:43:23 +02:00
|
|
|
void stateChanged(QString);
|
|
|
|
|
2010-08-31 11:09:16 +02:00
|
|
|
|
|
|
|
protected:
|
2010-09-21 21:28:01 +02:00
|
|
|
enum {IDLE, LOGGING, REPLAY} state;
|
2010-08-31 11:09:16 +02:00
|
|
|
LoggingThread * loggingThread;
|
|
|
|
|
2010-09-21 21:28:01 +02:00
|
|
|
// These are used for replay, logging in its own thread
|
2011-03-13 23:27:26 +01:00
|
|
|
LoggingConnection* logConnection;
|
2010-09-21 21:28:01 +02:00
|
|
|
|
2010-08-31 11:09:16 +02:00
|
|
|
private slots:
|
|
|
|
void toggleLogging();
|
|
|
|
void startLogging(QString file);
|
|
|
|
void stopLogging();
|
|
|
|
void loggingStopped();
|
2011-03-13 23:27:26 +01:00
|
|
|
void replayStarted();
|
2010-09-22 03:04:24 +02:00
|
|
|
void replayStopped();
|
2010-09-21 23:43:23 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
LoggingGadgetFactory *mf;
|
2011-03-13 22:23:26 +01:00
|
|
|
Core::Command* cmd;
|
2010-12-04 17:47:55 +01:00
|
|
|
|
2010-08-31 11:09:16 +02:00
|
|
|
};
|
|
|
|
#endif /* LoggingPLUGIN_H_ */
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
* @}
|
|
|
|
*/
|