Commit a2e9481b authored by Don Gagne's avatar Don Gagne

Merge pull request #1415 from DonLakeFlyer/OptionalParam

Handle parameters not being available
parents dbab7381 a8af57ee
......@@ -272,16 +272,6 @@ Rectangle {
}
Column {
property Fact cal_mag0_rot: Fact { name: "CAL_MAG0_ROT" }
property Fact cal_mag1_rot: Fact { name: "CAL_MAG1_ROT" }
property Fact cal_mag2_rot: Fact { name: "CAL_MAG2_ROT" }
// Compass rotation parameter < 0 indicates either internal compass, or no compass. So in
// both those cases we do not show a rotation combo.
property bool showCompass0: cal_mag0_rot.value >= 0
property bool showCompass1: cal_mag1_rot.value >= 0
property bool showCompass2: cal_mag2_rot.value >= 0
x: parent.width - rotationColumnWidth
QGCLabel { text: "Autpilot Orientation" }
......@@ -309,8 +299,8 @@ Rectangle {
fact: Fact { name: "CAL_MAG0_ROT" }
}
}
Loader { sourceComponent: parent.showCompass0 ? compass0ComponentLabel : null }
Loader { sourceComponent: parent.showCompass0 ? compass0ComponentCombo : null }
Loader { sourceComponent: controller.showCompass0 ? compass0ComponentLabel : null }
Loader { sourceComponent: controller.showCompass0 ? compass0ComponentCombo : null }
// Compass 1 rotation
Component {
......@@ -328,8 +318,8 @@ Rectangle {
fact: Fact { name: "CAL_MAG1_ROT" }
}
}
Loader { sourceComponent: parent.showCompass1 ? compass1ComponentLabel : null }
Loader { sourceComponent: parent.showCompass1 ? compass1ComponentCombo : null }
Loader { sourceComponent: controller.showCompass1 ? compass1ComponentLabel : null }
Loader { sourceComponent: controller.showCompass1 ? compass1ComponentCombo : null }
// Compass 2 rotation
Component {
......@@ -347,8 +337,8 @@ Rectangle {
fact: Fact { name: "CAL_MAG2_ROT" }
}
}
Loader { sourceComponent: parent.showCompass2 ? compass2ComponentLabel : null }
Loader { sourceComponent: parent.showCompass2 ? compass2ComponentCombo : null }
Loader { sourceComponent: controller.showCompass2 ? compass2ComponentLabel : null }
Loader { sourceComponent: controller.showCompass2 ? compass2ComponentCombo : null }
}
}
}
......
......@@ -38,6 +38,9 @@ SensorsComponentController::SensorsComponentController(AutoPilotPlugin* autopilo
_progressBar(NULL),
_showGyroCalArea(false),
_showAccelCalArea(false),
_showCompass0(false),
_showCompass1(false),
_showCompass2(false),
_gyroCalInProgress(false),
_accelCalDownSideDone(false),
_accelCalUpsideDownSideDone(false),
......@@ -54,7 +57,16 @@ SensorsComponentController::SensorsComponentController(AutoPilotPlugin* autopilo
_textLoggingStarted(false),
_autopilot(autopilot)
{
Q_ASSERT(autopilot);
Q_ASSERT(_autopilot);
Q_ASSERT(_autopilot->pluginReady());
// Mag rotation parameters are optional
_showCompass0 = _autopilot->parameterExists("CAL_MAG0_ROT") &&
_autopilot->getParameterFact("CAL_MAG0_ROT")->value().toInt() >= 0;
_showCompass1 = _autopilot->parameterExists("CAL_MAG1_ROT") &&
_autopilot->getParameterFact("CAL_MAG1_ROT")->value().toInt() >= 0;
_showCompass2 = _autopilot->parameterExists("CAL_MAG2_ROT") &&
_autopilot->getParameterFact("CAL_MAG2_ROT")->value().toInt() >= 0;
}
/// Appends the specified text to the status log area in the ui
......@@ -273,11 +285,19 @@ void SensorsComponentController::_refreshParams(void)
_autopilot->refreshParameter(FactSystem::defaultComponentId, "CAL_ACC0_ID");
_autopilot->refreshParameter(FactSystem::defaultComponentId, "SENS_DPRES_OFF");
_autopilot->refreshParameter(FactSystem::defaultComponentId, "CAL_MAG0_ROT");
_autopilot->refreshParameter(FactSystem::defaultComponentId, "CAL_MAG1_ROT");
_autopilot->refreshParameter(FactSystem::defaultComponentId, "CAL_MAG2_ROT");
_autopilot->refreshParameter(FactSystem::defaultComponentId, "SENS_BOARD_ROT");
// Mag rotation parameters are optional
if (_autopilot->parameterExists("CAL_MAG0_ROT")) {
_autopilot->refreshParameter(FactSystem::defaultComponentId, "CAL_MAG0_ROT");
}
if (_autopilot->parameterExists("CAL_MAG1_ROT")) {
_autopilot->refreshParameter(FactSystem::defaultComponentId, "CAL_MAG1_ROT");
}
if (_autopilot->parameterExists("CAL_MAG2_ROT")) {
_autopilot->refreshParameter(FactSystem::defaultComponentId, "CAL_MAG2_ROT");
}
// Pull full set in order to get all cal values back
_autopilot->refreshAllParameters();
}
......
......@@ -51,6 +51,10 @@ public:
Q_PROPERTY(QQuickItem* accelButton MEMBER _accelButton)
Q_PROPERTY(QQuickItem* airspeedButton MEMBER _airspeedButton)
Q_PROPERTY(bool showCompass0 MEMBER _showCompass0 CONSTANT)
Q_PROPERTY(bool showCompass1 MEMBER _showCompass1 CONSTANT)
Q_PROPERTY(bool showCompass2 MEMBER _showCompass2 CONSTANT)
Q_PROPERTY(bool showGyroCalArea MEMBER _showGyroCalArea NOTIFY showGyroCalAreaChanged)
Q_PROPERTY(bool showAccelCalArea MEMBER _showAccelCalArea NOTIFY showAccelCalAreaChanged)
......@@ -110,6 +114,10 @@ private:
bool _showGyroCalArea;
bool _showAccelCalArea;
bool _showCompass0;
bool _showCompass1;
bool _showCompass2;
bool _gyroCalInProgress;
bool _accelCalDownSideDone;
......
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