From 00576b225ad8b60ef1e0291e231aa499042436ba Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 20 Feb 2011 17:52:18 -0500 Subject: Added an InitialLocationInput --- config/C5Sign.xml | 41 +++++++++++++++++++++++++++++++++++++++++ inputs/InitialLocationInput.py | 24 ++++++++++++++++++++++++ operationscore/Input.py | 3 +++ 3 files changed, 68 insertions(+) create mode 100644 inputs/InitialLocationInput.py diff --git a/config/C5Sign.xml b/config/C5Sign.xml index 6d7de20..f99ef2b 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -51,6 +51,14 @@ 1800 + + inputs.InitialLocationInput + + centeronce + 0.5 + 0.5 + + inputs.OSCInput @@ -130,6 +138,14 @@ False + + behaviors/RandomColor.xml + + + (255,0,0) + + + behaviors/RandomColor.xml @@ -180,6 +196,13 @@ {y}<2 or {y}>24 + + behaviors.LocationMask + + stripsonly + ts.all ls.all rs.all bs.all + + behaviors.LocationMask @@ -309,6 +332,24 @@ + + behaviors.BehaviorChain + + coloredframe + + centeronce + + + redcolor + square + mover + singleframe + stripsonly + + {'mover':'colorshift'} + True + + behaviors.BehaviorChain diff --git a/inputs/InitialLocationInput.py b/inputs/InitialLocationInput.py new file mode 100644 index 0000000..8d39a40 --- /dev/null +++ b/inputs/InitialLocationInput.py @@ -0,0 +1,24 @@ +import util.TimeOps as clock +import util.ComponentRegistry as compReg +import util.Strings as Strings +from operationscore.Input import * +class InitialLocationInput(Input): + """Takes two arguments: xPos, yPos, where xPos and yPos is a value from + 0 to 1, where 0 represents top/left and 1 represents bottom/right of the + lightscreen. Will return that position on the screen only once.""" + + def inputInit(self): + compReg.getLock().acquire() + xmin, ymin, xmax, ymax = compReg.getComponent('Screen').getSize() + compReg.getLock().release() + + xlen = xmax-xmin + ylen = ymax-ymin + + self.xloc = xmin + xlen * self['xPos'] + self.yloc = ymin + ylen * self['yPos'] + + def sensingLoop(self): + self.respond({Strings.LOCATION: (self.xloc, self.yloc)}) + self.done = True + diff --git a/operationscore/Input.py b/operationscore/Input.py index 7720847..8800556 100644 --- a/operationscore/Input.py +++ b/operationscore/Input.py @@ -14,6 +14,7 @@ class Input(ThreadedSmootCoreObject): if not 'RefreshInterval' in self.argDict: self.argDict['RefreshInterval'] = 500 self.parentScope = self.argDict['parentScope'] + self.done = False self.inputInit() def respond(self, eventDict): @@ -44,6 +45,8 @@ class Input(ThreadedSmootCoreObject): self.acquireLock() self.sensingLoop() self.releaseLock() + if self.done: + break def sensingLoop(self): pass -- cgit v1.2.3 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 +++++++++++++++++++++++++++++++++++++++++++++ config/C5Sign.xml | 28 +++++++++++++++++++++++----- 3 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 behaviors/RunFinite.py create mode 100644 behaviors/SplitBehavior.py 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) diff --git a/config/C5Sign.xml b/config/C5Sign.xml index f99ef2b..93b3028 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -230,8 +230,8 @@ centerleft center - {'scanningbars':10,'runcolordecay':10,'expandingcircles':10} - {'scanningbars':'centerleft', 'runcolordecay':'center',\ + {'framedbars':10,'runcolordecay':10,'expandingcircles':10} + {'framedbars':'centerleft', 'runcolordecay':'center',\ 'expandingcircles':'center'} True @@ -332,14 +332,22 @@ + + behaviors.RunFinite + + runonce + 1 + + behaviors.BehaviorChain coloredframe - + + runonce redcolor square mover @@ -347,7 +355,17 @@ stripsonly {'mover':'colorshift'} - True + False + + + + behaviors.SplitBehavior + + framedbars + + coloredframe + scanningbars + -- 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 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