2019-03-10 22:06:04 +00:00
|
|
|
# coding=UTF-8
|
|
|
|
|
|
|
|
'''
|
|
|
|
Live words on different lasers
|
|
|
|
LICENCE : CC
|
|
|
|
'''
|
|
|
|
|
|
|
|
import redis
|
|
|
|
import lj3
|
|
|
|
import sys,time
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
from osc4py3.as_eventloop import *
|
|
|
|
from osc4py3 import oscbuildparse
|
|
|
|
#from osc4py3 import oscmethod as osm
|
|
|
|
from osc4py3.oscmethod import *
|
|
|
|
|
2019-03-24 16:24:52 +00:00
|
|
|
myIP = "127.0.0.1"
|
2019-03-10 22:06:04 +00:00
|
|
|
|
|
|
|
duration = 300
|
|
|
|
|
|
|
|
OSCinPort = 8006
|
|
|
|
|
2019-03-17 03:19:57 +00:00
|
|
|
Word0 = "LASER"
|
|
|
|
Word1 = "LASER"
|
|
|
|
Word2 = "LASER"
|
|
|
|
Word3 = "LASER"
|
2019-03-10 22:06:04 +00:00
|
|
|
|
|
|
|
'''
|
|
|
|
is_py2 = sys.version[0] == '2'
|
|
|
|
if is_py2:
|
|
|
|
from Queue import Queue
|
|
|
|
else:
|
|
|
|
from queue import Queue
|
|
|
|
'''
|
2019-03-17 03:19:57 +00:00
|
|
|
print ("Words is checking arguments parsing if needed...")
|
2019-03-10 22:06:04 +00:00
|
|
|
argsparser = argparse.ArgumentParser(description="Text Cycling for LJ")
|
|
|
|
argsparser.add_argument("-r","--redisIP",help="IP of the Redis server used by LJ (127.0.0.1 by default) ",type=str)
|
2019-03-24 16:24:52 +00:00
|
|
|
argsparser.add_argument("-m","--myIP",help="Local IP (127.0.0.1 by default) ",type=str)
|
2019-03-10 22:06:04 +00:00
|
|
|
argsparser.add_argument("-c","--client",help="LJ client number (0 by default)",type=int)
|
|
|
|
argsparser.add_argument("-v","--verbose",help="Verbosity level (0 by default)",type=int)
|
|
|
|
|
|
|
|
args = argsparser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
if args.client:
|
|
|
|
ljclient = args.client
|
|
|
|
else:
|
|
|
|
ljclient = 0
|
|
|
|
|
|
|
|
# Redis Computer IP
|
|
|
|
if args.redisIP != None:
|
|
|
|
redisIP = args.redisIP
|
|
|
|
else:
|
|
|
|
redisIP = '127.0.0.1'
|
|
|
|
|
2019-03-24 16:24:52 +00:00
|
|
|
# myIP
|
|
|
|
if args.myIP != None:
|
|
|
|
myIP = args.myIP
|
|
|
|
else:
|
|
|
|
myIP = '127.0.0.1'
|
|
|
|
|
2019-03-10 22:06:04 +00:00
|
|
|
|
|
|
|
if args.verbose:
|
|
|
|
debug = args.verbose
|
|
|
|
else:
|
|
|
|
debug = 0
|
|
|
|
|
|
|
|
|
|
|
|
lj3.Config(redisIP,ljclient)
|
|
|
|
#r = redis.StrictRedis(host=redisIP, port=6379, db=0)
|
|
|
|
|
|
|
|
|
|
|
|
def OSCword0(value):
|
2019-03-17 03:19:57 +00:00
|
|
|
global Word0
|
|
|
|
|
2019-03-10 22:06:04 +00:00
|
|
|
# Will receive message address, and message data flattened in s, x, y
|
2019-03-17 03:19:57 +00:00
|
|
|
print("Words 0 got /words/text/0 with value", value)
|
2019-03-10 22:06:04 +00:00
|
|
|
Word0 = value
|
|
|
|
|
|
|
|
def OSCword1(value):
|
2019-03-17 03:19:57 +00:00
|
|
|
global Word1
|
|
|
|
|
2019-03-10 22:06:04 +00:00
|
|
|
# Will receive message address, and message data flattened in s, x, y
|
2019-03-17 03:19:57 +00:00
|
|
|
print("Words 1 got /words/text/1 with value", value)
|
2019-03-10 22:06:04 +00:00
|
|
|
Word1 = value
|
|
|
|
|
|
|
|
def OSCword2(value):
|
2019-03-17 03:19:57 +00:00
|
|
|
global Word2
|
|
|
|
|
2019-03-10 22:06:04 +00:00
|
|
|
# Will receive message address, and message data flattened in s, x, y
|
2019-03-17 03:19:57 +00:00
|
|
|
print("Words 2 got /words/text/2 with value", value)
|
2019-03-24 16:24:52 +00:00
|
|
|
Word2 = value
|
2019-03-10 22:06:04 +00:00
|
|
|
|
|
|
|
def OSCword3(value):
|
2019-03-24 16:24:52 +00:00
|
|
|
global Word3
|
2019-03-17 03:19:57 +00:00
|
|
|
|
2019-03-10 22:06:04 +00:00
|
|
|
# Will receive message address, and message data flattened in s, x, y
|
2019-03-17 03:19:57 +00:00
|
|
|
print("Words 3 got /words/text/3 with value", value)
|
2019-03-10 22:06:04 +00:00
|
|
|
Word3 = value
|
|
|
|
|
|
|
|
def OSCljclient(value):
|
|
|
|
# Will receive message address, and message data flattened in s, x, y
|
2019-03-17 03:19:57 +00:00
|
|
|
print("Words got /words/ljclient with value", value)
|
2019-03-19 13:24:11 +00:00
|
|
|
lj3.WebStatus("Words to virtual "+ str(value))
|
2019-03-10 22:06:04 +00:00
|
|
|
ljclient = value
|
|
|
|
lj3.LjClient(ljclient)
|
|
|
|
|
|
|
|
|
2019-03-19 13:24:11 +00:00
|
|
|
|
2019-03-17 03:19:57 +00:00
|
|
|
# /ping
|
|
|
|
def OSCping():
|
2019-03-10 22:06:04 +00:00
|
|
|
|
2019-03-17 03:19:57 +00:00
|
|
|
lj3.OSCping("words")
|
|
|
|
lj3.SendLJ("words/text/0",Word0)
|
|
|
|
lj3.SendLJ("words/text/1",Word1)
|
2019-03-10 22:06:04 +00:00
|
|
|
|
2019-03-17 03:19:57 +00:00
|
|
|
# /quit
|
|
|
|
def OSCquit():
|
2019-03-10 22:06:04 +00:00
|
|
|
|
2019-03-19 13:24:11 +00:00
|
|
|
lj3.OSCquit("words")
|
2019-03-10 22:06:04 +00:00
|
|
|
|
2019-03-17 03:19:57 +00:00
|
|
|
|
|
|
|
def Run():
|
2019-03-10 22:06:04 +00:00
|
|
|
|
|
|
|
# OSC Server callbacks
|
2019-03-24 16:24:52 +00:00
|
|
|
print("Words starting its OSC server at", myIP, "port",OSCinPort,"...")
|
2019-03-10 22:06:04 +00:00
|
|
|
osc_startup()
|
2019-03-24 16:24:52 +00:00
|
|
|
osc_udp_server(myIP, OSCinPort, "InPort")
|
2019-03-17 03:19:57 +00:00
|
|
|
osc_method("/words/text/0*", OSCword0)
|
|
|
|
osc_method("/words/text/1*", OSCword1)
|
|
|
|
osc_method("/words/text/2*", OSCword2)
|
|
|
|
osc_method("/words/text/3*", OSCword3)
|
|
|
|
osc_method("/ping*", OSCping)
|
2019-03-19 13:24:11 +00:00
|
|
|
osc_method("/words/ljclient*", OSCljclient)
|
2019-03-17 03:19:57 +00:00
|
|
|
osc_method("/quit", OSCquit)
|
2019-03-10 22:06:04 +00:00
|
|
|
|
|
|
|
color = lj3.rgb2int(255,255,255)
|
2019-03-17 03:19:57 +00:00
|
|
|
lj3.WebStatus("Loading Words...")
|
|
|
|
lj3.WebStatus("Words ready.")
|
|
|
|
lj3.SendLJ("/words/start 1")
|
|
|
|
|
|
|
|
lj3.SendLJ("words/text/0",Word0)
|
|
|
|
lj3.SendLJ("words/text/1",Word1)
|
2019-03-10 22:06:04 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
while 1:
|
|
|
|
|
|
|
|
lj3.OSCframe()
|
|
|
|
|
|
|
|
lj3.Text(Word0, color, PL = 0, xpos = 300, ypos = 300, resize = 1, rotx =0, roty =0 , rotz=0)
|
|
|
|
lj3.DrawPL(0)
|
|
|
|
|
|
|
|
lj3.Text(Word1, color, PL = 1, xpos = 300, ypos = 300, resize = 1, rotx =0, roty =0 , rotz=0)
|
|
|
|
lj3.DrawPL(1)
|
|
|
|
|
|
|
|
lj3.Text(Word2, color, PL = 2, xpos = 300, ypos = 300, resize = 1, rotx =0, roty =0 , rotz=0)
|
|
|
|
lj3.DrawPL(2)
|
|
|
|
|
|
|
|
lj3.Text(Word3, color, PL = 3, xpos = 300, ypos = 300, resize = 1, rotx =0, roty =0 , rotz=0)
|
|
|
|
lj3.DrawPL(3)
|
|
|
|
|
|
|
|
time.sleep(0.01)
|
|
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Gently stop on CTRL C
|
|
|
|
|
|
|
|
finally:
|
|
|
|
|
2019-03-17 03:19:57 +00:00
|
|
|
lj3.WebStatus("Words Exit")
|
|
|
|
print("Stopping Words OSC...")
|
2019-03-10 22:06:04 +00:00
|
|
|
lj3.OSCstop()
|
|
|
|
|
|
|
|
print ("Words Stopped.")
|
|
|
|
|
|
|
|
|
|
|
|
Run()
|
|
|
|
|
|
|
|
|