*NOT_BACKWARD_COMPATIBLE* changes
Changes to the REPORTS section of the config and dmrlink.py to pave the way for more flexible reporting types.
This commit is contained in:
parent
d2a73a044e
commit
ec9c20d5ee
30
dmrlink.py
30
dmrlink.py
@ -77,10 +77,10 @@ try:
|
|||||||
elif section == 'REPORTS':
|
elif section == 'REPORTS':
|
||||||
# Process REPORTS items in the configuration
|
# Process REPORTS items in the configuration
|
||||||
REPORTS = {
|
REPORTS = {
|
||||||
'REPORT_PEERS': config.getboolean(section, 'REPORT_PEERS'),
|
'REPORT_NETWORKS': config.get(section, 'REPORT_NETWORKS'),
|
||||||
'REPORT_INTERVAL': config.getint(section, 'REPORT_INTERVAL'),
|
'REPORT_INTERVAL': config.getint(section, 'REPORT_INTERVAL'),
|
||||||
'PEER_REPORT_INC_MODE': config.getboolean(section, 'PEER_REPORT_INC_MODE'),
|
'PRINT_PEERS_INC_MODE': config.getboolean(section, 'PRINT_PEERS_INC_MODE'),
|
||||||
'PEER_REPORT_INC_FLAGS': config.getboolean(section, 'PEER_REPORT_INC_FLAGS')
|
'PRINT_PEERS_INC_FLAGS': config.getboolean(section, 'PRINT_PEERS_INC_FLAGS')
|
||||||
}
|
}
|
||||||
|
|
||||||
elif section == 'LOGGER':
|
elif section == 'LOGGER':
|
||||||
@ -551,11 +551,11 @@ def print_peer_list(_network):
|
|||||||
|
|
||||||
print('\tRADIO ID: {} {}' .format(int_id(peer), me))
|
print('\tRADIO ID: {} {}' .format(int_id(peer), me))
|
||||||
print('\t\tIP Address: {}:{}' .format(_this_peer['IP'], _this_peer['PORT']))
|
print('\t\tIP Address: {}:{}' .format(_this_peer['IP'], _this_peer['PORT']))
|
||||||
if _this_peer['MODE_DECODE'] and REPORTS['PEER_REPORT_INC_MODE']:
|
if _this_peer['MODE_DECODE'] and REPORTS['PRINT_PEERS_INC_MODE']:
|
||||||
print('\t\tMode Values:')
|
print('\t\tMode Values:')
|
||||||
for name, value in _this_peer['MODE_DECODE'].items():
|
for name, value in _this_peer['MODE_DECODE'].items():
|
||||||
print('\t\t\t{}: {}' .format(name, value))
|
print('\t\t\t{}: {}' .format(name, value))
|
||||||
if _this_peer['FLAGS_DECODE'] and REPORTS['PEER_REPORT_INC_FLAGS']:
|
if _this_peer['FLAGS_DECODE'] and REPORTS['PRINT_PEERS_INC_FLAGS']:
|
||||||
print('\t\tService Flags:')
|
print('\t\tService Flags:')
|
||||||
for name, value in _this_peer['FLAGS_DECODE'].items():
|
for name, value in _this_peer['FLAGS_DECODE'].items():
|
||||||
print('\t\t\t{}: {}' .format(name, value))
|
print('\t\t\t{}: {}' .format(name, value))
|
||||||
@ -573,11 +573,11 @@ def print_master(_network):
|
|||||||
_master = NETWORK[_network]['MASTER']
|
_master = NETWORK[_network]['MASTER']
|
||||||
print('Master for %s' % _network)
|
print('Master for %s' % _network)
|
||||||
print('\tRADIO ID: {}' .format(int(h(_master['RADIO_ID']), 16)))
|
print('\tRADIO ID: {}' .format(int(h(_master['RADIO_ID']), 16)))
|
||||||
if _master['MODE_DECODE'] and REPORTS['PEER_REPORT_INC_MODE']:
|
if _master['MODE_DECODE'] and REPORTS['PRINT_PEERS_INC_MODE']:
|
||||||
print('\t\tMode Values:')
|
print('\t\tMode Values:')
|
||||||
for name, value in _master['MODE_DECODE'].items():
|
for name, value in _master['MODE_DECODE'].items():
|
||||||
print('\t\t\t{}: {}' .format(name, value))
|
print('\t\t\t{}: {}' .format(name, value))
|
||||||
if _master['FLAGS_DECODE'] and REPORTS['PEER_REPORT_INC_FLAGS']:
|
if _master['FLAGS_DECODE'] and REPORTS['PRINT_PEERS_INC_FLAGS']:
|
||||||
print('\t\tService Flags:')
|
print('\t\tService Flags:')
|
||||||
for name, value in _master['FLAGS_DECODE'].items():
|
for name, value in _master['FLAGS_DECODE'].items():
|
||||||
print('\t\t\t{}: {}' .format(name, value))
|
print('\t\t\t{}: {}' .format(name, value))
|
||||||
@ -962,20 +962,30 @@ class IPSC(DatagramProtocol):
|
|||||||
self._master_maintenance = task.LoopingCall(self.master_maintenance_loop)
|
self._master_maintenance = task.LoopingCall(self.master_maintenance_loop)
|
||||||
self._master_maintenance_loop = self._master_maintenance.start(self._local['ALIVE_TIMER'])
|
self._master_maintenance_loop = self._master_maintenance.start(self._local['ALIVE_TIMER'])
|
||||||
#
|
#
|
||||||
# WE ALWAYS DO THIS
|
# INITIALIZE THE REPORTING LOOP IF CONFIGURED
|
||||||
|
if REPORTS['REPORT_NETWORKS']:
|
||||||
self._reporting = task.LoopingCall(self.reporting_loop)
|
self._reporting = task.LoopingCall(self.reporting_loop)
|
||||||
self._reporting_loop = self._reporting.start(REPORTS['REPORT_INTERVAL'])
|
self._reporting_loop = self._reporting.start(REPORTS['REPORT_INTERVAL'])
|
||||||
|
|
||||||
|
|
||||||
# Timed loop used for reporting IPSC status
|
# Timed loop used for reporting IPSC status
|
||||||
#
|
#
|
||||||
|
# REPORT BASED ON THE TYPE SELECTED IN THE MAIN CONFIG FILE
|
||||||
|
if REPORTS['REPORT_NETWORKS'] == 'PICKLE':
|
||||||
|
def reporting_loop(self):
|
||||||
|
logger.debug('(%s) Periodic Reporting Loop Started', self._network)
|
||||||
|
|
||||||
|
elif REPORTS['REPORT_NETWORKS'] == 'JSON':
|
||||||
|
def reporting_loop(self):
|
||||||
|
logger.debug('(%s) Periodic Reporting Loop Started', self._network)
|
||||||
|
|
||||||
|
elif REPORTS['REPORT_NETWORKS'] == 'PRINT':
|
||||||
def reporting_loop(self):
|
def reporting_loop(self):
|
||||||
# Right now, without this, we really don't know anything is happening.
|
|
||||||
logger.debug('(%s) Periodic Reporting Loop Started', self._network)
|
logger.debug('(%s) Periodic Reporting Loop Started', self._network)
|
||||||
if REPORTS['REPORT_PEERS']:
|
|
||||||
print_master(self._network)
|
print_master(self._network)
|
||||||
print_peer_list(self._network)
|
print_peer_list(self._network)
|
||||||
|
|
||||||
|
|
||||||
# Timed loop used for IPSC connection Maintenance when we are the MASTER
|
# Timed loop used for IPSC connection Maintenance when we are the MASTER
|
||||||
#
|
#
|
||||||
def master_maintenance_loop(self):
|
def master_maintenance_loop(self):
|
||||||
|
@ -8,18 +8,22 @@
|
|||||||
PATH: /absolute/path/to/DMRlink
|
PATH: /absolute/path/to/DMRlink
|
||||||
|
|
||||||
|
|
||||||
# STDOUT REPORTING CONFIG
|
# NETWORK REPORTING CONFIGURATION
|
||||||
# Enabling "REPORT_PEERS" will cause a print-out of the peers in each
|
# Enabling "REPORT_NETWORKS" will cause a reporting action for
|
||||||
# IPSC each time the periodic reporting loop runs, that perios is
|
# IPSC each time the periodic reporting loop runs, that period is
|
||||||
# specifiec by "REPORT_INTERVAL" in seconds. Likewise, the
|
# specifiec by "REPORT_INTERVAL" in seconds. Possible values
|
||||||
# additional features listed will cause that list to either include
|
# for "REPORT_NETWORKS" are:
|
||||||
# or not include MODE and/or SERVICE FLAG details.
|
# PICKLE - a Python pickle file of the network's data structure
|
||||||
|
# JSON - a JSON file of the network's data structure
|
||||||
|
# PRINT - a pretty print (STOUT) of the data structure
|
||||||
|
# "PRINT_PEERS_INC_MODE" - Boolean to include mode bits
|
||||||
|
# "PRINT_PEERS_INC_FLAGS" - Boolean to include flag bits
|
||||||
#
|
#
|
||||||
[REPORTS]
|
[REPORTS]
|
||||||
REPORT_PEERS: 0
|
REPORT_NETWORKS:
|
||||||
REPORT_INTERVAL: 60
|
REPORT_INTERVAL: 60
|
||||||
PEER_REPORT_INC_MODE: 0
|
PRINT_PEERS_INC_MODE: 0
|
||||||
PEER_REPORT_INC_FLAGS: 0
|
PRINT_PEERS_INC_FLAGS: 0
|
||||||
|
|
||||||
|
|
||||||
# SYSTEM LOGGER CONFIGURAITON
|
# SYSTEM LOGGER CONFIGURAITON
|
||||||
|
Loading…
x
Reference in New Issue
Block a user