changeset 40:7656f048bbdf moodplay

Added DMX send functionality into MovingBlob.draw, added globals for DMX universe, number of lighting fixtures, ambient lighting colour.
author JWoodbridge <j.woodbridge@se12.qmul.ac.uk>
date Thu, 07 May 2015 14:56:42 +0100
parents 874ac833c8e3
children 38dd615b7465
files visualclient2/visclient.py
diffstat 1 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/visualclient2/visclient.py	Thu May 07 12:55:49 2015 +0100
+++ b/visualclient2/visclient.py	Thu May 07 14:56:42 2015 +0100
@@ -23,6 +23,10 @@
 
 import OSC
 
+import array
+from ola.ClientWrapper import ClientWrapper
+
+
 scol   = (0,255,0,255)
 ecol   = (0,0,0,255)
 
@@ -31,6 +35,12 @@
 countavg=0
 moods = []
 
+universe = 1
+totalActiveFixtures = 4
+totalPassiveFixtures = 2
+
+ambicol = (224, 184, 30, 255)
+
 
 # X,Y=1140,900
 # X,Y = 600,400
@@ -168,7 +178,7 @@
 	def draw(self):
 		if not self.visible : return
 
-		global xavg,yavg,moods
+		global xavg,yavg,moods,universe,totalActiveFixtures,totalPassiveFixtures,ambicol
 		# xspeed = (xavg - self.x) / self.speed_factor
 		# yspeed = (yavg - self.y) / self.speed_factor
 		# self.x = self.x + xspeed
@@ -219,6 +229,28 @@
 		#if self.alpha < 5 : 
 		#	self.alpha = 1
 		#	self.visible = False
+
+		def DmxSent(state):
+        	wrapper.Stop()
+        	
+        dmxdata = array.array('B')
+
+        for x in range(0, totalActiveFixtures)
+            dmxdata.append(self.c[0])
+            dmxdata.append(self.c[1])
+            dmxdata.append(self.c[2])
+            dmxdata.append(self.alpha)
+
+        for x in range(0, totalPassiveFixtures)
+        	dmxdata.append(self.ambicol[0])
+        	dmxdata.append(self.ambicol[1])
+        	dmxdata.append(self.ambicol[2])
+        	dmxdata.append(self.ambicol[3])
+
+        wrapper = ClientWrapper()
+        client = wrapper.Client()
+        client.SendDmx(universe, dmxdata, DmxSent)
+        wrappper.Run()
 				
 	def age(self):
 		return time.time() - self.time