diff --git a/pizzactrl/main.py b/pizzactrl/main.py index 895522f..583bcd2 100644 --- a/pizzactrl/main.py +++ b/pizzactrl/main.py @@ -3,8 +3,9 @@ import sys import click import logging -from .statemachine import Statemachine, State -from . import sb_de, sb_en +from pizzactrl.statemachine import Statemachine, State +from pizzactrl.sb_showcase import STORYBOARD +from pizzactrl.hal_serial import PizzaHAL logger = logging.getLogger('pizzactrl.main') @@ -20,18 +21,14 @@ def main(move: bool=False, test: bool=False, debug: bool=False, loop: bool=False else: logging.basicConfig(level=logging.INFO, stream=sys.stdout) - sm = Statemachine(story_de=sb_de.STORYBOARD, - story_en=sb_en.STORYBOARD, - move=move, - loop=loop) + hal = PizzaHAL() + sm = Statemachine(hal, STORYBOARD, move=move, loop=loop, test=test) + sm.test = test exitcode = 0 try: sm.run() - except Exception: - logger.exception('An Error occurred while running the statemachine') - exitcode = 1 finally: if sm.state is State.ERROR: exitcode = 2 @@ -39,16 +36,5 @@ def main(move: bool=False, test: bool=False, debug: bool=False, loop: bool=False sys.exit(exitcode) -@click.command() -@click.option('--time', help='Safety deactivation time', type=float, - default=13.2) -def rewind(time: float): - from . import hal - pizza = hal.PizzaHAL() - hal.rewind(pizza.motor_ud, pizza.ud_sensor, max_time=time) - hal.turn_off(pizza) - del pizza - - if __name__ == '__main__': main() diff --git a/pizzactrl/statemachine.py b/pizzactrl/statemachine.py index 62a91a8..15c2e4e 100644 --- a/pizzactrl/statemachine.py +++ b/pizzactrl/statemachine.py @@ -161,7 +161,7 @@ class Statemachine: self.story.hal = self.hal fs_names.generate_session_id() - while self.story.hasnext(): + while self.story.hasnext() and self.hal.lid_open: self.story.play_chapter() self.story.advance_chapter() @@ -175,7 +175,7 @@ class Statemachine: # logger.debug('Converting video...') # cmdstring = f'MP4Box -add {fs_names.REC_DRAW_CITY} {fs_names.REC_MERGED_VIDEO}' # call([cmdstring], shell=True) - + self.hal.flush_serial() self._next_state() def _rewind(self): @@ -183,6 +183,7 @@ class Statemachine: Rewind all scrolls, post-process videos """ turn_off(self.hal) + self.story.skip_flag = False self.story.rewind() if self.loop: