1
0
Fork 0

add a watchdog to keep the universe status updated

This commit is contained in:
Kevin Matz 2022-12-02 16:35:27 -05:00
parent 3135c0ae6c
commit 37010fa8d4
2 changed files with 15 additions and 0 deletions

View File

@ -8,6 +8,7 @@
QSacnUniverse::QSacnUniverse(QObject *parent, std::shared_ptr<sACN::Universe> universe)
: QObject(parent)
, universe_(universe)
, status_watchdog_(new QTimer(this))
{
if (!universe)
return;
@ -17,6 +18,17 @@ QSacnUniverse::QSacnUniverse(QObject *parent, std::shared_ptr<sACN::Universe> un
if (!universe->isEditable())
list_change_token = universe_->onSourceListChange([this](){syncSources();});
// set the status watchdog to update the status if the universe
// isn't showing frequent activity
connect(status_watchdog_, &QTimer::timeout,
this, [this](){universe_->status();});
status_watchdog_->setInterval(DMX::E111_DATA_LOSS_TIMEOUT);
status_watchdog_->start();
connect(this, &QSacnUniverse::dataChanged,
this, [this](){status_watchdog_->start();});
connect(this, &QSacnUniverse::statusChanged,
this, [this](){status_watchdog_->start();});
};

View File

@ -3,6 +3,7 @@
#include <QObject>
#include <QList>
#include <QMap>
#include <QTimer>
#include "qsacn_global.h"
#include "universe.h"
@ -54,5 +55,7 @@ private:
std::shared_ptr<void> data_change_token;
std::shared_ptr<void> list_change_token;
std::shared_ptr<void> status_change_token;
QTimer *status_watchdog_;
};
Q_DECLARE_METATYPE(QSacnUniverse*)