From 56635d7e66549acf5b3befa84f132d1fffbb79d1 Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Fri, 24 Mar 2017 08:51:48 -0500 Subject: [PATCH] Don't repeat timer cancel actions if unneeded. --- confbridge.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/confbridge.py b/confbridge.py index 4f3c831..f827d2f 100755 --- a/confbridge.py +++ b/confbridge.py @@ -334,14 +334,14 @@ class confbridgeIPSC(IPSC): if _system['ACTIVE'] == False: _system['ACTIVE'] = True self._logger.info('(%s) Bridge: %s, connection changed to state: %s', self._system, _bridge, _system['ACTIVE']) + # Cancel the timer if we've enabled an "OFF" type timeout + if _system['TO_TYPE'] == 'OFF': + _system['TIMER'] = now + self._logger.info('(%s) Bridge: %s set to "OFF" with an on timer rule: timeout timer cancelled', self._system, _bridge) # Reset the timer for the rule if _system['ACTIVE'] == True and _system['TO_TYPE'] == 'ON': _system['TIMER'] = now + _system['TIMEOUT'] self._logger.info('(%s) Bridge: %s, timeout timer reset to: %s', self._system, _bridge, _system['TIMER'] - now) - # Cancel the timer if we've enabled an "OFF" type timeout - if _system['ACTIVE'] == True and _system['TO_TYPE'] == 'OFF': - _system['TIMER'] = now - self._logger.info('(%s) Bridge: %s set to "OFF" with an on timer rule: timeout timer cancelled', self._system, _bridge) # TGID matches an DE-ACTIVATION trigger if _dst_group in _system['OFF']: @@ -349,6 +349,10 @@ class confbridgeIPSC(IPSC): if _system['ACTIVE'] == True: _system['ACTIVE'] = False self._logger.info('(%s) Bridge: %s, connection changed to state: %s', self._system, _bridge, _system['ACTIVE']) + # Cancel the timer if we've enabled an "ON" type timeout + if _system['TO_TYPE'] == 'ON': + _system['TIMER'] = now + self._logger.info('(%s) Bridge: %s set to ON with and "OFF" timer rule: timeout timer cancelled', self._system, _bridge) # Reset tge timer for the rule if _system['ACTIVE'] == False and _system['TO_TYPE'] == 'OFF': _system['TIMER'] = now + _system['TIMEOUT']