Commit b42a36a8 authored by Don Gagne's avatar Don Gagne

Create base interface for UASManager and QGCUASParamManager

This allows us to create mock version of the objects to use for unit
tests
parent f566744a
......@@ -8,7 +8,7 @@
#include "UASParameterCommsMgr.h"
QGCUASParamManager::QGCUASParamManager(QObject *parent) :
QObject(parent),
QGCUASParamManagerInterface(parent),
mav(NULL),
paramDataModel(this),
paramCommsMgr(NULL)
......
......@@ -7,13 +7,14 @@
#include <QVariant>
#include "UASParameterDataModel.h"
#include "QGCUASParamManagerInterface.h"
//forward declarations
class QTextStream;
class UASInterface;
class UASParameterCommsMgr;
class QGCUASParamManager : public QObject
class QGCUASParamManager : public QGCUASParamManagerInterface
{
Q_OBJECT
public:
......
#ifndef QGCUASPARAMMANAGERINTERFACE_H
#define QGCUASPARAMMANAGERINTERFACE_H
#include <QWidget>
#include <QMap>
#include <QTimer>
#include <QVariant>
#include <QTextStream>
#include "UASParameterDataModel.h"
/**
* @brief This is the abstract base class for QGCUASParamManager. Although there is
* normally only a single QGCUASParamManager we still use an abstract base interface
* since this allows us to create mock versions.
*
* See QGCUASParamManager.h for method documentation
**/
//forward declarations
class QTextStream;
class UASInterface;
class UASParameterCommsMgr;
class QGCUASParamManagerInterface : public QObject
{
public:
QGCUASParamManagerInterface(QObject* parent = NULL) : QObject(parent) { }
virtual bool getParameterValue(int component, const QString& parameter, QVariant& value) const = 0;
virtual int getDefaultComponentId() = 0;
virtual QList<int> getComponentForParam(const QString& parameter) const = 0;
virtual void setParamDescriptions(const QMap<QString,QString>& paramDescs) = 0;
virtual int countPendingParams() = 0;
virtual int countOnboardParams() = 0;
virtual UASParameterDataModel* dataModel() = 0;
public slots:
virtual void setParameter(int component, QString parameterName, QVariant value) = 0;
virtual void sendPendingParameters(bool persistAfterSend = false, bool forceSend = false) = 0;
virtual void requestParameterList() = 0;
virtual void requestParameterListIfEmpty() = 0;
virtual void setPendingParam(int componentId, const QString& key, const QVariant& value, bool forceSend = false) = 0;
virtual void clearAllPendingParams() = 0;
virtual void requestParameterUpdate(int component, const QString& parameter) = 0;
virtual void writeOnboardParamsToStream(QTextStream &stream, const QString& uasName) = 0;
virtual void readPendingParamsFromStream(QTextStream &stream) = 0;
virtual void requestRcCalibrationParamsUpdate() = 0;
virtual void copyVolatileParamsToPersistent() = 0;
virtual void copyPersistentParamsToVolatile() = 0;
signals:
void parameterStatusMsgUpdated(QString msg, int level);
void parameterListUpToDate();
void parameterUpdated(int compId, QString paramName, QVariant value);
void pendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending);
};
#endif // QGCUASPARAMMANAGER_H
......@@ -22,8 +22,20 @@
#define MEAN_EARTH_DIAMETER 12756274.0
#define UMR 0.017453292519943295769236907684886
UASManager* UASManager::instance()
UASManagerInterface* UASManager::_mockUASManager = NULL;
void UASManager::setMockUASManager(UASManagerInterface* mockUASManager)
{
_mockUASManager = mockUASManager;
}
UASManagerInterface* UASManager::instance()
{
if (_mockUASManager) {
return _mockUASManager;
}
static UASManager* _instance = 0;
if(_instance == 0) {
_instance = new UASManager();
......
......@@ -31,6 +31,7 @@ This file is part of the QGROUNDCONTROL project
#ifndef _UASMANAGER_H_
#define _UASMANAGER_H_
#include "UASManagerInterface.h"
#include <QThread>
#include <QList>
#include <QMutex>
......@@ -44,13 +45,18 @@ This file is part of the QGROUNDCONTROL project
* This class keeps a list of all connected / configured UASs. It also stores which
* UAS is currently select with respect to user input or manual controls.
**/
class UASManager : public QObject
class UASManager : public UASManagerInterface
{
Q_OBJECT
public:
static UASManager* instance();
static UASManagerInterface* instance();
~UASManager();
/**
* @brief Sets a mock UASManager to be returned when a call is made to instance()
**/
static void setMockUASManager(UASManagerInterface* mockUASManager);
/**
* @brief Get the currently selected UAS
......@@ -265,6 +271,9 @@ protected:
Eigen::Vector3d nedSafetyLimitPosition2;
void initReference(const double & latitude, const double & longitude, const double & altitude);
private:
static UASManagerInterface* _mockUASManager;
signals:
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2011 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Definition of class UASManager
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef _UASMANAGERINTERFACE_H_
#define _UASMANAGERINTERFACE_H_
#include <QThread>
#include <QList>
#include <QMutex>
#include <UASInterface.h>
#include "../../libs/eigen/Eigen/Eigen"
#include "QGCGeo.h"
/**
* @brief Central manager for all connected aerial vehicles
*
* This class keeps a list of all connected / configured UASs. It also stores which
* UAS is currently select with respect to user input or manual controls.
*
* This is the abstract base class for UASManager. Although there is normally only
* a single UASManger we still use a abstract base interface since this allows us
* to create mock versions of the UASManager for testing purposes.
*
* See UASManager.h for method documentation
**/
class UASManagerInterface : public QObject
{
Q_OBJECT
public:
virtual UASInterface* getActiveUAS() = 0;
virtual UASWaypointManager *getActiveUASWaypointManager() = 0;
virtual UASInterface* silentGetActiveUAS() = 0;
virtual UASInterface* getUASForId(int id) = 0;
virtual QList<UASInterface*> getUASList() = 0;
virtual double getHomeLatitude() const = 0;
virtual double getHomeLongitude() const = 0;
virtual double getHomeAltitude() const = 0;
virtual int getHomeFrame() const = 0;
virtual Eigen::Vector3d wgs84ToEcef(const double & latitude, const double & longitude, const double & altitude) = 0;
virtual Eigen::Vector3d ecefToEnu(const Eigen::Vector3d & ecef) = 0;
virtual void wgs84ToEnu(const double& lat, const double& lon, const double& alt, double* east, double* north, double* up) = 0;
virtual void enuToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt) = 0;
virtual void nedToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt) = 0;
virtual void getLocalNEDSafetyLimits(double* x1, double* y1, double* z1, double* x2, double* y2, double* z2) = 0;
virtual bool isInLocalNEDSafetyLimits(double x, double y, double z) = 0;
public slots:
virtual void addUAS(UASInterface* UAS) = 0;
virtual void removeUAS(UASInterface* uas) = 0;
virtual void setActiveUAS(UASInterface* UAS) = 0;
virtual bool launchActiveUAS() = 0;
virtual bool haltActiveUAS() = 0;
virtual bool continueActiveUAS() = 0;
virtual bool returnActiveUAS() = 0;
virtual bool stopActiveUAS() = 0;
virtual bool killActiveUAS() = 0;
virtual void configureActiveUAS() = 0;
virtual bool shutdownActiveUAS() = 0;
virtual bool setHomePosition(double lat, double lon, double alt) = 0;
virtual bool setHomePositionAndNotify(double lat, double lon, double alt) = 0;
virtual void setLocalNEDSafetyBorders(double x1, double y1, double z1, double x2, double y2, double z2) = 0;
virtual void uavChangedHomePosition(int uav, double lat, double lon, double alt) = 0;
virtual void loadSettings() = 0;
virtual void storeSettings() = 0;
signals:
/** A new system was created */
void UASCreated(UASInterface* UAS);
/** A system was deleted */
void UASDeleted(UASInterface* UAS);
/** @brief The UAS currently under main operator control changed */
void activeUASSet(UASInterface* UAS);
/** @brief The UAS currently under main operator control changed */
void activeUASSet(int systemId);
/** @brief The UAS currently under main operator control changed */
void activeUASSetListIndex(int listIndex);
/** @brief The UAS currently under main operator control changed */
void activeUASStatusChanged(UASInterface* UAS, bool active);
/** @brief The UAS currently under main operator control changed */
void activeUASStatusChanged(int systemId, bool active);
/** @brief Current home position changed */
void homePositionChanged(double lat, double lon, double alt);
};
#endif // _UASMANAGERINTERFACE_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment