#zeile aufnehmen und an glaeser senden
#python ola_recv_dmx.py | grep array

#python ola_recv_dmx.py | python send-DMX.py

import sys
import os

i = 1
line = sys.stdin.readline()
while line:
	line = sys.stdin.readline()
	data = line.split("[")[1]
	ch1 = int(data.split(", ")[0])
	ch2 = int(data.split(", ")[1])
	ch3 = int(data.split(", ")[2])
	ch4 = int(data.split(", ")[3])
	ch5 = int(data.split(", ")[4])
	ch6 = int(data.split(", ")[5])
	print (ch1,ch2,ch3,ch4,ch5,ch6)
#   echo -n "170000070150000050" >/dev/udp/172.23.92.16/31302 	
	if i == 1:

#	172.23.92.16 ist Lounge, 172.23.92.19 ist flur
		cmd="/bin/bash -c \"echo -n \"%03i%03i%03i%03i%03i%03i\" >/dev/udp/172.23.92.16/31302\"" %(ch1,ch2,ch3,ch4,ch5,ch6) 
#		print cmd
		os.system(cmd)
		cmd="/bin/bash -c \"echo -n \"%03i%03i%03i%03i%03i%03i\" >/dev/udp/172.23.92.19/31302\"" %(ch1,ch2,ch3,ch4,ch5,ch6) 
		os.system(cmd)
		os.system(cmd)
		cmd="/bin/bash -c \"echo -n \"%03i%03i%03i%03i%03i%03i\" >/dev/udp/192.168.1.114/31302\"" %(ch1,ch2,ch3,ch4,ch5,ch6) 
		os.system(cmd)
		cmd="/bin/bash -c \"echo -n \"%03i%03i%03i%03i%03i%03i\" >/dev/udp/192.168.1.202/31302\"" %(ch1,ch2,ch3,ch4,ch5,ch6) 
		os.system(cmd)


	i = i+1
	if i > 5:
		i = 0
