updates to formatting

This commit is contained in:
n0mjs710 2018-12-07 20:09:25 -06:00
parent 26200dceb8
commit f6ae338fc5
4 changed files with 129 additions and 91 deletions

View File

@ -79,5 +79,10 @@
<hr> <hr>
<h3>Call Log Window:</h3> <h3>Call Log Window:</h3>
<pre id="log" style="height: 10em; overflow-y: scroll; background-color: #ccc;"></pre> <pre id="log" style="height: 10em; overflow-y: scroll; background-color: #ccc;"></pre>
<hr>
<center>
Copyright (c) 2016, 2027, 2018<br>The Regents of the K0USY Group. All rights reserved.
<!-- THIS COPYRIGHT NOTICE MUST BE DISPLAYED AS A CONDITOIN OF THE LICENCE GRANT FOR THIS SOFTWARE. ALL DERIVATEIVES WORKS MUST CARRY THIS NOTICE -->
</body> </body>
</html> </html>

View File

@ -28,7 +28,7 @@
<td>{{ system }}</td> <td>{{ system }}</td>
<td>{{ _table[_bridge][system]['TS'] }}</td> <td>{{ _table[_bridge][system]['TS'] }}</td>
<td>{{ _table[_bridge][system]['TGID'] }}</td> <td>{{ _table[_bridge][system]['TGID'] }}</td>
<td style="background-color:{{ _table[_bridge][system]['COLOR'] }}">{{ _table[_bridge][system]['ACTIVE'] }}</td> <td style="background-color:#{{ _table[_bridge][system]['BGCOLOR'] }}; color:#{{ _table[_bridge][system]['COLOR'] }}">{{ _table[_bridge][system]['ACTIVE'] }}</td>
<td>{{ _table[_bridge][system]['EXP_TIME'] }}</td> <td>{{ _table[_bridge][system]['EXP_TIME'] }}</td>
<td>{{ _table[_bridge][system]['TO_ACTION'] }}</td> <td>{{ _table[_bridge][system]['TO_ACTION'] }}</td>
<td>{{ _table[_bridge][system]['TRIG_ON'] }}</td> <td>{{ _table[_bridge][system]['TRIG_ON'] }}</td>

View File

