diff options
Diffstat (limited to 'behaviors')
-rw-r--r-- | behaviors/AllPixels.py | 6 | ||||
-rw-r--r-- | behaviors/DebugBehavior.py | 2 | ||||
-rw-r--r-- | behaviors/DimColor.xml | 8 | ||||
-rw-r--r-- | behaviors/DoorBehavior.py | 4 | ||||
-rw-r--r-- | behaviors/Expand.py | 17 | ||||
-rw-r--r-- | behaviors/RestrictLocation.py | 2 | ||||
-rw-r--r-- | behaviors/SingleFrame.xml | 7 | ||||
-rw-r--r-- | behaviors/Square.py | 1 | ||||
-rw-r--r-- | behaviors/XYMove.py | 17 |
9 files changed, 62 insertions, 2 deletions
diff --git a/behaviors/AllPixels.py b/behaviors/AllPixels.py new file mode 100644 index 0000000..e155e55 --- /dev/null +++ b/behaviors/AllPixels.py @@ -0,0 +1,6 @@ +from operationscore.Behavior import * +class AllPixels(Behavior): + def processResponse(self, sensorInputs, recursiveInputs): + for sensory in sensorInputs:#TODO: consider replicating the dict + sensory['Location'] = 'True' + return (sensorInputs, recursiveInputs) diff --git a/behaviors/DebugBehavior.py b/behaviors/DebugBehavior.py index 34f4106..17383db 100644 --- a/behaviors/DebugBehavior.py +++ b/behaviors/DebugBehavior.py @@ -4,5 +4,5 @@ import pdb class DebugBehavior(Behavior): def processResponse(self, sensorInputs, recursiveInputs): if sensorInputs != []: - main_log.debug('Sensor Inputs: ' + str(sensorInputs)) + main_log.error('Sensor Inputs: ' + str(sensorInputs)) return ([], []) diff --git a/behaviors/DimColor.xml b/behaviors/DimColor.xml new file mode 100644 index 0000000..b01908e --- /dev/null +++ b/behaviors/DimColor.xml @@ -0,0 +1,8 @@ +<Behavior> + <Class>behaviors.ModifyParam</Class> + <Args> + <ParamType>Sensor</ParamType> + <ParamName>Color</ParamName> + <ParamOp>[chan*.99 for chan in {val}]</ParamOp> + </Args> +</Behavior> diff --git a/behaviors/DoorBehavior.py b/behaviors/DoorBehavior.py new file mode 100644 index 0000000..5058f69 --- /dev/null +++ b/behaviors/DoorBehavior.py @@ -0,0 +1,4 @@ +from operationscore.behavior import * +class DoorBehavior.py(Behavior): + def behaviorInit(self): + pyt diff --git a/behaviors/Expand.py b/behaviors/Expand.py new file mode 100644 index 0000000..3415966 --- /dev/null +++ b/behaviors/Expand.py @@ -0,0 +1,17 @@ +from operationscore.Behavior import * +class Expand(Behavior): + def processResponse(self, sensorInputs, recurs): + ret = [] + for data in sensorInputs: + if not 'Left' in data: #If this is the first time we have seen this input + data['Left'] = data['Location'][0] + data['Right'] = data['Location'][0] + data['ExpandRate'] = self['ExpandRate'] + + data = dict(data) + data['Left'] -= data['ExpandRate'] + data['Right'] += data['ExpandRate'] + data['Location'] = "{x}>" + str(data['Left']) + ", {x}<" + str(data['Right']) + ret.append(data) + return (ret, []) + diff --git a/behaviors/RestrictLocation.py b/behaviors/RestrictLocation.py index febc9ed..f6c26ff 100644 --- a/behaviors/RestrictLocation.py +++ b/behaviors/RestrictLocation.py @@ -25,7 +25,7 @@ class RestrictLocation(Behavior): def processResponse(self, sensorInputs, recursiveInputs): ret = [] for data in sensorInputs: - if not self.locEval(data['Location']): + if self.locEval(data['Location']): (dataOut, recur) = self.paramModifier.immediateProcessInput([data], []) #behaviors expect lists ^[] ret += dataOut diff --git a/behaviors/SingleFrame.xml b/behaviors/SingleFrame.xml new file mode 100644 index 0000000..49b5dcf --- /dev/null +++ b/behaviors/SingleFrame.xml @@ -0,0 +1,7 @@ +<Behavior> + <Class>behaviors.AddPixelEvent</Class> + <Args> + <Class>pixelevents.SingleFrameEvent</Class> + <z-index>0</z-index> + </Args> +</Behavior> diff --git a/behaviors/Square.py b/behaviors/Square.py index a6e9401..aef3622 100644 --- a/behaviors/Square.py +++ b/behaviors/Square.py @@ -5,6 +5,7 @@ class Square(Behavior): xLoc = sensory['Location'][0] yLoc = sensory['Location'][1] width = self['Width'] + #sensory['Location'] = 'True' sensory['Location'] =\ '{x}<'+str(xLoc+width)+',{x}>'+str(xLoc-width)+\ ',{y}<'+str(yLoc+width)+',{y}>'+str(yLoc-width) diff --git a/behaviors/XYMove.py b/behaviors/XYMove.py new file mode 100644 index 0000000..8acbba8 --- /dev/null +++ b/behaviors/XYMove.py @@ -0,0 +1,17 @@ +from operationscore.Behavior import * +import util.Geo as Geo +class XYMove(Behavior): + def processResponse(self, sensor, recurs): + ret = [] + for loc in sensor: + oploc = dict(loc) + self.insertStepIfMissing(oploc) + oploc['Location'] = Geo.addLocations((oploc['XStep'], oploc['YStep']), oploc['Location']) + ret.append(oploc) + return (ret, []) + def insertStepIfMissing(self, data): + if not 'XStep' in data: + data['XStep'] = self['XStep'] + if not 'YStep' in data: + data['YStep'] = self['YStep'] + |