rearrange statemachine

This commit is contained in:
petrucci4prez 2017-06-08 01:02:31 -04:00
parent f073381d80
commit e7eeb8d29e
2 changed files with 28 additions and 28 deletions

View File

@ -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()

View File

@ -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):