aboutsummaryrefslogtreecommitdiffstats
path: root/src/emc/usr_intf/axis/scripts/debuglevel.py
blob: 8b6ae928c20b97143d12e5b121659c69051206f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python3
import sys, os
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"))

import linuxcnc
import tkinter
import time

if len(sys.argv) > 1 and sys.argv[1] == '-ini':
    ini = linuxcnc.ini(sys.argv[2])
    nmlfile = ini.find("EMC", "NML_FILE")
    if nmlfile: linuxcnc.nmlfile = nmlfile
    del sys.argv[1:3]

s = linuxcnc.stat()
s.poll()
c = linuxcnc.command()

t = tkinter.Tk(className="LinuxCNCDebugLevel")
t.wm_title(_("LinuxCNC Debug Level"))
t.wm_iconname(_("debuglevel"))
t.wm_resizable(0, 0)

import rs274.options
rs274.options.install(t)

# The configuration-related items are commented out because
# it only makes sense to enable them during startup.
#
# From inspection of the source, and because no messages were seen
# for those flags, it looks like the state of DEBUG_NML and DEBUG_RCS
# is only checked early in startup, so changing them later has no effect.
bits = [
    (linuxcnc.DEBUG_CONFIG, _('Configuration *')),
    (linuxcnc.DEBUG_VERSIONS, _('Version Numbers *')),
    (linuxcnc.DEBUG_NML, _('NML *')),
    (linuxcnc.DEBUG_RCS, _('RCS *')),
    (linuxcnc.DEBUG_TASK_ISSUE, _('Task Issue')),
    (linuxcnc.DEBUG_MOTION_TIME, _('Motion Time')),
    (linuxcnc.DEBUG_INTERP, _('Interpreter')),
    (linuxcnc.DEBUG_INTERP_LIST, _('Interpreter List')),
    (linuxcnc.DEBUG_STATE_TAGS, _('State Tags')),
]

def showdebug(value):
    d.set(_("Inifile setting for this debug level:\n[EMC]DEBUG=0x%08x") % value)

vars = {}
blackout = 0
def update_buttons_from_emc():
    if time.time() < blackout:
        t.after(1000, update_buttons_from_emc)
        return
    try:
        s.poll()
    except linuxcnc.error: # linuxcnc exited?
        raise SystemExit
    debug = s.debug
    for k, v in list(vars.items()):
        if debug & k: v.set(k)
        else: v.set(0)
    showdebug(debug)
    # .. just in case someone else changes it ..
    t.after(1000, update_buttons_from_emc)

def setdebug():
    blackout = time.time() + 1
    value = 0
    for k, v in list(vars.items()):
        value = value | v.get()
    c.debug(value)
    showdebug(value)

for k, v in bits:
    vv = tkinter.IntVar(t)
    vars[k] = vv
    b = tkinter.Checkbutton(text = v, onvalue = k, offvalue = 0,
                        command=setdebug, variable=vv, anchor="nw")
    b.pack(side="top", anchor="nw", fill="x", expand=0)
l = tkinter.Label(text=_("  * This option can only be enabled in the inifile"))
l.pack(side="top", anchor="nw")

d = tkinter.StringVar(t)
l = tkinter.Label(textvariable=d)
l.pack(side="top", anchor="nw")

showdebug(s.debug)

update_buttons_from_emc()

t.mainloop()
bues.ch cgit interface