From c6e7d15de067dac04a106969cdafce459ff3f4a2 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Wed, 27 Mar 2019 13:06:55 -0400 Subject: [PATCH] Add support for disabling logs --- qgcresources.qrc | 2 + .../PX4/Images/no-logging-light.svg | 29 ++++++++ .../PX4/Images/no-logging.svg | 30 +++++++++ src/AutoPilotPlugins/PX4/SafetyComponent.qml | 62 +++++++++++++++-- src/Settings/App.SettingsGroup.json | 7 ++ src/Settings/AppSettings.cc | 4 +- src/Settings/AppSettings.h | 1 + src/Vehicle/Vehicle.h | 8 +-- src/comm/MAVLinkProtocol.cc | 9 ++- src/ui/preferences/GeneralSettings.qml | 12 +++- src/ui/preferences/MavlinkSettings.qml | 66 +++++++++++-------- 11 files changed, 190 insertions(+), 40 deletions(-) create mode 100644 src/AutoPilotPlugins/PX4/Images/no-logging-light.svg create mode 100644 src/AutoPilotPlugins/PX4/Images/no-logging.svg diff --git a/qgcresources.qrc b/qgcresources.qrc index 24aba6af8..cd510d2be 100644 --- a/qgcresources.qrc +++ b/qgcresources.qrc @@ -186,6 +186,8 @@ src/FlightMap/Images/AlertAircraft.svg src/FlightMap/Images/AwarenessAircraft.svg resources/check.svg + src/AutoPilotPlugins/PX4/Images/no-logging.svg + src/AutoPilotPlugins/PX4/Images/no-logging-light.svg resources/action.svg diff --git a/src/AutoPilotPlugins/PX4/Images/no-logging-light.svg b/src/AutoPilotPlugins/PX4/Images/no-logging-light.svg new file mode 100644 index 000000000..e047c28ae --- /dev/null +++ b/src/AutoPilotPlugins/PX4/Images/no-logging-light.svg @@ -0,0 +1,29 @@ + + + + + + + + + + diff --git a/src/AutoPilotPlugins/PX4/Images/no-logging.svg b/src/AutoPilotPlugins/PX4/Images/no-logging.svg new file mode 100644 index 000000000..a4fbca666 --- /dev/null +++ b/src/AutoPilotPlugins/PX4/Images/no-logging.svg @@ -0,0 +1,30 @@ + + + + + + + + + + diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.qml b/src/AutoPilotPlugins/PX4/SafetyComponent.qml index a654239aa..3b8efd8eb 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.qml +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.qml @@ -43,6 +43,7 @@ SetupPage { property real _imageWidth: ScreenTools.defaultFontPixelWidth * 15 property real _imageHeight: ScreenTools.defaultFontPixelHeight * 3 + property Fact _disableLogging: controller.getParameterFact(-1, "SDLOG_MODE") property Fact _fenceAction: controller.getParameterFact(-1, "GF_ACTION") property Fact _fenceRadius: controller.getParameterFact(-1, "GF_MAX_HOR_DIST") property Fact _fenceAlt: controller.getParameterFact(-1, "GF_MAX_VER_DIST") @@ -98,7 +99,6 @@ SetupPage { } Rectangle { - id: otherLastRect x: landModeGrid.x + outerGrid.x - _margins y: landModeGrid.y + outerGrid.y - _margins width: landModeGrid.width + (_margins * 2) @@ -106,6 +106,15 @@ SetupPage { color: qgcPal.windowShade } + Rectangle { + id: otherLastRect + x: loggingGrid.x + outerGrid.x - _margins + y: loggingGrid.y + outerGrid.y - _margins + width: loggingGrid.width + (_margins * 2) + height: loggingGrid.height + (_margins * 2) + color: qgcPal.windowShade + } + Rectangle { id: lastRect x: hitlGrid.x + outerGrid.x - _margins @@ -486,6 +495,48 @@ SetupPage { } } + Item { width: 1; height: _margins; Layout.columnSpan: 3 } + + QGCLabel { + text: qsTr("Vehicle Logging") + Layout.columnSpan: 3 + } + + Item { width: 1; height: _margins; Layout.columnSpan: 3 } + + Item { width: _margins; height: 1 } + + GridLayout { + id: loggingGrid + columns: 4 + Item { + Layout.fillWidth: true + } + Image { + mipmap: true + fillMode: Image.PreserveAspectFit + source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/no-logging-light.svg" : "/qmlimages/no-logging.svg" + Layout.maximumWidth: _imageWidth + Layout.maximumHeight: _imageHeight + width: _imageWidth + height: _imageHeight + } + QGCCheckBox { + text: qsTr("Disable vehicle logging") + checkedState: _disableLogging ? (_disableLogging.value < 0 ? Qt.Checked : Qt.Unchecked) : Qt.Unchecked + Layout.minimumWidth: _editFieldWidth + Layout.alignment: Qt.AlignVCenter + onClicked: { + if(_disableLogging) { + _disableLogging.value = checked ? -1 : 0 + } + } + } + Item { + Layout.fillWidth: true + } + } + Item { width: 1; height: _margins; Layout.columnSpan: 3; visible: _hitlAvailable } QGCLabel { @@ -504,10 +555,10 @@ SetupPage { visible: _hitlAvailable Image { - mipmap: true - fillMode: Image.PreserveAspectFit - source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/VehicleSummaryIcon.png" : "/qmlimages/VehicleSummaryIcon.png" - Layout.rowSpan: 3 + mipmap: true + fillMode: Image.PreserveAspectFit + source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/VehicleSummaryIcon.png" : "/qmlimages/VehicleSummaryIcon.png" + Layout.rowSpan: 3 Layout.maximumWidth: _imageWidth Layout.maximumHeight: _imageHeight width: _imageWidth @@ -524,6 +575,7 @@ SetupPage { Layout.minimumWidth: _editFieldWidth } } + } } } diff --git a/src/Settings/App.SettingsGroup.json b/src/Settings/App.SettingsGroup.json index 79c82b2b2..e4c8ea94a 100644 --- a/src/Settings/App.SettingsGroup.json +++ b/src/Settings/App.SettingsGroup.json @@ -235,5 +235,12 @@ "enumStrings": "System,English,български (Bulgarian),Deutsche (German),Français (French),Italiano (Italian),한국어 (Korean),Pусский (Russian),Türk (Turkish),中文 (Chinese)", "enumValues": "0,1,2,3,4,5,6,7,8,9", "defaultValue": 0 +}, +{ + "name": "disableLocalLogging", + "shortDescription": "Disable all logging", + "longDescription": "If this option is enabled nothing will be stored to disk.", + "type": "bool", + "defaultValue": false } ] diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc index 2e9962dce..438c54d10 100644 --- a/src/Settings/AppSettings.cc +++ b/src/Settings/AppSettings.cc @@ -10,6 +10,7 @@ #include "AppSettings.h" #include "QGCPalette.h" #include "QGCApplication.h" +#include "ParameterManager.h" #include #include @@ -61,7 +62,7 @@ DECLARE_SETTINGGROUP(App, "") connect(savePathFact, &Fact::rawValueChanged, this, &AppSettings::_checkSavePathDirectories); _checkSavePathDirectories(); - //-- Same for language + //-- Keep track of language changes SettingsFact* languageFact = qobject_cast(language()); connect(languageFact, &Fact::rawValueChanged, this, &AppSettings::_languageChanged); } @@ -93,6 +94,7 @@ DECLARE_SETTINGSFACT(AppSettings, enableTaisync) DECLARE_SETTINGSFACT(AppSettings, enableTaisyncVideo) DECLARE_SETTINGSFACT(AppSettings, enableMicrohard) DECLARE_SETTINGSFACT(AppSettings, language) +DECLARE_SETTINGSFACT(AppSettings, disableLocalLogging) DECLARE_SETTINGSFACT_NO_FUNC(AppSettings, indoorPalette) { diff --git a/src/Settings/AppSettings.h b/src/Settings/AppSettings.h index 920ac30e3..9c73005f8 100644 --- a/src/Settings/AppSettings.h +++ b/src/Settings/AppSettings.h @@ -48,6 +48,7 @@ public: DEFINE_SETTINGFACT(enableTaisyncVideo) DEFINE_SETTINGFACT(enableMicrohard) DEFINE_SETTINGFACT(language) + DEFINE_SETTINGFACT(disableLocalLogging) // Although this is a global setting it only affects ArduPilot vehicle since PX4 automatically starts the stream from the vehicle side DEFINE_SETTINGFACT(apmStartMavlinkStreams) diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 530a4ed13..c3706980d 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -912,10 +912,10 @@ public: QString brandImageIndoor () const; QString brandImageOutdoor () const; QStringList unhealthySensors () const; - int sensorsPresentBits () const { return _onboardControlSensorsPresent; } - int sensorsEnabledBits () const { return _onboardControlSensorsEnabled; } - int sensorsHealthBits () const { return _onboardControlSensorsHealth; } - int sensorsUnhealthyBits () const { return _onboardControlSensorsUnhealthy; } + int sensorsPresentBits () const { return static_cast(_onboardControlSensorsPresent); } + int sensorsEnabledBits () const { return static_cast(_onboardControlSensorsEnabled); } + int sensorsHealthBits () const { return static_cast(_onboardControlSensorsHealth); } + int sensorsUnhealthyBits () const { return static_cast(_onboardControlSensorsUnhealthy); } QString missionFlightMode () const; QString pauseFlightMode () const; QString rtlFlightMode () const; diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc index 8c6de29ca..5f89daa86 100644 --- a/src/comm/MAVLinkProtocol.cc +++ b/src/comm/MAVLinkProtocol.cc @@ -404,9 +404,13 @@ void MAVLinkProtocol::_startLogging(void) if (qgcApp()->runningUnitTests()) { return; } + AppSettings* appSettings = _app->toolbox()->settingsManager()->appSettings(); + if(appSettings->disableLocalLogging()->rawValue().toBool()) { + return; + } #ifdef __mobile__ //-- Mobile build don't write to /tmp unless told to do so - if (!_app->toolbox()->settingsManager()->appSettings()->telemetrySave()->rawValue().toBool()) { + if (!appSettings->telemetrySave()->rawValue().toBool()) { return; } #endif @@ -435,7 +439,8 @@ void MAVLinkProtocol::_stopLogging(void) if (_tempLogFile.isOpen()) { if (_closeLogFile()) { if ((_vehicleWasArmed || _app->toolbox()->settingsManager()->appSettings()->telemetrySaveNotArmed()->rawValue().toBool()) && - _app->toolbox()->settingsManager()->appSettings()->telemetrySave()->rawValue().toBool()) { + _app->toolbox()->settingsManager()->appSettings()->telemetrySave()->rawValue().toBool() && + !_app->toolbox()->settingsManager()->appSettings()->disableLocalLogging()->rawValue().toBool()) { emit saveTelemetryLog(_tempLogFile.fileName()); } else { QFile::remove(_tempLogFile.fileName()); diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index 721aabbee..66f787785 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -44,6 +44,7 @@ QGCView { property Fact _followTarget: QGroundControl.settingsManager.appSettings.followTarget property real _panelWidth: _qgcView.width * _internalWidthRatio property real _margins: ScreenTools.defaultFontPixelWidth + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property string _videoSource: QGroundControl.settingsManager.videoSettings.videoSource.value property bool _isGst: QGroundControl.videoManager.isGStreamer @@ -262,11 +263,20 @@ QGCView { property Fact _audioMuted: QGroundControl.settingsManager.appSettings.audioMuted } + FactCheckBox { + id: disableLogging + text: qsTr("Disable local logging") + fact: _disableLogging + visible: _disableLogging.visible + property Fact _disableLogging: QGroundControl.settingsManager.appSettings.disableLocalLogging + } + FactCheckBox { id: promptSaveLog text: qsTr("Save telemetry log after each flight") fact: _telemetrySave visible: _telemetrySave.visible + enabled: !disableLogging.checked property Fact _telemetrySave: QGroundControl.settingsManager.appSettings.telemetrySave } @@ -274,7 +284,7 @@ QGCView { text: qsTr("Save telemetry log even if vehicle was not armed") fact: _telemetrySaveNotArmed visible: _telemetrySaveNotArmed.visible - enabled: promptSaveLog.checked + enabled: promptSaveLog.checked && !disableLogging.checked property Fact _telemetrySaveNotArmed: QGroundControl.settingsManager.appSettings.telemetrySaveNotArmed } diff --git a/src/ui/preferences/MavlinkSettings.qml b/src/ui/preferences/MavlinkSettings.qml index 2db2cc1d9..d2041356b 100644 --- a/src/ui/preferences/MavlinkSettings.qml +++ b/src/ui/preferences/MavlinkSettings.qml @@ -33,8 +33,10 @@ Rectangle { property real _columnSpacing: ScreenTools.defaultFontPixelHeight * 0.25 property bool _uploadedSelected: false property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle - property var _showMavlinkLog: QGroundControl.corePlugin.options.showMavlinkLogOptions + property bool _showMavlinkLog: QGroundControl.corePlugin.options.showMavlinkLogOptions property bool _showAPMStreamRates: QGroundControl.apmFirmwareSupported && QGroundControl.settingsManager.apmMavlinkStreamRateSettings.visible + property Fact _disableLoggingFact: QGroundControl.settingsManager.appSettings.disableLocalLogging + property bool _disableLogging: _disableLogging ? _disableLogging.rawValue : false QGCPalette { id: qgcPal } @@ -196,49 +198,49 @@ Rectangle { QGCLabel { text: qsTr("Raw Sensors") } FactComboBox { - fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRateRawSensors + fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings ? QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRateRawSensors : null indexModel: false Layout.preferredWidth: _valueWidth } QGCLabel { text: qsTr("Extended Status") } FactComboBox { - fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRateExtendedStatus + fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings ? QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRateExtendedStatus : null indexModel: false Layout.preferredWidth: _valueWidth } QGCLabel { text: qsTr("RC Channel") } FactComboBox { - fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRateRCChannels + fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings ? QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRateRCChannels : null indexModel: false Layout.preferredWidth: _valueWidth } QGCLabel { text: qsTr("Position") } FactComboBox { - fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRatePosition + fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings ? QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRatePosition : null indexModel: false Layout.preferredWidth: _valueWidth } QGCLabel { text: qsTr("Extra 1") } FactComboBox { - fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRateExtra1 + fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings ? QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRateExtra1 : null indexModel: false Layout.preferredWidth: _valueWidth } QGCLabel { text: qsTr("Extra 2") } FactComboBox { - fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRateExtra2 + fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings ? QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRateExtra2 : null indexModel: false Layout.preferredWidth: _valueWidth } QGCLabel { text: qsTr("Extra 3") } FactComboBox { - fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRateExtra3 + fact: QGroundControl.settingsManager.apmMavlinkStreamRateSettings ? QGroundControl.settingsManager.apmMavlinkStreamRateSettings.streamRateExtra3 : null indexModel: false Layout.preferredWidth: _valueWidth } @@ -370,14 +372,14 @@ Rectangle { QGCButton { text: qsTr("Start Logging") width: (_valueWidth * 0.5) - (ScreenTools.defaultFontPixelWidth * 0.5) - enabled: !QGroundControl.mavlinkLogManager.logRunning && QGroundControl.mavlinkLogManager.canStartLog + enabled: !QGroundControl.mavlinkLogManager.logRunning && QGroundControl.mavlinkLogManager.canStartLog && !_disableLogging onClicked: QGroundControl.mavlinkLogManager.startLogging() anchors.verticalCenter: parent.verticalCenter } QGCButton { text: qsTr("Stop Logging") width: (_valueWidth * 0.5) - (ScreenTools.defaultFontPixelWidth * 0.5) - enabled: QGroundControl.mavlinkLogManager.logRunning + enabled: QGroundControl.mavlinkLogManager.logRunning && !_disableLogging onClicked: QGroundControl.mavlinkLogManager.stopLogging() anchors.verticalCenter: parent.verticalCenter } @@ -387,6 +389,7 @@ Rectangle { QGCCheckBox { text: qsTr("Enable automatic logging") checked: QGroundControl.mavlinkLogManager.enableAutoStart + enabled: !_disableLogging onClicked: { QGroundControl.mavlinkLogManager.enableAutoStart = checked } @@ -428,9 +431,10 @@ Rectangle { text: qsTr("Email address for Log Upload:") } QGCTextField { - id: emailField - text: QGroundControl.mavlinkLogManager.emailAddress - width: _valueWidth + id: emailField + text: QGroundControl.mavlinkLogManager.emailAddress + width: _valueWidth + enabled: !_disableLogging inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhEmailCharactersOnly anchors.verticalCenter: parent.verticalCenter onEditingFinished: { @@ -448,9 +452,10 @@ Rectangle { text: qsTr("Default Description:") } QGCTextField { - id: descField - text: QGroundControl.mavlinkLogManager.description - width: _valueWidth + id: descField + text: QGroundControl.mavlinkLogManager.description + width: _valueWidth + enabled: !_disableLogging anchors.verticalCenter: parent.verticalCenter onEditingFinished: { saveItems(); @@ -467,9 +472,10 @@ Rectangle { text: qsTr("Default Upload URL") } QGCTextField { - id: urlField - text: QGroundControl.mavlinkLogManager.uploadURL - width: _valueWidth + id: urlField + text: QGroundControl.mavlinkLogManager.uploadURL + width: _valueWidth + enabled: !_disableLogging inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhUrlCharactersOnly anchors.verticalCenter: parent.verticalCenter onEditingFinished: { @@ -487,9 +493,10 @@ Rectangle { text: qsTr("Video URL:") } QGCTextField { - id: videoUrlField - text: QGroundControl.mavlinkLogManager.videoURL - width: _valueWidth + id: videoUrlField + text: QGroundControl.mavlinkLogManager.videoURL + width: _valueWidth + enabled: !_disableLogging inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhUrlCharactersOnly anchors.verticalCenter: parent.verticalCenter } @@ -504,8 +511,9 @@ Rectangle { text: qsTr("Wind Speed:") } QGCComboBox { - id: windCombo - width: _valueWidth + id: windCombo + width: _valueWidth + enabled: !_disableLogging model: ListModel { id: windItems ListElement { text: "Please Select"; value: -1 } @@ -540,8 +548,9 @@ Rectangle { text: qsTr("Flight Rating:") } QGCComboBox { - id: ratingCombo - width: _valueWidth + id: ratingCombo + width: _valueWidth + enabled: !_disableLogging model: ListModel { id: ratingItems ListElement { text: "Please Select"; value: "notset"} @@ -582,6 +591,7 @@ Rectangle { frameVisible: false font.pointSize: ScreenTools.defaultFontPointSize text: QGroundControl.mavlinkLogManager.feedback + enabled: !_disableLogging style: TextAreaStyle { textColor: qgcPal.windowShade backgroundColor: qgcPal.text @@ -593,6 +603,7 @@ Rectangle { QGCCheckBox { text: qsTr("Make this log publicly available") checked: QGroundControl.mavlinkLogManager.publicLog + enabled: !_disableLogging onClicked: { QGroundControl.mavlinkLogManager.publicLog = checked } @@ -603,6 +614,7 @@ Rectangle { id: autoUploadCheck text: qsTr("Enable automatic log uploads") checked: QGroundControl.mavlinkLogManager.enableAutoUpload + enabled: !_disableLogging onClicked: { saveItems(); if(checked && QGroundControl.mavlinkLogManager.emailAddress === "") @@ -614,7 +626,7 @@ Rectangle { QGCCheckBox { text: qsTr("Delete log file after uploading") checked: QGroundControl.mavlinkLogManager.deleteAfterUpload - enabled: autoUploadCheck.checked + enabled: autoUploadCheck.checked && !_disableLogging onClicked: { QGroundControl.mavlinkLogManager.deleteAfterUpload = checked } -- 2.22.0