Compare commits

...

2 Commits

Author SHA1 Message Date
9d00337c09 fixes 2024-08-19 22:47:42 +02:00
7e2d7c4afb initial implementation for extern_cmd 2024-08-19 21:22:38 +02:00
6 changed files with 268 additions and 227 deletions

25
LJ.conf
View File

@ -2,7 +2,7 @@
lasernumber = 1
debug = 0
rediserverip = 0.0.0.0
wwwip = 192.168.1.14
wwwip = 127.0.0.1
nozoscip = 127.0.0.1
oscserverip = 127.0.0.1
autostart = artnet
@ -10,22 +10,23 @@ wstype = ws
wsport = 9001
[laser0]
dac_family = extern_cmd
cmd = ./tracers/lj_rust/lj_rust ./tracers/lj_rust/settings.toml
color = -1
type = LOCAL
dac_family = etherdream
ip = 127.0.0.1
kpps = 10000
centerx = 7.0
centery = 61.0
zoomx = 312.0
zoomy = 1039.0
sizex = 32000.0
sizey = 32000.0
finangle = -0.02263757042605427
type = DS1000
ip = 192.168.1.35
kpps = 25000
intens = 255.0
red = 100
green = 100
blue = 100
centerx = -21504.0
centery = 21504.0
zoomx = 8.90625
zoomy = 20.671875
sizex = 32000.0
sizey = 32000.0
finangle = 0.0
swapx = -1
swapy = -1
lsteps = [ (1.0, 8),(0.25, 3), (0.75, 3), (1.0, 10)]

0
configure.py Normal file → Executable file
View File

View File

@ -103,6 +103,7 @@ from libs3 import settings, plugins, homographyp,log
r = redis.StrictRedis(host=gstt.RediServerIP , port=6379, db=0)
#r = redis.StrictRedis(host=gstt.RediServerIP , port=6379, db=0, password='-+F816Y+-')
workers = []
GenericCommands = ["start", "align", "ljclient", "scene", "addest", "deldest", "dest", "clientnumber", "vcvrack", "fft", "mitraille", "faceosc", "midigen", "viewgen", "audiogen", "noteon", "cc", "ljpong", "ljwars", "mouse", "emergency", "simu", "status", "run", "nozoid", "planet", "live", "words", "ai", "bank0", "pose", "lj", "cycl", "glyph", "pong", "maxw", "custom1", "square", "regen", "trckr", "aurora", "line1", "ForwardUI", "settings", "debug", "pl", "plugins"]
@ -726,18 +727,23 @@ def LJautokill():
print('Shutdown order for tracer '+str(laser), 9)
r.set('/order/'+str(laser), 9)
for (n,dac_worker) in enumerate(workers):
log.warn(f'Entering tracer{n} ...')
dac_worker.join()
lasernumber= gstt.LaserNumber -1
log.warn("Ending tracer0...")
worker0.join()
if lasernumber >0:
log.warn("Ending tracer1...")
worker1.join()
if lasernumber >1:
log.warn("Ending tracer2...")
worker2.join()
if lasernumber >2:
log.warn("Ending tracer3...")
worker3.join()
# log.warn("Ending tracer0...")
# worker0.join()
# if lasernumber >0:
# log.warn("Ending tracer1...")
# worker1.join()
# if lasernumber >1:
# log.warn("Ending tracer2...")
# worker2.join()
# if lasernumber >2:
# log.warn("Ending tracer3...")
# worker3.join()
log.warn("Laser feedbacks resetting...")
for laserid in range(0,lasernumber+1):

View File

@ -65,6 +65,7 @@ dacnumber = 0
kpps = [25000,25000,25000,25000]
lasertype = ["LOCAL","LOCAL","LOCAL","LOCAL"]
dacfamily = ["etherdream","etherdream","etherdream","etherdream"]
cmd = [None,None,None,None]
intensity = [-1,-1,-1,-1]
intens = [-1,-1,-1,-1]
red = [100,100,100,100]

View File

@ -32,6 +32,8 @@ def Write():
config.set(laser, 'ip', str(gstt.lasersIPS[i]))
config.set(laser, 'type', str(gstt.lasertype[i]))
config.set(laser, 'dac_family', str(gstt.dacfamily[i]))
if gstt.dacfamily[i] == "extern_cmd":
config.set(laser, 'cmd', str(gstt.cmd[i]))
config.set(laser, 'kpps', str(gstt.kpps[i]))
config.set(laser, 'intens', str(gstt.intens[i]))
config.set(laser, 'red', str(gstt.red[i]))
@ -69,6 +71,8 @@ def Read():
gstt.lasersIPS[i]= config.get(laser, 'ip')
gstt.lasertype[i]= config.get(laser, 'type')
gstt.dacfamily[i] = config.get(laser, 'dac_family')
if gstt.dacfamily[i] == "extern_cmd":
gstt.cmd[i] = config.get(laser, 'cmd')
gstt.kpps[i] = config.getint(laser, 'kpps')
gstt.intens[i] = config.getfloat(laser, 'intens')
gstt.red[i] = config.getint(laser, 'red')
@ -90,4 +94,3 @@ def Read():
config = configparser.ConfigParser()
config.read(gstt.ConfigName)

