Browse Source

relay: properly handle zero interlock time

schedule when >0, execute immediately otherwise
pull/2575/head
Maxim Prokhorov 1 year ago
parent
commit
11c897898d
1 changed files with 26 additions and 21 deletions
  1. +26
    -21
      code/espurna/relay.cpp

+ 26
- 21
code/espurna/relay.cpp View File

@ -1664,33 +1664,34 @@ void _relaySyncRelaysDelay(size_t first, size_t second) {
});
}
void _relaySyncUnlock() {
bool unlock = true;
bool all_off = true;
for (const auto& relay : _relays) {
unlock = unlock && (relay.current_status == relay.target_status);
if (!unlock) break;
all_off = all_off && !relay.current_status;
}
if (unlock) {
static const auto action = []() {
_relayUnlockAll();
void _relaySyncUnlockAction() {
_relayUnlockAll();
#if WEB_SUPPORT
_relayScheduleWsReport();
_relayScheduleWsReport();
#endif
};
}
void _relaySyncUnlock() {
bool interlock { false };
for (const auto& relay : _relays) {
if (relay.current_status != relay.target_status) {
return;
}
if (all_off) {
_relay_sync_timer.schedule(_relay_delay_interlock, action);
} else {
action();
if (relay.current_status) {
interlock = true;
}
}
}
void _relaySync() {
_relay_sync_timer.process();
if (interlock && (_relay_delay_interlock.count() > 0)) {
_relay_sync_timer.schedule(
_relay_delay_interlock, _relaySyncUnlockAction);
} else {
_relay_sync_timer.stop();
_relaySyncUnlockAction();
}
}
void _relaySyncTryUnlock() {
@ -1708,6 +1709,10 @@ void _relaySyncTryUnlock() {
}
}
void _relaySync() {
_relay_sync_timer.process();
}
} // namespace
// -----------------------------------------------------------------------------


Loading…
Cancel
Save