|
@@ -16,58 +16,84 @@ import tkinter as Tkinter
|
|
|
import _thread as thread
|
|
|
|
|
|
import nodescan
|
|
|
+#import nodescan2 #as nodescaner
|
|
|
|
|
|
title = "TK-ArtNet-Nodscaner"
|
|
|
sys.stdout.write("\x1b]2;"+title+"\x07")
|
|
|
|
|
|
-node_list = []
|
|
|
-def load(event=None):
|
|
|
- print()
|
|
|
- print("load()")
|
|
|
- #time.sleep(1)
|
|
|
+#lock.acquire()
|
|
|
+#lock.release()
|
|
|
+class LOCK_BUF():
|
|
|
+ def __init__(self):
|
|
|
+ self.data = []
|
|
|
+ self.lock = thread.allocate_lock()
|
|
|
+ def append(self,data):
|
|
|
+ try:
|
|
|
+ self.lock.acquire()
|
|
|
+ self.data.append(data)
|
|
|
+ finally:
|
|
|
+ self.lock.release()
|
|
|
+ def set(self,data):
|
|
|
+ try:
|
|
|
+ self.lock.acquire()
|
|
|
+ self.data = data[:]
|
|
|
+ finally:
|
|
|
+ self.lock.release()
|
|
|
+ def get(self):
|
|
|
+ out = []
|
|
|
+ try:
|
|
|
+ self.lock.acquire()
|
|
|
+ out = self.data[:]
|
|
|
+ finally:
|
|
|
+ self.lock.release()
|
|
|
+ return out
|
|
|
|
|
|
- for n in node_list:
|
|
|
- print("-",n)
|
|
|
- print("+++++")
|
|
|
+node_list = LOCK_BUF() #[]
|
|
|
|
|
|
- if len( li_nodes.curselection() ) < 1:
|
|
|
- print("NO sel: li_nodes.curselection()")
|
|
|
- return 0
|
|
|
- sel = int( li_nodes.curselection()[0] )
|
|
|
- print("li_nodes.get")
|
|
|
+def fill_form(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
+ global node_list
|
|
|
+ clear_form()
|
|
|
+
|
|
|
+ node_list2 = node_list.get()
|
|
|
+ sel=0
|
|
|
+ csel = li_nodes.curselection()[0]
|
|
|
+ print("+++",[csel,len(node_list2)])
|
|
|
+
|
|
|
+ sel = int(li_nodes.get(csel).split()[0])-1
|
|
|
try:
|
|
|
- sel = int(li_nodes.get(sel).split()[0])
|
|
|
+ sel = int(li_nodes(sel).split()[0])
|
|
|
print(sel)
|
|
|
except:
|
|
|
+ pass#return 0
|
|
|
+
|
|
|
+ if not node_list2:
|
|
|
return 0
|
|
|
- sel -= 1
|
|
|
- node_list[sel]
|
|
|
- clear_entry_ip()
|
|
|
-
|
|
|
+
|
|
|
+ print("INFO: sel,node_list2",sel,len(node_list2))
|
|
|
e_ip.configure(state='normal')
|
|
|
- e_ip.insert("end",node_list[sel]["IP"].replace("[","").replace("]",""))
|
|
|
+ e_ip.insert("end",node_list2[sel]["IP"].replace("[","").replace("]",""))
|
|
|
#e_ip.configure(state='readonly')
|
|
|
|
|
|
- e_ip_new.insert("end",node_list[sel]["IP"].replace("[","").replace("]",""))
|
|
|
+ e_ip_new.insert("end",node_list2[sel]["IP"].replace("[","").replace("]",""))
|
|
|
e_mac.delete("0","end")
|
|
|
- e_mac.insert("end",node_list[sel]["MAC"].replace("[","").replace("]",""))
|
|
|
+ e_mac.insert("end",node_list2[sel]["MAC"].replace("[","").replace("]",""))
|
|
|
e_mac2.delete("0","end")
|
|
|
- e_mac2.insert("end",node_list[sel]["MAC"].split(":")[-1])
|
|
|
+ e_mac2.insert("end",node_list2[sel]["MAC"].split(":")[-1])
|
|
|
|
|
|
- print("load",node_list[sel])
|
|
|
+ print("load",node_list2[sel])
|
|
|
e_lname.delete("0","end")
|
|
|
- e_lname.insert("end",node_list[sel]["lname"])
|
|
|
+ e_lname.insert("end",node_list2[sel]["lname"])
|
|
|
e_sname.delete("0","end")
|
|
|
- e_sname.insert("end",node_list[sel]["sname"])
|
|
|
+ e_sname.insert("end",node_list2[sel]["sname"])
|
|
|
|
|
|
e_artnet_uni1.delete("0","end")
|
|
|
univ = "0"
|
|
|
- print("tttttttttttttttttttttttttttttttttttttttt")
|
|
|
try:
|
|
|
- if node_list[sel]["PortTypes"][0] == "@":
|
|
|
- univ = ord(node_list[sel]["SwIn"][0])
|
|
|
+ if node_list2[sel]["PortTypes"][0] == "@":
|
|
|
+ univ = ord(node_list2[sel]["SwIn"][0])
|
|
|
else:
|
|
|
- univ = ord(node_list[sel]["SwOut"][0])
|
|
|
+ univ = ord(node_list2[sel]["SwOut"][0])
|
|
|
except Exception as e:
|
|
|
print("load Exception",e)
|
|
|
MSG["text"] = e
|
|
@@ -75,30 +101,21 @@ def load(event=None):
|
|
|
e_artnet_uni1.insert("end",univ)
|
|
|
|
|
|
|
|
|
-def clear_entry_ip():
|
|
|
+def clear_form():
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
e_ip.configure(state='normal')
|
|
|
e_ip.delete("0","end")
|
|
|
e_ip.configure(state='readonly')
|
|
|
e_ip_new.delete("0","end")
|
|
|
|
|
|
|
|
|
-def clear_node():
|
|
|
- global node_list
|
|
|
- li_nodes.delete("0","end")
|
|
|
- node_list = []
|
|
|
+def clear_node_list():
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
li_nodes.delete("0","end")
|
|
|
|
|
|
|
|
|
def poll(delay=1,ip=""):
|
|
|
- print("poll()")
|
|
|
- global old_tick
|
|
|
- clear()
|
|
|
-
|
|
|
- clear_entry_ip()
|
|
|
- clear_node()
|
|
|
- #time.sleep(delay)
|
|
|
- #time.sleep(0.5)
|
|
|
-
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
|
|
|
if not ip:
|
|
|
ip = p_variable.get()
|
|
@@ -106,154 +123,144 @@ def poll(delay=1,ip=""):
|
|
|
b_scan.insert("end", "ArtNetPoll -> "+str(ip)+"\n")
|
|
|
nodescan.ArtNet_poll(ip)
|
|
|
time.sleep(1)
|
|
|
- load()
|
|
|
- #return
|
|
|
- #try:
|
|
|
- # nodescan.poll()
|
|
|
- #except Exception as e:
|
|
|
- # print("e",e)
|
|
|
- # MSG["text"] = e
|
|
|
- # MSG["bg"] = "red"
|
|
|
- #time.sleep(0.5)
|
|
|
- #old_tick = 0
|
|
|
+ fill_form()
|
|
|
|
|
|
def clear(event= None):
|
|
|
- print("clear()")
|
|
|
- global rx
|
|
|
- rx.clear()
|
|
|
- clear_node()
|
|
|
- #poll()
|
|
|
- MSG["text"] = ""
|
|
|
- MSG["bg"] = "grey"
|
|
|
- time.sleep(0.1)
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
+ clear_node_list()
|
|
|
+ clear_form()
|
|
|
|
|
|
-def poll_loop(sleep):
|
|
|
- if sleep < 1:
|
|
|
- sleep = 1
|
|
|
- time.sleep(sleep)
|
|
|
+def poll_loop():
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
+ time.sleep(1)
|
|
|
while 1:
|
|
|
poll()
|
|
|
- time.sleep(sleep)
|
|
|
+ time.sleep(1)
|
|
|
|
|
|
old_tick = 0
|
|
|
rx = nodescan.ArtNetNodes()
|
|
|
-
|
|
|
-def _scan():
|
|
|
+#rx = nodescan2
|
|
|
+
|
|
|
+def scan():
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
global rx,node_list,old_tick,Scrollbar
|
|
|
print("get node from cache " )
|
|
|
li_nodes.insert("end",str("----"))
|
|
|
rx.loop()
|
|
|
while 1:
|
|
|
try:
|
|
|
- __scan()
|
|
|
+ _scan()
|
|
|
except Exception as e:
|
|
|
- print("_scan Exception as",e)
|
|
|
+ print("_scan Exception as",e,e.argv[0])
|
|
|
MSG["text"] = e
|
|
|
MSG["bg"] = "red"
|
|
|
- time.sleep(0.1)
|
|
|
+ time.sleep(0.3)
|
|
|
|
|
|
-def __scan():
|
|
|
+def _scan():
|
|
|
+ #print(sys._getframe().f_code.co_name)
|
|
|
global rx,node_list,old_tick,Scrollbar
|
|
|
|
|
|
- while 1:
|
|
|
-
|
|
|
- nodes = rx.get()
|
|
|
- new_tick = rx.tick()
|
|
|
-
|
|
|
- if new_tick == old_tick:
|
|
|
- continue
|
|
|
+ tick = rx.tick()
|
|
|
+ if tick == old_tick:
|
|
|
+ return 0
|
|
|
+ old_tick=tick
|
|
|
|
|
|
- old_tick = new_tick
|
|
|
- #print("node",nodes)
|
|
|
- if nodes:
|
|
|
- print(len(nodes))
|
|
|
- li_node_scroll = li_nodes.yview()
|
|
|
-
|
|
|
- #clear_node()
|
|
|
-
|
|
|
- #li_nodes.delete(0,"end")
|
|
|
- #print("yea",len(nodes))
|
|
|
- node_nr = 1
|
|
|
- nodesB = {}
|
|
|
- for node in nodes:
|
|
|
- k = node["MAC"]
|
|
|
- nodesB[k] = node
|
|
|
- print("k",nodesB.keys())
|
|
|
- #for node in nodes:
|
|
|
- #for k,node in nodesB.items():
|
|
|
- k_sort = list(nodesB.keys())
|
|
|
- k_sort.sort()
|
|
|
- print("k sort",k_sort)
|
|
|
- for k in k_sort:
|
|
|
- node = nodesB[k]
|
|
|
-
|
|
|
- li_nodes.insert("end",str(node_nr).rjust(3," ") +" "+ node["lname"])
|
|
|
- bg = "lightgrey"
|
|
|
- color = li_nodes.itemconfig("end", bg=bg)
|
|
|
- ip = str(node_nr).rjust(3," ") +" "+ node["IP"]
|
|
|
- bg = ""
|
|
|
- if "PortTypes" in node:
|
|
|
- if not node["PortTypes"]:
|
|
|
- pass
|
|
|
- if node["PortTypes"][0] == "@":
|
|
|
- ip += " DMX-in"
|
|
|
- bg ="yellow"
|
|
|
- else:
|
|
|
- ip += " DMX-out"
|
|
|
- bg ="lightgreen"
|
|
|
- if bg:
|
|
|
- color = li_nodes.itemconfig("end", bg=bg)
|
|
|
-
|
|
|
- li_nodes.insert("end",str(node_nr).rjust(3," ") +" short Name:"+ node["sname"])
|
|
|
- li_nodes.insert("end",ip)
|
|
|
- if bg:
|
|
|
- color = li_nodes.itemconfig("end", bg=bg)
|
|
|
-
|
|
|
- inout = " UNIVERS OUT="+ str(ord(node["SwOut"][0]))+" IN="+ str(ord(node["SwIn"][0]))
|
|
|
- li_nodes.insert("end",str(node_nr).rjust(3," ") + inout)
|
|
|
-
|
|
|
- li_nodes.insert("end",str(node_nr).rjust(3," ") +" MAC:"+ node["MAC"])
|
|
|
-
|
|
|
- timeline = ""
|
|
|
- timeline += " LASTCHANGE:%0.1f"% (time.time()-float(node["UPDATESTAMP"]) )
|
|
|
- REFRESHSTAMP = time.time()-float(node["REFRESHSTAMP"])
|
|
|
- timeline +=" LASTPING:%0.1f"% REFRESHSTAMP
|
|
|
- li_nodes.insert("end",str(node_nr).rjust(3," ") +timeline )
|
|
|
-
|
|
|
- if node["BOOT"]:
|
|
|
- BOOT = time.time()-float(node["BOOT"])
|
|
|
- else:
|
|
|
- BOOT = 0
|
|
|
- timeline =" BOOT:%0.1f"% BOOT
|
|
|
- li_nodes.insert("end",str(node_nr).rjust(3," ") +timeline +" sec" )
|
|
|
- bg = ""
|
|
|
- #if REFRESHSTAMP > 5 :
|
|
|
- # bg="red"
|
|
|
- #else:
|
|
|
- # bg="lightgreen"
|
|
|
- if bg:
|
|
|
- li_nodes.itemconfig("end", bg=bg)
|
|
|
- #li_nodes.insert("end",str(node_nr).rjust(3," ")
|
|
|
- #li_nodes.insert("end","")
|
|
|
- li_nodes.insert("end","*"*60)
|
|
|
- #li_nodes.itemconfig("end", bg="brown")
|
|
|
- node_nr += 1
|
|
|
- node_list += [node]
|
|
|
-
|
|
|
- #Scrollbar.set('0', '0.1')
|
|
|
- print(li_node_scroll)
|
|
|
- #print(dir(li_nodes))
|
|
|
- #li_node_scroll = int(li_node_scroll[0])
|
|
|
- #li_nodes.yview_moveto(li_node_scroll)
|
|
|
-
|
|
|
- time.sleep(0.2)
|
|
|
+ nodes = rx.get()
|
|
|
+ rx.clear()
|
|
|
+ ok=0
|
|
|
+ for n in nodes:
|
|
|
+ if n not in node_list.get():
|
|
|
+ node_list.append(n)
|
|
|
+ ok=1
|
|
|
+ if ok:
|
|
|
+ refresh_node_list()
|
|
|
+
|
|
|
+def refresh_node_list():
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
+ #aprint(len(nodes))
|
|
|
+ li_node_scroll = li_nodes.yview()
|
|
|
+
|
|
|
+ li_nodes.delete("0","end")
|
|
|
+ node_nr = 1
|
|
|
+ nodesB = {}
|
|
|
+ for node in node_list.get(): #nodes:
|
|
|
+ k = node["MAC"]
|
|
|
+ nodesB[k] = node
|
|
|
+
|
|
|
+ print("k",nodesB.keys())
|
|
|
+
|
|
|
+ k_sort = list(nodesB.keys())
|
|
|
+ k_sort.sort()
|
|
|
+
|
|
|
+ node_list.set([]) # =[]
|
|
|
+ for k in k_sort:
|
|
|
+ node_list.append(nodesB[k])
|
|
|
+
|
|
|
+ print("k sort",k_sort)
|
|
|
+ for k in k_sort:
|
|
|
+ node = nodesB[k]
|
|
|
+
|
|
|
+ li_nodes.insert("end",str(node_nr).rjust(3," ") +" "+ node["lname"])
|
|
|
+ bg = "lightgrey"
|
|
|
+ color = li_nodes.itemconfig("end", bg=bg)
|
|
|
+ ip = str(node_nr).rjust(3," ") +" "+ node["IP"]
|
|
|
+ bg = ""
|
|
|
+ if "PortTypes" in node:
|
|
|
+ if not node["PortTypes"]:
|
|
|
+ pass
|
|
|
+ if node["PortTypes"][0] == "@":
|
|
|
+ ip += " DMX-in"
|
|
|
+ bg ="yellow"
|
|
|
+ else:
|
|
|
+ ip += " DMX-out"
|
|
|
+ bg ="lightgreen"
|
|
|
+ if bg:
|
|
|
+ color = li_nodes.itemconfig("end", bg=bg)
|
|
|
+
|
|
|
+ li_nodes.insert("end",str(node_nr).rjust(3," ") +" short Name:"+ node["sname"])
|
|
|
+ li_nodes.insert("end",ip)
|
|
|
+ if bg:
|
|
|
+ color = li_nodes.itemconfig("end", bg=bg)
|
|
|
+
|
|
|
+ inout = " UNIVERS OUT="+ str(ord(node["SwOut"][0]))+" IN="+ str(ord(node["SwIn"][0]))
|
|
|
+ li_nodes.insert("end",str(node_nr).rjust(3," ") + inout)
|
|
|
+
|
|
|
+ li_nodes.insert("end",str(node_nr).rjust(3," ") +" MAC:"+ node["MAC"])
|
|
|
+
|
|
|
+ last_change=time.time()-float(node["UPDATESTAMP"])
|
|
|
+ timeline = ""
|
|
|
+ timeline += " LASTCHANGE:%0.1f"% (last_change)
|
|
|
+ REFRESHSTAMP = time.time()-float(node["REFRESHSTAMP"])
|
|
|
+ timeline +=" LASTPING:%0.1f"% REFRESHSTAMP
|
|
|
+ li_nodes.insert("end",str(node_nr).rjust(3," ") +timeline )
|
|
|
+ if last_change > 10:
|
|
|
+ color = li_nodes.itemconfig("end", bg="ORANGE")
|
|
|
+
|
|
|
+ if node["BOOT"]:
|
|
|
+ BOOT = time.time()-float(node["BOOT"])
|
|
|
+ else:
|
|
|
+ BOOT = 0
|
|
|
+ timeline =" BOOT:%0.1f"% BOOT
|
|
|
+ li_nodes.insert("end",str(node_nr).rjust(3," ") +timeline +" sec" )
|
|
|
+ bg = ""
|
|
|
+
|
|
|
+ if bg:
|
|
|
+ li_nodes.itemconfig("end", bg=bg)
|
|
|
+ li_nodes.insert("end","*"*60)
|
|
|
+ node_nr += 1
|
|
|
+ #node_list += [node]
|
|
|
+
|
|
|
+ print("scroll:",li_node_scroll)
|
|
|
+
|
|
|
|
|
|
|
|
|
def get_new_ip(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
b = e_ip_new.get().replace("[","").replace("]","")
|
|
|
return b
|
|
|
|
|
|
def get_new_ip_str(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
x = get_new_ip()
|
|
|
#x = x[1:-1]
|
|
|
x = x.strip()
|
|
@@ -264,6 +271,7 @@ def get_new_ip_str(event=None):
|
|
|
return x
|
|
|
|
|
|
def send_artaddr(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
ln = e_lname.get()
|
|
|
sn = e_sname.get()
|
|
|
|
|
@@ -282,9 +290,11 @@ def send_artaddr(event=None):
|
|
|
|
|
|
|
|
|
def send_none(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
pass
|
|
|
|
|
|
def send_mac(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
#new_mac = "CMD MAC6 " + hex(e_mac2.get()) #)
|
|
|
#new_mac = "CMD MAC6 " + struct.pack("<B",(int(e_mac2.get(),16))).decode()
|
|
|
new_mac = b"CMD MAC6 " + struct.pack("<B",(int(e_mac2.get(),16)))
|
|
@@ -299,6 +309,7 @@ def send_mac(event=None):
|
|
|
#poll(delay=1.5)
|
|
|
|
|
|
def send_dmx_store(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
cmd = "CMD DMX STORE "
|
|
|
|
|
|
a = e_ip.get().replace("[","").replace("]","")
|
|
@@ -310,23 +321,32 @@ def send_dmx_store(event=None):
|
|
|
poll(delay=1.5)
|
|
|
|
|
|
def send_cmd(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
cmd = e_cmd.get() #"CMD DMX STORE "
|
|
|
_send_cmd(cmd=cmd)
|
|
|
+
|
|
|
def send_cmd2(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
cmd = e_cmd2.get() #"CMD DMX STORE "
|
|
|
_send_cmd(cmd=cmd)
|
|
|
+
|
|
|
def send_cmd3(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
cmd = e_cmd3.get() #"CMD DMX STORE "
|
|
|
_send_cmd(cmd=cmd)
|
|
|
+
|
|
|
def send_cmd4(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
cmd = e_cmd4.get() #"CMD DMX STORE "
|
|
|
_send_cmd(cmd=cmd)
|
|
|
+
|
|
|
def send_cmd5(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
cmd = e_cmd5.get() #"CMD DMX STORE "
|
|
|
_send_cmd(cmd=cmd)
|
|
|
-
|
|
|
|
|
|
def _send_cmd(event=None,cmd=""):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
#cmd = e_cmd.get() #"CMD DMX STORE "
|
|
|
cmd = cmd.split(" ")
|
|
|
value = cmd[-1]
|
|
@@ -351,6 +371,7 @@ def _send_cmd(event=None,cmd=""):
|
|
|
#poll(delay=1.5)
|
|
|
|
|
|
def kill_librelight(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
#for i in ["CONSOLE.py","EDITOR.py","ASP"]:
|
|
|
for i in ["ASP"]:
|
|
|
cmd='screen -XS "{}" quit | echo ""'.format(i)
|
|
@@ -367,6 +388,7 @@ def kill_librelight(event=None):
|
|
|
os.execl("/usr/bin/python3", BASE_PATH, cmd,arg)
|
|
|
|
|
|
def start_librelight(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
#for i in ["CONSOLE.py","EDITOR.py","ASP"]:
|
|
|
for i in ["ASP"]:
|
|
|
cmd='screen -XS "{}" quit | echo ""'.format(i)
|
|
@@ -387,6 +409,7 @@ def start_librelight(event=None):
|
|
|
|
|
|
|
|
|
def set_ip(event=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
print("SET NEW IP")
|
|
|
|
|
|
cur_ip=(2,0,0,94)
|
|
@@ -418,6 +441,7 @@ def set_ip(event=None):
|
|
|
poll(delay=1.5)
|
|
|
|
|
|
def set_node_pin(evnet=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
cmd = "CMD DMX=PIN"
|
|
|
ip = get_new_ip_str()
|
|
|
print("ip",[ip])
|
|
@@ -425,12 +449,14 @@ def set_node_pin(evnet=None):
|
|
|
poll(delay=1.5)
|
|
|
|
|
|
def set_node_in(evnet=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
cmd="CMD DMX=IN"
|
|
|
ip = get_new_ip_str()
|
|
|
nodescan.send_node_cmd(ip,cmd=cmd)
|
|
|
poll(delay=1.5)
|
|
|
|
|
|
def set_node_out(evnet=None):
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
cmd="CMD DMX=OUT"
|
|
|
ip = get_new_ip_str()
|
|
|
nodescan.send_node_cmd(ip,cmd=cmd)
|
|
@@ -453,7 +479,7 @@ font3 = ("Helvetica", 12) # 16
|
|
|
font20 = font=("Helvetica", 12) # 22
|
|
|
font120 = font=("Helvetica", 22) # 22
|
|
|
|
|
|
-b_scan = Tkinter.Button(fframe,text="clear list",width=8,command=clear,font=font2)
|
|
|
+b_scan = Tkinter.Button(fframe,text="refresh list",width=8,command=refresh_node_list,font=font2)
|
|
|
b_scan.pack(side="left",expand=0,fill="y")
|
|
|
|
|
|
b_scan = Tkinter.Button(fframe,text="ArtNetPoll ->",width=10,command=poll,font=font2)
|
|
@@ -467,43 +493,45 @@ b_scan.pack(side="left",expand=0,fill="y")
|
|
|
#POLL ['2.0.0.255', 6454] OK ;
|
|
|
#POLL ['2.255.255.255', 6454] OK ;
|
|
|
|
|
|
-local_ips = []
|
|
|
-#local_ips.append("2.0.0.255")
|
|
|
-cmd='ip a | grep " inet " | cut -d " " -f 6 | sort -h'
|
|
|
-r=os.popen(cmd)
|
|
|
-print("cmd",cmd)
|
|
|
-txt=r.readlines()
|
|
|
-for ip in txt:
|
|
|
- ip = ip.strip()
|
|
|
- print([ip])
|
|
|
- if ip.startswith("127."):
|
|
|
- continue
|
|
|
- if ip.count(".") != 3:
|
|
|
- continue
|
|
|
-
|
|
|
- if ip.endswith("/24"):
|
|
|
- ip = ip.split(".")
|
|
|
- ip = ".".join(ip[:3])+".255"
|
|
|
- elif ip.endswith("/8"):
|
|
|
- ip = ip.split(".")
|
|
|
- ip = ".".join(ip[0])+".255.255.255"
|
|
|
- else:
|
|
|
- continue
|
|
|
- print("-",ip)
|
|
|
- if ip == "2.255.255.255":
|
|
|
- print("- workaround -")
|
|
|
- local_ips.append("2.0.0.255")
|
|
|
-
|
|
|
- local_ips.append(ip)
|
|
|
-
|
|
|
-#local_ips.sort()
|
|
|
+def get_ips():
|
|
|
+ local_ips = []
|
|
|
+ #local_ips.append("2.0.0.255")
|
|
|
+ cmd='ip a | grep " inet " | cut -d " " -f 6 | sort -h'
|
|
|
+ r=os.popen(cmd)
|
|
|
+ print("cmd",cmd)
|
|
|
+ txt=r.readlines()
|
|
|
+ for ip in txt:
|
|
|
+ ip = ip.strip()
|
|
|
+ print([ip])
|
|
|
+ if ip.startswith("127."):
|
|
|
+ continue
|
|
|
+ if ip.count(".") != 3:
|
|
|
+ continue
|
|
|
+
|
|
|
+ if ip.endswith("/24"):
|
|
|
+ ip = ip.split(".")
|
|
|
+ ip = ".".join(ip[:3])+".255"
|
|
|
+ elif ip.endswith("/8"):
|
|
|
+ ip = ip.split(".")
|
|
|
+ ip = ".".join(ip[0])+".255.255.255"
|
|
|
+ else:
|
|
|
+ continue
|
|
|
+ print("-",ip)
|
|
|
+ if ip == "2.255.255.255":
|
|
|
+ print("- workaround -")
|
|
|
+ local_ips.append("2.0.0.255")
|
|
|
+
|
|
|
+ local_ips.append(ip)
|
|
|
+ return local_ips
|
|
|
+
|
|
|
+local_ips =get_ips()
|
|
|
|
|
|
option_list=local_ips
|
|
|
p_variable = Tkinter.StringVar(root)
|
|
|
p_variable.set(option_list[0]) # default value
|
|
|
-e_poll_new = Tkinter.OptionMenu(fframe, p_variable,*option_list)
|
|
|
+e_poll_new = Tkinter.OptionMenu(fframe, p_variable,*option_list,)
|
|
|
e_poll_new.configure(font=("Helvetica", 13))
|
|
|
-e_poll_new.configure(width=16)
|
|
|
+e_poll_new.configure(width=13)
|
|
|
e_poll_new["bg"] = "#fff"
|
|
|
#print(dir(e_poll_new))
|
|
|
e_poll_new.option_add("end","") #', 'option_clear', 'option_get
|
|
@@ -524,7 +552,7 @@ scrollbar.pack(side=Tkinter.RIGHT, fill="y")
|
|
|
#pool = Tkinter.Listbox(root,selectmode="extended",exportselection=0)
|
|
|
li_nodes = Tkinter.Listbox(cframe,exportselection=0,width=35,font=font1)
|
|
|
li_nodes.pack(side="left",expand=0,fill="y")
|
|
|
-li_nodes.bind("<ButtonRelease-1>",load )
|
|
|
+li_nodes.bind("<ButtonRelease-1>",fill_form )
|
|
|
|
|
|
li_nodes.config(yscrollcommand=scrollbar.set)
|
|
|
scrollbar.config(command=li_nodes.yview)
|
|
@@ -569,6 +597,9 @@ Tkinter.Label(line_frame,text="OLD IP:",font=font3,width=6).pack(side="left",exp
|
|
|
e_ip = Tkinter.Entry(line_frame,font=font20,width=26,state="disabled")
|
|
|
e_ip["bg"] = "lightgrey"
|
|
|
e_ip.pack(side="left")
|
|
|
+
|
|
|
+b_scan = Tkinter.Button(line_frame,text="clean",font=font2,relief="flat",command=clear_form)
|
|
|
+b_scan.pack(side="left",expand=0)
|
|
|
#b_scan = Tkinter.Button(line_frame,width=14,font=font3)
|
|
|
#b_scan.pack(side="left",expand=1)
|
|
|
|
|
@@ -594,10 +625,13 @@ variable.set("255.0.0.0") # default value
|
|
|
Tkinter.Label(line_frame,text="MASK:",font=font3,width=6).pack(side="left",expand=0,fill="y")
|
|
|
e_mask_new = Tkinter.OptionMenu(line_frame, variable,"255.255.255.0","255.0.0.0") #,width=10)
|
|
|
e_mask_new.configure(font=("Helvetica", 12))
|
|
|
-e_mask_new.configure(width=23)
|
|
|
+e_mask_new.configure(width=12)
|
|
|
e_mask_new["bg"] = "#fff"
|
|
|
#heigh=1,font=("Helvetica", 20)
|
|
|
e_mask_new.pack(side="left")
|
|
|
+e=Tkinter.Label(line_frame,text="")
|
|
|
+e.configure(width=11)
|
|
|
+e.pack(side="left")
|
|
|
#e_mask_new.insert("end","255.0.0.0")
|
|
|
#e_mask_new.insert("end","255.255.255.0")
|
|
|
|
|
@@ -721,10 +755,10 @@ e_cmd5.bind("<Return>", send_cmd5 )
|
|
|
e_cmd5.pack(side="left")
|
|
|
|
|
|
|
|
|
-thread.start_new_thread(_scan, () )
|
|
|
nodescan.bind_cmd_node()
|
|
|
|
|
|
-def read_cmd_buf():
|
|
|
+def network_listenet():
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
b_scan.insert("end", "log:\n" )
|
|
|
while 1:
|
|
|
if nodescan.node_cmd_buf_list:
|
|
@@ -741,50 +775,23 @@ def read_cmd_buf():
|
|
|
b_scan.see("end")
|
|
|
time.sleep(0.1)
|
|
|
|
|
|
-#thread.start_new_thread(nodescan.node_cmd_recive, () )
|
|
|
-#thread.start_new_thread(read_cmd_buf, () )
|
|
|
|
|
|
-def _update():
|
|
|
+def update_idletask():
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
while 1:
|
|
|
time.sleep(1)
|
|
|
root.update_idletasks()
|
|
|
|
|
|
-def X():
|
|
|
- thread.start_new_thread(nodescan.node_cmd_recive, () )
|
|
|
- thread.start_new_thread(read_cmd_buf, () )
|
|
|
- thread.start_new_thread(_update, () )
|
|
|
- #thread.start_new_thread(node_cmd_recive, () )
|
|
|
- #send_node_cmd(ip=(2,0,0,91),cmd="DMX OUT STORE")
|
|
|
- ##nodescan.send_node_cmd(ip=(2,255,255,255),cmd="CMD GT ")
|
|
|
- #nodescan.send_node_cmd(ip,cmd=cmd)
|
|
|
-
|
|
|
-
|
|
|
- #rx.loop()
|
|
|
- z = 0
|
|
|
- time.sleep(1)
|
|
|
- poll()
|
|
|
- while 1:
|
|
|
-
|
|
|
- nodes = rx.get()
|
|
|
- #print(len(nodes))
|
|
|
|
|
|
- if z % 10 == 0:
|
|
|
- pass
|
|
|
- print("----#")
|
|
|
- #MSG["text"] = ""
|
|
|
- #MSG["bg"] = "grey"
|
|
|
- #pass#print("node count",len(nodes),rx.tick())
|
|
|
- #for node in nodes:
|
|
|
- # print(node["MAC"],node["lname"])
|
|
|
-
|
|
|
- z += 1
|
|
|
- time.sleep(0.2)
|
|
|
-
|
|
|
- print()
|
|
|
- print("time out")
|
|
|
- raw_input("ENDE")
|
|
|
|
|
|
-thread.start_new_thread(X,()) #node_cmd_recive, () )
|
|
|
+def main():
|
|
|
+ print(sys._getframe().f_code.co_name)
|
|
|
+ thread.start_new_thread(scan, () )
|
|
|
+ thread.start_new_thread(nodescan.node_cmd_recive, () )
|
|
|
+ thread.start_new_thread(network_listenet, () )
|
|
|
+ thread.start_new_thread(update_idletask, () )
|
|
|
+
|
|
|
+main()
|
|
|
root.mainloop()
|
|
|
|
|
|
|