Commit 9d42f680 authored by Lorenz Meier's avatar Lorenz Meier

Merge pull request #450 from DonLakeFlyer/UnitTestMocks

Unit test mocks
parents f566744a ac6e12a1
......@@ -511,7 +511,9 @@ HEADERS += src/MG.h \
src/ui/px4_configuration/QGCPX4MulticopterConfig.h \
src/ui/px4_configuration/QGCPX4SensorCalibration.h \
src/ui/designer/QGCXYPlot.h \
src/ui/menuactionhelper.h
src/ui/menuactionhelper.h \
src/uas/UASManagerInterface.h \
src/uas/QGCUASParamManagerInterface.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h
......@@ -746,10 +748,16 @@ CONFIG(debug, debug|release) {
HEADERS += \
src/qgcunittest/AutoTest.h \
src/qgcunittest/UASUnitTest.h
src/qgcunittest/UASUnitTest.h \
src/qgcunittest/MockUASManager.h \
src/qgcunittest/MockUAS.h \
src/qgcunittest/MockQGCUASParamManager.h
SOURCES += \
src/qgcunittest/UASUnitTest.cc
src/qgcunittest/UASUnitTest.cc \
src/qgcunittest/MockUASManager.cc \
src/qgcunittest/MockUAS.cc \
src/qgcunittest/MockQGCUASParamManager.cc
}
# Enable Google Earth only on Mac OS and Windows with Visual Studio compiler
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 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/>.
======================================================================*/
#include "MockQGCUASParamManager.h"
#include <QTest>
#include <QDebug>
MockQGCUASParamManager::MockQGCUASParamManager(void)
{
}
bool MockQGCUASParamManager::getParameterValue(int component, const QString& parameter, QVariant& value) const
{
Q_UNUSED(component);
if (_mapParams.contains(parameter)) {
value = _mapParams[parameter];
}
return false;
}
void MockQGCUASParamManager::setParameter(int component, QString parameterName, QVariant value)
{
Q_UNUSED(component);
_mapParamsSet[parameterName] = value;
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 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/>.
======================================================================*/
#ifndef MOCKQGCUASPARAMMANAGER_H
#define MOCKQGCUASPARAMMANAGER_H
#include "QGCUASParamManagerInterface.h"
/// @file
/// @brief This is a mock implementation of QGCUASParamManager for writing Unit Tests.
///
/// @author Don Gagne <don@thegagnes.com>
class MockQGCUASParamManager : public QGCUASParamManagerInterface
{
Q_OBJECT
signals:
// The following QGCSUASParamManagerInterface signals are supported
// currently none
public:
// Implemented QGCSUASParamManager overrides
virtual bool getParameterValue(int component, const QString& parameter, QVariant& value) const;
virtual int getDefaultComponentId(void) { return 0; }
virtual int countOnboardParams(void) { return _mapParams.count(); }
public slots:
// Implemented QGCSUASParamManager overrides
void setParameter(int component, QString parameterName, QVariant value);
public:
// MockQGCUASParamManager methods
MockQGCUASParamManager(void);
/// QMap of parameters, QString key is paremeter name, QVariant value is parameter value
typedef QMap<QString, QVariant> ParamMap_t;
/// Sets current set of parameters to support calls like getParameterValue
void setMockParameters(ParamMap_t& map) { _mapParams = map; }
/// Returns the parameters which were set by calls to setParameter calls
ParamMap_t getMockSetParameters(void) { return _mapParamsSet; }
/// Clears the set of parameters set by setParameter calls
void clearMockSetParameters(void) { _mapParamsSet.clear(); }
public:
// Unimplemented QGCUASParamManagerInterface overrides
virtual QList<int> getComponentForParam(const QString& parameter) const { Q_ASSERT(false); Q_UNUSED(parameter); return _bogusQListInt; }
virtual void setParamDescriptions(const QMap<QString,QString>& paramDescs) { Q_ASSERT(false); Q_UNUSED(paramDescs); }
virtual int countPendingParams() { Q_ASSERT(false); return 0; }
virtual UASParameterDataModel* dataModel() { Q_ASSERT(false); return NULL; }
public slots:
// Unimplemented QGCUASParamManagerInterface overrides
virtual void sendPendingParameters(bool persistAfterSend = false, bool forceSend = false)
{ Q_ASSERT(false); Q_UNUSED(persistAfterSend); Q_UNUSED(forceSend); }
virtual void requestParameterList() { Q_ASSERT(false); }
virtual void requestParameterListIfEmpty() { Q_ASSERT(false); }
virtual void setPendingParam(int componentId, const QString& key, const QVariant& value, bool forceSend = false)
{ Q_ASSERT(false); Q_UNUSED(componentId); Q_UNUSED(key); Q_UNUSED(value); Q_UNUSED(forceSend); }
virtual void clearAllPendingParams() { Q_ASSERT(false); }
virtual void requestParameterUpdate(int component, const QString& parameter)
{ Q_ASSERT(false); Q_UNUSED(component); Q_UNUSED(parameter); }
virtual void writeOnboardParamsToStream(QTextStream &stream, const QString& uasName)
{ Q_ASSERT(false); Q_UNUSED(stream); Q_UNUSED(uasName); }
virtual void readPendingParamsFromStream(QTextStream &stream) { Q_ASSERT(false); Q_UNUSED(stream); }
virtual void requestRcCalibrationParamsUpdate() { Q_ASSERT(false); }
virtual void copyVolatileParamsToPersistent() { Q_ASSERT(false); }
virtual void copyPersistentParamsToVolatile() { Q_ASSERT(false); }
private:
ParamMap_t _mapParams;
ParamMap_t _mapParamsSet;
// Bogus variables used for return types of NYI methods
QList<int> _bogusQListInt;
};
#endif
\ No newline at end of file
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 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/>.
======================================================================*/
#include "MockUAS.h"
QString MockUAS::_bogusStaticString;
MockUAS::MockUAS(void) :
_systemType(MAV_TYPE_QUADROTOR),
_systemId(1)
{
}
void MockUAS::setMockParametersAndSignal(MockQGCUASParamManager::ParamMap_t& map)
{
_paramManager.setMockParameters(map);
QMapIterator<QString, QVariant> i(map);
while (i.hasNext()) {
i.next();
emit parameterChanged(_systemId, 0, i.key(), i.value());
}
}
\ No newline at end of file
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 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/>.
======================================================================*/
#include "MockUASManager.h"
MockUASManager::MockUASManager(void) :
_mockUAS(NULL)
{
}
UASInterface* MockUASManager::getActiveUAS(void)
{
return _mockUAS;
}
void MockUASManager::setMockActiveUAS(MockUAS* mockUAS)
{
// Signal components that the last UAS is no longer active.
if (_mockUAS != NULL) {
emit activeUASStatusChanged(_mockUAS, false);
emit activeUASStatusChanged(_mockUAS->getUASID(), false);
}
_mockUAS = mockUAS;
// And signal that a new UAS is.
emit activeUASSet(_mockUAS);
if (_mockUAS)
{
// We don't support swiching between different UAS
//_mockUAS->setSelected();
emit activeUASSet(_mockUAS->getUASID());
emit activeUASStatusChanged(_mockUAS, true);
emit activeUASStatusChanged(_mockUAS->getUASID(), true);
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 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/>.
======================================================================*/
#ifndef MOCKUASMANAGER_H
#define MOCKUASMANAGER_H
#include "UASManagerInterface.h"
#include "MockUAS.h"
/// @file
/// @brief This is a mock implementation of a UASManager used for writing Unit Tests. In order
/// to use it you must call UASManager::setMockUASManager which will then cause all further
/// calls to UASManager::instance to return the mock UASManager instead of the normal one.
///
/// @author Don Gagne <don@thegagnes.com>
class MockUASManager : public UASManagerInterface
{
Q_OBJECT
signals:
// The following signals from UASManager interface are supported
void activeUASSet(UASInterface* UAS);
void activeUASSet(int systemId);
void activeUASStatusChanged(UASInterface* UAS, bool active);
void activeUASStatusChanged(int systemId, bool active);
public:
// Implemented UASManagerInterface overrides
virtual UASInterface* getActiveUAS(void);
public:
// MockUASManager methods
MockUASManager(void);
/// Sets the currently active mock UAS
/// @param mockUAS new mock uas, NULL for no active UAS
void setMockActiveUAS(MockUAS* mockUAS);
public:
// Unimplemented UASManagerInterface overrides
virtual UASWaypointManager *getActiveUASWaypointManager() { Q_ASSERT(false); return NULL; }
virtual UASInterface* silentGetActiveUAS() { Q_ASSERT(false); return NULL; }
virtual UASInterface* getUASForId(int id) { Q_ASSERT(false); Q_UNUSED(id); return NULL; }
virtual QList<UASInterface*> getUASList() { Q_ASSERT(false); return _bogusQListUASInterface; }
virtual double getHomeLatitude() const { Q_ASSERT(false); return std::numeric_limits<double>::quiet_NaN(); }
virtual double getHomeLongitude() const { Q_ASSERT(false); return std::numeric_limits<double>::quiet_NaN(); }
virtual double getHomeAltitude() const { Q_ASSERT(false); return std::numeric_limits<double>::quiet_NaN(); }
virtual int getHomeFrame() const { Q_ASSERT(false); return 0; }
virtual Eigen::Vector3d wgs84ToEcef(const double & latitude, const double & longitude, const double & altitude)
{ Q_ASSERT(false); Q_UNUSED(latitude); Q_UNUSED(longitude); Q_UNUSED(altitude); return _bogusEigenVector3d; }
virtual Eigen::Vector3d ecefToEnu(const Eigen::Vector3d & ecef)
{ Q_ASSERT(false); Q_UNUSED(ecef); return _bogusEigenVector3d; }
virtual void wgs84ToEnu(const double& lat, const double& lon, const double& alt, double* east, double* north, double* up)
{ Q_ASSERT(false); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); Q_UNUSED(east); Q_UNUSED(north); Q_UNUSED(up); }
virtual void enuToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt)
{ Q_ASSERT(false); Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(z); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); }
virtual void nedToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt)
{ Q_ASSERT(false); Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(z); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); }
virtual void getLocalNEDSafetyLimits(double* x1, double* y1, double* z1, double* x2, double* y2, double* z2)
{ Q_ASSERT(false); Q_UNUSED(x1); Q_UNUSED(y1); Q_UNUSED(z1); Q_UNUSED(x2); Q_UNUSED(y2); Q_UNUSED(z2); }
virtual bool isInLocalNEDSafetyLimits(double x, double y, double z)
{ Q_ASSERT(false); Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(z); return false; }
public slots:
// Unimplemented UASManagerInterface overrides
virtual void setActiveUAS(UASInterface* UAS) { Q_ASSERT(false); Q_UNUSED(UAS); }
virtual void addUAS(UASInterface* UAS) { Q_ASSERT(false); Q_UNUSED(UAS); }
virtual void removeUAS(UASInterface* uas) { Q_ASSERT(false); Q_UNUSED(uas);}
virtual bool launchActiveUAS() { Q_ASSERT(false); return false; }
virtual bool haltActiveUAS() { Q_ASSERT(false); return false; }
virtual bool continueActiveUAS() { Q_ASSERT(false); return false; }
virtual bool returnActiveUAS() { Q_ASSERT(false); return false; }
virtual bool stopActiveUAS() { Q_ASSERT(false); return false; }
virtual bool killActiveUAS() { Q_ASSERT(false); return false; }
virtual void configureActiveUAS() { Q_ASSERT(false); }
virtual bool shutdownActiveUAS() { Q_ASSERT(false); return false; }
virtual bool setHomePosition(double lat, double lon, double alt)
{ Q_ASSERT(false); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); return false; }
virtual bool setHomePositionAndNotify(double lat, double lon, double alt)
{ Q_ASSERT(false); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); return false; }
virtual void setLocalNEDSafetyBorders(double x1, double y1, double z1, double x2, double y2, double z2)
{ Q_ASSERT(false); Q_UNUSED(x1); Q_UNUSED(y1); Q_UNUSED(z1); Q_UNUSED(x2); Q_UNUSED(y2); Q_UNUSED(z2); }
virtual void uavChangedHomePosition(int uav, double lat, double lon, double alt)
{ Q_ASSERT(false); Q_UNUSED(uav); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); }
virtual void loadSettings() { Q_ASSERT(false); }
virtual void storeSettings() { Q_ASSERT(false); }
private:
MockUAS* _mockUAS;
// Bogus variables used for return types of NYI methods
QList<UASInterface*> _bogusQListUASInterface;
Eigen::Vector3d _bogusEigenVector3d;
public:
/* Need to align struct pointer to prevent a memory assertion:
* See http://eigen.tuxfamily.org/dox-devel/TopicUnalignedArrayAssert.html
* for details
*/
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
#endif
\ No newline at end of file
......@@ -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
......@@ -40,6 +40,7 @@ This file is part of the QGROUNDCONTROL project
#include "QGCFlightGearLink.h"
#include "QGCJSBSimLink.h"
#include "QGCXPlaneLink.h"
#include "QGCUASParamManager.h"
/**
......@@ -542,7 +543,7 @@ public:
}
/** @brief Get reference to the param manager **/
virtual QGCUASParamManager* getParamManager() {
virtual QGCUASParamManagerInterface* getParamManager() {
return &paramMgr;
}
......
......@@ -42,7 +42,7 @@ This file is part of the QGROUNDCONTROL project
#include "ProtocolInterface.h"
#include "UASParameterDataModel.h"
#include "UASWaypointManager.h"
#include "QGCUASParamManager.h"
#include "QGCUASParamManagerInterface.h"
#include "RadioCalibration/RadioCalibrationData.h"
#ifdef QGC_PROTOBUF_ENABLED
......@@ -156,7 +156,7 @@ public:
virtual UASWaypointManager* getWaypointManager(void) = 0;
/** @brief Get reference to the param manager **/
virtual QGCUASParamManager* getParamManager() = 0;
virtual QGCUASParamManagerInterface* getParamManager() = 0;
/* COMMUNICATION FLAGS */
......
......@@ -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 - 2014 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_
......@@ -2,7 +2,7 @@
#include <QSettings>
#include "QGCUASParamManager.h"
#include "QGCUASParamManagerInterface.h"
#include "UASInterface.h"
......
......@@ -3,9 +3,9 @@
#include <QFileDialog>
#include <QFile>
#include <QVariant>
#include <QTextStream>>
#include <QTextStream>
#include "QGCUASParamManager.h"
#include "QGCUASParamManagerInterface.h"
#include "UASInterface.h"
......
......@@ -8,7 +8,7 @@
//forward declarations
class QGCUASParamManager;
class QGCUASParamManagerInterface;
class UASInterface;
......@@ -50,7 +50,7 @@ public slots:
virtual void loadParametersFromFile();
protected:
QGCUASParamManager* paramMgr;
QGCUASParamManagerInterface* paramMgr;
UASInterface* mav;
QString updatingParamNameLock; ///< Name of param currently being updated-- used for reducing echo on param change
......
......@@ -276,7 +276,7 @@ protected:
bool doneLoadingConfig;
UASInterface* mav; ///< The current MAV
QGCUASParamManager* paramMgr; ///< params mgr for the mav
QGCUASParamManagerInterface* paramMgr; ///< params mgr for the mav
static const unsigned int chanMax = 14; ///< Maximum number of channels
static const unsigned int chanMappedMax = 16; ///< Maximum number of mapped channels (can be higher than input channel count)
unsigned int chanCount; ///< Actual channels
......
......@@ -158,7 +158,7 @@ protected slots:
protected:
bool doneLoadingConfig;
UASInterface* mav; ///< The current MAV
QGCUASParamManager* paramMgr; ///< params mgr for the mav
QGCUASParamManagerInterface* paramMgr; ///< params mgr for the mav
static const unsigned int chanMax = 8; ///< Maximum number of channels
unsigned int chanCount; ///< Actual channels
int rcType; ///< Type of the remote control
......
......@@ -34,10 +34,8 @@ This file is part of the QGROUNDCONTROL project
#include <QWidget>
#include "ui_FrameTypeConfig.h"
#include "UASInterface.h"
#include "UASManager.h"
#include "QGCUASParamManager.h"
#include "AP2ConfigWidget.h"
class FrameTypeConfig : public AP2ConfigWidget
{
Q_OBJECT
......
......@@ -7,7 +7,7 @@
#include "QGCToolWidgetItem.h"
class QGCUASParamManager;
class QGCUASParamManagerInterface;
namespace Ui
{
......@@ -52,7 +52,7 @@ protected slots:
/** @brief Updates current parameter based on new combobox value */
void comboBoxIndexChanged(QString val);
protected:
QGCUASParamManager *paramMgr; ///< Access to parameter manager
QGCUASParamManagerInterface *paramMgr; ///< Access to parameter manager
bool visibleEnabled;
QString visibleParam;
int visibleVal;
......
......@@ -134,7 +134,7 @@ bool QGCMapWidget::setHomeActionTriggered()
QMessageBox::information(0,"Error","Please connect first");
return false;
}
UASManager *uasManager = UASManager::instance();
UASManagerInterface *uasManager = UASManager::instance();
if (!uasManager) { return false; }
// Enter an altitude
......
......@@ -97,7 +97,7 @@ protected:
private:
UASInterface* mav;
QGCUASParamManager *paramMgr;
QGCUASParamManagerInterface *paramMgr;
QProgressDialog* progress;
unsigned pendingParams;
enum CONFIG_STATE configState;
......
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