From 83242972c09032eb89dd547f3ff3c4dcc2693555 Mon Sep 17 00:00:00 2001 From: rcoh Date: Mon, 14 Feb 2011 01:51:43 -0500 Subject: Fixed some threading bugs. Modified LightInstallation.py so that Behaviors are *Only* run if they are marked to be rendered. Fixed a threading issue tied to the component registry. --- behaviors/TimeSwitch.py | 11 ++++++----- behaviors/VerticalBar.py | 11 ++--------- 2 files changed, 8 insertions(+), 14 deletions(-) (limited to 'behaviors') diff --git a/behaviors/TimeSwitch.py b/behaviors/TimeSwitch.py index 2cedfcf..cfbfe4a 100644 --- a/behaviors/TimeSwitch.py +++ b/behaviors/TimeSwitch.py @@ -10,15 +10,16 @@ class TimeSwitch(Behavior): """ def behaviorInit(self): self.keyIndex = 0 - self.currentBehaviorId = self['Behaviors'].keys()[self.keyIndex] + self.currentBehaviorId = self['TimeMap'].keys()[self.keyIndex] self.behaviorStart = clock.time() def processResponse(self, sensors, recurs): - if self.behaviorStart + self['Behaviors'][self.currentBehaviorId]*1000 <= clock.time(): + if self.behaviorStart + self['TimeMap'][self.currentBehaviorId]*1000 <= clock.time(): self.keyIndex += 1 - self.keyIndex = self.keyIndex % len(self['Behaviors']) - self.currentBehaviorId = self['Behaviors'].keys()[self.keyIndex] + self.keyIndex = self.keyIndex % len(self['TimeMap']) + self.currentBehaviorId = self['TimeMap'].keys()[self.keyIndex] self.behaviorStart = clock.time() main_log.info('Switching behaviors') - return compReg.getComponent(self.currentBehaviorId).processResponse(sensors, recurs) + sensors = [s for s in sensors if s['InputId'] == self['InputMap'][self.currentBehaviorId]] + return compReg.getComponent(self.currentBehaviorId).immediateProcessInput(sensors, recurs) diff --git a/behaviors/VerticalBar.py b/behaviors/VerticalBar.py index e1a67fe..66c8e56 100644 --- a/behaviors/VerticalBar.py +++ b/behaviors/VerticalBar.py @@ -2,11 +2,11 @@ from operationscore.Behavior import * class VerticalBar(Behavior): def processResponse(self, inputs, recurs): - ret = [] + inputs = list(inputs) for inputset in inputs: #import pdb; pdb.set_trace() - + inputset = dict(inputset) if 'xLoc' not in inputset: inputset['xLoc'] = inputset['Location'][0] xLoc = inputset['xLoc'] @@ -19,12 +19,5 @@ class VerticalBar(Behavior): inputset['Location'] = condition ret.append(inputset) - return (ret, []) - def setLastOutput(self, output): - - coutput = Behavior.deepCopyPacket(output) - for data in coutput: - data['Location'] = data['xLoc'] - return coutput -- cgit v1.2.3