Skip to content

Commit

Permalink
Remove Global.solarChargers
Browse files Browse the repository at this point in the history
Use Global.solarDevices instead, as that contains not only
solarcharger devices, but also any multi and inverter devices that
have solar trackers.

AllDevicesModel now needs its own list of solarcharger devices, as it
cannot use Global.solarDevices.model, since that may contain multi
services (which should not be in the Device List), and also may
contain inverter services (which are already provided by
Global.inverterChargers.inverters).

Part of #1574
  • Loading branch information
blammit committed Jan 22, 2025
1 parent bf94162 commit 27ec557
Show file tree
Hide file tree
Showing 25 changed files with 103 additions and 412 deletions.
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ set (VENUS_QML_MODULE_SOURCES
data/ManualRelayModel.qml
data/Notifications.qml
data/PvInverters.qml
data/SolarChargers.qml
data/SolarDevices.qml
data/StartPageConfiguration.qml
data/System.qml
Expand All @@ -421,7 +420,6 @@ set (VENUS_QML_MODULE_SOURCES
data/common/Notification.qml
data/common/PvInverter.qml
data/common/PvMonitor.qml
data/common/SolarCharger.qml
data/common/SolarDailyHistory.qml
data/common/SolarDevice.qml
data/common/SolarHistory.qml
Expand Down Expand Up @@ -802,7 +800,6 @@ set(Dbus_QML_MODULE_SOURCES
data/dbus/GeneratorsImpl.qml
data/dbus/NotificationsImpl.qml
data/dbus/PvInvertersImpl.qml
data/dbus/SolarChargersImpl.qml
data/dbus/SystemSettingsImpl.qml
data/dbus/TanksImpl.qml
data/dbus/InverterChargersImpl.qml
Expand Down Expand Up @@ -850,7 +847,7 @@ set(Mock_QML_MODULE_SOURCES
data/mock/NotificationsImpl.qml
data/mock/PulseMetersImpl.qml
data/mock/PvInvertersImpl.qml
data/mock/SolarChargersImpl.qml
data/mock/SolarDevicesImpl.qml
data/mock/SystemImpl.qml
data/mock/SystemSettingsImpl.qml
data/mock/TanksImpl.qml
Expand Down Expand Up @@ -921,7 +918,6 @@ set(Mqtt_QML_MODULE_SOURCES
data/mqtt/MqttDataManager.qml
data/mqtt/NotificationsImpl.qml
data/mqtt/PvInvertersImpl.qml
data/mqtt/SolarChargersImpl.qml
data/mqtt/SystemSettingsImpl.qml
data/mqtt/TanksImpl.qml
data/mqtt/InverterChargersImpl.qml
Expand Down
4 changes: 1 addition & 3 deletions Global.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ QtObject {
property var inverterChargers
property var notifications
property var pvInverters
property var solarChargers
property var solarDevices
property var system
property var systemSettings
Expand Down Expand Up @@ -75,7 +74,7 @@ QtObject {
if (deviceClass === "com.victronenergy.battery") {
return [allDevicesModel.batteryDevices]
} else if (deviceClass === "com.victronenergy.solarcharger" || deviceClass === "solarcharger") {
return [solarChargers.model]
return [solarDevices.model]
} else if (deviceClass === "analog") {
return Global.tanks.allTankModels.concat([Global.environmentInputs.model])
}
Expand Down Expand Up @@ -107,7 +106,6 @@ QtObject {
inverterChargers = null
notifications = null
pvInverters = null
solarChargers = null
solarDevices = null
system = null
systemSettings = null
Expand Down
7 changes: 6 additions & 1 deletion components/AllDevicesModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ AggregateDeviceModel {
meteoDevices,
motorDriveDevices,
pulseMeterDevices,
solarChargerDevices,
Global.pvInverters.model,
Global.solarChargers.model,
unsupportedDevices,

// AC input models
Expand Down Expand Up @@ -85,6 +85,11 @@ AggregateDeviceModel {
modelId: "pulsemeter"
}

readonly property ServiceDeviceModel solarChargerDevices: ServiceDeviceModel {
serviceType: "solarcharger"
modelId: "solarcharger"
}

readonly property ServiceDeviceModel unsupportedDevices: ServiceDeviceModel {
serviceType: "unsupported"
modelId: "unsupported"
Expand Down
8 changes: 4 additions & 4 deletions components/SolarYieldModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ListModel {
property bool _resetting

property Instantiator _yieldUpdateConnections: Instantiator {
model: !!root.targetHistory ? null : Global.solarChargers.model
model: !!root.targetHistory ? null : Global.solarDevices.model

delegate: Connections {
target: model.device
Expand Down Expand Up @@ -52,9 +52,9 @@ ListModel {
yieldForDay += history.yieldKwh
}
} else {
for (i = 0; i < Global.solarChargers.model.count; ++i) {
const solarCharger = Global.solarChargers.model.deviceAt(i)
history = solarCharger.dailyHistory(day)
for (i = 0; i < Global.solarDevices.model.count; ++i) {
const solarDevice = Global.solarDevices.model.deviceAt(i)
history = solarDevice.dailyHistory(day)
if (history && !isNaN(history.yieldKwh)) {
yieldForDay += history.yieldKwh
}
Expand Down
8 changes: 4 additions & 4 deletions components/widgets/SolarYieldWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ OverviewWidget {
id: root

onClicked: {
const singleDeviceOnly = (Global.solarChargers.model.count + Global.pvInverters.model.count) === 1
if (singleDeviceOnly && Global.solarChargers.model.count === 1) {
const singleDeviceOnly = (Global.solarDevices.model.count + Global.pvInverters.model.count) === 1
if (singleDeviceOnly && Global.solarDevices.model.count === 1) {
Global.pageManager.pushPage("/pages/solar/SolarDevicePage.qml",
{ "bindPrefix": Global.solarChargers.model.firstObject.serviceUid })
{ "solarDevice": Global.solarDevices.model.firstObject })
} else if (singleDeviceOnly && Global.pvInverters.model === 1) {
Global.pageManager.pushPage("/pages/solar/PvInverterPage.qml",
{ "pvInverter": Global.pvInverters.model.deviceAt(0) })
Expand Down Expand Up @@ -53,7 +53,7 @@ OverviewWidget {
}
active: root.size >= VenusOS.OverviewWidget_Size_L
sourceComponent: {
if (Global.pvInverters.model.count === 1 && Global.solarChargers.model.count === 0) {
if (Global.pvInverters.model.count === 1 && Global.solarDevices.model.count === 0) {
return phaseComponent
} else if (Global.pvInverters.model.count === 0) {
return historyComponent
Expand Down
2 changes: 0 additions & 2 deletions data/DataManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Item {
&& !!Global.inverterChargers
&& !!Global.notifications
&& !!Global.pvInverters
&& !!Global.solarChargers
&& !!Global.solarDevices
&& !!Global.system
&& !!Global.systemSettings
Expand Down Expand Up @@ -100,7 +99,6 @@ Item {
InverterChargers {}
Notifications {}
PvInverters {}
SolarChargers {}
SolarDevices {}
System {}
SystemSettings {}
Expand Down
48 changes: 0 additions & 48 deletions data/SolarChargers.qml

This file was deleted.

4 changes: 2 additions & 2 deletions data/System.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ QtObject {
// In cases where the overall current cannot be determined, the value is NaN.
readonly property real current: {
if (Global.pvInverters.model.count > 0) {
if (Global.solarChargers.model.count > 0) {
if (Global.solarDevices.model.count > 0) {
// If both PV chargers and PV inverters are present, return NaN as the current
// cannot be summed across AC and DC systems.
return NaN
Expand All @@ -69,7 +69,7 @@ QtObject {
// There are one or more PV inverters, which are all single-phase, so it's safe to
// return a total current as they should all have the same PV output voltage.
return _pvMonitor.totalCurrent
} else if (Global.solarChargers.model.count > 0) {
} else if (Global.solarDevices.model.count > 0) {
return _dcPvCurrent.isValid ? _dcPvCurrent.value : NaN
}
return NaN
Expand Down
139 changes: 0 additions & 139 deletions data/common/SolarCharger.qml

This file was deleted.

2 changes: 1 addition & 1 deletion data/common/SolarDevice.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Device {
function trackerName(trackerIndex, format) {
const tracker = _trackerObjects.objectAt(trackerIndex)
const trackerName = tracker ? tracker.name || "" : ""
return Global.solarChargers.formatTrackerName(trackerName, trackerIndex, trackers.count, root.name, format)
return Global.solarDevices.formatTrackerName(trackerName, trackerIndex, trackers.count, root.name, format)
}

//--- internal members below ---
Expand Down
2 changes: 1 addition & 1 deletion data/common/SolarHistory.qml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ QtObject {
function trackerName(trackerIndex, format) {
const nameObject = _trackerNames.objectAt(trackerIndex)
const name = nameObject ? nameObject.value || "" : ""
return Global.solarChargers.formatTrackerName(name, trackerIndex, trackerCount, deviceName, format)
return Global.solarDevices.formatTrackerName(name, trackerIndex, trackerCount, deviceName, format)
}

readonly property Instantiator _trackerNames: Instantiator {
Expand Down
1 change: 0 additions & 1 deletion data/dbus/DBusDataManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ QtObject {
property var inverterChargers: InverterChargersImpl {}
property var notifications: NotificationsImpl {}
property var pvInverters: PvInvertersImpl { }
property var solarChargers: SolarChargersImpl { }
property var systemSettings: SystemSettingsImpl { }
property var tanks: TanksImpl { }

Expand Down
Loading

0 comments on commit 27ec557

Please sign in to comment.