Commit 6261e761 authored by Don Gagne's avatar Don Gagne
Browse files

FactPanel V2

parent c8b92a9a
......@@ -185,9 +185,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) :
#endif
// Set up timer for delayed missing fact display
_missingFactDelayedDisplayTimer.setSingleShot(true);
_missingFactDelayedDisplayTimer.setInterval(_missingFactDelayedDisplayTimerTimeout);
connect(&_missingFactDelayedDisplayTimer, &QTimer::timeout, this, &QGCApplication::_missingFactsDisplay);
_missingParamsDelayedDisplayTimer.setSingleShot(true);
_missingParamsDelayedDisplayTimer.setInterval(_missingParamsDelayedDisplayTimerTimeout);
connect(&_missingParamsDelayedDisplayTimer, &QTimer::timeout, this, &QGCApplication::_missingParamsDisplay);
// Set application information
if (_runningUnitTests) {
......@@ -675,28 +675,28 @@ void QGCApplication::_loadCurrentStyle(void)
restoreOverrideCursor();
}
void QGCApplication::reportMissingFact(const QString& name)
void QGCApplication::reportMissingParameter(int componentId, const QString& name)
{
_missingFacts += name;
_missingFactDelayedDisplayTimer.start();
_missingParams += QString("%1:%2").arg(componentId).arg(name);
_missingParamsDelayedDisplayTimer.start();
}
/// Called when the delay timer fires to show the missing facts warning
void QGCApplication::_missingFactsDisplay(void)
/// Called when the delay timer fires to show the missing parameters warning
void QGCApplication::_missingParamsDisplay(void)
{
Q_ASSERT(_missingFacts.count());
Q_ASSERT(_missingParams.count());
QString facts;
foreach (QString fact, _missingFacts) {
if (facts.isEmpty()) {
facts += fact;
QString params;
foreach (QString name, _missingParams) {
if (params.isEmpty()) {
params += name;
} else {
facts += QString(", %1").arg(fact);
params += QString(", %1").arg(name);
}
}
_missingFacts.clear();
_missingParams.clear();
QGCMessageBox::critical("Missing Parameters",
QString("Parameters missing from firmware: %1.\n\n"
"You should quit QGroundControl immediately and update your firmware.").arg(facts));
"You should quit QGroundControl immediately and update your firmware.").arg(params));
}
\ No newline at end of file
......@@ -96,9 +96,9 @@ public:
/// Set the current UI style
void setStyle(bool styleIsDark);
/// Used to report a missing Fact. Warning will be displayed to user. Method may be called
/// Used to report a missing Parameter. Warning will be displayed to user. Method may be called
/// multiple times.
void reportMissingFact(const QString& name);
void reportMissingParameter(int componentId, const QString& name);
public slots:
/// You can connect to this slot to show an information message box from a different thread.
......@@ -140,7 +140,7 @@ public:
static QGCApplication* _app; ///< Our own singleton. Should be reference directly by qgcApp
private slots:
void _missingFactsDisplay(void);
void _missingParamsDisplay(void);
private:
void _createSingletons(void);
......@@ -163,9 +163,9 @@ private:
static const char* _lightStyleFile;
bool _styleIsDark; ///< true: dark style, false: light style
static const int _missingFactDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display
QTimer _missingFactDelayedDisplayTimer; ///< Timer use to delay missing fact display
QStringList _missingFacts; ///< List of missing facts to be displayed
static const int _missingParamsDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display
QTimer _missingParamsDelayedDisplayTimer; ///< Timer use to delay missing fact display
QStringList _missingParams; ///< List of missing facts to be displayed
/// Unit Test have access to creating and destroying singletons
friend class UnitTest;
......
......@@ -43,7 +43,6 @@ QGCView {
property bool fullMode: true
QGCPalette { id: __qgcPal; colorGroupEnabled: true }
ParameterEditorController { id: __controller }
QGCLabel { id: __textMeasure; text: "X"; visible: false }
property Fact __editorDialogFact: Fact { }
......@@ -61,6 +60,8 @@ QGCView {
QGCViewPanel {
id: panel
ParameterEditorController { id: controller; factPanel: panel }
Component {
id: factRowsComponent
......@@ -82,22 +83,16 @@ QGCView {
}
Repeater {
model: __controller.getFactsForGroup(componentId, group)
model: controller.getFactsForGroup(componentId, group)
Column {
property Fact modelFact: controller.getParameterFact(componentId, modelData)
Item {
x: __leftMargin
width: parent.width
height: __textHeight + (ScreenTools.pixelSizeFactor * (9))
Fact {
id: modelFact
Component.onCompleted: {
name = modelData + ":" + componentId
}
}
QGCLabel {
id: nameLabel
width: __textWidth * (__maxParamChars + 1)
......@@ -166,22 +161,22 @@ QGCView {
QGCButton {
text: "Clear RC to Param"
onClicked: __controller.clearRCToParam()
onClicked: controller.clearRCToParam()
}
QGCButton {
text: "Save to file"
visible: fullMode
onClicked: __controller.saveToFile()
onClicked: controller.saveToFile()
}
QGCButton {
text: "Load from file"
visible: fullMode
onClicked: __controller.loadFromFile()
onClicked: controller.loadFromFile()
}
QGCButton {
id: firstButton
text: "Refresh"
onClicked: __controller.refresh()
onClicked: controller.refresh()
}
}
}
......@@ -203,7 +198,7 @@ QGCView {
Column {
Repeater {
model: __controller.componentIds
model: controller.componentIds
Column {
id: componentColumn
......@@ -218,7 +213,7 @@ QGCView {
}
Repeater {
model: __controller.getGroupsForComponent(componentColumn.componentId)
model: controller.getGroupsForComponent(componentColumn.componentId)
Column {
QGCButton {
......@@ -260,8 +255,8 @@ QGCView {
id: factRowsLoader
width: factScrollView.width
property int componentId: __controller.componentIds[0]
property string group: __controller.getGroupsForComponent(__controller.componentIds[0])[0]
property int componentId: controller.componentIds[0]
property string group: controller.getGroupsForComponent(controller.componentIds[0])[0]
sourceComponent: factRowsComponent
}
} // ScrollView - Facts
......@@ -276,6 +271,8 @@ QGCView {
QGCViewDialog {
id: editorDialog
ParameterEditorController { id: controller; factPanel: editorDialog }
property bool fullMode: true
function accept() {
......@@ -364,7 +361,7 @@ QGCView {
anchors.bottom: parent.bottom
visible: __editorDialogFact.defaultValueAvailable
text: "Set RC to Param..."
onClicked: __controller.setRCToParam(__editorDialogFact.name)
onClicked: controller.setRCToParam(__editorDialogFact.name)
}
} // Rectangle - editorDialog
} // Component - Editor Dialog
......
......@@ -33,17 +33,8 @@
#include "MainWindow.h"
/// @Brief Constructs a new ParameterEditorController Widget. This widget is used within the PX4VehicleConfig set of screens.
ParameterEditorController::ParameterEditorController(void) :
_uas(NULL),
_autopilot(NULL)
ParameterEditorController::ParameterEditorController(void)
{
_uas = UASManager::instance()->getActiveUAS();
Q_ASSERT(_uas);
_autopilot = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_uas);
Q_ASSERT(_autopilot);
Q_ASSERT(_autopilot->pluginReady());
const QMap<int, QMap<QString, QStringList> >& groupMap = _autopilot->getGroupMap();
foreach (int componentId, groupMap.keys()) {
......
......@@ -32,8 +32,9 @@
#include "AutoPilotPlugin.h"
#include "UASInterface.h"
#include "FactPanelController.h"
class ParameterEditorController : public QObject
class ParameterEditorController : public FactPanelController
{
Q_OBJECT
......@@ -54,8 +55,6 @@ public:
QList<QObject*> model(void);
private:
UASInterface* _uas;
AutoPilotPlugin* _autopilot;
QStringList _componentIds;
};
......
......@@ -412,7 +412,7 @@ void PX4RCCalibrationTest::_fullCalibration_test(void)
switchList << "RC_MAP_MODE_SW" << "RC_MAP_LOITER_SW" << "RC_MAP_RETURN_SW" << "RC_MAP_POSCTL_SW" << "RC_MAP_ACRO_SW";
foreach (QString switchParam, switchList) {
Q_ASSERT(_autopilot->getParameterFact(switchParam)->value().toInt() != channel + 1);
Q_ASSERT(_autopilot->getParameterFact(FactSystem::defaultComponentId, switchParam)->value().toInt() != channel + 1);
}
_rgFunctionChannelMap[function] = channel;
......@@ -424,7 +424,7 @@ void PX4RCCalibrationTest::_fullCalibration_test(void)
// If we aren't mapping this function during calibration, set it to the previous setting
if (!found) {
_rgFunctionChannelMap[function] = _autopilot->getParameterFact(PX4RCCalibration::_rgFunctionInfo[function].parameterName)->value().toInt();
_rgFunctionChannelMap[function] = _autopilot->getParameterFact(FactSystem::defaultComponentId, PX4RCCalibration::_rgFunctionInfo[function].parameterName)->value().toInt();
qCDebug(PX4RCCalibrationTestLog) << "Assigning switch" << function << _rgFunctionChannelMap[function];
if (_rgFunctionChannelMap[function] == 0) {
_rgFunctionChannelMap[function] = -1; // -1 signals no mapping
......@@ -488,8 +488,8 @@ void PX4RCCalibrationTest::_validateParameters(void)
expectedParameterValue = chanIndex + 1; // 1-based parameter value
}
qCDebug(PX4RCCalibrationTestLog) << "Validate" << chanFunction << _autopilot->getParameterFact(PX4RCCalibration::_rgFunctionInfo[chanFunction].parameterName)->value().toInt();
QCOMPARE(_autopilot->getParameterFact(PX4RCCalibration::_rgFunctionInfo[chanFunction].parameterName)->value().toInt(), expectedParameterValue);
qCDebug(PX4RCCalibrationTestLog) << "Validate" << chanFunction << _autopilot->getParameterFact(FactSystem::defaultComponentId, PX4RCCalibration::_rgFunctionInfo[chanFunction].parameterName)->value().toInt();
QCOMPARE(_autopilot->getParameterFact(FactSystem::defaultComponentId, PX4RCCalibration::_rgFunctionInfo[chanFunction].parameterName)->value().toInt(), expectedParameterValue);
}
// Validate the channel settings. Note the channels are 1-based in parameter names.
......@@ -503,13 +503,13 @@ void PX4RCCalibrationTest::_validateParameters(void)
int rcTrimExpected = _rgChannelSettingsValidate[chan].rcTrim;
bool rcReversedExpected = _rgChannelSettingsValidate[chan].reversed;
int rcMinActual = _autopilot->getParameterFact(minTpl.arg(oneBasedChannel))->value().toInt(&convertOk);
int rcMinActual = _autopilot->getParameterFact(FactSystem::defaultComponentId, minTpl.arg(oneBasedChannel))->value().toInt(&convertOk);
QCOMPARE(convertOk, true);
int rcMaxActual = _autopilot->getParameterFact(maxTpl.arg(oneBasedChannel))->value().toInt(&convertOk);
int rcMaxActual = _autopilot->getParameterFact(FactSystem::defaultComponentId, maxTpl.arg(oneBasedChannel))->value().toInt(&convertOk);
QCOMPARE(convertOk, true);
int rcTrimActual = _autopilot->getParameterFact(trimTpl.arg(oneBasedChannel))->value().toInt(&convertOk);
int rcTrimActual = _autopilot->getParameterFact(FactSystem::defaultComponentId, trimTpl.arg(oneBasedChannel))->value().toInt(&convertOk);
QCOMPARE(convertOk, true);
float rcReversedFloat = _autopilot->getParameterFact(revTpl.arg(oneBasedChannel))->value().toFloat(&convertOk);
float rcReversedFloat = _autopilot->getParameterFact(FactSystem::defaultComponentId, revTpl.arg(oneBasedChannel))->value().toFloat(&convertOk);
QCOMPARE(convertOk, true);
bool rcReversedActual = (rcReversedFloat == -1.0f);
......@@ -531,6 +531,6 @@ void PX4RCCalibrationTest::_validateParameters(void)
expectedValue = _rgFunctionChannelMap[chanFunction] + 1; // 1-based
}
// qCDebug(PX4RCCalibrationTestLog) << chanFunction << expectedValue << mapParamsSet[PX4RCCalibration::_rgFunctionInfo[chanFunction].parameterName].toInt();
QCOMPARE(_autopilot->getParameterFact(PX4RCCalibration::_rgFunctionInfo[chanFunction].parameterName)->value().toInt(), expectedValue);
QCOMPARE(_autopilot->getParameterFact(FactSystem::defaultComponentId, PX4RCCalibration::_rgFunctionInfo[chanFunction].parameterName)->value().toInt(), expectedValue);
}
}
......@@ -107,7 +107,7 @@ ParamLoader::ParamLoader(QString paramName, UASInterface* uas, QObject* parent)
void ParamLoader::load()
{
connect(_autopilot->getParameterFact(_paramName), &Fact::valueChanged, this, &ParamLoader::_parameterUpdated);
connect(_autopilot->getParameterFact(FactSystem::defaultComponentId, _paramName), &Fact::valueChanged, this, &ParamLoader::_parameterUpdated);
// refresh the parameter from onboard to make sure the current value is used
_autopilot->refreshParameter(FactSystem::defaultComponentId, _paramName);
......@@ -117,5 +117,5 @@ void ParamLoader::_parameterUpdated(QVariant value)
{
Q_UNUSED(value);
emit paramLoaded(true, _autopilot->getParameterFact(_paramName)->value().toFloat(), "");
emit paramLoaded(true, _autopilot->getParameterFact(FactSystem::defaultComponentId, _paramName)->value().toFloat(), "");
}
......@@ -707,7 +707,7 @@ void PX4RCCalibration::_resetInternalCalibrationValues(void)
enum rcCalFunctions curFunction = rgFlightModeFunctions[i];
bool ok;
int switchChannel = _autopilot->getParameterFact(_rgFunctionInfo[curFunction].parameterName)->value().toInt(&ok);
int switchChannel = _autopilot->getParameterFact(FactSystem::defaultComponentId, _rgFunctionInfo[curFunction].parameterName)->value().toInt(&ok);
Q_ASSERT(ok);
// Parameter: 1-based channel, 0=not mapped
......@@ -749,16 +749,16 @@ void PX4RCCalibration::_setInternalCalibrationValuesFromParameters(void)
for (int i = 0; i < _chanMax; ++i) {
struct ChannelInfo* info = &_rgChannelInfo[i];
info->rcTrim = _autopilot->getParameterFact(trimTpl.arg(i+1))->value().toInt(&convertOk);
info->rcTrim = _autopilot->getParameterFact(FactSystem::defaultComponentId, trimTpl.arg(i+1))->value().toInt(&convertOk);
Q_ASSERT(convertOk);
info->rcMin = _autopilot->getParameterFact(minTpl.arg(i+1))->value().toInt(&convertOk);
info->rcMin = _autopilot->getParameterFact(FactSystem::defaultComponentId, minTpl.arg(i+1))->value().toInt(&convertOk);
Q_ASSERT(convertOk);
info->rcMax = _autopilot->getParameterFact(maxTpl.arg(i+1))->value().toInt(&convertOk);
info->rcMax = _autopilot->getParameterFact(FactSystem::defaultComponentId, maxTpl.arg(i+1))->value().toInt(&convertOk);
Q_ASSERT(convertOk);
float floatReversed = _autopilot->getParameterFact(revTpl.arg(i+1))->value().toFloat(&convertOk);
float floatReversed = _autopilot->getParameterFact(FactSystem::defaultComponentId, revTpl.arg(i+1))->value().toFloat(&convertOk);
Q_ASSERT(convertOk);
Q_ASSERT(floatReversed == 1.0f || floatReversed == -1.0f);
info->reversed = floatReversed == -1.0f;
......@@ -767,7 +767,7 @@ void PX4RCCalibration::_setInternalCalibrationValuesFromParameters(void)
for (int i=0; i<rcCalFunctionMax; i++) {
int32_t paramChannel;
paramChannel = _autopilot->getParameterFact(_rgFunctionInfo[i].parameterName)->value().toInt(&convertOk);
paramChannel = _autopilot->getParameterFact(FactSystem::defaultComponentId, _rgFunctionInfo[i].parameterName)->value().toInt(&convertOk);
Q_ASSERT(convertOk);
if (paramChannel != 0) {
......@@ -877,10 +877,10 @@ void PX4RCCalibration::_writeCalibration(void)
struct ChannelInfo* info = &_rgChannelInfo[chan];
int oneBasedChannel = chan + 1;
_autopilot->getParameterFact(trimTpl.arg(oneBasedChannel))->setValue((float)info->rcTrim);
_autopilot->getParameterFact(minTpl.arg(oneBasedChannel))->setValue((float)info->rcMin);
_autopilot->getParameterFact(maxTpl.arg(oneBasedChannel))->setValue((float)info->rcMax);
_autopilot->getParameterFact(revTpl.arg(oneBasedChannel))->setValue(info->reversed ? -1.0f : 1.0f);
_autopilot->getParameterFact(FactSystem::defaultComponentId, trimTpl.arg(oneBasedChannel))->setValue((float)info->rcTrim);
_autopilot->getParameterFact(FactSystem::defaultComponentId, minTpl.arg(oneBasedChannel))->setValue((float)info->rcMin);
_autopilot->getParameterFact(FactSystem::defaultComponentId, maxTpl.arg(oneBasedChannel))->setValue((float)info->rcMax);
_autopilot->getParameterFact(FactSystem::defaultComponentId, revTpl.arg(oneBasedChannel))->setValue(info->reversed ? -1.0f : 1.0f);
}
// Write function mapping parameters
......@@ -893,12 +893,12 @@ void PX4RCCalibration::_writeCalibration(void)
// Note that the channel value is 1-based
paramChannel = _rgFunctionChannelMapping[i] + 1;
}
_autopilot->getParameterFact(_rgFunctionInfo[i].parameterName)->setValue(paramChannel);
_autopilot->getParameterFact(FactSystem::defaultComponentId, _rgFunctionInfo[i].parameterName)->setValue(paramChannel);
}
// If the RC_CHAN_COUNT parameter is available write the channel count
if (_autopilot->parameterExists("RC_CHAN_CNT")) {
_autopilot->getParameterFact("RC_CHAN_CNT")->setValue(_chanCount);
if (_autopilot->parameterExists(FactSystem::defaultComponentId, "RC_CHAN_CNT")) {
_autopilot->getParameterFact(FactSystem::defaultComponentId, "RC_CHAN_CNT")->setValue(_chanCount);
}
_stopCalibration();
......
Supports Markdown
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