From 5ed1b5bcc8b21ae76470da4676607606d9b75394 Mon Sep 17 00:00:00 2001 From: Jessica Date: Fri, 20 Jul 2012 15:50:23 -0700 Subject: [PATCH] System type is set to generic in constructor of UAS. --- qgcunittest/UASUnitTest.cc | 11 ++++++----- src/uas/UAS.cc | 35 ++++++++++++++++++++--------------- src/uas/UAS.h | 3 +-- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/qgcunittest/UASUnitTest.cc b/qgcunittest/UASUnitTest.cc index cf2c49a1d..ce36f7770 100644 --- a/qgcunittest/UASUnitTest.cc +++ b/qgcunittest/UASUnitTest.cc @@ -1,5 +1,6 @@ #include "UASUnitTest.h" #include +#include UASUnitTest::UASUnitTest() { } @@ -167,8 +168,9 @@ void UASUnitTest::getSelected_test() } void UASUnitTest::getSystemType_test() -{ //best guess: it is not initialized in the constructor, - //what should it be initialized to? +{ //check that system type is set to MAV_TYPE_GENERIC when initialized + QCOMPARE(uas->getSystemType(), 0); + uas->setSystemType(13); QCOMPARE(uas->getSystemType(), 13); } @@ -251,13 +253,12 @@ void UASUnitTest::getWaypoint_test() void UASUnitTest::signalWayPoint_test() { - QSignalSpy spy(uas->getWaypointManager(), SIGNAL(waypointListChanged(UASID))); - + QSignalSpy spy(uas->getWaypointManager(), SIGNAL(waypointEditableListChanged(UASID))); Waypoint* wp = new Waypoint(0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,false, false, MAV_FRAME_GLOBAL, MAV_CMD_MISSION_START, "blah"); uas->getWaypointManager()->addWaypointEditable(wp, true); printf("spy.count = %d\n", spy.count()); - //QCOMPARE(spy.count(), 1); // 1 listChanged for add wayPoint + QCOMPARE(spy.count(), 1); // 1 listChanged for add wayPoint uas->getWaypointManager()->removeWaypoint(0); QCOMPARE(spy.count(), 2); // 2 listChanged for remove wayPoint QSignalSpy spyDestroyed(uas->getWaypointManager(), SIGNAL(destroyed())); diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index f555ef806..30f3f3e14 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -111,7 +111,8 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), connect(statusTimeout, SIGNAL(timeout()), this, SLOT(updateState())); connect(this, SIGNAL(systemSpecsChanged(int)), this, SLOT(writeSettings())); statusTimeout->start(500); - readSettings(); + readSettings(); + type = MAV_TYPE_GENERIC; // Initial signals emit disarmed(); emit armingChanged(false); @@ -2081,21 +2082,25 @@ void UAS::requestParameter(int component, const QString& parameter) void UAS::setSystemType(int systemType) { - type = systemType; - // If the airframe is still generic, change it to a close default type - if (airframe == 0) + if((systemType >= MAV_TYPE_GENERIC) && (systemType < MAV_TYPE_ENUM_END)) { - switch (systemType) - { - case MAV_TYPE_FIXED_WING: - airframe = QGC_AIRFRAME_EASYSTAR; - break; - case MAV_TYPE_QUADROTOR: - airframe = QGC_AIRFRAME_MIKROKOPTER; - break; - } - } - emit systemSpecsChanged(uasId); + type = systemType; + + // If the airframe is still generic, change it to a close default type + if (airframe == 0) + { + switch (systemType) + { + case MAV_TYPE_FIXED_WING: + airframe = QGC_AIRFRAME_EASYSTAR; + break; + case MAV_TYPE_QUADROTOR: + airframe = QGC_AIRFRAME_MIKROKOPTER; + break; + } + } + emit systemSpecsChanged(uasId); + } } void UAS::setUASName(const QString& name) diff --git a/src/uas/UAS.h b/src/uas/UAS.h index bab9d5547..3f2e591c6 100644 --- a/src/uas/UAS.h +++ b/src/uas/UAS.h @@ -490,7 +490,7 @@ public slots: /** @brief Set the specific airframe type */ void setAirframe(int airframe) { - if((airframe >= 0) && (airframe < 12)) + if((airframe >= QGC_AIRFRAME_GENERIC) && (airframe < QGC_AIRFRAME_END_OF_ENUM)) { this->airframe = airframe; emit systemSpecsChanged(uasId); @@ -643,7 +643,6 @@ public slots: void stopDataRecording(); void deleteSettings(); signals: - /** @brief The main/battery voltage has changed/was updated */ //void voltageChanged(int uasId, double voltage); // Defined in UASInterface already /** @brief An actuator value has changed */ -- 2.22.0