1
0
Fork 0

add synchronization reset helper

This commit is contained in:
Kevin Matz 2022-12-08 18:02:43 -05:00
parent 85a7ec4762
commit f9896ff5f3
3 changed files with 50 additions and 3 deletions

View File

@ -242,8 +242,40 @@ void Receiver::dataFrameHandler(ACN::PDU::Message<DATA::Pdu> frame) {
/// >
/// > a value of 0 in the Synchronization Address indicates that the universe
/// > data is not synchronized.
if (metadata->sync_address != 0)
subscribe(metadata->sync_address);
if (metadata->sync_address == 0 ||
/// > \cite sACN 6.2.6 E1.31 Data Packet: Options Force_Synchronization
/// >
/// > This bit indicates whether to lock or revert to an unsynchronized
/// > state when synchronization is lost. When set to 0, components that
/// > had been operating in a synchronized state shall not update with
/// > any new packets until synchronization resumes. When set to 1, once
/// > synchronization has been lost, components that had been operating
/// > in a synchronized state need not wait for a new E1.31
/// > Synchronization Packet in order to update to the next E1.31 Data
/// > Packet.
(universe->isSyncronized() &&
metadata->options.force_synchronization &&
universe->rxRate() == 0))
{
universe->resetSynchronization();
}
else
{
subscribe(metadata->sync_address);
auto block = std::static_pointer_cast<ACN::PDU::Block<ACN::DMP::Pdu>>(frame->data());
if (!block->pdu->empty())
{
auto dmp = std::static_pointer_cast<ACN::DMP::Pdu>(block->pdu->front());
auto list = std::static_pointer_cast<ACN::DMP::address_pair_list>(dmp->data());
if (!list->properties.empty())
{
const auto & [_, data] = list->properties.front();
universe->setMetadata(metadata);
universe->setSyncData(data);
}
}
return;
}
/// > \cite sACN 6.7.2 Sequence Numbering
/// >

View File

@ -314,19 +314,32 @@ void Universe::synchronize(uint8_t sequence_number)
if (dif <= 0 && dif > -20)
return;
sync_sequence_ = sequence_number;
DMX::Universe::setData(*sync_data_);
resetSynchronization();
}
/**
* @brief Universe::resetSynchronization
*/
void Universe::resetSynchronization()
{
delete sync_data_;
sync_data_ = nullptr;
}
/**
* @brief Universe::setSyncData
* @param data
* @brief Universe::sACNsend
*/
void Universe::setSyncData(const std::vector<uint8_t> & data)
void Universe::sACNsend() const
{
resetSynchronization();
sync_data_ = new std::vector<uint8_t>(data);
}
/// > \cite sACN 6.2.5 E1.31 Data Packet: Sequence Number
/// >
/// > ... The sequence number for a universe shall be incremented by one for

View File

@ -60,6 +60,8 @@ public:
virtual bool isSyncronized();
virtual void synchronize(uint8_t = 0);
virtual void resetSynchronization();
virtual void setSyncData(const std::vector<uint8_t> &);
virtual bool isEditable() const;