From 96088ce831f287dbe79aed312b614c2e4cfa0b0f Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sun, 29 Nov 2015 16:48:23 +0100 Subject: [PATCH] LP-183 convert Qml files to use new UAV object syntax --- .../src/share/pfd/default/AltitudeScale.qml | 12 +- ground/gcs/src/share/pfd/default/Compass.qml | 23 ++- ground/gcs/src/share/pfd/default/Info.qml | 128 +++++++------ ground/gcs/src/share/pfd/default/Panels.qml | 179 ++++++++++-------- .../src/share/pfd/default/PfdWorldView.qml | 12 +- .../gcs/src/share/pfd/default/RollScale.qml | 13 +- .../gcs/src/share/pfd/default/SpeedScale.qml | 10 +- ground/gcs/src/share/pfd/default/VsiScale.qml | 24 ++- ground/gcs/src/share/pfd/default/Warnings.qml | 84 ++++---- ground/gcs/src/share/pfd/default/common.js | 8 - 10 files changed, 266 insertions(+), 227 deletions(-) diff --git a/ground/gcs/src/share/pfd/default/AltitudeScale.qml b/ground/gcs/src/share/pfd/default/AltitudeScale.qml index 35a57dba8..1e0aebb23 100644 --- a/ground/gcs/src/share/pfd/default/AltitudeScale.qml +++ b/ground/gcs/src/share/pfd/default/AltitudeScale.qml @@ -1,10 +1,14 @@ import QtQuick 2.0 +import UAVTalk.PositionState 1.0 +import UAVTalk.NedAccel 1.0 +import UAVTalk.PathDesired 1.0 + Item { id: sceneItem property variant sceneSize - property real altitude : -qmlWidget.altitudeFactor * PositionState.Down + property real altitude : -qmlWidget.altitudeFactor * positionState.down SvgElementImage { id: altitude_window @@ -60,7 +64,7 @@ Item { elementName: "altitude-vector" sceneSize: sceneItem.sceneSize - height: -NedAccel.Down * altitude_scale.height/10 + height: -nedAccel.down * altitude_scale.height / 10 anchors.left: parent.left anchors.bottom: parent.verticalCenter @@ -70,12 +74,12 @@ Item { id: altitude_waypoint elementName: "altitude-waypoint" sceneSize: sceneItem.sceneSize - visible: PathDesired.End_Down !== 0.0 + visible: (pathDesired.endDown != 0.0) anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: -altitude_scale.height/10 * (PositionState.Down - PathDesired.End_Down) * qmlWidget.altitudeFactor + anchors.verticalCenterOffset: -altitude_scale.height / 10 * (positionState.Down - pathDesired.endDown) * qmlWidget.altitudeFactor } } diff --git a/ground/gcs/src/share/pfd/default/Compass.qml b/ground/gcs/src/share/pfd/default/Compass.qml index 85163a04e..c75420bbf 100644 --- a/ground/gcs/src/share/pfd/default/Compass.qml +++ b/ground/gcs/src/share/pfd/default/Compass.qml @@ -1,5 +1,11 @@ import QtQuick 2.0 import "." + +import UAVTalk.AttitudeState 1.0 +import UAVTalk.PositionState 1.0 +import UAVTalk.PathDesired 1.0 +import UAVTalk.TakeOffLocation 1.0 + import "common.js" as Utils Item { @@ -32,7 +38,7 @@ Item { x: Math.floor(scaledBounds.x * sceneItem.width) y: Math.floor(scaledBounds.y * sceneItem.height) - rotation: -AttitudeState.Yaw + rotation: -attitudeState.yaw transformOrigin: Item.Center smooth: true @@ -47,11 +53,11 @@ Item { x: Math.floor(scaledBounds.x * sceneItem.width) y: Math.floor(scaledBounds.y * sceneItem.height) - property real home_degrees: 180/3.1415 * Math.atan2(TakeOffLocation.East - PositionState.East, TakeOffLocation.North - PositionState.North) + property real home_degrees: 180 / 3.1415 * Math.atan2(takeOffLocation.east - positionState.east, takeOffLocation.north - positionState.north) - rotation: -AttitudeState.Yaw + home_degrees + rotation: -attitudeState.yaw + home_degrees transformOrigin: Item.Bottom - visible: Utils.toInt(TakeOffLocation.Status) == 0 + visible: (takeOffLocation.status == Status.Valid) } @@ -63,13 +69,14 @@ Item { x: Math.floor(scaledBounds.x * sceneItem.width) y: Math.floor(scaledBounds.y * sceneItem.height) - property real course_degrees: 180/3.1415 * Math.atan2(PathDesired.End_East - PositionState.East, PathDesired.End_North - PositionState.North) + property real course_degrees: 180 / 3.1415 * Math.atan2(pathDesired.endEast - positionState.east, pathDesired.endNorth - positionState.north) - rotation: -AttitudeState.Yaw + course_degrees + rotation: -attitudeState.yaw + course_degrees transformOrigin: Item.Center smooth: true - visible: PathDesired.End_East !== 0.0 && PathDesired.End_East !== 0.0 + // FIXME : why test endEast twice? + visible: ((pathDesired.endEast != 0.0) && (pathDesired.endEast != 0.0)) } @@ -86,7 +93,7 @@ Item { Text { id: compass_text - text: Math.floor(AttitudeState.Yaw).toFixed() + text: Math.floor(attitudeState.yaw).toFixed() color: "white" font { family: pt_bold.name diff --git a/ground/gcs/src/share/pfd/default/Info.qml b/ground/gcs/src/share/pfd/default/Info.qml index 401e92e62..a03cafc5b 100644 --- a/ground/gcs/src/share/pfd/default/Info.qml +++ b/ground/gcs/src/share/pfd/default/Info.qml @@ -1,4 +1,16 @@ import QtQuick 2.0 + +import UAVTalk.HwSettings 1.0 +import UAVTalk.SystemAlarms 1.0 +import UAVTalk.VelocityState 1.0 +import UAVTalk.TakeOffLocation 1.0 +import UAVTalk.PathDesired 1.0 +import UAVTalk.WaypointActive 1.0 +import UAVTalk.GPSPositionSensor 1.0 as GPSPositionSensor +import UAVTalk.GPSSatellites 1.0 +import UAVTalk.FlightBatterySettings 1.0 +import UAVTalk.FlightBatteryState 1.0 + import "common.js" as Utils Item { @@ -19,29 +31,29 @@ Item { property bool init_dist: false - property real home_heading: 180/3.1415 * Math.atan2(TakeOffLocation.East - PositionState.East, - TakeOffLocation.North - PositionState.North) + property real home_heading: 180 / 3.1415 * Math.atan2(takeOffLocation.east - positionState.east, + takeOffLocation.north - positionState.north) - property real home_distance: Math.sqrt(Math.pow((TakeOffLocation.East - PositionState.East),2) + - Math.pow((TakeOffLocation.North - PositionState.North),2)) + property real home_distance: Math.sqrt(Math.pow((takeOffLocation.east - positionState.east), 2) + + Math.pow((takeOffLocation.north - positionState.north), 2)) - property real wp_heading: 180/3.1415 * Math.atan2(PathDesired.End_East - PositionState.East, - PathDesired.End_North - PositionState.North) + property real wp_heading: 180 / 3.1415 * Math.atan2(pathDesired.endEast - positionState.east, + pathDesired.endNorth - positionState.north) - property real wp_distance: Math.sqrt(Math.pow((PathDesired.End_East - PositionState.East),2) + - Math.pow(( PathDesired.End_North - PositionState.North),2)) + property real wp_distance: Math.sqrt(Math.pow((pathDesired.endEast - positionState.east), 2) + + Math.pow((pathDesired.endNorth - positionState.north), 2)) - property real current_velocity: Math.sqrt(Math.pow(VelocityState.North,2)+Math.pow(VelocityState.East,2)) + property real current_velocity: Math.sqrt(Math.pow(velocityState.north, 2) + Math.pow(velocityState.east, 2)) - property real home_eta: (home_distance > 0 && current_velocity > 0 ? Math.round(home_distance/current_velocity) : 0) + property real home_eta: (home_distance > 0 && current_velocity > 0 ? Math.round(home_distance / current_velocity) : 0) property real home_eta_h: (home_eta > 0 ? Math.floor(home_eta / 3600) : 0 ) - property real home_eta_m: (home_eta > 0 ? Math.floor((home_eta - home_eta_h*3600)/60) : 0) - property real home_eta_s: (home_eta > 0 ? Math.floor(home_eta - home_eta_h*3600 - home_eta_m*60) : 0) + property real home_eta_m: (home_eta > 0 ? Math.floor((home_eta - home_eta_h * 3600) / 60) : 0) + property real home_eta_s: (home_eta > 0 ? Math.floor(home_eta - home_eta_h * 3600 - home_eta_m * 60) : 0) property real wp_eta: (wp_distance > 0 && current_velocity > 0 ? Math.round(wp_distance/current_velocity) : 0) property real wp_eta_h: (wp_eta > 0 ? Math.floor(wp_eta / 3600) : 0 ) - property real wp_eta_m: (wp_eta > 0 ? Math.floor((wp_eta - wp_eta_h*3600)/60) : 0) - property real wp_eta_s: (wp_eta > 0 ? Math.floor(wp_eta - wp_eta_h*3600 - wp_eta_m*60) : 0) + property real wp_eta_m: (wp_eta > 0 ? Math.floor((wp_eta - wp_eta_h * 3600) / 60) : 0) + property real wp_eta_s: (wp_eta > 0 ? Math.floor(wp_eta - wp_eta_h * 3600 - wp_eta_m * 60) : 0) function reset_distance() { total_distance = 0; @@ -49,8 +61,8 @@ Item { function compute_distance(posEast,posNorth) { if (total_distance == 0 && !init_dist) { init_dist = "true"; posEast_old = posEast; posNorth_old = posNorth; } - if (posEast > posEast_old+3 || posEast < posEast_old-3 || posNorth > posNorth_old+3 || posNorth < posNorth_old-3) { - total_distance += Math.sqrt(Math.pow((posEast - posEast_old ),2) + Math.pow((posNorth - posNorth_old),2)); + if (posEast > posEast_old+3 || posEast < posEast_old - 3 || posNorth > posNorth_old + 3 || posNorth < posNorth_old - 3) { + total_distance += Math.sqrt(Math.pow((posEast - posEast_old ), 2) + Math.pow((posNorth - posNorth_old), 2)); total_distance_km = total_distance / 1000; posEast_old = posEast; @@ -76,14 +88,14 @@ Item { // property real bar_width: (info_bg.height + info_bg.width) / 110 - property int satsInView: Utils.toInt(GPSSatellites.SatsInView) - property variant gps_tooltip: "Altitude : "+GPSPositionSensor.Altitude.toFixed(2) +"m\n"+ - "H/V/P DOP : "+GPSPositionSensor.HDOP.toFixed(2)+"/"+GPSPositionSensor.VDOP.toFixed(2)+"/"+GPSPositionSensor.PDOP.toFixed(2)+"m\n"+ - satsInView+" Sats in view" + property int satsInView: gpsSatellites.satsInView + property variant gps_tooltip: "Altitude : " + gpsPositionSensor.altitude.toFixed(2) + "m\n" + + "H/V/P DOP : " + gpsPositionSensor.hdop.toFixed(2) + "/" + gpsPositionSensor.vdop.toFixed(2) + "/" + gpsPositionSensor.pdop.toFixed(2) + "m\n" + + satsInView + " Sats in view" Repeater { id: satNumberBar - property int satNumber : Utils.toInt(GPSPositionSensor.Satellites) + property int satNumber : gpsPositionSensor.satellites model: 13 Rectangle { @@ -95,9 +107,9 @@ Item { text: gps_tooltip } - x: Math.round((bar_width*4.5) + (bar_width * 1.6 * index)) + x: Math.round((bar_width * 4.5) + (bar_width * 1.6 * index)) height: bar_width * index * 0.6 - y: (bar_width*8) - height + y: (bar_width * 8) - height color: "green" opacity: satNumberBar.satNumber >= minSatNumber ? 1 : 0.4 } @@ -112,10 +124,10 @@ Item { } Text { - property int satNumber : Utils.toInt(GPSPositionSensor.Satellites) + property int satNumber : gpsPositionSensor.satellites - text: [satNumber > 5 ? " " + satNumber.toString() + " sats - " : ""] + - ["NO GPS", "NO FIX", "2D", "3D"][Utils.toInt(GPSPositionSensor.Status)] + text: [satNumber > 5 ? " " + satNumber.toString() + " sats - " : ""] + + ["NO GPS", "NO FIX", "2D", "3D"][gpsPositionSensor.status] anchors.centerIn: parent font.pixelSize: parent.height*1.3 font.family: pt_bold.name @@ -144,7 +156,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: Math.floor(scaledBounds.y * sceneItem.height) - visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1 + visible: (systemAlarms.alarmPathPlan == Alarm.OK) } SvgElementPositionItem { @@ -153,7 +165,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: Math.floor(scaledBounds.y * sceneItem.height) - visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1 + visible: (systemAlarms.alarmPathPlan == Alarm.OK) Text { text: " "+wp_heading.toFixed(1)+"°" @@ -174,7 +186,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: Math.floor(scaledBounds.y * sceneItem.height) - visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1 + visible: (systemAlarms.alarmPathPlan == Alarm.OK) Text { text: " "+wp_distance.toFixed(0)+" m" @@ -195,7 +207,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: Math.floor(scaledBounds.y * sceneItem.height) - visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1 + visible: (systemAlarms.alarmPathPlan == Alarm.OK) MouseArea { id: total_dist_mouseArea; anchors.fill: parent; cursorShape: Qt.PointingHandCursor; onClicked: reset_distance()} @@ -213,7 +225,7 @@ Item { Timer { interval: 1000; running: true; repeat: true; - onTriggered: {if (Utils.toInt(GPSPositionSensor.Status) == 3) compute_distance(PositionState.East,PositionState.North)} + onTriggered: { if (gpsPositionSensor.status == GPSPositionSensor.Status.Fix3D) compute_distance(positionState.east, positionState.north) } } } @@ -223,7 +235,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: Math.floor(scaledBounds.y * sceneItem.height) - visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1 + visible: (systemAlarms.alarmPathPlan == Alarm.OK) Text { text: Utils.formatTime(wp_eta_h) + ":" + Utils.formatTime(wp_eta_m) + ":" + Utils.formatTime(wp_eta_s) @@ -244,10 +256,10 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: Math.floor(scaledBounds.y * sceneItem.height) - visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1 + visible: (systemAlarms.alarmPathPlan == Alarm.OK) Text { - text: (WaypointActive.Index+1)+" / "+PathPlan.WaypointCount + text: (waypointActive.index + 1) + " / " + pathPlan.waypointCount anchors.centerIn: parent color: "cyan" @@ -265,10 +277,10 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: Math.floor(scaledBounds.y * sceneItem.height) - visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1 + visible: (systemAlarms.alarmPathPlan == Alarm.OK) Text { - text: ["GOTO ENDPOINT","FOLLOW VECTOR","CIRCLE RIGHT","CIRCLE LEFT","FIXED ATTITUDE","SET ACCESSORY","DISARM ALARM","LAND","BRAKE","VELOCITY","AUTO TAKEOFF"][Utils.toInt(PathDesired.Mode)] + text: ["GOTO ENDPOINT","FOLLOW VECTOR","CIRCLE RIGHT","CIRCLE LEFT","FIXED ATTITUDE","SET ACCESSORY","DISARM ALARM","LAND","BRAKE","VELOCITY","AUTO TAKEOFF"][pathDesired.mode] anchors.centerIn: parent color: "cyan" @@ -291,11 +303,11 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: scaledBounds.y * sceneItem.height - visible: (Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1) && (Utils.toInt(HwSettings.OptionalModules_Battery) == 1) + visible: ((systemAlarms.alarmPathPlan != Alarm.OK) && (hwSettings.optionalModulesBattery == OptionalModules.Enabled)) Rectangle { anchors.fill: parent - color: Utils.toInt(FlightBatterySettings.NbCells) > 0 ? info.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)] : "black" + color: (flightBatterySettings.nbCells > 0) ? info.batColors[systemAlarms.alarmBattery] : "black" } } @@ -306,7 +318,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: Math.floor(scaledBounds.y * sceneItem.height) - visible: (Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1) && (Utils.toInt(HwSettings.OptionalModules_Battery) == 1) + visible: ((systemAlarms.alarmPathPlan != Alarm.OK) && (hwSettings.optionalModulesBattery == OptionalModules.Enabled)) } SvgElementPositionItem { @@ -317,14 +329,14 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: scaledBounds.y * sceneItem.height - visible: (Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1) && (Utils.toInt(HwSettings.OptionalModules_Battery) == 1) + visible: ((systemAlarms.alarmPathPlan != Alarm.OK) && (hwSettings.optionalModulesBattery == OptionalModules.Enabled)) Rectangle { anchors.fill: parent color: "transparent" Text { - text: FlightBatteryState.Voltage.toFixed(2) + text: flightBatteryState.voltage.toFixed(2) anchors.centerIn: parent color: "white" font { @@ -344,14 +356,14 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: scaledBounds.y * sceneItem.height - visible: (Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1) && (Utils.toInt(HwSettings.OptionalModules_Battery) == 1) + visible: ((systemAlarms.alarmPathPlan != Alarm.OK) && (hwSettings.optionalModulesBattery == OptionalModules.Enabled)) Rectangle { anchors.fill: parent color: "transparent" Text { - text: FlightBatteryState.Current.toFixed(2) + text: flightBatteryState.current.toFixed(2) anchors.centerIn: parent color: "white" font { @@ -371,7 +383,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: scaledBounds.y * sceneItem.height - visible: (Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1) && (Utils.toInt(HwSettings.OptionalModules_Battery) == 1) + visible: ((systemAlarms.alarmPathPlan != Alarm.OK) && (hwSettings.optionalModulesBattery == OptionalModules.Enabled)) Rectangle { anchors.fill: parent @@ -380,23 +392,23 @@ Item { text: "Reset consumed energy" } - MouseArea { - id: reset_consumed_energy_mouseArea; + MouseArea { + id: reset_consumed_energy_mouseArea; anchors.fill: parent; - cursorShape: Qt.PointingHandCursor; + cursorShape: Qt.PointingHandCursor; onClicked: qmlWidget.resetConsumedEnergy(); } - // Alarm based on FlightBatteryState.EstimatedFlightTime < 120s orange, < 60s red - color: (FlightBatteryState.EstimatedFlightTime <= 120 && FlightBatteryState.EstimatedFlightTime > 60 ? "orange" : - (FlightBatteryState.EstimatedFlightTime <= 60 ? "red": info.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)])) + // Alarm based on flightBatteryState.estimatedFlightTime < 120s orange, < 60s red + color: ((flightBatteryState.estimatedFlightTime <= 120) && (flightBatteryState.estimatedFlightTime > 60)) ? "orange" : + (flightBatteryState.estimatedFlightTime <= 60) ? "red" : info.batColors[systemAlarms.alarmBattery] border.color: "white" border.width: topbattery_volt.width * 0.01 radius: border.width * 4 Text { - text: FlightBatteryState.ConsumedEnergy.toFixed(0) + text: flightBatteryState.consumedEnergy.toFixed(0) anchors.centerIn: parent color: "white" font { @@ -417,7 +429,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: Math.floor(scaledBounds.y * sceneItem.height) - visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1 + visible: (systemAlarms.alarmPathPlan != Alarm.OK) } SvgElementPositionItem { @@ -426,7 +438,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: Math.floor(scaledBounds.y * sceneItem.height) - visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1 + visible: (systemAlarms.alarmPathPlan != Alarm.OK) TooltipArea { text: "Reset distance counter" @@ -448,7 +460,7 @@ Item { Timer { interval: 1000; running: true; repeat: true; - onTriggered: {if (Utils.toInt(GPSPositionSensor.Status) == 3) compute_distance(PositionState.East,PositionState.North)} + onTriggered: { if (gpsPositionSensor.status == GPSPositionSensor.Status.Fix3D) compute_distance(positionState.east, positionState.north) } } } @@ -467,7 +479,7 @@ Item { states: State { name: "fading" - when: Utils.toInt(TakeOffLocation.Status) == 0 + when: (takeOffLocation.status == Status.Valid) PropertyChanges { target: home_bg; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; } } @@ -488,7 +500,7 @@ Item { states: State { name: "fading_heading" - when: Utils.toInt(TakeOffLocation.Status) == 0 + when: (takeOffLocation.status == Status.Valid) PropertyChanges { target: home_heading_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; } } @@ -519,7 +531,7 @@ Item { states: State { name: "fading_distance" - when: Utils.toInt(TakeOffLocation.Status) == 0 + when: (takeOffLocation.status == Status.Valid) PropertyChanges { target: home_distance_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; } } @@ -550,7 +562,7 @@ Item { states: State { name: "fading_distance" - when: Utils.toInt(TakeOffLocation.Status) == 0 + when: (takeOffLocation.status == Status.Valid) PropertyChanges { target: home_eta_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; } } diff --git a/ground/gcs/src/share/pfd/default/Panels.qml b/ground/gcs/src/share/pfd/default/Panels.qml index f93c6050f..ca164784b 100644 --- a/ground/gcs/src/share/pfd/default/Panels.qml +++ b/ground/gcs/src/share/pfd/default/Panels.qml @@ -1,14 +1,25 @@ import QtQuick 2.0 + +import UAVTalk.SystemSettings 1.0 +import UAVTalk.RevoSettings 1.0 +import UAVTalk.SystemAlarms 1.0 +import UAVTalk.FlightBatteryState 1.0 +import UAVTalk.GPSPositionSensor 1.0 +import UAVTalk.ManualControlCommand 1.0 +import UAVTalk.MagState 1.0 +import UAVTalk.ReceiverStatus 1.0 +import UAVTalk.OPLinkStatus 1.0 + import "common.js" as Utils Item { id: panels property variant sceneSize - property real est_flight_time: Math.round(FlightBatteryState.EstimatedFlightTime) - property real est_time_h: (est_flight_time > 0 ? Math.floor(est_flight_time / 3600) : 0 ) - property real est_time_m: (est_flight_time > 0 ? Math.floor((est_flight_time - est_time_h*3600)/60) : 0) - property real est_time_s: (est_flight_time > 0 ? Math.floor(est_flight_time - est_time_h*3600 - est_time_m*60) : 0) + property real est_flight_time: Math.round(flightBatteryState.estimatedFlightTime) + property real est_time_h: (est_flight_time > 0) ? Math.floor(est_flight_time / 3600) : 0 + property real est_time_m: (est_flight_time > 0) ? Math.floor((est_flight_time - est_time_h * 3600) / 60) : 0 + property real est_time_s: (est_flight_time > 0) ? Math.floor(est_flight_time - est_time_h * 3600 - est_time_m * 60) : 0 // // Panel functions @@ -72,16 +83,16 @@ Item { property real smeter_angle - property real memory_free : SystemStats.HeapRemaining > 1024 ? SystemStats.HeapRemaining / 1024 : SystemStats.HeapRemaining + property real memory_free : (systemStats.heapRemaining > 1024) ? systemStats.heapRemaining / 1024 : systemStats.heapRemaining // Needed to get correctly int8 value - property int cpuTemp : SystemStats.CPUTemp + property int cpuTemp : systemStats.cpuTemp // Needed to get correctly int8 value, reset value (-127) on disconnect - property int oplm0_db: telemetry_link == 1 ? OPLinkStatus.PairSignalStrengths_0 : -127 - property int oplm1_db: telemetry_link == 1 ? OPLinkStatus.PairSignalStrengths_1 : -127 - property int oplm2_db: telemetry_link == 1 ? OPLinkStatus.PairSignalStrengths_2 : -127 - property int oplm3_db: telemetry_link == 1 ? OPLinkStatus.PairSignalStrengths_3 : -127 + property int oplm0_db: (telemetry_link == 1) ? opLinkStatus.pairSignalStrengths0 : -127 + property int oplm1_db: (telemetry_link == 1) ? opLinkStatus.pairSignalStrengths1 : -127 + property int oplm2_db: (telemetry_link == 1) ? opLinkStatus.pairSignalStrengths2 : -127 + property int oplm3_db: (telemetry_link == 1) ? opLinkStatus.pairSignalStrengths3 : -127 property real telemetry_sum property real telemetry_sum_old @@ -90,9 +101,10 @@ Item { // Hack : check if telemetry is active. Works with real link and log replay function telemetry_check() { - telemetry_sum = OPLinkStatus.RXRate + OPLinkStatus.RXRate + // FIXME : why rxRate + rxRate? + telemetry_sum = opLinkStatus.rxRate + opLinkStatus.rxRate - if (telemetry_sum != telemetry_sum_old || Utils.toInt(OPLinkStatus.LinkState) == 4) { + if (telemetry_sum != telemetry_sum_old || (opLinkStatus.linkState == LinkState.Connected)) { telemetry_link = 1 } else { telemetry_link = 0 @@ -133,7 +145,7 @@ Item { } property int smeter_filter - property variant oplm_pair_id : OPLinkStatus.PairIDs_0 + property variant oplm_pair_id : opLinkStatus.pairIDs0 function select_oplm(index){ smeter_filter0.running = false; @@ -145,22 +157,22 @@ Item { case 0: smeter_filter0.running = true; smeter_filter = 0; - oplm_pair_id = OPLinkStatus.PairIDs_0 + oplm_pair_id = opLinkStatus.pairIDs0 break; case 1: smeter_filter1.running = true; smeter_filter = 1; - oplm_pair_id = OPLinkStatus.PairIDs_1 + oplm_pair_id = opLinkStatus.pairIDs1 break; case 2: smeter_filter2.running = true; smeter_filter = 2; - oplm_pair_id = OPLinkStatus.PairIDs_2 + oplm_pair_id = opLinkStatus.pairIDs2 break; case 3: smeter_filter3.running = true; smeter_filter = 3; - oplm_pair_id = OPLinkStatus.PairIDs_3 + oplm_pair_id = opLinkStatus.pairIDs3 break; } } @@ -210,7 +222,7 @@ Item { elementName: "panel-open-icon" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: close_bg.z+1 + z: close_bg.z + 1 opacity: show_panels == true ? 0 : 1 states: State { @@ -233,7 +245,7 @@ Item { elementName: "close-panel-mousearea" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: close_bg.z+100 + z: close_bg.z + 100 TooltipArea { text: show_panels == true ? "Close panels" : "Open panels" @@ -242,7 +254,7 @@ Item { MouseArea { id: hidedisp_close; anchors.fill: parent; - cursorShape: Qt.PointingHandCursor + cursorShape: Qt.PointingHandCursor onClicked: close_panels() } @@ -289,7 +301,7 @@ Item { elementName: "rc-input-labels" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: rc_input_bg.z+1 + z: rc_input_bg.z + 1 states: State { name: "fading" @@ -298,9 +310,9 @@ Item { } transitions: Transition { - SequentialAnimation { - PropertyAnimation { property: "x"; easing.type: anim_type; easing.amplitude: anim_amplitude; easing.period: anim_period; duration: duration_value } - } + SequentialAnimation { + PropertyAnimation { property: "x"; easing.type: anim_type; easing.amplitude: anim_amplitude; easing.period: anim_period; duration: duration_value } + } } } @@ -309,7 +321,7 @@ Item { elementName: "rc-input-panel-mousearea" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: rc_input_bg.z+1 + z: rc_input_bg.z + 1 TooltipArea { text: "RC panel" @@ -329,9 +341,9 @@ Item { } transitions: Transition { - SequentialAnimation { - PropertyAnimation { property: "x"; easing.type: anim_type; easing.amplitude: anim_amplitude; easing.period: anim_period; duration: duration_value } - } + SequentialAnimation { + PropertyAnimation { property: "x"; easing.type: anim_type; easing.amplitude: anim_amplitude; easing.period: anim_period; duration: duration_value } + } } } @@ -342,7 +354,7 @@ Item { z: rc_input_bg.z+2 width: scaledBounds.width * sceneItem.width - height: (scaledBounds.height * sceneItem.height) * (ManualControlCommand.Throttle) + height: (scaledBounds.height * sceneItem.height) * (manualControlCommand.throttle) x: scaledBounds.x * sceneItem.width y: (scaledBounds.y * sceneItem.height) - rc_throttle.height + (scaledBounds.height * sceneItem.height) @@ -356,9 +368,9 @@ Item { } transitions: Transition { - SequentialAnimation { - PropertyAnimation { property: "x"; easing.type: anim_type; easing.amplitude: anim_amplitude; easing.period: anim_period; duration: duration_value } - } + SequentialAnimation { + PropertyAnimation { property: "x"; easing.type: anim_type; easing.amplitude: anim_amplitude; easing.period: anim_period; duration: duration_value } + } } } @@ -371,13 +383,13 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height - y: (scaledBounds.y * sceneItem.height) + (ManualControlCommand.Pitch * rc_stick.width * 2.5) + y: (scaledBounds.y * sceneItem.height) + (manualControlCommand.pitch * rc_stick.width * 2.5) smooth: true //rotate it around his center transform: Rotation { - angle: ManualControlCommand.Yaw * 90 + angle: manualControlCommand.yaw * 90 origin.y : rc_stick.height / 2 origin.x : rc_stick.width / 2 } @@ -385,13 +397,13 @@ Item { states: State { name: "fading" when: show_panels == true - PropertyChanges { target: rc_stick; x: Math.floor(scaledBounds.x * sceneItem.width) + (ManualControlCommand.Roll * rc_stick.width * 2.5) + offset_value; } + PropertyChanges { target: rc_stick; x: Math.floor(scaledBounds.x * sceneItem.width) + (manualControlCommand.roll * rc_stick.width * 2.5) + offset_value; } } transitions: Transition { - SequentialAnimation { - PropertyAnimation { property: "x"; easing.type: anim_type; easing.amplitude: anim_amplitude; easing.period: anim_period; duration: duration_value } - } + SequentialAnimation { + PropertyAnimation { property: "x"; easing.type: anim_type; easing.amplitude: anim_amplitude; easing.period: anim_period; duration: duration_value } + } } } @@ -413,9 +425,9 @@ Item { } transitions: Transition { - SequentialAnimation { - PropertyAnimation { property: "x"; easing.type: anim_type; easing.amplitude: anim_amplitude; easing.period: anim_period; duration: duration_value } - } + SequentialAnimation { + PropertyAnimation { property: "x"; easing.type: anim_type; easing.amplitude: anim_amplitude; easing.period: anim_period; duration: duration_value } + } } } @@ -423,7 +435,7 @@ Item { id: battery_volt sceneSize: panels.sceneSize elementName: "battery-volt-text" - z: battery_bg.z+1 + z: battery_bg.z + 1 width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height @@ -443,13 +455,13 @@ Item { Rectangle { anchors.fill: parent - color: panels.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)] + color: panels.batColors[systemAlarms.alarmBattery] border.color: "white" border.width: battery_volt.width * 0.01 radius: border.width * 4 Text { - text: FlightBatteryState.Voltage.toFixed(2) + text: flightBatteryState.voltage.toFixed(2) anchors.centerIn: parent color: "white" font { @@ -484,13 +496,13 @@ Item { Rectangle { anchors.fill: parent - color: panels.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)] + color: panels.batColors[systemAlarms.alarmBattery] border.color: "white" border.width: battery_volt.width * 0.01 radius: border.width * 4 Text { - text: FlightBatteryState.Current.toFixed(2) + text: flightBatteryState.current.toFixed(2) anchors.centerIn: parent color: "white" font { @@ -531,24 +543,24 @@ Item { visible: display_bat == true ? 1 : 0 } - MouseArea { - id: reset_panel_consumed_energy_mouseArea; + MouseArea { + id: reset_panel_consumed_energy_mouseArea; anchors.fill: parent; cursorShape: Qt.PointingHandCursor; visible: display_bat == true ? 1 : 0 onClicked: qmlWidget.resetConsumedEnergy(); } - // Alarm based on FlightBatteryState.EstimatedFlightTime < 120s orange, < 60s red - color: (FlightBatteryState.EstimatedFlightTime <= 120 && FlightBatteryState.EstimatedFlightTime > 60 ? "orange" : - (FlightBatteryState.EstimatedFlightTime <= 60 ? "red": panels.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)])) + // Alarm based on flightBatteryState.estimatedFlightTime < 120s orange, < 60s red + color: (flightBatteryState.estimatedFlightTime <= 120 && flightBatteryState.estimatedFlightTime > 60 ? "orange" : + (flightBatteryState.estimatedFlightTime <= 60 ? "red": panels.batColors[systemAlarms.alarmBattery])) border.color: "white" border.width: battery_volt.width * 0.01 radius: border.width * 4 Text { - text: FlightBatteryState.ConsumedEnergy.toFixed(0) + text: flightBatteryState.consumedEnergy.toFixed(0) anchors.centerIn: parent color: "white" font { @@ -583,24 +595,24 @@ Item { Rectangle { anchors.fill: parent - //color: panels.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)] + //color: panels.batColors[systemAlarms.alarmBattery] TooltipArea { text: "Reset consumed energy" visible: display_bat == true ? 1 : 0 } - MouseArea { - id: reset_panel_consumed_energy_mouseArea2; + MouseArea { + id: reset_panel_consumed_energy_mouseArea2; anchors.fill: parent; - cursorShape: Qt.PointingHandCursor; + cursorShape: Qt.PointingHandCursor; visible: display_bat == true ? 1 : 0 onClicked: qmlWidget.resetConsumedEnergy(); } - // Alarm based on FlightBatteryState.EstimatedFlightTime < 120s orange, < 60s red - color: (FlightBatteryState.EstimatedFlightTime <= 120 && FlightBatteryState.EstimatedFlightTime > 60 ? "orange" : - (FlightBatteryState.EstimatedFlightTime <= 60 ? "red": panels.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)])) + // Alarm based on flightBatteryState.estimatedFlightTime < 120s orange, < 60s red + color: (flightBatteryState.estimatedFlightTime <= 120) && (flightBatteryState.estimatedFlightTime > 60) ? "orange" : + (flightBatteryState.estimatedFlightTime <= 60) ? "red" : panels.batColors[systemAlarms.alarmBattery] border.color: "white" border.width: battery_volt.width * 0.01 @@ -698,7 +710,7 @@ Item { elementName: "smeter-bg" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: oplm_bg.z+1 + z: oplm_bg.z + 1 states: State { name: "fading" @@ -718,7 +730,7 @@ Item { elementName: "smeter-scale" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: oplm_bg.z+2 + z: oplm_bg.z + 2 states: State { name: "fading" @@ -738,7 +750,7 @@ Item { elementName: "smeter-needle" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: oplm_bg.z+3 + z: oplm_bg.z + 3 states: State { name: "fading" @@ -766,7 +778,7 @@ Item { width: smeter_scale.width * 1.09 //anchors.horizontalCenter: smeter_scale - z: oplm_bg.z+4 + z: oplm_bg.z + 4 states: State { name: "fading" @@ -788,7 +800,7 @@ Item { y: Math.floor(scaledBounds.y * sceneItem.height) width: smeter_mask.width - z: oplm_bg.z+5 + z: oplm_bg.z + 5 states: State { name: "fading" @@ -807,7 +819,7 @@ Item { model: 4 SvgElementImage { - z: oplm_bg.z+5 + z: oplm_bg.z + 5 property variant idButton_oplm: "oplm_button_" + index property variant idButton_oplm_mousearea: "oplm_button_mousearea" + index property variant button_color: "button"+index+"_color" @@ -853,7 +865,7 @@ Item { elementName: "oplm-id-label" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: oplm_bg.z+6 + z: oplm_bg.z + 6 states: State { name: "fading" @@ -872,7 +884,7 @@ Item { id: oplm_id_text sceneSize: panels.sceneSize elementName: "oplm-id-text" - z: oplm_bg.z+7 + z: oplm_bg.z + 7 width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height @@ -908,7 +920,7 @@ Item { elementName: "rx-quality-label" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: oplm_bg.z+8 + z: oplm_bg.z + 8 states: State { name: "fading" @@ -927,7 +939,7 @@ Item { id: rx_quality_text sceneSize: panels.sceneSize elementName: "rx-quality-text" - z: oplm_bg.z+9 + z: oplm_bg.z + 9 width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height @@ -946,7 +958,7 @@ Item { } Text { - text: Utils.toInt(ReceiverStatus.Quality) > 0 ? Utils.toInt(ReceiverStatus.Quality)+"%" : "?? %" + text: (receiverStatus.quality > 0) ? receiverStatus.quality + "%" : "?? %" anchors.centerIn: parent color: "white" font { @@ -1018,7 +1030,7 @@ Item { elementName: "system-frame-type" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: system_bg.z+1 + z: system_bg.z + 1 states: State { name: "fading" @@ -1035,7 +1047,7 @@ Item { Text { text: ["FixedWing", "FixedWingElevon", "FixedWingVtail", "VTOL", "HeliCP", "QuadX", "QuadP", "Hexa+", "Octo+", "Custom", "HexaX", "HexaH", "OctoV", "OctoCoaxP", "OctoCoaxX", "OctoX", "HexaCoax", - "Tricopter", "GroundVehicleCar", "GroundVehicleDiff", "GroundVehicleMoto"][Utils.toInt(SystemSettings.AirframeType)] + "Tricopter", "GroundVehicleCar", "GroundVehicleDiff", "GroundVehicleMoto"][systemSettings.airframeType] anchors.right: parent.right color: "white" font { @@ -1051,7 +1063,7 @@ Item { elementName: "system-cpu-load-temp" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: system_bg.z+1 + z: system_bg.z + 1 states: State { name: "fading" @@ -1067,8 +1079,7 @@ Item { Text { // Coptercontrol detect with mem free : Only display Cpu load, no temperature available. - text: Utils.toInt(SystemStats.CPULoad)+"%"+ - [SystemStats.HeapRemaining < 3000 ? "" : " | "+cpuTemp+"°C"] + text: systemStats.cpuLoad + "%" + [(systemStats.heapRemaining < 3000) ? "" : " | " + cpuTemp + "°C"] anchors.right: parent.right color: "white" font { @@ -1084,7 +1095,7 @@ Item { elementName: "system-mem-free" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: system_bg.z+1 + z: system_bg.z + 1 states: State { name: "fading" @@ -1099,7 +1110,7 @@ Item { } Text { - text: SystemStats.HeapRemaining > 1024 ? memory_free.toFixed(2) +"Kb" : memory_free +"bytes" + text: (systemStats.heapRemaining > 1024) ? memory_free.toFixed(2) +"Kb" : memory_free +"bytes" anchors.right: parent.right color: "white" font { @@ -1115,7 +1126,7 @@ Item { elementName: "system-attitude-estimation-algo" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: system_bg.z+1 + z: system_bg.z + 1 states: State { name: "fading" @@ -1130,7 +1141,7 @@ Item { } Text { - text: ["None", "Basic (No Nav)", "CompMag", "Comp+Mag+GPS", "EKFIndoor", "GPS Nav (INS13)"][Utils.toInt(RevoSettings.FusionAlgorithm)] + text: ["None", "Basic (No Nav)", "CompMag", "Comp+Mag+GPS", "EKFIndoor", "GPS Nav (INS13)"][revoSettings.fusionAlgorithm] anchors.right: parent.right color: "white" font { @@ -1146,7 +1157,7 @@ Item { elementName: "system-mag-used" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: system_bg.z+1 + z: system_bg.z + 1 states: State { name: "fading" @@ -1161,7 +1172,7 @@ Item { } Text { - text: ["Invalid", "OnBoard", "External"][Utils.toInt(MagState.Source)] + text: ["Invalid", "OnBoard", "External"][magState.source] anchors.right: parent.right color: "white" font { @@ -1177,7 +1188,7 @@ Item { elementName: "system-gps-type" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: system_bg.z+1 + z: system_bg.z + 1 states: State { name: "fading" @@ -1192,7 +1203,7 @@ Item { } Text { - text: ["Unknown", "NMEA", "UBX", "UBX7", "UBX8"][Utils.toInt(GPSPositionSensor.SensorType)] + text: ["Unknown", "NMEA", "UBX", "UBX7", "UBX8"][gpsPositionSensor.sensorType] anchors.right: parent.right color: "white" font { @@ -1208,7 +1219,7 @@ Item { elementName: "system-panel-mousearea" sceneSize: panels.sceneSize y: Math.floor(scaledBounds.y * sceneItem.height) - z: system_bg.z+1 + z: system_bg.z + 1 TooltipArea { text: "System panel" diff --git a/ground/gcs/src/share/pfd/default/PfdWorldView.qml b/ground/gcs/src/share/pfd/default/PfdWorldView.qml index f72ddd9df..e60ea81e7 100644 --- a/ground/gcs/src/share/pfd/default/PfdWorldView.qml +++ b/ground/gcs/src/share/pfd/default/PfdWorldView.qml @@ -1,5 +1,7 @@ import QtQuick 2.0 +import UAVTalk.AttitudeState 1.0 + Item { id: worldView property real horizontCenter : horizontCenterItem.horizontCenter @@ -32,10 +34,10 @@ Item { x: Math.round((world.parent.width - world.width)/2) // y is centered around world_center element y: Math.round(horizontCenter - world.height/2 + - AttitudeState.Pitch*world.pitch1DegHeight) + attitudeState.pitch * world.pitch1DegHeight) }, Rotation { - angle: -AttitudeState.Roll + angle: -attitudeState.roll origin.x : world.parent.width/2 origin.y : horizontCenter } @@ -58,7 +60,7 @@ Item { sceneSize: background.sceneSize anchors.centerIn: parent - border: 1 + border: 1 smooth: true } } @@ -72,7 +74,7 @@ Item { width: Math.floor(scaledBounds.width * sceneItem.width) height: Math.floor(scaledBounds.height * sceneItem.height) - rotation: -AttitudeState.Roll + rotation: -attitudeState.roll transformOrigin: Item.Center smooth: true @@ -85,7 +87,7 @@ Item { sceneSize: background.sceneSize anchors.centerIn: parent //see comment for world transform - anchors.verticalCenterOffset: AttitudeState.Pitch*world.pitch1DegHeight + anchors.verticalCenterOffset: attitudeState.pitch * world.pitch1DegHeight border: 64 //sometimes numbers are excluded from bounding rect smooth: true diff --git a/ground/gcs/src/share/pfd/default/RollScale.qml b/ground/gcs/src/share/pfd/default/RollScale.qml index f5ab5df1a..240ec2094 100644 --- a/ground/gcs/src/share/pfd/default/RollScale.qml +++ b/ground/gcs/src/share/pfd/default/RollScale.qml @@ -1,12 +1,15 @@ import QtQuick 2.0 import "." +import UAVTalk.AttitudeState 1.0 + Item { id: sceneItem + property variant sceneSize property real horizontCenter - onHorizontCenterChanged: console.log("horizont center:"+horizontCenter) + //onHorizontCenterChanged: console.log("horizont center:" + horizontCenter) SvgElementImage { id: rollscale @@ -21,11 +24,11 @@ Item { smooth: true - //rotate it around the center of horizon + // rotate it around the center of horizon transform: Rotation { - angle: -AttitudeState.Roll - origin.y : rollscale.height*2.4 - origin.x : rollscale.width/2 + angle: -attitudeState.roll + origin.y : rollscale.height * 2.4 + origin.x : rollscale.width / 2 } } diff --git a/ground/gcs/src/share/pfd/default/SpeedScale.qml b/ground/gcs/src/share/pfd/default/SpeedScale.qml index a8b8153df..149948501 100644 --- a/ground/gcs/src/share/pfd/default/SpeedScale.qml +++ b/ground/gcs/src/share/pfd/default/SpeedScale.qml @@ -1,10 +1,12 @@ import QtQuick 2.0 +import UAVTalk.VelocityState 1.0 +import UAVTalk.PathDesired 1.0 + Item { id: sceneItem property variant sceneSize - property real groundSpeed : qmlWidget.speedFactor * Math.sqrt(Math.pow(VelocityState.North,2)+ - Math.pow(VelocityState.East,2)) + property real groundSpeed : qmlWidget.speedFactor * Math.sqrt(Math.pow(velocityState.north, 2) + Math.pow(velocityState.east, 2)) SvgElementImage { id: speed_window @@ -63,12 +65,12 @@ Item { id: speed_waypoint elementName: "speed-waypoint" sceneSize: sceneItem.sceneSize - visible: PathDesired.EndingVelocity !== 0.0 + visible: (pathDesired.endingVelocity != 0.0) anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: speed_scale.height/10 * (sceneItem.groundSpeed - (PathDesired.EndingVelocity * qmlWidget.speedFactor)) + anchors.verticalCenterOffset: speed_scale.height / 10 * (sceneItem.groundSpeed - (pathDesired.endingVelocity * qmlWidget.speedFactor)) } } diff --git a/ground/gcs/src/share/pfd/default/VsiScale.qml b/ground/gcs/src/share/pfd/default/VsiScale.qml index 4786688b0..ffe42aced 100644 --- a/ground/gcs/src/share/pfd/default/VsiScale.qml +++ b/ground/gcs/src/share/pfd/default/VsiScale.qml @@ -1,4 +1,8 @@ import QtQuick 2.0 + +import UAVTalk.FlightStatus 1.0 +import UAVTalk.VelocityDesired 1.0 + import "common.js" as Utils Item { @@ -8,7 +12,7 @@ Item { Timer { interval: 100; running: true; repeat: true - onTriggered: vert_velocity = (0.9 * vert_velocity) + (0.1 * VelocityState.Down) + onTriggered: vert_velocity = (0.9 * vert_velocity) + (0.1 * velocityState.down) } SvgElementImage { @@ -23,12 +27,12 @@ Item { y: scaledBounds.y * sceneItem.height smooth: true - visible: VelocityDesired.Down !== 0.0 && Utils.toInt(FlightStatus.FlightMode) > 7 + visible: ((velocityDesired.down != 0.0) && (flightStatus.flightMode > FlightMode.PositionHold)) - //rotate it around the center + // rotate it around the center transform: Rotation { - angle: -VelocityDesired.Down * 5 - origin.y : vsi_waypoint.height / 2 + angle: -velocityDesired.down * 5 + origin.y : vsi_waypoint.height / 2 origin.x : vsi_waypoint.width * 33 } } @@ -36,7 +40,7 @@ Item { SvgElementImage { id: vsi_scale_meter - visible: qmlWidget.altitudeUnit == "m" + visible: (qmlWidget.altitudeUnit == "m") elementName: "vsi-scale-meter" sceneSize: sceneItem.sceneSize @@ -48,7 +52,7 @@ Item { SvgElementImage { id: vsi_scale_ft - visible: qmlWidget.altitudeUnit == "ft" + visible: (qmlWidget.altitudeUnit == "ft") elementName: "vsi-scale-ft" sceneSize: sceneItem.sceneSize @@ -70,10 +74,10 @@ Item { smooth: true - //rotate it around the center + // rotate it around the center transform: Rotation { angle: -vert_velocity * 5 - origin.y : vsi_arrow.height / 2 + origin.y : vsi_arrow.height / 2 origin.x : vsi_arrow.width * 3.15 } } @@ -84,7 +88,7 @@ Item { sceneSize: sceneItem.sceneSize Text { - text: qmlWidget.altitudeUnit == "m" ? "m/s" : "ft/s" + text: (qmlWidget.altitudeUnit == "m") ? "m/s" : "ft/s" color: "cyan" font { family: pt_bold.name diff --git a/ground/gcs/src/share/pfd/default/Warnings.qml b/ground/gcs/src/share/pfd/default/Warnings.qml index 7b8191e69..9575aee5d 100644 --- a/ground/gcs/src/share/pfd/default/Warnings.qml +++ b/ground/gcs/src/share/pfd/default/Warnings.qml @@ -1,39 +1,42 @@ import QtQuick 2.0 + +import UAVTalk.SystemSettings 1.0 +import UAVTalk.SystemAlarms 1.0 +import UAVTalk.FlightStatus 1.0 +import UAVTalk.VtolPathFollowerSettings 1.0 + import "common.js" as Utils Item { id: warnings property variant sceneSize - // Uninitialised, OK, Warning, Error, Critical + + // Uninitialised, OK, Warning, Error, Critical property variant statusColors : ["gray", "green", "red", "red", "red"] - // DisArmed , Arming, Armed + // DisArmed , Arming, Armed property variant armColors : ["gray", "orange", "green"] - // All 'manual modes' are green, 'assisted' modes in cyan - // "MANUAL","STAB 1","STAB 2", "STAB 3", "STAB 4", "STAB 5", "STAB 6", - // "POS HOLD", "COURSELOCK","VEL ROAM", "HOME LEASH", "ABS POS", "RTB", "LAND", "PATHPLAN", "POI", "AUTOCRUISE", "AUTOTAKEOFF" - + // All 'manual modes' are green, 'assisted' modes in cyan + // "MANUAL","STAB 1","STAB 2", "STAB 3", "STAB 4", "STAB 5", "STAB 6", + // "POS HOLD", "COURSELOCK","VEL ROAM", "HOME LEASH", "ABS POS", "RTB", "LAND", "PATHPLAN", "POI", "AUTOCRUISE", "AUTOTAKEOFF" property variant flightmodeColors : ["gray", "green", "green", "green", "green", "green", "green", "cyan", "cyan", "cyan", "cyan", "cyan", "cyan", "cyan", "cyan", "cyan", "cyan", "cyan"] - // Manual,Rate,RateTrainer,Attitude,AxisLock,WeakLeveling,VirtualBar,Acro+,Rattitude, - // AltitudeHold,AltitudeVario,CruiseControl" + Auto mode (VTOL/Wing pathfollower) - // grey : 'disabled' modes - - property variant thrustmodeColors : ["green", "grey", "grey", "grey", "grey", "grey", "grey", "grey", "grey", + // Manual,Rate,RateTrainer,Attitude,AxisLock,WeakLeveling,VirtualBar,Acro+,Rattitude, + // AltitudeHold,AltitudeVario,CruiseControl" + Auto mode (VTOL/Wing pathfollower) + // grey : 'disabled' modes + property variant thrustmodeColors : ["green", "grey", "grey", "grey", "grey", "grey", "grey", "grey", "grey", "green", "green", "green", "cyan"] - // SystemSettings.AirframeType 3 - 17 : VtolPathFollower, check ThrustControl - - property var thrust_mode: Utils.toInt(FlightStatus.FlightMode) < 7 ? Utils.toInt(StabilizationDesired.StabilizationMode_Thrust) : - Utils.toInt(FlightStatus.FlightMode) > 6 && Utils.toInt(SystemSettings.AirframeType) > 2 && - Utils.toInt(SystemSettings.AirframeType) < 18 && Utils.toInt(VtolPathFollowerSettings.ThrustControl) == 1 ? 12 : - Utils.toInt(FlightStatus.FlightMode) > 6 && Utils.toInt(SystemSettings.AirframeType) < 3 ? 12: 0 + // systemSettings.airframeType 3 - 17 : VtolPathFollower, check ThrustControl + property var thrust_mode: (flightStatus.flightMode < FlightMode.PositionHold) ? stabilizationDesired.stabilizationModeThrust : + (flightStatus.flightMode >= FlightMode.PositionHold) && (systemSettings.airframeType > AirframeType.FixedWingVtail) && + (systemSettings.airframeType < AirframeType.GroundVehicleCar) && (vtolPathFollowerSettings.thrustControl == ThrustControl.Auto) ? 12 : + (flightStatus.flightMode >= FlightMode.PositionHold) && (systemSettings.airframeType < AirframeType.VTOL) ? 12 : 0 - - property real flight_time: Math.round(SystemStats.FlightTime / 1000) + property real flight_time: Math.round(systemStats.flightTime / 1000) property real time_h: (flight_time > 0 ? Math.floor(flight_time / 3600) : 0 ) property real time_m: (flight_time > 0 ? Math.floor((flight_time - time_h*3600)/60) : 0) property real time_s: (flight_time > 0 ? Math.floor(flight_time - time_h*3600 - time_m*60) : 0) @@ -57,7 +60,7 @@ Item { Rectangle { anchors.fill: parent - color: (SystemStats.FlightTime > 0 ? "green" : "grey") + color: (systemStats.flightTime > 0) ? "green" : "grey" Text { anchors.centerIn: parent @@ -82,11 +85,11 @@ Item { Rectangle { anchors.fill: parent - color: warnings.armColors[Utils.toInt(FlightStatus.Armed)] + color: warnings.armColors[flightStatus.armed] Text { anchors.centerIn: parent - text: ["DISARMED","ARMING","ARMED"][Utils.toInt(FlightStatus.Armed)] + text: ["DISARMED","ARMING","ARMED"][flightStatus.armed] font { family: pt_bold.name pixelSize: Math.floor(parent.height * 0.74) @@ -107,7 +110,7 @@ Item { Rectangle { anchors.fill: parent - color: warnings.statusColors[Utils.toInt(SystemAlarms.Alarm_ManualControl)] + color: warnings.statusColors[systemAlarms.alarmManualControl] Text { anchors.centerIn: parent @@ -130,11 +133,11 @@ Item { x: scaledBounds.x * sceneItem.width y: scaledBounds.y * sceneItem.height - property bool warningActive: (Utils.toInt(SystemAlarms.Alarm_BootFault) > 1 || - Utils.toInt(SystemAlarms.Alarm_OutOfMemory) > 1 || - Utils.toInt(SystemAlarms.Alarm_StackOverflow) > 1 || - Utils.toInt(SystemAlarms.Alarm_CPUOverload) > 1 || - Utils.toInt(SystemAlarms.Alarm_EventSystem) > 1) + property bool warningActive: ((systemAlarms.alarmBootFault > Alarm.OK) || + (systemAlarms.alarmOutOfMemory > Alarm.OK) || + (systemAlarms.alarmStackOverflow > Alarm.OK) || + (systemAlarms.alarmCPUOverload > Alarm.OK) || + (systemAlarms.alarmEventSystem > Alarm.OK)) Rectangle { anchors.fill: parent color: parent.warningActive ? "red" : "red" @@ -164,7 +167,7 @@ Item { Rectangle { anchors.fill: parent - color: warnings.statusColors[Utils.toInt(SystemAlarms.Alarm_Guidance)] + color: warnings.statusColors[systemAlarms.alarmGuidance] Text { anchors.centerIn: parent @@ -189,14 +192,14 @@ Item { Rectangle { anchors.fill: parent - color: warnings.flightmodeColors[Utils.toInt(FlightStatus.FlightMode)] - // Manual,Stabilized1,Stabilized2,Stabilized3,Stabilized4,Stabilized5,Stabilized6,PositionHold,CourseLock, - // VelocityRoam,HomeLeash,AbsolutePosition,ReturnToBase,Land,PathPlanner,POI,AutoCruise,AutoTakeoff + color: warnings.flightmodeColors[flightStatus.flightMode] + // Manual,Stabilized1,Stabilized2,Stabilized3,Stabilized4,Stabilized5,Stabilized6,PositionHold,CourseLock, + // VelocityRoam,HomeLeash,AbsolutePosition,ReturnToBase,Land,PathPlanner,POI,AutoCruise,AutoTakeoff Text { anchors.centerIn: parent text: ["MANUAL","STAB 1","STAB 2", "STAB 3", "STAB 4", "STAB 5", "STAB 6", "POS HOLD", "COURSELOCK", - "VEL ROAM", "HOME LEASH", "ABS POS", "RTB", "LAND", "PATHPLAN", "POI", "AUTOCRUISE", "AUTOTAKEOFF"][Utils.toInt(FlightStatus.FlightMode)] + "VEL ROAM", "HOME LEASH", "ABS POS", "RTB", "LAND", "PATHPLAN", "POI", "AUTOCRUISE", "AUTOTAKEOFF"][flightStatus.flightMode] font { family: pt_bold.name pixelSize: Math.floor(parent.height * 0.74) @@ -217,15 +220,14 @@ Item { Rectangle { anchors.fill: parent - color: Utils.toInt(FlightStatus.FlightMode) < 1 ? "grey" : warnings.thrustmodeColors[thrust_mode] + color: (flightStatus.flightMode == FlightMode.Manual) ? "grey" : warnings.thrustmodeColors[thrust_mode] - // Manual,Rate,RateTrainer,Attitude,AxisLock,WeakLeveling,VirtualBar,Acro+,Rattitude, - // AltitudeHold,AltitudeVario,CruiseControl - // grey : 'disabled' modes + // Manual,Rate,RateTrainer,Attitude,AxisLock,WeakLeveling,VirtualBar,Acro+,Rattitude, + // AltitudeHold,AltitudeVario,CruiseControl + // grey : 'disabled' modes Text { anchors.centerIn: parent - text: ["MANUAL"," "," ", " ", " ", " ", " ", " ", " ", - "ALT HOLD", "ALT VARIO", "CRUISECTRL", "AUTO"][thrust_mode] + text: ["MANUAL"," "," ", " ", " ", " ", " ", " ", " ", "ALT HOLD", "ALT VARIO", "CRUISECTRL", "AUTO"][thrust_mode] font { family: pt_bold.name pixelSize: Math.floor(parent.height * 0.74) @@ -240,7 +242,7 @@ Item { elementName: "warning-gps" sceneSize: warnings.sceneSize - visible: Utils.toInt(SystemAlarms.Alarm_GPS) > 1 + visible: (systemAlarms.alarmGPS > Alarm.OK) } SvgElementImage { @@ -248,6 +250,6 @@ Item { elementName: "warning-attitude" sceneSize: warnings.sceneSize anchors.centerIn: background.centerIn - visible: Utils.toInt(SystemAlarms.Alarm_Attitude) > 1 + visible: (systemAlarms.alarmAttitude > Alarm.OK) } } diff --git a/ground/gcs/src/share/pfd/default/common.js b/ground/gcs/src/share/pfd/default/common.js index fe5a57a2f..502e726a0 100644 --- a/ground/gcs/src/share/pfd/default/common.js +++ b/ground/gcs/src/share/pfd/default/common.js @@ -5,14 +5,6 @@ // // Librepilot // *********************** -// -// qml/js treats qint8 as a char, necessary to convert it back to integer value -function toInt(enum_value) { - if (Object.prototype.toString.call(enum_value) == "[object String]") { - return enum_value.charCodeAt(0); - } - return enum_value; -} // Format time function formatTime(time) {