Commit dee99ea5 authored by Don Gagne's avatar Don Gagne

Changed pluginReady mechanism

More consistent with Qml usage pattern
parent aa1b3191
......@@ -264,7 +264,8 @@
<file alias="QGroundControl/Controls/arrow-down.png">src/QmlControls/arrow-down.png</file>
<file alias="octo_x.png">files/images/px4/airframes/octo_x.png</file>
<file alias="px4fmu_2.x.png">files/images/px4/boards/px4fmu_2.x.png</file>
<file alias="SetupViewButtons.qml">src/VehicleSetup/SetupViewButtons.qml</file>
<file alias="SetupViewButtonsConnected.qml">src/VehicleSetup/SetupViewButtonsConnected.qml</file>
<file alias="SetupViewButtonsDisconnected.qml">src/VehicleSetup/SetupViewButtonsDisconnected.qml</file>
<file alias="VehicleSummary.qml">src/VehicleSetup/VehicleSummary.qml</file>
<file alias="FirmwareUpgrade.qml">src/VehicleSetup/FirmwareUpgrade.qml</file>
<file alias="SafetyComponent.qml">src/AutoPilotPlugins/PX4/SafetyComponent.qml</file>
......
......@@ -28,7 +28,8 @@
AutoPilotPlugin::AutoPilotPlugin(UASInterface* uas, QObject* parent) :
QObject(parent),
_uas(uas)
_uas(uas),
_pluginReady(false)
{
Q_ASSERT(_uas);
}
......
......@@ -50,6 +50,8 @@ class AutoPilotPlugin : public QObject
public:
AutoPilotPlugin(UASInterface* uas, QObject* parent);
Q_PROPERTY(bool pluginReady READ pluginReady NOTIFY pluginReadyChanged)
Q_PROPERTY(QVariantList components READ components CONSTANT)
Q_PROPERTY(QUrl setupBackgroundImage READ setupBackgroundImage CONSTANT)
......@@ -71,23 +73,23 @@ public:
virtual const QVariantMap& parameters(void) = 0;
virtual QUrl setupBackgroundImage(void) = 0;
/// Returns true if the plugin is ready for use
virtual bool pluginIsReady(void) const = 0;
/// FIXME: Kind of hacky
static void clearStaticData(void);
UASInterface* uas(void) { return _uas; }
bool pluginReady(void) { return _pluginReady; }
signals:
/// Signalled when plugin is ready for use
void pluginReady(void);
void pluginReadyChanged(bool pluginReady);
protected:
/// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin
AutoPilotPlugin(QObject* parent = NULL) : QObject(parent) { }
UASInterface* _uas;
UASInterface* _uas;
bool _pluginReady;
};
#endif
......@@ -34,8 +34,7 @@ GenericAutoPilotPlugin::GenericAutoPilotPlugin(UASInterface* uas, QObject* paren
_parameterFacts = new GenericParameterFacts(uas, this);
Q_CHECK_PTR(_parameterFacts);
connect(_parameterFacts, &GenericParameterFacts::factsReady, this, &GenericAutoPilotPlugin::pluginReady);
connect(_parameterFacts, &GenericParameterFacts::factsReady, this, &GenericAutoPilotPlugin::_factsReady);
}
QList<AutoPilotPluginManager::FullMode_t> GenericAutoPilotPlugin::getModes(void)
......@@ -104,3 +103,9 @@ QUrl GenericAutoPilotPlugin::setupBackgroundImage(void)
{
return QUrl::fromUserInput("qrc:/qml/px4fmu_2.x.png");
}
void GenericAutoPilotPlugin::_factsReady(void)
{
_pluginReady = true;
emit pluginReadyChanged(_pluginReady);
}
......@@ -41,7 +41,6 @@ public:
GenericAutoPilotPlugin(UASInterface* uas, QObject* parent = NULL);
// Overrides from AutoPilotPlugin
virtual bool pluginIsReady(void) const { return _parameterFacts->factsAreReady(); }
virtual QUrl setupBackgroundImage(void);
virtual const QVariantList& components(void);
virtual const QVariantMap& parameters(void);
......@@ -50,6 +49,9 @@ public:
static QString getShortModeText(uint8_t baseMode, uint32_t customMode);
static void clearStaticData(void);
private slots:
void _factsReady(void);
private:
GenericParameterFacts* _parameterFacts;
};
......
......@@ -44,7 +44,7 @@ FlightModesComponentController::FlightModesComponentController(QObject* parent)
_autoPilotPlugin = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_uas);
Q_ASSERT(_autoPilotPlugin);
Q_ASSERT(_autoPilotPlugin->pluginIsReady());
Q_ASSERT(_autoPilotPlugin->pluginReady());
_initRcValues();
_validateConfiguration();
......
......@@ -189,11 +189,6 @@ void PX4AutoPilotPlugin::clearStaticData(void)
PX4ParameterFacts::clearStaticData();
}
bool PX4AutoPilotPlugin::pluginIsReady(void) const
{
return _parameterFacts->factsAreReady();
}
const QVariantList& PX4AutoPilotPlugin::components(void)
{
if (_components.count() == 0 && !_incorrectParameterVersion) {
......@@ -261,5 +256,6 @@ void PX4AutoPilotPlugin::_pluginReadyPreChecks(void)
}
}
emit pluginReady();
_pluginReady = true;
emit pluginReadyChanged(_pluginReady);
}
......@@ -50,7 +50,6 @@ public:
~PX4AutoPilotPlugin();
// Overrides from AutoPilotPlugin
virtual bool pluginIsReady(void) const;
virtual const QVariantList& components(void);
virtual const QVariantMap& parameters(void);
virtual QUrl setupBackgroundImage(void);
......
......@@ -38,7 +38,7 @@ FactBinder::FactBinder(void) :
_autopilotPlugin = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(uas);
Q_ASSERT(_autopilotPlugin);
Q_ASSERT(_autopilotPlugin->pluginIsReady());
Q_ASSERT(_autopilotPlugin->pluginReady());
}
QString FactBinder::name(void) const
......
......@@ -72,11 +72,11 @@ void FactSystemTestBase::_init(MAV_AUTOPILOT autopilot)
// Wait for the plugin to be ready
QSignalSpy spyPlugin(_plugin, SIGNAL(pluginReady()));
if (!_plugin->pluginIsReady()) {
QSignalSpy spyPlugin(_plugin, SIGNAL(pluginReadyChanged(bool)));
if (!_plugin->pluginReady()) {
QCOMPARE(spyPlugin.wait(5000), true);
}
Q_ASSERT(_plugin->pluginIsReady());
Q_ASSERT(_plugin->pluginReady());
}
void FactSystemTestBase::_cleanup(void)
......
......@@ -54,12 +54,11 @@ SetupView::SetupView(QWidget* parent) :
Q_UNUSED(fSucceeded);
Q_ASSERT(fSucceeded);
_ui->buttonHolder->setAutoPilot(NULL);
_ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtons.qml"));
qmlRegisterType<FirmwareUpgradeController>("QGroundControl.FirmwareUpgradeController", 1, 0, "FirmwareUpgradeController");
_ui->buttonHolder->rootContext()->setContextProperty("controller", this);
qmlRegisterType<FirmwareUpgradeController>("QGroundControl.FirmwareUpgradeController", 1, 0, "FirmwareUpgradeController");
_ui->buttonHolder->setAutoPilot(NULL);
_ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtonsDisconnected.qml"));
_setActiveUAS(UASManager::instance()->getActiveUAS());
}
......@@ -73,35 +72,37 @@ void SetupView::_setActiveUAS(UASInterface* uas)
{
if (_uasCurrent) {
Q_ASSERT(_autoPilotPlugin);
disconnect(_autoPilotPlugin, &AutoPilotPlugin::pluginReady, this, &SetupView::_pluginReady);
disconnect(_autoPilotPlugin, &AutoPilotPlugin::pluginReadyChanged, this, &SetupView::_pluginReadyChanged);
}
_autoPilotPlugin = NULL;
_ui->buttonHolder->setAutoPilot(NULL);
firmwareButtonClicked();
QObject* button = _ui->buttonHolder->rootObject()->findChild<QObject*>("firmwareButton");
Q_ASSERT(button);
button->setProperty("checked", true);
_pluginReadyChanged(false);
_uasCurrent = uas;
if (_uasCurrent) {
_autoPilotPlugin = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_uasCurrent);
connect(_autoPilotPlugin, &AutoPilotPlugin::pluginReady, this, &SetupView::_pluginReady);
if (_autoPilotPlugin->pluginIsReady()) {
_pluginReady();
}
_pluginReadyChanged(_autoPilotPlugin->pluginReady());
connect(_autoPilotPlugin, &AutoPilotPlugin::pluginReadyChanged, this, &SetupView::_pluginReadyChanged);
}
}
void SetupView::_pluginReady(void)
void SetupView::_pluginReadyChanged(bool pluginReady)
{
_ui->buttonHolder->setAutoPilot(_autoPilotPlugin);
summaryButtonClicked();
QObject* button = _ui->buttonHolder->rootObject()->findChild<QObject*>("summaryButton");
Q_ASSERT(button);
button->setProperty("checked", true);
if (pluginReady) {
_ui->buttonHolder->setAutoPilot(_autoPilotPlugin);
_ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtonsConnected.qml"));
summaryButtonClicked();
QObject* button = _ui->buttonHolder->rootObject()->findChild<QObject*>("summaryButton");
Q_ASSERT(button);
button->setProperty("checked", true);
} else {
_ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtonsDisconnected.qml"));
_ui->buttonHolder->setAutoPilot(NULL);
firmwareButtonClicked();
QObject* button = _ui->buttonHolder->rootObject()->findChild<QObject*>("firmwareButton");
Q_ASSERT(button);
button->setProperty("checked", true);
}
}
void SetupView::_changeSetupWidget(QWidget* newWidget)
......
......@@ -54,7 +54,7 @@ public:
private slots:
void _setActiveUAS(UASInterface* uas);
void _pluginReady(void);
void _pluginReadyChanged(bool pluginReady);
private:
void _changeSetupWidget(QWidget* newWidget);
......
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtGraphicalEffects 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
Rectangle {
id: topLevel
QGCPalette { id: palette; colorGroupEnabled: true }
color: palette.window
ExclusiveGroup { id: setupButtonGroup }
Component {
id: disconnectedButtons
Column {
anchors.fill: parent
SubMenuButton {
id: firmwareButton; objectName: "firmwareButton"
width: parent.width
text: "FIRMWARE"
imageResource: "FirmwareUpgradeIcon.png"
setupIndicator: false
exclusiveGroup: setupButtonGroup
onClicked: controller.firmwareButtonClicked()
}
Item { width: parent.width; height: 10 } // spacer
QGCLabel {
width: parent.width
text: "Full setup options are only available when connected to vehicle and full parameter list has completed downloading."
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
}
}
}
Component {
id: connectedButtons
Column {
anchors.fill: parent
SubMenuButton {
id: summaryButton; objectName: "summaryButton"
width: parent.width
text: "SUMMARY"
imageResource: "VehicleSummaryIcon.png"
setupIndicator: false
exclusiveGroup: setupButtonGroup
onClicked: controller.summaryButtonClicked()
}
SubMenuButton {
id: firmwareButton; objectName: "firmwareButton"
width: parent.width
text: "FIRMWARE"
imageResource: "FirmwareUpgradeIcon.png"
setupIndicator: false
exclusiveGroup: setupButtonGroup
onClicked: controller.firmwareButtonClicked()
}
Repeater {
model: autopilot.components
SubMenuButton {
width: parent.width
text: modelData.name.toUpperCase()
imageResource: modelData.iconResource
setupComplete: modelData.setupComplete
exclusiveGroup: setupButtonGroup
onClicked: controller.setupButtonClicked(modelData)
}
}
SubMenuButton {
width: parent.width
text: "PARAMETERS"
setupIndicator: false
exclusiveGroup: setupButtonGroup
onClicked: controller.parametersButtonClicked()
}
}
}
Loader {
anchors.fill: parent
sourceComponent: autopilot ? connectedButtons : disconnectedButtons
}
}
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtGraphicalEffects 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
Rectangle {
id: topLevel
QGCPalette { id: palette; colorGroupEnabled: true }
color: palette.window
ExclusiveGroup { id: setupButtonGroup }
Column {
anchors.fill: parent
SubMenuButton {
id: summaryButton; objectName: "summaryButton"
width: parent.width
text: "SUMMARY"
imageResource: "VehicleSummaryIcon.png"
setupIndicator: false
exclusiveGroup: setupButtonGroup
onClicked: controller.summaryButtonClicked()
}
SubMenuButton {
id: firmwareButton; objectName: "firmwareButton"
width: parent.width
text: "FIRMWARE"
imageResource: "FirmwareUpgradeIcon.png"
setupIndicator: false
exclusiveGroup: setupButtonGroup
onClicked: controller.firmwareButtonClicked()
}
Repeater {
model: autopilot ? autopilot.components : 0
SubMenuButton {
width: parent.width
text: modelData.name.toUpperCase()
imageResource: modelData.iconResource
setupComplete: modelData.setupComplete
exclusiveGroup: setupButtonGroup
onClicked: controller.setupButtonClicked(modelData)
}
}
SubMenuButton {
width: parent.width
text: "PARAMETERS"
setupIndicator: false
exclusiveGroup: setupButtonGroup
onClicked: controller.parametersButtonClicked()
}
}
}
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtGraphicalEffects 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
Rectangle {
id: topLevel
QGCPalette { id: palette; colorGroupEnabled: true }
color: palette.window
ExclusiveGroup { id: setupButtonGroup }
Column {
anchors.fill: parent
SubMenuButton {
id: firmwareButton; objectName: "firmwareButton"
width: parent.width
text: "FIRMWARE"
imageResource: "FirmwareUpgradeIcon.png"
setupIndicator: false
exclusiveGroup: setupButtonGroup
onClicked: controller.firmwareButtonClicked()
}
Item { width: parent.width; height: 10 } // spacer
QGCLabel {
width: parent.width
text: "Full setup options are only available when connected to vehicle and full parameter list has completed downloading."
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
}
}
}
......@@ -181,7 +181,7 @@ void DebugConsole::addLink(LinkInterface* link)
// Register for name changes
connect(link, SIGNAL(nameChanged(QString)), this, SLOT(updateLinkName(QString)), Qt::UniqueConnection);
connect(LinkManager::instance(), &LinkManager::linkDeleted, this, &DebugConsole::removeLink, Qt::UniqueConnection);
connect(LinkManager::instance(), &LinkManager::linkDisconnected, this, &DebugConsole::removeLink, Qt::UniqueConnection);
}
void DebugConsole::removeLink(LinkInterface* const linkInterface)
......
......@@ -219,10 +219,11 @@ void PrimaryFlightDisplay::forgetUAS(UASInterface* uas)
disconnect(this->uas, SIGNAL(attitudeChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateAttitude(UASInterface*, double, double, double, quint64)));
disconnect(this->uas, SIGNAL(attitudeChanged(UASInterface*,int,double,double,double,quint64)), this, SLOT(updateAttitude(UASInterface*,int,double, double, double, quint64)));
disconnect(this->uas, SIGNAL(speedChanged(UASInterface*, double, double, quint64)), this, SLOT(updateSpeed(UASInterface*, double, double, quint64)));
disconnect(this->uas, SIGNAL(altitudeChanged(UASInterface*, double, double, double, double, quint64)), this, SLOT(updateAltitude(UASInterface*, double, double, double, quint64)));
disconnect(this->uas, SIGNAL(altitudeChanged(UASInterface*, double, double, double, double, quint64)), this, SLOT(updateAltitude(UASInterface*, double, double, double, double, quint64)));
disconnect(this->uas, SIGNAL(navigationControllerErrorsChanged(UASInterface*, double, double, double)), this, SLOT(updateNavigationControllerErrors(UASInterface*, double, double, double)));
disconnect(this->uas, &UASInterface::NavigationControllerDataChanged, this, &PrimaryFlightDisplay::UpdateNavigationControllerData);
}
this->uas = NULL;
}
/**
......
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