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_
|
|
|
|
|
|
|
|
#include <extensionsystem/iplugin.h>
|
|
|
|
#include <uavobjects/uavobjectmanager.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>
|
|
|
|
#include <QReadWriteLock>
|
|
|
|
|
|
|
|
class LoggingPlugin;
|
2010-09-21 23:43:23 +02:00
|
|
|
class LoggingGadgetFactory;
|
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);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void stopLogging();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void run();
|
|
|
|
QReadWriteLock lock;
|
2010-09-21 09:07:39 +02:00
|
|
|
LogFile logFile;
|
|
|
|
UAVTalk * uavTalk;
|
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();
|
|
|
|
|
2010-09-21 23:43:23 +02:00
|
|
|
LogFile * getLogfile() { return &logFile; };
|
|
|
|
|
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
|
|
|
|
UAVTalk * uavTalk;
|
2010-09-21 23:43:23 +02:00
|
|
|
LogFile logFile;
|
2010-09-21 21:28:01 +02:00
|
|
|
|
2010-08-31 11:09:16 +02:00
|
|
|
private slots:
|
|
|
|
void toggleLogging();
|
2010-09-21 21:28:01 +02:00
|
|
|
void toggleReplay();
|
2010-08-31 11:09:16 +02:00
|
|
|
void startLogging(QString file);
|
2010-09-21 21:28:01 +02:00
|
|
|
void startReplay(QString file);
|
2010-08-31 11:09:16 +02:00
|
|
|
void stopLogging();
|
|
|
|
void loggingStopped();
|
2010-09-22 03:04:24 +02:00
|
|
|
void replayStopped();
|
2010-09-21 23:43:23 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
LoggingGadgetFactory *mf;
|
2010-08-31 11:09:16 +02:00
|
|
|
};
|
|
|
|
#endif /* LoggingPLUGIN_H_ */
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
* @}
|
|
|
|
*/
|