From 4a5a0bcb3a603744c9ac0ded664df20a32a162ed Mon Sep 17 00:00:00 2001 From: Yury Shuvakin Date: Wed, 17 Aug 2022 05:30:25 +0300 Subject: [PATCH] Implemented cell monitor screen --- qml/Controls/AvailabilityIndicator.qml | 12 ++ qml/Controls/TextField.qml | 2 +- qml/Controls/qmldir | 1 + qml/MainWindow.qml | 1 + qml/Screens/AkbMonitorScreen.qml | 4 +- qml/Screens/CellMonitorScreen.qml | 169 ++++++++++++++++++++++++- qml/Utils/Palette.qml | 2 + qml/qml_items.qrc | 1 + 8 files changed, 188 insertions(+), 4 deletions(-) create mode 100644 qml/Controls/AvailabilityIndicator.qml diff --git a/qml/Controls/AvailabilityIndicator.qml b/qml/Controls/AvailabilityIndicator.qml new file mode 100644 index 0000000..7650c35 --- /dev/null +++ b/qml/Controls/AvailabilityIndicator.qml @@ -0,0 +1,12 @@ +import QtQuick 2.12 + +import Utils 1.0 + +Rectangle { + property bool enabled: false + + implicitWidth: 18 + implicitHeight: 18 + radius: implicitWidth / 2 + color: enabled ? Palette.alternativeBackgroundColor : Palette.borderColor +} diff --git a/qml/Controls/TextField.qml b/qml/Controls/TextField.qml index d1e55ff..771d894 100644 --- a/qml/Controls/TextField.qml +++ b/qml/Controls/TextField.qml @@ -10,7 +10,7 @@ TextField { selectionColor: Palette.alternativeBackgroundColor background: Rectangle { - color: Palette.backgroundColor + color: enabled ? Palette.backgroundColor : Palette.hoveredBackgroundColor border.color: Palette.borderColor border.width: 1 radius: 8 diff --git a/qml/Controls/qmldir b/qml/Controls/qmldir index ba36b57..d7f3912 100644 --- a/qml/Controls/qmldir +++ b/qml/Controls/qmldir @@ -11,3 +11,4 @@ TitleLabel 1.0 TitleLabel.qml SubtitleLabel 1.0 SubtitleLabel.qml ContentLabel 1.0 ContentLabel.qml DotSeparator 1.0 DotSeparator.qml +AvailabilityIndicator 1.0 AvailabilityIndicator.qml diff --git a/qml/MainWindow.qml b/qml/MainWindow.qml index acf6b36..1f333b3 100644 --- a/qml/MainWindow.qml +++ b/qml/MainWindow.qml @@ -199,6 +199,7 @@ ApplicationWindow { Layout.fillHeight: true Layout.leftMargin: 45 Layout.rightMargin: 45 + Layout.bottomMargin: 30 Screens.AkbMonitorScreen { } diff --git a/qml/Screens/AkbMonitorScreen.qml b/qml/Screens/AkbMonitorScreen.qml index 3e4e2ce..a878c92 100644 --- a/qml/Screens/AkbMonitorScreen.qml +++ b/qml/Screens/AkbMonitorScreen.qml @@ -314,13 +314,13 @@ Item { Connections { target: BmsInterface.bmsConfig() onUpdated: { - serialField.text = BmsInterface.bmsConfig().getParamDouble("notUsedCurrentThreshold") + serialField.text = BmsInterface.bmsConfig().getParamDouble("notUsedCurrentThreshold") // TODO numberOfModulesLabel.text = BmsInterface.bmsConfig().getParamInt("cellMonitorICCount") numberOfCellsLabel.text = BmsInterface.bmsConfig().getParamInt("noOfCellsSeries") nominalCapacityLabel.text = BmsInterface.bmsConfig().getParamDouble("batteryCapacity") - actualCapacityLabel.text = nominalCapacityLabel.text + actualCapacityLabel.text = nominalCapacityLabel.text // TODO } } diff --git a/qml/Screens/CellMonitorScreen.qml b/qml/Screens/CellMonitorScreen.qml index 59aec19..1700657 100644 --- a/qml/Screens/CellMonitorScreen.qml +++ b/qml/Screens/CellMonitorScreen.qml @@ -1,13 +1,180 @@ import QtQuick 2.12 import QtQuick.Layouts 1.12 +import QtGraphicalEffects 1.0 import Controls 1.0 as Controls import Cubo 1.0 +import Utils 1.0 Item { - Controls.Frame { + Component { + id: cellListHeader + + RowLayout { + spacing: 0 + width: ListView.view.width + + Rectangle { + id: numberTab + color: Palette.tableHeaderBackgroundColor + Layout.preferredHeight: 60 + Layout.fillWidth: true + + Controls.SubtitleLabel { + text: qsTr("№") + color: Palette.tableHeaderTextColor + anchors.centerIn: parent + } + } + + Rectangle { + id: voltageTab + color: Palette.tableHeaderBackgroundColor + Layout.preferredHeight: 60 + Layout.fillWidth: true + + Controls.SubtitleLabel { + text: qsTr("Voltage") + color: Palette.tableHeaderTextColor + anchors.centerIn: parent + } + } + + Rectangle { + id: balancingTab + color: Palette.tableHeaderBackgroundColor + Layout.preferredHeight: 60 + Layout.fillWidth: true + + Controls.SubtitleLabel { + text: qsTr("Balancing") + color: Palette.tableHeaderTextColor + anchors.centerIn: parent + } + } + + Layout.fillWidth: true + } + } + + Component { + id: cellListDelegate + + RowLayout { + spacing: 10 + width: ListView.view.width + height: 36 + + Item { + Layout.preferredWidth: parent.width / 6 - 20 + } + + Controls.SubtitleLabel { + text: index + color: Palette.tableHeaderTextColor + Layout.preferredWidth: 25 + Layout.alignment: Qt.AlignCenter + } + + Controls.DotSeparator { + Layout.fillWidth: true + } + + Controls.SubtitleLabel { + text: modelData.voltage + " " + qsTr("V") + color: Palette.tableHeaderTextColor + } + + Controls.DotSeparator { + Layout.fillWidth: true + } + + Controls.AvailabilityIndicator { + enabled: modelData.balancing + Layout.alignment: Qt.AlignCenter + } + + Item { + Layout.preferredWidth: parent.width / 6 - 20 + } + } + } + + RowLayout { anchors.fill: parent + spacing: 20 + Controls.Frame { + padding: 1 + ListView { + id: firstCellGroup + anchors.fill: parent + clip: true + model: [] + spacing: 2 + + header: cellListHeader + delegate: cellListDelegate + } + + Layout.fillWidth: true + Layout.fillHeight: true + } + + Controls.Frame { + padding: 1 + visible: secondCellGroup.model.length > 0 + + ListView { + id: secondCellGroup + anchors.fill: parent + clip: true + model: [] + spacing: 2 + + header: cellListHeader + delegate: cellListDelegate + } + + Layout.fillWidth: true + Layout.fillHeight: true + } + } + + Connections { + target: BmsInterface.commands() + onCellsReceived: { + firstCellGroup.model = [] + var firstModel = [] + + for (var i = 0; i < Math.min(cellCount, 16); ++i) { + firstModel.push({"voltage": cellVoltageArray[i], "balancing": true}) + } + firstCellGroup.model = firstModel + + if (cellCount > 16) { + secondCellGroup.model = [] + var secondModel = [] + + for (var j = 16; j < Math.min(cellCount, 32); ++j) { + secondModel.push({"voltage": cellVoltageArray[j], "balancing": true}) + } + secondCellGroup.model = secondModel + } + } + } + + Connections { + target: BmsInterface + onPortConnectedChanged: getValues() + } + + onVisibleChanged: getValues() + + function getValues() { + if (BmsInterface.isPortConnected() && visible) { + BmsInterface.commands().getCells() + } } } diff --git a/qml/Utils/Palette.qml b/qml/Utils/Palette.qml index 9b9ac0f..b5ae2f4 100644 --- a/qml/Utils/Palette.qml +++ b/qml/Utils/Palette.qml @@ -6,12 +6,14 @@ QtObject { property color selectedTextColor: "#009352" property color contentTextColor: "#869098" property color alternativeTextColor: "#FFFFFF" + property color tableHeaderTextColor: "#838D97" property color backgroundColor: "#FFFFFF" property color hoveredBackgroundColor: "#F0F1F4" property color selectedBackgroundColor: "#CCE9DC" property color alternativeBackgroundColor: "#009352" property color screenBackgroundColor: "#F7F8FC" + property color tableHeaderBackgroundColor: "#F0F1F4" property color borderColor: "#DFE0EB" diff --git a/qml/qml_items.qrc b/qml/qml_items.qrc index 6fd0e79..11a0ec5 100644 --- a/qml/qml_items.qrc +++ b/qml/qml_items.qrc @@ -20,5 +20,6 @@ Controls/SubtitleLabel.qml Controls/ContentLabel.qml Controls/DotSeparator.qml + Controls/AvailabilityIndicator.qml