- super().handle_pins_event()
- pins = self.pins()
- if pins.door_locked is None or pins.door_closed is None or pins.space_dactive is None or pins.bell_ringing is None:
- return None # wait till we have all sensors non-None
- if pins.door_locked:
- return StateMachine.StateZu(self.state_machine)
- else:
- return StateMachine.StateAuf(self.state_machine)
+ if not self.pins().door_locked:
+ return StateAboutToOpen(self.state_machine)
+ return super().handle_pins_event
+
+ class AbstractUnlockedState(State):
+ '''A state with invariant "The space is unlocked", switching to StateZu when the space becomes locked'''
+ def handle_pins_event(self):
+ if self.pins().door_locked:
+ if self.pins().space_active:
+ # FIXME the same state can be reached by first locking the door, and then activating the space. What to do then?
+ logger.info("StateMachine: door manually locked, but space switch is still on - going to StateZu")
+ play_sound("manual_lock")
+ return StateZu(self.state_machine)
+ return super().handle_pins_event