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 a3370bf
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions data/common/ActiveAcInput.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,17 @@ Device {
readonly property AcInputPhaseModel _phases: AcInputPhaseModel {
id: _phases

property real totalPower: NaN
property real firstPhaseCurrent: NaN
readonly property int totalPower: {
let sum = 0
for (let i = 0; i < count; ++i) {
sum += get(i).power || 0
}
return sum
}

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) {
if (propertyName === "current" && count === 1) {
firstPhaseCurrent = propertyValue
}
}
Expand Down

0 comments on commit a3370bf

Please sign in to comment.