Ver código fonte

fix: DMX OUT STORE ... create BUTTON and LOG-MSG

micha 2 semanas atrás
pai
commit
5d005667d5
1 arquivos alterados com 63 adições e 9 exclusões
  1. 63 9
      tool/TK-Nodescanner.py

+ 63 - 9
tool/TK-Nodescanner.py

@@ -16,6 +16,7 @@ import tkinter as Tkinter
 import _thread as thread
 import datetime
 import traceback
+import socket
 
 from cprint import cprint
 
@@ -151,6 +152,7 @@ def poll(delay=1,ip=""):
     cprint(sys._getframe().f_code.co_name,"="*30,color="yellow")
     
     ip = "2.255.255.255"
+    #ip = "192.168.0.255"
     if not ip:
         cprint("err poll() no ip !",color="red")
         return
@@ -409,6 +411,25 @@ def send_mac(event=None):
     print("SEND MAC:",cur_ip,new_mac)
     nodescan2.send_node_cmd(cur_ip,cmd=new_mac)
 
+def listen_cmd():
+
+    cmd_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
+    cmd_sock.bind(("0.0.0.0", 7601))
+    while 1:
+        try:
+            msg,addr = cmd_sock.recvfrom(1024)
+            print("****"*20)
+            msg = msg.strip()
+            msg = msg.decode("ascii")
+            msg = msg.replace("\x00","") 
+            msg += "\n"
+            print("cmd return:",[addr,msg])
+            log_text.insert("end",msg)
+            print("****"*20)
+        except Exception as e:
+            print("e",e)
+            time.sleep(1)
+    sys.exit()
 
 def SEND_CMD(cmd="NIX",entry=None):
     cprint(sys._getframe().f_code.co_name,color="yellow")
@@ -526,6 +547,23 @@ def set_ip(event=None):
     print()
     nodescan2.set_ip4(cur_ip,new_ip, new_netmask)
     
+def set_node_pin(evnet=None):
+    cprint(sys._getframe().f_code.co_name,color="yellow")
+    cmd = "CMD DMX=PIN"
+    ip = get_form()["IP"]
+    print("ip",[ip])
+    nodescan2.send_node_cmd(ip,cmd=cmd)
+
+def store_dmx(evnet=None):
+    cprint(sys._getframe().f_code.co_name,color="yellow")
+    cmd = "CMD DMX=PIN"
+    ip = get_form()["IP"]
+    print("ip",[ip])
+    nodescan2.send_node_cmd(ip,cmd=cmd)
+    time.sleep(0.1)
+    cmd="DMX OUT STORE "
+    nodescan2.send_node_cmd(ip,cmd=cmd)
+
 def set_node_pin(evnet=None):
     cprint(sys._getframe().f_code.co_name,color="yellow")
     cmd = "CMD DMX=PIN"
@@ -694,6 +732,7 @@ b_set_node_out.pack(side="left",expand=0)
 
 
 
+
 #-------------------------------------------- line
 line_frame = Tkinter.Frame(eframe)
 line_frame.pack(side="top",expand=0,fill="x")
@@ -758,6 +797,7 @@ line_frame.pack(side="top",expand=0,fill="x")
 e = Tkinter.Button(line_frame,text="DMX:255",font=font3,width=16,command=send_artdmx(255),bg="orange")
 e.pack(side="left")
 
+
 line_frame = Tkinter.Frame(eframe1)
 line_frame.pack(side="top",expand=0,fill="x")
 e = Tkinter.Label(line_frame,text="",width=16)
@@ -774,15 +814,15 @@ e_cmd2.insert("end",CMD)
 e_cmd2.bind("<Return>", c )
 e_cmd2.pack(side="left")
 #-------------------------------------------- line
-line_frame = Tkinter.Frame(eframe1)
-line_frame.pack(side="top",expand=0,fill="x")
-Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
-e_cmd3 = Tkinter.Entry(line_frame,font=font3,width=16)
-CMD="DMX OUT STORE"
-c=SEND_CMD(CMD)
-e_cmd3.insert("end",CMD)
-e_cmd3.bind("<Return>", c )
-e_cmd3.pack(side="left")
+#line_frame = Tkinter.Frame(eframe1)
+#line_frame.pack(side="top",expand=0,fill="x")
+#Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
+#e_cmd3 = Tkinter.Entry(line_frame,font=font3,width=16)
+#CMD="DMX OUT STORE "
+#c=SEND_CMD(CMD)
+#e_cmd3.insert("end",CMD)
+#e_cmd3.bind("<Return>", c )
+#e_cmd3.pack(side="left")
 #-------------------------------------------- line
 line_frame = Tkinter.Frame(eframe1)
 line_frame.pack(side="top",expand=0,fill="x")
@@ -805,6 +845,19 @@ e_cmd5.bind("<Return>", c )
 e_cmd5.pack(side="left")
 
 
+#-------------------------------------------- line
+line_frame = Tkinter.Frame(eframe1)
+line_frame.pack(side="top",expand=0,fill="x")
+e = Tkinter.Label(line_frame,text="",width=16)
+e.pack(side="left")
+
+#-------------------------------------------- line
+line_frame = Tkinter.Frame(eframe1)
+line_frame.pack(side="top",expand=0,fill="x")
+
+b_store_dmx = Tkinter.Button(line_frame,text="STORE_DMX",bg="orange",command=store_dmx,width=16,font=font3)
+b_store_dmx.pack(side="left",expand=0)
+
 
 def network_listenet():
     cprint(sys._getframe().f_code.co_name,color="yellow")
@@ -835,6 +888,7 @@ def tk_loop():
 def main():
     cprint(sys._getframe().f_code.co_name,color="yellow")
 
+    thread.start_new_thread(listen_cmd,())
 
     thread.start_new_thread(main_loop, () )