changeset 52:4455a77435b0 moodplay

MHD-BCN15 server changes
author gyorgyf
date Thu, 18 Jun 2015 18:05:14 +0200
parents 41ab44a85497
children 0dbc2d2d0a33
files mcserver/mcserver.py visualclient2/gradients.pyc visualclient2/visclient.py
diffstat 3 files changed, 47 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mcserver/mcserver.py	Mon Jun 15 07:12:54 2015 -0700
+++ b/mcserver/mcserver.py	Thu Jun 18 18:05:14 2015 +0200
@@ -33,7 +33,7 @@
 		self.y=float(y)
 		self.count = 1
 		self.age = age
-		self.dist = dist
+		self.dist = dist		
 		
 	def __cmp__(self,other):
 		d = math.sqrt( math.pow((self.x-other.x),2) + math.pow((self.y-other.y),2) )
@@ -62,6 +62,9 @@
 		self.age = 3
 		self.dist = 0.1
 		self.ninp = 18
+		self.current_playing = str()
+		self.px = 0.0
+		self.py = 0.0
 	
 	# def index(self):
 	# 	return str()
@@ -85,6 +88,30 @@
 		return str()
 		
 	@cp.expose
+	def put_ilmid(self,iid):
+		'''Receive Currently playing ILM ID'''
+		self.current_playing = iid
+				
+	@cp.expose
+	def get_ilmid(self):
+		'''Return the current ILM id received form the audio client.'''
+		return self.current_playing.__repr__()
+		
+	@cp.expose
+	def put_path_av(self,x,y):
+		try :
+			self.px = float(x)
+			self.py = float(y)
+		except :
+			# just keep the previous values
+			pass
+			# self.px, self.py = 0.0,0.0
+	
+	@cp.expose	
+	def get_path_av(self):
+		return "(%.4f,%.4f)" %(self.px,self.py)
+		
+	@cp.expose
 	def result(self):
 		for i in self.inputs :
 			if i.dead() : self.inputs.remove(i)
Binary file visualclient2/gradients.pyc has changed
--- a/visualclient2/visclient.py	Mon Jun 15 07:12:54 2015 -0700
+++ b/visualclient2/visclient.py	Thu Jun 18 18:05:14 2015 +0200
@@ -21,10 +21,17 @@
 
 import colorsys as cs
 
-import OSC
+# import OSC
 
 import array
-from ola.ClientWrapper import ClientWrapper
+
+OLA_INSTALLED = False
+try :
+	from ola.ClientWrapper import ClientWrapper
+	OLA_INSTALLED = True
+except:
+	print "OLA not installed"
+	OLA_INSTALLED = False
 
 
 scol   = (0,255,0,255)
@@ -83,7 +90,7 @@
 IP = "138.37.95.215" # this is the IP of kakapo<=>golden
 SCIP = "127.0.0.1"
 SCPORT = 57120
-OSCADDR = "/mood-conductor-sc"
+# OSCADDR = "/mood-conductor-sc"
 HTTP_TIMEOUT = 7
 SERVER_UPDATE_INTERVAL = 0.8
 
@@ -275,8 +282,9 @@
 			dmxdata.append(ambicol[2])
 
 		#print dmxdata
-		client.SendDmx(universe, dmxdata, DmxSent)
-		wrapper.Run()
+		if OLA_INSTALLED :
+			client.SendDmx(universe, dmxdata, DmxSent)
+			wrapper.Run()
 				
 	def age(self):
 		return time.time() - self.time
@@ -599,7 +607,7 @@
 		self.init_reconnect = False
 		self.suspend = False
 
-		self.osc_client = OSC.OSCClient()
+		# self.osc_client = OSC.OSCClient()
 		
 		pass
 		
@@ -1117,6 +1125,7 @@
 		self.indicators["config"].off().now(self.screen)
 		
 	def sendCoordinates(self, xcoord, ycoord):
+		# return
 		oscmsg = OSC.OSCMessage()
 		oscmsg.setAddress(OSCADDR)
 		oscmsg.append((xcoord, ycoord))
@@ -1136,9 +1145,10 @@
 def main():
 	
 	#OLA
-	global wrapper,client
-	wrapper = ClientWrapper()
-	client = wrapper.Client()
+	global wrapper,client		
+	if OLA_INSTALLED :
+		wrapper = ClientWrapper()
+		client = wrapper.Client()
 	
 	v = VisualClient()
 	v.run()