123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853 |
- #! /usr/bin/python
- # -*- coding: utf-8 -*-
- """
- Valid-License-Identifier: GPL-2.0-only
- SPDX-URL: https://spdx.org/licenses/GPL-2.0-only.html
- (c) 2012 micha@librelight.de
- """
- import os
- import time
- import struct
- import sys
- import tkinter as Tkinter
- import _thread as thread
- import datetime
- import traceback
- from cprint import cprint
- import nodescan
- _file_path = "/opt/LibreLight/Xdesk/"
- sys.path.insert(0,"/opt/LibreLight/Xdesk/")
- title = "TK-ArtNet-Nodscaner"
- sys.stdout.write("\x1b]2;"+title+"\x07")
- def connect_mc():
- mc = None
- try:
- import memcache
- mc = memcache.Client(['127.0.0.1:11211'], debug=0)
- #mc.set("dmx-1", [1]*512)
- except Exception as e:
- cprint("Exception",e,color="red")
- return mc
- mc = connect_mc()
- 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
- node_list = LOCK_BUF() #[]
- csel = 0
- def fill_form(event=None):
- cprint(sys._getframe().f_code.co_name,color="yellow")
- global node_list,csel
- clear_form()
- node_list2 = node_list.get()
- sel=0
- try:
- csel = li_nodes.curselection()[0]
- except Exception as e:
- cprint("ERR no node selected in node-list:",e,color="red")
- return 0
- print("+++",[csel,len(node_list2)])
- try:
- sel = int(li_nodes.get(csel).split()[0])-1
- except:
- cprint("ERR no leeding number in Listbox.line" ,color="red")
- return 0
- if not node_list2:
- return 0
- print("INFO: sel,node_list2",sel,len(node_list2))
- e_ip.configure(state='normal')
- e_ip.insert("end",node_list2[sel]["IP"].replace("[","").replace("]",""))
- #e_ip.configure(state='readonly')
-
- e_ip_new.insert("end",node_list2[sel]["IP"].replace("[","").replace("]",""))
- e_mac.delete("0","end")
- e_mac.insert("end",node_list2[sel]["MAC"].replace("[","").replace("]",""))
- e_mac2.delete("0","end")
- e_mac2.insert("end",node_list2[sel]["MAC"].split(":")[-1])
-
- #print("load",node_list2[sel])
- e_lname.delete("0","end")
- e_lname.insert("end",node_list2[sel]["lname"])
- e_sname.delete("0","end")
- e_sname.insert("end",node_list2[sel]["sname"])
- e_artnet_uni1.delete("0","end")
- univ = "0"
- try:
- if node_list2[sel]["PortTypes"][0] == "@":
- univ = ord(node_list2[sel]["SwIn"][0:1])
- else:
- univ = ord(node_list2[sel]["SwOut"][0:1])
- except Exception as e:
- cprint("load Exception",e,color="red")
- MSG["text"] = e
- MSG["bg"] = "red"
- e_artnet_uni1.insert("end",univ)
-
- def clear_form():
- cprint(sys._getframe().f_code.co_name,color="yellow")
- e_ip.configure(state='normal')
- e_ip.delete("0","end")
- e_ip.configure(state='readonly')
- e_ip_new.delete("0","end")
- e_mac.delete("0","end")
- e_mac2.delete("0","end")
- e_lname.delete("0","end")
- e_sname.delete("0","end")
- e_artnet_uni1.delete("0","end")
-
- def main_loop():
- while 1:
- try:
- poll()
- except Exception as e:
- print()
- cprint("Err main()",e,color="red")
- cprint(traceback.format_exc(),color="red")
- cprint("="*20,color="red")
- time.sleep(3)
- def poll(delay=1,ip=""):
- print()
- cprint(sys._getframe().f_code.co_name,"="*30,color="yellow")
-
- ip = "2.255.255.255"
- if not ip:
- cprint("err poll() no ip !",color="red")
- return
- log_text.insert("end", "ArtNetPoll -> "+str(ip)+"\n")
- log_text.yview("end")
- nodescan2.ArtPoll(ip=ip)
- nodes = load_node_list()
- refresh_node_list(nodes)
-
- import nodescan2
- def load_node_list():
- cprint(sys._getframe().f_code.co_name,"------------",color="yellow")
- global node_list,Scrollbar,mc
- #li_nodes.delete("0","end")
- ips = nodescan2.os_list_ip() #example
- nodes = []
- if not mc:
- cprint("mc (memcached) is none",color="red")
- mc = connect_mc()
- node_list.set([])
- return
- nodes = []
- artpoll = mc.get("index-artpoll")
- if not artpoll:
- cprint("mc.get('index-artpoll') is none ",color="red")
- mc = connect_mc()
- node_list.set([])
- return
- for k in artpoll:
- data = mc.get(k)
- opcode= nodescan2.artnet_get_opcode(data)
- if "ArtPollReplay" in opcode: # != '0x2100': #OpPollReplay
- node = nodescan2.ArtNet_decode_pollreplay(data)
- s = artpoll[k][1]
- s = datetime.datetime.strptime(s, '%Y-%m-%d %H:%M:%S')
- s = s.timestamp()
- node["UPDATESTAMP"] = s
- node["BOOT"] = 0
- node["REFRESHSTAMP"] = s
- node["LASTPING"] = 0
- #node1 = nodescan2.ArtNet_decode_pollreplay(data)
- nodes.append(node)
- ok=0
- for n in nodes:
- if n not in node_list.get():
- node_list.append(n)
- ok=1
- return node_list
- old_node_listbox = []
- def refresh_node_list(nodes):
- cprint(sys._getframe().f_code.co_name,color="yellow")
- global csel,old_node_listbox
-
- node_nr = 1
- nodesB = {}
- for node in node_list.get(): #nodes:
- k = node["MAC"]
- nodesB[k] = node
-
- if not nodesB:
- li_nodes.delete("0","end")
- li_nodes.insert("end"," - none -")
- k_sort = list(nodesB.keys())
- k_sort.sort()
- node_list.set([]) # =[]
- for k in k_sort:
- node_list.append(nodesB[k])
- out = []
- for k in k_sort:
- print(" ",k)
- node = nodesB[k]
- txt = str(node_nr).rjust(3," ") +" " + "-"*30
- bg=""
- out.append({"txt":txt,"bg":bg})
- bg = "white" #lightgrey"
- fg = ""
- #bg = "blue"
- #fg = "white"
- txt = str(node_nr).rjust(3," ") +" L-Name:"+ node["lname"]
- out.append({"txt":txt,"bg":bg,"fg":fg})
- #bg = "blue"
- #fg = "white"
- txt = str(node_nr).rjust(3," ") +" S-Name:"+ node["sname"]
- out.append({"txt":txt,"bg":bg,"fg":fg})
- bg = ""
- txt = str(node_nr).rjust(3," ") +" "+ node["IP"]
- if "PortTypes" in node:
- #print("-----", node["PortTypes"], node["PortTypes"][0] ,node["PortTypes"][0] == b"@")
- if not node["PortTypes"]:
- pass
- if node["PortTypes"][0] == 64: #b"@":
- txt += " DMX-in"
- bg ="yellow"
- else:
- txt += " DMX-out"
- bg ="lightgreen"
- out.append({"txt":txt,"bg":bg})
-
- txt = str(node_nr).rjust(3," ") + " UNIVERS OUT="+ str(ord(node["SwOut"][0:1]))+" IN="+ str(ord(node["SwIn"][0:1]))
- bg = ""
- out.append({"txt":txt,"bg":bg})
-
- txt = str(node_nr).rjust(3," ") +" MAC:"+ node["MAC"]
- bg = ""
- out.append({"txt":txt,"bg":bg})
-
- txt = ""
- bg = ""
- try:
- last_change=time.time()-float(node["UPDATESTAMP"])
- timeline = ""
- timeline += " CHANGE:%0.1f"% (last_change)
- REFRESHSTAMP = time.time()-float(node["REFRESHSTAMP"])
- timeline +=" PING:%0.1f"% REFRESHSTAMP
- txt = str(node_nr).rjust(3," ") +timeline
- if last_change > 20:
- bg="ORANGE"
- except Exception as e:
- txt = str(e)+"\n"
- bg = "red"
- out.append({"txt":txt,"bg":bg})
- txt=""
- bg = ""
- try:
- if node["BOOT"]:
- BOOT = time.time()-float(node["BOOT"])
- else:
- BOOT = 0
- timeline =" BOOT:%0.1f"% BOOT
- txt = str(node_nr).rjust(3," ") +timeline +" sec"
- bg = ""
- except Exception as e:
- txt = str(e)+"\n"
- bg = "red"
- out.append({"txt":txt,"bg":bg})
- node_nr += 1
-
- out.append({"txt":"","bg":"white"})
- # insert nodes in listbox
- if out == old_node_listbox:
- return
- old_node_listbox = out[:]
- if out:
- li_node_scroll = li_nodes.yview()
- li_nodes.delete("0","end")
- for i in out:
- #print("list:",i)
- li_nodes.insert("end",i["txt"])
- bg=i["bg"]
- fg="black"
- if "fg" in i:
- fg=i["fg"]
- if not bg:
- bg = "lightgrey"
- bg = "" ##ddd"
- li_nodes.itemconfig("end", bg=bg,fg=fg)
- print(csel)
- #li_nodes.yview(li_node_scroll )
- li_nodes.selection_set(csel)
- def get_form(event=None):
- cprint(sys._getframe().f_code.co_name,color="yellow")
- x = e_ip_new.get().replace("[","").replace("]","")
- x = x.strip()
- x = x.replace(" ","")
- x = x.split(",")
- ip2 = ".".join(x)
- ip = e_ip.get()
- ip = ip.replace(" ","")
- ip = ip.replace(",",".")
- MASK = variable.get() #e_mask_new.get()
- #new_mac = b"CMD MAC6 " + struct.pack("<B",(int(e_mac2.get(),16)))
- mac = e_mac.get()
- mac_new = e_mac2.get()
- ln = e_lname.get()
- sn = e_sname.get()
- univ = e_artnet_uni1.get()
- data={}
- data["IP"] = ip
- data["IP2"] = ip2
- data["sname"] = sn
- data["lname"] = ln
- data["netmask"] = MASK
- data["mac"] = mac
- data["mac_new"] = mac_new
- data["univ"] = univ
- print("FORM:")
- for k,v in data.items():
- print(" ",[k,v])
- return data
- def send_artaddr(event=None):
- cprint(sys._getframe().f_code.co_name,color="yellow")
- get_form()
- ln = e_lname.get()
- sn = e_sname.get()
- ip = e_ip_new.get()
- ip = ip.replace(" ","")
- ip = ip.replace(",",".")
- univ = e_artnet_uni1.get()
- print("SEND ArtAddress:",[ln,sn,ip,univ])
- if ln and sn and ip and univ:
- nodescan2.ArtAddress(ip=ip ,ShortName=sn, LongName=ln,Port="",Universes=univ)
- def send_none(event=None):
- cprint(sys._getframe().f_code.co_name,color="yellow")
- pass
-
- def send_mac(event=None):
- cprint(sys._getframe().f_code.co_name,color="yellow")
- #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)))
-
- a = e_ip.get().replace("[","").replace("]","")
- cur_ip = []
- for i in a.split(","):
- cur_ip +=[int(i)]
- print("SEND MAC:",cur_ip,new_mac)
- nodescan2.send_node_cmd(cur_ip,cmd=new_mac)
- def SEND_CMD(cmd="NIX",entry=None):
- cprint(sys._getframe().f_code.co_name,color="yellow")
- def cb(event=None):
- cprint(sys._getframe().f_code.co_name,color="yellow")
- _cmd=cmd
- if entry:
- _cmd = entry.get() #"CMD DMX STORE "
- print(" SEND_CMD.cb()",[_cmd])
- if not _cmd:
- cprint(" SEND_CMD: no cmd",color="red")
- #_send_cmd(cmd=_cmd)
- port = 7600
- form = get_form()
- if form["IP2"]:
- _cmd2 = []
- for i in _cmd:
- try:
- _cmd2.append(ord(i) )
- except:
- _cmd2.append(ord(" ") )
- print(" _cmd2",_cmd2)
- for i in range(31):
- if len(_cmd2) < i:
- _cmd2.append(0)
- for i in _cmd2:
- print(" ",i,i,hex(i))
- _cmd2 = bytes(_cmd2)
- print(" _cmd2",_cmd2)
- sock = nodescan2.UDP_Socket()
- sock.sendto(_cmd2 ,(form["IP2"],port))
- return cb
- def send_artdmx(val=127):
- def cb():
- form = get_form()
- print(form)
- import lib.ArtNetNode as an
- if form["IP2"] and form["univ"]:
- #artnet = an.ArtNetNode(to=form["netmask"],univ=form["univ"],port=4566)
- log_text.insert("end", "ArtDMX -> "+str(form["IP2"])+" univ:"+str(form["univ"])+" v="+ str(val)+"\n")
- log_text.yview("end")
- artnet = an.ArtNetNode(to=form["IP2"],univ=form["univ"],port=4566)
- artnet.send([val]*512,port=6454)
- print(artnet._data)
- return cb
-
- def _send_cmd(event=None,cmd=""):
- cprint(sys._getframe().f_code.co_name,color="yellow")
- #cmd = e_cmd.get() #"CMD DMX STORE "
- cmd = cmd.split(" ")
- value = cmd[-1]
- try:
- value = struct.pack("<B",int(value))
- except:pass
- cmd = cmd[:-1] #.append(value)
- cmd.append(value)
- print("_send_cmd:",[cmd])
- cmd=" ".join(map(str,cmd) )
- a = e_ip.get()
- if not a:
- cprint(" NO NODE-IP SELECTED",color="red")
- return
- a = a.replace("[","").replace("]","")
- cur_ip = []
- sep = "xx"
- if "," in a:
- sep = ","
- if "." in a:
- sep = "."
- for i in a.split(sep):
- cur_ip +=[int(i)]
- cprint("_cmd_send:",cur_ip ,"CMD:",[cmd],color="yellow")
- nodescan2.send_node_cmd(cur_ip,cmd)
- def ip_to_byte(ip):
- x = ip.strip()
- if "." in x:
- x = x.split(".")
- print(x)
- elif ":" in x:
- x = x.replace(":","")
- print(x)
- x = bytes.fromhex(x)
-
- else:
- return [0,0,0,0]
- y = []
- for i in x:
- y.append(int(i))
- return y
- def set_ip(event=None):
- print("SET NEW IP")
- d=get_form()
- cur_ip = ip_to_byte(d["IP"])
- new_ip = ip_to_byte(d["IP2"])
- #new_netmask = ip_to_byte( d["mac"])
- new_netmask = ip_to_byte( d["netmask"])
-
- print("new",[cur_ip, new_ip, new_netmask])
- if new_ip == cur_ip:
- cprint("ERR set_ip() neu und als IP sind gleich" ,color="red" )
- return 0
-
- print("new",[cur_ip, new_ip, new_netmask])
- 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 set_node_in(evnet=None):
- cprint(sys._getframe().f_code.co_name,color="yellow")
- cmd="CMD DMX=IN"
- ip = get_form()["IP"]
- nodescan2.send_node_cmd(ip,cmd=cmd)
-
- def set_node_out(evnet=None):
- cprint(sys._getframe().f_code.co_name,color="yellow")
- cmd="CMD DMX=OUT"
- ip = get_form()["IP"]
- nodescan2.send_node_cmd(ip,cmd=cmd)
- # ----------------------------------------------
- # TK-WINDOW
- # ----------------------------------------------
- root = Tkinter.Tk()
- root.geometry("650x600+100+100")
- root.title( title)
- fframe = Tkinter.Frame(root)
- fframe.pack(side="top",expand=0,fill="x")
- cframe = Tkinter.Frame(root)
- cframe.pack(side="top",expand=1,fill="both")
- font1 = ("Helvetica", 8)
- font2 = ("Helvetica", 12) # 10
- font3 = ("Helvetica", 12) # 16
- font20 = font=("Helvetica", 12) # 22
- font120 = font=("Helvetica", 22) # 22
- log_text = Tkinter.Button(fframe,text="refresh",width=8,command=poll,font=font2)
- log_text.pack(side="left",expand=0,fill="y")
- log_text = Tkinter.Button(fframe,text="ArtNetPoll ->",width=10,command=poll,font=font2)
- log_text.configure(bg="#0f0")
- scrollbar = Tkinter.Scrollbar(cframe)
- scrollbar.pack(side=Tkinter.LEFT, fill="y")
- li_nodes = Tkinter.Listbox(cframe,exportselection=0,width=35,font=font1,height=16)
- li_nodes.pack(side="left",expand=0,fill="y")
- li_nodes.bind("<ButtonRelease-1>",fill_form )
- li_nodes.config(yscrollcommand=scrollbar.set)
- scrollbar.config(command=li_nodes.yview)
- eframe = Tkinter.Frame(cframe)
- eframe.pack(side="left",expand=0,fill="y")
- eframe1 = Tkinter.Frame(cframe)
- eframe1.pack(side="left",expand=0,fill="y")
- # ----------------------------------------------
- line_frame = Tkinter.Frame(eframe)
- line_frame.pack(side="top",expand=0,fill="x")
- x=Tkinter.Label(line_frame,text=" ",font=font2,width=6)
- c= Tkinter.Label(line_frame,text=" ",font=font1,width=30,anchor="w")
- c.pack(side="left",expand=0,fill="y")
- # ----------------------------------------------
- # TK-FORM
- # ----------------------------------------------
- line_frame = Tkinter.Frame(eframe)
- line_frame.pack(side="top",expand=0,fill="x")
- x=Tkinter.Label(line_frame,text="MSG:",font=font3,width=6)
- x.pack(side="left",expand=0,fill="y")
- x.configure(bg="darkgrey")
- MSG = Tkinter.Label(line_frame,text="xxx",font=font1,width=60,anchor="w")
- MSG.pack(side="left",expand=0,fill="y")
- MSG.configure(bg="darkgrey")
- # ----------------------------------------------
- line_frame = Tkinter.Frame(eframe)
- line_frame.pack(side="top",expand=0,fill="x")
- c= Tkinter.Label(line_frame,text=" ",font=font120,width=30,anchor="w")
- c.pack(side="left",expand=0,fill="y")
- # ----------------------------------------------
- line_frame = Tkinter.Frame(eframe)
- line_frame.pack(side="top",expand=0,fill="x")
- Tkinter.Label(line_frame,text="OLD IP:",font=font3,width=6).pack(side="left",expand=0,fill="y")
- e_ip = Tkinter.Entry(line_frame,font=font20,width=16,state="disabled")
- e_ip["bg"] = "lightgrey"
- e_ip.pack(side="left")
- log_text = Tkinter.Button(line_frame,text="clean",font=font2,relief="flat",command=clear_form)
- log_text.pack(side="left",expand=0)
- #log_text = Tkinter.Button(line_frame,width=14,font=font3)
- #log_text.pack(side="left",expand=1)
- # ----------------------------------------------
- line_frame = Tkinter.Frame(eframe)
- line_frame.pack(side="top",expand=0,fill="x")
- e_ip_label = Tkinter.Label(line_frame,text=" IP:",font=font3,width=6)
- e_ip_label.pack(side="left",expand=0,fill="y")
- e_ip_new = Tkinter.Entry(line_frame,font=font20,width=16)
- e_ip_new.bind("<Return>", set_ip )
- e_ip_new.bind("<KP_Enter>", set_ip)
- e_ip_new.bind("<ISO_Left_Tab>", set_ip)
- e_ip_new.pack(side="left")
- #-------------------------------------------- line
- line_frame = Tkinter.Frame(eframe)
- line_frame.pack(side="top",expand=0,fill="x")
- variable = Tkinter.StringVar(root)
- 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=13)
- e_mask_new["bg"] = "#fff"
- e_mask_new.pack(side="left")
- #e=Tkinter.Label(line_frame,text="")
- #e.configure(width=1)
- #e.pack(side="left")
- log_text = Tkinter.Button(line_frame,text="SEND TO NODE",bg="lightgreen",command=set_ip,width=13,font=font1)
- log_text.pack(side="left",expand=0)
- #-------------------------------------------- line
- line_frame = Tkinter.Frame(eframe)
- line_frame.pack(side="top",expand=0,fill="x")
- Tkinter.Label(line_frame,text="MAC:",font=font3,width=6).pack(side="left",expand=0,fill="y")
- e_mac = Tkinter.Entry(line_frame,width=13,font=font20)
- e_mac.pack(side="left")
- e_mac["bg"] = "lightgrey"
- e_mac2 = Tkinter.Entry(line_frame,width=3,font=font20)
- e_mac2.pack(side="left")
- e_mac2.config(bg="orange")
- e_mac2.bind("<Return>", send_mac )
- e_mac2.bind("<KP_Enter>", send_mac)
- Tkinter.Button(line_frame,text="SEND TO NODE !",bg="orange",command=send_mac,width=14,font=font1).pack(side="left",expand=0)
- # ----------------------------------------------
- line_frame = Tkinter.Frame(eframe)
- line_frame.pack(side="top",expand=0,fill="x")
- c= Tkinter.Label(line_frame,text=" ",font=font120,width=30,anchor="w")
- c.pack(side="left",expand=0,fill="y")
- #-------------------------------------------- line
- line_frame = Tkinter.Frame(eframe)
- line_frame.pack(side="top",expand=0,fill="x")
- Tkinter.Label(line_frame,text="DMX:",font=font3,width=6).pack(side="left",expand=0,fill="y")
- b_set_node_pin = Tkinter.Button(line_frame,text="HW-PIN",bg="orange",command=set_node_pin,width=5,font=font3)
- b_set_node_pin.pack(side="left",expand=0)
- b_set_node_in = Tkinter.Button(line_frame,text="IN",bg="orange",command=set_node_in,width=2,font=font3)
- b_set_node_in.pack(side="left",expand=0)
- b_set_node_out = Tkinter.Button(line_frame,text="OUT",bg="orange",command=set_node_out,width=2,font=font3)
- b_set_node_out.pack(side="left",expand=0)
- #-------------------------------------------- line
- line_frame = Tkinter.Frame(eframe)
- 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_cmd = Tkinter.Entry(line_frame,font=font3,width=16)
- CMD="" #DMX OUT STORE"
- c=SEND_CMD(CMD,entry=e_cmd)
- e_cmd.bind("<Return>", c )
- e_cmd.pack(side="left")
- #-------------------------------------------- line
- line_frame = Tkinter.Frame(eframe)
- line_frame.pack(side="top",expand=0,fill="x")
- Tkinter.Label(line_frame,text="LName",font=font3,width=6).pack(side="left",expand=0,fill="y")
- e_lname = Tkinter.Entry(line_frame,font=font3,width=16)
- e_lname.pack(side="left")
- #-------------------------------------------- line
- line_frame = Tkinter.Frame(eframe)
- line_frame.pack(side="top",expand=0,fill="x")
- Tkinter.Label(line_frame,text="SName",font=font3,width=6).pack(side="left",expand=0,fill="y")
- e_sname = Tkinter.Entry(line_frame,font=font3,width=16)
- e_sname.pack(side="left")
- #-------------------------------------------- line
- line_frame = Tkinter.Frame(eframe)
- line_frame.pack(side="top",expand=0,fill="x")
- Tkinter.Label(line_frame,text="ArtNet",font=font3,width=6).pack(side="left",expand=0,fill="y")
- Tkinter.Label(line_frame,text="SUB:",font=font3,width=4).pack(side="left",expand=0,fill="y")
- e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4,state="disabled")
- e_artnet_uni1.pack(side="left")
- Tkinter.Label(line_frame,text="NET:",font=font3,width=4).pack(side="left",expand=0,fill="y")
- e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4,state="disabled")
- e_artnet_uni1.pack(side="left")
- Tkinter.Label(line_frame,text="UNI:",font=font3,width=4).pack(side="left",expand=0,fill="y")
- e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4)
- e_artnet_uni1.pack(side="left")
- Tkinter.Button(line_frame,text="send ArtAddr",bg="lightgreen",command=send_artaddr,width=14,font=font1).pack(side="left",expand=0)
- #-------------------------------------------- line
- log_text = Tkinter.Text(eframe,width=10,font=font2)
- log_text.pack(side="top",expand=1,fill="x")
- #-------------------------------------------- line
- line_frame = Tkinter.Frame(eframe1)
- line_frame.pack(side="top",expand=0,fill="x")
- e = Tkinter.Button(line_frame,text="DMX:0",font=font3,width=16,command=send_artdmx(0),bg="orange")
- e.pack(side="left")
- line_frame = Tkinter.Frame(eframe1)
- line_frame.pack(side="top",expand=0,fill="x")
- e = Tkinter.Button(line_frame,text="DMX:127",font=font3,width=16,command=send_artdmx(127),bg="orange")
- e.pack(side="left")
- line_frame = Tkinter.Frame(eframe1)
- 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)
- e.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_cmd2 = Tkinter.Entry(line_frame,font=font3,width=16)
- CMD="- DMX ERASE"
- c=SEND_CMD(CMD)
- 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
- 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_cmd4 = Tkinter.Entry(line_frame,font=font3,width=16)
- CMD="DMX OUT SET 2"
- c=SEND_CMD(CMD)
- e_cmd4.insert("end",CMD)
- e_cmd4.bind("<Return>", c )
- e_cmd4.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_cmd5 = Tkinter.Entry(line_frame,font=font3,width=16)
- CMD="REBOOT"
- c=SEND_CMD(CMD)
- e_cmd5.insert("end",CMD)
- e_cmd5.bind("<Return>", c )
- e_cmd5.pack(side="left")
- def network_listenet():
- cprint(sys._getframe().f_code.co_name,color="yellow")
- log_text.insert("end", "log:\n" )
- while 1:
- #print(".")
- if nodescan2.node_cmd_buf_list:
- msg = str(nodescan2.node_cmd_buf_list)
- print("read_cmd_buf msg",msg)
- nodescan2.node_cmd_buf_list = []
- stamp = str(time.time())+"\n"
- stamp = time.strftime("%Y-%m-%d %X\n")
- log_text.insert("end",stamp)
- log_text.insert("end", msg +"\n")
-
- log_text.see("end")
- time.sleep(0.1)
- def tk_loop():
- while 1:
- root.update_idletasks()
- time.sleep(1)
-
- def main():
- cprint(sys._getframe().f_code.co_name,color="yellow")
- thread.start_new_thread(main_loop, () )
- #thread.start_new_thread(nodescan.node_cmd_recive, () )
- #thread.start_new_thread(network_listenet, () )
- thread.start_new_thread(tk_loop, () )
- thread.start_new_thread(nodescan2.ArtNet_Server,())
- #nodescan.bind_cmd_node()
- main()
- root.mainloop()
|