aboutsummaryrefslogtreecommitdiff
path: root/renderers/IndoorRenderer.py
diff options
context:
space:
mode:
authorGravatar Russell Cohen <rcoh@mit.edu>2010-11-24 01:09:12 -0500
committerGravatar Russell Cohen <rcoh@mit.edu>2010-11-24 01:09:12 -0500
commitb042647b68abdc82490ca6e059993b8eba28904c (patch)
treea9ee95a38e98b377c251b7b2e9af9cbd8056cf7c /renderers/IndoorRenderer.py
parent407ac922fc4178021cf3a16dfb1bd875b6083ac4 (diff)
Refactoring complete! Made modules/packages as appropriate. Finally.
Diffstat (limited to 'renderers/IndoorRenderer.py')
-rw-r--r--renderers/IndoorRenderer.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/renderers/IndoorRenderer.py b/renderers/IndoorRenderer.py
new file mode 100644
index 0000000..efe2b3a
--- /dev/null
+++ b/renderers/IndoorRenderer.py
@@ -0,0 +1,31 @@
+from operationscore.Renderer import *
+import socket, Util
+import pdb
+kinetPort = 6038
+class IndoorRenderer(Renderer):
+ def initRenderer(self):
+ #pdb.set_trace()
+ self.stripLocations = {} #Dict that stores info necessary to render to
+ #strips
+ self.sockets = {} #dict of (IP,port)->Socket
+ #a strip
+# g self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ powerSupplies = self.argDict['PowerSupply']
+ if not type(powerSupplies) == type([]):
+ powerSupplies = [powerSupplies]
+ for powerSupply in powerSupplies:
+ ip = powerSupply['IP']
+ stripsInPowerSupply = powerSupply['PortMapping']
+ for stripId in stripsInPowerSupply:
+ self.stripLocations[stripId] = (ip, \
+ stripsInPowerSupply[stripId])
+ def render(self, lightSystem):
+ for pixelStrip in lightSystem.pixelStrips:
+ stripId = pixelStrip.argDict['Id']
+ (ip, port) = self.stripLocations[stripId]
+ if not ip in self.sockets: #do we have a socket to this
+ #strip? if not, spin off a new one
+ self.sockets[ip] = Util.getConnectedSocket(ip,kinetPort)
+ packet = Util.composePixelStripPacket(pixelStrip, port)
+ self.sockets[ip].send(packet, 0x00)
+