configurable hold-last-look

This commit is contained in:
Kevin Matz 2021-09-10 16:26:31 -04:00
parent 7039696807
commit abbfe6ee0d
5 changed files with 67 additions and 3 deletions

View File

@ -70,6 +70,7 @@
<string>sACN</string> <string>sACN</string>
</property> </property>
<addaction name="actionDiscovery"/> <addaction name="actionDiscovery"/>
<addaction name="actionHold_Last_Look"/>
</widget> </widget>
<addaction name="menuNetwork"/> <addaction name="menuNetwork"/>
<addaction name="menuEPI_19"/> <addaction name="menuEPI_19"/>
@ -226,6 +227,23 @@
<string>Ctrl+D</string> <string>Ctrl+D</string>
</property> </property>
</action> </action>
<action name="actionHold_Last_Look">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Hold Last Look</string>
</property>
<property name="toolTip">
<string>Retain at least 1 inacitve source.</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -32,6 +32,7 @@ namespace sACN {
ArbitratingUniverse::ArbitratingUniverse() ArbitratingUniverse::ArbitratingUniverse()
: sACN::Universe() : sACN::Universe()
, expectedUniverse(0) , expectedUniverse(0)
, HoldLastLook(true)
{ {
} }
@ -44,6 +45,26 @@ ArbitratingUniverse::~ArbitratingUniverse()
} }
/**
* @brief ArbitratingUniverse::setHoldLastLook
* @param state
*/
void ArbitratingUniverse::setHoldLastLook(const bool state)
{
HoldLastLook = state;
}
/**
* @brief ArbitratingUniverse::getHoldLastLook
* @return
*/
bool ArbitratingUniverse::getHoldLastLook() const
{
return HoldLastLook;
}
const std::vector<DATA::data_header> ArbitratingUniverse::sources() const const std::vector<DATA::data_header> ArbitratingUniverse::sources() const
{ {
std::vector<DATA::data_header> keys; std::vector<DATA::data_header> keys;
@ -246,8 +267,8 @@ std::shared_ptr<Universe> ArbitratingUniverse::dominant_()
{ {
auto universe = it->second; auto universe = it->second;
if (!ret) if (!ret && HoldLastLook)
{ // anything is better than nothing! { // anything is better than nothing
++it; ++it;
ret = universe; ret = universe;
continue; continue;

View File

@ -61,6 +61,9 @@ public:
uint16_t expectedUniverse; ///< Expected universe number uint16_t expectedUniverse; ///< Expected universe number
void setHoldLastLook(const bool);
bool getHoldLastLook() const;
// Source universes: // Source universes:
void deleteSourceUniverse(const DATA::data_header&); void deleteSourceUniverse(const DATA::data_header&);
void dataChangedNotifier(DMX::Universe* universe); void dataChangedNotifier(DMX::Universe* universe);
@ -91,6 +94,7 @@ public:
private: private:
std::unordered_map<DATA::data_header, std::shared_ptr<Universe>> sources_; std::unordered_map<DATA::data_header, std::shared_ptr<Universe>> sources_;
std::vector<std::function<void()>> cb_sourceListChange; //!< list of calback functions std::vector<std::function<void()>> cb_sourceListChange; //!< list of calback functions
bool HoldLastLook;
std::shared_ptr<Universe> dominant_(); std::shared_ptr<Universe> dominant_();
bool hasSourceUniverse(const DATA::data_header&) const; bool hasSourceUniverse(const DATA::data_header&) const;

View File

@ -36,6 +36,7 @@ namespace sACN {
*/ */
Receiver::Receiver(UUID::uuid cid) Receiver::Receiver(UUID::uuid cid)
: Component(cid) : Component(cid)
, HoldLastLook(true)
{ {
fctn_ = "OpenLCP sACN Receiver"; fctn_ = "OpenLCP sACN Receiver";
@ -56,6 +57,18 @@ Receiver::~Receiver()
} }
/**
* @brief Receiver::setHoldLastLook
* @param state
*/
void Receiver::setHoldLastLook(const bool state)
{
HoldLastLook = state;
for (const auto & [_, universe] : universes_)
universe->setHoldLastLook(state);
}
/** /**
* @brief Receiver::subscribe * @brief Receiver::subscribe
* @param num * @param num
@ -66,6 +79,7 @@ void Receiver::subscribe(const uint16_t num)
return; return;
universes_.emplace(num, std::make_shared<ArbitratingUniverse>()); universes_.emplace(num, std::make_shared<ArbitratingUniverse>());
universes_.at(num)->expectedUniverse = num; universes_.at(num)->expectedUniverse = num;
universes_.at(num)->setHoldLastLook(HoldLastLook);
} }
@ -222,7 +236,11 @@ void Receiver::dataFrameHandler(ACN::PDU::Message<DATA::Pdu> frame) {
/// > Any property values in an E1.31 Data Packet containing this bit /// > Any property values in an E1.31 Data Packet containing this bit
/// > shall be ignored. /// > shall be ignored.
if (source->options.stream_terminated) if (source->options.stream_terminated)
return universes_[source->universe]->deleteSourceUniverse(*source); {
auto universe = universes_.at(source->universe);
if (universe->sources().size() > 1 || !HoldLastLook)
return universes_[source->universe]->deleteSourceUniverse(*source);
}
/// > \cite sACN 6.2.4.1 Synchronization Address Usage in an E1.31 Data Packet /// > \cite sACN 6.2.4.1 Synchronization Address Usage in an E1.31 Data Packet
/// > /// >

View File

@ -69,6 +69,8 @@ public:
Receiver(UUID::uuid = UUID::uuid()); Receiver(UUID::uuid = UUID::uuid());
~Receiver(); ~Receiver();
void setHoldLastLook(const bool);
virtual void subscribe(const uint16_t); virtual void subscribe(const uint16_t);
virtual void unsubscribe(const uint16_t); virtual void unsubscribe(const uint16_t);
std::shared_ptr<Universe> universe(const uint16_t); std::shared_ptr<Universe> universe(const uint16_t);
@ -98,6 +100,7 @@ protected:
private: private:
std::unordered_map<uint16_t, std::shared_ptr<ArbitratingUniverse>> universes_; std::unordered_map<uint16_t, std::shared_ptr<ArbitratingUniverse>> universes_;
std::vector<std::function<void()>> discoveryCallbacks_; std::vector<std::function<void()>> discoveryCallbacks_;
bool HoldLastLook;
}; };
}; };