#!/usr/bin/python3 # -*- coding: utf-8 -*- # -*- mode: Python -*- ''' Tracer v0.8.2 Etherdream DACs handler on network via Redis LICENCE : CC Sam Neurohack, pclf One tracer process is launched per requested laser by LJ. Lasers parameters in LJ.conf. Live I/O based on redis keys : inputs (Pointlists to draw,...) and outputs (DAC state, errors,..). Keys are mostly read and set at each main loop. * Redis keys reference * - Drawing things : /pl/Scene/lasernumber [(x,y,color),(x1,y1,color),...] The live list of drawn pygame points. Tracer continously ask redis for key /clientkey+lasernumber /resampler/lasernumber [(1.0,8), (0.25,3),(0.75,3),(1.0,10)] : a string for resampling rules. the first tuple (1.0,8) is for short line < 4000 in etherdream space (0.25,3),(0.75,3),(1.0,10) for long line > 4000 i.e (0.25,3) means go at 25% position on the line, send 3 times this position to etherdream /clientkey "/pl/SceneNumber/" What Scene to retrieve from redis /EDH/lasernumber - Tracer control : /order 0-8 Set redis key with new value then issue the order number 0 : Draw Normal point list 1 : Get the new EDH = reread redis key /EDH/lasernumber 2 : Draw BLACK point list 3 : Draw GRID point list 4 : Resampler Change (longs and shorts lsteps) 5 : Client Key Change = reread redis key /clientkey 6 : Max Intensity Change = reread redis key /intensity 7 : kpps change = reread redis key /kpps 8 : color balance change = reread redis keys /red /green /blue - Managing Etherdream DACs : Discrete drawing values /kpps 0- DAC output speed to laser, then order 7. Depends of actual angle /intensity 0-255 Laser output power, then order 6 (for alignement,...) /red 0-100 % of full red, then order 8 /green 0-100 % of full green, then order 8 /blue 0-100 % of full blue, then order 8 DAC status report /lstt/lasernumber etherdream last_status.playback_state (0: idle 1: prepare 2: playing) /cap/lasernumber number of empty points sent to fill etherdream buffer (up to 1799) /lack/lasernumber "a": ACK "F": Full "I": invalid. 64 or 35 for no connection. Geometric corrections Doctodo ''' import socket import time import struct # from gstt import debug from libs3 import gstt, log import math from itertools import cycle # from globalVars import * import pdb import ast import redis from .tracer_etherdream import TracerEtherdream from .tracer_helios import TracerHelios from libs3 import homographyp import numpy as np import binascii r = redis.StrictRedis(host=gstt.LjayServerIP, port=6379, db=0) def DAC(mylaser, point_list_number, dac_family="etherdream"): print(f"# Starting DAC #{mylaser} PL#:{point_list_number} Family:'{dac_family}'") if dac_family == "etherdream": return TracerEtherdream(mylaser, point_list_number, redis=r, port=7765) if dac_family == "helios": return TracerHelios(mylaser, point_list_number, redis=r)