From 42a3112b7cd7518ab69ba8d69c636a6278cfb288 Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 20 Feb 2011 19:30:43 -0500 Subject: Added SplitBehavior and RunFinite behaviors --- behaviors/RunFinite.py | 25 +++++++++++++++++++++++++ behaviors/SplitBehavior.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 behaviors/RunFinite.py create mode 100644 behaviors/SplitBehavior.py (limited to 'behaviors') diff --git a/behaviors/RunFinite.py b/behaviors/RunFinite.py new file mode 100644 index 0000000..de2ce27 --- /dev/null +++ b/behaviors/RunFinite.py @@ -0,0 +1,25 @@ +from operationscore.Behavior import * +import util.ComponentRegistry as compReg + +class RunFinite(Behavior): + """RunFinite will just wire input to output, but only a finite number of + times as specified by the Iterations argument tag""" + + def behaviorInit(self): + pass + + def processResponse(self, inp, state): + + if state: + iterations = state + else: + iterations = self['Iterations'] + + if iterations > 0: + out = inp + else: + out = [] + + iterations -= 1 + + return (out, iterations) diff --git a/behaviors/SplitBehavior.py b/behaviors/SplitBehavior.py new file mode 100644 index 0000000..1892ad3 --- /dev/null +++ b/behaviors/SplitBehavior.py @@ -0,0 +1,45 @@ +from operationscore.Behavior import * +import util.ComponentRegistry as compReg + +class SplitBehavior(Behavior): + """SplitBehavior takes a list of behaviors, runs the input on all behaviors + listed, and then returns the concantenation of all the behavior outputs. + Behavior list is given under tag as a list of Id's + + Example: + + behaviors.SplitBehavior + + splitbehavior + + behavior1Id + behavior2Id + + + + """ + + def behaviorInit(self): + pass + + def processResponse(self, inp, state): + + out = [] + newstate = {} + for behaviorId in self['BehaviorList']: + + behavior = compReg.getComponent(behaviorId) + if behaviorId in state: + behaviorState = state[behaviorId] + else: + behaviorState = [] + + #print behaviorId, " ", str(inp), ",", str(behaviorState) + output = behavior.immediateProcessInput(inp, behaviorState) + (behaviorOutput, behaviorState) = output + #print " -->", str(behaviorState), ",", str(behaviorOutput) + + newstate[behaviorId] = behaviorState + out.extend(behaviorOutput) + + return (out, newstate) -- cgit v1.2.3 From 6cb8952976d771d5f3be20a1eb1cd9b957651a54 Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 20 Feb 2011 22:59:19 -0500 Subject: Fixed problems with RunFinite --- behaviors/RunFinite.py | 9 +- config/C5Sign-dxiao.xml | 396 ----------------------------------------------- config/C5Sign-pygame.xml | 2 +- 3 files changed, 7 insertions(+), 400 deletions(-) delete mode 100644 config/C5Sign-dxiao.xml (limited to 'behaviors') diff --git a/behaviors/RunFinite.py b/behaviors/RunFinite.py index de2ce27..498998a 100644 --- a/behaviors/RunFinite.py +++ b/behaviors/RunFinite.py @@ -10,7 +10,8 @@ class RunFinite(Behavior): def processResponse(self, inp, state): - if state: + print "runfinite ", str(inp), ",", str(state) + if state != []: iterations = state else: iterations = self['Iterations'] @@ -20,6 +21,8 @@ class RunFinite(Behavior): else: out = [] - iterations -= 1 - + if inp: + iterations -= 1 + + print " -->", str(iterations), ",", str(out) return (out, iterations) diff --git a/config/C5Sign-dxiao.xml b/config/C5Sign-dxiao.xml deleted file mode 100644 index 7dc4b81..0000000 --- a/config/C5Sign-dxiao.xml +++ /dev/null @@ -1,396 +0,0 @@ - - - - - simplemap - - - - layouts/C5SignLayout.xml - - - - - pixelmappers.C5SignMapper - - c5signmapper - 20 - - - - - pixelmappers.SimpleMapper - - simplemap - 20 - - - - pixelmappers.GaussianMapper - - gaussmap - 30 - 0.1 - 7 - 1 - - - - - - renderers/C5Renderer.xml - - - - - - - inputs.OSCInput - - osc - 1234 - 10 - - - - - inputs.UDPInput - - udp - 3344 - 50 - - - - inputs.ContinuousCenterInput - - center - 1800 - - - - - inputs.ContinuousLocationInput - - centerleft - left - center - 1800 - - - - - - - - - - touchosc - - behaviors.TouchOSC - - - behaviors/RandomColor.xml - - - - - - behaviors.BehaviorChain - - OSCTouchChase - - osc - - - touchosc - decay - - gaussmap - False - - - - behaviors/PixelDecay.xml - - - behaviors/SingleFrame.xml - - - - behaviors/PixelDecay.xml - - .001 - - - - - behaviors.XYMove - - xymove - 1 - 1 - - - - behaviors.RestrictLocation - - xbounce - {val}*-1 - XStep - {x}<2 or {x}>48 - - - - behaviors.RestrictLocation - - ybounce - {val}*-1 - YStep - {y}<2 or {y}>24 - - - - behaviors.BehaviorChain - - movebounce - - xymove - ybounce - xbounce - - - - - behaviors.ModifyParam - - ysin - YStep - Sensor - 4*math.sin({x}/float(40)) - - - - behaviors.DebugBehavior - - debug - 0 - - pygamekey - udp - - - - - behaviors.AllPixels - - square - 20 - - - - behaviors/LoopAndDie.xml - - 160 - - - - behaviors.BehaviorChain - - runcolordecay - - pygameclick - - - colorchange - mover - - decay - - {'mover':'movebounce'} - False - gaussmap - - - - behaviors.ResponseMover - - mover - - - - behaviors.RandomWalk - - randmovement - 2 - - - - behaviors/Accelerate.xml - - - behaviors.EchoBehavior - - echo - 0 - False - - - - behaviors.ColorShift - - colorshift - - - - behaviors.BehaviorChain - - mousechaser - - - - echo - innercircle - outercircle - singleframe - - False - - - - behaviors.Circle - - innercircle - 0 - True - - - - behaviors.Circle - - outercircle - 3 - True - - - - behaviors.ModifyParam - - incrinner - {val}+.3 - innercircleRadius - - - - behaviors.ModifyParam - - incrouter - {val}+.3 - outercircleRadius - - - - behaviors.BehaviorChain - - circle_expand - - innercircle - outercircle - incrinner - incrouter - recursivedecay - - - - - behaviors.BehaviorChain - - expandingcirlces - - centerleft - - - colorchange - mover - decay - - {'mover':'circle_expand'} - False - - - - - behaviors.ModifyParam - - incrVertBarLoc - xLoc - {val}+1 - - - - behaviors.VerticalBar - - vertBar - - - - behaviors.BehaviorChain - - bar_move - - vertBar - incrVertBarLoc - recursivedecay - - - - - behaviors.BehaviorChain - - scanningbars - - centerleft - - - colorchange - mover - slowdecay - - {'mover':'bar_move'} - True - - - - - behaviors/RunningBehavior.xml - - - diff --git a/config/C5Sign-pygame.xml b/config/C5Sign-pygame.xml index d08e14c..2040642 100644 --- a/config/C5Sign-pygame.xml +++ b/config/C5Sign-pygame.xml @@ -14,5 +14,5 @@ - config/C5Sign-Leah.xml + config/C5Sign.xml -- cgit v1.2.3