Browse Source

Completed

QGC4.4
dogmaphobic 9 years ago
parent
commit
e09ff0eb3c
  1. 81
      src/AutoPilotPlugins/PX4/CameraComponent.qml
  2. 30
      src/AutoPilotPlugins/PX4/CameraComponentSummary.qml
  3. 5
      src/FactSystem/FactControls/FactPanelController.cc
  4. 8
      src/FactSystem/FactControls/FactPanelController.h

81
src/AutoPilotPlugins/PX4/CameraComponent.qml

@ -49,8 +49,9 @@ QGCView {
property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 18 property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 18
property Fact _camTriggerMode: controller.getParameterFact(-1, "TRIG_MODE") property Fact _camTriggerMode: controller.getParameterFact(-1, "TRIG_MODE")
property Fact _camTriggerPol: controller.getParameterFact(-1, "TRIG_POLARITY", false) // Don't bitch about missing as these only exist if trigger mode is enabled
property Fact _auxPins: controller.getParameterFact(-1, "TRIG_PINS", false) // Ditto
property bool _hasFacts: false
property bool _rebooting: false property bool _rebooting: false
property var _auxChannels: [ 0, 0, 0, 0, 0, 0] property var _auxChannels: [ 0, 0, 0, 0, 0, 0]
@ -61,28 +62,24 @@ QGCView {
} }
function setAuxPins() { function setAuxPins() {
var values = [] if(_auxPins) {
for(var i = 0; i < 6; i++) { var values = ""
if(_auxChannels[i]) { for(var i = 0; i < 6; i++) {
values.push((i+1).toString()) if(_auxChannels[i]) {
values += ((i+1).toString())
}
} }
_auxPins.value = parseInt(values)
} }
var auxFact = controller.getParameterFact(-1, "TRIG_PINS")
auxFact.value = parseInt(values)
console.log(values)
} }
Component.onCompleted: { Component.onCompleted: {
_hasFacts = _camTriggerMode.value > 0 if(_auxPins) {
if(_hasFacts) {
clearAuxArray() clearAuxArray()
var auxFact = controller.getParameterFact(-1, "TRIG_PINS") var values = _auxPins.value.toString()
var values = auxFact.value.toString()
console.log(values)
for(var i = 0; i < values.length; i++) { for(var i = 0; i < values.length; i++) {
var b = parseInt(values[i]) - 1 var b = parseInt(values[i]) - 1
if(b >= 0 && b < 6) { if(b >= 0 && b < 6) {
console.log(b)
_auxChannels[b] = 1 _auxChannels[b] = 1
} }
} }
@ -110,6 +107,7 @@ QGCView {
anchors.right: parent.right anchors.right: parent.right
text: qsTr("Apply and Restart") text: qsTr("Apply and Restart")
onClicked: { onClicked: {
//-- This will reboot the vehicle! We're set not to allow changes if armed.
QGroundControl.multiVehicleManager.activeVehicle.rebootVehicle() QGroundControl.multiVehicleManager.activeVehicle.rebootVehicle()
applyAndRestart.visible = false applyAndRestart.visible = false
_rebooting = true _rebooting = true
@ -120,14 +118,14 @@ QGCView {
clip: true clip: true
anchors.top: applyAndRestart.visible ? applyAndRestart.bottom : parent.top anchors.top: applyAndRestart.visible ? applyAndRestart.bottom : parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter anchors.left: parent.left
width: mainCol.width anchors.right: parent.right
contentHeight: mainCol.height contentHeight: mainCol.height
contentWidth: mainCol.width
flickableDirection: Flickable.VerticalFlick flickableDirection: Flickable.VerticalFlick
Column { Column {
id: mainCol id: mainCol
spacing: _margins spacing: _margins
anchors.horizontalCenter: parent.horizontalCenter
/* /*
**** Camera Trigger **** **** Camera Trigger ****
*/ */
@ -185,10 +183,10 @@ QGCView {
} }
FactTextField { FactTextField {
id: timeIntervalField id: timeIntervalField
fact: _hasFacts ? controller.getParameterFact(-1, "TRIG_INTERVAL") : null fact: controller.getParameterFact(-1, "TRIG_INTERVAL", false)
showUnits: true showUnits: true
width: _editFieldWidth width: _editFieldWidth
enabled: _hasFacts && _camTriggerMode.value === 2 enabled: _auxPins && _camTriggerMode.value === 2
} }
} }
Row { Row {
@ -200,10 +198,10 @@ QGCView {
} }
FactTextField { FactTextField {
id: trigDistField id: trigDistField
fact: _hasFacts ? controller.getParameterFact(-1, "TRIG_DISTANCE") : null fact: controller.getParameterFact(-1, "TRIG_DISTANCE", false)
showUnits: true showUnits: true
width: _editFieldWidth width: _editFieldWidth
enabled: _hasFacts && _camTriggerMode.value === 3 enabled: _auxPins && _camTriggerMode.value === 3
} }
} }
} }
@ -216,20 +214,17 @@ QGCView {
QGCLabel { QGCLabel {
text: qsTr("Hardware Settings") text: qsTr("Hardware Settings")
font.weight: Font.DemiBold font.weight: Font.DemiBold
visible: _hasFacts visible: _auxPins
} }
Rectangle { Rectangle {
color: palette.windowShade color: palette.windowShade
width: camTrigRect.width width: camTrigRect.width
height: camHardwareRow.height + _margins * 2 height: camHardwareRow.height + _margins * 2
visible: _hasFacts visible: _auxPins
Row { Row {
id: camHardwareRow id: camHardwareRow
spacing: _margins spacing: _margins
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
property Fact _camTriggerPol: controller.getParameterFact(-1, "TRIG_POLARITY")
Item { width: _margins * 0.5; height: 1; } Item { width: _margins * 0.5; height: 1; }
Item { Item {
height: ScreenTools.defaultFontPixelWidth * 10 height: ScreenTools.defaultFontPixelWidth * 10
@ -258,13 +253,23 @@ QGCView {
width: ScreenTools.defaultFontPixelWidth * 2 width: ScreenTools.defaultFontPixelWidth * 2
height: ScreenTools.defaultFontPixelWidth * 2 height: ScreenTools.defaultFontPixelWidth * 2
border.color: palette.text border.color: palette.text
color: _auxChannels[model.index] ? "green" : palette.windowShadeDark color: {
if(_auxPins) {
var pins = _auxPins.value.toString()
var pin = (model.index + 1).toString()
if(pins.indexOf(pin) < 0)
return palette.windowShadeDark
else
return "green"
} else {
return palette.windowShade
}
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
_auxChannels[model.index] = 1 - _auxChannels[model.index] _auxChannels[model.index] = 1 - _auxChannels[model.index]
auxPin.color = _auxChannels[model.index] ? "green" : palette.windowShadeDark auxPin.color = _auxChannels[model.index] ? "green" : palette.windowShadeDark
console.log(model.index + " " + _auxChannels[model.index])
setAuxPins() setAuxPins()
} }
} }
@ -288,20 +293,28 @@ QGCView {
spacing: _margins * 0.5 spacing: _margins * 0.5
ExclusiveGroup { id: polarityGroup } ExclusiveGroup { id: polarityGroup }
QGCRadioButton { QGCRadioButton {
checked: _hasFacts && camHardwareRow._camTriggerPol.value === 0 checked: _camTriggerPol && _camTriggerPol.value === 0
exclusiveGroup: polarityGroup exclusiveGroup: polarityGroup
text: "Low (0V)" text: "Low (0V)"
onClicked: _camTriggerPol.value = 0 onClicked: {
if(_camTriggerPol) {
_camTriggerPol.value = 0
}
}
} }
QGCRadioButton { QGCRadioButton {
checked: _hasFacts && camHardwareRow._camTriggerPol.value > 0 checked: _camTriggerPol && _camTriggerPol.value > 0
exclusiveGroup: polarityGroup exclusiveGroup: polarityGroup
text: "High (3.3V)" text: "High (3.3V)"
onClicked: _camTriggerPol.value = 1 onClicked: {
if(_camTriggerPol) {
_camTriggerPol.value = 1
}
}
} }
} }
} }
Item { width: 1; height: _margins; } Item { width: 1; height: _margins * 0.5; }
Row { Row {
QGCLabel { QGCLabel {
text: qsTr("Trigger Period") text: qsTr("Trigger Period")
@ -311,7 +324,7 @@ QGCView {
} }
FactTextField { FactTextField {
id: trigPeriodField id: trigPeriodField
fact: controller.getParameterFact(-1, "TRIG_ACT_TIME") fact: controller.getParameterFact(-1, "TRIG_ACT_TIME", false)
showUnits: true showUnits: true
width: _editFieldWidth width: _editFieldWidth
} }

30
src/AutoPilotPlugins/PX4/CameraComponentSummary.qml

@ -15,15 +15,43 @@ FactPanel {
FactPanelController { id: controller; factPanel: panel } FactPanelController { id: controller; factPanel: panel }
property Fact _camTriggerMode: controller.getParameterFact(-1, "TRIG_MODE") property Fact _camTriggerMode: controller.getParameterFact(-1, "TRIG_MODE")
property Fact _camTriggerPol: controller.getParameterFact(-1, "TRIG_POLARITY", false) // Don't bitch about missing as these only exist if trigger mode is enabled
property Fact _auxPins: controller.getParameterFact(-1, "TRIG_PINS", false) // Ditto
property Fact _timeInterval: controller.getParameterFact(-1, "TRIG_INTERVAL", false) // Ditto
property Fact _distanceInterval:controller.getParameterFact(-1, "TRIG_DISTANCE", false) // Ditto
Column { Column {
anchors.fill: parent anchors.fill: parent
anchors.margins: 8 anchors.margins: 8
VehicleSummaryRow { VehicleSummaryRow {
labelText: qsTr("Camera Trigger Mode:") labelText: qsTr("Camera trigger mode:")
valueText: _camTriggerMode ? _camTriggerMode.enumStringValue : "" valueText: _camTriggerMode ? _camTriggerMode.enumStringValue : ""
} }
VehicleSummaryRow {
visible: _timeInterval && _camTriggerMode.value === 2
labelText: qsTr("Time interval:")
valueText: _timeInterval ? _timeInterval.value : ""
}
VehicleSummaryRow {
visible: _distanceInterval && _camTriggerMode.value === 3
labelText: qsTr("Distance interval:")
valueText: _distanceInterval ? _distanceInterval.value : ""
}
VehicleSummaryRow {
visible: _auxPins
labelText: qsTr("AUX pins:")
valueText: _auxPins ? _auxPins.value : ""
}
VehicleSummaryRow {
visible: _camTriggerPol
labelText: qsTr("AUX pin polarity:")
valueText: _camTriggerPol ? (_camTriggerPol.value ? "High (3.3V)" : "Low (0V)") : ""
}
} }
} }

5
src/FactSystem/FactControls/FactPanelController.cc

@ -129,14 +129,15 @@ void FactPanelController::_checkForMissingFactPanel(void)
} }
} }
Fact* FactPanelController::getParameterFact(int componentId, const QString& name) Fact* FactPanelController::getParameterFact(int componentId, const QString& name, bool reportMissing)
{ {
if (_autopilot && _autopilot->parameterExists(componentId, name)) { if (_autopilot && _autopilot->parameterExists(componentId, name)) {
Fact* fact = _autopilot->getParameterFact(componentId, name); Fact* fact = _autopilot->getParameterFact(componentId, name);
QQmlEngine::setObjectOwnership(fact, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(fact, QQmlEngine::CppOwnership);
return fact; return fact;
} else { } else {
_reportMissingParameter(componentId, name); if(reportMissing)
_reportMissingParameter(componentId, name);
return NULL; return NULL;
} }
} }

8
src/FactSystem/FactControls/FactPanelController.h

@ -40,15 +40,15 @@ Q_DECLARE_LOGGING_CATEGORY(FactPanelControllerLog)
/// missing Facts from C++ code. /// missing Facts from C++ code.
class FactPanelController : public QObject class FactPanelController : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
FactPanelController(void); FactPanelController(void);
Q_PROPERTY(QQuickItem* factPanel READ factPanel WRITE setFactPanel) Q_PROPERTY(QQuickItem* factPanel READ factPanel WRITE setFactPanel)
Q_INVOKABLE Fact* getParameterFact(int componentId, const QString& name); Q_INVOKABLE Fact* getParameterFact (int componentId, const QString& name, bool reportMissing = true);
Q_INVOKABLE bool parameterExists(int componentId, const QString& name); Q_INVOKABLE bool parameterExists (int componentId, const QString& name);
QQuickItem* factPanel(void); QQuickItem* factPanel(void);
void setFactPanel(QQuickItem* panel); void setFactPanel(QQuickItem* panel);

Loading…
Cancel
Save