aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LightInstallation.py9
-rw-r--r--behaviors/AllPixels.py6
-rw-r--r--behaviors/DebugBehavior.py2
-rw-r--r--behaviors/DimColor.xml8
-rw-r--r--behaviors/DoorBehavior.py4
-rw-r--r--behaviors/Expand.py17
-rw-r--r--behaviors/RestrictLocation.py2
-rw-r--r--behaviors/SingleFrame.xml7
-rw-r--r--behaviors/Square.py1
-rw-r--r--behaviors/XYMove.py17
-rw-r--r--config/6thFloor.xml103
-rw-r--r--inputs/TCPInput.py6
-rw-r--r--inputs/UDPInput.py6
-rw-r--r--layouts/60StripLayout.xml60
-rw-r--r--operationscore/Behavior.py2
-rw-r--r--operationscore/Input.py1
-rw-r--r--operationscore/PixelAssembler.py2
-rw-r--r--operationscore/PixelMapper.py4
-rw-r--r--operationscore/Renderer.py4
-rw-r--r--pixelcore/Pixel.py33
-rw-r--r--pixelcore/Screen.py25
-rw-r--r--pixelevents/SingleFrameEvent.py10
-rw-r--r--pixelmappers/GaussianMapper.py2
-rw-r--r--renderers/60StripSeq.xml4
24 files changed, 257 insertions, 78 deletions
diff --git a/LightInstallation.py b/LightInstallation.py
index 7f98473..b582bd2 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))
@@ -145,19 +146,19 @@ class LightInstallation(object):
def mainLoop(self):
lastLoopTime = clock.time()
refreshInterval = 30
- runCount = 2000
- while runCount > 0 and not self.dieNow:
- runCount -= 1
+ while not self.dieNow:
loopStart = clock.time()
responses = self.evaluateBehaviors() #inputs are all queued when they
#happen, so we only need to run the behaviors
self.timer.start()
[self.screen.respond(response) for response in responses if
response != []]
- self.screen.timeStep()
+ self.screen.timeStep(loopStart)
[r.render(self.screen, loopStart) for r in self.renderers]
loopElapsed = clock.time()-loopStart
sleepTime = max(0,refreshInterval-loopElapsed)
+ main_log.debug('Loop complete in ' + str(loopElapsed) + 'ms. Sleeping for ' +\
+ str(sleepTime))
self.timer.stop()
#print self.timer.elapsed()
if sleepTime > 0:
diff --git a/behaviors/AllPixels.py b/behaviors/AllPixels.py
new file mode 100644
index 0000000..e155e55
--- /dev/null
+++ b/behaviors/AllPixels.py
@@ -0,0 +1,6 @@
+from operationscore.Behavior import *
+class AllPixels(Behavior):
+ def processResponse(self, sensorInputs, recursiveInputs):
+ for sensory in sensorInputs:#TODO: consider replicating the dict
+ sensory['Location'] = 'True'
+ return (sensorInputs, recursiveInputs)
diff --git a/behaviors/DebugBehavior.py b/behaviors/DebugBehavior.py
index 34f4106..17383db 100644
--- a/behaviors/DebugBehavior.py
+++ b/behaviors/DebugBehavior.py
@@ -4,5 +4,5 @@ import pdb
class DebugBehavior(Behavior):
def processResponse(self, sensorInputs, recursiveInputs):
if sensorInputs != []:
- main_log.debug('Sensor Inputs: ' + str(sensorInputs))
+ main_log.error('Sensor Inputs: ' + str(sensorInputs))
return ([], [])
diff --git a/behaviors/DimColor.xml b/behaviors/DimColor.xml
new file mode 100644
index 0000000..b01908e
--- /dev/null
+++ b/behaviors/DimColor.xml
@@ -0,0 +1,8 @@
+<Behavior>
+ <Class>behaviors.ModifyParam</Class>
+ <Args>
+ <ParamType>Sensor</ParamType>
+ <ParamName>Color</ParamName>
+ <ParamOp>[chan*.99 for chan in {val}]</ParamOp>
+ </Args>
+</Behavior>
diff --git a/behaviors/DoorBehavior.py b/behaviors/DoorBehavior.py
new file mode 100644
index 0000000..5058f69
--- /dev/null
+++ b/behaviors/DoorBehavior.py
@@ -0,0 +1,4 @@
+from operationscore.behavior import *
+class DoorBehavior.py(Behavior):
+ def behaviorInit(self):
+ pyt
diff --git a/behaviors/Expand.py b/behaviors/Expand.py
new file mode 100644
index 0000000..3415966
--- /dev/null
+++ b/behaviors/Expand.py
@@ -0,0 +1,17 @@
+from operationscore.Behavior import *
+class Expand(Behavior):
+ def processResponse(self, sensorInputs, recurs):
+ ret = []
+ for data in sensorInputs:
+ if not 'Left' in data: #If this is the first time we have seen this input
+ data['Left'] = data['Location'][0]
+ data['Right'] = data['Location'][0]
+ data['ExpandRate'] = self['ExpandRate']
+
+ data = dict(data)
+ data['Left'] -= data['ExpandRate']
+ data['Right'] += data['ExpandRate']
+ data['Location'] = "{x}>" + str(data['Left']) + ", {x}<" + str(data['Right'])
+ ret.append(data)
+ return (ret, [])
+
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/SingleFrame.xml b/behaviors/SingleFrame.xml
new file mode 100644
index 0000000..49b5dcf
--- /dev/null
+++ b/behaviors/SingleFrame.xml
@@ -0,0 +1,7 @@
+<Behavior>
+ <Class>behaviors.AddPixelEvent</Class>
+ <Args>
+ <Class>pixelevents.SingleFrameEvent</Class>
+ <z-index>0</z-index>
+ </Args>
+</Behavior>
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/behaviors/XYMove.py b/behaviors/XYMove.py
new file mode 100644
index 0000000..8acbba8
--- /dev/null
+++ b/behaviors/XYMove.py
@@ -0,0 +1,17 @@
+from operationscore.Behavior import *
+import util.Geo as Geo
+class XYMove(Behavior):
+ def processResponse(self, sensor, recurs):
+ ret = []
+ for loc in sensor:
+ oploc = dict(loc)
+ self.insertStepIfMissing(oploc)
+ oploc['Location'] = Geo.addLocations((oploc['XStep'], oploc['YStep']), oploc['Location'])
+ ret.append(oploc)
+ return (ret, [])
+ def insertStepIfMissing(self, data):
+ if not 'XStep' in data:
+ data['XStep'] = self['XStep']
+ if not 'YStep' in data:
+ data['YStep'] = self['YStep']
+
diff --git a/config/6thFloor.xml b/config/6thFloor.xml
index 9c5f77e..c98486a 100644
--- a/config/6thFloor.xml
+++ b/config/6thFloor.xml
@@ -28,9 +28,9 @@
</PixelMapper>
</PixelMapperConfiguration>
<RendererConfiguration>
- <Renderer>
+ <!--Renderer>
<InheritsFrom>renderers/60StripSeq.xml</InheritsFrom>
- </Renderer>
+ </Renderer-->
<Renderer>
<InheritsFrom>renderers/Pygame.xml</InheritsFrom>
</Renderer>
@@ -43,6 +43,14 @@
<RefreshInterval>10</RefreshInterval>
</Args>
</InputElement>
+ <InputElement>
+ <Class>inputs.UDPInput</Class>
+ <Args>
+ <Id>udp</Id>
+ <Port>3344</Port>
+ <RefreshInterval>50</RefreshInterval>
+ </Args>
+ </InputElement>
<!--<InputElement>
<Class>inputs.TCPInput</Class>
<Args>
@@ -70,15 +78,34 @@
<RenderToScreen>False</RenderToScreen>
</Args>
</Behavior>
+ <Behavior Id="dim">
+ <InheritsFrom>behaviors/DimColor.xml</InheritsFrom>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.Expand</Class>
+ <Args>
+ <Id>expand</Id>
+ <ExpandRate>1</ExpandRate>
+ </Args>
+ </Behavior>
<Behavior Id="redshift">
<InheritsFrom>behaviors/RedShift.xml</InheritsFrom>
</Behavior>
<Behavior Id="colorchange">
<InheritsFrom>behaviors/RandomColor.xml</InheritsFrom>
+ <Args>
+ <ColorList>
+ <Val>(255,0,0)</Val>
+ <Val>(0,0,255)</Val>
+ </ColorList>
+ </Args>
</Behavior>
<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,12 +113,77 @@
</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}&lt;0 or {x}&gt;800</LocationRestriction>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.RestrictLocation</Class>
+ <Args>
+ <Id>ybounce</Id>
+ <Action>{val}*-1</Action>
+ <ParamName>YStep</ParamName>
+ <LocationRestriction>{y}&lt;0 or {y}&gt;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>expanddie</Id>
+ <ChainedBehaviors>
+ <Id>expand</Id>
+ <Id>dim</Id>
+ </ChainedBehaviors>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>inpexpanddim</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>
<z-index>0</z-index>
<Inputs>
<Id>pygame</Id>
+ <Id>udp</Id>
</Inputs>
</Args>
</Behavior>
@@ -127,7 +219,7 @@
<Id>decay</Id>
</ChainedBehaviors>
<RecursiveHooks>{'running':'acceleratedie'}</RecursiveHooks>
- <RenderToScreen>True</RenderToScreen>
+ <RenderToScreen>False</RenderToScreen>
<Mapper>gaussmap</Mapper>
</Args>
</Behavior>
@@ -144,7 +236,7 @@
<Id>decay</Id>
</ChainedBehaviors>
<RecursiveHooks>{'mover':'redwalk'}</RecursiveHooks>
- <RenderToScreen>True</RenderToScreen>
+ <RenderToScreen>False</RenderToScreen>
<Mapper>gaussmap</Mapper>
</Args>
</Behavior>
@@ -194,9 +286,8 @@
</Inputs>
<ChainedBehaviors>
<Id>echo</Id>
- <Id>redshift</Id>
<Id>square</Id>
- <Id>slowdecay</Id>
+ <Id>singleframe</Id>
</ChainedBehaviors>
<RenderToScreen>True</RenderToScreen>
</Args>
diff --git a/inputs/TCPInput.py b/inputs/TCPInput.py
index 513b853..2bc69ef 100644
--- a/inputs/TCPInput.py
+++ b/inputs/TCPInput.py
@@ -21,15 +21,15 @@ class TCPInput(Input):
def sensingLoop(self):
data = self.conn.recv(self.BUFFER_SIZE)
main_log.debug('Incoming data', data)
+
if not data or 'end' in data: # data end, close socket
main_log.debug('End in data')
print 'end of stream'
self.IS_RESPONDING = 0
self.conn.close()
self.sock.close()
-
- if self.IS_RESPONDING == 1: # if 'responding', respond to the received data
- #dataDict = json.loads(data)
+
+ if self.IS_RESPONDING == 1: # if 'responding', respond to the received data
try:
for datagroup in data.split('\n'):
if datagroup != None and datagroup != '':
diff --git a/inputs/UDPInput.py b/inputs/UDPInput.py
index 7d5609e..e95bd33 100644
--- a/inputs/UDPInput.py
+++ b/inputs/UDPInput.py
@@ -7,7 +7,7 @@ class UDPInput(Input):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.bind((HOST, PORT))
def sensingLoop(self):
- (data,address) = self.sock.recvfrom(1024)
- dataDict = {'data':data, 'address':address}
- self.respond(dataDict)
+ (data,address) = self.sock.recvfrom(1024)
+ dataDict = {'data':data, 'address':address}
+ self.respond(dataDict)
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/Behavior.py b/operationscore/Behavior.py
index 882a290..b3f7342 100644
--- a/operationscore/Behavior.py
+++ b/operationscore/Behavior.py
@@ -9,6 +9,7 @@
import pdb
from operationscore.SmootCoreObject import *
+from logger import main_log
#timeStep is called on every iteration of the LightInstallation
#addInput is called on each individual input received, and the inputs queue
class Behavior(SmootCoreObject):
@@ -56,4 +57,5 @@ class Behavior(SmootCoreObject):
self.recursiveResponseQueue)
self.sensorResponseQueue = []
self.recursiveResponseQueue = recursions
+ main_log.debug(self['Id'] + ' Ouputs ' + str(outputs))
return self.addMapperToResponse(outputs)
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/pixelcore/Pixel.py b/pixelcore/Pixel.py
index 7260e56..2f21fd8 100644
--- a/pixelcore/Pixel.py
+++ b/pixelcore/Pixel.py
@@ -13,7 +13,7 @@ class Pixel:
def __init__(self, location):
self.location = location
- self.events = {}
+ self.events = []
self.lastRenderTime = timeops.time()
self.lastRender = (0,0,0)
@@ -30,34 +30,45 @@ class Pixel:
#Add a pixelEvent to the list of active events
def processInput(self,pixelEvent,zindex, scale=1,currentTime=None): #consider migrating arg to dict
+ #TODO: fix for multiple pixel events
if currentTime == None:
currentTime = timeops.time()
- self.events[currentTime] = (zindex,scale, pixelEvent)
-
+ #if not currentTime in self.events:
+ # self.events[currentTime] = []
+ #self.events[currentTime].append((zindex,scale, pixelEvent))
+ self.events.append((currentTime, zindex, scale, pixelEvent)) #TODO: this is kindof
+ #gross
def clearAllEvents(self):
- self.events = {}
+ self.events = []
#Combines all PixelEvents currently active and computes the current color of
#the pixel.
def state(self, currentTime=timeops.time()): #TODO: this only evaluates at import time, I think
if currentTime-self.lastRenderTime < 5:
return self.lastRender
- if self.events == {}:
+ if self.events == []:
self.lastRenderTime = currentTime
return (0,0,0)
deadEvents = []
resultingColor = (0,0,0)
colors = []
- for eventTime in self.events: #TODO: right color weighting code
- (zindex,scale,event) = self.events[eventTime]
- eventResult = event.state(currentTime-eventTime)
+ for eventObj in self.events: #TODO: right color weighting code
+ if len(self.events) > 50:
+ pdb.set_trace()
+ #TODO: this sucks. fix it
+ eventTime, zindex, scale, pixelEvent = eventObj
+ eventResult = pixelEvent.state(currentTime-eventTime)
if eventResult != None:
- colors.append(color.multiplyColor(eventResult,scale))
+ scaledEvent = color.multiplyColor(eventResult,scale)
+ if (scaledEvent[0] + scaledEvent[1] + scaledEvent[2]) < 5:
+ deadEvents.append(eventObj)
+ else:
+ colors.append(scaledEvent)
else:
- deadEvents.append(eventTime)
+ deadEvents.append(eventObj)
resultingColor = color.combineColors(colors)
- [self.events.pop(event) for event in deadEvents]
+ [self.events.remove(event) for event in deadEvents]
resultingColor = [int(round(c)) for c in resultingColor]
self.lastRender = tuple(resultingColor)
self.lastRenderTime = currentTime
diff --git a/pixelcore/Screen.py b/pixelcore/Screen.py
index cfadee8..b595847 100644
--- a/pixelcore/Screen.py
+++ b/pixelcore/Screen.py
@@ -19,25 +19,28 @@ class Screen:
self.xSortedPixels = []
self.xPixelLocs = []
sizeValid = False
-
+ self.pixelsSorted = False
def addStrip(self, lS):
self.pixelStrips.append(lS)
self.sizeValid = False #keep track of whether or not our screen size has
+ self.pixelsSorted = False
#been invalidated by adding more pixels
- self.computeXSortedPixels()
#Returns (pixelIndex, pixel). Does a binary search.
def pixelsInRange(self, minX, maxX):
+ if not self.pixelsSorted:
+ self.computeXSortedPixels()
minIndex = Search.find_ge(self.xPixelLocs, minX)
maxIndex = Search.find_le(self.xPixelLocs, maxX)+1
return self.xSortedPixels[minIndex:maxIndex]
def computeXSortedPixels(self):
+ self.xSortedPixels = []
for pixel in self:
self.xSortedPixels.append((pixel.location[0], pixel))
self.xSortedPixels.sort()
self.xPixelLocs = [p[0] for p in self.xSortedPixels]
-
+ self.pixelsSorted = True
#For debug only
def allOn(self):
[lS.allOn(-1) for lS in self.pixelStrips]
@@ -49,11 +52,15 @@ class Screen:
#increment time -- This processes all queued responses. Responses generated
#during this period are added to the queue that will be processed on the next
#time step.
- def timeStep(self):
+ #SUBVERTING DESIGN FOR EFFICIENCY 1/24/11, RCOH -- It would be cleaner to store the time on the responses
+ #themselves, however, it is faster to just pass it in.
+ def timeStep(self, currentTime=None):
+ if currentTime == None:
+ currentTime = timeops.time()
tempQueue = list(self.responseQueue)
self.responseQueue = []
for response in tempQueue:
- self.processResponse(response)
+ self.processResponse(response, currentTime)
#public
def respond(self, responseInfo):
@@ -77,9 +84,12 @@ class Screen:
return (0, 0, maxX+100, maxY+100) #TODO: cleaner
#private
- def processResponse(self, responseInfo): #we need to make a new dict for
+ def processResponse(self, responseInfo, currentTime=None): #we need to make a new dict for
#each to prevent interference
#[strip.respond(dict(responseInfo)) for strip in self.pixelStrips]
+ if currentTime == None:
+ currentTime = timeops.time()
+ print 'cachetime fail'
if type(responseInfo) != type(dict()):
pass
if 'Mapper' in responseInfo:
@@ -89,7 +99,8 @@ class Screen:
#if type(mapper) != type(PixelMapper):
# raise Exception('No default mapper specified.')
pixelWeightList = mapper.mapEvent(responseInfo['Location'], self)
+ main_log.debug('Screen processing response. ' + str(len(pixelWeightList)) + ' events\
+generated')
PixelEvent.addPixelEventIfMissing(responseInfo)
- currentTime = timeops.time()
for (pixel, weight) in pixelWeightList:
pixel.processInput(responseInfo['PixelEvent'], 0,weight, currentTime) #TODO: z-index
diff --git a/pixelevents/SingleFrameEvent.py b/pixelevents/SingleFrameEvent.py
index 1c6239f..767f403 100644
--- a/pixelevents/SingleFrameEvent.py
+++ b/pixelevents/SingleFrameEvent.py
@@ -1,8 +1,10 @@
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):
+ if self.timeState == -1:
+ self.timeState = timeDelay
+ if self.timeState == timeDelay:
+ return self.Color
return None
diff --git a/pixelmappers/GaussianMapper.py b/pixelmappers/GaussianMapper.py
index 686ebcd..c82f243 100644
--- a/pixelmappers/GaussianMapper.py
+++ b/pixelmappers/GaussianMapper.py
@@ -4,6 +4,8 @@ class GaussianMapper(PixelMapper):
def mappingFunction(self, eventLocation, screen):
returnPixels = [] #TODO: consider preallocation and trimming
[x,y] = eventLocation
+ potentialPixels = screen.pixelsInRange(x-self.CutoffDist, \
+ x+self.CutoffDist)
for (x,pixel) in screen.pixelsInRange(x-self.CutoffDist, \
x+self.CutoffDist):
pixelDist = Geo.dist(pixel.location, eventLocation)
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>