From c16d549e94f22a335972b9c919d33df50d507bfb Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Sun, 30 Jul 2017 10:29:52 -0500 Subject: [PATCH] Added additional way to reset running timers Added a list of RESET TGIDs used, additionally, to reset running timers. All previous actions still work the same way, this is only ANOTHER way to reset timers. --- confbridge.py | 36 +++++++++++++++++++----------------- confbridge_rules_SAMPLE.py | 15 +++++++++------ 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/confbridge.py b/confbridge.py index 44c9037..8335c9f 100755 --- a/confbridge.py +++ b/confbridge.py @@ -385,31 +385,33 @@ class confbridgeIPSC(IPSC): if _system['SYSTEM'] == self._system: # TGID matches an ACTIVATION trigger - if _dst_group in _system['ON'] and _ts == _system['TS']: + if (_dst_group in _system['ON'] or _dst_group in _system['RESET']) and _ts == _system['TS']: # Set the matching rule as ACTIVE - 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) + if _dst_group in _system['ON']: + 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) # TGID matches an DE-ACTIVATION trigger - if _dst_group in _system['OFF'] and _ts == _system['TS']: + if (_dst_group in _system['OFF'] or _dst_group in _system['RESET']) and _ts == _system['TS']: # Set the matching rule as ACTIVE - 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 _dst_group in _system['OFF']: + 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 the timer for the rule if _system['ACTIVE'] == False and _system['TO_TYPE'] == 'OFF': _system['TIMER'] = now + _system['TIMEOUT'] self._logger.info('(%s) Bridge: %s, timeout timer reset to: %s', self._system, _bridge, _system['TIMER'] - now) diff --git a/confbridge_rules_SAMPLE.py b/confbridge_rules_SAMPLE.py index 43fa84e..3da80e4 100644 --- a/confbridge_rules_SAMPLE.py +++ b/confbridge_rules_SAMPLE.py @@ -19,6 +19,9 @@ configuration file. * ON and OFF are LISTS of Talkgroup IDs used to trigger this system off and on. Even if you only want one (as shown in the ON example), it has to be in list format. None can be handled with an empty list, such as " 'ON': [] ". + * RESET is a list of Talkgroup IDs that, in addition to the ON and OFF lists will cause a running + timer to be reset. This is useful if you are using different TGIDs for voice traffic than + triggering. If you are not, there is NO NEED to use this feature. * TO_TYPE is timeout type. If you want to use timers, ON means when it's turned on, it will turn off afer the timout period and OFF means it will turn back on after the timout period. If you don't want to use timers, set it to anything else, but 'NONE' might be @@ -40,16 +43,16 @@ BRIDGE_CONF = { BRIDGES = { 'WORLDWIDE': [ - {'SYSTEM': 'MASTER-1', 'TS': 1, 'TGID': 1, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'ON', 'ON': [2,], 'OFF': [9,10]}, - {'SYSTEM': 'CLIENT-1', 'TS': 1, 'TGID': 3100, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'ON', 'ON': [2,], 'OFF': [9,10]}, + {'SYSTEM': 'MASTER-1', 'TS': 1, 'TGID': 1, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'ON', 'ON': [2,], 'OFF': [9,10], 'RESET': []}, + {'SYSTEM': 'CLIENT-1', 'TS': 1, 'TGID': 3100, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'ON', 'ON': [2,], 'OFF': [9,10], 'RESET': []} ], 'ENGLISH': [ - {'SYSTEM': 'MASTER-1', 'TS': 1, 'TGID': 13, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [3,], 'OFF': [8,10]}, - {'SYSTEM': 'CLIENT-2', 'TS': 1, 'TGID': 13, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [3,], 'OFF': [8,10]}, + {'SYSTEM': 'MASTER-1', 'TS': 1, 'TGID': 13, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [3,], 'OFF': [8,10], 'RESET': []}, + {'SYSTEM': 'CLIENT-2', 'TS': 1, 'TGID': 13, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [3,], 'OFF': [8,10], 'RESET': []} ], 'STATEWIDE': [ - {'SYSTEM': 'MASTER-1', 'TS': 2, 'TGID': 3129, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [4,], 'OFF': [7,10]}, - {'SYSTEM': 'CLIENT-2', 'TS': 2, 'TGID': 3129, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [4,], 'OFF': [7,10]}, + {'SYSTEM': 'MASTER-1', 'TS': 2, 'TGID': 3129, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [4,], 'OFF': [7,10], 'RESET': []}, + {'SYSTEM': 'CLIENT-2', 'TS': 2, 'TGID': 3129, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [4,], 'OFF': [7,10], 'RESET': []} ] }