X-Git-Url: https://git.ralfj.de/saartuer.git/blobdiff_plain/311d7fb5023a6c80ce370d79a6f52495fd54d867..c0afad48bf55284285c1491965c971c9573fcd1a:/statemachine.py diff --git a/statemachine.py b/statemachine.py index fe92682..81b6b87 100644 --- a/statemachine.py +++ b/statemachine.py @@ -73,8 +73,6 @@ class StateMachine(): raise Exception("Unknown command number: %d" % ev) class StateStart(State): - def __init__(self, sm): - State.__init__(self,sm) def handle_pins_event(self): thepins = self.pins() for pin in thepins: @@ -86,8 +84,6 @@ class StateMachine(): return StateAuf class StateZu(State): - def __init__(self,sm): - State.__init__(self,sm) def handle_pins_event(self): pins = self.pins() if not pins.door_locked: @@ -97,7 +93,7 @@ class StateMachine(): class StateOpening(State): def __init__(self,callback,sm): - State.__init__(self,sm) + super().__init__(self,sm) self.callbacks=[callback] # FIXME: can we send "202 processing: Trying to open the door" here? Are the callbacks multi-use? self.tries = 0 @@ -128,16 +124,13 @@ class StateMachine(): return StateZu(self.state_machine) class AbstractStateWhereOpeningIsRedundant(State): - def __init__ (self,sm): - State.__init__(sm): def handle_open_event(self, callback): + # FIXME contradicting original plan where open would be ignored in StateAboutToOpen? callback("299 redundant: Space seems to be already open. Still processing your request tough.") logger.warning("Received OPEN command in StateAboutToOpen. This should not be necessary.") self.actor().act(Actor.CMD_OPEN) class StateAboutToOpen(AbstractStateWhereOpeningIsRedundant): - def __init__(self, sm): - AbstractStateWhereOpeningIsRedundant.__init__(sm) def handle_pins_event(self): pins = self.pins() if pins.door_locked: @@ -155,7 +148,7 @@ class StateMachine(): class StateAuf(AbstractStateWhereOpeningIsRedundant): def __init__(self,sm): - AbstractStateWhereOpeningIsRedundant.__init__(sm) + super().__init__(sm) self.last_buzzed = None def handle_pins_event(self): pins = self.pins() @@ -199,10 +192,10 @@ class StateMachine(): def _callback(self, cmd, arg=None): # update pins if cmd == StateMachine.CMD_PINS: - self.old_pins = self.pins self.pins = arg # handle stuff newstate = self.current_state.handle_event(cmd,arg) # returns None or an instance of the new state + self.old_pins = self.pins # FIXME not used? while newstate is not None: logger.info("StateMachine: new state = %s" % newstate.__class__.__name__) self.current_state = newstate