tracer bugfix

This commit is contained in:
nrhck 2018-12-27 12:40:30 +01:00
parent a806fabf5c
commit b252c6b56e
7 changed files with 92 additions and 82 deletions

View File

@ -1,15 +1,15 @@
[General]
set = 5
curve = 0
lasernumber = 3
debug = 1
lasernumber = 1
debug = 0
ljayserverip = 127.0.0.1
nozoscip = 127.0.0.1
bhoroscip = 127.0.0.1
[laser0]
color = -1
ip = 192.168.1.4
ip = 127.0.0.1
kpps = 25000
centerx = -695
centery = -1486

View File

@ -69,7 +69,7 @@ By default LJ uses on 127.0.0.1 (localhost) :
- An OSC client on 'bhoroscIP' port 8001.
- An OSC client for Nozoids support on 'nozoscIP', port 8003.
You need to update mainy.conf to your network/etherdreams IPs and be sure to check command arguments : python mainyservers.py --help
You need to update LJ.conf to your network/etherdreams IPs and be sure to check command arguments : python main.py --help
A dedicated computer to act as "laser server" usually depends on how many lasers you want to control and your main computer load. If you seen flickering with small point lists, try the dedicated computer option.
@ -109,7 +109,7 @@ Check the bind line in /etc/redis/redis.conf :
In webui/index.html change the ws ip adress to the server IP or 127.0.0.1 if client computer = laser server computer.
Using the same idea check all ip address in mainy.conf.
Using the same idea check all ip address in LJ.conf.
For network Gurus : bind to all network interface scheme is not working yet.
@ -123,7 +123,7 @@ Always start the laser server first.
Case 1 : the laser server computer is the same that the computer running a client :
python mainyservers.py
python main.py
Open/reload in browser webui/index.html. (javascript must be enabled)
@ -143,7 +143,7 @@ Say the laser server computer (running LJ) IP is 192.138.1.13, the client comput
On the server computer :
edit /etc/redis/redis.conf
python mainyservers.py -r 192.168.1.13
python main.py -r 192.168.1.13
on the client computer for all features :

View File

