From 7f88db7003a03b50dc500bf7bd711407f1a640de Mon Sep 17 00:00:00 2001 From: rcoh Date: Sat, 22 Jan 2011 13:31:56 -0500 Subject: Bouncing behavior. Working out a weird bug. Threading may be involved? --- LightInstallation.py | 1 + behaviors/RestrictLocation.py | 2 +- behaviors/Square.py | 1 + config/6thFloor.xml | 76 ++++++++++++++++++++++++++++++++++++---- layouts/60StripLayout.xml | 60 +++++++++++++++---------------- operationscore/Input.py | 1 - operationscore/PixelAssembler.py | 2 ++ operationscore/PixelMapper.py | 4 ++- operationscore/Renderer.py | 4 +-- pixelevents/SingleFrameEvent.py | 11 +++--- renderers/60StripSeq.xml | 4 --- setup.sh | 0 12 files changed, 117 insertions(+), 49 deletions(-) mode change 100644 => 100755 setup.sh diff --git a/LightInstallation.py b/LightInstallation.py index 7f98473..62d3f6a 100644 --- a/LightInstallation.py +++ b/LightInstallation.py @@ -134,6 +134,7 @@ class LightInstallation(object): main_log.debug(className + 'initialized with args ' + str(args)) #right except Exception as inst: + pdb.set_trace() main_log.error('Failure while initializing ' + className + ' with ' + str(args)) main_log.error(str(inst)) 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/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/config/6thFloor.xml b/config/6thFloor.xml index 9c5f77e..4c31892 100644 --- a/config/6thFloor.xml +++ b/config/6thFloor.xml @@ -7,6 +7,7 @@ layouts/60StripLayout.xml + @@ -28,9 +29,9 @@ - + renderers/Pygame.xml @@ -79,6 +80,9 @@ behaviors/PixelDecay.xml + + behaviors/SingleFrame.xml + behaviors/PixelDecay.xml @@ -86,6 +90,60 @@ + behaviors.XYMove + + xymove + 5 + 2 + + + + behaviors.RestrictLocation + + xbounce + {val}*-1 + XStep + {x}<0 or {x}>800 + + + + behaviors.RestrictLocation + + ybounce + {val}*-1 + YStep + {y}<0 or {y}>200 + + + + behaviors.BehaviorChain + + movebounce + + xymove + ybounce + xbounce + + + + + behaviors.BehaviorChain + + xymover + + pygame + + + colorchange + mover + decay + + {'mover':'movebounce'} + True + gaussmap + + + behaviors.DebugBehavior debug @@ -108,6 +166,12 @@ 20 + + behaviors.AllPixels + + allpixels + + behaviors/LoopAndDie.xml @@ -127,7 +191,7 @@ decay {'running':'acceleratedie'} - True + False gaussmap @@ -144,7 +208,7 @@ decay {'mover':'redwalk'} - True + False gaussmap @@ -196,9 +260,9 @@ echo redshift square - slowdecay + decay - True + False diff --git a/layouts/60StripLayout.xml b/layouts/60StripLayout.xml index 30f51c5..45ebcb3 100644 --- a/layouts/60StripLayout.xml +++ b/layouts/60StripLayout.xml @@ -1,179 +1,179 @@ - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml layouts/50PixelStrip.xml - + layouts/50PixelStrip.xml diff --git a/operationscore/Input.py b/operationscore/Input.py index 2ee3c3c..69375d3 100644 --- a/operationscore/Input.py +++ b/operationscore/Input.py @@ -14,7 +14,6 @@ class Input(ThreadedSmootCoreObject): def init(self): self.eventQueue = [] if not 'RefreshInterval' in self.argDict: - print 'RefreshInterval not defined. Defaulting to .5s.' self.argDict['RefreshInterval'] = 500 self.parentScope = self.argDict['parentScope'] self.inputInit() diff --git a/operationscore/PixelAssembler.py b/operationscore/PixelAssembler.py index 6878f8a..84f3b0b 100644 --- a/operationscore/PixelAssembler.py +++ b/operationscore/PixelAssembler.py @@ -23,6 +23,8 @@ class PixelAssembler(SmootCoreObject): between adjacent pixels must be less than \ pixelToPixelSpacing.') locations.append(newLocation) + if self['Reverse']: + locations.reverse() return locations def initLayout(self): pass diff --git a/operationscore/PixelMapper.py b/operationscore/PixelMapper.py index 1f94fa5..7e2b0af 100644 --- a/operationscore/PixelMapper.py +++ b/operationscore/PixelMapper.py @@ -1,4 +1,5 @@ from operationscore.SmootCoreObject import * +from logger import main_log import pdb class PixelMapper(SmootCoreObject): def init(self): @@ -8,7 +9,8 @@ class PixelMapper(SmootCoreObject): def mapEvent(self, eventLocation, screen): self.totalCalls += 1 if self.totalCalls % 100 == 0: - print self['Id'], self.cachehits / float(self.totalCalls) + main_log.info('Cache percentage for :', self['Id'], self.cachehits /\ + float(self.totalCalls)) if eventLocation in self.mem: self.cachehits += 1 return self.mem[eventLocation] diff --git a/operationscore/Renderer.py b/operationscore/Renderer.py index ed88a8c..b422304 100644 --- a/operationscore/Renderer.py +++ b/operationscore/Renderer.py @@ -3,8 +3,8 @@ #Inheriting classes may define initRenderer which is called after the dictionary #is pulled from config. #TODO: multithreaded-rendering -from operationscore.ThreadedSmootCoreObject import * -class Renderer(ThreadedSmootCoreObject): +from operationscore.SmootCoreObject import * +class Renderer(SmootCoreObject): def init(self): self.initRenderer() def render(lightSystem): diff --git a/pixelevents/SingleFrameEvent.py b/pixelevents/SingleFrameEvent.py index 1c6239f..97a2681 100644 --- a/pixelevents/SingleFrameEvent.py +++ b/pixelevents/SingleFrameEvent.py @@ -1,8 +1,11 @@ from operationscore.PixelEvent import * class SingleFrameEvent(PixelEvent): def initEvent(self): - self.rendered = False - def state(self): - if !self.rendered: - return self['Color'] + self.timeState = -1 + def state(self, timeDelay): + print 'singlehit' + + if self.timeState == (-1 or timeDelay): + self.timeState = timeDelay + return self.Color return None diff --git a/renderers/60StripSeq.xml b/renderers/60StripSeq.xml index 3f5255f..49e2c25 100644 --- a/renderers/60StripSeq.xml +++ b/renderers/60StripSeq.xml @@ -2,10 +2,6 @@ renderers.IndoorRenderer indoorRenderer - - 10.32.0.0 - {'strip0.1':1, 'strip0.2':2} - 10.32.0.1 {'strip1.1':1, 'strip1.2':2} diff --git a/setup.sh b/setup.sh old mode 100644 new mode 100755 -- cgit v1.2.3