From 62f1e03571d72313d664a6efa506842cd64a39ed Mon Sep 17 00:00:00 2001 From: Daniel McInnes Date: Tue, 4 Jul 2023 13:33:19 +1000 Subject: [PATCH 1/8] Update settings Add a switch to enable an alarm that triggers when the auto start function is left disabled for more than 10 minutes. The 'VRM Portal ID' now shows valid data instead of 'TODO'. --- pages/settings/PageSettingsGenerator.qml | 19 ++++++++++++++++--- pages/settings/PageSettingsLogger.qml | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pages/settings/PageSettingsGenerator.qml b/pages/settings/PageSettingsGenerator.qml index acfa78667..409f6981d 100644 --- a/pages/settings/PageSettingsGenerator.qml +++ b/pages/settings/PageSettingsGenerator.qml @@ -65,7 +65,20 @@ Page { } ListSwitch { - id: timeZones + //% "Alarm when generator is not in auto start mode" + text: qsTrId("page_settings_generator_alarm_when_not_in_auto_start") + dataSource: settingsBindPrefix + "/Alarms/AutoStartDisabled" + onClicked: { + if (!checked) { + //% "An alarm will be triggered when auto start function is left disabled for more than 10 minutes." + Global.notificationLayer.showToastNotification(VenusOS.Notification_Info, + qsTrId("page_settings_generator_alarm_info"), 12000) + } + } + } + + ListSwitch { + id: quietHours text: CommonWords.quiet_hours dataSource: settingsBindPrefix + "/QuietHours/Enabled" @@ -76,7 +89,7 @@ Page { //% "Quiet hours start time" text: qsTrId("page_settings_generator_quiet_hours_start_time") dataSource: settingsBindPrefix + "/QuietHours/StartTime" - visible: defaultVisible && timeZones.checked + visible: defaultVisible && quietHours.checked writeAccessLevel: VenusOS.User_AccessType_User } @@ -84,7 +97,7 @@ Page { //% "Quiet hours end time" text: qsTrId("page_settings_generator_quiet_hours_end_time") dataSource: settingsBindPrefix + "/QuietHours/EndTime" - visible: defaultVisible && timeZones.checked + visible: defaultVisible && quietHours.checked writeAccessLevel: VenusOS.User_AccessType_User } diff --git a/pages/settings/PageSettingsLogger.qml b/pages/settings/PageSettingsLogger.qml index b89b62e03..1e21145f1 100644 --- a/pages/settings/PageSettingsLogger.qml +++ b/pages/settings/PageSettingsLogger.qml @@ -45,7 +45,7 @@ Page { ListTextItem { //% "VRM Portal ID" text: qsTrId("settings_vrm_portal_id") - secondaryText: "TODO" // this depends on VePlatform, it returns the first line of /etc/venus/unique-id. Not sure how to handle it yet. + dataSource: "com.victronenergy.platform/Device/UniqueId" // this doesn't work with mqtt yet, see: https://github.com/victronenergy/gui-v2/issues/385 } ListRadioButtonGroup { From cc3701140270bf9512abc88b7b3a195432d2dd79 Mon Sep 17 00:00:00 2001 From: Daniel McInnes Date: Tue, 4 Jul 2023 13:43:18 +1000 Subject: [PATCH 2/8] ListSwitch bug - 'valid' -> 'dataValid' --- pages/settings/PageSettingsGenerator.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/settings/PageSettingsGenerator.qml b/pages/settings/PageSettingsGenerator.qml index 409f6981d..cc7f5019a 100644 --- a/pages/settings/PageSettingsGenerator.qml +++ b/pages/settings/PageSettingsGenerator.qml @@ -36,7 +36,7 @@ Page { //% "Detect generator at AC input" text: qsTrId("page_settings_generator_detect_generator_at_ac_input") dataSource: settingsBindPrefix + "/Alarms/NoGeneratorAtAcIn" - enabled: valid && (generatorIsSet || checked) + enabled: dataValid && (generatorIsSet || checked) onClicked: { if (!checked) { if (!generatorIsSet) { From 8eb45855d70299ef07665b253341177324571bdb Mon Sep 17 00:00:00 2001 From: Daniel McInnes Date: Tue, 4 Jul 2023 17:38:31 +1000 Subject: [PATCH 3/8] Add generator settings submenu Settings -> Generator start / stop -> Settings -> Run time and service --- components/CommonWords.qml | 3 + data/mock/SystemSettingsImpl.qml | 18 +-- .../settings/PageGeneratorRuntimeService.qml | 105 ++++++++++++++++++ pages/settings/PageSettingsGenerator.qml | 50 ++------- qml.qrc | 1 + 5 files changed, 129 insertions(+), 48 deletions(-) create mode 100644 pages/settings/PageGeneratorRuntimeService.qml diff --git a/components/CommonWords.qml b/components/CommonWords.qml index d9aec3a53..d2f35a745 100644 --- a/components/CommonWords.qml +++ b/components/CommonWords.qml @@ -111,6 +111,9 @@ QtObject { //% "Position" readonly property string position: qsTrId("common_words_position") + //% "Press to reset" + readonly property string press_to_reset: qsTrId("common_words_press_to_reset") + //% "Press to scan" readonly property string press_to_scan: qsTrId("common_words_press_to_scan") diff --git a/data/mock/SystemSettingsImpl.qml b/data/mock/SystemSettingsImpl.qml index 417020497..02b7ad565 100644 --- a/data/mock/SystemSettingsImpl.qml +++ b/data/mock/SystemSettingsImpl.qml @@ -175,20 +175,24 @@ QtObject { setMockSettingValue("Pump0/StartValue", 50) setMockSettingValue("Pump0/StopValue", 80) - setMockGeneratorStartStopValue('State', 'soc') - setMockGeneratorStartStopValue('RunningByCondition', 'soc') + setMockGeneratorStartStopValue('AccumulatedTotal', 3600) setMockGeneratorStartStopValue('Error', 1) + setMockGeneratorStartStopValue('ManualStartTimer', 3700) + setMockGeneratorStartStopValue('NextTestRun', Date.now() / 1000 + 80) + setMockGeneratorStartStopValue('RunningByCondition', 'soc') setMockGeneratorStartStopValue('Runtime', 1234) - setMockGeneratorStartStopValue('AccumulatedTotal', 3600) + setMockGeneratorStartStopValue('ServiceCounterReset', 0) + setMockGeneratorStartStopValue('State', 0) setMockGeneratorStartStopValue('TestRunIntervalRuntime', 5678) - setMockGeneratorStartStopValue('NextTestRun', Date.now() / 1000 + 80) + + setMockGenerator0Value('AccumulatedTotal', 3780849) setMockGenerator0Value('AutoStartEnabled', 1) - setMockGeneratorStartStopValue('ManualStartTimer', 3700) setMockGenerator0Value('AccumulatedDaily', '{"1667347200": 60, "1667433600": 120, "1667520000": 1800}') setMockGenerator0Value('BatteryService', "default") setMockGenerator0Value('OnLossCommunication', 2) - setMockGenerator0Value('StopWhenAc1Available', 0) + setMockGenerator0Value('ServiceInterval', 159984000) setMockGenerator0Value('Soc', 1) + setMockGenerator0Value('StopWhenAc1Available', 0) setMockSettingValue("Services/Modbus", 0) setMockModbusTcpValue("Services/Count", 2) @@ -217,7 +221,7 @@ QtObject { // equivalent of "ip -json -details -statistics link show can0" as per vePlatform::canBusStats() Global.systemSettings._canBusStats["can0"] = '[{"ifindex":3,"ifname":"can0","flags":["NOARP","UP","LOWER_UP","ECHO"],"mtu":16,"qdisc":"pfifo_fast","operstate":"UP","linkmode":"DEFAULT","group":"default","txqlen":100,"link_type":"can","promiscuity":0,"min_mtu":0,"max_mtu":0,"linkinfo":{"info_kind":"can","info_data":{"state":"ERROR-PASSIVE","berr_counter":{"tx":0,"rx":135},"restart_ms":100,"bittiming":{"bitrate":250000,"sample_point":0.875,"tq":250,"prop_seg":6,"phase_seg1":7,"phase_seg2":2,"sjw":1},"bittiming_const":{"name":"sun4i_can","tseg1":{"min":1,"max":16},"tseg2":{"min":1,"max":8},"sjw":{"min":1,"max":4},"brp":{"min":1,"max":64},"brp_inc":1},"clock":24000000},"info_xstats":{"restarts":0,"bus_error":2,"arbitration_lost":0,"error_warning":1,"error_passive":1,"bus_off":0}},"num_tx_queues":1,"num_rx_queues":1,"gso_max_size":65536,"gso_max_segs":65535,"stats64":{"rx":{"bytes":16,"packets":2,"errors":2,"dropped":0,"over_errors":0,"multicast":0},"tx":{"bytes":0,"packets":0,"errors":0,"dropped":0,"carrier_errors":0,"collisions":0}}}]' - setMockSettingValue("Relay/Function", 0) // Alarm + setMockSettingValue("Relay/Function", 1) setMockSettingValue("Relay/Polarity", 0) setMockSettingValue("Relay/1/Function", 4) // Temperature setMockSettingValue("Relay/1/Polarity", 0) diff --git a/pages/settings/PageGeneratorRuntimeService.qml b/pages/settings/PageGeneratorRuntimeService.qml new file mode 100644 index 000000000..ca9906471 --- /dev/null +++ b/pages/settings/PageGeneratorRuntimeService.qml @@ -0,0 +1,105 @@ +/* +** Copyright (C) 2023 Victron Energy B.V. +*/ + +import QtQuick +import Victron.VenusOS + +Page { + id: root + + property string settingsBindPrefix + property string startStopBindPrefix + + DataPoint { + id: state + + source: startStopBindPrefix + "/State" + } + + GradientListView { + id: settingsListView + + model: ObjectModel { + + ListButton { + //% "Reset daily run time counters" + text: qsTrId("page_settings_generator_reset_daily_run_time_counters") + button.text: CommonWords.press_to_reset + onClicked: { + if (state.value === 0) { + var now = new Date() + var today = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())) + var todayInSeconds = today.getTime() / 1000 + resetDaily.setValue('{"%1" : 0}'.arg(todayInSeconds.toString())) + //% "The daily runtime counter has been reset" + Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_runtime_counter_reset")) + } else if (state.value === 1) { + //% "It is not possible to modify the counters while the generator is running" + Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_runtime_counter_cant_reset_while_running")) + } + } + + DataPoint { + id: resetDaily + + source: settingsBindPrefix + "/AccumulatedDaily" + } + } + + ListTextField { + id: setTotalRunTime + + //% "Generator total run time (hours)" + text: qsTrId("page_settings_generator_total_run_time") + secondaryText: Math.round(accumulatedTotalItem.value / 60 / 60) - Math.round(dataValue / 60 / 60) + textField.inputMethodHints: Qt.ImhDigitsOnly + dataSource: settingsBindPrefix + "/AccumulatedTotalOffset" + enabled: userHasWriteAccess && state.value === 0 + textField.maximumLength: 6 + onAccepted: function(hours) { + setDataValue(accumulatedTotalItem.value - hours * 60 * 60) + } + + DataPoint { + id: accumulatedTotalItem + + source: settingsBindPrefix + "/AccumulatedTotal" + } + } + + ListTextField { + id: serviceInterval + + //% "Generator service interval (hours)" + text: qsTrId("page_settings_generator_service_interval") + secondaryText: Math.round(dataValue / 60 / 60) + textField.inputMethodHints: Qt.ImhDigitsOnly + dataSource: settingsBindPrefix + "/ServiceInterval" + onAccepted: function(hours) { + setDataValue(hours * 60 * 60) + //% "Service time interval set to %1h. Use the 'Reset service timer' button to reset the service timer." + Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_service_time_interval").arg(hours)) + } + } + + ListButton { + //% "Reset service timer" + text: qsTrId("page_settings_generator_reset_service_timer") + button.text: CommonWords.press_to_reset + visible: serviceReset.valid + onClicked: { + serviceReset.setValue(1) + //% "The service timer has been reset." + Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_service_timer_has_been_reset")) + } + + DataPoint { + id: serviceReset + + source: startStopBindPrefix + "/ServiceCounterReset" + } + } + } + } +} diff --git a/pages/settings/PageSettingsGenerator.qml b/pages/settings/PageSettingsGenerator.qml index cc7f5019a..677b31173 100644 --- a/pages/settings/PageSettingsGenerator.qml +++ b/pages/settings/PageSettingsGenerator.qml @@ -101,49 +101,17 @@ Page { writeAccessLevel: VenusOS.User_AccessType_User } - ListButton { - //% "Reset daily run time counters" - text: qsTrId("page_settings_generator_reset_daily_run_time_counters") - //% "Press to reset" - button.text: qsTrId("page_settings_generator_press_to_reset") - onClicked: { - if (state.value === 0) { - var now = new Date() - var today = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())) /* ignore the 'M306' warning for this line. - QtCreator thinks that functions that start with an uppercase letter are constructor functions that should only be used with new. - 'Date.UTC(...)' is a static method, not a constructor, this is fine. */ - var todayInSeconds = today.getTime() / 1000 - resetDaily.setValue('{"%1" : 0}'.arg(todayInSeconds.toString())) - //% "The daily runtime counter has been reset" - Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_runtime_counter_reset")) - } else if (state.value === 1) { - //% "It is not possible to modify the counters while the generator is running" - Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_runtime_counter_cant_reset_while_running")) - } - } - DataPoint { - id: resetDaily - - source: settingsBindPrefix + "/AccumulatedDaily" - } - } - - ListTimeSelector { - id: setTotalRunTime - - //% "Generator total run time (hours)" - text: qsTrId("page_settings_generator_total_run_time") - dataSource: settingsBindPrefix + "/AccumulatedTotal" - secondaryText: Math.round(value / 60 / 60) - maximumHour: 999999 - enabled: userHasWriteAccess && state.value === 0 + ListNavigationItem { + //% "Run time and service" + text: qsTrId("page_settings_generator_run_time_and_service") + onClicked: Global.pageManager.pushPage("/pages/settings/PageGeneratorRuntimeService.qml", + { + title: text, + settingsBindPrefix: root.settingsBindPrefix, + startStopBindPrefix: root.startStopBindPrefix + }) } } - DataPoint { - id: state - - source: startStopBindPrefix + "/State" - } } } diff --git a/qml.qrc b/qml.qrc index 0f4da9bb4..1469708cb 100644 --- a/qml.qrc +++ b/qml.qrc @@ -336,6 +336,7 @@ pages/settings/PageGenerator.qml pages/settings/PageGeneratorAcLoad.qml pages/settings/PageGeneratorConditions.qml + pages/settings/PageGeneratorRuntimeService.qml pages/settings/PageGeneratorTestRun.qml pages/settings/PageGps.qml pages/settings/PageHub4Debug.qml From 15974a8d088cdaf45c5264330b803e51a566848c Mon Sep 17 00:00:00 2001 From: Daniel McInnes Date: Wed, 12 Jul 2023 10:25:00 +1000 Subject: [PATCH 4/8] Fix race condition in ListTextField When editing a ListTextField, we would write the new value to the data point, then emit 'root.accepted(text)'. This causes problems for ListTextFields where the secondary text is different to the raw value of the DataPoint, such as the generator service interval, where the DataPoint stores the value in seconds, and the secondary text is presented in hours, as follows (elided for brevity): ListTextField { id: serviceInterval text: qsTrId("page_settings_generator_service_interval") secondaryText: Math.round(dataValue / 60 / 60) dataSource: settingsBindPrefix + "/ServiceInterval" onAccepted: function(hours) { setDataValue(hours * 60 * 60) } } The user might change the service interval to 1000 hours. The data point gets set to '1000'. The 'serviceInterval' object detects that the 'dataValue' has changed, and updates the secondary text to 1000 / 60 / 60, i.e. 0.2, which gets displayed as 0. ListTextField continues its 'onAccepted' routine, and emits 'root.accepted(text)', which is now equal to 0. The 'serviceInterval' object runs 'onAccepted', and calls 'setDataValue(hours * 60 * 60)', which in this case, is equal to 0. --- components/listitems/ListTextField.qml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/listitems/ListTextField.qml b/components/listitems/ListTextField.qml index 5005edd5a..100df0e0e 100644 --- a/components/listitems/ListTextField.qml +++ b/components/listitems/ListTextField.qml @@ -50,12 +50,13 @@ ListItem { text: dataValid ? dataValue : "" onAccepted: { + let newValue = text _accepted = true if (dataPoint.source) { - dataPoint.setValue(text) + dataPoint.setValue(newValue) } textField.focus = false - root.accepted(text) + root.accepted(newValue) } onEditingFinished: root.editingFinished() From d58f26fff881c15912013fd5d13c5ac6ef5574d1 Mon Sep 17 00:00:00 2001 From: Daniel McInnes Date: Mon, 17 Jul 2023 12:09:00 +1000 Subject: [PATCH 5/8] Revert "Fix race condition in ListTextField" This reverts commit 15974a8d088cdaf45c5264330b803e51a566848c. --- components/listitems/ListTextField.qml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/listitems/ListTextField.qml b/components/listitems/ListTextField.qml index 100df0e0e..5005edd5a 100644 --- a/components/listitems/ListTextField.qml +++ b/components/listitems/ListTextField.qml @@ -50,13 +50,12 @@ ListItem { text: dataValid ? dataValue : "" onAccepted: { - let newValue = text _accepted = true if (dataPoint.source) { - dataPoint.setValue(newValue) + dataPoint.setValue(text) } textField.focus = false - root.accepted(newValue) + root.accepted(text) } onEditingFinished: root.editingFinished() From cad7274a52166ea4a283284df1fa2bc70a687cd0 Mon Sep 17 00:00:00 2001 From: Daniel McInnes Date: Mon, 17 Jul 2023 12:09:00 +1000 Subject: [PATCH 6/8] Revert "Add generator settings submenu" This reverts commit 8eb45855d70299ef07665b253341177324571bdb. --- components/CommonWords.qml | 3 - data/mock/SystemSettingsImpl.qml | 18 ++- .../settings/PageGeneratorRuntimeService.qml | 105 ------------------ pages/settings/PageSettingsGenerator.qml | 50 +++++++-- qml.qrc | 1 - 5 files changed, 48 insertions(+), 129 deletions(-) delete mode 100644 pages/settings/PageGeneratorRuntimeService.qml diff --git a/components/CommonWords.qml b/components/CommonWords.qml index d2f35a745..d9aec3a53 100644 --- a/components/CommonWords.qml +++ b/components/CommonWords.qml @@ -111,9 +111,6 @@ QtObject { //% "Position" readonly property string position: qsTrId("common_words_position") - //% "Press to reset" - readonly property string press_to_reset: qsTrId("common_words_press_to_reset") - //% "Press to scan" readonly property string press_to_scan: qsTrId("common_words_press_to_scan") diff --git a/data/mock/SystemSettingsImpl.qml b/data/mock/SystemSettingsImpl.qml index 02b7ad565..417020497 100644 --- a/data/mock/SystemSettingsImpl.qml +++ b/data/mock/SystemSettingsImpl.qml @@ -175,24 +175,20 @@ QtObject { setMockSettingValue("Pump0/StartValue", 50) setMockSettingValue("Pump0/StopValue", 80) - setMockGeneratorStartStopValue('AccumulatedTotal', 3600) - setMockGeneratorStartStopValue('Error', 1) - setMockGeneratorStartStopValue('ManualStartTimer', 3700) - setMockGeneratorStartStopValue('NextTestRun', Date.now() / 1000 + 80) + setMockGeneratorStartStopValue('State', 'soc') setMockGeneratorStartStopValue('RunningByCondition', 'soc') + setMockGeneratorStartStopValue('Error', 1) setMockGeneratorStartStopValue('Runtime', 1234) - setMockGeneratorStartStopValue('ServiceCounterReset', 0) - setMockGeneratorStartStopValue('State', 0) + setMockGeneratorStartStopValue('AccumulatedTotal', 3600) setMockGeneratorStartStopValue('TestRunIntervalRuntime', 5678) - - setMockGenerator0Value('AccumulatedTotal', 3780849) + setMockGeneratorStartStopValue('NextTestRun', Date.now() / 1000 + 80) setMockGenerator0Value('AutoStartEnabled', 1) + setMockGeneratorStartStopValue('ManualStartTimer', 3700) setMockGenerator0Value('AccumulatedDaily', '{"1667347200": 60, "1667433600": 120, "1667520000": 1800}') setMockGenerator0Value('BatteryService', "default") setMockGenerator0Value('OnLossCommunication', 2) - setMockGenerator0Value('ServiceInterval', 159984000) - setMockGenerator0Value('Soc', 1) setMockGenerator0Value('StopWhenAc1Available', 0) + setMockGenerator0Value('Soc', 1) setMockSettingValue("Services/Modbus", 0) setMockModbusTcpValue("Services/Count", 2) @@ -221,7 +217,7 @@ QtObject { // equivalent of "ip -json -details -statistics link show can0" as per vePlatform::canBusStats() Global.systemSettings._canBusStats["can0"] = '[{"ifindex":3,"ifname":"can0","flags":["NOARP","UP","LOWER_UP","ECHO"],"mtu":16,"qdisc":"pfifo_fast","operstate":"UP","linkmode":"DEFAULT","group":"default","txqlen":100,"link_type":"can","promiscuity":0,"min_mtu":0,"max_mtu":0,"linkinfo":{"info_kind":"can","info_data":{"state":"ERROR-PASSIVE","berr_counter":{"tx":0,"rx":135},"restart_ms":100,"bittiming":{"bitrate":250000,"sample_point":0.875,"tq":250,"prop_seg":6,"phase_seg1":7,"phase_seg2":2,"sjw":1},"bittiming_const":{"name":"sun4i_can","tseg1":{"min":1,"max":16},"tseg2":{"min":1,"max":8},"sjw":{"min":1,"max":4},"brp":{"min":1,"max":64},"brp_inc":1},"clock":24000000},"info_xstats":{"restarts":0,"bus_error":2,"arbitration_lost":0,"error_warning":1,"error_passive":1,"bus_off":0}},"num_tx_queues":1,"num_rx_queues":1,"gso_max_size":65536,"gso_max_segs":65535,"stats64":{"rx":{"bytes":16,"packets":2,"errors":2,"dropped":0,"over_errors":0,"multicast":0},"tx":{"bytes":0,"packets":0,"errors":0,"dropped":0,"carrier_errors":0,"collisions":0}}}]' - setMockSettingValue("Relay/Function", 1) + setMockSettingValue("Relay/Function", 0) // Alarm setMockSettingValue("Relay/Polarity", 0) setMockSettingValue("Relay/1/Function", 4) // Temperature setMockSettingValue("Relay/1/Polarity", 0) diff --git a/pages/settings/PageGeneratorRuntimeService.qml b/pages/settings/PageGeneratorRuntimeService.qml deleted file mode 100644 index ca9906471..000000000 --- a/pages/settings/PageGeneratorRuntimeService.qml +++ /dev/null @@ -1,105 +0,0 @@ -/* -** Copyright (C) 2023 Victron Energy B.V. -*/ - -import QtQuick -import Victron.VenusOS - -Page { - id: root - - property string settingsBindPrefix - property string startStopBindPrefix - - DataPoint { - id: state - - source: startStopBindPrefix + "/State" - } - - GradientListView { - id: settingsListView - - model: ObjectModel { - - ListButton { - //% "Reset daily run time counters" - text: qsTrId("page_settings_generator_reset_daily_run_time_counters") - button.text: CommonWords.press_to_reset - onClicked: { - if (state.value === 0) { - var now = new Date() - var today = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())) - var todayInSeconds = today.getTime() / 1000 - resetDaily.setValue('{"%1" : 0}'.arg(todayInSeconds.toString())) - //% "The daily runtime counter has been reset" - Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_runtime_counter_reset")) - } else if (state.value === 1) { - //% "It is not possible to modify the counters while the generator is running" - Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_runtime_counter_cant_reset_while_running")) - } - } - - DataPoint { - id: resetDaily - - source: settingsBindPrefix + "/AccumulatedDaily" - } - } - - ListTextField { - id: setTotalRunTime - - //% "Generator total run time (hours)" - text: qsTrId("page_settings_generator_total_run_time") - secondaryText: Math.round(accumulatedTotalItem.value / 60 / 60) - Math.round(dataValue / 60 / 60) - textField.inputMethodHints: Qt.ImhDigitsOnly - dataSource: settingsBindPrefix + "/AccumulatedTotalOffset" - enabled: userHasWriteAccess && state.value === 0 - textField.maximumLength: 6 - onAccepted: function(hours) { - setDataValue(accumulatedTotalItem.value - hours * 60 * 60) - } - - DataPoint { - id: accumulatedTotalItem - - source: settingsBindPrefix + "/AccumulatedTotal" - } - } - - ListTextField { - id: serviceInterval - - //% "Generator service interval (hours)" - text: qsTrId("page_settings_generator_service_interval") - secondaryText: Math.round(dataValue / 60 / 60) - textField.inputMethodHints: Qt.ImhDigitsOnly - dataSource: settingsBindPrefix + "/ServiceInterval" - onAccepted: function(hours) { - setDataValue(hours * 60 * 60) - //% "Service time interval set to %1h. Use the 'Reset service timer' button to reset the service timer." - Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_service_time_interval").arg(hours)) - } - } - - ListButton { - //% "Reset service timer" - text: qsTrId("page_settings_generator_reset_service_timer") - button.text: CommonWords.press_to_reset - visible: serviceReset.valid - onClicked: { - serviceReset.setValue(1) - //% "The service timer has been reset." - Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_service_timer_has_been_reset")) - } - - DataPoint { - id: serviceReset - - source: startStopBindPrefix + "/ServiceCounterReset" - } - } - } - } -} diff --git a/pages/settings/PageSettingsGenerator.qml b/pages/settings/PageSettingsGenerator.qml index 677b31173..cc7f5019a 100644 --- a/pages/settings/PageSettingsGenerator.qml +++ b/pages/settings/PageSettingsGenerator.qml @@ -101,17 +101,49 @@ Page { writeAccessLevel: VenusOS.User_AccessType_User } - ListNavigationItem { - //% "Run time and service" - text: qsTrId("page_settings_generator_run_time_and_service") - onClicked: Global.pageManager.pushPage("/pages/settings/PageGeneratorRuntimeService.qml", - { - title: text, - settingsBindPrefix: root.settingsBindPrefix, - startStopBindPrefix: root.startStopBindPrefix - }) + ListButton { + //% "Reset daily run time counters" + text: qsTrId("page_settings_generator_reset_daily_run_time_counters") + //% "Press to reset" + button.text: qsTrId("page_settings_generator_press_to_reset") + onClicked: { + if (state.value === 0) { + var now = new Date() + var today = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())) /* ignore the 'M306' warning for this line. + QtCreator thinks that functions that start with an uppercase letter are constructor functions that should only be used with new. + 'Date.UTC(...)' is a static method, not a constructor, this is fine. */ + var todayInSeconds = today.getTime() / 1000 + resetDaily.setValue('{"%1" : 0}'.arg(todayInSeconds.toString())) + //% "The daily runtime counter has been reset" + Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_runtime_counter_reset")) + } else if (state.value === 1) { + //% "It is not possible to modify the counters while the generator is running" + Global.showToastNotification(VenusOS.Notification_Info, qsTrId("page_settings_generator_runtime_counter_cant_reset_while_running")) + } + } + DataPoint { + id: resetDaily + + source: settingsBindPrefix + "/AccumulatedDaily" + } + } + + ListTimeSelector { + id: setTotalRunTime + + //% "Generator total run time (hours)" + text: qsTrId("page_settings_generator_total_run_time") + dataSource: settingsBindPrefix + "/AccumulatedTotal" + secondaryText: Math.round(value / 60 / 60) + maximumHour: 999999 + enabled: userHasWriteAccess && state.value === 0 } } + DataPoint { + id: state + + source: startStopBindPrefix + "/State" + } } } diff --git a/qml.qrc b/qml.qrc index 1469708cb..0f4da9bb4 100644 --- a/qml.qrc +++ b/qml.qrc @@ -336,7 +336,6 @@ pages/settings/PageGenerator.qml pages/settings/PageGeneratorAcLoad.qml pages/settings/PageGeneratorConditions.qml - pages/settings/PageGeneratorRuntimeService.qml pages/settings/PageGeneratorTestRun.qml pages/settings/PageGps.qml pages/settings/PageHub4Debug.qml From f6b1b491d905cb9e9c03ea6d130fb9e1e54062a9 Mon Sep 17 00:00:00 2001 From: Daniel McInnes Date: Mon, 17 Jul 2023 12:09:00 +1000 Subject: [PATCH 7/8] Revert "ListSwitch bug - 'valid' -> 'dataValid'" This reverts commit cc3701140270bf9512abc88b7b3a195432d2dd79. --- pages/settings/PageSettingsGenerator.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/settings/PageSettingsGenerator.qml b/pages/settings/PageSettingsGenerator.qml index cc7f5019a..409f6981d 100644 --- a/pages/settings/PageSettingsGenerator.qml +++ b/pages/settings/PageSettingsGenerator.qml @@ -36,7 +36,7 @@ Page { //% "Detect generator at AC input" text: qsTrId("page_settings_generator_detect_generator_at_ac_input") dataSource: settingsBindPrefix + "/Alarms/NoGeneratorAtAcIn" - enabled: dataValid && (generatorIsSet || checked) + enabled: valid && (generatorIsSet || checked) onClicked: { if (!checked) { if (!generatorIsSet) { From 8d5350bc085f7c071f0c43d4e8b45f2a2969f77f Mon Sep 17 00:00:00 2001 From: Daniel McInnes Date: Mon, 17 Jul 2023 12:09:00 +1000 Subject: [PATCH 8/8] Revert "Update settings" This reverts commit 62f1e03571d72313d664a6efa506842cd64a39ed. --- pages/settings/PageSettingsGenerator.qml | 19 +++---------------- pages/settings/PageSettingsLogger.qml | 2 +- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/pages/settings/PageSettingsGenerator.qml b/pages/settings/PageSettingsGenerator.qml index 409f6981d..acfa78667 100644 --- a/pages/settings/PageSettingsGenerator.qml +++ b/pages/settings/PageSettingsGenerator.qml @@ -65,20 +65,7 @@ Page { } ListSwitch { - //% "Alarm when generator is not in auto start mode" - text: qsTrId("page_settings_generator_alarm_when_not_in_auto_start") - dataSource: settingsBindPrefix + "/Alarms/AutoStartDisabled" - onClicked: { - if (!checked) { - //% "An alarm will be triggered when auto start function is left disabled for more than 10 minutes." - Global.notificationLayer.showToastNotification(VenusOS.Notification_Info, - qsTrId("page_settings_generator_alarm_info"), 12000) - } - } - } - - ListSwitch { - id: quietHours + id: timeZones text: CommonWords.quiet_hours dataSource: settingsBindPrefix + "/QuietHours/Enabled" @@ -89,7 +76,7 @@ Page { //% "Quiet hours start time" text: qsTrId("page_settings_generator_quiet_hours_start_time") dataSource: settingsBindPrefix + "/QuietHours/StartTime" - visible: defaultVisible && quietHours.checked + visible: defaultVisible && timeZones.checked writeAccessLevel: VenusOS.User_AccessType_User } @@ -97,7 +84,7 @@ Page { //% "Quiet hours end time" text: qsTrId("page_settings_generator_quiet_hours_end_time") dataSource: settingsBindPrefix + "/QuietHours/EndTime" - visible: defaultVisible && quietHours.checked + visible: defaultVisible && timeZones.checked writeAccessLevel: VenusOS.User_AccessType_User } diff --git a/pages/settings/PageSettingsLogger.qml b/pages/settings/PageSettingsLogger.qml index 1e21145f1..b89b62e03 100644 --- a/pages/settings/PageSettingsLogger.qml +++ b/pages/settings/PageSettingsLogger.qml @@ -45,7 +45,7 @@ Page { ListTextItem { //% "VRM Portal ID" text: qsTrId("settings_vrm_portal_id") - dataSource: "com.victronenergy.platform/Device/UniqueId" // this doesn't work with mqtt yet, see: https://github.com/victronenergy/gui-v2/issues/385 + secondaryText: "TODO" // this depends on VePlatform, it returns the first line of /etc/venus/unique-id. Not sure how to handle it yet. } ListRadioButtonGroup {