#!/usr/bin/env python3 # This is a component of AXIS, a front-end for linuxcnc # Copyright 2004, 2005, 2006 Jeff Epler # and Chris Radek # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import sys, os import linuxcnc, time import rs274.options import gettext BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")) gettext.install("linuxcnc", localedir=os.path.join(BASE, "share", "locale")) if len(sys.argv) > 1 and sys.argv[1] == '-ini': ini = linuxcnc.ini(sys.argv[2]) linuxcnc.nmlfile = ini.find("EMC", "NML_FILE") or linuxcnc.nmlfile del sys.argv[1:3] s = linuxcnc.stat(); s.poll() def show_spindles(l): ct = 0; s = "" for d in l: for key in d: s = s+"%d %20s %s\n"% (ct,key,d[key]) ct = ct+1 return s def show_mcodes(l): return " ".join(["M%g" % i for i in l[1:] if i != -1]) def show_gcodes(l): return " ".join(["G%g" % (i/10.) for i in l[1:] if i != -1]) def show_position(p): return " ".join(["%-8.4f" % n for i, n in enumerate(p) if s.axis_mask & (1<", "break") b = tkinter.Button(text=_("Copy All"), command="%s tag add sel 0.0 end; tk_textCopy %s" % (t, t)) b.pack(side="bottom", anchor="sw") t.pack(side="left", expand=1, fill="both") sb.pack(side="left", expand=0, fill="y") changetime = {} oldvalues = {} def timer(): try: s.poll() except linuxcnc.error: root.destroy() selection = t.tag_ranges("sel") insert_point = t.index("insert") insert_gravity = t.mark_gravity("insert") try: anchor_point = t.index("anchor") anchor_gravity = t.mark_gravity("anchor") except TclError: anchor_point = None first = True now = time.time() for k in dir(s): if k.startswith("_"): continue if k in maps and maps[k] == None: continue v = getattr(s, k) if k in maps: m = maps[k] if callable(m): v = m(v) else: v = m.get(v, v) v = str(v) v = v.strip() v = v or "-" changed = oldvalues.get(k, None) != v if changed: changetime[k] = time.time() + 2 oldvalues[k] = v if changed: vtag = "changedvalue" elif k in changetime and changetime[k] < now: vtag = "value" if k in changetime: del changetime[k] elif not changed: continue vranges = t.tag_ranges(k) if vranges: t.tk.call(t, "replace", "%s.first" % k, "%s.last" % k, v, (k, vtag)) else: if first: first = False else: t.insert("end", "\n") t.insert("end", k, "key", "\t") t.insert("end", v, (k, vtag)) if selection: t.tag_add("sel", *selection) t.mark_set("insert", insert_point) t.mark_gravity("insert", insert_gravity) if anchor_point is not None: t.mark_set("anchor", anchor_point) t.mark_gravity("anchor", anchor_gravity) t.after(100, timer) timer() t.mainloop() def text(): s.poll() for k in dir(s): if k.startswith("_"): continue if k in maps and maps[k] == None: continue v = getattr(s, k) if k in maps: m = maps[k] if callable(m): v = m(v) else: v = m.get(v, v) print("%-20s %-.58s" % (k, v)) if len(sys.argv) > 1 and sys.argv[1] == '-t': text() else: gui() # vim:sw=4:sts=4:et