wip: first working proto
This commit is contained in:
parent
1847c8ebef
commit
f67e7992ba
@ -139,8 +139,9 @@ class OnePointIterator( ):
|
|||||||
for i in range(0, e[1]):
|
for i in range(0, e[1]):
|
||||||
self.ref.xyrgb_step = (self.ref.prev_x + step * delta_x,
|
self.ref.xyrgb_step = (self.ref.prev_x + step * delta_x,
|
||||||
self.ref.prev_y + step * delta_y) + rgb # + self.ref.xyrgb_prev[2:]# + rgb
|
self.ref.prev_y + step * delta_y) + rgb # + self.ref.xyrgb_prev[2:]# + rgb
|
||||||
print(self.ref.xyrgb_step)
|
# print(self.ref.xyrgb_step)
|
||||||
yield self.ref.xyrgb_step
|
yield self.ref.xyrgb_step
|
||||||
|
|
||||||
self.ref.prev_x, self.ref.prev_y = x, y
|
self.ref.prev_x, self.ref.prev_y = x, y
|
||||||
self.ref.xyrgb_prev = [x, y]
|
self.ref.xyrgb_prev = [x, y]
|
||||||
|
|
||||||
@ -192,19 +193,6 @@ class Tracer(object):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def GetPoints(self, capacity):
|
|
||||||
"""
|
|
||||||
Iterates points and sends them to OnePoint
|
|
||||||
|
|
||||||
:param capacity:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
iterator = OnePointIterator(self)
|
|
||||||
# i = list(next(iterator))
|
|
||||||
# d = [list(next(iterator)) for i in range(capacity)]
|
|
||||||
d = [list(next(iterator)) for i in range(capacity)]
|
|
||||||
|
|
||||||
return d
|
|
||||||
|
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
raise Exception("Please override the method")
|
raise Exception("Please override the method")
|
||||||
@ -247,7 +235,6 @@ class Tracer(object):
|
|||||||
Main loop common for every dac driver
|
Main loop common for every dac driver
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.before_loop()
|
self.before_loop()
|
||||||
|
|
||||||
started = 0
|
started = 0
|
||||||
@ -279,10 +266,10 @@ class Tracer(object):
|
|||||||
if order == 1:
|
if order == 1:
|
||||||
""" 1 : Get the new EDH / The zoom || trapezoidal / homography settings for the laser """
|
""" 1 : Get the new EDH / The zoom || trapezoidal / homography settings for the laser """
|
||||||
print("Tracer", self.laser_id, "new EDH ORDER in redis")
|
print("Tracer", self.laser_id, "new EDH ORDER in redis")
|
||||||
# gstt.EDH[self.laser_id] = np.array(
|
gstt.EDH[self.laser_id] = np.array(
|
||||||
# ast.literal_eval(self.redis.get('/EDH/' + str(self.laser_id)).decode('ascii')))
|
ast.literal_eval(self.redis.get('/EDH/' + str(self.laser_id)).decode('ascii')))
|
||||||
# # Back to user point list
|
# Back to user point list
|
||||||
# self.redis.set('/order/' + str(self.laser_id), 0)
|
self.redis.set('/order/' + str(self.laser_id), 0)
|
||||||
|
|
||||||
#
|
#
|
||||||
if order == 2:
|
if order == 2:
|
||||||
@ -341,22 +328,11 @@ class Tracer(object):
|
|||||||
# self.redis.set('/lstt/' + str(self.laser_id), self.last_status.playback_state)
|
# self.redis.set('/lstt/' + str(self.laser_id), self.last_status.playback_state)
|
||||||
# pdb.set_trace()
|
# pdb.set_trace()
|
||||||
# How much room?
|
# How much room?
|
||||||
|
|
||||||
capacity = self.get_points_capacity()
|
capacity = self.get_points_capacity()
|
||||||
self.redis.set('/cap/' + str(self.laser_id), capacity)
|
self.redis.set('/cap/' + str(self.laser_id), capacity)
|
||||||
iterator = OnePointIterator(self)
|
iterator = OnePointIterator(self)
|
||||||
points = [next(iterator) for i in range(capacity)]
|
points = [next(iterator) for i in range(capacity)]
|
||||||
|
|
||||||
# points = self.GetPoints(capacity)
|
|
||||||
|
|
||||||
# print("Writing %d points" % (cap, ))
|
|
||||||
# t0 = time.time()
|
|
||||||
# if self.laser_id == 2:
|
|
||||||
# print(points)
|
|
||||||
self.write(points)
|
self.write(points)
|
||||||
# t1 = time.time()
|
|
||||||
# print("Took %f" % (t1 - t0, )
|
|
||||||
|
|
||||||
if not started:
|
if not started:
|
||||||
print("Tracer", self.laser_id, "starting with", gstt.kpps[self.laser_id], "kpps")
|
print("Tracer", self.laser_id, "starting with", gstt.kpps[self.laser_id], "kpps")
|
||||||
self.begin(0, gstt.kpps[self.laser_id])
|
self.begin(0, gstt.kpps[self.laser_id])
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import ctypes
|
import ctypes
|
||||||
|
import random
|
||||||
|
|
||||||
from libs3 import gstt
|
from libs3 import gstt
|
||||||
from libs3 import homographyp
|
from libs3 import homographyp
|
||||||
@ -32,7 +33,7 @@ class TracerHelios(Tracer):
|
|||||||
self.redis = redis
|
self.redis = redis
|
||||||
self.laser_id = laser_id
|
self.laser_id = laser_id
|
||||||
self.PL = PL
|
self.PL = PL
|
||||||
self.pl = [[0,0,0]]
|
self.pl = [[0, 0, 0]]
|
||||||
self.clientkey = self.redis.get("/clientkey").decode('ascii')
|
self.clientkey = self.redis.get("/clientkey").decode('ascii')
|
||||||
self.xyrgb = self.xyrgb_prev = (0, 0, 0, 0, 0)
|
self.xyrgb = self.xyrgb_prev = (0, 0, 0, 0, 0)
|
||||||
self.intensity = 65280
|
self.intensity = 65280
|
||||||
@ -49,7 +50,7 @@ class TracerHelios(Tracer):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def get_points_capacity(self):
|
def get_points_capacity(self):
|
||||||
return 30000
|
return 1000
|
||||||
|
|
||||||
# def GetPoints(self, capacity):
|
# def GetPoints(self, capacity):
|
||||||
# a = [2,3]
|
# a = [2,3]
|
||||||
@ -58,19 +59,19 @@ class TracerHelios(Tracer):
|
|||||||
def prepare(self):
|
def prepare(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def begin(self, n, kpps):
|
def begin(self, n, kpps):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_status(self):
|
def get_status(self):
|
||||||
""" Return 0 if not ready (playing), 1 if ready to receive new frame,-1 if communication failed """
|
""" Return 0 if not ready (playing), 1 if ready to receive new frame,-1 if communication failed """
|
||||||
# va chercher dans le helios et renvoie la normalisée
|
# va chercher dans le helios et renvoie la normalisée
|
||||||
status = HeliosLib.GetStatus(0)
|
status = HeliosLib.GetStatus(0)
|
||||||
if status == 0 :
|
if status == 0:
|
||||||
return self.lstate["2"] # playing
|
return self.lstate["2"] # playing
|
||||||
if status == 1 :
|
if status == 1:
|
||||||
return self.lstate["0"] # ready
|
return self.lstate["0"] # ready
|
||||||
if status == -1 :
|
if status == -1:
|
||||||
return self.lstate["64"] # no connection
|
return self.lstate["64"] # no connection
|
||||||
|
|
||||||
def set_status(self, status: int):
|
def set_status(self, status: int):
|
||||||
return
|
return
|
||||||
@ -85,33 +86,33 @@ class TracerHelios(Tracer):
|
|||||||
# status_attempts += 1
|
# status_attempts += 1
|
||||||
# print("attempt {}".format(status_attempts))
|
# print("attempt {}".format(status_attempts))
|
||||||
# HeliosLib.WriteFrame(j, 3000, 0, ctypes.pointer(frames[i % 30]), 1000) # Send the frame
|
# HeliosLib.WriteFrame(j, 3000, 0, ctypes.pointer(frames[i % 30]), 1000) # Send the frame
|
||||||
try :
|
frame_type = HeliosPoint * self.get_points_capacity()
|
||||||
points = [ *i for i in items ]
|
frame = frame_type()
|
||||||
frames = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
helios_id = 0
|
||||||
frame_type = HeliosPoint * 1000
|
# print("hello got {} points".format(len(points)))
|
||||||
x = 0
|
points = [point for point in points]
|
||||||
y = 0
|
for i, point in enumerate(points):
|
||||||
for i in range(30):
|
a = 0
|
||||||
y = round(i * 0xFFF / 30)
|
# @todo why are there 2 tuples in the object ???
|
||||||
frames[i] = frame_type()
|
for one_point in point:
|
||||||
for j in range(1000):
|
x, y, r, g, b = one_point
|
||||||
if (j < 500):
|
# x = random.randrange(1500,2500)
|
||||||
x = round(j * 0xFFF / 500)
|
# y = random.randrange(1500,2500)
|
||||||
else:
|
# r = 255
|
||||||
x = round(0xFFF - ((j - 500) * 0xFFF / 500))
|
# g = 255
|
||||||
frames[i][j] = HeliosPoint(int(x), int(y), 255, 255, 255, 255)
|
# b = 255
|
||||||
for i in range(150):
|
break
|
||||||
for j in range(numDevices):
|
print(x,y,r,g,b)
|
||||||
statusAttempts = 0
|
frame[i] = HeliosPoint(int(x), int(y), int(r), int(g), int(b), 255)
|
||||||
# Make 512 attempts for DAC status to be ready. After that, just give up and try to write the frame anyway
|
statusAttempts = 0
|
||||||
while (statusAttempts < 512 and HeliosLib.GetStatus(j) != 1):
|
# Make 512 attempts for DAC status to be ready. After that, just give up and try to write the frame anyway
|
||||||
statusAttempts += 1
|
while (statusAttempts < 512 and HeliosLib.GetStatus(helios_id) != 1):
|
||||||
HeliosLib.WriteFrame(j, 30000, 0, ctypes.pointer(frames[i % 30]), 1000) # Send the frame
|
statusAttempts += 1
|
||||||
|
f = ctypes.pointer(frame)
|
||||||
|
# int HeliosDac::WriteFrame(unsigned int devNum, unsigned int pps, std::uint8_t flags, HeliosPoint* points, unsigned int numOfPoints)
|
||||||
|
r = HeliosLib.WriteFrame(0, 300, 0, f, len(frame))
|
||||||
|
|
||||||
except Exception as exc :
|
def get_warped_point(self, x, y):
|
||||||
print (exc)
|
|
||||||
|
|
||||||
def get_warped_point(self, x, y ):
|
|
||||||
|
|
||||||
# transform in one matrix, with warp !!
|
# transform in one matrix, with warp !!
|
||||||
# Etherpoint all transform in one matrix, with warp !!
|
# Etherpoint all transform in one matrix, with warp !!
|
||||||
|
Loading…
Reference in New Issue
Block a user