add a watchdog to keep the universe status updated
This commit is contained in:
parent
3135c0ae6c
commit
37010fa8d4
|
@ -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();});
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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*)
|
||||
|
|
Loading…
Reference in New Issue