diff --git a/bmsinterface.cpp b/bmsinterface.cpp index d83ac77..c7f7a35 100644 --- a/bmsinterface.cpp +++ b/bmsinterface.cpp @@ -429,7 +429,7 @@ bool BMSInterface::connectSerial(QString port, int baudrate) bool found = false; for (VSerialInfo_t ser: listSerialPorts()) { - if (ser.systemPath == port) { + if (ser.name == port) { found = true; break; } @@ -522,7 +522,7 @@ QStringList BMSInterface::serialPortNames() QStringList names; for (const auto& info: listSerialPorts()) { - names.append(info.systemPath); + names.append(info.name); } return names; } diff --git a/configparams.h b/configparams.h index 9936465..ddebf8d 100644 --- a/configparams.h +++ b/configparams.h @@ -101,10 +101,10 @@ public: bool loadXml(QString fileName, QString configName); QString xmlStatus(); - void getParamsXML(QXmlStreamWriter &stream); - bool setParamsXML(QXmlStreamReader &stream); - bool saveParamsXml(QString fileName); - bool loadParamsXml(QString fileName); + Q_INVOKABLE void getParamsXML(QXmlStreamWriter &stream); + Q_INVOKABLE bool setParamsXML(QXmlStreamReader &stream); + Q_INVOKABLE bool saveParamsXml(QString fileName); + Q_INVOKABLE bool loadParamsXml(QString fileName); bool saveCDefines(const QString &fileName, bool wrapIfdef = false); diff --git a/qml/Controls/ContentLabel.qml b/qml/Controls/ContentLabel.qml index c632db5..2141feb 100644 --- a/qml/Controls/ContentLabel.qml +++ b/qml/Controls/ContentLabel.qml @@ -7,4 +7,5 @@ Label { color: Palette.contentTextColor font.pixelSize: 18 font.weight: Font.Medium + elide: Text.ElideRight } diff --git a/qml/Controls/SubtitleLabel.qml b/qml/Controls/SubtitleLabel.qml index 2bae39e..32549d4 100644 --- a/qml/Controls/SubtitleLabel.qml +++ b/qml/Controls/SubtitleLabel.qml @@ -4,7 +4,8 @@ import QtQuick.Controls 2.12 import Utils 1.0 Label { - color: Palette.contentTextColor + color: Palette.textColor font.pixelSize: 18 font.weight: Font.ExtraBold + elide: Text.ElideRight } diff --git a/qml/Controls/TextField.qml b/qml/Controls/TextField.qml index 274b236..d1e55ff 100644 --- a/qml/Controls/TextField.qml +++ b/qml/Controls/TextField.qml @@ -1,6 +1,18 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 +import Utils 1.0 + TextField { + implicitHeight: 58 + color: Palette.textColor selectByMouse: true + selectionColor: Palette.alternativeBackgroundColor + + background: Rectangle { + color: Palette.backgroundColor + border.color: Palette.borderColor + border.width: 1 + radius: 8 + } } diff --git a/qml/Controls/TitleLabel.qml b/qml/Controls/TitleLabel.qml index 6fdc5a4..6c4bcda 100644 --- a/qml/Controls/TitleLabel.qml +++ b/qml/Controls/TitleLabel.qml @@ -7,4 +7,5 @@ Label { color: Palette.selectedTextColor font.pixelSize: 28 font.weight: Font.ExtraBold + elide: Text.ElideRight } diff --git a/qml/MainWindow.qml b/qml/MainWindow.qml index 95bc64c..acf6b36 100644 --- a/qml/MainWindow.qml +++ b/qml/MainWindow.qml @@ -4,6 +4,7 @@ import QtQuick.Layouts 1.12 import Controls 1.0 as Controls import Screens 1.0 as Screens +import Cubo 1.0 import Utils 1.0 ApplicationWindow { @@ -216,5 +217,10 @@ ApplicationWindow { color: Palette.screenBackgroundColor } - Component.onCompleted: connectionScreen.open() + Component.onCompleted: { + BmsInterface.bmsConfig().loadParamsXml("://res/config.xml") + BmsInterface.infoConfig().loadParamsXml("://res/info.xml") + + connectionScreen.open() + } } diff --git a/qml/Screens/AkbMonitorScreen.qml b/qml/Screens/AkbMonitorScreen.qml index 8491192..3e4e2ce 100644 --- a/qml/Screens/AkbMonitorScreen.qml +++ b/qml/Screens/AkbMonitorScreen.qml @@ -2,39 +2,54 @@ import QtQuick 2.12 import QtQuick.Layouts 1.12 import Controls 1.0 as Controls +import Cubo 1.0 Item { ColumnLayout { + spacing: 15 anchors.fill: parent Controls.Frame { + padding: 35 + implicitWidth: parent.width Layout.fillWidth: true RowLayout { + spacing: 90 anchors.fill: parent Controls.TitleLabel { text: qsTr("Serial number") Layout.fillWidth: true + Layout.maximumWidth: (parent.width - parent.spacing) / 2 } Controls.TextField { - text: "AABBCCDD" + id: serialField + 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: 90 + rowSpacing: 20 anchors.fill: parent RowLayout { + spacing: 10 Controls.ContentLabel { text: qsTr("Battery charge level, V") + Layout.fillWidth: true + Layout.maximumWidth: implicitWidth } Controls.DotSeparator { @@ -42,15 +57,20 @@ Item { } 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") + Layout.fillWidth: true + Layout.maximumWidth: implicitWidth } Controls.DotSeparator { @@ -58,15 +78,20 @@ Item { } 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") + Layout.fillWidth: true + Layout.maximumWidth: implicitWidth } Controls.DotSeparator { @@ -74,15 +99,20 @@ Item { } 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") + Layout.fillWidth: true + Layout.maximumWidth: implicitWidth } Controls.DotSeparator { @@ -90,10 +120,172 @@ Item { } 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") + Layout.fillWidth: true + Layout.maximumWidth: implicitWidth + } + + 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") + Layout.fillWidth: true + Layout.maximumWidth: implicitWidth + } + + 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") + Layout.fillWidth: true + Layout.maximumWidth: implicitWidth + } + + 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") + Layout.fillWidth: true + Layout.maximumWidth: implicitWidth + } + + 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: 90 + rowSpacing: 20 + anchors.fill: parent + + RowLayout { + spacing: 10 + Controls.ContentLabel { + text: qsTr("Maximum cell voltage, V") + Layout.fillWidth: true + Layout.maximumWidth: implicitWidth + } + + 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") + Layout.fillWidth: true + Layout.maximumWidth: implicitWidth + } + + 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") + Layout.fillWidth: true + Layout.maximumWidth: implicitWidth + } + + Controls.DotSeparator { + Layout.fillWidth: true + } + + Controls.SubtitleLabel { + id: currentLabel + text: "-" + } + + Layout.fillWidth: true + Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } } } @@ -102,4 +294,47 @@ Item { Layout.fillHeight: true } } + + Connections { + target: BmsInterface.commands() + onValuesReceived: { + batteryChargeLevelLabel.text = values.soC + batteryVoltageLabel.text = values.packVoltage + + batteryTemperatureLabel.text = values.tempBattHigh + bmsTemperatureLabel.text = values.tempBMSHigh + + maximumCellVoltageLabel.text = values.cVHigh + minimumCellVoltageLabel.text = values.cVLow + + currentLabel.text = values.packCurrent + } + } + + Connections { + target: BmsInterface.bmsConfig() + onUpdated: { + serialField.text = BmsInterface.bmsConfig().getParamDouble("notUsedCurrentThreshold") + + numberOfModulesLabel.text = BmsInterface.bmsConfig().getParamInt("cellMonitorICCount") + numberOfCellsLabel.text = BmsInterface.bmsConfig().getParamInt("noOfCellsSeries") + + nominalCapacityLabel.text = BmsInterface.bmsConfig().getParamDouble("batteryCapacity") + actualCapacityLabel.text = nominalCapacityLabel.text + } + } + + Connections { + target: BmsInterface + onPortConnectedChanged: getValues() + } + + onVisibleChanged: getValues() + + function getValues() { + if (BmsInterface.isPortConnected() && visible) { + BmsInterface.commands().getValues() + BmsInterface.bmsConfig().updateDone() + } + } } diff --git a/qml/Screens/CellMonitorScreen.qml b/qml/Screens/CellMonitorScreen.qml index 9c36e13..59aec19 100644 --- a/qml/Screens/CellMonitorScreen.qml +++ b/qml/Screens/CellMonitorScreen.qml @@ -1,5 +1,13 @@ -import QtQuick 2.0 +import QtQuick 2.12 +import QtQuick.Layouts 1.12 + +import Controls 1.0 as Controls +import Cubo 1.0 Item { + Controls.Frame { + anchors.fill: parent + + } }