console.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. #! /usr/bin/python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. This file is part of LibreLight.
  5. LibreLight is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, version 2 of the License.
  8. LibreLight is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with LibreLight. If not, see <http://www.gnu.org/licenses/>.
  14. (c) 2012 micha@uxsrv.de
  15. """
  16. import sys
  17. rnd_id = ""
  18. rnd_id += " Beta 22.02 "
  19. import subprocess
  20. rnd_id += subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
  21. if "__file__" in dir():
  22. sys.stdout.write("\x1b]2;"+str(__file__)+" "+rnd_id+"\x07") # terminal title
  23. else:
  24. sys.stdout.write("\x1b]2;"+str("__file__")+" "+rnd_if+"\x07") # terminal title
  25. import time
  26. import socket
  27. import struct
  28. import sys
  29. import random
  30. import math
  31. from collections import OrderedDict
  32. import lib.chat as chat
  33. import lib.ArtNetNode as ANN
  34. import _thread as thread
  35. #thread.start_new_thread
  36. import lib.motion as motion
  37. #idmx = [0]*512 # incremental dmx
  38. dmx = [0]*512 # absolute dmx data
  39. gcolor = 1
  40. def cprint(*text,color="blue",space=" ",end="\n"):
  41. #return 0 #disable print dbg
  42. if not gcolor:
  43. print(text)
  44. return 0
  45. if color == "green":
  46. txt = '\033[92m'
  47. elif color == "red":
  48. txt = '\033[0;31m\033[1m'
  49. elif color == "yellow":
  50. txt = '\033[93m\033[1m'
  51. elif color == "cyan":
  52. txt = '\033[96m'
  53. else:
  54. txt = '\033[94m'
  55. for t in text:
  56. txt += str(t ) +" "
  57. #HEADER = '\033[95m'
  58. #OKBLUE = '\033[94m'
  59. #OKCYAN = '\033[96m'
  60. #OKGREEN = '\033[92m'
  61. #WARNING = '\033[93m'
  62. #FAIL = '\033[91m'
  63. #ENDC = '\033[0m'
  64. #BOLD = '\033[1m'
  65. #UNDERLINE = '\033[4m'
  66. txt += '\033[0m'
  67. print(txt,end=end)
  68. #return txt
  69. def artnet_loop():
  70. #artnet = ANN.ArtNetNode(to="127.0.0.1",port=6555,univ=12)
  71. #artnet = ANN.ArtNetNode(to="127.0.0.1",port=6555,univ=0)
  72. artnet = ANN.ArtNetNode(to="10.10.10.255",univ=0)
  73. #artnet = ANN.ArtNetNode(to="2.0.0.255",univ=0)
  74. #artnet = ANN.ArtNetNode(to="10.10.10.255",univ=1)
  75. #dmx[205] = 255 #205 BLUE
  76. artnet.dmx= dmx #[0]*512
  77. artnet.send()
  78. while 1:
  79. #artnet._test_frame()
  80. artnet.next()
  81. time.sleep(0.01)
  82. class Main():
  83. def __init__(self):
  84. #artnet = ANN.ArtNetNode(to="127.0.0.1",port=6555,univ=12)
  85. #artnet = ANN.ArtNetNode(to="127.0.0.1",port=6555,univ=0)
  86. #artnet = ANN.ArtNetNode(to="2.0.0.255",univ=0)
  87. #artnet = ANN.ArtNetNode(to="10.10.10.255",univ=1)
  88. self.artnet = {}
  89. #self.artnet["0"] = ANN.ArtNetNode(to="10.10.10.255",univ=0)
  90. #self.artnet["0"].dmx[512-1] = 10
  91. #self.artnet["1"] = ANN.ArtNetNode(to="10.10.10.255",univ=1)
  92. #self.artnet["1"].dmx[512-1] = 11
  93. self.fx = {} # key is dmx address
  94. def loop(self):
  95. #dmx[205] = 255 #205 BLUE
  96. #self.artnet.send()
  97. xx = [0]*512
  98. #artnet = self.artnet["0"]
  99. #artnet.dmx = xx# [:] #dmx #[0]*512
  100. old_univ = -1
  101. while 1:
  102. t = clock.time()
  103. ii = 0
  104. for ii,dmxch in enumerate(Bdmx):
  105. i = ii%512
  106. univ = ii//512
  107. if str(univ) not in self.artnet:
  108. print("add uiv",univ)
  109. self.artnet[str(univ)] = ANN.ArtNetNode(to="10.10.10.255",univ=univ)
  110. self.artnet[str(univ)].dmx[512-1] = 100+univ
  111. if univ != old_univ:
  112. old_univ = univ
  113. #print("UNIV",ii/512)
  114. try:
  115. artnet.next()
  116. except:pass
  117. artnet = self.artnet[str(univ)]
  118. artnet.dmx = xx
  119. v = dmxch.next(t)
  120. if i == 0:
  121. #print(dmxch)
  122. if int(xx[i]*100) != int( v*100):
  123. #print("----v",x[i],v,t)
  124. pass
  125. #print("i:{:0.2f} xx:{:0.2f} v:{:0.2f} {:0.2f}----v {}".format(i,xx[i],v,t+100,dmxch))
  126. #print("i:{:0.2f} xx:{:0.2f} v:{:0.2f} {:0.2f}----v {}".format(i,xx[i],v,t+100,dmxch))
  127. xx[i] = int(v)
  128. try:
  129. artnet.next()
  130. except:pass
  131. time.sleep(0.01)
  132. main = Main()
  133. #thread.start_new_thread(artnet_loop,())
  134. thread.start_new_thread(main.loop,())
  135. class CLOCK():
  136. def __init__(self):
  137. self.__time = 0
  138. self.__start = time.time() # only for debugging
  139. self.__tick = 0.01 # incremental timer drift's on highe cpu load ?
  140. def time(self):
  141. return self.__time
  142. def get_drift(self):
  143. run_time = time.time() - self.__start
  144. tick_time = self.__time # * self.__tick
  145. print( "runtime:{:0.2f} tick_timer:{:0.2f} drift:{:0.2f}".format(run_time,tick_time,run_time-tick_time))
  146. def loop(self):
  147. while 1:
  148. self.__time +=self.__tick
  149. #if int(self.__time*100)/10. % 10 == 0:# self.__time % 2 == 0:
  150. # print( self.get_drift())
  151. #print(self.__time)
  152. #for i in range(10):
  153. time.sleep(self.__tick)
  154. clock = CLOCK()
  155. thread.start_new_thread(clock.loop,())
  156. class Fade():
  157. def __init__(self,start,target,ftime,clock,delay=0):
  158. #print("init Fade ",start,target,ftime,clock)
  159. if delay < 0:
  160. delay = 0.0001
  161. if ftime <= 0:
  162. ftime = 0.0001
  163. clock += delay
  164. self.__delay = delay
  165. self.__clock = clock
  166. self.__clock_curr = clock
  167. self.__ftime = ftime
  168. self.__start = start
  169. self.__last = start
  170. self.__target = target
  171. self.run = 1
  172. #print("INIT", str(self) )
  173. def __str__(self):
  174. return self.__repr__()
  175. def __repr__(self):
  176. return "<Fade Next:{:0.2f} Start:{:0.2f} Target:{:0.2f} T{:0.2f} Clock:{:0.2f} run:{} delay:{:0.2f}>".format(
  177. self.__last, self.__start,self.__target,self.__ftime,self.__clock_curr,self.run,self.__delay )
  178. def next(self,clock=None):
  179. if self.__ftime <= 0 and self.__delay <= 0:
  180. self.__last = self.__target
  181. self.run = 0
  182. if type(clock) is float or type(clock) is int:#not None:
  183. self.__clock_curr = clock
  184. if self.__target > self.__start:
  185. if self.__last >= self.__target:
  186. self.run = 0
  187. return self.__target
  188. else:
  189. if self.__last <= self.__target:
  190. self.run = 0
  191. return self.__target
  192. current = (self.__clock - self.__clock_curr) / self.__ftime
  193. length = self.__start - self.__target
  194. self.__last = self.__start+ length*current
  195. #if self.__last < 0:
  196. # self.__last = 0
  197. #if self.__last > 255:
  198. # self.__last = 255
  199. self.run = 1
  200. return self.__last
  201. def ctl(self,cmd="",value=None): # if x-fade cmd="%" value=50
  202. # start,stop,fwd,bwd,revers
  203. pass
  204. class FX():
  205. def __init__(self,xtype="sinus",size=10,speed=10,invert=0,width=100,start=0,offset=0,base="",clock=0):
  206. self.__xtype=xtype
  207. self.__size = size
  208. self.__start = start
  209. if width > 200:
  210. width = 200
  211. self.__width = width
  212. self.__invert = invert
  213. self.__base = base
  214. self.__speed = speed
  215. self.__offset = offset
  216. self.__clock = clock
  217. self.__clock_curr = clock
  218. self.out = 0
  219. self.run = 1
  220. self.__angel = self.__clock_curr*360%360
  221. def __str__(self):
  222. return self.__repr__()
  223. def __repr__(self):
  224. return "<FX Next:{:0.2f} xtype:{} Size:{:0.2f} Speed:{:0.2f} ang:{:0.2f} base:{} Clock:{:0.2f} run:{}>".format(
  225. self.next(),self.__xtype, self.__size,self.__speed,self.__angel, self.__base,self.__clock_curr,self.run )
  226. def next(self,clock=None):
  227. if type(clock) is float or type(clock) is int:#not None:
  228. self.__clock_curr = clock
  229. t = self.__clock_curr * self.__speed / 60
  230. t += self.__offset / 1024 #255
  231. t += self.__start / 1024 #255
  232. tw = t%1
  233. t = t * (100/self.__width)
  234. if tw > self.__width/100:
  235. t = 1 #self.__width/100
  236. #self.__angel = t%1*360 #self.__clock_curr%1 #*360%360
  237. self.__angel = t%1*360 #self.__clock_curr%1 #*360%360
  238. t = t%1
  239. rad = math.radians(self.__angel)
  240. base = 0
  241. if self.__base == "+": # add
  242. base = self.__size
  243. elif self.__base == "-": # sub
  244. base = self.__size*-1
  245. # todo start angle 20°
  246. # todo width angle 90°
  247. #print("{:0.2f} {:0.2f} {:0.2f} {:0.2f}".format(self.__angel ,self.__clock_curr,self.__angel ,math.sin(rad) ) )
  248. out = 0
  249. if self.__xtype == "sinus":
  250. out = math.sin( rad ) * self.__size +base #/2 + base/2
  251. elif self.__xtype == "cosinus":
  252. if self.__base == "+": # add
  253. out = math.cos( rad ) * self.__size*-1 + base #*4 #/2
  254. elif self.__base == "-": # add
  255. out = math.cos( rad ) * self.__size + base #*4
  256. else:
  257. out = math.cos( rad ) * self.__size #+ base/2
  258. elif self.__xtype == "on2":
  259. out = self.__size/2
  260. if self.__angel > 90 and self.__angel <=270:
  261. out *=-1
  262. out += base/2
  263. print("ON {:0.2f} {:0.2f} {:0.2f} {:0.2f}".format(out,t,0,self.__angel, base))
  264. #return out
  265. elif self.__xtype == "on":
  266. out = self.__size/2
  267. if self.__angel > 90 and self.__angel <=270:
  268. pass
  269. else:
  270. out *=-1
  271. out += base/2
  272. #return out
  273. elif self.__xtype == "bump":
  274. out = 0
  275. if self.__base == "-": # sub
  276. out = (t%1-1) * self.__size
  277. elif self.__base == "+": # sub
  278. out = (t%1) * self.__size
  279. else:
  280. out = (t%1-0.5) * self.__size
  281. #print("bump",out)
  282. #return out
  283. elif self.__xtype == "bump2":
  284. out = 0
  285. if self.__base == "+": # sub
  286. out = (t%1-1) * (self.__size *-1)
  287. elif self.__base == "-": # sub
  288. out = (t%1) * (self.__size *-1)
  289. else:
  290. out = (t%1-0.5) * (self.__size *-1)
  291. #print("bump",out)
  292. #return out
  293. elif self.__xtype == "fade":
  294. x = t * 2
  295. if x > 1:
  296. x = 2-x
  297. x -= 0.5
  298. if self.__base == "+": # add
  299. base = self.__size
  300. out = x * self.__size + base/2
  301. else:
  302. base = self.__size*-1
  303. out = x * self.__size + base/2
  304. out = self.__size*-1 -out
  305. #if self.__base == "+": # sub
  306. # out = self.__size*-1 -out
  307. #if not self.__invert:
  308. # out = self.__size*-1 -out
  309. self.out = out
  310. return out
  311. class DMXCH(object):
  312. def __init__(self):
  313. self._base_value = 0
  314. self._fade = None
  315. self._fx = None
  316. self._fx_value = 0
  317. self._flush = None
  318. self._flush_fx = None
  319. self._flush_fx_value = 0
  320. self._last_val = None
  321. def fade(self,target,ftime=0,clock=0,delay=0):
  322. if target != self._base_value:
  323. try:
  324. target = float(target)
  325. self._fade = Fade(self._base_value,target,ftime=ftime,clock=clock,delay=delay)
  326. #self._fade.next()
  327. #self._fade.next()
  328. except Exception as e:
  329. print( "Except:fade",e,target,ftime,clock)
  330. def fx(self,xtype="sinus",size=40,speed=40,invert=0,width=100,start=0,offset=0,base="", clock=0):
  331. print([self,xtype,size,speed,start,offset,base, clock])
  332. if str(xtype).lower() == "off":
  333. #self._fx = Fade(self._fx_value,target=0,ftime=2,clock=clock)
  334. self._fx = None
  335. self._fx_value = 0
  336. else:
  337. self._fx = FX(xtype=xtype,size=size,speed=speed,invert=invert,width=width,start=start,offset=offset,base=base,clock=clock)
  338. def flush(self,target,ftime=0,clock=0,delay=0):
  339. if str(target).lower() == "off":
  340. self._flush = None
  341. else:#elif target != self._base_value:
  342. try:
  343. target = float(target)
  344. self._flush = Fade(self._last_val,target,ftime=ftime,clock=clock,delay=delay)
  345. except Exception as e:
  346. print( "Except:flush",target,ftime,clock,__name__,e,)
  347. def flush_fx(self,xtype="sinus",size=40,speed=40,invert=0,width=100,start=0,offset=0,base="",clock=0):
  348. if str(xtype).lower() == "off":
  349. #self._fx = Fade(self._fx_value,target=0,ftime=2,clock=clock)
  350. self._flush_fx = None
  351. self._flush_fx_value = 0
  352. else:
  353. self._flush_fx = FX(xtype=xtype,size=size,speed=speed,invert=invert,width=width,start=start,offset=offset,base=base,clock=clock)
  354. def fx_ctl(self,cmd=""):#start,stop,off
  355. pass
  356. def __str__(self):
  357. return self.__repr__()
  358. def __repr__(self):
  359. return "< DMXCH {:0.2f} > {} {}".format( self._last_val,self._fx,self._fade)
  360. def fade_ctl(self,cmd=""):#start,stop,backw,fwd,bounce
  361. pass
  362. def next(self,clock=0):
  363. value = self._base_value
  364. if self._last_val is None:
  365. self._last_val = value
  366. fx_value = self._fx_value
  367. if self._flush is not None:
  368. value = self._flush.next(clock)
  369. #flicker bug ?!
  370. value = self._flush.next(clock)
  371. fx_value = 0
  372. elif self._fade is not None:#is Fade:# is Fade:
  373. self._base_value = self._fade.next(clock)
  374. #flicker bug ?!
  375. self._base_value = self._fade.next(clock)
  376. value = self._base_value
  377. if self._flush_fx is not None:# is FX:
  378. fx_value = self._flush_fx.next(clock)
  379. elif self._fx is not None and self._flush is None:# is FX:
  380. self._fx_value = self._fx.next(clock)
  381. fx_value = self._fx_value
  382. self._last_val = value+fx_value
  383. return self._last_val
  384. Bdmx = []
  385. for i in range(512*3):
  386. Bdmx.append( DMXCH() )
  387. #print(type(dmx[i]))
  388. def split_cmd(data):
  389. if "cmd" in data:
  390. cmd = data["cmd"]
  391. #print("cmd",cmd)
  392. if "," in cmd:
  393. cmds = cmd.split(",")
  394. else:
  395. cmds = [cmd]
  396. return cmds
  397. import time
  398. import json
  399. import zlib
  400. def JCB(data): #json client input
  401. t_start = time.time()
  402. #jdatas = data["cmd"].split("\x00")
  403. jdatas = [data["cmd"]]
  404. c = clock.time()
  405. c = float(c)
  406. print("JCB",round(c,2))
  407. ftime = 0
  408. delay = 0
  409. for j in jdatas:
  410. if not j:
  411. continue
  412. try:
  413. jdata = j #jdatas[j]
  414. jtxt = jdata
  415. #jtxt = zlib.decompress(jtxt) #jtxt.decode())
  416. jtxt = str(jtxt,"UTF-8")
  417. cmds = json.loads(jtxt)
  418. for x in cmds:
  419. #cprint(int(clock.time()*1000)/1000,end=" ",color="yellow")#time.time())
  420. #cprint("json", x,type(x),color="yellow")#,cmds[x])
  421. if "DMX" in x:
  422. DMX = int(x["DMX"])
  423. else:continue
  424. if DMX > 0:
  425. DMX -=1
  426. else:continue
  427. if "VALUE" in x:# and x["VALUE"] is not None:
  428. v = x["VALUE"]
  429. else:continue
  430. if "FX" in x:# and x["VALUE"] is not None:
  431. fx = x["FX"]
  432. else:fx=""
  433. if "FX2" in x:# and x["VALUE"] is not None:
  434. fx2 = x["FX2"]
  435. else:fx2={}
  436. if "FADE" in x:
  437. ftime = x["FADE"]
  438. else:ftime=0
  439. if "DELAY" in x:
  440. delay = x["DELAY"]
  441. else:delay=0
  442. if len(Bdmx) < DMX:
  443. continue
  444. if v is not None:
  445. if "FLASH" in x:
  446. #print("FLASH")
  447. Bdmx[DMX].flush(target=v,ftime=ftime, clock=c,delay=delay)
  448. else:
  449. #print("FADE")
  450. Bdmx[DMX].fade(target=v,ftime=ftime, clock=c,delay=delay)
  451. if type(fx2) is dict and fx2:
  452. #cprint("FX2",DMX,fx2,color="green")
  453. xtype="fade"
  454. size = 10
  455. speed = 10
  456. start = 0
  457. offset= 0
  458. width=100
  459. invert=0
  460. base = "-"
  461. if "TYPE" in fx2:
  462. xtype = fx2["TYPE"]
  463. if "SIZE" in fx2:
  464. size = fx2["SIZE"]
  465. if "SPEED" in fx2:
  466. speed = fx2["SPEED"]
  467. if "OFFSET" in fx2:
  468. offset = fx2["OFFSET"]
  469. if "BASE" in fx2:
  470. base = fx2["BASE"]
  471. if "INVERT" in fx2:
  472. invert = fx2["INVERT"]
  473. if "WIDTH" in fx2:
  474. width = fx2["WIDTH"]
  475. if "alloff" == xtype.lower():
  476. for i in Bdmx:
  477. if i is not None:
  478. i.flush_fx(xtype="off",clock=c)
  479. i.fx(xtype="off",clock=c)
  480. if "FLASH" in x:
  481. Bdmx[DMX].flush_fx(xtype=xtype,size=size,speed=speed,invert=invert,width=width,start=start,offset=offset,base=base,clock=c)
  482. else:
  483. Bdmx[DMX].fx(xtype=xtype,size=size,speed=speed,invert=invert,width=width,start=start,offset=offset,base=base,clock=c)
  484. elif type(fx) is str and fx: # old fx like sinus:200:12:244
  485. ccm = str(DMX+1)+":"+fx
  486. print("fx",ccm)
  487. if "FLASH" in x:
  488. CB({"cmd":"fxf"+ccm})
  489. else:
  490. CB({"cmd":"fx"+ccm})
  491. print(time.time()-t_start)
  492. print(time.time())
  493. return
  494. except Exception as e:
  495. cprint("EXCEPTION JCB",e,color="red")
  496. cprint("----",jdata,color="red")
  497. cprint("Error on line {}".format(sys.exc_info()[-1].tb_lineno),color="red")
  498. def CB(data): # raw/text client input
  499. #print("CB",data)
  500. cmds = split_cmd(data)
  501. c = clock.time()
  502. c = float(c)
  503. ftime = 0
  504. delay = 0
  505. for xcmd in cmds:
  506. if xcmd:
  507. cprint("CB",xcmd,end=" ")
  508. pass
  509. else:
  510. continue
  511. if xcmd.startswith("fxf"):
  512. xxcmd=xcmd[3:].split(":")
  513. #print("fxf:",xxcmd)
  514. if "alloff" == xxcmd[1].lower():
  515. for i in Bdmx:
  516. if i is not None:
  517. i.flush_fx(xtype="off",clock=c)
  518. l = xxcmd
  519. try:
  520. xtype=""
  521. size=40
  522. speed=100
  523. start=0
  524. offset=0
  525. base=""
  526. k=int(l[0])-1
  527. xtype=l[1]
  528. if len(l) >= 3:
  529. try:size=int(l[2])
  530. except:pass
  531. if len(l) >= 4:
  532. try:speed=int(l[3])
  533. except:pass
  534. if len(l) >= 5:
  535. try:start=int(l[4])
  536. except:pass
  537. if len(l) >= 6:
  538. try:offset=int(l[5])
  539. except:pass
  540. if len(l) >= 7:
  541. try:base=l[6]
  542. except:pass
  543. if len(Bdmx) > k:
  544. #Bdmx[k].fade(target=v,ftime=t, clock=c)
  545. Bdmx[k].flush_fx(xtype=xtype,size=size,speed=speed,start=start,offset=offset,base=base,clock=c)
  546. except Exception as e:
  547. print("EXCEPTION IN FX",e)
  548. print("Error on line {}".format(sys.exc_info()[-1].tb_lineno))
  549. elif xcmd.startswith("fx"):
  550. xxcmd=xcmd[2:].split(":")
  551. print("DMX:",xxcmd)
  552. if len(xxcmd) < 2:
  553. print("xxcmd err",xxcmd,xcmd)
  554. continue
  555. if "alloff" == xxcmd[1].lower():
  556. for i in Bdmx:
  557. i.fx(xtype="off",clock=c)
  558. l = xxcmd
  559. try:
  560. xtype=""
  561. size=40
  562. speed=100
  563. start=0
  564. offset=0
  565. base=""
  566. k=int(l[0])-1
  567. xtype=l[1]
  568. if len(l) >= 3:
  569. try:size=int(l[2])
  570. except:pass
  571. if len(l) >= 4:
  572. try:speed=int(l[3])
  573. except:pass
  574. if len(l) >= 5:
  575. try:start=int(l[4])
  576. except:pass
  577. if len(l) >= 6:
  578. try:offset=int(l[5])
  579. except:pass
  580. if len(l) >= 7:
  581. try:base=l[6]
  582. except:pass
  583. if len(Bdmx) > k:
  584. #Bdmx[k].fade(target=v,ftime=t, clock=c)
  585. Bdmx[k].fx(xtype=xtype,size=size,speed=speed,start=start,offset=offset,base=base,clock=c)
  586. except Exception as e:
  587. print("EXCEPTION IN FX",xcmd,e)
  588. print("Error on line {}".format(sys.exc_info()[-1].tb_lineno))
  589. #jchat = chat.CMD(CB,port=50001) # server listener
  590. #thread.start_new_thread(jchat.poll,())
  591. chat.cmd(JCB) # server listener
  592. #chat.cmd(JCB,port=50001) # server listener
  593. #input("END")