From 77815f31822738665ec09d462f3a9609a77360e6 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 22 Mar 2023 17:34:15 +0000 Subject: [PATCH] Fix bridge debug and fix routine --- bridge_master.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 9cd8c6d..3effcd7 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -388,13 +388,14 @@ def statTrimmer(): if CONFIG['REPORTS']['REPORT']: report_server.send_clients(b'bridge updated') -#Identify systems with no bridges +#Debug and fix bridge table issues. def bridgeDebug(): logger.info('(BRIDGEDEBUG) Running bridge debug') for system in CONFIG['SYSTEMS']: bridgeroll = 0 dialroll = 0 activeroll = 0 + statroll = 0 for _bridge in BRIDGES: for enabled_system in BRIDGES[_bridge]: if enabled_system['SYSTEM'] == system: @@ -405,6 +406,8 @@ def bridgeDebug(): activeroll += 1 else: activeroll += 1 + if enabled_system['TO_TYPE'] == 'STAT': + statroll += 1 if bridgeroll: logger.debug('(BRIDGEDEBUG) system %s has %s bridges of which %s are in an ACTIVE state', system, bridgeroll, activeroll) @@ -414,15 +417,20 @@ def bridgeDebug(): for _bridge in BRIDGES: for enabled_system in BRIDGES[_bridge]: if enabled_system['ACTIVE'] and _bridge and _bridge[0:1] == '#': - times[enabled_system['TIMER']] == _bridge - ordered == sorted(keys(times)) - ordered.pop() - for _bridge in ordered: - for _entry in BRIDGES[_bridge]: - if _entry['SYSTEM'][0:3] == 'OBP': - continue - if _entry['SYSTEM'] == system: - _entry['ACTIVE'] = False + times[enabled_system['TIMER']] = _bridge + ordered = sorted(times.keys()) + _setbridge = times[ordered.pop()] + logger.warning('(BRIDGEDEBUG) setting %s dial bridge to %s as this bridge has the longest timer set to run',system, _setbridge) + + for _tstamp in ordered: + for _bridge in times.values(): + for _entry in BRIDGES[_bridge]: + + if CONFIG['SYSTEMS'][system]['MODE'] == 'MASTER': + if _entry['SYSTEM'] == system: + _entry['ACTIVE'] = False + + logger.info('(BRIDGEDEBUG) The server currently has %s STATic bridges',statroll)