From 8ebd95da702e6d8fb79d1bf8dae7cf8ea9a2c1ed Mon Sep 17 00:00:00 2001 From: mattrwang Date: Wed, 27 Mar 2024 21:20:28 -0400 Subject: [PATCH 01/15] #41: Debug Graph --- NERODesign/content/DebugGraph.qml | 18 +++++++++++ .../src/controllers/debuggraphcontroller.cpp | 26 ++++++++++++++++ .../src/controllers/debuggraphcontroller.h | 31 +++++++++++++++++++ NERODevelopment/src/models/model.cpp | 4 +++ NERODevelopment/src/models/model.h | 1 + 5 files changed, 80 insertions(+) create mode 100644 NERODesign/content/DebugGraph.qml create mode 100644 NERODevelopment/src/controllers/debuggraphcontroller.cpp create mode 100644 NERODevelopment/src/controllers/debuggraphcontroller.h diff --git a/NERODesign/content/DebugGraph.qml b/NERODesign/content/DebugGraph.qml new file mode 100644 index 0000000..4315091 --- /dev/null +++ b/NERODesign/content/DebugGraph.qml @@ -0,0 +1,18 @@ +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtCharts + +Item { + id: debugGraph + width: 800 + height: 480 + + ChartView { + title: "AVERAGE CELL TEMPERATURE" + anchors.fill: parent + antialiasing: true + LineSeries { + + } + } +} diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.cpp b/NERODevelopment/src/controllers/debuggraphcontroller.cpp new file mode 100644 index 0000000..628fb2d --- /dev/null +++ b/NERODevelopment/src/controllers/debuggraphcontroller.cpp @@ -0,0 +1,26 @@ +#include "debuggraphcontroller.h" + +DebugGraphController::DebugGraphController(Model *model, QObject *parent) + : ButtonController(model, parent) { + connect(&m_dataUpdateTimer, &QTimer::timeout, this, + &DebugGraphController::updateGraphData); + m_dataUpdateTimer.start(1000); +} + +DebugGraphController::~DebugGraphController() { m_dataUpdateTimer.stop(); } + +QList DebugGraphController::graphData() const { return m_graphData; } + +void DebugGraphController::updateGraphData() { + QList newData; + auto pinnedDataMap = m_model->getPinnedData(); + + for (const auto &key : pinnedDataMap.keys()) { + const auto &value = pinnedDataMap.value(key); + newData.append(QVariant::fromValue(value)); + } + + m_graphData = newData; + + emit graphDataChanged(); +} diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.h b/NERODevelopment/src/controllers/debuggraphcontroller.h new file mode 100644 index 0000000..1947a5a --- /dev/null +++ b/NERODevelopment/src/controllers/debuggraphcontroller.h @@ -0,0 +1,31 @@ +#ifndef DEBUGGRAPHCONTROLLER_H +#define DEBUGGRAPHCONTROLLER_H + +#include "QtCore/qvariant.h" +#include "buttoncontroller.h" +#include "src/models/model.h" +#include +#include + +class DebugGraphController : public ButtonController { + Q_OBJECT + Q_PROPERTY(QList graphData READ graphData WRITE updateGraphData + NOTIFY graphDataChanged) + +public: + explicit DebugGraphController(Model *model, QObject *parent = nullptr); + ~DebugGraphController(); + QList graphData() const; + +signals: + void graphDataChanged(); + +public slots: + void updateGraphData(); + +private: + QList m_graphData; + QTimer m_dataUpdateTimer; +}; + +#endif // DEBUGGRAPHCONTROLLER_H diff --git a/NERODevelopment/src/models/model.cpp b/NERODevelopment/src/models/model.cpp index e07f541..f5efe4b 100644 --- a/NERODevelopment/src/models/model.cpp +++ b/NERODevelopment/src/models/model.cpp @@ -33,6 +33,10 @@ void Model::updatePinnedData() { } } +QMap Model::getPinnedData() { + return this->pinnedData; +} + void Model::updateAverageCellTemps() { if (averageCellTemps.size() >= 30) { averageCellTemps.pop_front(); diff --git a/NERODevelopment/src/models/model.h b/NERODevelopment/src/models/model.h index a6ed9d9..02c7d49 100644 --- a/NERODevelopment/src/models/model.h +++ b/NERODevelopment/src/models/model.h @@ -85,6 +85,7 @@ class Model : public QObject { void addPinnedData(QString id); void removePinnedData(QString id); void updatePinnedData(); + QMap getPinnedData(); void updateAverageCellTemps(); void updateStateOfChargeDeltas(); std::optional getById(QString id); From ce90112f5e84f99129df8a91029a5b6779a8571d Mon Sep 17 00:00:00 2001 From: mattrwang Date: Sun, 31 Mar 2024 21:12:54 -0400 Subject: [PATCH 02/15] #41: debug graph --- NERODesign/content/DebugGraph.qml | 68 +++++++++++++++++-- .../src/controllers/debuggraphcontroller.cpp | 24 ++----- .../src/controllers/debuggraphcontroller.h | 8 +-- NERODevelopment/src/main.cpp | 2 + 4 files changed, 77 insertions(+), 25 deletions(-) diff --git a/NERODesign/content/DebugGraph.qml b/NERODesign/content/DebugGraph.qml index 4315091..960b6f3 100644 --- a/NERODesign/content/DebugGraph.qml +++ b/NERODesign/content/DebugGraph.qml @@ -1,18 +1,78 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import QtCharts +import QtCharts 2.6 Item { - id: debugGraph + 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 { - title: "AVERAGE CELL TEMPERATURE" anchors.fill: parent - antialiasing: true + 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: "" + chartItem.xLabel + "" + tickCount: chartItem.maxX + 1 + labelFormat: "%d" + } + + ValuesAxis { + id: yAxis + min: chartItem.minY + max: chartItem.maxY + gridVisible: false + labelsColor: "white" + color: "white" + titleText: "" + chartItem.yLabel + "" + 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); + } } } } diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.cpp b/NERODevelopment/src/controllers/debuggraphcontroller.cpp index 628fb2d..549a230 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.cpp +++ b/NERODevelopment/src/controllers/debuggraphcontroller.cpp @@ -1,26 +1,16 @@ #include "debuggraphcontroller.h" DebugGraphController::DebugGraphController(Model *model, QObject *parent) - : ButtonController(model, parent) { - connect(&m_dataUpdateTimer, &QTimer::timeout, this, - &DebugGraphController::updateGraphData); - m_dataUpdateTimer.start(1000); -} + : ButtonController(model, 7, parent) {} DebugGraphController::~DebugGraphController() { m_dataUpdateTimer.stop(); } -QList DebugGraphController::graphData() const { return m_graphData; } - -void DebugGraphController::updateGraphData() { - QList newData; - auto pinnedDataMap = m_model->getPinnedData(); +QList DebugGraphController::graphData() const { + return m_graphData; +} - for (const auto &key : pinnedDataMap.keys()) { - const auto &value = pinnedDataMap.value(key); - newData.append(QVariant::fromValue(value)); +void DebugGraphController::setGraphData(QList json) { + if (this->m_graphData != json) { + this->m_graphData = json; } - - m_graphData = newData; - - emit graphDataChanged(); } diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.h b/NERODevelopment/src/controllers/debuggraphcontroller.h index 1947a5a..5267382 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.h +++ b/NERODevelopment/src/controllers/debuggraphcontroller.h @@ -9,22 +9,22 @@ class DebugGraphController : public ButtonController { Q_OBJECT - Q_PROPERTY(QList graphData READ graphData WRITE updateGraphData + Q_PROPERTY(QList graphData READ graphData WRITE setGraphData NOTIFY graphDataChanged) public: explicit DebugGraphController(Model *model, QObject *parent = nullptr); ~DebugGraphController(); - QList graphData() const; + QList graphData() const; signals: void graphDataChanged(); public slots: - void updateGraphData(); + void setGraphData(QList); private: - QList m_graphData; + QList m_graphData; QTimer m_dataUpdateTimer; }; diff --git a/NERODevelopment/src/main.cpp b/NERODevelopment/src/main.cpp index 5bf19ab..985f2ac 100644 --- a/NERODevelopment/src/main.cpp +++ b/NERODevelopment/src/main.cpp @@ -3,6 +3,7 @@ #include "app_environment.h" #include "controllers/configurationcontroller.h" +#include "controllers/debuggraphcontroller.h" #include "controllers/debugtablecontroller.h" #include "controllers/flappybirdcontroller.h" #include "controllers/headercontroller.h" @@ -49,6 +50,7 @@ int main(int argc, char *argv[]) { FlappyBirdController flappyBirdController(model); ConfigurationController configurationController(model); KeyboardController keyboardController(model); + DebugGraphController graphController(model); const QUrl url(u"qrc:Main/main.qml"_qs); QObject::connect( From b1b0740603b71efaa9b88b03e68b857dc28a5201 Mon Sep 17 00:00:00 2001 From: mattrwang Date: Thu, 4 Apr 2024 18:35:23 -0400 Subject: [PATCH 03/15] #41: debug graph --- NERODevelopment/content/DebugTable.qml | 10 ++++++++ .../src/controllers/debuggraphcontroller.cpp | 24 ++++++++++++++++++- .../src/controllers/debuggraphcontroller.h | 12 ++++++++++ .../src/controllers/debugtablecontroller.cpp | 19 +++++++++++---- .../src/controllers/debugtablecontroller.h | 8 +++++++ NERODevelopment/src/main.cpp | 8 ++++--- 6 files changed, 73 insertions(+), 8 deletions(-) diff --git a/NERODevelopment/content/DebugTable.qml b/NERODevelopment/content/DebugTable.qml index e85a7e0..78c4b09 100644 --- a/NERODevelopment/content/DebugTable.qml +++ b/NERODevelopment/content/DebugTable.qml @@ -17,6 +17,7 @@ Item { property int rowHeight: 30 Keys.onPressed: event => { + console.log(event.key, Qt.Key_Enter) switch (event.key) { case Qt.Key_Up: debugTableController.upButtonPressed() @@ -30,6 +31,9 @@ Item { case Qt.Key_Down: debugTableController.downButtonPressed() break + case Qt.Key_Return: + debugTableController.enterButtonPressed() + break default: break } @@ -147,4 +151,10 @@ Item { } } } + + DebugGraph { + visible: debugTableController.showGraph + chartTitle: debugTableController.selectedValues[debugTableController.selectedValuesIndex]["name"] + yLabel: debugTableController.selectedValues[debugTableController.selectedValuesIndex]["unit"] + } } diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.cpp b/NERODevelopment/src/controllers/debuggraphcontroller.cpp index 549a230..193d153 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.cpp +++ b/NERODevelopment/src/controllers/debuggraphcontroller.cpp @@ -6,11 +6,33 @@ DebugGraphController::DebugGraphController(Model *model, QObject *parent) DebugGraphController::~DebugGraphController() { m_dataUpdateTimer.stop(); } QList DebugGraphController::graphData() const { - return m_graphData; + return this->m_graphData; } +QString DebugGraphController::unit() const { return this->m_unit; } + +QString DebugGraphController::title() const { return this->m_title; } + void DebugGraphController::setGraphData(QList json) { if (this->m_graphData != json) { this->m_graphData = json; } } + +void DebugGraphController::setUnit(QString unit) { this->m_unit = unit; } + +void DebugGraphController::setTitle(QString title) { + this->m_title = title; + this->m_model->addPinnedData(title); +} + +void DebugGraphController::setValues(QString title, QString unit) { + setUnit(unit); + setTitle(title); +} + +void DebugGraphController::update() { + this->m_model->updatePinnedData(); + + // setGraphData(pinnedData.map qlist of qjson (x, y)) +} diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.h b/NERODevelopment/src/controllers/debuggraphcontroller.h index 5267382..5bb9ccc 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.h +++ b/NERODevelopment/src/controllers/debuggraphcontroller.h @@ -11,20 +11,32 @@ class DebugGraphController : public ButtonController { Q_OBJECT Q_PROPERTY(QList graphData READ graphData WRITE setGraphData NOTIFY graphDataChanged) + Q_PROPERTY(QString unit READ unit WRITE setUnit NOTIFY unitChanged) + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) public: explicit DebugGraphController(Model *model, QObject *parent = nullptr); ~DebugGraphController(); QList graphData() const; + QString unit() const; + QString title() const; signals: void graphDataChanged(); + void unitChanged(); + void titleChanged(); public slots: void setGraphData(QList); + void setUnit(QString); + void setTitle(QString); + void setValues(QString, QString); + void update(); private: QList m_graphData; + QString m_unit = "TEMPERATURE (C)"; + QString m_title = "AVERAGE CELL TEMPERATURE"; QTimer m_dataUpdateTimer; }; diff --git a/NERODevelopment/src/controllers/debugtablecontroller.cpp b/NERODevelopment/src/controllers/debugtablecontroller.cpp index 7f2d657..999e59b 100644 --- a/NERODevelopment/src/controllers/debugtablecontroller.cpp +++ b/NERODevelopment/src/controllers/debugtablecontroller.cpp @@ -26,6 +26,8 @@ bool DebugTableController::scrollingTopics() const { return this->m_scrollingTopics; } +bool DebugTableController::showGraph() const { return this->m_showGraph; } + void DebugTableController::setScrollingTopics(bool scrollingTopics) { if (this->m_scrollingTopics != scrollingTopics) { this->m_scrollingTopics = scrollingTopics; @@ -57,8 +59,17 @@ void DebugTableController::setTopics(QList topics) { emit this->topicsChanged(); } +void DebugTableController::setShowGraph(bool show) { + if (this->m_showGraph != show) { + this->m_showGraph = show; + emit this->showGraphChanged(); + } +} + void DebugTableController::enterButtonPressed() { - // TODO SELECT CURRENTLY SELECTED VALUE + if (!this->scrollingTopics()) { + setShowGraph(!this->m_showGraph); + } } void DebugTableController::downButtonPressed() { @@ -107,9 +118,9 @@ void DebugTableController::update() { return; } this->m_last_refresh = QDateTime::currentMSecsSinceEpoch(); - qDebug() << "updating debug table" - << this->m_last_refresh + this->m_refresh_rate - << QDateTime::currentMSecsSinceEpoch(); + // qDebug() << "updating debug table" + // << this->m_last_refresh + this->m_refresh_rate + // << QDateTime::currentMSecsSinceEpoch(); QSet topicsSet = {}; QList topics = {}; QList rows = this->m_model->getDebugTableValues(); diff --git a/NERODevelopment/src/controllers/debugtablecontroller.h b/NERODevelopment/src/controllers/debugtablecontroller.h index 1bfa15a..f440c0b 100644 --- a/NERODevelopment/src/controllers/debugtablecontroller.h +++ b/NERODevelopment/src/controllers/debugtablecontroller.h @@ -3,6 +3,7 @@ #include "QtCore/qvariant.h" #include "buttoncontroller.h" +#include "src/controllers/navigationcontroller.h" #include "src/models/model.h" #include @@ -18,6 +19,8 @@ class DebugTableController : public ButtonController { setSelectedValuesIndex NOTIFY selectedValuesIndexChanged FINAL) Q_PROPERTY(bool scrollingTopics READ scrollingTopics WRITE setScrollingTopics NOTIFY scrollingTopicsChanged FINAL) + Q_PROPERTY(bool showGraph READ showGraph WRITE setShowGraph NOTIFY + showGraphChanged FINAL) public: explicit DebugTableController(Model *model, QObject *parent = nullptr); @@ -26,6 +29,7 @@ class DebugTableController : public ButtonController { int selectedValuesIndex() const; int selectedTopicsIndex() const; bool scrollingTopics() const; + bool showGraph() const; signals: void topicsChanged(); @@ -33,6 +37,8 @@ class DebugTableController : public ButtonController { void selectedValuesIndexChanged(); void selectedTopicsIndexChanged(); void scrollingTopicsChanged(); + void valueSelected(QString, QString); + void showGraphChanged(); public slots: void setTopics(QList); @@ -40,6 +46,7 @@ public slots: void setSelectedValuesIndex(int); void setSelectedTopicsIndex(int); void setScrollingTopics(bool); + void setShowGraph(bool); void update(); @@ -54,6 +61,7 @@ public slots: QList m_selectedValues; int m_selectedTopicsIndex = 0; bool m_scrollingTopics = true; + bool m_showGraph = false; int m_selectedValuesIndex = 0; int m_refresh_rate = 500; qint64 m_last_refresh = 0; diff --git a/NERODevelopment/src/main.cpp b/NERODevelopment/src/main.cpp index 985f2ac..9c4e2c0 100644 --- a/NERODevelopment/src/main.cpp +++ b/NERODevelopment/src/main.cpp @@ -15,7 +15,7 @@ #include "import_qml_plugins.h" #include "src/models/mock_model.h" #include "src/models/raspberry_model.h" -#include +#include #include #include #include @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) { set_qt_environment(); - QGuiApplication app(argc, argv); + QApplication app(argc, argv); QQmlApplicationEngine engine; @@ -45,8 +45,8 @@ int main(int argc, char *argv[]) { HomeController homeController(model); HeaderController headerController(model); OffViewController offViewController(model); - DebugTableController tableController(model); NavigationController navigationController(model); + DebugTableController tableController(model); FlappyBirdController flappyBirdController(model); ConfigurationController configurationController(model); KeyboardController keyboardController(model); @@ -76,6 +76,8 @@ int main(int argc, char *argv[]) { &configurationController); engine.rootContext()->setContextProperty("keyboardViewController", &keyboardController); + engine.rootContext()->setContextProperty("debugGraphController", + &graphController); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); From 472e417204a2363cc66e13d41181477a5f9c5a05 Mon Sep 17 00:00:00 2001 From: mattrwang Date: Mon, 8 Apr 2024 20:19:05 -0400 Subject: [PATCH 04/15] #41: debug graph --- NERODevelopment/content/DebugGraph.qml | 78 +++++++++ NERODevelopment/content/DebugTable.qml | 7 +- .../src/controllers/debuggraphcontroller.cpp | 73 +++++++- .../src/controllers/debuggraphcontroller.h | 16 +- .../src/controllers/speedcontroller.cpp | 162 +++++++++--------- .../src/controllers/speedcontroller.h | 160 ++++++++--------- NERODevelopment/src/models/mock_model.cpp | 1 + NERODevelopment/src/models/mock_model.h | 2 +- NERODevelopment/src/models/model.cpp | 33 +--- NERODevelopment/src/models/model.h | 3 - .../src/models/raspberry_model.cpp | 5 +- NERODevelopment/src/utils/data_type_names.h | 3 +- 12 files changed, 348 insertions(+), 195 deletions(-) create mode 100644 NERODevelopment/content/DebugGraph.qml diff --git a/NERODevelopment/content/DebugGraph.qml b/NERODevelopment/content/DebugGraph.qml new file mode 100644 index 0000000..3b5cd7e --- /dev/null +++ b/NERODevelopment/content/DebugGraph.qml @@ -0,0 +1,78 @@ +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: 20 + property string xLabel: "TIME (MS)" + + property int minY: debugGraphController.minY + property int maxY: debugGraphController.maxY + property string yLabel: "" + + property var dummyData: debugGraphController.graphData + + onDummyDataChanged: { + 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: "" + chartItem.xLabel + "" + tickCount: chartItem.maxX + 1 + labelFormat: "%d" + } + + ValuesAxis { + id: yAxis + min: chartItem.minY + max: chartItem.maxY + gridVisible: false + labelsColor: "white" + color: "white" + titleText: "" + chartItem.yLabel + "" + 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); + } + } + } +} diff --git a/NERODevelopment/content/DebugTable.qml b/NERODevelopment/content/DebugTable.qml index 78c4b09..0181b79 100644 --- a/NERODevelopment/content/DebugTable.qml +++ b/NERODevelopment/content/DebugTable.qml @@ -13,6 +13,7 @@ Item { property int selectedTopicIndex: debugTableController.selectedTopicsIndex property int selectedValueIndex: debugTableController.selectedValuesIndex property bool scrollingTopics: debugTableController.scrollingTopics + property bool showGraph: debugTableController.showGraph property int rowHeight: 30 @@ -153,8 +154,8 @@ Item { } DebugGraph { - visible: debugTableController.showGraph - chartTitle: debugTableController.selectedValues[debugTableController.selectedValuesIndex]["name"] - yLabel: debugTableController.selectedValues[debugTableController.selectedValuesIndex]["unit"] + visible: showGraph + chartTitle: values[selectedValueIndex]["name"] + yLabel: values[selectedValueIndex]["unit"] } } diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.cpp b/NERODevelopment/src/controllers/debuggraphcontroller.cpp index 193d153..c31a722 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.cpp +++ b/NERODevelopment/src/controllers/debuggraphcontroller.cpp @@ -1,7 +1,10 @@ #include "debuggraphcontroller.h" DebugGraphController::DebugGraphController(Model *model, QObject *parent) - : ButtonController(model, 7, parent) {} + : ButtonController(model, 7, parent) { + connect(model, &Model::onCurrentDataChange, this, + &DebugGraphController::update); +} DebugGraphController::~DebugGraphController() { m_dataUpdateTimer.stop(); } @@ -13,9 +16,16 @@ 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 json) { if (this->m_graphData != json) { this->m_graphData = json; + emit this->graphDataChanged(); } } @@ -26,6 +36,20 @@ void DebugGraphController::setTitle(QString title) { this->m_model->addPinnedData(title); } +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); @@ -34,5 +58,50 @@ void DebugGraphController::setValues(QString title, QString unit) { void DebugGraphController::update() { this->m_model->updatePinnedData(); - // setGraphData(pinnedData.map qlist of qjson (x, y)) + if (QDateTime::currentMSecsSinceEpoch() - this->m_last_refresh < + this->m_refresh_rate) { + return; + } + + this->m_last_refresh = QDateTime::currentMSecsSinceEpoch(); + + QList allPoints; + QMap pinnedData = this->m_model->getPinnedData(); + + int globalIndex = 0; + + auto iter = pinnedData.constBegin(); + while (iter != pinnedData.constEnd()) { + const QList &dataList = iter.value().data; + for (int i = 0; i < this->m_num_points; ++i) { + float value = dataList.at(i); + if (!std::isnan(value) && std::isfinite(value)) { + QJsonObject point; + point["x"] = globalIndex++; + point["y"] = value; + allPoints.append(point); + } + } + ++iter; + } + + int maxY = 0; + int minY = 0; + + for (const QJsonObject &point : allPoints) { + int yValue = point["y"].toInt(); + if (yValue > maxY) { + maxY = yValue; + } + if (yValue < minY) { + minY = yValue; + } + } + + setMaxY(maxY * 1.1); + setMinY(minY); + + std::reverse(allPoints.begin(), allPoints.end()); + + setGraphData(allPoints); } diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.h b/NERODevelopment/src/controllers/debuggraphcontroller.h index 5bb9ccc..d6ea98b 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.h +++ b/NERODevelopment/src/controllers/debuggraphcontroller.h @@ -13,6 +13,8 @@ class DebugGraphController : public ButtonController { NOTIFY graphDataChanged) Q_PROPERTY(QString unit READ unit WRITE setUnit NOTIFY unitChanged) Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + Q_PROPERTY(int maxY READ maxY WRITE setMaxY NOTIFY maxYChanged) + Q_PROPERTY(int minY READ minY WRITE setMinY NOTIFY minYChanged) public: explicit DebugGraphController(Model *model, QObject *parent = nullptr); @@ -20,24 +22,36 @@ class DebugGraphController : public ButtonController { QList graphData() const; QString unit() const; QString title() const; + int maxY() const; + int minY() const; + int getNumPoints(); signals: void graphDataChanged(); void unitChanged(); void titleChanged(); + void maxYChanged(); + void minYChanged(); public slots: void setGraphData(QList); void setUnit(QString); void setTitle(QString); + void setMaxY(int); + void setMinY(int); void setValues(QString, QString); void update(); private: - QList m_graphData; + QList m_graphData = {}; QString m_unit = "TEMPERATURE (C)"; QString m_title = "AVERAGE CELL TEMPERATURE"; + int m_maxY = 60; + int m_minY = 0; QTimer m_dataUpdateTimer; + qint64 m_last_refresh = 0; + int m_refresh_rate = 500; + int m_num_points = 21; }; #endif // DEBUGGRAPHCONTROLLER_H diff --git a/NERODevelopment/src/controllers/speedcontroller.cpp b/NERODevelopment/src/controllers/speedcontroller.cpp index ad5335d..9a1996e 100644 --- a/NERODevelopment/src/controllers/speedcontroller.cpp +++ b/NERODevelopment/src/controllers/speedcontroller.cpp @@ -1,112 +1,116 @@ #include "speedcontroller.h" -SpeedController::SpeedController(Model *model, QObject* parent): ButtonController{model, parent}, m_tractionControl(), m_packTemp(), - m_motorTemp(), m_chargeState(), m_currentTime(), m_fastestTime(), m_lastTime(), m_currentSpeed(), - m_maxSpeed(), m_current(), m_maxCurrent(), m_currentDischarge(), m_maxCurrentDischarge(){ - connect(m_model, &Model::onCurrentDataChange, this, &SpeedController::update); +SpeedController::SpeedController(Model *model, QObject *parent) + : ButtonController{model, 10, parent}, m_tractionControl(), m_packTemp(), + m_motorTemp(), m_chargeState(), m_currentTime(), m_fastestTime(), + m_lastTime(), m_currentSpeed(), m_maxSpeed(), m_current(), m_maxCurrent(), + m_currentDischarge(), m_maxCurrentDischarge() { + connect(m_model, &Model::onCurrentDataChange, this, &SpeedController::update); } -bool SpeedController::tractionControl() const {return m_tractionControl;} +bool SpeedController::tractionControl() const { return m_tractionControl; } void SpeedController::setTractionControl(bool tractionStatus) { - if (tractionStatus != m_tractionControl) { - m_tractionControl = tractionStatus; - emit tractionControlChanged(tractionStatus); - } + if (tractionStatus != m_tractionControl) { + m_tractionControl = tractionStatus; + emit tractionControlChanged(tractionStatus); + } } -float SpeedController::packTemp() const {return m_packTemp;} +float SpeedController::packTemp() const { return m_packTemp; } void SpeedController::setPackTemp(float packTemp) { - if (packTemp != m_packTemp) { - m_packTemp = packTemp; - emit packTempChanged(packTemp); - } + if (packTemp != m_packTemp) { + m_packTemp = packTemp; + emit packTempChanged(packTemp); + } } -float SpeedController::motorTemp() const {return m_motorTemp;} +float SpeedController::motorTemp() const { return m_motorTemp; } void SpeedController::setMotorTemp(float motorTemp) { - if (motorTemp != m_motorTemp) { - m_motorTemp = motorTemp; - emit motorTempChanged(motorTemp); - } + if (motorTemp != m_motorTemp) { + m_motorTemp = motorTemp; + emit motorTempChanged(motorTemp); + } } -float SpeedController::chargeState() const {return m_chargeState;} +float SpeedController::chargeState() const { return m_chargeState; } void SpeedController::setChargeState(float chargeState) { - if (chargeState != m_chargeState) { - m_chargeState = chargeState; - emit packTempChanged(chargeState); - } + if (chargeState != m_chargeState) { + m_chargeState = chargeState; + emit packTempChanged(chargeState); + } } -int SpeedController::currentTime() const {return m_currentTime;} +int SpeedController::currentTime() const { return m_currentTime; } void SpeedController::setCurrentTime(int currentTime) { - if (currentTime != m_currentTime) { - m_currentTime = currentTime; - emit currentTimeChanged(currentTime); - } + if (currentTime != m_currentTime) { + m_currentTime = currentTime; + emit currentTimeChanged(currentTime); + } } -int SpeedController::fastestTime() const {return m_fastestTime;} +int SpeedController::fastestTime() const { return m_fastestTime; } void SpeedController::setFastestTime(int fastTime) { - if (fastTime != m_fastestTime) { - m_fastestTime = fastTime; - emit fastestTimeChanged(fastTime); - } + if (fastTime != m_fastestTime) { + m_fastestTime = fastTime; + emit fastestTimeChanged(fastTime); + } } -int SpeedController::lastTime() const {return m_lastTime;} +int SpeedController::lastTime() const { return m_lastTime; } void SpeedController::setLastTime(int lastTime) { - if (lastTime != m_lastTime) { - m_lastTime = lastTime; - emit lastTimeChanged(lastTime); - } + if (lastTime != m_lastTime) { + m_lastTime = lastTime; + emit lastTimeChanged(lastTime); + } } -int SpeedController::currentSpeed() const {return m_currentSpeed;} +int SpeedController::currentSpeed() const { return m_currentSpeed; } void SpeedController::setCurrentSpeed(int currentSpeed) { - if (currentSpeed != m_currentSpeed) { - m_currentSpeed = currentSpeed; - emit currentSpeedChanged(currentSpeed); - } + if (currentSpeed != m_currentSpeed) { + m_currentSpeed = currentSpeed; + emit currentSpeedChanged(currentSpeed); + } } -int SpeedController::maxSpeed() const {return m_maxSpeed;} +int SpeedController::maxSpeed() const { return m_maxSpeed; } void SpeedController::setMaxSpeed(int maxSpeed) { - if (maxSpeed != m_maxSpeed) { - m_maxSpeed = maxSpeed; - emit maxSpeedChanged(maxSpeed); - } + if (maxSpeed != m_maxSpeed) { + m_maxSpeed = maxSpeed; + emit maxSpeedChanged(maxSpeed); + } } -float SpeedController::current() const {return m_current;} +float SpeedController::current() const { return m_current; } void SpeedController::setCurrent(float current) { - if (current != m_current) { - m_current = current; - emit currentChanged(current); - } + if (current != m_current) { + m_current = current; + emit currentChanged(current); + } } -float SpeedController::maxCurrent() const {return m_maxCurrent;} +float SpeedController::maxCurrent() const { return m_maxCurrent; } void SpeedController::setMaxCurrent(float maxCurrent) { - if (maxCurrent != m_maxCurrent) { - m_maxCurrent = maxCurrent; - emit maxCurrentChanged(maxCurrent); - } + if (maxCurrent != m_maxCurrent) { + m_maxCurrent = maxCurrent; + emit maxCurrentChanged(maxCurrent); + } } -float SpeedController::currentDischarge() const {return m_currentDischarge;} +float SpeedController::currentDischarge() const { return m_currentDischarge; } void SpeedController::setCurrentDischarge(float currentDischarge) { - if (currentDischarge != m_currentDischarge) { - m_currentDischarge = currentDischarge; - emit currentDischargeChanged(currentDischarge); - } + if (currentDischarge != m_currentDischarge) { + m_currentDischarge = currentDischarge; + emit currentDischargeChanged(currentDischarge); + } +} +float SpeedController::maxCurrentDischarge() const { + return m_maxCurrentDischarge; } -float SpeedController::maxCurrentDischarge() const {return m_maxCurrentDischarge;} void SpeedController::setMaxCurrentDischarge(float maxCurrentDischarge) { - if (maxCurrentDischarge != m_maxCurrentDischarge) { - m_maxCurrentDischarge = maxCurrentDischarge; - emit maxCurrentDischargeChanged(maxCurrentDischarge); - } + if (maxCurrentDischarge != m_maxCurrentDischarge) { + m_maxCurrentDischarge = maxCurrentDischarge; + emit maxCurrentDischargeChanged(maxCurrentDischarge); + } } void SpeedController::update() { - setTractionControl(*m_model->getTractionControl()); - setPackTemp(*m_model->getPackTemp()); - setMotorTemp(*m_model->getMotorTemp()); - setChargeState(*m_model->getStateOfCharge()); - setCurrentTime(*m_model->getTime()); - setFastestTime(m_model->getFastestTime()); - setLastTime(m_model->getLastTime()); - setCurrentSpeed(*m_model->getMph()); - setMaxSpeed(m_model->getMaxSpeed()); - setCurrent(*m_model->getCurrent()); + setTractionControl(*m_model->getTractionControl()); + setPackTemp(*m_model->getPackTemp()); + setMotorTemp(*m_model->getMotorTemp()); + setChargeState(*m_model->getStateOfCharge()); + setCurrentTime(*m_model->getTime()); + setFastestTime(m_model->getFastestTime()); + setLastTime(m_model->getLastTime()); + setCurrentSpeed(*m_model->getMph()); + setMaxSpeed(m_model->getMaxSpeed()); + setCurrent(*m_model->getCurrent()); } diff --git a/NERODevelopment/src/controllers/speedcontroller.h b/NERODevelopment/src/controllers/speedcontroller.h index 98e4364..5e54a3e 100644 --- a/NERODevelopment/src/controllers/speedcontroller.h +++ b/NERODevelopment/src/controllers/speedcontroller.h @@ -1,107 +1,113 @@ #ifndef SPEEDCONTROLLER_H #define SPEEDCONTROLLER_H -#include #include "../models/model.h" #include "buttoncontroller.h" +#include class SpeedController : public ButtonController { - Q_OBJECT - Q_PROPERTY(bool tractionControl READ tractionControlStatus WRITE setTractionControl - NOTIFY tractionControlChanged); - - Q_PROPERTY(float packTemp READ packTemp WRITE setPackTemp NOTIFY packTempChanged); + Q_OBJECT + Q_PROPERTY(bool tractionControl READ tractionControl WRITE setTractionControl + NOTIFY tractionControlChanged); - Q_PROPERTY(float motorTemp READ motorTemp WRITE setMotorTemp NOTIFY motorTempChanged); + Q_PROPERTY( + float packTemp READ packTemp WRITE setPackTemp NOTIFY packTempChanged); - Q_PROPERTY(float chargeState READ chargeState WRITE setChargeState NOTIFY chargeStateChanged); + Q_PROPERTY(float motorTemp READ motorTemp WRITE setMotorTemp NOTIFY + motorTempChanged); - Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime NOTIFY currentTimeChanged); + Q_PROPERTY(float chargeState READ chargeState WRITE setChargeState NOTIFY + chargeStateChanged); - Q_PROPERTY(int fastestTime READ fastestTime WRITE setFastestTime NOTIFY fastestTimeChanged); + Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime NOTIFY + currentTimeChanged); - Q_PROPERTY(int lastTime READ lastTime WRITE setLastTime NOTIFY lastTimeChanged); + Q_PROPERTY(int fastestTime READ fastestTime WRITE setFastestTime NOTIFY + fastestTimeChanged); - Q_PROPERTY(int currentSpeed READ currentSpeed WRITE setCurrentSpeed NOTIFY currentSpeedChanged); + Q_PROPERTY( + int lastTime READ lastTime WRITE setLastTime NOTIFY lastTimeChanged); - Q_PROPERTY(int maxSpeed READ maxSpeed WRITE setMaxSpeed NOTIFY maxSpeedChanged); + Q_PROPERTY(int currentSpeed READ currentSpeed WRITE setCurrentSpeed NOTIFY + currentSpeedChanged); - Q_PROPERTY(float current READ current WRITE setCurrent NOTIFY currentChanged); + Q_PROPERTY( + int maxSpeed READ maxSpeed WRITE setMaxSpeed NOTIFY maxSpeedChanged); - Q_PROPERTY(float maxCurrent READ maxCurrent WRITE setMaxCurrent NOTIFY maxCurrentChanged); - - Q_PROPERTY(float currentDischarge READ currentDischarge WRITE setCurrentDischarge NOTIFY currentDischargeChanged); - - Q_PROPERTY(float maxCurrentDischarge READ maxCurrentDischarge WRITE setMaxCurrentDischarge - NOTIFY maxcurrentDischargeChanged); + Q_PROPERTY(float current READ current WRITE setCurrent NOTIFY currentChanged); + Q_PROPERTY(float maxCurrent READ maxCurrent WRITE setMaxCurrent NOTIFY + maxCurrentChanged); + Q_PROPERTY(float currentDischarge READ currentDischarge WRITE + setCurrentDischarge NOTIFY currentDischargeChanged); + Q_PROPERTY(float maxCurrentDischarge READ maxCurrentDischarge WRITE + setMaxCurrentDischarge NOTIFY maxCurrentDischargeChanged); public: - explicit SpeedController(Model *model ,QObject *parent = nullptr); - - bool tractionControl() const; - float packTemp() const; - float motorTemp() const; - float chargeState() const; - int currentTime() const; - int fastestTime() const; - int lastTime() const; - int currentSpeed() const; - int maxSpeed() const; - float current() const; - float maxCurrent() const; - float currentDischarge() const; - float maxCurrentDischarge() const; + explicit SpeedController(Model *model, QObject *parent = nullptr); + + bool tractionControl() const; + float packTemp() const; + float motorTemp() const; + float chargeState() const; + int currentTime() const; + int fastestTime() const; + int lastTime() const; + int currentSpeed() const; + int maxSpeed() const; + float current() const; + float maxCurrent() const; + float currentDischarge() const; + float maxCurrentDischarge() const; signals: - void tractionControlChanged(bool); - void packTempChanged(float); - void motorTempChanged(float); - void chargeStateChanged(float); - void currentTimeChanged(int); - void fastestTimeChanged(int); - void lastTimeChanged(int); - void currentSpeedChanged(int); - void maxSpeedChanged(int); - void currentChanged(float); - void maxCurrentChanged(float); - void currentDischargeChanged(float); - void maxCurrentDischargeChanged(float); + void tractionControlChanged(bool); + void packTempChanged(float); + void motorTempChanged(float); + void chargeStateChanged(float); + void currentTimeChanged(int); + void fastestTimeChanged(int); + void lastTimeChanged(int); + void currentSpeedChanged(int); + void maxSpeedChanged(int); + void currentChanged(float); + void maxCurrentChanged(float); + void currentDischargeChanged(float); + void maxCurrentDischargeChanged(float); public slots: - void setTractionControl(bool); - void setPackTemp(float); - void setMotorTemp(float); - void setChargeState(float); - void setCurrentTime(int); - void setFastestTime(int); - void setLastTime(int); - void setCurrentSpeed(int); - void setMaxSpeed(int); - void setCurrent(float); - void setMaxCurrent(float); - void setCurrentDischarge(float); - void setMaxCurrentDischarge(float); - - void update(); + void setTractionControl(bool); + void setPackTemp(float); + void setMotorTemp(float); + void setChargeState(float); + void setCurrentTime(int); + void setFastestTime(int); + void setLastTime(int); + void setCurrentSpeed(int); + void setMaxSpeed(int); + void setCurrent(float); + void setMaxCurrent(float); + void setCurrentDischarge(float); + void setMaxCurrentDischarge(float); + + void update(); private: - bool m_tractionControl = false; - float m_packTemp = 0; - float m_motorTemp = 0; - float m_chargeState = 0; - int m_currentTime = 0; - int m_fastestTime = 0; - int m_lastTime = 0; - int m_currentSpeed = 0; - int m_maxSpeed = 0; - float m_current = 0; - float m_maxCurrent = 0; - float m_currentDischarge = 0; - float m_maxCurrentDischarge = 0; - + bool m_tractionControl = false; + float m_packTemp = 0; + float m_motorTemp = 0; + float m_chargeState = 0; + int m_currentTime = 0; + int m_fastestTime = 0; + int m_lastTime = 0; + int m_currentSpeed = 0; + int m_maxSpeed = 0; + float m_current = 0; + float m_maxCurrent = 0; + float m_currentDischarge = 0; + float m_maxCurrentDischarge = 0; }; #endif // SPEEDCONTROLLER_H diff --git a/NERODevelopment/src/models/mock_model.cpp b/NERODevelopment/src/models/mock_model.cpp index 5d78d38..4a5ad49 100644 --- a/NERODevelopment/src/models/mock_model.cpp +++ b/NERODevelopment/src/models/mock_model.cpp @@ -355,6 +355,7 @@ std::optional MockModel::getNumberOfCriticalFaults() { return 1; } std::optional MockModel::getNumberOfNonCriticalFaults() { return 1; } +std::optional MockModel::getTime() { return 0; } void MockModel::sendMessage(QString topic, QString message) { qDebug() << "Sending Message: " << topic << " " << message; } diff --git a/NERODevelopment/src/models/mock_model.h b/NERODevelopment/src/models/mock_model.h index 35a4421..8b0973e 100644 --- a/NERODevelopment/src/models/mock_model.h +++ b/NERODevelopment/src/models/mock_model.h @@ -73,7 +73,7 @@ class MockModel : public Model { std::optional getIsTalking() override; std::optional getNumberOfCriticalFaults() override; std::optional getNumberOfNonCriticalFaults() override; - std::optional getTime() override; + std::optional getTime() override; void sendMessage(const QString topic, const QString message) override; diff --git a/NERODevelopment/src/models/model.cpp b/NERODevelopment/src/models/model.cpp index c1535e6..29216ad 100644 --- a/NERODevelopment/src/models/model.cpp +++ b/NERODevelopment/src/models/model.cpp @@ -13,13 +13,13 @@ void Model::updatePackTempData() { } void Model::addPinnedData(QString id) { - DataInfo value = this->currentData[id]; bool success; - float parsedValue = value.values[0].toFloat(&success); + DataInfo dataInfo = this->currentData.value(id, DataInfo()); + float value = dataInfo.values[0].toFloat(&success); - if (success) { + if (success && value != -9999) { pinnedData.insert( - id, DebugPlotValue(value.topic, value.unit, QList(parsedValue))); + id, DebugPlotValue(dataInfo.topic, dataInfo.unit, QList(value))); } } @@ -45,30 +45,11 @@ void Model::updateAverageCellTemps() { averageCellTemps.append(getAveCellTemp() ? *getAveCellTemp() : 0); } +int Model::getLastTime() { return m_lastTime; } -int Model::getLastTime() { - return m_lastTime; -} - -int Model::getFastestTime() { - return m_fastestTime; -} - -int Model::getMaxSpeed() { - return m_maxSpeed; -} +int Model::getFastestTime() { return m_fastestTime; } - -void Model::updateStateOfChargeDeltas() { - if (stateOfChargeDeltas.size() >= 30) { - stateOfChargeDeltas.pop_front(); - } - std::optional soc = this->getStateOfCharge(); - if (soc) { - stateOfChargeDeltas.append(*soc - prevSoc); - prevSoc = *soc; - } -} +int Model::getMaxSpeed() { return m_maxSpeed; } QList Model::getDebugTableValues() { QList table = {}; diff --git a/NERODevelopment/src/models/model.h b/NERODevelopment/src/models/model.h index 7de69e0..b03be77 100644 --- a/NERODevelopment/src/models/model.h +++ b/NERODevelopment/src/models/model.h @@ -81,8 +81,6 @@ class Model : public QObject { virtual std::optional getTime() = 0; virtual void sendMessage(QString topic, QString message) = 0; - - int getFastestTime(); int getLastTime(); int getMaxSpeed(); @@ -116,7 +114,6 @@ private slots: int m_fastestTime; int m_lastTime; int m_maxSpeed; - }; #define ModelInterfaceId "com.ner.model" diff --git a/NERODevelopment/src/models/raspberry_model.cpp b/NERODevelopment/src/models/raspberry_model.cpp index 47b355f..1b2bdf2 100644 --- a/NERODevelopment/src/models/raspberry_model.cpp +++ b/NERODevelopment/src/models/raspberry_model.cpp @@ -345,7 +345,6 @@ std::optional RaspberryModel::getNumberOfNonCriticalFaults() { return std::nullopt; } - int RaspberryModel::totalNumberOfOnesIn(float value) { int total = 0; std::string binary = std::bitset<8>(static_cast(value)).to_string(); @@ -357,4 +356,8 @@ int RaspberryModel::totalNumberOfOnesIn(float value) { return total; } +std::optional RaspberryModel::getTime() { + return this->getById(CURRENT_TIME); +} + #endif diff --git a/NERODevelopment/src/utils/data_type_names.h b/NERODevelopment/src/utils/data_type_names.h index 74b88aa..58250cd 100644 --- a/NERODevelopment/src/utils/data_type_names.h +++ b/NERODevelopment/src/utils/data_type_names.h @@ -68,7 +68,6 @@ #define MICROPHONE "MICROPHONE" #define FASTESTTIME "FASTESTTIME" #define LASTTIME "LASTTIME" - - +#define CURRENT_TIME "CURRENT_TIME" #endif // DATATYPENAMES_H From 19ddfb7ead0a28433d947f7dea8667fc5ccd5176 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Mon, 8 Apr 2024 21:20:29 -0400 Subject: [PATCH 05/15] #41 Explicitly add widgets --- NERODevelopment/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NERODevelopment/CMakeLists.txt b/NERODevelopment/CMakeLists.txt index 92e6a64..fc5db92 100644 --- a/NERODevelopment/CMakeLists.txt +++ b/NERODevelopment/CMakeLists.txt @@ -68,7 +68,7 @@ set(PROJECT_SOURCES src/controllers/speedcontroller.cpp ) -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick Network Mqtt Protobuf) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick Network Mqtt Protobuf Widgets) qt_add_executable(NEROApp ${PROJECT_SOURCES}) @@ -95,6 +95,7 @@ target_link_libraries(NEROApp PRIVATE Qt6::Mqtt Qt6::Quick Qt6::Protobuf + Qt6::Widgets ) if (BUILD_QDS_COMPONENTS) From a2c1fa12a13dc26b5d3ec49914072eb7e68f0e7e Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Mon, 8 Apr 2024 22:00:14 -0400 Subject: [PATCH 06/15] #41 Only Listen to Button inputs when not showing graph --- NERODevelopment/CMakeLists.txt | 2 ++ NERODevelopment/content/CMakeLists.txt | 1 + NERODevelopment/content/DebugTable.qml | 1 + NERODevelopment/src/controllers/debugtablecontroller.cpp | 8 ++++++++ NERODevelopment/src/models/raspberry_model.cpp | 4 ---- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/NERODevelopment/CMakeLists.txt b/NERODevelopment/CMakeLists.txt index fc5db92..f5bc53f 100644 --- a/NERODevelopment/CMakeLists.txt +++ b/NERODevelopment/CMakeLists.txt @@ -27,6 +27,7 @@ set(PROJECT_SOURCES src/controllers/flappybirdcontroller.h src/controllers/keyboardcontroller.h src/controllers/configurationcontroller.h + src/controllers/debuggraphcontroller.h src/models/mock_model.h src/models/model.h @@ -51,6 +52,7 @@ set(PROJECT_SOURCES src/controllers/flappybirdcontroller.cpp src/controllers/keyboardcontroller.cpp src/controllers/configurationcontroller.cpp + src/controllers/debuggraphcontroller.cpp src/models/mock_model.cpp src/models/model.cpp diff --git a/NERODevelopment/content/CMakeLists.txt b/NERODevelopment/content/CMakeLists.txt index c531bf5..9211ea7 100644 --- a/NERODevelopment/content/CMakeLists.txt +++ b/NERODevelopment/content/CMakeLists.txt @@ -34,6 +34,7 @@ qt6_add_qml_module(content CriticalFaultIcon.qml NonCriticalWarning.qml MicrophoneComponent.qml + DebugGraph.qml RESOURCES fonts/fonts.txt diff --git a/NERODevelopment/content/DebugTable.qml b/NERODevelopment/content/DebugTable.qml index 0181b79..71b30ca 100644 --- a/NERODevelopment/content/DebugTable.qml +++ b/NERODevelopment/content/DebugTable.qml @@ -157,5 +157,6 @@ Item { visible: showGraph chartTitle: values[selectedValueIndex]["name"] yLabel: values[selectedValueIndex]["unit"] + anchors.fill: parent } } diff --git a/NERODevelopment/src/controllers/debugtablecontroller.cpp b/NERODevelopment/src/controllers/debugtablecontroller.cpp index 999e59b..06fb433 100644 --- a/NERODevelopment/src/controllers/debugtablecontroller.cpp +++ b/NERODevelopment/src/controllers/debugtablecontroller.cpp @@ -73,6 +73,8 @@ void DebugTableController::enterButtonPressed() { } void DebugTableController::downButtonPressed() { + if (this->m_showGraph) + return; qDebug() << "pressed down arrow" << m_selectedTopicsIndex << m_scrollingTopics << this->m_topics.length() << m_selectedValues.length() << m_selectedValuesIndex; @@ -89,6 +91,8 @@ void DebugTableController::downButtonPressed() { } void DebugTableController::upButtonPressed() { + if (this->m_showGraph) + return; if (this->m_scrollingTopics) { if (this->m_selectedTopicsIndex != 0) { this->setSelectedTopicsIndex(this->m_selectedTopicsIndex - 1); @@ -102,10 +106,14 @@ void DebugTableController::upButtonPressed() { } void DebugTableController::leftButtonPressed() { + if (this->m_showGraph) + return; this->setScrollingTopics(true); } void DebugTableController::rightButtonPressed() { + if (this->m_showGraph) + return; this->setScrollingTopics(false); } diff --git a/NERODevelopment/src/models/raspberry_model.cpp b/NERODevelopment/src/models/raspberry_model.cpp index 661e6f8..1cac196 100644 --- a/NERODevelopment/src/models/raspberry_model.cpp +++ b/NERODevelopment/src/models/raspberry_model.cpp @@ -364,8 +364,4 @@ int RaspberryModel::totalNumberOfOnesIn(float value) { return total; } -std::optional RaspberryModel::getTime() { - return this->getById(CURRENT_TIME); -} - #endif From 8383498a53f3d2349fd86658960fd3c8f355c8cf Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Mon, 8 Apr 2024 22:11:42 -0400 Subject: [PATCH 07/15] #41 Fix Timer --- NERODevelopment/src/controllers/debuggraphcontroller.cpp | 5 ++--- NERODevelopment/src/controllers/debuggraphcontroller.h | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.cpp b/NERODevelopment/src/controllers/debuggraphcontroller.cpp index c31a722..57bcbb7 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.cpp +++ b/NERODevelopment/src/controllers/debuggraphcontroller.cpp @@ -6,8 +6,6 @@ DebugGraphController::DebugGraphController(Model *model, QObject *parent) &DebugGraphController::update); } -DebugGraphController::~DebugGraphController() { m_dataUpdateTimer.stop(); } - QList DebugGraphController::graphData() const { return this->m_graphData; } @@ -56,13 +54,14 @@ void DebugGraphController::setValues(QString title, QString unit) { } void DebugGraphController::update() { - this->m_model->updatePinnedData(); if (QDateTime::currentMSecsSinceEpoch() - this->m_last_refresh < this->m_refresh_rate) { return; } + this->m_model->updatePinnedData(); + this->m_last_refresh = QDateTime::currentMSecsSinceEpoch(); QList allPoints; diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.h b/NERODevelopment/src/controllers/debuggraphcontroller.h index d6ea98b..878573d 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.h +++ b/NERODevelopment/src/controllers/debuggraphcontroller.h @@ -18,7 +18,6 @@ class DebugGraphController : public ButtonController { public: explicit DebugGraphController(Model *model, QObject *parent = nullptr); - ~DebugGraphController(); QList graphData() const; QString unit() const; QString title() const; @@ -48,7 +47,6 @@ public slots: QString m_title = "AVERAGE CELL TEMPERATURE"; int m_maxY = 60; int m_minY = 0; - QTimer m_dataUpdateTimer; qint64 m_last_refresh = 0; int m_refresh_rate = 500; int m_num_points = 21; From acf05abeb6ef40a19719bacbb59d8d866ccc67fd Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Mon, 8 Apr 2024 22:20:50 -0400 Subject: [PATCH 08/15] #41 Set Correct Page Index --- .../src/controllers/debuggraphcontroller.cpp | 11 ++++++++--- .../src/controllers/efficiencycontroller.h | 14 +++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.cpp b/NERODevelopment/src/controllers/debuggraphcontroller.cpp index 57bcbb7..d9a20fb 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.cpp +++ b/NERODevelopment/src/controllers/debuggraphcontroller.cpp @@ -1,7 +1,7 @@ #include "debuggraphcontroller.h" DebugGraphController::DebugGraphController(Model *model, QObject *parent) - : ButtonController(model, 7, parent) { + : ButtonController(model, 3, parent) { connect(model, &Model::onCurrentDataChange, this, &DebugGraphController::update); } @@ -55,14 +55,19 @@ void DebugGraphController::setValues(QString title, QString unit) { void DebugGraphController::update() { + qDebug() << this->m_pageIndex << this->m_model->currentPageIndex; + 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(); + qDebug() << "updating"; - this->m_last_refresh = QDateTime::currentMSecsSinceEpoch(); + this->m_model->updatePinnedData(); QList allPoints; QMap pinnedData = this->m_model->getPinnedData(); diff --git a/NERODevelopment/src/controllers/efficiencycontroller.h b/NERODevelopment/src/controllers/efficiencycontroller.h index edde72d..3c9cf2a 100644 --- a/NERODevelopment/src/controllers/efficiencycontroller.h +++ b/NERODevelopment/src/controllers/efficiencycontroller.h @@ -56,13 +56,13 @@ public slots: void currentDataDidChange(); private: - int m_currentMaxTorque; // torque percentage [0,100] - int m_currentRegenStrength; // regen strength [1,3] - int m_stateOfCharge; // charge percentage [0,100] - int m_motorTemp; // Celsius - int m_packTemp; // Celsius - int m_lowVoltageStateOfCharge; // charge percentage [0,100] - int m_speed; // speed in mph + int m_currentMaxTorque = 0; // torque percentage [0,100] + int m_currentRegenStrength = 0; // regen strength [1,3] + int m_stateOfCharge = 0; // charge percentage [0,100] + int m_motorTemp = 0; // Celsius + int m_packTemp = 0; // Celsius + int m_lowVoltageStateOfCharge = 0; // charge percentage [0,100] + int m_speed = 0; // speed in mph }; #endif // EFFICIENCYCONTROLLER_H From b8a5d9fdbc13ed539fb6696096378951175c18e3 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Mon, 8 Apr 2024 22:42:08 -0400 Subject: [PATCH 09/15] #41 Fix Pinned Data Interpretatoin --- .../src/controllers/debuggraphcontroller.cpp | 34 +++++++++---------- .../src/controllers/debugtablecontroller.h | 1 - .../src/modes/debug_mode/debug_utils.cpp | 2 ++ .../src/modes/debug_mode/debug_utils.h | 2 ++ 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.cpp b/NERODevelopment/src/controllers/debuggraphcontroller.cpp index d9a20fb..2b95ee1 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.cpp +++ b/NERODevelopment/src/controllers/debuggraphcontroller.cpp @@ -30,8 +30,13 @@ void DebugGraphController::setGraphData(QList json) { 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) { @@ -54,8 +59,6 @@ void DebugGraphController::setValues(QString title, QString unit) { } void DebugGraphController::update() { - - qDebug() << this->m_pageIndex << this->m_model->currentPageIndex; if (this->m_model->currentPageIndex != this->m_pageIndex) return; @@ -72,21 +75,18 @@ void DebugGraphController::update() { QList allPoints; QMap pinnedData = this->m_model->getPinnedData(); - int globalIndex = 0; - - auto iter = pinnedData.constBegin(); - while (iter != pinnedData.constEnd()) { - const QList &dataList = iter.value().data; - for (int i = 0; i < this->m_num_points; ++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 globalIndex = this->m_num_points - 1; + + const QList &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); } - ++iter; } int maxY = 0; @@ -105,7 +105,5 @@ void DebugGraphController::update() { setMaxY(maxY * 1.1); setMinY(minY); - std::reverse(allPoints.begin(), allPoints.end()); - setGraphData(allPoints); } diff --git a/NERODevelopment/src/controllers/debugtablecontroller.h b/NERODevelopment/src/controllers/debugtablecontroller.h index f440c0b..954d56e 100644 --- a/NERODevelopment/src/controllers/debugtablecontroller.h +++ b/NERODevelopment/src/controllers/debugtablecontroller.h @@ -3,7 +3,6 @@ #include "QtCore/qvariant.h" #include "buttoncontroller.h" -#include "src/controllers/navigationcontroller.h" #include "src/models/model.h" #include diff --git a/NERODevelopment/src/modes/debug_mode/debug_utils.cpp b/NERODevelopment/src/modes/debug_mode/debug_utils.cpp index 2def07a..5854333 100644 --- a/NERODevelopment/src/modes/debug_mode/debug_utils.cpp +++ b/NERODevelopment/src/modes/debug_mode/debug_utils.cpp @@ -7,6 +7,8 @@ DebugPlotValue::DebugPlotValue(const QString &name, const QString &unit, // Constructor implementation } +DebugPlotValue::DebugPlotValue() : data(), name(""), unit("") {} + FaultInstance::FaultInstance(int fault_decimal, int max_cell_temp, int max_cell_voltage, int average_cell_temp, int average_cell_voltage, int min_cell_temp, diff --git a/NERODevelopment/src/modes/debug_mode/debug_utils.h b/NERODevelopment/src/modes/debug_mode/debug_utils.h index afe08ca..9355d2e 100644 --- a/NERODevelopment/src/modes/debug_mode/debug_utils.h +++ b/NERODevelopment/src/modes/debug_mode/debug_utils.h @@ -65,6 +65,8 @@ struct DebugPlotValue { public: DebugPlotValue(const QString &name, const QString &unit, const QList &data); + + DebugPlotValue(); QList data; QString name; QString unit; From aa36c1ba60a42a3b5fd802038b3e10b1ac589c79 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Mon, 8 Apr 2024 22:52:36 -0400 Subject: [PATCH 10/15] #41 Make min and max kind of work --- NERODevelopment/content/DebugGraph.qml | 10 +++++----- .../src/controllers/debuggraphcontroller.cpp | 6 ++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/NERODevelopment/content/DebugGraph.qml b/NERODevelopment/content/DebugGraph.qml index 3b5cd7e..7d2ec55 100644 --- a/NERODevelopment/content/DebugGraph.qml +++ b/NERODevelopment/content/DebugGraph.qml @@ -21,11 +21,11 @@ Item { property var dummyData: debugGraphController.graphData onDummyDataChanged: { - series.clear(); + series.clear() } onVisibleChanged: { - debugGraphController.setTitle(chartTitle); + debugGraphController.setTitle(chartTitle) } ChartView { anchors.fill: parent @@ -42,7 +42,7 @@ Item { color: "white" labelsColor: "white" titleText: "" + chartItem.xLabel + "" - tickCount: chartItem.maxX + 1 + tickCount: chartItem.maxX - chartItem.minX + 1 labelFormat: "%d" } @@ -54,7 +54,7 @@ Item { labelsColor: "white" color: "white" titleText: "" + chartItem.yLabel + "" - tickCount: chartItem.maxY / 5 + 1 + tickCount: chartItem.maxY - chartItem.minY + 1 labelFormat: "%d" } @@ -71,7 +71,7 @@ Item { model: dummyData delegate: Item { Component.onCompleted: { - series.append(modelData.x, modelData.y); + series.append(modelData.x, modelData.y) } } } diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.cpp b/NERODevelopment/src/controllers/debuggraphcontroller.cpp index 2b95ee1..f03d875 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.cpp +++ b/NERODevelopment/src/controllers/debuggraphcontroller.cpp @@ -68,8 +68,6 @@ void DebugGraphController::update() { } this->m_last_refresh = QDateTime::currentMSecsSinceEpoch(); - qDebug() << "updating"; - this->m_model->updatePinnedData(); QList allPoints; @@ -89,8 +87,8 @@ void DebugGraphController::update() { } } - int maxY = 0; - int minY = 0; + int maxY = -99999; + int minY = 99999; for (const QJsonObject &point : allPoints) { int yValue = point["y"].toInt(); From b914d3b2fb2f5e5b0b4790d31e91f151486a872f Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Mon, 8 Apr 2024 22:53:47 -0400 Subject: [PATCH 11/15] #41 Set Exit To 6th Index --- NERODevelopment/content/NavigationController.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NERODevelopment/content/NavigationController.qml b/NERODevelopment/content/NavigationController.qml index 88c3ecc..5cd0227 100644 --- a/NERODevelopment/content/NavigationController.qml +++ b/NERODevelopment/content/NavigationController.qml @@ -77,7 +77,7 @@ Item { } HomeMenuItem { - highlighted: selectedPageIndex === 5 + highlighted: selectedPageIndex === 6 text: "Exit" } } From 50131e52811e04e46d0303cfca1ed95528a1a63d Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Mon, 8 Apr 2024 23:09:06 -0400 Subject: [PATCH 12/15] #41 Set Reasonable Tick Count --- NERODevelopment/content/DebugGraph.qml | 5 +++-- NERODevelopment/src/controllers/debuggraphcontroller.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NERODevelopment/content/DebugGraph.qml b/NERODevelopment/content/DebugGraph.qml index 7d2ec55..e859257 100644 --- a/NERODevelopment/content/DebugGraph.qml +++ b/NERODevelopment/content/DebugGraph.qml @@ -11,7 +11,7 @@ Item { property string chartTitle: "" property int minX: 0 - property int maxX: 20 + property int maxX: debugGraphController.graphData.length property string xLabel: "TIME (MS)" property int minY: debugGraphController.minY @@ -21,6 +21,7 @@ Item { property var dummyData: debugGraphController.graphData onDummyDataChanged: { + console.log(maxX) series.clear() } @@ -54,7 +55,7 @@ Item { labelsColor: "white" color: "white" titleText: "" + chartItem.yLabel + "" - tickCount: chartItem.maxY - chartItem.minY + 1 + tickCount: 5 labelFormat: "%d" } diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.cpp b/NERODevelopment/src/controllers/debuggraphcontroller.cpp index f03d875..cbc5fdc 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.cpp +++ b/NERODevelopment/src/controllers/debuggraphcontroller.cpp @@ -76,6 +76,7 @@ void DebugGraphController::update() { int globalIndex = this->m_num_points - 1; const QList &dataList = pinnedData[this->m_title].data; + qDebug() << dataList.length(); for (int i = 0; i < std::min(this->m_num_points, (int)dataList.length()); ++i) { float value = dataList.at(i); @@ -100,8 +101,8 @@ void DebugGraphController::update() { } } - setMaxY(maxY * 1.1); - setMinY(minY); + setMaxY(maxY + 5); + setMinY(minY - 5); setGraphData(allPoints); } From 9d11c3158a4f3dbe3d79eca2547692e72e29f2d5 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 10 Apr 2024 14:17:30 -0400 Subject: [PATCH 13/15] #41 Update Number of pages --- NERODevelopment/src/controllers/navigationcontroller.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NERODevelopment/src/controllers/navigationcontroller.h b/NERODevelopment/src/controllers/navigationcontroller.h index a8f9ce1..803cc0b 100644 --- a/NERODevelopment/src/controllers/navigationcontroller.h +++ b/NERODevelopment/src/controllers/navigationcontroller.h @@ -33,7 +33,7 @@ public slots: private: bool m_isSelected = false; int m_selectedPageIndex = 0; - int m_numPages = 6; + int m_numPages = 7; }; #endif // NAVIGATIONCONTROLLER_H From f1ca80e26b0406d5fe9927fd69c8bb171172a944 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 10 Apr 2024 14:41:53 -0400 Subject: [PATCH 14/15] #41 Only Show Name after topic --- NERODevelopment/content/DebugTable.qml | 7 +++---- .../src/controllers/debuggraphcontroller.cpp | 2 +- .../src/controllers/debugtablecontroller.cpp | 7 +------ .../src/modes/debug_mode/debug_utils.cpp | 17 ++++++++++++++++- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/NERODevelopment/content/DebugTable.qml b/NERODevelopment/content/DebugTable.qml index 71b30ca..6f4bf79 100644 --- a/NERODevelopment/content/DebugTable.qml +++ b/NERODevelopment/content/DebugTable.qml @@ -18,7 +18,6 @@ Item { property int rowHeight: 30 Keys.onPressed: event => { - console.log(event.key, Qt.Key_Enter) switch (event.key) { case Qt.Key_Up: debugTableController.upButtonPressed() @@ -144,8 +143,8 @@ Item { } } - property var columnWidths: [valuesTableView.width * 3 - / 4, valuesTableView.width / 8, valuesTableView.width / 8] + property var columnWidths: [valuesTableView.width + / 2, valuesTableView.width / 4, valuesTableView.width / 4] columnWidthProvider: function (column) { return columnWidths[column] } @@ -155,7 +154,7 @@ Item { DebugGraph { visible: showGraph - chartTitle: values[selectedValueIndex]["name"] + chartTitle: values[selectedValueIndex]["id"] yLabel: values[selectedValueIndex]["unit"] anchors.fill: parent } diff --git a/NERODevelopment/src/controllers/debuggraphcontroller.cpp b/NERODevelopment/src/controllers/debuggraphcontroller.cpp index cbc5fdc..e86dfe7 100644 --- a/NERODevelopment/src/controllers/debuggraphcontroller.cpp +++ b/NERODevelopment/src/controllers/debuggraphcontroller.cpp @@ -76,7 +76,7 @@ void DebugGraphController::update() { int globalIndex = this->m_num_points - 1; const QList &dataList = pinnedData[this->m_title].data; - qDebug() << dataList.length(); + for (int i = 0; i < std::min(this->m_num_points, (int)dataList.length()); ++i) { float value = dataList.at(i); diff --git a/NERODevelopment/src/controllers/debugtablecontroller.cpp b/NERODevelopment/src/controllers/debugtablecontroller.cpp index 4ee62d9..d638a78 100644 --- a/NERODevelopment/src/controllers/debugtablecontroller.cpp +++ b/NERODevelopment/src/controllers/debugtablecontroller.cpp @@ -75,9 +75,6 @@ void DebugTableController::enterButtonPressed() { void DebugTableController::downButtonPressed() { if (this->m_showGraph) return; - qDebug() << "pressed down arrow" << m_selectedTopicsIndex << m_scrollingTopics - << this->m_topics.length() << m_selectedValues.length() - << m_selectedValuesIndex; if (this->m_scrollingTopics) { if (this->m_selectedTopicsIndex < this->m_topics.length() - 1) { this->setSelectedTopicsIndex(this->m_selectedTopicsIndex + 1); @@ -126,9 +123,7 @@ void DebugTableController::update() { return; } this->m_last_refresh = QDateTime::currentMSecsSinceEpoch(); - // qDebug() << "updating debug table" - // << this->m_last_refresh + this->m_refresh_rate - // << QDateTime::currentMSecsSinceEpoch(); + QSet topicsSet = {}; QList topics = {}; QList rows = this->m_model->getDebugTableValues(); diff --git a/NERODevelopment/src/modes/debug_mode/debug_utils.cpp b/NERODevelopment/src/modes/debug_mode/debug_utils.cpp index 5854333..58cf6cc 100644 --- a/NERODevelopment/src/modes/debug_mode/debug_utils.cpp +++ b/NERODevelopment/src/modes/debug_mode/debug_utils.cpp @@ -45,9 +45,24 @@ QString DebugTableRowValue::unit() const { return m_unit; } QJsonObject DebugTableRowValue::json() const { QJsonObject object; - object["name"] = this->m_name; + /* Get the name after the first two / */ + QList split = this->m_name.split("/"); + QString name = ""; + if (split.length() > 2) { + for (int i = 2; i < split.length(); i++) { + name += split[i]; + if (i != split.length() - 1) { + name += "/"; + } + } + } else { + name = this->m_name; + } + + object["name"] = name; object["value"] = this->m_value; object["unit"] = this->m_unit; + object["id"] = this->m_name; return object; } From 7c6a8b33cfa6e7f81af8be141751b26f2afc8ee1 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Wed, 10 Apr 2024 14:42:35 -0400 Subject: [PATCH 15/15] #41 Fill Parent Debug Table --- NERODevelopment/content/DebugTable.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NERODevelopment/content/DebugTable.qml b/NERODevelopment/content/DebugTable.qml index 6f4bf79..a386393 100644 --- a/NERODevelopment/content/DebugTable.qml +++ b/NERODevelopment/content/DebugTable.qml @@ -5,8 +5,7 @@ import NERO Item { id: debugTable - width: 800 - height: 480 + anchors.fill: parent property variant topics: debugTableController.topics property variant values: debugTableController.selectedValues