TK-Nodescanner.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  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. for i in ["ASP"]:
  286. cmd='screen -XS "{}" quit | echo ""'.format(i)
  287. print(cmd)
  288. os.system(cmd)
  289. cmd="screen -ls"
  290. os.system(cmd)
  291. time.sleep(1)
  292. BASE_PATH = "/opt/LibreLight/Xdesk/"
  293. cmd="_LibreLightDesk.py"
  294. cmd="tool/TK-Nodescanner.py" #&"
  295. arg = ""
  296. os.execl("/usr/bin/python3", BASE_PATH, cmd,arg)
  297. def start_librelight(event=None):
  298. #for i in ["CONSOLE.py","EDITOR.py","ASP"]:
  299. for i in ["ASP"]:
  300. cmd='screen -XS "{}" quit | echo ""'.format(i)
  301. print(cmd)
  302. os.system(cmd)
  303. nodescan.is_running = 0 # exit all thread loop's
  304. root.quit()
  305. time.sleep(0.5)
  306. BASE_PATH = "/opt/LibreLight/Xdesk/"
  307. cmd="init/10-ASP.sh"
  308. arg = ""
  309. os.system(cmd)
  310. #os.execl("/usr/bin/sh", BASE_PATH, cmd,arg)
  311. def set_ip(event=None):
  312. print("SET NEW IP")
  313. cur_ip=(2,0,0,94)
  314. new_ip=(2,0,0,201)
  315. new_netmask=(255,0,0,0)
  316. a = e_ip.get().replace("[","").replace("]","")
  317. b = e_ip_new.get().replace("[","").replace("]","")
  318. c = variable.get() #e_mask_new.get()
  319. new_netmask = [] #c.split(".") #list(c)
  320. for i in c.split("."):
  321. new_netmask +=[int(i)]
  322. cur_ip = []
  323. for i in a.split(","):
  324. cur_ip +=[int(i)]
  325. new_ip = []
  326. for i in b.split(","):
  327. new_ip +=[int(i)]
  328. if new_ip == cur_ip:
  329. print("neu und als IP sind gleich" )
  330. return 0
  331. #cur_ip=(2,0,0,94)
  332. #new_ip=(2,0,0,201)
  333. print("new",[cur_ip, new_ip, new_netmask])
  334. print()
  335. nodescan.set_ip4(cur_ip,new_ip, new_netmask)
  336. poll(delay=1.5)
  337. def set_node_pin(evnet=None):
  338. cmd = "CMD DMX=PIN"
  339. ip = get_new_ip_str()
  340. print("ip",[ip])
  341. nodescan.send_node_cmd(ip,cmd=cmd)
  342. poll(delay=1.5)
  343. def set_node_in(evnet=None):
  344. cmd="CMD DMX=IN"
  345. ip = get_new_ip_str()
  346. nodescan.send_node_cmd(ip,cmd=cmd)
  347. poll(delay=1.5)
  348. def set_node_out(evnet=None):
  349. cmd="CMD DMX=OUT"
  350. ip = get_new_ip_str()
  351. nodescan.send_node_cmd(ip,cmd=cmd)
  352. poll(delay=1.5)
  353. root = Tkinter.Tk()
  354. #root.geometry("900x700+100+100")
  355. root.geometry("700x600+100+100")
  356. root.title( title)
  357. fframe = Tkinter.Frame(root)
  358. fframe.pack(side="top",expand=0,fill="x")
  359. cframe = Tkinter.Frame(root)
  360. cframe.pack(side="top",expand=1,fill="both")
  361. font1 = ("Helvetica", 8)
  362. font2 = ("Helvetica", 12) # 10
  363. font3 = ("Helvetica", 12) # 16
  364. font20 = font=("Helvetica", 12) # 22
  365. font120 = font=("Helvetica", 22) # 22
  366. b_scan = Tkinter.Button(fframe,text="clear list",width=8,command=clear,font=font2)
  367. b_scan.pack(side="left",expand=0,fill="y")
  368. b_scan = Tkinter.Button(fframe,text="ArtNetPoll ->",width=10,command=poll,font=font2)
  369. b_scan.configure(bg="#0f0")
  370. b_scan.pack(side="left",expand=0,fill="y")
  371. #POLL ['192.168.0.255', 6454] OK ;
  372. #POLL ['192.168.0.99', 6454] OK ;
  373. #POLL ['2.255.255.255', 6454] OK ;
  374. #POLL ['2.0.0.255', 6454] OK ;
  375. #POLL ['2.255.255.255', 6454] OK ;
  376. local_ips = []
  377. #local_ips.append("2.0.0.255")
  378. cmd='ip a | grep " inet " | cut -d " " -f 6 | sort -h'
  379. r=os.popen(cmd)
  380. print("cmd",cmd)
  381. txt=r.readlines()
  382. for ip in txt:
  383. ip = ip.strip()
  384. print([ip])
  385. if ip.startswith("127."):
  386. continue
  387. if ip.count(".") != 3:
  388. continue
  389. if ip.endswith("/24"):
  390. ip = ip.split(".")
  391. ip = ".".join(ip[:3])+".255"
  392. elif ip.endswith("/8"):
  393. ip = ip.split(".")
  394. ip = ".".join(ip[0])+".255.255.255"
  395. else:
  396. continue
  397. print("-",ip)
  398. if ip == "2.255.255.255":
  399. print("- workaround -")
  400. local_ips.append("2.0.0.255")
  401. local_ips.append(ip)
  402. #local_ips.sort()
  403. option_list=local_ips
  404. p_variable = Tkinter.StringVar(root)
  405. p_variable.set(option_list[0]) # default value
  406. e_poll_new = Tkinter.OptionMenu(fframe, p_variable,*option_list)
  407. e_poll_new.configure(font=("Helvetica", 13))
  408. e_poll_new.configure(width=16)
  409. e_poll_new["bg"] = "#fff"
  410. #print(dir(e_poll_new))
  411. e_poll_new.option_add("end","") #', 'option_clear', 'option_get
  412. e_poll_new.option_add("end","215.0.0.0")
  413. e_poll_new.pack(side="left")
  414. #exit()
  415. b_scan = Tkinter.Button(fframe,text="Librelight:",font=font2,relief="flat",bg="orange")
  416. b_scan.pack(side="left",expand=0)
  417. b_scan = Tkinter.Button(fframe,text="KILL !",command=kill_librelight,width=6,font=font2,bg="red")
  418. b_scan.pack(side="left",expand=0)
  419. b_scan = Tkinter.Button(fframe,text="START ",command=start_librelight,width=6,font=font2,bg="green")
  420. b_scan.pack(side="left",expand=0)
  421. scrollbar = Tkinter.Scrollbar(cframe)
  422. scrollbar.pack(side=Tkinter.RIGHT, fill="y")
  423. #pool = Tkinter.Listbox(root,selectmode="extended",exportselection=0)
  424. li_nodes = Tkinter.Listbox(cframe,exportselection=0,width=35,font=font1)
  425. li_nodes.pack(side="left",expand=0,fill="y")
  426. li_nodes.bind("<ButtonRelease-1>",load )
  427. li_nodes.config(yscrollcommand=scrollbar.set)
  428. scrollbar.config(command=li_nodes.yview)
  429. eframe = Tkinter.Frame(cframe)
  430. eframe.pack(side="left",expand=0,fill="y")
  431. eframe1 = Tkinter.Frame(cframe)
  432. eframe1.pack(side="left",expand=0,fill="y")
  433. # ----------------------------------------------
  434. line_frame = Tkinter.Frame(eframe)
  435. line_frame.pack(side="top",expand=0,fill="x")
  436. x=Tkinter.Label(line_frame,text=" ",font=font2,width=6)
  437. c= Tkinter.Label(line_frame,text=" ",font=font1,width=30,anchor="w")
  438. c.pack(side="left",expand=0,fill="y")
  439. # ----------------------------------------------
  440. # ----------------------------------------------
  441. line_frame = Tkinter.Frame(eframe)
  442. line_frame.pack(side="top",expand=0,fill="x")
  443. x=Tkinter.Label(line_frame,text="MSG:",font=font3,width=6)
  444. x.pack(side="left",expand=0,fill="y")
  445. x.configure(bg="darkgrey")
  446. MSG = Tkinter.Label(line_frame,text="xxx",font=font1,width=30,anchor="w")
  447. MSG.pack(side="left",expand=0,fill="y")
  448. MSG.configure(bg="darkgrey")
  449. #msg["bg"] = "lightgrey"
  450. #msg.pack(side="left")
  451. # ----------------------------------------------
  452. line_frame = Tkinter.Frame(eframe)
  453. line_frame.pack(side="top",expand=0,fill="x")
  454. c= Tkinter.Label(line_frame,text=" ",font=font120,width=30,anchor="w")
  455. c.pack(side="left",expand=0,fill="y")
  456. # ----------------------------------------------
  457. line_frame = Tkinter.Frame(eframe)
  458. line_frame.pack(side="top",expand=0,fill="x")
  459. Tkinter.Label(line_frame,text="OLD IP:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  460. e_ip = Tkinter.Entry(line_frame,font=font20,width=26,state="disabled")
  461. e_ip["bg"] = "lightgrey"
  462. e_ip.pack(side="left")
  463. #b_scan = Tkinter.Button(line_frame,width=14,font=font3)
  464. #b_scan.pack(side="left",expand=1)
  465. # ----------------------------------------------
  466. line_frame = Tkinter.Frame(eframe)
  467. line_frame.pack(side="top",expand=0,fill="x")
  468. e_ip_label = Tkinter.Label(line_frame,text=" IP:",font=font3,width=6)
  469. e_ip_label.pack(side="left",expand=0,fill="y")
  470. e_ip_new = Tkinter.Entry(line_frame,font=font20,width=26)
  471. e_ip_new.bind("<Return>", set_ip )
  472. e_ip_new.bind("<KP_Enter>", set_ip)
  473. #e_ip_new.bind("<Tab>", update_name)
  474. e_ip_new.bind("<ISO_Left_Tab>", set_ip)
  475. e_ip_new.pack(side="left")
  476. #-------------------------------------------- line
  477. line_frame = Tkinter.Frame(eframe)
  478. line_frame.pack(side="top",expand=0,fill="x")
  479. variable = Tkinter.StringVar(root)
  480. variable.set("255.0.0.0") # default value
  481. Tkinter.Label(line_frame,text="MASK:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  482. e_mask_new = Tkinter.OptionMenu(line_frame, variable,"255.255.255.0","255.0.0.0") #,width=10)
  483. e_mask_new.configure(font=("Helvetica", 12))
  484. e_mask_new.configure(width=23)
  485. e_mask_new["bg"] = "#fff"
  486. #heigh=1,font=("Helvetica", 20)
  487. e_mask_new.pack(side="left")
  488. #e_mask_new.insert("end","255.0.0.0")
  489. #e_mask_new.insert("end","255.255.255.0")
  490. b_scan = Tkinter.Button(line_frame,text="SEND TO NODE",command=set_ip,width=14,font=font1)
  491. b_scan.pack(side="left",expand=0)
  492. #-------------------------------------------- line
  493. line_frame = Tkinter.Frame(eframe)
  494. line_frame.pack(side="top",expand=0,fill="x")
  495. Tkinter.Label(line_frame,text="MAC:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  496. e_mac = Tkinter.Entry(line_frame,width=23,font=font20)
  497. e_mac.pack(side="left")
  498. e_mac["bg"] = "lightgrey"
  499. e_mac2 = Tkinter.Entry(line_frame,width=3,font=font20)
  500. e_mac2.pack(side="left")
  501. e_mac2.bind("<Return>", send_mac )
  502. e_mac2.bind("<KP_Enter>", send_mac)
  503. Tkinter.Button(line_frame,text="SEND TO NODE",command=send_mac,width=14,font=font1).pack(side="left",expand=0)
  504. # ----------------------------------------------
  505. line_frame = Tkinter.Frame(eframe)
  506. line_frame.pack(side="top",expand=0,fill="x")
  507. c= Tkinter.Label(line_frame,text=" ",font=font120,width=30,anchor="w")
  508. c.pack(side="left",expand=0,fill="y")
  509. # ----------------------------------------------
  510. #-------------------------------------------- line
  511. #b_scan = Tkinter.Button(eframe1,width=14,font=font3)
  512. #b_scan.pack(side="top",expand=0)
  513. line_frame = Tkinter.Frame(eframe)
  514. line_frame.pack(side="top",expand=0,fill="x")
  515. Tkinter.Label(line_frame,text="DMX:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  516. b_set_node_pin = Tkinter.Button(line_frame,text="HW-PIN",command=set_node_pin,width=6,font=font3)
  517. b_set_node_pin.pack(side="left",expand=0)
  518. b_set_node_in = Tkinter.Button(line_frame,text="IN",command=set_node_in,width=6,font=font3)
  519. b_set_node_in.pack(side="left",expand=0)
  520. b_set_node_out = Tkinter.Button(line_frame,text="OUT",command=set_node_out,width=6,font=font3)
  521. b_set_node_out.pack(side="left",expand=0)
  522. #-------------------------------------------- line
  523. line_frame = Tkinter.Frame(eframe)
  524. line_frame.pack(side="top",expand=0,fill="x")
  525. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  526. e_cmd = Tkinter.Entry(line_frame,font=font3,width=26)
  527. e_cmd.bind("<Return>", send_cmd )
  528. e_cmd.pack(side="left")
  529. #-------------------------------------------- line
  530. line_frame = Tkinter.Frame(eframe)
  531. line_frame.pack(side="top",expand=0,fill="x")
  532. Tkinter.Label(line_frame,text="LName",font=font3,width=6).pack(side="left",expand=0,fill="y")
  533. e_lname = Tkinter.Entry(line_frame,font=font3,width=26)
  534. e_lname.pack(side="left")
  535. #-------------------------------------------- line
  536. line_frame = Tkinter.Frame(eframe)
  537. line_frame.pack(side="top",expand=0,fill="x")
  538. Tkinter.Label(line_frame,text="SName",font=font3,width=6).pack(side="left",expand=0,fill="y")
  539. e_sname = Tkinter.Entry(line_frame,font=font3,width=26)
  540. e_sname.pack(side="left")
  541. #-------------------------------------------- line
  542. line_frame = Tkinter.Frame(eframe)
  543. line_frame.pack(side="top",expand=0,fill="x")
  544. Tkinter.Label(line_frame,text="ArtNet",font=font3,width=6).pack(side="left",expand=0,fill="y")
  545. Tkinter.Label(line_frame,text="SUB:",font=font3,width=4).pack(side="left",expand=0,fill="y")
  546. e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4,state="disabled")
  547. e_artnet_uni1.pack(side="left")
  548. Tkinter.Label(line_frame,text="NET:",font=font3,width=4).pack(side="left",expand=0,fill="y")
  549. e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4,state="disabled")
  550. e_artnet_uni1.pack(side="left")
  551. Tkinter.Label(line_frame,text="UNI:",font=font3,width=4).pack(side="left",expand=0,fill="y")
  552. e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4)
  553. e_artnet_uni1.pack(side="left")
  554. Tkinter.Button(line_frame,text="send ArtAddr",command=send_artaddr,width=14,font=font1).pack(side="left",expand=0)
  555. #-------------------------------------------- line
  556. b_scan = Tkinter.Text(eframe,width=20,font=font2)
  557. b_scan.pack(side="top",expand=1,fill="x")
  558. #-------------------------------------------- line
  559. line_frame = Tkinter.Frame(eframe1)
  560. line_frame.pack(side="top",expand=0,fill="x")
  561. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  562. e_cmd2 = Tkinter.Entry(line_frame,font=font3,width=16)
  563. e_cmd2.insert("end","DMX ERASE ")
  564. e_cmd2.bind("<Return>", send_cmd2 )
  565. e_cmd2.pack(side="left")
  566. #-------------------------------------------- line
  567. line_frame = Tkinter.Frame(eframe1)
  568. line_frame.pack(side="top",expand=0,fill="x")
  569. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  570. e_cmd3 = Tkinter.Entry(line_frame,font=font3,width=16)
  571. e_cmd3.insert("end","DMX OUT STORE ")
  572. e_cmd3.bind("<Return>", send_cmd3 )
  573. e_cmd3.pack(side="left")
  574. #-------------------------------------------- line
  575. line_frame = Tkinter.Frame(eframe1)
  576. line_frame.pack(side="top",expand=0,fill="x")
  577. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  578. e_cmd4 = Tkinter.Entry(line_frame,font=font3,width=16)
  579. e_cmd4.insert("end","DMX OUT SET 2")
  580. e_cmd4.bind("<Return>", send_cmd4 )
  581. e_cmd4.pack(side="left")
  582. #-------------------------------------------- line
  583. line_frame = Tkinter.Frame(eframe1)
  584. line_frame.pack(side="top",expand=0,fill="x")
  585. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  586. e_cmd5 = Tkinter.Entry(line_frame,font=font3,width=16)
  587. e_cmd5.insert("end","REBOOT ")
  588. e_cmd5.bind("<Return>", send_cmd5 )
  589. e_cmd5.pack(side="left")
  590. thread.start_new_thread(_scan, () )
  591. nodescan.bind_cmd_node()
  592. def read_cmd_buf():
  593. b_scan.insert("end", "log:\n" )
  594. while 1:
  595. if nodescan.node_cmd_buf_list:
  596. msg = str(nodescan.node_cmd_buf_list)
  597. print("read_cmd_buf msg",msg)
  598. nodescan.node_cmd_buf_list = []
  599. stamp = str(time.time())+"\n"
  600. stamp = time.strftime("%Y-%m-%d %X\n")
  601. b_scan.insert("end",stamp)
  602. b_scan.insert("end", msg +"\n")
  603. b_scan.see("end")
  604. time.sleep(0.1)
  605. #thread.start_new_thread(nodescan.node_cmd_recive, () )
  606. #thread.start_new_thread(read_cmd_buf, () )
  607. def _update():
  608. while 1:
  609. time.sleep(1)
  610. root.update_idletasks()
  611. def X():
  612. thread.start_new_thread(nodescan.node_cmd_recive, () )
  613. thread.start_new_thread(read_cmd_buf, () )
  614. thread.start_new_thread(_update, () )
  615. #thread.start_new_thread(node_cmd_recive, () )
  616. #send_node_cmd(ip=(2,0,0,91),cmd="DMX OUT STORE")
  617. ##nodescan.send_node_cmd(ip=(2,255,255,255),cmd="CMD GT ")
  618. #nodescan.send_node_cmd(ip,cmd=cmd)
  619. #rx.loop()
  620. z = 0
  621. time.sleep(1)
  622. poll()
  623. while 1:
  624. nodes = rx.get()
  625. #print(len(nodes))
  626. if z % 10 == 0:
  627. pass
  628. print("----")
  629. #MSG["text"] = ""
  630. #MSG["bg"] = "grey"
  631. #pass#print("node count",len(nodes),rx.tick())
  632. #for node in nodes:
  633. # print(node["MAC"],node["lname"])
  634. z += 1
  635. time.sleep(0.2)
  636. print()
  637. print("time out")
  638. raw_input("ENDE")
  639. thread.start_new_thread(X,()) #node_cmd_recive, () )
  640. root.mainloop()