Skip to content

Commit

Permalink
Rename SolarChargerPage to SolarDevicePage
Browse files Browse the repository at this point in the history
This page will no longer be specific to solarcharger devices; it will
also show multi and inverter devices that support solar data.

Give the file a more generic name, and add a "Product page" link to
the appropriate settings page for the service.

Remove "Link", "Networked operation" and "Alarms & Errors" list items
as those are already present in PageSolarCharger, and are not relevant
to multi and inverter devices. The "Alarms & Errors" information is
now more basic, but it needs to be reworked to be more useful in any
case.

Part of #1574
  • Loading branch information
blammit committed Jan 21, 2025
1 parent 16f53c8 commit 4c6f84a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 149 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,7 @@ set (VENUS_QML_MODULE_SOURCES
pages/solar/PageSolarCharger.qml
pages/solar/PageSolarParallelOperation.qml
pages/solar/PvInverterPage.qml
pages/solar/SolarChargerAlarmsAndErrorsPage.qml
pages/solar/SolarChargerPage.qml
pages/solar/SolarDevicePage.qml
pages/solar/SolarDeviceListPage.qml
pages/solar/SolarHistoryPage.qml
pages/vebusdevice/PageAcSensor.qml
Expand Down
2 changes: 1 addition & 1 deletion components/widgets/SolarYieldWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ OverviewWidget {
onClicked: {
const singleDeviceOnly = (Global.solarChargers.model.count + Global.pvInverters.model.count) === 1
if (singleDeviceOnly && Global.solarChargers.model.count === 1) {
Global.pageManager.pushPage("/pages/solar/SolarChargerPage.qml",
Global.pageManager.pushPage("/pages/solar/SolarDevicePage.qml",
{ "bindPrefix": Global.solarChargers.model.firstObject.serviceUid })
} else if (singleDeviceOnly && Global.pvInverters.model === 1) {
Global.pageManager.pushPage("/pages/solar/PvInverterPage.qml",
Expand Down
78 changes: 0 additions & 78 deletions pages/solar/SolarChargerAlarmsAndErrorsPage.qml

This file was deleted.

2 changes: 1 addition & 1 deletion pages/solar/SolarDeviceListPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Page {
tableMode: true

onClicked: {
Global.pageManager.pushPage("/pages/solar/SolarChargerPage.qml", { "bindPrefix": solarCharger.serviceUid })
Global.pageManager.pushPage("/pages/solar/SolarDevicePage.qml", { "bindPrefix": solarCharger.serviceUid })
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,6 @@ Page {
]
}

/* Only available on 15A chargers */
/* If load is on and current present, show current.
* Otherwise show the state of the load output. */
ListQuantity {
id: loadQuantityItem

//% "Load"
text: qsTrId("charger_load")
dataItem.uid: root.solarCharger.serviceUid + "/Load/I"
unit: VenusOS.Units_Amp
preferredVisible: dataItem.isValid
}

ListText {
text: loadQuantityItem.text
dataItem.uid: root.solarCharger.serviceUid + "/Load/State"
preferredVisible: dataItem.isValid && !loadQuantityItem.visible
secondaryText: CommonWords.yesOrNo(dataItem.value)
}

ListSwitch {
text: CommonWords.relay
checked: root.solarCharger.relayOn
Expand All @@ -135,49 +115,10 @@ Page {
enabled: false
}

ListNavigation {
// This is the number of active alarms, plus the active error (if present).
readonly property int itemCount: (lowBatteryAlarm.isValid && lowBatteryAlarm.value !== 0 ? 1 : 0)
+ (highBatteryAlarm.isValid && highBatteryAlarm.value !== 0 ? 1 : 0)
+ (highTemperatureAlarm.isValid && highTemperatureAlarm.value !== 0 ? 1 : 0)
+ (shortCircuitAlarm.isValid && shortCircuitAlarm.value !== 0 ? 1 : 0)
+ (root.solarCharger.errorCode > 0 ? 1 : 0)

//% "Alarms & Errors"
text: qsTrId("charger_alarms_alarms_and_errors")
secondaryText: enabled
? (itemCount > 0
//: Shows number of items found. %1 = number of items
//% "%1 found"
? qsTrId("charger_history_found_with_count").arg(itemCount)
: "")
: CommonWords.none_errors
secondaryLabel.color: itemCount ? Theme.color_critical : Theme.color_font_secondary

// Only enable if there is content on the alarms/errors page.
enabled: itemCount > 0 || root.solarCharger.errorModel.count

onClicked: {
Global.pageManager.pushPage("/pages/solar/SolarChargerAlarmsAndErrorsPage.qml",
{ "title": text, "solarCharger": root.solarCharger })
}

VeQuickItem {
id: lowBatteryAlarm
uid: root.solarCharger.serviceUid + "/Alarms/LowVoltage"
}
VeQuickItem {
id: highBatteryAlarm
uid: root.solarCharger.serviceUid + "/Alarms/HighVoltage"
}
VeQuickItem {
id: highTemperatureAlarm
uid: root.solarCharger.serviceUid + "/Alarms/HighTemperature"
}
VeQuickItem {
id: shortCircuitAlarm
uid: root.solarCharger.serviceUid + "/Alarms/ShortCircuit"
}
ListText {
text: CommonWords.error
dataItem.uid: root.solarCharger.serviceUid + "/ErrorCode"
secondaryText: ChargerError.description(dataItem.value)
}

ListNavigation {
Expand All @@ -190,16 +131,31 @@ Page {
}

ListNavigation {
//% "Networked operation"
text: qsTrId("charger_networked_operation")
id: productPageLink

readonly property string pageUrl: {
const serviceType = BackendConnection.serviceTypeFromUid(root.solarCharger.serviceUid)
if (serviceType === "solarcharger") {
return "/pages/solar/PageSolarCharger.qml"
} else if (serviceType === "multi") {
return "/pages/settings/devicelist/rs/PageMultiRs.qml"
} else if (serviceType === "inverter") {
return "/pages/settings/devicelist/inverter/PageInverter.qml"
} else {
return ""
}
}

text: CommonWords.product_page
preferredVisible: pageUrl.length > 0
onClicked: {
Global.pageManager.pushPage("/pages/solar/PageSolarParallelOperation.qml",
{ "title": text, "bindPrefix": root.solarCharger.serviceUid })
Global.pageManager.pushPage(pageUrl, { title: text, bindPrefix: root.solarCharger.serviceUid })
}
}

ListNavigation {
text: CommonWords.device_info_title
preferredVisible: productPageLink.pageUrl.length === 0
onClicked: {
Global.pageManager.pushPage("/pages/settings/PageDeviceInfo.qml",
{ "title": text, "bindPrefix": root.solarCharger.serviceUid })
Expand Down

0 comments on commit 4c6f84a

Please sign in to comment.