import QtQuick 2.12 import QtQuick.Layouts 1.12 import Controls 1.0 as Controls import Cubo 1.0 import Utils 1.0 Item { id: root ColumnLayout { spacing: 15 anchors.fill: parent Controls.Frame { padding: 35 implicitWidth: parent.width Layout.fillWidth: true RowLayout { spacing: 70 anchors.fill: parent Controls.TitleLabel { text: qsTr("Serial number") Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.spacing) / 2 } Controls.TextField { id: serialNumberField enabled: false Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.spacing) / 2 } } } Controls.Frame { padding: 35 implicitWidth: parent.width Layout.fillWidth: true GridLayout { columns: 2 columnSpacing: 70 rowSpacing: 20 anchors.fill: parent RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Battery charge level, %") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: batteryChargeLevelLabel text: "-" } Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Number of modules") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: numberOfModulesLabel text: "-" } Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Battery voltage, V") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: batteryVoltageLabel text: "-" } Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Number of cells") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: numberOfCellsLabel text: "-" } Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Nominal capacity, A/h") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: nominalCapacityLabel text: "-" } Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Actual capacity, A/h") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: actualCapacityLabel text: "-" } Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Battery temperature, °C") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: batteryTemperatureLabel text: "-" } Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } // RowLayout { // spacing: 10 // Controls.ContentLabel { // text: qsTr("BMS temperature, °C") // } // Controls.DotSeparator { // Layout.fillWidth: true // } // Controls.SubtitleLabel { // id: bmsTemperatureLabel // text: "-" // } // Layout.fillWidth: true // Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 // } } } Controls.Frame { padding: 35 implicitWidth: parent.width Layout.fillWidth: true GridLayout { columns: 2 columnSpacing: 70 rowSpacing: 20 anchors.fill: parent RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Maximum cell voltage, V") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: maximumCellVoltageLabel text: "-" } Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Minimum cell voltage, V") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: minimumCellVoltageLabel text: "-" } Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Current") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: currentLabel text: "-" } Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } } } Item { Layout.fillHeight: true } } Connections { target: BmsInterface.commands() enabled: root.visible onValuesReceived: { batteryChargeLevelLabel.text = values.soC batteryVoltageLabel.text = MathHelper.roundDouble(values.packVoltage) batteryTemperatureLabel.text = MathHelper.roundDouble(values.tempBattHigh) // bmsTemperatureLabel.text = MathHelper.roundDouble(values.tempBMSHigh) maximumCellVoltageLabel.text = MathHelper.roundDouble(values.cVHigh) minimumCellVoltageLabel.text = MathHelper.roundDouble(values.cVLow) currentLabel.text = MathHelper.roundDouble(values.packCurrent) } } Connections { target: BmsInterface.bmsConfig() onUpdated: { serialNumberField.text = Number(BmsInterface.bmsConfig().getParamDouble("notUsedCurrentThreshold")).toFixed() numberOfModulesLabel.text = BmsInterface.bmsConfig().getParamInt("cellMonitorICCount") numberOfCellsLabel.text = BmsInterface.bmsConfig().getParamInt("noOfCellsSeries") nominalCapacityLabel.text = MathHelper.roundDouble(BmsInterface.bmsConfig().getParamDouble("batteryCapacity")) actualCapacityLabel.text = nominalCapacityLabel.text // TODO } } Connections { target: BmsInterface onPortConnectedChanged: getValues() } onVisibleChanged: getValues() Timer { id: refreshValuesTimer interval: 1000 onTriggered: getValues() } function getValues() { if (BmsInterface.isPortConnected() && visible) { BmsInterface.commands().getValues() refreshValuesTimer.start() } } }