wip: first working proto

This commit is contained in:
alban 2023-02-25 10:07:20 +01:00
parent 1847c8ebef
commit f67e7992ba
3 changed files with 43 additions and 65 deletions

View File

@ -139,8 +139,9 @@ class OnePointIterator( ):
for i in range(0, e[1]):
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
print(self.ref.xyrgb_step)
# print(self.ref.xyrgb_step)
yield self.ref.xyrgb_step
self.ref.prev_x, self.ref.prev_y = 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):
raise Exception("Please override the method")
@ -247,7 +235,6 @@ class Tracer(object):
Main loop common for every dac driver
:return:
"""
self.before_loop()
started = 0
@ -279,10 +266,10 @@ class Tracer(object):
if order == 1:
""" 1 : Get the new EDH / The zoom || trapezoidal / homography settings for the laser """
print("Tracer", self.laser_id, "new EDH ORDER in redis")
# gstt.EDH[self.laser_id] = np.array(
# ast.literal_eval(self.redis.get('/EDH/' + str(self.laser_id)).decode('ascii')))
# # Back to user point list
# self.redis.set('/order/' + str(self.laser_id), 0)
gstt.EDH[self.laser_id] = np.array(
ast.literal_eval(self.redis.get('/EDH/' + str(self.laser_id)).decode('ascii')))
# Back to user point list
self.redis.set('/order/' + str(self.laser_id), 0)
#
if order == 2:
@ -341,22 +328,11 @@ class Tracer(object):
# self.redis.set('/lstt/' + str(self.laser_id), self.last_status.playback_state)
# pdb.set_trace()
# How much room?
capacity = self.get_points_capacity()
self.redis.set('/cap/' + str(self.laser_id), capacity)
iterator = OnePointIterator(self)
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)
# t1 = time.time()
# print("Took %f" % (t1 - t0, )
if not started:
print("Tracer", self.laser_id, "starting with", gstt.kpps[self.laser_id], "kpps")
self.begin(0, gstt.kpps[self.laser_id])

View File

@ -1,4 +1,5 @@
import ctypes
import random
from libs3 import gstt
from libs3 import homographyp
@ -32,7 +33,7 @@ class TracerHelios(Tracer):
self.redis = redis
self.laser_id = laser_id
self.PL = PL
self.pl = [[0,0,0]]
self.pl = [[0, 0, 0]]
self.clientkey = self.redis.get("/clientkey").decode('ascii')
self.xyrgb = self.xyrgb_prev = (0, 0, 0, 0, 0)
self.intensity = 65280
@ -49,7 +50,7 @@ class TracerHelios(Tracer):
pass
def get_points_capacity(self):
return 30000
return 1000
# def GetPoints(self, capacity):
# a = [2,3]
@ -58,19 +59,19 @@ class TracerHelios(Tracer):
def prepare(self):
return True
def begin(self, n, kpps):
def begin(self, n, kpps):
return True
def get_status(self):
""" 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
status = HeliosLib.GetStatus(0)
if status == 0 :
return self.lstate["2"] # playing
if status == 1 :
return self.lstate["0"] # ready
if status == -1 :
return self.lstate["64"] # no connection
if status == 0:
return self.lstate["2"] # playing
if status == 1:
return self.lstate["0"] # ready
if status == -1:
return self.lstate["64"] # no connection
def set_status(self, status: int):
return
@ -85,33 +86,33 @@ class TracerHelios(Tracer):
# status_attempts += 1
# print("attempt {}".format(status_attempts))
# HeliosLib.WriteFrame(j, 3000, 0, ctypes.pointer(frames[i % 30]), 1000) # Send the frame
try :
points = [ *i for i in items ]
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]
frame_type = HeliosPoint * 1000
x = 0
y = 0
for i in range(30):
y = round(i * 0xFFF / 30)
frames[i] = frame_type()
for j in range(1000):
if (j < 500):
x = round(j * 0xFFF / 500)
else:
x = round(0xFFF - ((j - 500) * 0xFFF / 500))
frames[i][j] = HeliosPoint(int(x), int(y), 255, 255, 255, 255)
for i in range(150):
for j in range(numDevices):
statusAttempts = 0
# Make 512 attempts for DAC status to be ready. After that, just give up and try to write the frame anyway
while (statusAttempts < 512 and HeliosLib.GetStatus(j) != 1):
statusAttempts += 1
HeliosLib.WriteFrame(j, 30000, 0, ctypes.pointer(frames[i % 30]), 1000) # Send the frame
frame_type = HeliosPoint * self.get_points_capacity()
frame = frame_type()
helios_id = 0
# print("hello got {} points".format(len(points)))
points = [point for point in points]
for i, point in enumerate(points):
a = 0
# @todo why are there 2 tuples in the object ???
for one_point in point:
x, y, r, g, b = one_point
# x = random.randrange(1500,2500)
# y = random.randrange(1500,2500)
# r = 255
# g = 255
# b = 255
break
print(x,y,r,g,b)
frame[i] = HeliosPoint(int(x), int(y), int(r), int(g), int(b), 255)
statusAttempts = 0
# Make 512 attempts for DAC status to be ready. After that, just give up and try to write the frame anyway
while (statusAttempts < 512 and HeliosLib.GetStatus(helios_id) != 1):
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 :
print (exc)
def get_warped_point(self, x, y ):
def get_warped_point(self, x, y):
# transform in one matrix, with warp !!
# Etherpoint all transform in one matrix, with warp !!

View File

@ -23,6 +23,7 @@ Plugins OSC Ports (see LJ.conf)
'''
# import pdb
import traceback
from libs3 import log