tk-nodescan_v7.3.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. #! /usr/bin/python
  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, either version 2 of the License, or
  8. (at your option) any later version.
  9. librelight is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with librelight. If not, see <http://www.gnu.org/licenses/>.
  15. (c) 2012 micha.rathfelder@gmail.com
  16. """
  17. import time
  18. import struct
  19. import sys
  20. import tkinter as Tkinter
  21. import _thread as thread
  22. import nodescan_v6_2 as nodscaner
  23. title = "TK-ArtNet-Nodscaner"
  24. sys.stdout.write("\x1b]2;"+title+"\x07")
  25. node_list = []
  26. def load(event):
  27. sel = int( li_nodes.curselection()[0] )
  28. print("li_nodes.get")
  29. try:
  30. sel = int(li_nodes.get(sel).split()[0])
  31. print(sel)
  32. except:
  33. return 0
  34. sel -= 1
  35. node_list[sel]
  36. clear_entry_ip()
  37. e_ip.configure(state='normal')
  38. e_ip.insert("end",node_list[sel]["IP"].replace("[","").replace("]",""))
  39. #e_ip.configure(state='readonly')
  40. e_ip_new.insert("end",node_list[sel]["IP"].replace("[","").replace("]",""))
  41. e_mac.delete("0","end")
  42. e_mac.insert("end",node_list[sel]["MAC"].replace("[","").replace("]",""))
  43. e_mac2.delete("0","end")
  44. e_mac2.insert("end",node_list[sel]["MAC"].split(":")[-1])
  45. print("load",node_list[sel])
  46. e_lname.delete("0","end")
  47. e_lname.insert("end",node_list[sel]["lname"])
  48. e_sname.delete("0","end")
  49. e_sname.insert("end",node_list[sel]["sname"])
  50. e_artnet_uni1.delete("0","end")
  51. univ = "0"
  52. print("tttttttttttttttttttttttttttttttttttttttt")
  53. try:
  54. if node_list[sel]["PortTypes"][0] == "@":
  55. univ = ord(node_list[sel]["SwIn"][0])
  56. else:
  57. univ = ord(node_list[sel]["SwOut"][0])
  58. except Exception as e:
  59. print("load Exception",e)
  60. e_artnet_uni1.insert("end",univ)
  61. def clear_entry_ip():
  62. e_ip.configure(state='normal')
  63. e_ip.delete("0","end")
  64. e_ip.configure(state='readonly')
  65. e_ip_new.delete("0","end")
  66. def clear_node():
  67. global node_list
  68. li_nodes.delete("0","end")
  69. node_list = []
  70. li_nodes.delete("0","end")
  71. def poll(delay=1):
  72. global old_tick
  73. clear_entry_ip()
  74. clear_node()
  75. time.sleep(delay)
  76. nodscaner.poll()
  77. time.sleep(0.5)
  78. old_tick = 0
  79. def clear(event= None):
  80. global rx
  81. rx.clear()
  82. clear_node()
  83. #poll()
  84. def poll_loop(sleep):
  85. if sleep < 1:
  86. sleep = 1
  87. time.sleep(sleep)
  88. while 1:
  89. poll()
  90. time.sleep(sleep)
  91. old_tick = 0
  92. rx = nodscaner.ArtNetNodes()
  93. def _scan():
  94. global rx,node_list,old_tick,Scrollbar
  95. rx.loop()
  96. print("get node from cache " )
  97. li_nodes.insert("end",str("----"))
  98. while 1:
  99. nodes = rx.get()
  100. new_tick = rx.tick()
  101. if new_tick == old_tick:
  102. continue
  103. old_tick = new_tick
  104. #print("node",nodes)
  105. if nodes:
  106. li_node_scroll = li_nodes.yview()
  107. #clear_node()
  108. #li_nodes.delete(0,"end")
  109. #print("yea",len(nodes))
  110. node_nr = 1
  111. nodesB = {}
  112. for node in nodes:
  113. k = node["MAC"]
  114. nodesB[k] = node
  115. print("k",nodesB.keys())
  116. #for node in nodes:
  117. #for k,node in nodesB.items():
  118. k_sort = list(nodesB.keys())
  119. k_sort.sort()
  120. print("k sort",k_sort)
  121. for k in k_sort:
  122. node = nodesB[k]
  123. li_nodes.insert("end",str(node_nr).rjust(3," ") +" "+ node["lname"])
  124. bg = "lightgrey"
  125. color = li_nodes.itemconfig("end", bg=bg)
  126. ip = str(node_nr).rjust(3," ") +" "+ node["IP"]
  127. bg = ""
  128. if node["PortTypes"][0] == "@":
  129. ip += " DMX-in"
  130. bg ="yellow"
  131. else:
  132. ip += " DMX-out"
  133. bg ="lightgreen"
  134. if bg:
  135. color = li_nodes.itemconfig("end", bg=bg)
  136. li_nodes.insert("end",str(node_nr).rjust(3," ") +" short Name:"+ node["sname"])
  137. li_nodes.insert("end",ip)
  138. if bg:
  139. color = li_nodes.itemconfig("end", bg=bg)
  140. inout = " UNIVERS OUT="+ str(ord(node["SwOut"][0]))+" IN="+ str(ord(node["SwIn"][0]))
  141. li_nodes.insert("end",str(node_nr).rjust(3," ") + inout)
  142. li_nodes.insert("end",str(node_nr).rjust(3," ") +" MAC:"+ node["MAC"])
  143. timeline = ""
  144. timeline += " LASTCHANGE:%0.1f"% (time.time()-float(node["UPDATESTAMP"]) )
  145. REFRESHSTAMP = time.time()-float(node["REFRESHSTAMP"])
  146. timeline +=" LASTPING:%0.1f"% REFRESHSTAMP
  147. li_nodes.insert("end",str(node_nr).rjust(3," ") +timeline )
  148. if node["BOOT"]:
  149. BOOT = time.time()-float(node["BOOT"])
  150. else:
  151. BOOT = 0
  152. timeline =" BOOT:%0.1f"% BOOT
  153. li_nodes.insert("end",str(node_nr).rjust(3," ") +timeline +" sec" )
  154. bg = ""
  155. #if REFRESHSTAMP > 5 :
  156. # bg="red"
  157. #else:
  158. # bg="lightgreen"
  159. if bg:
  160. li_nodes.itemconfig("end", bg=bg)
  161. #li_nodes.insert("end",str(node_nr).rjust(3," ")
  162. #li_nodes.insert("end","")
  163. li_nodes.insert("end","*"*60)
  164. #li_nodes.itemconfig("end", bg="brown")
  165. node_nr += 1
  166. node_list += [node]
  167. #Scrollbar.set('0', '0.1')
  168. print(li_node_scroll)
  169. #print(dir(li_nodes))
  170. #li_node_scroll = int(li_node_scroll[0])
  171. #li_nodes.yview_moveto(li_node_scroll)
  172. time.sleep(0.2)
  173. def get_new_ip(event=None):
  174. b = e_ip_new.get().replace("[","").replace("]","")
  175. return b
  176. def get_new_ip_str(event=None):
  177. x = get_new_ip()
  178. #x = x[1:-1]
  179. x = x.strip()
  180. #x = x.replace(",",".")
  181. x = x.replace(" ","")
  182. x = x.split(",")
  183. print( "get_new_ip_str",x)
  184. return x
  185. def send_artaddr(event=None):
  186. ln = e_lname.get()
  187. sn = e_sname.get()
  188. ip = e_ip_new.get()
  189. ip = ip.replace(" ","")
  190. ip = ip.replace(",",".")
  191. univ = e_artnet_uni1.get()
  192. print("SEND ArtAddress:",[ln,sn,ip,univ])
  193. if ln and sn and ip and univ:
  194. nodscaner.ArtAddress(ip=ip ,ShortName=sn, LongName=ln,Port="",Universes=univ)
  195. def send_none(event=None):
  196. pass
  197. def send_mac(event=None):
  198. #new_mac = "CMD MAC6 " + hex(e_mac2.get()) #)
  199. #new_mac = "CMD MAC6 " + struct.pack("<B",(int(e_mac2.get(),16))).decode()
  200. new_mac = b"CMD MAC6 " + struct.pack("<B",(int(e_mac2.get(),16)))
  201. a = e_ip.get().replace("[","").replace("]","")
  202. cur_ip = []
  203. for i in a.split(","):
  204. cur_ip +=[int(i)]
  205. print("SEND MAC:",cur_ip,new_mac)
  206. nodscaner.send_node_cmd(cur_ip,cmd=new_mac)
  207. #poll(1.5)
  208. def send_dmx_store(event=None):
  209. cmd = "CMD DMX STORE "
  210. a = e_ip.get().replace("[","").replace("]","")
  211. cur_ip = []
  212. for i in a.split(","):
  213. cur_ip +=[int(i)]
  214. print("SEND:",cur_ip,cmd)
  215. nodscaner.send_node_cmd(cur_ip,cmd)
  216. poll(1.5)
  217. def send_cmd(event=None):
  218. cmd = e_cmd.get() #"CMD DMX STORE "
  219. _send_cmd(cmd=cmd)
  220. def send_cmd2(event=None):
  221. cmd = e_cmd2.get() #"CMD DMX STORE "
  222. _send_cmd(cmd=cmd)
  223. def send_cmd3(event=None):
  224. cmd = e_cmd3.get() #"CMD DMX STORE "
  225. _send_cmd(cmd=cmd)
  226. def send_cmd4(event=None):
  227. cmd = e_cmd4.get() #"CMD DMX STORE "
  228. _send_cmd(cmd=cmd)
  229. def send_cmd5(event=None):
  230. cmd = e_cmd5.get() #"CMD DMX STORE "
  231. _send_cmd(cmd=cmd)
  232. def _send_cmd(event=None,cmd=""):
  233. #cmd = e_cmd.get() #"CMD DMX STORE "
  234. cmd = cmd.split(" ")
  235. value = cmd[-1]
  236. try:
  237. value = struct.pack("<B",int(value))
  238. except:pass
  239. cmd = cmd[:-1] #.append(value)
  240. cmd.append(value)
  241. print("_send_cmd:",cmd)
  242. cmd=" ".join(map(str,cmd) )
  243. a = e_ip.get().replace("[","").replace("]","")
  244. cur_ip = []
  245. sep = "xx"
  246. if "," in a:
  247. sep = ","
  248. if "." in a:
  249. sep = "."
  250. for i in a.split(sep):
  251. cur_ip +=[int(i)]
  252. print("SEND:",cur_ip,cmd)
  253. nodscaner.send_node_cmd(cur_ip,cmd)
  254. #poll(1.5)
  255. def set_ip(event=None):
  256. print("SET NEW IP")
  257. cur_ip=(2,0,0,94)
  258. new_ip=(2,0,0,201)
  259. new_netmask=(255,0,0,0)
  260. a = e_ip.get().replace("[","").replace("]","")
  261. b = e_ip_new.get().replace("[","").replace("]","")
  262. c = variable.get() #e_mask_new.get()
  263. new_netmask = [] #c.split(".") #list(c)
  264. for i in c.split("."):
  265. new_netmask +=[int(i)]
  266. cur_ip = []
  267. for i in a.split(","):
  268. cur_ip +=[int(i)]
  269. new_ip = []
  270. for i in b.split(","):
  271. new_ip +=[int(i)]
  272. if new_ip == cur_ip:
  273. print("neu und als IP sind gleich" )
  274. return 0
  275. #cur_ip=(2,0,0,94)
  276. #new_ip=(2,0,0,201)
  277. print("new",[cur_ip, new_ip, new_netmask])
  278. print()
  279. nodscaner.set_ip4(cur_ip,new_ip, new_netmask)
  280. poll(1.5)
  281. def set_node_pin(evnet=None):
  282. cmd = "CMD DMX=PIN"
  283. ip = get_new_ip_str()
  284. print("ip",[ip])
  285. nodscaner.send_node_cmd(ip,cmd=cmd)
  286. poll(1.5)
  287. def set_node_in(evnet=None):
  288. cmd="CMD DMX=IN"
  289. ip = get_new_ip_str()
  290. nodscaner.send_node_cmd(ip,cmd=cmd)
  291. poll(1.5)
  292. def set_node_out(evnet=None):
  293. cmd="CMD DMX=OUT"
  294. ip = get_new_ip_str()
  295. nodscaner.send_node_cmd(ip,cmd=cmd)
  296. poll(1.5)
  297. root = Tkinter.Tk()
  298. #root.geometry("900x700+100+100")
  299. root.geometry("900x400+100+100")
  300. root.title( title)
  301. fframe = Tkinter.Frame(root)
  302. fframe.pack(side="top",expand=0,fill="x")
  303. cframe = Tkinter.Frame(root)
  304. cframe.pack(side="top",expand=1,fill="both")
  305. font1 = ("Helvetica", 8)
  306. font2 = ("Helvetica", 10)
  307. font3 = ("Helvetica", 16)
  308. font20 = font=("Helvetica", 20)
  309. b_scan = Tkinter.Button(fframe,text="ArtNetPoll",width=10,command=poll,font=font2)
  310. b_scan.pack(side="left",expand=0,fill="y")
  311. b_scan = Tkinter.Button(fframe,text="clear",width=10,command=clear,font=font2)
  312. b_scan.pack(side="left",expand=0,fill="y")
  313. scrollbar = Tkinter.Scrollbar(cframe)
  314. scrollbar.pack(side=Tkinter.RIGHT, fill="y")
  315. #pool = Tkinter.Listbox(root,selectmode="extended",exportselection=0)
  316. li_nodes = Tkinter.Listbox(cframe,exportselection=0,width=35,font=font1)
  317. li_nodes.pack(side="left",expand=0,fill="y")
  318. li_nodes.bind("<ButtonRelease-1>",load )
  319. li_nodes.config(yscrollcommand=scrollbar.set)
  320. scrollbar.config(command=li_nodes.yview)
  321. eframe = Tkinter.Frame(cframe)
  322. eframe.pack(side="left",expand=0,fill="y")
  323. eframe1 = Tkinter.Frame(cframe)
  324. eframe1.pack(side="left",expand=0,fill="y")
  325. # ----------------------------------------------
  326. line_frame = Tkinter.Frame(eframe)
  327. line_frame.pack(side="top",expand=0,fill="x")
  328. Tkinter.Label(line_frame,text="OLD IP:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  329. e_ip = Tkinter.Entry(line_frame,font=font20,width=13,state="disabled")
  330. e_ip["bg"] = "lightgrey"
  331. e_ip.pack(side="left")
  332. #b_scan = Tkinter.Button(line_frame,width=14,font=font3)
  333. #b_scan.pack(side="left",expand=1)
  334. # ----------------------------------------------
  335. line_frame = Tkinter.Frame(eframe)
  336. line_frame.pack(side="top",expand=0,fill="x")
  337. e_ip_label = Tkinter.Label(line_frame,text=" IP:",font=font3,width=6)
  338. e_ip_label.pack(side="left",expand=0,fill="y")
  339. e_ip_new = Tkinter.Entry(line_frame,font=font20,width=13)
  340. e_ip_new.bind("<Return>", set_ip )
  341. e_ip_new.bind("<KP_Enter>", set_ip)
  342. #e_ip_new.bind("<Tab>", update_name)
  343. e_ip_new.bind("<ISO_Left_Tab>", set_ip)
  344. e_ip_new.pack(side="left")
  345. #-------------------------------------------- line
  346. line_frame = Tkinter.Frame(eframe)
  347. line_frame.pack(side="top",expand=0,fill="x")
  348. variable = Tkinter.StringVar(root)
  349. variable.set("255.0.0.0") # default value
  350. Tkinter.Label(line_frame,text="MASK",font=font3,width=6).pack(side="left",expand=0,fill="y")
  351. e_mask_new = Tkinter.OptionMenu(line_frame, variable,"255.255.255.0","255.0.0.0") #,width=10)
  352. e_mask_new.configure(font=("Helvetica", 22))
  353. e_mask_new.configure(width=10)
  354. e_mask_new["bg"] = "#fff"
  355. #heigh=1,font=("Helvetica", 20)
  356. e_mask_new.pack(side="left")
  357. #e_mask_new.insert("end","255.0.0.0")
  358. #e_mask_new.insert("end","255.255.255.0")
  359. b_scan = Tkinter.Button(line_frame,text="SEND TO NODE",command=set_ip,width=14,font=font1)
  360. b_scan.pack(side="left",expand=0)
  361. #-------------------------------------------- line
  362. line_frame = Tkinter.Frame(eframe)
  363. line_frame.pack(side="top",expand=0,fill="x")
  364. Tkinter.Label(line_frame,text="MAC:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  365. e_mac = Tkinter.Entry(line_frame,width=13,font=font20)
  366. e_mac.pack(side="left")
  367. e_mac["bg"] = "lightgrey"
  368. e_mac2 = Tkinter.Entry(line_frame,width=3,font=font20)
  369. e_mac2.pack(side="left")
  370. e_mac2.bind("<Return>", send_mac )
  371. e_mac2.bind("<KP_Enter>", send_mac)
  372. Tkinter.Button(line_frame,text="SEND TO NODE",command=send_mac,width=14,font=font1).pack(side="left",expand=0)
  373. #-------------------------------------------- line
  374. #b_scan = Tkinter.Button(eframe1,width=14,font=font3)
  375. #b_scan.pack(side="top",expand=0)
  376. line_frame = Tkinter.Frame(eframe)
  377. line_frame.pack(side="top",expand=0,fill="x")
  378. Tkinter.Label(line_frame,text="DMX:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  379. b_set_node_pin = Tkinter.Button(line_frame,text="HW-PIN",command=set_node_pin,width=6,font=font3)
  380. b_set_node_pin.pack(side="left",expand=0)
  381. b_set_node_in = Tkinter.Button(line_frame,text="IN",command=set_node_in,width=6,font=font3)
  382. b_set_node_in.pack(side="left",expand=0)
  383. b_set_node_out = Tkinter.Button(line_frame,text="OUT",command=set_node_out,width=6,font=font3)
  384. b_set_node_out.pack(side="left",expand=0)
  385. #-------------------------------------------- line
  386. line_frame = Tkinter.Frame(eframe)
  387. line_frame.pack(side="top",expand=0,fill="x")
  388. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  389. e_cmd = Tkinter.Entry(line_frame,font=font3,width=16)
  390. e_cmd.bind("<Return>", send_cmd )
  391. e_cmd.pack(side="left")
  392. #-------------------------------------------- line
  393. line_frame = Tkinter.Frame(eframe)
  394. line_frame.pack(side="top",expand=0,fill="x")
  395. Tkinter.Label(line_frame,text="LName",font=font3,width=6).pack(side="left",expand=0,fill="y")
  396. e_lname = Tkinter.Entry(line_frame,font=font3,width=26)
  397. e_lname.pack(side="left")
  398. #-------------------------------------------- line
  399. line_frame = Tkinter.Frame(eframe)
  400. line_frame.pack(side="top",expand=0,fill="x")
  401. Tkinter.Label(line_frame,text="SName",font=font3,width=6).pack(side="left",expand=0,fill="y")
  402. e_sname = Tkinter.Entry(line_frame,font=font3,width=16)
  403. e_sname.pack(side="left")
  404. #-------------------------------------------- line
  405. line_frame = Tkinter.Frame(eframe)
  406. line_frame.pack(side="top",expand=0,fill="x")
  407. Tkinter.Label(line_frame,text="ArtNet",font=font3,width=6).pack(side="left",expand=0,fill="y")
  408. Tkinter.Label(line_frame,text="SUB:",font=font3,width=4).pack(side="left",expand=0,fill="y")
  409. e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4,state="disabled")
  410. e_artnet_uni1.pack(side="left")
  411. Tkinter.Label(line_frame,text="NET:",font=font3,width=4).pack(side="left",expand=0,fill="y")
  412. e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4,state="disabled")
  413. e_artnet_uni1.pack(side="left")
  414. Tkinter.Label(line_frame,text="UNI:",font=font3,width=4).pack(side="left",expand=0,fill="y")
  415. e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4)
  416. e_artnet_uni1.pack(side="left")
  417. Tkinter.Button(line_frame,text="send ArtAddr",command=send_artaddr,width=14,font=font1).pack(side="left",expand=0)
  418. #-------------------------------------------- line
  419. b_scan = Tkinter.Text(eframe,width=20,font=font2)
  420. b_scan.pack(side="top",expand=1,fill="x")
  421. #-------------------------------------------- line
  422. line_frame = Tkinter.Frame(eframe1)
  423. line_frame.pack(side="top",expand=0,fill="x")
  424. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  425. e_cmd2 = Tkinter.Entry(line_frame,font=font3,width=16)
  426. e_cmd2.insert("end","DMX ERASE ")
  427. e_cmd2.bind("<Return>", send_cmd2 )
  428. e_cmd2.pack(side="left")
  429. #-------------------------------------------- line
  430. line_frame = Tkinter.Frame(eframe1)
  431. line_frame.pack(side="top",expand=0,fill="x")
  432. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  433. e_cmd3 = Tkinter.Entry(line_frame,font=font3,width=16)
  434. e_cmd3.insert("end","DMX OUT STORE ")
  435. e_cmd3.bind("<Return>", send_cmd3 )
  436. e_cmd3.pack(side="left")
  437. #-------------------------------------------- line
  438. line_frame = Tkinter.Frame(eframe1)
  439. line_frame.pack(side="top",expand=0,fill="x")
  440. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  441. e_cmd4 = Tkinter.Entry(line_frame,font=font3,width=16)
  442. e_cmd4.insert("end","DMX OUT SET 2")
  443. e_cmd4.bind("<Return>", send_cmd4 )
  444. e_cmd4.pack(side="left")
  445. #-------------------------------------------- line
  446. line_frame = Tkinter.Frame(eframe1)
  447. line_frame.pack(side="top",expand=0,fill="x")
  448. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  449. e_cmd5 = Tkinter.Entry(line_frame,font=font3,width=16)
  450. e_cmd5.insert("end","REBOOT ")
  451. e_cmd5.bind("<Return>", send_cmd5 )
  452. e_cmd5.pack(side="left")
  453. thread.start_new_thread(_scan, () )
  454. nodscaner.bind_cmd_node()
  455. def read_cmd_buf():
  456. b_scan.insert("end", "buf read\n" )
  457. while 1:
  458. if nodscaner.node_cmd_buf_list:
  459. msg = str(nodscaner.node_cmd_buf_list)
  460. print("read_cmd_buf msg",msg)
  461. nodscaner.node_cmd_buf_list = []
  462. stamp = str(time.time())+"\n"
  463. stamp = time.strftime("%Y-%m-%d %X\n")
  464. b_scan.insert("end",stamp)
  465. b_scan.insert("end", msg +"\n")
  466. b_scan.see("end")
  467. time.sleep(0.1)
  468. #thread.start_new_thread(nodscaner.node_cmd_recive, () )
  469. #thread.start_new_thread(read_cmd_buf, () )
  470. def _update():
  471. while 1:
  472. time.sleep(1)
  473. root.update_idletasks()
  474. def X():
  475. thread.start_new_thread(nodscaner.node_cmd_recive, () )
  476. thread.start_new_thread(read_cmd_buf, () )
  477. thread.start_new_thread(_update, () )
  478. #thread.start_new_thread(node_cmd_recive, () )
  479. #send_node_cmd(ip=(2,0,0,91),cmd="DMX OUT STORE")
  480. ##nodscaner.send_node_cmd(ip=(2,255,255,255),cmd="CMD GT ")
  481. #nodscaner.send_node_cmd(ip,cmd=cmd)
  482. #rx.loop()
  483. z = 0
  484. #poll()
  485. while 1:
  486. nodes = rx.get()
  487. #print(len(nodes))
  488. if z % 10 == 0:
  489. pass
  490. #print("----")
  491. #pass#print("node count",len(nodes),rx.tick())
  492. #for node in nodes:
  493. # print(node["MAC"],node["lname"])
  494. z += 1
  495. time.sleep(0.2)
  496. print()
  497. print("time out")
  498. raw_input("ENDE")
  499. thread.start_new_thread(X,()) #node_cmd_recive, () )
  500. root.mainloop()