|
@@ -30,6 +30,12 @@ import subprocess
|
|
|
import tool.git as git
|
|
|
rnd_id += git.get_all()
|
|
|
|
|
|
+import lib.binfs as binfs
|
|
|
+binfs.fname="/tmp/vmaster.bin"
|
|
|
+#binfs.data =[0]*1024
|
|
|
+#binfs.patch(self._v_master_id,vm)
|
|
|
+binfs.debug = 0
|
|
|
+binfs.loop()
|
|
|
|
|
|
if "__file__" in dir():
|
|
|
sys.stdout.write("\x1b]2;"+str(__file__)+" "+rnd_id+"\x07") # terminal title
|
|
@@ -582,7 +588,7 @@ class DMXCH(object):
|
|
|
if str(xtype).lower() == "off":
|
|
|
fx_value = self._fx_value
|
|
|
if fx_value != 0:
|
|
|
- cprint("???????______ FX OFF AS FADE",fx_value,0,255)
|
|
|
+ #cprint("???????______ FX OFF AS FADE",fx_value,0,255)
|
|
|
if self._fx[1].abs:
|
|
|
self._fx[1] = Fade(self._last_val_raw,0,ftime=0.5,clock=clock)
|
|
|
else:
|
|
@@ -704,7 +710,10 @@ class DMXCH(object):
|
|
|
|
|
|
if self._v_master_id in V_MASTER:
|
|
|
vm = V_MASTER[self._v_master_id].next(clock)
|
|
|
+ #binfs.patch(self._v_master_id,int(vm))
|
|
|
+ binfs.buffer(self._v_master_id,int(vm))
|
|
|
vm = vm/256
|
|
|
+
|
|
|
self._last_val *= vm
|
|
|
|
|
|
out = self._last_val
|
|
@@ -1033,225 +1042,290 @@ def set_dmx_fine_ch(Admx,dmx_fine_nr):
|
|
|
cprint(x,color="red")
|
|
|
cprint("except 3455",e,color="red")
|
|
|
|
|
|
-def _parse_cmds(cmds,clock=0,master_fx=None):
|
|
|
- c=clock
|
|
|
+def _parse_fx2(x,fx2,clock):
|
|
|
+ if type(fx2) is dict and fx2:
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ return
|
|
|
+
|
|
|
+ xtype="fade"
|
|
|
+ size = 10
|
|
|
+ speed = 10
|
|
|
+ start = 0
|
|
|
+ offset= 0
|
|
|
+ width=100
|
|
|
+ invert=0
|
|
|
+ base = "-"
|
|
|
+ if "TYPE" in fx2:
|
|
|
+ xtype = fx2["TYPE"]
|
|
|
+ if "SIZE" in fx2:
|
|
|
+ size = fx2["SIZE"]
|
|
|
+ if "SPEED" in fx2:
|
|
|
+ speed = fx2["SPEED"]
|
|
|
+ if "OFFSET" in fx2:
|
|
|
+ offset = fx2["OFFSET"]
|
|
|
+ if "BASE" in fx2:
|
|
|
+ base = fx2["BASE"]
|
|
|
+ if "INVERT" in fx2:
|
|
|
+ invert = fx2["INVERT"]
|
|
|
+ if "WIDTH" in fx2:
|
|
|
+ width = fx2["WIDTH"]
|
|
|
+
|
|
|
+ if "off" == x["VALUE"]: #fix fx flash off
|
|
|
+ xtype= "off"
|
|
|
+
|
|
|
+ if "alloff" == xtype.lower():
|
|
|
+ for dmxch in Bdmx:
|
|
|
+ if dmxch is not None:
|
|
|
+ dmxch.flash_fx(xtype="off",clock=clock)
|
|
|
+ dmxch.fx(xtype="off",clock=clock)
|
|
|
+ for j in V_MASTER:
|
|
|
+ dmxch = V_MASTER[j]
|
|
|
+ if j is not None:
|
|
|
+ dmxch.flash_fx(xtype="off",clock=clock)
|
|
|
+ dmxch.fx(xtype="off",clock=clock)
|
|
|
+
|
|
|
+ xout = {"xtype":xtype,"size":size,"speed":speed
|
|
|
+ ,"invert":invert,"width":width,"start":start
|
|
|
+ ,"offset":offset,"base":base,"clock":clock,"master":0
|
|
|
+ }
|
|
|
+ #,"offset":offset,"base":base,"clock":c,"master":master_fx
|
|
|
+
|
|
|
+ mode="fx"
|
|
|
+ if "FLASH" in x:
|
|
|
+ mode = "flash_fx"
|
|
|
+
|
|
|
+ return [mode,xout]
|
|
|
+
|
|
|
+
|
|
|
+def _parse_master(x):
|
|
|
+ print("CMD:",x)
|
|
|
+
|
|
|
+ if "EXEC-SPEED-MASTER" == x["CMD"]:
|
|
|
+ exec_speed_master.val(x["NR"],x["VALUE"])
|
|
|
+ if "EXEC-SIZE-MASTER" == x["CMD"]:
|
|
|
+ exec_size_master.val(x["NR"],x["VALUE"])
|
|
|
+ if "EXEC-OFFSET-MASTER" == x["CMD"]:
|
|
|
+ exec_offset_master.val(x["NR"],x["VALUE"])
|
|
|
+
|
|
|
+ if "SPEED-MASTER" == x["CMD"]:
|
|
|
+ speed_master.val(x["NR"],x["VALUE"])
|
|
|
+ if "SIZE-MASTER" == x["CMD"]:
|
|
|
+ size_master.val(x["NR"],x["VALUE"])
|
|
|
+
|
|
|
+def _parse_cmds(cmds,clock=0):
|
|
|
out = {}
|
|
|
- for x in cmds:
|
|
|
- Admx = DMXCH() #dummy
|
|
|
-
|
|
|
- _fix_id=0
|
|
|
- _attr = ""
|
|
|
- if "CMD" in x:
|
|
|
- print("CMD:",x)
|
|
|
-
|
|
|
- if "EXEC-SPEED-MASTER" == x["CMD"]:
|
|
|
- exec_speed_master.val(x["NR"],x["VALUE"])
|
|
|
- if "EXEC-SIZE-MASTER" == x["CMD"]:
|
|
|
- exec_size_master.val(x["NR"],x["VALUE"])
|
|
|
- if "EXEC-OFFSET-MASTER" == x["CMD"]:
|
|
|
- exec_offset_master.val(x["NR"],x["VALUE"])
|
|
|
-
|
|
|
- if "SPEED-MASTER" == x["CMD"]:
|
|
|
- speed_master.val(x["NR"],x["VALUE"])
|
|
|
- if "SIZE-MASTER" == x["CMD"]:
|
|
|
- size_master.val(x["NR"],x["VALUE"])
|
|
|
+ for cmd in cmds:
|
|
|
+ try:
|
|
|
+ _parse_cmd(out,cmd,clock=clock)
|
|
|
+ except Exception as e:
|
|
|
+ cprint("EXCEPTION JCB",e,color="red")
|
|
|
+ cprint("----",str(cmds)[:150],"...",color="red")
|
|
|
+ cprint("Error on line {}".format(sys.exc_info()[-1].tb_lineno),color="red")
|
|
|
+ raise e
|
|
|
+ return out
|
|
|
+
|
|
|
+def _parse_cmd(out,cmd,clock=0):
|
|
|
+ master_fx = MASTER_FX()
|
|
|
+ Admx = DMXCH() #dummy
|
|
|
+ x=cmd
|
|
|
+ c=clock
|
|
|
+
|
|
|
+ _fix_id=0
|
|
|
+ _attr = ""
|
|
|
+ if "CMD" in x:
|
|
|
+ _parse_master(x)
|
|
|
+ return #continue
|
|
|
+
|
|
|
+ if "DMX" not in x:
|
|
|
+ return #continue
|
|
|
+ DMX = int(x["DMX"])
|
|
|
+
|
|
|
+ if "VALUE" not in x:
|
|
|
+ return #continue
|
|
|
+
|
|
|
+ _val = x["VALUE"]
|
|
|
+ _inc = 0
|
|
|
+ _fix_id = 0
|
|
|
+ _clock = 0
|
|
|
+ exec_id = None
|
|
|
+
|
|
|
+ if "INC" in x:
|
|
|
+ _inc = x["INC"]
|
|
|
+ if "FIX" in x:
|
|
|
+ _fix_id = x["FIX"]
|
|
|
+ if "clock" in x:
|
|
|
+ _clock=x["clock"]
|
|
|
+ if "ATTR" in x:
|
|
|
+ _attr = x["ATTR"]
|
|
|
+
|
|
|
+ if DMX <= 0: # VIRTUAL
|
|
|
+ DMX = "FIX"+str(_fix_id)
|
|
|
+ ok = 0
|
|
|
+ if "ATTR" in x:
|
|
|
+ _attr = x["ATTR"]
|
|
|
+ if "DIM" == x["ATTR"]:
|
|
|
+ if _fix_id not in V_MASTER:
|
|
|
+ V_MASTER[_fix_id] = DMXCH()
|
|
|
+ #print("_val",_val)
|
|
|
+ #V_MASTER[_fix_id].fade(_val,ftime=0,clock=0,delay=0)
|
|
|
+ #print(" V-MASTER",_fix_id,_val,_inc)
|
|
|
+ ok = 1
|
|
|
+
|
|
|
+ if _fix_id in V_MASTER:
|
|
|
+ Admx = V_MASTER[_fix_id]
|
|
|
+
|
|
|
+ if not ok:
|
|
|
+ return #continue
|
|
|
|
|
|
+ else:
|
|
|
+ if DMX < len(Bdmx):
|
|
|
+ Admx = Bdmx[DMX-1]
|
|
|
else:
|
|
|
- #print("x",x)
|
|
|
-
|
|
|
- if "DMX" in x:
|
|
|
- DMX = int(x["DMX"])
|
|
|
- else:
|
|
|
- continue
|
|
|
+ print("DMX ADDRESS too BIG",DMX)
|
|
|
+ return #continue
|
|
|
|
|
|
- if "VALUE" in x:
|
|
|
- v = x["VALUE"]
|
|
|
- else:
|
|
|
- continue
|
|
|
-
|
|
|
- _inc = 0
|
|
|
- _fix_id = 0
|
|
|
- _val = -1
|
|
|
- _clock = 0
|
|
|
- exec_id = None
|
|
|
-
|
|
|
- if "VALUE" in x:
|
|
|
- _val = x["VALUE"]
|
|
|
- if "INC" in x:
|
|
|
- _inc = x["INC"]
|
|
|
- if "FIX" in x:
|
|
|
- _fix_id = x["FIX"]
|
|
|
- if "clock" in x:
|
|
|
- _clock=x["clock"]
|
|
|
- if "ATTR" in x:
|
|
|
- _attr = x["ATTR"]
|
|
|
-
|
|
|
- if DMX <= 0: # VIRTUAL
|
|
|
- DMX = "FIX"+str(_fix_id)
|
|
|
- ok = 0
|
|
|
- if "ATTR" in x:
|
|
|
- _attr = x["ATTR"]
|
|
|
- if "DIM" == x["ATTR"]:
|
|
|
- if _fix_id not in V_MASTER:
|
|
|
- V_MASTER[_fix_id] = DMXCH()
|
|
|
- #print("_val",_val)
|
|
|
- #V_MASTER[_fix_id].fade(_val,ftime=0,clock=0,delay=0)
|
|
|
- #print(" V-MASTER",_fix_id,_val,_inc)
|
|
|
- ok = 1
|
|
|
-
|
|
|
-
|
|
|
- if _fix_id in V_MASTER:
|
|
|
- Admx = V_MASTER[_fix_id]
|
|
|
-
|
|
|
- if not ok:
|
|
|
- continue
|
|
|
+
|
|
|
+ if "DMX-FINE" in x and DMX > 0:
|
|
|
+ set_dmx_fine_ch(Admx, x["DMX-FINE"])
|
|
|
+
|
|
|
+ if "EXEC" in x:
|
|
|
+ exec_id = x["EXEC"]
|
|
|
+ if "ATTR" in x:
|
|
|
+ _attr = x["ATTR"]
|
|
|
+ if "FIX" in x:
|
|
|
+ _fix_id = x["FIX"]
|
|
|
+
|
|
|
+
|
|
|
+ fx=""
|
|
|
+ fx2={}
|
|
|
+ ftime=0
|
|
|
+ delay=0
|
|
|
+ if "FX" in x:
|
|
|
+ fx = x["FX"]
|
|
|
+ if "FX2" in x:
|
|
|
+ fx2 = x["FX2"]
|
|
|
+ if "FADE" in x:
|
|
|
+ ftime = x["FADE"]
|
|
|
+ if "DELAY" in x:
|
|
|
+ delay = x["DELAY"]
|
|
|
+
|
|
|
+
|
|
|
+ #print("DO",[exec_id],x)
|
|
|
+ # ids = [401,402,304,103]
|
|
|
+ # exec-id, exec-fx-id, flush-id, flush-fx-id
|
|
|
+ if _val != "off":
|
|
|
+ if "FLASH" in x:
|
|
|
+ ids = Admx.exec_ids()
|
|
|
+ if type(_val) is int:
|
|
|
+ ids[2] = exec_id
|
|
|
+ if fx2:
|
|
|
+ ids[3] = exec_id
|
|
|
+ #print(" ",[ids, exec_id],"FL")
|
|
|
+ else: # GO or ON
|
|
|
+ ids = Admx.exec_ids()
|
|
|
+ if type(_val) is int:
|
|
|
+ ids[0] = exec_id
|
|
|
+ if fx2:
|
|
|
+ ids[1] = exec_id
|
|
|
+ #print(" ",[ids, exec_id],"GO")
|
|
|
+
|
|
|
+ if _val == "off":
|
|
|
+ # flash bug if lot's of virtual dimmer are RELEASED-FROM-FLASH ("FLASH off")
|
|
|
+ # the V-MASTER FLASH ist HANGING ... no ENCODER change possible !!! ???
|
|
|
+ if 0: # "FLASH" in x:
|
|
|
+ ids = Admx.exec_ids()
|
|
|
+ stop = 0
|
|
|
+ #print(" ",[ids, exec_id])
|
|
|
+ if ids[2] != exec_id:
|
|
|
+ stop = 1
|
|
|
else:
|
|
|
- if DMX < len(Bdmx):
|
|
|
- Admx = Bdmx[DMX-1]
|
|
|
- else:
|
|
|
- print("DMX ADDRESS too BIG",DMX)
|
|
|
- continue
|
|
|
+ ids[2] = None
|
|
|
|
|
|
-
|
|
|
- if "DMX-FINE" in x and DMX > 0:
|
|
|
- set_dmx_fine_ch(Admx, x["DMX-FINE"])
|
|
|
-
|
|
|
- #print("-")
|
|
|
- if "EXEC" in x:
|
|
|
- exec_id = x["EXEC"]
|
|
|
-
|
|
|
- if "ATTR" in x:
|
|
|
- _attr = x["ATTR"]
|
|
|
- if "FIX" in x:
|
|
|
- _fix_id = x["FIX"]
|
|
|
-
|
|
|
-
|
|
|
- fx=""
|
|
|
- fx2={}
|
|
|
- ftime=0
|
|
|
- delay=0
|
|
|
- if "FX" in x:
|
|
|
- fx = x["FX"]
|
|
|
- if "FX2" in x:
|
|
|
- fx2 = x["FX2"]
|
|
|
- if "FADE" in x:
|
|
|
- ftime = x["FADE"]
|
|
|
- if "DELAY" in x:
|
|
|
- delay = x["DELAY"]
|
|
|
-
|
|
|
-
|
|
|
- #print("DO",[exec_id],x)
|
|
|
- # ids = [401,402,304,103]
|
|
|
- # exec-id, exec-fx-id, flush-id, flush-fx-id
|
|
|
- if v != "off":
|
|
|
- if "FLASH" in x:
|
|
|
- ids = Admx.exec_ids()
|
|
|
- if type(v) is int:
|
|
|
- ids[2] = exec_id
|
|
|
- if fx2:
|
|
|
- ids[3] = exec_id
|
|
|
- #print(" ",[ids, exec_id],"FL")
|
|
|
- else: # GO or ON
|
|
|
- ids = Admx.exec_ids()
|
|
|
- if type(v) is int:
|
|
|
- ids[0] = exec_id
|
|
|
- if fx2:
|
|
|
- ids[1] = exec_id
|
|
|
- #print(" ",[ids, exec_id],"GO")
|
|
|
-
|
|
|
- if v == "off":
|
|
|
- # flash bug if lot's of virtual dimmer are RELEASED-FROM-FLASH ("FLASH off")
|
|
|
- # the V-MASTER FLASH ist HANGING ... no ENCODER change possible !!! ???
|
|
|
- if 0: # "FLASH" in x:
|
|
|
- ids = Admx.exec_ids()
|
|
|
+ if fx2:
|
|
|
+ if ids[3] != exec_id:
|
|
|
+ stop = 1
|
|
|
+ else:
|
|
|
+ ids[3] = None
|
|
|
stop = 0
|
|
|
- #print(" ",[ids, exec_id])
|
|
|
- if ids[2] != exec_id:
|
|
|
- stop = 1
|
|
|
- else:
|
|
|
- ids[2] = None
|
|
|
-
|
|
|
- if fx2:
|
|
|
- if ids[3] != exec_id:
|
|
|
- stop = 1
|
|
|
- else:
|
|
|
- ids[3] = None
|
|
|
- stop = 0
|
|
|
- if stop:
|
|
|
- # this FLASH cmd OFF/RELEASE is not valid anymore
|
|
|
- continue
|
|
|
+ if stop:
|
|
|
+ # this FLASH cmd OFF/RELEASE is not valid anymore
|
|
|
+ return #continue
|
|
|
+
|
|
|
+
|
|
|
+ #aprint("OK")
|
|
|
+ #ids = Admx.exec_ids()
|
|
|
+ #print("OK ",[ids, exec_id])
|
|
|
+
|
|
|
+ #Bdmx[DMX].exec_id(exec_id)
|
|
|
+ out[DMX] = {"flash":{},"fade":{},"fx":{},"flash_fx":{},"fix_id":_fix_id,"attr":_attr,"DMXCH":Admx}
|
|
|
+ if _val is not None:
|
|
|
+ Xval = {"target":_val,"ftime":ftime, "clock":c,"delay":delay,"DMXCH":Admx}
|
|
|
+ mode = "fade"
|
|
|
+ if "FLASH" in x:
|
|
|
+ mode = "flash"
|
|
|
+ out[DMX][mode] = Xval
|
|
|
+
|
|
|
+
|
|
|
+ # FX PARSE
|
|
|
+ _fx2 = _parse_fx2(x,fx2,clock=c)
|
|
|
+ if _fx2:
|
|
|
+ _key=_fx2[0] # fx, fx_flash
|
|
|
+ Xval=_fx2[1] # dict
|
|
|
+ Xval["master"] = master_fx
|
|
|
+
|
|
|
+ out[DMX][_key] = Xval
|
|
|
+
|
|
|
+ elif type(fx) is str and fx:
|
|
|
+ # old fx like sinus:200:12:244
|
|
|
+ ccm = str(DMX+1)+":"+fx
|
|
|
+ print("fx",ccm)
|
|
|
+ if "FLASH" in x:
|
|
|
+ pass #CB({"cmd":"fxf"+ccm})
|
|
|
+ else:
|
|
|
+ pass #CB({"cmd":"fx"+ccm})
|
|
|
|
|
|
|
|
|
- #aprint("OK")
|
|
|
- #ids = Admx.exec_ids()
|
|
|
- #print("OK ",[ids, exec_id])
|
|
|
+def calc_jitter(jdatas,t_start):
|
|
|
+ for cmds in jdatas:
|
|
|
+ for line in cmds:
|
|
|
+ if "time" in line:
|
|
|
+ jt_start = line["time"]
|
|
|
+ latenz = round(t_start-jt_start,4)
|
|
|
+ if latenz > 0.5:
|
|
|
+ cprint("jitter 0.5 >",latenz,color="red")
|
|
|
+ break
|
|
|
|
|
|
- #Bdmx[DMX].exec_id(exec_id)
|
|
|
- out[DMX] = {"flash":{},"fade":{},"fx":{},"flash_fx":{},"fix_id":_fix_id,"attr":_attr,"DMXCH":Admx}
|
|
|
- if v is not None:
|
|
|
- if "FLASH" in x:
|
|
|
- out[DMX]["flash"] = {"target":v,"ftime":ftime, "clock":c,"delay":delay,"DMXCH":Admx}
|
|
|
- else:
|
|
|
- out[DMX]["fade"] = {"target":v,"ftime":ftime, "clock":c,"delay":delay,"DMXCH":Admx}
|
|
|
-
|
|
|
- if type(fx2) is dict and fx2:
|
|
|
- xtype="fade"
|
|
|
- size = 10
|
|
|
- speed = 10
|
|
|
- start = 0
|
|
|
- offset= 0
|
|
|
- width=100
|
|
|
- invert=0
|
|
|
- base = "-"
|
|
|
- if "TYPE" in fx2:
|
|
|
- xtype = fx2["TYPE"]
|
|
|
- if "SIZE" in fx2:
|
|
|
- size = fx2["SIZE"]
|
|
|
- if "SPEED" in fx2:
|
|
|
- speed = fx2["SPEED"]
|
|
|
- if "OFFSET" in fx2:
|
|
|
- offset = fx2["OFFSET"]
|
|
|
- if "BASE" in fx2:
|
|
|
- base = fx2["BASE"]
|
|
|
- if "INVERT" in fx2:
|
|
|
- invert = fx2["INVERT"]
|
|
|
- if "WIDTH" in fx2:
|
|
|
- width = fx2["WIDTH"]
|
|
|
-
|
|
|
- if "off" == x["VALUE"]: #fix fx flash off
|
|
|
- xtype= "off"
|
|
|
-
|
|
|
- if "alloff" == xtype.lower():
|
|
|
- for dmxch in Bdmx:
|
|
|
- if dmxch is not None:
|
|
|
- dmxch.flash_fx(xtype="off",clock=c)
|
|
|
- dmxch.fx(xtype="off",clock=c)
|
|
|
- for j in V_MASTER:
|
|
|
- dmxch = V_MASTER[j]
|
|
|
- if j is not None:
|
|
|
- dmxch.flash_fx(xtype="off",clock=c)
|
|
|
- dmxch.fx(xtype="off",clock=c)
|
|
|
-
|
|
|
- if "FLASH" in x:
|
|
|
- out[DMX]["flash_fx"] = {"xtype":xtype,"size":size,"speed":speed,
|
|
|
- "invert":invert,"width":width,"start":start
|
|
|
- ,"offset":offset,"base":base,"clock":c,"master":master_fx}
|
|
|
- else:
|
|
|
- out[DMX]["fx"] = {"xtype":xtype,"size":size,"speed":speed
|
|
|
- ,"invert":invert,"width":width,"start":start
|
|
|
- ,"offset":offset,"base":base,"clock":c,"master":master_fx}
|
|
|
-
|
|
|
- elif type(fx) is str and fx:
|
|
|
- # old fx like sinus:200:12:244
|
|
|
- ccm = str(DMX+1)+":"+fx
|
|
|
- print("fx",ccm)
|
|
|
- if "FLASH" in x:
|
|
|
- pass#CB({"cmd":"fxf"+ccm})
|
|
|
- else:
|
|
|
- pass#CB({"cmd":"fx"+ccm})
|
|
|
- return out
|
|
|
+def process_flash(jdatas):
|
|
|
+ for cmds in jdatas:
|
|
|
+ for line in cmds: # run first
|
|
|
+ if "FLASH" in line:
|
|
|
+ cprint("FLUSH",end=" ",color="CYAN")
|
|
|
+ if "VALUE" in line:
|
|
|
+ if line["VALUE"] == "off":
|
|
|
+ cprint("OFF",end=" ",color="red")
|
|
|
+ else:
|
|
|
+ cprint("ON",end=" ",color="green")
|
|
|
+ print("")
|
|
|
+ else:
|
|
|
+ cprint("FADE",color="CYAN")
|
|
|
+ break
|
|
|
|
|
|
+def parse_json(data):
|
|
|
+ jdatas = []
|
|
|
+ l2 = 0
|
|
|
+ print("INPUT JCB =>",len(data),":",l2)
|
|
|
+ for line in data:
|
|
|
+ data2 = json.loads(line)
|
|
|
+ l2 += len(data2)
|
|
|
+ jdatas.append(data2) #["CMD"])
|
|
|
|
|
|
+ jdatas2 = []
|
|
|
+ for cmds in jdatas:
|
|
|
+ if not cmds:
|
|
|
+ continue
|
|
|
+ jdatas2.append(cmds)
|
|
|
+ return jdatas2
|
|
|
|
|
|
import hashlib
|
|
|
JCB_GLOB_BUF = {}
|
|
@@ -1267,61 +1341,22 @@ def JCB(data,sock=None): #json client input
|
|
|
msg = msg.format(ct,e-s,sys.getsizeof(data) )
|
|
|
print(msg)
|
|
|
|
|
|
- jdatas = []
|
|
|
- l2 = 0
|
|
|
- for line in data:
|
|
|
-
|
|
|
- data2 = json.loads(line)
|
|
|
- l2 += len(data2)
|
|
|
- #print("line:",line)
|
|
|
- jdatas.append(data2) #["CMD"])
|
|
|
+ jdatas = parse_json(data)
|
|
|
|
|
|
- print("INPUT JCB =>",len(data),":",l2)
|
|
|
c = clock.time()
|
|
|
c = float(c)
|
|
|
ftime = 0
|
|
|
delay = 0
|
|
|
out = {}
|
|
|
line=""
|
|
|
- for cmds in jdatas:
|
|
|
- for line in cmds: # run first
|
|
|
- if "FLASH" in line:
|
|
|
- cprint("FLUSH",end=" ",color="CYAN")
|
|
|
- if "VALUE" in line:
|
|
|
- if line["VALUE"] == "off":
|
|
|
- cprint("OFF",end=" ",color="red")
|
|
|
- else:
|
|
|
- cprint("ON",end=" ",color="green")
|
|
|
- print("")
|
|
|
- else:
|
|
|
- cprint("FADE",color="CYAN")
|
|
|
- break
|
|
|
+
|
|
|
+
|
|
|
+ process_flash(jdatas)
|
|
|
+ calc_jitter(jdatas,t_start)
|
|
|
|
|
|
for cmds in jdatas:
|
|
|
- for line in cmds:
|
|
|
- if "time" in line:
|
|
|
- jt_start = line["time"]
|
|
|
- latenz = round(t_start-jt_start,4)
|
|
|
- if latenz > 0.5:
|
|
|
- cprint("latenz 0.5 >",latenz,color="red")
|
|
|
- break
|
|
|
- for cmds in jdatas:
|
|
|
- #line = json.dumps(cmds)
|
|
|
- #md5 = hashlib.md5.hexdigest(line)
|
|
|
-
|
|
|
master_fx = MASTER_FX()
|
|
|
- if not cmds:
|
|
|
- continue
|
|
|
- try:
|
|
|
- out = _parse_cmds(cmds,clock=c,master_fx=master_fx)
|
|
|
- #cprint("-","{:0.04} sec.".format(time.time()-t_start),color="yellow")
|
|
|
- # ------- ----------------------------------------------------
|
|
|
-
|
|
|
- except Exception as e:
|
|
|
- cprint("EXCEPTION JCB",e,color="red")
|
|
|
- cprint("----",str(cmds)[:150],"...",color="red")
|
|
|
- cprint("Error on line {}".format(sys.exc_info()[-1].tb_lineno),color="red")
|
|
|
- raise e
|
|
|
+ out = _parse_cmds(cmds,clock=c)
|
|
|
|
|
|
line_count = 0
|
|
|
line_count_sub = 0
|
|
@@ -1330,58 +1365,59 @@ def JCB(data,sock=None): #json client input
|
|
|
attr_count2 = 0
|
|
|
|
|
|
|
|
|
- if out:
|
|
|
- try:
|
|
|
- try: # second loop to sync-start all dmxch's
|
|
|
- main.lock.acquire_lock()
|
|
|
- for _id in out:
|
|
|
- row = out[_id]
|
|
|
- #print(" ",_id,[str(row)])
|
|
|
- line_size += sys.getsizeof(row)
|
|
|
-
|
|
|
- #print("_id",_id)
|
|
|
- Admx = row["DMXCH"]
|
|
|
- #print("Admx",Admx)
|
|
|
-
|
|
|
- if "attr" in row:
|
|
|
- if row["attr"] not in attr_count:
|
|
|
- attr_count[row["attr"]] = 0
|
|
|
- attr_count[row["attr"]] += 1
|
|
|
- attr_count2 +=1
|
|
|
-
|
|
|
- if row["fix_id"]:
|
|
|
- _fix_id = row["fix_id"]
|
|
|
- Admx._fix_id = _fix_id
|
|
|
- if "attr" in row:
|
|
|
- if row["attr"] in ["RED","GREEN","BLUE","WHITE","AMBER"]: #CYAN,MAGENTA,YELLOW
|
|
|
- Admx._v_master_id = _fix_id
|
|
|
- #print("SET V_MASTER",row)
|
|
|
-
|
|
|
- line_count_sub += _init_action(row)
|
|
|
- line_count += 1
|
|
|
- e = time.time()
|
|
|
- print(" sub-JCB TIME:","{:0.02f}".format(e-s),int(e*100)/100)
|
|
|
-
|
|
|
- finally:
|
|
|
- main.lock.release_lock()
|
|
|
- #time.sleep(1/30)
|
|
|
+ if not out:
|
|
|
+ return
|
|
|
|
|
|
- except Exception as e:
|
|
|
- cprint("EXCEPTION JCB",e,color="red")
|
|
|
- cprint("----",str(cmds)[:150],"...",color="red")
|
|
|
- cprint("Error on line {}".format(sys.exc_info()[-1].tb_lineno),color="red")
|
|
|
- raise e
|
|
|
+ try:
|
|
|
+ main.lock.acquire_lock()
|
|
|
+ for _id in out:
|
|
|
+ row = out[_id]
|
|
|
+ #print(" ",_id,[str(row)])
|
|
|
+ line_size += sys.getsizeof(row)
|
|
|
+
|
|
|
+ #print("_id",_id)
|
|
|
+ Admx = row["DMXCH"]
|
|
|
+ #print("Admx",Admx)
|
|
|
+
|
|
|
+ if "attr" in row:
|
|
|
+ if row["attr"] not in attr_count:
|
|
|
+ attr_count[row["attr"]] = 0
|
|
|
+ attr_count[row["attr"]] += 1
|
|
|
+ attr_count2 +=1
|
|
|
+
|
|
|
+ if row["fix_id"]:
|
|
|
+ _fix_id = row["fix_id"]
|
|
|
+ Admx._fix_id = _fix_id
|
|
|
+ if "attr" in row:
|
|
|
+ if row["attr"] in ["RED","GREEN","BLUE","WHITE","AMBER"]: #CYAN,MAGENTA,YELLOW
|
|
|
+ Admx._v_master_id = _fix_id
|
|
|
+ #print("SET V_MASTER",row)
|
|
|
+
|
|
|
+ line_count_sub += _init_action(row)
|
|
|
+ line_count += 1
|
|
|
+ e = time.time()
|
|
|
+ print(" sub-JCB TIME:","{:0.02f}".format(e-s),int(e*100)/100)
|
|
|
+
|
|
|
+ #time.sleep(1/30)
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ cprint("EXCEPTION JCB",e,color="red")
|
|
|
+ cprint("----",str(cmds)[:150],"...",color="red")
|
|
|
+ cprint("Error on line {}".format(sys.exc_info()[-1].tb_lineno),color="red")
|
|
|
+ raise e
|
|
|
+ finally:
|
|
|
+ main.lock.release_lock()
|
|
|
|
|
|
- #cprint(" ","{:0.04} sec.".format(time.time()-t_start),color="yellow")
|
|
|
- print("attr_count:",attr_count)
|
|
|
- #print(line_count,line_size)
|
|
|
+ #cprint(" ","{:0.04} sec.".format(time.time()-t_start),color="yellow")
|
|
|
+ print("attr_count:",attr_count)
|
|
|
+ #print(line_count,line_size)
|
|
|
|
|
|
- e = time.time()
|
|
|
- ct = int(e*100)/100
|
|
|
- msg = "{} JCB: END {:0.02f} sizeof:{} fix-count:{} attr-count:{}"
|
|
|
- msg = msg.format(ct,e-s,line_size,line_count,line_count_sub )
|
|
|
- print(msg)
|
|
|
- time.sleep(1/60)
|
|
|
+ e = time.time()
|
|
|
+ ct = int(e*100)/100
|
|
|
+ msg = "{} JCB: END {:0.02f} sizeof:{} fix-count:{} attr-count:{}"
|
|
|
+ msg = msg.format(ct,e-s,line_size,line_count,line_count_sub )
|
|
|
+ print(msg)
|
|
|
+ time.sleep(1/60)
|
|
|
|
|
|
|
|
|
if __run_main:
|