Commit 7e063193 authored by Don Gagne's avatar Don Gagne

Convert Airframe Config to Qml

parent a251c07d
......@@ -332,7 +332,6 @@ FORMS += \
src/ui/JoystickAxis.ui \
src/ui/configuration/terminalconsole.ui \
src/ui/configuration/SerialSettingsDialog.ui \
src/ui/px4_configuration/QGCPX4AirframeConfig.ui \
src/ui/px4_configuration/PX4RCCalibration.ui \
src/ui/QGCUASFileView.ui \
src/QGCQmlWidgetHolder.ui \
......@@ -463,7 +462,6 @@ HEADERS += \
src/uas/UASParameterDataModel.h \
src/uas/UASParameterCommsMgr.h \
src/ui/QGCPendingParamWidget.h \
src/ui/px4_configuration/QGCPX4AirframeConfig.h \
src/ui/QGCBaseParamWidget.h \
src/ui/px4_configuration/PX4RCCalibration.h \
src/ui/px4_configuration/RCValueWidget.h \
......@@ -607,7 +605,6 @@ SOURCES += \
src/uas/UASParameterDataModel.cc \
src/uas/UASParameterCommsMgr.cc \
src/ui/QGCPendingParamWidget.cc \
src/ui/px4_configuration/QGCPX4AirframeConfig.cc \
src/ui/QGCBaseParamWidget.cc \
src/ui/px4_configuration/PX4RCCalibration.cc \
src/ui/px4_configuration/RCValueWidget.cc \
......@@ -730,6 +727,8 @@ HEADERS+= \
src/AutoPilotPlugins/PX4/FlightModesComponent.h \
src/AutoPilotPlugins/PX4/FlightModesComponentController.h \
src/AutoPilotPlugins/PX4/AirframeComponent.h \
src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h \
src/AutoPilotPlugins/PX4/AirframeComponentController.h \
src/AutoPilotPlugins/PX4/SensorsComponent.h \
src/AutoPilotPlugins/PX4/SensorsComponentController.h \
src/AutoPilotPlugins/PX4/SafetyComponent.h \
......@@ -753,6 +752,8 @@ SOURCES += \
src/AutoPilotPlugins/PX4/FlightModesComponent.cc \
src/AutoPilotPlugins/PX4/FlightModesComponentController.cc \
src/AutoPilotPlugins/PX4/AirframeComponent.cc \
src/AutoPilotPlugins/PX4/AirframeComponentAirframes.cc \
src/AutoPilotPlugins/PX4/AirframeComponentController.cc \
src/AutoPilotPlugins/PX4/SensorsComponent.cc \
src/AutoPilotPlugins/PX4/SensorsComponentController.cc \
src/AutoPilotPlugins/PX4/SafetyComponent.cc \
......
......@@ -244,11 +244,13 @@
<qresource prefix="/qml">
<file alias="test.qml">src/test.qml</file>
<file alias="QmlTest.qml">src/QmlControls/QmlTest.qml</file>
<file alias="QGroundControl/FactControls/qmldir">src/FactSystem/FactControls/qmldir</file>
<file alias="QGroundControl/FactControls/FactLabel.qml">src/FactSystem/FactControls/FactLabel.qml</file>
<file alias="QGroundControl/FactControls/FactTextField.qml">src/FactSystem/FactControls/FactTextField.qml</file>
<file alias="QGroundControl/FactControls/FactCheckBox.qml">src/FactSystem/FactControls/FactCheckBox.qml</file>
<file alias="QGroundControl/FactControls/FactComboBox.qml">src/FactSystem/FactControls/FactComboBox.qml</file>
<file alias="QGroundControl/Controls/qmldir">src/QmlControls/qmldir</file>
<file alias="QGroundControl/Controls/QGCButton.qml">src/QmlControls/QGCButton.qml</file>
<file alias="QGroundControl/Controls/QGCRadioButton.qml">src/QmlControls/QGCRadioButton.qml</file>
......@@ -262,10 +264,13 @@
<file alias="QGroundControl/Controls/IndicatorButton.qml">src/QmlControls/IndicatorButton.qml</file>
<file alias="QGroundControl/Controls/VehicleRotationCal.qml">src/QmlControls/VehicleRotationCal.qml</file>
<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="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>
......@@ -283,12 +288,27 @@
<file alias="SafetyComponentHome.png">src/AutoPilotPlugins/PX4/Images/SafetyComponentHome.png</file>
<file alias="SafetyComponentArrowDown.png">src/AutoPilotPlugins/PX4/Images/SafetyComponentArrowDown.png</file>
<file alias="SafetyComponentPlane.png">src/AutoPilotPlugins/PX4/Images/SafetyComponentPlane.png</file>
<file alias="VehicleDown.png">src/AutoPilotPlugins/PX4/Images/VehicleDown.png</file>
<file alias="VehicleUpsideDown.png">src/AutoPilotPlugins/PX4/Images/VehicleUpsideDown.png</file>
<file alias="VehicleLeft.png">src/AutoPilotPlugins/PX4/Images/VehicleLeft.png</file>
<file alias="VehicleRight.png">src/AutoPilotPlugins/PX4/Images/VehicleRight.png</file>
<file alias="VehicleNoseDown.png">src/AutoPilotPlugins/PX4/Images/VehicleNoseDown.png</file>
<file alias="VehicleTailDown.png">src/AutoPilotPlugins/PX4/Images/VehicleTailDown.png</file>
<!-- Airframe component resourecs -->
<file alias="AirframeComponent.qml">src/AutoPilotPlugins/PX4/AirframeComponent.qml</file>
<file alias="AirframeStandardPlane.png">src/AutoPilotPlugins/PX4/Images/AirframeStandardPlane.png</file>
<file alias="AirframeFlyingWing.png">src/AutoPilotPlugins/PX4/Images/AirframeFlyingWing.png</file>
<file alias="AirframeQuadRotorX.png">src/AutoPilotPlugins/PX4/Images/AirframeQuadRotorX.png</file>
<file alias="AirframeQuadRotorPlus.png">src/AutoPilotPlugins/PX4/Images/AirframeQuadRotorPlus.png</file>
<file alias="AirframeOctoRotorX.png">src/AutoPilotPlugins/PX4/Images/AirframeOctoRotorX.png</file>
<file alias="AirframeOctoRotorPlus.png">src/AutoPilotPlugins/PX4/Images/AirframeOctoRotorPlus.png</file>
<file alias="AirframeHexaRotorX.png">src/AutoPilotPlugins/PX4/Images/AirframeHexaRotorX.png</file>
<file alias="AirframeHexaRotorPlus.png">src/AutoPilotPlugins/PX4/Images/AirframeHexaRotorPlus.png</file>
<file alias="AirframeQuadRotorH.png">src/AutoPilotPlugins/PX4/Images/AirframeQuadRotorH.png</file>
<file alias="AirframeSimulation.png">src/AutoPilotPlugins/PX4/Images/AirframeSimulation.png</file>
<file alias="QGroundControl/Controls/subMenuButtonImage.png">files/Setup/cogwheels.png</file>
<file alias="QGroundControl/Controls/SensorsComponentIcon.png">src/AutoPilotPlugins/PX4/Images/SensorsComponentIcon.png</file>
<file alias="QGroundControl/Controls/RadioComponentIcon.png">src/AutoPilotPlugins/PX4/Images/RadioComponentIcon.png</file>
......@@ -298,12 +318,14 @@
<file alias="QGroundControl/Controls/PowerComponentIcon.png">src/AutoPilotPlugins/PX4/Images/PowerComponentIcon.png</file>
<file alias="QGroundControl/Controls/FirmwareUpgradeIcon.png">src/VehicleSetup/FirmwareUpgradeIcon.png</file>
<file alias="QGroundControl/Controls/VehicleSummaryIcon.png">src/VehicleSetup/VehicleSummaryIcon.png</file>
<file alias="PowerComponentBattery_01cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_01cell.svg</file>
<file alias="PowerComponentBattery_02cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_02cell.svg</file>
<file alias="PowerComponentBattery_03cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_03cell.svg</file>
<file alias="PowerComponentBattery_04cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_04cell.svg</file>
<file alias="PowerComponentBattery_05cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_05cell.svg</file>
<file alias="PowerComponentBattery_06cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_06cell.svg</file>
<file alias="MainToolBar.qml">src/ui/toolbar/MainToolBar.qml</file>
</qresource>
<qresource prefix="/AutoPilotPlugins/PX4">
......
......@@ -25,7 +25,7 @@
/// @author Don Gagne <don@thegagnes.com>
#include "AirframeComponent.h"
#include "QGCPX4AirframeConfig.h"
#include "QGCQmlWidgetHolder.h"
#if 0
// Broken by latest mavlink module changes. Not used yet. Comment out for now.
......@@ -179,7 +179,14 @@ QStringList AirframeComponent::paramFilterList(void) const
QWidget* AirframeComponent::setupWidget(void) const
{
return new QGCPX4AirframeConfig;
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder();
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/AirframeComponent.qml"));
return holder;
}
QUrl AirframeComponent::summaryQmlSource(void) const
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Controllers 1.0
Rectangle {
AirframeComponentController { id: controller }
QGCPalette { id: qgcPal; colorGroupEnabled: true }
color: qgcPal.window
Column {
anchors.fill: parent
QGCLabel {
text: "AIRFRAME CONFIG"
font.pointSize: 20
}
Item { height: 20; width: 10 } // spacer
Row {
width: parent.width
QGCLabel {
width: parent.width - applyButton.width
text: "Select you airframe type and specific vehicle bellow. Click 'Apply and Restart' when ready and your vehicle will be disconnected, rebooted to the new settings and re-connected."
wrapMode: Text.WordWrap
}
QGCButton {
id: applyButton
text: "Apply and Restart"
onClicked: { controller.changeAutostart() }
}
}
Item { height: 20; width: 10 } // spacer
Flow {
width: parent.width
spacing: 10
ExclusiveGroup {
id: airframeTypeExclusive
}
Repeater {
model: controller.airframeTypes
// Outer summary item rectangle
Rectangle {
readonly property real titleHeight: 30
readonly property real innerMargin: 10
width: 250
height: 200
color: qgcPal.windowShade
Rectangle {
id: title
width: parent.width
height: parent.titleHeight
color: qgcPal.windowShadeDark
Text {
anchors.fill: parent
color: qgcPal.buttonText
font.pixelSize: 12
text: modelData.name
verticalAlignment: TextEdit.AlignVCenter
horizontalAlignment: TextEdit.AlignHCenter
}
}
Image {
id: image
x: innerMargin
width: parent.width - (innerMargin * 2)
height: parent.height - title.height - combo.height - (innerMargin * 3)
anchors.topMargin: innerMargin
anchors.top: title.bottom
source: modelData.imageResource
fillMode: Image.PreserveAspectFit
smooth: true
}
QGCCheckBox {
id: airframeCheckBox
anchors.bottom: image.bottom
anchors.right: image.right
checked: modelData.name == controller.currentAirframeType
exclusiveGroup: airframeTypeExclusive
onCheckedChanged: {
if (checked && combo.currentIndex != -1) {
controller.autostartId = modelData.airframes[combo.currentIndex].autostartId
}
}
}
QGCComboBox {
id: combo
objectName: modelData.airframeType + "ComboBox"
x: innerMargin
anchors.topMargin: innerMargin
anchors.top: image.bottom
width: parent.width - (innerMargin * 2)
model: modelData.airframes
currentIndex: (modelData.name == controller.currentAirframeType) ? controller.currentVehicleIndex : 0
onCurrentIndexChanged: {
if (airframeCheckBox.checked) {
controller.autostartId = modelData.airframes[currentIndex].autostartId
}
}
}
}
}
}
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "AirframeComponentAirframes.h"
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoStandardPlane[] = {
{ "Multiplex Easystar 1/2", 2100 },
{ "Hobbyking Bixler 1/2", 2101 },
{ "3DR Skywalker", 2102 },
{ "Skyhunter (1800 mm)", 2103 },
{ NULL, 0 }
};
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoSimulation[] = {
{ "Plane (HilStar, X-Plane)", 1000 },
{ "Plane (Rascal, FlightGear)", 1004 },
{ "Quad X HIL", 1001 },
{ "Quad + HIL", 1003 },
{ NULL, 0 }
};
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoFlyingWing[] = {
{ "Z-84 Wing Wing (845 mm)", 3033 },
{ "TBS Caipirinha (850 mm)", 3100 },
{ "Bormatec Camflyer Q (800 mm)", 3030 },
{ "FX-61 Phantom FPV (1550 mm)", 3031 },
{ "FX-79 Buffalo (2000 mm)", 3034 },
{ "Skywalker X5 (1180 mm)", 3032 },
{ "Viper v2 (3000 mm)", 3035 },
{ NULL, 0 }
};
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoQuadRotorX[] = {
{ "DJI F330 8\" Quad", 4010 },
{ "DJI F450 10\" Quad", 4011 },
{ "X frame Quad UAVCAN", 4012 },
{ "AR.Drone Frame Quad", 4008 },
{ NULL, 0 }
};
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoQuadRotorPlus[] = {
{ "Generic 10\" Quad +", 5001 },
{ NULL, 0 }
};
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoHexaRotorX[] = {
{ "Standard 10\" Hexa X", 6001 },
{ "Coaxial 10\" Hexa X", 11001 },
{ NULL, 0 }
};
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoHexaRotorPlus[] = {
{ "Standard 10\" Hexa", 7001 },
{ NULL, 0 }
};
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoOctoRotorX[] = {
{ "Standard 10\" Octo", 8001 },
{ "Coaxial 10\" Octo", 12001 },
{ NULL, 0 }
};
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoOctoRotorPlus[] = {
{ "Standard 10\" Octo", 9001 },
{ NULL, 0 }
};
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoQuadRotorH[] = {
{ "3DR Iris", 10016 },
{ "TBS Discovery", 10015 },
{ "SteadiDrone QU4D", 10017 },
{ NULL, 0 }
};
const AirframeComponentAirframes::AirframeType_t AirframeComponentAirframes::rgAirframeTypes[] = {
{ "Standard Airplane", "qrc:/qml/AirframeStandardPlane.png", AirframeComponentAirframes::_rgAirframeInfoStandardPlane },
{ "Flying Wing", "qrc:/qml/AirframeFlyingWing.png", AirframeComponentAirframes::_rgAirframeInfoFlyingWing },
{ "QuadRotor X", "qrc:/qml/AirframeQuadRotorX.png", AirframeComponentAirframes::_rgAirframeInfoQuadRotorX },
{ "QuadRotor +", "qrc:/qml/AirframeQuadRotorPlus.png", AirframeComponentAirframes::_rgAirframeInfoQuadRotorPlus },
{ "HexaRotor X", "qrc:/qml/AirframeHexaRotorX.png", AirframeComponentAirframes::_rgAirframeInfoHexaRotorX },
{ "HexaRotor +", "qrc:/qml/AirframeHexaRotorPlus.png", AirframeComponentAirframes::_rgAirframeInfoHexaRotorPlus },
{ "OctoRotor X", "qrc:/qml/AirframeOctoRotorX.png", AirframeComponentAirframes::_rgAirframeInfoOctoRotorX },
{ "OctoRotor +", "qrc:/qml/AirframeOctoRotorPlus.png", AirframeComponentAirframes::_rgAirframeInfoOctoRotorPlus },
{ "QuadRotor H", "qrc:/qml/AirframeQuadRotorH.png", AirframeComponentAirframes::_rgAirframeInfoQuadRotorH },
{ "Simulation", "qrc:/qml/AirframeSimulation.png", AirframeComponentAirframes::_rgAirframeInfoSimulation },
{ NULL, NULL, NULL }
};
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef AIRFRAMECOMPONENTAIRFRAMES_H
#define AIRFRAMECOMPONENTAIRFRAMES_H
#include <QObject>
#include <QQuickItem>
#include <QList>
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
/// MVC Controller for AirframeComponent.qml.
class AirframeComponentAirframes
{
public:
typedef struct {
const char* name;
int autostartId;
} AirframeInfo_t;
typedef struct {
const char* name;
const char* imageResource;
const AirframeInfo_t* rgAirframeInfo;
} AirframeType_t;
public:
static const AirframeType_t rgAirframeTypes[];
private:
static const AirframeInfo_t _rgAirframeInfoStandardPlane[];
static const AirframeInfo_t _rgAirframeInfoFlyingWing[];
static const AirframeInfo_t _rgAirframeInfoQuadRotorX[];
static const AirframeInfo_t _rgAirframeInfoQuadRotorPlus[];
static const AirframeInfo_t _rgAirframeInfoOctoRotorX[];
static const AirframeInfo_t _rgAirframeInfoOctoRotorPlus[];
static const AirframeInfo_t _rgAirframeInfoHexaRotorX[];
static const AirframeInfo_t _rgAirframeInfoHexaRotorPlus[];
static const AirframeInfo_t _rgAirframeInfoQuadRotorH[];
static const AirframeInfo_t _rgAirframeInfoSimulation[];
};
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "AirframeComponentController.h"
#include "AirframeComponentAirframes.h"
#include "QGCMAVLink.h"
#include "UASManager.h"
#include "AutoPilotPluginManager.h"
#include "QGCApplication.h"
#include "QGCMessageBox.h"
#include <QVariant>
#include <QQmlProperty>
bool AirframeComponentController::_typesRegistered = false;
AirframeComponentController::AirframeComponentController(QObject* parent) :
QObject(parent),
_uas(NULL),
_autoPilotPlugin(NULL)
{
_uas = UASManager::instance()->getActiveUAS();
Q_ASSERT(_uas);
_autoPilotPlugin = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_uas);
Q_ASSERT(_autoPilotPlugin);
Q_ASSERT(_autoPilotPlugin->pluginReady());
if (!_typesRegistered) {
_typesRegistered = true;
qmlRegisterUncreatableType<AirframeType>("QGroundControl.Controllers", 1, 0, "AiframeType", "Can only reference AirframeType");
qmlRegisterUncreatableType<Airframe>("QGroundControl.Controllers", 1, 0, "Aiframe", "Can only reference Airframe");
}
// Load up member variables
bool autostartFound = false;
_autostartId = _autoPilotPlugin->getParameterFact("SYS_AUTOSTART")->value().toInt();
for (const AirframeComponentAirframes::AirframeType_t* pType=&AirframeComponentAirframes::rgAirframeTypes[0]; pType->name != NULL; pType++) {
AirframeType* airframeType = new AirframeType(pType->name, pType->imageResource, this);
Q_CHECK_PTR(airframeType);
int index = 0;
for (const AirframeComponentAirframes::AirframeInfo_t* pInfo=&pType->rgAirframeInfo[0]; pInfo->name != NULL; pInfo++) {
if (_autostartId == pInfo->autostartId) {
Q_ASSERT(!autostartFound);
autostartFound = true;
_currentAirframeType = pType->name;
_currentVehicleName = pInfo->name;
_currentVehicleIndex = index;
}
airframeType->addAirframe(pInfo->name, pInfo->autostartId);
index++;
}
_airframeTypes.append(QVariant::fromValue(airframeType));
}
// FIXME: Should be a user error
Q_ASSERT(autostartFound);
}
AirframeComponentController::~AirframeComponentController()
{
}
void AirframeComponentController::changeAutostart(void)
{
LinkManager* linkManager = LinkManager::instance();
if (linkManager->getLinks().count() > 1) {
QGCMessageBox::warning("Airframe Config", "You cannot change airframe configuration while connected to multiple vehicles.");
return;
}
_autoPilotPlugin->getParameterFact("SYS_AUTOSTART")->setValue(_autostartId);
_autoPilotPlugin->getParameterFact("SYS_AUTOCONFIG")->setValue(1);
// Wait for the parameters to come back to us
qgcApp()->setOverrideCursor(Qt::WaitCursor);
int waitSeconds = 10;
bool success = false;
QGCUASParamManagerInterface* paramMgr = _uas->getParamManager();
while (true) {
if (paramMgr->countPendingParams() == 0) {
success = true;
break;
}
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
QGC::SLEEP::sleep(1);
if (--waitSeconds == 0) {
break;
}
}
if (!success) {
qgcApp()->restoreOverrideCursor();
QGCMessageBox::critical("Airframe Config", "Airframe Config parameters not received back from vehicle. Config has not been set.");
return;
}
_uas->executeCommand(MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN, 1, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
QGC::SLEEP::sleep(1);
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
qgcApp()->reconnectAfterWait(5);
}
AirframeType::AirframeType(const QString& name, const QString& imageResource, QObject* parent) :
QObject(parent),
_name(name),
_imageResource(imageResource)
{
}
AirframeType::~AirframeType()
{
}
void AirframeType::addAirframe(const QString& name, int autostartId)
{
Airframe* airframe = new Airframe(name, autostartId);
Q_CHECK_PTR(airframe);
_airframes.append(QVariant::fromValue(airframe));
}
Airframe::Airframe(const QString& name, int autostartId, QObject* parent) :
QObject(parent),
_name(name),
_autostartId(autostartId)
{
}
Airframe::~Airframe()
{
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef AIRFRAMECOMPONENTCONTROLLER_H
#define AIRFRAMECOMPONENTCONTROLLER_H
#include <QObject>
#include <QQuickItem>
#include <QList>
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
/// MVC Controller for AirframeComponent.qml.
class AirframeComponentController : public QObject
{
Q_OBJECT
public:
AirframeComponentController(QObject* parent = NULL);
~AirframeComponentController();
Q_PROPERTY(QVariantList airframeTypes MEMBER _airframeTypes CONSTANT)
Q_PROPERTY(QString currentAirframeType MEMBER _currentAirframeType CONSTANT)
Q_PROPERTY(QString currentVehicleName MEMBER _currentVehicleName CONSTANT)
Q_PROPERTY(int currentVehicleIndex MEMBER _currentVehicleIndex CONSTANT)
Q_PROPERTY(int autostartId MEMBER _autostartId NOTIFY autostartIdChanged)
Q_INVOKABLE void changeAutostart(void);
int currentAirframeIndex(void);
void setCurrentAirframeIndex(int newIndex);
signals:
void autostartIdChanged(int newAutostartId);
private:
static bool _typesRegistered;
UASInterface* _uas;
AutoPilotPlugin* _autoPilotPlugin;
QVariantList _airframeTypes;
QString _currentAirframeType;
QString _currentVehicleName;
int _currentVehicleIndex;
int _autostartId;
};
class Airframe : public QObject
{
Q_OBJECT
public:
Airframe(const QString& name, int autostartId, QObject* parent = NULL);
~Airframe();
Q_PROPERTY(QString text MEMBER _name CONSTANT)
Q_PROPERTY(int autostartId MEMBER _autostartId CONSTANT)
private:
QString _name;
int _autostartId;
};
class AirframeType : public QObject
{
Q_OBJECT
public:
AirframeType(const QString& name, const QString& imageResource, QObject* parent = NULL);
~AirframeType();
Q_PROPERTY(QString name MEMBER _name CONSTANT)
Q_PROPERTY(QString imageResource MEMBER _imageResource CONSTANT)
Q_PROPERTY(QVariantList airframes MEMBER _airframes CONSTANT)
void addAirframe(const QString& name, int autostartId);
private:
QString _name;
QString _imageResource;
QVariantList _airframes;
};
#endif
......@@ -5,11 +5,14 @@ import QtQuick.Controls.Styles 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Controllers 1.0
Column {
anchors.fill: parent
anchors.margins: 8
AirframeComponentController { id: controller }
Row {
width: parent.width
......@@ -24,12 +27,24 @@ Column {
Row {
width: parent.width
QGCLabel { id: airframe; text: "Airframe:" }
QGCLabel { id: airframeType; text: "Airframe type:" }
QGCLabel {
property Fact fact: Fact { name: "SYS_AUTOSTART" }
horizontalAlignment: Text.AlignRight
width: parent.width - airframeType.contentWidth
text: fact.value == 0 ? "Setup required" : controller.currentAirframeType
}
}
Row {
width: parent.width
QGCLabel { id: vehicle; text: "Vehicle:" }
QGCLabel {
property Fact fact: Fact { name: "SYS_AUTOSTART" }
horizontalAlignment: Text.AlignRight
width: parent.width - airframe.contentWidth
text: fact.value == 0 ? "Setup required" : fact.value
width: parent.width - vehicle.contentWidth
text: fact.value == 0 ? "Setup required" : controller.currentVehicleName
}
}
}
......@@ -27,6 +27,7 @@
#include "QGCUASParamManagerInterface.h"
#include "PX4ParameterFacts.h"
#include "FlightModesComponentController.h"
#include "AirframeComponentController.h"
#include "QGCMessageBox.h"
/// @file
......@@ -76,6 +77,7 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(UASInterface* uas, QObject* parent) :
Q_ASSERT(uas);
qmlRegisterType<FlightModesComponentController>("QGroundControl.Controllers", 1, 0, "FlightModesComponentController");
qmlRegisterType<AirframeComponentController>("QGroundControl.Controllers", 1, 0, "AirframeComponentController");
_parameterFacts = new PX4ParameterFacts(uas, this);
Q_CHECK_PTR(_parameterFacts);
......
This diff is collapsed.
#ifndef QGCPX4AIRFRAMECONFIG_H
#define QGCPX4AIRFRAMECONFIG_H
#include <QWidget>
#include <UASInterface.h>
class QProgressDialog;
namespace Ui {
class QGCPX4AirframeConfig;
}
class QGCPX4AirframeConfig : public QWidget
{
Q_OBJECT
public:
explicit QGCPX4AirframeConfig(QWidget *parent = 0);
~QGCPX4AirframeConfig();
public slots:
/**
* @brief Set the system currently operated on by this widget
* @param uas The currently active / configured system
*/
void setActiveUAS(UASInterface* uas);
/**
* @brief Handle parameter changes
* @param uas
* @param component
* @param parameterName
* @param value
*/
void parameterChanged(int uas, int component, QString parameterName, QVariant value);
/**
* @brief Quadrotor in X configuration has been selected
*/
void quadXSelected();
/**
* @brief Quadrotor in X configuration has been selected with sub-type
* @param index The autostart index which maps to a particular sub-type
*/
void quadXSelected(int index);
void simSelected();
void simSelected(int index);
void planeSelected();
void planeSelected(int index);
void flyingWingSelected();
void flyingWingSelected(int index);
void quadPlusSelected();
void quadPlusSelected(int index);
void hexaXSelected();
void hexaXSelected(int index);
void hexaPlusSelected();
void hexaPlusSelected(int index);
void octoXSelected();
void octoXSelected(int index);
void octoPlusSelected();
void octoPlusSelected(int index);
void hSelected();
void hSelected(int index);
/**
* @brief Apply changes and reboot system
*/
void applyAndReboot();
protected slots:
void checkConfigState();
protected:
/**
* @brief Set the ID of the current airframe
* @param id the ID as defined by the PX4 SYS_AUTOSTART enum
*/
void setAirframeID(int id);
/**
* @brief Enable automatic configuration
* @param enabled If true, the system sets the default gains for this platform on the next boot
*/
void setAutoConfig(bool enabled);
void uncheckAll();
enum CONFIG_STATE {
CONFIG_STATE_ABORT = 0,
CONFIG_STATE_SEND,
CONFIG_STATE_WAIT_PENDING,
CONFIG_STATE_REBOOT
};
private:
UASInterface* mav;
QGCUASParamManagerInterface *paramMgr;
QProgressDialog* progress;
unsigned pendingParams;
enum CONFIG_STATE configState;
int selectedId;
Ui::QGCPX4AirframeConfig *ui;
};
#endif // QGCPX4AIRFRAMECONFIG_H
This diff is collapsed.
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