webui simu with colors

This commit is contained in:
nrhck 2018-12-19 12:39:54 +01:00
parent 4bacb00395
commit b6909e4490
8 changed files with 53 additions and 41 deletions

View File

@ -83,6 +83,9 @@ console.log(pl0);
console.log(pl1); console.log(pl1);
// Send points lists to redis server // Send points lists to redis server
// /pl/clientnumber/lasernumber pointlist
// you're client 0 and want to send points to laser 0 and 1
client.set("/pl/0/0",pl0); client.set("/pl/0/0",pl0);
client.set("/pl/0/1",pl1); client.set("/pl/0/1",pl1);

View File

@ -25,6 +25,10 @@ def rgb2int(r,g,b):
# White rectangular shape # White rectangular shape
pl1 = [(100,300,rgb2int(255,255,255)),(200,300,rgb2int(255,255,255)),(200,200,rgb2int(255,255,255)),(100,200,rgb2int(255,255,255))] pl1 = [(100,300,rgb2int(255,255,255)),(200,300,rgb2int(255,255,255)),(200,200,rgb2int(255,255,255)),(100,200,rgb2int(255,255,255))]
# /pl/clientnumber/lasernumber pointlist
# Consider you're client 0
# Send to laser 0 (see mainy.conf) # Send to laser 0 (see mainy.conf)
r.set('/pl/0/0', str(pl0)) r.set('/pl/0/0', str(pl0))

View File

@ -19,6 +19,11 @@ anims= [[],[],[],[]]
# How many lasers are connected. Different that "currentlaser" used by bhorosc # How many lasers are connected. Different that "currentlaser" used by bhorosc
LaserNumber = 2 LaserNumber = 2
# What laser client to listen at launch
LasClientNumber = 0
MaxLasClient = 3
screen_size = [800,600] screen_size = [800,600]
xy_center = [screen_size[0]/2,screen_size[1]/2] xy_center = [screen_size[0]/2,screen_size[1]/2]
@ -38,7 +43,7 @@ simuPL = 1
# gstt.laserIPS. Will be overridden by the ConfigName (see below) file values # gstt.laserIPS. Will be overridden by the ConfigName (see below) file values
lasersIPS = ['192.168.1.5','192.168.1.6','192.168.1.3','192.168.1.4'] lasersIPS = ['192.168.1.5','192.168.1.6','192.168.1.3','192.168.1.4']
ClientNumber = 1
# gstt.kpps stores kpps for each laser. # gstt.kpps stores kpps for each laser.
# ** Will be overridden by the ConfigName (see below) file values ** # ** Will be overridden by the ConfigName (see below) file values **

10
las.py
View File

@ -88,13 +88,13 @@ def LasClientChange(clientnumber):
if r.get("/pl/"+str(clientnumber)+"/0") != None: if r.get("/pl/"+str(clientnumber)+"/0") != None:
print "Switching to laser client", clientnumber print "Switching to laser client", clientnumber
gstt.ClientNumber = clientnumber gstt.LasClientNumber = clientnumber
r.set('/clientkey', "/pl/"+str(clientnumber)+"/") r.set('/clientkey', "/pl/"+str(clientnumber)+"/")
print "clientkey set to", "/pl/"+str(clientnumber)+"/" print "clientkey set to", "/pl/"+str(clientnumber)+"/"
for laserid in xrange(0,gstt.LaserNumber): for laserid in xrange(0,gstt.LaserNumber):
r.set('/order/'+str(laserid), 5) r.set('/order/'+str(laserid), 5)
else: else:
print "Error : new laser client",clientnumber,"must send points first to","/pl/"+str(clientnumber)+"/0" print "ERROR : MaxLasClient is set to ", gstt.MaxLasClient
@ -105,14 +105,14 @@ def NoteOn(note):
if note < 8: if note < 8:
LasClientChange(note) LasClientChange(note)
# New PL displayed # Change PL displayed on webui
if note > 23 and note < 32: if note > 23 and note < 32:
if note - 24 > gstt.LaserNumber -1: if note - 24 > gstt.LaserNumber -1:
print "Only",gstt.LaserNumber,"asked, you dum ass !" print "Only",gstt.LaserNumber,"lasers asked, you dum ass !"
else: else:
gstt.Laser = note -24 gstt.Laser = note -24
print "Current Laser switched to",gstt.Laser print "Current Laser switched to",gstt.Laser
#LasClientChange(gstt.Laser)

View File

