Innovenergy_trunk/firmware/opt/victronenergy/gui/qml/PageBatteryContainer.qml

57 lines
1.2 KiB
QML

import QtQuick 1.1
import com.victron.velib 1.0
import "utils.js" as Utils
MbPage {
id: root
property string bindPrefix
title: qsTr("Individual Batteries")
property VBusItem batteryCheck:VBusItem {}
model: VisualItemModel {}
function isBatteryPresent(x)
{
batteryCheck.bind=Utils.path(bindPrefix, "/_Battery/" + x + "/Dc/0/Current");
return batteryCheck.valid;
}
function createBatteries()
{
var batteryComponent = Qt.createComponent("PageBattery.qml");
var submenuComponent = Qt.createComponent("MbSubMenu.qml");
var textComponent = Qt.createComponent("MbTextBlock.qml");
function createBattery(n)
{
var submenu = submenuComponent.createObject(root)
var title = qsTr("Node") + " " + n
var text = textComponent.createObject(root)
submenu.description = title
var bat = batteryComponent.createObject(root)
bat.bindPrefix = Utils.path(bindPrefix, "/_Battery/" + n)
bat.slaveAddress = n
bat.summary = title
submenu.subpage = bat
text.item=bat.bmsVersion
submenu.values= text
bat.isAggregatedBattery = true
return submenu
}
for (var i = 1; i <= 10; i++)
{
if (isBatteryPresent(i)) {
model.append(createBattery(i))
}
}
root.initListView()
}
Component.onCompleted: createBatteries()
}