Implemented AKB monitor screen

This commit is contained in:
Yury Shuvakin
2022-08-17 01:09:17 +03:00
parent dce22c65d6
commit a4196df821
9 changed files with 274 additions and 10 deletions

View File

@@ -429,7 +429,7 @@ bool BMSInterface::connectSerial(QString port, int baudrate)
bool found = false; bool found = false;
for (VSerialInfo_t ser: listSerialPorts()) { for (VSerialInfo_t ser: listSerialPorts()) {
if (ser.systemPath == port) { if (ser.name == port) {
found = true; found = true;
break; break;
} }
@@ -522,7 +522,7 @@ QStringList BMSInterface::serialPortNames()
QStringList names; QStringList names;
for (const auto& info: listSerialPorts()) for (const auto& info: listSerialPorts())
{ {
names.append(info.systemPath); names.append(info.name);
} }
return names; return names;
} }

View File

@@ -101,10 +101,10 @@ public:
bool loadXml(QString fileName, QString configName); bool loadXml(QString fileName, QString configName);
QString xmlStatus(); QString xmlStatus();
void getParamsXML(QXmlStreamWriter &stream); Q_INVOKABLE void getParamsXML(QXmlStreamWriter &stream);
bool setParamsXML(QXmlStreamReader &stream); Q_INVOKABLE bool setParamsXML(QXmlStreamReader &stream);
bool saveParamsXml(QString fileName); Q_INVOKABLE bool saveParamsXml(QString fileName);
bool loadParamsXml(QString fileName); Q_INVOKABLE bool loadParamsXml(QString fileName);
bool saveCDefines(const QString &fileName, bool wrapIfdef = false); bool saveCDefines(const QString &fileName, bool wrapIfdef = false);

View File

@@ -7,4 +7,5 @@ Label {
color: Palette.contentTextColor color: Palette.contentTextColor
font.pixelSize: 18 font.pixelSize: 18
font.weight: Font.Medium font.weight: Font.Medium
elide: Text.ElideRight
} }

View File

@@ -4,7 +4,8 @@ import QtQuick.Controls 2.12
import Utils 1.0 import Utils 1.0
Label { Label {
color: Palette.contentTextColor color: Palette.textColor
font.pixelSize: 18 font.pixelSize: 18
font.weight: Font.ExtraBold font.weight: Font.ExtraBold
elide: Text.ElideRight
} }

View File

@@ -1,6 +1,18 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import Utils 1.0
TextField { TextField {
implicitHeight: 58
color: Palette.textColor
selectByMouse: true selectByMouse: true
selectionColor: Palette.alternativeBackgroundColor
background: Rectangle {
color: Palette.backgroundColor
border.color: Palette.borderColor
border.width: 1
radius: 8
}
} }

View File

@@ -7,4 +7,5 @@ Label {
color: Palette.selectedTextColor color: Palette.selectedTextColor
font.pixelSize: 28 font.pixelSize: 28
font.weight: Font.ExtraBold font.weight: Font.ExtraBold
elide: Text.ElideRight
} }

View File

@@ -4,6 +4,7 @@ import QtQuick.Layouts 1.12
import Controls 1.0 as Controls import Controls 1.0 as Controls
import Screens 1.0 as Screens import Screens 1.0 as Screens
import Cubo 1.0
import Utils 1.0 import Utils 1.0
ApplicationWindow { ApplicationWindow {
@@ -216,5 +217,10 @@ ApplicationWindow {
color: Palette.screenBackgroundColor color: Palette.screenBackgroundColor
} }
Component.onCompleted: connectionScreen.open() Component.onCompleted: {
BmsInterface.bmsConfig().loadParamsXml("://res/config.xml")
BmsInterface.infoConfig().loadParamsXml("://res/info.xml")
connectionScreen.open()
}
} }

View File

@@ -2,39 +2,54 @@ import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import Controls 1.0 as Controls import Controls 1.0 as Controls
import Cubo 1.0
Item { Item {
ColumnLayout { ColumnLayout {
spacing: 15
anchors.fill: parent anchors.fill: parent
Controls.Frame { Controls.Frame {
padding: 35
implicitWidth: parent.width
Layout.fillWidth: true Layout.fillWidth: true
RowLayout { RowLayout {
spacing: 90
anchors.fill: parent anchors.fill: parent
Controls.TitleLabel { Controls.TitleLabel {
text: qsTr("Serial number") text: qsTr("Serial number")
Layout.fillWidth: true Layout.fillWidth: true
Layout.maximumWidth: (parent.width - parent.spacing) / 2
} }
Controls.TextField { Controls.TextField {
text: "AABBCCDD" id: serialField
enabled: false
Layout.fillWidth: true Layout.fillWidth: true
Layout.maximumWidth: (parent.width - parent.spacing) / 2
} }
} }
} }
Controls.Frame { Controls.Frame {
padding: 35
implicitWidth: parent.width
Layout.fillWidth: true Layout.fillWidth: true
GridLayout { GridLayout {
columns: 2 columns: 2
columnSpacing: 90
rowSpacing: 20
anchors.fill: parent anchors.fill: parent
RowLayout { RowLayout {
spacing: 10
Controls.ContentLabel { Controls.ContentLabel {
text: qsTr("Battery charge level, V") text: qsTr("Battery charge level, V")
Layout.fillWidth: true
Layout.maximumWidth: implicitWidth
} }
Controls.DotSeparator { Controls.DotSeparator {
@@ -42,15 +57,20 @@ Item {
} }
Controls.SubtitleLabel { Controls.SubtitleLabel {
id: batteryChargeLevelLabel
text: "-" text: "-"
} }
Layout.fillWidth: true Layout.fillWidth: true
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
} }
RowLayout { RowLayout {
spacing: 10
Controls.ContentLabel { Controls.ContentLabel {
text: qsTr("Number of modules") text: qsTr("Number of modules")
Layout.fillWidth: true
Layout.maximumWidth: implicitWidth
} }
Controls.DotSeparator { Controls.DotSeparator {
@@ -58,15 +78,20 @@ Item {
} }
Controls.SubtitleLabel { Controls.SubtitleLabel {
id: numberOfModulesLabel
text: "-" text: "-"
} }
Layout.fillWidth: true Layout.fillWidth: true
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
} }
RowLayout { RowLayout {
spacing: 10
Controls.ContentLabel { Controls.ContentLabel {
text: qsTr("Battery voltage, V") text: qsTr("Battery voltage, V")
Layout.fillWidth: true
Layout.maximumWidth: implicitWidth
} }
Controls.DotSeparator { Controls.DotSeparator {
@@ -74,15 +99,20 @@ Item {
} }
Controls.SubtitleLabel { Controls.SubtitleLabel {
id: batteryVoltageLabel
text: "-" text: "-"
} }
Layout.fillWidth: true Layout.fillWidth: true
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
} }
RowLayout { RowLayout {
spacing: 10
Controls.ContentLabel { Controls.ContentLabel {
text: qsTr("Number of cells") text: qsTr("Number of cells")
Layout.fillWidth: true
Layout.maximumWidth: implicitWidth
} }
Controls.DotSeparator { Controls.DotSeparator {
@@ -90,10 +120,172 @@ Item {
} }
Controls.SubtitleLabel { Controls.SubtitleLabel {
id: numberOfCellsLabel
text: "-" text: "-"
} }
Layout.fillWidth: true 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 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()
}
}
} }

View File

@@ -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 { Item {
Controls.Frame {
anchors.fill: parent
}
} }