-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #41: Debug Graph * #41: debug graph * #41: debug graph * #41: debug graph * #41 Explicitly add widgets * #41 Only Listen to Button inputs when not showing graph * #41 Fix Timer * #41 Set Correct Page Index * #41 Fix Pinned Data Interpretatoin * #41 Make min and max kind of work * #41 Set Exit To 6th Index * #41 Set Reasonable Tick Count * #41 Update Number of pages * #41 Only Show Name after topic * #41 Fill Parent Debug Table --------- Co-authored-by: Peyton-McKee <[email protected]>
- Loading branch information
1 parent
868c81e
commit c661614
Showing
17 changed files
with
412 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.15 | ||
import QtCharts 2.6 | ||
|
||
Item { | ||
id: chartItem | ||
width: 800 | ||
height: 480 | ||
|
||
property string chartTitle: "AVERAGE CELL TEMPERATURE" | ||
|
||
property int minX: 0 | ||
property int maxX: 20 | ||
property string xLabel: "TIME (MS)" | ||
|
||
property int minY: 0 | ||
property int maxY: 50 | ||
property string yLabel: "TEMPERATURE (C)" | ||
|
||
property var dummyData: [ | ||
{"x": 0, "y": 30}, | ||
{"x": 4, "y": 15}, | ||
{"x": 6, "y": 30}, | ||
{"x": 8, "y": 15}, | ||
{"x": 13, "y": 40}, | ||
{"x": 18, "y": 15}, | ||
{"x": 20, "y": 27} | ||
] | ||
|
||
ChartView { | ||
anchors.fill: parent | ||
backgroundColor: "black" | ||
title: chartItem.chartTitle | ||
titleColor: "white" | ||
legend.visible: false | ||
|
||
ValuesAxis { | ||
id: xAxis | ||
min: chartItem.minX | ||
max: chartItem.maxX | ||
gridVisible: false | ||
color: "white" | ||
labelsColor: "white" | ||
titleText: "<font color='white'>" + chartItem.xLabel + "</font>" | ||
tickCount: chartItem.maxX + 1 | ||
labelFormat: "%d" | ||
} | ||
|
||
ValuesAxis { | ||
id: yAxis | ||
min: chartItem.minY | ||
max: chartItem.maxY | ||
gridVisible: false | ||
labelsColor: "white" | ||
color: "white" | ||
titleText: "<font color='white'>" + chartItem.yLabel + "</font>" | ||
tickCount: chartItem.maxY / 5 + 1 | ||
labelFormat: "%d" | ||
} | ||
|
||
LineSeries { | ||
id: series | ||
name: "Temperature" | ||
color: "red" | ||
axisX: xAxis | ||
axisY: yAxis | ||
} | ||
} | ||
|
||
Repeater { | ||
model: dummyData | ||
delegate: Item { | ||
Component.onCompleted: { | ||
series.append(modelData.x, modelData.y); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.15 | ||
import QtCharts 2.6 | ||
import NERO | ||
|
||
Item { | ||
id: chartItem | ||
width: 800 | ||
height: 480 | ||
|
||
property string chartTitle: "" | ||
|
||
property int minX: 0 | ||
property int maxX: debugGraphController.graphData.length | ||
property string xLabel: "TIME (MS)" | ||
|
||
property int minY: debugGraphController.minY | ||
property int maxY: debugGraphController.maxY | ||
property string yLabel: "" | ||
|
||
property var dummyData: debugGraphController.graphData | ||
|
||
onDummyDataChanged: { | ||
console.log(maxX) | ||
series.clear() | ||
} | ||
|
||
onVisibleChanged: { | ||
debugGraphController.setTitle(chartTitle) | ||
} | ||
ChartView { | ||
anchors.fill: parent | ||
backgroundColor: "black" | ||
title: chartItem.chartTitle | ||
titleColor: "white" | ||
legend.visible: false | ||
|
||
ValuesAxis { | ||
id: xAxis | ||
min: chartItem.minX | ||
max: chartItem.maxX | ||
gridVisible: false | ||
color: "white" | ||
labelsColor: "white" | ||
titleText: "<font color='white'>" + chartItem.xLabel + "</font>" | ||
tickCount: chartItem.maxX - chartItem.minX + 1 | ||
labelFormat: "%d" | ||
} | ||
|
||
ValuesAxis { | ||
id: yAxis | ||
min: chartItem.minY | ||
max: chartItem.maxY | ||
gridVisible: false | ||
labelsColor: "white" | ||
color: "white" | ||
titleText: "<font color='white'>" + chartItem.yLabel + "</font>" | ||
tickCount: 5 | ||
labelFormat: "%d" | ||
} | ||
|
||
LineSeries { | ||
id: series | ||
name: "Temperature" | ||
color: "red" | ||
axisX: xAxis | ||
axisY: yAxis | ||
} | ||
} | ||
|
||
Repeater { | ||
model: dummyData | ||
delegate: Item { | ||
Component.onCompleted: { | ||
series.append(modelData.x, modelData.y) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
NERODevelopment/src/controllers/debuggraphcontroller.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#include "debuggraphcontroller.h" | ||
|
||
DebugGraphController::DebugGraphController(Model *model, QObject *parent) | ||
: ButtonController(model, 3, parent) { | ||
connect(model, &Model::onCurrentDataChange, this, | ||
&DebugGraphController::update); | ||
} | ||
|
||
QList<QJsonObject> DebugGraphController::graphData() const { | ||
return this->m_graphData; | ||
} | ||
|
||
QString DebugGraphController::unit() const { return this->m_unit; } | ||
|
||
QString DebugGraphController::title() const { return this->m_title; } | ||
|
||
int DebugGraphController::maxY() const { return this->m_maxY; } | ||
|
||
int DebugGraphController::minY() const { return this->m_minY; } | ||
|
||
int DebugGraphController::getNumPoints() { return this->m_num_points; } | ||
|
||
void DebugGraphController::setGraphData(QList<QJsonObject> json) { | ||
if (this->m_graphData != json) { | ||
this->m_graphData = json; | ||
emit this->graphDataChanged(); | ||
} | ||
} | ||
|
||
void DebugGraphController::setUnit(QString unit) { this->m_unit = unit; } | ||
|
||
void DebugGraphController::setTitle(QString title) { | ||
if (m_title == title) { | ||
this->m_model->removePinnedData(title); | ||
return; | ||
} | ||
this->m_title = title; | ||
this->m_model->addPinnedData(title); | ||
emit this->titleChanged(); | ||
} | ||
|
||
void DebugGraphController::setMaxY(int max) { | ||
if (this->m_maxY != max) { | ||
this->m_maxY = max; | ||
emit this->maxYChanged(); | ||
} | ||
} | ||
|
||
void DebugGraphController::setMinY(int min) { | ||
if (this->m_minY != min) { | ||
this->m_minY = min; | ||
emit this->minYChanged(); | ||
} | ||
} | ||
|
||
void DebugGraphController::setValues(QString title, QString unit) { | ||
setUnit(unit); | ||
setTitle(title); | ||
} | ||
|
||
void DebugGraphController::update() { | ||
if (this->m_model->currentPageIndex != this->m_pageIndex) | ||
return; | ||
|
||
if (QDateTime::currentMSecsSinceEpoch() - this->m_last_refresh < | ||
this->m_refresh_rate) { | ||
return; | ||
} | ||
this->m_last_refresh = QDateTime::currentMSecsSinceEpoch(); | ||
|
||
this->m_model->updatePinnedData(); | ||
|
||
QList<QJsonObject> allPoints; | ||
QMap<QString, DebugPlotValue> pinnedData = this->m_model->getPinnedData(); | ||
|
||
int globalIndex = this->m_num_points - 1; | ||
|
||
const QList<float> &dataList = pinnedData[this->m_title].data; | ||
|
||
for (int i = 0; i < std::min(this->m_num_points, (int)dataList.length()); | ||
++i) { | ||
float value = dataList.at(i); | ||
if (!std::isnan(value) && std::isfinite(value)) { | ||
QJsonObject point; | ||
point["x"] = globalIndex--; | ||
point["y"] = value; | ||
allPoints.append(point); | ||
} | ||
} | ||
|
||
int maxY = -99999; | ||
int minY = 99999; | ||
|
||
for (const QJsonObject &point : allPoints) { | ||
int yValue = point["y"].toInt(); | ||
if (yValue > maxY) { | ||
maxY = yValue; | ||
} | ||
if (yValue < minY) { | ||
minY = yValue; | ||
} | ||
} | ||
|
||
setMaxY(maxY + 5); | ||
setMinY(minY - 5); | ||
|
||
setGraphData(allPoints); | ||
} |
Oops, something went wrong.