@ -1,7 +1,7 @@
[General] [General]
set = 5 set = 5
curve = 0 curve = 0
lasernumber = 2 lasernumber = 3
debug = 0 debug = 0
ljayserverip = 127.0.0.1 ljayserverip = 127.0.0.1
nozoscip = 127.0.0.1 nozoscip = 127.0.0.1
@ -18,8 +18,8 @@ zoomy = 29.0
sizex = 31450 sizex = 31450
sizey = 32000 sizey = 32000
finangle = 17.0 finangle = 17.0
swapx = 1 swapx = -1
swapy = 1 swapy = -1
lsteps = [ (1.0, 8),(0.25, 3), (0.75, 3), (1.0, 10)] lsteps = [ (1.0, 8),(0.25, 3), (0.75, 3), (1.0, 10)]
warpdest = [[-1500., 1500.], warpdest = [[-1500., 1500.],
[ 1500., 1500.], [ 1500., 1500.],
@ -31,7 +31,7 @@ color = -1
ip = 192.168.1.5 ip = 192.168.1.5
kpps = 25000 kpps = 25000
centerx = -506 centerx = -506
centery = -357 centery = -413
zoomx = 81.5 zoomx = 81.5
zoomy = 50.1 zoomy = 50.1
sizex = 32000 sizex = 32000

View File

@ -70,7 +70,7 @@ def dac_process(number, pl):
# webUI server # webUI server
# #
print "Laser client number :",gstt.ClientNumber print "Laser client number :",gstt.LasClientNumber
serverIP = gstt.LjayServerIP serverIP = gstt.LjayServerIP
print "Redis IP :", serverIP print "Redis IP :", serverIP
@ -212,6 +212,7 @@ def osc_thread():
lack= r.get('/lack/'+str(laserid)) lack= r.get('/lack/'+str(laserid))
if gstt.debug >0:
print "laserid", laserid,"lack",lack print "laserid", laserid,"lack",lack
if lack == 'a': # Dac sent ACK ("a") -> led is green (1) if lack == 'a': # Dac sent ACK ("a") -> led is green (1)
sendWSall("/lack/" + str(laserid) +" 1") sendWSall("/lack/" + str(laserid) +" 1")
@ -231,8 +232,8 @@ def osc_thread():
# last number of points sent to etherdream buffer # last number of points sent to etherdream buffer
sendWSall("/points/" + str(laserid) + " " + str(r.get('/cap/'+str(laserid)))) sendWSall("/points/" + str(laserid) + " " + str(r.get('/cap/'+str(laserid))))
print "Sending simu frame from",'/pl/'+str(gstt.ClientNumber)+'/'+str(gstt.Laser) print "Sending simu frame from",'/pl/'+str(gstt.LasClientNumber)+'/'+str(gstt.Laser)
sendWSall("/plframe" +" "+ r.get('/pl/'+str(gstt.ClientNumber)+'/'+str(gstt.Laser))) sendWSall("/simul" +" "+ r.get('/pl/'+str(gstt.LasClientNumber)+'/'+str(gstt.Laser)))
except Exception as e: except Exception as e:
@ -311,23 +312,23 @@ def sendWSall(message):
# Some random lists for all lasers at launch for laser client gstt.ClientNumber # Creating a startup point list for each client : 0,1,2,...
print "" print ""
print "Creating startup point lists for client",gstt.ClientNumber,"..." for clientid in range(0,gstt.MaxLasClient):
print "Creating startup point lists for client",clientid,"..."
digit_points = font1.DigitsDots(clientid,65280)
# Order all lasers to show the laser client number at startup -> tell all 4 laser process to USER PLs
for laserid in range(0,gstt.LaserNumber):
digit_points = font1.DigitsDots(gstt.ClientNumber,16711935) if r.set('/pl/'+str(clientid)+'/'+str(laserid), str(digit_points)) == True:
print "/pl/"+str(clientid)+"/"+str(laserid)+" ", ast.literal_eval(r.get('/pl/'+str(clientid)+'/'+str(laserid)))
# Order all lasers to show the laser client number at startup -> tell all 4 laser process to USER PLs
for laserid in range(0,gstt.LaserNumber):
if r.set('/pl/'+str(gstt.ClientNumber)+'/'+str(laserid), str(digit_points)) == True:
print "/pl/"+str(gstt.ClientNumber)+"/"+str(laserid)+" ", ast.literal_eval(r.get('/pl/'+str(gstt.ClientNumber)+'/'+str(laserid)))
r.set('/order/'+str(laserid), 0) r.set('/order/'+str(laserid), 0)
if r.set("/clientkey","/pl/"+str(gstt.ClientNumber)+"/")==True: if r.set("/clientkey","/pl/"+str(gstt.LasClientNumber)+"/")==True:
print "sent clientkey : /pl/"+str(gstt.ClientNumber)+"/" print "sent clientkey : /pl/"+str(gstt.LasClientNumber)+"/"
print "" print ""
print "Etherdream connection check is NOT DISPLAYED" print "Etherdream connection check is NOT DISPLAYED"

View File

@ -98,22 +98,18 @@
case "/statu": case "/statu":
_WS.showstatus(e.data.slice(8)); _WS.showstatus(e.data.slice(8));
break; break;
case "/plfra": case "/simul":
console.log(e.data.slice(11)); pl = e.data.slice(7);
pl = e.data.slice(9);
//console.log(pl);
pl2 = eval(pl.replace(/[()]/g, '')); pl2 = eval(pl.replace(/[()]/g, ''));
//console.log(pl2);
break; break;
case "/plpoi": case "/plpoi":
//console.log("plpoint"); //console.log("plpoint");
break; break;
default: default:
//console.log(res[0] + " " + res[1])
//console.log(res[1])
document.getElementById(res[0].slice(1)).value = res[1]; document.getElementById(res[0].slice(1)).value = res[1];
}
_WS.showin(e.data); _WS.showin(e.data);
}
}, },
onError: function (e) { onError: function (e) {
_WS.showin('<span style="color: red;">ERROR:</span> ' + e.data); _WS.showin('<span style="color: red;">ERROR:</span> ' + e.data);

View File

@ -560,10 +560,13 @@
// Draw Lines // Draw Lines
for (var i = 0; i < pl2.length/3; i++) { for (var i = 0; i < pl2.length/3; i++) {
ctx.lineTo(pl2[i*3]*0.7, pl2[1+(i*3)]*0.7); ctx.lineTo(pl2[i*3]*0.7, pl2[1+(i*3)]*0.7);
//ctx.strokeStyle = "#"+(pl2[2+(i*3)]).toString(16);
ctx.strokeStyle = "#"+((pl2[2+(i*3)]) + Math.pow(16, 6)).toString(16).slice(-6);
ctx.stroke();
} }
ctx.strokeStyle = "#888"; //ctx.strokeStyle = "#888";
ctx.stroke(); //ctx.stroke();
lastpoint.x = pl2[i*3]; lastpoint.x = pl2[i*3];
lastpoint.y = pl2[1+(i*3)]; lastpoint.y = pl2[1+(i*3)];
} }