rearrange statemachine
This commit is contained in:
parent
f073381d80
commit
e7eeb8d29e
|
@ -74,6 +74,32 @@ class StateMachine:
|
||||||
self.camera = Camera()
|
self.camera = Camera()
|
||||||
self.fileDump = FileDump()
|
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):
|
def startTimer(t, sound):
|
||||||
self._timer = CountdownTimer(t, partial(self.selectState, SIGNALS.TIMOUT), 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,
|
(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):
|
def start(self):
|
||||||
resetUSBDevice('1-1')
|
resetUSBDevice('1-1', logger)
|
||||||
|
|
||||||
self.soundLib.start()
|
self.soundLib.start()
|
||||||
self.LED.start()
|
self.LED.start()
|
||||||
|
|
|
@ -355,7 +355,7 @@ class Camera(ThreadedPipeline):
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
# video is on usb, so wait until it comes back after we hard reset the bus
|
# 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)
|
ThreadedPipeline.start(self, play=False)
|
||||||
|
|
||||||
class FileDump(ThreadedPipeline):
|
class FileDump(ThreadedPipeline):
|
||||||
|
|
Loading…
Reference in New Issue