bring active slot awareness down to the base universe class
This commit is contained in:
parent
417d8cd18b
commit
f1f153f09e
@ -36,6 +36,7 @@ Universe::Universe(int timeout_period)
|
|||||||
: null_start_data({0})
|
: null_start_data({0})
|
||||||
, rx_timeout_period_(timeout_period)
|
, rx_timeout_period_(timeout_period)
|
||||||
, status_(DMX_NULL)
|
, status_(DMX_NULL)
|
||||||
|
, active_data_slots_(1) // start code
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +145,14 @@ void Universe::setValue(const uint16_t start, const uint16_t footprint,
|
|||||||
std::unique_lock lk_ctl(mtx_control);
|
std::unique_lock lk_ctl(mtx_control);
|
||||||
last_updated_ = std::chrono::system_clock::now();
|
last_updated_ = std::chrono::system_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set active_data_slots to at least end of footprint
|
||||||
|
if (start + footprint > active_data_slots_)
|
||||||
|
{
|
||||||
|
std::unique_lock lk_ctl(mtx_control);
|
||||||
|
active_data_slots_ = start + footprint;
|
||||||
|
}
|
||||||
|
|
||||||
setStatus(DMX_ACTIVE);
|
setStatus(DMX_ACTIVE);
|
||||||
do_callbacks_(cb_dataChange);
|
do_callbacks_(cb_dataChange);
|
||||||
}
|
}
|
||||||
@ -183,6 +192,10 @@ void Universe::setData(const std::vector<uint8_t>& data)
|
|||||||
null_start_data.fill(0); // wipe old data
|
null_start_data.fill(0); // wipe old data
|
||||||
std::copy_n(data.cbegin(), length, null_start_data.begin()); // copy new data
|
std::copy_n(data.cbegin(), length, null_start_data.begin()); // copy new data
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
std::unique_lock lk_ctl(mtx_control);
|
||||||
|
active_data_slots_ = length;
|
||||||
|
}
|
||||||
rx_timeout_(true); // update rx times
|
rx_timeout_(true); // update rx times
|
||||||
do_callbacks_(cb_dataChange); // run callbacks
|
do_callbacks_(cb_dataChange); // run callbacks
|
||||||
}
|
}
|
||||||
@ -289,6 +302,17 @@ void Universe::rx_timeout_(bool add_now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Universe::activeSlots
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
uint16_t Universe::activeSlots() const
|
||||||
|
{
|
||||||
|
std::shared_lock lk_ctl(mtx_control);
|
||||||
|
return active_data_slots_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Universe::doCallbacks
|
* @brief Universe::doCallbacks
|
||||||
* @param callbacks
|
* @param callbacks
|
||||||
|
@ -63,6 +63,8 @@ class Universe {
|
|||||||
std::shared_ptr<void> onDataChange(const std::function<void(Universe*)>);
|
std::shared_ptr<void> onDataChange(const std::function<void(Universe*)>);
|
||||||
std::shared_ptr<void> onStatusChange(const std::function<void(Universe*)>);
|
std::shared_ptr<void> onStatusChange(const std::function<void(Universe*)>);
|
||||||
|
|
||||||
|
virtual uint16_t activeSlots() const;
|
||||||
|
|
||||||
/// Known states of the universe Status value
|
/// Known states of the universe Status value
|
||||||
enum Status : uint8_t {
|
enum Status : uint8_t {
|
||||||
DMX_NULL = 0, //!< uninitialized
|
DMX_NULL = 0, //!< uninitialized
|
||||||
@ -89,6 +91,15 @@ class Universe {
|
|||||||
std::queue<std::chrono::time_point<std::chrono::system_clock>> rx_times_;
|
std::queue<std::chrono::time_point<std::chrono::system_clock>> rx_times_;
|
||||||
std::vector<std::weak_ptr<const std::function<void(Universe*)>>> cb_dataChange;
|
std::vector<std::weak_ptr<const std::function<void(Universe*)>>> cb_dataChange;
|
||||||
std::vector<std::weak_ptr<const std::function<void(Universe*)>>> cb_statusChange;
|
std::vector<std::weak_ptr<const std::function<void(Universe*)>>> cb_statusChange;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief \cite DMX 8.7 Minimum number of data slots
|
||||||
|
*
|
||||||
|
* > There shall be no minimum number of data slots on the data link. DMX512 data packets
|
||||||
|
* > with fewer than 512 slots may be transmitted, subject to the minimum timing requirements
|
||||||
|
* > of this Standard – see clause 8.10 and figure 5.
|
||||||
|
*/
|
||||||
|
uint16_t active_data_slots_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace DMX
|
} // namespace DMX
|
||||||
|
@ -39,7 +39,6 @@ Universe::Universe(Source* src, Receiver* rsv)
|
|||||||
, sender_(src ? new UniverseSender(src, this) : nullptr)
|
, sender_(src ? new UniverseSender(src, this) : nullptr)
|
||||||
, metadata_(std::make_shared<DATA::data_header>())
|
, metadata_(std::make_shared<DATA::data_header>())
|
||||||
, sync_data_(nullptr)
|
, sync_data_(nullptr)
|
||||||
, active_data_slots_(1) // start code
|
|
||||||
, sync_sequence_(0)
|
, sync_sequence_(0)
|
||||||
{
|
{
|
||||||
destination.type = ACN::SDT::SDT_ADDR_NULL;
|
destination.type = ACN::SDT::SDT_ADDR_NULL;
|
||||||
@ -142,13 +141,6 @@ void Universe::setValue (const uint16_t start, const uint16_t footprint,
|
|||||||
if (start < 1 || start + footprint > null_start_data.size())
|
if (start < 1 || start + footprint > null_start_data.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// set active_data_slots to at least end of footprint
|
|
||||||
if (start + footprint > active_data_slots_)
|
|
||||||
{
|
|
||||||
std::unique_lock lk_ctl(mtx_control);
|
|
||||||
active_data_slots_ = start + footprint;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get a copy of the current values
|
// get a copy of the current values
|
||||||
uint8_t og[footprint];
|
uint8_t og[footprint];
|
||||||
{
|
{
|
||||||
@ -303,8 +295,7 @@ uint16_t Universe::activeSlots() const
|
|||||||
if (arbitrator_)
|
if (arbitrator_)
|
||||||
return arbitrator_->activeSlots();
|
return arbitrator_->activeSlots();
|
||||||
|
|
||||||
std::shared_lock lk_ctl(mtx_control);
|
return DMX::Universe::activeSlots();
|
||||||
return active_data_slots_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -401,10 +392,7 @@ void Universe::rxDmpSetProperty(ACN::PDU::Message<ACN::DMP::Pdu> message)
|
|||||||
/// > DMX512-A [DMX] Slots (including the START Code slot).
|
/// > DMX512-A [DMX] Slots (including the START Code slot).
|
||||||
if (range.count < 1 || range.count > null_start_data.size())
|
if (range.count < 1 || range.count > null_start_data.size())
|
||||||
return;
|
return;
|
||||||
{
|
|
||||||
std::unique_lock lk_ctl(mtx_control);
|
|
||||||
active_data_slots_ = range.address + range.count;
|
|
||||||
}
|
|
||||||
/// > \cite sACN 7.7 Property Values (DMX512-A Data)
|
/// > \cite sACN 7.7 Property Values (DMX512-A Data)
|
||||||
/// >
|
/// >
|
||||||
/// > The DMP Layer's Property values field is used to encode the
|
/// > The DMP Layer's Property values field is used to encode the
|
||||||
|
@ -83,7 +83,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
virtual bool isEditable() const;
|
virtual bool isEditable() const;
|
||||||
virtual uint16_t activeSlots() const;
|
virtual uint16_t activeSlots() const override;
|
||||||
virtual bool hasSources() const;
|
virtual bool hasSources() const;
|
||||||
virtual const std::vector<DATA::data_header> sources() const;
|
virtual const std::vector<DATA::data_header> sources() const;
|
||||||
UniverseArbitrator* arbitrator() const;
|
UniverseArbitrator* arbitrator() const;
|
||||||
@ -118,19 +118,6 @@ private:
|
|||||||
std::shared_ptr<DATA::data_header> metadata_;
|
std::shared_ptr<DATA::data_header> metadata_;
|
||||||
std::vector<uint8_t> * sync_data_;
|
std::vector<uint8_t> * sync_data_;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief \cite sACN 3.7 Active Data Slots
|
|
||||||
*
|
|
||||||
* > When translating ANSI E1.11 DMX512-A \cite DMX to E1.31, the active data
|
|
||||||
* > slots are defined as ranging from data slot 1 to the maximum data slot in
|
|
||||||
* > the most recently received packet with the corresponding START Code.
|
|
||||||
* >
|
|
||||||
* > Devices originating E1.31 shall define their active data slots using
|
|
||||||
* > the DMP First Property Address and DMP Property Count fields shown in
|
|
||||||
* > Table 4-1.
|
|
||||||
*/
|
|
||||||
uint16_t active_data_slots_;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* > \cite sACN 6.3.2 E1.31 Synchronization Packet: Sequence Number
|
* > \cite sACN 6.3.2 E1.31 Synchronization Packet: Sequence Number
|
||||||
* >
|
* >
|
||||||
|
@ -205,8 +205,8 @@ void UniverseSender::update_dmp_()
|
|||||||
ACN::DMP::Range pr(*addrtyp);
|
ACN::DMP::Range pr(*addrtyp);
|
||||||
pr.address = 0;
|
pr.address = 0;
|
||||||
pr.incriment = 1;
|
pr.incriment = 1;
|
||||||
pr.count = mUniverse->active_data_slots_ < mUniverse->null_start_data.size()
|
pr.count = mUniverse->activeSlots() < mUniverse->null_start_data.size()
|
||||||
? mUniverse->active_data_slots_
|
? mUniverse->activeSlots()
|
||||||
: mUniverse->null_start_data.size();
|
: mUniverse->null_start_data.size();
|
||||||
|
|
||||||
// property data
|
// property data
|
||||||
|
Loading…
Reference in New Issue
Block a user