Skip to content

Commit

Permalink
Refactor - move totalPower and firstPhaseCurrent properties
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMcInnes committed Jul 3, 2024
1 parent c4f3879 commit 78d672a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
16 changes: 15 additions & 1 deletion data/common/AcInputPhaseModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@ import Victron.VenusOS
ListModel {
id: root

readonly property bool _feedbackEnabled: Global.systemSettings.essFeedbackToGridEnabled
property int totalPower
property real firstPhaseCurrent: count === 1 ? get(0).current : NaN

readonly property Timer _timer: Timer { // timer needed so the display doesn't update too frequently
interval: 1000
repeat: true
running: true
onTriggered: {
let sum = 0
for (let i = 0; i < _phases.count; ++i) {
sum += _phases.get(i).power || 0
}
root.totalPower = sum
}
}

property Instantiator _phaseObjects: Instantiator {
model: null
Expand Down
15 changes: 0 additions & 15 deletions data/common/ActiveAcInput.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@ Device {
readonly property AcInputPhaseModel _phases: AcInputPhaseModel {
id: _phases

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

readonly property Timer _timer: Timer { // timer needed so the display doesn't update too frequently
interval: 1000
repeat: true
running: true
onTriggered: {
let sum = 0
for (let i = 0; i < _phases.count; ++i) {
sum += _phases.get(i).power || 0
}
_phases.totalPower = sum
}
}
}

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

0 comments on commit 78d672a

Please sign in to comment.