123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #!/usr/bin/python3
- import time
- import traceback
- import json
- import __main__ as MAIN
- from lib.cprint import *
- import lib.fixlib as fixlib
- def JSCB(x,sock=None):
- # REMOTE KEY EVENT's
- i = ""
- msg = ""
- msgs = []
- try:
- #print("JSCB",sock)
- for i in x:
- #print("i",[i])
- msgs = json.loads(i)
- #print(" JSCB",msgs) #,sock)
- if type(msgs) is not list:
- continue
- for msg in msgs:
- OK = 0
- #print(" msg",msg)
- if "event" not in msg:
- continue
- if "FIXTURES" == msg["event"]:
- FIX=0
- VAL=""
- ATTR=""
- if "FIX" in msg:
- FIX=msg["FIX"]
- if "VAL" in msg:
- VAL=msg["VAL"]
- if "ATTR" in msg:
- ATTR=msg["ATTR"]
- print(" MAIN.tk_event",FIX,VAL,ATTR)
- #cb = MAIN.tk_event(fix=FIX,elem=None,attr=ATTR,mode="ENCODER",data=[]) #data)
- fixlib.encoder(MAIN.FIXTURES.fixtures,str(FIX),ATTR,xval=VAL,xfade=0,xdelay=0)#,blind=0)
- #print(dir(cb))
- #event.num = enum
- #cb.cb(event)
- OK = 1
- if "CLEAR" == msg["event"]:
- #MAIN.FIXTURES.clear()
- fixlib.clear(MAIN.FIXTURES.fixtures)
- MAIN.modes.val("REC",0)
- #MAIN.master.xcb("CLEAR",1)
- OK = 1
- elif "REC" == msg["event"]:
- MAIN.modes.val("REC",1)
- OK = 1
- elif "EDIT" == msg["event"]:
- MAIN.modes.val("EDIT",1)
- OK = 1
- elif "BLIND" == msg["event"]:
- MAIN.modes.val("BLIND",1)
- OK = 1
- elif "FLASH" == msg["event"]:
- MAIN.modes.val("FLASH",1)
- OK = 1
- elif "CFG-BTN" == msg["event"]:
- MAIN.modes.val("CFG-BTN",1)
- OK = 1
- elif "LABEL" == msg["event"]:
- MAIN.modes.val("LABEL",1)
- OK = 1
- elif "REC" == msg["event"]:
- MAIN.modes.val("REC",1)
- OK = 1
- elif "FX-OFF" == msg["event"]:
- MAIN.modes.val("FX-OFF",1)
- #OK = 1
- elif "SAVE\nSHOW" == msg["event"]:
- MAIN.save_show()
- OK = 1
- elif "RESTART" == msg["event"]:
- print("OK OK")
- MAIN.LOAD_SHOW_AND_RESTART("").cb(force=1)
- OK = 1
- elif "REC-FX" == msg["event"]:
- MAIN.modes.val("REC-FX",1)
- OK = 1
- elif "EXEC" == msg["event"]:
- print(" EXEC EXEC")
- val = -1
- exec_nr = -1
- try:
- if "VAL" in msg:
- val = int(msg["VAL"])
- if "EXEC" in msg:
- exec_nr = int(msg["EXEC"])
- if val >= 0 and exec_nr > 0:
- print("EXEC_GOOO",exec_nr,val)
- s = time.time()
- MAIN.master.exec_go(exec_nr-1,xfade=None,val=val)
- e = time.time()
- #print("time:",e-s,e)
- #print("TIME:",int((e-s)*1000),int(e*10)-1_703_800_000)
- #print("TIME:",int((e-s)*1000),int(e*10)/10)
- print("EXE TIME:","{:0.02f}".format(e-s),int(e*100)/100)
- print()
- OK = 1
- except Exception as e:
- print("EXEC ERR:",e)
-
- if OK:
- cprint(" remote-key:",msg ,color="green")
- else:
- cprint(" remote-key:",msg ,color="red")
- except Exception as e:
- cprint("exception JSCB:",e,color="red")
- cprint("- i:",i,color="red")
- cprint("- msg:",msgs,color="red")
- cprint(traceback.format_exc(),color="red")
- if sock:
- msg = ["Notice: Exception on JSCB-SERVER: ",str(e)]
- msg = json.dumps(msg)
- msg = bytes(msg,"utf8")
- cprint(msg,color="red")
- #chat._send(sock,msg)
- #time.sleep(1/60)
|