From 8ecfeb97c6292f5a74c66b910170432a9eac952a Mon Sep 17 00:00:00 2001 From: Frederic Date: Thu, 4 Jun 2015 18:59:58 +0200 Subject: [PATCH] implemented shortcut functionality and dail timeout --- configreader.py | 3 ++- fetapdtest.py | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/configreader.py b/configreader.py index cefb826..6a1657e 100644 --- a/configreader.py +++ b/configreader.py @@ -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(), ) diff --git a/fetapdtest.py b/fetapdtest.py index 6f73984..7f07171 100644 --- a/fetapdtest.py +++ b/fetapdtest.py @@ -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)