From a7697c9d636b5adab9bdf95d42ff77c3a060c63d Mon Sep 17 00:00:00 2001 From: rcoh Date: Sun, 13 Feb 2011 02:47:07 -0500 Subject: Added ability to specify a precise pixelmap. untested. --- layouts/SpecifiedLayout.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 layouts/SpecifiedLayout.py diff --git a/layouts/SpecifiedLayout.py b/layouts/SpecifiedLayout.py new file mode 100644 index 0000000..967a3d6 --- /dev/null +++ b/layouts/SpecifiedLayout.py @@ -0,0 +1,20 @@ +from operationscore.PixelAssembler import * +class SpecifiedLayout(PixelAssembler): + """SpecifiedLayout is a class that allows precise specification of each individual LED. + Configure with a tag in the args dict as follows': + + + (1,1) + (50,50) + + etc. + + You may put attributes on the Locs so that you don't get confused. + """ + + def layoutInit(self): + self.lightNum = -1 + + def layoutFunc(self, lastLocation): + self.lightNum += 1 + return self['Locations'][self.lightNum] -- cgit v1.2.3 From a0f1f7ceea56398849d5e32d73485ecc89d51973 Mon Sep 17 00:00:00 2001 From: rcoh Date: Sun, 13 Feb 2011 03:09:35 -0500 Subject: sign config --- config/C5Sign.xml | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 config/C5Sign.xml diff --git a/config/C5Sign.xml b/config/C5Sign.xml new file mode 100644 index 0000000..6550067 --- /dev/null +++ b/config/C5Sign.xml @@ -0,0 +1,234 @@ + + + + + simplemap + + + + layouts/C5SignLayout.xml + + + + pixelmappers.SimpleMapper + + simplemap + 20 + + + + pixelmappers.GaussianMapper + + gaussmap + 30 + 0.1 + 10 + 1 + + + + + + renderers/C5Renderer.xml + + + renderers/Pygame.xml + + + + + inputs.PygameInput + + pygameclick + 10 + True + + + + inputs.PygameInput + + pygamekey + 10 + True + + + + inputs.UDPInput + + udp + 3344 + 50 + + + + + inputs/MouseFollower.xml + + + + + behaviors/RandomColor.xml + + + (255,0,0) + (0,0,255) + + + + + behaviors/PixelDecay.xml + + + behaviors/SingleFrame.xml + + + behaviors/PixelDecay.xml + + .01 + + + + behaviors.XYMove + + xymove + 5 + 2 + + + + behaviors.RestrictLocation + + xbounce + {val}*-1 + XStep + {x}<0 or {x}>200 + + + + behaviors.RestrictLocation + + ybounce + {val}*-1 + YStep + {y}<0 or {y}>100 + + + + behaviors.BehaviorChain + + movebounce + + xymove + colorshift + 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 + + 80 + + + + behaviors.BehaviorChain + + runcolordecay + + pygameclick + + + colorchange + mover + decay + + {'mover':'movebounce'} + True + gaussmap + + + + behaviors.ResponseMover + + mover + + + + behaviors.RandomWalk + + randmovement + 2 + + + + behaviors/Accelerate.xml + + + behaviors.EchoBehavior + + echo + 0 + False + + + + behaviors.ColorShift + + colorshift + + + + behaviors.BehaviorChain + + mousechaser + + followmouse + + + echo + square + singleframe + + False + + + + behaviors/RunningBehavior.xml + + + -- cgit v1.2.3 From 055510465b754f764ec05a44728396274f8cbee2 Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 13 Feb 2011 03:10:40 -0500 Subject: new c5 layout. --- layouts/C5SignLayout.xml | 70 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/layouts/C5SignLayout.xml b/layouts/C5SignLayout.xml index 58310d7..cd07f21 100644 --- a/layouts/C5SignLayout.xml +++ b/layouts/C5SignLayout.xml @@ -1,16 +1,66 @@ - layouts.ZigzagLayout + layouts.SpecifiedLayout - strip1 - 10 - X - 1 - 20 - 20 - 50 - (0,0) + + + (2,22) + (2,16) + (2,10) + (2,4) + + (4, 2) + (10,2) + (16,2) + (22,2) + (27,2) + (33,2) + (39,2) + (44,2) + + (45,4) + (45,10) + (45,16) + (45,22) + + (44,22) + (39,22) + (34,22) + (27,22) + (22,22) + (16,22) + (10,22) + (4,22) + + (12,19) + (13,19) + (16,19) + (18,19) + (21,19) + (23,19) + (26,19) + (27,19) + (30,19) + (34,19) + (37,19) + + (31,12) + (26,12) + (24,14) + (17,16) + (21,14) + + (19,7) + (6,7) + (11,7) + (15,7) + (22,7) + (27,7) + (33,8) + (38,7) + (42,7) + (34,8) + -- cgit v1.2.3 From 7e3ff67854e469ddfa7e6af51c904f403b3c4c77 Mon Sep 17 00:00:00 2001 From: rcoh Date: Sun, 13 Feb 2011 03:25:00 -0500 Subject: Note that y coordinates in Layout must be subtracted from 24 --- config/C5Sign.xml | 3 +- layouts/C5SignLayout.xml | 120 ++++++++++++++++++++------------------- layouts/SpecifiedLayout.py | 2 +- operationscore/PixelAssembler.py | 1 + 4 files changed, 66 insertions(+), 60 deletions(-) diff --git a/config/C5Sign.xml b/config/C5Sign.xml index 6550067..65a45bc 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -175,11 +175,12 @@ colorchange mover + square decay {'mover':'movebounce'} True - gaussmap + diff --git a/layouts/C5SignLayout.xml b/layouts/C5SignLayout.xml index cd07f21..2424509 100644 --- a/layouts/C5SignLayout.xml +++ b/layouts/C5SignLayout.xml @@ -2,64 +2,68 @@ layouts.SpecifiedLayout - - - (2,22) - (2,16) - (2,10) - (2,4) - - (4, 2) - (10,2) - (16,2) - (22,2) - (27,2) - (33,2) - (39,2) - (44,2) - - (45,4) - (45,10) - (45,16) - (45,22) - - (44,22) - (39,22) - (34,22) - (27,22) - (22,22) - (16,22) - (10,22) - (4,22) - - (12,19) - (13,19) - (16,19) - (18,19) - (21,19) - (23,19) - (26,19) - (27,19) - (30,19) - (34,19) - (37,19) - - (31,12) - (26,12) - (24,14) - (17,16) - (21,14) - - (19,7) - (6,7) - (11,7) - (15,7) - (22,7) - (27,7) - (33,8) - (38,7) - (42,7) - (34,8) + strip1 + 50 + 12 + 12 + (2,22) + + + (2,16) + (2,10) + (2,4) + + (4, 2) + (10,2) + (16,2) + (22,2) + (27,2) + (33,2) + (39,2) + (44,2) + + (45,4) + (45,10) + (45,16) + (45,22) + + (44,22) + (39,22) + (34,22) + (27,22) + (22,22) + (16,22) + (10,22) + (4,22) + + (12,19) + (13,19) + (16,19) + (18,19) + (21,19) + (23,19) + (26,19) + (27,19) + (30,19) + (34,19) + (37,19) + + (31,12) + (26,12) + (24,14) + (17,16) + (21,14) + + (19,7) + (11,7) + (6,7) + (15,7) + (22,7) + (27,7) + (33,8) + (38,7) + (42,7) + (34,8) diff --git a/layouts/SpecifiedLayout.py b/layouts/SpecifiedLayout.py index 967a3d6..b746e68 100644 --- a/layouts/SpecifiedLayout.py +++ b/layouts/SpecifiedLayout.py @@ -12,7 +12,7 @@ class SpecifiedLayout(PixelAssembler): You may put attributes on the Locs so that you don't get confused. """ - def layoutInit(self): + def initLayout(self): self.lightNum = -1 def layoutFunc(self, lastLocation): diff --git a/operationscore/PixelAssembler.py b/operationscore/PixelAssembler.py index 84f3b0b..582b59d 100644 --- a/operationscore/PixelAssembler.py +++ b/operationscore/PixelAssembler.py @@ -19,6 +19,7 @@ class PixelAssembler(SmootCoreObject): defined or improperly defined.') if Geo.dist(newLocation, locations[-1]) > \ self['pixelToPixelSpacing']: + import pdb; pdb.set_trace() raise Exception('Illegal pixel location. Distance \ between adjacent pixels must be less than \ pixelToPixelSpacing.') -- cgit v1.2.3 From 824e7c94dd97dab78a9c328b005fa28e1bf5aa9b Mon Sep 17 00:00:00 2001 From: rcoh Date: Sun, 13 Feb 2011 03:25:18 -0500 Subject: Picking up the renderer --- renderers/C5Renderer.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 renderers/C5Renderer.xml diff --git a/renderers/C5Renderer.xml b/renderers/C5Renderer.xml new file mode 100644 index 0000000..d9fc9b0 --- /dev/null +++ b/renderers/C5Renderer.xml @@ -0,0 +1,10 @@ + + renderers.IndoorRenderer + + indoorRenderer + + 10.32.97.17 + {'strip1':1} + + + -- cgit v1.2.3 From db19c9731c7bed3716a387a0db5b56dd3ba72104 Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 13 Feb 2011 03:34:10 -0500 Subject: changed C5Sign layout to reflect accurate origin --- layouts/C5SignLayout.xml | 96 ++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/layouts/C5SignLayout.xml b/layouts/C5SignLayout.xml index 2424509..353ae73 100644 --- a/layouts/C5SignLayout.xml +++ b/layouts/C5SignLayout.xml @@ -6,64 +6,64 @@ 50 12 12 - (2,22) + (2,2) - (2,16) - (2,10) - (2,4) + (2,8) + (2,14) + (2,20) - (4, 2) - (10,2) - (16,2) - (22,2) - (27,2) - (33,2) - (39,2) - (44,2) + (4, 22) + (10,22) + (16,22) + (22,22) + (27,22) + (33,22) + (39,22) + (44,22) - (45,4) - (45,10) - (45,16) - (45,22) + (45,20) + (45,14) + (45,8) + (45,2) - (44,22) - (39,22) - (34,22) - (27,22) - (22,22) - (16,22) - (10,22) - (4,22) + (44,2) + (39,2) + (34,2) + (27,2) + (22,2) + (16,2) + (10,2) + (4,2) - (12,19) - (13,19) - (16,19) - (18,19) - (21,19) - (23,19) - (26,19) - (27,19) - (30,19) - (34,19) - (37,19) + (12,5) + (13,5) + (16,5) + (18,5) + (21,5) + (23,5) + (26,5) + (27,5) + (30,5) + (34,5) + (37,5) (31,12) (26,12) - (24,14) - (17,16) - (21,14) + (24,10) + (17,8) + (21,10) - (19,7) - (11,7) - (6,7) - (15,7) - (22,7) - (27,7) - (33,8) - (38,7) - (42,7) - (34,8) + (19,17) + (11,17) + (6,17) + (15,17) + (22,17) + (27,17) + (33,16) + (38,17) + (42,17) + (34,16) -- cgit v1.2.3 From f6dd5ab92949843d2fb163e2d84f19e824a291dc Mon Sep 17 00:00:00 2001 From: rcoh Date: Sun, 13 Feb 2011 03:57:56 -0500 Subject: Added OSC (phone controlled) behavior to the C5 Sign --- config/C5Sign.xml | 44 ++++++++++++++++++++++++++++++++++++-------- inputs/PygameInput.py | 4 ++++ renderers/PygameRenderer.py | 7 ++++++- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/config/C5Sign.xml b/config/C5Sign.xml index 65a45bc..8c2871e 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -22,7 +22,7 @@ gaussmap 30 0.1 - 10 + 7 1 @@ -44,6 +44,14 @@ True + + inputs.OSCInput + + osc + 1234 + 10 + + inputs.PygameInput @@ -73,6 +81,12 @@ + + + touchosc + + behaviors.TouchOSC + behaviors/RandomColor.xml @@ -82,6 +96,21 @@ + + behaviors.BehaviorChain + + OSCTouchChase + + osc + + + touchosc + decay + + gaussmap + True + + behaviors/PixelDecay.xml @@ -98,8 +127,8 @@ behaviors.XYMove xymove - 5 - 2 + 1 + 1 @@ -108,7 +137,7 @@ xbounce {val}*-1 XStep - {x}<0 or {x}>200 + {x}<2 or {x}>48 @@ -117,7 +146,7 @@ ybounce {val}*-1 YStep - {y}<0 or {y}>100 + {y}<2 or {y}>24 @@ -126,7 +155,7 @@ movebounce xymove - colorshift + ybounce xbounce @@ -175,12 +204,11 @@ colorchange mover - square decay {'mover':'movebounce'} True - + gaussmap diff --git a/inputs/PygameInput.py b/inputs/PygameInput.py index 480630c..8de55f9 100644 --- a/inputs/PygameInput.py +++ b/inputs/PygameInput.py @@ -15,6 +15,10 @@ class PygameInput(Input): NB: If follow mouse is enabled, PygameInput will not return mouse and keypresses. You can, however, instantiate other PygameInputs in the XML that will capture mouse and keypresses.""" def sensingLoop(self): + if 'Scale' in self: + scale = self['Scale'] + else: + scale = 1 if self['FollowMouse']: self.respond({Strings.LOCATION: pygame.mouse.get_pos()}) return diff --git a/renderers/PygameRenderer.py b/renderers/PygameRenderer.py index bc50360..01e2615 100644 --- a/renderers/PygameRenderer.py +++ b/renderers/PygameRenderer.py @@ -18,8 +18,13 @@ class PygameRenderer(Renderer): def render(self, lightSystem, currentTime=timeops.time()): self.background.fill(Color(0,0,0)) #print 'drawing color:',light.color + if 'Scale' in self: + scale = self['Scale'] + else: + scale = 1 for light in lightSystem: - pygame.draw.circle(self.background, light.state(currentTime), light.location, \ + scaledLoc = [l*scale for l in light.location] + pygame.draw.circle(self.background, light.state(currentTime), scaledLoc, \ light.radius) self.screen.blit(self.background, (0,0)) -- cgit v1.2.3 From 5de7f02a2b7bd8e79847311da834f025421726c6 Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 13 Feb 2011 04:07:06 -0500 Subject: blah --- config/C5Sign.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/C5Sign.xml b/config/C5Sign.xml index 65a45bc..6160b11 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -175,12 +175,12 @@ colorchange mover - square + decay {'mover':'movebounce'} True - + gaussmap -- cgit v1.2.3 From 2f0fa768ddbcc9eb7b4637d888a89d148c5cd7bf Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 13 Feb 2011 14:46:00 -0500 Subject: Added new C5PixelMapper, not yet complete --- pixelmappers/C5SignMapper.py | 63 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 pixelmappers/C5SignMapper.py diff --git a/pixelmappers/C5SignMapper.py b/pixelmappers/C5SignMapper.py new file mode 100644 index 0000000..b310c59 --- /dev/null +++ b/pixelmappers/C5SignMapper.py @@ -0,0 +1,63 @@ +from operationscore.PixelMapper import * +import util.Geo as Geo +import sys +class C5SignMapper(PixelMapper): + """C5SignMapper is a modification to SimpleMapper which maps events to the + nearest Pixel. In addtion, it also maps sign artifacts (letters, logo, etc) + to their representative locations if given in the form "ts rs :: conditions" + It also supports strings of the form: {x}>5, {y}<10, {x}*{y}<{x}, etc. + (Conditons, separated by commas. and and or may also be used).""" + + signPosition = { + "ls" : [(2,8), (2,14), (2,20)], + "ts" : [(4,22), (10,22), (16,22), (22,22), (27, 22), (33, 22), (39,22), + (44, 22)], + "rs" : [(45,2), (45, 8), (45,14), (45,20)], + "bs" : [(4,2), (10,2), (16,2), (22, 2), (27,2), (34,2), (39,2), (44,2)], + "wt" : [(12,5), (13, 5), (16,5), (18,5), (21,5), (23,5), (26,5), (27,5), + (30,5), (34,5), (37,5)], + "cl" : [(17,8), (21,10), (24,10), (26,12), (31,12)], + "c5" : [(6,17), (11,17), (15,17), (19,17), (22, 17), (27,17), (33,16), + (34, 16), (38,17), (42,17)]} + + def mappingFunction(self, eventLocation, screen): + if type(eventLocation) == type(tuple()): + bestDist = sys.maxint + bestPixel = None + [x,y] = eventLocation + for (x,pixel) in screen.pixelsInRange(x-self['CutoffDist'], \ + x+self['CutoffDist']): + pixelDist = Geo.dist(pixel.location, eventLocation) + if pixelDist < bestDist: + bestPixel = pixel + bestDist = pixelDist + if bestPixel != None: + return [(bestPixel,1)] + else: + return [] + elif type(eventLocation) == type + else: + eventLocSplit = eventLocation.split(' :: ') + if len(eventLocSplit) == 2: + [signPart, eventLocation] = eventLocSplit + signParts = [signPosition[x] for x in signPart.split(' ')] + + #{x}>5,{y} Date: Sun, 13 Feb 2011 16:03:39 -0500 Subject: Added a circle behavior to make circles. Added ContinuousCenterInput to do what it says. Modified SimpleMapper a bit. --- behaviors/Circle.py | 29 ++++++++++++++ behaviors/ModifyParam.py | 2 + config/C5Sign.xml | 84 +++++++++++++++++++++++++++++++++++++---- inputs/ContinuousCenterInput.py | 12 ++++++ pixelcore/Screen.py | 2 +- pixelmappers/SimpleMapper.py | 17 ++++++--- 6 files changed, 132 insertions(+), 14 deletions(-) create mode 100644 behaviors/Circle.py create mode 100644 inputs/ContinuousCenterInput.py diff --git a/behaviors/Circle.py b/behaviors/Circle.py new file mode 100644 index 0000000..24d71f1 --- /dev/null +++ b/behaviors/Circle.py @@ -0,0 +1,29 @@ +from operationscore.Behavior import * +class Circle(Behavior): + def processResponse(self, sensors, recurs): + ret = [] + for data in sensors: + #import pdb; pdb.set_trace() + if 'CenterLoc' in data: + xLoc = data['CenterLoc'][0] + yLoc = data['CenterLoc'][1] + else: + data['CenterLoc'] = tuple(data['Location']) + xLoc = data['Location'][0] + yLoc = data['Location'][1] + if not self['Id']+'Radius' in data: + data[self['Id']+'Radius'] = self['Radius'] + rad = data[self['Id']+'Radius'] + cond = '>=' if self['Outside'] else '<=' + circleStr = 'math.sqrt(({x}-'+str(xLoc)+')**2+(({y}-'+str(yLoc)+')**2))'+cond+str(rad) + if self['Combine']: + data['Location'] += ',' + circleStr + else: + data['Location'] = circleStr + ret.append(data) + return (ret, []) + def setLastOutput(self, output): + coutput = Behavior.deepCopyPacket(output) + for data in coutput: + data['Location'] = data['CenterLoc'] + return coutput diff --git a/behaviors/ModifyParam.py b/behaviors/ModifyParam.py index 0ef3a60..ebcb98f 100644 --- a/behaviors/ModifyParam.py +++ b/behaviors/ModifyParam.py @@ -30,6 +30,8 @@ class ModifyParam(Behavior): #TODO: move elsewhere paramOp = paramOp.replace('{y}', "behaviorInput['Location'][1]") paramOp = paramOp.replace('{x}', "behaviorInput['Location'][0]") + if eval(paramOp) == None: + import pdb; pdb.set_trace() behaviorInput[paramName] = eval(paramOp) if paramType == 'Sensor': #return accordingly return (searchSet, recursiveInputs) diff --git a/config/C5Sign.xml b/config/C5Sign.xml index 8c2871e..23a823a 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -68,6 +68,13 @@ 50 + + inputs.ContinuousCenterInput + + center + 1800 + + - + inputs/MouseFollower.xml @@ -90,10 +97,10 @@ behaviors/RandomColor.xml - + @@ -108,7 +115,7 @@ decay gaussmap - True + False @@ -155,7 +162,6 @@ movebounce xymove - ybounce xbounce @@ -207,7 +213,7 @@ decay {'mover':'movebounce'} - True + False gaussmap @@ -246,16 +252,78 @@ mousechaser - followmouse echo - square + 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 + + pygameclick + center + + + colorchange + mover + decay + + {'mover':'circle_expand'} + True + + behaviors/RunningBehavior.xml diff --git a/inputs/ContinuousCenterInput.py b/inputs/ContinuousCenterInput.py new file mode 100644 index 0000000..a7635b2 --- /dev/null +++ b/inputs/ContinuousCenterInput.py @@ -0,0 +1,12 @@ +import util.TimeOps as clock +import util.ComponentRegistry as compReg +import util.Strings as Strings +from operationscore.Input import * +class ContinuousCenterInput(Input): + def inputInit(self): + minX,minY,maxX,maxY = compReg.getComponent('Screen').getSize() + self.center = ((minX+maxX) / 2, (minY+maxY) / 2) + print self.center + def sensingLoop(self): + self.respond({Strings.LOCATION: self.center}) + diff --git a/pixelcore/Screen.py b/pixelcore/Screen.py index ada8d4a..1bed4f1 100644 --- a/pixelcore/Screen.py +++ b/pixelcore/Screen.py @@ -79,7 +79,7 @@ class Screen: maxY = max(y, maxY) self.size = (0,0, maxX, maxY) self.sizeValid = True - return (0, 0, maxX, maxY) + return (minX, minY, maxX, maxY) #private def processResponse(self, responseInfo, currentTime=None): #we need to make a new dict for diff --git a/pixelmappers/SimpleMapper.py b/pixelmappers/SimpleMapper.py index 1568de3..6603c98 100644 --- a/pixelmappers/SimpleMapper.py +++ b/pixelmappers/SimpleMapper.py @@ -1,11 +1,13 @@ from operationscore.PixelMapper import * import util.Geo as Geo +import math import sys class SimpleMapper(PixelMapper): """SimpleMapper is a PixelMapper which maps events to the nearest Pixel. It also supports strings of the form: - {x}>5, {y}<10, {x}*{y}<{x}, etc. (Conditons, separated by commas. and and or may also be - used).""" + {x}>5, {y}<10, {x}*{y}<{x}, etc. (Conditions, separated by commas. Standard python syntax such + as and and or may also be + used). You may use 'math.' functions such as math.sqrt, etc. It also accepts lists of strings""" def mappingFunction(self, eventLocation, screen): if type(eventLocation) == type(tuple()): bestDist = sys.maxint @@ -24,10 +26,14 @@ class SimpleMapper(PixelMapper): else: #{x}>5,{y} Date: Sun, 13 Feb 2011 16:34:40 -0500 Subject: Completed C5SignMapper, first version --- pixelmappers/C5SignMapper.py | 95 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 79 insertions(+), 16 deletions(-) diff --git a/pixelmappers/C5SignMapper.py b/pixelmappers/C5SignMapper.py index b310c59..79ebe1a 100644 --- a/pixelmappers/C5SignMapper.py +++ b/pixelmappers/C5SignMapper.py @@ -9,16 +9,73 @@ class C5SignMapper(PixelMapper): (Conditons, separated by commas. and and or may also be used).""" signPosition = { - "ls" : [(2,8), (2,14), (2,20)], - "ts" : [(4,22), (10,22), (16,22), (22,22), (27, 22), (33, 22), (39,22), - (44, 22)], - "rs" : [(45,2), (45, 8), (45,14), (45,20)], - "bs" : [(4,2), (10,2), (16,2), (22, 2), (27,2), (34,2), (39,2), (44,2)], - "wt" : [(12,5), (13, 5), (16,5), (18,5), (21,5), (23,5), (26,5), (27,5), - (30,5), (34,5), (37,5)], - "cl" : [(17,8), (21,10), (24,10), (26,12), (31,12)], - "c5" : [(6,17), (11,17), (15,17), (19,17), (22, 17), (27,17), (33,16), - (34, 16), (38,17), (42,17)]} + "ls" : { + 'all' : [(2,2),(2,8), (2,14), (2,20)], + '1' : [(2,2)], + '2' : [(2,8)], + '3' : [(2,14)], + '4' : [(2,20)] }, + "ts" : { + 'all' : [(4,22), (10,22), (16,22), (22,22), (27, 22), (33, 22), (39,22), (44, 22)], + '1' : [(4,22)], + '2' : [(10,22)], + '3' : [(16,22)], + '4' : [(22,22)], + '5' : [(27,22)], + '6' : [(33,22)], + '7' : [(39,22)], + '8' : [(44,22)] }, + "rs" : { + 'all' : [(45,2), (45, 8), (45,14), (45,20)], + '1' : [(45,2)], + '2' : [(45,8)], + '3' : [(45,14)], + '4' : [(45,20)] }, + "bs" : { + 'all' : [(4,2), (10,2), (16,2), (22, 2), (27,2), (34,2), (39,2), (44,2)], + '1' : [(4,2)], + '2' : [(10,2)], + '3' : [(16,2)], + '4' : [(22,2)], + '5' : [(27,2)], + '6' : [(33,2)], + '7' : [(39,2)], + '8' : [(44,2)] }, + "wt" : { + 'all' : [(12,5), (13, 5), (16,5), (18,5), (21,5), (23,5), (26,5), (27,5), (30,5), (34,5), (37,5)], + '1' : [(12,5), (13,5)], + '2' : [(16,5)], + '3' : [(18,5)], + '4' : [(21,5)], + '5' : [(23,5)], + '6' : [(26,5),(27,5)], + '7' : [(30,5)], + '8' : [(34,5)], + '9' : [(37,5)] }, + "cl" : { + 'all' : [(17,8), (21,10), (24,10), (26,12), (31,12)], + 'in' : [(21,10),(24,10),(26,12)], + 'out' : [(17,8),(31,12)], + '1' : [(17,8)], + '2' : [(21,10)], + '3' : [(24,10)], + '4' : [(26,12)], + '5' : [(31,12)] }, + "c5" : { + 'all' : [(6,17), (11,17), (15,17), (19,17), (22, 17), (27,17), (33,16), (34, 16), (38,17), (42,17)], + 'con' : [(6,17), (11,17), (15,17), (19,17), (22, 17), (27,17)], + 'five': [(33,16), (34, 16), (38,17), (42,17)], + '1' : [(6,17)], + '2' : [(11,17)], + '3' : [(15,17)], + '4' : [(19,17)], + '5' : [(22,17)], + '6' : [(27,17)], + '7' : [(33,16)], + '8' : [(34,16)], + '9' : [(38,17)], + '10' : [(42,17)] }, + } def mappingFunction(self, eventLocation, screen): if type(eventLocation) == type(tuple()): @@ -35,19 +92,25 @@ class C5SignMapper(PixelMapper): return [(bestPixel,1)] else: return [] - elif type(eventLocation) == type else: - eventLocSplit = eventLocation.split(' :: ') + #pixel locs + eventLocSplit = eventLocation.split('@') if len(eventLocSplit) == 2: - [signPart, eventLocation] = eventLocSplit - signParts = [signPosition[x] for x in signPart.split(' ')] + [eventLocation, signPart] = eventLocSplit + signParts = signPart.split('.') + pixelLocs = signPosition[signParts[0]][signParts[1]] + screen = [p for p in screen if (p.location in pixelLocs)] + #{x}>5,{y} 0: + conditions = eventLocation.split(',') + conditionLambdas = [eval('lambda pixel:'+condition) for condition in conditions] + else: + conditionLambdas = [] for pixel in screen: try: pixelValid = True -- cgit v1.2.3 From 9f61ad1981febe1be8631c0ee24d8febd83db714 Mon Sep 17 00:00:00 2001 From: rcoh Date: Sun, 13 Feb 2011 18:14:01 -0500 Subject: Added TimeSwitch to switch between behaviors at set time intervals --- behaviors/Circle.py | 2 +- behaviors/TimeSwitch.py | 24 ++++++++++++++++++++++++ config/C5Sign.xml | 32 ++++++++++++++++++-------------- util/Config.py | 8 ++++---- 4 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 behaviors/TimeSwitch.py diff --git a/behaviors/Circle.py b/behaviors/Circle.py index 24d71f1..f3e103b 100644 --- a/behaviors/Circle.py +++ b/behaviors/Circle.py @@ -15,7 +15,7 @@ class Circle(Behavior): data[self['Id']+'Radius'] = self['Radius'] rad = data[self['Id']+'Radius'] cond = '>=' if self['Outside'] else '<=' - circleStr = 'math.sqrt(({x}-'+str(xLoc)+')**2+(({y}-'+str(yLoc)+')**2))'+cond+str(rad) + circleStr = 'math.sqrt(({x}-'+str(xLoc)+')**2+(({y}-'+str(yLoc)+')**2)*2)'+cond+str(rad) if self['Combine']: data['Location'] += ',' + circleStr else: diff --git a/behaviors/TimeSwitch.py b/behaviors/TimeSwitch.py new file mode 100644 index 0000000..2cedfcf --- /dev/null +++ b/behaviors/TimeSwitch.py @@ -0,0 +1,24 @@ +from operationscore.Behavior import * +import util.TimeOps as clock +import util.ComponentRegistry as compReg +from logger import main_log +class TimeSwitch(Behavior): + """TimeSwitch is a behavior that alternates between different behaviors for a set amount of time + (specify time in seconds. Specify in a python-style dict: + {'behaviorId1':60, 'behaviorId2':120} + Would alternate between the 2 behaviors, spending 1 minute on b1 and 2 minutes on b2. + """ + def behaviorInit(self): + self.keyIndex = 0 + self.currentBehaviorId = self['Behaviors'].keys()[self.keyIndex] + self.behaviorStart = clock.time() + + def processResponse(self, sensors, recurs): + if self.behaviorStart + self['Behaviors'][self.currentBehaviorId]*1000 <= clock.time(): + self.keyIndex += 1 + self.keyIndex = self.keyIndex % len(self['Behaviors']) + self.currentBehaviorId = self['Behaviors'].keys()[self.keyIndex] + self.behaviorStart = clock.time() + main_log.info('Switching behaviors') + return compReg.getComponent(self.currentBehaviorId).processResponse(sensors, recurs) + diff --git a/config/C5Sign.xml b/config/C5Sign.xml index 02bd0a2..12cf6e6 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -164,6 +164,7 @@ xymove ybounce xbounce + longrecursivedecay @@ -176,6 +177,17 @@ 4*math.sin({x}/float(40)) + + behaviors.TimeSwitch + + main + + center + + {'runcolordecay':10,'expandingcircles':10} + True + + behaviors.DebugBehavior @@ -194,19 +206,16 @@ 20 - + + behaviors/LoopAndDie.xml + + behaviors/LoopAndDie.xml - - 80 - behaviors.BehaviorChain runcolordecay - - pygameclick - colorchange mover @@ -311,18 +320,13 @@ behaviors.BehaviorChain - expandingcirlces - - pygameclick - center - + expandingcircles colorchange mover - decay + singleframe {'mover':'circle_expand'} - True diff --git a/util/Config.py b/util/Config.py index 25018a8..962aa25 100644 --- a/util/Config.py +++ b/util/Config.py @@ -26,8 +26,8 @@ def loadConfigFile(fileName): #TODO: error handling etc. resolveDocumentInheritances(config.getroot()) return config except Exception as inst: - main_log.error('Error loading config file ' + fileName)#, inst) TODO: log exception too - main_log.error(str(inst)) + main_log.info('Error loading config file ' + fileName)#, inst) TODO: log exception too + main_log.info(str(inst)) return None def getElement(el): """Takes an Element or an ElementTree. If it is a tree, it returns its root. Otherwise, just returns @@ -89,7 +89,7 @@ def fileToDict(fileName): for line in f: fileText += line.rstrip('\n').lstrip('\t') + ' ' except IOError: - exception_log.exception('Failure reading ' + fileName) + main_log.info('Failure reading ' + fileName) return {} if fileText == '': return {} @@ -98,7 +98,7 @@ def fileToDict(fileName): main_log.info(fileName + ' read and parsed') return resultDict except: - exception_log.info(fileName + ' is not a well formed python dict. Parsing failed') + main_log.exception(fileName + ' is not a well formed python dict. Parsing failed') return eval(fileText) def pullArgsFromItem(parentNode): -- cgit v1.2.3 From 7a4f06d15b0fe9bd22996af6a1ca2c3ca5ca3e3f Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 13 Feb 2011 19:00:44 -0500 Subject: Added a vertical bars animation to C5Sign-dxiao --- behaviors/VerticalBar.py | 30 +++ config/C5Sign-dxiao.xml | 396 ++++++++++++++++++++++++++++++++++++++ config/C5Sign.xml | 2 +- inputs/ContinuousLocationInput.py | 19 ++ pixelmappers/C5SignMapper.py | 8 +- 5 files changed, 452 insertions(+), 3 deletions(-) create mode 100644 behaviors/VerticalBar.py create mode 100644 config/C5Sign-dxiao.xml create mode 100644 inputs/ContinuousLocationInput.py diff --git a/behaviors/VerticalBar.py b/behaviors/VerticalBar.py new file mode 100644 index 0000000..e1a67fe --- /dev/null +++ b/behaviors/VerticalBar.py @@ -0,0 +1,30 @@ +from operationscore.Behavior import * +class VerticalBar(Behavior): + + def processResponse(self, inputs, recurs): + + ret = [] + for inputset in inputs: + #import pdb; pdb.set_trace() + + if 'xLoc' not in inputset: + inputset['xLoc'] = inputset['Location'][0] + xLoc = inputset['xLoc'] + + condition = '{x} == ' + str(xLoc) + + if self['Combine']: + inputset['Location'] += ',' + condition + else: + 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 diff --git a/config/C5Sign-dxiao.xml b/config/C5Sign-dxiao.xml new file mode 100644 index 0000000..38eb40c --- /dev/null +++ b/config/C5Sign-dxiao.xml @@ -0,0 +1,396 @@ + + + + + simplemap + + + + layouts/C5SignLayout.xml + + + + + pixelmappers.C5SignMapper + + c5signmapper + 20 + + + + + pixelmappers.SimpleMapper + + simplemap + 20 + + + + pixelmappers.GaussianMapper + + gaussmap + 30 + 0.1 + 7 + 1 + + + + + + renderers/C5Renderer.xml + + + renderers/Pygame.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.xml b/config/C5Sign.xml index 02bd0a2..45e42de 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -10,7 +10,7 @@ - pixelmappers.SimpleMapper + pixelmappers.C5SignMapper simplemap 20 diff --git a/inputs/ContinuousLocationInput.py b/inputs/ContinuousLocationInput.py new file mode 100644 index 0000000..f39bd9b --- /dev/null +++ b/inputs/ContinuousLocationInput.py @@ -0,0 +1,19 @@ +import util.TimeOps as clock +import util.ComponentRegistry as compReg +import util.Strings as Strings +from operationscore.Input import * +class ContinuousLocationInput(Input): + '''Continuously returns one of nine positions on the screen as specified by the xloc + and yloc arguments, which can take values 'min', 'max', and 'center'. ''' + def inputInit(self): + xvals = {} + yvals = {} + xvals['left'], yvals['bottom'], xvals['right'], yvals['top'] = compReg.getComponent('Screen').getSize() + (xvals['center'], yvals['center']) = ((xvals['left']+xvals['right']) / 2, (yvals['top']+yvals['bottom']) / 2) + + self.location = (xvals[self['xloc']], yvals[self['yloc']]) + + def sensingLoop(self): + print (self.location) + self.respond({Strings.LOCATION: self.location}) + diff --git a/pixelmappers/C5SignMapper.py b/pixelmappers/C5SignMapper.py index 79ebe1a..24631c4 100644 --- a/pixelmappers/C5SignMapper.py +++ b/pixelmappers/C5SignMapper.py @@ -1,6 +1,7 @@ from operationscore.PixelMapper import * import util.Geo as Geo import sys +import math class C5SignMapper(PixelMapper): """C5SignMapper is a modification to SimpleMapper which maps events to the nearest Pixel. In addtion, it also maps sign artifacts (letters, logo, etc) @@ -99,7 +100,9 @@ class C5SignMapper(PixelMapper): [eventLocation, signPart] = eventLocSplit signParts = signPart.split('.') pixelLocs = signPosition[signParts[0]][signParts[1]] - screen = [p for p in screen if (p.location in pixelLocs)] + screenPixels = [p for p in screen if (p.location in pixelLocs)] + else: + screenPixels = [p for p in screen] #{x}>5,{y} Date: Sun, 13 Feb 2011 19:10:40 -0500 Subject: Config changes. --- config/C5Sign.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/C5Sign.xml b/config/C5Sign.xml index 12cf6e6..7ecb9e0 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -115,7 +115,7 @@ decay gaussmap - False + True @@ -185,7 +185,7 @@ center {'runcolordecay':10,'expandingcircles':10} - True + False -- cgit v1.2.3 From fcaed61eacb4ba296229b16df2de24e701cf53d3 Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 13 Feb 2011 19:41:35 -0500 Subject: Get rid annoying print statement for Russell --- config/C5Sign-dxiao.xml | 4 ++-- inputs/ContinuousLocationInput.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/config/C5Sign-dxiao.xml b/config/C5Sign-dxiao.xml index 38eb40c..7dc4b81 100644 --- a/config/C5Sign-dxiao.xml +++ b/config/C5Sign-dxiao.xml @@ -40,9 +40,9 @@ renderers/C5Renderer.xml - + - - inputs/MouseFollower.xml - @@ -94,15 +91,56 @@ behaviors.TouchOSC - - behaviors/RandomColor.xml + + behaviors/PixelDecay.xml + + .001 + + + + 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'} + False + + + + behaviors/RandomColor.xml + behaviors.BehaviorChain @@ -115,7 +153,7 @@ decay gaussmap - True + False @@ -124,12 +162,6 @@ behaviors/SingleFrame.xml - - behaviors/PixelDecay.xml - - .01 - - behaviors.XYMove @@ -168,24 +200,18 @@ - - behaviors.ModifyParam - - ysin - YStep - Sensor - 4*math.sin({x}/float(40)) - - behaviors.TimeSwitch main + centerleft center - {'runcolordecay':10,'expandingcircles':10} - False + {'scanningbars':10,'runcolordecay':10,'expandingcircles':10} + {'scanningbars':'centerleft', 'runcolordecay':'center',\ + 'expandingcircles':'center'} + True @@ -206,10 +232,10 @@ 20 - + behaviors/LoopAndDie.xml - + behaviors/LoopAndDie.xml @@ -233,45 +259,12 @@ 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 @@ -292,7 +285,7 @@ behaviors.ModifyParam incrinner - {val}+.3 + {val}+.6 innercircleRadius @@ -300,7 +293,7 @@ behaviors.ModifyParam incrouter - {val}+.3 + {val}+.6 outercircleRadius @@ -324,13 +317,11 @@ colorchange mover - singleframe + decay + {'mover':'circle_expand'} - - behaviors/RunningBehavior.xml - diff --git a/inputs/ContinuousCenterInput.py b/inputs/ContinuousCenterInput.py index a7635b2..88534f0 100644 --- a/inputs/ContinuousCenterInput.py +++ b/inputs/ContinuousCenterInput.py @@ -4,9 +4,10 @@ import util.Strings as Strings from operationscore.Input import * class ContinuousCenterInput(Input): def inputInit(self): + compReg.getLock().acquire() minX,minY,maxX,maxY = compReg.getComponent('Screen').getSize() + compReg.getLock().release() self.center = ((minX+maxX) / 2, (minY+maxY) / 2) - print self.center def sensingLoop(self): self.respond({Strings.LOCATION: self.center}) diff --git a/inputs/ContinuousLocationInput.py b/inputs/ContinuousLocationInput.py index 52a36ad..72ca8f0 100644 --- a/inputs/ContinuousLocationInput.py +++ b/inputs/ContinuousLocationInput.py @@ -8,7 +8,9 @@ class ContinuousLocationInput(Input): def inputInit(self): xvals = {} yvals = {} + compReg.getLock().acquire() xvals['left'], yvals['bottom'], xvals['right'], yvals['top'] = compReg.getComponent('Screen').getSize() + compReg.getLock().release() (xvals['center'], yvals['center']) = ((xvals['left']+xvals['right']) / 2, (yvals['top']+yvals['bottom']) / 2) self.location = (xvals[self['xloc']], yvals[self['yloc']]) diff --git a/renderers/PygameRenderer.py b/renderers/PygameRenderer.py index 01e2615..8be272c 100644 --- a/renderers/PygameRenderer.py +++ b/renderers/PygameRenderer.py @@ -25,7 +25,7 @@ class PygameRenderer(Renderer): for light in lightSystem: scaledLoc = [l*scale for l in light.location] pygame.draw.circle(self.background, light.state(currentTime), scaledLoc, \ - light.radius) + 5) self.screen.blit(self.background, (0,0)) pygame.display.flip() diff --git a/util/ComponentRegistry.py b/util/ComponentRegistry.py index be913df..3036138 100644 --- a/util/ComponentRegistry.py +++ b/util/ComponentRegistry.py @@ -1,12 +1,18 @@ import pdb import hashlib from logger import main_log +import thread #TODO: make component registry a singleton def initRegistry(): #TODO: don't overwrite existing registry if not 'Registry' in globals(): globals()['Registry'] = {} - + makelock() + + +def makelock(): + global utilLock + utilLock = thread.allocate_lock() def clearRegistry(): initRegistry() @@ -14,6 +20,9 @@ def removeComponent(cid): global Registry Registry.pop(cid) +def getLock(): + global utilLock + return utilLock def getComponent(cid): global Registry return Registry[cid] @@ -31,6 +40,8 @@ def registerComponent(component, cid=None): cid = getNewId() component['Id'] = cid main_log.debug(cid + 'automatically assigned') + if cid in Registry: + import pdb; pdb.set_trace() Registry[cid] = component return cid @@ -42,10 +53,6 @@ def removeComponent(cid): global Registry Registry.pop(cid) -def getComponent(cid): - global Registry - return Registry[cid] - def getNewId(): global Registry trialKey = len(Registry) -- cgit v1.2.3 From 2df9e408a0ff74539862c4a4e562a878cc11a329 Mon Sep 17 00:00:00 2001 From: rcoh Date: Wed, 16 Feb 2011 18:20:36 -0500 Subject: Code cleanup. Made Oval behavior (circle with h/w). --- LightInstallation.py | 1 - behaviors/Circle.py | 2 +- behaviors/ModifyParam.py | 3 --- behaviors/Oval.py | 36 ++++++++++++++++++++++++++++++++++++ behaviors/VerticalBar.py | 1 - config/C5Sign.xml | 6 +++--- operationscore/PixelAssembler.py | 4 ++-- pixelmappers/SimpleMapper.py | 4 ++-- util/ComponentRegistry.py | 3 +-- 9 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 behaviors/Oval.py diff --git a/LightInstallation.py b/LightInstallation.py index 91be752..19d6c54 100755 --- a/LightInstallation.py +++ b/LightInstallation.py @@ -181,7 +181,6 @@ class LightInstallation(object): def processResponse(self,inputDict, responseDict): inputId = inputDict['Id'] - #coming from. boundBehaviorIds = self.inputBehaviorRegistry[inputId] try: [compReg.getComponent(b).addInput(responseDict) for b in boundBehaviorIds] diff --git a/behaviors/Circle.py b/behaviors/Circle.py index f3e103b..24d71f1 100644 --- a/behaviors/Circle.py +++ b/behaviors/Circle.py @@ -15,7 +15,7 @@ class Circle(Behavior): data[self['Id']+'Radius'] = self['Radius'] rad = data[self['Id']+'Radius'] cond = '>=' if self['Outside'] else '<=' - circleStr = 'math.sqrt(({x}-'+str(xLoc)+')**2+(({y}-'+str(yLoc)+')**2)*2)'+cond+str(rad) + circleStr = 'math.sqrt(({x}-'+str(xLoc)+')**2+(({y}-'+str(yLoc)+')**2))'+cond+str(rad) if self['Combine']: data['Location'] += ',' + circleStr else: diff --git a/behaviors/ModifyParam.py b/behaviors/ModifyParam.py index ebcb98f..6f81383 100644 --- a/behaviors/ModifyParam.py +++ b/behaviors/ModifyParam.py @@ -1,6 +1,5 @@ from operationscore.Behavior import * import math -import pdb #Class to perform a given operation on some element of an argDict. Designed to be used a recursive hook, but can serve sensor-based functions as well. Specify ParamType (Sensor or Recurse), ParamName, and ParamOp, (a valid python statement with the old value represented as {val}) class ModifyParam(Behavior): """ModifyParam is a powerful class to perform an action on a specified key in the Argument @@ -30,8 +29,6 @@ class ModifyParam(Behavior): #TODO: move elsewhere paramOp = paramOp.replace('{y}', "behaviorInput['Location'][1]") paramOp = paramOp.replace('{x}', "behaviorInput['Location'][0]") - if eval(paramOp) == None: - import pdb; pdb.set_trace() behaviorInput[paramName] = eval(paramOp) if paramType == 'Sensor': #return accordingly return (searchSet, recursiveInputs) diff --git a/behaviors/Oval.py b/behaviors/Oval.py new file mode 100644 index 0000000..b7486f5 --- /dev/null +++ b/behaviors/Oval.py @@ -0,0 +1,36 @@ +from operationscore.Behavior import * +class Oval(Behavior): + def processResponse(self, sensors, recurs): + ret = [] + for data in sensors: + #import pdb; pdb.set_trace() + height = width = 1 + if 'Height' in self: + height = 1/float(self['Height']) + if 'Width' in self: + width = 1/float(self['Width']) + if 'CenterLoc' in data: + xLoc = data['CenterLoc'][0] + yLoc = data['CenterLoc'][1] + else: + data['CenterLoc'] = tuple(data['Location']) + xLoc = data['Location'][0] + yLoc = data['Location'][1] + if not self['Id']+'Radius' in data: + data[self['Id']+'Radius'] = self['Radius'] + rad = data[self['Id']+'Radius'] + cond = '>=' if self['Outside'] else '<=' + circleStr = \ + 'math.sqrt((({x}-%(xLoc)d))**2*%(width)d+(({y}-%(yLoc)d)**2)*%(height)d)%(cond)s%(rad)d' % \ + locals() + if self['Combine']: + data['Location'] += ',' + circleStr + else: + data['Location'] = circleStr + ret.append(data) + return (ret, []) + def setLastOutput(self, output): + coutput = Behavior.deepCopyPacket(output) + for data in coutput: + data['Location'] = data['CenterLoc'] + return coutput diff --git a/behaviors/VerticalBar.py b/behaviors/VerticalBar.py index 66c8e56..85960cb 100644 --- a/behaviors/VerticalBar.py +++ b/behaviors/VerticalBar.py @@ -5,7 +5,6 @@ class VerticalBar(Behavior): 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] diff --git a/config/C5Sign.xml b/config/C5Sign.xml index a05cb1e..024f0d8 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -208,7 +208,7 @@ centerleft center - {'scanningbars':10,'runcolordecay':10,'expandingcircles':10} + {'scanningbars':0,'runcolordecay':10,'expandingcircles':10} {'scanningbars':'centerleft', 'runcolordecay':'center',\ 'expandingcircles':'center'} True @@ -266,7 +266,7 @@ - behaviors.Circle + behaviors.Oval innercircle 0 @@ -274,7 +274,7 @@ - behaviors.Circle + behaviors.Oval outercircle 3 diff --git a/operationscore/PixelAssembler.py b/operationscore/PixelAssembler.py index 582b59d..8ae27c9 100644 --- a/operationscore/PixelAssembler.py +++ b/operationscore/PixelAssembler.py @@ -19,10 +19,10 @@ class PixelAssembler(SmootCoreObject): defined or improperly defined.') if Geo.dist(newLocation, locations[-1]) > \ self['pixelToPixelSpacing']: - import pdb; pdb.set_trace() raise Exception('Illegal pixel location. Distance \ between adjacent pixels must be less than \ - pixelToPixelSpacing.') + pixelToPixelSpacing. Illegal distance is between '+str(pixelIndex) + ' and'\ + + str(pixelIndex+1)) locations.append(newLocation) if self['Reverse']: locations.reverse() diff --git a/pixelmappers/SimpleMapper.py b/pixelmappers/SimpleMapper.py index 6603c98..1decdd1 100644 --- a/pixelmappers/SimpleMapper.py +++ b/pixelmappers/SimpleMapper.py @@ -44,7 +44,7 @@ class SimpleMapper(PixelMapper): if pixelValid: ret.append((pixel, 1)) except Exception as exp: - import pdb; pdb.set_trace() - raise Exception('Bad event condition') + exp.message += 'Bad Event Condition' + raise exp return ret diff --git a/util/ComponentRegistry.py b/util/ComponentRegistry.py index 3036138..1db5135 100644 --- a/util/ComponentRegistry.py +++ b/util/ComponentRegistry.py @@ -1,4 +1,3 @@ -import pdb import hashlib from logger import main_log import thread @@ -41,7 +40,7 @@ def registerComponent(component, cid=None): component['Id'] = cid main_log.debug(cid + 'automatically assigned') if cid in Registry: - import pdb; pdb.set_trace() + main_log.warn(cid + 'overwritten.') Registry[cid] = component return cid -- cgit v1.2.3