From 8abae06275ecb0d77ac92c764b71650a9c069edc Mon Sep 17 00:00:00 2001 From: Yury Shuvakin Date: Tue, 23 Aug 2022 01:33:17 +0300 Subject: [PATCH] Added validators for various configuration settings. Implemented reading the configuration and loading the default configuration --- qml/Screens/AkbMonitorScreen.qml | 2 +- qml/Screens/BmsSettingsScreen.qml | 54 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/qml/Screens/AkbMonitorScreen.qml b/qml/Screens/AkbMonitorScreen.qml index f9b74f9..39b0810 100644 --- a/qml/Screens/AkbMonitorScreen.qml +++ b/qml/Screens/AkbMonitorScreen.qml @@ -334,7 +334,7 @@ Item { function getValues() { if (BmsInterface.isPortConnected() && visible) { BmsInterface.commands().getValues() - BmsInterface.bmsConfig().updateDone() + BmsInterface.commands().getBMSconf() } } } diff --git a/qml/Screens/BmsSettingsScreen.qml b/qml/Screens/BmsSettingsScreen.qml index 0c057d0..c0969a3 100644 --- a/qml/Screens/BmsSettingsScreen.qml +++ b/qml/Screens/BmsSettingsScreen.qml @@ -78,12 +78,14 @@ RowLayout { Controls.TextField { id: numberOfBoardsField + validator: IntValidator {} Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } Controls.TextField { id: numberOfCellsField + validator: IntValidator {} Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } @@ -124,12 +126,14 @@ RowLayout { Controls.TextField { id: numberOfParallelCellsField + validator: IntValidator {} Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } Controls.TextField { id: batteryCapacityField + validator: DoubleValidator {} Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } @@ -168,12 +172,14 @@ RowLayout { Controls.TextField { id: maximumChargeCurrentField + validator: DoubleValidator {} Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } Controls.TextField { id: maximumLoadCurrentField + validator: DoubleValidator {} Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } @@ -187,6 +193,7 @@ RowLayout { Controls.TextField { id: maximumTemperatureField + validator: DoubleValidator {} Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 Layout.columnSpan: 2 @@ -226,12 +233,14 @@ RowLayout { Controls.TextField { id: lowerShutdownThresholdField + validator: DoubleValidator {} Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } Controls.TextField { id: upperShutdownThresholdField + validator: DoubleValidator {} Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } @@ -299,12 +308,14 @@ RowLayout { Controls.TextField { id: balancingStartVoltageField + validator: DoubleValidator {} Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } Controls.TextField { id: balancingStartDeltaVoltageField + validator: DoubleValidator {} Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } @@ -509,6 +520,7 @@ RowLayout { Controls.TextField { id: zeroSensorValueField + validator: DoubleValidator {} Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 Layout.columnSpan: 2 @@ -586,11 +598,13 @@ RowLayout { Controls.OutlineButton { text: qsTr("Read settings from file") Layout.fillWidth: true + onClicked: BmsInterface.commands().getBMSconfDefault() } Controls.OutlineButton { text: qsTr("Read current settings from BMS") Layout.fillWidth: true + onClicked: BmsInterface.commands().getBMSconf() } Controls.OutlineButton { @@ -609,4 +623,44 @@ RowLayout { Layout.maximumWidth: 320 Layout.fillHeight: true } + + Connections { + target: BmsInterface.bmsConfig() + onUpdated: { + serialNumberField.text = BmsInterface.bmsConfig().getParamDouble("notUsedCurrentThreshold") + + numberOfBoardsField.text = BmsInterface.bmsConfig().getParamInt("cellMonitorICCount") + numberOfCellsField.text = BmsInterface.bmsConfig().getParamInt("noOfCellsSeries") + + numberOfParallelCellsField.text = BmsInterface.bmsConfig().getParamInt("noOfCellsParallel") + batteryCapacityField.text = BmsInterface.bmsConfig().getParamDouble("batteryCapacity") + + maximumChargeCurrentField.text = BmsInterface.bmsConfig().getParamDouble("maxAllowedCurrent") + maximumLoadCurrentField.text = BmsInterface.bmsConfig().getParamDouble("maxMismatchThreshold") + maximumTemperatureField.text = BmsInterface.bmsConfig().getParamDouble("allowedTempBattChargingMax") + + // TODO + lowerShutdownThresholdField.text = BmsInterface.bmsConfig().getParamDouble("cellHardUnderVoltage") + upperShutdownThresholdField.text = BmsInterface.bmsConfig().getParamDouble("cellHardOverVoltage") + + // TODO + balancingStartVoltageField.text = BmsInterface.bmsConfig().getParamDouble("cellBalanceStart") + balancingStartDeltaVoltageField.text = BmsInterface.bmsConfig().getParamDouble("cellBalanceDifferenceThreshold") + + zeroSensorValueField.text = BmsInterface.bmsConfig().getParamDouble("shuntLCFactor") + } + } + + Connections { + target: BmsInterface + onPortConnectedChanged: getValues() + } + + onVisibleChanged: getValues() + + function getValues() { + if (BmsInterface.isPortConnected() && visible) { + BmsInterface.bmsConfig().updateDone() + } + } }