import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 import Controls 1.0 as Controls import Cubo 1.0 import Utils 1.0 Item { id: root property var numberOfBoards: 0 property var auxSensorsModel: [] property var expSensorsModel: [] ColumnLayout { spacing: 15 anchors.fill: parent Controls.Frame { padding: 25 implicitWidth: parent.width Layout.fillWidth: true Layout.rightMargin: 10 GridLayout { columns: 1 // 2 columnSpacing: 70 rowSpacing: 15 anchors.fill: parent RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Minimum battery temperature, °C") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: minBatteryTemperatureLabel text: "-" } Layout.fillWidth: true // Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } // RowLayout { // spacing: 10 // Controls.ContentLabel { // text: qsTr("Minimum BMS temperature, °C") // } // Controls.DotSeparator { // Layout.fillWidth: true // } // Controls.SubtitleLabel { // id: minBmsTemperatureLabel // text: "-" // } // Layout.fillWidth: true // Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 // } RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Average battery temperature, °C") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: avgBatteryTemperatureLabel text: "-" } Layout.fillWidth: true // Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } // RowLayout { // spacing: 10 // Controls.ContentLabel { // text: qsTr("Average BMS temperature, °C") // } // Controls.DotSeparator { // Layout.fillWidth: true // } // Controls.SubtitleLabel { // id: avgBmsTemperatureLabel // text: "-" // } // Layout.fillWidth: true // Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 // } RowLayout { spacing: 10 Controls.ContentLabel { text: qsTr("Maximum battery temperature, °C") } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { id: maxBatteryTemperatureLabel text: "-" } Layout.fillWidth: true // Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } // RowLayout { // spacing: 10 // Controls.ContentLabel { // text: qsTr("Maximum BMS temperature, °C") // } // Controls.DotSeparator { // Layout.fillWidth: true // } // Controls.SubtitleLabel { // id: maxBmsTemperatureLabel // text: "-" // } // Layout.fillWidth: true // Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 // } } } Flickable { id: settingsFlickable clip: true contentWidth: width - rightMargin - leftMargin contentHeight: boardsLayout.height boundsBehavior: Flickable.StopAtBounds rightMargin: 10 GridLayout { id: boardsLayout width: parent.width columns: 2 rowSpacing: 15 columnSpacing: 15 Repeater { model: numberOfBoards Controls.Frame { padding: 25 Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 ColumnLayout { id: sensorsLayout anchors.fill: parent spacing: 15 property var boardIndex: index Controls.SubtitleLabel { text: index === 0 ? qsTr("Sensors for master board") : qsTr("Sensors for slave board #") + index maximumLineCount: 2 wrapMode: Text.WordWrap Layout.fillWidth: true } Repeater { model: 4 RowLayout { spacing: 10 opacity: (sensorsLayout.boardIndex === 0 && (index === 2 || index === 3)) ? 0 : 1 Controls.ContentLabel { text: qsTr("Sensor #") + (index + 1) + ", °C" } Controls.DotSeparator { Layout.fillWidth: true } Controls.SubtitleLabel { text: { var value = auxSensorsModel[sensorsLayout.boardIndex * 4 + index] return value ? value : 0 } } Layout.fillWidth: true Layout.maximumWidth: (parent.width - parent.columnSpacing) / 2 } } } } } } ScrollBar.vertical: Controls.ScrollBar {} Layout.fillWidth: true Layout.fillHeight: true } } Connections { target: BmsInterface.commands() enabled: root.visible onValuesReceived: { maxBatteryTemperatureLabel.text = MathHelper.roundDouble(values.tempBattHigh) avgBatteryTemperatureLabel.text = MathHelper.roundDouble(values.tempBattAverage) minBatteryTemperatureLabel.text = MathHelper.roundDouble(values.tempBattLow) // maxBmsTemperatureLabel.text = MathHelper.roundDouble(values.tempBMSHigh) // avgBmsTemperatureLabel.text = MathHelper.roundDouble(values.tempBMSAverage) // minBmsTemperatureLabel.text = MathHelper.roundDouble(values.tempBMSLow) } onAuxReceived: { let tempModel = [] for (let temperature of auxVoltageArray) { tempModel.push(temperature) } auxSensorsModel = [] auxSensorsModel = tempModel } onExpTempReceived: { let tempModel = [] for (let temperature of expTempVoltageArray) { tempModel.push(temperature) } expSensorsModel = [] expSensorsModel = tempModel } } Connections { target: BmsInterface.bmsConfig() onUpdated: { numberOfBoards = BmsInterface.bmsConfig().getParamInt("cellMonitorICCount") } } Connections { target: BmsInterface onPortConnectedChanged: getValues() } onVisibleChanged: getValues() Timer { id: refreshValuesTimer interval: 1000 onTriggered: getValues() } function getValues() { if (BmsInterface.isPortConnected() && visible) { BmsInterface.commands().getValues() BmsInterface.commands().getAux() // BmsInterface.commands().getExpansionTemp() refreshValuesTimer.start() } } }