Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion data/mock/SystemAcImpl.qml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ Item {
let phaseAcOutCurrent = NaN
for (let objectIndex = 0; objectIndex < count; ++objectIndex) {
const acService = objectAt(objectIndex)
if (!acService) {
const acServicePhaseCount = Math.max(acService.acIn.phaseCount, acService.acOut.phaseCount)
if (!acService || phaseIndex >= acServicePhaseCount) {
continue
}
phaseAcInPower = Units.sumRealNumbers(phaseAcInPower, acService.acIn["powerL" + (phaseIndex + 1)].value)
Expand Down Expand Up @@ -173,6 +174,12 @@ Item {
: _activeInput.value + 1
property bool completed

readonly property string phaseCountUid: (acService.serviceType === "vebus" || acService.serviceType === "acsystem")
? acService.uid + "/Ac/NumberOfPhases"
: (acService.serviceType === "grid" || acService.serviceType === "genset")
? acService.uid + "/NrOfPhases"
: ""

// For simplicity, attempt to fetch L1/L2/L3 in/out data, regardless of the actual
// number of phases on the device.
readonly property ObjectAcConnection acIn: ObjectAcConnection {
Expand All @@ -182,6 +189,12 @@ Item {
: acService.serviceType === "acsystem" ? acService.uid + "/Ac/In/%1".arg(activeInput.value + 1)
: acService.serviceType === "charger" ? acService.uid + "/Ac/In"
: "" // no AC-in for inverters
_phaseCount.uid: acService.phaseCountUid
onPhaseCountChanged: {
if (acService.completed) {
Qt.callLater(acServiceObjects.updateConsumption)
}
}
onPowerChanged: {
if (acService.completed) {
Qt.callLater(acServiceObjects.updateConsumption)
Expand All @@ -192,6 +205,12 @@ Item {
powerKey: "P"
currentKey: "I"
bindPrefix: acService.serviceType === "charger" ? "" : acService.uid + "/Ac/Out"
_phaseCount.uid: acService.phaseCountUid
onPhaseCountChanged: {
if (acService.completed) {
Qt.callLater(acServiceObjects.updateConsumption)
}
}
onPowerChanged: {
if (acService.completed) {
Qt.callLater(acServiceObjects.updateConsumption)
Expand Down
37 changes: 32 additions & 5 deletions data/mock/page-conf/BriefAndOverviewPageConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ Item {
}

function setSystem(config) {
let i
if (config?.state !== undefined) {
MockManager.setValue(Global.system.serviceUid + "/SystemState/State", config.state)
}
Expand All @@ -314,15 +315,32 @@ Item {
MockManager.setValue(Global.systemSettings.serviceUid + "/Settings/SystemSetup/HasAcOutSystem", config.hasAcOutSystem ? 1 : 0)
}
const phaseCount = config?.ac ? (config.ac.phaseCount ?? 3) : 0
Global.system.load.ac.phases.phaseCount = phaseCount
Global.system.load.acIn.phases.phaseCount = phaseCount
Global.system.load.acOut.phases.phaseCount = phaseCount

// Clear the Power/Current values for any phases beyond the requested phase count.
for (const path of ["/Ac/Consumption", "/Ac/ConsumptionOnInput", "/Ac/ConsumptionOnOutput"]) {
for (i = 0; i < 3; ++i) {
const phasePath = Global.system.serviceUid + path + "/L" + (i+1)
for (const phaseSubPath of ["/Power", "/Current"]) {
if (i >= phaseCount) {
MockManager.setValue(phasePath + phaseSubPath, undefined)
} else {
MockManager.setValue(phasePath + phaseSubPath, 0)
}
}
}
}

// Update the /NumberOfPhases for the system AC load totals.
for (const acObject of [Global.system.load.ac, Global.system.load.acIn, Global.system.load.acOut]) {
acObject._phaseCount.setValue(0) // trigger reset of PhaseModel
acObject._phaseCount.setValue(phaseCount)
}

while (dcLoadsModel.count > 0) {
removeDevice(dcLoadsModel.deviceAt(dcLoadsModel.count - 1).serviceUid)
}
const dcServiceTypes = config?.dc?.serviceTypes ?? []
for (let i = 0; i < dcServiceTypes.length; ++i) {
for (i = 0; i < dcServiceTypes.length; ++i) {
const values = {
"/Dc/0/Power": Math.random() * 500,
"/Dc/0/Voltage": Math.random() * 50,
Expand Down Expand Up @@ -372,8 +390,10 @@ Item {
// Set phase data
const objectAcConn = input._phaseMeasurements
const phaseCount = inputInfoConfig.phaseCount ?? 1
objectAcConn._phaseCount.setValue(0) // trigger reset of PhaseModel
objectAcConn._phaseCount.setValue(phaseCount)
for (let phaseIndex = 0; phaseIndex < phaseCount; phaseIndex++) {
let phaseIndex
for (phaseIndex = 0; phaseIndex < phaseCount; phaseIndex++) {
const current = Math.random() * 30
const voltage = current * 5
const powerItem = objectAcConn["powerL" + (phaseIndex + 1)]
Expand All @@ -389,6 +409,13 @@ Item {
MockManager.setValue(`${objectAcConn.bindPrefix}/L${phaseIndex + 1}/${voltageKey}`, voltage)
}
}

// Clear the Power/Current values for any phases beyond the requested phase count.
for (phaseIndex = phaseCount; phaseIndex < 3; ++phaseIndex) {
const phasePath = `${objectAcConn.bindPrefix}/L${phaseIndex + 1}`
MockManager.setValue(phasePath + "/" + objectAcConn.powerKey, undefined)
MockManager.setValue(phasePath + "/" + objectAcConn.currentKey, undefined)
}
}
}

Expand Down