182 lines
4.8 KiB
QML
182 lines
4.8 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 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) {
|
|
profileSeries.clear();
|
|
var last_x = 0;
|
|
for (var point of data) {
|
|
profileSeries.append(point[0], point[1]);
|
|
last_x = point[0];
|
|
}
|
|
axisX.max = last_x;
|
|
axisX.applyNiceNumbers();
|
|
}
|
|
}
|
|
|
|
onProfileTimeChanged: {
|
|
currentTimeSeries.clear()
|
|
currentTimeSeries.append(profileTime, 0)
|
|
currentTimeSeries.append(profileTime, 100)
|
|
}
|
|
|
|
onBmsErrorChanged: {
|
|
console.log(bmsError);
|
|
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 {
|
|
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 {
|
|
objectName: "start_pause"
|
|
text: "START"
|
|
enabled: false
|
|
}
|
|
Button {
|
|
objectName: "stop"
|
|
text: "STOP"
|
|
enabled: false
|
|
}
|
|
}
|
|
}
|
|
GridLayout {
|
|
Text {
|
|
text: "Current [A]:"
|
|
Layout.row: 0
|
|
Layout.column: 0
|
|
}
|
|
Text {
|
|
text: current.toFixed(1)
|
|
Layout.row: 0
|
|
Layout.column: 1
|
|
}
|
|
Text {
|
|
text: "Time [min]:"
|
|
Layout.row: 1
|
|
Layout.column: 0
|
|
}
|
|
Text {
|
|
text: time
|
|
Layout.row: 1
|
|
Layout.column: 1
|
|
}
|
|
Text {
|
|
text: "Voltage [V]:"
|
|
Layout.row: 2
|
|
Layout.column: 0
|
|
}
|
|
Text {
|
|
text: "[" + voltage_min.toFixed(2) + ", " + voltage_max.toFixed(2) + "]"
|
|
Layout.row: 2
|
|
Layout.column: 1
|
|
}
|
|
Text {
|
|
text: "Temperature [°C]:"
|
|
Layout.row: 3
|
|
Layout.column: 0
|
|
}
|
|
Text {
|
|
text: "[" + temp_min.toFixed(1) + ", " + temp_max.toFixed(1) + "]"
|
|
Layout.row: 3
|
|
Layout.column: 1
|
|
}
|
|
Text {
|
|
text: "BMS Error:"
|
|
Layout.row: 4
|
|
Layout.column: 0
|
|
visible: bmsErrorVisible
|
|
color: "red"
|
|
font.bold: true
|
|
}
|
|
Text {
|
|
text: bmsError
|
|
Layout.row: 4
|
|
Layout.column: 1
|
|
visible: bmsErrorVisible
|
|
color: "red"
|
|
font.bold: true
|
|
}
|
|
}
|
|
}
|
|
|
|
minimumWidth: layout.Layout.minimumWidth
|
|
minimumHeight: layout.Layout.minimumHeight
|
|
}
|