Skip to content

Commit

Permalink
Fix bug in AC input power calculation
Browse files Browse the repository at this point in the history
Specific to AC inputs on Multi RS systems
  • Loading branch information
DanielMcInnes committed Jun 20, 2024
1 parent e1a56e0 commit c5c3b13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
4 changes: 0 additions & 4 deletions data/common/AcInputPhaseModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import Victron.VenusOS
ListModel {
id: root

signal phaseValueChanged(int phaseIndex, string propertyName, real propertyValue)

readonly property bool _feedbackEnabled: Global.systemSettings.essFeedbackToGridEnabled

property Instantiator _phaseObjects: Instantiator {
Expand All @@ -25,7 +23,6 @@ ListModel {
onClampedCurrentValueChanged: {
if (model.index >= 0 && model.index < root.count) {
setProperty(model.index, "current", clampedCurrentValue)
root.phaseValueChanged(model.index, "current", clampedCurrentValue)
}
}
}
Expand All @@ -39,7 +36,6 @@ ListModel {
onClampedPowerValueChanged: {
if (model.index >= 0 && model.index < root.count) {
setProperty(model.index, "power", clampedPowerValue)
root.phaseValueChanged(model.index, "power", clampedPowerValue)
}
}
}
Expand Down
24 changes: 7 additions & 17 deletions data/common/ActiveAcInput.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,15 @@ Device {
readonly property AcInputPhaseModel _phases: AcInputPhaseModel {
id: _phases

property real totalPower: NaN
property real firstPhaseCurrent: NaN

onPhaseValueChanged: function(phaseIndex, propertyName, propertyValue) {
if (propertyName === "power" && !root._acInputService.hasTotalPower) {
let total = NaN
for (let i = 0; i < phases.count; ++i) {
if (i === phaseIndex) {
total = Units.sumRealNumbers(total, propertyValue)
} else {
const phase = get(phaseIndex)
total = Units.sumRealNumbers(total, phase ? phase[propertyName] : NaN)
}
}
totalPower = total
} else if (propertyName === "current" && count === 1) {
firstPhaseCurrent = propertyValue
readonly property int totalPower: {
let sum = 0
for (let i = 0; i < count; ++i) {
sum += get(i).power || 0
}
return sum
}

property real firstPhaseCurrent: count === 1 ? get(0).current : NaN
}

// Data from the input-specific service, e.g. com.victronenergy.vebus for a VE.Bus input,
Expand Down

0 comments on commit c5c3b13

Please sign in to comment.