From e7eeb8d29e4ade7c69049bfe8593383767b68b10 Mon Sep 17 00:00:00 2001 From: petrucci4prez Date: Thu, 8 Jun 2017 01:02:31 -0400 Subject: [PATCH] rearrange statemachine --- stateMachine.py | 54 ++++++++++++++++++++++++------------------------- stream.py | 2 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/stateMachine.py b/stateMachine.py index c46dde5..5301e96 100644 --- a/stateMachine.py +++ b/stateMachine.py @@ -74,6 +74,32 @@ class StateMachine: self.camera = Camera() self.fileDump = FileDump() + secretTable = { + "dynamoHum": partial(self.selectState, SIGNALS.DISARM), + "zombyWoof": partial(self.selectState, SIGNALS.ARM), + "imTheSlime": partial(self.selectState, SIGNALS.INSTANT_ARM) + } + + def secretCallback(secret, logger): + if secret in secretTable: + secretTable[secret]() + logger.debug('Secret pipe listener received: \"%s\"', secret) + elif logger: + logger.debug('Secret pipe listener received invalid secret') + + self.secretListener = PipeListener( + callback = secretCallback, + name = 'secret' + ) + + self.keypadListener = KeypadListener( + stateMachine = self, + callbackDisarm = partial(self.selectState, 'disarm'), + callbackArm = partial(self.selectState, 'arm'), + soundLib = self.soundLib, + passwd = '5918462' + ) + def startTimer(t, sound): self._timer = CountdownTimer(t, partial(self.selectState, SIGNALS.TIMOUT), sound) @@ -134,34 +160,8 @@ class StateMachine: (self.states.triggered, SIGNALS.ARM): self.states.armed, } - secretTable = { - "dynamoHum": partial(self.selectState, SIGNALS.DISARM), - "zombyWoof": partial(self.selectState, SIGNALS.ARM), - "imTheSlime": partial(self.selectState, SIGNALS.INSTANT_ARM) - } - - def secretCallback(secret, logger): - if secret in secretTable: - secretTable[secret]() - logger.debug('Secret pipe listener received: \"%s\"', secret) - elif logger: - logger.debug('Secret pipe listener received invalid secret') - - self.secretListener = PipeListener( - callback = secretCallback, - name = 'secret' - ) - - self.keypadListener = KeypadListener( - stateMachine = self, - callbackDisarm = partial(self.selectState, 'disarm'), - callbackArm = partial(self.selectState, 'arm'), - soundLib = self.soundLib, - passwd = '5918462' - ) - def start(self): - resetUSBDevice('1-1') + resetUSBDevice('1-1', logger) self.soundLib.start() self.LED.start() diff --git a/stream.py b/stream.py index 8b87fca..00ede9d 100644 --- a/stream.py +++ b/stream.py @@ -355,7 +355,7 @@ class Camera(ThreadedPipeline): def start(self): # video is on usb, so wait until it comes back after we hard reset the bus - waitForPath(self._vPath) + waitForPath(self._vPath, logger) ThreadedPipeline.start(self, play=False) class FileDump(ThreadedPipeline):