more of making thing constant
This commit is contained in:
parent
52758cc904
commit
dbcde09616
|
@ -44,7 +44,7 @@ Universe::Universe(int timeout_period)
|
|||
* @brief milliseconds since the last update
|
||||
* @return
|
||||
*/
|
||||
long Universe::age()
|
||||
long Universe::age() const
|
||||
{
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
if (!last_updated_.time_since_epoch().count())
|
||||
|
@ -80,9 +80,8 @@ double Universe::rxRate()
|
|||
* Like Schrödinger's cat, the status of the universe may exist in a superpostion
|
||||
* of states. Only by observing it will it collaps into a single status.
|
||||
*/
|
||||
uint8_t Universe::status()
|
||||
uint8_t Universe::status() const
|
||||
{
|
||||
rx_timeout_(); // many things may have happened since the last observation
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
return status_;
|
||||
}
|
||||
|
@ -93,7 +92,7 @@ uint8_t Universe::status()
|
|||
* @param address
|
||||
* @return
|
||||
*/
|
||||
uint8_t Universe::slot(const uint16_t address)
|
||||
uint8_t Universe::slot(const uint16_t address) const
|
||||
{
|
||||
std::shared_lock lck(mtx_data);
|
||||
try {
|
||||
|
@ -296,7 +295,7 @@ void Universe::rx_timeout_(bool add_now)
|
|||
*/
|
||||
void Universe::do_callbacks_(std::vector<std::weak_ptr<const std::function<void(Universe*)>>> & callbacks)
|
||||
{
|
||||
for (auto it = callbacks.begin(); it != callbacks.end();)
|
||||
for (auto it = callbacks.cbegin(); it != callbacks.cend();)
|
||||
{
|
||||
if (auto sp = it->lock())
|
||||
{ // the owner is still holding the token
|
||||
|
@ -304,8 +303,10 @@ void Universe::do_callbacks_(std::vector<std::weak_ptr<const std::function<void(
|
|||
++it;
|
||||
}
|
||||
else
|
||||
// the owner has released the token
|
||||
it = callbacks.erase(it);
|
||||
{ // the owner has released the token
|
||||
std::unique_lock lk(mtx_control);
|
||||
it = callbacks.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ class Universe {
|
|||
public:
|
||||
explicit Universe (int timeout_period = E111_DATA_LOSS_TIMEOUT);
|
||||
|
||||
virtual long age();
|
||||
virtual long age() const;
|
||||
virtual double rxRate();
|
||||
virtual uint8_t status();
|
||||
virtual uint8_t slot(const uint16_t);
|
||||
virtual uint8_t status() const;
|
||||
virtual uint8_t slot(const uint16_t) const;
|
||||
|
||||
virtual void setStatus(uint8_t);
|
||||
virtual void setValue(const uint16_t start, const uint16_t footprint,
|
||||
|
|
|
@ -181,7 +181,7 @@ std::shared_ptr<void> ArbitratingUniverse::onSourceListChange(std::function<void
|
|||
*/
|
||||
void ArbitratingUniverse::doListChangeCallbacks()
|
||||
{
|
||||
for (auto it = cb_sourceListChange.begin(); it != cb_sourceListChange.end();)
|
||||
for (auto it = cb_sourceListChange.cbegin(); it != cb_sourceListChange.cend();)
|
||||
{
|
||||
if (auto sp = it->lock())
|
||||
{ // if the caller is still holding the token
|
||||
|
@ -201,7 +201,7 @@ void ArbitratingUniverse::doListChangeCallbacks()
|
|||
* @brief ArbitratingUniverse::isSyncronized
|
||||
* @return
|
||||
*/
|
||||
bool ArbitratingUniverse::isSyncronized()
|
||||
bool ArbitratingUniverse::isSyncronized() const
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (!universe)
|
||||
|
@ -214,7 +214,7 @@ bool ArbitratingUniverse::isSyncronized()
|
|||
* @brief ArbitratingUniverse::metadata
|
||||
* @return
|
||||
*/
|
||||
std::shared_ptr<DATA::data_header> ArbitratingUniverse::metadata()
|
||||
std::shared_ptr<DATA::data_header> ArbitratingUniverse::metadata() const
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (universe)
|
||||
|
@ -228,20 +228,12 @@ std::shared_ptr<DATA::data_header> ArbitratingUniverse::metadata()
|
|||
}
|
||||
|
||||
|
||||
uint8_t ArbitratingUniverse::status()
|
||||
uint8_t ArbitratingUniverse::status() const
|
||||
{
|
||||
uint8_t status;
|
||||
auto universe = dominant_();
|
||||
if (universe)
|
||||
{
|
||||
status = universe->status();
|
||||
setStatus(status);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = Universe::status();
|
||||
}
|
||||
return status;
|
||||
if (!universe)
|
||||
return Universe::DMX_NULL;
|
||||
return universe->status();
|
||||
}
|
||||
|
||||
|
||||
|
@ -263,7 +255,7 @@ bool ArbitratingUniverse::isEditable() const
|
|||
}
|
||||
|
||||
|
||||
uint16_t ArbitratingUniverse::activeSlots()
|
||||
uint16_t ArbitratingUniverse::activeSlots() const
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (!universe)
|
||||
|
@ -277,7 +269,7 @@ uint16_t ArbitratingUniverse::activeSlots()
|
|||
* @param s
|
||||
* @return
|
||||
*/
|
||||
uint8_t ArbitratingUniverse::slot(const uint16_t s)
|
||||
uint8_t ArbitratingUniverse::slot(const uint16_t s) const
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (!universe)
|
||||
|
@ -314,7 +306,7 @@ void ArbitratingUniverse::rxDmpSetProperty(ACN::PDU::Message<ACN::DMP::Pdu> mess
|
|||
* @brief MergeProxyUniverse::dominant_
|
||||
* @return
|
||||
*/
|
||||
std::shared_ptr<Universe> ArbitratingUniverse::dominant_()
|
||||
std::shared_ptr<Universe> ArbitratingUniverse::dominant_() const
|
||||
{
|
||||
if (sources_.empty())
|
||||
return nullptr;
|
||||
|
@ -326,7 +318,6 @@ std::shared_ptr<Universe> ArbitratingUniverse::dominant_()
|
|||
for (const auto& [header, universe] : sources_)
|
||||
ages.insert({header, universe->age()});
|
||||
}
|
||||
purge_stale_sources_(&ages);
|
||||
|
||||
// order universe into a two dimentional container; priority then age
|
||||
std::map<uint,std::multimap<uint,std::shared_ptr<Universe>>> by_priority;
|
||||
|
|
|
@ -67,17 +67,17 @@ public:
|
|||
void dataChangedNotifier(DMX::Universe* universe);
|
||||
|
||||
// DMX::Universe overrides:
|
||||
virtual uint8_t status() override;
|
||||
uint8_t slot(const uint16_t) override;
|
||||
virtual uint8_t status() const override;
|
||||
uint8_t slot(const uint16_t) const override;
|
||||
double rxRate() override;
|
||||
|
||||
// sACN::Universe Overrides
|
||||
std::shared_ptr<DATA::data_header> metadata() override;
|
||||
std::shared_ptr<DATA::data_header> metadata() const override;
|
||||
void setMetadata(std::shared_ptr<DATA::data_header>) override {};
|
||||
bool isSyncronized() override;
|
||||
bool isSyncronized() const override;
|
||||
void synchronize(uint8_t = 0) override;
|
||||
bool isEditable() const override;
|
||||
uint16_t activeSlots() override;
|
||||
uint16_t activeSlots() const override;
|
||||
// api for poly-source universes
|
||||
const std::vector<DATA::data_header> sources() const override;
|
||||
std::shared_ptr<Universe> sourceUniverse(const DATA::data_header&) override;
|
||||
|
@ -99,8 +99,8 @@ private:
|
|||
|
||||
bool hold_last_look_;
|
||||
|
||||
std::shared_ptr<Universe> dominant_();
|
||||
void purge_stale_sources_(std::unordered_map<DATA::data_header, uint> * = nullptr);
|
||||
std::shared_ptr<Universe> dominant_() const;
|
||||
void purge_stale_sources_();
|
||||
bool hasSourceUniverse(const DATA::data_header&) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ Universe::Universe(Source* src)
|
|||
, ACN::DMP::Component(UUID::uuid(), "OpenLCP sACN Universe")
|
||||
, sender_(src ? new UniverseSender(src, this) : nullptr)
|
||||
, metadata_(std::make_shared<DATA::data_header>())
|
||||
, sync_data_(nullptr)
|
||||
, active_data_slots_(1) // start code
|
||||
, sync_sequence_(0)
|
||||
{
|
||||
|
@ -60,7 +61,7 @@ Universe::~Universe()
|
|||
* @brief Universe::metadata
|
||||
* @return
|
||||
*/
|
||||
std::shared_ptr<DATA::data_header> Universe::metadata()
|
||||
std::shared_ptr<DATA::data_header> Universe::metadata() const
|
||||
{
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
return metadata_;
|
||||
|
@ -82,7 +83,7 @@ void Universe::setMetadata(std::shared_ptr<DATA::data_header> metadata)
|
|||
* @brief Universe::isSyncronized
|
||||
* @return
|
||||
*/
|
||||
bool Universe::isSyncronized()
|
||||
bool Universe::isSyncronized() const
|
||||
{
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
return !sync_data_;
|
||||
|
@ -161,7 +162,7 @@ bool Universe::isEditable() const
|
|||
* @brief Universe::activeSlots
|
||||
* @return
|
||||
*/
|
||||
uint16_t Universe::activeSlots()
|
||||
uint16_t Universe::activeSlots() const
|
||||
{
|
||||
std::shared_lock lk_ctl(mtx_control);
|
||||
return active_data_slots_;
|
||||
|
|
|
@ -51,17 +51,17 @@ public:
|
|||
|
||||
friend class UniverseSender;
|
||||
|
||||
virtual std::shared_ptr<DATA::data_header> metadata();
|
||||
virtual std::shared_ptr<DATA::data_header> metadata() const;
|
||||
virtual void setMetadata(std::shared_ptr<DATA::data_header>);
|
||||
|
||||
virtual bool isSyncronized();
|
||||
virtual bool isSyncronized() const;
|
||||
virtual void synchronize(uint8_t = 0);
|
||||
virtual void resetSynchronization();
|
||||
virtual void setSyncData(const std::vector<uint8_t> &);
|
||||
|
||||
virtual bool isEditable() const;
|
||||
|
||||
virtual uint16_t activeSlots();
|
||||
virtual uint16_t activeSlots() const;
|
||||
|
||||
// api for poly-source universes
|
||||
virtual const std::vector<DATA::data_header> sources() const;
|
||||
|
@ -101,7 +101,7 @@ protected:
|
|||
private:
|
||||
UniverseSender * sender_;
|
||||
std::shared_ptr<DATA::data_header> metadata_;
|
||||
std::vector<uint8_t> * sync_data_ = nullptr;
|
||||
std::vector<uint8_t> * sync_data_;
|
||||
|
||||
/**
|
||||
* @brief \cite sACN 3.7 Active Data Slots
|
||||
|
|
Loading…
Reference in New Issue