Added temperature monitor screen. Added current factors for BMS configuration
This commit is contained in:
@@ -62,6 +62,7 @@ RowLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
GridLayout {
|
||||
id: configurationLayout
|
||||
columns: 2
|
||||
rowSpacing: contentRowSpacing
|
||||
columnSpacing: contentColumnSpacing
|
||||
@@ -87,17 +88,137 @@ RowLayout {
|
||||
|
||||
Controls.TextField {
|
||||
id: numberOfBoardsField
|
||||
validator: IntValidator {}
|
||||
validator: IntValidator { bottom: 0 }
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
|
||||
|
||||
onTextChanged: configurationLayout.recalculateSensorsMasks()
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
id: numberOfCellsField
|
||||
validator: IntValidator {}
|
||||
validator: IntValidator { bottom: 0 }
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: bmsSensorsMaskRepeater
|
||||
|
||||
property var bmsSensorsMaskModel: []
|
||||
|
||||
ColumnLayout {
|
||||
id: bmsSensorsMaskLayout
|
||||
Layout.fillWidth: true
|
||||
|
||||
property var boardIndex: index
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
text: index === 0 ? qsTr("BMS sensors mask for master board") : qsTr("BMS sensors mask for slave board #") + index
|
||||
maximumLineCount: 2
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Controls.Frame {
|
||||
padding: 10
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 10
|
||||
anchors.fill: parent
|
||||
|
||||
Repeater {
|
||||
model: 4
|
||||
Controls.CheckBox {
|
||||
text: qsTr("#") + (index + 1)
|
||||
opacity: (bmsSensorsMaskLayout.boardIndex === 0 && (index === 2 || index === 3)) ? 0 : 1
|
||||
enabled: opacity
|
||||
checked: bmsSensorsMaskRepeater.bmsSensorsMaskModel[bmsSensorsMaskLayout.boardIndex * 4 + index]
|
||||
onCheckedChanged: bmsSensorsMaskRepeater.bmsSensorsMaskModel[bmsSensorsMaskLayout.boardIndex * 4 + index] = checked
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
visible: index === 0
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: batterySensorsMaskRepeater
|
||||
|
||||
property var batterySensorsMaskModel: []
|
||||
|
||||
ColumnLayout {
|
||||
id: batterySensorsMaskLayout
|
||||
Layout.fillWidth: true
|
||||
|
||||
property var boardIndex: index
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
text: index === 0 ? qsTr("Battery sensors mask for master board") : qsTr("Battery sensors mask for slave board #") + index
|
||||
maximumLineCount: 2
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Controls.Frame {
|
||||
padding: 10
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 10
|
||||
anchors.fill: parent
|
||||
|
||||
Repeater {
|
||||
model: 4
|
||||
Controls.CheckBox {
|
||||
text: qsTr("#") + (index + 1)
|
||||
enabled: opacity
|
||||
opacity: (batterySensorsMaskLayout.boardIndex === 0 && (index === 2 || index === 3)) ? 0 : 1
|
||||
checked: batterySensorsMaskRepeater.batterySensorsMaskModel[batterySensorsMaskLayout.boardIndex * 4 + index]
|
||||
onCheckedChanged: batterySensorsMaskRepeater.batterySensorsMaskModel[batterySensorsMaskLayout.boardIndex * 4 + index] = checked
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
visible: index === 0
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateSensorsMasks() {
|
||||
const bmsSensorsModel = bmsSensorsMaskRepeater.bmsSensorsMaskModel
|
||||
const batterySensorsModel = batterySensorsMaskRepeater.batterySensorsMaskModel
|
||||
|
||||
const newSize = parseInt(numberOfBoardsField.text) * 4
|
||||
if (newSize) {
|
||||
arrayResize(bmsSensorsModel, newSize, false)
|
||||
arrayResize(batterySensorsModel, newSize, true)
|
||||
|
||||
bmsSensorsMaskRepeater.model = 0
|
||||
bmsSensorsMaskRepeater.bmsSensorsMaskModel = bmsSensorsModel
|
||||
bmsSensorsMaskRepeater.model = parseInt(numberOfBoardsField.text)
|
||||
|
||||
batterySensorsMaskRepeater.model = 0
|
||||
batterySensorsMaskRepeater.batterySensorsMaskModel = batterySensorsModel
|
||||
batterySensorsMaskRepeater.model = parseInt(numberOfBoardsField.text)
|
||||
}
|
||||
}
|
||||
|
||||
function arrayResize(array, size, value) {
|
||||
while (array.length > size) { array.pop(); }
|
||||
while (array.length < size) { array.push(value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,6 +484,82 @@ RowLayout {
|
||||
}
|
||||
}
|
||||
|
||||
Controls.Frame {
|
||||
id: currentConfigurationFrame
|
||||
padding: contentPadding
|
||||
implicitWidth: parent.width
|
||||
Layout.fillWidth: true
|
||||
|
||||
GridLayout {
|
||||
columns: 2
|
||||
rowSpacing: contentRowSpacing
|
||||
columnSpacing: contentColumnSpacing
|
||||
anchors.fill: parent
|
||||
|
||||
Controls.TitleLabel {
|
||||
text: qsTr("Current configuration")
|
||||
Layout.fillWidth: true
|
||||
Layout.columnSpan: 2
|
||||
}
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
text: qsTr("Current factor K1")
|
||||
maximumLineCount: 2
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
|
||||
}
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
text: qsTr("Current factor K2")
|
||||
maximumLineCount: 2
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
id: currentFactorK1Field
|
||||
validator: DoubleValidator { decimals: 3; locale: "en-US"; notation: DoubleValidator.StandardNotation }
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
id: currentFactorK2Field
|
||||
validator: DoubleValidator { decimals: 3; locale: "en-US"; notation: DoubleValidator.StandardNotation }
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
|
||||
}
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
text: qsTr("Current sensor value \"0\"")
|
||||
Layout.fillWidth: true
|
||||
Layout.columnSpan: 2
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
id: zeroSensorValueField
|
||||
validator: DoubleValidator { decimals: 3; locale: "en-US"; notation: DoubleValidator.StandardNotation }
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
|
||||
Layout.columnSpan: 2
|
||||
}
|
||||
|
||||
Controls.Button {
|
||||
id: zeroSensorValueCalibrationButton
|
||||
text: qsTr("Calibrate \"0\"")
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
|
||||
Layout.columnSpan: 2
|
||||
onClicked: {
|
||||
BmsInterface.commands().sendTerminalCmd("setZeroCurrent")
|
||||
Qt.callLater(storeBmsConfigurationButton.clicked)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Controls.Frame {
|
||||
id: outputSettingsFrame
|
||||
padding: contentPadding
|
||||
@@ -581,43 +778,6 @@ RowLayout {
|
||||
}
|
||||
}
|
||||
|
||||
Controls.Frame {
|
||||
id: zeroSensorSettingsFrame
|
||||
padding: contentPadding
|
||||
implicitWidth: parent.width
|
||||
Layout.fillWidth: true
|
||||
|
||||
GridLayout {
|
||||
columns: 2
|
||||
rowSpacing: contentRowSpacing
|
||||
columnSpacing: contentColumnSpacing
|
||||
anchors.fill: parent
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
text: qsTr("Current sensor value \"0\"")
|
||||
Layout.fillWidth: true
|
||||
Layout.columnSpan: 2
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
id: zeroSensorValueField
|
||||
validator: DoubleValidator { decimals: 2; locale: "en-US"; notation: DoubleValidator.StandardNotation }
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
|
||||
Layout.columnSpan: 2
|
||||
}
|
||||
|
||||
Controls.Button {
|
||||
id: zeroSensorValueCalibrationButton
|
||||
text: qsTr("Calibrate \"0\"")
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2
|
||||
Layout.columnSpan: 2
|
||||
onClicked: BmsInterface.commands().sendTerminalCmd("setZeroCurrent")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Controls.OutlineButton {
|
||||
text: qsTr("Load settings from file")
|
||||
onClicked: loadFileDialog.open()
|
||||
@@ -710,14 +870,14 @@ RowLayout {
|
||||
}
|
||||
|
||||
Controls.LinkLabel {
|
||||
text: qsTr("Output settings")
|
||||
onClicked: settingsFlickable.contentY = outputSettingsFrame.mapToItem(settingsFlickable.contentItem, 0, 0).y
|
||||
text: qsTr("Current configuration")
|
||||
onClicked: settingsFlickable.contentY = currentConfigurationFrame.mapToItem(settingsFlickable.contentItem, 0, 0).y
|
||||
}
|
||||
|
||||
Controls.LinkLabel {
|
||||
text: qsTr("Current sensor value \"0\"")
|
||||
text: qsTr("Output settings")
|
||||
onClicked: {
|
||||
settingsFlickable.contentY = zeroSensorSettingsFrame.mapToItem(settingsFlickable.contentItem, 0, 0).y
|
||||
settingsFlickable.contentY = outputSettingsFrame.mapToItem(settingsFlickable.contentItem, 0, 0).y
|
||||
settingsFlickable.returnToBounds()
|
||||
}
|
||||
}
|
||||
@@ -746,6 +906,7 @@ RowLayout {
|
||||
}
|
||||
|
||||
Controls.OutlineButton {
|
||||
id: writeBmsConfigurationButton
|
||||
text: qsTr("Write current values to BMS")
|
||||
Layout.fillWidth: true
|
||||
onClicked: if (BmsInterface.isPortConnected()) {
|
||||
@@ -755,6 +916,7 @@ RowLayout {
|
||||
}
|
||||
|
||||
Controls.Button {
|
||||
id: storeBmsConfigurationButton
|
||||
text: qsTr("Write to non-volatile memory of BMS")
|
||||
Layout.fillWidth: true
|
||||
onClicked: if (BmsInterface.isPortConnected()) {
|
||||
@@ -777,6 +939,29 @@ RowLayout {
|
||||
BmsInterface.bmsConfig().setParamValue("cellMonitorICCount", parseInt(numberOfBoardsField.text))
|
||||
BmsInterface.bmsConfig().setParamValue("noOfCellsSeries", parseInt(numberOfCellsField.text))
|
||||
|
||||
const numberOfBoards = parseInt(numberOfBoardsField.text)
|
||||
const bmsSensorsModel = bmsSensorsMaskRepeater.bmsSensorsMaskModel
|
||||
const batterySensorsModel = batterySensorsMaskRepeater.batterySensorsMaskModel
|
||||
|
||||
let bmsSensorsMask = 0
|
||||
let batterySensorsMask = 0
|
||||
for (let i = 0; i < numberOfBoards * 4; ++i) {
|
||||
bmsSensorsMask |= Number(bmsSensorsModel[i]) << i
|
||||
batterySensorsMask |= Number(batterySensorsModel[i]) << i
|
||||
}
|
||||
|
||||
// disable 3 and 4 sensor for master
|
||||
bmsSensorsMask = bmsSensorsMask & ~(1 << 2)
|
||||
bmsSensorsMask = bmsSensorsMask & ~(1 << 3)
|
||||
|
||||
batterySensorsMask = batterySensorsMask & ~(1 << 2)
|
||||
batterySensorsMask = batterySensorsMask & ~(1 << 3)
|
||||
|
||||
print(bmsSensorsMask, batterySensorsMask)
|
||||
|
||||
BmsInterface.bmsConfig().setParamValue("tempEnableMaskBMS", bmsSensorsMask)
|
||||
BmsInterface.bmsConfig().setParamValue("tempEnableMaskBattery", batterySensorsMask)
|
||||
|
||||
BmsInterface.bmsConfig().setParamValue("noOfCellsParallel", parseInt(numberOfParallelCellsField.text))
|
||||
BmsInterface.bmsConfig().setParamValue("batteryCapacity", parseFloat(batteryCapacityField.text))
|
||||
|
||||
@@ -793,6 +978,8 @@ RowLayout {
|
||||
BmsInterface.bmsConfig().setParamValue("cellBalanceDifferenceThreshold", parseFloat(balancingStartDeltaVoltageField.text))
|
||||
BmsInterface.bmsConfig().setParamValue("cellBalanceUpdateInterval", parseInt(balancingCellIntervalField.text))
|
||||
|
||||
BmsInterface.bmsConfig().setParamValue("floatCurrentK1", parseFloat(currentFactorK1Field.text))
|
||||
BmsInterface.bmsConfig().setParamValue("floatCurrentK2", parseFloat(currentFactorK2Field.text))
|
||||
BmsInterface.bmsConfig().setParamValue("shuntLCFactor", parseFloat(zeroSensorValueField.text))
|
||||
|
||||
BmsInterface.bmsConfig().setParamValue("chargeBatteryOutputChecked", chargeBatteryOutputCheckBox.checked)
|
||||
@@ -819,6 +1006,21 @@ RowLayout {
|
||||
numberOfBoardsField.text = BmsInterface.bmsConfig().getParamInt("cellMonitorICCount")
|
||||
numberOfCellsField.text = BmsInterface.bmsConfig().getParamInt("noOfCellsSeries")
|
||||
|
||||
const numberOfBoards = BmsInterface.bmsConfig().getParamInt("cellMonitorICCount")
|
||||
const numberOfSensorsPerBoard = BmsInterface.bmsConfig().getParamInt("noOfTempSensorPerModule")
|
||||
const bmsSensorsMask = BmsInterface.bmsConfig().getParamInt("tempEnableMaskBMS")
|
||||
const batterySensorsMask = BmsInterface.bmsConfig().getParamInt("tempEnableMaskBattery")
|
||||
|
||||
const bmsSensorsModel = []
|
||||
const batterySensorsModel = []
|
||||
for (let i = 0; i < numberOfBoards * numberOfSensorsPerBoard; ++i) {
|
||||
bmsSensorsModel.push((bmsSensorsMask & (1 << i)) != 0)
|
||||
batterySensorsModel.push((batterySensorsMask & (1 << i)) != 0)
|
||||
}
|
||||
|
||||
bmsSensorsMaskRepeater.bmsSensorsMaskModel = bmsSensorsModel
|
||||
batterySensorsMaskRepeater.batterySensorsMaskModel = batterySensorsModel
|
||||
|
||||
numberOfParallelCellsField.text = BmsInterface.bmsConfig().getParamInt("noOfCellsParallel")
|
||||
batteryCapacityField.text = MathHelper.roundDouble(BmsInterface.bmsConfig().getParamDouble("batteryCapacity"))
|
||||
|
||||
@@ -835,7 +1037,9 @@ RowLayout {
|
||||
balancingStartDeltaVoltageField.text = MathHelper.roundDouble(BmsInterface.bmsConfig().getParamDouble("cellBalanceDifferenceThreshold"))
|
||||
balancingCellIntervalField.text = BmsInterface.bmsConfig().getParamInt("cellBalanceUpdateInterval")
|
||||
|
||||
zeroSensorValueField.text = MathHelper.roundDouble(BmsInterface.bmsConfig().getParamDouble("shuntLCFactor"))
|
||||
currentFactorK1Field.text = MathHelper.roundDouble(BmsInterface.bmsConfig().getParamDouble("floatCurrentK1"), 3)
|
||||
currentFactorK2Field.text = MathHelper.roundDouble(BmsInterface.bmsConfig().getParamDouble("floatCurrentK2"), 3)
|
||||
zeroSensorValueField.text = MathHelper.roundDouble(BmsInterface.bmsConfig().getParamDouble("shuntLCFactor"), 3)
|
||||
|
||||
chargeBatteryOutputCheckBox.checked = BmsInterface.bmsConfig().getParamBool("chargeBatteryOutputChecked")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user