84
main.py
View File

@ -82,7 +82,6 @@ elif os_name == "Darwin": # macOS
elif os_name == "Linux":
print("Plateform: Linux")
def dac_process(number, pl):
import sys
@ -90,6 +89,7 @@ def dac_process(number, pl):
print("Starting dac process", number)
while True:
try:
d = tracer.DAC(number,pl)
@ -325,7 +325,7 @@ def osc_thread():
#
def get_Host_name_IP():
try:
host_name = socket.gethostname()
host_name = "localhost" #socket.gethostname()
host_ip = socket.gethostbyname(host_name)
print("Hostname : ", host_name)
print("IP : ", host_ip)
@ -480,10 +480,32 @@ for sceneid in range(0,gstt.MaxScenes+1):
r.set('/order/'+str(laserid), 0)
#
# For tracer as external command
#
import subprocess
import select
def spawn(cmd):
p = subprocess.Popen(cmd,
shell=True,
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
return p
#
# Starts one DAC process per requested Laser
#
import signal
import sys
def signal_handler(sig, frame):
print('You pressed Ctrl+C!')
commands.LJautokill()
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
if __name__ == '__main__':
# Bug in 3.8.4 MacOS default multiprocessing start method is spawn. Spawn doesn't work properly
@ -498,33 +520,44 @@ if __name__ == '__main__':
else:
log.infog("Resquested DACs mode")
lasernumber = gstt.LaserNumber -1
#lasernumber = gstt.LaserNumber -1
print("LaserNumber = ", gstt.LaserNumber)
log.info("Starting "+str(gstt.LaserNumber) + " DACs process...")
commands.workers = []
for lasernumber in range(0,gstt.LaserNumber):
# Launch one process (a tracer3 instance) by laser
dac_worker0= Process(target=dac_process, args=(0,0,))
dac_worker0.start()
commands.worker0 = dac_worker0
print("Tracer 0 : name", dac_worker0.name , "pid", dac_worker0.pid )
if gstt.dacfamily[lasernumber] == "extern_cmd":
dac_worker = spawn(gstt.cmd[lasernumber])
dac_worker.name = f'ExternCmd{lasernumber}'
dac_worker.join = dac_worker.wait
else:
dac_worker= Process(target=dac_process, args=(lasernumber,0,))
dac_worker.start()
if lasernumber >0:
dac_worker1= Process(target=dac_process, args=(1,0,))
commands.worker1 = dac_worker1
print("Tracer 1 : name", dac_worker1.name , "pid", dac_worker1.pid )
dac_worker1.start()
#commands.worker0 = dac_worker0 # ???
commands.workers.append(dac_worker)
print(f"Tracer {lasernumber} : name", dac_worker.name , "pid", dac_worker.pid )
print("DAC Family:", gstt.dacfamily[lasernumber]);
if lasernumber >1:
dac_worker2= Process(target=dac_process, args=(2,0,))
dac_worker2.start()
commands.worker2 = dac_worker2
print("Tracer 2 : name", dac_worker2.name , "pid", dac_worker2.pid )
# if lasernumber >0:
if lasernumber >2:
dac_worker3= Process(target=dac_process, args=(3,0,))
print("Tracer 3 : name", dac_worker3.name , "pid", dac_worker3.pid )
commands.worker3 = dac_worker3
dac_worker3.start()
# dac_worker1= Process(target=dac_process, args=(1,0,))
# commands.worker1 = dac_worker1
# print("Tracer 1 : name", dac_worker1.name , "pid", dac_worker1.pid )
# dac_worker1.start()
# if lasernumber >1:
# dac_worker2= Process(target=dac_process, args=(2,0,))
# dac_worker2.start()
# commands.worker2 = dac_worker2
# print("Tracer 2 : name", dac_worker2.name , "pid", dac_worker2.pid )
# if lasernumber >2:
# dac_worker3= Process(target=dac_process, args=(3,0,))
# print("Tracer 3 : name", dac_worker3.name , "pid", dac_worker3.pid )
# commands.worker3 = dac_worker3
# dac_worker3.start()
print("")
#
@ -542,8 +575,8 @@ if __name__ == '__main__':
print("python3 configure.py")
log.err('Exiting...')
#gstt.wwwIP = hostIP
commands.LJautokill()
sys.exit()
#commands.LJautokill()
#sys.exit()
# Launch OSC thread listening to oscserver
print("OSC server to receive messages (UI,...)")
@ -612,6 +645,3 @@ if __name__ == '__main__':
random_points = [(300.0+random.randint(-100, 100), 200.0+random.randint(-100, 100), 0), (500.0+random.randint(-100, 100), 200.0+random.randint(-100, 100), 65280), (500.0+random.randint(-100, 100), 400.0+random.randint(-100, 100), 65280), (300.0+random.randint(-100, 100), 400.0+random.randint(-100, 100), 65280), (300.0+random.randint(-100, 100), 200.0+random.randint(-100, 100), 65280)]
'''