LJ/clients/pyclient.py

42 lines
1.0 KiB
Python
Raw Normal View History

2018-12-13 11:05:32 +00:00
# coding=UTF-8
'''
2019-01-16 00:50:24 +00:00
Multi Laser client example with direct send of point lists to redis server.
Remember : LJ will automatically warp geometry according to alignement data. See webUI.
2018-12-13 11:05:32 +00:00
LICENCE : CC
'''
import redis
# IP defined in /etd/redis/redis.conf
redisIP = '127.0.0.1'
r = redis.StrictRedis(host=redisIP, port=6379, db=0)
# (x,y,color in integer) 65280 is color #00FF00
# Green rectangular shape :
pl0 = [(100,300,65280),(200,300,65280),(200,200,65280),(100,200,65280),(100,300,65280)]
2018-12-13 11:05:32 +00:00
# If you want to use rgb for color :
def rgb2int(r,g,b):
return int('0x%02x%02x%02x' % (r,g,b),0)
# White rectangular shape
pl1 = [(100,300,rgb2int(255,255,255)),(200,300,rgb2int(255,255,255)),(200,200,rgb2int(255,255,255)),(100,200,rgb2int(255,255,255)),(100,300,rgb2int(255,255,255))]
2018-12-13 11:05:32 +00:00
2018-12-19 11:39:54 +00:00
# /pl/clientnumber/lasernumber pointlist
# Consider you're client 0
2019-01-16 00:50:24 +00:00
# Send to laser 0 (see LJ.conf)
2018-12-18 01:45:23 +00:00
r.set('/pl/0/0', str(pl0))
2018-12-13 11:05:32 +00:00
2019-01-16 00:50:24 +00:00
# Send to laser 1 (see LJ.conf)
2018-12-18 01:45:23 +00:00
r.set('/pl/0/1', str(pl1))
2019-01-16 00:50:24 +00:00
# Send to laser 2 (see LJ.conf)
2018-12-18 01:45:23 +00:00
r.set('/pl/0/2', str(pl1))
2018-12-13 11:05:32 +00:00