43 changed files with 1388 additions and 1430 deletions
@ -0,0 +1,140 @@
@@ -0,0 +1,140 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009 - 2015 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 "FlightMapSettings.h" |
||||
|
||||
#include <QSettings> |
||||
#include <QtQml> |
||||
|
||||
IMPLEMENT_QGC_SINGLETON(FlightMapSettings, FlightMapSettings) |
||||
|
||||
const char* FlightMapSettings::_defaultMapProvider = "Bing"; // Bing is default since it support full street/satellite/hybrid set
|
||||
const char* FlightMapSettings::_settingsGroup = "FlightMapSettings"; |
||||
const char* FlightMapSettings::_mapProviderKey = "MapProvider"; |
||||
const char* FlightMapSettings::_mapTypeKey = "MapType"; |
||||
|
||||
FlightMapSettings::FlightMapSettings(QObject* parent) |
||||
: QObject(parent) |
||||
, _mapProvider(_defaultMapProvider) |
||||
{ |
||||
qmlRegisterUncreatableType<FlightMapSettings> ("QGroundControl", 1, 0, "FlightMapSetting", "Reference only"); |
||||
|
||||
_supportedMapProviders << "Bing" << "Google" << "Open"; |
||||
|
||||
_loadSettings(); |
||||
} |
||||
|
||||
FlightMapSettings::~FlightMapSettings() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void FlightMapSettings::_storeSettings(void) |
||||
{ |
||||
QSettings settings; |
||||
|
||||
settings.beginGroup(_settingsGroup); |
||||
settings.setValue(_mapProviderKey, _supportedMapProviders.contains(_mapProvider) ? _mapProvider : _defaultMapProvider); |
||||
} |
||||
|
||||
void FlightMapSettings::_loadSettings(void) |
||||
{ |
||||
QSettings settings; |
||||
|
||||
settings.beginGroup(_settingsGroup); |
||||
_mapProvider = settings.value(_mapProviderKey, _defaultMapProvider).toString(); |
||||
|
||||
if (!_supportedMapProviders.contains(_mapProvider)) { |
||||
_mapProvider = _defaultMapProvider; |
||||
} |
||||
|
||||
_setMapTypesForCurrentProvider(); |
||||
} |
||||
|
||||
QString FlightMapSettings::mapProvider(void) |
||||
{ |
||||
return _mapProvider; |
||||
} |
||||
|
||||
void FlightMapSettings::setMapProvider(const QString& mapProvider) |
||||
{ |
||||
if (_supportedMapProviders.contains(mapProvider)) { |
||||
_mapProvider = mapProvider; |
||||
_storeSettings(); |
||||
_setMapTypesForCurrentProvider(); |
||||
emit mapProviderChanged(mapProvider); |
||||
} |
||||
} |
||||
|
||||
void FlightMapSettings::_setMapTypesForCurrentProvider(void) |
||||
{ |
||||
_mapTypes.clear(); |
||||
|
||||
if (_mapProvider == "Bing") { |
||||
_mapTypes << "Street Map" << "Satellite Map" << "Hybrid Map"; |
||||
} else if (_mapProvider == "Google") { |
||||
_mapTypes << "Street Map" << "Satellite Map" << "Terrain Map"; |
||||
} else if (_mapProvider == "Open") { |
||||
_mapTypes << "Street Map"; |
||||
} |
||||
|
||||
emit mapTypesChanged(_mapTypes); |
||||
} |
||||
|
||||
QString FlightMapSettings::mapTypeForMapName(const QString& mapName) |
||||
{ |
||||
QSettings settings; |
||||
|
||||
settings.beginGroup(_settingsGroup); |
||||
settings.beginGroup(mapName); |
||||
settings.beginGroup(_mapProvider); |
||||
return settings.value(_mapTypeKey, "Street Map").toString(); |
||||
} |
||||
|
||||
void FlightMapSettings::setMapTypeForMapName(const QString& mapName, const QString& mapType) |
||||
{ |
||||
QSettings settings; |
||||
|
||||
settings.beginGroup(_settingsGroup); |
||||
settings.beginGroup(mapName); |
||||
settings.beginGroup(_mapProvider); |
||||
settings.setValue(_mapTypeKey, mapType); |
||||
} |
||||
|
||||
void FlightMapSettings::saveMapSetting (const QString &mapName, const QString& key, const QString& value) |
||||
{ |
||||
QSettings settings; |
||||
|
||||
settings.beginGroup(_settingsGroup); |
||||
settings.beginGroup(mapName); |
||||
settings.setValue(key, value); |
||||
} |
||||
|
||||
QString FlightMapSettings::loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue) |
||||
{ |
||||
QSettings settings; |
||||
|
||||
settings.beginGroup(_settingsGroup); |
||||
settings.beginGroup(mapName); |
||||
return settings.value(key, defaultValue).toString(); |
||||
} |
@ -0,0 +1,79 @@
@@ -0,0 +1,79 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009 - 2015 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 FlightMapSettings_H |
||||
#define FlightMapSettings_H |
||||
|
||||
#include "QGCSingleton.h" |
||||
|
||||
#include <QStringList> |
||||
|
||||
class FlightMapSettings : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
DECLARE_QGC_SINGLETON(FlightMapSettings, FlightMapSettings) |
||||
|
||||
public: |
||||
/// mapProvider is either Bing, Google or Open to specify to set of maps available
|
||||
Q_PROPERTY(QString mapProvider READ mapProvider WRITE setMapProvider NOTIFY mapProviderChanged) |
||||
|
||||
/// Map types associated with current map provider
|
||||
Q_PROPERTY(QStringList mapTypes MEMBER _mapTypes NOTIFY mapTypesChanged) |
||||
|
||||
Q_INVOKABLE QString mapTypeForMapName(const QString& mapName); |
||||
Q_INVOKABLE void setMapTypeForMapName(const QString& mapName, const QString& mapType); |
||||
|
||||
Q_INVOKABLE void saveMapSetting (const QString &mapName, const QString& key, const QString& value); |
||||
Q_INVOKABLE QString loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue); |
||||
|
||||
// Property accessors
|
||||
|
||||
QString mapProvider(void); |
||||
void setMapProvider(const QString& mapProvider); |
||||
|
||||
signals: |
||||
void mapProviderChanged(const QString& mapProvider); |
||||
void mapTypesChanged(const QStringList& mapTypes); |
||||
|
||||
private: |
||||
/// @brief All access to FlightMapSettings singleton is through FlightMapSettings::instance
|
||||
FlightMapSettings(QObject* parent = NULL); |
||||
~FlightMapSettings(); |
||||
|
||||
void _storeSettings(void); |
||||
void _loadSettings(void); |
||||
|
||||
void _setMapTypesForCurrentProvider(void); |
||||
|
||||
QString _mapProvider; ///< Current map provider
|
||||
QStringList _supportedMapProviders; |
||||
QStringList _mapTypes; ///< Map types associated with current map provider
|
||||
|
||||
static const char* _defaultMapProvider; |
||||
static const char* _settingsGroup; |
||||
static const char* _mapProviderKey; |
||||
static const char* _mapTypeKey; |
||||
}; |
||||
|
||||
#endif |
Before Width: | Height: | Size: 1014 B After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 644 B After Width: | Height: | Size: 658 B |
@ -0,0 +1,182 @@
@@ -0,0 +1,182 @@
|
||||
/*=====================================================================
|
||||
|
||||
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 "MissionItemTest.h" |
||||
|
||||
UT_REGISTER_TEST(MissionItemTest) |
||||
|
||||
const MissionItemTest::ItemInfo_t MissionItemTest::_rgItemInfo[] = { |
||||
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_WAYPOINT, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT }, |
||||
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_UNLIM, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT }, |
||||
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_TURNS, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT }, |
||||
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_TIME, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT }, |
||||
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LAND, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT }, |
||||
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_TAKEOFF, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT }, |
||||
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_CONDITION_DELAY, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_MISSION }, |
||||
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_DO_JUMP, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_MISSION }, |
||||
}; |
||||
|
||||
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesWaypoint[] = { |
||||
{ "Latitude:", -10.0 }, |
||||
{ "Longitude:", -20.0 }, |
||||
{ "Altitude:", -30.0 }, |
||||
{ "Heading:", 40.0 }, |
||||
{ "Radius:", 20.0 }, |
||||
{ "Hold:", 10.0 }, |
||||
}; |
||||
|
||||
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLoiterUnlim[] = { |
||||
{ "Latitude:", -10.0 }, |
||||
{ "Longitude:", -20.0 }, |
||||
{ "Altitude:", -30.0 }, |
||||
{ "Heading:", 40.0 }, |
||||
{ "Radius:", 30.0 }, |
||||
}; |
||||
|
||||
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLoiterTurns[] = { |
||||
{ "Latitude:", -10.0 }, |
||||
{ "Longitude:", -20.0 }, |
||||
{ "Altitude:", -30.0 }, |
||||
{ "Heading:", 40.0 }, |
||||
{ "Radius:", 30.0 }, |
||||
{ "Turns:", 10.0 }, |
||||
}; |
||||
|
||||
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLoiterTime[] = { |
||||
{ "Latitude:", -10.0 }, |
||||
{ "Longitude:", -20.0 }, |
||||
{ "Altitude:", -30.0 }, |
||||
{ "Heading:", 40.0 }, |
||||
{ "Radius:", 30.0 }, |
||||
{ "Seconds:", 10.0 }, |
||||
}; |
||||
|
||||
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLand[] = { |
||||
{ "Latitude:", -10.0 }, |
||||
{ "Longitude:", -20.0 }, |
||||
{ "Altitude:", -30.0 }, |
||||
{ "Heading:", 40.0 }, |
||||
}; |
||||
|
||||
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesTakeoff[] = { |
||||
{ "Latitude:", -10.0 }, |
||||
{ "Longitude:", -20.0 }, |
||||
{ "Altitude:", -30.0 }, |
||||
{ "Heading:", 40.0 }, |
||||
{ "Pitch:", 10.0 }, |
||||
}; |
||||
|
||||
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesConditionDelay[] = { |
||||
{ "Seconds:", 10.0 }, |
||||
}; |
||||
|
||||
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesDoJump[] = { |
||||
{ "Seq #:", 10.0 }, |
||||
{ "Repeat:", 20.0 }, |
||||
}; |
||||
|
||||
const MissionItemTest::ItemExpected_t MissionItemTest::_rgItemExpected[] = { |
||||
{ "1\t0\t3\t16\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesWaypoint)/sizeof(MissionItemTest::_rgFactValuesWaypoint[0]), MissionItemTest::_rgFactValuesWaypoint }, |
||||
{ "1\t0\t3\t17\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesLoiterUnlim)/sizeof(MissionItemTest::_rgFactValuesLoiterUnlim[0]), MissionItemTest::_rgFactValuesLoiterUnlim }, |
||||
{ "1\t0\t3\t18\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesLoiterTurns)/sizeof(MissionItemTest::_rgFactValuesLoiterTurns[0]), MissionItemTest::_rgFactValuesLoiterTurns }, |
||||
{ "1\t0\t3\t19\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesLoiterTime)/sizeof(MissionItemTest::_rgFactValuesLoiterTime[0]), MissionItemTest::_rgFactValuesLoiterTime }, |
||||
{ "1\t0\t3\t21\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesLand)/sizeof(MissionItemTest::_rgFactValuesLand[0]), MissionItemTest::_rgFactValuesLand }, |
||||
{ "1\t0\t3\t22\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesTakeoff)/sizeof(MissionItemTest::_rgFactValuesTakeoff[0]), MissionItemTest::_rgFactValuesTakeoff }, |
||||
{ "1\t0\t2\t112\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesConditionDelay)/sizeof(MissionItemTest::_rgFactValuesConditionDelay[0]), MissionItemTest::_rgFactValuesConditionDelay }, |
||||
{ "1\t0\t2\t177\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesDoJump)/sizeof(MissionItemTest::_rgFactValuesDoJump[0]), MissionItemTest::_rgFactValuesDoJump }, |
||||
}; |
||||
|
||||
MissionItemTest::MissionItemTest(void) |
||||
{ |
||||
|
||||
} |
||||
|
||||
void MissionItemTest::_test(void) |
||||
{ |
||||
for (size_t i=0; i<sizeof(_rgItemInfo)/sizeof(_rgItemInfo[0]); i++) { |
||||
const ItemInfo_t* info = &_rgItemInfo[i]; |
||||
const ItemExpected_t* expected = &_rgItemExpected[i]; |
||||
|
||||
qDebug() << "Command:" << info->command; |
||||
|
||||
MissionItem* item = new MissionItem(NULL, |
||||
info->sequenceNumber, |
||||
info->coordinate, |
||||
info->command, |
||||
info->param1, |
||||
info->param2, |
||||
info->param3, |
||||
info->param4, |
||||
info->autocontinue, |
||||
info->isCurrentItem, |
||||
info->frame); |
||||
|
||||
// Validate the saving is working correctly
|
||||
QString savedItemString; |
||||
QTextStream saveStream(&savedItemString, QIODevice::WriteOnly); |
||||
item->save(saveStream); |
||||
QCOMPARE(savedItemString, QString(expected->streamString)); |
||||
|
||||
// Validate that the fact values are correctly returned
|
||||
size_t factCount = 0; |
||||
for (int i=0; i<item->textFieldFacts()->count(); i++) { |
||||
Fact* fact = qobject_cast<Fact*>(item->textFieldFacts()->get(i)); |
||||
|
||||
bool found = false; |
||||
for (size_t j=0; j<expected->cFactValues; j++) { |
||||
const FactValue_t* factValue = &expected->rgFactValues[j]; |
||||
|
||||
if (factValue->name == fact->name()) { |
||||
qDebug() << factValue->name; |
||||
QCOMPARE(fact->value().toDouble(), factValue->value); |
||||
factCount ++; |
||||
found = true; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
QVERIFY(found); |
||||
} |
||||
QCOMPARE(factCount, expected->cFactValues); |
||||
|
||||
// Validate that loading is working correctly
|
||||
MissionItem* loadedItem = new MissionItem(); |
||||
QTextStream loadStream(&savedItemString, QIODevice::ReadOnly); |
||||
QVERIFY(loadedItem->load(loadStream)); |
||||
//qDebug() << savedItemString;
|
||||
QCOMPARE(loadedItem->coordinate().latitude(), item->coordinate().latitude()); |
||||
QCOMPARE(loadedItem->coordinate().longitude(), item->coordinate().longitude()); |
||||
QCOMPARE(loadedItem->coordinate().altitude(), item->coordinate().altitude()); |
||||
QCOMPARE(loadedItem->command(), item->command()); |
||||
QCOMPARE(loadedItem->param1(), item->param1()); |
||||
QCOMPARE(loadedItem->param2(), item->param2()); |
||||
QCOMPARE(loadedItem->param3(), item->param3()); |
||||
QCOMPARE(loadedItem->param4(), item->param4()); |
||||
QCOMPARE(loadedItem->autoContinue(), item->autoContinue()); |
||||
QCOMPARE(loadedItem->isCurrentItem(), item->isCurrentItem()); |
||||
QCOMPARE(loadedItem->frame(), item->frame()); |
||||
|
||||
delete item; |
||||
delete loadedItem; |
||||
} |
||||
} |
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009 - 2015 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 MissionItemTest_H |
||||
#define MissionItemTest_H |
||||
|
||||
#include "UnitTest.h" |
||||
#include "TCPLink.h" |
||||
#include "MultiSignalSpy.h" |
||||
|
||||
/// @file
|
||||
/// @brief FlightGear HIL Simulation unit tests
|
||||
///
|
||||
/// @author Don Gagne <don@thegagnes.com>
|
||||
|
||||
class MissionItemTest : public UnitTest |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
MissionItemTest(void); |
||||
|
||||
private slots: |
||||
void _test(void); |
||||
|
||||
private: |
||||
typedef struct { |
||||
int sequenceNumber; |
||||
QGeoCoordinate coordinate; |
||||
int command; |
||||
double param1; |
||||
double param2; |
||||
double param3; |
||||
double param4; |
||||
bool autocontinue; |
||||
bool isCurrentItem; |
||||
int frame; |
||||
} ItemInfo_t; |
||||
|
||||
typedef struct { |
||||
const char* name; |
||||
double value; |
||||
} FactValue_t; |
||||
|
||||
typedef struct { |
||||
const char* streamString; |
||||
size_t cFactValues; |
||||
const FactValue_t* rgFactValues; |
||||
} ItemExpected_t; |
||||
|
||||
static const ItemInfo_t _rgItemInfo[]; |
||||
static const ItemExpected_t _rgItemExpected[]; |
||||
static const FactValue_t _rgFactValuesWaypoint[]; |
||||
static const FactValue_t _rgFactValuesLoiterUnlim[]; |
||||
static const FactValue_t _rgFactValuesLoiterTurns[]; |
||||
static const FactValue_t _rgFactValuesLoiterTime[]; |
||||
static const FactValue_t _rgFactValuesLand[]; |
||||
static const FactValue_t _rgFactValuesTakeoff[]; |
||||
static const FactValue_t _rgFactValuesConditionDelay[]; |
||||
static const FactValue_t _rgFactValuesDoJump[]; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,214 @@
@@ -0,0 +1,214 @@
|
||||
/*=====================================================================
|
||||
|
||||
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 "MissionManagerTest.h" |
||||
#include "LinkManager.h" |
||||
#include "MultiVehicleManager.h" |
||||
|
||||
UT_REGISTER_TEST(MissionManagerTest) |
||||
|
||||
const MissionManagerTest::TestCase_t MissionManagerTest::_rgTestCases[] = { |
||||
{ "1\t0\t3\t16\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", { 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_WAYPOINT, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT } }, |
||||
{ "1\t0\t3\t17\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", { 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_UNLIM, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT } }, |
||||
{ "1\t0\t3\t18\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", { 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_TURNS, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT } }, |
||||
{ "1\t0\t3\t19\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", { 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_TIME, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT } }, |
||||
{ "1\t0\t3\t21\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", { 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LAND, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT } }, |
||||
{ "1\t0\t3\t22\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", { 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_TAKEOFF, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT } }, |
||||
{ "1\t0\t2\t112\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", { 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_CONDITION_DELAY, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_MISSION } }, |
||||
{ "1\t0\t2\t177\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", { 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_DO_JUMP, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_MISSION } }, |
||||
}; |
||||
|
||||
MissionManagerTest::MissionManagerTest(void) |
||||
: _mockLink(NULL) |
||||
{ |
||||
|
||||
} |
||||
|
||||
void MissionManagerTest::init(void) |
||||
{ |
||||
UnitTest::init(); |
||||
|
||||
LinkManager* linkMgr = LinkManager::instance(); |
||||
Q_CHECK_PTR(linkMgr); |
||||
|
||||
_mockLink = new MockLink(); |
||||
Q_CHECK_PTR(_mockLink); |
||||
LinkManager::instance()->_addLink(_mockLink); |
||||
|
||||
linkMgr->connectLink(_mockLink); |
||||
|
||||
// Wait for the Vehicle to work it's way through the various threads
|
||||
|
||||
QSignalSpy spyVehicle(MultiVehicleManager::instance(), SIGNAL(activeVehicleChanged(Vehicle*))); |
||||
QCOMPARE(spyVehicle.wait(5000), true); |
||||
|
||||
// Wait for the Mission Manager to finish it's initial load
|
||||
|
||||
_missionManager = MultiVehicleManager::instance()->activeVehicle()->missionManager(); |
||||
QVERIFY(_missionManager); |
||||
|
||||
_rgSignals[canEditChangedSignalIndex] = SIGNAL(canEditChanged(bool)); |
||||
_rgSignals[newMissionItemsAvailableSignalIndex] = SIGNAL(newMissionItemsAvailable(void)); |
||||
_rgSignals[inProgressChangedSignalIndex] = SIGNAL(inProgressChanged(bool)); |
||||
|
||||
_multiSpy = new MultiSignalSpy(); |
||||
Q_CHECK_PTR(_multiSpy); |
||||
QCOMPARE(_multiSpy->init(_missionManager, _rgSignals, _cSignals), true); |
||||
|
||||
if (_missionManager->inProgress()) { |
||||
_multiSpy->waitForSignalByIndex(newMissionItemsAvailableSignalIndex, 1000); |
||||
_multiSpy->waitForSignalByIndex(inProgressChangedSignalIndex, 1000); |
||||
QCOMPARE(_multiSpy->checkSignalByMask(newMissionItemsAvailableSignalMask | inProgressChangedSignalMask), true); |
||||
QCOMPARE(_multiSpy->checkNoSignalByMask(canEditChangedSignalIndex), true); |
||||
} |
||||
|
||||
QVERIFY(!_missionManager->inProgress()); |
||||
QCOMPARE(_missionManager->missionItems()->count(), 0); |
||||
_multiSpy->clearAllSignals(); |
||||
} |
||||
|
||||
void MissionManagerTest::cleanup(void) |
||||
{ |
||||
delete _multiSpy; |
||||
_multiSpy = NULL; |
||||
|
||||
LinkManager::instance()->disconnectLink(_mockLink); |
||||
_mockLink = NULL; |
||||
QTest::qWait(1000); // Need to allow signals to move between threads
|
||||
|
||||
UnitTest::cleanup(); |
||||
} |
||||
|
||||
/// Checks the state of the inProgress value and signal to match the specified value
|
||||
void MissionManagerTest::_checkInProgressValues(bool inProgress) |
||||
{ |
||||
QCOMPARE(_missionManager->inProgress(), inProgress); |
||||
QSignalSpy* spy = _multiSpy->getSpyByIndex(inProgressChangedSignalIndex); |
||||
QList<QVariant> signalArgs = spy->takeFirst(); |
||||
QCOMPARE(signalArgs.count(), 1); |
||||
QCOMPARE(signalArgs[0].toBool(), inProgress); |
||||
} |
||||
|
||||
void MissionManagerTest::_readEmptyVehicle(void) |
||||
{ |
||||
_missionManager->requestMissionItems(); |
||||
|
||||
// requestMissionItems should emit inProgressChanged signal before returning so no need to wait for it
|
||||
QVERIFY(_missionManager->inProgress()); |
||||
QCOMPARE(_multiSpy->checkOnlySignalByMask(inProgressChangedSignalMask), true); |
||||
_checkInProgressValues(true); |
||||
|
||||
_multiSpy->clearAllSignals(); |
||||
|
||||
// Now wait for read sequence to complete. We should get both a newMissionItemsAvailable and a
|
||||
// inProgressChanged signal to signal completion.
|
||||
_multiSpy->waitForSignalByIndex(newMissionItemsAvailableSignalIndex, 1000); |
||||
_multiSpy->waitForSignalByIndex(inProgressChangedSignalIndex, 1000); |
||||
QCOMPARE(_multiSpy->checkSignalByMask(newMissionItemsAvailableSignalMask | inProgressChangedSignalMask), true); |
||||
QCOMPARE(_multiSpy->checkNoSignalByMask(canEditChangedSignalMask), true); |
||||
_checkInProgressValues(false); |
||||
|
||||
// Vehicle should have no items at this point
|
||||
QCOMPARE(_missionManager->missionItems()->count(), 0); |
||||
QCOMPARE(_missionManager->canEdit(), true); |
||||
} |
||||
|
||||
void MissionManagerTest::_roundTripItems(void) |
||||
{ |
||||
// Setup our test case data
|
||||
const size_t cTestCases = sizeof(_rgTestCases)/sizeof(_rgTestCases[0]); |
||||
QmlObjectListModel* list = new QmlObjectListModel(); |
||||
|
||||
for (size_t i=0; i<cTestCases; i++) { |
||||
const TestCase_t* testCase = &_rgTestCases[i]; |
||||
|
||||
MissionItem* item = new MissionItem(list); |
||||
|
||||
QTextStream loadStream(testCase->itemStream, QIODevice::ReadOnly); |
||||
QVERIFY(item->load(loadStream)); |
||||
|
||||
list->append(item); |
||||
} |
||||
|
||||
// Send the items to the vehicle
|
||||
_missionManager->writeMissionItems(*list); |
||||
|
||||
// writeMissionItems should emit inProgressChanged signal before returning so no need to wait for it
|
||||
QVERIFY(_missionManager->inProgress()); |
||||
QCOMPARE(_multiSpy->checkOnlySignalByMask(inProgressChangedSignalMask), true); |
||||
_checkInProgressValues(true); |
||||
|
||||
_multiSpy->clearAllSignals(); |
||||
|
||||
// Now wait for write sequence to complete. We should only get an inProgressChanged signal to signal completion.
|
||||
_multiSpy->waitForSignalByIndex(inProgressChangedSignalIndex, 1000); |
||||
QCOMPARE(_multiSpy->checkOnlySignalByMask(inProgressChangedSignalMask), true); |
||||
_checkInProgressValues(false); |
||||
|
||||
QCOMPARE(_missionManager->missionItems()->count(), (int)cTestCases); |
||||
QCOMPARE(_missionManager->canEdit(), true); |
||||
|
||||
delete list; |
||||
list = NULL; |
||||
_multiSpy->clearAllSignals(); |
||||
|
||||
// Read the items back from the vehicle
|
||||
_missionManager->requestMissionItems(); |
||||
|
||||
// requestMissionItems should emit inProgressChanged signal before returning so no need to wait for it
|
||||
QVERIFY(_missionManager->inProgress()); |
||||
QCOMPARE(_multiSpy->checkOnlySignalByMask(inProgressChangedSignalMask), true); |
||||
_checkInProgressValues(true); |
||||
|
||||
_multiSpy->clearAllSignals(); |
||||
|
||||
// Now wait for read sequence to complete. We should get both a newMissionItemsAvailable and a
|
||||
// inProgressChanged signal to signal completion.
|
||||
_multiSpy->waitForSignalByIndex(newMissionItemsAvailableSignalIndex, 1000); |
||||
_multiSpy->waitForSignalByIndex(inProgressChangedSignalIndex, 1000); |
||||
QCOMPARE(_multiSpy->checkSignalByMask(newMissionItemsAvailableSignalMask | inProgressChangedSignalMask), true); |
||||
QCOMPARE(_multiSpy->checkNoSignalByMask(canEditChangedSignalMask), true); |
||||
_checkInProgressValues(false); |
||||
|
||||
QCOMPARE(_missionManager->missionItems()->count(), (int)cTestCases); |
||||
QCOMPARE(_missionManager->canEdit(), true); |
||||
|
||||
// Validate the returned items against our test data
|
||||
|
||||
for (size_t i=0; i<cTestCases; i++) { |
||||
const TestCase_t* testCase = &_rgTestCases[i]; |
||||
MissionItem* actual = qobject_cast<MissionItem*>(_missionManager->missionItems()->get(i)); |
||||
|
||||
qDebug() << "Test case" << i; |
||||
QCOMPARE(actual->coordinate().latitude(), testCase->expectedItem.coordinate.latitude()); |
||||
QCOMPARE(actual->coordinate().longitude(), testCase->expectedItem.coordinate.longitude()); |
||||
QCOMPARE(actual->coordinate().altitude(), testCase->expectedItem.coordinate.altitude()); |
||||
QCOMPARE((int)actual->command(), (int)testCase->expectedItem.command); |
||||
QCOMPARE(actual->param1(), testCase->expectedItem.param1); |
||||
QCOMPARE(actual->param2(), testCase->expectedItem.param2); |
||||
QCOMPARE(actual->param3(), testCase->expectedItem.param3); |
||||
QCOMPARE(actual->param4(), testCase->expectedItem.param4); |
||||
QCOMPARE(actual->autoContinue(), testCase->expectedItem.autocontinue); |
||||
QCOMPARE(actual->frame(), testCase->expectedItem.frame); |
||||
} |
||||
} |
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009 - 2015 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 MissionManagerTest_H |
||||
#define MissionManagerTest_H |
||||
|
||||
#include "UnitTest.h" |
||||
#include "MockLink.h" |
||||
#include "MissionManager.h" |
||||
#include "MultiSignalSpy.h" |
||||
|
||||
class MissionManagerTest : public UnitTest |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
MissionManagerTest(void); |
||||
|
||||
private slots: |
||||
void init(void); |
||||
void cleanup(void); |
||||
|
||||
void _readEmptyVehicle(void); |
||||
void _roundTripItems(void); |
||||
|
||||
private: |
||||
void _checkInProgressValues(bool inProgress); |
||||
|
||||
MockLink* _mockLink; |
||||
MissionManager* _missionManager; |
||||
|
||||
enum { |
||||
canEditChangedSignalIndex = 0, |
||||
newMissionItemsAvailableSignalIndex, |
||||
inProgressChangedSignalIndex, |
||||
maxSignalIndex |
||||
}; |
||||
|
||||
enum { |
||||
canEditChangedSignalMask = 1 << canEditChangedSignalIndex, |
||||
newMissionItemsAvailableSignalMask = 1 << newMissionItemsAvailableSignalIndex, |
||||
inProgressChangedSignalMask = 1 << inProgressChangedSignalIndex, |
||||
}; |
||||
|
||||
MultiSignalSpy* _multiSpy; |
||||
static const size_t _cSignals = maxSignalIndex; |
||||
const char* _rgSignals[_cSignals]; |
||||
|
||||
typedef struct { |
||||
int sequenceNumber; |
||||
QGeoCoordinate coordinate; |
||||
int command; |
||||
double param1; |
||||
double param2; |
||||
double param3; |
||||
double param4; |
||||
bool autocontinue; |
||||
bool isCurrentItem; |
||||
int frame; |
||||
} ItemInfo_t; |
||||
|
||||
typedef struct { |
||||
const char* itemStream; |
||||
const ItemInfo_t expectedItem; |
||||
} TestCase_t; |
||||
|
||||
static const TestCase_t _rgTestCases[]; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
import QtQuick 2.2 |
||||
import QtQuick.Controls 1.2 |
||||
import QtQuick.Controls.Styles 1.2 |
||||
|
||||
import QGroundControl.Palette 1.0 |
||||
import QGroundControl.ScreenTools 1.0 |
||||
|
||||
/// Canvas has some sort of bug in it which can cause it to not paint when top level Views |
||||
/// are switched. In order to fix this we ahve a signal hacked into ScreenTools to force |
||||
/// a repaint. |
||||
Canvas { |
||||
Connections { |
||||
target: ScreenTools |
||||
|
||||
onRepaintRequested: arrowCanvas.requestPaint() |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue