Prep for adding rule timers

This commit is contained in:
Cort Buffington 2016-08-05 09:20:06 -05:00
parent 70bf6d3dce
commit dba648bb89
1 changed files with 18 additions and 7 deletions

View File

@ -35,6 +35,9 @@ from twisted.internet import task
from binascii import b2a_hex as h
from time import time
# For debugging
from pprint import pprint
import sys
from dmrlink import IPSC, NETWORK, networks, REPORTS, reporting_loop, dmr_nat, logger, hex_str_3, hex_str_4, int_id
@ -85,6 +88,9 @@ for _ipsc in RULES_FILE:
_rule['ON'][i] = hex_str_3(_rule['ON'][i])
for i, e in enumerate(_rule['OFF']):
_rule['OFF'][i] = hex_str_3(_rule['OFF'][i])
_rule['ON_TIME'] = _rule['ON_TIME']*60
_rule['OFF_TIME'] = _rule['OFF_TIME']*60
_rule['TIMER'] = time()
if _ipsc not in NETWORK:
sys.exit('ERROR: Bridge rules found for an IPSC network not configured in main configuration')
for _ipsc in NETWORK:
@ -136,8 +142,9 @@ else:
def allow_sub(_sub):
return True
# Run this every minute for rule timer updates
def rule_timer_loop():
pass
class bridgeIPSC(IPSC):
def __init__(self, *args, **kwargs):
@ -393,4 +400,8 @@ if __name__ == '__main__':
reporting = task.LoopingCall(reporting_loop)
reporting.start(REPORTS['REPORT_INTERVAL'])
# INITIALIZE THE REPORTING LOOP IF CONFIGURED
rule_timer = task.LoopingCall(rule_timer_loop)
rule_timer.start(60)
reactor.run()