|
|
|
@ -38,6 +38,9 @@ class AbstractState(object):
@@ -38,6 +38,9 @@ class AbstractState(object):
|
|
|
|
|
def on_invalid_number(self): |
|
|
|
|
raise IllegalEventError() |
|
|
|
|
|
|
|
|
|
def on_nummernschalter_active(self): |
|
|
|
|
raise IllegalEventError() |
|
|
|
|
|
|
|
|
|
def on_nummernschalter_input(self, num): |
|
|
|
|
raise IllegalEventError() |
|
|
|
|
|
|
|
|
@ -74,6 +77,9 @@ class IdleState(AbstractState):
@@ -74,6 +77,9 @@ class IdleState(AbstractState):
|
|
|
|
|
def on_gabelschalter_down(self): |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def on_nummernschalter_active(self, x): |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def on_nummernschalter_input(self, x): |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
@ -178,6 +184,10 @@ class DialingState(AbstractState):
@@ -178,6 +184,10 @@ class DialingState(AbstractState):
|
|
|
|
|
self.__on_leave() |
|
|
|
|
return IdleState |
|
|
|
|
|
|
|
|
|
def on_nummernschalter_active(self): |
|
|
|
|
if self.__dial_tone: |
|
|
|
|
self._controller.get_phone().stop_playing() |
|
|
|
|
|
|
|
|
|
def on_nummernschalter_input(self, num): |
|
|
|
|
print('nummernschalter: %d' % (num)) |
|
|
|
|
if self.__dial_tone: |
|
|
|
@ -257,7 +267,11 @@ def gabelschalter_cb(state):
@@ -257,7 +267,11 @@ def gabelschalter_cb(state):
|
|
|
|
|
else: |
|
|
|
|
c.queue_event('gabelschalter_down') |
|
|
|
|
|
|
|
|
|
def nummernschalter_cb(digit): |
|
|
|
|
def nummernschalter_active_cb(): |
|
|
|
|
global c |
|
|
|
|
c.queue_event('nummernschalter_active') |
|
|
|
|
|
|
|
|
|
def nummernschalter_done_cb(digit): |
|
|
|
|
global c |
|
|
|
|
c.queue_event('nummernschalter_input', digit) |
|
|
|
|
|
|
|
|
@ -284,7 +298,8 @@ if __name__ == '__main__':
@@ -284,7 +298,8 @@ if __name__ == '__main__':
|
|
|
|
|
c = StateMachineController(phone, feap) |
|
|
|
|
|
|
|
|
|
feap.add_gabelschalter_callback(gabelschalter_cb) |
|
|
|
|
feap.add_nummernschalter_callback(nummernschalter_cb) |
|
|
|
|
feap.add_nummernschalter_active_callback(nummernschalter_active_cb) |
|
|
|
|
feap.add_nummernschalter_done_callback(nummernschalter_done_cb) |
|
|
|
|
phone.add_event_cb(phone_cb) |
|
|
|
|
|
|
|
|
|
phone.start() |
|
|
|
|