diff options
author | rcoh <rcoh@mit.edu> | 2011-01-22 13:31:56 -0500 |
---|---|---|
committer | rcoh <rcoh@mit.edu> | 2011-01-22 13:31:56 -0500 |
commit | 7f88db7003a03b50dc500bf7bd711407f1a640de (patch) | |
tree | 64c08cf2bfd6fb30ccbfc3f4a9fb2435f417abdf | |
parent | a223608dda0751551c6e8688c0c0e1c9a1d4e69c (diff) |
Bouncing behavior. Working out a weird bug. Threading may be involved?
-rw-r--r-- | LightInstallation.py | 1 | ||||
-rw-r--r-- | behaviors/RestrictLocation.py | 2 | ||||
-rw-r--r-- | behaviors/Square.py | 1 | ||||
-rw-r--r-- | config/6thFloor.xml | 76 | ||||
-rw-r--r-- | layouts/60StripLayout.xml | 60 | ||||
-rw-r--r-- | operationscore/Input.py | 1 | ||||
-rw-r--r-- | operationscore/PixelAssembler.py | 2 | ||||
-rw-r--r-- | operationscore/PixelMapper.py | 4 | ||||
-rw-r--r-- | operationscore/Renderer.py | 4 | ||||
-rw-r--r-- | pixelevents/SingleFrameEvent.py | 11 | ||||
-rw-r--r-- | renderers/60StripSeq.xml | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | setup.sh | 0 |
12 files changed, 117 insertions, 49 deletions
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 @@ </InstallationConfiguration> <PixelConfiguration> <InheritsFrom>layouts/60StripLayout.xml</InheritsFrom> + <!--<InheritsFrom>layouts/BasicSixStrip.xml</InheritsFrom--> </PixelConfiguration> <PixelMapperConfiguration> <PixelMapper> @@ -28,9 +29,9 @@ </PixelMapper> </PixelMapperConfiguration> <RendererConfiguration> - <Renderer> + <!--<Renderer> <InheritsFrom>renderers/60StripSeq.xml</InheritsFrom> - </Renderer> + </Renderer>--> <Renderer> <InheritsFrom>renderers/Pygame.xml</InheritsFrom> </Renderer> @@ -79,6 +80,9 @@ <Behavior Id="decay"> <InheritsFrom>behaviors/PixelDecay.xml</InheritsFrom> </Behavior> + <Behavior Id="singleframe"> + <InheritsFrom>behaviors/SingleFrame.xml</InheritsFrom> + </Behavior> <Behavior Id="slowdecay"> <InheritsFrom>behaviors/PixelDecay.xml</InheritsFrom> <Args> @@ -86,6 +90,60 @@ </Args> </Behavior> <Behavior> + <Class>behaviors.XYMove</Class> + <Args> + <Id>xymove</Id> + <XStep>5</XStep> + <YStep>2</YStep> + </Args> + </Behavior> + <Behavior> + <Class>behaviors.RestrictLocation</Class> + <Args> + <Id>xbounce</Id> + <Action>{val}*-1</Action> + <ParamName>XStep</ParamName> + <LocationRestriction>{x}<0 or {x}>800</LocationRestriction> + </Args> + </Behavior> + <Behavior> + <Class>behaviors.RestrictLocation</Class> + <Args> + <Id>ybounce</Id> + <Action>{val}*-1</Action> + <ParamName>YStep</ParamName> + <LocationRestriction>{y}<0 or {y}>200</LocationRestriction> + </Args> + </Behavior> + <Behavior> + <Class>behaviors.BehaviorChain</Class> + <Args> + <Id>movebounce</Id> + <ChainedBehaviors> + <Id>xymove</Id> + <Id>ybounce</Id> + <Id>xbounce</Id> + </ChainedBehaviors> + </Args> + </Behavior> + <Behavior> + <Class>behaviors.BehaviorChain</Class> + <Args> + <Id>xymover</Id> + <Inputs> + <Id>pygame</Id> + </Inputs> + <ChainedBehaviors> + <Id>colorchange</Id> + <Id>mover</Id> + <Id>decay</Id> + </ChainedBehaviors> + <RecursiveHooks>{'mover':'movebounce'}</RecursiveHooks> + <RenderToScreen>True</RenderToScreen> + <Mapper>gaussmap</Mapper> + </Args> + </Behavior> + <Behavior> <Class>behaviors.DebugBehavior</Class> <Args> <Id>debug</Id> @@ -108,6 +166,12 @@ <Width>20</Width> </Args> </Behavior> + <Behavior> + <Class>behaviors.AllPixels</Class> + <Args> + <Id>allpixels</Id> + </Args> + </Behavior> <Behavior Id="recursivedecay"> <InheritsFrom>behaviors/LoopAndDie.xml</InheritsFrom> <Args> @@ -127,7 +191,7 @@ <Id>decay</Id> </ChainedBehaviors> <RecursiveHooks>{'running':'acceleratedie'}</RecursiveHooks> - <RenderToScreen>True</RenderToScreen> + <RenderToScreen>False</RenderToScreen> <Mapper>gaussmap</Mapper> </Args> </Behavior> @@ -144,7 +208,7 @@ <Id>decay</Id> </ChainedBehaviors> <RecursiveHooks>{'mover':'redwalk'}</RecursiveHooks> - <RenderToScreen>True</RenderToScreen> + <RenderToScreen>False</RenderToScreen> <Mapper>gaussmap</Mapper> </Args> </Behavior> @@ -196,9 +260,9 @@ <Id>echo</Id> <Id>redshift</Id> <Id>square</Id> - <Id>slowdecay</Id> + <Id>decay</Id> </ChainedBehaviors> - <RenderToScreen>True</RenderToScreen> + <RenderToScreen>False</RenderToScreen> </Args> </Behavior> <Behavior Id="running"> 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 @@ <PixelConfiguration> - <PixelStrip Id="strip1.1" originLocation="(0,0)"> + <PixelStrip Id="strip1.1" originLocation="(0,0)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip1.2" originLocation="(200,0)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip2.1" originLocation="(0,15)"> + <PixelStrip Id="strip2.1" originLocation="(0,15)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip2.2" originLocation="(200,15)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip3.1" originLocation="(0,30)"> + <PixelStrip Id="strip3.1" originLocation="(0,30)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip3.2" originLocation="(200,30)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip4.1" originLocation="(0,45)"> + <PixelStrip Id="strip4.1" originLocation="(0,45)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip4.2" originLocation="(200,45)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip5.1" originLocation="(0,60)"> + <PixelStrip Id="strip5.1" originLocation="(0,60)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip5.2" originLocation="(200,60)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip6.1" originLocation="(0,75)"> + <PixelStrip Id="strip6.1" originLocation="(0,75)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip6.2" originLocation="(200,75)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip7.1" originLocation="(0,90)"> + <PixelStrip Id="strip7.1" originLocation="(0,90)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip7.2" originLocation="(200,90)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip8.1" originLocation="(0,105)"> + <PixelStrip Id="strip8.1" originLocation="(0,105)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip8.2" originLocation="(200,105)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip9.1" originLocation="(0,120)"> + <PixelStrip Id="strip9.1" originLocation="(0,120)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip9.2" originLocation="(200,120)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip10.1" originLocation="(0,135)"> + <PixelStrip Id="strip10.1" originLocation="(0,135)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip10.2" originLocation="(200,135)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip11.1" originLocation="(0,150)"> + <PixelStrip Id="strip11.1" originLocation="(0,150)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip11.2" originLocation="(200,150)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip12.1" originLocation="(0,165)"> + <PixelStrip Id="strip12.1" originLocation="(0,165)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip12.2" originLocation="(200,165)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip13.1" originLocation="(0,180)"> + <PixelStrip Id="strip13.1" originLocation="(0,180)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip13.2" originLocation="(200,180)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip14.1" originLocation="(0,195)"> + <PixelStrip Id="strip14.1" originLocation="(0,195)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip14.2" originLocation="(200,195)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip15.1" originLocation="(0,210)"> + <PixelStrip Id="strip15.1" originLocation="(0,210)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip15.2" originLocation="(200,210)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip16.1" originLocation="(400,0)"> + <PixelStrip Id="strip16.1" originLocation="(400,0)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip16.2" originLocation="(600,0)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip17.1" originLocation="(400,15)"> + <PixelStrip Id="strip17.1" originLocation="(400,15)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip17.2" originLocation="(600,15)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip18.1" originLocation="(400,30)"> + <PixelStrip Id="strip18.1" originLocation="(400,30)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip18.2" originLocation="(600,30)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip19.1" originLocation="(400,45)"> + <PixelStrip Id="strip19.1" originLocation="(400,45)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip19.2" originLocation="(600,45)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip20.1" originLocation="(400,60)"> + <PixelStrip Id="strip20.1" originLocation="(400,60)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip20.2" originLocation="(600,60)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip21.1" originLocation="(400,75)"> + <PixelStrip Id="strip21.1" originLocation="(400,75)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip21.2" originLocation="(600,75)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip22.1" originLocation="(400,90)"> + <PixelStrip Id="strip22.1" originLocation="(400,90)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip22.2" originLocation="(600,90)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip23.1" originLocation="(400,105)"> + <PixelStrip Id="strip23.1" originLocation="(400,105)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip23.2" originLocation="(600,105)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip24.1" originLocation="(400,120)"> + <PixelStrip Id="strip24.1" originLocation="(400,120)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip24.2" originLocation="(600,120)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip25.1" originLocation="(400,135)"> + <PixelStrip Id="strip25.1" originLocation="(400,135)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip25.2" originLocation="(600,135)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip26.1" originLocation="(400,150)"> + <PixelStrip Id="strip26.1" originLocation="(400,150)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip26.2" originLocation="(600,150)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip27.1" originLocation="(400,165)"> + <PixelStrip Id="strip27.1" originLocation="(400,165)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip27.2" originLocation="(600,165)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip28.1" originLocation="(400,180)"> + <PixelStrip Id="strip28.1" originLocation="(400,180)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip28.2" originLocation="(600,180)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip29.1" originLocation="(400,195)"> + <PixelStrip Id="strip29.1" originLocation="(400,195)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip29.2" originLocation="(600,195)"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> - <PixelStrip Id="strip30.1" originLocation="(400,210)"> + <PixelStrip Id="strip30.1" originLocation="(400,210)" Reverse="True"> <InheritsFrom>layouts/50PixelStrip.xml</InheritsFrom> </PixelStrip> <PixelStrip Id="strip30.2" originLocation="(600,210)"> 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 @@ -3,10 +3,6 @@ <Args> <Id>indoorRenderer</Id> <PowerSupply> - <IP>10.32.0.0</IP> - <PortMapping>{'strip0.1':1, 'strip0.2':2}</PortMapping> - </PowerSupply> - <PowerSupply> <IP>10.32.0.1</IP> <PortMapping>{'strip1.1':1, 'strip1.2':2}</PortMapping> </PowerSupply> |