@ -12,7 +12,7 @@ pclf, Sam Neurohack
import math
import redis
redisIP = '192.168.1.13'
redisIP = '127.0.0.1'
r = redis.StrictRedis(host=redisIP, port=6379, db=0)
point_list = []
@ -104,8 +104,9 @@ def rPolyLineOneColor(xy_list, c, PL , closed, xpos = 0, ypos =0, resize =0.7, r
# set all points for given laser. special behavior depends on GridDisplay flag
# 0: point list / 1: Grid
def LinesPL(PL):
#print '/pl/0/'+str(PL), str(pl[PL])
if r.set('/pl/0/'+str(PL), str(pl[PL])) == True:
pl[PL] = []
return True
else:
return False

View File

@ -197,7 +197,7 @@ def osc_thread():
try:
while True:
time.sleep(1)
time.sleep(0.5)
osc_frame()
for laserid in range(0,gstt.LaserNumber): # Laser not used -> led is not lit
@ -232,7 +232,7 @@ def osc_thread():
# last number of points sent to etherdream buffer
sendWSall("/points/" + str(laserid) + " " + str(r.get('/cap/'+str(laserid))))
print "Sending simu frame from",'/pl/'+str(gstt.LasClientNumber)+'/'+str(gstt.Laser)
#print "Sending simu frame from",'/pl/'+str(gstt.LasClientNumber)+'/'+str(gstt.Laser)
sendWSall("/simul" +" "+ r.get('/pl/'+str(gstt.LasClientNumber)+'/'+str(gstt.Laser)))
@ -306,8 +306,8 @@ def handle_timeout(self):
def sendWSall(message):
if gstt.debug >0:
print("WS sending %s" % (message))
#if gstt.debug >0:
#print("WS sending %s" % (message))
server.send_message_to_all(message)

103
tracer.py
View File

@ -248,7 +248,7 @@ class DAC(object):
self.PL = PL
# Lower case pl is the actual point list coordinates
print "Laser",self.mylaser,"asking for ckey", self.clientkey+str(self.mylaser)
print "Init laser",self.mylaser,"asking for ckey", self.clientkey+str(self.mylaser)
self.pl = ast.literal_eval(r.get(self.clientkey + str(self.mylaser)))
#if self.mylaser ==0:
#print "DAC Init Laser", self.mylaser
@ -262,15 +262,6 @@ class DAC(object):
#print "Laser",self.mylaser,"found its EDH in redis"
#print gstt.EDH[self.mylaser]
'''
d =homographyp.apply(gstt.EDH[self.mylaser],np.array([(300,400)]))
print ''
print "d",d
print "d0",d[0]
#print "d1",len(d[1])
print " "
'''
self.xyrgb = self.xyrgb_prev = (0,0,0,0,0)
self.newstream = self.OnePoint()
@ -332,6 +323,8 @@ class DAC(object):
self.conn.sendall("?")
return self.readresp("?")
def play_stream(self):
# print last playback state
@ -351,11 +344,14 @@ class DAC(object):
#print "laser", self.mylaser, "Pb : ",self.last_status.playback_state
order = r.get('/order/'+str(self.mylaser))
order = int(r.get('/order/'+str(self.mylaser)))
#print "laser", self.mylaser, "order : ",type(order)
if order == 0:
# USER point list
self.pl = ast.literal_eval(r.get(self.clientkey+str(self.mylaser)))
#print "laser", self.mylaser, "pl : ",length(self.pl)
else:
@ -397,7 +393,47 @@ class DAC(object):
'''
r.set('/lstt/'+str(self.mylaser), self.last_status.playback_state)
# pdb.set_trace()
# How much room?
cap = 1799 - self.last_status.fullness
points = self.GetPoints(cap)
r.set('/cap/'+str(self.mylaser), cap)
if cap < 100:
time.sleep(0.001)
cap += 150
# print "Writing %d points" % (cap, )
#t0 = time.time()
#print points
self.write(points)
#t1 = time.time()
# print "Took %f" % (t1 - t0, )
if not started:
print "starting laser", self.mylaser, "with", gstt.kpps[self.mylaser],"kpps"
self.begin(0, gstt.kpps[self.mylaser])
started = 1
# not used in LJay.
def find_dac():
"""Listen for broadcast packets."""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(("0.0.0.0", 7654))
while True:
data, addr = s.recvfrom(1024)
bp = BroadcastPacket(data)
print "Packet from %s: " % (addr, )
bp.dump()
'''
#Laser order bit 0 = 0
if not order & (1 << (self.mylaser*2)):
#print "laser",mylaser,"bit 0 : 0"
@ -431,45 +467,4 @@ class DAC(object):
# Laser bit 0 = 1 and bit 1 = 1 : GRID PL
#print "laser",mylaser,"bit 1 : 1"
self.pl = grid_points
'''
r.set('/lstt/'+str(self.mylaser), self.last_status.playback_state)
# pdb.set_trace()
# How much room?
cap = 1799 - self.last_status.fullness
points = self.GetPoints(cap)
r.set('/cap/'+str(self.mylaser), cap)
#if self.mylaser == 0:
#print self.mylaser, cap
if cap < 100:
time.sleep(0.001)
cap += 150
# print "Writing %d points" % (cap, )
#t0 = time.time()
#print points
self.write(points)
#t1 = time.time()
# print "Took %f" % (t1 - t0, )
if not started:
print "starting laser", self.mylaser, "with", gstt.kpps[self.mylaser],"kpps"
self.begin(0, gstt.kpps[self.mylaser])
started = 1
# not used in LJay.
def find_dac():
"""Listen for broadcast packets."""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(("0.0.0.0", 7654))
while True:
data, addr = s.recvfrom(1024)
bp = BroadcastPacket(data)
print "Packet from %s: " % (addr, )
bp.dump()
'''

View File

@ -547,30 +547,34 @@
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var lastpoint = { x: 0, y: 0, color: 0};
ctx.clearRect(0,0,400,400);
ctx.save
// Todo : laser point will have black points to go from a polyline to another. Need to discard those black points.
function draw() {
// Clear Canvas At The Start Of Every Frame
ctx.clearRect(0,0,400,400);
ctx.restore
if (pl2.length > 0)
{
// Begin a new path
// 0.7 reduces max coordinates in a more browser compatible resolution.
ctx.beginPath();
ctx.moveTo(pl2[0]*0.7, pl2[1]*0.7);
//ctx.clearRect(0,0,400,400);
ctx.moveTo(pl2[0]*0.5, pl2[1]*0.5);
lastpoint.color = pl2[2];
// Draw n Lines
for (var i = 0; i < pl2.length/3; i++)
{
// New point has the same color -> add a new line to new point
// New point has the same color -> add a new line to the new point
if (pl2[2+(i*3)] === lastpoint.color)
{
ctx.lineTo(pl2[i*3]*0.7, pl2[1+(i*3)]*0.7);
ctx.lineTo(pl2[i*3]*0.5, pl2[1+(i*3)]*0.5);
}
// New point has different color -> stroke with previous color
@ -578,16 +582,24 @@
{
ctx.strokeStyle = "#"+(lastpoint.color + Math.pow(16, 6)).toString(16).slice(-6);
ctx.stroke();
//ctx.closePath()
ctx.restore
ctx.beginPath();
ctx.moveTo(pl2[i*3]*0.7, pl2[1+(i*3)]*0.7);
//ctx.clearRect(0,0,400,400);
ctx.moveTo(pl2[i*3]*0.5, pl2[1+(i*3)]*0.5);
}
// Last point -> stroke with current color
if (i === (pl2.length/3)-1 )
{
ctx.moveTo(pl2[i*3]*0.7, pl2[1+(i*3)]*0.7);
ctx.moveTo(pl2[i*3]*0.5, pl2[1+(i*3)]*0.5);
ctx.strokeStyle = "#"+((pl2[2+(i*3)]) + Math.pow(16, 6)).toString(16).slice(-6);
ctx.stroke();
//ctx.closePath()
ctx.restore
//ctx.clearRect(0,0,400,400);
}
// store point for comparison

View File

@ -22,7 +22,9 @@
var lastpoint = { x: 0, y: 0, color: 0};
// 2 different shapes, one blue one green.
var LJ = "/plframe [(350, 330, 65280), (370, 270, 65280), (430, 270, 65280), (410, 330, 65280), (350, 330, 65280),(300, 300, 255), (350, 250, 255), (400, 250, 255), (400, 300, 255), (300, 300, 255)]";
// var LJ = "/plframe [(350, 330, 65280), (370, 270, 65280), (430, 270, 65280), (410, 330, 65280), (350, 330, 65280),(300, 300, 255), (350, 250, 255), (400, 250, 255), (400, 300, 255), (300, 300, 255)]";
var LJ = "/plframe [(186.66666666666669, 86.66666666666669, 0), (613.3333333333333, 86.66666666666669, 16777215), (613.3333333333333, 513.3333333333333, 16777215), (186.66666666666669, 513.3333333333333, 16777215), (613.3333333333333, 86.66666666666669, 16777215), (480.0, 220.0, 16777215), (480.0, 380.0, 16777215), (613.3333333333333, 513.3333333333333, 16777215), (480.0, 220.0, 16777215), (320.0, 220.0, 16777215), (320.0, 380.0, 16777215), (480.0, 380.0, 16777215), (320.0, 220.0, 16777215), (186.66666666666669, 86.66666666666669, 16777215), (186.66666666666669, 513.3333333333333, 16777215), (320.0, 380.0, 16777215), (186.66666666666669, 86.66666666666669, 16777215), (320.0, 220.0, 16777215), (480.0, 220.0, 16777215), (613.3333333333333, 86.66666666666669, 16777215), (186.66666666666669, 513.3333333333333, 16777215), (613.3333333333333, 513.3333333333333, 16777215), (480.0, 380.0, 16777215), (320.0, 380.0, 16777215), (-73.4959349593496, 86.66666666666669, 0), (353.1707317073171, 86.66666666666669, 16711680), (353.1707317073171, 513.3333333333333, 16711680), (-73.4959349593496, 513.3333333333333, 16711680), (353.1707317073171, 86.66666666666669, 16711680), (582.5641025641025, 220.0, 16711680), (582.5641025641025, 380.0, 16711680), (353.1707317073171, 513.3333333333333, 16711680), (582.5641025641025, 220.0, 16711680), (422.5641025641026, 220.0, 16711680), (422.5641025641026, 380.0, 16711680), (582.5641025641025, 380.0, 16711680), (422.5641025641026, 220.0, 16711680), (-73.4959349593496, 86.66666666666669, 16711680), (-73.4959349593496, 513.3333333333333, 16711680), (422.5641025641026, 380.0, 16711680), (-73.4959349593496, 86.66666666666669, 16711680), (422.5641025641026, 220.0, 16711680), (582.5641025641025, 220.0, 16711680), (353.1707317073171, 86.66666666666669, 16711680), (-73.4959349593496, 513.3333333333333, 16711680), (353.1707317073171, 513.3333333333333, 16711680), (582.5641025641025, 380.0, 16711680), (422.5641025641026, 380.0, 16711680), (446.8292682926829, 86.66666666666669, 0), (873.4959349593496, 86.66666666666669, 255), (873.4959349593496, 513.3333333333333, 255), (446.8292682926829, 513.3333333333333, 255), (873.4959349593496, 86.66666666666669, 255), (377.4358974358974, 220.0, 255), (377.4358974358974, 380.0, 255), (873.4959349593496, 513.3333333333333, 255), (377.4358974358974, 220.0, 255), (217.43589743589746, 220.0, 255), (217.43589743589746, 380.0, 255), (377.4358974358974, 380.0, 255), (217.43589743589746, 220.0, 255), (446.8292682926829, 86.66666666666669, 255), (446.8292682926829, 513.3333333333333, 255), (217.43589743589746, 380.0, 255), (446.8292682926829, 86.66666666666669, 255), (217.43589743589746, 220.0, 255), (377.4358974358974, 220.0, 255), (873.4959349593496, 86.66666666666669, 255), (446.8292682926829, 513.3333333333333, 255), (873.4959349593496, 513.3333333333333, 255), (377.4358974358974, 380.0, 255), (217.43589743589746, 380.0, 255)]";
var pl ="";
var pl2 = new Array();