diff --git a/qgcunittest/UASUnitTest.cc b/qgcunittest/UASUnitTest.cc index 117aed1fbc6d33ec92b132da309c10851eb690d9..650ec845adbf5a998fe7031718ca1a33365f8df8 100644 --- a/qgcunittest/UASUnitTest.cc +++ b/qgcunittest/UASUnitTest.cc @@ -163,10 +163,7 @@ void UASUnitTest::getYaw_test() void UASUnitTest::getSelected_test() { - bool test = uas->getSelected(); - if(test != NULL){ - QCOMPARE(test, false); - } + QCOMPARE(uas->getSelected(), false); } void UASUnitTest::getSystemType_test() @@ -176,12 +173,24 @@ void UASUnitTest::getSystemType_test() void UASUnitTest::getAirframe_test() { + //when uas is constructed, airframe is set to QGC_AIRFRAME_GENERIC which is 0 QCOMPARE(uas->getAirframe(), 0); - - uas->setAirframe(25); - QVERIFY(uas->getAirframe() == 25); } +void UASUnitTest::setAirframe_test() +{ + //check at construction, that airframe=0 (GENERIC) + QVERIFY(uas->getAirframe() == 0); + + //check that set airframe works + uas->setAirframe(11); + QVERIFY(uas->getAirframe() == 11); + + //check that setAirframe will not assign a number to airframe, that is + //not defined in the enum + uas->setAirframe(12); + QVERIFY(uas->getAirframe() == 11); +} void UASUnitTest::getWaypointList_test() { QVector kk = uas->getWaypointManager()->getWaypointEditableList(); diff --git a/qgcunittest/UASUnitTest.h b/qgcunittest/UASUnitTest.h index 6a409f8124c6ab2f05fd90a226e1bd71b05e07ea..192257e5ae223f3f08c3c3e7a0e67af2ed2cebcd 100644 --- a/qgcunittest/UASUnitTest.h +++ b/qgcunittest/UASUnitTest.h @@ -49,6 +49,7 @@ private slots: void getSelected_test(); void getSystemType_test(); void getAirframe_test(); + void setAirframe_test(); void getWaypointList_test(); void signalWayPoint_test(); void getWaypoint_test(); diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index e9188bc29d13cdae22ad9cfcf472b6fc19e41e02..f555ef806fde01fb08bd5da7fa7ef53d1946341e 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -86,7 +86,7 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), receivedRGBDImageTimestamp(0.0), #endif paramsOnceRequested(false), - airframe(QGC_AIRFRAME_EASYSTAR), + airframe(QGC_AIRFRAME_GENERIC), attitudeKnown(false), paramManager(NULL), attitudeStamped(false), @@ -104,7 +104,7 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), componentID[i] = -1; componentMulti[i] = false; } - + color = UASInterface::getNextColor(); setBatterySpecs(QString("9V,9.5V,12.6V")); @@ -152,9 +152,9 @@ void UAS::readSettings() void UAS::deleteSettings() { this->name = ""; - this->airframe = QGC_AIRFRAME_EASYSTAR; + this->airframe = QGC_AIRFRAME_GENERIC; this->autopilot = -1; - setBatterySpecs(QString("9V,9.5V,12.6V")); + setBatterySpecs(QString("9V,9.5V,12.6V")); } int UAS::getUASID() const diff --git a/src/uas/UAS.h b/src/uas/UAS.h index 919d798efaf748c45e5e0387dbae70a4adea4c3f..bab9d55478b6cf7b6cfe097a3d0187da730a05e0 100644 --- a/src/uas/UAS.h +++ b/src/uas/UAS.h @@ -483,15 +483,19 @@ public slots: void setAutopilotType(int apType) { autopilot = apType; - //emit systemSpecsChanged(uasId); + emit systemSpecsChanged(uasId); } /** @brief Set the type of airframe */ void setSystemType(int systemType); /** @brief Set the specific airframe type */ void setAirframe(int airframe) { - this->airframe = airframe; - emit systemSpecsChanged(uasId); + if((airframe >= 0) && (airframe < 12)) + { + this->airframe = airframe; + emit systemSpecsChanged(uasId); + } + } /** @brief Set a new name **/ void setUASName(const QString& name); diff --git a/src/uas/UASInterface.h b/src/uas/UASInterface.h index 47cc7bf807c37888b692dd2d61c4fe929cb4c07b..034d77b39961b76c0408b73a22b76eea589a6495 100644 --- a/src/uas/UASInterface.h +++ b/src/uas/UASInterface.h @@ -149,7 +149,8 @@ public: QGC_AIRFRAME_COAXIAL, QGC_AIRFRAME_PTERYX, QGC_AIRFRAME_TRICOPTER, - QGC_AIRFRAME_HEXCOPTER + QGC_AIRFRAME_HEXCOPTER, + QGC_AIRFRAME_END_OF_ENUM }; /**