Various changes have been made as a result of the discussion of the first version
This commit is contained in:
@@ -8,9 +8,10 @@ import Cubo 1.0
|
||||
import Utils 1.0
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
spacing: 20
|
||||
|
||||
property int currentTime: 0
|
||||
property real currentTime: 0
|
||||
|
||||
property var voltageData: []
|
||||
property var currentData: []
|
||||
@@ -86,6 +87,7 @@ ColumnLayout {
|
||||
property Controls.ChartView chartItem: undefined
|
||||
property color seriesColor: "black"
|
||||
property bool horizontal: true
|
||||
property bool selected: false
|
||||
|
||||
Controls.CheckBox {
|
||||
id: checkSeries
|
||||
@@ -114,9 +116,17 @@ ColumnLayout {
|
||||
Rectangle {
|
||||
color: seriesColor
|
||||
radius: width / 2
|
||||
Layout.preferredWidth: 18
|
||||
Layout.preferredHeight: 18
|
||||
border.width: selected ? 2 : 0
|
||||
border.color: "black"
|
||||
Layout.preferredWidth: selected ? 21 : 18
|
||||
Layout.preferredHeight: selected ? 21 : 18
|
||||
Layout.rightMargin: 20
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: if (!selected) selected = true
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
@@ -124,6 +134,10 @@ ColumnLayout {
|
||||
horizontal = !ListView.view
|
||||
seriesColor = chartItem.series(modelData).color
|
||||
checkSeries.text = Qt.binding(function(){ return chartItem.series(modelData).name })
|
||||
|
||||
selectedChanged.connect(function (){ if (selected) chartItem.selectedSeriesIndex = index })
|
||||
chartItem.selectedSeriesIndexChanged.connect(function (){ if (typeof(selected) != "undefined") selected = chartItem.selectedSeriesIndex === index })
|
||||
selected = chartItem.selectedSeriesIndex === index
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -289,44 +303,6 @@ ColumnLayout {
|
||||
RowLayout {
|
||||
spacing: 20
|
||||
|
||||
Controls.Button {
|
||||
text: timer.running ? qsTr("Pause data collection") : qsTr("Resume data collection")
|
||||
onClicked: {
|
||||
if (timer.running)
|
||||
timer.stop()
|
||||
else
|
||||
timer.start()
|
||||
}
|
||||
}
|
||||
|
||||
Controls.Button {
|
||||
text: qsTr("Clear data")
|
||||
onClicked: {
|
||||
currentTime = 0
|
||||
|
||||
clearData(voltageData, voltageLoader)
|
||||
clearData(currentData, currentLoader)
|
||||
clearData(batteryTemperatureData, batteryTemperatureLoader)
|
||||
clearData(bmsTemperatureData, bmsTemperatureLoader)
|
||||
clearData(cellVoltageData, cellVoltageLoader)
|
||||
clearData(cellListData, cellListLoader)
|
||||
|
||||
resetZoomButton.clicked()
|
||||
}
|
||||
|
||||
function clearData(dataObject, chartObject) {
|
||||
for (var i = 0; i < dataObject.length; ++i) {
|
||||
dataObject[i].splice(0, dataObject[i].length)
|
||||
var series = chartObject.item.chart.series(i)
|
||||
series.removePoints(0, series.count)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Controls.Button {
|
||||
id: resetZoomButton
|
||||
text: qsTr("Reset zoom")
|
||||
@@ -382,6 +358,73 @@ ColumnLayout {
|
||||
return min
|
||||
}
|
||||
}
|
||||
|
||||
Controls.Button {
|
||||
property string pauseText: qsTr("Pause data collection")
|
||||
property string resumeText: qsTr("Resume data collection")
|
||||
text: pauseText
|
||||
onClicked: {
|
||||
if (timer.running) {
|
||||
text = resumeText
|
||||
timer.stop()
|
||||
} else {
|
||||
text = pauseText
|
||||
timer.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Controls.Button {
|
||||
text: qsTr("Clear data")
|
||||
onClicked: {
|
||||
currentTime = 0
|
||||
|
||||
clearData(voltageData, voltageLoader)
|
||||
clearData(currentData, currentLoader)
|
||||
clearData(batteryTemperatureData, batteryTemperatureLoader)
|
||||
clearData(bmsTemperatureData, bmsTemperatureLoader)
|
||||
clearData(cellVoltageData, cellVoltageLoader)
|
||||
clearData(cellListData, cellListLoader)
|
||||
|
||||
resetZoomButton.clicked()
|
||||
}
|
||||
|
||||
function clearData(dataObject, chartObject) {
|
||||
for (var i = 0; i < dataObject.length; ++i) {
|
||||
dataObject[i].splice(0, dataObject[i].length)
|
||||
var series = chartObject.item.chart.series(i)
|
||||
series.removePoints(0, series.count)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: 10
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
text: qsTr("Interval, s")
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
id: intervalField
|
||||
validator: DoubleValidator { bottom: 0.1; top: 100; decimals: 1; locale: "en-US" }
|
||||
text: "1"
|
||||
onEditingFinished: timer.interval = parseFloat(text) * 1000
|
||||
Layout.preferredHeight: 44
|
||||
}
|
||||
|
||||
Controls.ImageButton {
|
||||
icon.source: "qrc:/Icons/check-indicator.svg"
|
||||
icon.width: 32
|
||||
icon.height: 32
|
||||
Layout.preferredWidth: 42
|
||||
Layout.preferredHeight: 42
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
@@ -395,6 +438,7 @@ ColumnLayout {
|
||||
|
||||
Connections {
|
||||
target: BmsInterface.commands()
|
||||
enabled: root.visible
|
||||
|
||||
onValuesReceived: {
|
||||
addValueToChart(values.packVoltage, voltageData, voltageLoader, 0, 0.05)
|
||||
@@ -428,7 +472,7 @@ ColumnLayout {
|
||||
addValueToChart(cellVoltageArray[j], cellListData, cellListLoader, j, 0.05)
|
||||
}
|
||||
|
||||
currentTime += 1
|
||||
currentTime = Math.round((timer.interval / 1000 + currentTime + Number.EPSILON) * 10) / 10
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user