implemented shortcut functionality and dail timeout
This commit is contained in:
parent
37e5042808
commit
8ecfeb97c6
2 changed files with 16 additions and 6 deletions
|
@ -51,6 +51,7 @@ class ConfigurationReader(object):
|
|||
for row in csv.DictReader(csvfile):
|
||||
print 'row', row
|
||||
shortcuts[row['shortcut']] = row['number']
|
||||
print 'shortcuts:', shortcuts
|
||||
return shortcuts
|
||||
|
||||
|
||||
|
@ -70,7 +71,7 @@ class ConfigurationReader(object):
|
|||
)
|
||||
|
||||
self.__dialconfig = fetapdtest.DialConfiguration(
|
||||
self.__get_global_val('dial_timeout'),
|
||||
self.__get_global_val_int('dial_timeout'),
|
||||
self.__read_shortcuts(),
|
||||
)
|
||||
|
||||
|
|
|
@ -241,18 +241,23 @@ class DialingState(BaseState):
|
|||
self._controller.phone.stop_playing()
|
||||
self.__number += str(num)
|
||||
self._controller.abort_timeout()
|
||||
self._controller.set_timeout(5000)
|
||||
self._controller.set_timeout(self._controller.dialconfig.dial_timeout * 1000)
|
||||
|
||||
def on_timeout(self):
|
||||
print 'Dialing number:', self.__number
|
||||
self._controller.phone.call(self.__number)
|
||||
number = self.__number
|
||||
print 'Dialing number:', number
|
||||
if number in self._controller.dialconfig.shortcuts:
|
||||
number = self._controller.dialconfig.shortcuts[number]
|
||||
print 'shortcut resolved:', number
|
||||
self._controller.phone.call(number)
|
||||
return ConnectingState
|
||||
|
||||
|
||||
class StateMachineController(object):
|
||||
def __init__(self, phone, feap):
|
||||
def __init__(self, phone, feap, dialconfig):
|
||||
self.__phone = phone
|
||||
self.__feap = feap
|
||||
self.__dialconfig = dialconfig
|
||||
|
||||
self.__state = InitState(self)
|
||||
|
||||
|
@ -307,6 +312,10 @@ class StateMachineController(object):
|
|||
def feap(self):
|
||||
return self.__feap
|
||||
|
||||
@property
|
||||
def dialconfig(self):
|
||||
return self.__dialconfig
|
||||
|
||||
def stop(self, hard=False):
|
||||
if hard:
|
||||
self.__running = False
|
||||
|
@ -354,7 +363,7 @@ if __name__ == '__main__':
|
|||
|
||||
phone = PhoneInterface(cfg.phoneconfig)
|
||||
feap = FeApUserInterface(cfg.pinconfig)
|
||||
c = StateMachineController(phone, feap)
|
||||
c = StateMachineController(phone, feap, cfg.dialconfig)
|
||||
|
||||
feap.add_gabelschalter_callback(gabelschalter_cb)
|
||||
feap.add_nummernschalter_active_callback(nummernschalter_active_cb)
|
||||
|
|
Loading…
Reference in a new issue