changeset 29:f5ca9dbabe83

concert april 2013
author gyorgyf
date Thu, 18 Apr 2013 16:51:36 +0100
parents 6022a370c7dd
children 4a7fde8ff0fd
files mcserver/mcserver.py mcserver/static/app.js visualclient/visclient.py
diffstat 3 files changed, 80 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/mcserver/mcserver.py	Sat Sep 29 10:10:27 2012 +0100
+++ b/mcserver/mcserver.py	Thu Apr 18 16:51:36 2013 +0100
@@ -61,7 +61,7 @@
 		self.inputs = []
 		self.age = 3
 		self.dist = 0.1
-		self.ninp = 12
+		self.ninp = 18
 	
 	# def index(self):
 	# 	return str()
@@ -75,7 +75,7 @@
 		else :
 			self.inputs.insert(0,i)
 		self.inputs = self.inputs[:self.ninp]
-		cp.log.error("%s - %.6s-%.6s" %(str(cp.request.remote.ip),x,y))
+		cp.log.error("%s,%.6s,%.6s,%s" %(str(cp.request.remote.ip),x,y,i.time))
 		return str()
 		
 	@cp.expose
@@ -92,11 +92,13 @@
 			self.dist = float(kwargs['dist'])
 		if kwargs.has_key('ninp') :
 			self.ninp = int(kwargs['ninp'])
+		# cp.log.error("Config changed...")
 		return str()
 
 	@cp.expose
 	def getconf(self):
 		self.config_list = ['age','dist','ninp']
+		cp.log.error(str(map(lambda x: (x,"%.3f" % self.__dict__[x]),self.config_list)))
 		return str(map(lambda x: (x,"%.3f" % self.__dict__[x]),self.config_list)) #+ " Sessions: " + str(cp.tools.sessions)
 	
 
--- a/mcserver/static/app.js	Sat Sep 29 10:10:27 2012 +0100
+++ b/mcserver/static/app.js	Thu Apr 18 16:51:36 2013 +0100
@@ -93,14 +93,24 @@
     ctx.fill();
 
     ctx.font = "16px Arial";
-    ctx.fillText("Valence", 200, 158);  
+    ctx.fillText("Positive", 245, 158);  
+    ctx.fillText("Negative", 15, 158);  
+
     
     ctx.save();
-    ctx.translate(158, 120);
+    ctx.translate(158, 75);
     ctx.rotate(Math.PI * 1.5);
     ctx.font = "16px Arial";
-    ctx.fillText("Arousal", 0, 0);  
+    ctx.fillText("Excited", 0, 0);  
     ctx.restore();
+
+    ctx.save();
+    ctx.translate(158, 305);
+    ctx.rotate(Math.PI * 1.5);
+    ctx.font = "16px Arial";
+    ctx.fillText("Calm", 0, 0);  
+    ctx.restore();
+
  
     if (this.marker) {
       ctx.fillStyle = "rgba(0, 0, 0, 0.5)";
--- a/visualclient/visclient.py	Sat Sep 29 10:10:27 2012 +0100
+++ b/visualclient/visclient.py	Thu Apr 18 16:51:36 2013 +0100
@@ -58,11 +58,13 @@
 FRAMERATE = 60
 
 # Connection:
-# IP = "192.168.2.184:8030"
+# IP = "127.0.0.1:8030"
+# IP = "192.168.2.158:8030"
 IP = "138.37.95.215"
 HTTP_TIMEOUT = 3
 SERVER_UPDATE_INTERVAL = 0.8
 
+
 class Indicator(object):
 	
 	off_color = pg.Color(110,0,0)
@@ -192,6 +194,9 @@
 	def __init__(self):
 		# self.conn = ht.HTTPConnection("192.168.2.184:8030")
 		# self.conn = ht.HTTPConnection("138.37.95.215")
+		self.s_age = 10
+		self.s_dist = DIST
+		self.s_ninp = 18
 		
 		pg.init()
 		
@@ -396,6 +401,34 @@
 						for blob in self.blobs :
 							blob.fade(15)
 							blob.reset_time()
+				# inc age
+				elif event.key == K_1 :
+					self.s_age += 1
+					self.update_server_config(self.s_age,self.s_dist,self.s_ninp)
+				# dec age
+				elif event.key == K_2 :
+					self.s_age -= 1
+					self.update_server_config(self.s_age,self.s_dist,self.s_ninp)
+				# inc dist
+				elif event.key == K_3 :
+					self.s_dist += 0.025
+					self.update_server_config(self.s_age,self.s_dist,self.s_ninp)
+				# dec dist
+				elif event.key == K_4 :
+					self.s_dist -= 0.025
+					if self.s_dist < 0.025 : self.s_dist = 0.025
+					self.update_server_config(self.s_age,self.s_dist,self.s_ninp)
+				# inc ninp
+				elif event.key == K_5 :
+					self.s_ninp += 1
+					self.update_server_config(self.s_age,self.s_dist,self.s_ninp)
+				# dec ninp
+				elif event.key == K_6 :
+					self.s_ninp -= 1
+					if self.s_ninp < 2 : self.s_ninp = 2
+					self.update_server_config(self.s_age,self.s_dist,self.s_ninp)
+				
+				pass
 		pass
 		
 	def toggle_screen_mode(self):
@@ -456,26 +489,36 @@
 		
 	def configure_server(self):
 		'''Send the server some configuration data.'''
-		age = 10.0
-		dist = DIST
-		ninp = 18
-		self.conn.putrequest("GET","/moodconductor/config?age=%(age)s&dist=%(dist)s&ninp=%(ninp)s" %locals(), skip_host=True)
-		self.conn.putheader("Host", "www.isophonics.net")
-		self.conn.endheaders()
-		res = self.conn.getresponse()
-		if not res.status == 200 :
-			print "Server response:", res.status, res.reason
-			self.indicators["conn"].off()
-		time.sleep(1)
-		self.conn.putrequest("GET","/moodconductor/getconf", skip_host=True)
-		self.conn.putheader("Host", "www.isophonics.net")
-		self.conn.endheaders()
-		res = self.conn.getresponse()
-		if not res.status == 200 :
-			print "Server response:", res.status, res.reason
-			self.indicators["conn"].off()		
-		print "Server configuration:", res.read()
+		# age = 10.0
+		# dist = DIST
+		# ninp = 18
+		self.update_server_config(self.s_age,self.s_dist,self.s_ninp)
+				
 
+	def update_server_config(self,age,dist,ninp,retry = 3):
+		'''Send the server some configuration data.'''
+		try :
+			self.conn.putrequest("GET","/moodconductor/config?age=%(age)s&dist=%(dist)s&ninp=%(ninp)s" %locals(), skip_host=True)
+			self.conn.putheader("Host", "www.isophonics.net")
+			self.conn.endheaders()
+			res = self.conn.getresponse()
+			if not res.status == 200 :
+				print "Server response:", res.status, res.reason
+				self.indicators["conn"].off()
+			time.sleep(0.5)
+			self.conn.putrequest("GET","/moodconductor/getconf", skip_host=True)
+			self.conn.putheader("Host", "www.isophonics.net")
+			self.conn.endheaders()
+			res = self.conn.getresponse()
+			if not res.status == 200 :
+				print "Server response:", res.status, res.reason
+				self.indicators["conn"].off()		
+			print "Server configuration:", res.read()
+		except:
+			time.sleep(2)
+			retry -= 1
+			self.update_server_config(age,dist,ninp,retry)
+	
 		
 	def connect(self,retry = 5):
 		'''Connect to the server and test connection.'''