Commit e09ff0eb authored by dogmaphobic's avatar dogmaphobic

Completed

parent 45e27160
...@@ -49,8 +49,9 @@ QGCView { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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
} }
......
...@@ -15,15 +15,43 @@ FactPanel { ...@@ -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)") : ""
}
} }
} }
...@@ -129,14 +129,15 @@ void FactPanelController::_checkForMissingFactPanel(void) ...@@ -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;
} }
} }
......
/*===================================================================== /*=====================================================================
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful, QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>. along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/ ======================================================================*/
#ifndef FactPanelController_H #ifndef FactPanelController_H
...@@ -40,34 +40,34 @@ Q_DECLARE_LOGGING_CATEGORY(FactPanelControllerLog) ...@@ -40,34 +40,34 @@ 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);
protected: protected:
/// Checks for existence of the specified parameters /// Checks for existence of the specified parameters
/// @return true: all parameters exists, false: parameters missing and reported /// @return true: all parameters exists, false: parameters missing and reported
bool _allParametersExists(int componentId, QStringList names); bool _allParametersExists(int componentId, QStringList names);
/// Report a missing parameter to the FactPanel Qml element /// Report a missing parameter to the FactPanel Qml element
void _reportMissingParameter(int componentId, const QString& name); void _reportMissingParameter(int componentId, const QString& name);
Vehicle* _vehicle; Vehicle* _vehicle;
UASInterface* _uas; UASInterface* _uas;
AutoPilotPlugin* _autopilot; AutoPilotPlugin* _autopilot;
private slots: private slots:
void _checkForMissingFactPanel(void); void _checkForMissingFactPanel(void);
private: private:
void _notifyPanelMissingParameter(const QString& missingParam); void _notifyPanelMissingParameter(const QString& missingParam);
void _notifyPanelErrorMsg(const QString& errorMsg); void _notifyPanelErrorMsg(const QString& errorMsg);
...@@ -77,4 +77,4 @@ private: ...@@ -77,4 +77,4 @@ private:
QStringList _delayedMissingParams; QStringList _delayedMissingParams;
}; };
#endif #endif
\ No newline at end of file
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