13 changed files with 469 additions and 5 deletions
@ -0,0 +1,206 @@ |
|||||||
|
import QtQuick 2.3 |
||||||
|
import QtQml.Models 2.1 |
||||||
|
|
||||||
|
import QGroundControl 1.0 |
||||||
|
import QGroundControl.FlightDisplay 1.0 |
||||||
|
import QGroundControl.ScreenTools 1.0 |
||||||
|
import QGroundControl.Controls 1.0 |
||||||
|
import QGroundControl.Palette 1.0 |
||||||
|
import QGroundControl.Vehicle 1.0 |
||||||
|
|
||||||
|
// This class stores the data and functions of the check list but NOT the GUI (which is handled somewhere else). |
||||||
|
Item { |
||||||
|
// Properties |
||||||
|
property int unhealthySensors: _activeVehicle ? _activeVehicle.sensorsUnhealthyBits : 0 |
||||||
|
property bool gpsLock: _activeVehicle ? _activeVehicle.gps.lock.rawValue>=3 : 0 |
||||||
|
property var batPercentRemaining: _activeVehicle ? _activeVehicle.battery.percentRemaining.value : 0 |
||||||
|
property bool audioMuted: QGroundControl.settingsManager.appSettings.audioMuted.rawValue |
||||||
|
property ObjectModel checkListItems: _checkListItems |
||||||
|
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle |
||||||
|
property int _checkState: _activeVehicle ? (_activeVehicle.armed ? 1 + (buttonActuators._state + buttonMotors._state + buttonMission._state + buttonSoundOutput._state) / 4 / 4 : 0) : 0 ; // Shows progress of checks inside the checklist - unlocks next check steps in groups |
||||||
|
|
||||||
|
// Connections |
||||||
|
onBatPercentRemainingChanged: buttonBattery.updateItem(); |
||||||
|
onGpsLockChanged: buttonSensors.updateItem(); |
||||||
|
onAudioMutedChanged: buttonSoundOutput.updateItem(); |
||||||
|
onUnhealthySensorsChanged: updateVehicleDependentItems(); |
||||||
|
|
||||||
|
Connections { |
||||||
|
target: QGroundControl.multiVehicleManager |
||||||
|
onActiveVehicleChanged: onActiveVehicleChanged(); |
||||||
|
} |
||||||
|
Component.onCompleted: { |
||||||
|
if(QGroundControl.multiVehicleManager.vehicles.count > 0) { |
||||||
|
onActiveVehicleChanged(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// Functions |
||||||
|
function updateVehicleDependentItems() { |
||||||
|
buttonSensors.updateItem(); |
||||||
|
buttonBattery.updateItem(); |
||||||
|
buttonRC.updateItem(); |
||||||
|
buttonEstimator.updateItem(); |
||||||
|
} |
||||||
|
function onActiveVehicleChanged() { |
||||||
|
buttonSoundOutput.updateItem(); // Just updated here for initialization once we connect to a vehicle |
||||||
|
updateVehicleDependentItems(); |
||||||
|
} |
||||||
|
function resetNrClicks() { |
||||||
|
buttonHardware.resetNrClicks(); |
||||||
|
buttonBattery.resetNrClicks(); |
||||||
|
buttonRC.resetNrClicks(); |
||||||
|
buttonActuators.resetNrClicks(); |
||||||
|
buttonMotors.resetNrClicks(); |
||||||
|
buttonMission.resetNrClicks(); |
||||||
|
buttonSoundOutput.resetNrClicks(); |
||||||
|
buttonPayload.resetNrClicks(); |
||||||
|
buttonWeather.resetNrClicks(); |
||||||
|
buttonFlightAreaFree.resetNrClicks(); |
||||||
|
} |
||||||
|
|
||||||
|
// Check list item data |
||||||
|
ObjectModel { |
||||||
|
id: _checkListItems |
||||||
|
|
||||||
|
// Standard check list items (group 0) - Available from the start |
||||||
|
QGCCheckListItem { |
||||||
|
id: buttonHardware |
||||||
|
name: "Hardware" |
||||||
|
defaulttext: "Props mounted? Wings secured? Tail secured?" |
||||||
|
} |
||||||
|
QGCCheckListItem { |
||||||
|
id: buttonBattery |
||||||
|
name: "Battery" |
||||||
|
pendingtext: "Healthy & charged > 40%. Battery connector firmly plugged?" |
||||||
|
function updateItem() { |
||||||
|
if (!_activeVehicle) { |
||||||
|
_state = 0; |
||||||
|
} else { |
||||||
|
if (!(unhealthySensors & Vehicle.SysStatusSensorBattery) && batPercentRemaining>=40.0) _state = 1+3*(_nrClicked>0); |
||||||
|
else { |
||||||
|
if(unhealthySensors & Vehicle.SysStatusSensorBattery) failuretext="Not healthy. Check console."; |
||||||
|
else if(batPercentRemaining<40.0) failuretext="Low (below 40%). Please recharge."; |
||||||
|
_state = 3; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
QGCCheckListItem { |
||||||
|
id: buttonSensors |
||||||
|
name: "Sensors" |
||||||
|
function updateItem() { |
||||||
|
if (!_activeVehicle) { |
||||||
|
_state = 0; |
||||||
|
} else { |
||||||
|
if(!(unhealthySensors & Vehicle.SysStatusSensor3dMag) && |
||||||
|
!(unhealthySensors & Vehicle.SysStatusSensor3dAccel) && |
||||||
|
!(unhealthySensors & Vehicle.SysStatusSensor3dGyro) && |
||||||
|
!(unhealthySensors & Vehicle.SysStatusSensorAbsolutePressure) && |
||||||
|
!(unhealthySensors & Vehicle.SysStatusSensorDifferentialPressure) && |
||||||
|
!(unhealthySensors & Vehicle.SysStatusSensorGPS)) { |
||||||
|
if(!gpsLock) { |
||||||
|
pendingtext="Pending. Waiting for GPS lock."; |
||||||
|
_state=1; |
||||||
|
} else { |
||||||
|
_state = 4; // All OK |
||||||
|
} |
||||||
|
} else { |
||||||
|
if(unhealthySensors & Vehicle.SysStatusSensor3dMag) failuretext="Failure. Magnetometer issues. Check console."; |
||||||
|
else if(unhealthySensors & Vehicle.SysStatusSensor3dAccel) failuretext="Failure. Accelerometer issues. Check console."; |
||||||
|
else if(unhealthySensors & Vehicle.SysStatusSensor3dGyro) failuretext="Failure. Gyroscope issues. Check console."; |
||||||
|
else if(unhealthySensors & Vehicle.SysStatusSensorAbsolutePressure) failuretext="Failure. Barometer issues. Check console."; |
||||||
|
else if(unhealthySensors & Vehicle.SysStatusSensorDifferentialPressure) failuretext="Failure. Airspeed sensor issues. Check console."; |
||||||
|
else if(unhealthySensors & Vehicle.SysStatusSensorGPS) failuretext="Failure. No valid or low quality GPS signal. Check console."; |
||||||
|
_state = 3; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
QGCCheckListItem { |
||||||
|
id: buttonRC |
||||||
|
name: "Radio Control" |
||||||
|
pendingtext: "Receiving signal. Perform range test & confirm." |
||||||
|
failuretext: "No signal or invalid autopilot-RC config. Check RC and console." |
||||||
|
function updateItem() { |
||||||
|
if (!_activeVehicle) { |
||||||
|
_state = 0; |
||||||
|
} else { |
||||||
|
if (unhealthySensors & Vehicle.SysStatusSensorRCReceiver) {_state = 3} |
||||||
|
else {_state = 1+3*(_nrClicked>0);} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
QGCCheckListItem { |
||||||
|
id: buttonEstimator |
||||||
|
name: "Global position estimate" |
||||||
|
function updateItem() { |
||||||
|
if (!_activeVehicle) { |
||||||
|
_state = 0; |
||||||
|
} else { |
||||||
|
if (unhealthySensors & Vehicle.SysStatusSensorAHRS) {_state = 3;} |
||||||
|
else {_state = 4;} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// Check list item group 1 - Require arming |
||||||
|
QGCLabel {text:qsTr("<i>Please arm the vehicle here.</i>") ; opacity: 0.2+0.8*(QGroundControl.multiVehicleManager.vehicles.count > 0) ; anchors.horizontalCenter:buttonHardware.horizontalCenter ; anchors.topMargin:40 ; anchors.bottomMargin:40;} |
||||||
|
QGCCheckListItem { |
||||||
|
id: buttonActuators |
||||||
|
name: "Actuators" |
||||||
|
group: 1 |
||||||
|
defaulttext: "Move all control surfaces. Did they work properly?" |
||||||
|
} |
||||||
|
QGCCheckListItem { |
||||||
|
id: buttonMotors |
||||||
|
name: "Motors" |
||||||
|
group: 1 |
||||||
|
defaulttext: "Propellers free? Then throttle up gently. Working properly?" |
||||||
|
} |
||||||
|
QGCCheckListItem { |
||||||
|
id: buttonMission |
||||||
|
name: "Mission" |
||||||
|
group: 1 |
||||||
|
defaulttext: "Please confirm mission is valid (waypoints valid, no terrain collision)." |
||||||
|
} |
||||||
|
QGCCheckListItem { |
||||||
|
id: buttonSoundOutput |
||||||
|
name: "Sound output" |
||||||
|
group: 1 |
||||||
|
pendingtext: "QGC audio output enabled. System audio output enabled, too?" |
||||||
|
failuretext: "Failure, QGC audio output is disabled. Please enable it under application settings->general to hear audio warnings!" |
||||||
|
function updateItem() { |
||||||
|
if (!_activeVehicle) { |
||||||
|
_state = 0; |
||||||
|
} else { |
||||||
|
if (audioMuted) {_state = 3 ; _nrClicked=0;} |
||||||
|
else {_state = 1+3*(_nrClicked>0);} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// Check list item group 2 - Final checks before launch |
||||||
|
QGCLabel {text:qsTr("<i>Last preparations before launch</i>") ; opacity : 0.2+0.8*(_checkState >= 2); anchors.horizontalCenter:buttonHardware.horizontalCenter} |
||||||
|
QGCCheckListItem { |
||||||
|
id: buttonPayload |
||||||
|
name: "Payload" |
||||||
|
group: 2 |
||||||
|
defaulttext: "Configured and started?" |
||||||
|
pendingtext: "Payload lid closed?" |
||||||
|
} |
||||||
|
QGCCheckListItem { |
||||||
|
id: buttonWeather |
||||||
|
name: "Wind & weather" |
||||||
|
group: 2 |
||||||
|
defaulttext: "OK for your platform?" |
||||||
|
pendingtext: "Launching into the wind?" |
||||||
|
} |
||||||
|
QGCCheckListItem { |
||||||
|
id: buttonFlightAreaFree |
||||||
|
name: "Flight area" |
||||||
|
group: 2 |
||||||
|
defaulttext: "Launch area and path free of obstacles/people?" |
||||||
|
} |
||||||
|
} // Object Model |
||||||
|
} |
@ -0,0 +1,74 @@ |
|||||||
|
import QtQuick 2.3 |
||||||
|
import QtQuick.Controls 1.2 |
||||||
|
import QtQuick.Controls.Styles 1.4 |
||||||
|
|
||||||
|
import QGroundControl 1.0 |
||||||
|
import QGroundControl.Palette 1.0 |
||||||
|
import QGroundControl.ScreenTools 1.0 |
||||||
|
|
||||||
|
QGCButton { |
||||||
|
property string name: "" |
||||||
|
property int group: 0 |
||||||
|
property string defaulttext: "Not checked yet" |
||||||
|
property string pendingtext: "" |
||||||
|
property string failuretext: "Failure. Check console." |
||||||
|
property int _state: 0 |
||||||
|
property var _color: qgcPal.button |
||||||
|
property int _nrClicked: 0 |
||||||
|
property string _text: qsTr(name)+ ": " + qsTr(defaulttext) |
||||||
|
|
||||||
|
enabled : (_activeVehicle==null || _activeVehicle.connectionLost) ? false : checklist._checkState>=group |
||||||
|
opacity : (_activeVehicle==null || _activeVehicle.connectionLost) ? 0.4 : 0.2+0.8*(checklist._checkState >= group); |
||||||
|
width: 40*ScreenTools.defaultFontPixelWidth |
||||||
|
style: ButtonStyle { |
||||||
|
background: Rectangle {color:_color; border.color: qgcPal.button; radius:3} |
||||||
|
label: Label { |
||||||
|
text: _text |
||||||
|
wrapMode: Text.WordWrap |
||||||
|
horizontalAlignment: Text.AlignHCenter |
||||||
|
color: _state>0 ? qgcPal.mapWidgetBorderLight : qgcPal.buttonText |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// Connections |
||||||
|
onPendingtextChanged: { if(_state==1) {getTextFromState(); getColorFromState();} } |
||||||
|
onFailuretextChanged: { if(_state==3) {getTextFromState(); getColorFromState();} } |
||||||
|
on_StateChanged: { getTextFromState(); getColorFromState(); } |
||||||
|
onClicked: { |
||||||
|
if(_state<2) _nrClicked=_nrClicked+1; //Only allow click-counter to increase when not failed yet |
||||||
|
updateItem(); |
||||||
|
} |
||||||
|
|
||||||
|
//Functions |
||||||
|
function updateItem() { |
||||||
|
// This is the default updateFunction. It assumes the item is a MANUAL check list item, i.e. one that |
||||||
|
// only requires user clicks (one click if pendingtext="", two clicks otherwise) for completion. |
||||||
|
|
||||||
|
if(_nrClicked===0) _state = 0; |
||||||
|
else if(_nrClicked===1) { |
||||||
|
if(pendingtext.length === 0) _state = 4; |
||||||
|
else _state = 1; |
||||||
|
} else _state = 4; |
||||||
|
|
||||||
|
getTextFromState(); |
||||||
|
getColorFromState(); |
||||||
|
} |
||||||
|
function getTextFromState() { |
||||||
|
if(_state === 0) {_text= qsTr(name) + ": " + qsTr(defaulttext)} // Not checked yet |
||||||
|
else if(_state === 1) {_text= "<b>"+qsTr(name)+"</b>" +": " + qsTr(pendingtext)} // Pending |
||||||
|
else if(_state === 2) {_text= "<b>"+qsTr(name)+"</b>" +": " + qsTr("Minor problem")} // Small problem or need further user action to resolve |
||||||
|
else if(_state === 3) {_text= "<b>"+qsTr(name)+"</b>" +": " + qsTr(failuretext)} // Big problem |
||||||
|
else {_text= "<b>"+qsTr(name)+"</b>" +": " + qsTr("OK")} // All OK |
||||||
|
} |
||||||
|
function getColorFromState() { |
||||||
|
if(_state === 0) {_color=qgcPal.button} // Not checked yet |
||||||
|
else if(_state === 1) {_color=Qt.rgba(0.9,0.47,0.2,1)} // Pending |
||||||
|
else if(_state === 2) {_color=Qt.rgba(1.0,0.6,0.2,1)} // Small problem or need further user action to resolve |
||||||
|
else if(_state === 3) {_color=Qt.rgba(0.92,0.22,0.22,1)} // Big problem |
||||||
|
else {_color=Qt.rgba(0.27,0.67,0.42,1)} // All OK |
||||||
|
} |
||||||
|
function resetNrClicks() { |
||||||
|
_nrClicked=0; |
||||||
|
updateItem(); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue