TK-Nodescanner.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Valid-License-Identifier: GPL-2.0-only
  5. SPDX-URL: https://spdx.org/licenses/GPL-2.0-only.html
  6. (c) 2012 micha@librelight.de
  7. """
  8. import os
  9. import time
  10. import struct
  11. import sys
  12. import tkinter as Tkinter
  13. import _thread as thread
  14. import nodescan
  15. title = "TK-ArtNet-Nodscaner"
  16. sys.stdout.write("\x1b]2;"+title+"\x07")
  17. node_list = []
  18. def load(event):
  19. print()
  20. print("load()")
  21. sel = int( li_nodes.curselection()[0] )
  22. print("li_nodes.get")
  23. try:
  24. sel = int(li_nodes.get(sel).split()[0])
  25. print(sel)
  26. except:
  27. return 0
  28. sel -= 1
  29. node_list[sel]
  30. clear_entry_ip()
  31. e_ip.configure(state='normal')
  32. e_ip.insert("end",node_list[sel]["IP"].replace("[","").replace("]",""))
  33. #e_ip.configure(state='readonly')
  34. e_ip_new.insert("end",node_list[sel]["IP"].replace("[","").replace("]",""))
  35. e_mac.delete("0","end")
  36. e_mac.insert("end",node_list[sel]["MAC"].replace("[","").replace("]",""))
  37. e_mac2.delete("0","end")
  38. e_mac2.insert("end",node_list[sel]["MAC"].split(":")[-1])
  39. print("load",node_list[sel])
  40. e_lname.delete("0","end")
  41. e_lname.insert("end",node_list[sel]["lname"])
  42. e_sname.delete("0","end")
  43. e_sname.insert("end",node_list[sel]["sname"])
  44. e_artnet_uni1.delete("0","end")
  45. univ = "0"
  46. print("tttttttttttttttttttttttttttttttttttttttt")
  47. try:
  48. if node_list[sel]["PortTypes"][0] == "@":
  49. univ = ord(node_list[sel]["SwIn"][0])
  50. else:
  51. univ = ord(node_list[sel]["SwOut"][0])
  52. except Exception as e:
  53. print("load Exception",e)
  54. MSG["text"] = e
  55. MSG["bg"] = "red"
  56. e_artnet_uni1.insert("end",univ)
  57. def clear_entry_ip():
  58. e_ip.configure(state='normal')
  59. e_ip.delete("0","end")
  60. e_ip.configure(state='readonly')
  61. e_ip_new.delete("0","end")
  62. def clear_node():
  63. global node_list
  64. li_nodes.delete("0","end")
  65. node_list = []
  66. li_nodes.delete("0","end")
  67. def poll(delay=1,ip=""):
  68. print("poll()")
  69. global old_tick
  70. clear()
  71. clear_entry_ip()
  72. clear_node()
  73. time.sleep(delay)
  74. time.sleep(0.5)
  75. if not ip:
  76. ip = p_variable.get()
  77. b_scan.insert("end", "ArtNetPoll -> "+str(ip)+"\n")
  78. nodescan.ArtNet_poll(ip)
  79. #return
  80. #try:
  81. # nodescan.poll()
  82. #except Exception as e:
  83. # print("e",e)
  84. # MSG["text"] = e
  85. # MSG["bg"] = "red"
  86. #time.sleep(0.5)
  87. #old_tick = 0
  88. def clear(event= None):
  89. print("clear()")
  90. global rx
  91. rx.clear()
  92. clear_node()
  93. #poll()
  94. MSG["text"] = ""
  95. MSG["bg"] = "grey"
  96. time.sleep(0.1)
  97. def poll_loop(sleep):
  98. if sleep < 1:
  99. sleep = 1
  100. time.sleep(sleep)
  101. while 1:
  102. poll()
  103. time.sleep(sleep)
  104. old_tick = 0
  105. rx = nodescan.ArtNetNodes()
  106. def _scan():
  107. global rx,node_list,old_tick,Scrollbar
  108. print("get node from cache " )
  109. li_nodes.insert("end",str("----"))
  110. rx.loop()
  111. while 1:
  112. try:
  113. __scan()
  114. except Exception as e:
  115. print("_scan Exception as",e)
  116. MSG["text"] = e
  117. MSG["bg"] = "red"
  118. time.sleep(0.1)
  119. def __scan():
  120. global rx,node_list,old_tick,Scrollbar
  121. while 1:
  122. nodes = rx.get()
  123. new_tick = rx.tick()
  124. if new_tick == old_tick:
  125. continue
  126. old_tick = new_tick
  127. #print("node",nodes)
  128. if nodes:
  129. li_node_scroll = li_nodes.yview()
  130. #clear_node()
  131. #li_nodes.delete(0,"end")
  132. #print("yea",len(nodes))
  133. node_nr = 1
  134. nodesB = {}
  135. for node in nodes:
  136. k = node["MAC"]
  137. nodesB[k] = node
  138. print("k",nodesB.keys())
  139. #for node in nodes:
  140. #for k,node in nodesB.items():
  141. k_sort = list(nodesB.keys())
  142. k_sort.sort()
  143. print("k sort",k_sort)
  144. for k in k_sort:
  145. node = nodesB[k]
  146. li_nodes.insert("end",str(node_nr).rjust(3," ") +" "+ node["lname"])
  147. bg = "lightgrey"
  148. color = li_nodes.itemconfig("end", bg=bg)
  149. ip = str(node_nr).rjust(3," ") +" "+ node["IP"]
  150. bg = ""
  151. if "PortTypes" in node:
  152. if not node["PortTypes"]:
  153. pass
  154. if node["PortTypes"][0] == "@":
  155. ip += " DMX-in"
  156. bg ="yellow"
  157. else:
  158. ip += " DMX-out"
  159. bg ="lightgreen"
  160. if bg:
  161. color = li_nodes.itemconfig("end", bg=bg)
  162. li_nodes.insert("end",str(node_nr).rjust(3," ") +" short Name:"+ node["sname"])
  163. li_nodes.insert("end",ip)
  164. if bg:
  165. color = li_nodes.itemconfig("end", bg=bg)
  166. inout = " UNIVERS OUT="+ str(ord(node["SwOut"][0]))+" IN="+ str(ord(node["SwIn"][0]))
  167. li_nodes.insert("end",str(node_nr).rjust(3," ") + inout)
  168. li_nodes.insert("end",str(node_nr).rjust(3," ") +" MAC:"+ node["MAC"])
  169. timeline = ""
  170. timeline += " LASTCHANGE:%0.1f"% (time.time()-float(node["UPDATESTAMP"]) )
  171. REFRESHSTAMP = time.time()-float(node["REFRESHSTAMP"])
  172. timeline +=" LASTPING:%0.1f"% REFRESHSTAMP
  173. li_nodes.insert("end",str(node_nr).rjust(3," ") +timeline )
  174. if node["BOOT"]:
  175. BOOT = time.time()-float(node["BOOT"])
  176. else:
  177. BOOT = 0
  178. timeline =" BOOT:%0.1f"% BOOT
  179. li_nodes.insert("end",str(node_nr).rjust(3," ") +timeline +" sec" )
  180. bg = ""
  181. #if REFRESHSTAMP > 5 :
  182. # bg="red"
  183. #else:
  184. # bg="lightgreen"
  185. if bg:
  186. li_nodes.itemconfig("end", bg=bg)
  187. #li_nodes.insert("end",str(node_nr).rjust(3," ")
  188. #li_nodes.insert("end","")
  189. li_nodes.insert("end","*"*60)
  190. #li_nodes.itemconfig("end", bg="brown")
  191. node_nr += 1
  192. node_list += [node]
  193. #Scrollbar.set('0', '0.1')
  194. print(li_node_scroll)
  195. #print(dir(li_nodes))
  196. #li_node_scroll = int(li_node_scroll[0])
  197. #li_nodes.yview_moveto(li_node_scroll)
  198. time.sleep(0.2)
  199. def get_new_ip(event=None):
  200. b = e_ip_new.get().replace("[","").replace("]","")
  201. return b
  202. def get_new_ip_str(event=None):
  203. x = get_new_ip()
  204. #x = x[1:-1]
  205. x = x.strip()
  206. #x = x.replace(",",".")
  207. x = x.replace(" ","")
  208. x = x.split(",")
  209. print( "get_new_ip_str",x)
  210. return x
  211. def send_artaddr(event=None):
  212. ln = e_lname.get()
  213. sn = e_sname.get()
  214. ip = e_ip_new.get()
  215. ip = ip.replace(" ","")
  216. ip = ip.replace(",",".")
  217. univ = e_artnet_uni1.get()
  218. print("SEND ArtAddress:",[ln,sn,ip,univ])
  219. if ln and sn and ip and univ:
  220. nodescan.ArtAddress(ip=ip ,ShortName=sn, LongName=ln,Port="",Universes=univ)
  221. time.sleep(1)
  222. poll()
  223. def send_none(event=None):
  224. pass
  225. def send_mac(event=None):
  226. #new_mac = "CMD MAC6 " + hex(e_mac2.get()) #)
  227. #new_mac = "CMD MAC6 " + struct.pack("<B",(int(e_mac2.get(),16))).decode()
  228. new_mac = b"CMD MAC6 " + struct.pack("<B",(int(e_mac2.get(),16)))
  229. a = e_ip.get().replace("[","").replace("]","")
  230. cur_ip = []
  231. for i in a.split(","):
  232. cur_ip +=[int(i)]
  233. print("SEND MAC:",cur_ip,new_mac)
  234. nodescan.send_node_cmd(cur_ip,cmd=new_mac)
  235. #poll(delay=1.5)
  236. def send_dmx_store(event=None):
  237. cmd = "CMD DMX STORE "
  238. a = e_ip.get().replace("[","").replace("]","")
  239. cur_ip = []
  240. for i in a.split(","):
  241. cur_ip +=[int(i)]
  242. print("SEND:",cur_ip,cmd)
  243. nodescan.send_node_cmd(cur_ip,cmd)
  244. poll(delay=1.5)
  245. def send_cmd(event=None):
  246. cmd = e_cmd.get() #"CMD DMX STORE "
  247. _send_cmd(cmd=cmd)
  248. def send_cmd2(event=None):
  249. cmd = e_cmd2.get() #"CMD DMX STORE "
  250. _send_cmd(cmd=cmd)
  251. def send_cmd3(event=None):
  252. cmd = e_cmd3.get() #"CMD DMX STORE "
  253. _send_cmd(cmd=cmd)
  254. def send_cmd4(event=None):
  255. cmd = e_cmd4.get() #"CMD DMX STORE "
  256. _send_cmd(cmd=cmd)
  257. def send_cmd5(event=None):
  258. cmd = e_cmd5.get() #"CMD DMX STORE "
  259. _send_cmd(cmd=cmd)
  260. def _send_cmd(event=None,cmd=""):
  261. #cmd = e_cmd.get() #"CMD DMX STORE "
  262. cmd = cmd.split(" ")
  263. value = cmd[-1]
  264. try:
  265. value = struct.pack("<B",int(value))
  266. except:pass
  267. cmd = cmd[:-1] #.append(value)
  268. cmd.append(value)
  269. print("_send_cmd:",cmd)
  270. cmd=" ".join(map(str,cmd) )
  271. a = e_ip.get().replace("[","").replace("]","")
  272. cur_ip = []
  273. sep = "xx"
  274. if "," in a:
  275. sep = ","
  276. if "." in a:
  277. sep = "."
  278. for i in a.split(sep):
  279. cur_ip +=[int(i)]
  280. print("SEND:",cur_ip,cmd)
  281. nodescan.send_node_cmd(cur_ip,cmd)
  282. #poll(delay=1.5)
  283. def kill_librelight(event=None):
  284. for i in ["CONSOLE.py","EDITOR.py","ASP"]:
  285. cmd='screen -XS "{}" quit | echo ""'.format(i)
  286. print(cmd)
  287. os.system(cmd)
  288. cmd="screen -ls"
  289. os.system(cmd)
  290. time.sleep(1)
  291. BASE_PATH = "/opt/LibreLight/Xdesk/"
  292. cmd="_LibreLightDesk.py"
  293. cmd="tool/TK-Nodescanner.py" #&"
  294. arg = ""
  295. os.execl("/usr/bin/python3", BASE_PATH, cmd,arg)
  296. def set_ip(event=None):
  297. print("SET NEW IP")
  298. cur_ip=(2,0,0,94)
  299. new_ip=(2,0,0,201)
  300. new_netmask=(255,0,0,0)
  301. a = e_ip.get().replace("[","").replace("]","")
  302. b = e_ip_new.get().replace("[","").replace("]","")
  303. c = variable.get() #e_mask_new.get()
  304. new_netmask = [] #c.split(".") #list(c)
  305. for i in c.split("."):
  306. new_netmask +=[int(i)]
  307. cur_ip = []
  308. for i in a.split(","):
  309. cur_ip +=[int(i)]
  310. new_ip = []
  311. for i in b.split(","):
  312. new_ip +=[int(i)]
  313. if new_ip == cur_ip:
  314. print("neu und als IP sind gleich" )
  315. return 0
  316. #cur_ip=(2,0,0,94)
  317. #new_ip=(2,0,0,201)
  318. print("new",[cur_ip, new_ip, new_netmask])
  319. print()
  320. nodescan.set_ip4(cur_ip,new_ip, new_netmask)
  321. poll(delay=1.5)
  322. def set_node_pin(evnet=None):
  323. cmd = "CMD DMX=PIN"
  324. ip = get_new_ip_str()
  325. print("ip",[ip])
  326. nodescan.send_node_cmd(ip,cmd=cmd)
  327. poll(delay=1.5)
  328. def set_node_in(evnet=None):
  329. cmd="CMD DMX=IN"
  330. ip = get_new_ip_str()
  331. nodescan.send_node_cmd(ip,cmd=cmd)
  332. poll(delay=1.5)
  333. def set_node_out(evnet=None):
  334. cmd="CMD DMX=OUT"
  335. ip = get_new_ip_str()
  336. nodescan.send_node_cmd(ip,cmd=cmd)
  337. poll(delay=1.5)
  338. root = Tkinter.Tk()
  339. #root.geometry("900x700+100+100")
  340. root.geometry("700x600+100+100")
  341. root.title( title)
  342. fframe = Tkinter.Frame(root)
  343. fframe.pack(side="top",expand=0,fill="x")
  344. cframe = Tkinter.Frame(root)
  345. cframe.pack(side="top",expand=1,fill="both")
  346. font1 = ("Helvetica", 8)
  347. font2 = ("Helvetica", 12) # 10
  348. font3 = ("Helvetica", 12) # 16
  349. font20 = font=("Helvetica", 12) # 22
  350. font120 = font=("Helvetica", 22) # 22
  351. b_scan = Tkinter.Button(fframe,text="clear list",width=8,command=clear,font=font2)
  352. b_scan.pack(side="left",expand=0,fill="y")
  353. b_scan = Tkinter.Button(fframe,text="ArtNetPoll ->",width=10,command=poll,font=font2)
  354. b_scan.configure(bg="#0f0")
  355. b_scan.pack(side="left",expand=0,fill="y")
  356. #POLL ['192.168.0.255', 6454] OK ;
  357. #POLL ['192.168.0.99', 6454] OK ;
  358. #POLL ['2.255.255.255', 6454] OK ;
  359. #POLL ['2.0.0.255', 6454] OK ;
  360. #POLL ['2.255.255.255', 6454] OK ;
  361. local_ips = []
  362. #local_ips.append("2.0.0.255")
  363. cmd='ip a | grep " inet " | cut -d " " -f 6 | sort -h'
  364. r=os.popen(cmd)
  365. print("cmd",cmd)
  366. txt=r.readlines()
  367. for ip in txt:
  368. ip = ip.strip()
  369. print([ip])
  370. if ip.startswith("127."):
  371. continue
  372. if ip.count(".") != 3:
  373. continue
  374. if ip.endswith("/24"):
  375. ip = ip.split(".")
  376. ip = ".".join(ip[:3])+".255"
  377. elif ip.endswith("/8"):
  378. ip = ip.split(".")
  379. ip = ".".join(ip[0])+".255.255.255"
  380. else:
  381. continue
  382. print("-",ip)
  383. if ip == "2.255.255.255":
  384. print("- workaround -")
  385. local_ips.append("2.0.0.255")
  386. local_ips.append(ip)
  387. #local_ips.sort()
  388. option_list=local_ips
  389. p_variable = Tkinter.StringVar(root)
  390. p_variable.set(option_list[0]) # default value
  391. e_poll_new = Tkinter.OptionMenu(fframe, p_variable,*option_list)
  392. e_poll_new.configure(font=("Helvetica", 13))
  393. e_poll_new.configure(width=16)
  394. e_poll_new["bg"] = "#fff"
  395. #print(dir(e_poll_new))
  396. e_poll_new.option_add("end","") #', 'option_clear', 'option_get
  397. e_poll_new.option_add("end","215.0.0.0")
  398. e_poll_new.pack(side="left")
  399. #exit()
  400. b_scan = Tkinter.Button(fframe,text="KILL Librelight !",command=kill_librelight,width=14,font=font2,bg="red")
  401. b_scan.pack(side="left",expand=0)
  402. scrollbar = Tkinter.Scrollbar(cframe)
  403. scrollbar.pack(side=Tkinter.RIGHT, fill="y")
  404. #pool = Tkinter.Listbox(root,selectmode="extended",exportselection=0)
  405. li_nodes = Tkinter.Listbox(cframe,exportselection=0,width=35,font=font1)
  406. li_nodes.pack(side="left",expand=0,fill="y")
  407. li_nodes.bind("<ButtonRelease-1>",load )
  408. li_nodes.config(yscrollcommand=scrollbar.set)
  409. scrollbar.config(command=li_nodes.yview)
  410. eframe = Tkinter.Frame(cframe)
  411. eframe.pack(side="left",expand=0,fill="y")
  412. eframe1 = Tkinter.Frame(cframe)
  413. eframe1.pack(side="left",expand=0,fill="y")
  414. # ----------------------------------------------
  415. line_frame = Tkinter.Frame(eframe)
  416. line_frame.pack(side="top",expand=0,fill="x")
  417. x=Tkinter.Label(line_frame,text=" ",font=font2,width=6)
  418. c= Tkinter.Label(line_frame,text=" ",font=font1,width=30,anchor="w")
  419. c.pack(side="left",expand=0,fill="y")
  420. # ----------------------------------------------
  421. # ----------------------------------------------
  422. line_frame = Tkinter.Frame(eframe)
  423. line_frame.pack(side="top",expand=0,fill="x")
  424. x=Tkinter.Label(line_frame,text="MSG:",font=font3,width=6)
  425. x.pack(side="left",expand=0,fill="y")
  426. x.configure(bg="darkgrey")
  427. MSG = Tkinter.Label(line_frame,text="xxx",font=font1,width=30,anchor="w")
  428. MSG.pack(side="left",expand=0,fill="y")
  429. MSG.configure(bg="darkgrey")
  430. #msg["bg"] = "lightgrey"
  431. #msg.pack(side="left")
  432. # ----------------------------------------------
  433. line_frame = Tkinter.Frame(eframe)
  434. line_frame.pack(side="top",expand=0,fill="x")
  435. c= Tkinter.Label(line_frame,text=" ",font=font120,width=30,anchor="w")
  436. c.pack(side="left",expand=0,fill="y")
  437. # ----------------------------------------------
  438. line_frame = Tkinter.Frame(eframe)
  439. line_frame.pack(side="top",expand=0,fill="x")
  440. Tkinter.Label(line_frame,text="OLD IP:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  441. e_ip = Tkinter.Entry(line_frame,font=font20,width=26,state="disabled")
  442. e_ip["bg"] = "lightgrey"
  443. e_ip.pack(side="left")
  444. #b_scan = Tkinter.Button(line_frame,width=14,font=font3)
  445. #b_scan.pack(side="left",expand=1)
  446. # ----------------------------------------------
  447. line_frame = Tkinter.Frame(eframe)
  448. line_frame.pack(side="top",expand=0,fill="x")
  449. e_ip_label = Tkinter.Label(line_frame,text=" IP:",font=font3,width=6)
  450. e_ip_label.pack(side="left",expand=0,fill="y")
  451. e_ip_new = Tkinter.Entry(line_frame,font=font20,width=26)
  452. e_ip_new.bind("<Return>", set_ip )
  453. e_ip_new.bind("<KP_Enter>", set_ip)
  454. #e_ip_new.bind("<Tab>", update_name)
  455. e_ip_new.bind("<ISO_Left_Tab>", set_ip)
  456. e_ip_new.pack(side="left")
  457. #-------------------------------------------- line
  458. line_frame = Tkinter.Frame(eframe)
  459. line_frame.pack(side="top",expand=0,fill="x")
  460. variable = Tkinter.StringVar(root)
  461. variable.set("255.0.0.0") # default value
  462. Tkinter.Label(line_frame,text="MASK:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  463. e_mask_new = Tkinter.OptionMenu(line_frame, variable,"255.255.255.0","255.0.0.0") #,width=10)
  464. e_mask_new.configure(font=("Helvetica", 12))
  465. e_mask_new.configure(width=23)
  466. e_mask_new["bg"] = "#fff"
  467. #heigh=1,font=("Helvetica", 20)
  468. e_mask_new.pack(side="left")
  469. #e_mask_new.insert("end","255.0.0.0")
  470. #e_mask_new.insert("end","255.255.255.0")
  471. b_scan = Tkinter.Button(line_frame,text="SEND TO NODE",command=set_ip,width=14,font=font1)
  472. b_scan.pack(side="left",expand=0)
  473. #-------------------------------------------- line
  474. line_frame = Tkinter.Frame(eframe)
  475. line_frame.pack(side="top",expand=0,fill="x")
  476. Tkinter.Label(line_frame,text="MAC:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  477. e_mac = Tkinter.Entry(line_frame,width=23,font=font20)
  478. e_mac.pack(side="left")
  479. e_mac["bg"] = "lightgrey"
  480. e_mac2 = Tkinter.Entry(line_frame,width=3,font=font20)
  481. e_mac2.pack(side="left")
  482. e_mac2.bind("<Return>", send_mac )
  483. e_mac2.bind("<KP_Enter>", send_mac)
  484. Tkinter.Button(line_frame,text="SEND TO NODE",command=send_mac,width=14,font=font1).pack(side="left",expand=0)
  485. # ----------------------------------------------
  486. line_frame = Tkinter.Frame(eframe)
  487. line_frame.pack(side="top",expand=0,fill="x")
  488. c= Tkinter.Label(line_frame,text=" ",font=font120,width=30,anchor="w")
  489. c.pack(side="left",expand=0,fill="y")
  490. # ----------------------------------------------
  491. #-------------------------------------------- line
  492. #b_scan = Tkinter.Button(eframe1,width=14,font=font3)
  493. #b_scan.pack(side="top",expand=0)
  494. line_frame = Tkinter.Frame(eframe)
  495. line_frame.pack(side="top",expand=0,fill="x")
  496. Tkinter.Label(line_frame,text="DMX:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  497. b_set_node_pin = Tkinter.Button(line_frame,text="HW-PIN",command=set_node_pin,width=6,font=font3)
  498. b_set_node_pin.pack(side="left",expand=0)
  499. b_set_node_in = Tkinter.Button(line_frame,text="IN",command=set_node_in,width=6,font=font3)
  500. b_set_node_in.pack(side="left",expand=0)
  501. b_set_node_out = Tkinter.Button(line_frame,text="OUT",command=set_node_out,width=6,font=font3)
  502. b_set_node_out.pack(side="left",expand=0)
  503. #-------------------------------------------- line
  504. line_frame = Tkinter.Frame(eframe)
  505. line_frame.pack(side="top",expand=0,fill="x")
  506. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  507. e_cmd = Tkinter.Entry(line_frame,font=font3,width=26)
  508. e_cmd.bind("<Return>", send_cmd )
  509. e_cmd.pack(side="left")
  510. #-------------------------------------------- line
  511. line_frame = Tkinter.Frame(eframe)
  512. line_frame.pack(side="top",expand=0,fill="x")
  513. Tkinter.Label(line_frame,text="LName",font=font3,width=6).pack(side="left",expand=0,fill="y")
  514. e_lname = Tkinter.Entry(line_frame,font=font3,width=26)
  515. e_lname.pack(side="left")
  516. #-------------------------------------------- line
  517. line_frame = Tkinter.Frame(eframe)
  518. line_frame.pack(side="top",expand=0,fill="x")
  519. Tkinter.Label(line_frame,text="SName",font=font3,width=6).pack(side="left",expand=0,fill="y")
  520. e_sname = Tkinter.Entry(line_frame,font=font3,width=26)
  521. e_sname.pack(side="left")
  522. #-------------------------------------------- line
  523. line_frame = Tkinter.Frame(eframe)
  524. line_frame.pack(side="top",expand=0,fill="x")
  525. Tkinter.Label(line_frame,text="ArtNet",font=font3,width=6).pack(side="left",expand=0,fill="y")
  526. Tkinter.Label(line_frame,text="SUB:",font=font3,width=4).pack(side="left",expand=0,fill="y")
  527. e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4,state="disabled")
  528. e_artnet_uni1.pack(side="left")
  529. Tkinter.Label(line_frame,text="NET:",font=font3,width=4).pack(side="left",expand=0,fill="y")
  530. e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4,state="disabled")
  531. e_artnet_uni1.pack(side="left")
  532. Tkinter.Label(line_frame,text="UNI:",font=font3,width=4).pack(side="left",expand=0,fill="y")
  533. e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4)
  534. e_artnet_uni1.pack(side="left")
  535. Tkinter.Button(line_frame,text="send ArtAddr",command=send_artaddr,width=14,font=font1).pack(side="left",expand=0)
  536. #-------------------------------------------- line
  537. b_scan = Tkinter.Text(eframe,width=20,font=font2)
  538. b_scan.pack(side="top",expand=1,fill="x")
  539. #-------------------------------------------- line
  540. line_frame = Tkinter.Frame(eframe1)
  541. line_frame.pack(side="top",expand=0,fill="x")
  542. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  543. e_cmd2 = Tkinter.Entry(line_frame,font=font3,width=16)
  544. e_cmd2.insert("end","DMX ERASE ")
  545. e_cmd2.bind("<Return>", send_cmd2 )
  546. e_cmd2.pack(side="left")
  547. #-------------------------------------------- line
  548. line_frame = Tkinter.Frame(eframe1)
  549. line_frame.pack(side="top",expand=0,fill="x")
  550. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  551. e_cmd3 = Tkinter.Entry(line_frame,font=font3,width=16)
  552. e_cmd3.insert("end","DMX OUT STORE ")
  553. e_cmd3.bind("<Return>", send_cmd3 )
  554. e_cmd3.pack(side="left")
  555. #-------------------------------------------- line
  556. line_frame = Tkinter.Frame(eframe1)
  557. line_frame.pack(side="top",expand=0,fill="x")
  558. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  559. e_cmd4 = Tkinter.Entry(line_frame,font=font3,width=16)
  560. e_cmd4.insert("end","DMX OUT SET 2")
  561. e_cmd4.bind("<Return>", send_cmd4 )
  562. e_cmd4.pack(side="left")
  563. #-------------------------------------------- line
  564. line_frame = Tkinter.Frame(eframe1)
  565. line_frame.pack(side="top",expand=0,fill="x")
  566. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  567. e_cmd5 = Tkinter.Entry(line_frame,font=font3,width=16)
  568. e_cmd5.insert("end","REBOOT ")
  569. e_cmd5.bind("<Return>", send_cmd5 )
  570. e_cmd5.pack(side="left")
  571. thread.start_new_thread(_scan, () )
  572. nodescan.bind_cmd_node()
  573. def read_cmd_buf():
  574. b_scan.insert("end", "log:\n" )
  575. while 1:
  576. if nodescan.node_cmd_buf_list:
  577. msg = str(nodescan.node_cmd_buf_list)
  578. print("read_cmd_buf msg",msg)
  579. nodescan.node_cmd_buf_list = []
  580. stamp = str(time.time())+"\n"
  581. stamp = time.strftime("%Y-%m-%d %X\n")
  582. b_scan.insert("end",stamp)
  583. b_scan.insert("end", msg +"\n")
  584. b_scan.see("end")
  585. time.sleep(0.1)
  586. #thread.start_new_thread(nodescan.node_cmd_recive, () )
  587. #thread.start_new_thread(read_cmd_buf, () )
  588. def _update():
  589. while 1:
  590. time.sleep(1)
  591. root.update_idletasks()
  592. def X():
  593. thread.start_new_thread(nodescan.node_cmd_recive, () )
  594. thread.start_new_thread(read_cmd_buf, () )
  595. thread.start_new_thread(_update, () )
  596. #thread.start_new_thread(node_cmd_recive, () )
  597. #send_node_cmd(ip=(2,0,0,91),cmd="DMX OUT STORE")
  598. ##nodescan.send_node_cmd(ip=(2,255,255,255),cmd="CMD GT ")
  599. #nodescan.send_node_cmd(ip,cmd=cmd)
  600. #rx.loop()
  601. z = 0
  602. time.sleep(1)
  603. poll()
  604. while 1:
  605. nodes = rx.get()
  606. #print(len(nodes))
  607. if z % 10 == 0:
  608. pass
  609. print("----")
  610. #MSG["text"] = ""
  611. #MSG["bg"] = "grey"
  612. #pass#print("node count",len(nodes),rx.tick())
  613. #for node in nodes:
  614. # print(node["MAC"],node["lname"])
  615. z += 1
  616. time.sleep(0.2)
  617. print()
  618. print("time out")
  619. raw_input("ENDE")
  620. thread.start_new_thread(X,()) #node_cmd_recive, () )
  621. root.mainloop()