@ -1,19 +1,18 @@
<h3>HBlink Status Tables:</h3> <h3>HBlink Status Tables:</h3>
<h4>Master Systems</h4>
<table style="width:100%; font: 10pt arial, sans-serif"> <table style="width:100%; font: 10pt arial, sans-serif">
<colgroup> <colgroup>
<col style="width: 10%" /> <col style="width: 10%" />
<col style="width: 20%" /> <col style="width: 20%" />
<col style="width: 8%" /> <col style="width: 8%" />
<col style="width: 4%" /> <col style="width: 5%" />
<col style="width: 3%" /> <col style="width: 3%" />
<col style="width: 10%" /> <col style="width: 9%" />
<col style="width: 15%" /> <col style="width: 15%" />
<col style="width: 15%" /> <col style="width: 15%" />
<col style="width: 15%" /> <col style="width: 15%" />
</colgroup> </colgroup>
<tr style="width:100%; font: 10pt arial, sans-serif; background-color:#666666; color:white"> <tr style="width:100%; font: 10pt arial, sans-serif; background-color:#666666; color:white">
<th>HBP System</th> <th>Homebrew Protocol<br>Master Systems</th>
<th>ID/Callsign/Location<br>IP:Port/Time Connected</th> <th>ID/Callsign/Location<br>IP:Port/Time Connected</th>
<th>Frequency</th> <th>Frequency</th>
<th>ColorCode<br>LinkedTS</th> <th>ColorCode<br>LinkedTS</th>
@ -35,39 +34,38 @@
<td rowspan="2">{{ _cdata['RX_FREQ'] }}<br>{{ _cdata['TX_FREQ'] }}</td> <td rowspan="2">{{ _cdata['RX_FREQ'] }}<br>{{ _cdata['TX_FREQ'] }}</td>
<td rowspan="2">{{ _cdata['COLORCODE'] }}<br>{{ _cdata['SLOTS'] }}</td> <td rowspan="2">{{ _cdata['COLORCODE'] }}<br>{{ _cdata['SLOTS'] }}</td>
<td style="background-color:#{{ _cdata[1]['COLOR'] }}; color:#{{ _cdata[1]['BGCOLOR'] }}">TS1</td> <td style="background-color:#{{ _cdata[1]['BGCOLOR'] }}; color:#{{ _cdata[1]['COLOR'] }}">TS1</td>
<td style="background-color:#{{ _cdata[1]['COLOR'] }}; color:#{{ _cdata[1]['BGCOLOR'] }}">{{ _cdata[1]['TYPE'] }}</td> <td style="background-color:#{{ _cdata[1]['BGCOLOR'] }}; color:#{{ _cdata[1]['COLOR'] }}">{{ _cdata[1]['TYPE'] }}</td>
<td style="background-color:#{{ _cdata[1]['COLOR'] }}; color:#{{ _cdata[1]['BGCOLOR'] }}">{{ _cdata[1]['SUB'] }}</td> <td style="background-color:#{{ _cdata[1]['BGCOLOR'] }}; color:#{{ _cdata[1]['COLOR'] }}">{{ _cdata[1]['SUB'] }}</td>
<td style="background-color:#{{ _cdata[1]['COLOR'] }}; color:#{{ _cdata[1]['BGCOLOR'] }}">{{ _cdata[1]['SRC'] }}</td> <td style="background-color:#{{ _cdata[1]['BGCOLOR'] }}; color:#{{ _cdata[1]['COLOR'] }}">{{ _cdata[1]['SRC'] }}</td>
<td style="background-color:#{{ _cdata[1]['COLOR'] }}; color:#{{ _cdata[1]['BGCOLOR'] }}">{{ _cdata[1]['DEST'] }}</td> <td style="background-color:#{{ _cdata[1]['BGCOLOR'] }}; color:#{{ _cdata[1]['COLOR'] }}">{{ _cdata[1]['DEST'] }}</td>
<tr> <tr>
<td style="background-color:#{{ _cdata[2]['COLOR'] }}; color:#{{ _cdata[2]['BGCOLOR'] }}">TS2</td> <td style="background-color:#{{ _cdata[2]['BGCOLOR'] }}; color:#{{ _cdata[2]['COLOR'] }}">TS2</td>
<td style="background-color:#{{ _cdata[2]['COLOR'] }}; color:#{{ _cdata[2]['BGCOLOR'] }}">{{ _cdata[2]['TYPE'] }}</td> <td style="background-color:#{{ _cdata[2]['BGCOLOR'] }}; color:#{{ _cdata[2]['COLOR'] }}">{{ _cdata[2]['TYPE'] }}</td>
<td style="background-color:#{{ _cdata[2]['COLOR'] }}; color:#{{ _cdata[2]['BGCOLOR'] }}">{{ _cdata[2]['SUB'] }}</td> <td style="background-color:#{{ _cdata[2]['BGCOLOR'] }}; color:#{{ _cdata[2]['COLOR'] }}">{{ _cdata[2]['SUB'] }}</td>
<td style="background-color:#{{ _cdata[2]['COLOR'] }}; color:#{{ _cdata[2]['BGCOLOR'] }}">{{ _cdata[2]['SRC'] }}</td> <td style="background-color:#{{ _cdata[2]['BGCOLOR'] }}; color:#{{ _cdata[2]['COLOR'] }}">{{ _cdata[2]['SRC'] }}</td>
<td style="background-color:#{{ _cdata[2]['COLOR'] }}; color:#{{ _cdata[2]['BGCOLOR'] }}">{{ _cdata[2]['DEST'] }}</td> <td style="background-color:#{{ _cdata[2]['BGCOLOR'] }}; color:#{{ _cdata[2]['COLOR'] }}">{{ _cdata[2]['DEST'] }}</td>
</tr> </tr>
</tr> </tr>
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
</table> </table>
<br>
<h4>Client Systems</h4>
<table style="width:100%; font: 10pt arial, sans-serif"> <table style="width:100%; font: 10pt arial, sans-serif">
<colgroup> <colgroup>
<col style="width: 10%" /> <col style="width: 10%" />
<col style="width: 20%" /> <col style="width: 20%" />
<col style="width: 8%" /> <col style="width: 8%" />
<col style="width: 4%" /> <col style="width: 5%" />
<col style="width: 3%" /> <col style="width: 3%" />
<col style="width: 10%" /> <col style="width: 9%" />
<col style="width: 15%" /> <col style="width: 15%" />
<col style="width: 15%" /> <col style="width: 15%" />
<col style="width: 15%" /> <col style="width: 15%" />
</colgroup> </colgroup>
<tr style="width:100%; font: 10pt arial, sans-serif; background-color:#666666; color:white"> <tr style="width:100%; font: 10pt arial, sans-serif; background-color:#666666; color:white">
<th>HBP System</th> <th>Homebrew Protocol<br>Peer Systems</th>
<th>ID/Callsign/Location<br>Master IP:Port</th> <th>ID/Callsign/Location<br>Master IP:Port</th>
<th>Connected<br>Sent/Ack/Missed</th> <th>Connected<br>Sent/Ack/Missed</th>
<th>LinkedTS</th> <th>LinkedTS</th>
@ -78,39 +76,37 @@
<th>Destination</th> <th>Destination</th>
</tr> </tr>
{% for _peer in _table['PEERS'] %} {% for _peer, _pdata in _table['PEERS'].iteritems() %}
<tr> <tr>
<td style="font-weight:bold" rowspan="2"> {{ _peer}}</td> <td style="font-weight:bold" rowspan="2"> {{ _peer}}</td>
<td rowspan="2">{{ _table['PEERS'][_peer]['RADIO_ID'] }}, {{_table['PEERS'][_peer]['CALLSIGN']}}, {{_table['PEERS'][_peer]['LOCATION']}}<br><div style="font: 8pt arial, sans-serif">Master: {{ _table['PEERS'][_peer]['MASTER_IP'] }}:{{ _table['PEERS'][_peer]['MASTER_PORT'] }}</div></td> <td rowspan="2">{{ _table['PEERS'][_peer]['RADIO_ID'] }}, {{_table['PEERS'][_peer]['CALLSIGN']}}, {{_table['PEERS'][_peer]['LOCATION']}}<br><div style="font: 8pt arial, sans-serif">Master: {{ _table['PEERS'][_peer]['MASTER_IP'] }}:{{ _table['PEERS'][_peer]['MASTER_PORT'] }}</div></td>
<td rowspan="2"; style={{ 'background-color:#00ff00' if _table['PEERS'][_peer]['STATS']['CONNECTION'] == 'YES' else ';background-color:#ff0000' }}>{{ _table['PEERS'][_peer]['STATS']['CONNECTED'] }}<br><div style="font: 8pt arial, sans-serif">{{ _table['PEERS'][_peer]['STATS']['PINGS_SENT'] }} / {{ _table['PEERS'][_peer]['STATS']['PINGS_ACKD'] }} / {{ _table['PEERS'][_peer]['STATS']['PINGS_SENT'] - _table['PEERS'][_peer]['STATS']['PINGS_ACKD'] }}</div></td> <td rowspan="2"; style={{ 'background-color:#00ff00' if _table['PEERS'][_peer]['STATS']['CONNECTION'] == 'YES' else ';background-color:#ff0000' }}>{{ _table['PEERS'][_peer]['STATS']['CONNECTED'] }}<br><div style="font: 8pt arial, sans-serif">{{ _table['PEERS'][_peer]['STATS']['PINGS_SENT'] }} / {{ _table['PEERS'][_peer]['STATS']['PINGS_ACKD'] }} / {{ _table['PEERS'][_peer]['STATS']['PINGS_SENT'] - _table['PEERS'][_peer]['STATS']['PINGS_ACKD'] }}</div></td>
<td rowspan="2"> {{ _table['PEERS'][_peer]['SLOTS'] }}</td> <td rowspan="2"> {{ _table['PEERS'][_peer]['SLOTS'] }}</td>
<td>TS1</td> <td style="background-color:#{{ _pdata[1]['BGCOLOR'] }}; color:#{{ _pdata[1]['COLOR'] }}">TS1</td>
<td></td> <td style="background-color:#{{ _pdata[1]['BGCOLOR'] }}; color:#{{ _pdata[1]['COLOR'] }}">{{ _pdata[1]['TYPE'] }}</td>
<td></td> <td style="background-color:#{{ _pdata[1]['BGCOLOR'] }}; color:#{{ _pdata[1]['COLOR'] }}">{{ _pdata[1]['SUB'] }}</td>
<td></td> <td style="background-color:#{{ _pdata[1]['BGCOLOR'] }}; color:#{{ _pdata[1]['COLOR'] }}">{{ _pdata[1]['SRC'] }}</td>
<td></td> <td style="background-color:#{{ _pdata[1]['BGCOLOR'] }}; color:#{{ _pdata[1]['COLOR'] }}">{{ _pdata[1]['DEST'] }}</td>
<tr> <tr>
<td>TS2</td> <td style="background-color:#{{ _pdata[2]['BGCOLOR'] }}; color:#{{ _pdata[2]['COLOR'] }}">TS2</td>
<td></td> <td style="background-color:#{{ _pdata[2]['BGCOLOR'] }}; color:#{{ _pdata[2]['COLOR'] }}">{{ _pdata[2]['TYPE'] }}</td>
<td></td> <td style="background-color:#{{ _pdata[2]['BGCOLOR'] }}; color:#{{ _pdata[2]['COLOR'] }}">{{ _pdata[2]['SUB'] }}</td>
<td></td> <td style="background-color:#{{ _pdata[2]['BGCOLOR'] }}; color:#{{ _pdata[2]['COLOR'] }}">{{ _pdata[2]['SRC'] }}</td>
<td></td> <td style="background-color:#{{ _pdata[2]['BGCOLOR'] }}; color:#{{ _pdata[2]['COLOR'] }}">{{ _pdata[2]['DEST'] }}</td>
</tr> </tr>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
<br>
<h4>OpenBridge Systems</h4>
<table style="width:100%; font: 10pt arial, sans-serif"> <table style="width:100%; font: 10pt arial, sans-serif">
<colgroup> <colgroup>
<col style="width: 10%" /> <col style="width: 10%" />
<col style="width: 15%" /> <col style="width: 20%" />
<col style="width: 75%" /> <col style="width: 70%" />
</colgroup> </colgroup>
<tr style="width:100%; font: 10pt arial, sans-serif; background-color:#666666; color:white"> <tr style="width:100%; font: 10pt arial, sans-serif; background-color:#666666; color:white">
<th>OpenBridge System</th> <th>OpenBridge Systems</th>
<th>Network ID<br>Target IP:Port</th> <th>Network ID<br>Target IP:Port</th>
<th>Active Calls</th> <th>Active Calls</th>
</tr> </tr>
@ -120,8 +116,8 @@
<tr> <tr>
<td style="font-weight:bold"> {{ _openbridge}} </td> <td style="font-weight:bold"> {{ _openbridge}} </td>
<td>{{ _table['OPENBRIDGES'][_openbridge]['NETWORK_ID'] }}<br><div style="font: 8pt arial, sans-serif">{{ _table['OPENBRIDGES'][_openbridge]['TARGET_IP'] }}:{{ _table['OPENBRIDGES'][_openbridge]['TARGET_PORT'] }}</div></td> <td>{{ _table['OPENBRIDGES'][_openbridge]['NETWORK_ID'] }}<br><div style="font: 8pt arial, sans-serif">{{ _table['OPENBRIDGES'][_openbridge]['TARGET_IP'] }}:{{ _table['OPENBRIDGES'][_openbridge]['TARGET_PORT'] }}</div></td>
<th /> <td>{% for entry in _table['OPENBRIDGES'][_openbridge]['STREAMS'] %}({{ _table['OPENBRIDGES'][_openbridge]['STREAMS'][entry][0] }} >> {{ _table['OPENBRIDGES'][_openbridge]['STREAMS'][entry][1] }}) {% endfor %}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View File

