set DMX_LOST status from E111_DATA_LOSS_TIMEOUT
This commit is contained in:
parent
6be8dfbebd
commit
8a3eb928dd
|
@ -88,12 +88,11 @@ double Universe::rxRate()
|
|||
unsigned int Universe::rxAge()
|
||||
{
|
||||
rx_timeout_();
|
||||
if (!rx_times_.size())
|
||||
if (rx_times_.empty())
|
||||
return -1;
|
||||
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto latest = rx_times_.back();
|
||||
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now - latest);
|
||||
|
||||
return elapsed.count();
|
||||
|
@ -268,22 +267,22 @@ void Universe::doDataCallbacks()
|
|||
void Universe::rx_timeout_(bool add_now)
|
||||
{
|
||||
auto now = std::chrono::system_clock::now();
|
||||
if (add_now)
|
||||
rx_times_.push(now);
|
||||
|
||||
auto elapsed = [] (auto& a, auto& b) {
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(a - b);
|
||||
};
|
||||
|
||||
if (add_now)
|
||||
rx_times_.push(now);
|
||||
|
||||
while (!rx_times_.empty() &&
|
||||
elapsed(now, rx_times_.front()).count() > rx_timeout_period_)
|
||||
while (!rx_times_.empty())
|
||||
{
|
||||
rx_times_.pop();
|
||||
if (rx_times_.empty())
|
||||
{
|
||||
status_ = Status::DMX_LOST;
|
||||
doDataCallbacks();
|
||||
}
|
||||
auto age = elapsed(now, rx_times_.front()).count();
|
||||
if (age < rx_timeout_period_)
|
||||
break;
|
||||
else
|
||||
rx_times_.pop();
|
||||
if (age >= E111_DATA_LOSS_TIMEOUT)
|
||||
setStatus(Status::DMX_LOST);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue