diff options
-rw-r--r-- | behaviors/AllPixelsLeft.py | 11 | ||||
-rw-r--r-- | config/Outdoor.xml | 7 | ||||
-rw-r--r-- | pixelmappers/SimpleMapper.py | 6 |
3 files changed, 22 insertions, 2 deletions
diff --git a/behaviors/AllPixelsLeft.py b/behaviors/AllPixelsLeft.py new file mode 100644 index 0000000..7f731e9 --- /dev/null +++ b/behaviors/AllPixelsLeft.py @@ -0,0 +1,11 @@ +from operationscore.Behavior import * +import util.ComponentRegistry as compReg +import pdb +class AllPixelsLeft(Behavior): + def processResponse(self, sensorInputs, recursiveInputs): + for sensory in sensorInputs: + xLoc = sensory['Location'][0] + if type(xLoc) == type(tuple()): + pdb.set_trace() + sensory['Location'] = '[{x}<' + str(xLoc) + ']' + return (sensorInputs, recursiveInputs) diff --git a/config/Outdoor.xml b/config/Outdoor.xml index a004c4e..ebe11ad 100644 --- a/config/Outdoor.xml +++ b/config/Outdoor.xml @@ -184,6 +184,12 @@ </Args> </Behavior> <Behavior> + <Class>behaviors.AllPixelsLeft</Class> + <Args> + <Id>pixelsleft</Id> + </Args> + </Behavior> + <Behavior> <Class>behaviors.RecursiveDecay</Class> <Args> <Id>recursivedecay</Id> @@ -234,6 +240,7 @@ </Inputs> <ChainedBehaviors> <Id>echo</Id> + <Id>pixelsleft</Id> <Id>colorchange</Id> <Id>decay</Id> </ChainedBehaviors> diff --git a/pixelmappers/SimpleMapper.py b/pixelmappers/SimpleMapper.py index 6b414ea..bc51cf9 100644 --- a/pixelmappers/SimpleMapper.py +++ b/pixelmappers/SimpleMapper.py @@ -19,8 +19,10 @@ class SimpleMapper(PixelMapper): eventLocation = eventLocation.replace('{y}', 'pixel.location[1]') for pixel in screen: try: - pixelValid = sum(eval(eventLocation)) == len(eventLocation) - ret.append((pixel, 1)) + pixelValid = sum(eval(eventLocation)) == len(eval(eventLocation)) #TODO: some + #optimizations possible. This might be slow in the long run + if pixelValid: + ret.append((pixel, 1)) except: raise Exception('Bad event condition') return ret |