@ -75,12 +75,12 @@ BTABLE['BRIDGES'] = {}
BRIDGES_RX = '' BRIDGES_RX = ''
CONFIG_RX = '' CONFIG_RX = ''
LOGBUF = deque(100*[''], 100) LOGBUF = deque(100*[''], 100)
RED = '#ff0000' RED = 'ff0000'
BLACK = '#000000' BLACK = '000000'
GREEN = '#00ff00' GREEN = '00ff00'
BLUE = '#0000ff' BLUE = '0000ff'
ORANGE = '#ff8000' ORANGE = 'ff8000'
WHITE = '#ffffff' WHITE = 'ffffff'
# For importing HTML templates # For importing HTML templates
@ -118,7 +118,7 @@ def alias_call(_id, _dict):
return ', '.join(alias) return ', '.join(alias)
else: else:
return str(alias) return str(alias)
# Return friendly elpasted time from time in seconds. # Return friendly elpasted time from time in seconds.
def since(_time): def since(_time):
now = int(time()) now = int(time())
@ -140,7 +140,7 @@ def since(_time):
def add_hb_peer(_peer_conf, _ctable_loc, _peer): def add_hb_peer(_peer_conf, _ctable_loc, _peer):
_ctable_loc[int_id(_peer)] = {} _ctable_loc[int_id(_peer)] = {}
_ctable_peer = _ctable_loc[int_id(_peer)] _ctable_peer = _ctable_loc[int_id(_peer)]
# if the Frequency is 000.xxx assume it's not an RF peer, otherwise format the text fields # if the Frequency is 000.xxx assume it's not an RF peer, otherwise format the text fields
if _peer_conf['TX_FREQ'][:3] == '000' or _peer_conf['RX_FREQ'][:3] == '000': if _peer_conf['TX_FREQ'][:3] == '000' or _peer_conf['RX_FREQ'][:3] == '000':
_ctable_peer['TX_FREQ'] = 'N/A' _ctable_peer['TX_FREQ'] = 'N/A'
@ -148,7 +148,7 @@ def add_hb_peer(_peer_conf, _ctable_loc, _peer):
else: else:
_ctable_peer['TX_FREQ'] = 'TX: ' + _peer_conf['TX_FREQ'][:3] + '.' + _peer_conf['TX_FREQ'][3:7] _ctable_peer['TX_FREQ'] = 'TX: ' + _peer_conf['TX_FREQ'][:3] + '.' + _peer_conf['TX_FREQ'][3:7]
_ctable_peer['RX_FREQ'] = 'RX: ' + _peer_conf['RX_FREQ'][:3] + '.' + _peer_conf['RX_FREQ'][3:7] _ctable_peer['RX_FREQ'] = 'RX: ' + _peer_conf['RX_FREQ'][:3] + '.' + _peer_conf['RX_FREQ'][3:7]
# timeslots are kinda complicated too. 0 = none, 1 or 2 mean that one slot, 3 is both, and anythign else it considered DMO # timeslots are kinda complicated too. 0 = none, 1 or 2 mean that one slot, 3 is both, and anythign else it considered DMO
if (_peer_conf['SLOTS'] == '0'): if (_peer_conf['SLOTS'] == '0'):
_ctable_peer['SLOTS'] = 'NONE' _ctable_peer['SLOTS'] = 'NONE'
@ -158,7 +158,7 @@ def add_hb_peer(_peer_conf, _ctable_loc, _peer):
_ctable_peer['SLOTS'] = 'BOTH' _ctable_peer['SLOTS'] = 'BOTH'
else: else:
_ctable_peer['SLOTS'] = 'DMO' _ctable_peer['SLOTS'] = 'DMO'
# Simple translation items # Simple translation items
_ctable_peer['COLORCODE'] = _peer_conf['COLORCODE'] _ctable_peer['COLORCODE'] = _peer_conf['COLORCODE']
_ctable_peer['CALLSIGN'] = _peer_conf['CALLSIGN'] _ctable_peer['CALLSIGN'] = _peer_conf['CALLSIGN']
@ -168,7 +168,7 @@ def add_hb_peer(_peer_conf, _ctable_loc, _peer):
_ctable_peer['IP'] = _peer_conf['IP'] _ctable_peer['IP'] = _peer_conf['IP']
_ctable_peer['PORT'] = _peer_conf['PORT'] _ctable_peer['PORT'] = _peer_conf['PORT']
#_ctable_peer['LAST_PING'] = _peer_conf['LAST_PING'] #_ctable_peer['LAST_PING'] = _peer_conf['LAST_PING']
# SLOT 1&2 - for real-time montior: make the structure for later use # SLOT 1&2 - for real-time montior: make the structure for later use
for ts in range(1,3): for ts in range(1,3):
_ctable_peer[ts]= {} _ctable_peer[ts]= {}
@ -179,13 +179,13 @@ def add_hb_peer(_peer_conf, _ctable_loc, _peer):
_ctable_peer[ts]['SUB'] = '' _ctable_peer[ts]['SUB'] = ''
_ctable_peer[ts]['SRC'] = '' _ctable_peer[ts]['SRC'] = ''
_ctable_peer[ts]['DEST'] = '' _ctable_peer[ts]['DEST'] = ''
# Build the HBlink connections table # Build the HBlink connections table
def build_hblink_table(_config, _stats_table): def build_hblink_table(_config, _stats_table):
for _hbp, _hbp_data in _config.iteritems(): for _hbp, _hbp_data in _config.iteritems():
if _hbp_data['ENABLED'] == True: if _hbp_data['ENABLED'] == True:
# Process Master Systems # Process Master Systems
if _hbp_data['MODE'] == 'MASTER': if _hbp_data['MODE'] == 'MASTER':
_stats_table['MASTERS'][_hbp] = {} _stats_table['MASTERS'][_hbp] = {}
@ -196,19 +196,20 @@ def build_hblink_table(_config, _stats_table):
_stats_table['MASTERS'][_hbp]['PEERS'] = {} _stats_table['MASTERS'][_hbp]['PEERS'] = {}
for _peer in _hbp_data['PEERS']: for _peer in _hbp_data['PEERS']:
add_hb_peer(_hbp_data['PEERS'][_peer], _stats_table['MASTERS'][_hbp]['PEERS'], _peer) add_hb_peer(_hbp_data['PEERS'][_peer], _stats_table['MASTERS'][_hbp]['PEERS'], _peer)
# Proccess Peer Systems # Proccess Peer Systems
elif _hbp_data['MODE'] == 'PEER': elif _hbp_data['MODE'] == 'PEER':
pprint(_hbp_data)
_stats_table['PEERS'][_hbp] = {} _stats_table['PEERS'][_hbp] = {}
_stats_table['PEERS'][_hbp]['CALLSIGN'] = _hbp_data['CALLSIGN'] _stats_table['PEERS'][_hbp]['CALLSIGN'] = _hbp_data['CALLSIGN']
_stats_table['PEERS'][_hbp]['LOCATION'] = _hbp_data['LOCATION'] _stats_table['PEERS'][_hbp]['LOCATION'] = _hbp_data['LOCATION']
_stats_table['PEERS'][_hbp]['RADIO_ID'] = int_id(_hbp_data['RADIO_ID']) _stats_table['PEERS'][_hbp]['RADIO_ID'] = int_id(_hbp_data['RADIO_ID'])
_stats_table['PEERS'][_hbp]['MASTER_IP'] = _hbp_data['MASTER_IP'] _stats_table['PEERS'][_hbp]['MASTER_IP'] = _hbp_data['MASTER_IP']
_stats_table['PEERS'][_hbp]['MASTER_PORT'] = _hbp_data['MASTER_PORT'] _stats_table['PEERS'][_hbp]['MASTER_PORT'] = _hbp_data['MASTER_PORT']
_stats_table['PEERS'][_hbp]['STATS'] = _hbp_data['STATS'] _stats_table['PEERS'][_hbp]['STATS'] = {}
_stats_table['PEERS'][_hbp]['STATS']['CONNECTION'] = _hbp_data['STATS']['CONNECTION'] _stats_table['PEERS'][_hbp]['STATS']['CONNECTION'] = _hbp_data['STATS']['CONNECTION']
_stats_table['PEERS'][_hbp]['STATS']['CONNECTED'] = since(_hbp_data['STATS']['CONNECTED']) _stats_table['PEERS'][_hbp]['STATS']['CONNECTED'] = since(_hbp_data['STATS']['CONNECTED'])
_stats_table['PEERS'][_hbp]['STATS']['PINGS_SENT'] = _hbp_data['STATS']['PINGS_SENT']
_stats_table['PEERS'][_hbp]['STATS']['PINGS_ACKD'] = _hbp_data['STATS']['PINGS_ACKD']
if _hbp_data['SLOTS'] == 0: if _hbp_data['SLOTS'] == 0:
_stats_table['PEERS'][_hbp]['SLOTS'] = 'NONE' _stats_table['PEERS'][_hbp]['SLOTS'] = 'NONE'
elif _hbp_data['SLOTS'] <= '2': elif _hbp_data['SLOTS'] <= '2':
@ -217,29 +218,40 @@ def build_hblink_table(_config, _stats_table):
_stats_table['PEERS'][_hbp]['SLOTS'] = 'BOTH' _stats_table['PEERS'][_hbp]['SLOTS'] = 'BOTH'
else: else:
_stats_table['SLOTS'][_hbp]['SLOTS'] = 'DMO' _stats_table['SLOTS'][_hbp]['SLOTS'] = 'DMO'
# SLOT 1&2 - for real-time montior: make the structure for later use
for ts in range(1,3):
_stats_table['PEERS'][_hbp][ts]= {}
_stats_table['PEERS'][_hbp][ts]['COLOR'] = ''
_stats_table['PEERS'][_hbp][ts]['BGCOLOR'] = ''
_stats_table['PEERS'][_hbp][ts]['TS'] = ''
_stats_table['PEERS'][_hbp][ts]['TYPE'] = ''
_stats_table['PEERS'][_hbp][ts]['SUB'] = ''
_stats_table['PEERS'][_hbp][ts]['SRC'] = ''
_stats_table['PEERS'][_hbp][ts]['DEST'] = ''
# Process OpenBridge systems # Process OpenBridge systems
elif _hbp_data['MODE'] == 'OPENBRIDGE': elif _hbp_data['MODE'] == 'OPENBRIDGE':
_stats_table['OPENBRIDGES'][_hbp] = {} _stats_table['OPENBRIDGES'][_hbp] = {}
_stats_table['OPENBRIDGES'][_hbp]['NETWORK_ID'] = int_id(_hbp_data['NETWORK_ID']) _stats_table['OPENBRIDGES'][_hbp]['NETWORK_ID'] = int_id(_hbp_data['NETWORK_ID'])
_stats_table['OPENBRIDGES'][_hbp]['TARGET_IP'] = _hbp_data['TARGET_IP'] _stats_table['OPENBRIDGES'][_hbp]['TARGET_IP'] = _hbp_data['TARGET_IP']
_stats_table['OPENBRIDGES'][_hbp]['TARGET_PORT'] = _hbp_data['TARGET_PORT'] _stats_table['OPENBRIDGES'][_hbp]['TARGET_PORT'] = _hbp_data['TARGET_PORT']
return(_stats_table) _stats_table['OPENBRIDGES'][_hbp]['STREAMS'] = {}
#return(_stats_table)
def update_hblink_table(_config, _stats_table): def update_hblink_table(_config, _stats_table):
logger.info('running update table')
# Is there a system in HBlink's config monitor doesn't know about? # Is there a system in HBlink's config monitor doesn't know about?
for _hbp in _config: for _hbp in _config:
add_list = [] add_list = []
if _config[_hbp]['MODE'] == 'MASTER': if _config[_hbp]['MODE'] == 'MASTER':
for _peer in _config[_hbp]['PEERS']: for _peer in _config[_hbp]['PEERS']:
if int_id(_peer) not in _stats_table['MASTERS'][_hbp]['PEERS']: if int_id(_peer) not in _stats_table['MASTERS'][_hbp]['PEERS']:
logger.info('Adding peer to CTABLE that has registerred: %s', int_id(_peer)) logger.info('Adding peer to CTABLE that has registerred: %s', int_id(_peer))
add_hb_peer(_config[_hbp]['PEERS'][_peer], _stats_table['MASTERS'][_hbp]['PEERS'], _peer) add_hb_peer(_config[_hbp]['PEERS'][_peer], _stats_table['MASTERS'][_hbp]['PEERS'], _peer)
# Is there a system in monitor that's been removed from HBlink's config?
# Is there a system in monitor that's been removed from HBlink's config?
for _hbp in _stats_table['MASTERS']: for _hbp in _stats_table['MASTERS']:
remove_list = [] remove_list = []
if _config[_hbp]['MODE'] == 'MASTER': if _config[_hbp]['MODE'] == 'MASTER':
@ -250,14 +262,18 @@ def update_hblink_table(_config, _stats_table):
for _peer in remove_list: for _peer in remove_list:
logger.info('Deleting stats peer not in hblink config: %s', _peer) logger.info('Deleting stats peer not in hblink config: %s', _peer)
del (_stats_table['MASTERS'][_hbp]['PEERS'][_peer]) del (_stats_table['MASTERS'][_hbp]['PEERS'][_peer])
# Update connection time # Update connection time
for _hbp in _stats_table['MASTERS']: for _hbp in _stats_table['MASTERS']:
if _config[_hbp]['MODE'] == 'MASTER': for _peer in _stats_table['MASTERS'][_hbp]['PEERS']:
for _peer in _stats_table['MASTERS'][_hbp]['PEERS']: if hex_str_4(_peer) in _config[_hbp]['PEERS']:
if hex_str_4(_peer) in _config[_hbp]['PEERS']: _stats_table['MASTERS'][_hbp]['PEERS'][_peer]['CONNECTED'] = since(_config[_hbp]['PEERS'][hex_str_4(_peer)]['CONNECTED'])
_stats_table['MASTERS'][_hbp]['PEERS'][_peer]['CONNECTED'] = since(_config[_hbp]['PEERS'][hex_str_4(_peer)]['CONNECTED'])
for _hbp in _stats_table['PEERS']:
_stats_table['PEERS'][_hbp]['STATS']['CONNECTED'] = since(_config[_hbp]['STATS']['CONNECTED'])
_stats_table['PEERS'][_hbp]['STATS']['PINGS_SENT'] = _config[_hbp]['STATS']['PINGS_SENT']
_stats_table['PEERS'][_hbp]['STATS']['PINGS_ACKD'] = _config[_hbp]['STATS']['PINGS_ACKD']
build_stats() build_stats()
# #
@ -291,12 +307,12 @@ def build_bridge_table(_bridges):
if system['ACTIVE'] == True: if system['ACTIVE'] == True:
_stats_table[_bridge][system['SYSTEM']]['ACTIVE'] = 'Connected' _stats_table[_bridge][system['SYSTEM']]['ACTIVE'] = 'Connected'
_stats_table[_bridge][system['SYSTEM']]['COLOR'] = GREEN _stats_table[_bridge][system['SYSTEM']]['COLOR'] = BLACK
_stats_table[_bridge][system['SYSTEM']]['BGCOLOR'] = BLACK _stats_table[_bridge][system['SYSTEM']]['BGCOLOR'] = GREEN
elif system['ACTIVE'] == False: elif system['ACTIVE'] == False:
_stats_table[_bridge][system['SYSTEM']]['ACTIVE'] = 'Disconnected' _stats_table[_bridge][system['SYSTEM']]['ACTIVE'] = 'Disconnected'
_stats_table[_bridge][system['SYSTEM']]['COLOR'] = RED _stats_table[_bridge][system['SYSTEM']]['COLOR'] = WHITE
_stats_table[_bridge][system['SYSTEM']]['BGCOLOR'] = WHITE _stats_table[_bridge][system['SYSTEM']]['BGCOLOR'] = RED
for i in range(len(system['ON'])): for i in range(len(system['ON'])):
system['ON'][i] = str(int_id(system['ON'][i])) system['ON'][i] = str(int_id(system['ON'][i]))
@ -336,16 +352,16 @@ def rts_update(p):
sourceSub = int(p[6]) sourceSub = int(p[6])
timeSlot = int(p[7]) timeSlot = int(p[7])
destination = int(p[8]) destination = int(p[8])
if system in CTABLE['MASTERS']: if system in CTABLE['MASTERS']:
for peer in CTABLE['MASTERS'][system]['PEERS']: for peer in CTABLE['MASTERS'][system]['PEERS']:
if sourcePeer == peer: if sourcePeer == peer:
color = '00ff00' bgcolor = GREEN
bgcolor = '000000' color = BLACK
else: else:
color = 'ff0000' bgcolor = RED
bgcolor = 'ffffff' color = WHITE
#color, bgcolor = '00ff00', '000000' if sourcePeer == peer else 'ff0000', '000000'
if action == 'START': if action == 'START':
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['TS'] = True CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['TS'] = True
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['COLOR'] = color CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['COLOR'] = color
@ -356,8 +372,8 @@ def rts_update(p):
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['DEST'] = destination CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['DEST'] = destination
if action == 'END': if action == 'END':
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['TS'] = False CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['TS'] = False
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['COLOR'] = 'ffffff' CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['COLOR'] = BLACK
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['BGCOLOR'] = '000000' CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['BGCOLOR'] = WHITE
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['TYPE'] = '' CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['TYPE'] = ''
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['SUB'] = '' CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['SUB'] = ''
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['SRC'] = '' CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['SRC'] = ''
@ -366,13 +382,34 @@ def rts_update(p):
else: else:
logger.warning('tried to update a tranmission for a peer not yet listed: system %s, action %s, callType %s, tx/rx %s, streamid %s, sourcePeer %s, sourceSub %s, timeSlot %s, destination %s ', system, action, callType, trx, streamId, sourcePeer, sourceSub, timeSlot, destination) logger.warning('tried to update a tranmission for a peer not yet listed: system %s, action %s, callType %s, tx/rx %s, streamid %s, sourcePeer %s, sourceSub %s, timeSlot %s, destination %s ', system, action, callType, trx, streamId, sourcePeer, sourceSub, timeSlot, destination)
if system in CTABLE['OPENBRIDGES']: if system in CTABLE['OPENBRIDGES']:
pass if action == 'START':
CTABLE['OPENBRIDGES'][system]['STREAMS'][streamId] = (alias_call(sourceSub, subscriber_ids), destination)
if system in CTABLE['PEERS']: if action == 'END':
pass if streamId in CTABLE['OPENBRIDGES'][system]['STREAMS']:
del CTABLE['OPENBRIDGES'][system]['STREAMS'][streamId]
build_stats() if system in CTABLE['PEERS']:
bgcolor = GREEN
if action == 'START':
CTABLE['PEERS'][system][timeSlot]['TS'] = True
CTABLE['PEERS'][system][timeSlot]['COLOR'] = BLACK
CTABLE['PEERS'][system][timeSlot]['BGCOLOR'] = bgcolor
CTABLE['PEERS'][system][timeSlot]['TYPE'] = callType
CTABLE['PEERS'][system][timeSlot]['SUB'] = sourceSub
CTABLE['PEERS'][system][timeSlot]['SRC'] = sourcePeer
CTABLE['PEERS'][system][timeSlot]['DEST'] = destination
if action == 'END':
CTABLE['PEERS'][system][timeSlot]['TS'] = False
CTABLE['PEERS'][system][timeSlot]['COLOR'] = BLACK
CTABLE['PEERS'][system][timeSlot]['BGCOLOR'] = WHITE
CTABLE['PEERS'][system][timeSlot]['TYPE'] = ''
CTABLE['PEERS'][system][timeSlot]['SUB'] = ''
CTABLE['PEERS'][system][timeSlot]['SRC'] = ''
CTABLE['PEERS'][system][timeSlot]['DEST'] = ''
build_stats()
# #
# PROCESS IN COMING MESSAGES AND TAKE THE CORRECT ACTION DEPENING ON THE OPCODE # PROCESS IN COMING MESSAGES AND TAKE THE CORRECT ACTION DEPENING ON THE OPCODE
@ -416,10 +453,10 @@ def process_message(_message):
dashboard_server.broadcast('l' + log_message) dashboard_server.broadcast('l' + log_message)
LOGBUF.append(log_message) LOGBUF.append(log_message)
else: else:
logging.debug('{}: UNKNOWN LOG MESSAGE'.format(_now)) logging.debug('{}: UNKNOWN LOG MESSAGE'.format(_now))
else: else:
logging.debug('got unknown opcode: {}, message: {}'.format(repr(opcode), repr(_message[1:]))) logging.debug('got unknown opcode: {}, message: {}'.format(repr(opcode), repr(_message[1:])))