|
|
@ -49,6 +49,9 @@ class AbstractState(object): |
|
|
|
def on_timeout(self): |
|
|
|
def on_timeout(self): |
|
|
|
raise IllegalEventError() |
|
|
|
raise IllegalEventError() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def leave(self): |
|
|
|
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
The basic state that every other state inherits from. It defines default |
|
|
|
The basic state that every other state inherits from. It defines default |
|
|
@ -112,15 +115,13 @@ class SchelltState(BaseState): |
|
|
|
super(SchelltState, self).__init__(controller) |
|
|
|
super(SchelltState, self).__init__(controller) |
|
|
|
self._controller.get_feap().set_wecker(True) |
|
|
|
self._controller.get_feap().set_wecker(True) |
|
|
|
|
|
|
|
|
|
|
|
def __on_leave(self): |
|
|
|
def leave(self): |
|
|
|
self._controller.get_feap().set_wecker(False) |
|
|
|
self._controller.get_feap().set_wecker(False) |
|
|
|
|
|
|
|
|
|
|
|
def on_gabelschalter_up(self): |
|
|
|
def on_gabelschalter_up(self): |
|
|
|
self.__on_leave() |
|
|
|
|
|
|
|
return AcceptingState |
|
|
|
return AcceptingState |
|
|
|
|
|
|
|
|
|
|
|
def on_call_ended(self): |
|
|
|
def on_call_ended(self): |
|
|
|
self.__on_leave() |
|
|
|
|
|
|
|
return IdleState |
|
|
|
return IdleState |
|
|
|
|
|
|
|
|
|
|
|
class AcceptingState(BaseState): |
|
|
|
class AcceptingState(BaseState): |
|
|
@ -151,14 +152,13 @@ class BusyBeepingState(BaseState): |
|
|
|
super(BusyBeepingState, self).__init__(controller) |
|
|
|
super(BusyBeepingState, self).__init__(controller) |
|
|
|
self._controller.get_phone().play_busy_tone() |
|
|
|
self._controller.get_phone().play_busy_tone() |
|
|
|
|
|
|
|
|
|
|
|
def __on_leave(self): |
|
|
|
def leave(self): |
|
|
|
self._controller.get_phone().stop_playing() |
|
|
|
self._controller.get_phone().stop_playing() |
|
|
|
|
|
|
|
|
|
|
|
def on_timeout(self): |
|
|
|
def on_timeout(self): |
|
|
|
return ForgottenState |
|
|
|
return ForgottenState |
|
|
|
|
|
|
|
|
|
|
|
def on_gabelschalter_down(self): |
|
|
|
def on_gabelschalter_down(self): |
|
|
|
self.__on_leave() |
|
|
|
|
|
|
|
return IdleState |
|
|
|
return IdleState |
|
|
|
|
|
|
|
|
|
|
|
class CallRunningState(BaseState): |
|
|
|
class CallRunningState(BaseState): |
|
|
@ -202,13 +202,12 @@ class DialingState(BaseState): |
|
|
|
self.__dial_tone = True |
|
|
|
self.__dial_tone = True |
|
|
|
self.__number = '' |
|
|
|
self.__number = '' |
|
|
|
|
|
|
|
|
|
|
|
def __on_leave(self): |
|
|
|
def leave(self): |
|
|
|
if self.__dial_tone: |
|
|
|
if self.__dial_tone: |
|
|
|
self._controller.get_phone().stop_playing() |
|
|
|
self._controller.get_phone().stop_playing() |
|
|
|
self._controller.abort_timeout() |
|
|
|
self._controller.abort_timeout() |
|
|
|
|
|
|
|
|
|
|
|
def on_gabelschalter_down(self): |
|
|
|
def on_gabelschalter_down(self): |
|
|
|
self.__on_leave() |
|
|
|
|
|
|
|
return IdleState |
|
|
|
return IdleState |
|
|
|
|
|
|
|
|
|
|
|
def on_nummernschalter_active(self): |
|
|
|
def on_nummernschalter_active(self): |
|
|
@ -225,7 +224,6 @@ class DialingState(BaseState): |
|
|
|
self._controller.set_timeout(5000) |
|
|
|
self._controller.set_timeout(5000) |
|
|
|
|
|
|
|
|
|
|
|
def on_timeout(self): |
|
|
|
def on_timeout(self): |
|
|
|
self.__on_leave() |
|
|
|
|
|
|
|
print 'Dialing number:', self.__number |
|
|
|
print 'Dialing number:', self.__number |
|
|
|
self._controller.get_phone().call(self.__number) |
|
|
|
self._controller.get_phone().call(self.__number) |
|
|
|
return ConnectingState |
|
|
|
return ConnectingState |
|
|
@ -259,6 +257,9 @@ class StateMachineController(object): |
|
|
|
if not newstate: |
|
|
|
if not newstate: |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.__state.leave() |
|
|
|
|
|
|
|
self.abort_timeout() |
|
|
|
|
|
|
|
|
|
|
|
oldstate = self.__state.__class__ |
|
|
|
oldstate = self.__state.__class__ |
|
|
|
print('%s -> %s' % (oldstate.__name__, newstate.__name__)) |
|
|
|
print('%s -> %s' % (oldstate.__name__, newstate.__name__)) |
|
|
|
self.__state = newstate(self) |
|
|
|
self.__state = newstate(self) |
|
|
|