229 lines
6.5 KiB
QML

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 2.15
import QtCharts 2.15
ApplicationWindow {
visible: true
width: 600
height: 500
title: "Load Controller"
property QtObject profile_handler
property string profile: "None"
property real profileTime: 0
property real current: 0
property real currentActual: 0
property real currentIntegrated: 0
property string time: "00:00 / 00:00"
property real voltage_min: 0
property real voltage_max: 0
property real temp_min: 0
property real temp_max: 0
property string bmsError: ""
property bool bmsErrorVisible: false
Connections {
target: profile_handler
function onCurrentChanged(new_current) {
current = new_current;
}
function onProfileChanged(data) {
profile_handler.fill_series(profileSeries);
var x_max = data[data.length - 1][0];
axisX.max = x_max;
axisX.applyNiceNumbers();
profileView.zoomReset();
}
}
onProfileTimeChanged: {
var old_x = profileView.mapToPosition(currentTimeSeries.at(0)).x;
currentTimeSeries.clear()
currentTimeSeries.append(profileTime, 0)
currentTimeSeries.append(profileTime, 100)
var new_x = profileView.mapToPosition(currentTimeSeries.at(0)).x;
if (new_x > profileView.plotArea.width / 2) {
profileView.scrollRight(new_x - old_x);
}
}
onBmsErrorChanged: {
bmsErrorVisible = bmsError != "";
}
RowLayout {
id: layout
anchors.fill: parent
spacing: 6
ColumnLayout {
RowLayout {
Text {
text: "Profile:"
}
Text {
text: profile
}
Button {
objectName: "profile_chooser"
text: "Choose"
}
}
ChartView {
id: profileView
Layout.fillWidth: true
Layout.fillHeight: true
Layout.minimumWidth: 400
Layout.minimumHeight: 400
antialiasing: true
legend.visible: false
ValueAxis {
id: axisX
min: 0
titleText: "Time [s]"
}
ValueAxis {
id: axisY
min: 0
max: 100
tickCount: 11
titleText: "Current [A]"
}
LineSeries {
id: profileSeries
axisX: axisX
axisY: axisY
}
LineSeries {
id: currentTimeSeries
axisX: axisX
axisY: axisY
XYPoint {x: 0; y: 0}
XYPoint {x: 0; y: 100}
visible: true
}
}
RowLayout {
Button {
text: "+"
onClicked: {
var r = Qt.rect(profileView.plotArea.x, profileView.plotArea.y, profileView.plotArea.width / 2, profileView.plotArea.height);
profileView.zoomIn(r);
}
}
Button {
text: "-"
onClicked: {
var r = Qt.rect(profileView.plotArea.x, profileView.plotArea.y, profileView.plotArea.width * 2, profileView.plotArea.height);
profileView.zoomIn(r);
}
}
Button {
text: "Reset zoom"
onClicked: {
profileView.zoomReset();
}
}
}
RowLayout {
Button {
objectName: "start_pause"
text: "START"
enabled: false
}
Button {
objectName: "stop"
text: "STOP"
enabled: false
}
}
}
GridLayout {
Text {
text: "Current (target) [A]:"
Layout.row: 0
Layout.column: 0
}
Text {
text: current.toFixed(1)
Layout.row: 0
Layout.column: 1
}
Text {
text: "Current (actual) [A]:"
Layout.row: 1
Layout.column: 0
}
Text {
text: currentActual.toFixed(1)
Layout.row: 1
Layout.column: 1
}
Text {
text: "Time [min]:"
Layout.row: 2
Layout.column: 0
}
Text {
text: time
Layout.row: 2
Layout.column: 1
}
Text {
text: "Voltage [V]:"
Layout.row: 3
Layout.column: 0
}
Text {
text: "[" + voltage_min.toFixed(2) + ", " + voltage_max.toFixed(2) + "]"
Layout.row: 3
Layout.column: 1
}
Text {
text: "Temperature [°C]:"
Layout.row: 4
Layout.column: 0
}
Text {
text: "[" + temp_min.toFixed(1) + ", " + temp_max.toFixed(1) + "]"
Layout.row: 4
Layout.column: 1
}
Text {
text: "Coulomb counter [Ah]:"
Layout.row: 5
Layout.column: 0
}
Text {
text: currentIntegrated.toFixed(1)
Layout.row: 5
Layout.column: 1
}
Text {
text: "BMS Error:"
Layout.row: 6
Layout.column: 0
visible: bmsErrorVisible
color: "red"
font.bold: true
}
Text {
text: bmsError
Layout.row: 6
Layout.column: 1
visible: bmsErrorVisible
color: "red"
font.bold: true
}
}
}
minimumWidth: layout.Layout.minimumWidth
minimumHeight: layout.Layout.minimumHeight
}