aboutsummaryrefslogtreecommitdiff
path: root/behaviors
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-02-14 01:51:43 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-02-14 01:51:43 -0500
commit83242972c09032eb89dd547f3ff3c4dcc2693555 (patch)
tree62fdb611afbb37ff90f0356cac5828f48ec50f60 /behaviors
parent9c76b22071259fe8195eaf5bd846219fc2cade4d (diff)
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.
Diffstat (limited to 'behaviors')
-rw-r--r--behaviors/TimeSwitch.py11
-rw-r--r--behaviors/VerticalBar.py11
2 files changed, 8 insertions, 14 deletions
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