This commit is contained in:
Alex Spataru 2021-02-08 11:02:00 -05:00
parent e9696a06cb
commit 8dcd401531
4 changed files with 10 additions and 28 deletions

View File

@ -63,22 +63,20 @@ GraphProvider::GraphProvider()
qRegisterMetaType<QAbstractAxis *>();
qRegisterMetaType<QAbstractSeries *>();
// Update graph values as soon as JSON manager reads data
// Module signals/slots
auto cp = CSV::Player::getInstance();
auto io = IO::Manager::getInstance();
auto co = IO::Console::getInstance();
auto ge = JSON::Generator::getInstance();
connect(cp, SIGNAL(openChanged()), this, SLOT(resetData()));
connect(ge, SIGNAL(jsonChanged()), this, SLOT(updateValues()));
connect(io, SIGNAL(connectedChanged()), this, SLOT(resetData()));
connect(co, SIGNAL(enabledChanged()), this, SLOT(updateValues()));
// Avoid issues when CSV player goes backwards
connect(CSV::Player::getInstance(), SIGNAL(timestampChanged()),
this, SLOT(csvPlayerFixes()));
// Update user interface at a frequency of ~40 Hz
m_timer.setInterval(1000 / 40);
m_timer.setTimerType(Qt::PreciseTimer);
connect(&m_timer, &QTimer::timeout, this, &GraphProvider::updateValues);
m_timer.start();
// clang-format on
LOG_TRACE() << "Class initialized";
}
@ -211,11 +209,6 @@ void GraphProvider::updateValues()
if (IO::Console::getInstance()->enabled())
return;
// Abort if not connected to device or reproducing CSV file
if (!IO::Manager::getInstance()->connected()
&& !CSV::Player::getInstance()->isPlaying())
return;
// Clear dataset & latest values list
m_datasets.clear();

View File

@ -23,7 +23,6 @@
#ifndef GRAPH_PROVIDER_H
#define GRAPH_PROVIDER_H
#include <QTimer>
#include <QVector>
#include <QObject>
#include <QVector>
@ -80,7 +79,6 @@ private slots:
void csvPlayerFixes();
private:
QTimer m_timer;
int m_prevFramePos;
int m_displayedPoints;
QVector<double> m_maximumValues;

View File

@ -43,17 +43,15 @@ static WidgetProvider *INSTANCE = Q_NULLPTR;
*/
WidgetProvider::WidgetProvider()
{
// React to open/close of devices & files
// Module signals/slots
auto cp = CSV::Player::getInstance();
auto io = IO::Manager::getInstance();
auto co = IO::Console::getInstance();
auto ge = JSON::Generator::getInstance();
connect(cp, SIGNAL(openChanged()), this, SLOT(resetData()));
connect(ge, SIGNAL(jsonChanged()), this, SLOT(updateModels()));
connect(io, SIGNAL(connectedChanged()), this, SLOT(resetData()));
// Update user interface at a frequency of ~40 Hz
m_timer.setInterval(1000 / 40);
m_timer.setTimerType(Qt::PreciseTimer);
connect(&m_timer, &QTimer::timeout, this, &WidgetProvider::updateModels);
m_timer.start();
connect(co, SIGNAL(enabledChanged()), this, SLOT(updateModels()));
// Look like a pro
LOG_TRACE() << "Class initialized";
@ -416,11 +414,6 @@ void WidgetProvider::updateModels()
if (IO::Console::getInstance()->enabled())
return;
// Abort if not connected to device or reproducing CSV file
if (!IO::Manager::getInstance()->connected()
&& !CSV::Player::getInstance()->isPlaying())
return;
// Clear current groups
m_barDatasets.clear();
m_mapGroups.clear();

View File

@ -24,7 +24,6 @@
#define WIDGETPROVIDER_H
#include <QList>
#include <QTimer>
#include <QObject>
#include <JSON/Frame.h>
@ -88,7 +87,6 @@ private:
QList<JSON::Dataset *> getWidgetDatasets(const QString &handle);
private:
QTimer m_timer;
QList<JSON::Group *> m_mapGroups;
QList<JSON::Group *> m_gyroGroups;
QList<JSON::Dataset *> m_barDatasets;