move discovery state tracking form platform driver to protocol receiver
This commit is contained in:
parent
2003e22110
commit
99d919d613
|
@ -20,7 +20,7 @@ MultiverseView::MultiverseView(QWidget *parent, QSacnNode *node)
|
|||
ui->actionTerminate->setEnabled(false);
|
||||
ui->actionUnsubscribe->setEnabled(false);
|
||||
ui->actionInspect->setEnabled(false);
|
||||
ui->actionDiscovery->setChecked(node->isDiscovering());
|
||||
ui->actionDiscovery->setChecked(node->discoveryEnabled());
|
||||
|
||||
sortProxy->setSourceModel(model);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ void SacnExplorer::saveSettings()
|
|||
settings_->endGroup();
|
||||
settings_->beginGroup("sACN");
|
||||
settings_->beginGroup("receiver");
|
||||
settings_->setValue("discovery", node_->isDiscovering());
|
||||
settings_->setValue("discovery", node_->discoveryEnabled());
|
||||
settings_->endGroup();
|
||||
settings_->endGroup();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
QSacnNode::QSacnNode(QObject *parent, QUuid cid, QString fctn)
|
||||
: Component(UUID::uuid(cid.toString().toStdString()), fctn.toStdString())
|
||||
, QUdpSocket(parent)
|
||||
, is_discovering_(false)
|
||||
{
|
||||
bind(QHostAddress::AnyIPv4, sACN::ACN_SDT_MULTICAST_PORT);
|
||||
|
||||
|
@ -31,7 +30,7 @@ QSacnNode::QSacnNode(QObject *parent, QUuid cid, QString fctn)
|
|||
*/
|
||||
QSacnNode::~QSacnNode()
|
||||
{
|
||||
if (is_discovering_)
|
||||
if (Receiver::discoveryEnabled())
|
||||
QSacnNode::unsubscribe(sACN::E131_DISCOVERY_UNIVERSE);
|
||||
|
||||
auto rx_list = rx_universes.keys();
|
||||
|
@ -56,10 +55,9 @@ void QSacnNode::subscribe(const uint16_t num)
|
|||
switch (num) {
|
||||
case sACN::E131_DISCOVERY_UNIVERSE:
|
||||
{
|
||||
if (is_discovering_)
|
||||
if (discoveryEnabled())
|
||||
return;
|
||||
qDebug() << "Enabling sACN Discovery";
|
||||
is_discovering_ = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -90,10 +88,9 @@ void QSacnNode::unsubscribe(const uint16_t num)
|
|||
switch (num) {
|
||||
case sACN::E131_DISCOVERY_UNIVERSE:
|
||||
{
|
||||
if (!is_discovering_)
|
||||
if (!discoveryEnabled())
|
||||
return;
|
||||
qDebug() << "Disabling sACN Discovery";
|
||||
is_discovering_ = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -30,12 +30,6 @@ public:
|
|||
QSacnUniverse* universe(const uint16_t u);
|
||||
QSacnUniverse* source(const uint16_t u);
|
||||
|
||||
/**
|
||||
* @brief isDiscovering
|
||||
* @return
|
||||
*/
|
||||
bool isDiscovering() const {return is_discovering_;}
|
||||
|
||||
public slots:
|
||||
void subscribe(const uint16_t) override;
|
||||
void unsubscribe(const uint16_t) override;
|
||||
|
@ -55,8 +49,6 @@ private:
|
|||
QHash<uint16_t, QSacnUniverse*> rx_universes;
|
||||
QHash<uint16_t, QSacnUniverse*> tx_universes;
|
||||
|
||||
bool is_discovering_;
|
||||
|
||||
public:
|
||||
/// \cite sACN 9.3.1 Allocation of IPv4 Multicast Addresses
|
||||
///
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace sACN {
|
|||
*/
|
||||
Receiver::Receiver(UUID::uuid cid, std::string fctn)
|
||||
: Component(cid, fctn)
|
||||
, discovery_enabled_(false)
|
||||
, HoldLastLook(true)
|
||||
{
|
||||
RlpRegisterVector(VECTOR_ROOT_E131_DATA, std::bind(&Receiver::dataReceiver,
|
||||
|
@ -121,6 +122,7 @@ std::shared_ptr<Universe> Receiver::universe(const uint16_t num) const
|
|||
void Receiver::discoveryStart()
|
||||
{
|
||||
subscribe(sACN::E131_DISCOVERY_UNIVERSE);
|
||||
discovery_enabled_ = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -130,6 +132,7 @@ void Receiver::discoveryStart()
|
|||
void Receiver::discoveryStop()
|
||||
{
|
||||
unsubscribe(sACN::E131_DISCOVERY_UNIVERSE);
|
||||
discovery_enabled_ = false;
|
||||
discovered.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
virtual void unsubscribe(const uint16_t);
|
||||
std::shared_ptr<Universe> universe(const uint16_t) const;
|
||||
|
||||
bool discoveryEnabled() const {return discovery_enabled_;} //!< @brief is discovery enabled @return
|
||||
void discoveryStart();
|
||||
void discoveryStop();
|
||||
void onDiscovered(const std::function<void()>);
|
||||
|
@ -100,6 +101,7 @@ protected:
|
|||
private:
|
||||
std::unordered_map<uint16_t, std::shared_ptr<ArbitratingUniverse>> universes_;
|
||||
std::vector<std::function<void()>> discoveryCallbacks_;
|
||||
bool discovery_enabled_;
|
||||
bool HoldLastLook;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue