|
|
@ -75,7 +75,7 @@ class BaseState(AbstractState): |
|
|
|
return None |
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
def on_incoming_call(self): |
|
|
|
def on_incoming_call(self): |
|
|
|
self._controller.get_phone().decline_call() |
|
|
|
self._controller.phone.decline_call() |
|
|
|
|
|
|
|
|
|
|
|
def on_call_ended(self): |
|
|
|
def on_call_ended(self): |
|
|
|
# When an incoming call is declined, a call_ended event occurs, which |
|
|
|
# When an incoming call is declined, a call_ended event occurs, which |
|
|
@ -92,7 +92,7 @@ class BaseState(AbstractState): |
|
|
|
class InitState(BaseState): |
|
|
|
class InitState(BaseState): |
|
|
|
def __init__(self, controller): |
|
|
|
def __init__(self, controller): |
|
|
|
super(InitState, self).__init__(controller) |
|
|
|
super(InitState, self).__init__(controller) |
|
|
|
self._controller.get_feap().set_schauzeichen(True) |
|
|
|
self._controller.feap.set_schauzeichen(True) |
|
|
|
|
|
|
|
|
|
|
|
def on_registration_in_progress(self): |
|
|
|
def on_registration_in_progress(self): |
|
|
|
print('registration in progress') |
|
|
|
print('registration in progress') |
|
|
@ -104,7 +104,7 @@ class RegisteringState(BaseState): |
|
|
|
|
|
|
|
|
|
|
|
def on_registration_successful(self): |
|
|
|
def on_registration_successful(self): |
|
|
|
print('registration successful') |
|
|
|
print('registration successful') |
|
|
|
self._controller.get_feap().set_schauzeichen(False) |
|
|
|
self._controller.feap.set_schauzeichen(False) |
|
|
|
return IdleState |
|
|
|
return IdleState |
|
|
|
|
|
|
|
|
|
|
|
class IdleState(BaseState): |
|
|
|
class IdleState(BaseState): |
|
|
@ -119,10 +119,10 @@ class IdleState(BaseState): |
|
|
|
class SchelltState(BaseState): |
|
|
|
class SchelltState(BaseState): |
|
|
|
def __init__(self, controller): |
|
|
|
def __init__(self, controller): |
|
|
|
super(SchelltState, self).__init__(controller) |
|
|
|
super(SchelltState, self).__init__(controller) |
|
|
|
self._controller.get_feap().set_wecker(True) |
|
|
|
self._controller.feap.set_wecker(True) |
|
|
|
|
|
|
|
|
|
|
|
def leave(self): |
|
|
|
def leave(self): |
|
|
|
self._controller.get_feap().set_wecker(False) |
|
|
|
self._controller.feap.set_wecker(False) |
|
|
|
|
|
|
|
|
|
|
|
def on_gabelschalter_up(self): |
|
|
|
def on_gabelschalter_up(self): |
|
|
|
return AcceptingState |
|
|
|
return AcceptingState |
|
|
@ -133,7 +133,7 @@ class SchelltState(BaseState): |
|
|
|
class AcceptingState(BaseState): |
|
|
|
class AcceptingState(BaseState): |
|
|
|
def __init__(self, controller): |
|
|
|
def __init__(self, controller): |
|
|
|
super(AcceptingState, self).__init__(controller) |
|
|
|
super(AcceptingState, self).__init__(controller) |
|
|
|
self._controller.get_phone().accept_call() |
|
|
|
self._controller.phone.accept_call() |
|
|
|
|
|
|
|
|
|
|
|
def on_call_accepted(self): |
|
|
|
def on_call_accepted(self): |
|
|
|
return CallRunningState |
|
|
|
return CallRunningState |
|
|
@ -141,7 +141,7 @@ class AcceptingState(BaseState): |
|
|
|
class CallTerminatingState(BaseState): |
|
|
|
class CallTerminatingState(BaseState): |
|
|
|
def __init__(self, controller): |
|
|
|
def __init__(self, controller): |
|
|
|
super(CallTerminatingState, self).__init__(controller) |
|
|
|
super(CallTerminatingState, self).__init__(controller) |
|
|
|
self._controller.get_phone().end_call() |
|
|
|
self._controller.phone.end_call() |
|
|
|
|
|
|
|
|
|
|
|
def on_call_ended(self): |
|
|
|
def on_call_ended(self): |
|
|
|
return IdleState |
|
|
|
return IdleState |
|
|
@ -156,10 +156,10 @@ class ForgottenState(BaseState): |
|
|
|
class BusyBeepingState(BaseState): |
|
|
|
class BusyBeepingState(BaseState): |
|
|
|
def __init__(self, controller): |
|
|
|
def __init__(self, controller): |
|
|
|
super(BusyBeepingState, self).__init__(controller) |
|
|
|
super(BusyBeepingState, self).__init__(controller) |
|
|
|
self._controller.get_phone().play_busy_tone() |
|
|
|
self._controller.phone.play_busy_tone() |
|
|
|
|
|
|
|
|
|
|
|
def leave(self): |
|
|
|
def leave(self): |
|
|
|
self._controller.get_phone().stop_playing() |
|
|
|
self._controller.phone.stop_playing() |
|
|
|
|
|
|
|
|
|
|
|
def on_timeout(self): |
|
|
|
def on_timeout(self): |
|
|
|
return ForgottenState |
|
|
|
return ForgottenState |
|
|
@ -175,6 +175,13 @@ class CallRunningState(BaseState): |
|
|
|
return BusyBeepingState |
|
|
|
return BusyBeepingState |
|
|
|
|
|
|
|
|
|
|
|
class WecktState(BaseState): |
|
|
|
class WecktState(BaseState): |
|
|
|
|
|
|
|
def __init__(self, controller): |
|
|
|
|
|
|
|
super(WecktState, self).__init__(controller) |
|
|
|
|
|
|
|
self._controller.phone.play_ringback_tone() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def leave(self): |
|
|
|
|
|
|
|
self._controller.phone.stop_playing() |
|
|
|
|
|
|
|
|
|
|
|
def on_gabelschalter_down(self): |
|
|
|
def on_gabelschalter_down(self): |
|
|
|
return CallTerminatingState |
|
|
|
return CallTerminatingState |
|
|
|
|
|
|
|
|
|
|
@ -204,13 +211,13 @@ class ConnectingState(BaseState): |
|
|
|
class DialingState(BaseState): |
|
|
|
class DialingState(BaseState): |
|
|
|
def __init__(self, controller): |
|
|
|
def __init__(self, controller): |
|
|
|
super(DialingState, self).__init__(controller) |
|
|
|
super(DialingState, self).__init__(controller) |
|
|
|
self._controller.get_phone().play_dial_tone() |
|
|
|
self._controller.phone.play_dial_tone() |
|
|
|
self.__dial_tone = True |
|
|
|
self.__dial_tone = True |
|
|
|
self.__number = '' |
|
|
|
self.__number = '' |
|
|
|
|
|
|
|
|
|
|
|
def leave(self): |
|
|
|
def leave(self): |
|
|
|
if self.__dial_tone: |
|
|
|
if self.__dial_tone: |
|
|
|
self._controller.get_phone().stop_playing() |
|
|
|
self._controller.phone.stop_playing() |
|
|
|
self._controller.abort_timeout() |
|
|
|
self._controller.abort_timeout() |
|
|
|
|
|
|
|
|
|
|
|
def on_gabelschalter_down(self): |
|
|
|
def on_gabelschalter_down(self): |
|
|
@ -219,28 +226,29 @@ class DialingState(BaseState): |
|
|
|
def on_nummernschalter_active(self): |
|
|
|
def on_nummernschalter_active(self): |
|
|
|
self._controller.abort_timeout() |
|
|
|
self._controller.abort_timeout() |
|
|
|
if self.__dial_tone: |
|
|
|
if self.__dial_tone: |
|
|
|
self._controller.get_phone().stop_playing() |
|
|
|
self._controller.phone.stop_playing() |
|
|
|
|
|
|
|
|
|
|
|
def on_nummernschalter_input(self, num): |
|
|
|
def on_nummernschalter_input(self, num): |
|
|
|
print('nummernschalter: %d' % (num)) |
|
|
|
print('nummernschalter: %d' % (num)) |
|
|
|
if self.__dial_tone: |
|
|
|
if self.__dial_tone: |
|
|
|
self._controller.get_phone().stop_playing() |
|
|
|
self._controller.phone.stop_playing() |
|
|
|
self.__number += str(num) |
|
|
|
self.__number += str(num) |
|
|
|
self._controller.abort_timeout() |
|
|
|
self._controller.abort_timeout() |
|
|
|
self._controller.set_timeout(5000) |
|
|
|
self._controller.set_timeout(5000) |
|
|
|
|
|
|
|
|
|
|
|
def on_timeout(self): |
|
|
|
def on_timeout(self): |
|
|
|
print 'Dialing number:', self.__number |
|
|
|
print 'Dialing number:', self.__number |
|
|
|
self._controller.get_phone().call(self.__number) |
|
|
|
self._controller.phone.call(self.__number) |
|
|
|
return ConnectingState |
|
|
|
return ConnectingState |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class StateMachineController(object): |
|
|
|
class StateMachineController(object): |
|
|
|
def __init__(self, phone, feap): |
|
|
|
def __init__(self, phone, feap): |
|
|
|
self.__state = InitState(self) |
|
|
|
|
|
|
|
self.__phone = phone |
|
|
|
self.__phone = phone |
|
|
|
self.__feap = feap |
|
|
|
self.__feap = feap |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.__state = InitState(self) |
|
|
|
|
|
|
|
|
|
|
|
self.__timeout = None |
|
|
|
self.__timeout = None |
|
|
|
|
|
|
|
|
|
|
|
self.__running = True |
|
|
|
self.__running = True |
|
|
@ -284,11 +292,13 @@ class StateMachineController(object): |
|
|
|
self.__timeout.cancel() |
|
|
|
self.__timeout.cancel() |
|
|
|
self.__timeout = None |
|
|
|
self.__timeout = None |
|
|
|
|
|
|
|
|
|
|
|
def get_phone(self): |
|
|
|
@property |
|
|
|
return phone |
|
|
|
def phone(self): |
|
|
|
|
|
|
|
return self.__phone |
|
|
|
|
|
|
|
|
|
|
|
def get_feap(self): |
|
|
|
@property |
|
|
|
return feap |
|
|
|
def feap(self): |
|
|
|
|
|
|
|
return self.__feap |
|
|
|
|
|
|
|
|
|
|
|
def stop(self, hard=False): |
|
|
|
def stop(self, hard=False): |
|
|
|
if hard: |
|
|
|
if hard: |
|
|
|