From e2547c4b63b2fbf78bcd01b25eed10ad42ec527c Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 10 Nov 2026 17:31:07 +0100 Subject: [PATCH 01/27] tests: record what the task planner does with every command tests/task-planner brings task into each situation its planner tells apart (E-stop, off, Manual, MDI idle and running, Auto idle, reading, waiting and paused) and sends it every command emcTaskPlan() handles, one at a time, plus one it has no case for. From task's own debug output it records, for each, whether the planner issued the command, queued it for later, refused it or handled it itself, and what situation the command left task in. The table is compared with tests/task-planner/ expected, which is the behaviour of today's planner. A change to the planner that is not meant to change behaviour leaves the table as it is; one that is shows up as a diff of it. The commands come from test_task_probe, a small NML client that sends any of them with arguments that change as little as possible. It is built for run-in-place only and not installed; the test skips without it. --- src/Makefile | 2 +- src/emc/task/Submakefile | 9 + src/emc/task/test_task_probe.cc | 266 +++++++++++ tests/task-planner/.gitignore | 5 + tests/task-planner/checkresult | 118 +++++ tests/task-planner/expected | 683 +++++++++++++++++++++++++++ tests/task-planner/flush.ngc | 2 + tests/task-planner/task-planner.ini | 99 ++++ tests/task-planner/test-ui.py | 226 +++++++++ tests/task-planner/test.sh | 22 + tests/task-planner/tool.tbl.original | 1 + tests/task-planner/waiting.ngc | 3 + 12 files changed, 1435 insertions(+), 1 deletion(-) create mode 100644 src/emc/task/test_task_probe.cc create mode 100644 tests/task-planner/.gitignore create mode 100755 tests/task-planner/checkresult create mode 100644 tests/task-planner/expected create mode 100644 tests/task-planner/flush.ngc create mode 100644 tests/task-planner/task-planner.ini create mode 100755 tests/task-planner/test-ui.py create mode 100755 tests/task-planner/test.sh create mode 100644 tests/task-planner/tool.tbl.original create mode 100644 tests/task-planner/waiting.ngc diff --git a/src/Makefile b/src/Makefile index 05715dd7985..4e5344b0dc4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -655,7 +655,7 @@ endif $(DIR) $(DESTDIR)$(sampleconfsdir) ((cd ../configs && tar --exclude CVS --exclude .cvsignore --exclude .gitignore -cf - .) | (cd $(DESTDIR)$(sampleconfsdir) && tar -xf -)) - $(EXE) $(filter-out ../bin/rtapi_app ../bin/linuxcnc_module_helper ../bin/pci_write ../bin/pci_read ../bin/test_rtapi_vsnprintf, $(filter ../bin/%,$(TARGETS))) $(DESTDIR)$(bindir) + $(EXE) $(filter-out ../bin/rtapi_app ../bin/linuxcnc_module_helper ../bin/pci_write ../bin/pci_read ../bin/test_rtapi_vsnprintf ../bin/test_task_probe, $(filter ../bin/%,$(TARGETS))) $(DESTDIR)$(bindir) $(EXE) ../scripts/linuxcnc $(DESTDIR)$(bindir) $(EXE) ../scripts/linuxcnc_info $(DESTDIR)$(bindir) $(EXE) ../scripts/setup_designer $(DESTDIR)$(bindir) diff --git a/src/emc/task/Submakefile b/src/emc/task/Submakefile index 9fdab7004d6..2f4950450b5 100644 --- a/src/emc/task/Submakefile +++ b/src/emc/task/Submakefile @@ -38,3 +38,12 @@ USERSRCS += $(MILLTASKSRCS) $(ECHO) Linking $(notdir $@) $(CXX) -o $@ $^ $(LDFLAGS) $(PYTHON_EXTRA_LDFLAGS) $(BOOST_PYTHON_LIB) $(PYTHON_LIBS) $(PYTHON_EXTRA_LIBS) -lfmt TARGETS += ../bin/milltask + +# test helper for tests/task-planner, not installed (see ../Makefile) +TESTTASKPROBESRCS := emc/task/test_task_probe.cc +USERSRCS += $(TESTTASKPROBESRCS) + +../bin/test_task_probe: $(call TOOBJS, $(TESTTASKPROBESRCS)) ../lib/liblinuxcnchal.so.0 ../lib/liblinuxcnc.a ../lib/libnml.so.0 ../lib/liblinuxcncini.so.1 + $(ECHO) Linking $(notdir $@) + $(Q)$(CXX) -o $@ $^ -lfmt $(LDFLAGS) +TARGETS += ../bin/test_task_probe diff --git a/src/emc/task/test_task_probe.cc b/src/emc/task/test_task_probe.cc new file mode 100644 index 00000000000..fa217cfdaa4 --- /dev/null +++ b/src/emc/task/test_task_probe.cc @@ -0,0 +1,266 @@ +/******************************************************************** +* Description: test_task_probe.cc +* Test helper for tests/task-planner: sends task one command at a time, +* with arguments that change as little as possible, so that the test can +* record what the planner does with each command in each task state. +* +* It reads lines from stdin: +* +* list print the names of all the commands it can send +* probe LABEL NAME send command NAME, bracketed by two operator +* display messages "probe-begin LABEL NAME" and +* "probe-end", and print "serial N" with the +* serial number the command was sent with +* +* Every message is sent only once task has taken the previous one, so +* task's EMC_DEBUG_TASK_ISSUE output shows them in order, between the two +* markers. The test reads that output; this helper reports nothing else. +* +* Built into ../bin for run-in-place tests, never installed. +* +* License: GPL Version 2 +* System: Linux +********************************************************************/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "nml_intf/emc.hh" +#include "nml_intf/emc_nml.hh" +#include "nml_intf/emcglb.h" // emc_nmlfile, emcGetArgs() +#include // EMCMOT_MAX_JOINTS +#include +#include "timeutil.hh" + +static RCS_CMD_CHANNEL *cmdChannel; +static RCS_STAT_CHANNEL *statChannel; + +static const EMC_STAT &stat() +{ + statChannel->peek(); + return *static_cast(statChannel->get_address()); +} + +// Send a command and wait until task has taken it. Returns its serial +// number, or -1. +static int send(RCS_CMD_MSG &cmd) +{ + if (cmdChannel->write(&cmd) != 0) { + return -1; + } + const int serial = cmd.serial_number; + const double end = linuxcnc::etime() + 10.0; + while (linuxcnc::etime() < end) { + if (stat().echo_serial_number - serial >= 0) { + return serial; + } + usleep(1000); + } + fprintf(stderr, "test_task_probe: timeout waiting for serial %d\n", serial); + return -1; +} + +static int display(const std::string &text) +{ + EMC_OPERATOR_DISPLAY msg; + snprintf(msg.display, sizeof(msg.display), "%s", text.c_str()); + return send(msg); +} + +// A joint number no machine has: the joint commands that check their +// joint number then do nothing at all. +static const int NO_JOINT = EMCMOT_MAX_JOINTS; + +typedef std::function(const EMC_STAT &)> Maker; + +// The command, built with arguments that leave things as they are where +// that is possible: the values task already has, joint NO_JOINT, spindle 0. +static std::vector> commands() +{ + std::vector> c; + +#define CMD(name, T, body) \ + c.emplace_back(name, [](const EMC_STAT &s) -> std::unique_ptr { \ + auto m = std::make_unique(); \ + (void)s; \ + body; \ + return m; \ + }) + + CMD("EMC_NULL", EMC_NULL, ); + + // joint configuration, for a joint that does not exist + CMD("EMC_JOINT_SET_BACKLASH", EMC_JOINT_SET_BACKLASH, m->joint = NO_JOINT); + CMD("EMC_JOINT_SET_HOMING_PARAMS", EMC_JOINT_SET_HOMING_PARAMS, m->joint = NO_JOINT); + CMD("EMC_JOINT_SET_FERROR", EMC_JOINT_SET_FERROR, m->joint = NO_JOINT); + CMD("EMC_JOINT_SET_MIN_FERROR", EMC_JOINT_SET_MIN_FERROR, m->joint = NO_JOINT); + CMD("EMC_JOINT_SET_MAX_POSITION_LIMIT", EMC_JOINT_SET_MAX_POSITION_LIMIT, m->joint = NO_JOINT); + CMD("EMC_JOINT_SET_MIN_POSITION_LIMIT", EMC_JOINT_SET_MIN_POSITION_LIMIT, m->joint = NO_JOINT); + CMD("EMC_JOINT_LOAD_COMP", EMC_JOINT_LOAD_COMP, m->joint = NO_JOINT); + CMD("EMC_JOINT_HALT", EMC_JOINT_HALT, m->joint = NO_JOINT); + CMD("EMC_JOINT_HOME", EMC_JOINT_HOME, m->joint = NO_JOINT); + CMD("EMC_JOINT_UNHOME", EMC_JOINT_UNHOME, m->joint = NO_JOINT); + CMD("EMC_JOINT_OVERRIDE_LIMITS", EMC_JOINT_OVERRIDE_LIMITS, m->joint = NO_JOINT); + + // jogs of a joint or axis that does not exist + CMD("EMC_JOG_CONT", EMC_JOG_CONT, m->joint_or_axis = NO_JOINT; m->jjogmode = 1); + CMD("EMC_JOG_INCR", EMC_JOG_INCR, m->joint_or_axis = NO_JOINT; m->jjogmode = 1); + CMD("EMC_JOG_ABS", EMC_JOG_ABS, m->joint_or_axis = NO_JOINT; m->jjogmode = 1); + CMD("EMC_JOG_STOP", EMC_JOG_STOP, m->joint_or_axis = NO_JOINT; m->jjogmode = 1); + + // trajectory settings, set to what they are + CMD("EMC_TRAJ_SET_SCALE", EMC_TRAJ_SET_SCALE, m->scale = s.motion.traj.scale); + CMD("EMC_TRAJ_SET_RAPID_SCALE", EMC_TRAJ_SET_RAPID_SCALE, m->scale = s.motion.traj.rapid_scale); + CMD("EMC_TRAJ_SET_MAX_VELOCITY", EMC_TRAJ_SET_MAX_VELOCITY, m->velocity = s.motion.traj.maxVelocity); + CMD("EMC_TRAJ_SET_SPINDLE_SCALE", EMC_TRAJ_SET_SPINDLE_SCALE, + m->spindle = 0; m->scale = s.motion.spindle[0].spindle_scale); + CMD("EMC_TRAJ_SET_FO_ENABLE", EMC_TRAJ_SET_FO_ENABLE, m->mode = s.motion.traj.feed_override_enabled); + CMD("EMC_TRAJ_SET_FH_ENABLE", EMC_TRAJ_SET_FH_ENABLE, m->mode = s.motion.traj.feed_hold_enabled); + CMD("EMC_TRAJ_SET_SO_ENABLE", EMC_TRAJ_SET_SO_ENABLE, + m->spindle = 0; m->mode = s.motion.spindle[0].spindle_override_enabled); + CMD("EMC_TRAJ_SET_VELOCITY", EMC_TRAJ_SET_VELOCITY, + m->velocity = s.motion.traj.velocity; m->ini_maxvel = s.motion.traj.maxVelocity); + CMD("EMC_TRAJ_SET_ACCELERATION", EMC_TRAJ_SET_ACCELERATION, m->acceleration = s.motion.traj.acceleration); + CMD("EMC_TRAJ_SET_TELEOP_ENABLE", EMC_TRAJ_SET_TELEOP_ENABLE, + m->enable = s.motion.traj.mode == EMC_TRAJ_MODE::TELEOP); + CMD("EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG", EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG, ); + CMD("EMC_MOTION_SET_DOUT", EMC_MOTION_SET_DOUT, m->index = 0; m->start = 0; m->end = 0; m->now = 1); + CMD("EMC_MOTION_SET_AOUT", EMC_MOTION_SET_AOUT, m->index = 0; m->start = 0; m->end = 0; m->now = 1); + CMD("EMC_MOTION_ADAPTIVE", EMC_MOTION_ADAPTIVE, m->status = s.motion.traj.adaptive_feed_enabled); + CMD("EMC_AUX_INPUT_WAIT", EMC_AUX_INPUT_WAIT, + m->index = 0; m->input_type = 0; m->wait_type = 0; m->timeout = 0); + CMD("EMC_SET_DEBUG", EMC_SET_DEBUG, m->debug = s.debug); + + // spindle and coolant, each "on" followed by its "off" + CMD("EMC_SPINDLE_SPEED", EMC_SPINDLE_SPEED, m->spindle = 0; m->speed = s.motion.spindle[0].speed); + CMD("EMC_SPINDLE_ON", EMC_SPINDLE_ON, m->spindle = 0; m->speed = 0); + CMD("EMC_SPINDLE_INCREASE", EMC_SPINDLE_INCREASE, m->spindle = 0); + CMD("EMC_SPINDLE_DECREASE", EMC_SPINDLE_DECREASE, m->spindle = 0); + CMD("EMC_SPINDLE_CONSTANT", EMC_SPINDLE_CONSTANT, m->spindle = 0); + CMD("EMC_SPINDLE_OFF", EMC_SPINDLE_OFF, m->spindle = 0); + CMD("EMC_SPINDLE_BRAKE_ENGAGE", EMC_SPINDLE_BRAKE_ENGAGE, m->spindle = 0); + CMD("EMC_SPINDLE_BRAKE_RELEASE", EMC_SPINDLE_BRAKE_RELEASE, m->spindle = 0); + CMD("EMC_COOLANT_MIST_ON", EMC_COOLANT_MIST_ON, ); + CMD("EMC_COOLANT_MIST_OFF", EMC_COOLANT_MIST_OFF, ); + CMD("EMC_COOLANT_FLOOD_ON", EMC_COOLANT_FLOOD_ON, ); + CMD("EMC_COOLANT_FLOOD_OFF", EMC_COOLANT_FLOOD_OFF, ); + + // the interpreter's settings, set to what they are + CMD("EMC_TASK_PLAN_SET_OPTIONAL_STOP", EMC_TASK_PLAN_SET_OPTIONAL_STOP, + m->state = s.task.optional_stop_state); + CMD("EMC_TASK_PLAN_SET_BLOCK_DELETE", EMC_TASK_PLAN_SET_BLOCK_DELETE, + m->state = s.task.block_delete_state); + CMD("EMC_TASK_PLAN_SYNCH", EMC_TASK_PLAN_SYNCH, ); + CMD("EMC_TASK_PLAN_OPEN", EMC_TASK_PLAN_OPEN, + snprintf(m->file, sizeof(m->file), "%s", s.task.file)); + + // A command the planner has no case for, so refused unless a state + // accepts it without looking, and one the interpreter never queues, + // which would make it look queued. Should it get through, it sets the + // mode motion is in. + CMD("EMC_TRAJ_SET_MODE", EMC_TRAJ_SET_MODE, m->mode = s.motion.traj.mode); + + // Commands that may well change task's state. The test sets the state + // up again after each of them. + CMD("EMC_TOOL_LOAD_TOOL_TABLE", EMC_TOOL_LOAD_TOOL_TABLE, ); + CMD("EMC_TOOL_SET_NUMBER", EMC_TOOL_SET_NUMBER, m->tool = s.io.tool.toolInSpindle); + CMD("EMC_TOOL_SET_OFFSET", EMC_TOOL_SET_OFFSET, m->pocket = 1; m->toolno = 1; m->diameter = 0.25); + CMD("EMC_SPINDLE_ORIENT", EMC_SPINDLE_ORIENT, m->spindle = 0); + CMD("EMC_SPINDLE_WAIT_ORIENT_COMPLETE", EMC_SPINDLE_WAIT_ORIENT_COMPLETE, + m->spindle = 0; m->timeout = 0.001); + CMD("EMC_TRAJ_PROBE", EMC_TRAJ_PROBE, m->pos = s.motion.traj.position); + CMD("EMC_TRAJ_RIGID_TAP", EMC_TRAJ_RIGID_TAP, m->pos = s.motion.traj.position); + CMD("EMC_TASK_PLAN_OPTIONAL_STOP", EMC_TASK_PLAN_OPTIONAL_STOP, ); + CMD("EMC_TASK_PLAN_EXECUTE", EMC_TASK_PLAN_EXECUTE, + snprintf(m->command, sizeof(m->command), "(probe)")); + CMD("EMC_TASK_PLAN_INIT", EMC_TASK_PLAN_INIT, ); + CMD("EMC_TASK_PLAN_CLOSE", EMC_TASK_PLAN_CLOSE, ); + CMD("EMC_TASK_PLAN_RUN", EMC_TASK_PLAN_RUN, m->line = 0); + CMD("EMC_TASK_PLAN_STEP", EMC_TASK_PLAN_STEP, ); + CMD("EMC_TASK_PLAN_PAUSE", EMC_TASK_PLAN_PAUSE, ); + CMD("EMC_TASK_PLAN_RESUME", EMC_TASK_PLAN_RESUME, ); + CMD("EMC_TASK_PLAN_REVERSE", EMC_TASK_PLAN_REVERSE, ); + CMD("EMC_TASK_PLAN_FORWARD", EMC_TASK_PLAN_FORWARD, ); + CMD("EMC_TASK_ABORT", EMC_TASK_ABORT, ); + CMD("EMC_TASK_SET_MODE(MANUAL)", EMC_TASK_SET_MODE, m->mode = EMC_TASK_MODE::MANUAL); + CMD("EMC_TASK_SET_MODE(AUTO)", EMC_TASK_SET_MODE, m->mode = EMC_TASK_MODE::AUTO); + CMD("EMC_TASK_SET_MODE(MDI)", EMC_TASK_SET_MODE, m->mode = EMC_TASK_MODE::MDI); + CMD("EMC_TASK_SET_STATE(ESTOP)", EMC_TASK_SET_STATE, m->state = EMC_TASK_STATE::ESTOP); + CMD("EMC_TASK_SET_STATE(ESTOP_RESET)", EMC_TASK_SET_STATE, m->state = EMC_TASK_STATE::ESTOP_RESET); + CMD("EMC_TASK_SET_STATE(OFF)", EMC_TASK_SET_STATE, m->state = EMC_TASK_STATE::OFF); + CMD("EMC_TASK_SET_STATE(ON)", EMC_TASK_SET_STATE, m->state = EMC_TASK_STATE::ON); + +#undef CMD + return c; +} + +int main(int argc, char *argv[]) +{ + if (emcGetArgs(argc, argv) != 0) { + fprintf(stderr, "usage: %s [-ini INIFILE]\n", argv[0]); + return 1; + } + { + linuxcnc::IniFile inifile(emc_inifile); + if (inifile) { + if (auto nml = inifile.findString("NML_FILE", "EMC")) { + snprintf(emc_nmlfile, sizeof(emc_nmlfile), "%s", nml->c_str()); + } + } + } + + // like shcom's tryNml(): the status needs a moment after connecting + const double end = linuxcnc::etime() + 10.0; + while (true) { + cmdChannel = new RCS_CMD_CHANNEL(emcFormat, "emcCommand", "xemc", emc_nmlfile); + statChannel = new RCS_STAT_CHANNEL(emcFormat, "emcStatus", "xemc", emc_nmlfile); + if (cmdChannel->valid() && statChannel->valid() && statChannel->peek() == EMC_STAT_TYPE) { + break; + } + delete cmdChannel; + delete statChannel; + if (linuxcnc::etime() > end) { + fprintf(stderr, "test_task_probe: can't connect to task\n"); + return 1; + } + usleep(100000); + } + + const auto cmds = commands(); + std::map byName; + for (const auto &c : cmds) { + byName[c.first] = &c.second; + } + + std::string line; + while (std::getline(std::cin, line)) { + char what[32], label[64], name[64]; + int n = sscanf(line.c_str(), "%31s %63s %63s", what, label, name); + if (n >= 1 && strcmp(what, "list") == 0) { + for (const auto &c : cmds) { + printf("%s\n", c.first.c_str()); + } + printf("end\n"); + } else if (n == 3 && strcmp(what, "probe") == 0 && byName.count(name)) { + auto cmd = (*byName[name])(stat()); + int serial = -1; + if (display(std::string("probe-begin ") + label + " " + name) >= 0) { + serial = send(*cmd); + display("probe-end"); + } + printf("serial %d\n", serial); + } else { + printf("error %s\n", line.c_str()); + } + fflush(stdout); + } + return 0; +} diff --git a/tests/task-planner/.gitignore b/tests/task-planner/.gitignore new file mode 100644 index 00000000000..03a2396556e --- /dev/null +++ b/tests/task-planner/.gitignore @@ -0,0 +1,5 @@ +tool.tbl +reading.ngc +sim.var +sim.var.bak +planner-table diff --git a/tests/task-planner/checkresult b/tests/task-planner/checkresult new file mode 100755 index 00000000000..3a4bb810285 --- /dev/null +++ b/tests/task-planner/checkresult @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 + +# Build the planner table from the test's output and compare it with the +# expected one. +# +# Task prints (EMC_DEBUG_TASK_ISSUE) every command it issues, with its serial +# number, and (EMC_DEBUG_INTERP_LIST) every command it queues for later. +# test_task_probe brackets each probe by two operator display messages, so +# what task did with the probe sits between "probe-begin" and "probe-end". +# The first of these decides: +# +# issued task issued the command (the serial is the probe's) +# queued task queued a command of that type for later +# refused task said it can't do that now +# handled none of these: the planner dealt with it itself, or ignored it +# +# test-ui.py adds the situation the command left task in, when it changed. +# +# The table is written to planner-table; to accept a change of behaviour, +# copy it over expected. + +import os +import re +import sys + +result = sys.argv[1] +here = os.path.dirname(os.path.abspath(sys.argv[0])) + +BEGIN = re.compile(r"^Issuing EMC_OPERATOR_DISPLAY -- \t \(.*,probe-begin\\032(\S+?)\\032(\S+),\)$") +END = re.compile(r"^Issuing EMC_OPERATOR_DISPLAY -- \t \(.*,probe-end,\)$") +ISSUED = re.compile(r"^Issuing (\S+) -- \t \(\s*\+\d+,\+\d+,\s*\+(\d+),") +QUEUED = re.compile(r"^InterpList\(0x[0-9a-f]+\)::append\((\S+)\)") +REFUSED = re.compile(r"can't do that|cannot be executed until") +PROBE = re.compile(r"^PROBE (\S+) (\S+) (\d+) (\S+)$") + +windows = {} # (situation, command) -> lines between the markers +probes = [] # (situation, command, serial, situation afterwards) +current = None +with open(result, errors='replace') as f: + for line in f: + line = line.rstrip('\n') + m = PROBE.match(line) + if m: + probes.append((m.group(1), m.group(2), int(m.group(3)), m.group(4))) + continue + m = BEGIN.match(line) + if m: + current = (m.group(1), m.group(2)) + windows[current] = [] + continue + if END.match(line): + current = None + continue + if current is not None: + windows[current].append(line) + + +def outcome(command, serial, lines): + base = command.split('(')[0] + for line in lines: + m = ISSUED.match(line) + if m and int(m.group(2)) == serial: + return 'issued' + m = QUEUED.match(line) + if m and m.group(1) == base: + return 'queued' + if REFUSED.search(line): + return 'refused' + return 'handled' + + +situations = [] +commands = [] +cells = {} +for situation, command, serial, after in probes: + if situation not in situations: + situations.append(situation) + if command not in commands: + commands.append(command) + lines = windows.get((situation, command)) + if lines is None: + cell = 'missing' + else: + cell = outcome(command, serial, lines) + if after != '-': + cell += ' -> ' + after + cells[(situation, command)] = cell + +if not probes: + print("no probes in the test output") + sys.exit(1) + +width = max(len(c) for c in commands) +table = [] +for situation in situations: + table.append("[%s]" % situation) + for command in commands: + table.append("%-*s %s" % (width, command, cells.get((situation, command), 'missing'))) + table.append("") +text = "\n".join(table) + +with open(os.path.join(here, 'planner-table'), 'w') as f: + f.write(text) + +try: + with open(os.path.join(here, 'expected')) as f: + expected = f.read() +except FileNotFoundError: + print("no expected table; this run's table is in planner-table") + sys.exit(1) + +if expected == text: + sys.exit(0) + +import difflib +sys.stdout.writelines(difflib.unified_diff(expected.splitlines(True), text.splitlines(True), + 'expected', 'planner-table')) +sys.exit(1) diff --git a/tests/task-planner/expected b/tests/task-planner/expected new file mode 100644 index 00000000000..edd8a9b24b6 --- /dev/null +++ b/tests/task-planner/expected @@ -0,0 +1,683 @@ +[estop] +EMC_NULL handled +EMC_JOINT_SET_BACKLASH issued +EMC_JOINT_SET_HOMING_PARAMS issued +EMC_JOINT_SET_FERROR issued +EMC_JOINT_SET_MIN_FERROR issued +EMC_JOINT_SET_MAX_POSITION_LIMIT refused +EMC_JOINT_SET_MIN_POSITION_LIMIT refused +EMC_JOINT_LOAD_COMP issued +EMC_JOINT_HALT refused +EMC_JOINT_HOME refused +EMC_JOINT_UNHOME issued +EMC_JOINT_OVERRIDE_LIMITS issued +EMC_JOG_CONT refused +EMC_JOG_INCR refused +EMC_JOG_ABS refused +EMC_JOG_STOP refused +EMC_TRAJ_SET_SCALE issued +EMC_TRAJ_SET_RAPID_SCALE issued +EMC_TRAJ_SET_MAX_VELOCITY issued +EMC_TRAJ_SET_SPINDLE_SCALE issued +EMC_TRAJ_SET_FO_ENABLE issued +EMC_TRAJ_SET_FH_ENABLE issued +EMC_TRAJ_SET_SO_ENABLE issued +EMC_TRAJ_SET_VELOCITY issued +EMC_TRAJ_SET_ACCELERATION issued +EMC_TRAJ_SET_TELEOP_ENABLE issued +EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued +EMC_MOTION_SET_DOUT issued +EMC_MOTION_SET_AOUT issued +EMC_MOTION_ADAPTIVE issued +EMC_AUX_INPUT_WAIT issued +EMC_SET_DEBUG issued +EMC_SPINDLE_SPEED refused +EMC_SPINDLE_ON refused +EMC_SPINDLE_INCREASE refused +EMC_SPINDLE_DECREASE refused +EMC_SPINDLE_CONSTANT refused +EMC_SPINDLE_OFF refused +EMC_SPINDLE_BRAKE_ENGAGE refused +EMC_SPINDLE_BRAKE_RELEASE refused +EMC_COOLANT_MIST_ON refused +EMC_COOLANT_MIST_OFF refused +EMC_COOLANT_FLOOD_ON refused +EMC_COOLANT_FLOOD_OFF refused +EMC_TASK_PLAN_SET_OPTIONAL_STOP issued +EMC_TASK_PLAN_SET_BLOCK_DELETE issued +EMC_TASK_PLAN_SYNCH issued +EMC_TASK_PLAN_OPEN issued +EMC_TRAJ_SET_MODE refused +EMC_TOOL_LOAD_TOOL_TABLE queued +EMC_TOOL_SET_NUMBER queued +EMC_TOOL_SET_OFFSET queued +EMC_SPINDLE_ORIENT refused +EMC_SPINDLE_WAIT_ORIENT_COMPLETE refused +EMC_TRAJ_PROBE issued +EMC_TRAJ_RIGID_TAP issued +EMC_TASK_PLAN_OPTIONAL_STOP refused +EMC_TASK_PLAN_EXECUTE refused +EMC_TASK_PLAN_INIT issued -> ESTOP/MANUAL/IDLE +EMC_TASK_PLAN_CLOSE issued +EMC_TASK_PLAN_RUN refused +EMC_TASK_PLAN_STEP refused +EMC_TASK_PLAN_PAUSE refused +EMC_TASK_PLAN_RESUME refused +EMC_TASK_PLAN_REVERSE refused +EMC_TASK_PLAN_FORWARD refused +EMC_TASK_ABORT issued +EMC_TASK_SET_MODE(MANUAL) issued +EMC_TASK_SET_MODE(AUTO) issued -> ESTOP/AUTO/IDLE/reading.ngc +EMC_TASK_SET_MODE(MDI) issued -> ESTOP/MDI/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP) issued +EMC_TASK_SET_STATE(ESTOP_RESET) issued -> OFF/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_STATE(OFF) issued +EMC_TASK_SET_STATE(ON) issued + +[off] +EMC_NULL handled +EMC_JOINT_SET_BACKLASH issued +EMC_JOINT_SET_HOMING_PARAMS issued +EMC_JOINT_SET_FERROR issued +EMC_JOINT_SET_MIN_FERROR issued +EMC_JOINT_SET_MAX_POSITION_LIMIT refused +EMC_JOINT_SET_MIN_POSITION_LIMIT refused +EMC_JOINT_LOAD_COMP issued +EMC_JOINT_HALT refused +EMC_JOINT_HOME refused +EMC_JOINT_UNHOME issued +EMC_JOINT_OVERRIDE_LIMITS handled +EMC_JOG_CONT refused +EMC_JOG_INCR refused +EMC_JOG_ABS refused +EMC_JOG_STOP refused +EMC_TRAJ_SET_SCALE issued +EMC_TRAJ_SET_RAPID_SCALE issued +EMC_TRAJ_SET_MAX_VELOCITY issued +EMC_TRAJ_SET_SPINDLE_SCALE issued +EMC_TRAJ_SET_FO_ENABLE issued +EMC_TRAJ_SET_FH_ENABLE issued +EMC_TRAJ_SET_SO_ENABLE issued +EMC_TRAJ_SET_VELOCITY issued +EMC_TRAJ_SET_ACCELERATION issued +EMC_TRAJ_SET_TELEOP_ENABLE issued -> OFF/MANUAL/IDLE/reading.ngc +EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued +EMC_MOTION_SET_DOUT issued +EMC_MOTION_SET_AOUT issued +EMC_MOTION_ADAPTIVE issued +EMC_AUX_INPUT_WAIT issued +EMC_SET_DEBUG issued +EMC_SPINDLE_SPEED refused +EMC_SPINDLE_ON refused +EMC_SPINDLE_INCREASE refused +EMC_SPINDLE_DECREASE refused +EMC_SPINDLE_CONSTANT refused +EMC_SPINDLE_OFF refused +EMC_SPINDLE_BRAKE_ENGAGE refused +EMC_SPINDLE_BRAKE_RELEASE refused +EMC_COOLANT_MIST_ON refused +EMC_COOLANT_MIST_OFF refused +EMC_COOLANT_FLOOD_ON refused +EMC_COOLANT_FLOOD_OFF refused +EMC_TASK_PLAN_SET_OPTIONAL_STOP issued +EMC_TASK_PLAN_SET_BLOCK_DELETE issued +EMC_TASK_PLAN_SYNCH issued +EMC_TASK_PLAN_OPEN issued +EMC_TRAJ_SET_MODE refused +EMC_TOOL_LOAD_TOOL_TABLE queued +EMC_TOOL_SET_NUMBER queued +EMC_TOOL_SET_OFFSET queued +EMC_SPINDLE_ORIENT refused +EMC_SPINDLE_WAIT_ORIENT_COMPLETE refused +EMC_TRAJ_PROBE issued +EMC_TRAJ_RIGID_TAP issued +EMC_TASK_PLAN_OPTIONAL_STOP refused +EMC_TASK_PLAN_EXECUTE refused +EMC_TASK_PLAN_INIT issued -> OFF/AUTO/IDLE +EMC_TASK_PLAN_CLOSE issued +EMC_TASK_PLAN_RUN refused +EMC_TASK_PLAN_STEP refused +EMC_TASK_PLAN_PAUSE refused +EMC_TASK_PLAN_RESUME refused +EMC_TASK_PLAN_REVERSE refused +EMC_TASK_PLAN_FORWARD refused +EMC_TASK_ABORT issued +EMC_TASK_SET_MODE(MANUAL) issued -> OFF/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_MODE(AUTO) issued +EMC_TASK_SET_MODE(MDI) issued -> OFF/MDI/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/AUTO/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP_RESET) issued +EMC_TASK_SET_STATE(OFF) issued +EMC_TASK_SET_STATE(ON) issued -> ON/AUTO/IDLE/reading.ngc + +[manual] +EMC_NULL handled +EMC_JOINT_SET_BACKLASH issued +EMC_JOINT_SET_HOMING_PARAMS issued +EMC_JOINT_SET_FERROR issued +EMC_JOINT_SET_MIN_FERROR issued +EMC_JOINT_SET_MAX_POSITION_LIMIT issued +EMC_JOINT_SET_MIN_POSITION_LIMIT issued +EMC_JOINT_LOAD_COMP refused +EMC_JOINT_HALT issued +EMC_JOINT_HOME issued +EMC_JOINT_UNHOME issued +EMC_JOINT_OVERRIDE_LIMITS issued +EMC_JOG_CONT issued +EMC_JOG_INCR issued +EMC_JOG_ABS issued +EMC_JOG_STOP issued +EMC_TRAJ_SET_SCALE issued +EMC_TRAJ_SET_RAPID_SCALE issued +EMC_TRAJ_SET_MAX_VELOCITY issued +EMC_TRAJ_SET_SPINDLE_SCALE issued +EMC_TRAJ_SET_FO_ENABLE issued +EMC_TRAJ_SET_FH_ENABLE issued +EMC_TRAJ_SET_SO_ENABLE issued +EMC_TRAJ_SET_VELOCITY refused +EMC_TRAJ_SET_ACCELERATION refused +EMC_TRAJ_SET_TELEOP_ENABLE issued +EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued +EMC_MOTION_SET_DOUT issued +EMC_MOTION_SET_AOUT issued +EMC_MOTION_ADAPTIVE issued +EMC_AUX_INPUT_WAIT issued +EMC_SET_DEBUG issued +EMC_SPINDLE_SPEED issued +EMC_SPINDLE_ON issued +EMC_SPINDLE_INCREASE issued +EMC_SPINDLE_DECREASE issued +EMC_SPINDLE_CONSTANT issued +EMC_SPINDLE_OFF issued +EMC_SPINDLE_BRAKE_ENGAGE issued +EMC_SPINDLE_BRAKE_RELEASE issued +EMC_COOLANT_MIST_ON issued +EMC_COOLANT_MIST_OFF issued +EMC_COOLANT_FLOOD_ON issued +EMC_COOLANT_FLOOD_OFF issued +EMC_TASK_PLAN_SET_OPTIONAL_STOP issued +EMC_TASK_PLAN_SET_BLOCK_DELETE issued +EMC_TASK_PLAN_SYNCH issued +EMC_TASK_PLAN_OPEN issued +EMC_TRAJ_SET_MODE refused +EMC_TOOL_LOAD_TOOL_TABLE queued +EMC_TOOL_SET_NUMBER queued +EMC_TOOL_SET_OFFSET queued +EMC_SPINDLE_ORIENT refused +EMC_SPINDLE_WAIT_ORIENT_COMPLETE refused +EMC_TRAJ_PROBE issued +EMC_TRAJ_RIGID_TAP issued +EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/MANUAL/PAUSED/reading.ngc +EMC_TASK_PLAN_EXECUTE issued +EMC_TASK_PLAN_INIT issued -> ON/MANUAL/IDLE +EMC_TASK_PLAN_CLOSE issued +EMC_TASK_PLAN_RUN handled +EMC_TASK_PLAN_STEP refused +EMC_TASK_PLAN_PAUSE issued -> ON/MANUAL/PAUSED/reading.ngc +EMC_TASK_PLAN_RESUME issued +EMC_TASK_PLAN_REVERSE issued +EMC_TASK_PLAN_FORWARD issued +EMC_TASK_ABORT issued +EMC_TASK_SET_MODE(MANUAL) issued +EMC_TASK_SET_MODE(AUTO) issued -> ON/AUTO/IDLE/reading.ngc +EMC_TASK_SET_MODE(MDI) issued -> ON/MDI/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP_RESET) issued +EMC_TASK_SET_STATE(OFF) issued -> OFF/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_STATE(ON) issued + +[mdi] +EMC_NULL handled +EMC_JOINT_SET_BACKLASH issued +EMC_JOINT_SET_HOMING_PARAMS issued +EMC_JOINT_SET_FERROR issued +EMC_JOINT_SET_MIN_FERROR issued +EMC_JOINT_SET_MAX_POSITION_LIMIT refused +EMC_JOINT_SET_MIN_POSITION_LIMIT refused +EMC_JOINT_LOAD_COMP refused +EMC_JOINT_HALT refused +EMC_JOINT_HOME refused +EMC_JOINT_UNHOME issued +EMC_JOINT_OVERRIDE_LIMITS refused +EMC_JOG_CONT issued +EMC_JOG_INCR issued +EMC_JOG_ABS issued +EMC_JOG_STOP issued +EMC_TRAJ_SET_SCALE issued +EMC_TRAJ_SET_RAPID_SCALE issued +EMC_TRAJ_SET_MAX_VELOCITY issued +EMC_TRAJ_SET_SPINDLE_SCALE issued +EMC_TRAJ_SET_FO_ENABLE issued +EMC_TRAJ_SET_FH_ENABLE issued +EMC_TRAJ_SET_SO_ENABLE issued +EMC_TRAJ_SET_VELOCITY refused +EMC_TRAJ_SET_ACCELERATION refused +EMC_TRAJ_SET_TELEOP_ENABLE issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued +EMC_MOTION_SET_DOUT issued +EMC_MOTION_SET_AOUT issued +EMC_MOTION_ADAPTIVE issued +EMC_AUX_INPUT_WAIT issued +EMC_SET_DEBUG issued +EMC_SPINDLE_SPEED issued +EMC_SPINDLE_ON issued +EMC_SPINDLE_INCREASE issued +EMC_SPINDLE_DECREASE issued +EMC_SPINDLE_CONSTANT issued +EMC_SPINDLE_OFF issued +EMC_SPINDLE_BRAKE_ENGAGE issued +EMC_SPINDLE_BRAKE_RELEASE issued +EMC_COOLANT_MIST_ON issued +EMC_COOLANT_MIST_OFF issued +EMC_COOLANT_FLOOD_ON issued +EMC_COOLANT_FLOOD_OFF issued +EMC_TASK_PLAN_SET_OPTIONAL_STOP issued +EMC_TASK_PLAN_SET_BLOCK_DELETE issued +EMC_TASK_PLAN_SYNCH issued +EMC_TASK_PLAN_OPEN issued +EMC_TRAJ_SET_MODE refused +EMC_TOOL_LOAD_TOOL_TABLE queued +EMC_TOOL_SET_NUMBER refused +EMC_TOOL_SET_OFFSET queued +EMC_SPINDLE_ORIENT issued +EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued +EMC_TRAJ_PROBE issued +EMC_TRAJ_RIGID_TAP issued +EMC_TASK_PLAN_OPTIONAL_STOP issued +EMC_TASK_PLAN_EXECUTE issued +EMC_TASK_PLAN_INIT issued -> ON/MDI/IDLE +EMC_TASK_PLAN_CLOSE issued +EMC_TASK_PLAN_RUN refused +EMC_TASK_PLAN_STEP refused +EMC_TASK_PLAN_PAUSE issued +EMC_TASK_PLAN_RESUME issued +EMC_TASK_PLAN_REVERSE issued +EMC_TASK_PLAN_FORWARD issued +EMC_TASK_ABORT issued +EMC_TASK_SET_MODE(MANUAL) issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_MODE(AUTO) issued -> ON/AUTO/IDLE/reading.ngc +EMC_TASK_SET_MODE(MDI) issued +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MDI/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP_RESET) issued +EMC_TASK_SET_STATE(OFF) issued -> OFF/MDI/IDLE/reading.ngc +EMC_TASK_SET_STATE(ON) issued + +[mdi-busy] +EMC_NULL handled +EMC_JOINT_SET_BACKLASH issued +EMC_JOINT_SET_HOMING_PARAMS issued +EMC_JOINT_SET_FERROR issued +EMC_JOINT_SET_MIN_FERROR issued +EMC_JOINT_SET_MAX_POSITION_LIMIT refused +EMC_JOINT_SET_MIN_POSITION_LIMIT refused +EMC_JOINT_LOAD_COMP refused +EMC_JOINT_HALT refused +EMC_JOINT_HOME refused +EMC_JOINT_UNHOME issued +EMC_JOINT_OVERRIDE_LIMITS refused +EMC_JOG_CONT issued +EMC_JOG_INCR issued +EMC_JOG_ABS issued +EMC_JOG_STOP issued +EMC_TRAJ_SET_SCALE issued +EMC_TRAJ_SET_RAPID_SCALE issued +EMC_TRAJ_SET_MAX_VELOCITY issued +EMC_TRAJ_SET_SPINDLE_SCALE issued +EMC_TRAJ_SET_FO_ENABLE issued +EMC_TRAJ_SET_FH_ENABLE issued +EMC_TRAJ_SET_SO_ENABLE issued +EMC_TRAJ_SET_VELOCITY refused +EMC_TRAJ_SET_ACCELERATION refused +EMC_TRAJ_SET_TELEOP_ENABLE issued -> ON/MANUAL/READING/reading.ngc +EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued +EMC_MOTION_SET_DOUT issued +EMC_MOTION_SET_AOUT issued +EMC_MOTION_ADAPTIVE issued +EMC_AUX_INPUT_WAIT issued -> ON/MDI/IDLE/reading.ngc +EMC_SET_DEBUG issued +EMC_SPINDLE_SPEED issued +EMC_SPINDLE_ON issued +EMC_SPINDLE_INCREASE issued +EMC_SPINDLE_DECREASE issued +EMC_SPINDLE_CONSTANT issued +EMC_SPINDLE_OFF issued +EMC_SPINDLE_BRAKE_ENGAGE issued +EMC_SPINDLE_BRAKE_RELEASE issued +EMC_COOLANT_MIST_ON issued +EMC_COOLANT_MIST_OFF issued +EMC_COOLANT_FLOOD_ON issued +EMC_COOLANT_FLOOD_OFF issued +EMC_TASK_PLAN_SET_OPTIONAL_STOP issued +EMC_TASK_PLAN_SET_BLOCK_DELETE issued +EMC_TASK_PLAN_SYNCH issued +EMC_TASK_PLAN_OPEN issued +EMC_TRAJ_SET_MODE refused +EMC_TOOL_LOAD_TOOL_TABLE queued +EMC_TOOL_SET_NUMBER refused +EMC_TOOL_SET_OFFSET queued +EMC_SPINDLE_ORIENT issued +EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued -> ON/MDI/IDLE/reading.ngc +EMC_TRAJ_PROBE issued -> ON/MDI/IDLE/reading.ngc +EMC_TRAJ_RIGID_TAP issued -> ON/MDI/IDLE/reading.ngc +EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/MDI/PAUSED/reading.ngc +EMC_TASK_PLAN_EXECUTE issued +EMC_TASK_PLAN_INIT issued -> ON/MDI/READING +EMC_TASK_PLAN_CLOSE issued +EMC_TASK_PLAN_RUN refused +EMC_TASK_PLAN_STEP refused +EMC_TASK_PLAN_PAUSE issued -> ON/MDI/PAUSED/reading.ngc +EMC_TASK_PLAN_RESUME issued +EMC_TASK_PLAN_REVERSE issued +EMC_TASK_PLAN_FORWARD issued +EMC_TASK_ABORT issued -> ON/MDI/IDLE/reading.ngc +EMC_TASK_SET_MODE(MANUAL) issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_MODE(AUTO) issued -> ON/AUTO/IDLE/reading.ngc +EMC_TASK_SET_MODE(MDI) issued -> ON/MDI/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MDI/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/MDI/IDLE/reading.ngc +EMC_TASK_SET_STATE(OFF) issued -> OFF/MDI/IDLE/reading.ngc +EMC_TASK_SET_STATE(ON) issued + +[auto] +EMC_NULL handled +EMC_JOINT_SET_BACKLASH issued +EMC_JOINT_SET_HOMING_PARAMS issued +EMC_JOINT_SET_FERROR issued +EMC_JOINT_SET_MIN_FERROR issued +EMC_JOINT_SET_MAX_POSITION_LIMIT refused +EMC_JOINT_SET_MIN_POSITION_LIMIT refused +EMC_JOINT_LOAD_COMP refused +EMC_JOINT_HALT refused +EMC_JOINT_HOME refused +EMC_JOINT_UNHOME issued +EMC_JOINT_OVERRIDE_LIMITS refused +EMC_JOG_CONT issued +EMC_JOG_INCR issued +EMC_JOG_ABS issued +EMC_JOG_STOP issued +EMC_TRAJ_SET_SCALE issued +EMC_TRAJ_SET_RAPID_SCALE issued +EMC_TRAJ_SET_MAX_VELOCITY issued +EMC_TRAJ_SET_SPINDLE_SCALE issued +EMC_TRAJ_SET_FO_ENABLE issued +EMC_TRAJ_SET_FH_ENABLE issued +EMC_TRAJ_SET_SO_ENABLE issued +EMC_TRAJ_SET_VELOCITY refused +EMC_TRAJ_SET_ACCELERATION refused +EMC_TRAJ_SET_TELEOP_ENABLE issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued +EMC_MOTION_SET_DOUT refused +EMC_MOTION_SET_AOUT refused +EMC_MOTION_ADAPTIVE refused +EMC_AUX_INPUT_WAIT issued +EMC_SET_DEBUG issued +EMC_SPINDLE_SPEED issued +EMC_SPINDLE_ON issued +EMC_SPINDLE_INCREASE issued +EMC_SPINDLE_DECREASE issued +EMC_SPINDLE_CONSTANT issued +EMC_SPINDLE_OFF issued +EMC_SPINDLE_BRAKE_ENGAGE issued +EMC_SPINDLE_BRAKE_RELEASE issued +EMC_COOLANT_MIST_ON issued +EMC_COOLANT_MIST_OFF issued +EMC_COOLANT_FLOOD_ON issued +EMC_COOLANT_FLOOD_OFF issued +EMC_TASK_PLAN_SET_OPTIONAL_STOP issued +EMC_TASK_PLAN_SET_BLOCK_DELETE issued +EMC_TASK_PLAN_SYNCH refused +EMC_TASK_PLAN_OPEN issued +EMC_TRAJ_SET_MODE refused +EMC_TOOL_LOAD_TOOL_TABLE queued +EMC_TOOL_SET_NUMBER refused +EMC_TOOL_SET_OFFSET queued +EMC_SPINDLE_ORIENT issued +EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued +EMC_TRAJ_PROBE issued +EMC_TRAJ_RIGID_TAP issued +EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/AUTO/PAUSED/reading.ngc +EMC_TASK_PLAN_EXECUTE issued +EMC_TASK_PLAN_INIT issued -> ON/AUTO/IDLE +EMC_TASK_PLAN_CLOSE issued +EMC_TASK_PLAN_RUN issued -> ON/AUTO/READING/reading.ngc +EMC_TASK_PLAN_STEP handled -> ON/AUTO/PAUSED/reading.ngc +EMC_TASK_PLAN_PAUSE issued -> ON/AUTO/PAUSED/reading.ngc +EMC_TASK_PLAN_RESUME issued +EMC_TASK_PLAN_REVERSE issued +EMC_TASK_PLAN_FORWARD issued +EMC_TASK_ABORT issued +EMC_TASK_SET_MODE(MANUAL) issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_MODE(AUTO) issued +EMC_TASK_SET_MODE(MDI) issued -> ON/MDI/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/AUTO/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP_RESET) issued +EMC_TASK_SET_STATE(OFF) issued -> OFF/AUTO/IDLE/reading.ngc +EMC_TASK_SET_STATE(ON) issued + +[auto-reading] +EMC_NULL handled +EMC_JOINT_SET_BACKLASH issued +EMC_JOINT_SET_HOMING_PARAMS issued +EMC_JOINT_SET_FERROR issued +EMC_JOINT_SET_MIN_FERROR issued +EMC_JOINT_SET_MAX_POSITION_LIMIT refused +EMC_JOINT_SET_MIN_POSITION_LIMIT refused +EMC_JOINT_LOAD_COMP refused +EMC_JOINT_HALT refused +EMC_JOINT_HOME refused +EMC_JOINT_UNHOME issued +EMC_JOINT_OVERRIDE_LIMITS refused +EMC_JOG_CONT refused +EMC_JOG_INCR refused +EMC_JOG_ABS refused +EMC_JOG_STOP refused +EMC_TRAJ_SET_SCALE issued +EMC_TRAJ_SET_RAPID_SCALE issued +EMC_TRAJ_SET_MAX_VELOCITY issued +EMC_TRAJ_SET_SPINDLE_SCALE issued +EMC_TRAJ_SET_FO_ENABLE issued +EMC_TRAJ_SET_FH_ENABLE issued +EMC_TRAJ_SET_SO_ENABLE issued +EMC_TRAJ_SET_VELOCITY refused +EMC_TRAJ_SET_ACCELERATION refused +EMC_TRAJ_SET_TELEOP_ENABLE refused +EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued +EMC_MOTION_SET_DOUT refused +EMC_MOTION_SET_AOUT refused +EMC_MOTION_ADAPTIVE refused +EMC_AUX_INPUT_WAIT issued +EMC_SET_DEBUG issued +EMC_SPINDLE_SPEED refused +EMC_SPINDLE_ON refused +EMC_SPINDLE_INCREASE issued +EMC_SPINDLE_DECREASE issued +EMC_SPINDLE_CONSTANT issued +EMC_SPINDLE_OFF refused +EMC_SPINDLE_BRAKE_ENGAGE refused +EMC_SPINDLE_BRAKE_RELEASE refused +EMC_COOLANT_MIST_ON issued +EMC_COOLANT_MIST_OFF issued +EMC_COOLANT_FLOOD_ON issued +EMC_COOLANT_FLOOD_OFF issued +EMC_TASK_PLAN_SET_OPTIONAL_STOP issued +EMC_TASK_PLAN_SET_BLOCK_DELETE issued +EMC_TASK_PLAN_SYNCH refused +EMC_TASK_PLAN_OPEN refused +EMC_TRAJ_SET_MODE refused +EMC_TOOL_LOAD_TOOL_TABLE refused +EMC_TOOL_SET_NUMBER refused +EMC_TOOL_SET_OFFSET refused +EMC_SPINDLE_ORIENT refused +EMC_SPINDLE_WAIT_ORIENT_COMPLETE refused +EMC_TRAJ_PROBE issued +EMC_TRAJ_RIGID_TAP issued -> ON/AUTO/IDLE/reading.ngc +EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/AUTO/PAUSED/reading.ngc +EMC_TASK_PLAN_EXECUTE refused +EMC_TASK_PLAN_INIT refused +EMC_TASK_PLAN_CLOSE refused +EMC_TASK_PLAN_RUN refused +EMC_TASK_PLAN_STEP handled +EMC_TASK_PLAN_PAUSE issued -> ON/AUTO/PAUSED/reading.ngc +EMC_TASK_PLAN_RESUME issued +EMC_TASK_PLAN_REVERSE issued +EMC_TASK_PLAN_FORWARD issued +EMC_TASK_ABORT issued -> ON/AUTO/IDLE/reading.ngc +EMC_TASK_SET_MODE(MANUAL) issued +EMC_TASK_SET_MODE(AUTO) issued -> ON/AUTO/IDLE/reading.ngc +EMC_TASK_SET_MODE(MDI) issued +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/AUTO/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/AUTO/IDLE/reading.ngc +EMC_TASK_SET_STATE(OFF) issued -> OFF/AUTO/IDLE/reading.ngc +EMC_TASK_SET_STATE(ON) issued + +[auto-waiting] +EMC_NULL handled +EMC_JOINT_SET_BACKLASH issued +EMC_JOINT_SET_HOMING_PARAMS issued +EMC_JOINT_SET_FERROR issued +EMC_JOINT_SET_MIN_FERROR issued +EMC_JOINT_SET_MAX_POSITION_LIMIT refused +EMC_JOINT_SET_MIN_POSITION_LIMIT refused +EMC_JOINT_LOAD_COMP refused +EMC_JOINT_HALT refused +EMC_JOINT_HOME refused +EMC_JOINT_UNHOME issued +EMC_JOINT_OVERRIDE_LIMITS refused +EMC_JOG_CONT refused +EMC_JOG_INCR refused +EMC_JOG_ABS refused +EMC_JOG_STOP refused +EMC_TRAJ_SET_SCALE issued +EMC_TRAJ_SET_RAPID_SCALE issued +EMC_TRAJ_SET_MAX_VELOCITY issued +EMC_TRAJ_SET_SPINDLE_SCALE issued +EMC_TRAJ_SET_FO_ENABLE issued +EMC_TRAJ_SET_FH_ENABLE issued +EMC_TRAJ_SET_SO_ENABLE issued +EMC_TRAJ_SET_VELOCITY refused +EMC_TRAJ_SET_ACCELERATION refused +EMC_TRAJ_SET_TELEOP_ENABLE refused +EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued +EMC_MOTION_SET_DOUT refused +EMC_MOTION_SET_AOUT refused +EMC_MOTION_ADAPTIVE refused +EMC_AUX_INPUT_WAIT issued +EMC_SET_DEBUG issued +EMC_SPINDLE_SPEED refused +EMC_SPINDLE_ON refused +EMC_SPINDLE_INCREASE issued +EMC_SPINDLE_DECREASE issued +EMC_SPINDLE_CONSTANT issued +EMC_SPINDLE_OFF refused +EMC_SPINDLE_BRAKE_ENGAGE refused +EMC_SPINDLE_BRAKE_RELEASE refused +EMC_COOLANT_MIST_ON issued +EMC_COOLANT_MIST_OFF issued +EMC_COOLANT_FLOOD_ON issued +EMC_COOLANT_FLOOD_OFF issued +EMC_TASK_PLAN_SET_OPTIONAL_STOP issued +EMC_TASK_PLAN_SET_BLOCK_DELETE issued +EMC_TASK_PLAN_SYNCH refused +EMC_TASK_PLAN_OPEN refused +EMC_TRAJ_SET_MODE refused +EMC_TOOL_LOAD_TOOL_TABLE refused +EMC_TOOL_SET_NUMBER refused +EMC_TOOL_SET_OFFSET refused +EMC_SPINDLE_ORIENT refused +EMC_SPINDLE_WAIT_ORIENT_COMPLETE refused +EMC_TRAJ_PROBE issued +EMC_TRAJ_RIGID_TAP issued -> ON/AUTO/IDLE/waiting.ngc +EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/AUTO/PAUSED/waiting.ngc +EMC_TASK_PLAN_EXECUTE issued +EMC_TASK_PLAN_INIT refused +EMC_TASK_PLAN_CLOSE refused +EMC_TASK_PLAN_RUN refused +EMC_TASK_PLAN_STEP handled +EMC_TASK_PLAN_PAUSE issued -> ON/AUTO/PAUSED/waiting.ngc +EMC_TASK_PLAN_RESUME issued +EMC_TASK_PLAN_REVERSE issued +EMC_TASK_PLAN_FORWARD issued +EMC_TASK_ABORT issued -> ON/AUTO/IDLE/waiting.ngc +EMC_TASK_SET_MODE(MANUAL) issued +EMC_TASK_SET_MODE(AUTO) issued -> ON/AUTO/IDLE/waiting.ngc +EMC_TASK_SET_MODE(MDI) issued +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/AUTO/IDLE/waiting.ngc +EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/AUTO/IDLE/waiting.ngc +EMC_TASK_SET_STATE(OFF) issued -> OFF/AUTO/IDLE/waiting.ngc +EMC_TASK_SET_STATE(ON) issued + +[auto-paused] +EMC_NULL handled +EMC_JOINT_SET_BACKLASH issued +EMC_JOINT_SET_HOMING_PARAMS issued +EMC_JOINT_SET_FERROR issued +EMC_JOINT_SET_MIN_FERROR issued +EMC_JOINT_SET_MAX_POSITION_LIMIT refused +EMC_JOINT_SET_MIN_POSITION_LIMIT refused +EMC_JOINT_LOAD_COMP refused +EMC_JOINT_HALT refused +EMC_JOINT_HOME refused +EMC_JOINT_UNHOME issued +EMC_JOINT_OVERRIDE_LIMITS refused +EMC_JOG_CONT refused +EMC_JOG_INCR refused +EMC_JOG_ABS refused +EMC_JOG_STOP refused +EMC_TRAJ_SET_SCALE issued +EMC_TRAJ_SET_RAPID_SCALE issued +EMC_TRAJ_SET_MAX_VELOCITY issued +EMC_TRAJ_SET_SPINDLE_SCALE issued +EMC_TRAJ_SET_FO_ENABLE issued +EMC_TRAJ_SET_FH_ENABLE issued +EMC_TRAJ_SET_SO_ENABLE issued +EMC_TRAJ_SET_VELOCITY refused +EMC_TRAJ_SET_ACCELERATION refused +EMC_TRAJ_SET_TELEOP_ENABLE refused +EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued +EMC_MOTION_SET_DOUT refused +EMC_MOTION_SET_AOUT refused +EMC_MOTION_ADAPTIVE refused +EMC_AUX_INPUT_WAIT issued +EMC_SET_DEBUG issued +EMC_SPINDLE_SPEED issued +EMC_SPINDLE_ON issued +EMC_SPINDLE_INCREASE issued +EMC_SPINDLE_DECREASE issued +EMC_SPINDLE_CONSTANT issued +EMC_SPINDLE_OFF issued +EMC_SPINDLE_BRAKE_ENGAGE issued +EMC_SPINDLE_BRAKE_RELEASE issued +EMC_COOLANT_MIST_ON issued +EMC_COOLANT_MIST_OFF issued +EMC_COOLANT_FLOOD_ON issued +EMC_COOLANT_FLOOD_OFF issued +EMC_TASK_PLAN_SET_OPTIONAL_STOP issued +EMC_TASK_PLAN_SET_BLOCK_DELETE issued +EMC_TASK_PLAN_SYNCH refused +EMC_TASK_PLAN_OPEN refused +EMC_TRAJ_SET_MODE refused +EMC_TOOL_LOAD_TOOL_TABLE refused +EMC_TOOL_SET_NUMBER refused +EMC_TOOL_SET_OFFSET refused +EMC_SPINDLE_ORIENT issued +EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued +EMC_TRAJ_PROBE issued +EMC_TRAJ_RIGID_TAP issued -> ON/AUTO/IDLE/reading.ngc +EMC_TASK_PLAN_OPTIONAL_STOP issued +EMC_TASK_PLAN_EXECUTE issued +EMC_TASK_PLAN_INIT refused +EMC_TASK_PLAN_CLOSE refused +EMC_TASK_PLAN_RUN refused +EMC_TASK_PLAN_STEP handled +EMC_TASK_PLAN_PAUSE issued +EMC_TASK_PLAN_RESUME issued -> ON/AUTO/READING/reading.ngc +EMC_TASK_PLAN_REVERSE issued +EMC_TASK_PLAN_FORWARD issued +EMC_TASK_ABORT issued -> ON/AUTO/IDLE/reading.ngc +EMC_TASK_SET_MODE(MANUAL) issued +EMC_TASK_SET_MODE(AUTO) issued -> ON/AUTO/IDLE/reading.ngc +EMC_TASK_SET_MODE(MDI) issued +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/AUTO/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/AUTO/IDLE/reading.ngc +EMC_TASK_SET_STATE(OFF) issued -> OFF/AUTO/IDLE/reading.ngc +EMC_TASK_SET_STATE(ON) issued diff --git a/tests/task-planner/flush.ngc b/tests/task-planner/flush.ngc new file mode 100644 index 00000000000..524219889f8 --- /dev/null +++ b/tests/task-planner/flush.ngc @@ -0,0 +1,2 @@ +(ends at once: running it clears the wait flag) +M2 diff --git a/tests/task-planner/task-planner.ini b/tests/task-planner/task-planner.ini new file mode 100644 index 00000000000..850985025f3 --- /dev/null +++ b/tests/task-planner/task-planner.ini @@ -0,0 +1,99 @@ +[EMC] +VERSION = 1.1 +# EMC_DEBUG_TASK_ISSUE | EMC_DEBUG_INTERP_LIST: what the test reads +DEBUG = 0x00000810 +RCS_DEBUG = 0x05400f01 + +[DISPLAY] +DISPLAY = ./test-ui.py + +[RS274NGC] +PARAMETER_FILE = sim.var + +[EMCMOT] +EMCMOT = motmod +COMM_TIMEOUT = 4.0 +BASE_PERIOD = 0 +SERVO_PERIOD = 1000000 + +[TASK] +TASK = milltask +CYCLE_TIME = 0.001 +MDI_QUEUED_COMMANDS=10000 + +[HAL] +HALFILE = LIB:core_sim.hal + +[EMCIO] +TOOL_TABLE = tool.tbl + +[TRAJ] +NO_FORCE_HOMING=1 +AXES = 3 +COORDINATES = X Y Z +HOME = 0 0 0 +LINEAR_UNITS = inch +ANGULAR_UNITS = degree +DEFAULT_LINEAR_VELOCITY = 1.2 +MAX_LINEAR_VELOCITY = 4 + +[KINS] +KINEMATICS = trivkins +JOINTS = 3 + +[AXIS_X] +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 + +[JOINT_0] +TYPE = LINEAR +HOME = 0.000 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 +BACKLASH = 0.000 +INPUT_SCALE = 4000 +OUTPUT_SCALE = 1.000 +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +FERROR = 0.050 +MIN_FERROR = 0.010 + +[AXIS_Y] +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 + +[JOINT_1] +TYPE = LINEAR +HOME = 0.000 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 +BACKLASH = 0.000 +INPUT_SCALE = 4000 +OUTPUT_SCALE = 1.000 +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +FERROR = 0.050 +MIN_FERROR = 0.010 + +[AXIS_Z] +MIN_LIMIT = -4.0 +MAX_LIMIT = 4.0 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 + +[JOINT_2] +TYPE = LINEAR +HOME = 0.0 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 +BACKLASH = 0.000 +INPUT_SCALE = 4000 +OUTPUT_SCALE = 1.000 +MIN_LIMIT = -4.0 +MAX_LIMIT = 4.0 +FERROR = 0.050 +MIN_FERROR = 0.010 diff --git a/tests/task-planner/test-ui.py b/tests/task-planner/test-ui.py new file mode 100755 index 00000000000..f44ffefe7f9 --- /dev/null +++ b/tests/task-planner/test-ui.py @@ -0,0 +1,226 @@ +#!/usr/bin/env python3 + +# Bring task into each situation the planner tells apart and have +# test_task_probe send it every command there, one at a time. For each probe +# this prints +# +# PROBE +# +# checkresult then reads, from task's own output, what the planner did with +# the command, and compares the table with the expected one. + +import linuxcnc +import os +import subprocess +import sys +import time + +program_start = time.time() + +def log(msg): + print("%.3f: %s" % (time.time() - program_start, msg)) + sys.stdout.flush() + + +c = linuxcnc.command() +s = linuxcnc.stat() +e = linuxcnc.error_channel() + +probe = subprocess.Popen(['test_task_probe', '-ini', os.environ['INI_FILE_NAME']], + stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True) + +def probe_cmd(line): + probe.stdin.write(line + "\n") + probe.stdin.flush() + return probe.stdout.readline().strip() + +probe.stdin.write("list\n") +probe.stdin.flush() +commands = [] +while True: + name = probe.stdout.readline().strip() + if name == 'end' or name == '': + break + commands.append(name) + +# Commands from EMC_TOOL_LOAD_TOOL_TABLE on (test_task_probe lists them +# last) set the situation up again afterwards, changed or not: they may +# leave something behind that the situation doesn't show, such as a wait +# for the interpreter, a pause pending, or a move in motion. +first_unsafe = commands.index('EMC_TOOL_LOAD_TOOL_TABLE') + +reading = os.path.abspath('reading.ngc') +waiting = os.path.abspath('waiting.ngc') +flush = os.path.abspath('flush.ngc') + +# The three tool commands set task's wait flag (emcTaskPlanSetWait()), and +# only a program reading or an MDI command waiting clears it again; an +# abort does not. While it is set, an MDI command in MDI mode is queued +# rather than issued. So that a probe does not depend on the ones before it, +# the flag is cleared, by running a program that ends at once, whenever a +# situation is set up afresh and after each tool command. +TOOL_COMMANDS = {'EMC_TOOL_LOAD_TOOL_TABLE', 'EMC_TOOL_SET_NUMBER', 'EMC_TOOL_SET_OFFSET'} + +STATE = {linuxcnc.STATE_ESTOP: 'ESTOP', linuxcnc.STATE_ESTOP_RESET: 'OFF', + linuxcnc.STATE_OFF: 'OFF', linuxcnc.STATE_ON: 'ON'} +MODE = {linuxcnc.MODE_MANUAL: 'MANUAL', linuxcnc.MODE_AUTO: 'AUTO', + linuxcnc.MODE_MDI: 'MDI'} +INTERP = {linuxcnc.INTERP_IDLE: 'IDLE', linuxcnc.INTERP_READING: 'READING', + linuxcnc.INTERP_PAUSED: 'PAUSED', linuxcnc.INTERP_WAITING: 'WAITING'} + + +def situation(): + s.poll() + return "%s/%s/%s%s%s" % (STATE[s.task_state], MODE[s.task_mode], + INTERP[s.interp_state], + '/queued-mdi' if s.queued_mdi_commands else '', + '/' + os.path.basename(s.file) if s.file else '') + + +def drain_errors(): + while e.poll(): + pass + + +def wait_for(what, cond, timeout=10.0): + end = time.time() + timeout + while time.time() < end: + s.poll() + if cond(): + return + time.sleep(0.01) + log("timeout waiting for %s, situation %s" % (what, situation())) + sys.exit(1) + + +# Each step only when it is needed: setting up again is most of the time +# this test takes. + +def command(what, cond, *args): + what(*args) + # a program run is EXEC until it ends: wait for the state it is after + if what != c.auto: + c.wait_complete() + wait_for(what.__name__, cond) + + +def state(st): + s.poll() + if st == linuxcnc.STATE_ON and s.task_state != linuxcnc.STATE_ON: + if s.task_state == linuxcnc.STATE_ESTOP: + command(c.state, lambda: s.task_state != linuxcnc.STATE_ESTOP, + linuxcnc.STATE_ESTOP_RESET) + command(c.state, lambda: s.task_state == linuxcnc.STATE_ON, linuxcnc.STATE_ON) + elif st == linuxcnc.STATE_ESTOP and s.task_state != linuxcnc.STATE_ESTOP: + command(c.state, lambda: s.task_state == linuxcnc.STATE_ESTOP, linuxcnc.STATE_ESTOP) + elif st == linuxcnc.STATE_OFF and s.task_state not in (linuxcnc.STATE_OFF, + linuxcnc.STATE_ESTOP_RESET): + if s.task_state == linuxcnc.STATE_ESTOP: + command(c.state, lambda: s.task_state != linuxcnc.STATE_ESTOP, + linuxcnc.STATE_ESTOP_RESET) + else: + command(c.state, lambda: s.task_state != linuxcnc.STATE_ON, linuxcnc.STATE_OFF) + + +def idle(): + s.poll() + if s.interp_state != linuxcnc.INTERP_IDLE or s.queued_mdi_commands: + command(c.abort, lambda: s.interp_state == linuxcnc.INTERP_IDLE) + + +def mode(m): + s.poll() + if s.task_mode != m: + command(c.mode, lambda: s.task_mode == m, m) + + +def program(f): + s.poll() + if s.file != f: + c.program_open(f) + c.wait_complete() + + +def run(f, interp): + state(linuxcnc.STATE_ON) + idle() + mode(linuxcnc.MODE_AUTO) + program(f) + command(c.auto, lambda: s.interp_state == interp, linuxcnc.AUTO_RUN, 0) + + +def clear_wait_flag(): + state(linuxcnc.STATE_ON) + idle() + mode(linuxcnc.MODE_AUTO) + program(flush) + c.auto(linuxcnc.AUTO_RUN, 0) + wait_for("flush.ngc to end", lambda: s.interp_state == linuxcnc.INTERP_IDLE + and s.exec_state == linuxcnc.EXEC_DONE) + + +def set_up(name, afresh=False): + if afresh: + clear_wait_flag() + # the same program is open in every situation, so that the open file + # is part of the situation without being set up again for each one + if name in ('estop', 'off', 'manual', 'mdi', 'mdi-busy', 'auto'): + idle() + program(reading) + if name == 'estop': + mode(linuxcnc.MODE_MANUAL) + state(linuxcnc.STATE_ESTOP) + elif name == 'off': + mode(linuxcnc.MODE_AUTO) + state(linuxcnc.STATE_OFF) + elif name in ('manual', 'mdi', 'auto'): + state(linuxcnc.STATE_ON) + mode({'manual': linuxcnc.MODE_MANUAL, 'mdi': linuxcnc.MODE_MDI, + 'auto': linuxcnc.MODE_AUTO}[name]) + elif name == 'mdi-busy': + state(linuxcnc.STATE_ON) + mode(linuxcnc.MODE_MDI) + c.mdi("G4 P600") + wait_for("MDI running", lambda: s.interp_state != linuxcnc.INTERP_IDLE) + elif name == 'auto-reading': + run(reading, linuxcnc.INTERP_READING) + elif name == 'auto-waiting': + run(waiting, linuxcnc.INTERP_WAITING) + elif name == 'auto-paused': + run(reading, linuxcnc.INTERP_READING) + command(c.auto, lambda: s.interp_state == linuxcnc.INTERP_PAUSED, linuxcnc.AUTO_PAUSE) + time.sleep(0.02) + drain_errors() + return situation() + + +SITUATIONS = ['estop', 'off', 'manual', 'mdi', 'mdi-busy', + 'auto', 'auto-reading', 'auto-waiting', 'auto-paused'] + +for name in SITUATIONS: + expected = set_up(name, afresh=True) + log("situation %s: %s" % (name, expected)) + for i, cmd in enumerate(commands): + reply = probe_cmd("probe %s %s" % (name, cmd)) + if not reply.startswith('serial ') or int(reply.split()[1]) < 0: + log("probe %s %s failed: %s" % (name, cmd, reply)) + sys.exit(1) + serial = int(reply.split()[1]) + time.sleep(0.05) + after = situation() + print("PROBE %s %s %d %s" % (name, cmd, serial, + after if after != expected else '-')) + sys.stdout.flush() + if after != expected or i >= first_unsafe: + if set_up(name, afresh=cmd in TOOL_COMMANDS) != expected: + log("cannot set up %s again after %s: %s" % (name, cmd, situation())) + sys.exit(1) + drain_errors() + +probe.stdin.close() +probe.wait() + +c.state(linuxcnc.STATE_ESTOP) +c.wait_complete() +log("done") +sys.exit(0) diff --git a/tests/task-planner/test.sh b/tests/task-planner/test.sh new file mode 100755 index 00000000000..841f459fdff --- /dev/null +++ b/tests/task-planner/test.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# The probe helper is built with the run-in-place tree only. +if ! command -v test_task_probe > /dev/null; then + echo "test_task_probe not found, skipping (run-in-place builds only)" + exit 0 +fi + +cp -f tool.tbl.original tool.tbl + +# A program long enough that the interpreter is still reading while the +# test probes: tiny moves, far more of them than task reads ahead. +{ + echo "G1 F1" + for i in $(seq 5000); do + echo "X0.001" + echo "X0" + done + echo "M2" +} > reading.ngc + +exec linuxcnc -r task-planner.ini diff --git a/tests/task-planner/tool.tbl.original b/tests/task-planner/tool.tbl.original new file mode 100644 index 00000000000..b9efc8ef48f --- /dev/null +++ b/tests/task-planner/tool.tbl.original @@ -0,0 +1 @@ +T1 P1 D0.25 Z0.5 ;probe tool diff --git a/tests/task-planner/waiting.ngc b/tests/task-planner/waiting.ngc new file mode 100644 index 00000000000..9949fb236ed --- /dev/null +++ b/tests/task-planner/waiting.ngc @@ -0,0 +1,3 @@ +(one long move: the interpreter is done reading, task waits for motion) +G1 X1 F0.1 +M2 From 910b3b4fc7d2ce3ee27600b2b2641198556ab8a6 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 10 Nov 2026 17:36:59 +0100 Subject: [PATCH 02/27] task: hand emcTaskPlan() the new command emcTaskPlan() found its command itself: it compared emcCommand's serial number with the echoed one to tell a new command from none, and allow_while_idle_type() read the command's type from the NML buffer once more. Have the main loop make that decision and pass the new command, or NULL, and use only that inside the planner. This is what lets a command reach the planner by another way than the NML buffer. No change in behaviour: tests/task-planner is unchanged. --- src/emc/task/emctaskmain.cc | 86 ++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 45 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index c6304738767..b63e9c86c93 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -791,12 +791,10 @@ void readahead_waiting(void) } } -static bool allow_while_idle_type() { +static bool allow_while_idle_type(NMLTYPE type) { // allow for EMC_TASK_MODE::AUTO, EMC_TASK_MODE::MDI // expect immediate command - RCS_CMD_MSG *emcCommand; - emcCommand = emcCommandBuffer->get_address(); - switch(emcCommand->_type) { + switch(type) { case EMC_JOG_CONT_TYPE: case EMC_JOG_INCR_TYPE: case EMC_JOG_STOP_TYPE: @@ -812,27 +810,21 @@ static bool allow_while_idle_type() { emcTaskPlan() Planner for NC code or manual mode operations + + cmd is the new command to handle this cycle, or NULL if there is none. + It is only used for the duration of the call. */ -static int emcTaskPlan(void) +static int emcTaskPlan(NMLmsg *cmd) { - NMLTYPE type; + NMLTYPE type = cmd ? cmd->_type : 0; int retval = 0; - // check for new command - if (emcCommand->serial_number != emcStatus->echo_serial_number) { - // flag it here locally as a new command - type = emcCommand->_type; - } else { - // no new command-- reset local flag - type = 0; - } - // Always display messages switch (type) { case EMC_OPERATOR_ERROR_TYPE: case EMC_OPERATOR_TEXT_TYPE: case EMC_OPERATOR_DISPLAY_TYPE: - retval = emcTaskIssueCommand(emcCommand); + retval = emcTaskIssueCommand(cmd); return retval; } @@ -889,20 +881,20 @@ static int emcTaskPlan(void) case EMC_TRAJ_RIGID_TAP_TYPE: case EMC_TRAJ_SET_TELEOP_ENABLE_TYPE: case EMC_SET_DEBUG_TYPE: - retval = emcTaskIssueCommand(emcCommand); + retval = emcTaskIssueCommand(cmd); break; // one case where we need to be in manual mode case EMC_JOINT_OVERRIDE_LIMITS_TYPE: retval = 0; if (emcStatus->task.mode == EMC_TASK_MODE::MANUAL) { - retval = emcTaskIssueCommand(emcCommand); + retval = emcTaskIssueCommand(cmd); } break; case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: { // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(emcCommand))); + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); // signify no more reading emcTaskPlanSetWait(); // then resynch interpreter @@ -911,7 +903,7 @@ static int emcTaskPlan(void) } case EMC_TOOL_SET_OFFSET_TYPE: { // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(emcCommand))); + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); // signify no more reading emcTaskPlanSetWait(); // then resynch interpreter @@ -921,7 +913,7 @@ static int emcTaskPlan(void) case EMC_TOOL_SET_NUMBER_TYPE: { // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(emcCommand))); + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); // signify no more reading emcTaskPlanSetWait(); // then resynch interpreter @@ -1013,7 +1005,7 @@ static int emcTaskPlan(void) case EMC_TRAJ_RIGID_TAP_TYPE: case EMC_TRAJ_SET_TELEOP_ENABLE_TYPE: case EMC_SET_DEBUG_TYPE: - retval = emcTaskIssueCommand(emcCommand); + retval = emcTaskIssueCommand(cmd); break; // queued commands @@ -1023,12 +1015,12 @@ static int emcTaskPlan(void) // externally emcTaskQueueTaskPlanSynchCmd(); // and now call for interpreter execute - retval = emcTaskIssueCommand(emcCommand); + retval = emcTaskIssueCommand(cmd); break; case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: { // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(emcCommand))); + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); // signify no more reading emcTaskPlanSetWait(); // then resynch interpreter @@ -1037,7 +1029,7 @@ static int emcTaskPlan(void) } case EMC_TOOL_SET_OFFSET_TYPE: { // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(emcCommand))); + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); // signify no more reading emcTaskPlanSetWait(); // then resynch interpreter @@ -1047,7 +1039,7 @@ static int emcTaskPlan(void) case EMC_TOOL_SET_NUMBER_TYPE: { // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(emcCommand))); + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); // signify no more reading emcTaskPlanSetWait(); // then resynch interpreter @@ -1129,7 +1121,7 @@ static int emcTaskPlan(void) case EMC_AUX_INPUT_WAIT_TYPE: case EMC_TRAJ_RIGID_TAP_TYPE: case EMC_SET_DEBUG_TYPE: - retval = emcTaskIssueCommand(emcCommand); + retval = emcTaskIssueCommand(cmd); break; case EMC_TASK_PLAN_STEP_TYPE: @@ -1150,7 +1142,7 @@ static int emcTaskPlan(void) case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: { // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(emcCommand))); + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); // signify no more reading emcTaskPlanSetWait(); // then resynch interpreter @@ -1159,7 +1151,7 @@ static int emcTaskPlan(void) } case EMC_TOOL_SET_OFFSET_TYPE: { // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(emcCommand))); + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); // signify no more reading emcTaskPlanSetWait(); // then resynch interpreter @@ -1170,8 +1162,8 @@ static int emcTaskPlan(void) // otherwise we can't handle it default: //EMC_TASK_MODE::AUTO(2) && EMC_TASK_INTERP::IDLE(1) - if ( allow_while_idle_type() ) { - retval = emcTaskIssueCommand(emcCommand); + if ( allow_while_idle_type(type) ) { + retval = emcTaskIssueCommand(cmd); break; } emcOperatorError(_("can't do that (%s) in auto mode with the interpreter idle"), emc_symbol_lookup(type)); @@ -1225,7 +1217,7 @@ static int emcTaskPlan(void) case EMC_COOLANT_MIST_OFF_TYPE: case EMC_COOLANT_FLOOD_ON_TYPE: case EMC_COOLANT_FLOOD_OFF_TYPE: - retval = emcTaskIssueCommand(emcCommand); + retval = emcTaskIssueCommand(cmd); return retval; break; @@ -1299,7 +1291,7 @@ static int emcTaskPlan(void) case EMC_AUX_INPUT_WAIT_TYPE: case EMC_TRAJ_RIGID_TAP_TYPE: case EMC_SET_DEBUG_TYPE: - retval = emcTaskIssueCommand(emcCommand); + retval = emcTaskIssueCommand(cmd); break; case EMC_TASK_PLAN_STEP_TYPE: @@ -1372,7 +1364,7 @@ static int emcTaskPlan(void) case EMC_COOLANT_MIST_OFF_TYPE: case EMC_COOLANT_FLOOD_ON_TYPE: case EMC_COOLANT_FLOOD_OFF_TYPE: - retval = emcTaskIssueCommand(emcCommand); + retval = emcTaskIssueCommand(cmd); break; case EMC_TASK_PLAN_STEP_TYPE: @@ -1461,7 +1453,7 @@ static int emcTaskPlan(void) case EMC_MOTION_ADAPTIVE_TYPE: case EMC_TRAJ_RIGID_TAP_TYPE: case EMC_SET_DEBUG_TYPE: - retval = emcTaskIssueCommand(emcCommand); + retval = emcTaskIssueCommand(cmd); break; case EMC_TASK_PLAN_EXECUTE_TYPE: @@ -1476,11 +1468,11 @@ static int emcTaskPlan(void) && (emcTaskCommand == NULL) && (emcTaskPlanIsWait() == 0) ) { - retval = emcTaskIssueCommand(emcCommand); + retval = emcTaskIssueCommand(cmd); } else { - auto cmd = std::make_unique(); - rtapi_strlcpy(cmd->command, static_cast(emcCommand)->command, sizeof(cmd->command)); - mdi_execute_queue.append(std::move(cmd)); + auto queued = std::make_unique(); + rtapi_strlcpy(queued->command, static_cast(cmd)->command, sizeof(queued->command)); + mdi_execute_queue.append(std::move(queued)); emcStatus->task.queuedMDIcommands = mdi_execute_queue.len(); retval = 0; } @@ -1488,7 +1480,7 @@ static int emcTaskPlan(void) case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: { // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(emcCommand))); + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); // signify no more reading emcTaskPlanSetWait(); // then resynch interpreter @@ -1497,7 +1489,7 @@ static int emcTaskPlan(void) } case EMC_TOOL_SET_OFFSET_TYPE: { // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(emcCommand))); + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); // signify no more reading emcTaskPlanSetWait(); // then resynch interpreter @@ -1508,8 +1500,8 @@ static int emcTaskPlan(void) // otherwise we can't handle it default: //EMC_TASK_MODE::MDI(3) && EMC_TASK_INTERP::IDLE(1) - if ( allow_while_idle_type() ) { - retval = emcTaskIssueCommand(emcCommand); + if ( allow_while_idle_type(type) ) { + retval = emcTaskIssueCommand(cmd); break; } emcOperatorError(_("can't do that (%s:%d) in MDI mode"), emc_symbol_lookup(type),(int) type); @@ -3596,8 +3588,12 @@ int main(int argc, char *argv[]) taskPlanError = 0; taskExecuteError = 0; } - // run control cycle - if (0 != emcTaskPlan()) { + // run control cycle, with the new command if there is one + NMLmsg *newCommand = NULL; + if (emcCommand->serial_number != emcStatus->echo_serial_number) { + newCommand = emcCommand; + } + if (0 != emcTaskPlan(newCommand)) { taskPlanError = 1; } if (0 != emcTaskExecute()) { From f3d8ff047195c4bb8ea34937e627db5a33a7a486 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 10 Nov 2026 17:48:51 +0100 Subject: [PATCH 03/27] task: one list of immediate commands for the planner tables The planner's tables repeated the commands each passes straight to emcTaskIssueCommand(): 22 accepted in any state, three more only while the machine is off, twelve once it is on, the spindle commands unless a program is reading or waiting, the program and I/O commands unless one runs, and so on. isImmediate() now says this once, by the state, mode and interpreter state task is in, and each table keeps only what is special to it and its own refusal. allow_while_idle_type() is part of it now, and the three tool commands share queueToolCommand(). No change in behaviour: tests/task-planner is unchanged, and fails if spindle orient is let through in Manual, as an example of a slip. --- src/emc/task/emctaskmain.cc | 620 +++++++++++------------------------- 1 file changed, 182 insertions(+), 438 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index b63e9c86c93..d710613c84c 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -791,19 +791,144 @@ void readahead_waiting(void) } } -static bool allow_while_idle_type(NMLTYPE type) { - // allow for EMC_TASK_MODE::AUTO, EMC_TASK_MODE::MDI - // expect immediate command - switch(type) { - case EMC_JOG_CONT_TYPE: - case EMC_JOG_INCR_TYPE: - case EMC_JOG_STOP_TYPE: - case EMC_JOG_ABS_TYPE: - case EMC_TRAJ_SET_TELEOP_ENABLE_TYPE: - return 1; - break; +/* + isImmediate() + + The commands emcTaskPlan() passes straight to emcTaskIssueCommand(), by + the state, mode and interpreter state task is in. Everything else is + handled, or refused, by the planner's table for that situation. + */ +static bool isImmediate(NMLTYPE type) +{ + const EMC_TASK_STAT &task = emcStatus->task; + const bool on = task.state == EMC_TASK_STATE::ON; + const bool manual = on && task.mode == EMC_TASK_MODE::MANUAL; + const bool mdi = on && task.mode == EMC_TASK_MODE::MDI; + const bool autoMode = on && task.mode == EMC_TASK_MODE::AUTO; + const bool autoIdle = autoMode && task.interpState == EMC_TASK_INTERP::IDLE; + const bool autoPaused = autoMode && task.interpState == EMC_TASK_INTERP::PAUSED; + const bool autoWaiting = autoMode && task.interpState == EMC_TASK_INTERP::WAITING; + + switch (type) { + // in any state + case EMC_JOINT_SET_BACKLASH_TYPE: + case EMC_JOINT_SET_HOMING_PARAMS_TYPE: + case EMC_JOINT_SET_FERROR_TYPE: + case EMC_JOINT_SET_MIN_FERROR_TYPE: + case EMC_JOINT_UNHOME_TYPE: + case EMC_TRAJ_SET_SCALE_TYPE: + case EMC_TRAJ_SET_RAPID_SCALE_TYPE: + case EMC_TRAJ_SET_MAX_VELOCITY_TYPE: + case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE: + case EMC_TRAJ_SET_FO_ENABLE_TYPE: + case EMC_TRAJ_SET_FH_ENABLE_TYPE: + case EMC_TRAJ_SET_SO_ENABLE_TYPE: + case EMC_TASK_SET_MODE_TYPE: + case EMC_TASK_SET_STATE_TYPE: + case EMC_TASK_ABORT_TYPE: + case EMC_TASK_PLAN_SET_OPTIONAL_STOP_TYPE: + case EMC_TASK_PLAN_SET_BLOCK_DELETE_TYPE: + case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: + case EMC_TRAJ_PROBE_TYPE: + case EMC_AUX_INPUT_WAIT_TYPE: + case EMC_TRAJ_RIGID_TAP_TYPE: + case EMC_SET_DEBUG_TYPE: + return true; + + // only while the machine is off or in E-stop + case EMC_JOINT_LOAD_COMP_TYPE: + case EMC_TRAJ_SET_VELOCITY_TYPE: + case EMC_TRAJ_SET_ACCELERATION_TYPE: + return !on; + + // once the machine is on, whatever runs + case EMC_SPINDLE_INCREASE_TYPE: + case EMC_SPINDLE_DECREASE_TYPE: + case EMC_SPINDLE_CONSTANT_TYPE: + case EMC_COOLANT_MIST_ON_TYPE: + case EMC_COOLANT_MIST_OFF_TYPE: + case EMC_COOLANT_FLOOD_ON_TYPE: + case EMC_COOLANT_FLOOD_OFF_TYPE: + case EMC_TASK_PLAN_PAUSE_TYPE: + case EMC_TASK_PLAN_REVERSE_TYPE: + case EMC_TASK_PLAN_FORWARD_TYPE: + case EMC_TASK_PLAN_RESUME_TYPE: + case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: + return on; + + // once the machine is on, unless a program is reading or waiting + case EMC_SPINDLE_SPEED_TYPE: + case EMC_SPINDLE_ON_TYPE: + case EMC_SPINDLE_OFF_TYPE: + case EMC_SPINDLE_BRAKE_RELEASE_TYPE: + case EMC_SPINDLE_BRAKE_ENGAGE_TYPE: + return manual || mdi || autoIdle || autoPaused; + + // the same, but not in Manual + case EMC_SPINDLE_ORIENT_TYPE: + case EMC_SPINDLE_WAIT_ORIENT_COMPLETE_TYPE: + return mdi || autoIdle || autoPaused; + + // unless a program runs + case EMC_TASK_PLAN_INIT_TYPE: + case EMC_TASK_PLAN_OPEN_TYPE: + case EMC_TASK_PLAN_CLOSE_TYPE: + return !on || manual || mdi || autoIdle; + + // not in Auto + case EMC_TASK_PLAN_SYNCH_TYPE: + case EMC_MOTION_SET_DOUT_TYPE: + case EMC_MOTION_SET_AOUT_TYPE: + case EMC_MOTION_ADAPTIVE_TYPE: + return !on || manual || mdi; + + // Auto only + case EMC_TASK_PLAN_RUN_TYPE: + return autoIdle; + case EMC_TASK_PLAN_EXECUTE_TYPE: + return autoIdle || autoPaused || autoWaiting; + + // Manual only + case EMC_JOINT_SET_MAX_POSITION_LIMIT_TYPE: + case EMC_JOINT_SET_MIN_POSITION_LIMIT_TYPE: + case EMC_JOINT_HALT_TYPE: + case EMC_JOINT_HOME_TYPE: + case EMC_JOINT_OVERRIDE_LIMITS_TYPE: + return manual; + + // jogs, and in Auto only while the interpreter is idle + case EMC_JOG_CONT_TYPE: + case EMC_JOG_INCR_TYPE: + case EMC_JOG_ABS_TYPE: + case EMC_JOG_STOP_TYPE: + return manual || mdi || autoIdle; + case EMC_TRAJ_SET_TELEOP_ENABLE_TYPE: + return !on || manual || mdi || autoIdle; } - return 0; + return false; +} + +// The tool commands go through interp_list: no more reading until they +// are done, then the interpreter synchs. +static void queueToolCommand(NMLmsg *cmd) +{ + switch (cmd->_type) { + case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); + break; + case EMC_TOOL_SET_OFFSET_TYPE: + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); + break; + case EMC_TOOL_SET_NUMBER_TYPE: + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); + break; + default: + return; + } + // signify no more reading + emcTaskPlanSetWait(); + // then resynch interpreter + emcTaskQueueTaskPlanSynchCmd(); } /* @@ -813,6 +938,10 @@ static bool allow_while_idle_type(NMLTYPE type) { cmd is the new command to handle this cycle, or NULL if there is none. It is only used for the duration of the call. + + Each state has a table: no command, the commands passed straight through + (isImmediate()), then what is special to that state, and a refusal for + everything else. */ static int emcTaskPlan(NMLmsg *cmd) { @@ -847,43 +976,6 @@ static int emcTaskPlan(NMLmsg *cmd) // no command break; - // immediate commands - case EMC_JOINT_SET_BACKLASH_TYPE: - case EMC_JOINT_SET_HOMING_PARAMS_TYPE: - case EMC_JOINT_SET_FERROR_TYPE: - case EMC_JOINT_SET_MIN_FERROR_TYPE: - case EMC_JOINT_LOAD_COMP_TYPE: - case EMC_JOINT_UNHOME_TYPE: - case EMC_TRAJ_SET_SCALE_TYPE: - case EMC_TRAJ_SET_RAPID_SCALE_TYPE: - case EMC_TRAJ_SET_MAX_VELOCITY_TYPE: - case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE: - case EMC_TRAJ_SET_FO_ENABLE_TYPE: - case EMC_TRAJ_SET_FH_ENABLE_TYPE: - case EMC_TRAJ_SET_SO_ENABLE_TYPE: - case EMC_TRAJ_SET_VELOCITY_TYPE: - case EMC_TRAJ_SET_ACCELERATION_TYPE: - case EMC_TASK_SET_MODE_TYPE: - case EMC_TASK_SET_STATE_TYPE: - case EMC_TASK_PLAN_INIT_TYPE: - case EMC_TASK_PLAN_OPEN_TYPE: - case EMC_TASK_PLAN_CLOSE_TYPE: - case EMC_TASK_PLAN_SET_OPTIONAL_STOP_TYPE: - case EMC_TASK_PLAN_SET_BLOCK_DELETE_TYPE: - case EMC_TASK_ABORT_TYPE: - case EMC_TASK_PLAN_SYNCH_TYPE: - case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: - case EMC_TRAJ_PROBE_TYPE: - case EMC_AUX_INPUT_WAIT_TYPE: - case EMC_MOTION_SET_DOUT_TYPE: - case EMC_MOTION_ADAPTIVE_TYPE: - case EMC_MOTION_SET_AOUT_TYPE: - case EMC_TRAJ_RIGID_TAP_TYPE: - case EMC_TRAJ_SET_TELEOP_ENABLE_TYPE: - case EMC_SET_DEBUG_TYPE: - retval = emcTaskIssueCommand(cmd); - break; - // one case where we need to be in manual mode case EMC_JOINT_OVERRIDE_LIMITS_TYPE: retval = 0; @@ -892,36 +984,17 @@ static int emcTaskPlan(NMLmsg *cmd) } break; - case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: { - // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - // signify no more reading - emcTaskPlanSetWait(); - // then resynch interpreter - emcTaskQueueTaskPlanSynchCmd(); - break; - } - case EMC_TOOL_SET_OFFSET_TYPE: { - // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - // signify no more reading - emcTaskPlanSetWait(); - // then resynch interpreter - emcTaskQueueTaskPlanSynchCmd(); - break; - } - - case EMC_TOOL_SET_NUMBER_TYPE: { - // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - // signify no more reading - emcTaskPlanSetWait(); - // then resynch interpreter - emcTaskQueueTaskPlanSynchCmd(); + case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: + case EMC_TOOL_SET_OFFSET_TYPE: + case EMC_TOOL_SET_NUMBER_TYPE: + queueToolCommand(cmd); break; - } default: + if (isImmediate(type)) { + retval = emcTaskIssueCommand(cmd); + break; + } emcOperatorError(_("command (%s) cannot be executed until the machine is out of E-stop and turned on"), emc_symbol_lookup(type)); retval = -1; break; @@ -947,67 +1020,6 @@ static int emcTaskPlan(NMLmsg *cmd) // no command break; - // immediate commands - - case EMC_JOINT_SET_BACKLASH_TYPE: - case EMC_JOINT_SET_HOMING_PARAMS_TYPE: - case EMC_JOINT_SET_FERROR_TYPE: - case EMC_JOINT_SET_MIN_FERROR_TYPE: - case EMC_JOINT_SET_MAX_POSITION_LIMIT_TYPE: - case EMC_JOINT_SET_MIN_POSITION_LIMIT_TYPE: - case EMC_JOINT_HALT_TYPE: - case EMC_JOINT_HOME_TYPE: - case EMC_JOINT_UNHOME_TYPE: - case EMC_JOG_CONT_TYPE: - case EMC_JOG_INCR_TYPE: - case EMC_JOG_ABS_TYPE: - case EMC_JOG_STOP_TYPE: - case EMC_JOINT_OVERRIDE_LIMITS_TYPE: - case EMC_TRAJ_SET_SCALE_TYPE: - case EMC_TRAJ_SET_RAPID_SCALE_TYPE: - case EMC_TRAJ_SET_MAX_VELOCITY_TYPE: - case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE: - case EMC_TRAJ_SET_FO_ENABLE_TYPE: - case EMC_TRAJ_SET_FH_ENABLE_TYPE: - case EMC_TRAJ_SET_SO_ENABLE_TYPE: - case EMC_SPINDLE_SPEED_TYPE: - case EMC_SPINDLE_ON_TYPE: - case EMC_SPINDLE_OFF_TYPE: - case EMC_SPINDLE_BRAKE_RELEASE_TYPE: - case EMC_SPINDLE_BRAKE_ENGAGE_TYPE: - case EMC_SPINDLE_INCREASE_TYPE: - case EMC_SPINDLE_DECREASE_TYPE: - case EMC_SPINDLE_CONSTANT_TYPE: - case EMC_COOLANT_MIST_ON_TYPE: - case EMC_COOLANT_MIST_OFF_TYPE: - case EMC_COOLANT_FLOOD_ON_TYPE: - case EMC_COOLANT_FLOOD_OFF_TYPE: - case EMC_TASK_SET_MODE_TYPE: - case EMC_TASK_SET_STATE_TYPE: - case EMC_TASK_ABORT_TYPE: - case EMC_TASK_PLAN_OPEN_TYPE: - case EMC_TASK_PLAN_CLOSE_TYPE: - case EMC_TASK_PLAN_PAUSE_TYPE: - case EMC_TASK_PLAN_REVERSE_TYPE: - case EMC_TASK_PLAN_FORWARD_TYPE: - case EMC_TASK_PLAN_RESUME_TYPE: - case EMC_TASK_PLAN_INIT_TYPE: - case EMC_TASK_PLAN_SYNCH_TYPE: - case EMC_TASK_PLAN_SET_OPTIONAL_STOP_TYPE: - case EMC_TASK_PLAN_SET_BLOCK_DELETE_TYPE: - case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: - case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: - case EMC_TRAJ_PROBE_TYPE: - case EMC_AUX_INPUT_WAIT_TYPE: - case EMC_MOTION_SET_DOUT_TYPE: - case EMC_MOTION_SET_AOUT_TYPE: - case EMC_MOTION_ADAPTIVE_TYPE: - case EMC_TRAJ_RIGID_TAP_TYPE: - case EMC_TRAJ_SET_TELEOP_ENABLE_TYPE: - case EMC_SET_DEBUG_TYPE: - retval = emcTaskIssueCommand(cmd); - break; - // queued commands case EMC_TASK_PLAN_EXECUTE_TYPE: @@ -1018,34 +1030,11 @@ static int emcTaskPlan(NMLmsg *cmd) retval = emcTaskIssueCommand(cmd); break; - case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: { - // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - // signify no more reading - emcTaskPlanSetWait(); - // then resynch interpreter - emcTaskQueueTaskPlanSynchCmd(); - break; - } - case EMC_TOOL_SET_OFFSET_TYPE: { - // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - // signify no more reading - emcTaskPlanSetWait(); - // then resynch interpreter - emcTaskQueueTaskPlanSynchCmd(); + case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: + case EMC_TOOL_SET_OFFSET_TYPE: + case EMC_TOOL_SET_NUMBER_TYPE: + queueToolCommand(cmd); break; - } - - case EMC_TOOL_SET_NUMBER_TYPE: { - // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - // signify no more reading - emcTaskPlanSetWait(); - // then resynch interpreter - emcTaskQueueTaskPlanSynchCmd(); - break; - } case EMC_TASK_PLAN_RUN_TYPE: if (GET_EXTERNAL_OFFSET_APPLIED()) { @@ -1056,6 +1045,10 @@ static int emcTaskPlan(NMLmsg *cmd) // otherwise we can't handle it default: + if (isImmediate(type)) { + retval = emcTaskIssueCommand(cmd); + break; + } emcOperatorError(_("can't do that (%s:%d) in manual mode"), emc_symbol_lookup(type),(int) type); retval = -1; break; @@ -1073,57 +1066,6 @@ static int emcTaskPlan(NMLmsg *cmd) // no command break; - // immediate commands - - case EMC_JOINT_SET_BACKLASH_TYPE: - case EMC_JOINT_SET_HOMING_PARAMS_TYPE: - case EMC_JOINT_SET_FERROR_TYPE: - case EMC_JOINT_SET_MIN_FERROR_TYPE: - case EMC_JOINT_UNHOME_TYPE: - case EMC_TRAJ_SET_SCALE_TYPE: - case EMC_TRAJ_SET_RAPID_SCALE_TYPE: - case EMC_TRAJ_SET_MAX_VELOCITY_TYPE: - case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE: - case EMC_TRAJ_SET_FO_ENABLE_TYPE: - case EMC_TRAJ_SET_FH_ENABLE_TYPE: - case EMC_TRAJ_SET_SO_ENABLE_TYPE: - case EMC_SPINDLE_SPEED_TYPE: - case EMC_SPINDLE_ORIENT_TYPE: - case EMC_SPINDLE_WAIT_ORIENT_COMPLETE_TYPE: - case EMC_SPINDLE_ON_TYPE: - case EMC_SPINDLE_OFF_TYPE: - case EMC_SPINDLE_BRAKE_RELEASE_TYPE: - case EMC_SPINDLE_BRAKE_ENGAGE_TYPE: - case EMC_SPINDLE_INCREASE_TYPE: - case EMC_SPINDLE_DECREASE_TYPE: - case EMC_SPINDLE_CONSTANT_TYPE: - case EMC_COOLANT_MIST_ON_TYPE: - case EMC_COOLANT_MIST_OFF_TYPE: - case EMC_COOLANT_FLOOD_ON_TYPE: - case EMC_COOLANT_FLOOD_OFF_TYPE: - case EMC_TASK_SET_MODE_TYPE: - case EMC_TASK_SET_STATE_TYPE: - case EMC_TASK_ABORT_TYPE: - case EMC_TASK_PLAN_INIT_TYPE: - case EMC_TASK_PLAN_OPEN_TYPE: - case EMC_TASK_PLAN_CLOSE_TYPE: - case EMC_TASK_PLAN_RUN_TYPE: - case EMC_TASK_PLAN_EXECUTE_TYPE: - case EMC_TASK_PLAN_PAUSE_TYPE: - case EMC_TASK_PLAN_REVERSE_TYPE: - case EMC_TASK_PLAN_FORWARD_TYPE: - case EMC_TASK_PLAN_RESUME_TYPE: - case EMC_TASK_PLAN_SET_OPTIONAL_STOP_TYPE: - case EMC_TASK_PLAN_SET_BLOCK_DELETE_TYPE: - case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: - case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: - case EMC_TRAJ_PROBE_TYPE: - case EMC_AUX_INPUT_WAIT_TYPE: - case EMC_TRAJ_RIGID_TAP_TYPE: - case EMC_SET_DEBUG_TYPE: - retval = emcTaskIssueCommand(cmd); - break; - case EMC_TASK_PLAN_STEP_TYPE: // handles case where first action is to step the program taskPlanRunCmd.line = 0; // run from start @@ -1140,32 +1082,17 @@ static int emcTaskPlan(NMLmsg *cmd) retval = 0; break; - case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: { - // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - // signify no more reading - emcTaskPlanSetWait(); - // then resynch interpreter - emcTaskQueueTaskPlanSynchCmd(); + case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: + case EMC_TOOL_SET_OFFSET_TYPE: + queueToolCommand(cmd); break; - } - case EMC_TOOL_SET_OFFSET_TYPE: { - // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - // signify no more reading - emcTaskPlanSetWait(); - // then resynch interpreter - emcTaskQueueTaskPlanSynchCmd(); - break; - } // otherwise we can't handle it default: - //EMC_TASK_MODE::AUTO(2) && EMC_TASK_INTERP::IDLE(1) - if ( allow_while_idle_type(type) ) { - retval = emcTaskIssueCommand(cmd); - break; - } + if (isImmediate(type)) { + retval = emcTaskIssueCommand(cmd); + break; + } emcOperatorError(_("can't do that (%s) in auto mode with the interpreter idle"), emc_symbol_lookup(type)); retval = -1; break; @@ -1181,46 +1108,6 @@ static int emcTaskPlan(NMLmsg *cmd) // no command break; - // immediate commands - - case EMC_JOINT_SET_BACKLASH_TYPE: - case EMC_JOINT_SET_HOMING_PARAMS_TYPE: - case EMC_JOINT_SET_FERROR_TYPE: - case EMC_JOINT_SET_MIN_FERROR_TYPE: - case EMC_JOINT_UNHOME_TYPE: - case EMC_TRAJ_SET_SCALE_TYPE: - case EMC_TRAJ_SET_RAPID_SCALE_TYPE: - case EMC_TRAJ_SET_MAX_VELOCITY_TYPE: - case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE: - case EMC_TRAJ_SET_FO_ENABLE_TYPE: - case EMC_TRAJ_SET_FH_ENABLE_TYPE: - case EMC_TRAJ_SET_SO_ENABLE_TYPE: - case EMC_SPINDLE_INCREASE_TYPE: - case EMC_SPINDLE_DECREASE_TYPE: - case EMC_SPINDLE_CONSTANT_TYPE: - case EMC_TASK_PLAN_PAUSE_TYPE: - case EMC_TASK_PLAN_REVERSE_TYPE: - case EMC_TASK_PLAN_FORWARD_TYPE: - case EMC_TASK_PLAN_RESUME_TYPE: - case EMC_TASK_PLAN_SET_OPTIONAL_STOP_TYPE: - case EMC_TASK_PLAN_SET_BLOCK_DELETE_TYPE: - case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: - case EMC_TASK_SET_MODE_TYPE: - case EMC_TASK_SET_STATE_TYPE: - case EMC_TASK_ABORT_TYPE: - case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: - case EMC_TRAJ_PROBE_TYPE: - case EMC_AUX_INPUT_WAIT_TYPE: - case EMC_TRAJ_RIGID_TAP_TYPE: - case EMC_SET_DEBUG_TYPE: - case EMC_COOLANT_MIST_ON_TYPE: - case EMC_COOLANT_MIST_OFF_TYPE: - case EMC_COOLANT_FLOOD_ON_TYPE: - case EMC_COOLANT_FLOOD_OFF_TYPE: - retval = emcTaskIssueCommand(cmd); - return retval; - break; - case EMC_TASK_PLAN_STEP_TYPE: emcStatus->motion.traj.single_stepping = 1; stepping = 1; // set stepping mode in case it's not @@ -1229,6 +1116,10 @@ static int emcTaskPlan(NMLmsg *cmd) // otherwise we can't handle it default: + if (isImmediate(type)) { + // no readahead this cycle + return emcTaskIssueCommand(cmd); + } emcOperatorError(_("can't do that (%s) in auto mode with the interpreter reading"), emc_symbol_lookup(type)); retval = -1; break; @@ -1247,53 +1138,6 @@ static int emcTaskPlan(NMLmsg *cmd) // no command break; - // immediate commands - - case EMC_JOINT_SET_BACKLASH_TYPE: - case EMC_JOINT_SET_HOMING_PARAMS_TYPE: - case EMC_JOINT_SET_FERROR_TYPE: - case EMC_JOINT_SET_MIN_FERROR_TYPE: - case EMC_JOINT_UNHOME_TYPE: - case EMC_TRAJ_SET_SCALE_TYPE: - case EMC_TRAJ_SET_RAPID_SCALE_TYPE: - case EMC_TRAJ_SET_MAX_VELOCITY_TYPE: - case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE: - case EMC_TRAJ_SET_FO_ENABLE_TYPE: - case EMC_TRAJ_SET_FH_ENABLE_TYPE: - case EMC_TRAJ_SET_SO_ENABLE_TYPE: - case EMC_SPINDLE_SPEED_TYPE: - case EMC_SPINDLE_ORIENT_TYPE: - case EMC_SPINDLE_WAIT_ORIENT_COMPLETE_TYPE: - case EMC_SPINDLE_ON_TYPE: - case EMC_SPINDLE_OFF_TYPE: - case EMC_SPINDLE_BRAKE_RELEASE_TYPE: - case EMC_SPINDLE_BRAKE_ENGAGE_TYPE: - case EMC_SPINDLE_INCREASE_TYPE: - case EMC_SPINDLE_DECREASE_TYPE: - case EMC_SPINDLE_CONSTANT_TYPE: - case EMC_COOLANT_MIST_ON_TYPE: - case EMC_COOLANT_MIST_OFF_TYPE: - case EMC_COOLANT_FLOOD_ON_TYPE: - case EMC_COOLANT_FLOOD_OFF_TYPE: - case EMC_TASK_SET_MODE_TYPE: - case EMC_TASK_SET_STATE_TYPE: - case EMC_TASK_ABORT_TYPE: - case EMC_TASK_PLAN_EXECUTE_TYPE: - case EMC_TASK_PLAN_PAUSE_TYPE: - case EMC_TASK_PLAN_REVERSE_TYPE: - case EMC_TASK_PLAN_FORWARD_TYPE: - case EMC_TASK_PLAN_RESUME_TYPE: - case EMC_TASK_PLAN_SET_OPTIONAL_STOP_TYPE: - case EMC_TASK_PLAN_SET_BLOCK_DELETE_TYPE: - case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: - case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: - case EMC_TRAJ_PROBE_TYPE: - case EMC_AUX_INPUT_WAIT_TYPE: - case EMC_TRAJ_RIGID_TAP_TYPE: - case EMC_SET_DEBUG_TYPE: - retval = emcTaskIssueCommand(cmd); - break; - case EMC_TASK_PLAN_STEP_TYPE: emcStatus->motion.traj.single_stepping = 1; stepping = 1; @@ -1310,6 +1154,10 @@ static int emcTaskPlan(NMLmsg *cmd) // otherwise we can't handle it default: + if (isImmediate(type)) { + retval = emcTaskIssueCommand(cmd); + break; + } emcOperatorError(_("can't do that (%s) in auto mode with the interpreter paused"), emc_symbol_lookup(type)); retval = -1; break; @@ -1327,46 +1175,6 @@ static int emcTaskPlan(NMLmsg *cmd) // no command break; - // immediate commands - - case EMC_JOINT_SET_BACKLASH_TYPE: - case EMC_JOINT_SET_HOMING_PARAMS_TYPE: - case EMC_JOINT_SET_FERROR_TYPE: - case EMC_JOINT_SET_MIN_FERROR_TYPE: - case EMC_JOINT_UNHOME_TYPE: - case EMC_TRAJ_SET_SCALE_TYPE: - case EMC_TRAJ_SET_RAPID_SCALE_TYPE: - case EMC_TRAJ_SET_MAX_VELOCITY_TYPE: - case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE: - case EMC_TRAJ_SET_FO_ENABLE_TYPE: - case EMC_TRAJ_SET_FH_ENABLE_TYPE: - case EMC_TRAJ_SET_SO_ENABLE_TYPE: - case EMC_SPINDLE_INCREASE_TYPE: - case EMC_SPINDLE_DECREASE_TYPE: - case EMC_SPINDLE_CONSTANT_TYPE: - case EMC_TASK_PLAN_EXECUTE_TYPE: - case EMC_TASK_PLAN_PAUSE_TYPE: - case EMC_TASK_PLAN_REVERSE_TYPE: - case EMC_TASK_PLAN_FORWARD_TYPE: - case EMC_TASK_PLAN_RESUME_TYPE: - case EMC_TASK_PLAN_SET_OPTIONAL_STOP_TYPE: - case EMC_TASK_PLAN_SET_BLOCK_DELETE_TYPE: - case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: - case EMC_TASK_SET_MODE_TYPE: - case EMC_TASK_SET_STATE_TYPE: - case EMC_TASK_ABORT_TYPE: - case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: - case EMC_TRAJ_PROBE_TYPE: - case EMC_AUX_INPUT_WAIT_TYPE: - case EMC_TRAJ_RIGID_TAP_TYPE: - case EMC_SET_DEBUG_TYPE: - case EMC_COOLANT_MIST_ON_TYPE: - case EMC_COOLANT_MIST_OFF_TYPE: - case EMC_COOLANT_FLOOD_ON_TYPE: - case EMC_COOLANT_FLOOD_OFF_TYPE: - retval = emcTaskIssueCommand(cmd); - break; - case EMC_TASK_PLAN_STEP_TYPE: emcStatus->motion.traj.single_stepping = 1; stepping = 1; // set stepping mode in case it's not @@ -1375,6 +1183,10 @@ static int emcTaskPlan(NMLmsg *cmd) // otherwise we can't handle it default: + if (isImmediate(type)) { + retval = emcTaskIssueCommand(cmd); + break; + } emcOperatorError(_("can't do that (%s) in auto mode with the interpreter waiting"), emc_symbol_lookup(type)); retval = -1; break; @@ -1403,59 +1215,6 @@ static int emcTaskPlan(NMLmsg *cmd) // no command break; - // immediate commands - - case EMC_JOINT_SET_BACKLASH_TYPE: - case EMC_JOINT_SET_HOMING_PARAMS_TYPE: - case EMC_JOINT_SET_FERROR_TYPE: - case EMC_JOINT_SET_MIN_FERROR_TYPE: - case EMC_JOINT_UNHOME_TYPE: - case EMC_TRAJ_SET_SCALE_TYPE: - case EMC_TRAJ_SET_RAPID_SCALE_TYPE: - case EMC_TRAJ_SET_MAX_VELOCITY_TYPE: - case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE: - case EMC_TRAJ_SET_FO_ENABLE_TYPE: - case EMC_TRAJ_SET_FH_ENABLE_TYPE: - case EMC_TRAJ_SET_SO_ENABLE_TYPE: - case EMC_SPINDLE_SPEED_TYPE: - case EMC_SPINDLE_ORIENT_TYPE: - case EMC_SPINDLE_WAIT_ORIENT_COMPLETE_TYPE: - case EMC_SPINDLE_ON_TYPE: - case EMC_SPINDLE_OFF_TYPE: - case EMC_SPINDLE_BRAKE_RELEASE_TYPE: - case EMC_SPINDLE_BRAKE_ENGAGE_TYPE: - case EMC_SPINDLE_INCREASE_TYPE: - case EMC_SPINDLE_DECREASE_TYPE: - case EMC_SPINDLE_CONSTANT_TYPE: - case EMC_COOLANT_MIST_ON_TYPE: - case EMC_COOLANT_MIST_OFF_TYPE: - case EMC_COOLANT_FLOOD_ON_TYPE: - case EMC_COOLANT_FLOOD_OFF_TYPE: - case EMC_TASK_SET_MODE_TYPE: - case EMC_TASK_SET_STATE_TYPE: - case EMC_TASK_PLAN_INIT_TYPE: - case EMC_TASK_PLAN_OPEN_TYPE: - case EMC_TASK_PLAN_CLOSE_TYPE: - case EMC_TASK_PLAN_PAUSE_TYPE: - case EMC_TASK_PLAN_REVERSE_TYPE: - case EMC_TASK_PLAN_FORWARD_TYPE: - case EMC_TASK_PLAN_SET_OPTIONAL_STOP_TYPE: - case EMC_TASK_PLAN_SET_BLOCK_DELETE_TYPE: - case EMC_TASK_PLAN_RESUME_TYPE: - case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: - case EMC_TASK_PLAN_SYNCH_TYPE: - case EMC_TASK_ABORT_TYPE: - case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: - case EMC_TRAJ_PROBE_TYPE: - case EMC_AUX_INPUT_WAIT_TYPE: - case EMC_MOTION_SET_DOUT_TYPE: - case EMC_MOTION_SET_AOUT_TYPE: - case EMC_MOTION_ADAPTIVE_TYPE: - case EMC_TRAJ_RIGID_TAP_TYPE: - case EMC_SET_DEBUG_TYPE: - retval = emcTaskIssueCommand(cmd); - break; - case EMC_TASK_PLAN_EXECUTE_TYPE: // If there are no queued MDI commands, no commands in // interp_list, and waitFlag isn't set, then this new @@ -1478,32 +1237,17 @@ static int emcTaskPlan(NMLmsg *cmd) } break; - case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: { - // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - // signify no more reading - emcTaskPlanSetWait(); - // then resynch interpreter - emcTaskQueueTaskPlanSynchCmd(); + case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: + case EMC_TOOL_SET_OFFSET_TYPE: + queueToolCommand(cmd); break; - } - case EMC_TOOL_SET_OFFSET_TYPE: { - // send to IO - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - // signify no more reading - emcTaskPlanSetWait(); - // then resynch interpreter - emcTaskQueueTaskPlanSynchCmd(); - break; - } // otherwise we can't handle it default: - //EMC_TASK_MODE::MDI(3) && EMC_TASK_INTERP::IDLE(1) - if ( allow_while_idle_type(type) ) { - retval = emcTaskIssueCommand(cmd); + if (isImmediate(type)) { + retval = emcTaskIssueCommand(cmd); break; - } + } emcOperatorError(_("can't do that (%s:%d) in MDI mode"), emc_symbol_lookup(type),(int) type); retval = -1; From 83cfb05327deadd54074e92a37954f0f5c5ed470 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 10 Nov 2026 17:55:02 +0100 Subject: [PATCH 04/27] task: export halui's status pins that motion and iocontrol lack Task gets a HAL component, "task", with the status pins of halui that have no equivalent elsewhere: the task mode and whether motion is in joint mode, the interpreter state, optional stop and block delete, the override and max-velocity values, the soft limits and override-limits of each joint, each axis' Cartesian feedback and relative (DRO) position, the tool diameter and units-per-mm. Their names are halui's under "task." instead of "halui.". They are updated once per task cycle from task's own status, so they are current in the same cycle, where halui's lag by its poll. The component is created before inihal is ready, so that the HAL files, which the linuxcnc script runs as soon as inihal is, can connect its pins, as they can halui's. The axes and spindles are therefore read from the INI file, the way task sets motion up with them. tests/task-hal-pins connects some of the pins in a HAL file, and compares every one of them with halui's pin in manual, teleop, MDI with offsets and tools, with overrides, and while a program runs and is paused. --- src/emc/task/Submakefile | 1 + src/emc/task/emctaskmain.cc | 11 ++ src/emc/task/taskhal.cc | 260 ++++++++++++++++++++++++++ src/emc/task/taskhal.hh | 30 +++ tests/task-hal-pins/.gitignore | 1 + tests/task-hal-pins/checkresult | 2 + tests/task-hal-pins/slow.ngc | 2 + tests/task-hal-pins/task-hal-pins.ini | 102 ++++++++++ tests/task-hal-pins/task-pins.hal | 5 + tests/task-hal-pins/test-ui.py | 174 +++++++++++++++++ tests/task-hal-pins/test.sh | 5 + tests/task-hal-pins/tool.tbl.original | 2 + 12 files changed, 595 insertions(+) create mode 100644 src/emc/task/taskhal.cc create mode 100644 src/emc/task/taskhal.hh create mode 100644 tests/task-hal-pins/.gitignore create mode 100755 tests/task-hal-pins/checkresult create mode 100644 tests/task-hal-pins/slow.ngc create mode 100644 tests/task-hal-pins/task-hal-pins.ini create mode 100644 tests/task-hal-pins/task-pins.hal create mode 100755 tests/task-hal-pins/test-ui.py create mode 100755 tests/task-hal-pins/test.sh create mode 100644 tests/task-hal-pins/tool.tbl.original diff --git a/src/emc/task/Submakefile b/src/emc/task/Submakefile index 2f4950450b5..7ed45cd7887 100644 --- a/src/emc/task/Submakefile +++ b/src/emc/task/Submakefile @@ -22,6 +22,7 @@ MILLTASKSRCS := \ emc/motion/dbuf.c \ emc/motion/stashf.c \ emc/task/taskclass.cc \ + emc/task/taskhal.cc \ emc/task/backtrace.cc \ emc/usr_intf/mapini.cc diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index d710613c84c..869d244dcc6 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -84,6 +84,7 @@ fpu_control_t __fpu_control = _FPU_IEEE & ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_M #include "timeutil.hh" #include "task.hh" // emcTaskCommand etc #include "taskclass.hh" +#include "taskhal.hh" #include "motion/motion.h" // EMCMOT_ORIENT_* #include "ini/inihal.hh" @@ -3033,6 +3034,14 @@ constexpr auto RETRY_TIME = 10s; // wait for subsystems to come up return -1; } + // Before ini_hal_init(): the linuxcnc script runs the HAL files as + // soon as the inihal component is ready, and they may connect task's + // pins. + if (emcTaskHalInit(joints)) { + log_error("{}: emcTaskHalInit failed\n", __PRETTY_FUNCTION__); + return -1; + } + if (ini_hal_init(joints)) { log_error("{}: ini_hal_init failed\n", __PRETTY_FUNCTION__); return -1; @@ -3112,6 +3121,7 @@ static int emctask_shutdown(void) emcTaskPlanExit(); emcMotionHalt(); } + emcTaskHalExit(); // delete the timer if (NULL != timer) { delete timer; @@ -3472,6 +3482,7 @@ int main(int argc, char *argv[]) // update task-specific status emcTaskUpdate(&emcStatus->task); + emcTaskHalUpdate(*emcStatus); // handle RCS_STAT_MSG base class members explicitly, since this // is not an NML_MODULE and they won't be set automatically diff --git a/src/emc/task/taskhal.cc b/src/emc/task/taskhal.cc new file mode 100644 index 00000000000..0ffa3697cdf --- /dev/null +++ b/src/emc/task/taskhal.cc @@ -0,0 +1,260 @@ +/******************************************************************** +* Description: taskhal.cc +* HAL pins exported by Task ("task.*"). +* +* These are the halui pins that motion and iocontrol do not already +* provide. They are computed the same way halui computes them, but +* directly from Task's own status, once per Task cycle. +* +* License: GPL Version 2 +* System: Linux +********************************************************************/ + +#include +#include +#include +#include // TO_RAD +#include +#include +#include "taskhal.hh" +#include "nml_intf/emcglb.h" // emc_inifile +#include "logutil.hh" + +#define TASKHAL "task" + +using namespace linuxcnc; + +static const char axis_letters[] = "xyzabcuvw"; + +struct taskhal_str { + hal_real_t units_per_mm; + + hal_bool_t mode_is_manual; + hal_bool_t mode_is_auto; + hal_bool_t mode_is_mdi; + hal_bool_t mode_is_joint; + + hal_bool_t program_is_idle; + hal_bool_t program_is_running; + hal_bool_t program_is_paused; + hal_bool_t program_os_is_on; + hal_bool_t program_bd_is_on; + + hal_real_t mv_value; + hal_real_t fo_value; + hal_real_t ro_value; + hal_real_t so_value[EMCMOT_MAX_SPINDLES]; + + hal_bool_t joint_on_soft_min_limit[EMCMOT_MAX_JOINTS]; + hal_bool_t joint_on_soft_max_limit[EMCMOT_MAX_JOINTS]; + hal_bool_t joint_override_limits[EMCMOT_MAX_JOINTS]; + + hal_real_t axis_pos_feedback[EMCMOT_MAX_AXIS]; + hal_real_t axis_pos_relative[EMCMOT_MAX_AXIS]; + + hal_real_t tool_diameter; +}; + +static int comp_id = -1; +static taskhal_str *taskhal_data; +static int num_joints; +static int num_spindles; +static int axis_mask; + +#define CHK(x) do { \ + int rv = (x); \ + if (rv < 0) { \ + log_error(TASKHAL ": cannot create HAL pin\n"); \ + hal_exit(comp_id); \ + comp_id = -1; \ + return rv; \ + } \ + } while (0) + +int emcTaskHalInit(int joints) +{ + num_joints = joints; + + // The spindles and axes motion is set up with, read the same way as + // loadTraj() in ini/initraj.cc does: motion is not up yet. + { + linuxcnc::IniFile inifile(emc_inifile); + num_spindles = 1; + axis_mask = (1 << 0) | (1 << 1) | (1 << 2); + if (inifile) { + num_spindles = inifile.findIntV("SPINDLES", "TRAJ", 1); + if (auto coord = inifile.findString("COORDINATES", "TRAJ")) { + static const std::string axes{"XYZABCUVW"}; + axis_mask = 0; + for (auto c : *coord) { + size_t n = axes.find_first_of(toupper(c & 0xff)); + if (n != std::string::npos) { + axis_mask |= 1 << n; + } + } + } + } + } + + if (num_joints < 0 || num_joints > EMCMOT_MAX_JOINTS || + num_spindles < 0 || num_spindles > EMCMOT_MAX_SPINDLES) { + log_error(TASKHAL ": bad joint ({}) or spindle ({}) count\n", + num_joints, num_spindles); + return -1; + } + + comp_id = hal_init(TASKHAL); + if (comp_id < 0) { + log_error(TASKHAL ": hal_init() failed\n"); + return -1; + } + + taskhal_data = (taskhal_str *) hal_malloc(sizeof(taskhal_str)); + if (taskhal_data == NULL) { + log_error(TASKHAL ": hal_malloc() failed\n"); + hal_exit(comp_id); + comp_id = -1; + return -1; + } + taskhal_str *d = taskhal_data; + memset(d, 0, sizeof(*d)); + + CHK(hal_pin_new_real(comp_id, HAL_OUT, &d->units_per_mm, 0.0, TASKHAL ".machine.units-per-mm")); + + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->mode_is_manual, 0, TASKHAL ".mode.is-manual")); + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->mode_is_auto, 0, TASKHAL ".mode.is-auto")); + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->mode_is_mdi, 0, TASKHAL ".mode.is-mdi")); + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->mode_is_joint, 0, TASKHAL ".mode.is-joint")); + + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->program_is_idle, 0, TASKHAL ".program.is-idle")); + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->program_is_running, 0, TASKHAL ".program.is-running")); + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->program_is_paused, 0, TASKHAL ".program.is-paused")); + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->program_os_is_on, 0, TASKHAL ".program.optional-stop.is-on")); + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->program_bd_is_on, 0, TASKHAL ".program.block-delete.is-on")); + + CHK(hal_pin_new_real(comp_id, HAL_OUT, &d->mv_value, 0.0, TASKHAL ".max-velocity.value")); + CHK(hal_pin_new_real(comp_id, HAL_OUT, &d->fo_value, 0.0, TASKHAL ".feed-override.value")); + CHK(hal_pin_new_real(comp_id, HAL_OUT, &d->ro_value, 0.0, TASKHAL ".rapid-override.value")); + for (int s = 0; s < num_spindles; s++) { + CHK(hal_pin_new_real(comp_id, HAL_OUT, &d->so_value[s], 0.0, TASKHAL ".spindle.%d.override.value", s)); + } + + for (int j = 0; j < num_joints; j++) { + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->joint_on_soft_min_limit[j], 0, TASKHAL ".joint.%d.on-soft-min-limit", j)); + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->joint_on_soft_max_limit[j], 0, TASKHAL ".joint.%d.on-soft-max-limit", j)); + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->joint_override_limits[j], 0, TASKHAL ".joint.%d.override-limits", j)); + } + + for (int a = 0; a < EMCMOT_MAX_AXIS; a++) { + if (!(axis_mask & (1 << a))) { continue; } + CHK(hal_pin_new_real(comp_id, HAL_OUT, &d->axis_pos_feedback[a], 0.0, TASKHAL ".axis.%c.pos-feedback", axis_letters[a])); + CHK(hal_pin_new_real(comp_id, HAL_OUT, &d->axis_pos_relative[a], 0.0, TASKHAL ".axis.%c.pos-relative", axis_letters[a])); + } + + CHK(hal_pin_new_real(comp_id, HAL_OUT, &d->tool_diameter, 0.0, TASKHAL ".tool.diameter")); + + hal_ready(comp_id); + return 0; +} + +void emcTaskHalExit() +{ + if (comp_id >= 0) { + hal_exit(comp_id); + comp_id = -1; + } + taskhal_data = NULL; +} + +// the loaded tool's entry comes with the status, as halui reads it +static double tool_diameter(const EMC_TOOL_STAT &tool) +{ + const CANON_TOOL_TABLE &loaded = tool.toolTableCurrent; + if (tool.toolInSpindle != 0 && loaded.toolno == tool.toolInSpindle) { + return loaded.diameter; + } + return 0.0; +} + +void emcTaskHalUpdate(const EMC_STAT &stat) +{ + taskhal_str *d = taskhal_data; + if (!d) { + return; + } + const EMC_TASK_STAT &task = stat.task; + const EMC_TRAJ_STAT &traj = stat.motion.traj; + + hal_set_real(d->units_per_mm, traj.linearUnits); + + hal_set_bool(d->mode_is_manual, task.mode == EMC_TASK_MODE::MANUAL); + hal_set_bool(d->mode_is_auto, task.mode == EMC_TASK_MODE::AUTO); + hal_set_bool(d->mode_is_mdi, task.mode == EMC_TASK_MODE::MDI); + hal_set_bool(d->mode_is_joint, traj.mode == EMC_TRAJ_MODE::FREE); + + hal_set_bool(d->program_is_idle, task.interpState == EMC_TASK_INTERP::IDLE); + hal_set_bool(d->program_is_running, task.interpState == EMC_TASK_INTERP::READING || + task.interpState == EMC_TASK_INTERP::WAITING); + hal_set_bool(d->program_is_paused, task.interpState == EMC_TASK_INTERP::PAUSED); + hal_set_bool(d->program_os_is_on, task.optional_stop_state); + hal_set_bool(d->program_bd_is_on, task.block_delete_state); + + hal_set_real(d->mv_value, traj.maxVelocity); + hal_set_real(d->fo_value, traj.scale); + hal_set_real(d->ro_value, traj.rapid_scale); + for (int s = 0; s < num_spindles; s++) { + hal_set_real(d->so_value[s], stat.motion.spindle[s].spindle_scale); + } + + for (int j = 0; j < num_joints; j++) { + const EMC_JOINT_STAT &joint = stat.motion.joint[j]; + hal_set_bool(d->joint_on_soft_min_limit[j], joint.minSoftLimit); + hal_set_bool(d->joint_on_soft_max_limit[j], joint.maxSoftLimit); + hal_set_bool(d->joint_override_limits[j], joint.overrideLimits); + } + + // the relative position: the offset chain taken off in reverse, the + // tool offset, G5x, the XY rotation, G92 and the tilted work plane + const EmcPose &act = traj.actualPosition; + double rel[EMCMOT_MAX_AXIS]; + double rx = act.tran.x - task.g5x_offset.tran.x - task.toolOffset.tran.x; + double ry = act.tran.y - task.g5x_offset.tran.y - task.toolOffset.tran.y; + double rz = act.tran.z - task.g5x_offset.tran.z - task.toolOffset.tran.z; + { + double t = -task.rotation_xy * TO_RAD; + double x = rx * cos(t) - ry * sin(t); + double y = ry * cos(t) + rx * sin(t); + rx = x - task.g92_offset.tran.x; + ry = y - task.g92_offset.tran.y; + rz -= task.g92_offset.tran.z; + } + if (task.g68_active) { + const double *r = task.g68_rotation; + double x = rx - task.g68_offset.tran.x; + double y = ry - task.g68_offset.tran.y; + double z = rz - task.g68_offset.tran.z; + rx = r[0]*x + r[3]*y + r[6]*z; + ry = r[1]*x + r[4]*y + r[7]*z; + rz = r[2]*x + r[5]*y + r[8]*z; + } + rel[0] = rx; + rel[1] = ry; + rel[2] = rz; + rel[3] = act.a - task.g5x_offset.a - task.g92_offset.a - task.toolOffset.a; + rel[4] = act.b - task.g5x_offset.b - task.g92_offset.b - task.toolOffset.b; + rel[5] = act.c - task.g5x_offset.c - task.g92_offset.c - task.toolOffset.c; + rel[6] = act.u - task.g5x_offset.u - task.g92_offset.u - task.toolOffset.u; + rel[7] = act.v - task.g5x_offset.v - task.g92_offset.v - task.toolOffset.v; + rel[8] = act.w - task.g5x_offset.w - task.g92_offset.w - task.toolOffset.w; + + const double fb[EMCMOT_MAX_AXIS] = { + act.tran.x, act.tran.y, act.tran.z, act.a, act.b, act.c, act.u, act.v, act.w + }; + for (int a = 0; a < EMCMOT_MAX_AXIS; a++) { + if (!(axis_mask & (1 << a))) { continue; } + hal_set_real(d->axis_pos_feedback[a], fb[a]); + hal_set_real(d->axis_pos_relative[a], rel[a]); + } + + hal_set_real(d->tool_diameter, tool_diameter(stat.io.tool)); +} diff --git a/src/emc/task/taskhal.hh b/src/emc/task/taskhal.hh new file mode 100644 index 00000000000..767ddb5d289 --- /dev/null +++ b/src/emc/task/taskhal.hh @@ -0,0 +1,30 @@ +// HAL pins exported by Task ("task.*"), taking over halui's pins. +// +// 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. +#ifndef TASKHAL_HH +#define TASKHAL_HH + +#include "nml_intf/emc_nml.hh" + +// Create the "task" HAL component and its pins, before the HAL files run: +// they may connect them. The axes and spindles come from the INI file. +int emcTaskHalInit(int joints); + +// Copy status into the output pins, once per Task cycle. +void emcTaskHalUpdate(const EMC_STAT &stat); + +void emcTaskHalExit(); + +#endif diff --git a/tests/task-hal-pins/.gitignore b/tests/task-hal-pins/.gitignore new file mode 100644 index 00000000000..fa50ddda01b --- /dev/null +++ b/tests/task-hal-pins/.gitignore @@ -0,0 +1 @@ +tool.tbl diff --git a/tests/task-hal-pins/checkresult b/tests/task-hal-pins/checkresult new file mode 100755 index 00000000000..24dc9aa53e3 --- /dev/null +++ b/tests/task-hal-pins/checkresult @@ -0,0 +1,2 @@ +#!/bin/sh +exit 0 # test failure is indicated by test.sh exit value diff --git a/tests/task-hal-pins/slow.ngc b/tests/task-hal-pins/slow.ngc new file mode 100644 index 00000000000..99a89ba503a --- /dev/null +++ b/tests/task-hal-pins/slow.ngc @@ -0,0 +1,2 @@ +G1 F1 X5 +M2 diff --git a/tests/task-hal-pins/task-hal-pins.ini b/tests/task-hal-pins/task-hal-pins.ini new file mode 100644 index 00000000000..d8a8bbf67e9 --- /dev/null +++ b/tests/task-hal-pins/task-hal-pins.ini @@ -0,0 +1,102 @@ +[EMC] +VERSION = 1.1 +DEBUG = 0x7fffffff +RCS_DEBUG = 0x05400f01 + +[DISPLAY] +DISPLAY = ./test-ui.py + +[RS274NGC] +PARAMETER_FILE = sim.var + +[EMCMOT] +EMCMOT = motmod +COMM_TIMEOUT = 4.0 +BASE_PERIOD = 0 +SERVO_PERIOD = 1000000 + +[TASK] +TASK = milltask +CYCLE_TIME = 0.001 +MDI_QUEUED_COMMANDS=10000 + +[HAL] +HALUI = halui +HALFILE = LIB:core_sim.hal +HALFILE = task-pins.hal + +[EMCIO] +TOOL_TABLE = tool.tbl + +[HALUI] + +[TRAJ] +NO_FORCE_HOMING=1 +AXES = 3 +COORDINATES = X Y Z +HOME = 0 0 0 +LINEAR_UNITS = inch +ANGULAR_UNITS = degree +DEFAULT_LINEAR_VELOCITY = 1.2 +MAX_LINEAR_VELOCITY = 4 + +[KINS] +KINEMATICS = trivkins +JOINTS = 3 + +[AXIS_X] +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 + +[JOINT_0] +TYPE = LINEAR +HOME = 0.000 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 +BACKLASH = 0.000 +INPUT_SCALE = 4000 +OUTPUT_SCALE = 1.000 +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +FERROR = 0.050 +MIN_FERROR = 0.010 + +[AXIS_Y] +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 + +[JOINT_1] +TYPE = LINEAR +HOME = 0.000 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 +BACKLASH = 0.000 +INPUT_SCALE = 4000 +OUTPUT_SCALE = 1.000 +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +FERROR = 0.050 +MIN_FERROR = 0.010 + +[AXIS_Z] +MIN_LIMIT = -4.0 +MAX_LIMIT = 4.0 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 + +[JOINT_2] +TYPE = LINEAR +HOME = 0.0 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 +BACKLASH = 0.000 +INPUT_SCALE = 4000 +OUTPUT_SCALE = 1.000 +MIN_LIMIT = -4.0 +MAX_LIMIT = 4.0 +FERROR = 0.050 +MIN_FERROR = 0.010 diff --git a/tests/task-hal-pins/task-pins.hal b/tests/task-hal-pins/task-pins.hal new file mode 100644 index 00000000000..0dedcadec26 --- /dev/null +++ b/tests/task-hal-pins/task-pins.hal @@ -0,0 +1,5 @@ +# Task's pins must exist by the time the HAL files run, like halui's: a +# configuration nets them here, not only from a POSTGUI file. +net task-units-per-mm task.machine.units-per-mm +net task-is-manual task.mode.is-manual +net task-x-pos-feedback task.axis.x.pos-feedback diff --git a/tests/task-hal-pins/test-ui.py b/tests/task-hal-pins/test-ui.py new file mode 100755 index 00000000000..e715cee2a42 --- /dev/null +++ b/tests/task-hal-pins/test-ui.py @@ -0,0 +1,174 @@ +#!/usr/bin/env python3 + +# Check that the status pins Task exports (task.*) match the halui pins +# they replace, in a range of machine states. + +import linuxcnc +import hal +import time +import sys +import os + +program_start = time.time() + +def log(msg): + delta_t = time.time() - program_start + print("%.3f: %s" % (delta_t, msg)) + sys.stdout.flush() + + +# task pin -> halui pin +pairs = { + 'task.machine.units-per-mm': 'halui.machine.units-per-mm', + 'task.mode.is-manual': 'halui.mode.is-manual', + 'task.mode.is-auto': 'halui.mode.is-auto', + 'task.mode.is-mdi': 'halui.mode.is-mdi', + 'task.mode.is-joint': 'halui.mode.is-joint', + 'task.program.is-idle': 'halui.program.is-idle', + 'task.program.is-running': 'halui.program.is-running', + 'task.program.is-paused': 'halui.program.is-paused', + 'task.program.optional-stop.is-on': 'halui.program.optional-stop.is-on', + 'task.program.block-delete.is-on': 'halui.program.block-delete.is-on', + 'task.max-velocity.value': 'halui.max-velocity.value', + 'task.feed-override.value': 'halui.feed-override.value', + 'task.rapid-override.value': 'halui.rapid-override.value', + 'task.spindle.0.override.value': 'halui.spindle.0.override.value', + 'task.tool.diameter': 'halui.tool.diameter', +} +for j in range(3): + for p in ('on-soft-min-limit', 'on-soft-max-limit', 'override-limits'): + pairs['task.joint.%d.%s' % (j, p)] = 'halui.joint.%d.%s' % (j, p) +for a in 'xyz': + for p in ('pos-feedback', 'pos-relative'): + pairs['task.axis.%s.%s' % (a, p)] = 'halui.axis.%s.%s' % (a, p) + + +def same(a, b): + if isinstance(a, float) or isinstance(b, float): + return abs(a - b) < 1e-9 + return a == b + + +def check(what, expect={}, moving=False): + """Wait for every task pin to match its halui pin (halui polls, so it + lags), and for the pins in expect to have the given values. While the + machine moves, halui's positions are always a poll behind, so those + are not compared.""" + timeout = 5.0 + start = time.time() + while True: + bad = [] + for t, h in pairs.items(): + if moving and '.pos-' in t: + continue + tv = hal.get_value(t) + hv = hal.get_value(h) + if not same(tv, hv): + bad.append("%s=%r but %s=%r" % (t, tv, h, hv)) + for t, v in expect.items(): + tv = hal.get_value(t) + if not same(tv, v): + bad.append("%s=%r, expected %r" % (t, tv, v)) + if not bad: + log("%s: ok" % what) + return + if time.time() - start > timeout: + log("%s: FAILED" % what) + for b in bad: + log(" " + b) + sys.exit(1) + time.sleep(0.05) + + +def wait_for(what, cond): + start = time.time() + while time.time() - start < 10.0: + s.poll() + if cond(): + return + time.sleep(0.05) + log("timeout waiting for %s" % what) + sys.exit(1) + + +c = linuxcnc.command() +s = linuxcnc.stat() +e = linuxcnc.error_channel() + +c.state(linuxcnc.STATE_ESTOP_RESET) +c.state(linuxcnc.STATE_ON) +c.wait_complete() + +c.mode(linuxcnc.MODE_MANUAL) +c.wait_complete() +check("manual", {'task.mode.is-manual': True, 'task.program.is-idle': True, + 'task.machine.units-per-mm': 1 / 25.4}) + +for j in range(3): + c.home(j) + c.wait_complete() +wait_for("homed", lambda: all(s.homed[:3])) +c.teleop_enable(1) +c.wait_complete() +wait_for("teleop", lambda: s.motion_mode == linuxcnc.TRAJ_MODE_TELEOP) +check("teleop", {'task.mode.is-joint': False}) + +c.mode(linuxcnc.MODE_MDI) +c.wait_complete() +for cmd in ("G10 L2 P2 X1 Y2 Z3 R30", "G55", "T1 M6", "G43", "G92 X0.5", + "G0 X1 Y1 Z-1"): + c.mdi(cmd) + c.wait_complete() +wait_for("move done", lambda: s.inpos and s.interp_state == linuxcnc.INTERP_IDLE) +check("mdi with offsets and tool 1", {'task.mode.is-mdi': True, + 'task.tool.diameter': 0.25}) + +c.mdi("T2 M6") +c.wait_complete() +check("tool 2", {'task.tool.diameter': 0.375}) + +c.feedrate(0.7) +c.rapidrate(0.4) +c.spindleoverride(0.8, 0) +c.maxvel(2.0) +c.set_optional_stop(True) +c.set_block_delete(True) +c.wait_complete() +check("overrides", {'task.feed-override.value': 0.7, + 'task.rapid-override.value': 0.4, + 'task.spindle.0.override.value': 0.8, + 'task.max-velocity.value': 2.0, + 'task.program.optional-stop.is-on': True, + 'task.program.block-delete.is-on': True}) +c.set_optional_stop(False) +c.set_block_delete(False) +c.wait_complete() +check("opt stop / block delete off", + {'task.program.optional-stop.is-on': False, + 'task.program.block-delete.is-on': False}) + +c.mode(linuxcnc.MODE_AUTO) +c.wait_complete() +c.program_open(os.path.abspath("slow.ngc")) +c.wait_complete() +c.auto(linuxcnc.AUTO_RUN, 0) +wait_for("program running", lambda: s.interp_state in + (linuxcnc.INTERP_READING, linuxcnc.INTERP_WAITING) and s.current_vel > 0) +check("running", {'task.mode.is-auto': True, 'task.program.is-running': True}, + moving=True) + +c.auto(linuxcnc.AUTO_PAUSE) +wait_for("program paused", lambda: s.interp_state == linuxcnc.INTERP_PAUSED) +check("paused", {'task.program.is-paused': True}) + +c.abort() +c.wait_complete() +wait_for("program idle", lambda: s.interp_state == linuxcnc.INTERP_IDLE) +check("aborted", {'task.program.is-idle': True}) + +c.state(linuxcnc.STATE_OFF) +c.state(linuxcnc.STATE_ESTOP) +c.wait_complete() + +log("all pins match") +sys.exit(0) diff --git a/tests/task-hal-pins/test.sh b/tests/task-hal-pins/test.sh new file mode 100755 index 00000000000..c12c75b2697 --- /dev/null +++ b/tests/task-hal-pins/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cp -f tool.tbl.original tool.tbl + +exec linuxcnc -r task-hal-pins.ini diff --git a/tests/task-hal-pins/tool.tbl.original b/tests/task-hal-pins/tool.tbl.original new file mode 100644 index 00000000000..f4191907f5d --- /dev/null +++ b/tests/task-hal-pins/tool.tbl.original @@ -0,0 +1,2 @@ +T1 P1 D0.250000 Z+0.500000 ; +T2 P2 D0.375000 Z+0.750000 ; From 7cca15209d0b5073db95818b626713478fd1fddb Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 10 Nov 2026 18:06:23 +0100 Subject: [PATCH 05/27] task: halui's command pins, as task-internal commands Task exports halui's command input pins: machine on/off, E-stop reset, teleop/joint mode, mist and flood, program run/pause/resume/step/stop, abort, optional stop and block delete, home-all (with [JOINT_0]HOME_SEQUENCE, like halui), home and unhome of each joint, and start/stop/forward/reverse/increase/decrease/brake of each spindle. Like halui's they act on the rising edge, spindle increase and decrease also on the falling one, and send the same commands. halui's mode.manual, .auto and .mdi pins are left out: task's modes are to follow what task runs rather than be set. program.run switches to Auto first, as halui does. The commands do not go through NML. emcTaskQueueInternalCommand() queues them, and the main loop hands one to emcTaskPlan() on each cycle without a new NML command. They leave the echo serial number alone, and a refused one is reported on the error channel only: it does not turn the status of the UI's last command into ERROR, nor does a successful one clear that command's error. tests/task-hal-inputs pulses each pin, without halui, and checks both; it also sets one of the pins from a HAL file. --- src/emc/task/emctaskmain.cc | 39 +++- src/emc/task/task.hh | 3 + src/emc/task/taskhal.cc | 267 +++++++++++++++++++++- src/emc/task/taskhal.hh | 3 + tests/task-hal-inputs/.gitignore | 1 + tests/task-hal-inputs/checkresult | 2 + tests/task-hal-inputs/slow.ngc | 2 + tests/task-hal-inputs/task-hal-inputs.ini | 104 +++++++++ tests/task-hal-inputs/task-inputs.hal | 3 + tests/task-hal-inputs/test-ui.py | 167 ++++++++++++++ tests/task-hal-inputs/test.sh | 5 + tests/task-hal-inputs/tool.tbl.original | 2 + 12 files changed, 590 insertions(+), 8 deletions(-) create mode 100644 tests/task-hal-inputs/.gitignore create mode 100755 tests/task-hal-inputs/checkresult create mode 100644 tests/task-hal-inputs/slow.ngc create mode 100644 tests/task-hal-inputs/task-hal-inputs.ini create mode 100644 tests/task-hal-inputs/task-inputs.hal create mode 100755 tests/task-hal-inputs/test-ui.py create mode 100755 tests/task-hal-inputs/test.sh create mode 100644 tests/task-hal-inputs/tool.tbl.original diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 869d244dcc6..077bb88b99f 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -59,6 +59,7 @@ #include // isspace() #include #include +#include #include "motion/usrmotintf.h" #include // rtapi_strlcpy() #include "tooldata/tooldata.hh" @@ -135,6 +136,19 @@ static int emcTaskIssueCommand(NMLmsg * cmd); // pending command to be sent out by emcTaskExecute() std::unique_ptr emcTaskCommand; +// commands generated inside Task (not received over NML), handed to +// emcTaskPlan() one per cycle on cycles without a new NML command +static std::deque> internal_command_queue; + +int emcTaskQueueInternalCommand(std::unique_ptr &&cmd) +{ + if (!cmd) { + return -1; + } + internal_command_queue.push_back(std::move(cmd)); + return 0; +} + // signal handling code to stop main loop volatile int done; static int emctask_shutdown(void); @@ -3342,13 +3356,25 @@ int main(int argc, char *argv[]) taskPlanError = 0; taskExecuteError = 0; } - // run control cycle, with the new command if there is one - NMLmsg *newCommand = NULL; + // run control cycle, with at most one new command: a UI command + // over NML takes precedence over a queued internal one if (emcCommand->serial_number != emcStatus->echo_serial_number) { - newCommand = emcCommand; - } - if (0 != emcTaskPlan(newCommand)) { - taskPlanError = 1; + if (0 != emcTaskPlan(emcCommand)) { + taskPlanError = 1; + } + } else if (!internal_command_queue.empty()) { + std::unique_ptr cmd = std::move(internal_command_queue.front()); + internal_command_queue.pop_front(); + // not reported through taskPlanError: that would flag the last + // UI command as failed. emcTaskPlan() reports its own errors. + if (0 != emcTaskPlan(cmd.get())) { + log_debug(EMC_DEBUG_TASK_ISSUE, "internal command {} failed\n", + emcSymbolLookup(cmd->_type)); + } + } else { + if (0 != emcTaskPlan(nullptr)) { + taskPlanError = 1; + } } if (0 != emcTaskExecute()) { taskExecuteError = 1; @@ -3483,6 +3509,7 @@ int main(int argc, char *argv[]) // update task-specific status emcTaskUpdate(&emcStatus->task); emcTaskHalUpdate(*emcStatus); + emcTaskHalCheckInputs(*emcStatus); // handle RCS_STAT_MSG base class members explicitly, since this // is not an NML_MODULE and they won't be set automatically diff --git a/src/emc/task/task.hh b/src/emc/task/task.hh index d8c619cdb50..6503a131f53 100644 --- a/src/emc/task/task.hh +++ b/src/emc/task/task.hh @@ -23,6 +23,9 @@ extern std::unique_ptr emcTaskCommand; extern int stepping; extern int steppingWait; extern int emcTaskQueueCommand(std::unique_ptr &&cmd); +// Queue a command for emcTaskPlan() as if it came from a UI, but without +// touching the NML echo serial number or the command status UIs wait on. +extern int emcTaskQueueInternalCommand(std::unique_ptr &&cmd); extern int emcTaskOnce(const char *inifile, EMC_IO_STAT &emcioStatus); // Returns 0 if all joints are homed, 1 if any joints are un-homed. diff --git a/src/emc/task/taskhal.cc b/src/emc/task/taskhal.cc index 0ffa3697cdf..022bfad4a64 100644 --- a/src/emc/task/taskhal.cc +++ b/src/emc/task/taskhal.cc @@ -3,8 +3,10 @@ * HAL pins exported by Task ("task.*"). * * These are the halui pins that motion and iocontrol do not already -* provide. They are computed the same way halui computes them, but -* directly from Task's own status, once per Task cycle. +* provide. Status pins are computed the same way halui computes them, +* but directly from Task's own status once per Task cycle. Command pins +* act on their rising edge, like halui's, and queue the same commands +* halui would send, as Task-internal commands. * * License: GPL Version 2 * System: Linux @@ -17,6 +19,7 @@ #include #include #include "taskhal.hh" +#include "task.hh" // emcTaskQueueInternalCommand() #include "nml_intf/emcglb.h" // emc_inifile #include "logutil.hh" @@ -53,6 +56,53 @@ struct taskhal_str { hal_real_t axis_pos_relative[EMCMOT_MAX_AXIS]; hal_real_t tool_diameter; + + // command inputs, acting on the rising edge + hal_bool_t machine_on; + hal_bool_t machine_off; + hal_bool_t estop_reset; + hal_bool_t mode_teleop; + hal_bool_t mode_joint; + hal_bool_t mist_on; + hal_bool_t mist_off; + hal_bool_t flood_on; + hal_bool_t flood_off; + hal_bool_t program_run; + hal_bool_t program_pause; + hal_bool_t program_resume; + hal_bool_t program_step; + hal_bool_t program_stop; + hal_bool_t program_os_on; + hal_bool_t program_os_off; + hal_bool_t program_bd_on; + hal_bool_t program_bd_off; + hal_bool_t abort; + hal_bool_t home_all; + hal_bool_t joint_home[EMCMOT_MAX_JOINTS]; + hal_bool_t joint_unhome[EMCMOT_MAX_JOINTS]; + hal_bool_t spindle_start[EMCMOT_MAX_SPINDLES]; + hal_bool_t spindle_stop[EMCMOT_MAX_SPINDLES]; + hal_bool_t spindle_forward[EMCMOT_MAX_SPINDLES]; + hal_bool_t spindle_reverse[EMCMOT_MAX_SPINDLES]; + hal_bool_t spindle_increase[EMCMOT_MAX_SPINDLES]; + hal_bool_t spindle_decrease[EMCMOT_MAX_SPINDLES]; + hal_bool_t spindle_brake_on[EMCMOT_MAX_SPINDLES]; + hal_bool_t spindle_brake_off[EMCMOT_MAX_SPINDLES]; +}; + +// previous values of the command inputs, for edge detection +struct taskhal_inputs { + bool machine_on, machine_off, estop_reset; + bool mode_teleop, mode_joint; + bool mist_on, mist_off, flood_on, flood_off; + bool program_run, program_pause, program_resume, program_step, program_stop; + bool program_os_on, program_os_off, program_bd_on, program_bd_off; + bool abort, home_all; + bool joint_home[EMCMOT_MAX_JOINTS], joint_unhome[EMCMOT_MAX_JOINTS]; + bool spindle_start[EMCMOT_MAX_SPINDLES], spindle_stop[EMCMOT_MAX_SPINDLES]; + bool spindle_forward[EMCMOT_MAX_SPINDLES], spindle_reverse[EMCMOT_MAX_SPINDLES]; + bool spindle_increase[EMCMOT_MAX_SPINDLES], spindle_decrease[EMCMOT_MAX_SPINDLES]; + bool spindle_brake_on[EMCMOT_MAX_SPINDLES], spindle_brake_off[EMCMOT_MAX_SPINDLES]; }; static int comp_id = -1; @@ -60,6 +110,8 @@ static taskhal_str *taskhal_data; static int num_joints; static int num_spindles; static int axis_mask; +static bool have_home_all; +static taskhal_inputs old_inputs; #define CHK(x) do { \ int rv = (x); \ @@ -74,6 +126,7 @@ static int axis_mask; int emcTaskHalInit(int joints) { num_joints = joints; + old_inputs = taskhal_inputs(); // The spindles and axes motion is set up with, read the same way as // loadTraj() in ini/initraj.cc does: motion is not up yet. @@ -94,6 +147,9 @@ int emcTaskHalInit(int joints) } } } + + // like halui, only offer home-all when there is a homing sequence + have_home_all = inifile && inifile.isSet("HOME_SEQUENCE", "JOINT_0"); } if (num_joints < 0 || num_joints > EMCMOT_MAX_JOINTS || @@ -153,6 +209,43 @@ int emcTaskHalInit(int joints) CHK(hal_pin_new_real(comp_id, HAL_OUT, &d->tool_diameter, 0.0, TASKHAL ".tool.diameter")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->machine_on, 0, TASKHAL ".machine.on")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->machine_off, 0, TASKHAL ".machine.off")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->estop_reset, 0, TASKHAL ".estop.reset")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->mode_teleop, 0, TASKHAL ".mode.teleop")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->mode_joint, 0, TASKHAL ".mode.joint")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->mist_on, 0, TASKHAL ".mist.on")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->mist_off, 0, TASKHAL ".mist.off")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->flood_on, 0, TASKHAL ".flood.on")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->flood_off, 0, TASKHAL ".flood.off")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->program_run, 0, TASKHAL ".program.run")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->program_pause, 0, TASKHAL ".program.pause")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->program_resume, 0, TASKHAL ".program.resume")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->program_step, 0, TASKHAL ".program.step")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->program_stop, 0, TASKHAL ".program.stop")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->program_os_on, 0, TASKHAL ".program.optional-stop.on")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->program_os_off, 0, TASKHAL ".program.optional-stop.off")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->program_bd_on, 0, TASKHAL ".program.block-delete.on")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->program_bd_off, 0, TASKHAL ".program.block-delete.off")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->abort, 0, TASKHAL ".abort")); + if (have_home_all) { + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->home_all, 0, TASKHAL ".home-all")); + } + for (int j = 0; j < num_joints; j++) { + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->joint_home[j], 0, TASKHAL ".joint.%d.home", j)); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->joint_unhome[j], 0, TASKHAL ".joint.%d.unhome", j)); + } + for (int s = 0; s < num_spindles; s++) { + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->spindle_start[s], 0, TASKHAL ".spindle.%d.start", s)); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->spindle_stop[s], 0, TASKHAL ".spindle.%d.stop", s)); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->spindle_forward[s], 0, TASKHAL ".spindle.%d.forward", s)); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->spindle_reverse[s], 0, TASKHAL ".spindle.%d.reverse", s)); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->spindle_increase[s], 0, TASKHAL ".spindle.%d.increase", s)); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->spindle_decrease[s], 0, TASKHAL ".spindle.%d.decrease", s)); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->spindle_brake_on[s], 0, TASKHAL ".spindle.%d.brake-on", s)); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->spindle_brake_off[s], 0, TASKHAL ".spindle.%d.brake-off", s)); + } + hal_ready(comp_id); return 0; } @@ -258,3 +351,173 @@ void emcTaskHalUpdate(const EMC_STAT &stat) hal_set_real(d->tool_diameter, tool_diameter(stat.io.tool)); } + +// true on the rising edge of pin; old remembers the previous value +static bool rising(const hal_bool_t &pin, bool &old) +{ + bool v = hal_get_bool(pin); + bool r = v && !old; + old = v; + return r; +} + +// a change of pin in either direction; old remembers the previous value +static bool changed(const hal_bool_t &pin, bool &old) +{ + bool v = hal_get_bool(pin); + bool r = v != old; + old = v; + return r; +} + +template +static void queue(std::unique_ptr msg) +{ + emcTaskQueueInternalCommand(std::move(msg)); +} + +template +static void queue() +{ + queue(std::make_unique()); +} + +static void queue_state(EMC_TASK_STATE state) +{ + auto msg = std::make_unique(); + msg->state = state; + queue(std::move(msg)); +} + +// like halui, a mode command for the current mode is not sent at all +static void queue_mode(const EMC_STAT &stat, EMC_TASK_MODE mode) +{ + if (stat.task.mode == mode) { + return; + } + auto msg = std::make_unique(); + msg->mode = mode; + queue(std::move(msg)); +} + +static void queue_teleop(int enable) +{ + auto msg = std::make_unique(); + msg->enable = enable; + queue(std::move(msg)); +} + +static void queue_optional_stop(bool state) +{ + auto msg = std::make_unique(); + msg->state = state; + queue(std::move(msg)); +} + +static void queue_block_delete(bool state) +{ + auto msg = std::make_unique(); + msg->state = state; + queue(std::move(msg)); +} + +static void queue_program_run(const EMC_STAT &stat) +{ + if (stat.task.file[0] == 0) { + return; // no program open + } + queue_mode(stat, EMC_TASK_MODE::AUTO); + auto msg = std::make_unique(); + msg->line = 0; + queue(std::move(msg)); +} + +static void queue_home(int joint) +{ + auto msg = std::make_unique(); + msg->joint = joint; + queue(std::move(msg)); +} + +static void queue_unhome(int joint) +{ + auto msg = std::make_unique(); + msg->joint = joint; + queue(std::move(msg)); +} + +// dir is +1 or -1; the speed is the active S word, or 1 if there is none +static void queue_spindle_on(const EMC_STAT &stat, int spindle, int dir) +{ + auto msg = std::make_unique(); + msg->spindle = spindle; + double speed = fabs(stat.task.activeSettings[2]); + msg->speed = dir * (speed != 0 ? speed : 1); + queue(std::move(msg)); +} + +template +static void queue_spindle(int spindle) +{ + auto msg = std::make_unique(); + msg->spindle = spindle; + queue(std::move(msg)); +} + +void emcTaskHalCheckInputs(const EMC_STAT &stat) +{ + taskhal_str *d = taskhal_data; + if (!d) { + return; + } + taskhal_inputs &o = old_inputs; + + // same order as halui, so simultaneous edges queue in the same order + if (rising(d->machine_on, o.machine_on)) queue_state(EMC_TASK_STATE::ON); + if (rising(d->machine_off, o.machine_off)) queue_state(EMC_TASK_STATE::OFF); + if (rising(d->estop_reset, o.estop_reset)) queue_state(EMC_TASK_STATE::ESTOP_RESET); + + if (rising(d->mode_teleop, o.mode_teleop)) queue_teleop(1); + if (rising(d->mode_joint, o.mode_joint)) queue_teleop(0); + + if (rising(d->mist_on, o.mist_on)) queue(); + if (rising(d->mist_off, o.mist_off)) queue(); + if (rising(d->flood_on, o.flood_on)) queue(); + if (rising(d->flood_off, o.flood_off)) queue(); + + if (rising(d->program_run, o.program_run)) queue_program_run(stat); + if (rising(d->program_pause, o.program_pause)) queue(); + if (rising(d->program_os_on, o.program_os_on)) queue_optional_stop(true); + if (rising(d->program_os_off, o.program_os_off)) queue_optional_stop(false); + if (rising(d->program_bd_on, o.program_bd_on)) queue_block_delete(true); + if (rising(d->program_bd_off, o.program_bd_off)) queue_block_delete(false); + if (rising(d->program_resume, o.program_resume)) queue(); + if (rising(d->program_step, o.program_step)) queue(); + if (rising(d->program_stop, o.program_stop)) queue(); + + for (int s = 0; s < num_spindles; s++) { + if (rising(d->spindle_start[s], o.spindle_start[s])) queue_spindle_on(stat, s, +1); + if (rising(d->spindle_stop[s], o.spindle_stop[s])) queue_spindle(s); + if (rising(d->spindle_forward[s], o.spindle_forward[s])) queue_spindle_on(stat, s, +1); + if (rising(d->spindle_reverse[s], o.spindle_reverse[s])) queue_spindle_on(stat, s, -1); + // increase/decrease run while held, and fall back to constant on release + if (changed(d->spindle_increase[s], o.spindle_increase[s])) { + if (o.spindle_increase[s]) queue_spindle(s); + else queue_spindle(s); + } + if (changed(d->spindle_decrease[s], o.spindle_decrease[s])) { + if (o.spindle_decrease[s]) queue_spindle(s); + else queue_spindle(s); + } + if (rising(d->spindle_brake_on[s], o.spindle_brake_on[s])) queue_spindle(s); + if (rising(d->spindle_brake_off[s], o.spindle_brake_off[s])) queue_spindle(s); + } + + if (rising(d->abort, o.abort)) queue(); + if (have_home_all && rising(d->home_all, o.home_all)) queue_home(-1); + + for (int j = 0; j < num_joints; j++) { + if (rising(d->joint_home[j], o.joint_home[j])) queue_home(j); + if (rising(d->joint_unhome[j], o.joint_unhome[j])) queue_unhome(j); + } +} diff --git a/src/emc/task/taskhal.hh b/src/emc/task/taskhal.hh index 767ddb5d289..f9c70d33565 100644 --- a/src/emc/task/taskhal.hh +++ b/src/emc/task/taskhal.hh @@ -25,6 +25,9 @@ int emcTaskHalInit(int joints); // Copy status into the output pins, once per Task cycle. void emcTaskHalUpdate(const EMC_STAT &stat); +// Queue the commands for the input pins that changed since the last call. +void emcTaskHalCheckInputs(const EMC_STAT &stat); + void emcTaskHalExit(); #endif diff --git a/tests/task-hal-inputs/.gitignore b/tests/task-hal-inputs/.gitignore new file mode 100644 index 00000000000..fa50ddda01b --- /dev/null +++ b/tests/task-hal-inputs/.gitignore @@ -0,0 +1 @@ +tool.tbl diff --git a/tests/task-hal-inputs/checkresult b/tests/task-hal-inputs/checkresult new file mode 100755 index 00000000000..24dc9aa53e3 --- /dev/null +++ b/tests/task-hal-inputs/checkresult @@ -0,0 +1,2 @@ +#!/bin/sh +exit 0 # test failure is indicated by test.sh exit value diff --git a/tests/task-hal-inputs/slow.ngc b/tests/task-hal-inputs/slow.ngc new file mode 100644 index 00000000000..99a89ba503a --- /dev/null +++ b/tests/task-hal-inputs/slow.ngc @@ -0,0 +1,2 @@ +G1 F1 X5 +M2 diff --git a/tests/task-hal-inputs/task-hal-inputs.ini b/tests/task-hal-inputs/task-hal-inputs.ini new file mode 100644 index 00000000000..e982854944c --- /dev/null +++ b/tests/task-hal-inputs/task-hal-inputs.ini @@ -0,0 +1,104 @@ +[EMC] +VERSION = 1.1 +DEBUG = 0x7fffffff +RCS_DEBUG = 0x05400f01 + +[DISPLAY] +DISPLAY = ./test-ui.py + +[RS274NGC] +PARAMETER_FILE = sim.var + +[EMCMOT] +EMCMOT = motmod +COMM_TIMEOUT = 4.0 +BASE_PERIOD = 0 +SERVO_PERIOD = 1000000 + +[TASK] +TASK = milltask +CYCLE_TIME = 0.001 +MDI_QUEUED_COMMANDS=10000 + +[HAL] +HALFILE = LIB:core_sim.hal +HALFILE = task-inputs.hal + +[EMCIO] +TOOL_TABLE = tool.tbl + +[HALUI] + +[TRAJ] +NO_FORCE_HOMING=1 +AXES = 3 +COORDINATES = X Y Z +HOME = 0 0 0 +LINEAR_UNITS = inch +ANGULAR_UNITS = degree +DEFAULT_LINEAR_VELOCITY = 1.2 +MAX_LINEAR_VELOCITY = 4 + +[KINS] +KINEMATICS = trivkins +JOINTS = 3 + +[AXIS_X] +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 + +[JOINT_0] +HOME_SEQUENCE = 0 +TYPE = LINEAR +HOME = 0.000 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 +BACKLASH = 0.000 +INPUT_SCALE = 4000 +OUTPUT_SCALE = 1.000 +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +FERROR = 0.050 +MIN_FERROR = 0.010 + +[AXIS_Y] +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 + +[JOINT_1] +HOME_SEQUENCE = 0 +TYPE = LINEAR +HOME = 0.000 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 +BACKLASH = 0.000 +INPUT_SCALE = 4000 +OUTPUT_SCALE = 1.000 +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +FERROR = 0.050 +MIN_FERROR = 0.010 + +[AXIS_Z] +MIN_LIMIT = -4.0 +MAX_LIMIT = 4.0 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 + +[JOINT_2] +HOME_SEQUENCE = 0 +TYPE = LINEAR +HOME = 0.0 +MAX_VELOCITY = 4 +MAX_ACCELERATION = 1000.0 +BACKLASH = 0.000 +INPUT_SCALE = 4000 +OUTPUT_SCALE = 1.000 +MIN_LIMIT = -4.0 +MAX_LIMIT = 4.0 +FERROR = 0.050 +MIN_FERROR = 0.010 diff --git a/tests/task-hal-inputs/task-inputs.hal b/tests/task-hal-inputs/task-inputs.hal new file mode 100644 index 00000000000..5a7a1eb6575 --- /dev/null +++ b/tests/task-hal-inputs/task-inputs.hal @@ -0,0 +1,3 @@ +# Task's command pins must exist by the time the HAL files run, like +# halui's. (test-ui.py connects the ones it pulses itself, later.) +setp task.joint.1.home 0 diff --git a/tests/task-hal-inputs/test-ui.py b/tests/task-hal-inputs/test-ui.py new file mode 100755 index 00000000000..bd073f10256 --- /dev/null +++ b/tests/task-hal-inputs/test-ui.py @@ -0,0 +1,167 @@ +#!/usr/bin/env python3 + +# Drive Task through its command input pins (task.*), without halui, and +# check that each one has the same effect halui's pin has. + +import linuxcnc +import hal +import time +import sys +import os + +program_start = time.time() + +def log(msg): + delta_t = time.time() - program_start + print("%.3f: %s" % (delta_t, msg)) + sys.stdout.flush() + + +inputs = [ + 'machine.on', 'machine.off', 'estop.reset', + 'mode.teleop', 'mode.joint', + 'mist.on', 'mist.off', 'flood.on', 'flood.off', + 'program.run', 'program.pause', 'program.resume', 'program.step', + 'program.stop', 'abort', + 'program.optional-stop.on', 'program.optional-stop.off', + 'program.block-delete.on', 'program.block-delete.off', + 'home-all', 'joint.0.home', 'joint.0.unhome', + 'spindle.0.start', 'spindle.0.stop', 'spindle.0.forward', + 'spindle.0.reverse', 'spindle.0.increase', 'spindle.0.decrease', + 'spindle.0.brake-on', 'spindle.0.brake-off', +] + +h = hal.component("python-ui") +for name in inputs: + h.newpin(name, hal.Type.BOOL, hal.Dir.OUT) +h.ready() +for name in inputs: + sig = 'sig-' + name.replace('.', '-') + if os.system("halcmd net %s python-ui.%s task.%s" % (sig, name, name)): + log("cannot connect task.%s" % name) + sys.exit(1) + +c = linuxcnc.command() +s = linuxcnc.stat() +e = linuxcnc.error_channel() + + +def pulse(name): + h[name] = True + time.sleep(0.05) + h[name] = False + time.sleep(0.05) + + +def wait_for(what, cond): + start = time.time() + while time.time() - start < 10.0: + s.poll() + if cond(): + log("%s: ok" % what) + return + time.sleep(0.05) + log("timeout waiting for %s" % what) + log(" task_state=%d task_mode=%d interp=%d state=%d" % (s.task_state, s.task_mode, s.interp_state, s.state)) + while True: + err = e.poll() + if not err: + break + log(" error channel: %s" % err[1]) + sys.exit(1) + + +def press(name, what, cond): + pulse(name) + wait_for("%s -> %s" % (name, what), cond) + + +press('estop.reset', 'estop reset', lambda: s.task_state == linuxcnc.STATE_ESTOP_RESET) +press('machine.on', 'machine on', lambda: s.task_state == linuxcnc.STATE_ON) + +c.mode(linuxcnc.MODE_MANUAL) +c.wait_complete() + +press('mist.on', 'mist on', lambda: s.mist) +press('mist.off', 'mist off', lambda: not s.mist) +press('flood.on', 'flood on', lambda: s.flood) +press('flood.off', 'flood off', lambda: not s.flood) + +press('home-all', 'all homed', lambda: all(s.homed[:3])) +press('mode.joint', 'joint mode', lambda: s.motion_mode == linuxcnc.TRAJ_MODE_FREE) +# motion only unhomes in joint mode +press('joint.0.unhome', 'joint 0 unhomed', lambda: not s.homed[0]) +press('joint.0.home', 'joint 0 homed', lambda: s.homed[0]) +press('mode.teleop', 'teleop mode', lambda: s.motion_mode == linuxcnc.TRAJ_MODE_TELEOP) + +press('program.optional-stop.on', 'optional stop on', lambda: s.optional_stop) +press('program.optional-stop.off', 'optional stop off', lambda: not s.optional_stop) +press('program.block-delete.on', 'block delete on', lambda: s.block_delete) +press('program.block-delete.off', 'block delete off', lambda: not s.block_delete) + +press('spindle.0.forward', 'spindle forward', lambda: s.spindle[0]['direction'] == 1) +press('spindle.0.reverse', 'spindle reverse', lambda: s.spindle[0]['direction'] == -1) +press('spindle.0.stop', 'spindle stopped', lambda: s.spindle[0]['direction'] == 0) +press('spindle.0.start', 'spindle started', lambda: s.spindle[0]['direction'] == 1) +s.poll() +speed = abs(s.spindle[0]['speed']) +press('spindle.0.increase', 'spindle faster', lambda: abs(s.spindle[0]['speed']) > speed) +s.poll() +speed = abs(s.spindle[0]['speed']) +press('spindle.0.decrease', 'spindle slower', lambda: abs(s.spindle[0]['speed']) < speed) +press('spindle.0.stop', 'spindle stopped', lambda: s.spindle[0]['direction'] == 0) +press('spindle.0.brake-on', 'brake on', lambda: s.spindle[0]['brake']) +press('spindle.0.brake-off', 'brake off', lambda: not s.spindle[0]['brake']) + +# a rejected internal command must not mark the UI's last command failed +c.mode(linuxcnc.MODE_MANUAL) +c.wait_complete() +pulse('program.step') # can't step in manual mode +time.sleep(0.2) +s.poll() +if s.state != linuxcnc.RCS_DONE: + log("rejected internal command changed the UI command status to %d" % s.state) + sys.exit(1) +log("rejected internal command: UI status still done") + +# nor clear the error of the UI's last command, when one of them succeeds +c.auto(linuxcnc.AUTO_STEP) # can't step in manual mode either +c.wait_complete() +s.poll() +if s.state != linuxcnc.RCS_ERROR: + log("refused UI command: status %d, expected error" % s.state) + sys.exit(1) +pulse('mist.on') +wait_for('mist.on -> mist on', lambda: s.mist) +if s.state != linuxcnc.RCS_ERROR: + log("internal command cleared the UI command's error: status %d" % s.state) + sys.exit(1) +log("internal command: UI command's error kept") +pulse('mist.off') +wait_for('mist.off -> mist off', lambda: not s.mist) +while e.poll(): + pass + +c.program_open(os.path.abspath("slow.ngc")) +c.wait_complete() +press('program.run', 'auto mode, program running', + lambda: s.task_mode == linuxcnc.MODE_AUTO and + s.interp_state in (linuxcnc.INTERP_READING, linuxcnc.INTERP_WAITING)) +press('program.pause', 'paused', lambda: s.interp_state == linuxcnc.INTERP_PAUSED) +press('program.resume', 'running again', + lambda: s.interp_state in (linuxcnc.INTERP_READING, linuxcnc.INTERP_WAITING) and s.current_vel > 0) +press('program.stop', 'stopped', lambda: s.interp_state == linuxcnc.INTERP_IDLE) +press('program.step', 'stepped (paused)', lambda: s.interp_state == linuxcnc.INTERP_PAUSED) +press('abort', 'aborted', lambda: s.interp_state == linuxcnc.INTERP_IDLE) + +c.mode(linuxcnc.MODE_MANUAL) +c.wait_complete() + +# Task reports a machine that is off but out of estop as ESTOP_RESET +press('machine.off', 'machine off', lambda: s.task_state == linuxcnc.STATE_ESTOP_RESET) + +c.state(linuxcnc.STATE_ESTOP) +c.wait_complete() + +log("all input pins work") +sys.exit(0) diff --git a/tests/task-hal-inputs/test.sh b/tests/task-hal-inputs/test.sh new file mode 100755 index 00000000000..a56b5a072d1 --- /dev/null +++ b/tests/task-hal-inputs/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cp -f tool.tbl.original tool.tbl + +exec linuxcnc -r task-hal-inputs.ini diff --git a/tests/task-hal-inputs/tool.tbl.original b/tests/task-hal-inputs/tool.tbl.original new file mode 100644 index 00000000000..f4191907f5d --- /dev/null +++ b/tests/task-hal-inputs/tool.tbl.original @@ -0,0 +1,2 @@ +T1 P1 D0.250000 Z+0.500000 ; +T2 P2 D0.375000 Z+0.750000 ; From dc8c0ba1a4696041eafde261de7fda63ea734b92 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 10 Nov 2026 18:12:24 +0100 Subject: [PATCH 06/27] task: the halui pins whose iocontrol counterpart differs Three halui pins have a counterpart in iocontrol that is not quite the same signal, so a configuration could not just be renamed to it: - task.estop.is-activated: iocontrol.0.user-enable-out is its inverse. - task.estop.activate: iocontrol.0.emc-enable-in is a level that holds the machine in E-stop; this is an edge that puts it there once. - task.tool.number: iocontrol.0.tool-number is signed, halui's unsigned. With these, each halui pin that motion, iocontrol or task now covers has exactly one pin to be renamed to. --- src/emc/task/taskhal.cc | 15 ++++++++++++++- tests/task-hal-inputs/test-ui.py | 5 ++--- tests/task-hal-pins/test-ui.py | 8 ++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/emc/task/taskhal.cc b/src/emc/task/taskhal.cc index 022bfad4a64..920795fd260 100644 --- a/src/emc/task/taskhal.cc +++ b/src/emc/task/taskhal.cc @@ -32,6 +32,9 @@ static const char axis_letters[] = "xyzabcuvw"; struct taskhal_str { hal_real_t units_per_mm; + // also in iocontrol, but inverted there (user-enable-out) + hal_bool_t estop_is_activated; + hal_bool_t mode_is_manual; hal_bool_t mode_is_auto; hal_bool_t mode_is_mdi; @@ -56,10 +59,14 @@ struct taskhal_str { hal_real_t axis_pos_relative[EMCMOT_MAX_AXIS]; hal_real_t tool_diameter; + // also in iocontrol, but signed there (tool-number) + hal_uint_t tool_number; // command inputs, acting on the rising edge hal_bool_t machine_on; hal_bool_t machine_off; + // iocontrol's emc-enable-in is a level, this an edge + hal_bool_t estop_activate; hal_bool_t estop_reset; hal_bool_t mode_teleop; hal_bool_t mode_joint; @@ -92,7 +99,7 @@ struct taskhal_str { // previous values of the command inputs, for edge detection struct taskhal_inputs { - bool machine_on, machine_off, estop_reset; + bool machine_on, machine_off, estop_activate, estop_reset; bool mode_teleop, mode_joint; bool mist_on, mist_off, flood_on, flood_off; bool program_run, program_pause, program_resume, program_step, program_stop; @@ -176,6 +183,7 @@ int emcTaskHalInit(int joints) memset(d, 0, sizeof(*d)); CHK(hal_pin_new_real(comp_id, HAL_OUT, &d->units_per_mm, 0.0, TASKHAL ".machine.units-per-mm")); + CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->estop_is_activated, 0, TASKHAL ".estop.is-activated")); CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->mode_is_manual, 0, TASKHAL ".mode.is-manual")); CHK(hal_pin_new_bool(comp_id, HAL_OUT, &d->mode_is_auto, 0, TASKHAL ".mode.is-auto")); @@ -208,9 +216,11 @@ int emcTaskHalInit(int joints) } CHK(hal_pin_new_real(comp_id, HAL_OUT, &d->tool_diameter, 0.0, TASKHAL ".tool.diameter")); + CHK(hal_pin_new_uint(comp_id, HAL_OUT, &d->tool_number, 0, TASKHAL ".tool.number")); CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->machine_on, 0, TASKHAL ".machine.on")); CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->machine_off, 0, TASKHAL ".machine.off")); + CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->estop_activate, 0, TASKHAL ".estop.activate")); CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->estop_reset, 0, TASKHAL ".estop.reset")); CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->mode_teleop, 0, TASKHAL ".mode.teleop")); CHK(hal_pin_new_bool(comp_id, HAL_IN, &d->mode_joint, 0, TASKHAL ".mode.joint")); @@ -279,6 +289,7 @@ void emcTaskHalUpdate(const EMC_STAT &stat) const EMC_TRAJ_STAT &traj = stat.motion.traj; hal_set_real(d->units_per_mm, traj.linearUnits); + hal_set_bool(d->estop_is_activated, task.state == EMC_TASK_STATE::ESTOP); hal_set_bool(d->mode_is_manual, task.mode == EMC_TASK_MODE::MANUAL); hal_set_bool(d->mode_is_auto, task.mode == EMC_TASK_MODE::AUTO); @@ -350,6 +361,7 @@ void emcTaskHalUpdate(const EMC_STAT &stat) } hal_set_real(d->tool_diameter, tool_diameter(stat.io.tool)); + hal_set_uint(d->tool_number, stat.io.tool.toolInSpindle); } // true on the rising edge of pin; old remembers the previous value @@ -475,6 +487,7 @@ void emcTaskHalCheckInputs(const EMC_STAT &stat) // same order as halui, so simultaneous edges queue in the same order if (rising(d->machine_on, o.machine_on)) queue_state(EMC_TASK_STATE::ON); if (rising(d->machine_off, o.machine_off)) queue_state(EMC_TASK_STATE::OFF); + if (rising(d->estop_activate, o.estop_activate)) queue_state(EMC_TASK_STATE::ESTOP); if (rising(d->estop_reset, o.estop_reset)) queue_state(EMC_TASK_STATE::ESTOP_RESET); if (rising(d->mode_teleop, o.mode_teleop)) queue_teleop(1); diff --git a/tests/task-hal-inputs/test-ui.py b/tests/task-hal-inputs/test-ui.py index bd073f10256..c15edc24751 100755 --- a/tests/task-hal-inputs/test-ui.py +++ b/tests/task-hal-inputs/test-ui.py @@ -18,7 +18,7 @@ def log(msg): inputs = [ - 'machine.on', 'machine.off', 'estop.reset', + 'machine.on', 'machine.off', 'estop.activate', 'estop.reset', 'mode.teleop', 'mode.joint', 'mist.on', 'mist.off', 'flood.on', 'flood.off', 'program.run', 'program.pause', 'program.resume', 'program.step', @@ -160,8 +160,7 @@ def press(name, what, cond): # Task reports a machine that is off but out of estop as ESTOP_RESET press('machine.off', 'machine off', lambda: s.task_state == linuxcnc.STATE_ESTOP_RESET) -c.state(linuxcnc.STATE_ESTOP) -c.wait_complete() +press('estop.activate', 'estop', lambda: s.task_state == linuxcnc.STATE_ESTOP) log("all input pins work") sys.exit(0) diff --git a/tests/task-hal-pins/test-ui.py b/tests/task-hal-pins/test-ui.py index e715cee2a42..238b5eae49a 100755 --- a/tests/task-hal-pins/test-ui.py +++ b/tests/task-hal-pins/test-ui.py @@ -20,6 +20,8 @@ def log(msg): # task pin -> halui pin pairs = { 'task.machine.units-per-mm': 'halui.machine.units-per-mm', + 'task.estop.is-activated': 'halui.estop.is-activated', + 'task.tool.number': 'halui.tool.number', 'task.mode.is-manual': 'halui.mode.is-manual', 'task.mode.is-auto': 'halui.mode.is-auto', 'task.mode.is-mdi': 'halui.mode.is-mdi', @@ -121,11 +123,12 @@ def wait_for(what, cond): c.wait_complete() wait_for("move done", lambda: s.inpos and s.interp_state == linuxcnc.INTERP_IDLE) check("mdi with offsets and tool 1", {'task.mode.is-mdi': True, - 'task.tool.diameter': 0.25}) + 'task.tool.diameter': 0.25, + 'task.tool.number': 1}) c.mdi("T2 M6") c.wait_complete() -check("tool 2", {'task.tool.diameter': 0.375}) +check("tool 2", {'task.tool.diameter': 0.375, 'task.tool.number': 2}) c.feedrate(0.7) c.rapidrate(0.4) @@ -169,6 +172,7 @@ def wait_for(what, cond): c.state(linuxcnc.STATE_OFF) c.state(linuxcnc.STATE_ESTOP) c.wait_complete() +check("estop", {'task.estop.is-activated': True}) log("all pins match") sys.exit(0) From 932da0b098aab787422be147d3296849b9ad6858 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 20:08:51 +0100 Subject: [PATCH 07/27] nml: remove seven commands nothing in the tree sends EMC_JOG_ABS, EMC_JOINT_HALT, EMC_JOINT_SET_FERROR, EMC_JOINT_SET_MIN_FERROR, EMC_JOINT_SET_HOMING_PARAMS, EMC_TRAJ_SET_VELOCITY and EMC_TRAJ_SET_ACCELERATION, with their classes, task's handling of them and their rows in the planner table. emcJogAbs() had no other caller. --- docs/src/code/nml-messages.adoc | 7 -- src/emc/nml_intf/emc.cc | 133 ------------------------------ src/emc/nml_intf/emc.hh | 8 -- src/emc/nml_intf/emc_nml.hh | 138 -------------------------------- src/emc/task/emctaskmain.cc | 74 ----------------- src/emc/task/taskintf.cc | 28 ------- src/emc/task/test_task_probe.cc | 8 -- tests/task-planner/expected | 63 --------------- 8 files changed, 459 deletions(-) diff --git a/docs/src/code/nml-messages.adoc b/docs/src/code/nml-messages.adoc index 307066ea39d..6271df5421b 100644 --- a/docs/src/code/nml-messages.adoc +++ b/docs/src/code/nml-messages.adoc @@ -24,12 +24,8 @@ EMC_JOINT_SET_JOINT_TYPE EMC_JOINT_SET_UNITS_TYPE EMC_JOINT_SET_MIN_POSITION_LIMIT_TYPE EMC_JOINT_SET_MAX_POSITION_LIMIT_TYPE -EMC_JOINT_SET_FERROR_TYPE -EMC_JOINT_SET_HOMING_PARAMS_TYPE -EMC_JOINT_SET_MIN_FERROR_TYPE EMC_JOINT_SET_MAX_VELOCITY_TYPE EMC_JOINT_INIT_TYPE -EMC_JOINT_HALT_TYPE EMC_JOINT_ABORT_TYPE EMC_JOINT_ENABLE_TYPE EMC_JOINT_DISABLE_TYPE @@ -56,7 +52,6 @@ EMC_AXIS_STAT_TYPE ---- EMC_JOG_CONT_TYPE EMC_JOG_INCR_TYPE -EMC_JOG_ABS_TYPE EMC_JOG_STOP_TYPE ---- @@ -68,8 +63,6 @@ EMC_TRAJ_SET_AXES_TYPE EMC_TRAJ_SET_UNITS_TYPE EMC_TRAJ_SET_CYCLE_TIME_TYPE EMC_TRAJ_SET_MODE_TYPE -EMC_TRAJ_SET_VELOCITY_TYPE -EMC_TRAJ_SET_ACCELERATION_TYPE EMC_TRAJ_SET_MAX_VELOCITY_TYPE EMC_TRAJ_SET_MAX_ACCELERATION_TYPE EMC_TRAJ_SET_SCALE_TYPE diff --git a/src/emc/nml_intf/emc.cc b/src/emc/nml_intf/emc.cc index 3716cde7aee..a98bbf7e10c 100644 --- a/src/emc/nml_intf/emc.cc +++ b/src/emc/nml_intf/emc.cc @@ -49,9 +49,6 @@ int emcFormat(NMLTYPE type, void *buffer, CMS * cms) case EMC_AUX_STAT_TYPE: ((EMC_AUX_STAT *) buffer)->update(cms); break; - case EMC_JOINT_HALT_TYPE: - ((EMC_JOINT_HALT *) buffer)->update(cms); - break; case EMC_JOINT_HOME_TYPE: ((EMC_JOINT_HOME *) buffer)->update(cms); break; @@ -64,9 +61,6 @@ int emcFormat(NMLTYPE type, void *buffer, CMS * cms) case EMC_JOG_INCR_TYPE: ((EMC_JOG_INCR *) buffer)->update(cms); break; - case EMC_JOG_ABS_TYPE: - ((EMC_JOG_ABS *) buffer)->update(cms); - break; case EMC_JOG_STOP_TYPE: ((EMC_JOG_STOP *) buffer)->update(cms); break; @@ -76,21 +70,12 @@ int emcFormat(NMLTYPE type, void *buffer, CMS * cms) case EMC_JOINT_OVERRIDE_LIMITS_TYPE: ((EMC_JOINT_OVERRIDE_LIMITS *) buffer)->update(cms); break; - case EMC_JOINT_SET_FERROR_TYPE: - ((EMC_JOINT_SET_FERROR *) buffer)->update(cms); - break; case EMC_JOINT_SET_BACKLASH_TYPE: ((EMC_JOINT_SET_BACKLASH *) buffer)->update(cms); break; - case EMC_JOINT_SET_HOMING_PARAMS_TYPE: - ((EMC_JOINT_SET_HOMING_PARAMS *) buffer)->update(cms); - break; case EMC_JOINT_SET_MAX_POSITION_LIMIT_TYPE: ((EMC_JOINT_SET_MAX_POSITION_LIMIT *) buffer)->update(cms); break; - case EMC_JOINT_SET_MIN_FERROR_TYPE: - ((EMC_JOINT_SET_MIN_FERROR *) buffer)->update(cms); - break; case EMC_JOINT_SET_MIN_POSITION_LIMIT_TYPE: ((EMC_JOINT_SET_MIN_POSITION_LIMIT *) buffer)->update(cms); break; @@ -268,9 +253,6 @@ int emcFormat(NMLTYPE type, void *buffer, CMS * cms) case EMC_AUX_INPUT_WAIT_TYPE: ((EMC_AUX_INPUT_WAIT *) buffer)->update(cms); break; - case EMC_TRAJ_SET_ACCELERATION_TYPE: - ((EMC_TRAJ_SET_ACCELERATION *) buffer)->update(cms); - break; case EMC_TRAJ_SET_MAX_VELOCITY_TYPE: ((EMC_TRAJ_SET_MAX_VELOCITY *) buffer)->update(cms); break; @@ -326,9 +308,6 @@ int emcFormat(NMLTYPE type, void *buffer, CMS * cms) ((EMC_TRAJ_SET_SPINDLESYNC *) buffer)->update(cms); break; break; - case EMC_TRAJ_SET_VELOCITY_TYPE: - ((EMC_TRAJ_SET_VELOCITY *) buffer)->update(cms); - break; case EMC_TRAJ_STAT_TYPE: ((EMC_TRAJ_STAT *) buffer)->update(cms); break; @@ -345,8 +324,6 @@ const char *emc_symbol_lookup(uint32_t type) switch (type) { case EMC_AUX_STAT_TYPE: return "EMC_AUX_STAT"; - case EMC_JOINT_HALT_TYPE: - return "EMC_JOINT_HALT"; case EMC_JOINT_HOME_TYPE: return "EMC_JOINT_HOME"; case EMC_JOINT_UNHOME_TYPE: @@ -355,24 +332,16 @@ const char *emc_symbol_lookup(uint32_t type) return "EMC_JOG_CONT"; case EMC_JOG_INCR_TYPE: return "EMC_JOG_INCR"; - case EMC_JOG_ABS_TYPE: - return "EMC_JOG_ABS"; case EMC_JOG_STOP_TYPE: return "EMC_JOG_STOP"; case EMC_JOINT_LOAD_COMP_TYPE: return "EMC_JOINT_LOAD_COMP"; case EMC_JOINT_OVERRIDE_LIMITS_TYPE: return "EMC_JOINT_OVERRIDE_LIMITS"; - case EMC_JOINT_SET_FERROR_TYPE: - return "EMC_JOINT_SET_FERROR"; case EMC_JOINT_SET_BACKLASH_TYPE: return "EMC_JOINT_SET_BACKLASH"; - case EMC_JOINT_SET_HOMING_PARAMS_TYPE: - return "EMC_JOINT_SET_HOMING_PARAMS"; case EMC_JOINT_SET_MAX_POSITION_LIMIT_TYPE: return "EMC_JOINT_SET_MAX_POSITION_LIMIT"; - case EMC_JOINT_SET_MIN_FERROR_TYPE: - return "EMC_JOINT_SET_MIN_FERROR"; case EMC_JOINT_SET_MIN_POSITION_LIMIT_TYPE: return "EMC_JOINT_SET_MIN_POSITION_LIMIT"; case EMC_JOINT_STAT_TYPE: @@ -495,8 +464,6 @@ const char *emc_symbol_lookup(uint32_t type) return "EMC_AUX_INPUT_WAIT"; case EMC_TRAJ_RIGID_TAP_TYPE: return "EMC_TRAJ_RIGID_TAP"; - case EMC_TRAJ_SET_ACCELERATION_TYPE: - return "EMC_TRAJ_SET_ACCELERATION"; case EMC_TRAJ_SET_MAX_VELOCITY_TYPE: return "EMC_TRAJ_SET_MAX_VELOCITY"; case EMC_TRAJ_SET_MODE_TYPE: @@ -533,8 +500,6 @@ const char *emc_symbol_lookup(uint32_t type) return "EMC_TRAJ_SET_TERM_COND"; case EMC_TRAJ_SET_SPINDLESYNC_TYPE: return "EMC_TRAJ_SET_SPINDLESYNC"; - case EMC_TRAJ_SET_VELOCITY_TYPE: - return "EMC_TRAJ_SET_VELOCITY"; case EMC_TRAJ_STAT_TYPE: return "EMC_TRAJ_STAT"; default: @@ -675,19 +640,6 @@ void EMC_TRAJ_DELAY::update(CMS * cms) cms->update(delay); } -/* -* NML/CMS Update function for EMC_JOG_ABS -*/ -// cppcheck-suppress duplInheritedMember -void EMC_JOG_ABS::update(CMS * cms) -{ - EMC_JOG_CMD_MSG::update(cms); - cms->update(pos); - cms->update(vel); - cms->update(jjogmode); - -} - /* * NML/CMS Update function for EMC_JOG_STOP */ @@ -778,18 +730,6 @@ void PmCartesian_update(CMS * cms, PmCartesian * x) cms->update(x->z); } -/* -* NML/CMS Update function for EMC_JOINT_SET_FERROR -* Automatically generated by NML CodeGen Java Applet. -* on Sat Oct 11 13:45:16 UTC 2003 -*/ -// cppcheck-suppress duplInheritedMember -void EMC_JOINT_SET_FERROR::update(CMS * cms) -{ - EMC_JOINT_CMD_MSG::update(cms); - cms->update(ferror); -} - /* * NML/CMS Update function for EMC_JOINT_SET_MIN_POSITION_LIMIT * Automatically generated by NML CodeGen Java Applet. @@ -802,19 +742,6 @@ void EMC_JOINT_SET_MIN_POSITION_LIMIT::update(CMS * cms) cms->update(limit); } -/* -* NML/CMS Update function for EMC_TRAJ_SET_VELOCITY -* Automatically generated by NML CodeGen Java Applet. -* on Sat Oct 11 13:45:16 UTC 2003 -*/ -// cppcheck-suppress duplInheritedMember -void EMC_TRAJ_SET_VELOCITY::update(CMS * cms) -{ - EMC_TRAJ_CMD_MSG::update(cms); - cms->update(velocity); - cms->update(ini_maxvel); -} - /* * NML/CMS Update function for EMC_TASK_ABORT * Automatically generated by NML CodeGen Java Applet. @@ -837,18 +764,6 @@ void EMC_TASK_PLAN_INIT::update(CMS * cms) EMC_TASK_CMD_MSG::update(cms); } -/* -* NML/CMS Update function for EMC_TRAJ_SET_ACCELERATION -* Automatically generated by NML CodeGen Java Applet. -* on Sat Oct 11 13:45:16 UTC 2003 -*/ -// cppcheck-suppress duplInheritedMember -void EMC_TRAJ_SET_ACCELERATION::update(CMS * cms) -{ - EMC_TRAJ_CMD_MSG::update(cms); - cms->update(acceleration); -} - /* * NML/CMS Update function for EMC_AUX_STAT * Automatically generated by NML CodeGen Java Applet. @@ -1781,18 +1696,6 @@ void EMC_AUX_CMD_MSG::update(CMS * /*cms*/) } -/* -* NML/CMS Update function for EMC_JOINT_SET_MIN_FERROR -* Automatically generated by NML CodeGen Java Applet. -* on Sat Oct 11 13:45:17 UTC 2003 -*/ -// cppcheck-suppress duplInheritedMember -void EMC_JOINT_SET_MIN_FERROR::update(CMS * cms) -{ - EMC_JOINT_CMD_MSG::update(cms); - cms->update(ferror); -} - /* * NML/CMS Update function for EMC_NULL * Automatically generated by NML CodeGen Java Applet. @@ -1902,31 +1805,6 @@ void EMC_TASK_PLAN_OPEN::update(CMS * cms) cms->update(remote_buffer, sizeof(remote_buffer)); } -/* -* NML/CMS Update function for EMC_JOINT_SET_HOMING_PARAMS -* Manually generated - do not use NML CodeGen Java Applet. -*/ -// cppcheck-suppress duplInheritedMember -void EMC_JOINT_SET_HOMING_PARAMS::update(CMS * cms) -{ - EMC_JOINT_CMD_MSG::update(cms); - cms->update(home); - cms->update(offset); - cms->update(home_final_vel); - cms->update(search_vel); - cms->update(latch_vel); - cms->update(search_dist); - cms->update(latch_dist); - cms->update(use_index); - cms->update(encoder_does_not_reset); - cms->update(ignore_limits); - cms->update(is_shared); - cms->update(home_sequence); - cms->update(volatile_home); - cms->update(locking_indexer); - cms->update(absolute_encoder); -} - /* * NML/CMS Update function for EMC_TRAJ_SET_MODE * Automatically generated by NML CodeGen Java Applet. @@ -1987,17 +1865,6 @@ void EMC_TRAJ_SET_TELEOP_ENABLE::update(CMS * cms) cms->update(enable); } -/* -* NML/CMS Update function for EMC_JOINT_HALT -* Automatically generated by NML CodeGen Java Applet. -* on Sat Oct 11 13:45:17 UTC 2003 -*/ -// cppcheck-suppress duplInheritedMember -void EMC_JOINT_HALT::update(CMS * cms) -{ - EMC_JOINT_CMD_MSG::update(cms); -} - /* * NML/CMS Update function for EMC_TASK_PLAN_PAUSE * Automatically generated by NML CodeGen Java Applet. diff --git a/src/emc/nml_intf/emc.hh b/src/emc/nml_intf/emc.hh index 2037aba3a62..6cd98021727 100644 --- a/src/emc/nml_intf/emc.hh +++ b/src/emc/nml_intf/emc.hh @@ -60,14 +60,9 @@ struct PM_CARTESIAN; #define EMC_JOINT_SET_MIN_POSITION_LIMIT_TYPE ((NMLTYPE) 107) #define EMC_JOINT_SET_MAX_POSITION_LIMIT_TYPE ((NMLTYPE) 108) -#define EMC_JOINT_SET_FERROR_TYPE ((NMLTYPE) 111) -#define EMC_JOINT_SET_HOMING_PARAMS_TYPE ((NMLTYPE) 112) -#define EMC_JOINT_SET_MIN_FERROR_TYPE ((NMLTYPE) 115) -#define EMC_JOINT_HALT_TYPE ((NMLTYPE) 119) #define EMC_JOINT_HOME_TYPE ((NMLTYPE) 123) #define EMC_JOG_CONT_TYPE ((NMLTYPE) 124) #define EMC_JOG_INCR_TYPE ((NMLTYPE) 125) -#define EMC_JOG_ABS_TYPE ((NMLTYPE) 126) #define EMC_JOINT_OVERRIDE_LIMITS_TYPE ((NMLTYPE) 129) #define EMC_JOINT_LOAD_COMP_TYPE ((NMLTYPE) 131) #define EMC_JOINT_SET_BACKLASH_TYPE ((NMLTYPE) 134) @@ -85,8 +80,6 @@ struct PM_CARTESIAN; #define EMC_TRAJ_TERM_COND_BLEND 2 #define EMC_TRAJ_SET_MODE_TYPE ((NMLTYPE) 204) -#define EMC_TRAJ_SET_VELOCITY_TYPE ((NMLTYPE) 205) -#define EMC_TRAJ_SET_ACCELERATION_TYPE ((NMLTYPE) 206) #define EMC_TRAJ_SET_MAX_VELOCITY_TYPE ((NMLTYPE) 207) #define EMC_TRAJ_SET_SCALE_TYPE ((NMLTYPE) 209) #define EMC_TRAJ_SET_RAPID_SCALE_TYPE ((NMLTYPE) 238) @@ -326,7 +319,6 @@ extern int emcJointLoadComp(int joint, const char *file, int type); extern int emcJogStop(int nr, int jjogmode); extern int emcJogCont(int nr, double vel, int jjogmode); extern int emcJogIncr(int nr, double incr, double vel, int jjogmode); -extern int emcJogAbs(int nr, double pos, double vel, int jjogmode); extern int emcJointUpdate(EMC_JOINT_STAT stat[], int numJoints); diff --git a/src/emc/nml_intf/emc_nml.hh b/src/emc/nml_intf/emc_nml.hh index 2f91f26cb91..43d999d1a7b 100644 --- a/src/emc/nml_intf/emc_nml.hh +++ b/src/emc/nml_intf/emc_nml.hh @@ -244,93 +244,6 @@ class EMC_JOINT_SET_MAX_POSITION_LIMIT:public EMC_JOINT_CMD_MSG { double limit; }; -class EMC_JOINT_SET_FERROR:public EMC_JOINT_CMD_MSG { - public: - EMC_JOINT_SET_FERROR() - : EMC_JOINT_CMD_MSG(EMC_JOINT_SET_FERROR_TYPE, sizeof(EMC_JOINT_SET_FERROR)), - ferror(0.0) - {}; - - // For internal NML/CMS use only. - // Sub-class update() calls base-class update() - // cppcheck-suppress duplInheritedMember - void update(CMS * cms); - - double ferror; -}; - -class EMC_JOINT_SET_MIN_FERROR:public EMC_JOINT_CMD_MSG { - public: - EMC_JOINT_SET_MIN_FERROR() - : EMC_JOINT_CMD_MSG (EMC_JOINT_SET_MIN_FERROR_TYPE, sizeof(EMC_JOINT_SET_MIN_FERROR)), - ferror(0.0) - {}; - - // For internal NML/CMS use only. - // Sub-class update() calls base-class update() - // cppcheck-suppress duplInheritedMember - void update(CMS * cms); - - double ferror; -}; - -class EMC_JOINT_SET_HOMING_PARAMS:public EMC_JOINT_CMD_MSG { - public: - // False positive. Triggers on 'offset' - // cppcheck-suppress uninitMemberVar - EMC_JOINT_SET_HOMING_PARAMS() - : EMC_JOINT_CMD_MSG(EMC_JOINT_SET_HOMING_PARAMS_TYPE, sizeof(EMC_JOINT_SET_HOMING_PARAMS)), - home(0.0), - offset(0.0), - home_final_vel(0.0), - search_vel(0.0), - latch_vel(0.0), - search_dist(0.0), - latch_dist(0.0), - use_index(0), - encoder_does_not_reset(0), - ignore_limits(0), - is_shared(0), - home_sequence(0), - volatile_home(0), - locking_indexer(0), - absolute_encoder(0) - {}; - - // For internal NML/CMS use only. - // Sub-class update() calls base-class update() - // cppcheck-suppress duplInheritedMember - void update(CMS * cms); - - double home; - double offset; - double home_final_vel; - double search_vel; - double latch_vel; - double search_dist; - double latch_dist; - int use_index; - int encoder_does_not_reset; - int ignore_limits; - int is_shared; - int home_sequence; - int volatile_home; - int locking_indexer; - int absolute_encoder; -}; - -class EMC_JOINT_HALT:public EMC_JOINT_CMD_MSG { - public: - EMC_JOINT_HALT() - : EMC_JOINT_CMD_MSG(EMC_JOINT_HALT_TYPE, sizeof(EMC_JOINT_HALT)) - {}; - - // For internal NML/CMS use only. - // Sub-class update() calls base-class update() - // cppcheck-suppress duplInheritedMember - void update(CMS * cms); -}; - class EMC_JOINT_HOME:public EMC_JOINT_CMD_MSG { public: EMC_JOINT_HOME() @@ -391,25 +304,6 @@ class EMC_JOG_INCR:public EMC_JOG_CMD_MSG { int jjogmode; // 1==> joint jog, 0==> axis jog }; -class EMC_JOG_ABS:public EMC_JOG_CMD_MSG { - public: - EMC_JOG_ABS() - : EMC_JOG_CMD_MSG(EMC_JOG_ABS_TYPE, sizeof(EMC_JOG_ABS)), - pos(0.0), - vel(0.0), - jjogmode(0) - {}; - - // For internal NML/CMS use only. - // Sub-class update() calls base-class update() - // cppcheck-suppress duplInheritedMember - void update(CMS * cms); - - double pos; - double vel; - int jjogmode; // 1==> joint jog, 0==> axis jog -}; - class EMC_JOG_STOP:public EMC_JOG_CMD_MSG { public: EMC_JOG_STOP() @@ -539,38 +433,6 @@ class EMC_TRAJ_SET_MODE:public EMC_TRAJ_CMD_MSG { EMC_TRAJ_MODE mode; }; -class EMC_TRAJ_SET_VELOCITY:public EMC_TRAJ_CMD_MSG { - public: - EMC_TRAJ_SET_VELOCITY() - : EMC_TRAJ_CMD_MSG(EMC_TRAJ_SET_VELOCITY_TYPE, sizeof(EMC_TRAJ_SET_VELOCITY)), - velocity(0.0), - ini_maxvel(0.0) - {}; - - // For internal NML/CMS use only. - // Sub-class update() calls base-class update() - // cppcheck-suppress duplInheritedMember - void update(CMS * cms); - - double velocity; - double ini_maxvel; -}; - -class EMC_TRAJ_SET_ACCELERATION:public EMC_TRAJ_CMD_MSG { - public: - EMC_TRAJ_SET_ACCELERATION() - : EMC_TRAJ_CMD_MSG(EMC_TRAJ_SET_ACCELERATION_TYPE, sizeof(EMC_TRAJ_SET_ACCELERATION)), - acceleration(0.0) - {}; - - // For internal NML/CMS use only. - // Sub-class update() calls base-class update() - // cppcheck-suppress duplInheritedMember - void update(CMS * cms); - - double acceleration; -}; - class EMC_TRAJ_SET_MAX_VELOCITY:public EMC_TRAJ_CMD_MSG { public: EMC_TRAJ_SET_MAX_VELOCITY() diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 077bb88b99f..693c3c75257 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -390,17 +390,12 @@ int emcSystemCmd(char *s) } // shorthand typecasting ptrs -static EMC_JOINT_HALT *joint_halt_msg; static EMC_JOINT_HOME *home_msg; static EMC_JOINT_UNHOME *unhome_msg; static EMC_JOG_CONT *jog_cont_msg; static EMC_JOG_STOP *jog_stop_msg; static EMC_JOG_INCR *jog_incr_msg; -static EMC_JOG_ABS *jog_abs_msg; static EMC_JOINT_SET_BACKLASH *set_backlash_msg; -static EMC_JOINT_SET_HOMING_PARAMS *set_homing_params_msg; -static EMC_JOINT_SET_FERROR *set_ferror_msg; -static EMC_JOINT_SET_MIN_FERROR *set_min_ferror_msg; static EMC_JOINT_SET_MAX_POSITION_LIMIT *set_max_limit_msg; static EMC_JOINT_SET_MIN_POSITION_LIMIT *set_min_limit_msg; static EMC_JOINT_OVERRIDE_LIMITS *joint_lim_msg; @@ -412,8 +407,6 @@ static EMC_TRAJ_SET_SCALE *emcTrajSetScaleMsg; static EMC_TRAJ_SET_RAPID_SCALE *emcTrajSetRapidScaleMsg; static EMC_TRAJ_SET_MAX_VELOCITY *emcTrajSetMaxVelocityMsg; static EMC_TRAJ_SET_SPINDLE_SCALE *emcTrajSetSpindleScaleMsg; -static EMC_TRAJ_SET_VELOCITY *emcTrajSetVelocityMsg; -static EMC_TRAJ_SET_ACCELERATION *emcTrajSetAccelerationMsg; static EMC_TRAJ_LINEAR_MOVE *emcTrajLinearMoveMsg; static EMC_TRAJ_CIRCULAR_MOVE *emcTrajCircularMoveMsg; static EMC_TRAJ_DELAY *emcTrajDelayMsg; @@ -827,9 +820,6 @@ static bool isImmediate(NMLTYPE type) switch (type) { // in any state case EMC_JOINT_SET_BACKLASH_TYPE: - case EMC_JOINT_SET_HOMING_PARAMS_TYPE: - case EMC_JOINT_SET_FERROR_TYPE: - case EMC_JOINT_SET_MIN_FERROR_TYPE: case EMC_JOINT_UNHOME_TYPE: case EMC_TRAJ_SET_SCALE_TYPE: case EMC_TRAJ_SET_RAPID_SCALE_TYPE: @@ -852,8 +842,6 @@ static bool isImmediate(NMLTYPE type) // only while the machine is off or in E-stop case EMC_JOINT_LOAD_COMP_TYPE: - case EMC_TRAJ_SET_VELOCITY_TYPE: - case EMC_TRAJ_SET_ACCELERATION_TYPE: return !on; // once the machine is on, whatever runs @@ -906,7 +894,6 @@ static bool isImmediate(NMLTYPE type) // Manual only case EMC_JOINT_SET_MAX_POSITION_LIMIT_TYPE: case EMC_JOINT_SET_MIN_POSITION_LIMIT_TYPE: - case EMC_JOINT_HALT_TYPE: case EMC_JOINT_HOME_TYPE: case EMC_JOINT_OVERRIDE_LIMITS_TYPE: return manual; @@ -914,7 +901,6 @@ static bool isImmediate(NMLTYPE type) // jogs, and in Auto only while the interpreter is idle case EMC_JOG_CONT_TYPE: case EMC_JOG_INCR_TYPE: - case EMC_JOG_ABS_TYPE: case EMC_JOG_STOP_TYPE: return manual || mdi || autoIdle; case EMC_TRAJ_SET_TELEOP_ENABLE_TYPE: @@ -1320,8 +1306,6 @@ static EMC_TASK_EXEC emcTaskCheckPreconditions(NMLmsg * cmd) case EMC_TRAJ_LINEAR_MOVE_TYPE: case EMC_TRAJ_JOINT_MOVE_TYPE: case EMC_TRAJ_CIRCULAR_MOVE_TYPE: - case EMC_TRAJ_SET_VELOCITY_TYPE: - case EMC_TRAJ_SET_ACCELERATION_TYPE: case EMC_TRAJ_SET_TERM_COND_TYPE: case EMC_TRAJ_SET_SPINDLESYNC_TYPE: case EMC_TRAJ_SET_FO_ENABLE_TYPE: @@ -1554,14 +1538,6 @@ static int emcTaskIssueCommand(NMLmsg * cmd) jog_incr_msg->jjogmode); break; - case EMC_JOG_ABS_TYPE: - jog_abs_msg = reinterpret_cast(cmd); - retval = emcJogAbs(jog_abs_msg->joint_or_axis, - jog_abs_msg->pos, - jog_abs_msg->vel, - jog_abs_msg->jjogmode); - break; - case EMC_JOINT_SET_BACKLASH_TYPE: set_backlash_msg = reinterpret_cast(cmd); retval = @@ -1569,38 +1545,6 @@ static int emcTaskIssueCommand(NMLmsg * cmd) set_backlash_msg->backlash); break; - case EMC_JOINT_SET_HOMING_PARAMS_TYPE: - set_homing_params_msg = reinterpret_cast(cmd); - retval = emcJointSetHomingParams(set_homing_params_msg->joint, - set_homing_params_msg->home, - set_homing_params_msg->offset, - set_homing_params_msg->home_final_vel, - set_homing_params_msg->search_vel, - set_homing_params_msg->latch_vel, - set_homing_params_msg->search_dist, - set_homing_params_msg->latch_dist, - set_homing_params_msg->use_index, - set_homing_params_msg->encoder_does_not_reset, - set_homing_params_msg->ignore_limits, - set_homing_params_msg->is_shared, - set_homing_params_msg->home_sequence, - set_homing_params_msg->volatile_home, - set_homing_params_msg->locking_indexer, - set_homing_params_msg->absolute_encoder); - break; - - case EMC_JOINT_SET_FERROR_TYPE: - set_ferror_msg = reinterpret_cast(cmd); - retval = emcJointSetFerror(set_ferror_msg->joint, - set_ferror_msg->ferror); - break; - - case EMC_JOINT_SET_MIN_FERROR_TYPE: - set_min_ferror_msg = reinterpret_cast(cmd); - retval = emcJointSetMinFerror(set_min_ferror_msg->joint, - set_min_ferror_msg->ferror); - break; - case EMC_JOINT_SET_MAX_POSITION_LIMIT_TYPE: set_max_limit_msg = reinterpret_cast(cmd); retval = emcJointSetMaxPositionLimit(set_max_limit_msg->joint, @@ -1613,11 +1557,6 @@ static int emcTaskIssueCommand(NMLmsg * cmd) set_min_limit_msg->limit); break; - case EMC_JOINT_HALT_TYPE: - joint_halt_msg = reinterpret_cast(cmd); - retval = emcJointHalt(joint_halt_msg->joint); - break; - case EMC_JOINT_OVERRIDE_LIMITS_TYPE: joint_lim_msg = reinterpret_cast(cmd); retval = emcJointOverrideLimits(joint_lim_msg->joint); @@ -1665,17 +1604,6 @@ static int emcTaskIssueCommand(NMLmsg * cmd) retval = emcTrajSetSOEnable((reinterpret_cast(cmd))->mode); //spindle speed override enable/disable break; - case EMC_TRAJ_SET_VELOCITY_TYPE: - emcTrajSetVelocityMsg = reinterpret_cast(cmd); - retval = emcTrajSetVelocity(emcTrajSetVelocityMsg->velocity, - emcTrajSetVelocityMsg->ini_maxvel); - break; - - case EMC_TRAJ_SET_ACCELERATION_TYPE: - emcTrajSetAccelerationMsg = reinterpret_cast(cmd); - retval = emcTrajSetAcceleration(emcTrajSetAccelerationMsg->acceleration); - break; - case EMC_TRAJ_LINEAR_MOVE_TYPE: emcTrajUpdateTag((reinterpret_cast(cmd))->tag); emcTrajLinearMoveMsg = reinterpret_cast(cmd); @@ -2346,8 +2274,6 @@ static EMC_TASK_EXEC emcTaskCheckPostconditions(NMLmsg * cmd) case EMC_TRAJ_JOINT_MOVE_TYPE: case EMC_TRAJ_LINEAR_MOVE_TYPE: case EMC_TRAJ_CIRCULAR_MOVE_TYPE: - case EMC_TRAJ_SET_VELOCITY_TYPE: - case EMC_TRAJ_SET_ACCELERATION_TYPE: case EMC_TRAJ_SET_TERM_COND_TYPE: case EMC_TRAJ_SET_SPINDLESYNC_TYPE: case EMC_TRAJ_SET_OFFSET_TYPE: diff --git a/src/emc/task/taskintf.cc b/src/emc/task/taskintf.cc index c291547cf39..974305861be 100644 --- a/src/emc/task/taskintf.cc +++ b/src/emc/task/taskintf.cc @@ -877,34 +877,6 @@ int emcJogIncr(int nr, double incr, double vel, int jjogmode) return usrmotWriteEmcmotCommand(&emcmotCommand); } -int emcJogAbs(int nr, double pos, double vel, int jjogmode) -{ - if (jjogmode) { - if (nr < 0 || nr >= EMCMOT_MAX_JOINTS) { return 0; } - if (vel > JointConfig[nr].MaxVel) { - vel = JointConfig[nr].MaxVel; - } else if (vel < -JointConfig[nr].MaxVel) { - vel = -JointConfig[nr].MaxVel; - } - emcmotCommand.joint = nr; - emcmotCommand.axis = -1; //NA - } else { - if (nr < 0 || nr >= EMCMOT_MAX_AXIS) { return 0; } - if (vel > AxisConfig[nr].MaxVel) { - vel = AxisConfig[nr].MaxVel; - } else if (vel < -AxisConfig[nr].MaxVel) { - vel = -AxisConfig[nr].MaxVel; - } - emcmotCommand.joint = -1; //NA - emcmotCommand.axis = nr; - } - emcmotCommand.command = EMCMOT_JOG_ABS; - emcmotCommand.vel = vel; - emcmotCommand.offset = pos; - - return usrmotWriteEmcmotCommand(&emcmotCommand); -} - int emcJogStop(int nr, int jjogmode) { if (jjogmode) { diff --git a/src/emc/task/test_task_probe.cc b/src/emc/task/test_task_probe.cc index fa217cfdaa4..630e3d585df 100644 --- a/src/emc/task/test_task_probe.cc +++ b/src/emc/task/test_task_probe.cc @@ -99,13 +99,9 @@ static std::vector> commands() // joint configuration, for a joint that does not exist CMD("EMC_JOINT_SET_BACKLASH", EMC_JOINT_SET_BACKLASH, m->joint = NO_JOINT); - CMD("EMC_JOINT_SET_HOMING_PARAMS", EMC_JOINT_SET_HOMING_PARAMS, m->joint = NO_JOINT); - CMD("EMC_JOINT_SET_FERROR", EMC_JOINT_SET_FERROR, m->joint = NO_JOINT); - CMD("EMC_JOINT_SET_MIN_FERROR", EMC_JOINT_SET_MIN_FERROR, m->joint = NO_JOINT); CMD("EMC_JOINT_SET_MAX_POSITION_LIMIT", EMC_JOINT_SET_MAX_POSITION_LIMIT, m->joint = NO_JOINT); CMD("EMC_JOINT_SET_MIN_POSITION_LIMIT", EMC_JOINT_SET_MIN_POSITION_LIMIT, m->joint = NO_JOINT); CMD("EMC_JOINT_LOAD_COMP", EMC_JOINT_LOAD_COMP, m->joint = NO_JOINT); - CMD("EMC_JOINT_HALT", EMC_JOINT_HALT, m->joint = NO_JOINT); CMD("EMC_JOINT_HOME", EMC_JOINT_HOME, m->joint = NO_JOINT); CMD("EMC_JOINT_UNHOME", EMC_JOINT_UNHOME, m->joint = NO_JOINT); CMD("EMC_JOINT_OVERRIDE_LIMITS", EMC_JOINT_OVERRIDE_LIMITS, m->joint = NO_JOINT); @@ -113,7 +109,6 @@ static std::vector> commands() // jogs of a joint or axis that does not exist CMD("EMC_JOG_CONT", EMC_JOG_CONT, m->joint_or_axis = NO_JOINT; m->jjogmode = 1); CMD("EMC_JOG_INCR", EMC_JOG_INCR, m->joint_or_axis = NO_JOINT; m->jjogmode = 1); - CMD("EMC_JOG_ABS", EMC_JOG_ABS, m->joint_or_axis = NO_JOINT; m->jjogmode = 1); CMD("EMC_JOG_STOP", EMC_JOG_STOP, m->joint_or_axis = NO_JOINT; m->jjogmode = 1); // trajectory settings, set to what they are @@ -126,9 +121,6 @@ static std::vector> commands() CMD("EMC_TRAJ_SET_FH_ENABLE", EMC_TRAJ_SET_FH_ENABLE, m->mode = s.motion.traj.feed_hold_enabled); CMD("EMC_TRAJ_SET_SO_ENABLE", EMC_TRAJ_SET_SO_ENABLE, m->spindle = 0; m->mode = s.motion.spindle[0].spindle_override_enabled); - CMD("EMC_TRAJ_SET_VELOCITY", EMC_TRAJ_SET_VELOCITY, - m->velocity = s.motion.traj.velocity; m->ini_maxvel = s.motion.traj.maxVelocity); - CMD("EMC_TRAJ_SET_ACCELERATION", EMC_TRAJ_SET_ACCELERATION, m->acceleration = s.motion.traj.acceleration); CMD("EMC_TRAJ_SET_TELEOP_ENABLE", EMC_TRAJ_SET_TELEOP_ENABLE, m->enable = s.motion.traj.mode == EMC_TRAJ_MODE::TELEOP); CMD("EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG", EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG, ); diff --git a/tests/task-planner/expected b/tests/task-planner/expected index edd8a9b24b6..9059d09922f 100644 --- a/tests/task-planner/expected +++ b/tests/task-planner/expected @@ -1,19 +1,14 @@ [estop] EMC_NULL handled EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_HOMING_PARAMS issued -EMC_JOINT_SET_FERROR issued -EMC_JOINT_SET_MIN_FERROR issued EMC_JOINT_SET_MAX_POSITION_LIMIT refused EMC_JOINT_SET_MIN_POSITION_LIMIT refused EMC_JOINT_LOAD_COMP issued -EMC_JOINT_HALT refused EMC_JOINT_HOME refused EMC_JOINT_UNHOME issued EMC_JOINT_OVERRIDE_LIMITS issued EMC_JOG_CONT refused EMC_JOG_INCR refused -EMC_JOG_ABS refused EMC_JOG_STOP refused EMC_TRAJ_SET_SCALE issued EMC_TRAJ_SET_RAPID_SCALE issued @@ -22,8 +17,6 @@ EMC_TRAJ_SET_SPINDLE_SCALE issued EMC_TRAJ_SET_FO_ENABLE issued EMC_TRAJ_SET_FH_ENABLE issued EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_VELOCITY issued -EMC_TRAJ_SET_ACCELERATION issued EMC_TRAJ_SET_TELEOP_ENABLE issued EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued EMC_MOTION_SET_DOUT issued @@ -77,19 +70,14 @@ EMC_TASK_SET_STATE(ON) issued [off] EMC_NULL handled EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_HOMING_PARAMS issued -EMC_JOINT_SET_FERROR issued -EMC_JOINT_SET_MIN_FERROR issued EMC_JOINT_SET_MAX_POSITION_LIMIT refused EMC_JOINT_SET_MIN_POSITION_LIMIT refused EMC_JOINT_LOAD_COMP issued -EMC_JOINT_HALT refused EMC_JOINT_HOME refused EMC_JOINT_UNHOME issued EMC_JOINT_OVERRIDE_LIMITS handled EMC_JOG_CONT refused EMC_JOG_INCR refused -EMC_JOG_ABS refused EMC_JOG_STOP refused EMC_TRAJ_SET_SCALE issued EMC_TRAJ_SET_RAPID_SCALE issued @@ -98,8 +86,6 @@ EMC_TRAJ_SET_SPINDLE_SCALE issued EMC_TRAJ_SET_FO_ENABLE issued EMC_TRAJ_SET_FH_ENABLE issued EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_VELOCITY issued -EMC_TRAJ_SET_ACCELERATION issued EMC_TRAJ_SET_TELEOP_ENABLE issued -> OFF/MANUAL/IDLE/reading.ngc EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued EMC_MOTION_SET_DOUT issued @@ -153,19 +139,14 @@ EMC_TASK_SET_STATE(ON) issued -> ON/AUTO/IDLE/reading.ngc [manual] EMC_NULL handled EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_HOMING_PARAMS issued -EMC_JOINT_SET_FERROR issued -EMC_JOINT_SET_MIN_FERROR issued EMC_JOINT_SET_MAX_POSITION_LIMIT issued EMC_JOINT_SET_MIN_POSITION_LIMIT issued EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HALT issued EMC_JOINT_HOME issued EMC_JOINT_UNHOME issued EMC_JOINT_OVERRIDE_LIMITS issued EMC_JOG_CONT issued EMC_JOG_INCR issued -EMC_JOG_ABS issued EMC_JOG_STOP issued EMC_TRAJ_SET_SCALE issued EMC_TRAJ_SET_RAPID_SCALE issued @@ -174,8 +155,6 @@ EMC_TRAJ_SET_SPINDLE_SCALE issued EMC_TRAJ_SET_FO_ENABLE issued EMC_TRAJ_SET_FH_ENABLE issued EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_VELOCITY refused -EMC_TRAJ_SET_ACCELERATION refused EMC_TRAJ_SET_TELEOP_ENABLE issued EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued EMC_MOTION_SET_DOUT issued @@ -229,19 +208,14 @@ EMC_TASK_SET_STATE(ON) issued [mdi] EMC_NULL handled EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_HOMING_PARAMS issued -EMC_JOINT_SET_FERROR issued -EMC_JOINT_SET_MIN_FERROR issued EMC_JOINT_SET_MAX_POSITION_LIMIT refused EMC_JOINT_SET_MIN_POSITION_LIMIT refused EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HALT refused EMC_JOINT_HOME refused EMC_JOINT_UNHOME issued EMC_JOINT_OVERRIDE_LIMITS refused EMC_JOG_CONT issued EMC_JOG_INCR issued -EMC_JOG_ABS issued EMC_JOG_STOP issued EMC_TRAJ_SET_SCALE issued EMC_TRAJ_SET_RAPID_SCALE issued @@ -250,8 +224,6 @@ EMC_TRAJ_SET_SPINDLE_SCALE issued EMC_TRAJ_SET_FO_ENABLE issued EMC_TRAJ_SET_FH_ENABLE issued EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_VELOCITY refused -EMC_TRAJ_SET_ACCELERATION refused EMC_TRAJ_SET_TELEOP_ENABLE issued -> ON/MANUAL/IDLE/reading.ngc EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued EMC_MOTION_SET_DOUT issued @@ -305,19 +277,14 @@ EMC_TASK_SET_STATE(ON) issued [mdi-busy] EMC_NULL handled EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_HOMING_PARAMS issued -EMC_JOINT_SET_FERROR issued -EMC_JOINT_SET_MIN_FERROR issued EMC_JOINT_SET_MAX_POSITION_LIMIT refused EMC_JOINT_SET_MIN_POSITION_LIMIT refused EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HALT refused EMC_JOINT_HOME refused EMC_JOINT_UNHOME issued EMC_JOINT_OVERRIDE_LIMITS refused EMC_JOG_CONT issued EMC_JOG_INCR issued -EMC_JOG_ABS issued EMC_JOG_STOP issued EMC_TRAJ_SET_SCALE issued EMC_TRAJ_SET_RAPID_SCALE issued @@ -326,8 +293,6 @@ EMC_TRAJ_SET_SPINDLE_SCALE issued EMC_TRAJ_SET_FO_ENABLE issued EMC_TRAJ_SET_FH_ENABLE issued EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_VELOCITY refused -EMC_TRAJ_SET_ACCELERATION refused EMC_TRAJ_SET_TELEOP_ENABLE issued -> ON/MANUAL/READING/reading.ngc EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued EMC_MOTION_SET_DOUT issued @@ -381,19 +346,14 @@ EMC_TASK_SET_STATE(ON) issued [auto] EMC_NULL handled EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_HOMING_PARAMS issued -EMC_JOINT_SET_FERROR issued -EMC_JOINT_SET_MIN_FERROR issued EMC_JOINT_SET_MAX_POSITION_LIMIT refused EMC_JOINT_SET_MIN_POSITION_LIMIT refused EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HALT refused EMC_JOINT_HOME refused EMC_JOINT_UNHOME issued EMC_JOINT_OVERRIDE_LIMITS refused EMC_JOG_CONT issued EMC_JOG_INCR issued -EMC_JOG_ABS issued EMC_JOG_STOP issued EMC_TRAJ_SET_SCALE issued EMC_TRAJ_SET_RAPID_SCALE issued @@ -402,8 +362,6 @@ EMC_TRAJ_SET_SPINDLE_SCALE issued EMC_TRAJ_SET_FO_ENABLE issued EMC_TRAJ_SET_FH_ENABLE issued EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_VELOCITY refused -EMC_TRAJ_SET_ACCELERATION refused EMC_TRAJ_SET_TELEOP_ENABLE issued -> ON/MANUAL/IDLE/reading.ngc EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued EMC_MOTION_SET_DOUT refused @@ -457,19 +415,14 @@ EMC_TASK_SET_STATE(ON) issued [auto-reading] EMC_NULL handled EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_HOMING_PARAMS issued -EMC_JOINT_SET_FERROR issued -EMC_JOINT_SET_MIN_FERROR issued EMC_JOINT_SET_MAX_POSITION_LIMIT refused EMC_JOINT_SET_MIN_POSITION_LIMIT refused EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HALT refused EMC_JOINT_HOME refused EMC_JOINT_UNHOME issued EMC_JOINT_OVERRIDE_LIMITS refused EMC_JOG_CONT refused EMC_JOG_INCR refused -EMC_JOG_ABS refused EMC_JOG_STOP refused EMC_TRAJ_SET_SCALE issued EMC_TRAJ_SET_RAPID_SCALE issued @@ -478,8 +431,6 @@ EMC_TRAJ_SET_SPINDLE_SCALE issued EMC_TRAJ_SET_FO_ENABLE issued EMC_TRAJ_SET_FH_ENABLE issued EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_VELOCITY refused -EMC_TRAJ_SET_ACCELERATION refused EMC_TRAJ_SET_TELEOP_ENABLE refused EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued EMC_MOTION_SET_DOUT refused @@ -533,19 +484,14 @@ EMC_TASK_SET_STATE(ON) issued [auto-waiting] EMC_NULL handled EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_HOMING_PARAMS issued -EMC_JOINT_SET_FERROR issued -EMC_JOINT_SET_MIN_FERROR issued EMC_JOINT_SET_MAX_POSITION_LIMIT refused EMC_JOINT_SET_MIN_POSITION_LIMIT refused EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HALT refused EMC_JOINT_HOME refused EMC_JOINT_UNHOME issued EMC_JOINT_OVERRIDE_LIMITS refused EMC_JOG_CONT refused EMC_JOG_INCR refused -EMC_JOG_ABS refused EMC_JOG_STOP refused EMC_TRAJ_SET_SCALE issued EMC_TRAJ_SET_RAPID_SCALE issued @@ -554,8 +500,6 @@ EMC_TRAJ_SET_SPINDLE_SCALE issued EMC_TRAJ_SET_FO_ENABLE issued EMC_TRAJ_SET_FH_ENABLE issued EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_VELOCITY refused -EMC_TRAJ_SET_ACCELERATION refused EMC_TRAJ_SET_TELEOP_ENABLE refused EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued EMC_MOTION_SET_DOUT refused @@ -609,19 +553,14 @@ EMC_TASK_SET_STATE(ON) issued [auto-paused] EMC_NULL handled EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_HOMING_PARAMS issued -EMC_JOINT_SET_FERROR issued -EMC_JOINT_SET_MIN_FERROR issued EMC_JOINT_SET_MAX_POSITION_LIMIT refused EMC_JOINT_SET_MIN_POSITION_LIMIT refused EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HALT refused EMC_JOINT_HOME refused EMC_JOINT_UNHOME issued EMC_JOINT_OVERRIDE_LIMITS refused EMC_JOG_CONT refused EMC_JOG_INCR refused -EMC_JOG_ABS refused EMC_JOG_STOP refused EMC_TRAJ_SET_SCALE issued EMC_TRAJ_SET_RAPID_SCALE issued @@ -630,8 +569,6 @@ EMC_TRAJ_SET_SPINDLE_SCALE issued EMC_TRAJ_SET_FO_ENABLE issued EMC_TRAJ_SET_FH_ENABLE issued EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_VELOCITY refused -EMC_TRAJ_SET_ACCELERATION refused EMC_TRAJ_SET_TELEOP_ENABLE refused EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued EMC_MOTION_SET_DOUT refused From bd2ce468dc29358a39730b5c49118045259f6f9a Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 20:09:07 +0100 Subject: [PATCH 08/27] task: remove the MDI input queue nothing appends to, and what is left of checkInterpList() checkInterpList() lost its limit checks long ago and always returned 0; it now only shows the operator errors of the lines it drops. task read [TASK]MDI_QUEUED_COMMANDS and never used it. --- src/emc/task/emctaskmain.cc | 69 ++++++------------------------------- 1 file changed, 10 insertions(+), 59 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 693c3c75257..36da4501846 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -504,49 +504,16 @@ static int mdi_execute_wait = 0; // Side queue to store MDI commands static NML_INTERP_LIST mdi_execute_queue; -// MDI input queue -static NML_INTERP_LIST mdi_input_queue; -#define MAX_MDI_QUEUE 10 -static int max_mdi_queued_commands = MAX_MDI_QUEUE; - -/* - checkInterpList(NML_INTERP_LIST *il, EMC_STAT *stat) takes a pointer - to an interpreter list and a pointer to the EMC status, pops each NML - message off the list, and checks it against limits, resource availability, - etc. in the status. - - It returns 0 if all messages check out, -1 if any of them fail. If one - fails, the rest of the list is not checked. - */ -static int checkInterpList(NML_INTERP_LIST * il, EMC_STAT * /*stat*/) +// Empty the interpreter list of a line that is being skipped over, but +// still show the operator errors it holds. +static void checkInterpList(NML_INTERP_LIST * il) { while (il->len() > 0) { auto cmd = il->get(); - - switch (cmd->_type) { - - case EMC_OPERATOR_ERROR_TYPE: { - auto error_msg = static_cast(cmd.get()); - emcOperatorError("%s", error_msg->error); - break; - } - - //FIXME: there was limit checking tests below, see if they were needed - case EMC_TRAJ_LINEAR_MOVE_TYPE: - break; - - case EMC_TRAJ_JOINT_MOVE_TYPE: - break; - - case EMC_TRAJ_CIRCULAR_MOVE_TYPE: - break; - - default: - break; + if (cmd->_type == EMC_OPERATOR_ERROR_TYPE) { + emcOperatorError("%s", static_cast(cmd.get())->error); } } - - return 0; } extern int emcTaskMopup(); @@ -642,20 +609,9 @@ void readahead_reading(void) emcTaskPlanLevel() == 0 && ( programStartLine < 0 || emcTaskPlanLine() <= programStartLine )) { - // we're stepping over lines, so check them - // for - // limits, etc. and clear then out - if (0 != checkInterpList(&interp_list, - emcStatus)) { - // problem with actions, so do same as we - // did - // for a bad read from emcTaskPlanRead() - // above - emcStatus->task.interpState = - EMC_TASK_INTERP::WAITING; - } - // and clear it regardless - interp_list.clear(); + // we're stepping over lines, so drop what + // they queued + checkInterpList(&interp_list); } if (emcStatus->task.readLine < programStartLine && @@ -753,8 +709,8 @@ static void mdi_execute_hook(void) !mdi_execute_next) { // finished. Check for dequeuing of queued MDI command is done in emcTaskPlan(). - log_debug(EMC_DEBUG_TASK_ISSUE, "mdi_execute_hook: MDI command '{}' done (remaining: {})\n", - emcStatus->task.command, mdi_input_queue.len()); + log_debug(EMC_DEBUG_TASK_ISSUE, "mdi_execute_hook: MDI command '{}' done\n", + emcStatus->task.command); emcStatus->task.command[0] = 0; emcStatus->task.interpState = EMC_TASK_INTERP::IDLE; } @@ -3155,11 +3111,6 @@ static int iniLoad(const char *filename) io_error = strdup(inistring->c_str()); } - // max number of queued MDI commands - if (auto inival = inifile.findSInt("MDI_QUEUED_COMMANDS", "TASK")) { - max_mdi_queued_commands = *inival; - } - return 0; } From c9bb969a4aad658ab133cee2389d5aeedc12bc7f Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 20:11:14 +0100 Subject: [PATCH 09/27] task: the message pointers of emcTaskIssueCommand() are locals 42 file-level pointers each held the cast for one case. Those used once are folded into the call; the others are declared in their case. --- src/emc/task/emctaskmain.cc | 216 ++++++++++++++---------------------- 1 file changed, 85 insertions(+), 131 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 36da4501846..549a8fa2b1b 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -389,29 +389,6 @@ int emcSystemCmd(char *s) return 0; } -// shorthand typecasting ptrs -static EMC_JOINT_HOME *home_msg; -static EMC_JOINT_UNHOME *unhome_msg; -static EMC_JOG_CONT *jog_cont_msg; -static EMC_JOG_STOP *jog_stop_msg; -static EMC_JOG_INCR *jog_incr_msg; -static EMC_JOINT_SET_BACKLASH *set_backlash_msg; -static EMC_JOINT_SET_MAX_POSITION_LIMIT *set_max_limit_msg; -static EMC_JOINT_SET_MIN_POSITION_LIMIT *set_min_limit_msg; -static EMC_JOINT_OVERRIDE_LIMITS *joint_lim_msg; -//static EMC_JOINT_SET_OUTPUT *axis_output_msg; -static EMC_JOINT_LOAD_COMP *joint_load_comp_msg; -//static EMC_AXIS_SET_STEP_PARAMS *set_step_params_msg; - -static EMC_TRAJ_SET_SCALE *emcTrajSetScaleMsg; -static EMC_TRAJ_SET_RAPID_SCALE *emcTrajSetRapidScaleMsg; -static EMC_TRAJ_SET_MAX_VELOCITY *emcTrajSetMaxVelocityMsg; -static EMC_TRAJ_SET_SPINDLE_SCALE *emcTrajSetSpindleScaleMsg; -static EMC_TRAJ_LINEAR_MOVE *emcTrajLinearMoveMsg; -static EMC_TRAJ_CIRCULAR_MOVE *emcTrajCircularMoveMsg; -static EMC_TRAJ_DELAY *emcTrajDelayMsg; -static EMC_TRAJ_SET_TERM_COND *emcTrajSetTermCondMsg; -static EMC_TRAJ_SET_SPINDLESYNC *emcTrajSetSpindlesyncMsg; // These classes are commented out because the compiler // complains that they are "defined but not used". @@ -452,33 +429,10 @@ static EMC_TRAJ_MODE homingPriorMode = EMC_TRAJ_MODE::FREE; // mode to restore o // an immediate home keeps its original pass-through behaviour. static bool issuingQueuedCommand = false; -static EMC_SPINDLE_SPEED *spindle_speed_msg; -static EMC_SPINDLE_ORIENT *spindle_orient_msg; -static EMC_SPINDLE_WAIT_ORIENT_COMPLETE *wait_spindle_orient_complete_msg; -static EMC_SPINDLE_ON *spindle_on_msg; -static EMC_SPINDLE_OFF *spindle_off_msg; -static EMC_SPINDLE_BRAKE_ENGAGE *spindle_brake_engage_msg; -static EMC_SPINDLE_BRAKE_RELEASE *spindle_brake_release_msg; -static EMC_SPINDLE_INCREASE *spindle_increase_msg; -static EMC_SPINDLE_DECREASE *spindle_decrease_msg; -static EMC_SPINDLE_CONSTANT *spindle_constant_msg; -static EMC_TOOL_PREPARE *tool_prepare_msg; -static EMC_TOOL_LOAD_TOOL_TABLE *load_tool_table_msg; -static EMC_TOOL_SET_OFFSET *emc_tool_set_offset_msg; -static EMC_TOOL_SET_NUMBER *emc_tool_set_number_msg; -static EMC_TASK_SET_MODE *mode_msg; -static EMC_TASK_SET_STATE *state_msg; -static EMC_TASK_PLAN_RUN *run_msg; -static EMC_TASK_PLAN_EXECUTE *execute_msg; -static EMC_TASK_PLAN_OPEN *open_msg; -static EMC_TASK_PLAN_SET_OPTIONAL_STOP *os_msg; -static EMC_TASK_PLAN_SET_BLOCK_DELETE *bd_msg; - -static EMC_AUX_INPUT_WAIT *emcAuxInputWaitMsg; + static int emcAuxInputWaitType = 0; static int emcAuxInputWaitIndex = -1; -static EMC_TRAJ_SELECT_KINS *kSwitch_msg; // commands we compose here static EMC_TASK_PLAN_RUN taskPlanRunCmd; // 16-Aug-1999 FMP @@ -1419,10 +1373,9 @@ static int emcTaskIssueCommand(NMLmsg * cmd) // joint commands case EMC_JOINT_HOME_TYPE: - home_msg = reinterpret_cast(cmd); homingWaiting = false; // default; set true below only if we actually issue a home { - const int target_joint = home_msg->joint; + const int target_joint = reinterpret_cast(cmd)->joint; if (!issuingQueuedCommand) { // Immediate command (the GUI Home button, halui, linuxcncrsh): // pass it straight through, exactly as before this sequencing @@ -1469,84 +1422,87 @@ static int emcTaskIssueCommand(NMLmsg * cmd) // only arrive as an immediate command (the GUI, halui, linuxcncrsh), // never from the interpreter, so there is no queued path whose // trajectory mode would need dipping and restoring. - unhome_msg = reinterpret_cast(cmd); - retval = emcJointUnhome(unhome_msg->joint); + retval = emcJointUnhome(reinterpret_cast(cmd)->joint); break; - case EMC_JOG_CONT_TYPE: - jog_cont_msg = reinterpret_cast(cmd); + case EMC_JOG_CONT_TYPE: { + auto jog_cont_msg = reinterpret_cast(cmd); retval = emcJogCont(jog_cont_msg->joint_or_axis, jog_cont_msg->vel, jog_cont_msg->jjogmode); break; + } - case EMC_JOG_STOP_TYPE: - jog_stop_msg = reinterpret_cast(cmd); + case EMC_JOG_STOP_TYPE: { + auto jog_stop_msg = reinterpret_cast(cmd); retval = emcJogStop(jog_stop_msg->joint_or_axis, jog_stop_msg->jjogmode); break; + } - case EMC_JOG_INCR_TYPE: - jog_incr_msg = reinterpret_cast(cmd); + case EMC_JOG_INCR_TYPE: { + auto jog_incr_msg = reinterpret_cast(cmd); retval = emcJogIncr(jog_incr_msg->joint_or_axis, jog_incr_msg->incr, jog_incr_msg->vel, jog_incr_msg->jjogmode); break; + } - case EMC_JOINT_SET_BACKLASH_TYPE: - set_backlash_msg = reinterpret_cast(cmd); + case EMC_JOINT_SET_BACKLASH_TYPE: { + auto set_backlash_msg = reinterpret_cast(cmd); retval = emcJointSetBacklash(set_backlash_msg->joint, set_backlash_msg->backlash); break; + } - case EMC_JOINT_SET_MAX_POSITION_LIMIT_TYPE: - set_max_limit_msg = reinterpret_cast(cmd); + case EMC_JOINT_SET_MAX_POSITION_LIMIT_TYPE: { + auto set_max_limit_msg = reinterpret_cast(cmd); retval = emcJointSetMaxPositionLimit(set_max_limit_msg->joint, set_max_limit_msg->limit); break; + } - case EMC_JOINT_SET_MIN_POSITION_LIMIT_TYPE: - set_min_limit_msg = reinterpret_cast(cmd); + case EMC_JOINT_SET_MIN_POSITION_LIMIT_TYPE: { + auto set_min_limit_msg = reinterpret_cast(cmd); retval = emcJointSetMinPositionLimit(set_min_limit_msg->joint, set_min_limit_msg->limit); break; + } case EMC_JOINT_OVERRIDE_LIMITS_TYPE: - joint_lim_msg = reinterpret_cast(cmd); - retval = emcJointOverrideLimits(joint_lim_msg->joint); + retval = emcJointOverrideLimits(reinterpret_cast(cmd)->joint); break; - case EMC_JOINT_LOAD_COMP_TYPE: - joint_load_comp_msg = reinterpret_cast(cmd); + case EMC_JOINT_LOAD_COMP_TYPE: { + auto joint_load_comp_msg = reinterpret_cast(cmd); retval = emcJointLoadComp(joint_load_comp_msg->joint, joint_load_comp_msg->file, joint_load_comp_msg->type); break; + } // traj commands case EMC_TRAJ_SET_SCALE_TYPE: - emcTrajSetScaleMsg = reinterpret_cast(cmd); - retval = emcTrajSetScale(emcTrajSetScaleMsg->scale); + retval = emcTrajSetScale(reinterpret_cast(cmd)->scale); break; case EMC_TRAJ_SET_RAPID_SCALE_TYPE: - emcTrajSetRapidScaleMsg = reinterpret_cast(cmd); - retval = emcTrajSetRapidScale(emcTrajSetRapidScaleMsg->scale); + retval = emcTrajSetRapidScale(reinterpret_cast(cmd)->scale); break; case EMC_TRAJ_SET_MAX_VELOCITY_TYPE: - emcTrajSetMaxVelocityMsg = reinterpret_cast(cmd); - retval = emcTrajSetMaxVelocity(emcTrajSetMaxVelocityMsg->velocity); + retval = emcTrajSetMaxVelocity(reinterpret_cast(cmd)->velocity); break; - case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE: - emcTrajSetSpindleScaleMsg = reinterpret_cast(cmd); + case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE: { + auto emcTrajSetSpindleScaleMsg = reinterpret_cast(cmd); retval = emcTrajSetSpindleScale(emcTrajSetSpindleScaleMsg->spindle, emcTrajSetSpindleScaleMsg->scale); break; + } case EMC_TRAJ_SET_FO_ENABLE_TYPE: retval = emcTrajSetFOEnable((reinterpret_cast(cmd))->mode); // feed override enable/disable @@ -1560,15 +1516,16 @@ static int emcTaskIssueCommand(NMLmsg * cmd) retval = emcTrajSetSOEnable((reinterpret_cast(cmd))->mode); //spindle speed override enable/disable break; - case EMC_TRAJ_LINEAR_MOVE_TYPE: + case EMC_TRAJ_LINEAR_MOVE_TYPE: { emcTrajUpdateTag((reinterpret_cast(cmd))->tag); - emcTrajLinearMoveMsg = reinterpret_cast(cmd); + auto emcTrajLinearMoveMsg = reinterpret_cast(cmd); retval = emcTrajLinearMove(emcTrajLinearMoveMsg->end, emcTrajLinearMoveMsg->type, emcTrajLinearMoveMsg->vel, emcTrajLinearMoveMsg->ini_maxvel, emcTrajLinearMoveMsg->acc, emcTrajLinearMoveMsg->ini_maxjerk, emcTrajLinearMoveMsg->vlimit_scale, emcTrajLinearMoveMsg->indexer_jnum); break; + } case EMC_TRAJ_JOINT_MOVE_TYPE: { EMC_TRAJ_JOINT_MOVE *jm = reinterpret_cast(cmd); @@ -1577,9 +1534,9 @@ static int emcTaskIssueCommand(NMLmsg * cmd) break; } - case EMC_TRAJ_CIRCULAR_MOVE_TYPE: + case EMC_TRAJ_CIRCULAR_MOVE_TYPE: { emcTrajUpdateTag((reinterpret_cast(cmd))->tag); - emcTrajCircularMoveMsg = reinterpret_cast(cmd); + auto emcTrajCircularMoveMsg = reinterpret_cast(cmd); retval = emcTrajCircularMove(emcTrajCircularMoveMsg->end, emcTrajCircularMoveMsg->center, emcTrajCircularMoveMsg->normal, emcTrajCircularMoveMsg->turn, emcTrajCircularMoveMsg->type, @@ -1588,16 +1545,16 @@ static int emcTaskIssueCommand(NMLmsg * cmd) emcTrajCircularMoveMsg->acc, emcTrajCircularMoveMsg->ini_maxjerk, emcTrajCircularMoveMsg->vlimit_scale); break; + } case EMC_TRAJ_DELAY_TYPE: - emcTrajDelayMsg = reinterpret_cast(cmd); // set the timeout clock to expire at 'now' + delay time - taskExecDelayTimeout = etime() + emcTrajDelayMsg->delay; + taskExecDelayTimeout = etime() + reinterpret_cast(cmd)->delay; retval = 0; break; - case EMC_TRAJ_SET_TERM_COND_TYPE: - emcTrajSetTermCondMsg = reinterpret_cast(cmd); + case EMC_TRAJ_SET_TERM_COND_TYPE: { + auto emcTrajSetTermCondMsg = reinterpret_cast(cmd); retval = emcTrajSetTermCond(emcTrajSetTermCondMsg->cond, emcTrajSetTermCondMsg->tolerance); /* G64_R_PLANNER: a G64 R word piggybacks the planner request here so it * is applied in program order. Sentinels (<0) mean "leave unchanged". @@ -1621,11 +1578,13 @@ static int emcTaskIssueCommand(NMLmsg * cmd) if (retval == 0 && emcTrajSetTermCondMsg->scurve_peak_scale >= 0.0) emcTrajSetScurvePeakScale(emcTrajSetTermCondMsg->scurve_peak_scale); break; + } - case EMC_TRAJ_SET_SPINDLESYNC_TYPE: - emcTrajSetSpindlesyncMsg = reinterpret_cast(cmd); + case EMC_TRAJ_SET_SPINDLESYNC_TYPE: { + auto emcTrajSetSpindlesyncMsg = reinterpret_cast(cmd); retval = emcTrajSetSpindleSync(emcTrajSetSpindlesyncMsg->spindle, emcTrajSetSpindlesyncMsg->feed_per_revolution, emcTrajSetSpindlesyncMsg->velocity_mode, emcTrajSetSpindlesyncMsg->angular_offset_degrees); break; + } case EMC_TRAJ_SET_OFFSET_TYPE: { // update tool offset @@ -1677,8 +1636,8 @@ static int emcTaskIssueCommand(NMLmsg * cmd) (reinterpret_cast(cmd))->probe_type); break; - case EMC_AUX_INPUT_WAIT_TYPE: - emcAuxInputWaitMsg = reinterpret_cast(cmd); + case EMC_AUX_INPUT_WAIT_TYPE: { + auto emcAuxInputWaitMsg = reinterpret_cast(cmd); if (emcAuxInputWaitMsg->timeout == WAIT_MODE_IMMEDIATE) { //nothing to do, CANON will get the needed value when asked by the interp emcStatus->task.input_timeout = 0; // no timeout can occur emcAuxInputWaitIndex = -1; @@ -1691,10 +1650,10 @@ static int emcTaskIssueCommand(NMLmsg * cmd) taskExecDelayTimeout = etime() + emcAuxInputWaitMsg->timeout; } break; + } case EMC_SPINDLE_WAIT_ORIENT_COMPLETE_TYPE: - wait_spindle_orient_complete_msg = reinterpret_cast(cmd); - taskExecDelayTimeout = etime() + wait_spindle_orient_complete_msg->timeout; + taskExecDelayTimeout = etime() + reinterpret_cast(cmd)->timeout; break; case EMC_TRAJ_RIGID_TAP_TYPE: @@ -1746,52 +1705,51 @@ static int emcTaskIssueCommand(NMLmsg * cmd) // IO commands - case EMC_SPINDLE_SPEED_TYPE: - spindle_speed_msg = reinterpret_cast(cmd); + case EMC_SPINDLE_SPEED_TYPE: { + auto spindle_speed_msg = reinterpret_cast(cmd); retval = emcSpindleSpeed(spindle_speed_msg->spindle, spindle_speed_msg->speed, spindle_speed_msg->factor, spindle_speed_msg->xoffset); break; + } - case EMC_SPINDLE_ORIENT_TYPE: - spindle_orient_msg = reinterpret_cast(cmd); + case EMC_SPINDLE_ORIENT_TYPE: { + auto spindle_orient_msg = reinterpret_cast(cmd); retval = emcSpindleOrient(spindle_orient_msg->spindle, spindle_orient_msg->orientation, spindle_orient_msg->mode); break; + } - case EMC_SPINDLE_ON_TYPE: - spindle_on_msg = reinterpret_cast(cmd); + case EMC_SPINDLE_ON_TYPE: { + auto spindle_on_msg = reinterpret_cast(cmd); retval = emcSpindleOn(spindle_on_msg->spindle, spindle_on_msg->speed, spindle_on_msg->factor, spindle_on_msg->xoffset, spindle_on_msg->wait_for_spindle_at_speed); break; + } - case EMC_SPINDLE_OFF_TYPE: - spindle_off_msg = reinterpret_cast(cmd); + case EMC_SPINDLE_OFF_TYPE: { + auto spindle_off_msg = reinterpret_cast(cmd); retval = emcSpindleOff(spindle_off_msg->spindle, spindle_off_msg->wait_for_spindle_at_speed); break; + } case EMC_SPINDLE_BRAKE_RELEASE_TYPE: - spindle_brake_release_msg = reinterpret_cast(cmd); - retval = emcSpindleBrakeRelease(spindle_brake_release_msg->spindle); + retval = emcSpindleBrakeRelease(reinterpret_cast(cmd)->spindle); break; case EMC_SPINDLE_INCREASE_TYPE: - spindle_increase_msg = reinterpret_cast(cmd); - retval = emcSpindleIncrease(spindle_increase_msg->spindle); + retval = emcSpindleIncrease(reinterpret_cast(cmd)->spindle); break; case EMC_SPINDLE_DECREASE_TYPE: - spindle_decrease_msg = reinterpret_cast(cmd); - retval = emcSpindleDecrease(spindle_decrease_msg->spindle); + retval = emcSpindleDecrease(reinterpret_cast(cmd)->spindle); break; case EMC_SPINDLE_CONSTANT_TYPE: - spindle_constant_msg = reinterpret_cast(cmd); - retval = emcSpindleConstant(spindle_constant_msg->spindle); + retval = emcSpindleConstant(reinterpret_cast(cmd)->spindle); break; case EMC_SPINDLE_BRAKE_ENGAGE_TYPE: - spindle_brake_engage_msg = reinterpret_cast(cmd); - retval = emcSpindleBrakeEngage(spindle_brake_engage_msg->spindle); + retval = emcSpindleBrakeEngage(reinterpret_cast(cmd)->spindle); break; case EMC_COOLANT_MIST_ON_TYPE: @@ -1811,8 +1769,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) break; case EMC_TOOL_PREPARE_TYPE: - tool_prepare_msg = reinterpret_cast(cmd); - retval = emcToolPrepare(tool_prepare_msg->tool); + retval = emcToolPrepare(reinterpret_cast(cmd)->tool); break; case EMC_TOOL_LOAD_TYPE: @@ -1820,12 +1777,11 @@ static int emcTaskIssueCommand(NMLmsg * cmd) break; case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: - load_tool_table_msg = reinterpret_cast(cmd); - retval = emcToolLoadToolTable(load_tool_table_msg->file); + retval = emcToolLoadToolTable(reinterpret_cast(cmd)->file); break; - case EMC_TOOL_SET_OFFSET_TYPE: - emc_tool_set_offset_msg = reinterpret_cast(cmd); + case EMC_TOOL_SET_OFFSET_TYPE: { + auto emc_tool_set_offset_msg = reinterpret_cast(cmd); retval = emcToolSetOffset(emc_tool_set_offset_msg->pocket, emc_tool_set_offset_msg->toolno, emc_tool_set_offset_msg->offset, @@ -1834,10 +1790,10 @@ static int emcTaskIssueCommand(NMLmsg * cmd) emc_tool_set_offset_msg->backangle, emc_tool_set_offset_msg->orientation); break; + } case EMC_TOOL_SET_NUMBER_TYPE: - emc_tool_set_number_msg = reinterpret_cast(cmd); - retval = emcToolSetNumber(emc_tool_set_number_msg->tool); + retval = emcToolSetNumber(reinterpret_cast(cmd)->tool); break; // task commands @@ -1859,8 +1815,8 @@ static int emcTaskIssueCommand(NMLmsg * cmd) // mode and state commands - case EMC_TASK_SET_MODE_TYPE: - mode_msg = reinterpret_cast(cmd); + case EMC_TASK_SET_MODE_TYPE: { + auto mode_msg = reinterpret_cast(cmd); if (emcStatus->task.mode == EMC_TASK_MODE::AUTO && emcStatus->task.interpState != EMC_TASK_INTERP::IDLE && mode_msg->mode != EMC_TASK_MODE::AUTO) { @@ -1907,10 +1863,10 @@ static int emcTaskIssueCommand(NMLmsg * cmd) retval = emcTaskSetMode(mode_msg->mode); } break; + } case EMC_TASK_SET_STATE_TYPE: - state_msg = reinterpret_cast(cmd); - retval = emcTaskSetState(state_msg->state); + retval = emcTaskSetState(reinterpret_cast(cmd)->state); break; // interpreter commands @@ -1928,8 +1884,8 @@ static int emcTaskIssueCommand(NMLmsg * cmd) unlink(remote_tmpfilename); break; - case EMC_TASK_PLAN_OPEN_TYPE: - open_msg = reinterpret_cast(cmd); + case EMC_TASK_PLAN_OPEN_TYPE: { + auto open_msg = reinterpret_cast(cmd); /* receive file in chunks from remote process via open_msg->remote_buffer */ if(open_msg->remote_filesize > 0) { @@ -1990,12 +1946,13 @@ static int emcTaskIssueCommand(NMLmsg * cmd) retval = 0; } break; + } - case EMC_TASK_PLAN_EXECUTE_TYPE: + case EMC_TASK_PLAN_EXECUTE_TYPE: { emcStatus->motion.traj.single_stepping = 0; stepping = 0; steppingWait = 0; - execute_msg = reinterpret_cast(cmd); + auto execute_msg = reinterpret_cast(cmd); if (!all_homed() && !no_force_homing) { //!no_force_homing = force homing before MDI emcOperatorError(_("Can't issue MDI command when not homed")); retval = -1; @@ -2081,6 +2038,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) } } break; + } case EMC_TASK_PLAN_RUN_TYPE: if (!all_homed() && !no_force_homing) { //!no_force_homing = force homing before Auto @@ -2094,8 +2052,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) if (!taskplanopen && emcStatus->task.file[0] != 0) { emcTaskPlanOpen(emcStatus->task.file); } - run_msg = reinterpret_cast(cmd); - programStartLine = run_msg->line; + programStartLine = reinterpret_cast(cmd)->line; emcStatus->task.interpState = EMC_TASK_INTERP::READING; emcStatus->task.task_paused = 0; retval = 0; @@ -2162,20 +2119,17 @@ static int emcTaskIssueCommand(NMLmsg * cmd) break; case EMC_TASK_PLAN_SET_OPTIONAL_STOP_TYPE: - os_msg = reinterpret_cast(cmd); - emcTaskPlanSetOptionalStop(os_msg->state); + emcTaskPlanSetOptionalStop(reinterpret_cast(cmd)->state); retval = 0; break; case EMC_TASK_PLAN_SET_BLOCK_DELETE_TYPE: - bd_msg = reinterpret_cast(cmd); - emcTaskPlanSetBlockDelete(bd_msg->state); + emcTaskPlanSetBlockDelete(reinterpret_cast(cmd)->state); retval = 0; break; case EMC_TRAJ_SELECT_KINS_TYPE: - kSwitch_msg = static_cast(cmd); - retval = emcSelectKinsType(kSwitch_msg->switchkins_type); + retval = emcSelectKinsType(reinterpret_cast(cmd)->switchkins_type); break; default: From 83495324346d5da6cd129b833e3b3410cd3b0789 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 20:12:52 +0100 Subject: [PATCH 10/27] task: one table for what a queued command waits for, before and after emcTaskCheckPreconditions() and emcTaskCheckPostconditions() become commandWaits(), and the STEPPING_CHECK macro becomes steppingHolds(). The table says what the two switches said, command for command. --- src/emc/task/emctaskmain.cc | 358 +++++++++++------------------------- 1 file changed, 111 insertions(+), 247 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 549a8fa2b1b..e57073b52cb 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -422,7 +422,7 @@ static EMC_TRAJ_MODE homingPriorMode = EMC_TRAJ_MODE::FREE; // mode to restore o // interp_list. emcTaskIssueCommand() serves both that queued path and the // immediate commands emcTaskPlan() sends straight through (the GUI's Home // button, halui, linuxcncrsh), and only the queued path is followed by -// emcTaskCheckPostconditions() -- so only the queued path can ever reach +// the wait commandWaits() names -- so only the queued path can ever reach // EMC_TASK_EXEC::WAITING_FOR_HOMING to undo the FREE-mode dip and restore the // previous trajectory mode. Dipping on an immediate command would therefore // strand the machine in FREE for good. Gate the sequencing on this flag so @@ -1184,144 +1184,6 @@ static int emcTaskPlan(NMLmsg *cmd) return retval; } -/* - emcTaskCheckPreconditions() is called for commands on the interp_list. - Immediate commands, i.e., commands sent from calls to emcTaskIssueCommand() - in emcTaskPlan() directly, are not handled here. - - The return value is a state for emcTaskExecute() to wait on, e.g., - EMC_TASK_EXEC::WAITING_FOR_MOTION, before the command can be sent out. - */ -static EMC_TASK_EXEC emcTaskCheckPreconditions(NMLmsg * cmd) -{ - if (NULL == cmd) { - return EMC_TASK_EXEC::DONE; - } - - switch (cmd->_type) { - // operator messages, if queued, will go out when everything before - // them is done - case EMC_OPERATOR_ERROR_TYPE: - case EMC_OPERATOR_TEXT_TYPE: - case EMC_OPERATOR_DISPLAY_TYPE: - case EMC_SYSTEM_CMD_TYPE: - case EMC_TRAJ_PROBE_TYPE: // prevent blending of this - case EMC_TRAJ_RIGID_TAP_TYPE: //and this - case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: // and this - case EMC_AUX_INPUT_WAIT_TYPE: - case EMC_SPINDLE_WAIT_ORIENT_COMPLETE_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_MOTION_AND_IO; - break; - - case EMC_TRAJ_LINEAR_MOVE_TYPE: - case EMC_TRAJ_JOINT_MOVE_TYPE: - case EMC_TRAJ_CIRCULAR_MOVE_TYPE: - case EMC_TRAJ_SET_TERM_COND_TYPE: - case EMC_TRAJ_SET_SPINDLESYNC_TYPE: - case EMC_TRAJ_SET_FO_ENABLE_TYPE: - case EMC_TRAJ_SET_FH_ENABLE_TYPE: - case EMC_TRAJ_SET_SO_ENABLE_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_IO; - break; - - case EMC_TRAJ_SET_OFFSET_TYPE: - // this applies the tool length offset variable after previous - // motions - case EMC_TRAJ_SET_G5X_TYPE: - case EMC_TRAJ_SET_G92_TYPE: - case EMC_TRAJ_SET_ROTATION_TYPE: - case EMC_TRAJ_SET_G68_TYPE: - // this applies the program origin after previous motions - return EMC_TASK_EXEC::WAITING_FOR_MOTION; - break; - - case EMC_TOOL_LOAD_TYPE: - case EMC_COOLANT_MIST_ON_TYPE: - case EMC_COOLANT_MIST_OFF_TYPE: - case EMC_COOLANT_FLOOD_ON_TYPE: - case EMC_COOLANT_FLOOD_OFF_TYPE: - case EMC_SPINDLE_SPEED_TYPE: - case EMC_SPINDLE_ON_TYPE: - case EMC_SPINDLE_OFF_TYPE: - case EMC_SPINDLE_ORIENT_TYPE: // not sure - return EMC_TASK_EXEC::WAITING_FOR_MOTION_AND_IO; - break; - - case EMC_TOOL_PREPARE_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_IO; - break; - - case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: - case EMC_TOOL_SET_OFFSET_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_MOTION_AND_IO; - break; - - case EMC_TOOL_SET_NUMBER_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_IO; - break; - - case EMC_TASK_PLAN_PAUSE_TYPE: - case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: - /* pause on the interp list is queued, so wait until all are done */ - return EMC_TASK_EXEC::WAITING_FOR_MOTION_AND_IO; - break; - - case EMC_TASK_PLAN_END_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_MOTION_AND_IO; - break; - - case EMC_TASK_PLAN_INIT_TYPE: - case EMC_TASK_PLAN_RUN_TYPE: - case EMC_TASK_PLAN_SYNCH_TYPE: - case EMC_TASK_PLAN_EXECUTE_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_MOTION_AND_IO; - break; - - case EMC_TRAJ_DELAY_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_MOTION_AND_IO; - break; - - case EMC_MOTION_SET_AOUT_TYPE: - if ((reinterpret_cast(cmd))->now) { - return EMC_TASK_EXEC::WAITING_FOR_MOTION; - } - return EMC_TASK_EXEC::DONE; - break; - - case EMC_MOTION_SET_DOUT_TYPE: - if ((reinterpret_cast(cmd))->now) { - return EMC_TASK_EXEC::WAITING_FOR_MOTION; - } - return EMC_TASK_EXEC::DONE; - break; - - case EMC_MOTION_ADAPTIVE_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_MOTION; - break; - - case EMC_TRAJ_SELECT_KINS_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_MOTION_AND_IO; - break; - - case EMC_JOINT_HOME_TYPE: // G28.2: program-order homing - // drain prior motion before homing; without this case a queued home - // hit default -> EMC_TASK_EXEC::ERROR and was silently dropped - // (never reached motion). - return EMC_TASK_EXEC::WAITING_FOR_MOTION; - - default: - // unrecognized command - if (emc_debug & EMC_DEBUG_TASK_ISSUE) { - log_error("preconditions: unrecognized command {}:{}\n", - (int)cmd->_type, emc_symbol_lookup(cmd->_type)); - } - return EMC_TASK_EXEC::ERROR; - break; - } - - return EMC_TASK_EXEC::DONE; -} - // puts command on interp list int emcTaskQueueCommand(std::unique_ptr &&cmd) { @@ -1379,7 +1241,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) if (!issuingQueuedCommand) { // Immediate command (the GUI Home button, halui, linuxcncrsh): // pass it straight through, exactly as before this sequencing - // existed. Nothing calls emcTaskCheckPostconditions() for an + // existed. Nothing waits as commandWaits() says for an // immediate command, so a mode dip taken here would never be // undone. See issuingQueuedCommand. retval = emcJointHome(target_joint); @@ -2155,133 +2017,117 @@ static int emcTaskIssueCommand(NMLmsg * cmd) return retval; } -/* - emcTaskCheckPostconditions() is called for commands on the interp_list. - Immediate commands, i.e., commands sent from calls to emcTaskIssueCommand() - in emcTaskPlan() directly, are not handled here. - - The return value is a state for emcTaskExecute() to wait on, e.g., - EMC_TASK_EXEC::WAITING_FOR_MOTION, after the command has finished and - before any other commands can be sent out. - */ -static EMC_TASK_EXEC emcTaskCheckPostconditions(NMLmsg * cmd) +// What a command from interp_list waits for before it is issued, and what +// task waits for after it, before the next command goes out. Commands that +// emcTaskPlan() issues directly do not come through here. +struct Waits { + EMC_TASK_EXEC before; + EMC_TASK_EXEC after; +}; + +static Waits commandWaits(NMLmsg *cmd) { - if (NULL == cmd) { - return EMC_TASK_EXEC::DONE; - } + const EMC_TASK_EXEC DONE = EMC_TASK_EXEC::DONE; + const EMC_TASK_EXEC MOTION = EMC_TASK_EXEC::WAITING_FOR_MOTION; + const EMC_TASK_EXEC IO = EMC_TASK_EXEC::WAITING_FOR_IO; + const EMC_TASK_EXEC ALL = EMC_TASK_EXEC::WAITING_FOR_MOTION_AND_IO; switch (cmd->_type) { + // these go out when everything before them is done; nothing blends + // into a probe or a rigid tap case EMC_OPERATOR_ERROR_TYPE: case EMC_OPERATOR_TEXT_TYPE: case EMC_OPERATOR_DISPLAY_TYPE: - return EMC_TASK_EXEC::DONE; - break; - - case EMC_SYSTEM_CMD_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_SYSTEM_CMD; - break; - - case EMC_TRAJ_JOINT_MOVE_TYPE: - case EMC_TRAJ_LINEAR_MOVE_TYPE: - case EMC_TRAJ_CIRCULAR_MOVE_TYPE: - case EMC_TRAJ_SET_TERM_COND_TYPE: - case EMC_TRAJ_SET_SPINDLESYNC_TYPE: - case EMC_TRAJ_SET_OFFSET_TYPE: - case EMC_TRAJ_SET_G5X_TYPE: - case EMC_TRAJ_SET_G92_TYPE: - case EMC_TRAJ_SET_ROTATION_TYPE: - case EMC_TRAJ_SET_G68_TYPE: case EMC_TRAJ_PROBE_TYPE: case EMC_TRAJ_RIGID_TAP_TYPE: case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: - case EMC_TRAJ_SET_TELEOP_ENABLE_TYPE: - case EMC_TRAJ_SET_FO_ENABLE_TYPE: - case EMC_TRAJ_SET_FH_ENABLE_TYPE: - case EMC_TRAJ_SET_SO_ENABLE_TYPE: - return EMC_TASK_EXEC::DONE; - break; - - case EMC_TOOL_PREPARE_TYPE: case EMC_TOOL_LOAD_TYPE: case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: case EMC_TOOL_SET_OFFSET_TYPE: - case EMC_TOOL_SET_NUMBER_TYPE: + case EMC_COOLANT_MIST_ON_TYPE: + case EMC_COOLANT_MIST_OFF_TYPE: + case EMC_COOLANT_FLOOD_ON_TYPE: + case EMC_COOLANT_FLOOD_OFF_TYPE: case EMC_SPINDLE_SPEED_TYPE: case EMC_SPINDLE_ON_TYPE: case EMC_SPINDLE_OFF_TYPE: case EMC_SPINDLE_ORIENT_TYPE: - case EMC_COOLANT_MIST_ON_TYPE: - case EMC_COOLANT_MIST_OFF_TYPE: - case EMC_COOLANT_FLOOD_ON_TYPE: - case EMC_COOLANT_FLOOD_OFF_TYPE: - return EMC_TASK_EXEC::DONE; - break; - - case EMC_TASK_PLAN_RUN_TYPE: case EMC_TASK_PLAN_PAUSE_TYPE: + case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: case EMC_TASK_PLAN_END_TYPE: case EMC_TASK_PLAN_INIT_TYPE: + case EMC_TASK_PLAN_RUN_TYPE: case EMC_TASK_PLAN_SYNCH_TYPE: case EMC_TASK_PLAN_EXECUTE_TYPE: - case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: - return EMC_TASK_EXEC::DONE; - break; - - case EMC_SPINDLE_WAIT_ORIENT_COMPLETE_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_SPINDLE_ORIENTED; - break; + return {ALL, DONE}; - case EMC_JOINT_HOME_TYPE: - // homingWaiting is false when the command was passed straight through - // as an immediate command (see issuingQueuedCommand) -- the sequencing - // did not run, so there is nothing to wait for. - return homingWaiting ? EMC_TASK_EXEC::WAITING_FOR_HOMING : EMC_TASK_EXEC::DONE; - break; + case EMC_SYSTEM_CMD_TYPE: + return {ALL, EMC_TASK_EXEC::WAITING_FOR_SYSTEM_CMD}; case EMC_TRAJ_DELAY_TYPE: case EMC_AUX_INPUT_WAIT_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_DELAY; - break; + return {ALL, EMC_TASK_EXEC::WAITING_FOR_DELAY}; + + case EMC_SPINDLE_WAIT_ORIENT_COMPLETE_TYPE: + return {ALL, EMC_TASK_EXEC::WAITING_FOR_SPINDLE_ORIENTED}; + + case EMC_TRAJ_SELECT_KINS_TYPE: + return {ALL, EMC_TASK_EXEC::WAITING_FOR_KINS_SWITCH}; + + // moves, and what travels with them, queue up in motion + case EMC_TRAJ_LINEAR_MOVE_TYPE: + case EMC_TRAJ_JOINT_MOVE_TYPE: + case EMC_TRAJ_CIRCULAR_MOVE_TYPE: + case EMC_TRAJ_SET_TERM_COND_TYPE: + case EMC_TRAJ_SET_SPINDLESYNC_TYPE: + case EMC_TRAJ_SET_FO_ENABLE_TYPE: + case EMC_TRAJ_SET_FH_ENABLE_TYPE: + case EMC_TRAJ_SET_SO_ENABLE_TYPE: + case EMC_TOOL_PREPARE_TYPE: + case EMC_TOOL_SET_NUMBER_TYPE: + return {IO, DONE}; + // offsets apply after the motions before them + case EMC_TRAJ_SET_OFFSET_TYPE: + case EMC_TRAJ_SET_G5X_TYPE: + case EMC_TRAJ_SET_G92_TYPE: + case EMC_TRAJ_SET_ROTATION_TYPE: + case EMC_TRAJ_SET_G68_TYPE: + case EMC_MOTION_ADAPTIVE_TYPE: + return {MOTION, DONE}; + + // an output that is not set "now" is queued in motion with the moves case EMC_MOTION_SET_AOUT_TYPE: + return {static_cast(cmd)->now ? MOTION : DONE, DONE}; case EMC_MOTION_SET_DOUT_TYPE: - case EMC_MOTION_ADAPTIVE_TYPE: - return EMC_TASK_EXEC::DONE; - break; + return {static_cast(cmd)->now ? MOTION : DONE, DONE}; - case EMC_TRAJ_SELECT_KINS_TYPE: - return EMC_TASK_EXEC::WAITING_FOR_KINS_SWITCH; - break; + // G28.2: drain the motion before it, then wait for the homing. + // homingWaiting is set when it is issued, see issuingQueuedCommand. + case EMC_JOINT_HOME_TYPE: + return {MOTION, homingWaiting ? EMC_TASK_EXEC::WAITING_FOR_HOMING : DONE}; + } - default: - // unrecognized command - if (emc_debug & EMC_DEBUG_TASK_ISSUE) { - log_error("postconditions: unrecognized command {}:{}\n", - (int)cmd->_type, emc_symbol_lookup(cmd->_type)); - } - return EMC_TASK_EXEC::DONE; - break; + if (emc_debug & EMC_DEBUG_TASK_ISSUE) { + log_error("execute: unrecognized command {}:{}\n", + (int)cmd->_type, emc_symbol_lookup(cmd->_type)); } - return EMC_TASK_EXEC::DONE; // unreached + return {EMC_TASK_EXEC::ERROR, DONE}; } -/* - STEPPING_CHECK() is a macro that prefaces a switch-case with a check - for stepping. If stepping is active, it waits until the step has been - given, then falls through to the rest of the case statement. -*/ - -#define STEPPING_CHECK() \ -if (stepping) { \ - if (! steppingWait) { \ - steppingWait = 1; \ - steppedLine = emcStatus->task.currentLine; \ - } \ - else { \ - if (emcStatus->task.currentLine != steppedLine) { \ - break; \ - } \ - } \ +// While stepping, everything holds once the step has moved on to another +// line, until the next step is given. +static bool steppingHolds() +{ + if (!stepping) { + return false; + } + if (!steppingWait) { + steppingWait = 1; + steppedLine = emcStatus->task.currentLine; + return false; + } + return emcStatus->task.currentLine != steppedLine; } // executor function @@ -2346,7 +2192,9 @@ static int emcTaskExecute(void) break; case EMC_TASK_EXEC::DONE: - STEPPING_CHECK(); + if (steppingHolds()) { + break; + } if (!emcStatus->motion.traj.queueFull && emcStatus->task.interpState != EMC_TASK_INTERP::PAUSED) { if (NULL == emcTaskCommand) { @@ -2366,13 +2214,13 @@ static int emcTaskExecute(void) emcStatus->task.execState = EMC_TASK_EXEC::WAITING_FOR_MOTION_QUEUE; } else { - emcStatus->task.execState = emcTaskCheckPreconditions(emcTaskCommand.get()); + emcStatus->task.execState = commandWaits(emcTaskCommand.get()).before; } } } else { // have an outstanding command // This is the one emcTaskIssueCommand() call site followed by - // emcTaskCheckPostconditions(), i.e. the only one whose commands + // the wait commandWaits() names, i.e. the only one whose commands // can reach a WAITING_FOR_* state. See issuingQueuedCommand. issuingQueuedCommand = true; const int issue_retval = emcTaskIssueCommand(emcTaskCommand.get()); @@ -2381,7 +2229,7 @@ static int emcTaskExecute(void) emcStatus->task.execState = EMC_TASK_EXEC::ERROR; retval = -1; } else { - emcStatus->task.execState = emcTaskCheckPostconditions(emcTaskCommand.get()); + emcStatus->task.execState = commandWaits(emcTaskCommand.get()).after; emcTaskEager = 1; } emcTaskCommand = NULL; // reset it @@ -2390,10 +2238,12 @@ static int emcTaskExecute(void) break; case EMC_TASK_EXEC::WAITING_FOR_MOTION_QUEUE: - STEPPING_CHECK(); + if (steppingHolds()) { + break; + } if (!emcStatus->motion.traj.queueFull) { if (NULL != emcTaskCommand) { - emcStatus->task.execState = emcTaskCheckPreconditions(emcTaskCommand.get()); + emcStatus->task.execState = commandWaits(emcTaskCommand.get()).before; emcTaskEager = 1; } else { emcStatus->task.execState = EMC_TASK_EXEC::DONE; @@ -2403,7 +2253,9 @@ static int emcTaskExecute(void) break; case EMC_TASK_EXEC::WAITING_FOR_MOTION: - STEPPING_CHECK(); + if (steppingHolds()) { + break; + } if (emcStatus->motion.status == RCS_STATUS::ERROR) { // emcOperatorError(0, "error in motion controller"); emcStatus->task.execState = EMC_TASK_EXEC::ERROR; @@ -2414,7 +2266,9 @@ static int emcTaskExecute(void) break; case EMC_TASK_EXEC::WAITING_FOR_IO: - STEPPING_CHECK(); + if (steppingHolds()) { + break; + } if (emcStatus->io.status == RCS_STATUS::ERROR) { // emcOperatorError(0, "error in IO controller"); emcStatus->task.execState = EMC_TASK_EXEC::ERROR; @@ -2425,7 +2279,9 @@ static int emcTaskExecute(void) break; case EMC_TASK_EXEC::WAITING_FOR_MOTION_AND_IO: - STEPPING_CHECK(); + if (steppingHolds()) { + break; + } if (emcStatus->motion.status == RCS_STATUS::ERROR) { // emcOperatorError(0, "error in motion controller"); emcStatus->task.execState = EMC_TASK_EXEC::ERROR; @@ -2440,7 +2296,9 @@ static int emcTaskExecute(void) break; case EMC_TASK_EXEC::WAITING_FOR_SPINDLE_ORIENTED: - STEPPING_CHECK(); // not sure + if (steppingHolds()) { // not sure + break; + } {int state = 0; for (int n = 0; n < emcStatus->motion.traj.spindles; n++){ if (emcStatus->motion.spindle[n].orient_state > state) @@ -2497,7 +2355,9 @@ static int emcTaskExecute(void) // advances while motion is in FREE, which is why we dipped into it // there), then restore the prior trajectory mode. See the // homingWaiting block of static state near the top of this file. - STEPPING_CHECK(); + if (steppingHolds()) { + break; + } { bool any_homing = false; bool all_target_homed = true; // success criterion @@ -2648,7 +2508,9 @@ static int emcTaskExecute(void) break; case EMC_TASK_EXEC::WAITING_FOR_DELAY: - STEPPING_CHECK(); + if (steppingHolds()) { + break; + } // check if delay has passed emcStatus->task.delayLeft = taskExecDelayTimeout - etime(); if (etime() >= taskExecDelayTimeout) { @@ -2706,7 +2568,9 @@ static int emcTaskExecute(void) break; case EMC_TASK_EXEC::WAITING_FOR_SYSTEM_CMD: - STEPPING_CHECK(); + if (steppingHolds()) { + break; + } // if we got here without a system command pending, say we're done if (0 == emcSystemCmdPid) { From 9d90fa02dce8bd9c14ee0efa57de3fddeb8657a6 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 20:15:38 +0100 Subject: [PATCH 11/27] task: the planner is one switch instead of seven nested ones emcTaskPlan() works out the situation once, then a command is handled by the planner itself (planSpecial()), passed straight through (isImmediate()) or refused (refuse()). The planner table is unchanged. --- src/emc/task/emctaskmain.cc | 509 +++++++++++++----------------------- 1 file changed, 184 insertions(+), 325 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index e57073b52cb..0403feadbab 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -709,6 +709,28 @@ void readahead_waiting(void) } } +// The situation the planner decides by: the machine off (or in E-stop), or +// on and in one of the modes, Auto split by what the interpreter does. +struct Situation { + bool on, manual, mdi, autoIdle, autoReading, autoPaused, autoWaiting; +}; + +static Situation situation() +{ + const EMC_TASK_STAT &task = emcStatus->task; + const bool on = task.state == EMC_TASK_STATE::ON; + const bool autoMode = on && task.mode == EMC_TASK_MODE::AUTO; + return { + on, + on && task.mode == EMC_TASK_MODE::MANUAL, + on && task.mode == EMC_TASK_MODE::MDI, + autoMode && task.interpState == EMC_TASK_INTERP::IDLE, + autoMode && task.interpState == EMC_TASK_INTERP::READING, + autoMode && task.interpState == EMC_TASK_INTERP::PAUSED, + autoMode && task.interpState == EMC_TASK_INTERP::WAITING, + }; +} + /* isImmediate() @@ -716,16 +738,10 @@ void readahead_waiting(void) the state, mode and interpreter state task is in. Everything else is handled, or refused, by the planner's table for that situation. */ -static bool isImmediate(NMLTYPE type) +static bool isImmediate(NMLTYPE type, const Situation &s) { - const EMC_TASK_STAT &task = emcStatus->task; - const bool on = task.state == EMC_TASK_STATE::ON; - const bool manual = on && task.mode == EMC_TASK_MODE::MANUAL; - const bool mdi = on && task.mode == EMC_TASK_MODE::MDI; - const bool autoMode = on && task.mode == EMC_TASK_MODE::AUTO; - const bool autoIdle = autoMode && task.interpState == EMC_TASK_INTERP::IDLE; - const bool autoPaused = autoMode && task.interpState == EMC_TASK_INTERP::PAUSED; - const bool autoWaiting = autoMode && task.interpState == EMC_TASK_INTERP::WAITING; + const bool on = s.on, manual = s.manual, mdi = s.mdi, autoIdle = s.autoIdle, + autoPaused = s.autoPaused, autoWaiting = s.autoWaiting; switch (type) { // in any state @@ -842,6 +858,134 @@ static void queueToolCommand(NMLmsg *cmd) emcTaskQueueTaskPlanSynchCmd(); } +// What the planner does itself with a command in this situation, instead +// of passing it through or refusing it. False if there is nothing special. +static bool planSpecial(NMLmsg *cmd, const Situation &s, int &retval) +{ + switch (cmd->_type) { + case EMC_JOINT_OVERRIDE_LIMITS_TYPE: + // with the machine off: in manual mode only, ignored otherwise + if (s.on) { + return false; + } + if (emcStatus->task.mode == EMC_TASK_MODE::MANUAL) { + retval = emcTaskIssueCommand(cmd); + } + return true; + + case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: + case EMC_TOOL_SET_OFFSET_TYPE: + case EMC_TOOL_SET_NUMBER_TYPE: + if (!s.on || s.manual + || ((s.autoIdle || s.mdi) && cmd->_type != EMC_TOOL_SET_NUMBER_TYPE)) { + queueToolCommand(cmd); + return true; + } + return false; + + case EMC_TASK_PLAN_EXECUTE_TYPE: + if (s.manual) { + // resynch the interpreter, since we may have moved + // externally + emcTaskQueueTaskPlanSynchCmd(); + // and now call for interpreter execute + retval = emcTaskIssueCommand(cmd); + return true; + } + if (s.mdi) { + // If there are no queued MDI commands, no commands in + // interp_list, and waitFlag isn't set, then this new + // incoming MDI command can just be issued directly. + // Otherwise we need to queue it and deal with it + // later. + if ((mdi_execute_queue.len() == 0) + && (interp_list.len() == 0) + && (emcTaskCommand == NULL) + && (emcTaskPlanIsWait() == 0)) { + retval = emcTaskIssueCommand(cmd); + } else { + auto queued = std::make_unique(); + rtapi_strlcpy(queued->command, static_cast(cmd)->command, sizeof(queued->command)); + mdi_execute_queue.append(std::move(queued)); + emcStatus->task.queuedMDIcommands = mdi_execute_queue.len(); + } + return true; + } + return false; + + case EMC_TASK_PLAN_RUN_TYPE: + if (!s.manual) { + return false; + } + if (GET_EXTERNAL_OFFSET_APPLIED()) { + // err here, fewer err reports + retval = -1; + } + return true; + + case EMC_TASK_PLAN_STEP_TYPE: + if (s.autoIdle) { + // handles case where first action is to step the program + taskPlanRunCmd.line = 0; // run from start + /*! \todo FIXME-- can have GUI set this; send a run instead of a + step */ + retval = emcTaskIssueCommand(&taskPlanRunCmd); + if (retval != 0) { + return true; + } + emcTrajPause(); + if (emcStatus->task.interpState != EMC_TASK_INTERP::PAUSED) { + interpResumeState = emcStatus->task.interpState; + } + emcStatus->task.interpState = EMC_TASK_INTERP::PAUSED; + emcStatus->task.task_paused = 1; + return true; + } + if (s.autoReading || s.autoWaiting) { + emcStatus->motion.traj.single_stepping = 1; + stepping = 1; // set stepping mode in case it's not + steppingWait = 0; // clear the wait + return true; + } + if (s.autoPaused) { + emcStatus->motion.traj.single_stepping = 1; + stepping = 1; + steppingWait = 0; + if (emcStatus->motion.traj.paused && + emcStatus->motion.traj.queue > 0) { + // there are pending motions paused; step them + emcTrajStep(); + } else { + emcStatus->task.interpState = interpResumeState; + } + emcStatus->task.task_paused = 1; + return true; + } + return false; + } + return false; +} + +static void refuse(NMLTYPE type, const Situation &s) +{ + const char *name = emc_symbol_lookup(type); + if (!s.on) { + emcOperatorError(_("command (%s) cannot be executed until the machine is out of E-stop and turned on"), name); + } else if (s.manual) { + emcOperatorError(_("can't do that (%s:%d) in manual mode"), name, (int) type); + } else if (s.mdi) { + emcOperatorError(_("can't do that (%s:%d) in MDI mode"), name, (int) type); + } else if (s.autoIdle) { + emcOperatorError(_("can't do that (%s) in auto mode with the interpreter idle"), name); + } else if (s.autoReading) { + emcOperatorError(_("can't do that (%s) in auto mode with the interpreter reading"), name); + } else if (s.autoPaused) { + emcOperatorError(_("can't do that (%s) in auto mode with the interpreter paused"), name); + } else if (s.autoWaiting) { + emcOperatorError(_("can't do that (%s) in auto mode with the interpreter waiting"), name); + } +} + /* emcTaskPlan() @@ -850,336 +994,51 @@ static void queueToolCommand(NMLmsg *cmd) cmd is the new command to handle this cycle, or NULL if there is none. It is only used for the duration of the call. - Each state has a table: no command, the commands passed straight through - (isImmediate()), then what is special to that state, and a refusal for - everything else. + A command is handled by the planner itself (planSpecial()), passed + straight through (isImmediate()), or refused. */ static int emcTaskPlan(NMLmsg *cmd) { - NMLTYPE type = cmd ? cmd->_type : 0; + const NMLTYPE type = cmd ? cmd->_type : 0; + const Situation s = situation(); int retval = 0; - // Always display messages switch (type) { + case 0: + case EMC_NULL_TYPE: + // no command + break; + + // Always display messages case EMC_OPERATOR_ERROR_TYPE: case EMC_OPERATOR_TEXT_TYPE: case EMC_OPERATOR_DISPLAY_TYPE: - retval = emcTaskIssueCommand(cmd); - return retval; - } - - // handle any new command - switch (emcStatus->task.state) { - case EMC_TASK_STATE::OFF: - case EMC_TASK_STATE::ESTOP: - case EMC_TASK_STATE::ESTOP_RESET: - - // now switch on the mode - switch (emcStatus->task.mode) { - case EMC_TASK_MODE::MANUAL: - case EMC_TASK_MODE::AUTO: - case EMC_TASK_MODE::MDI: - - // now switch on the command - switch (type) { - case 0: - case EMC_NULL_TYPE: - // no command - break; - - // one case where we need to be in manual mode - case EMC_JOINT_OVERRIDE_LIMITS_TYPE: - retval = 0; - if (emcStatus->task.mode == EMC_TASK_MODE::MANUAL) { - retval = emcTaskIssueCommand(cmd); - } - break; - - case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: - case EMC_TOOL_SET_OFFSET_TYPE: - case EMC_TOOL_SET_NUMBER_TYPE: - queueToolCommand(cmd); - break; + return emcTaskIssueCommand(cmd); - default: - if (isImmediate(type)) { - retval = emcTaskIssueCommand(cmd); - break; - } - emcOperatorError(_("command (%s) cannot be executed until the machine is out of E-stop and turned on"), emc_symbol_lookup(type)); - retval = -1; - break; - - } // switch (type) - - default: - // invalid mode + default: + if (planSpecial(cmd, s, retval)) { break; - - } // switch (mode) - - break; // case EMC_TASK_STATE::OFF,ESTOP,ESTOP_RESET - - case EMC_TASK_STATE::ON: - /* we can do everything (almost) when the machine is on, so let's - switch on the execution mode */ - switch (emcStatus->task.mode) { - case EMC_TASK_MODE::MANUAL: // ON, MANUAL - switch (type) { - case 0: - case EMC_NULL_TYPE: - // no command - break; - - // queued commands - - case EMC_TASK_PLAN_EXECUTE_TYPE: - // resynch the interpreter, since we may have moved - // externally - emcTaskQueueTaskPlanSynchCmd(); - // and now call for interpreter execute - retval = emcTaskIssueCommand(cmd); - break; - - case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: - case EMC_TOOL_SET_OFFSET_TYPE: - case EMC_TOOL_SET_NUMBER_TYPE: - queueToolCommand(cmd); - break; - - case EMC_TASK_PLAN_RUN_TYPE: - if (GET_EXTERNAL_OFFSET_APPLIED()) { - // err here, fewer err reports - retval = -1; - } - break; - - // otherwise we can't handle it - default: - if (isImmediate(type)) { - retval = emcTaskIssueCommand(cmd); - break; - } - emcOperatorError(_("can't do that (%s:%d) in manual mode"), emc_symbol_lookup(type),(int) type); - retval = -1; - break; - - } // switch (type) in ON, MANUAL - - break; // case EMC_TASK_MODE::MANUAL - - case EMC_TASK_MODE::AUTO: // ON, AUTO - switch (emcStatus->task.interpState) { - case EMC_TASK_INTERP::IDLE: // ON, AUTO, IDLE - switch (type) { - case 0: - case EMC_NULL_TYPE: - // no command - break; - - case EMC_TASK_PLAN_STEP_TYPE: - // handles case where first action is to step the program - taskPlanRunCmd.line = 0; // run from start - /*! \todo FIXME-- can have GUI set this; send a run instead of a - step */ - retval = emcTaskIssueCommand(&taskPlanRunCmd); - if(retval != 0) break; - emcTrajPause(); - if (emcStatus->task.interpState != EMC_TASK_INTERP::PAUSED) { - interpResumeState = emcStatus->task.interpState; - } - emcStatus->task.interpState = EMC_TASK_INTERP::PAUSED; - emcStatus->task.task_paused = 1; - retval = 0; - break; - - case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: - case EMC_TOOL_SET_OFFSET_TYPE: - queueToolCommand(cmd); - break; - - // otherwise we can't handle it - default: - if (isImmediate(type)) { - retval = emcTaskIssueCommand(cmd); - break; - } - emcOperatorError(_("can't do that (%s) in auto mode with the interpreter idle"), emc_symbol_lookup(type)); - retval = -1; - break; - - } // switch (type) in ON, AUTO, IDLE - - break; // EMC_TASK_INTERP::IDLE - - case EMC_TASK_INTERP::READING: // ON, AUTO, READING - switch (type) { - case 0: - case EMC_NULL_TYPE: - // no command - break; - - case EMC_TASK_PLAN_STEP_TYPE: - emcStatus->motion.traj.single_stepping = 1; - stepping = 1; // set stepping mode in case it's not - steppingWait = 0; // clear the wait - break; - - // otherwise we can't handle it - default: - if (isImmediate(type)) { - // no readahead this cycle - return emcTaskIssueCommand(cmd); - } - emcOperatorError(_("can't do that (%s) in auto mode with the interpreter reading"), emc_symbol_lookup(type)); - retval = -1; - break; - - } // switch (type) in ON, AUTO, READING - - // handle interp readahead logic - readahead_reading(); - - break; // EMC_TASK_INTERP::READING - - case EMC_TASK_INTERP::PAUSED: // ON, AUTO, PAUSED - switch (type) { - case 0: - case EMC_NULL_TYPE: - // no command - break; - - case EMC_TASK_PLAN_STEP_TYPE: - emcStatus->motion.traj.single_stepping = 1; - stepping = 1; - steppingWait = 0; - if (emcStatus->motion.traj.paused && - emcStatus->motion.traj.queue > 0) { - // there are pending motions paused; step them - emcTrajStep(); - } else { - emcStatus->task.interpState = interpResumeState; - } - emcStatus->task.task_paused = 1; - break; - - // otherwise we can't handle it - default: - if (isImmediate(type)) { - retval = emcTaskIssueCommand(cmd); - break; - } - emcOperatorError(_("can't do that (%s) in auto mode with the interpreter paused"), emc_symbol_lookup(type)); - retval = -1; - break; - - } // switch (type) in ON, AUTO, PAUSED - - break; // EMC_TASK_INTERP::PAUSED - - case EMC_TASK_INTERP::WAITING: - // interpreter ran to end - // handle input commands - switch (type) { - case 0: - case EMC_NULL_TYPE: - // no command - break; - - case EMC_TASK_PLAN_STEP_TYPE: - emcStatus->motion.traj.single_stepping = 1; - stepping = 1; // set stepping mode in case it's not - steppingWait = 0; // clear the wait - break; - - // otherwise we can't handle it - default: - if (isImmediate(type)) { - retval = emcTaskIssueCommand(cmd); - break; - } - emcOperatorError(_("can't do that (%s) in auto mode with the interpreter waiting"), emc_symbol_lookup(type)); - retval = -1; - break; - - } // switch (type) in ON, AUTO, WAITING - - // handle interp readahead logic - readahead_waiting(); - - break; // end of case EMC_TASK_INTERP::WAITING - - default: - // coding error - log_error("invalid mode({})", (int)emcStatus->task.mode); - retval = -1; - break; - - } // switch (mode) in ON, AUTO - - break; // case EMC_TASK_MODE::AUTO - - case EMC_TASK_MODE::MDI: // ON, MDI - switch (type) { - case 0: - case EMC_NULL_TYPE: - // no command - break; - - case EMC_TASK_PLAN_EXECUTE_TYPE: - // If there are no queued MDI commands, no commands in - // interp_list, and waitFlag isn't set, then this new - // incoming MDI command can just be issued directly. - // Otherwise we need to queue it and deal with it - // later. - if ( - (mdi_execute_queue.len() == 0) - && (interp_list.len() == 0) - && (emcTaskCommand == NULL) - && (emcTaskPlanIsWait() == 0) - ) { - retval = emcTaskIssueCommand(cmd); - } else { - auto queued = std::make_unique(); - rtapi_strlcpy(queued->command, static_cast(cmd)->command, sizeof(queued->command)); - mdi_execute_queue.append(std::move(queued)); - emcStatus->task.queuedMDIcommands = mdi_execute_queue.len(); - retval = 0; - } - break; - - case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: - case EMC_TOOL_SET_OFFSET_TYPE: - queueToolCommand(cmd); - break; - - // otherwise we can't handle it - default: - if (isImmediate(type)) { - retval = emcTaskIssueCommand(cmd); - break; - } - emcOperatorError(_("can't do that (%s:%d) in MDI mode"), emc_symbol_lookup(type),(int) type); - - retval = -1; - break; - - } // switch (type) in ON, MDI - mdi_execute_hook(); - - break; // case EMC_TASK_MODE::MDI - - default: + } + if (isImmediate(type, s)) { + retval = emcTaskIssueCommand(cmd); + if (s.autoReading) { + // no readahead this cycle + return retval; + } break; - - } // switch (mode) - - break; // case EMC_TASK_STATE::ON - - default: + } + refuse(type, s); + retval = -1; break; + } - } // switch (task.state) + if (s.autoReading) { + readahead_reading(); + } else if (s.autoWaiting) { + readahead_waiting(); + } else if (s.mdi) { + mdi_execute_hook(); + } return retval; } From 75bc00a994e8075f56cf064d58e09605fad39279 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 20:43:09 +0100 Subject: [PATCH 12/27] motion: remove EMCMOT_JOG_ABS, which nothing sends any more With EMC_JOG_ABS and emcJogAbs() gone the handler had no caller. In teleop it was not absolute either: axis_jog_abs() added the target to the current position. --- docs/src/code/code-notes.adoc | 31 ------------ src/emc/motion-logger/motion-logger.c | 4 -- src/emc/motion/axis.c | 22 -------- src/emc/motion/axis.h | 1 - src/emc/motion/command.c | 72 --------------------------- src/emc/motion/motion.h | 1 - 6 files changed, 131 deletions(-) diff --git a/docs/src/code/code-notes.adoc b/docs/src/code/code-notes.adoc index e3b72e492a9..57ecf31bc04 100644 --- a/docs/src/code/code-notes.adoc +++ b/docs/src/code/code-notes.adoc @@ -638,37 +638,6 @@ planner accelerates at the joint accel limit at the beginning of the move, and will decelerate at the joint accel limit to stop at the target position. -=== JOG_ABS - -The JOG_ABS command initiates an absolute jog on a single joint. An -absolute jog is a simple move to a specific location, in joint -coordinates. Normally absolute jogs stop when they reach the desired -location, however they also stop when they hit a limit, or on an ABORT -command. - -==== Requirements - -The command handler will silently reject the JOG_ABS command if -machine is not in free mode, or if any joint is in motion -(GET_MOTION_INPOS_FLAG() == FALSE), or if motion is not enabled. It -will also silently ignore the command if the joint is already at or -beyond its limit and the commanded jog would make it worse. - -==== Results - -The free mode trajectory planner for the joint identified by -emcmotCommand\->axis is activated, the target position is set to -emcmotCommand\->offset, and the velocity limit is set to -emcmotCommand\->vel. The free mode trajectory planner will generate a -smooth trapezoidal move from the present position to the target -position. The planner can correctly handle changes in the target -position that happen while the move is in progress. If multiple JOG_ABS -commands are issued in quick succession, each new command changes the -target position and the machine goes to the final commanded position. -The free mode planner accelerates at the joint accel limit at the -beginning of the move, and will decelerate at the joint accel limit to -stop at the target position. - === SET_LINE The SET_LINE command adds a straight line to the trajectory planner diff --git a/src/emc/motion-logger/motion-logger.c b/src/emc/motion-logger/motion-logger.c index 28978ae80e8..86fe6c60b5c 100644 --- a/src/emc/motion-logger/motion-logger.c +++ b/src/emc/motion-logger/motion-logger.c @@ -449,10 +449,6 @@ int main(int argc, char* argv[]) { log_print("JOG_INCR\n"); break; - case EMCMOT_JOG_ABS: - log_print("JOG_ABS\n"); - break; - case EMCMOT_SET_LINE: log_print( "SET_LINE x=%.6g, y=%.6g, z=%.6g, a=%.6g, b=%.6g, c=%.6g, u=%.6g, v=%.6g, w=%.6g, id=%d, motion_type=%d, vel=%.6g, ini_maxvel=%.6g, acc=%.6g, turn=%d\n", diff --git a/src/emc/motion/axis.c b/src/emc/motion/axis.c index 4aa4a26ba13..b6674f826cd 100644 --- a/src/emc/motion/axis.c +++ b/src/emc/motion/axis.c @@ -363,28 +363,6 @@ void axis_jog_incr(int axis_num, double offset, double vel, long servo_period) axis->teleop_tp.enable = 1; } -void axis_jog_abs(int axis_num, double offset, double vel) -{ - emcmot_axis_t *axis = &axis_array[axis_num]; - double tmp1, min_lim, max_lim; - - axis->kb_ajog_active = 1; - if (axis->wheel_ajog_active) { return; } - if (vel > 0.0) { - tmp1 = axis->teleop_tp.pos_cmd + offset; - } else { - tmp1 = axis->teleop_tp.pos_cmd - offset; - } - axis_jog_limits(axis_num, &min_lim, &max_lim); - if (tmp1 > max_lim) { return; } - if (tmp1 < min_lim) { return; } - axis->teleop_tp.pos_cmd = tmp1; - axis->teleop_tp.max_vel = fabs(vel); - axis->teleop_tp.max_acc = axis->acc_limit; - axis->kb_ajog_active = 1; - axis->teleop_tp.enable = 1; -} - bool axis_jog_abort(int axis_num, bool immediate) { bool aborted = 0; diff --git a/src/emc/motion/axis.h b/src/emc/motion/axis.h index 5d61f0b13f0..f09299dbd5d 100644 --- a/src/emc/motion/axis.h +++ b/src/emc/motion/axis.h @@ -19,7 +19,6 @@ void axis_check_constraints(double pos[], int failing_axes[]); void axis_jog_cont(int axis_num, double vel, long servo_period); void axis_jog_incr(int axis_num, double offset, double vel, long servo_period); -void axis_jog_abs(int axis_num, double offset, double vel); bool axis_jog_abort_all(bool immediate); bool axis_jog_abort(int axis_num, bool immediate); bool axis_jog_is_active(void); diff --git a/src/emc/motion/command.c b/src/emc/motion/command.c index b669000e664..8afcf69a2f7 100644 --- a/src/emc/motion/command.c +++ b/src/emc/motion/command.c @@ -508,7 +508,6 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) // example: attempt to jog locking indexer axis letter if ( emcmotCommand->command == EMCMOT_JOG_CONT || emcmotCommand->command == EMCMOT_JOG_INCR - || emcmotCommand->command == EMCMOT_JOG_ABS ) { if (GET_MOTION_TELEOP_FLAG() && (emcmotCommand->axis < 0)) { emsg = "command.com teleop: unexpected negative axis_num"; @@ -549,9 +548,6 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) case EMCMOT_JOG_INCR: rtapi_print_msg(RTAPI_MSG_ERR,"JOG_INCR %s\n",emsg); break; - case EMCMOT_JOG_ABS: - rtapi_print_msg(RTAPI_MSG_ERR,"JOG_ABS %s\n",emsg); - break; default: break; } return; @@ -561,7 +557,6 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) joint = &joints[joint_num]; if ( ( emcmotCommand->command == EMCMOT_JOG_CONT || emcmotCommand->command == EMCMOT_JOG_INCR - || emcmotCommand->command == EMCMOT_JOG_ABS ) && !(GET_MOTION_TELEOP_FLAG()) && get_home_is_synchronized(joint_num) @@ -1026,73 +1021,6 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) } break; - case EMCMOT_JOG_ABS: - /* do an absolute jog */ - rtapi_print_msg(RTAPI_MSG_DBG, "JOG_ABS %d", joint_num); - if (joint == 0) { - break; - } - if (!GET_MOTION_ENABLE_FLAG()) { - reportError(_("Can't jog joint when not enabled.")); - SET_JOINT_ERROR_FLAG(joint, 1); - break; - } - // cannot jog if jog-inhibit is TRUE - if (hal_get_bool(emcmot_hal_data->jog_inhibit)){ - reportError(_("Cannot jog while jog-inhibit is active.")); - break; - } - if ( get_homing_is_active() ) { - reportError(_("Can't jog any joints while homing.")); - SET_JOINT_ERROR_FLAG(joint, 1); - break; - } - if (!GET_MOTION_TELEOP_FLAG()) { - // FREE JOG_ABS - if (joint->wheel_jjog_active) { - /* can't do two kinds of jog at once */ - break; - } - /* don't jog further onto limits */ - if (!joint_jog_ok(joint_num, emcmotCommand->vel)) { - SET_JOINT_ERROR_FLAG(joint, 1); - break; - } - /*! \todo FIXME-- use 'goal' instead */ - joint->free_tp.pos_cmd = emcmotCommand->offset; - /* don't jog past limits */ - refresh_jog_limits(joint,joint_num); - if (joint->free_tp.pos_cmd > joint->max_jog_limit) { - joint->free_tp.pos_cmd = joint->max_jog_limit; - } - if (joint->free_tp.pos_cmd < joint->min_jog_limit) { - joint->free_tp.pos_cmd = joint->min_jog_limit; - } - /* set velocity of jog */ - joint->free_tp.max_vel = fabs(emcmotCommand->vel); - /* use max joint accel */ - joint->free_tp.max_acc = joint->acc_limit; - /* lock out other jog sources */ - joint->kb_jjog_active = 1; - /* and let it go */ - joint->free_tp.enable = 1; - SET_JOINT_ERROR_FLAG(joint, 0); - /* clear joint homed flag(s) if we don't have forward kins. - Otherwise, a transition into coordinated mode will incorrectly - assume the homed position. Do all if they've all been moved - since homing, otherwise just do this one */ - clearHomes(joint_num); - } else { - // TELEOP JOG_ABS - axis_jog_abs(emcmotCommand->axis, emcmotCommand->offset, emcmotCommand->vel); - for (joint_num = 0; joint_num < ALL_JOINTS; joint_num++) { - joint = &joints[joint_num]; - if (joint != 0) { joint->free_tp.enable = 0; } - } - return; - } - break; - case EMCMOT_SET_TERM_COND: /* sets termination condition for motion emcmotInternal->coord_tp */ rtapi_print_msg(RTAPI_MSG_DBG, "SET_TERM_COND"); diff --git a/src/emc/motion/motion.h b/src/emc/motion/motion.h index 49cb1b00a94..36fb6c4fa30 100644 --- a/src/emc/motion/motion.h +++ b/src/emc/motion/motion.h @@ -153,7 +153,6 @@ extern "C" { EMCMOT_SET_PROBE_ERR_INHIBIT, EMCMOT_JOG_CONT, /* continuous jog */ EMCMOT_JOG_INCR, /* incremental jog */ - EMCMOT_JOG_ABS, /* absolute jog */ EMCMOT_JOG_ABORT, /* abort one joint num or axis num */ EMCMOT_JOINT_ACTIVATE, /* make joint active */ From 225fc36b4f492f601602b71d847159d8f9cb5c3f Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 23:13:12 +0100 Subject: [PATCH 13/27] tests: task-planner is skipped without test_task_probe test.sh exited 0 without the probe and checkresult then failed for lack of probes, in every package build. A skip file is what runtests has for this. The loop variable shellcheck flagged as unused (SC2034) is now _. --- tests/task-planner/skip | 3 +++ tests/task-planner/test.sh | 8 +------- 2 files changed, 4 insertions(+), 7 deletions(-) create mode 100755 tests/task-planner/skip diff --git a/tests/task-planner/skip b/tests/task-planner/skip new file mode 100755 index 00000000000..6d7f0bdb110 --- /dev/null +++ b/tests/task-planner/skip @@ -0,0 +1,3 @@ +#!/bin/sh +# The probe helper is built with the run-in-place tree only. +command -v test_task_probe > /dev/null diff --git a/tests/task-planner/test.sh b/tests/task-planner/test.sh index 841f459fdff..a5e5363414c 100755 --- a/tests/task-planner/test.sh +++ b/tests/task-planner/test.sh @@ -1,18 +1,12 @@ #!/bin/bash -# The probe helper is built with the run-in-place tree only. -if ! command -v test_task_probe > /dev/null; then - echo "test_task_probe not found, skipping (run-in-place builds only)" - exit 0 -fi - cp -f tool.tbl.original tool.tbl # A program long enough that the interpreter is still reading while the # test probes: tiny moves, far more of them than task reads ahead. { echo "G1 F1" - for i in $(seq 5000); do + for _ in $(seq 5000); do echo "X0.001" echo "X0" done From 45d132a01e50807beec7e2c742b40347e50781d6 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 17 Nov 2026 01:59:36 +0100 Subject: [PATCH 14/27] jog while paused, and return to the paused position on resume Axes can be jogged (keyboard, AXIS, halui, linuxcncrsh, wheel) while a program or MDI command is paused, M0/M1 included, once the pause has stopped the motion. Joints cannot. Motion keeps the paused program position and adds a per-axis pause offset on top of it, as the external offsets are added (axis_pause_*() in axis.c), within the soft limits. The queued moves and the interpreter are untouched. On resume or step, do_pause_resume() (control.c): - puts the spindles back as they were at the pause (state, direction, speed, CSS) and waits for them to be at speed; - returns the axes: the ones not in [TRAJ]PAUSE_RETURN_LAST (default Z) together in a straight line, then those, at the axis limits, and sets the offsets to exactly zero; - then resumes or steps. Task restores mist and flood. Pausing during the return stops it there. An abort keeps the machine where it was jogged to: the planner takes the offsets into its position. Reverse run is refused while jogged away. Status: pause_offset, pause_jog_ok and pause_returning in EMC_MOTION_STAT and Python. Task accepts axis jogs while paused (planSpecial()), halui and linuxcncrsh send them, AXIS enables its jog and spindle controls (not homing) and does not ask for Manual mode while paused. This is the work from #4700, for a task that still has modes: - the mode stays Auto or MDI during the pause; nothing switches it; - in coordinated mode without a pause (MDI mode, idle) a jog still does nothing and reports nothing; - the planner table changes in one cell: EMC_JOG_STOP is issued while Auto is paused; - no absolute jog, which this branch has removed. Tests: new tests/jog-while-paused; motion-logger expectations gain the SET_PAUSE_RETURN_LAST startup command. --- docs/src/config/ini-config.adoc | 3 + docs/src/config/python-interface.adoc | 14 + .../getting-started/updating-linuxcnc.adoc | 18 + share/axis/tcl/axis.tcl | 7 + src/emc/ini/initraj.cc | 19 ++ src/emc/motion-logger/motion-logger.c | 4 + src/emc/motion/axis.c | 307 +++++++++++++++++- src/emc/motion/axis.h | 17 +- src/emc/motion/command.c | 179 +++++++++- src/emc/motion/control.c | 92 +++++- src/emc/motion/mot_priv.h | 5 + src/emc/motion/motion.h | 16 + src/emc/nml_intf/emc.cc | 3 + src/emc/nml_intf/emc.hh | 1 + src/emc/nml_intf/emc_nml.hh | 3 + src/emc/nml_intf/emcops.cc | 3 + src/emc/task/emctaskmain.cc | 82 +++++ src/emc/task/taskintf.cc | 15 + src/emc/usr_intf/axis/extensions/emcmodule.cc | 7 + src/emc/usr_intf/axis/scripts/axis.py | 52 ++- src/emc/usr_intf/halui.cc | 6 +- src/emc/usr_intf/shcom.cc | 9 +- .../expected.motion-logger | 1 + tests/jog-while-paused/.gitignore | 2 + tests/jog-while-paused/checkresult | 2 + tests/jog-while-paused/m0.ngc | 5 + tests/jog-while-paused/program.ngc | 9 + tests/jog-while-paused/sim.hal | 16 + tests/jog-while-paused/test-ui.py | 244 ++++++++++++++ tests/jog-while-paused/test.ini | 82 +++++ tests/jog-while-paused/test.sh | 3 + tests/jog-while-paused/tool.tbl | 1 + .../basic/expected.builtin-startup.in | 1 + .../mountaindew/expected.motion-logger | 1 + .../expected.motion-logger.in | 1 + tests/task-planner/checkresult | 2 +- tests/task-planner/expected | 2 +- 37 files changed, 1195 insertions(+), 39 deletions(-) create mode 100644 tests/jog-while-paused/.gitignore create mode 100755 tests/jog-while-paused/checkresult create mode 100644 tests/jog-while-paused/m0.ngc create mode 100644 tests/jog-while-paused/program.ngc create mode 100644 tests/jog-while-paused/sim.hal create mode 100755 tests/jog-while-paused/test-ui.py create mode 100644 tests/jog-while-paused/test.ini create mode 100755 tests/jog-while-paused/test.sh create mode 100644 tests/jog-while-paused/tool.tbl diff --git a/docs/src/config/ini-config.adoc b/docs/src/config/ini-config.adoc index 37d63eaa701..17e65443ca0 100644 --- a/docs/src/config/ini-config.adoc +++ b/docs/src/config/ini-config.adoc @@ -958,6 +958,9 @@ Finally, no amount of tweaking will speed up a tool path with lots of small, tig * `MAX_LINEAR_VELOCITY = 5.0` - (((MAX VELOCITY))) The maximum velocity for any axis or coordinated move, in 'machine units' per second. The value shown equals 300 units per minute. * `MAX_LINEAR_ACCELERATION = 20.0` - (((MAX ACCELERATION))) The maximum acceleration for any axis or coordinated axis move, in 'machine units' per second per second. +* `PAUSE_RETURN_LAST = Z` - (((PAUSE RETURN LAST))) The axes that return last when a paused program or MDI command resumes after jogs while paused. + The other axes return to the paused position first, together in a straight line, then these, so by default the tool comes down onto the point last. + Empty: all axes return in one straight line. The return runs at the axis velocity and acceleration limits. * `PLANNER_TYPE = 0` - (((PLANNER TYPE))) Selects the trajectory planner type: 0 = trapezoidal (default), 1 = S-curve with jerk limiting. S-curve planning is only active when `PLANNER_TYPE = 1` AND `MAX_LINEAR_JERK` is 1.0 or above; a smaller value falls back to trapezoidal, with an operator message. diff --git a/docs/src/config/python-interface.adoc b/docs/src/config/python-interface.adoc index 9bc5ac5e286..5cc7738a717 100644 --- a/docs/src/config/python-interface.adoc +++ b/docs/src/config/python-interface.adoc @@ -298,6 +298,20 @@ see <> for an example. *paused*:: '(returns boolean)' - `motion paused` flag. +*pause_jog_ok*:: '(returns boolean)' - + a pause has stopped the motion of a program or MDI command: axes may + jog, see `pause_offset`. + +*pause_offset*:: '(returns tuple of floats)' - + how far jogs while paused have moved each axis off the paused position. + Resume (or step) brings them back to zero first: the spindles and the + coolant as they were at the pause, the spindles at speed, the axes other + than `[TRAJ]PAUSE_RETURN_LAST` in a straight line, then those, then the + program goes on. An abort keeps the machine where it was jogged to. + +*pause_returning*:: '(returns boolean)' - + resuming after a pause: spindles, back to the paused position, then on. + *single_stepping*:: '(returns boolean)' - `motion single_stepping` flag. diff --git a/docs/src/getting-started/updating-linuxcnc.adoc b/docs/src/getting-started/updating-linuxcnc.adoc index d0f8caa5ac8..d906bed994b 100644 --- a/docs/src/getting-started/updating-linuxcnc.adoc +++ b/docs/src/getting-started/updating-linuxcnc.adoc @@ -261,6 +261,24 @@ LinuxCNC. Use *iocontrol.0.tool-prep-number* (the tool number) or *iocontrol.0.tool-prep-pocket* (its pocket) instead. A HAL file that still connects the pin fails to load. +=== Jogging while paused + +Axes can now be jogged, by keyboard, halui, linuxcncrsh or a wheel, while +a program or MDI command is paused, including at M0 and M1, once the pause +has stopped the motion. Joints cannot. On resume (or step) LinuxCNC first: + +. puts the spindles and the coolant back as they were at the pause, and + waits for the spindles to be at speed; +. returns the axes to the paused position: the axes other than + `[TRAJ]PAUSE_RETURN_LAST` (default `Z`) together in a straight line, + then those, at the axis limits; +. goes on with the program. + +Pausing again during the return stops it; the axes can be jogged again +from there. An abort keeps the machine where it was jogged to. Reverse +run is refused while the axes are away from the paused position. AXIS +enables its jog and spindle controls while paused. + == Preview renderer now requires OpenGL 3.3 core diff --git a/share/axis/tcl/axis.tcl b/share/axis/tcl/axis.tcl index 2b99ad86ae8..98ba9ffbc0b 100644 --- a/share/axis/tcl/axis.tcl +++ b/share/axis/tcl/axis.tcl @@ -1891,6 +1891,11 @@ proc update_state {args} { set_mode_from_tab } enable_group $::manualgroup + } elseif {$::task_state == $::STATE_ON && $::pause_jog_ok} { + # a paused program or MDI: jogs and the spindle, see jog_ok, but + # no homing + enable_group $::manualgroup + $::_tabs_manual.jogf.zerohome.home configure -state disabled } else { disable_group $::manualgroup } @@ -1999,6 +2004,7 @@ set block_delete 0 set interp_pause 0 set last_interp_state 0 set interp_state 0 +set pause_jog_ok 0 set running_line -1 set highlight_line -1 set coord_type 1 @@ -2020,6 +2026,7 @@ trace add variable optional_stop write queue_update_state trace add variable block_delete write queue_update_state trace add variable interp_pause write queue_update_state trace add variable interp_state write queue_update_state +trace add variable pause_jog_ok write queue_update_state trace add variable running_line write queue_update_state trace add variable highlight_line write queue_update_state trace add variable spindledir write queue_update_state diff --git a/src/emc/ini/initraj.cc b/src/emc/ini/initraj.cc index 36537e70bdc..6e6e9eb31e6 100644 --- a/src/emc/ini/initraj.cc +++ b/src/emc/ini/initraj.cc @@ -66,6 +66,7 @@ static int loadKins(const IniFile &ini) // [TRAJ]MAX_LINEAR_ACCELERATION Maximum linear acceleration (dv/dt) // [TRAJ]MAX_LINEAR_JERK Maximum linear jerk (da/dt) // [TRAJ]PLANNER_TYPE Planner type (0=standard, 1=S-curve) +// [TRAJ]PAUSE_RETURN_LAST Axes that return last after jogs while paused (default Z) // [TRAJ]ARC_BLEND_ENABLE S-curve planner settings // [TRAJ]ARC_BLEND_FALLBACK_ENABLE ... // [TRAJ]ARC_BLEND_OPTIMIZATION_DEPTH ... @@ -152,6 +153,24 @@ static int loadTraj(const IniFile &ini) return -1; } + // After jogs while paused, the other axes return to the paused position + // first, then these: by default Z, so the tool comes down onto the point + // last. Empty: all axes in one straight line. + unsigned pause_return_last = 1 << 2; + if (auto last = ini.findString("PAUSE_RETURN_LAST", "TRAJ")) { + static const std::string axes{"XYZABCUVW"}; + pause_return_last = 0; + for (auto c : *last) { + size_t n = axes.find_first_of(std::toupper(c & 0xff)); + if (n != std::string::npos) + pause_return_last |= 1u << n; + } + } + if (0 != emcTrajSetPauseReturnLast(pause_return_last)) { + print_dbg_config("emcTrajSetPauseReturnLast"); + return -1; + } + // Planner: 0 = trapezoidal, 1 = S-curve // Default = 0 int planner_type = ini.findIntV("PLANNER_TYPE", "TRAJ", 0, 0, 1); diff --git a/src/emc/motion-logger/motion-logger.c b/src/emc/motion-logger/motion-logger.c index 86fe6c60b5c..67b431ccf98 100644 --- a/src/emc/motion-logger/motion-logger.c +++ b/src/emc/motion-logger/motion-logger.c @@ -572,6 +572,10 @@ int main(int argc, char* argv[]) { log_print("SET_SCURVE_PEAK_SCALE scale=%.6g\n", c->scurve_peak_scale); break; + case EMCMOT_SET_PAUSE_RETURN_LAST: + log_print("SET_PAUSE_RETURN_LAST mask=0x%x\n", (unsigned)c->flags); + break; + case EMCMOT_SET_TERM_COND: log_print("SET_TERM_COND termCond=%d, tolerance=%.6g\n", c->termCond, c->tolerance); break; diff --git a/src/emc/motion/axis.c b/src/emc/motion/axis.c index b6674f826cd..65d85852db8 100644 --- a/src/emc/motion/axis.c +++ b/src/emc/motion/axis.c @@ -36,6 +36,11 @@ typedef struct { double ext_offset_acc_limit; /* upper limit of axis accel for ext offset */ double old_eoffset_counts; simple_tp_t ext_offset_tp; /* planner for external coordinate offsets*/ + + simple_tp_t pause_tp; /* planner for jogs while paused, see axis_pause_update() */ + double pause_base; /* paused program position plus external offset */ + int kb_pjog_active; /* non-zero during a keyboard jog while paused */ + int wheel_pjog_active; /* non-zero during a wheel jog while paused */ } emcmot_axis_t; typedef struct { @@ -69,6 +74,12 @@ typedef struct { static emcmot_axis_t axis_array[EMCMOT_MAX_AXIS]; static axis_hal_data_t *hal_data = NULL; +// The axes that return last when a paused program resumes after jogs, +// [TRAJ]PAUSE_RETURN_LAST, and how far that return has got: 0 not +// returning, 1 the other axes, 2 these. +static unsigned pause_return_last_mask = 1 << 2; // Z +static int pause_return_phase = 0; + // Mark strings for translation, but defer translation to userspace #define _(s) (s) @@ -395,14 +406,17 @@ bool axis_jog_is_active(void) emcmot_axis_t *axis; for (n = 0; n < EMCMOT_MAX_AXIS; n++) { axis = &axis_array[n]; - if (axis->kb_ajog_active || axis->wheel_ajog_active) { + if (axis->kb_ajog_active || axis->wheel_ajog_active + || axis->kb_pjog_active || axis->wheel_pjog_active) { return 1; } } return 0; } -void axis_handle_jogwheels(bool motion_teleop_flag, bool motion_enable_flag, bool homing_is_active) +static void pause_jog_limits(int axis_num, double *min_lim, double *max_lim); + +void axis_handle_jogwheels(bool motion_teleop_flag, bool pause_jog_flag, bool motion_enable_flag, bool homing_is_active) { int axis_num; emcmot_axis_t *axis; @@ -433,6 +447,34 @@ void axis_handle_jogwheels(bool motion_teleop_flag, bool motion_enable_flag, boo //just update counts continue; } + if (pause_jog_flag) { + // a wheel jog while a coordinated move is paused moves the + // pause offset, see axis_pause_update() + double min_lim, max_lim; + if (!motion_enable_flag) { continue; } + if (!hal_get_bool(axis_data->ajog_enable)) { continue; } + if (axis->kb_pjog_active) { continue; } + if (axis->locking_joint >= 0) { continue; } + pos = axis->pause_tp.pos_cmd + delta * hal_get_real(axis_data->ajog_scale); + if ( hal_get_bool(axis_data->ajog_vel_mode) ) { + double v = axis->vel_limit; + stop_dist = v * v / ( 2 * aaccel_limit); + if ( pos > axis->pause_tp.curr_pos + stop_dist ) { + pos = axis->pause_tp.curr_pos + stop_dist; + } else if ( pos < axis->pause_tp.curr_pos - stop_dist ) { + pos = axis->pause_tp.curr_pos - stop_dist; + } + } + pause_jog_limits(axis_num, &min_lim, &max_lim); + if (pos > max_lim) { continue; } + if (pos < min_lim) { continue; } + axis->pause_tp.pos_cmd = pos; + axis->pause_tp.max_vel = axis->vel_limit; + axis->pause_tp.max_acc = aaccel_limit; + axis->wheel_pjog_active = 1; + axis->pause_tp.enable = 1; + continue; + } if (!motion_teleop_flag) { axis->teleop_tp.enable = 0; return; @@ -757,3 +799,264 @@ int axis_calc_motion(double servo_period) } return violated_teleop_limit; } + +/* +** Jogs while a coordinated move is paused. +** +** The paused program position stays where it is. A jog moves the axis by +** an offset on top of it (pause_tp), added in axis_pause_update() the way +** the external offsets are. On resume the offsets run back to zero first +** (axis_pause_return_start()), so the machine is back where it paused +** before the program continues: the other axes together in a straight +** line, then the [TRAJ]PAUSE_RETURN_LAST ones, at the axis limits. +*/ + +void axis_set_pause_return_last(unsigned mask) +{ + pause_return_last_mask = mask; +} + +/* The range the pause offset may jog in: the soft limits, less the paused +** position, for a homed axis; one limit range either way otherwise, as +** axis_jog_limits() does. */ +static void pause_jog_limits(int axis_num, double *min_lim, double *max_lim) +{ + emcmot_axis_t *axis = &axis_array[axis_num]; + + if (axis_is_homed(axis_num)) { + *min_lim = axis->min_pos_limit - axis->pause_base; + *max_lim = axis->max_pos_limit - axis->pause_base; + } else { + double range = axis->max_pos_limit - axis->min_pos_limit; + *min_lim = axis->pause_tp.curr_pos - range; + *max_lim = axis->pause_tp.curr_pos + range; + } +} + +void axis_pause_jog_cont(int axis_num, double vel) +{ + emcmot_axis_t *axis = &axis_array[axis_num]; + double min_lim, max_lim; + + if (axis->wheel_pjog_active) { return; } + pause_jog_limits(axis_num, &min_lim, &max_lim); + axis->pause_tp.pos_cmd = (vel > 0.0) ? max_lim : min_lim; + axis->pause_tp.max_vel = fabs(vel); + axis->pause_tp.max_acc = axis->acc_limit; + axis->kb_pjog_active = 1; + axis->pause_tp.enable = 1; +} + +void axis_pause_jog_incr(int axis_num, double offset, double vel) +{ + emcmot_axis_t *axis = &axis_array[axis_num]; + double target, min_lim, max_lim; + + if (axis->wheel_pjog_active) { return; } + target = axis->pause_tp.pos_cmd + ((vel > 0.0) ? offset : -offset); + pause_jog_limits(axis_num, &min_lim, &max_lim); + if (target > max_lim) { return; } + if (target < min_lim) { return; } + axis->pause_tp.pos_cmd = target; + axis->pause_tp.max_vel = fabs(vel); + axis->pause_tp.max_acc = axis->acc_limit; + axis->kb_pjog_active = 1; + axis->pause_tp.enable = 1; +} + +void axis_pause_jog_abort(int axis_num) +{ + emcmot_axis_t *axis = &axis_array[axis_num]; + + if (pause_return_phase) { return; } + axis->pause_tp.enable = 0; + axis->kb_pjog_active = 0; + axis->wheel_pjog_active = 0; +} + +void axis_pause_update(double *pcmd_p[], double servo_period) +{ + int n; + + for (n = 0; n < EMCMOT_MAX_AXIS; n++) { + emcmot_axis_t *axis = &axis_array[n]; + double save_curr_pos = axis->pause_tp.curr_pos; + + axis->pause_base = *pcmd_p[n] + axis->ext_offset_tp.curr_pos; + if (!pause_return_phase) { + axis->pause_tp.max_jerk = axis->jerk_limit; + if (axis->pause_tp.max_vel > axis->vel_limit) { + axis->pause_tp.max_vel = axis->vel_limit; + } + } + simple_tp_update(&axis->pause_tp, servo_period); + + // stay within the soft limits, as update_teleop_with_check() does; + // a return only moves back toward the paused position + if ( !pause_return_phase + && !((0 == axis->max_pos_limit) && (0 == axis->min_pos_limit)) + && axis_is_homed(n)) { + double pos = axis->pause_base + axis->pause_tp.curr_pos; + if ( (pos >= axis->max_pos_limit && axis->pause_tp.curr_pos > save_curr_pos) + || (pos <= axis->min_pos_limit && axis->pause_tp.curr_pos < save_curr_pos)) { + axis->pause_tp.curr_pos = save_curr_pos; + axis->pause_tp.curr_vel = 0; + axis->pause_tp.pos_cmd = save_curr_pos; + } + } + if (!axis->pause_tp.active) { + axis->kb_pjog_active = 0; + axis->wheel_pjog_active = 0; + } + *pcmd_p[n] += axis->pause_tp.curr_pos; + } +} + +/* Send the axes in mask back to zero offset in a straight line: the same +** profile for all, scaled by each one's distance, as fast as the slowest +** axis allows. Returns whether any axis has to move. */ +static bool pause_return_plan(unsigned mask) +{ + double v = 1e99, a = 1e99, j = 1e99; + bool jerk = true, any = false; + int n; + + for (n = 0; n < EMCMOT_MAX_AXIS; n++) { + emcmot_axis_t *axis = &axis_array[n]; + double d = fabs(axis->pause_tp.curr_pos); + if (!(mask & (1u << n))) { continue; } + if (d < 1e-12) { continue; } + any = true; + if (axis->vel_limit / d < v) { v = axis->vel_limit / d; } + if (axis->acc_limit / d < a) { a = axis->acc_limit / d; } + if (axis->jerk_limit > 0) { + if (axis->jerk_limit / d < j) { j = axis->jerk_limit / d; } + } else { + jerk = false; + } + } + for (n = 0; n < EMCMOT_MAX_AXIS; n++) { + emcmot_axis_t *axis = &axis_array[n]; + double d = fabs(axis->pause_tp.curr_pos); + if (!(mask & (1u << n))) { continue; } + axis->kb_pjog_active = 0; + axis->wheel_pjog_active = 0; + if (d < 1e-12) { + axis->pause_tp.curr_pos = axis->pause_tp.pos_cmd = 0; + continue; + } + axis->pause_tp.pos_cmd = 0; + axis->pause_tp.max_vel = d * v; + axis->pause_tp.max_acc = d * a; + axis->pause_tp.max_jerk = jerk ? d * j : 0; + axis->pause_tp.enable = 1; + // moving from now on: pause_return_settled() may run before the + // planner has, and must not take the old 'not active' for arrived + axis->pause_tp.active = 1; + } + return any; +} + +static bool pause_return_settled(unsigned mask) +{ + int n; + + for (n = 0; n < EMCMOT_MAX_AXIS; n++) { + if (!(mask & (1u << n))) { continue; } + if (axis_array[n].pause_tp.active) { return false; } + } + // the planner stops within a tiny distance of zero; make it zero + for (n = 0; n < EMCMOT_MAX_AXIS; n++) { + if (!(mask & (1u << n))) { continue; } + axis_array[n].pause_tp.curr_pos = axis_array[n].pause_tp.pos_cmd = 0; + axis_array[n].pause_tp.curr_vel = 0; + axis_array[n].pause_tp.curr_acc = 0; + } + return true; +} + +void axis_pause_return_start(void) +{ + pause_return_phase = 1; + if (!pause_return_plan(~pause_return_last_mask)) { + pause_return_settled(~pause_return_last_mask); + pause_return_phase = 2; + if (!pause_return_plan(pause_return_last_mask)) { + pause_return_settled(pause_return_last_mask); + pause_return_phase = 0; + } + } +} + +bool axis_pause_return_update(void) +{ + if (pause_return_phase == 1 && pause_return_settled(~pause_return_last_mask)) { + pause_return_phase = 2; + if (!pause_return_plan(pause_return_last_mask)) { + pause_return_settled(pause_return_last_mask); + pause_return_phase = 0; + } + } else if (pause_return_phase == 2 && pause_return_settled(pause_return_last_mask)) { + pause_return_phase = 0; + } + return pause_return_phase == 0; +} + +void axis_pause_return_cancel(void) +{ + int n; + + pause_return_phase = 0; + for (n = 0; n < EMCMOT_MAX_AXIS; n++) { + axis_array[n].pause_tp.enable = 0; + } +} + +bool axis_pause_returning(void) +{ + return pause_return_phase != 0; +} + +bool axis_pause_offset_active(void) +{ + int n; + + for (n = 0; n < EMCMOT_MAX_AXIS; n++) { + if (axis_array[n].pause_tp.curr_pos != 0 || axis_array[n].pause_tp.active) { + return true; + } + } + return false; +} + +bool axis_pause_jog_is_active(void) +{ + int n; + + for (n = 0; n < EMCMOT_MAX_AXIS; n++) { + if (axis_array[n].kb_pjog_active || axis_array[n].wheel_pjog_active) { + return true; + } + } + return false; +} + +void axis_pause_clear(void) +{ + int n; + + pause_return_phase = 0; + for (n = 0; n < EMCMOT_MAX_AXIS; n++) { + simple_tp_t *tp = &axis_array[n].pause_tp; + tp->pos_cmd = tp->curr_pos = tp->curr_vel = tp->curr_acc = 0; + tp->enable = 0; + tp->active = 0; + axis_array[n].kb_pjog_active = 0; + axis_array[n].wheel_pjog_active = 0; + } +} + +double axis_get_pause_offset(int axis_num) +{ + return axis_array[axis_num].pause_tp.curr_pos; +} diff --git a/src/emc/motion/axis.h b/src/emc/motion/axis.h index f09299dbd5d..2d9c8ebbd54 100644 --- a/src/emc/motion/axis.h +++ b/src/emc/motion/axis.h @@ -13,7 +13,7 @@ void axis_init_all(void); void axis_initialize_external_offsets(void); int axis_init_hal_io(int mot_comp_id); -void axis_handle_jogwheels(bool motion_teleop_flag, bool motion_enable_flag, bool homing_is_active); +void axis_handle_jogwheels(bool motion_teleop_flag, bool pause_jog_flag, bool motion_enable_flag, bool homing_is_active); bool axis_plan_external_offsets(double servo_period, bool motion_enable_flag, bool all_homed); void axis_check_constraints(double pos[], int failing_axes[]); @@ -52,6 +52,21 @@ int axis_update_coord_with_bound(double *pcmd_p[], double servo_period); int axis_calc_motion(double servo_period); +// jogs while a coordinated move is paused, see axis.c +void axis_set_pause_return_last(unsigned mask); +void axis_pause_jog_cont(int axis_num, double vel); +void axis_pause_jog_incr(int axis_num, double offset, double vel); +void axis_pause_jog_abort(int axis_num); +void axis_pause_update(double *pcmd_p[], double servo_period); +void axis_pause_return_start(void); +bool axis_pause_return_update(void); +void axis_pause_return_cancel(void); +bool axis_pause_returning(void); +bool axis_pause_offset_active(void); +bool axis_pause_jog_is_active(void); +void axis_pause_clear(void); +double axis_get_pause_offset(int axis_num); + #ifdef __cplusplus } diff --git a/src/emc/motion/command.c b/src/emc/motion/command.c index 8afcf69a2f7..4348d444e66 100644 --- a/src/emc/motion/command.c +++ b/src/emc/motion/command.c @@ -269,6 +269,105 @@ void apply_spindle_limits(spindle_status_t *s){ } } +/* Jogs while paused. In coordinated mode a jog moves the pause offset + (axis_pause_*() in axis.c): only an axis, and only once a pause has + stopped the motion (emcmotStatus->pause_jog_ok, set in control.c). */ +static bool pause_jog_check(void) +{ + int axis_num = emcmotCommand->axis; + + if (!emcmotStatus->paused) { + /* coordinated mode without a pause, as in MDI mode: a jog does + nothing and says nothing, as it always has */ + return false; + } + if (axis_num < 0 || axis_num >= EMCMOT_MAX_AXIS) { + reportError(_("Can't jog a joint while a coordinated move is paused, jog an axis")); + return false; + } + if (!emcmotStatus->pause_jog_ok) { + reportError(_("Can't jog until the paused motion has stopped")); + return false; + } + if (axis_get_locking_joint(axis_num) >= 0) { + reportError(_("Cannot jog a locking indexer AXIS_%c"), "XYZABCUVW"[axis_num]); + return false; + } + return true; +} + +/* What EMCMOT_RESUME and EMCMOT_STEP do, right away or, after jogs while + paused, once do_pause_resume() (control.c) has the machine back. */ +void pause_resume_now(int cmd) +{ + if (cmd == EMCMOT_STEP) { + if (emcmotStatus->paused) { + emcmotInternal->idForStep = emcmotStatus->id; + emcmotStatus->stepping = 1; + tpResume(&emcmotInternal->coord_tp); + emcmotStatus->paused = 1; + } else { + reportError(_("MOTION: can't STEP while already executing")); + } + return; + } + emcmotStatus->stepping = 0; + tpResume(&emcmotInternal->coord_tp); + emcmotStatus->paused = 0; + emcmotInternal->pause_spindles_saved = 0; +} + +/* The spindles as they were when the motion paused. */ +void pause_save_spindles(void) +{ + int n; + + for (n = 0; n < emcmotConfig->numSpindles; n++) { + spindle_status_t *sp = &emcmotStatus->spindle_status[n]; + emcmotInternal->pause_spindle[n].state = sp->state; + emcmotInternal->pause_spindle[n].direction = sp->direction; + emcmotInternal->pause_spindle[n].brake = sp->brake; + emcmotInternal->pause_spindle[n].speed = sp->speed; + emcmotInternal->pause_spindle[n].css_factor = sp->css_factor; + emcmotInternal->pause_spindle[n].xoffset = sp->xoffset; + } + emcmotInternal->pause_spindles_saved = 1; +} + +/* Put the spindles back the way they were when the motion paused, as + EMCMOT_SPINDLE_ON and EMCMOT_SPINDLE_OFF would. Returns whether any of + them changed. */ +bool pause_restore_spindles(void) +{ + bool changed = false; + int n; + + if (!emcmotInternal->pause_spindles_saved) { return false; } + for (n = 0; n < emcmotConfig->numSpindles; n++) { + spindle_status_t *sp = &emcmotStatus->spindle_status[n]; + const emcmot_pause_spindle_t *saved = &emcmotInternal->pause_spindle[n]; + if ( sp->state == saved->state && sp->direction == saved->direction + && sp->speed == saved->speed && sp->css_factor == saved->css_factor + && sp->xoffset == saved->xoffset) { + continue; + } + changed = true; + hal_set_bool(emcmot_hal_data->spindle[n].spindle_locked, 0); + hal_set_bool(emcmot_hal_data->spindle[n].spindle_orient, 0); + sp->orient_state = EMCMOT_ORIENT_NONE; + sp->state = saved->state; + sp->speed = saved->speed; + sp->css_factor = saved->css_factor; + sp->xoffset = saved->xoffset; + sp->direction = saved->direction; + sp->brake = saved->brake; + if (sp->state) { + apply_spindle_limits(sp); + } + } + return changed; +} + /* inRange() returns non-zero if the position lies within the joint limits, or 0 if not. It also reports an error for each joint limit @@ -506,8 +605,9 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) // joints_axes test for unexpected conditions // example: non-cooperating guis // example: attempt to jog locking indexer axis letter - if ( emcmotCommand->command == EMCMOT_JOG_CONT - || emcmotCommand->command == EMCMOT_JOG_INCR + if ( ( emcmotCommand->command == EMCMOT_JOG_CONT + || emcmotCommand->command == EMCMOT_JOG_INCR) + && !GET_MOTION_COORD_FLAG() // jogs while paused, see pause_jog_check() ) { if (GET_MOTION_TELEOP_FLAG() && (emcmotCommand->axis < 0)) { emsg = "command.com teleop: unexpected negative axis_num"; @@ -559,6 +659,7 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) || emcmotCommand->command == EMCMOT_JOG_INCR ) && !(GET_MOTION_TELEOP_FLAG()) + && !GET_MOTION_COORD_FLAG() && get_home_is_synchronized(joint_num) && !get_homing_is_active() ) { @@ -631,6 +732,14 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) SET_JOINT_FAULT_FLAG(joint, 0); } emcmotStatus->paused = 0; + /* stop jogs while paused and any return; control.c takes the + offsets into the planner position once it is idle */ + emcmotInternal->pause_resume_cmd = 0; + emcmotInternal->pause_spindles_saved = 0; + axis_pause_return_cancel(); + for (n = 0; n < EMCMOT_MAX_AXIS; n++) { + axis_pause_jog_abort(n); + } /* Drop any pending at-speed barrier so it can't strand a later move. */ emcmotStatus->atspeed_next_feed = 0; // Clear pins on abort so tests see a clean state @@ -649,7 +758,12 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) /* abort one joint number or axis number */ /* can happen at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "JOG_ABORT: %i", joint_num); - if (GET_MOTION_TELEOP_FLAG()) { + if (GET_MOTION_COORD_FLAG()) { + /* a jog while paused */ + if ((emcmotCommand->axis >= 0) && (emcmotCommand->axis < EMCMOT_MAX_AXIS)) { + axis_pause_jog_abort(emcmotCommand->axis); + } + } else if (GET_MOTION_TELEOP_FLAG()) { /* tell teleop planner to stop */ if ((emcmotCommand->axis >= 0) && (emcmotCommand->axis < EMCMOT_MAX_AXIS)) { axis_jog_abort(emcmotCommand->axis, 0); @@ -895,6 +1009,13 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) SET_JOINT_ERROR_FLAG(joint, 1); break; } + if (GET_MOTION_COORD_FLAG()) { + // COORD (paused) JOG_CONT + if (pause_jog_check()) { + axis_pause_jog_cont(emcmotCommand->axis, emcmotCommand->vel); + } + break; + } if (!GET_MOTION_TELEOP_FLAG()) { if (joint->wheel_jjog_active) { /* can't do two kinds of jog at once */ @@ -963,6 +1084,13 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) SET_JOINT_ERROR_FLAG(joint, 1); break; } + if (GET_MOTION_COORD_FLAG()) { + // COORD (paused) JOG_INCR + if (pause_jog_check()) { + axis_pause_jog_incr(emcmotCommand->axis, emcmotCommand->offset, emcmotCommand->vel); + } + break; + } if (!GET_MOTION_TELEOP_FLAG()) { if (joint->wheel_jjog_active) { /* can't do two kinds of jog at once */ @@ -1426,6 +1554,11 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) /* ===== END PLANNER_SWITCH_DEFER ==================================== */ break; + case EMCMOT_SET_PAUSE_RETURN_LAST: + rtapi_print_msg(RTAPI_MSG_DBG, "SET_PAUSE_RETURN_LAST"); + axis_set_pause_return_last((unsigned)emcmotCommand->flags); + break; + case EMCMOT_SET_SCURVE_PEAK_SCALE: /* S-curve rest-to-rest peak velocity scale: 0.5 = faithful (original * behaviour), 1.0 = physically-correct (full jerk-feasible cornering). @@ -1444,6 +1577,14 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) /* pause the motion */ /* can happen at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "PAUSE"); + if (!emcmotStatus->paused) { + pause_save_spindles(); + } + /* pausing again while resuming stops the return where it is */ + if (emcmotInternal->pause_resume_cmd) { + emcmotInternal->pause_resume_cmd = 0; + axis_pause_return_cancel(); + } tpPause(&emcmotInternal->coord_tp); emcmotStatus->paused = 1; break; @@ -1452,6 +1593,10 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) /* run motion in reverse*/ /* only allowed during a pause */ rtapi_print_msg(RTAPI_MSG_DBG, "REVERSE"); + if (axis_pause_offset_active() || emcmotInternal->pause_resume_cmd) { + reportError(_("Can't run in reverse while jogged away from the paused position")); + break; + } tpSetRunDir(&emcmotInternal->coord_tp, TC_DIR_REVERSE); break; @@ -1459,6 +1604,10 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) /* run motion in reverse*/ /* only allowed during a pause */ rtapi_print_msg(RTAPI_MSG_DBG, "FORWARD"); + if (axis_pause_offset_active() || emcmotInternal->pause_resume_cmd) { + reportError(_("Can't change direction while jogged away from the paused position")); + break; + } tpSetRunDir(&emcmotInternal->coord_tp, TC_DIR_FORWARD); break; @@ -1466,23 +1615,27 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) /* resume paused motion */ /* can happen at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "RESUME"); - emcmotStatus->stepping = 0; - tpResume(&emcmotInternal->coord_tp); - emcmotStatus->paused = 0; + if (emcmotStatus->paused && GET_MOTION_COORD_FLAG()) { + /* spindles, then back to the paused position, then on: + do_pause_resume() in control.c */ + emcmotInternal->pause_resume_cmd = EMCMOT_RESUME; + emcmotInternal->pause_resume_phase = 0; + break; + } + pause_resume_now(EMCMOT_RESUME); break; case EMCMOT_STEP: /* resume paused motion until id changes */ /* can happen at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "STEP"); - if(emcmotStatus->paused) { - emcmotInternal->idForStep = emcmotStatus->id; - emcmotStatus->stepping = 1; - tpResume(&emcmotInternal->coord_tp); - emcmotStatus->paused = 1; - } else { - reportError(_("MOTION: can't STEP while already executing")); + if (emcmotStatus->paused && GET_MOTION_COORD_FLAG()) { + /* as EMCMOT_RESUME, see do_pause_resume() */ + emcmotInternal->pause_resume_cmd = EMCMOT_STEP; + emcmotInternal->pause_resume_phase = 0; + break; } + pause_resume_now(EMCMOT_STEP); break; case EMCMOT_FEED_SCALE: diff --git a/src/emc/motion/control.c b/src/emc/motion/control.c index 22cbfdaf5a4..bd4c7437ead 100644 --- a/src/emc/motion/control.c +++ b/src/emc/motion/control.c @@ -196,6 +196,9 @@ static void update_status(void); static void handle_kinematicsSwitch(void); static int reanchor_pose(const double *joint_pos, EmcPose *at); +/* resume after jogs while paused: spindles, at speed, back, on */ +static void do_pause_resume(void); + /*********************************************************************** * PUBLIC FUNCTION CODE * ************************************************************************/ @@ -262,7 +265,7 @@ void emcmotController(void *arg, long period) handle_jjogwheels(); } if (!emcmotStatus->on_soft_limit && !hal_get_bool(emcmot_hal_data->jog_inhibit)) { // change from teleop to move off joint soft limit - axis_handle_jogwheels(GET_MOTION_TELEOP_FLAG(), GET_MOTION_ENABLE_FLAG(), get_homing_is_active()); + axis_handle_jogwheels(GET_MOTION_TELEOP_FLAG(), emcmotStatus->pause_jog_ok, GET_MOTION_ENABLE_FLAG(), get_homing_is_active()); } if ( (emcmotStatus->motion_state == EMCMOT_MOTION_FREE) && do_homing()) { @@ -1067,6 +1070,8 @@ static void set_operating_mode(void) hal_set_bool(emcmot_hal_data->eoffset_limited, 0); } axis_initialize_external_offsets(); + axis_pause_clear(); + emcmotInternal->pause_resume_cmd = 0; tpSetPos(&emcmotInternal->coord_tp, &emcmotStatus->carte_pos_cmd); for (joint_num = 0; joint_num < ALL_JOINTS; joint_num++) { /* point to joint data */ @@ -1112,6 +1117,11 @@ static void set_operating_mode(void) } } coord_cubic_active = 0; + /* jogs while paused end with coordinated mode; their offsets + are in carte_pos_cmd */ + axis_pause_clear(); + emcmotInternal->pause_resume_cmd = 0; + emcmotStatus->pause_jog_ok = 0; /* Initialize things to do when starting teleop mode. */ SET_MOTION_TELEOP_FLAG(1); SET_MOTION_COORD_FLAG(0); @@ -1177,6 +1187,9 @@ static void set_operating_mode(void) /* but it can stay disabled until a move is required */ joint->free_tp.enable = 0; } + axis_pause_clear(); + emcmotInternal->pause_resume_cmd = 0; + emcmotStatus->pause_jog_ok = 0; SET_MOTION_COORD_FLAG(0); SET_MOTION_TELEOP_FLAG(0); SET_MOTION_ERROR_FLAG(0); @@ -1548,6 +1561,25 @@ static void get_pos_cmds(long period) /* get new commanded traj pos */ tpGetPos(&emcmotInternal->coord_tp, &emcmotStatus->carte_pos_cmd); + /* jogs while paused move the axes off the paused position by + the pause offsets; a resume first brings them back */ + emcmotStatus->pause_jog_ok = emcmotStatus->paused + && !emcmotStatus->stepping + && !emcmotInternal->pause_resume_cmd + && emcmotStatus->current_vel < 1e-9; + axis_pause_update(pcmd_p, servo_period); + do_pause_resume(); + if ( !emcmotStatus->paused + && !emcmotInternal->pause_resume_cmd + && axis_pause_offset_active() + && !axis_pause_jog_is_active() + && tpIsDone(&emcmotInternal->coord_tp)) { + /* aborted while jogged away: stay here, the planner + takes the offsets into its position */ + tpSetPos(&emcmotInternal->coord_tp, &emcmotStatus->carte_pos_cmd); + axis_pause_clear(); + } + if (tpJointSegmentsQueued(&emcmotInternal->coord_tp)) { /* an external offset cannot ride on a joint interpolated segment: its joints were solved without one, and the @@ -2413,6 +2445,20 @@ static void update_status(void) emcmotStatus->external_offsets_applied = hal_get_bool(emcmot_hal_data->eoffset_active); + emcmotStatus->pause_offset.tran.x = axis_get_pause_offset(0); + emcmotStatus->pause_offset.tran.y = axis_get_pause_offset(1); + emcmotStatus->pause_offset.tran.z = axis_get_pause_offset(2); + emcmotStatus->pause_offset.a = axis_get_pause_offset(3); + emcmotStatus->pause_offset.b = axis_get_pause_offset(4); + emcmotStatus->pause_offset.c = axis_get_pause_offset(5); + emcmotStatus->pause_offset.u = axis_get_pause_offset(6); + emcmotStatus->pause_offset.v = axis_get_pause_offset(7); + emcmotStatus->pause_offset.w = axis_get_pause_offset(8); + emcmotStatus->pause_returning = emcmotInternal->pause_resume_cmd != 0; + if (!GET_MOTION_COORD_FLAG()) { + emcmotStatus->pause_jog_ok = 0; + } + for (dio = 0; dio < emcmotConfig->numDIO; dio++) { emcmotStatus->synch_di[dio] = hal_get_bool(emcmot_hal_data->synch_di[dio]); emcmotStatus->synch_do[dio] = hal_get_bool(emcmot_hal_data->synch_do[dio]); @@ -2532,3 +2578,47 @@ static void update_status(void) } #endif } + +/* Resuming a pause (EMCMOT_RESUME or EMCMOT_STEP, see command.c): put the + spindles back the way they were when the motion paused and wait until + they are at speed, return the axes from jogs while paused to the paused + position (axis_pause_return_*()), then resume. A pause on the way stops + it (command.c). */ +static void do_pause_resume(void) +{ + // a changed spindle's at-speed input needs a moment to follow the new + // command before it can be trusted + static const double SPINDLE_SETTLE = 0.1; + static double settle; + int n; + + if (!emcmotInternal->pause_resume_cmd) { return; } + + switch (emcmotInternal->pause_resume_phase) { + case 0: + settle = pause_restore_spindles() ? SPINDLE_SETTLE : 0; + emcmotInternal->pause_resume_phase = 1; + /* fall through */ + case 1: + if (settle > 0) { + settle -= servo_period; + return; + } + for (n = 0; n < emcmotConfig->numSpindles; n++) { + if (emcmotStatus->spindle_status[n].state + && !emcmotStatus->spindle_status[n].at_speed) { + return; + } + } + axis_pause_return_start(); + emcmotInternal->pause_resume_phase = 2; + /* fall through */ + case 2: + if (!axis_pause_return_update()) { return; } + n = emcmotInternal->pause_resume_cmd; + emcmotInternal->pause_resume_cmd = 0; + emcmotInternal->pause_resume_phase = 0; + pause_resume_now(n); + break; + } +} diff --git a/src/emc/motion/mot_priv.h b/src/emc/motion/mot_priv.h index 3a0f8e5f697..5a9109110b3 100644 --- a/src/emc/motion/mot_priv.h +++ b/src/emc/motion/mot_priv.h @@ -265,6 +265,11 @@ extern int emcmotGetRotaryIsUnlocked(int axis); // void switch_to_teleop_mode(void); +/* resuming after jogs while paused, see command.c and do_pause_resume() */ +void pause_resume_now(int cmd); +void pause_save_spindles(void); +bool pause_restore_spindles(void); + /* recalculates jog limits */ extern void refresh_jog_limits(emcmot_joint_t *joint,int joint_num); /* handles 'homed' flags, see command.c for details */ diff --git a/src/emc/motion/motion.h b/src/emc/motion/motion.h index 36fb6c4fa30..df4b7896f5c 100644 --- a/src/emc/motion/motion.h +++ b/src/emc/motion/motion.h @@ -130,6 +130,7 @@ extern "C" { EMCMOT_SET_JERK, /* set the max jerk for moves (tooltip) */ EMCMOT_SET_PLANNER_TYPE, /* set planner type (0=trapezoidal, 1=S-curve) */ EMCMOT_SET_SCURVE_PEAK_SCALE, /* set S-curve rest-to-rest peak scale (0.5=faithful..1.0=full) */ + EMCMOT_SET_PAUSE_RETURN_LAST, /* axes (flags mask) that return last after jogs while paused */ EMCMOT_SET_TERM_COND, /* set termination condition (stop, blend) */ EMCMOT_SET_NUM_JOINTS, /* set the number of joints */ EMCMOT_SET_NUM_SPINDLES, /* set the number of spindles */ @@ -691,6 +692,9 @@ Suggestion: Split this in to an Error and a Status flag register.. unsigned int tail; /* split read counter, see rtapi_seqlock.h */ int external_offsets_applied; EmcPose eoffset_pose; + EmcPose pause_offset; /* how far jogs while paused moved off the paused position */ + int pause_jog_ok; /* paused and stopped in coordinated mode: axes may jog */ + int pause_returning; /* resuming: back to the paused position, then on */ int numExtraJoints; int stepping; bool jogging_active; @@ -793,6 +797,12 @@ Suggestion: Split this in to an Error and a Status flag register.. } emcmot_error_t; +/* a spindle as it was when the motion paused, see pause_save_spindles() */ +typedef struct { + int state, direction, brake; + double speed, css_factor, xoffset; +} emcmot_pause_spindle_t; + typedef struct emcmot_internal_t { unsigned int head; /* split read counter, see rtapi_seqlock.h */ unsigned int tail; /* split read counter, see rtapi_seqlock.h */ @@ -804,6 +814,12 @@ typedef struct emcmot_internal_t { move while overriding limits */ TP_STRUCT coord_tp; /* coordinated mode planner */ int idForStep; /* status id while stepping */ + /* resuming after jogs while paused, see do_pause_resume() in control.c: + 0 nothing to do, EMCMOT_RESUME or EMCMOT_STEP once back */ + int pause_resume_cmd; + int pause_resume_phase; /* 0 spindles, 1 at speed, 2 return */ + int pause_spindles_saved; + emcmot_pause_spindle_t pause_spindle[EMCMOT_MAX_SPINDLES]; /* the spindles when paused */ } emcmot_internal_t; /* error ring buffer access functions */ diff --git a/src/emc/nml_intf/emc.cc b/src/emc/nml_intf/emc.cc index a98bbf7e10c..971b92cc2a8 100644 --- a/src/emc/nml_intf/emc.cc +++ b/src/emc/nml_intf/emc.cc @@ -1761,6 +1761,9 @@ void EMC_MOTION_STAT::update(CMS * cms) cms->update(on_soft_limit); cms->update(external_offsets_applied); EmcPose_update(cms, &eoffset_pose); + EmcPose_update(cms, &pause_offset); + cms->update(pause_jog_ok); + cms->update(pause_returning); cms->update(numExtraJoints); cms->update(jogging_active); cms->update(homing_active); diff --git a/src/emc/nml_intf/emc.hh b/src/emc/nml_intf/emc.hh index 6cd98021727..c4fd823735f 100644 --- a/src/emc/nml_intf/emc.hh +++ b/src/emc/nml_intf/emc.hh @@ -387,6 +387,7 @@ extern int emcTrajUpdate(EMC_TRAJ_STAT * stat); extern int emcTrajSetJerk(double jerk); extern int emcTrajSetMaxJerk(double jerk); extern int emcTrajPlannerType(int type); +extern int emcTrajSetPauseReturnLast(unsigned axis_mask); extern int emcTrajSetScurvePeakScale(double scale); /* G64_R_PLANNER: [TRAJ]SMOOTH_PLANNER - planner a G64 R>0 request resolves to */ extern int emcTrajSetSmoothPlanner(int type); diff --git a/src/emc/nml_intf/emc_nml.hh b/src/emc/nml_intf/emc_nml.hh index 43d999d1a7b..8bdc4976dd8 100644 --- a/src/emc/nml_intf/emc_nml.hh +++ b/src/emc/nml_intf/emc_nml.hh @@ -1069,6 +1069,9 @@ class EMC_MOTION_STAT:public EMC_MOTION_STAT_MSG { int on_soft_limit; int external_offsets_applied; EmcPose eoffset_pose; + EmcPose pause_offset; // how far jogs while paused moved off the paused position + bool pause_jog_ok; // paused and stopped: axes may jog + bool pause_returning; // resuming: spindles, back to the paused position, then on int numExtraJoints; bool jogging_active; // Aggregate "the homing state machine is running", from diff --git a/src/emc/nml_intf/emcops.cc b/src/emc/nml_intf/emcops.cc index 2fe4fe31a0e..5d1a74951a2 100644 --- a/src/emc/nml_intf/emcops.cc +++ b/src/emc/nml_intf/emcops.cc @@ -124,6 +124,9 @@ EMC_MOTION_STAT::EMC_MOTION_STAT() on_soft_limit(0), external_offsets_applied(0), eoffset_pose{}, + pause_offset{}, + pause_jog_ok(false), + pause_returning(false), numExtraJoints(0), jogging_active(0), homing_active(false), diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 0403feadbab..41348563047 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -858,6 +858,72 @@ static void queueToolCommand(NMLmsg *cmd) emcTaskQueueTaskPlanSynchCmd(); } +// The coolant as it was when a program or MDI paused: resume puts it back, +// as motion does with the spindles (pause_restore_spindles()). +static bool pauseCoolantSaved = false; +static int pauseMist = 0; +static int pauseFlood = 0; + +static void pauseSaveCoolant() +{ + if (!emcStatus->task.task_paused) { + // what is left of a pause that an abort ended + pauseCoolantSaved = false; + } + if (pauseCoolantSaved) { + return; + } + pauseMist = emcStatus->io.coolant.mist; + pauseFlood = emcStatus->io.coolant.flood; + pauseCoolantSaved = true; +} + +static void pauseRestoreCoolant(bool resuming) +{ + if (!emcStatus->task.task_paused) { + pauseCoolantSaved = false; + } + if (!pauseCoolantSaved) { + return; + } + if (emcStatus->io.coolant.mist != pauseMist) { + pauseMist ? emcCoolantMistOn() : emcCoolantMistOff(); + } + if (emcStatus->io.coolant.flood != pauseFlood) { + pauseFlood ? emcCoolantFloodOn() : emcCoolantFloodOff(); + } + // a step pauses again, with the same coolant to come back to + pauseCoolantSaved = !resuming; +} + +// A jog while a program or MDI is paused moves the axes off the paused +// position, and resuming brings them back first (motion, axis_pause_*()). +// Only axes jog, and only once the pause has stopped the motion. +static int pausedJog(NMLmsg *cmd) +{ + int jjogmode = 0; + + switch (cmd->_type) { + case EMC_JOG_STOP_TYPE: + return emcTaskIssueCommand(cmd); + case EMC_JOG_CONT_TYPE: + jjogmode = static_cast(cmd)->jjogmode; + break; + case EMC_JOG_INCR_TYPE: + jjogmode = static_cast(cmd)->jjogmode; + break; + } + if (jjogmode) { + emcOperatorError(_("Can't jog a joint while paused, jog an axis")); + return -1; + } + if (!emcStatus->motion.pause_jog_ok) { + emcOperatorError(_("Can't jog until the paused motion has stopped")); + return -1; + } + return emcTaskIssueCommand(cmd); +} + // What the planner does itself with a command in this situation, instead // of passing it through or refusing it. False if there is nothing special. static bool planSpecial(NMLmsg *cmd, const Situation &s, int &retval) @@ -913,6 +979,16 @@ static bool planSpecial(NMLmsg *cmd, const Situation &s, int &retval) } return false; + case EMC_JOG_CONT_TYPE: + case EMC_JOG_INCR_TYPE: + case EMC_JOG_STOP_TYPE: + if (s.autoPaused + || (s.mdi && emcStatus->task.interpState == EMC_TASK_INTERP::PAUSED)) { + retval = pausedJog(cmd); + return true; + } + return false; + case EMC_TASK_PLAN_RUN_TYPE: if (!s.manual) { return false; @@ -951,6 +1027,7 @@ static bool planSpecial(NMLmsg *cmd, const Situation &s, int &retval) emcStatus->motion.traj.single_stepping = 1; stepping = 1; steppingWait = 0; + pauseRestoreCoolant(false); if (emcStatus->motion.traj.paused && emcStatus->motion.traj.queue > 0) { // there are pending motions paused; step them @@ -1780,6 +1857,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) break; case EMC_TASK_PLAN_PAUSE_TYPE: + pauseSaveCoolant(); emcTrajPause(); if (emcStatus->task.interpState != EMC_TASK_INTERP::PAUSED) { interpResumeState = emcStatus->task.interpState; @@ -1791,6 +1869,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: if (GET_OPTIONAL_PROGRAM_STOP() == ON) { + pauseSaveCoolant(); emcTrajPause(); if (emcStatus->task.interpState != EMC_TASK_INTERP::PAUSED) { interpResumeState = emcStatus->task.interpState; @@ -1812,6 +1891,9 @@ static int emcTaskIssueCommand(NMLmsg * cmd) break; case EMC_TASK_PLAN_RESUME_TYPE: + // motion puts the spindles back and returns from jogs while paused + // before it goes on + pauseRestoreCoolant(true); emcTrajResume(); emcStatus->task.interpState = interpResumeState; emcStatus->task.task_paused = 0; diff --git a/src/emc/task/taskintf.cc b/src/emc/task/taskintf.cc index 974305861be..6495036a338 100644 --- a/src/emc/task/taskintf.cc +++ b/src/emc/task/taskintf.cc @@ -1139,6 +1139,18 @@ int emcTrajSetJerk(double jerk) return retval; } +// The axes that return last after jogs while paused, [TRAJ]PAUSE_RETURN_LAST +int emcTrajSetPauseReturnLast(unsigned axis_mask) +{ + emcmotCommand.command = EMCMOT_SET_PAUSE_RETURN_LAST; + emcmotCommand.flags = (int)axis_mask; + + int retval = usrmotWriteEmcmotCommand(&emcmotCommand); + + log_debug(EMC_DEBUG_CONFIG, "{}({:#x}) returned {}\n", __FUNCTION__, axis_mask, retval); + return retval; +} + int emcTrajPlannerType(int type) { emcmotCommand.command = EMCMOT_SET_PLANNER_TYPE; @@ -2155,6 +2167,9 @@ int emcMotionUpdate(EMC_MOTION_STAT * stat) } stat->jogging_active = emcmotStatus.jogging_active; + stat->pause_offset = emcmotStatus.pause_offset; + stat->pause_jog_ok = emcmotStatus.pause_jog_ok; + stat->pause_returning = emcmotStatus.pause_returning; stat->homing_active = emcmotStatus.homing_active; stat->homing_runs = emcmotStatus.homing_runs; stat->numExtraJoints = emcmotStatus.numExtraJoints; diff --git a/src/emc/usr_intf/axis/extensions/emcmodule.cc b/src/emc/usr_intf/axis/extensions/emcmodule.cc index 4efc4c5b2a1..245589195ee 100644 --- a/src/emc/usr_intf/axis/extensions/emcmodule.cc +++ b/src/emc/usr_intf/axis/extensions/emcmodule.cc @@ -1154,6 +1154,8 @@ static PyMemberDef Stat_members[] = { { "interpreter_errcode", T_INT, O(task.interpreter_errcode), READONLY, NULL}, { "optional_stop", T_BOOL, O(task.optional_stop_state), READONLY, NULL}, { "block_delete", T_BOOL, O(task.block_delete_state), READONLY, NULL}, + { "pause_jog_ok", T_BOOL, O(motion.pause_jog_ok), READONLY, NULL}, + { "pause_returning", T_BOOL, O(motion.pause_returning), READONLY, NULL}, { "task_paused", T_INT, O(task.task_paused), READONLY, NULL}, { "input_timeout", T_BOOL, O(task.input_timeout), READONLY, NULL}, { "rotation_xy", T_DOUBLE, O(task.rotation_xy), READONLY, NULL}, @@ -1317,6 +1319,10 @@ static PyObject *Stat_actual(pyStatChannel *s, void *) { return pose(s->status.motion.traj.actualPosition); } +static PyObject *Stat_pause_offset(pyStatChannel *s, void *) { + return pose(s->status.motion.pause_offset); +} + static PyObject *Stat_joint_position(pyStatChannel *s, void *) { PyObject *res = PyTuple_New(EMCMOT_MAX_JOINTS); for(int i=0; imotion.traj.mode == EMC_TRAJ_MODE::TELEOP) ) - || ( (jjogmode == JOGTELEOP ) && (emcStatus->motion.traj.mode != EMC_TRAJ_MODE::TELEOP) ) + || ( (jjogmode == JOGTELEOP ) && (emcStatus->motion.traj.mode != EMC_TRAJ_MODE::TELEOP) && !emcStatus->motion.pause_jog_ok && (emcStatus->motion.traj.mode != EMC_TRAJ_MODE::COORD) ) ) { return; } @@ -1102,7 +1102,7 @@ static void sendJogCont(int ja, double speed, int jjogmode) if (emcStatus->task.state != EMC_TASK_STATE::ON) { return; } if ( ( (jjogmode == JOGJOINT) && (emcStatus->motion.traj.mode == EMC_TRAJ_MODE::TELEOP) ) - || ( (jjogmode == JOGTELEOP ) && (emcStatus->motion.traj.mode != EMC_TRAJ_MODE::TELEOP) ) + || ( (jjogmode == JOGTELEOP ) && (emcStatus->motion.traj.mode != EMC_TRAJ_MODE::TELEOP) && !emcStatus->motion.pause_jog_ok ) ) { return; } @@ -1124,7 +1124,7 @@ static void sendJogIncr(int ja, double speed, double incr, int jjogmode) if (emcStatus->task.state != EMC_TASK_STATE::ON) { return; } if ( ( (jjogmode == JOGJOINT) && (emcStatus->motion.traj.mode == EMC_TRAJ_MODE::TELEOP) ) - || ( (jjogmode == JOGTELEOP ) && (emcStatus->motion.traj.mode != EMC_TRAJ_MODE::TELEOP) ) + || ( (jjogmode == JOGTELEOP ) && (emcStatus->motion.traj.mode != EMC_TRAJ_MODE::TELEOP) && !emcStatus->motion.pause_jog_ok ) ) { return; } diff --git a/src/emc/usr_intf/shcom.cc b/src/emc/usr_intf/shcom.cc index 0c96ebc5493..262ca782f0c 100644 --- a/src/emc/usr_intf/shcom.cc +++ b/src/emc/usr_intf/shcom.cc @@ -517,7 +517,8 @@ int sendJogStop(int ja, int jjogmode) if ( ( (jjogmode == JOGJOINT) && (emcStatus->motion.traj.mode == EMC_TRAJ_MODE::TELEOP) ) || ( (jjogmode == JOGTELEOP ) - && (emcStatus->motion.traj.mode != EMC_TRAJ_MODE::TELEOP) ) + && (emcStatus->motion.traj.mode != EMC_TRAJ_MODE::TELEOP) + && !emcStatus->motion.pause_jog_ok ) ) { return -1; } @@ -543,7 +544,8 @@ int sendJogCont(int ja, int jjogmode, double speed) if ( ( (jjogmode == JOGJOINT) && (emcStatus->motion.traj.mode == EMC_TRAJ_MODE::TELEOP) ) || ( (jjogmode == JOGTELEOP ) - && (emcStatus->motion.traj.mode != EMC_TRAJ_MODE::TELEOP) ) + && (emcStatus->motion.traj.mode != EMC_TRAJ_MODE::TELEOP) + && !emcStatus->motion.pause_jog_ok ) ) { return -1; } @@ -571,7 +573,8 @@ int sendJogIncr(int ja, int jjogmode, double speed, double incr) if ( ( (jjogmode == JOGJOINT) && ( emcStatus->motion.traj.mode == EMC_TRAJ_MODE::TELEOP) ) || ( (jjogmode == JOGTELEOP ) - && ( emcStatus->motion.traj.mode != EMC_TRAJ_MODE::TELEOP) ) + && ( emcStatus->motion.traj.mode != EMC_TRAJ_MODE::TELEOP) + && !emcStatus->motion.pause_jog_ok ) ) { return -1; } diff --git a/tests/interp/m98m99/12-M99-endless-main-program/expected.motion-logger b/tests/interp/m98m99/12-M99-endless-main-program/expected.motion-logger index 3f1d81c8228..f57d1cc9b65 100644 --- a/tests/interp/m98m99/12-M99-endless-main-program/expected.motion-logger +++ b/tests/interp/m98m99/12-M99-endless-main-program/expected.motion-logger @@ -4,6 +4,7 @@ SET_VEL vel=0, ini_maxvel=1.2 SET_VEL_LIMIT vel=4 SET_ACC acc=1e+99 SET_JERK jerk=1e+09 +SET_PAUSE_RETURN_LAST mask=0x4 SET_PLANNER_TYPE planner_type=0 SET_SCURVE_PEAK_SCALE scale=1 SETUP_ARC_BLENDS diff --git a/tests/jog-while-paused/.gitignore b/tests/jog-while-paused/.gitignore new file mode 100644 index 00000000000..57585c75340 --- /dev/null +++ b/tests/jog-while-paused/.gitignore @@ -0,0 +1,2 @@ +sim.var +sim.var.bak diff --git a/tests/jog-while-paused/checkresult b/tests/jog-while-paused/checkresult new file mode 100755 index 00000000000..24dc9aa53e3 --- /dev/null +++ b/tests/jog-while-paused/checkresult @@ -0,0 +1,2 @@ +#!/bin/sh +exit 0 # test failure is indicated by test.sh exit value diff --git a/tests/jog-while-paused/m0.ngc b/tests/jog-while-paused/m0.ngc new file mode 100644 index 00000000000..f0a1bac706e --- /dev/null +++ b/tests/jog-while-paused/m0.ngc @@ -0,0 +1,5 @@ +G21 G90 G17 +G1 F1200 X10 +M0 +G1 X0 +M2 diff --git a/tests/jog-while-paused/program.ngc b/tests/jog-while-paused/program.ngc new file mode 100644 index 00000000000..ba981850341 --- /dev/null +++ b/tests/jog-while-paused/program.ngc @@ -0,0 +1,9 @@ +G21 G90 G17 +S1000 M3 +M8 +G1 F600 X20 +G1 Y20 +G1 X0 +G1 Y0 +M5 M9 +M2 diff --git a/tests/jog-while-paused/sim.hal b/tests/jog-while-paused/sim.hal new file mode 100644 index 00000000000..5779ccc98f6 --- /dev/null +++ b/tests/jog-while-paused/sim.hal @@ -0,0 +1,16 @@ +loadrt [KINS]KINEMATICS +loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS +addf motion-command-handler servo-thread +addf motion-controller servo-thread + +net Xpos joint.0.motor-pos-cmd => joint.0.motor-pos-fb +net Ypos joint.1.motor-pos-cmd => joint.1.motor-pos-fb +net Zpos joint.2.motor-pos-cmd => joint.2.motor-pos-fb + +net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in +net tool-prepare-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared +net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed + +# a wheel on Y: one count is 0.01 +setp axis.y.jog-scale 0.01 +setp axis.y.jog-vel-mode 0 diff --git a/tests/jog-while-paused/test-ui.py b/tests/jog-while-paused/test-ui.py new file mode 100755 index 00000000000..f1cec61b67d --- /dev/null +++ b/tests/jog-while-paused/test-ui.py @@ -0,0 +1,244 @@ +#!/usr/bin/env python3 +# Jogs while a program is paused: axes move off the paused position, and +# resume brings them back (the other axes first, then Z) with the spindle +# and coolant as they were, before the program goes on. + +import math +import os +import sys +import time + +import hal +import linuxcnc + +c = linuxcnc.command() +s = linuxcnc.stat() +e = linuxcnc.error_channel() +h = hal.component("test-ui") +h.ready() + +fails = 0 + + +def check(name, ok, detail=''): + global fails + print('%s: %s %s' % ('ok' if ok else 'FAIL', name, detail), flush=True) + if not ok: + fails += 1 + + +def wait(fn, timeout=5.0): + end = time.time() + timeout + while time.time() < end: + s.poll() + if fn(): + return True + time.sleep(0.005) + s.poll() + return fn() + + +def errors(): + msgs = [] + while True: + m = e.poll() + if not m: + return msgs + msgs.append(m[1]) + + +def pos(): + return s.actual_position[:3] + + +def near(a, b, tol=1e-6): + return all(abs(x - y) <= tol for x, y in zip(a, b)) + + +def idle(): + return s.interp_state == linuxcnc.INTERP_IDLE and s.queue == 0 and s.inpos + + +def mdi(cmd): + c.mode(linuxcnc.MODE_MDI) + c.wait_complete() + c.mdi(cmd) + + +def run_and_pause(prog, at_x): + c.mode(linuxcnc.MODE_AUTO) + c.wait_complete() + c.program_open(os.path.abspath(prog)) + c.wait_complete() + c.auto(linuxcnc.AUTO_RUN, 0) + if not wait(lambda: s.actual_position[0] >= at_x, 10): + check('program reached X%g' % at_x, False, pos()) + c.auto(linuxcnc.AUTO_PAUSE) + c.wait_complete() + return wait(lambda: s.pause_jog_ok, 2) + + +wait(lambda: s.task_state != 0, 10) +c.state(linuxcnc.STATE_ESTOP_RESET) +c.state(linuxcnc.STATE_ON) +c.home(-1) +c.wait_complete() +wait(lambda: all(s.homed[:3]), 10) +c.teleop_enable(1) +c.wait_complete() +mdi('G0 X0 Y0 Z0') +wait(idle) +errors() + +# --- pause in the middle of a G1, jog three axes three ways +check('paused and ready to jog', run_and_pause('program.ngc', 5.0)) +p = pos() +print('paused at', p, flush=True) +check('spindle and flood on at the pause', s.spindle[0]['direction'] == 1 and s.flood, (s.spindle[0]['direction'], s.flood)) + +c.jog(linuxcnc.JOG_INCREMENT, False, 2, 20, 5.0) # Z +5 +check('incremental Z jog', wait(lambda: near(pos(), (p[0], p[1], p[2] + 5))), pos()) +c.jog(linuxcnc.JOG_CONTINUOUS, False, 0, 10) # X +, 10 mm/s +time.sleep(0.3) +c.jog(linuxcnc.JOG_STOP, False, 0) +check('continuous X jog stopped', wait(lambda: s.current_vel == 0 and not s.motion.jogging_active + if hasattr(s, 'motion') else not hal.get_value('motion.jog-is-active')), pos()) +# the jog counts as stopped while the axis still decelerates +def at_rest(): + was = pos() + time.sleep(0.05) + s.poll() + return pos() == was +wait(at_rest) +dx = pos()[0] - p[0] +check('continuous X jog moved', 1.0 < dx < 5.0, dx) +hal.set_p('axis.y.jog-enable', '1') +hal.set_p('axis.y.jog-counts', '200') # Y +2 +check('wheel Y jog', wait(lambda: near(pos(), (p[0] + dx, p[1] + 2, p[2] + 5))), pos()) +s.poll() +check('pause offset reported', near(s.pause_offset[:3], (dx, 2, 5)), s.pause_offset[:3]) +check('still paused', s.paused and s.interp_state == linuxcnc.INTERP_PAUSED) +check('no errors from the jogs', not errors()) + +# --- joint jogs and reverse run are refused while jogged away +c.jog(linuxcnc.JOG_INCREMENT, True, 0, 10, 1) +c.wait_complete() +time.sleep(0.1) +msgs = errors() +check('joint jog refused while paused', any('jog a joint' in m for m in msgs), msgs) +c.auto(linuxcnc.AUTO_REVERSE) +c.wait_complete() +time.sleep(0.1) +msgs = errors() +check('reverse refused while jogged away', any('reverse' in m for m in msgs), msgs) + +# --- the operator stops spindle and coolant; resume puts them back and +# waits for the spindle to be at speed before moving +c.spindle(linuxcnc.SPINDLE_OFF) +c.flood(linuxcnc.FLOOD_OFF) +c.wait_complete() +check('spindle and flood off', wait(lambda: s.spindle[0]['direction'] == 0 and not s.flood)) +hal.set_p('spindle.0.at-speed', '0') +off = pos() +c.auto(linuxcnc.AUTO_RESUME) +c.wait_complete() +check('resume restores the spindle', wait(lambda: s.spindle[0]['direction'] == 1 and s.spindle[0]['speed'] == 1000, 1), s.spindle[0]['speed']) +check('resume restores the flood', wait(lambda: s.flood, 1)) +check('returning', wait(lambda: s.pause_returning, 1)) +time.sleep(0.5) +s.poll() +check('no move until the spindle is at speed', near(pos(), off), (pos(), off)) + +# --- at speed: XY back in a straight line with Z up, then Z down, then on. +# The commanded offsets (pause_offset) show the path; actual_position lags +# them by the joint interpolation. +offsets = [] +hal.set_p('spindle.0.at-speed', '1') +end = time.time() + 5 +while time.time() < end: + s.poll() + offsets.append(s.pause_offset[:3]) + if not s.pause_returning: + break + time.sleep(0.002) +s.poll() +check('back at the paused position: offsets exactly zero', offsets and offsets[-1] == (0.0, 0.0, 0.0), offsets[-1:]) +z_early = [o for o in offsets if abs(o[2] - 5) > 1e-6 and (abs(o[0]) > 0 or abs(o[1]) > 0)] +check('Z stays up until XY are back', not z_early, z_early[:3]) +off_line = [o for o in offsets if abs(o[0] * 2 - o[1] * dx) > 1e-6] +check('XY return is a straight line', not off_line, off_line[:3]) +xy_on_way = [o for o in offsets if 0.1 < o[0] < dx - 0.1] +check('XY move back, no jump', len(xy_on_way) > 10, len(xy_on_way)) +z_on_way = [o for o in offsets if 0.1 < o[2] < 4.9] +check('Z moves back, no jump', len(z_on_way) > 10, len(z_on_way)) +check('program finished at the end point', wait(lambda: idle(), 20), pos()) +check('program end position', near(pos()[:2], (0, 0), 1e-6), pos()) +check('no errors from the resume', not errors()) + +# --- abort while jogged away: no jump, stay there +check('paused again', run_and_pause('program.ngc', 5.0)) +p = pos() +c.jog(linuxcnc.JOG_INCREMENT, False, 2, 20, 3.0) +check('Z jog before abort', wait(lambda: near(pos(), (p[0], p[1], p[2] + 3))), pos()) +c.abort() +c.wait_complete() +check('idle after abort', wait(idle)) +time.sleep(0.2) +s.poll() +check('abort keeps the jogged position', near(pos(), (p[0], p[1], p[2] + 3)), pos()) +check('pause offset gone after abort', near(s.pause_offset[:3], (0, 0, 0), 0), s.pause_offset[:3]) +mdi('G0 X1') +check('MDI after the abort', wait(lambda: idle() and near(pos(), (1, p[1], p[2] + 3))), pos()) +errors() + +# --- soft limits hold during a jog while paused (X max is 30) +check('paused for the limit test', run_and_pause('program.ngc', 5.0)) +c.jog(linuxcnc.JOG_CONTINUOUS, False, 0, 40) +time.sleep(1.5) +s.poll() +check('X stops at its soft limit', s.actual_position[0] <= 30 + 1e-9 and s.actual_position[0] > 29, s.actual_position[0]) +c.jog(linuxcnc.JOG_STOP, False, 0) +c.abort() +c.wait_complete() +wait(idle) +mdi('G0 X0 Y0 Z0') +wait(idle) +errors() + +# --- step with an offset returns first, then steps +check('paused for the step test', run_and_pause('program.ngc', 5.0)) +p = pos() +c.jog(linuxcnc.JOG_INCREMENT, False, 1, 20, 4.0) +wait(lambda: near(pos(), (p[0], p[1] + 4, p[2]))) +c.auto(linuxcnc.AUTO_STEP) +c.wait_complete() +check('step brings the offset back', wait(lambda: near(s.pause_offset[:3], (0, 0, 0), 0), 5), s.pause_offset[:3]) +check('step moved on along the program', wait(lambda: s.actual_position[0] > p[0] + 1e-3 or s.actual_position[1] > p[1] + 1e-3, 5), pos()) +c.abort() +c.wait_complete() +wait(idle) +mdi('G0 X0 Y0 Z0') +wait(idle) +errors() + +# --- an M0 stop is a pause too +c.mode(linuxcnc.MODE_AUTO) +c.wait_complete() +c.program_open(os.path.abspath('m0.ngc')) +c.wait_complete() +c.auto(linuxcnc.AUTO_RUN, 0) +check('stopped at M0', wait(lambda: s.paused and s.pause_jog_ok, 10), pos()) +p = pos() +c.jog(linuxcnc.JOG_INCREMENT, False, 2, 20, 2.0) +wait(lambda: near(pos(), (p[0], p[1], p[2] + 2))) +c.auto(linuxcnc.AUTO_RESUME) +c.wait_complete() +check('M0: back and finished', wait(lambda: idle() and near(pos(), (0, p[1], p[2])), 10), pos()) + +msgs = errors() +check('no unexpected errors', not msgs, msgs) + +c.state(linuxcnc.STATE_OFF) +c.wait_complete() +print('%d failures' % fails, flush=True) +os._exit(1 if fails else 0) diff --git a/tests/jog-while-paused/test.ini b/tests/jog-while-paused/test.ini new file mode 100644 index 00000000000..26aa8e03958 --- /dev/null +++ b/tests/jog-while-paused/test.ini @@ -0,0 +1,82 @@ +[EMC] +VERSION = 1.1 +DEBUG = 0 + +[DISPLAY] +DISPLAY = ./test-ui.py + +[RS274NGC] +PARAMETER_FILE = sim.var + +[EMCMOT] +EMCMOT = motmod +COMM_TIMEOUT = 4.0 +SERVO_PERIOD = 1000000 + +[TASK] +TASK = milltask +CYCLE_TIME = 0.001 + +[HAL] +HALFILE = sim.hal + +[TRAJ] +COORDINATES = X Y Z +LINEAR_UNITS = mm +ANGULAR_UNITS = degree +MAX_LINEAR_VELOCITY = 40 + +[EMCIO] +TOOL_TABLE = tool.tbl + +[KINS] +KINEMATICS = trivkins +JOINTS = 3 + +[AXIS_X] +MIN_LIMIT = -100.0 +MAX_LIMIT = 30.0 +MAX_VELOCITY = 40 +MAX_ACCELERATION = 1000.0 + +[JOINT_0] +TYPE = LINEAR +HOME_SEQUENCE = 0 +MAX_VELOCITY = 40 +MAX_ACCELERATION = 1000.0 +MIN_LIMIT = -100.0 +MAX_LIMIT = 30.0 +FERROR = 1 +MIN_FERROR = 1 + +[AXIS_Y] +MIN_LIMIT = -100.0 +MAX_LIMIT = 100.0 +MAX_VELOCITY = 40 +MAX_ACCELERATION = 1000.0 + +[JOINT_1] +TYPE = LINEAR +HOME_SEQUENCE = 0 +MAX_VELOCITY = 40 +MAX_ACCELERATION = 1000.0 +MIN_LIMIT = -100.0 +MAX_LIMIT = 100.0 +FERROR = 1 +MIN_FERROR = 1 + +[AXIS_Z] +MIN_LIMIT = -100.0 +MAX_LIMIT = 100.0 +MAX_VELOCITY = 40 +MAX_ACCELERATION = 1000.0 + +[JOINT_2] +TYPE = LINEAR +HOME_SEQUENCE = 0 +MAX_VELOCITY = 40 +MAX_ACCELERATION = 1000.0 +MIN_LIMIT = -100.0 +MAX_LIMIT = 100.0 +FERROR = 1 +MIN_FERROR = 1 diff --git a/tests/jog-while-paused/test.sh b/tests/jog-while-paused/test.sh new file mode 100755 index 00000000000..972cf4ffcb8 --- /dev/null +++ b/tests/jog-while-paused/test.sh @@ -0,0 +1,3 @@ +#!/bin/bash +rm -f sim.var +linuxcnc -r test.ini diff --git a/tests/jog-while-paused/tool.tbl b/tests/jog-while-paused/tool.tbl new file mode 100644 index 00000000000..aee1343f663 --- /dev/null +++ b/tests/jog-while-paused/tool.tbl @@ -0,0 +1 @@ +T1 P1 Z0.5 ;tool 1 diff --git a/tests/motion-logger/basic/expected.builtin-startup.in b/tests/motion-logger/basic/expected.builtin-startup.in index fce76f310a5..8eda7cd994c 100644 --- a/tests/motion-logger/basic/expected.builtin-startup.in +++ b/tests/motion-logger/basic/expected.builtin-startup.in @@ -4,6 +4,7 @@ SET_VEL vel=0, ini_maxvel=1.2 SET_VEL_LIMIT vel=4 SET_ACC acc=1e+99 SET_JERK jerk=1e+09 +SET_PAUSE_RETURN_LAST mask=0x4 SET_PLANNER_TYPE planner_type=0 SET_SCURVE_PEAK_SCALE scale=1 SETUP_ARC_BLENDS diff --git a/tests/motion-logger/mountaindew/expected.motion-logger b/tests/motion-logger/mountaindew/expected.motion-logger index 928320a5a4e..73dc85fb4e6 100644 --- a/tests/motion-logger/mountaindew/expected.motion-logger +++ b/tests/motion-logger/mountaindew/expected.motion-logger @@ -4,6 +4,7 @@ SET_VEL vel=0, ini_maxvel=120 SET_VEL_LIMIT vel=400 SET_ACC acc=1e+99 SET_JERK jerk=1e+09 +SET_PAUSE_RETURN_LAST mask=0x4 SET_PLANNER_TYPE planner_type=0 SET_SCURVE_PEAK_SCALE scale=1 SETUP_ARC_BLENDS diff --git a/tests/motion-logger/startup-gcode-abort/expected.motion-logger.in b/tests/motion-logger/startup-gcode-abort/expected.motion-logger.in index 8bc77b66e94..3c4f04e1563 100644 --- a/tests/motion-logger/startup-gcode-abort/expected.motion-logger.in +++ b/tests/motion-logger/startup-gcode-abort/expected.motion-logger.in @@ -9,6 +9,7 @@ SET_VEL vel=0, ini_maxvel=1.2 SET_VEL_LIMIT vel=4 SET_ACC acc=1e+99 SET_JERK jerk=1e+09 +SET_PAUSE_RETURN_LAST mask=0x4 SET_PLANNER_TYPE planner_type=0 SET_SCURVE_PEAK_SCALE scale=1 SETUP_ARC_BLENDS diff --git a/tests/task-planner/checkresult b/tests/task-planner/checkresult index 3a4bb810285..bbb98459b76 100755 --- a/tests/task-planner/checkresult +++ b/tests/task-planner/checkresult @@ -30,7 +30,7 @@ BEGIN = re.compile(r"^Issuing EMC_OPERATOR_DISPLAY -- \t \(.*,probe-begin\\032(\ END = re.compile(r"^Issuing EMC_OPERATOR_DISPLAY -- \t \(.*,probe-end,\)$") ISSUED = re.compile(r"^Issuing (\S+) -- \t \(\s*\+\d+,\+\d+,\s*\+(\d+),") QUEUED = re.compile(r"^InterpList\(0x[0-9a-f]+\)::append\((\S+)\)") -REFUSED = re.compile(r"can't do that|cannot be executed until") +REFUSED = re.compile(r"can't do that|cannot be executed until|Can't jog a joint while paused") PROBE = re.compile(r"^PROBE (\S+) (\S+) (\d+) (\S+)$") windows = {} # (situation, command) -> lines between the markers diff --git a/tests/task-planner/expected b/tests/task-planner/expected index 9059d09922f..f4b741fb55e 100644 --- a/tests/task-planner/expected +++ b/tests/task-planner/expected @@ -561,7 +561,7 @@ EMC_JOINT_UNHOME issued EMC_JOINT_OVERRIDE_LIMITS refused EMC_JOG_CONT refused EMC_JOG_INCR refused -EMC_JOG_STOP refused +EMC_JOG_STOP issued EMC_TRAJ_SET_SCALE issued EMC_TRAJ_SET_RAPID_SCALE issued EMC_TRAJ_SET_MAX_VELOCITY issued From 91514105617d762c67ae40af7b49efd438606da0 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Fri, 16 Oct 2026 19:02:06 +0200 Subject: [PATCH 15/27] task: the task mode follows what runs and cannot be set Manual, MDI and Auto are no longer modes a user interface switches between. Task tracks what it runs (idle, a program, MDI) and reports the mode from that: Auto while a program runs or is paused, MDI while MDI commands run, Manual otherwise. - While idle task accepts jogs, homing, MDI commands and program runs. Starting a run checks homing, an open program and that no jog (including a wheel jog) is active, switches motion to coordinated mode and re-syncs the interpreter; nothing leaves interp_list until motion is in coordinated mode. When the run ends motion goes back to the joint or world mode it had before, so wheel jogs work whenever nothing runs. - The planner chooses its command table by what runs: idle (the old Manual and Auto-idle tables merged), program (unchanged), MDI running (jogs and joint/world switching refused). - EMC_TASK_SET_MODE is accepted in any state and does nothing. - halui: halui.mode.manual, .mdi and .auto do nothing, the is-* pins show the derived mode, MDI commands go straight to task. User interfaces that switch pages on the mode keep working through a per-UI view mode: Python mode(), Tcl emc_mode and linuxcncrsh set mode (per connection) record the page asked for, and task_mode / get mode report it while task is idle. AXIS loses its "coordinated while Manual, force teleop" kick and the dead tab-raise code. Behaviour changes, documented in updating-linuxcnc: switching to Manual no longer aborts a running MDI command; a run started from Manual runs the program; a run with no program open is refused; the parameter file is saved at the start of every MDI command from idle. Tests: new tests/task-modeless; halui/mdi rewritten for the new semantics; g28.2/invalid-pword waits for motion to leave coordinated mode; motion-logger, M99, interp_initcode and linuxcncrsh expectations updated for the mode switches that moved (COORD at run start, FREE or TELEOP at run end, no abort from a mode change). --- docs/src/config/python-interface.adoc | 16 +- .../getting-started/updating-linuxcnc.adoc | 34 ++ docs/src/gui/halui.adoc | 19 +- docs/src/man/man1/halui.1.adoc | 12 +- docs/src/man/man1/linuxcncrsh.1.adoc | 10 +- src/emc/task/emctask.cc | 83 +--- src/emc/task/emctaskmain.cc | 422 ++++++++++-------- src/emc/task/task.hh | 10 +- src/emc/usr_intf/axis/extensions/emcmodule.cc | 28 +- src/emc/usr_intf/axis/scripts/axis.py | 21 - src/emc/usr_intf/emcrsh.cc | 28 +- src/emc/usr_intf/emcsh.cc | 16 +- src/emc/usr_intf/halui.cc | 87 +--- tests/halui/mdi/test-ui.py | 73 ++- tests/interp/g28.2/invalid-pword/test-ui.py | 7 +- .../expected.motion-logger | 18 +- tests/linuxcncrsh/expected-telnet-output | 12 +- tests/linuxcncrsh/test.sh | 12 +- .../basic/expected.builtin-startup.in | 23 +- tests/motion-logger/basic/expected.g0 | 2 + tests/motion-logger/basic/expected.g1 | 2 + tests/motion-logger/basic/expected.reset | 2 + tests/motion-logger/basic/expected.s | 2 + .../mountaindew/expected.motion-logger | 18 +- tests/task-hal-pins/test-ui.py | 2 +- tests/task-modeless/.gitignore | 2 + tests/task-modeless/checkresult | 2 + tests/task-modeless/program.ngc | 4 + tests/task-modeless/sim.hal | 16 + tests/task-modeless/test-ui.py | 234 ++++++++++ tests/task-modeless/test.ini | 83 ++++ tests/task-modeless/test.sh | 3 + tests/task-modeless/tool.tbl | 1 + 33 files changed, 783 insertions(+), 521 deletions(-) create mode 100644 tests/task-modeless/.gitignore create mode 100755 tests/task-modeless/checkresult create mode 100644 tests/task-modeless/program.ngc create mode 100644 tests/task-modeless/sim.hal create mode 100755 tests/task-modeless/test-ui.py create mode 100644 tests/task-modeless/test.ini create mode 100755 tests/task-modeless/test.sh create mode 100644 tests/task-modeless/tool.tbl diff --git a/docs/src/config/python-interface.adoc b/docs/src/config/python-interface.adoc index 5cc7738a717..bf50dd0aef4 100644 --- a/docs/src/config/python-interface.adoc +++ b/docs/src/config/python-interface.adoc @@ -378,6 +378,11 @@ see <> for an example. *task_mode*:: '(returns integer)' - current task mode. One of `MODE_MDI`, `MODE_AUTO`, `MODE_MANUAL`. + `MODE_AUTO` while a program runs (including paused) and `MODE_MDI` + while MDI commands run. While task is idle it is the mode this process + last asked for with `mode()`, `MODE_MANUAL` until then: task's own mode + reports what runs and cannot be set, so each user interface keeps its + own page. *task_paused*:: '(returns integer)' - task paused flag. @@ -609,8 +614,6 @@ def ok_for_mdi(): return not s.estop and s.enabled and (s.homed.count(1) == s.joints) and (s.interp_state == linuxcnc.INTERP_IDLE) if ok_for_mdi(): - c.mode(linuxcnc.MODE_MDI) - c.wait_complete() # wait until mode switch executed (or default timeout of 5s occurs!) c.mdi("G0 X10 Y20 Z30") ---- @@ -657,10 +660,6 @@ c.mdi("G0 X10 Y20 Z30") c.mist(linuxcnc.MIST_ON) c.mist(linuxcnc.MIST_OFF) -c.mode(linuxcnc.MODE_MDI) -c.mode(linuxcnc.MODE_AUTO) -c.mode(linuxcnc.MODE_MANUAL) - c.override_limits() c.program_open("foo.ngc") @@ -749,7 +748,10 @@ c.tool_offset(toolno, z_offset, x_offset, diameter, frontangle, backangle, orie MIST_OFF `mode(int)`:: - set mode (MODE_MDI, MODE_MANUAL, MODE_AUTO). + set the mode this process shows (MODE_MDI, MODE_MANUAL, MODE_AUTO), see + `task_mode`. Nothing is sent to task: it starts an MDI run on `mdi()` + and a program run on `auto(AUTO_RUN)` or `auto(AUTO_STEP)` when it is + idle, and jogs and homes whenever it is idle, whatever mode was set. `override_limits()`:: set the override axis limits flag. diff --git a/docs/src/getting-started/updating-linuxcnc.adoc b/docs/src/getting-started/updating-linuxcnc.adoc index d906bed994b..1326b4ec295 100644 --- a/docs/src/getting-started/updating-linuxcnc.adoc +++ b/docs/src/getting-started/updating-linuxcnc.adoc @@ -261,6 +261,40 @@ LinuxCNC. Use *iocontrol.0.tool-prep-number* (the tool number) or *iocontrol.0.tool-prep-pocket* (its pocket) instead. A HAL file that still connects the pin fails to load. +=== The task mode cannot be set + +Manual, MDI and Auto are no longer modes a user interface switches +between. Task accepts what fits what it is doing: + +* while idle: jogs, homing, an MDI command (which starts MDI) and a + program run or step (which starts the program); +* while MDI runs: more MDI commands, which queue, pause and abort; +* while a program runs: pause, step and abort, as before. + +Immediate commands such as overrides, spindle and coolant are accepted +as before. Several user interfaces can therefore show different pages at +the same time without taking the machine away from each other. + +* Task's mode, and `halui.mode.is-manual`, `.is-mdi`, `.is-auto`, report + what runs: Auto while a program runs or is paused, MDI while MDI + commands run, Manual otherwise. They change on their own when a run + starts and ends. +* The Python `mode()` command, Tcl `emc_mode` and linuxcncrsh `set mode` + no longer reach task. They set the mode that user interface (Python or + Tcl process, linuxcncrsh connection) shows, which `task_mode`, + `emc_mode` and `get mode` report while task is idle. User interfaces + that switch pages on the mode keep working, each with its own page. +* The `halui.mode.manual`, `.mdi` and `.auto` pins do nothing. +* Switching to Manual used to abort a running MDI command. It no longer + does: use abort. +* Task puts motion into coordinated mode when a run starts and back into + joint or world mode when it ends, so wheel (MPG) jogs work whenever + nothing runs. A jog in progress, including a wheel jog, holds off MDI + and program starts, which are refused with an error. +* A run started in Manual mode used to be ignored. It now runs the + program. A run or step with no program open is refused. +* While MDI runs, jogs and switching between joint and world mode are + refused; they used to be passed to motion. === Jogging while paused Axes can now be jogged, by keyboard, halui, linuxcncrsh or a wheel, while diff --git a/docs/src/gui/halui.adoc b/docs/src/gui/halui.adoc index e9c87f8c1ae..1d41a5bb31c 100644 --- a/docs/src/gui/halui.adoc +++ b/docs/src/gui/halui.adoc @@ -78,8 +78,8 @@ Owner Type Dir Value Name When a halui MDI pin is set (pulsed) true, halui will send the MDI command defined in the INI. -This will not always succeed depending on the current operating -mode (e.g., while in AUTO halui can't successfully send MDI commands). +This will not always succeed depending on what LinuxCNC is doing +(e.g., while a program runs or a jog is active task refuses MDI commands). == Example Configuration @@ -159,11 +159,10 @@ that is set in the [TRAJ] section of the INI file. * 'halui.mdi-command-__' (bool, in) - halui will try to send the MDI command defined in the INI. __ is a two digit number starting at 00. + - If the command succeeds then it will place LinuxCNC in the MDI mode and then back to Manual mode. + If no [HALUI]MDI_COMMAND variables are set in the ini file, no halui.mdi-command- pins will be exported by halui. * 'halui.halui-mdi-is-running' (bool, out) - execution status of MDI commands sent by halui. The status is active - even during mode switching. + from the press until the command finishes. If no [HALUI]MDI_COMMAND variables are set in the ini file, this pins will not be exported by halui. === Joint @@ -242,15 +241,15 @@ _L_ = axis letter (xyzabcuvw) === Mode -* 'halui.mode.auto' (bool, in) - pin for requesting auto mode -* 'halui.mode.is-auto' (bool, out) - indicates auto mode is on +* 'halui.mode.auto' (bool, in) - does nothing, the task mode follows what task runs and cannot be set +* 'halui.mode.is-auto' (bool, out) - indicates a program runs, or is paused * 'halui.mode.is-joint' (bool, out) - indicates joint by joint jog mode is on -* 'halui.mode.is-manual' (bool, out) - indicates manual mode is on -* 'halui.mode.is-mdi' (bool, out) - indicates MDI mode is on +* 'halui.mode.is-manual' (bool, out) - indicates task is idle: neither a program nor MDI runs +* 'halui.mode.is-mdi' (bool, out) - indicates MDI commands run * 'halui.mode.is-teleop' (bool, out) - indicates coordinated jog mode is on * 'halui.mode.joint' (bool, in) - pin for requesting joint by joint jog mode -* 'halui.mode.manual' (bool, in) - pin for requesting manual mode -* 'halui.mode.mdi' (bool, in) - pin for requesting MDI mode +* 'halui.mode.manual' (bool, in) - does nothing, see 'halui.mode.auto' +* 'halui.mode.mdi' (bool, in) - does nothing, see 'halui.mode.auto' * 'halui.mode.teleop' (bool, in) - pin for requesting coordinated jog mode === Program diff --git a/docs/src/man/man1/halui.1.adoc b/docs/src/man/man1/halui.1.adoc index 861abcd04c0..2ba190417c4 100644 --- a/docs/src/man/man1/halui.1.adoc +++ b/docs/src/man/man1/halui.1.adoc @@ -143,23 +143,23 @@ contact) connect the physical button to a HAL debounce filter first. === Mode *halui.mode.auto* bool in:: - pin for requesting auto mode + does nothing. The task mode follows what task runs and cannot be set. *halui.mode.is-auto* bool out:: - pin for auto mode is on + a program runs, or is paused *halui.mode.is-joint* bool out:: pin showing joint by joint jog mode is on *halui.mode.is-manual* bool out:: - pin for manual mode is on + task is idle: neither a program nor MDI runs *halui.mode.is-mdi* bool out:: - pin for MDI mode is on + MDI commands run *halui.mode.is-teleop* bool out:: pin showing coordinated jog mode is on *halui.mode.joint* bool in:: pin for requesting joint by joint jog mode *halui.mode.manual* bool in:: - pin for requesting manual mode + does nothing, see *halui.mode.auto* *halui.mode.mdi* bool in:: - pin for requesting MDI mode + does nothing, see *halui.mode.auto* *halui.mode.teleop* bool in:: pin for requesting coordinated jog mode diff --git a/docs/src/man/man1/linuxcncrsh.1.adoc b/docs/src/man/man1/linuxcncrsh.1.adoc index 1278e8d9923..b39c15e3a78 100644 --- a/docs/src/man/man1/linuxcncrsh.1.adoc +++ b/docs/src/man/man1/linuxcncrsh.1.adoc @@ -432,8 +432,12 @@ Subcommands for 'GET' and 'SET' are: *get mode*:: *set mode* {manual|auto|mdi}:: - With get, returns the current machine mode. - With set, sets the machine mode as specified. + With get, returns AUTO while a program runs, MDI while MDI commands + run and, while the machine is idle, the mode this connection last set + (MANUAL until then). + With set, sets the mode this connection shows. It is not sent to the + machine: task's mode reports what runs and cannot be set, and task + accepts jogs, MDI commands and program runs whatever mode is set. *get open* *set open* __:: @@ -491,7 +495,7 @@ Subcommands for 'GET' and 'SET' are: Additionally, many sanity and boundary condition checks are performed that are hard to duplicate outside of the canon interface. + - The 'SET PROBE' command can only be run in MDI mode (use 'SET MODE MDI'). + 'SET PROBE' is sent as an MDI command, so it is refused while a program runs. Additionally, 'SET PROBE' never returns a 'SET PROBE NAK' if the probe fails to make contact. However, an error is produced (use 'GET ERROR') and the 'GET PROBE_TRIPPED' returns 'NO' in that case. diff --git a/src/emc/task/emctask.cc b/src/emc/task/emctask.cc index 2b4490aca48..682ffb7ff40 100644 --- a/src/emc/task/emctask.cc +++ b/src/emc/task/emctask.cc @@ -53,8 +53,7 @@ static_assert(EMC_MAX_CALL_STACK >= INTERP_SUB_ROUTINE_LEVELS, #define MAX_M_DIRS (USER_DEFINED_FUNCTION_MAX_DIRS+1) //note:the +1 is for the PROGRAM_PREFIX or default directory==nc_files -/* flag for how we want to interpret traj coord mode, as mdi or auto */ -static EMC_TASK_MODE mdiOrAuto = EMC_TASK_MODE::AUTO; +TaskRun taskRun = TaskRun::NONE; InterpBase *pinterp=NULL; #define interp (*pinterp) @@ -222,7 +221,7 @@ int emcTaskStateRestore() { int res = 0; // Do NOT restore on MDI command - if (emcStatus->task.mode == EMC_TASK_MODE::AUTO) { + if (taskRun == TaskRun::PROGRAM) { // Validity of state tag checked within restore function res = pinterp->restore_from_tag(emcStatus->motion.traj.tag); } @@ -273,50 +272,6 @@ int emcTaskAbort() return 0; } -int emcTaskSetMode(EMC_TASK_MODE mode) -{ - int retval = 0; - - if (jogging_is_active()) { - log_info("Ignoring task mode change while jogging"); - return 0; - } - - switch (mode) { - case EMC_TASK_MODE::MANUAL: - // go to manual mode - if (all_homed()) { - emcTrajSetMode(EMC_TRAJ_MODE::TELEOP); - } else { - emcTrajSetMode(EMC_TRAJ_MODE::FREE); - } - mdiOrAuto = EMC_TASK_MODE::AUTO; // we'll default back to here - break; - - case EMC_TASK_MODE::MDI: - // go to mdi mode - emcTrajSetMode(EMC_TRAJ_MODE::COORD); - emcTaskAbort(); - emcTaskPlanSynch(); - mdiOrAuto = EMC_TASK_MODE::MDI; - break; - - case EMC_TASK_MODE::AUTO: - // go to auto mode - emcTrajSetMode(EMC_TRAJ_MODE::COORD); - emcTaskAbort(); - emcTaskPlanSynch(); - mdiOrAuto = EMC_TASK_MODE::AUTO; - break; - - default: - retval = -1; - break; - } - - return retval; -} - int emcTaskSetState(EMC_TASK_STATE state) { int t; @@ -381,27 +336,25 @@ int emcTaskSetState(EMC_TASK_STATE state) /* determineMode() - Looks at mode of subsystems, and returns associated mode + The task mode is not set by anyone, it reports what task is running: - Depends on traj mode, and mdiOrAuto flag - - traj mode mdiOrAuto task mode - --------- --------- --------- - FREE XXX MANUAL - TELEOP XXX MANUAL - COORD MDI MDI - COORD AUTO AUTO + taskRun task mode + ------- --------- + NONE MANUAL + PROGRAM AUTO + MDI MDI */ EMC_TASK_MODE determineMode() { - if (emcStatus->motion.traj.mode == EMC_TRAJ_MODE::FREE) { - return EMC_TASK_MODE::MANUAL; - } - if (emcStatus->motion.traj.mode == EMC_TRAJ_MODE::TELEOP) { - return EMC_TASK_MODE::MANUAL; - } - // for EMC_TRAJ_MODE::COORD - return mdiOrAuto; + switch (taskRun) { + case TaskRun::PROGRAM: + return EMC_TASK_MODE::AUTO; + case TaskRun::MDI: + return EMC_TASK_MODE::MDI; + case TaskRun::NONE: + break; + } + return EMC_TASK_MODE::MANUAL; } /* @@ -753,7 +706,7 @@ int emcTaskUpdate(EMC_TASK_STAT * stat) } // If we get an error from trying to unpack from the motion state, always // use interp's internal state, so the active state is never out of date - if (emcStatus->task.mode != EMC_TASK_MODE::AUTO || + if (taskRun != TaskRun::PROGRAM || res_state == INTERP_ERROR) { interp.active_g_codes(&stat->activeGCodes[0]); interp.active_m_codes(&stat->activeMCodes[0]); diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 41348563047..5d2147d276b 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -401,7 +401,7 @@ int emcSystemCmd(char *s) // MDI while running in TELEOP/COORD would otherwise silently stall. We dip // motion into FREE for the duration and restore whatever mode it was in // before, invisibly to the task-level MDI/AUTO/MANUAL state -// (mdiOrAuto is untouched) -- same principle as multichannel-DESIGN.txt's +// (taskRun is untouched) -- same principle as multichannel-DESIGN.txt's // "channel sessions do NOT flip the global teleop mode" for the analogous // per-channel-homing problem. static int homingWaitJoint = -1; // joint (-1 = all) we're waiting on @@ -709,25 +709,127 @@ void readahead_waiting(void) } } +// Runs. Task is idle (taskRun NONE) until an MDI command or a program +// starts a run, and idle again once the run is over. Nobody sets a task +// mode; the one reported is derived from taskRun (determineMode()). +// +// Motion follows: while idle it is in free or teleop mode, so jogs, wheel +// jogs and homing work; a run puts it in coordinated mode. Motion only +// makes that switch once in position, so a run waits for it before the +// first command leaves interp_list (see coordWaiting in emcTaskExecute()). + +// Set by taskRunStart(), cleared once motion is in coordinated mode. +static bool coordWaiting = false; +static double coordWaitStart = 0.0; +static const double COORD_WAIT_TIMEOUT = 5.0; + +// The motion mode and homing at the start of a run, to go back to, and +// the mode the last run went back to. +static EMC_TRAJ_MODE runPriorMode = EMC_TRAJ_MODE::FREE; +static bool runPriorHomed = false; +static EMC_TRAJ_MODE idleMode = EMC_TRAJ_MODE::FREE; + +// Leave idle for a run. Returns -1, with an operator error, if the run may +// not start. +static int taskRunStart(TaskRun run) +{ + const bool mdi = run == TaskRun::MDI; + + if (!all_homed() && !no_force_homing) { //!no_force_homing = force homing before MDI and Auto + emcOperatorError(mdi ? _("Can't issue MDI command when not homed") + : _("Can't run a program when not homed")); + return -1; + } + if (!mdi && emcStatus->task.file[0] == 0) { + // a step would pause on nothing and never finish + emcOperatorError(_("Can't run a program: no program is open")); + return -1; + } + if (jogging_is_active()) { + emcOperatorError(mdi ? _("Can't issue MDI command while jogging") + : _("Can't run a program while jogging")); + return -1; + } + + // Right after a run the status can still show coordinated mode while + // motion is on its way back to idleMode, so send the switch anyway. + runPriorMode = emcStatus->motion.traj.mode; + if (runPriorMode == EMC_TRAJ_MODE::COORD) { + runPriorMode = idleMode; + } + runPriorHomed = all_homed(); + if (emcTrajSetMode(EMC_TRAJ_MODE::COORD) != 0) { + emcOperatorError(_("Can't switch motion to coordinated mode")); + return -1; + } + coordWaiting = true; + coordWaitStart = etime(); + + if (mdi && taskplanopen) { + // what a switch to MDI mode did: MDI does not run with the + // program open; PLAN_RUN opens it again + emcTaskPlanClose(); + } + // the machine may have moved since the interpreter last looked + emcTaskPlanSynch(); + + taskRun = run; + return 0; +} + +// Back to idle: the motion mode the run started from, or, if homing +// changed in between, world mode when homed and joint mode otherwise. +static void taskRunEnd() +{ + taskRun = TaskRun::NONE; + coordWaiting = false; + + EMC_TRAJ_MODE mode = all_homed() ? EMC_TRAJ_MODE::TELEOP : EMC_TRAJ_MODE::FREE; + if (runPriorHomed == (bool)all_homed()) { + mode = runPriorMode; + } + idleMode = mode; + emcTrajSetMode(mode); +} + +// End the run once the interpreter is idle: a program that ran to its end, +// an MDI command that finished with nothing queued behind it, or anything +// aborted. What an abort leaves on interp_list (the interpreter synch) runs +// while idle. +static void taskRunCheckDone() +{ + if (taskRun == TaskRun::NONE + || emcStatus->task.interpState != EMC_TASK_INTERP::IDLE) { + return; + } + if (taskRun == TaskRun::MDI + && (mdi_execute_queue.len() != 0 || mdi_execute_wait || mdi_execute_next)) { + return; + } + taskRunEnd(); +} + // The situation the planner decides by: the machine off (or in E-stop), or -// on and in one of the modes, Auto split by what the interpreter does. +// on and idle, running MDI, or running a program, split by what the +// interpreter does. A program whose interpreter is idle was aborted in +// this cycle; taskRunCheckDone() ends the run in the next one. struct Situation { - bool on, manual, mdi, autoIdle, autoReading, autoPaused, autoWaiting; + bool on, idle, mdi, reading, waiting, paused, ending; }; static Situation situation() { const EMC_TASK_STAT &task = emcStatus->task; const bool on = task.state == EMC_TASK_STATE::ON; - const bool autoMode = on && task.mode == EMC_TASK_MODE::AUTO; + const bool program = on && taskRun == TaskRun::PROGRAM; return { on, - on && task.mode == EMC_TASK_MODE::MANUAL, - on && task.mode == EMC_TASK_MODE::MDI, - autoMode && task.interpState == EMC_TASK_INTERP::IDLE, - autoMode && task.interpState == EMC_TASK_INTERP::READING, - autoMode && task.interpState == EMC_TASK_INTERP::PAUSED, - autoMode && task.interpState == EMC_TASK_INTERP::WAITING, + on && taskRun == TaskRun::NONE, + on && taskRun == TaskRun::MDI, + program && task.interpState == EMC_TASK_INTERP::READING, + program && task.interpState == EMC_TASK_INTERP::WAITING, + program && task.interpState == EMC_TASK_INTERP::PAUSED, + program && task.interpState == EMC_TASK_INTERP::IDLE, }; } @@ -735,13 +837,13 @@ static Situation situation() isImmediate() The commands emcTaskPlan() passes straight to emcTaskIssueCommand(), by - the state, mode and interpreter state task is in. Everything else is - handled, or refused, by the planner's table for that situation. + what task is doing. Everything else is handled, or refused, by the table + for the state task is in. */ static bool isImmediate(NMLTYPE type, const Situation &s) { - const bool on = s.on, manual = s.manual, mdi = s.mdi, autoIdle = s.autoIdle, - autoPaused = s.autoPaused, autoWaiting = s.autoWaiting; + const bool on = s.on; + const bool program = on && taskRun == TaskRun::PROGRAM; switch (type) { // in any state @@ -754,7 +856,6 @@ static bool isImmediate(NMLTYPE type, const Situation &s) case EMC_TRAJ_SET_FO_ENABLE_TYPE: case EMC_TRAJ_SET_FH_ENABLE_TYPE: case EMC_TRAJ_SET_SO_ENABLE_TYPE: - case EMC_TASK_SET_MODE_TYPE: case EMC_TASK_SET_STATE_TYPE: case EMC_TASK_ABORT_TYPE: case EMC_TASK_PLAN_SET_OPTIONAL_STOP_TYPE: @@ -771,13 +872,13 @@ static bool isImmediate(NMLTYPE type, const Situation &s) return !on; // once the machine is on, whatever runs - case EMC_SPINDLE_INCREASE_TYPE: - case EMC_SPINDLE_DECREASE_TYPE: - case EMC_SPINDLE_CONSTANT_TYPE: case EMC_COOLANT_MIST_ON_TYPE: case EMC_COOLANT_MIST_OFF_TYPE: case EMC_COOLANT_FLOOD_ON_TYPE: case EMC_COOLANT_FLOOD_OFF_TYPE: + case EMC_SPINDLE_INCREASE_TYPE: + case EMC_SPINDLE_DECREASE_TYPE: + case EMC_SPINDLE_CONSTANT_TYPE: case EMC_TASK_PLAN_PAUSE_TYPE: case EMC_TASK_PLAN_REVERSE_TYPE: case EMC_TASK_PLAN_FORWARD_TYPE: @@ -785,52 +886,29 @@ static bool isImmediate(NMLTYPE type, const Situation &s) case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: return on; - // once the machine is on, unless a program is reading or waiting + // once the machine is on, unless a program runs and is not paused case EMC_SPINDLE_SPEED_TYPE: + case EMC_SPINDLE_ORIENT_TYPE: + case EMC_SPINDLE_WAIT_ORIENT_COMPLETE_TYPE: case EMC_SPINDLE_ON_TYPE: case EMC_SPINDLE_OFF_TYPE: case EMC_SPINDLE_BRAKE_RELEASE_TYPE: case EMC_SPINDLE_BRAKE_ENGAGE_TYPE: - return manual || mdi || autoIdle || autoPaused; - - // the same, but not in Manual - case EMC_SPINDLE_ORIENT_TYPE: - case EMC_SPINDLE_WAIT_ORIENT_COMPLETE_TYPE: - return mdi || autoIdle || autoPaused; + return on && (!program || emcStatus->task.interpState == EMC_TASK_INTERP::PAUSED); // unless a program runs case EMC_TASK_PLAN_INIT_TYPE: case EMC_TASK_PLAN_OPEN_TYPE: case EMC_TASK_PLAN_CLOSE_TYPE: - return !on || manual || mdi || autoIdle; - - // not in Auto case EMC_TASK_PLAN_SYNCH_TYPE: case EMC_MOTION_SET_DOUT_TYPE: case EMC_MOTION_SET_AOUT_TYPE: case EMC_MOTION_ADAPTIVE_TYPE: - return !on || manual || mdi; - - // Auto only - case EMC_TASK_PLAN_RUN_TYPE: - return autoIdle; - case EMC_TASK_PLAN_EXECUTE_TYPE: - return autoIdle || autoPaused || autoWaiting; + return !program; - // Manual only - case EMC_JOINT_SET_MAX_POSITION_LIMIT_TYPE: - case EMC_JOINT_SET_MIN_POSITION_LIMIT_TYPE: - case EMC_JOINT_HOME_TYPE: - case EMC_JOINT_OVERRIDE_LIMITS_TYPE: - return manual; - - // jogs, and in Auto only while the interpreter is idle - case EMC_JOG_CONT_TYPE: - case EMC_JOG_INCR_TYPE: - case EMC_JOG_STOP_TYPE: - return manual || mdi || autoIdle; + // unless a program or MDI runs case EMC_TRAJ_SET_TELEOP_ENABLE_TYPE: - return !on || manual || mdi || autoIdle; + return !on || taskRun == TaskRun::NONE; } return false; } @@ -849,8 +927,6 @@ static void queueToolCommand(NMLmsg *cmd) case EMC_TOOL_SET_NUMBER_TYPE: emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); break; - default: - return; } // signify no more reading emcTaskPlanSetWait(); @@ -858,6 +934,19 @@ static void queueToolCommand(NMLmsg *cmd) emcTaskQueueTaskPlanSynchCmd(); } +// Start a run from idle with cmd, see taskRunStart(). +static int taskRunIssue(TaskRun run, NMLmsg *cmd) +{ + int retval = taskRunStart(run); + if (retval == 0) { + retval = emcTaskIssueCommand(cmd); + if (retval != 0) { + taskRunEnd(); + } + } + return retval; +} + // The coolant as it was when a program or MDI paused: resume puts it back, // as motion does with the spindles (pause_restore_spindles()). static bool pauseCoolantSaved = false; @@ -930,32 +1019,52 @@ static bool planSpecial(NMLmsg *cmd, const Situation &s, int &retval) { switch (cmd->_type) { case EMC_JOINT_OVERRIDE_LIMITS_TYPE: - // with the machine off: in manual mode only, ignored otherwise - if (s.on) { + // with the machine off: only while nothing runs, ignored otherwise + if (s.idle || (!s.on && taskRun == TaskRun::NONE)) { + retval = emcTaskIssueCommand(cmd); + } + return s.idle || !s.on; + + // homing and the soft limits, while nothing runs + case EMC_JOINT_SET_MAX_POSITION_LIMIT_TYPE: + case EMC_JOINT_SET_MIN_POSITION_LIMIT_TYPE: + case EMC_JOINT_HOME_TYPE: + if (!s.idle) { return false; } - if (emcStatus->task.mode == EMC_TASK_MODE::MANUAL) { + retval = emcTaskIssueCommand(cmd); + return true; + + // jogs, while nothing runs or what runs is paused + case EMC_JOG_CONT_TYPE: + case EMC_JOG_INCR_TYPE: + case EMC_JOG_STOP_TYPE: + if (s.idle) { retval = emcTaskIssueCommand(cmd); + return true; } - return true; + if (s.paused + || (s.mdi && (emcStatus->task.interpState == EMC_TASK_INTERP::PAUSED + || cmd->_type == EMC_JOG_STOP_TYPE))) { + retval = pausedJog(cmd); + return true; + } + return false; case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: case EMC_TOOL_SET_OFFSET_TYPE: case EMC_TOOL_SET_NUMBER_TYPE: - if (!s.on || s.manual - || ((s.autoIdle || s.mdi) && cmd->_type != EMC_TOOL_SET_NUMBER_TYPE)) { + if (!s.on || s.idle + || (s.mdi && cmd->_type != EMC_TOOL_SET_NUMBER_TYPE)) { queueToolCommand(cmd); return true; } return false; + // the commands that start a run case EMC_TASK_PLAN_EXECUTE_TYPE: - if (s.manual) { - // resynch the interpreter, since we may have moved - // externally - emcTaskQueueTaskPlanSynchCmd(); - // and now call for interpreter execute - retval = emcTaskIssueCommand(cmd); + if (s.idle) { + retval = taskRunIssue(TaskRun::MDI, cmd); return true; } if (s.mdi) { @@ -979,33 +1088,20 @@ static bool planSpecial(NMLmsg *cmd, const Situation &s, int &retval) } return false; - case EMC_JOG_CONT_TYPE: - case EMC_JOG_INCR_TYPE: - case EMC_JOG_STOP_TYPE: - if (s.autoPaused - || (s.mdi && emcStatus->task.interpState == EMC_TASK_INTERP::PAUSED)) { - retval = pausedJog(cmd); - return true; - } - return false; - case EMC_TASK_PLAN_RUN_TYPE: - if (!s.manual) { + if (!s.idle) { return false; } - if (GET_EXTERNAL_OFFSET_APPLIED()) { - // err here, fewer err reports - retval = -1; - } + retval = taskRunIssue(TaskRun::PROGRAM, cmd); return true; case EMC_TASK_PLAN_STEP_TYPE: - if (s.autoIdle) { + if (s.idle) { // handles case where first action is to step the program taskPlanRunCmd.line = 0; // run from start /*! \todo FIXME-- can have GUI set this; send a run instead of a step */ - retval = emcTaskIssueCommand(&taskPlanRunCmd); + retval = taskRunIssue(TaskRun::PROGRAM, &taskPlanRunCmd); if (retval != 0) { return true; } @@ -1017,13 +1113,13 @@ static bool planSpecial(NMLmsg *cmd, const Situation &s, int &retval) emcStatus->task.task_paused = 1; return true; } - if (s.autoReading || s.autoWaiting) { + if (s.reading || s.waiting) { emcStatus->motion.traj.single_stepping = 1; stepping = 1; // set stepping mode in case it's not steppingWait = 0; // clear the wait return true; } - if (s.autoPaused) { + if (s.paused) { emcStatus->motion.traj.single_stepping = 1; stepping = 1; steppingWait = 0; @@ -1048,25 +1144,22 @@ static void refuse(NMLTYPE type, const Situation &s) const char *name = emc_symbol_lookup(type); if (!s.on) { emcOperatorError(_("command (%s) cannot be executed until the machine is out of E-stop and turned on"), name); - } else if (s.manual) { - emcOperatorError(_("can't do that (%s:%d) in manual mode"), name, (int) type); + } else if (s.idle) { + emcOperatorError(_("can't do that (%s:%d) while idle"), name, (int) type); } else if (s.mdi) { - emcOperatorError(_("can't do that (%s:%d) in MDI mode"), name, (int) type); - } else if (s.autoIdle) { - emcOperatorError(_("can't do that (%s) in auto mode with the interpreter idle"), name); - } else if (s.autoReading) { - emcOperatorError(_("can't do that (%s) in auto mode with the interpreter reading"), name); - } else if (s.autoPaused) { - emcOperatorError(_("can't do that (%s) in auto mode with the interpreter paused"), name); - } else if (s.autoWaiting) { - emcOperatorError(_("can't do that (%s) in auto mode with the interpreter waiting"), name); + emcOperatorError(_("can't do that (%s) while MDI is running"), name); + } else if (s.reading || s.waiting) { + emcOperatorError(_("can't do that (%s) while a program runs, with the interpreter %s"), name, + s.reading ? "reading" : "waiting"); + } else if (s.paused) { + emcOperatorError(_("can't do that (%s) while a program runs, with the interpreter paused"), name); } } /* emcTaskPlan() - Planner for NC code or manual mode operations + Planner for NC code or manual operations cmd is the new command to handle this cycle, or NULL if there is none. It is only used for the duration of the call. @@ -1077,20 +1170,29 @@ static void refuse(NMLTYPE type, const Situation &s) static int emcTaskPlan(NMLmsg *cmd) { const NMLTYPE type = cmd ? cmd->_type : 0; - const Situation s = situation(); int retval = 0; + // Always display messages. A mode change is accepted in any state and + // does nothing, see EMC_TASK_SET_MODE_TYPE in emcTaskIssueCommand(). switch (type) { - case 0: - case EMC_NULL_TYPE: - // no command - break; - - // Always display messages case EMC_OPERATOR_ERROR_TYPE: case EMC_OPERATOR_TEXT_TYPE: case EMC_OPERATOR_DISPLAY_TYPE: + case EMC_TASK_SET_MODE_TYPE: return emcTaskIssueCommand(cmd); + } + + taskRunCheckDone(); + const Situation s = situation(); + if (s.ending) { + return 0; + } + + switch (type) { + case 0: + case EMC_NULL_TYPE: + // no command + break; default: if (planSpecial(cmd, s, retval)) { @@ -1098,7 +1200,7 @@ static int emcTaskPlan(NMLmsg *cmd) } if (isImmediate(type, s)) { retval = emcTaskIssueCommand(cmd); - if (s.autoReading) { + if (s.reading) { // no readahead this cycle return retval; } @@ -1109,9 +1211,9 @@ static int emcTaskPlan(NMLmsg *cmd) break; } - if (s.autoReading) { + if (s.reading) { readahead_reading(); - } else if (s.autoWaiting) { + } else if (s.waiting) { readahead_waiting(); } else if (s.mdi) { mdi_execute_hook(); @@ -1204,9 +1306,8 @@ static int emcTaskIssueCommand(NMLmsg * cmd) // invalid joint number) -- homing will never start, so the // WAITING_FOR_HOMING poll below would never run to undo the // FREE-mode dip either. Undo it here instead, or traj.mode - // (and therefore task.mode, which determineMode() derives - // from it) stays stuck at FREE/MANUAL until the operator - // manually cycles mode again. + // stays stuck at FREE and the rest of the program or MDI + // command cannot move. homingWaiting = false; if (homingPriorMode != EMC_TRAJ_MODE::FREE) { emcTrajSetMode(homingPriorMode); @@ -1613,55 +1714,11 @@ static int emcTaskIssueCommand(NMLmsg * cmd) // mode and state commands - case EMC_TASK_SET_MODE_TYPE: { - auto mode_msg = reinterpret_cast(cmd); - if (emcStatus->task.mode == EMC_TASK_MODE::AUTO && - emcStatus->task.interpState != EMC_TASK_INTERP::IDLE && - mode_msg->mode != EMC_TASK_MODE::AUTO) { - emcOperatorError(_("Can't switch mode while mode is AUTO and interpreter is not IDLE")); - } else { // we can honour the modeswitch - if (mode_msg->mode == EMC_TASK_MODE::MANUAL && - emcStatus->task.mode != EMC_TASK_MODE::MANUAL) { - // leaving auto or mdi mode for manual - - /*! \todo FIXME-- duplicate code for abort, - also near end of main, when aborting on subordinate errors, - and in emcTaskExecute() */ - - // abort motion - emcTaskAbort(); - mdi_execute_abort(); - - // without emcTaskPlanClose(), a new run command resumes at - // aborted line-- feature that may be considered later - { - int was_open = taskplanopen; - emcTaskPlanClose(); - if (emc_debug & EMC_DEBUG_INTERP && was_open) { - log_info("emcTaskPlanClose() called at {}:{}\n", - __FILE__, __LINE__); - } - } - - // clear out the pending command - emcTaskCommand = NULL; - interp_list.clear(); - emcStatus->task.currentLine = 0; - - // clear out the interpreter state - emcStatus->task.interpState = EMC_TASK_INTERP::IDLE; - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcStatus->motion.traj.single_stepping = 0; - stepping = 0; - steppingWait = 0; - - // now queue up command to resynch interpreter - emcTaskQueueTaskPlanSynchCmd(); - } - retval = emcTaskSetMode(mode_msg->mode); - } + case EMC_TASK_SET_MODE_TYPE: + // The task mode reports what task is running (determineMode()) and + // cannot be set. Accept the request so existing clients keep working. + retval = 0; break; - } case EMC_TASK_SET_STATE_TYPE: retval = emcTaskSetState(reinterpret_cast(cmd)->state); @@ -1751,16 +1808,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) stepping = 0; steppingWait = 0; auto execute_msg = reinterpret_cast(cmd); - if (!all_homed() && !no_force_homing) { //!no_force_homing = force homing before MDI - emcOperatorError(_("Can't issue MDI command when not homed")); - retval = -1; - break; - } - if (emcStatus->task.mode != EMC_TASK_MODE::MDI) { - emcOperatorError(_("Must be in MDI mode to issue MDI command")); - retval = -1; - break; - } + // taskRunStart() has checked homing // track interpState also during MDI - it might be an oword sub call emcStatus->task.interpState = EMC_TASK_INTERP::READING; @@ -1775,26 +1823,22 @@ static int emcTaskIssueCommand(NMLmsg * cmd) } int level = emcTaskPlanLevel(); - if (emcStatus->task.mode == EMC_TASK_MODE::MDI) { - if (mdi_execute_level < 0) - mdi_execute_level = level; - } + if (mdi_execute_level < 0) + mdi_execute_level = level; execRetval = emcTaskPlanExecute(command, 0); level = emcTaskPlanLevel(); - if (emcStatus->task.mode == EMC_TASK_MODE::MDI) { - if (mdi_execute_level == level) { - mdi_execute_level = -1; - } else if (level > 0) { - // Still insude call. Need another execute(0) call - // but only if we didn't encounter an error - if (execRetval == INTERP_ERROR) { - mdi_execute_next = 0; - } else { - mdi_execute_next = 1; - } + if (mdi_execute_level == level) { + mdi_execute_level = -1; + } else if (level > 0) { + // Still insude call. Need another execute(0) call + // but only if we didn't encounter an error + if (execRetval == INTERP_ERROR) { + mdi_execute_next = 0; + } else { + mdi_execute_next = 1; } } switch (execRetval) { @@ -1839,11 +1883,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) } case EMC_TASK_PLAN_RUN_TYPE: - if (!all_homed() && !no_force_homing) { //!no_force_homing = force homing before Auto - emcOperatorError(_("Can't run a program when not homed")); - retval = -1; - break; - } + // taskRunStart() has checked homing emcStatus->motion.traj.single_stepping = 0; stepping = 0; steppingWait = 0; @@ -2136,6 +2176,20 @@ static int emcTaskExecute(void) if (steppingHolds()) { break; } + if (coordWaiting) { + // a run has just started; see taskRunStart() + if (emcStatus->motion.traj.mode == EMC_TRAJ_MODE::COORD) { + coordWaiting = false; + } else { + if (etime() - coordWaitStart > COORD_WAIT_TIMEOUT) { + coordWaiting = false; + emcOperatorError(_("Motion did not switch to coordinated mode")); + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + retval = -1; + } + break; + } + } if (!emcStatus->motion.traj.queueFull && emcStatus->task.interpState != EMC_TASK_INTERP::PAUSED) { if (NULL == emcTaskCommand) { diff --git a/src/emc/task/task.hh b/src/emc/task/task.hh index 6503a131f53..fae4067fb91 100644 --- a/src/emc/task/task.hh +++ b/src/emc/task/task.hh @@ -32,11 +32,19 @@ extern int emcTaskOnce(const char *inifile, EMC_IO_STAT &emcioStatus); int all_homed(void); bool jogging_is_active(void); +// What task is running. The task mode reported in the status is derived +// from it (determineMode()); nothing sets the mode directly. +enum class TaskRun { + NONE, // idle: jogs, homing, MDI and program starts are accepted + PROGRAM, // a program run, from PLAN_RUN or PLAN_STEP + MDI, // MDI commands, from PLAN_EXECUTE +}; +extern TaskRun taskRun; + int emcTaskInit(); int emcTaskHalt(); int emcTaskStateRestore(); int emcTaskAbort(); -int emcTaskSetMode(EMC_TASK_MODE mode); int emcTaskSetState(EMC_TASK_STATE state); int emcTaskPlanInit(); int emcTaskPlanSetWait(); diff --git a/src/emc/usr_intf/axis/extensions/emcmodule.cc b/src/emc/usr_intf/axis/extensions/emcmodule.cc index 245589195ee..24f187cfd1b 100644 --- a/src/emc/usr_intf/axis/extensions/emcmodule.cc +++ b/src/emc/usr_intf/axis/extensions/emcmodule.cc @@ -1134,7 +1134,6 @@ static PyMemberDef Stat_members[] = { { "state", T_INT, O(status), READONLY, NULL}, // task - { "task_mode", T_INT, O(task.mode), READONLY, NULL}, { "task_state", T_INT, O(task.state), READONLY, "Current Task state. Possible values:\n" " STATE_ESTOP: E-Stop is active.\n" @@ -1386,6 +1385,21 @@ static PyObject *Stat_homed(pyStatChannel *s, void *) { return res; } +// The page a user interface shows. Task's mode cannot be set: it reports +// MDI or Auto while one runs and Manual while idle. mode() records the +// page this process asked for instead, and task_mode returns it while task +// is idle, so each user interface keeps its own page and the ones that +// follow task_mode to switch pages keep working. +static EMC_TASK_MODE view_mode = EMC_TASK_MODE::MANUAL; + +static PyObject *Stat_task_mode(pyStatChannel *s, void *) { + EMC_TASK_MODE mode = s->status.task.mode; + if (mode == EMC_TASK_MODE::MANUAL) { + mode = view_mode; + } + return PyLong_FromLong((long)mode); +} + static PyObject *Stat_ain(pyStatChannel *s, void *) { return double_array(s->status.motion.analog_input, EMCMOT_MAX_AIO); } @@ -1610,6 +1624,7 @@ static PyGetSetDef Stat_getsetlist[] = { {(char*)"actual_position", (getter)Stat_actual, NULL, NULL, NULL}, {(char*)"pause_offset", (getter)Stat_pause_offset, NULL, NULL, NULL}, {(char*)"ain", (getter)Stat_ain, NULL, NULL, NULL}, + {(char*)"task_mode", (getter)Stat_task_mode, NULL, NULL, NULL}, {(char*)"aout", (getter)Stat_aout, NULL, NULL, NULL}, {(char*)"joint", (getter)Stat_joint, NULL, NULL, NULL}, {(char*)"axis", (getter)Stat_axis, NULL, NULL, NULL}, @@ -1784,10 +1799,11 @@ static PyObject *optional_stop(pyCommandChannel *s, PyObject *o) { return Py_None; } -static PyObject *mode(pyCommandChannel *s, PyObject *o) { - EMC_TASK_SET_MODE m; - if(!PyArg_ParseTuple(o, "i", &m.mode)) return NULL; - switch(m.mode) { +// Nothing goes to task, see view_mode. +static PyObject *mode(pyCommandChannel * /*s*/, PyObject *o) { + EMC_TASK_MODE m; + if(!PyArg_ParseTuple(o, "i", &m)) return NULL; + switch(m) { case EMC_TASK_MODE::MDI: case EMC_TASK_MODE::MANUAL: case EMC_TASK_MODE::AUTO: @@ -1796,7 +1812,7 @@ static PyObject *mode(pyCommandChannel *s, PyObject *o) { PyErr_Format(PyExc_ValueError,"Mode should be MODE_MDI, MODE_MANUAL, or MODE_AUTO"); return NULL; } - emcSendCommand(s, m); + view_mode = m; Py_INCREF(Py_None); return Py_None; } diff --git a/src/emc/usr_intf/axis/scripts/axis.py b/src/emc/usr_intf/axis/scripts/axis.py index 4ba5ef9eeb7..d4fd019696a 100755 --- a/src/emc/usr_intf/axis/scripts/axis.py +++ b/src/emc/usr_intf/axis/scripts/axis.py @@ -747,7 +747,6 @@ def start(self): self.stat = linuxcnc.stat() except linuxcnc.error: return False - self.last_task_mode = self.stat.task_mode self.last_motion_mode = self.stat.motion_mode def C(s): a = o.colors[s + "_alpha"] @@ -845,30 +844,10 @@ def update(self): continuous_jog_in_progress = 0 cjogindices = [] - if ( (self.stat.motion_mode == linuxcnc.TRAJ_MODE_COORD) - and (self.stat.task_mode == linuxcnc.MODE_MANUAL) - ): - set_motion_teleop(1) if ( (self.stat.motion_mode == linuxcnc.TRAJ_MODE_TELEOP) and not vars.teleop_mode.get() ): vars.teleop_mode.set(1) - # With joints_axes support and jogging while mdi - # (ref: emctaskmain.cc:allow_while_idle_type()) - # behavior is better without changing tabs upon detecting - # a task_mode change. - # Restore behavior with this local var: enable_tab_change - enable_tab_change = False - if ( enable_tab_change - and (self.stat.task_mode != self.last_task_mode)): - if (self.stat.task_mode == linuxcnc.MODE_MANUAL): - root_window.tk.eval(pane_top + ".tabs raise manual") - if (self.stat.task_mode == linuxcnc.MODE_MDI): - root_window.tk.eval(pane_top + ".tabs raise mdi") - if (self.stat.task_mode == linuxcnc.MODE_AUTO): - # not sure if anything needs to be done for this - pass - self.last_task_mode = self.stat.task_mode self.after = self.win.after(update_ms, self.update) diff --git a/src/emc/usr_intf/emcrsh.cc b/src/emc/usr_intf/emcrsh.cc index 88550e56177..500a05f986c 100644 --- a/src/emc/usr_intf/emcrsh.cc +++ b/src/emc/usr_intf/emcrsh.cc @@ -172,6 +172,7 @@ typedef struct { std::string version; // Client's version std::string progname; // Filename of (g-code) program EMC_WAIT_TYPE waitmode; // Local to the connection to allow others to intervene + EMC_TASK_MODE viewmode; // The mode this connection asked for, see getMode() double cmdtimeout; // Command timeout (infinite when <= 0.0) double usrtimeout; // Timeout as set by SET TIMEOUT int serial; // The serial number of the last command sent @@ -1161,20 +1162,13 @@ static cmdResponseType setUpdateStatus(connectionRecType &) static cmdResponseType setMode(connectionRecType &ctx) { // SET MODE + // Nothing goes to task: its mode cannot be set. The connection keeps + // the mode it asked for, see getMode(). switch (checkManualAutoMDI(ctx.toks[2])) { default: errornl(ctx, fmt::format("Invalid argument '{}', must be {{manual,auto,mdi}}", ctx.toks[2])); return rtError; - case kwManual: - if (sendManual()) - return rtError; - break; - case kwAuto: - if (sendAuto()) - return rtError; - break; - case kwMDI: - if (sendMdi()) - return rtError; - break; + case kwManual: ctx.viewmode = EMC_TASK_MODE::MANUAL; break; + case kwAuto: ctx.viewmode = EMC_TASK_MODE::AUTO; break; + case kwMDI: ctx.viewmode = EMC_TASK_MODE::MDI; break; } return rtOk; } @@ -2015,12 +2009,17 @@ static cmdResponseType getMachine(connectionRecType &ctx) static cmdResponseType getMode(connectionRecType &ctx) { // GET MODE - switch (emcStatus->task.mode) { + // Task's mode reports what runs and cannot be set. While task is + // idle, report the mode this connection asked for with SET MODE. + EMC_TASK_MODE mode = emcStatus->task.mode; + if (mode == EMC_TASK_MODE::MANUAL) + mode = ctx.viewmode; + switch (mode) { case EMC_TASK_MODE::MANUAL: replynl(ctx, "MODE MANUAL"); break; case EMC_TASK_MODE::AUTO: replynl(ctx, "MODE AUTO"); break; case EMC_TASK_MODE::MDI: replynl(ctx, "MODE MDI"); break; default: - errornl(ctx, fmt::format("internal: GET MODE: unrecognised EMC_TASK_MODE value '{}'", (int)emcStatus->task.mode)); + errornl(ctx, fmt::format("internal: GET MODE: unrecognised EMC_TASK_MODE value '{}'", (int)mode)); replynl(ctx, "MODE ?"); } return rtOk; @@ -3590,6 +3589,7 @@ static int sockMain(int svrfd) cr.version = "1.1"; cr.echo = true; cr.waitmode = EMC_WAIT_DONE; + cr.viewmode = EMC_TASK_MODE::MANUAL; //cr.timestamp= true; clients.push_back(cr); if(isipv4) { diff --git a/src/emc/usr_intf/emcsh.cc b/src/emc/usr_intf/emcsh.cc index e7e20296f37..87de1946b26 100644 --- a/src/emc/usr_intf/emcsh.cc +++ b/src/emc/usr_intf/emcsh.cc @@ -1008,6 +1008,10 @@ static int emc_machine(ClientData /*clientdata*/, return TCL_ERROR; } +// The mode this process asked for with emc_mode. Task's mode reports what +// runs and cannot be set; while task is idle emc_mode reports this one. +static EMC_TASK_MODE viewMode = EMC_TASK_MODE::MANUAL; + static int emc_mode(ClientData /*clientdata*/, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]) { @@ -1019,7 +1023,11 @@ static int emc_mode(ClientData /*clientdata*/, if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } - switch (emcStatus->task.mode) { + EMC_TASK_MODE mode = emcStatus->task.mode; + if (mode == EMC_TASK_MODE::MANUAL) { + mode = viewMode; + } + switch (mode) { case EMC_TASK_MODE::MANUAL: setresult(interp,"manual"); break; @@ -1039,15 +1047,15 @@ static int emc_mode(ClientData /*clientdata*/, if (objc == 2) { objstr = Tcl_GetStringFromObj(objv[1], NULL); if (!strcmp(objstr, "manual")) { - sendManual(); + viewMode = EMC_TASK_MODE::MANUAL; return TCL_OK; } if (!strcmp(objstr, "auto")) { - sendAuto(); + viewMode = EMC_TASK_MODE::AUTO; return TCL_OK; } if (!strcmp(objstr, "mdi")) { - sendMdi(); + viewMode = EMC_TASK_MODE::MDI; return TCL_OK; } } diff --git a/src/emc/usr_intf/halui.cc b/src/emc/usr_intf/halui.cc index 21aedc301d9..3a7929f45d2 100644 --- a/src/emc/usr_intf/halui.cc +++ b/src/emc/usr_intf/halui.cc @@ -245,7 +245,6 @@ static double maxFeedOverride=1; static double maxMaxVelocity=1; static double minSpindleOverride=0.0; static double maxSpindleOverride=1.0; -static EMC_TASK_MODE halui_old_mode = EMC_TASK_MODE::MANUAL; static int halui_sent_mdi = 0; // the NML channels to the EMC task @@ -794,42 +793,6 @@ static int sendEstopReset() return emcCommandSend(state_msg); } -static int sendManual() -{ - EMC_TASK_SET_MODE mode_msg; - - if (emcStatus->task.mode == EMC_TASK_MODE::MANUAL) { - return 0; - } - - mode_msg.mode = EMC_TASK_MODE::MANUAL; - return emcCommandSend(mode_msg); -} - -static int sendAuto() -{ - EMC_TASK_SET_MODE mode_msg; - - if (emcStatus->task.mode == EMC_TASK_MODE::AUTO) { - return 0; - } - - mode_msg.mode = EMC_TASK_MODE::AUTO; - return emcCommandSend(mode_msg); -} - -static int sendMdi() -{ - EMC_TASK_SET_MODE mode_msg; - - if (emcStatus->task.mode == EMC_TASK_MODE::MDI) { - return 0; - } - - mode_msg.mode = EMC_TASK_MODE::MDI; - return emcCommandSend(mode_msg); -} - static int sendMdiCommand(int n) { EMC_TASK_PLAN_EXECUTE emc_task_plan_execute_msg; @@ -838,13 +801,6 @@ static int sendMdiCommand(int n) return -1; } - if (!halui_sent_mdi) { - // There is currently no MDI command from halui executing, we're - // currently starting the first one. Record what the Task mode is, - // so we can restore it when all the MDI commands finish. - halui_old_mode = emcStatus->task.mode; - } - halui_sent_mdi = 1; if (num_mdi_commands>0){ @@ -852,21 +808,8 @@ static int sendMdiCommand(int n) updateStatus(); } - // switch to MDI mode if needed - if (emcStatus->task.mode != EMC_TASK_MODE::MDI) { - if (sendMdi() != 0) { - rtapi_print("halui: %s: failed to Set Mode MDI\n", __func__); - return -1; - } - if (updateStatus() != 0) { - rtapi_print("halui: %s: failed to update status\n", __func__); - return -1; - } - if (emcStatus->task.mode != EMC_TASK_MODE::MDI) { - rtapi_print("halui: %s: switched mode, but got %d instead of mdi\n", __func__, (int)emcStatus->task.mode); - return -1; - } - } + // Task needs no mode for it: an MDI command starts an MDI run when task + // is idle, and queues behind the running one during MDI. rtapi_strxcpy(emc_task_plan_execute_msg.command, mdi_commands[n]); if (emcCommandSend(emc_task_plan_execute_msg)) { rtapi_print("halui: %s: failed to send mdi command %d\n", __func__, n); @@ -943,7 +886,6 @@ static int sendProgramRun(int line) programStartLine = line; emc_task_plan_run_msg.line = line; - sendAuto(); return emcCommandSend(emc_task_plan_run_msg); } @@ -1451,14 +1393,8 @@ static void check_hal_changes() if (check_bit_changed(new_halui_data.estop_reset, old_halui_data.estop_reset) != 0) sendEstopReset(); - if (check_bit_changed(new_halui_data.mode_manual, old_halui_data.mode_manual) != 0) - sendManual(); - - if (check_bit_changed(new_halui_data.mode_auto, old_halui_data.mode_auto) != 0) - sendAuto(); - - if (check_bit_changed(new_halui_data.mode_mdi, old_halui_data.mode_mdi) != 0) - sendMdi(); + // halui.mode.manual, .auto and .mdi do nothing: the task mode follows + // what task runs if (check_bit_changed(new_halui_data.mode_teleop, old_halui_data.mode_teleop) != 0) sendTeleop(); @@ -1904,22 +1840,9 @@ static void modify_hal_pins() hal_set_bool(halui_data->machine_is_on, emcStatus->task.state == EMC_TASK_STATE::ON); hal_set_bool(halui_data->estop_is_activated, emcStatus->task.state == EMC_TASK_STATE::ESTOP); - // Decide once whether an ongoing halui MDI command has finished: the mode - // restore below refreshes emcStatus, and Task may echo it while still EXEC. + // whether an ongoing halui MDI command has finished bool mdi_finished = halui_sent_mdi && emcStatus->status == RCS_STATUS::DONE; - if (halui_sent_mdi) { // we have an ongoing MDI command - if (mdi_finished) { //which seems to have finished - switch (halui_old_mode) { - case EMC_TASK_MODE::MANUAL: sendManual();break; - case EMC_TASK_MODE::MDI: break; - case EMC_TASK_MODE::AUTO: sendAuto();break; - default: sendManual();break; - } - } - } - - hal_set_bool(halui_data->mode_is_manual, emcStatus->task.mode == EMC_TASK_MODE::MANUAL); hal_set_bool(halui_data->mode_is_auto, emcStatus->task.mode == EMC_TASK_MODE::AUTO); hal_set_bool(halui_data->mode_is_mdi, emcStatus->task.mode == EMC_TASK_MODE::MDI); diff --git a/tests/halui/mdi/test-ui.py b/tests/halui/mdi/test-ui.py index 296db4b1d62..a096dd71c2f 100755 --- a/tests/halui/mdi/test-ui.py +++ b/tests/halui/mdi/test-ui.py @@ -115,61 +115,40 @@ def wait_for_halui_mode(pin_name): # wrong. # -log("setting mode to Manual") +# The task mode cannot be set: halui's MDI commands run from whatever mode +# a UI asked for, and task is back in Manual (idle) when they finish. +# c.mode() only sets this process's view (what s.task_mode reports while +# task is idle), so task's own mode is read from the halui pins. + +def mdi_then_manual(n, x, y, z): + log("running MDI command %d" % n) + h['mdi-%d' % n] = 1 + wait_for_joint_to_stop_at(0, x); + wait_for_joint_to_stop_at(1, y); + wait_for_joint_to_stop_at(2, z); + h['mdi-%d' % n] = 0 + wait_for_halui_mode('is-manual') + +log("asking for Manual mode") c.mode(linuxcnc.MODE_MANUAL) wait_for_halui_mode('is-manual') -log("running MDI command 0") -h['mdi-0'] = 1 -wait_for_joint_to_stop_at(0, -1); -wait_for_joint_to_stop_at(1, 0); -wait_for_joint_to_stop_at(2, 0); -h['mdi-0'] = 0 -wait_for_task_mode(linuxcnc.MODE_MANUAL) -wait_for_halui_mode('is-manual') +mdi_then_manual(0, -1, 0, 0) -log("setting mode to Auto") +log("asking for Auto mode, which only sets this process's view") c.mode(linuxcnc.MODE_AUTO) -wait_for_halui_mode('is-auto') -log("running MDI command 1") -h['mdi-1'] = 1 -wait_for_joint_to_stop_at(0, 1); -wait_for_joint_to_stop_at(1, 0); -wait_for_joint_to_stop_at(2, 0); -h['mdi-1'] = 0 +c.wait_complete() wait_for_task_mode(linuxcnc.MODE_AUTO) -wait_for_halui_mode('is-auto') +wait_for_halui_mode('is-manual') +mdi_then_manual(1, 1, 0, 0) -log("setting mode to MDI") +log("asking for MDI mode, which only sets this process's view") c.mode(linuxcnc.MODE_MDI) -wait_for_halui_mode('is-mdi') -log("running MDI command 2") -h['mdi-2'] = 1 -wait_for_joint_to_stop_at(0, 1); -wait_for_joint_to_stop_at(1, 2); -wait_for_joint_to_stop_at(2, 0); -h['mdi-2'] = 0 -s.poll() -wait_for_task_mode(linuxcnc.MODE_MDI) -wait_for_halui_mode('is-mdi') - -log("running MDI command 3") -h['mdi-3'] = 1 -wait_for_joint_to_stop_at(0, 1); -wait_for_joint_to_stop_at(1, 2); -wait_for_joint_to_stop_at(2, 3); -h['mdi-3'] = 0 -wait_for_task_mode(linuxcnc.MODE_MDI) -wait_for_halui_mode('is-mdi') - -log("running MDI command 0") -h['mdi-0'] = 1 -wait_for_joint_to_stop_at(0, -1); -wait_for_joint_to_stop_at(1, 0); -wait_for_joint_to_stop_at(2, 0); -h['mdi-0'] = 0 +c.wait_complete() wait_for_task_mode(linuxcnc.MODE_MDI) -wait_for_halui_mode('is-mdi') +wait_for_halui_mode('is-manual') +mdi_then_manual(2, 1, 2, 0) +mdi_then_manual(3, 1, 2, 3) +mdi_then_manual(0, -1, 0, 0) sys.exit(0) - diff --git a/tests/interp/g28.2/invalid-pword/test-ui.py b/tests/interp/g28.2/invalid-pword/test-ui.py index 19effdd827e..e217b08e887 100755 --- a/tests/interp/g28.2/invalid-pword/test-ui.py +++ b/tests/interp/g28.2/invalid-pword/test-ui.py @@ -60,10 +60,13 @@ def near(a, b, tol=0.001): def wait_idle(timeout=10.0): + # Task is idle once the interpreter is and motion has left the + # coordinated mode of the run for the joint or world mode it had before. t0 = time.time() while time.time() - t0 < timeout: poll() - if s.interp_state == linuxcnc.INTERP_IDLE: + if (s.interp_state == linuxcnc.INTERP_IDLE + and s.motion_mode != linuxcnc.TRAJ_MODE_COORD): return True time.sleep(0.01) return False @@ -88,7 +91,7 @@ def mode_name(m): c.state(linuxcnc.STATE_ON) linuxcnc_util.LinuxCNC(command=c, status=s, error=e).home_joints([0, 1, 2]) -# Establish a coordinated mode worth preserving. +# Establish a mode worth preserving: the one motion goes back to after a run. c.mode(linuxcnc.MODE_MDI) c.mdi("G0 X1") if not wait_idle(): diff --git a/tests/interp/m98m99/12-M99-endless-main-program/expected.motion-logger b/tests/interp/m98m99/12-M99-endless-main-program/expected.motion-logger index f57d1cc9b65..0dca98e1279 100644 --- a/tests/interp/m98m99/12-M99-endless-main-program/expected.motion-logger +++ b/tests/interp/m98m99/12-M99-endless-main-program/expected.motion-logger @@ -199,23 +199,6 @@ SPINDLE_OFF SS_ENABLE ENABLE COORD -JOG_ABORT joint=0 -JOG_ABORT joint=1 -JOG_ABORT joint=2 -JOG_ABORT joint=3 -JOG_ABORT joint=4 -JOG_ABORT joint=5 -JOG_ABORT joint=6 -JOG_ABORT joint=7 -JOG_ABORT joint=8 -JOG_ABORT joint=9 -JOG_ABORT joint=10 -JOG_ABORT joint=11 -JOG_ABORT joint=12 -JOG_ABORT joint=13 -JOG_ABORT joint=14 -JOG_ABORT joint=15 -ABORT SET_LINE x=1, y=0, z=0, a=0, b=0, c=0, u=0, v=0, w=0, id=19, motion_type=2, vel=0.666667, ini_maxvel=4, acc=1000, turn=-1 SET_LINE x=1, y=-4, z=0, a=0, b=0, c=0, u=0, v=0, w=0, id=26, motion_type=2, vel=0.666667, ini_maxvel=4, acc=1000, turn=-1 SET_LINE x=5, y=-4, z=0, a=0, b=0, c=0, u=0, v=0, w=0, id=21, motion_type=2, vel=0.666667, ini_maxvel=4, acc=1000, turn=-1 @@ -227,4 +210,5 @@ SET_LINE x=1, y=-4, z=0, a=0, b=0, c=0, u=0, v=0, w=0, id=26, motion_type=2, vel SET_LINE x=5, y=-4, z=0, a=0, b=0, c=0, u=0, v=0, w=0, id=21, motion_type=2, vel=0.666667, ini_maxvel=4, acc=1000, turn=-1 SET_SPINDLESYNC sync=0.000000, flags=0x00000000 SPINDLE_OFF +FREE DISABLE diff --git a/tests/linuxcncrsh/expected-telnet-output b/tests/linuxcncrsh/expected-telnet-output index 935b42dc147..f2ab9f7f09b 100644 --- a/tests/linuxcncrsh/expected-telnet-output +++ b/tests/linuxcncrsh/expected-telnet-output @@ -55,7 +55,7 @@ PROBE_VALUE 0 SET PROBE_CLEAR ACK ERROR OK SET PROBE NAK -ERROR Must be in MDI mode to issue MDI command +ERROR Cannot probe with zero feed rate SET PROBE_CLEAR ACK ERROR OK MODE MANUAL @@ -445,7 +445,7 @@ PROGRAM_UNITS INCH REL_ACT_POS 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 REL_CMD_POS 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 WAIT_MODE DONE -TELEOP_ENABLE OFF +TELEOP_ENABLE ON TIMEOUT 0.000000 TOOL 0 TOOL_OFFSET 0.000000 @@ -485,14 +485,14 @@ SET OPTIONAL_STOP ACK OPTIONAL_STOP ON ERROR OK OVERRIDE_LIMITS OFF -SET OVERRIDE_LIMITS NAK +SET OVERRIDE_LIMITS ACK OVERRIDE_LIMITS OFF -ERROR can't do that (EMC_JOINT_OVERRIDE_LIMITS:129) in MDI mode +ERROR OK SET STEP NAK -ERROR can't do that (EMC_TASK_PLAN_STEP:511) in MDI mode +ERROR Can't run a program: no program is open SET TASK_PLAN_INIT ACK ERROR OK -TELEOP_ENABLE OFF +TELEOP_ENABLE ON SET TELEOP_ENABLE ACK TELEOP_ENABLE OFF ERROR OK diff --git a/tests/linuxcncrsh/test.sh b/tests/linuxcncrsh/test.sh index bd4cc09c083..9a18fa57dea 100755 --- a/tests/linuxcncrsh/test.sh +++ b/tests/linuxcncrsh/test.sh @@ -91,7 +91,7 @@ function testSetOnly() { testSet estop off testSet machine on - # test if probing in manual mode fails + # probing with the manual view still runs it (as MDI); zero feed fails testSet mode manual echo get pos_offset echo get probe_tripped @@ -244,9 +244,9 @@ function testSetOnly() { testSet angular_unit_conversion deg # testSet feed_override 100 # testSet flood on # - testSetOnly jog 0 1 # - testSetOnly jog_incr 0 1 1 # - testSetOnly jog_stop 0 # + testSetOnly jog x 1 # ; world mode after MDI + testSetOnly jog_incr x 1 1 # + testSetOnly jog_stop x # testSet linear_unit_conversion mm # testSet mist on # testSet optional_stop 1 # @@ -256,12 +256,10 @@ function testSetOnly() { #testSet Open #testSet run - # Testing set override_limits results in command line message: - # can't do that (EMC_JOINT_OVERRIDE_LIMITS:129) in MDI mode testSet override_limits off # # Testing step results in a command line message: - # can't do that (EMC_TASK_PLAN_STEP:511) in MDI mode + # Can't run a program: no program is open testSetOnly step testSetOnly task_plan_init diff --git a/tests/motion-logger/basic/expected.builtin-startup.in b/tests/motion-logger/basic/expected.builtin-startup.in index 8eda7cd994c..fbe6a7a222d 100644 --- a/tests/motion-logger/basic/expected.builtin-startup.in +++ b/tests/motion-logger/basic/expected.builtin-startup.in @@ -206,25 +206,6 @@ SS_ENABLE ENABLE # -# The test UI finally switches mode to Auto, which switches Motion to Coord -# and aborts. +# The test UI then asks for Auto mode. That sets only the test UI's own +# view; nothing goes to Task or Motion. # - -COORD -JOG_ABORT joint=0 -JOG_ABORT joint=1 -JOG_ABORT joint=2 -JOG_ABORT joint=3 -JOG_ABORT joint=4 -JOG_ABORT joint=5 -JOG_ABORT joint=6 -JOG_ABORT joint=7 -JOG_ABORT joint=8 -JOG_ABORT joint=9 -JOG_ABORT joint=10 -JOG_ABORT joint=11 -JOG_ABORT joint=12 -JOG_ABORT joint=13 -JOG_ABORT joint=14 -JOG_ABORT joint=15 -ABORT diff --git a/tests/motion-logger/basic/expected.g0 b/tests/motion-logger/basic/expected.g0 index aad80163311..cc271eebade 100644 --- a/tests/motion-logger/basic/expected.g0 +++ b/tests/motion-logger/basic/expected.g0 @@ -1,4 +1,6 @@ +COORD SET_LINE x=1, y=2, z=3, a=4, b=5, c=6, u=7, v=8, w=9, id=2, motion_type=1, vel=1.66296, ini_maxvel=1.66296, acc=415.74, turn=-1 SET_LINE x=0.1, y=0.2, z=0.3, a=0.4, b=0.5, c=0.6, u=0.7, v=0.8, w=0.9, id=4, motion_type=1, vel=1.66296, ini_maxvel=1.66296, acc=415.74, turn=-1 SET_SPINDLESYNC sync=0.000000, flags=0x00000000 SPINDLE_OFF +FREE diff --git a/tests/motion-logger/basic/expected.g1 b/tests/motion-logger/basic/expected.g1 index d2c3bffbad6..bd250d5d9b5 100644 --- a/tests/motion-logger/basic/expected.g1 +++ b/tests/motion-logger/basic/expected.g1 @@ -1,5 +1,7 @@ +COORD SET_LINE x=1, y=2, z=3, a=4, b=5, c=6, u=7, v=8, w=9, id=2, motion_type=2, vel=0.0166667, ini_maxvel=1.66296, acc=415.74, turn=-1 SET_LINE x=0.1, y=2, z=0.3, a=0.4, b=5, c=0.6, u=0.7, v=8, w=0.9, id=3, motion_type=2, vel=0.0333333, ini_maxvel=1.40546, acc=351.364, turn=-1 SET_LINE x=10, y=2, z=0.3, a=10, b=5, c=0.6, u=10, v=8, w=0.9, id=5, motion_type=2, vel=0.00166667, ini_maxvel=4, acc=1000, turn=-1 SET_SPINDLESYNC sync=0.000000, flags=0x00000000 SPINDLE_OFF +FREE diff --git a/tests/motion-logger/basic/expected.reset b/tests/motion-logger/basic/expected.reset index 2a358b4b4f8..70687f3e8d3 100644 --- a/tests/motion-logger/basic/expected.reset +++ b/tests/motion-logger/basic/expected.reset @@ -1,3 +1,5 @@ +COORD SET_OFFSET x=0, y=0, z=0, a=0, b=0, c=0 u=0, v=0, w=0 SET_SPINDLESYNC sync=0.000000, flags=0x00000000 SPINDLE_OFF +FREE diff --git a/tests/motion-logger/basic/expected.s b/tests/motion-logger/basic/expected.s index c4216ad2293..fd0fd722768 100644 --- a/tests/motion-logger/basic/expected.s +++ b/tests/motion-logger/basic/expected.s @@ -1,3 +1,4 @@ +COORD SET_LINE x=1, y=0, z=0, a=0, b=0, c=0, u=0, v=0, w=0, id=2, motion_type=1, vel=4, ini_maxvel=4, acc=1000, turn=-1 SPINDLE_ON speed=0.000000, css_factor=0.000000, xoffset=0.000000 SET_LINE x=1.5, y=0, z=0, a=0, b=0, c=0, u=0, v=0, w=0, id=6, motion_type=1, vel=4, ini_maxvel=4, acc=1000, turn=-1 @@ -13,3 +14,4 @@ SPINDLE_ON speed=0.000000, css_factor=0.000000, xoffset=0.000000 SET_LINE x=5, y=0, z=0, a=0, b=0, c=0, u=0, v=0, w=0, id=26, motion_type=1, vel=4, ini_maxvel=4, acc=1000, turn=-1 SET_SPINDLESYNC sync=0.000000, flags=0x00000000 SPINDLE_OFF +FREE diff --git a/tests/motion-logger/mountaindew/expected.motion-logger b/tests/motion-logger/mountaindew/expected.motion-logger index 73dc85fb4e6..3f7e8e80d2b 100644 --- a/tests/motion-logger/mountaindew/expected.motion-logger +++ b/tests/motion-logger/mountaindew/expected.motion-logger @@ -103,23 +103,6 @@ SPINDLE_OFF SS_ENABLE ENABLE COORD -JOG_ABORT joint=0 -JOG_ABORT joint=1 -JOG_ABORT joint=2 -JOG_ABORT joint=3 -JOG_ABORT joint=4 -JOG_ABORT joint=5 -JOG_ABORT joint=6 -JOG_ABORT joint=7 -JOG_ABORT joint=8 -JOG_ABORT joint=9 -JOG_ABORT joint=10 -JOG_ABORT joint=11 -JOG_ABORT joint=12 -JOG_ABORT joint=13 -JOG_ABORT joint=14 -JOG_ABORT joint=15 -ABORT SET_LINE x=2, y=0, z=0, a=0, b=0, c=0, u=0, v=0, w=0, id=4, motion_type=2, vel=0.666667, ini_maxvel=400, acc=1000, turn=-1 SET_LINE x=3, y=0, z=0, a=0, b=0, c=0, u=0, v=0, w=0, id=5, motion_type=2, vel=0.666667, ini_maxvel=400, acc=1000, turn=-1 SET_LINE x=3, y=4, z=0, a=0, b=0, c=0, u=0, v=0, w=0, id=6, motion_type=2, vel=0.666667, ini_maxvel=400, acc=1000, turn=-1 @@ -132,4 +115,5 @@ SET_LINE x=0, y=1, z=0.5, a=0, b=0, c=0, u=0, v=0, w=0, id=5, motion_type=1, vel SET_LINE x=0, y=0, z=0.5, a=0, b=0, c=0, u=0, v=0, w=0, id=6, motion_type=1, vel=400, ini_maxvel=400, acc=1000, turn=-1 SET_SPINDLESYNC sync=0.000000, flags=0x00000000 SPINDLE_OFF +FREE DISABLE diff --git a/tests/task-hal-pins/test-ui.py b/tests/task-hal-pins/test-ui.py index 238b5eae49a..0ef0df9ce24 100755 --- a/tests/task-hal-pins/test-ui.py +++ b/tests/task-hal-pins/test-ui.py @@ -122,7 +122,7 @@ def wait_for(what, cond): c.mdi(cmd) c.wait_complete() wait_for("move done", lambda: s.inpos and s.interp_state == linuxcnc.INTERP_IDLE) -check("mdi with offsets and tool 1", {'task.mode.is-mdi': True, +check("mdi with offsets and tool 1", {'task.mode.is-manual': True, 'task.tool.diameter': 0.25, 'task.tool.number': 1}) diff --git a/tests/task-modeless/.gitignore b/tests/task-modeless/.gitignore new file mode 100644 index 00000000000..57585c75340 --- /dev/null +++ b/tests/task-modeless/.gitignore @@ -0,0 +1,2 @@ +sim.var +sim.var.bak diff --git a/tests/task-modeless/checkresult b/tests/task-modeless/checkresult new file mode 100755 index 00000000000..24dc9aa53e3 --- /dev/null +++ b/tests/task-modeless/checkresult @@ -0,0 +1,2 @@ +#!/bin/sh +exit 0 # test failure is indicated by test.sh exit value diff --git a/tests/task-modeless/program.ngc b/tests/task-modeless/program.ngc new file mode 100644 index 00000000000..cd7c1b0f097 --- /dev/null +++ b/tests/task-modeless/program.ngc @@ -0,0 +1,4 @@ +G0 X2 +G4 P1.5 +G0 X4 +M2 diff --git a/tests/task-modeless/sim.hal b/tests/task-modeless/sim.hal new file mode 100644 index 00000000000..d5d3ef1538b --- /dev/null +++ b/tests/task-modeless/sim.hal @@ -0,0 +1,16 @@ +loadrt [KINS]KINEMATICS +loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS +addf motion-command-handler servo-thread +addf motion-controller servo-thread + +net Xpos joint.0.motor-pos-cmd => joint.0.motor-pos-fb +net Ypos joint.1.motor-pos-cmd => joint.1.motor-pos-fb +net Zpos joint.2.motor-pos-cmd => joint.2.motor-pos-fb + +net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in +net tool-prepare-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared +net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed + +# a wheel on X: one count is 0.01 +setp axis.x.jog-scale 0.01 +setp axis.x.jog-vel-mode 0 diff --git a/tests/task-modeless/test-ui.py b/tests/task-modeless/test-ui.py new file mode 100755 index 00000000000..febae9f2c42 --- /dev/null +++ b/tests/task-modeless/test-ui.py @@ -0,0 +1,234 @@ +#!/usr/bin/env python3 +# The task mode cannot be set: it reports what task runs, and task accepts +# jogs, MDI and program runs by what it is doing. Nothing here calls +# c.mode() except to check what it does: it sets this process's view, which +# stat.task_mode reports while task is idle. halui's mode pins show task's +# own mode. + +import os +import sys +import time + +import hal +import linuxcnc + +c = linuxcnc.command() +s = linuxcnc.stat() +e = linuxcnc.error_channel() +h = hal.component("test-ui") +h.ready() + +fails = 0 + + +def check(name, ok, detail=''): + global fails + print('%s: %s %s' % ('ok' if ok else 'FAIL', name, detail), flush=True) + if not ok: + fails += 1 + + +def wait(fn, timeout=5.0): + end = time.time() + timeout + while time.time() < end: + s.poll() + if fn(): + return True + time.sleep(0.01) + s.poll() + return fn() + + +def errors(): + msgs = [] + while True: + m = e.poll() + if not m: + return msgs + msgs.append(m[1]) + + +def idle(): + return (s.interp_state == linuxcnc.INTERP_IDLE and s.queue == 0 + and hal.get_value('task.mode.is-manual')) + + +def x(): + return s.actual_position[0] + + +MODE = {linuxcnc.MODE_MANUAL: 'MANUAL', linuxcnc.MODE_MDI: 'MDI', linuxcnc.MODE_AUTO: 'AUTO'} +TRAJ = {linuxcnc.TRAJ_MODE_FREE: 'FREE', linuxcnc.TRAJ_MODE_TELEOP: 'TELEOP', + linuxcnc.TRAJ_MODE_COORD: 'COORD'} + + +def modes(): + return '%s/%s' % (MODE.get(s.task_mode), TRAJ.get(s.motion_mode)) + + +wait(lambda: s.task_mode in MODE and s.motion_mode in TRAJ, 10.0) +check('starts idle', s.task_mode == linuxcnc.MODE_MANUAL and s.motion_mode == linuxcnc.TRAJ_MODE_FREE, modes()) + +c.state(linuxcnc.STATE_ESTOP_RESET) +c.state(linuxcnc.STATE_ON) +c.wait_complete() + +# --- before homing: MDI is refused, joint jogs work +errors() +c.mdi('G0 X1') +c.wait_complete() +time.sleep(0.1) +msgs = errors() +check('MDI refused before homing', any('not homed' in m for m in msgs), msgs) +check('still idle in joint mode', wait(lambda: idle() and s.motion_mode == linuxcnc.TRAJ_MODE_FREE), modes()) + +c.jog(linuxcnc.JOG_INCREMENT, True, 1, 10, 0.5) +check('joint jog without a mode change', wait(lambda: abs(s.joint_actual_position[1] - 0.5) < 1e-6), s.joint_actual_position[1]) + +c.home(-1) +c.wait_complete() +check('homed', wait(lambda: all(s.homed[:3])), s.homed[:3]) +c.teleop_enable(1) +c.wait_complete() +check('world mode', wait(lambda: s.motion_mode == linuxcnc.TRAJ_MODE_TELEOP), modes()) + +# --- no program open: run and step are refused +errors() +c.auto(linuxcnc.AUTO_STEP) +c.wait_complete() +time.sleep(0.1) +msgs = errors() +check('step refused with no program', any('no program is open' in m for m in msgs), msgs) +check('still idle after the refused step', wait(idle), modes()) + +# --- MDI from idle, no mode change +c.mdi('G0 X1') +check('MDI shows as MDI mode', wait(lambda: s.task_mode == linuxcnc.MODE_MDI, 1.0), modes()) +check('MDI runs in coordinated mode', wait(lambda: s.motion_mode == linuxcnc.TRAJ_MODE_COORD, 1.0), modes()) +check('MDI moved X', wait(lambda: abs(x() - 1) < 1e-6), x()) +check('idle again after MDI', wait(idle), modes()) +check('back in world mode', wait(lambda: s.motion_mode == linuxcnc.TRAJ_MODE_TELEOP), modes()) +check('halui sees manual', wait(lambda: hal.get_value('task.mode.is-manual'))) +check('no errors from MDI', not errors()) + +# --- wheel jog while idle after MDI +hal.set_p('axis.x.jog-enable', '1') +hal.set_p('axis.x.jog-counts', '100') +check('wheel jog after MDI', wait(lambda: abs(x() - 2) < 1e-6), x()) + +# --- a world jog right after MDI, with no mode change +c.jog(linuxcnc.JOG_INCREMENT, False, 0, 10, 0.5) +check('world jog after MDI', wait(lambda: abs(x() - 2.5) < 1e-6), x()) + +# --- mode() sets this process's view only +c.mode(linuxcnc.MODE_AUTO) +c.wait_complete() +time.sleep(0.1) +s.poll() +check('mode(AUTO) shows as the view', s.task_mode == linuxcnc.MODE_AUTO, modes()) +check('mode(AUTO) leaves task idle', hal.get_value('task.mode.is-manual') and s.motion_mode == linuxcnc.TRAJ_MODE_TELEOP, modes()) +c.mode(linuxcnc.MODE_MDI) +c.wait_complete() +time.sleep(0.1) +s.poll() +check('mode(MDI) shows as the view', s.task_mode == linuxcnc.MODE_MDI, modes()) +check('mode(MDI) leaves task idle', hal.get_value('task.mode.is-manual') and s.motion_mode == linuxcnc.TRAJ_MODE_TELEOP, modes()) +c.jog(linuxcnc.JOG_INCREMENT, False, 0, 10, 0.5) +check('world jog with the MDI view', wait(lambda: abs(x() - 3) < 1e-6), x()) +c.mode(linuxcnc.MODE_MANUAL) +s.poll() +check('mode(MANUAL) view', s.task_mode == linuxcnc.MODE_MANUAL, modes()) +check('no errors from mode()', not errors()) + +# --- queued MDI; jogs are refused while it runs +c.mdi('G4 P1') +c.mdi('G0 X3.5') +check('MDI queue runs', wait(lambda: s.task_mode == linuxcnc.MODE_MDI, 1.0), modes()) +check('halui sees MDI', wait(lambda: hal.get_value('task.mode.is-mdi'), 1.0)) +y = s.actual_position[1] +c.jog(linuxcnc.JOG_INCREMENT, False, 1, 10, 0.5) +c.wait_complete() +time.sleep(0.1) +msgs = errors() +check('jog refused while MDI runs', any('while MDI is running' in m for m in msgs), msgs) +c.mode(linuxcnc.MODE_MANUAL) +c.wait_complete() +check('mode(MANUAL) does not stop MDI: queued MDI finished', wait(lambda: abs(x() - 3.5) < 1e-6, 4.0), x()) +check('idle after the MDI queue', wait(idle), modes()) +check('Y did not move', abs(s.actual_position[1] - y) < 1e-6, (s.actual_position[1], y)) + +# --- a jog in progress holds off MDI +c.jog(linuxcnc.JOG_CONTINUOUS, False, 1, 1) +wait(lambda: s.current_vel > 0.5, 1.0) +c.mdi('G0 X0') +c.wait_complete() +time.sleep(0.1) +msgs = errors() +check('MDI refused while jogging', any('while jogging' in m for m in msgs), msgs) +c.jog(linuxcnc.JOG_STOP, False, 1) +check('jog stopped, idle', wait(lambda: idle() and s.current_vel == 0), modes()) + +# --- a program run from idle, no mode change +c.program_open(os.path.abspath('program.ngc')) +c.wait_complete() +c.auto(linuxcnc.AUTO_RUN, 0) +check('program shows as AUTO mode', wait(lambda: s.task_mode == linuxcnc.MODE_AUTO, 1.0), modes()) +check('halui sees auto', wait(lambda: hal.get_value('task.mode.is-auto'), 1.0)) +check('program reached the dwell', wait(lambda: abs(x() - 2) < 1e-6), x()) +c.mode(linuxcnc.MODE_MANUAL) +c.mdi('G0 X0') +c.jog(linuxcnc.JOG_INCREMENT, False, 1, 10, 0.5) +c.wait_complete() +time.sleep(0.1) +msgs = errors() +s.poll() +check('mode(MANUAL) leaves the program running', s.task_mode == linuxcnc.MODE_AUTO and hal.get_value('task.mode.is-auto'), modes()) +check('MDI refused while the program runs', any('EMC_TASK_PLAN_EXECUTE' in m for m in msgs), msgs) +check('jog refused while the program runs', any('EMC_JOG_INCR' in m for m in msgs), msgs) +check('program finished', wait(lambda: abs(x() - 4) < 1e-6, 5.0), x()) +check('idle after the program', wait(idle), modes()) +check('world mode after the program', wait(lambda: s.motion_mode == linuxcnc.TRAJ_MODE_TELEOP), modes()) + +# --- abort a paused program +c.auto(linuxcnc.AUTO_RUN, 0) +wait(lambda: abs(x() - 2) < 1e-6) +c.auto(linuxcnc.AUTO_PAUSE) +check('paused program is AUTO', wait(lambda: s.paused and s.task_mode == linuxcnc.MODE_AUTO), modes()) +c.abort() +c.wait_complete() +check('abort ends the run', wait(idle), modes()) +errors() + +# --- joint mode is kept across a run +c.teleop_enable(0) +c.wait_complete() +wait(lambda: s.motion_mode == linuxcnc.TRAJ_MODE_FREE) +c.mdi('G0 X1') +check('MDI from joint mode', wait(lambda: abs(x() - 1) < 1e-6), x()) +check('back in joint mode', wait(lambda: idle() and s.motion_mode == linuxcnc.TRAJ_MODE_FREE), modes()) +c.teleop_enable(1) +c.wait_complete() + + +# --- the view comes back once a run ends +c.mode(linuxcnc.MODE_MDI) +c.mdi('G0 X0.5') +check('MDI from the MDI view', wait(lambda: abs(x() - 0.5) < 1e-6), x()) +check('idle again, MDI view kept', wait(lambda: hal.get_value('task.mode.is-manual') and s.interp_state == linuxcnc.INTERP_IDLE) + and s.task_mode == linuxcnc.MODE_MDI, modes()) +c.mode(linuxcnc.MODE_MANUAL) + +# --- step from idle starts the program paused +c.auto(linuxcnc.AUTO_STEP) +check('step starts the program', wait(lambda: s.task_mode == linuxcnc.MODE_AUTO and s.paused), modes()) +c.abort() +c.wait_complete() +check('abort after step', wait(idle), modes()) + +msgs = errors() +check('no unexpected errors', not msgs, msgs) + +c.state(linuxcnc.STATE_OFF) +c.wait_complete() +print('%d failures' % fails, flush=True) +sys.exit(1 if fails else 0) diff --git a/tests/task-modeless/test.ini b/tests/task-modeless/test.ini new file mode 100644 index 00000000000..b7214fb8e19 --- /dev/null +++ b/tests/task-modeless/test.ini @@ -0,0 +1,83 @@ +[EMC] +VERSION = 1.1 +DEBUG = 0 + +[DISPLAY] +DISPLAY = ./test-ui.py + +[RS274NGC] +PARAMETER_FILE = sim.var + +[EMCMOT] +EMCMOT = motmod +COMM_TIMEOUT = 4.0 +SERVO_PERIOD = 1000000 + +[TASK] +TASK = milltask +CYCLE_TIME = 0.001 + +[HAL] +HALFILE = sim.hal + + +[TRAJ] +COORDINATES = X Y Z +LINEAR_UNITS = mm +ANGULAR_UNITS = degree +MAX_LINEAR_VELOCITY = 40 + +[EMCIO] +TOOL_TABLE = tool.tbl + +[KINS] +KINEMATICS = trivkins +JOINTS = 3 + +[AXIS_X] +MIN_LIMIT = -100.0 +MAX_LIMIT = 100.0 +MAX_VELOCITY = 40 +MAX_ACCELERATION = 1000.0 + +[JOINT_0] +TYPE = LINEAR +HOME_SEQUENCE = 0 +MAX_VELOCITY = 40 +MAX_ACCELERATION = 1000.0 +MIN_LIMIT = -100.0 +MAX_LIMIT = 100.0 +FERROR = 1 +MIN_FERROR = 1 + +[AXIS_Y] +MIN_LIMIT = -100.0 +MAX_LIMIT = 100.0 +MAX_VELOCITY = 40 +MAX_ACCELERATION = 1000.0 + +[JOINT_1] +TYPE = LINEAR +HOME_SEQUENCE = 0 +MAX_VELOCITY = 40 +MAX_ACCELERATION = 1000.0 +MIN_LIMIT = -100.0 +MAX_LIMIT = 100.0 +FERROR = 1 +MIN_FERROR = 1 + +[AXIS_Z] +MIN_LIMIT = -100.0 +MAX_LIMIT = 100.0 +MAX_VELOCITY = 40 +MAX_ACCELERATION = 1000.0 + +[JOINT_2] +TYPE = LINEAR +HOME_SEQUENCE = 0 +MAX_VELOCITY = 40 +MAX_ACCELERATION = 1000.0 +MIN_LIMIT = -100.0 +MAX_LIMIT = 100.0 +FERROR = 1 +MIN_FERROR = 1 diff --git a/tests/task-modeless/test.sh b/tests/task-modeless/test.sh new file mode 100755 index 00000000000..972cf4ffcb8 --- /dev/null +++ b/tests/task-modeless/test.sh @@ -0,0 +1,3 @@ +#!/bin/bash +rm -f sim.var +linuxcnc -r test.ini diff --git a/tests/task-modeless/tool.tbl b/tests/task-modeless/tool.tbl new file mode 100644 index 00000000000..aee1343f663 --- /dev/null +++ b/tests/task-modeless/tool.tbl @@ -0,0 +1 @@ +T1 P1 Z0.5 ;tool 1 From 30f52cdc35c490f7793e441b76be92163490a79c Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Fri, 16 Oct 2026 21:04:26 +0200 Subject: [PATCH 16/27] user interfaces: no wait after a mode change mode() sends nothing to task any more; it sets the page the user interface shows. The wait_complete() after it waited on whatever command came before, and while a program runs or is paused task does not report DONE, so each one sat out its timeout: AXIS hung for 5 s on a spindle button while paused (ensure_mode()). Remove the wait after every mode() call in the user interfaces, their libraries and the sample configs: AXIS, gmoccapy, gscreen and the silverdragon skin, touchy, pyui, GStat, the gladevcp and qtvcp actions, the gladevcp offset page and probe panels, the 3pcenter panel. The waits after teleop_enable() that follow some of them stay. --- configs/sim/axis/gladevcp/probe.py | 1 - .../gmoccapy/lathe_configs/lathehandler.py | 1 - .../qtvcp_experimental/lathehandler.py | 1 - lib/python/common/hal_glib.py | 2 -- .../gtk_little_probe/gtk_little_probe.py | 23 --------------- .../gtk_verser_probe/gtk_verser_probe.py | 23 --------------- lib/python/gladevcp/gtk_action.py | 1 - lib/python/gladevcp/hal_actions.py | 1 - lib/python/gladevcp/offsetpage_widget.py | 9 ------ lib/python/qtvcp/qt_action.py | 1 - .../silverdragon/silverdragon_handler.py | 20 ------------- .../qtvcp/panels/3pcenter/3pcenter_handler.py | 2 -- src/emc/usr_intf/axis/scripts/axis.py | 6 ++-- src/emc/usr_intf/gmoccapy/gmoccapy.py | 28 ------------------- src/emc/usr_intf/gscreen/emc_interface.py | 5 ---- src/emc/usr_intf/gscreen/mdi.py | 12 -------- src/emc/usr_intf/pyui/commands.py | 6 ---- src/emc/usr_intf/touchy/emc_interface.py | 1 - src/emc/usr_intf/touchy/mdi.py | 1 - 19 files changed, 3 insertions(+), 141 deletions(-) diff --git a/configs/sim/axis/gladevcp/probe.py b/configs/sim/axis/gladevcp/probe.py index fcca3592815..089dedd378b 100644 --- a/configs/sim/axis/gladevcp/probe.py +++ b/configs/sim/axis/gladevcp/probe.py @@ -65,7 +65,6 @@ def ensure_mode(self,m, *p): if self.s.task_mode == m or self.s.task_mode in p: return True if self.running(do_poll=False): return False self.c.mode(m) - self.c.wait_complete() return True def active_codes(self): diff --git a/configs/sim/gmoccapy/lathe_configs/lathehandler.py b/configs/sim/gmoccapy/lathe_configs/lathehandler.py index b8ae574d4b0..46e2bd403a9 100755 --- a/configs/sim/gmoccapy/lathe_configs/lathehandler.py +++ b/configs/sim/gmoccapy/lathe_configs/lathehandler.py @@ -198,7 +198,6 @@ def cycle_pin(self, pin, data = None): if c is not None: self.cmd.abort() self.cmd.mode(linuxcnc.MODE_MDI) - self.cmd.wait_complete() c.emit('clicked') print(c.get_name(), "clicked") diff --git a/configs/sim/qtvcp_screens/qtvcp_experimental/lathehandler.py b/configs/sim/qtvcp_screens/qtvcp_experimental/lathehandler.py index 4997894099e..eedbc15047c 100644 --- a/configs/sim/qtvcp_screens/qtvcp_experimental/lathehandler.py +++ b/configs/sim/qtvcp_screens/qtvcp_experimental/lathehandler.py @@ -188,7 +188,6 @@ def cycle_pin(self, pin, data = None): if c.name.partition('.')[2] == 'action': self.cmd.abort() self.cmd.mode(linuxcnc.MODE_MANUAL) - self.cmd.wait_complete() c.emit('clicked') def gash(self, obj, data = None): diff --git a/lib/python/common/hal_glib.py b/lib/python/common/hal_glib.py index 70cec83b495..0d0f9c574fe 100644 --- a/lib/python/common/hal_glib.py +++ b/lib/python/common/hal_glib.py @@ -1377,7 +1377,6 @@ def set_tool_touchoff(self,tool,axis,value): if self.stat.task_mode != linuxcnc.MODE_MDI: premode = self.stat.task_mode self.cmd.mode(linuxcnc.MODE_MDI) - self.cmd.wait_complete() self.cmd.mdi(m) self.cmd.wait_complete() self.cmd.mdi("g43") @@ -1392,7 +1391,6 @@ def set_axis_origin(self,axis,value): if self.stat.task_mode != linuxcnc.MODE_MDI: premode = self.stat.task_mode self.cmd.mode(linuxcnc.MODE_MDI) - self.cmd.wait_complete() self.cmd.mdi(m) self.cmd.wait_complete() if premode: diff --git a/lib/python/gladevcp/builtin-panels/gtk_little_probe/gtk_little_probe.py b/lib/python/gladevcp/builtin-panels/gtk_little_probe/gtk_little_probe.py index 7f790cf2d7b..b23f59427f1 100644 --- a/lib/python/gladevcp/builtin-panels/gtk_little_probe/gtk_little_probe.py +++ b/lib/python/gladevcp/builtin-panels/gtk_little_probe/gtk_little_probe.py @@ -626,21 +626,18 @@ def lenght_y(self, data = None): def on_btn1_set_x_released(self, gtkbutton, data = None): self.prefs.putpref( "ps_offs_x", self.spbtn_offs_x.get_value(), float ) self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() self.command.mdi( "G10 L20 P0 X%f" % self.spbtn_offs_x.get_value() ) time.sleep(1) def on_btn1_set_y_released(self, gtkbutton, data = None): self.prefs.putpref( "ps_offs_y", self.spbtn_offs_y.get_value(), float ) self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() self.command.mdi( "G10 L20 P0 Y%f" % self.spbtn_offs_y.get_value() ) time.sleep(1) def on_btn1_set_z_released(self, gtkbutton, data = None): self.prefs.putpref( "ps_offs_z", self.spbtn_offs_z.get_value(), float ) self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() self.command.mdi( "G10 L20 P0 Z%f" % self.spbtn_offs_z.get_value() ) time.sleep(1) @@ -648,7 +645,6 @@ def on_btn1_set_angle_released(self, gtkbutton, data = None): self.prefs.putpref( "ps_offs_angle", self.spbtn_offs_angle.get_value(), float ) self.lb_probe_a.set_text( "%.3f" % self.spbtn_offs_angle.get_value()) self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() s="G10 L2 P0" if self.chk_set_zero.get_active() : s += " X%.4f"%self.spbtn_offs_x.get_value() @@ -672,7 +668,6 @@ def on_btn1_set_angle_released(self, gtkbutton, data = None): # Down def on_down_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # Start gtk_probe_down.ngc if self.ocode ("O call") == -1: return @@ -686,7 +681,6 @@ def on_down_released(self, gtkbutton, data = None): # X+ def on_xp_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X - xy_clearance s="""G91 G1 X-%f @@ -717,7 +711,6 @@ def on_xp_released(self, gtkbutton, data = None): # Y+ def on_yp_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y - xy_clearance s="""G91 G1 Y-%f @@ -748,7 +741,6 @@ def on_yp_released(self, gtkbutton, data = None): # X- def on_xm_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X + xy_clearance s="""G91 G1 X%f @@ -779,7 +771,6 @@ def on_xm_released(self, gtkbutton, data = None): # Y- def on_ym_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y + xy_clearance s="""G91 G1 Y%f @@ -812,7 +803,6 @@ def on_ym_released(self, gtkbutton, data = None): # X+Y+ def on_xpyp_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X - xy_clearance Y + edge_lenght s="""G91 G1 X-%f Y%f @@ -865,7 +855,6 @@ def on_xpyp_released(self, gtkbutton, data = None): # X+Y- def on_xpym_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X - xy_clearance Y + edge_lenght s="""G91 G1 X-%f Y-%f @@ -917,7 +906,6 @@ def on_xpym_released(self, gtkbutton, data = None): # X-Y+ def on_xmyp_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X + xy_clearance Y + edge_lenght s="""G91 G1 X%f Y%f @@ -970,7 +958,6 @@ def on_xmyp_released(self, gtkbutton, data = None): # X-Y- def on_xmym_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X + xy_clearance Y - edge_lenght s="""G91 G1 X%f Y-%f @@ -1023,7 +1010,6 @@ def on_xmym_released(self, gtkbutton, data = None): # Center X+ X- Y+ Y- def on_xy_center_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X - edge_lenght- xy_clearance s="""G91 G1 X-%f @@ -1137,7 +1123,6 @@ def on_xy_center_released(self, gtkbutton, data = None): # X+Y+ def on_xpyp1_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y - edge_lenght X - xy_clearance s="""G91 G1 X-%f Y-%f @@ -1185,7 +1170,6 @@ def on_xpyp1_released(self, gtkbutton, data = None): # X+Y- def on_xpym1_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y + edge_lenght X - xy_clearance s="""G91 G1 X-%f Y%f @@ -1233,7 +1217,6 @@ def on_xpym1_released(self, gtkbutton, data = None): # X-Y+ def on_xmyp1_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y - edge_lenght X + xy_clearance s="""G91 G1 X%f Y-%f @@ -1282,7 +1265,6 @@ def on_xmyp1_released(self, gtkbutton, data = None): # X-Y- def on_xmym1_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y + edge_lenght X + xy_clearance s="""G91 G1 X%f Y%f @@ -1330,7 +1312,6 @@ def on_xmym1_released(self, gtkbutton, data = None): # Hole Xin- Xin+ Yin- Yin+ def on_xy_hole_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() if self.z_clearance_down() == -1: return # move X - edge_lenght Y + xy_clearance @@ -1428,7 +1409,6 @@ def on_angle_yp_released(self, gtkbutton, data = None): self.stat.poll() xstart=self.stat.position[0]-self.stat.g5x_offset[0] - self.stat.g92_offset[0] - self.stat.tool_offset[0] self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y - xy_clearance s="""G91 G1 Y-%f @@ -1477,7 +1457,6 @@ def on_angle_ym_released(self, gtkbutton, data = None): self.stat.poll() xstart=self.stat.position[0]-self.stat.g5x_offset[0] - self.stat.g92_offset[0] - self.stat.tool_offset[0] self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y + xy_clearance s="""G91 G1 Y%f @@ -1525,7 +1504,6 @@ def on_angle_xp_released(self, gtkbutton, data = None): self.stat.poll() ystart=self.stat.position[1]-self.stat.g5x_offset[1] - self.stat.g92_offset[1] - self.stat.tool_offset[1] self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X - xy_clearance s="""G91 G1 X-%f @@ -1573,7 +1551,6 @@ def on_angle_xm_released(self, gtkbutton, data = None): self.stat.poll() ystart=self.stat.position[1]-self.stat.g5x_offset[1] - self.stat.g92_offset[1] - self.stat.tool_offset[1] self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X + xy_clearance s="""G91 G1 X%f diff --git a/lib/python/gladevcp/builtin-panels/gtk_verser_probe/gtk_verser_probe.py b/lib/python/gladevcp/builtin-panels/gtk_verser_probe/gtk_verser_probe.py index b538e0b26d2..9f6aa1287a7 100644 --- a/lib/python/gladevcp/builtin-panels/gtk_verser_probe/gtk_verser_probe.py +++ b/lib/python/gladevcp/builtin-panels/gtk_verser_probe/gtk_verser_probe.py @@ -627,21 +627,18 @@ def lenght_y(self, data = None): def on_btn1_set_x_released(self, gtkbutton, data = None): self.prefs.putpref( "ps_offs_x", self.spbtn_offs_x.get_value(), float ) self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() self.command.mdi( "G10 L20 P0 X%f" % self.spbtn_offs_x.get_value() ) time.sleep(1) def on_btn1_set_y_released(self, gtkbutton, data = None): self.prefs.putpref( "ps_offs_y", self.spbtn_offs_y.get_value(), float ) self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() self.command.mdi( "G10 L20 P0 Y%f" % self.spbtn_offs_y.get_value() ) time.sleep(1) def on_btn1_set_z_released(self, gtkbutton, data = None): self.prefs.putpref( "ps_offs_z", self.spbtn_offs_z.get_value(), float ) self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() self.command.mdi( "G10 L20 P0 Z%f" % self.spbtn_offs_z.get_value() ) time.sleep(1) @@ -649,7 +646,6 @@ def on_btn1_set_angle_released(self, gtkbutton, data = None): self.prefs.putpref( "ps_offs_angle", self.spbtn_offs_angle.get_value(), float ) self.lb_probe_a.set_text( "%.3f" % self.spbtn_offs_angle.get_value()) self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() s="G10 L2 P0" if self.chk_set_zero.get_active() : s += " X%.4f"%self.spbtn_offs_x.get_value() @@ -673,7 +669,6 @@ def on_btn1_set_angle_released(self, gtkbutton, data = None): # Down def on_down_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # Start gtk_probe_down.ngc if self.ocode ("O call") == -1: return @@ -684,7 +679,6 @@ def on_down_released(self, gtkbutton, data = None): # X+ def on_xp_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X - xy_clearance s="""G91 G1 X-%f @@ -713,7 +707,6 @@ def on_xp_released(self, gtkbutton, data = None): # Y+ def on_yp_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y - xy_clearance s="""G91 G1 Y-%f @@ -742,7 +735,6 @@ def on_yp_released(self, gtkbutton, data = None): # X- def on_xm_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X + xy_clearance s="""G91 G1 X%f @@ -771,7 +763,6 @@ def on_xm_released(self, gtkbutton, data = None): # Y- def on_ym_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y + xy_clearance s="""G91 G1 Y%f @@ -802,7 +793,6 @@ def on_ym_released(self, gtkbutton, data = None): # X+Y+ def on_xpyp_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X - xy_clearance Y + edge_lenght s="""G91 G1 X-%f Y%f @@ -853,7 +843,6 @@ def on_xpyp_released(self, gtkbutton, data = None): # X+Y- def on_xpym_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X - xy_clearance Y + edge_lenght s="""G91 G1 X-%f Y-%f @@ -903,7 +892,6 @@ def on_xpym_released(self, gtkbutton, data = None): # X-Y+ def on_xmyp_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X + xy_clearance Y + edge_lenght s="""G91 G1 X%f Y%f @@ -954,7 +942,6 @@ def on_xmyp_released(self, gtkbutton, data = None): # X-Y- def on_xmym_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X + xy_clearance Y - edge_lenght s="""G91 G1 X%f Y-%f @@ -1005,7 +992,6 @@ def on_xmym_released(self, gtkbutton, data = None): # Center X+ X- Y+ Y- def on_xy_center_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X - edge_lenght- xy_clearance s="""G91 G1 X-%f @@ -1117,7 +1103,6 @@ def on_xy_center_released(self, gtkbutton, data = None): # X+Y+ def on_xpyp1_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y - edge_lenght X - xy_clearance s="""G91 G1 X-%f Y-%f @@ -1163,7 +1148,6 @@ def on_xpyp1_released(self, gtkbutton, data = None): # X+Y- def on_xpym1_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y + edge_lenght X - xy_clearance s="""G91 G1 X-%f Y%f @@ -1209,7 +1193,6 @@ def on_xpym1_released(self, gtkbutton, data = None): # X-Y+ def on_xmyp1_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y - edge_lenght X + xy_clearance s="""G91 G1 X%f Y-%f @@ -1256,7 +1239,6 @@ def on_xmyp1_released(self, gtkbutton, data = None): # X-Y- def on_xmym1_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y + edge_lenght X + xy_clearance s="""G91 G1 X%f Y%f @@ -1302,7 +1284,6 @@ def on_xmym1_released(self, gtkbutton, data = None): # Hole Xin- Xin+ Yin- Yin+ def on_xy_hole_released(self, gtkbutton, data = None): self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() if self.z_clearance_down() == -1: return # move X - edge_lenght Y + xy_clearance @@ -1398,7 +1379,6 @@ def on_angle_yp_released(self, gtkbutton, data = None): self.stat.poll() xstart=self.stat.position[0]-self.stat.g5x_offset[0] - self.stat.g92_offset[0] - self.stat.tool_offset[0] self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y - xy_clearance s="""G91 G1 Y-%f @@ -1445,7 +1425,6 @@ def on_angle_ym_released(self, gtkbutton, data = None): self.stat.poll() xstart=self.stat.position[0]-self.stat.g5x_offset[0] - self.stat.g92_offset[0] - self.stat.tool_offset[0] self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move Y + xy_clearance s="""G91 G1 Y%f @@ -1491,7 +1470,6 @@ def on_angle_xp_released(self, gtkbutton, data = None): self.stat.poll() ystart=self.stat.position[1]-self.stat.g5x_offset[1] - self.stat.g92_offset[1] - self.stat.tool_offset[1] self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X - xy_clearance s="""G91 G1 X-%f @@ -1537,7 +1515,6 @@ def on_angle_xm_released(self, gtkbutton, data = None): self.stat.poll() ystart=self.stat.position[1]-self.stat.g5x_offset[1] - self.stat.g92_offset[1] - self.stat.tool_offset[1] self.command.mode( linuxcnc.MODE_MDI ) - self.command.wait_complete() # move X + xy_clearance s="""G91 G1 X%f diff --git a/lib/python/gladevcp/gtk_action.py b/lib/python/gladevcp/gtk_action.py index 1316c29f2dd..a5981f3a0c7 100644 --- a/lib/python/gladevcp/gtk_action.py +++ b/lib/python/gladevcp/gtk_action.py @@ -674,7 +674,6 @@ def ensure_mode(self, *modes): truth, premode = STATUS.check_for_modes(modes) if truth is False: self.cmd.mode(modes[0]) - self.cmd.wait_complete() return (True, premode) else: return (truth, premode) diff --git a/lib/python/gladevcp/hal_actions.py b/lib/python/gladevcp/hal_actions.py index 2adacc30110..b8f5862fd21 100644 --- a/lib/python/gladevcp/hal_actions.py +++ b/lib/python/gladevcp/hal_actions.py @@ -299,7 +299,6 @@ def ensure_mode(s, c, *modes): if s.task_mode in modes: return True if running(s, do_poll=False): return False c.mode(modes[0]) - c.wait_complete() return True class EMC_Action_Python(_EMC_Action): diff --git a/lib/python/gladevcp/offsetpage_widget.py b/lib/python/gladevcp/offsetpage_widget.py index 11dad262b3a..a295d3e77e8 100755 --- a/lib/python/gladevcp/offsetpage_widget.py +++ b/lib/python/gladevcp/offsetpage_widget.py @@ -445,7 +445,6 @@ def system_to_p(system): if lncnc_running: if self.status.task_mode != self.linuxcnc.MODE_MDI: self.cmd.mode(self.linuxcnc.MODE_MDI) - self.cmd.wait_complete() if row == 0: self.cmd.mdi("G43.1 %s %10.4f" % (self.axisletters[axisnum], qualified)) elif row == 1: @@ -462,9 +461,7 @@ def system_to_p(system): else: self.cmd.mdi("G10 L2 P%d %s %10.4f" % (pnum, self.axisletters[axisnum], qualified)) self.cmd.mode(self.linuxcnc.MODE_MANUAL) - self.cmd.wait_complete() self.cmd.mode(self.linuxcnc.MODE_MDI) - self.cmd.wait_complete() self.gstat.emit('reload-display') except Exception as error: print(_("offsetpage widget error: MDI call error")) @@ -479,12 +476,9 @@ def zero_g92(self, widget): try: if self.status.task_mode != self.linuxcnc.MODE_MDI: self.cmd.mode(self.linuxcnc.MODE_MDI) - self.cmd.wait_complete() self.cmd.mdi("G92.1") self.cmd.mode(self.linuxcnc.MODE_MANUAL) - self.cmd.wait_complete() self.cmd.mode(self.linuxcnc.MODE_MDI) - self.cmd.wait_complete() self.gstat.emit('reload-display') except: print(_("MDI error in offsetpage widget -zero G92")) @@ -496,12 +490,9 @@ def zero_rot(self, widget): try: if self.status.task_mode != self.linuxcnc.MODE_MDI: self.cmd.mode(self.linuxcnc.MODE_MDI) - self.cmd.wait_complete() self.cmd.mdi("G10 L2 P0 R 0") self.cmd.mode(self.linuxcnc.MODE_MANUAL) - self.cmd.wait_complete() self.cmd.mode(self.linuxcnc.MODE_MDI) - self.cmd.wait_complete() self.gstat.emit('reload-display') except: print(_("MDI error in offsetpage widget-zero rotational offset")) diff --git a/lib/python/qtvcp/qt_action.py b/lib/python/qtvcp/qt_action.py index 1ef2912d51b..8c81b08a3d6 100644 --- a/lib/python/qtvcp/qt_action.py +++ b/lib/python/qtvcp/qt_action.py @@ -1037,7 +1037,6 @@ def ensure_mode(self, *modes): truth, premode = STATUS.check_for_modes(modes) if truth is False: self.cmd.mode(modes[0]) - self.cmd.wait_complete() return (True, premode) else: return (truth, premode) diff --git a/share/gscreen/skins/silverdragon/silverdragon_handler.py b/share/gscreen/skins/silverdragon/silverdragon_handler.py index e78c1a1db8c..846e68b16f5 100644 --- a/share/gscreen/skins/silverdragon/silverdragon_handler.py +++ b/share/gscreen/skins/silverdragon/silverdragon_handler.py @@ -187,7 +187,6 @@ def initialize_widgets(self): self.widgets.ntb_main.set_current_page(_NB_PREVIEW) self.gscreen.sensitize_widgets(self.data.sensitive_on_off, False) self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() def initialize_preferences(self): self.gscreen.init_general_pref() @@ -426,7 +425,6 @@ def on_rbt_manual_clicked(self, widget): if self.widgets.ntb_main.get_current_page() == _NB_SETUP: return self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() def on_rbt_mdi_clicked(self, widget): if self.widgets.ntb_main.get_current_page() == _NB_SETUP: @@ -434,7 +432,6 @@ def on_rbt_mdi_clicked(self, widget): self.widgets.rbt_mdi.set_active(False) else: self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() def on_rbt_auto_clicked(self, widget): if self.widgets.ntb_main.get_current_page() == _NB_SETUP: @@ -442,7 +439,6 @@ def on_rbt_auto_clicked(self, widget): self.widgets.rbt_auto.set_active(False) else: self.command.mode(linuxcnc.MODE_AUTO) - self.command.wait_complete() def on_ntb_main_switch_page(self, widget, tab, index): if self.stat.task_mode == linuxcnc.MODE_AUTO: @@ -511,13 +507,11 @@ def on_zero_axis_clicked(self, widget): self.gscreen.notify(_("ERROR"), _("Unknown axis selected"), ALERT_ICON) return self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() command = "G10 L20 P0 {0}0".format(self.axis_to_ref) self.command.mdi(command) self.command.wait_complete() self.gscreen.reload_plot() self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() self.gscreen.prefs.putpref("offset_axis_{0}".format(self.axis_to_ref), 0, float) def on_ref_axis_clicked(self, widget): @@ -540,7 +534,6 @@ def on_ref_axis_clicked(self, widget): title = "Enter Offset for Axis %s"%self.axis_to_ref self.gscreen.launch_numerical_input(callback, 0, 0, title) self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() def on_tbtn_flood_toggled(self, widget, data=None): if self.stat.flood == widget.get_active(): @@ -782,10 +775,8 @@ def on_default_window_pressed(self, widget): def on_btn_zero_g92_clicked(self, widget, data=None): self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() self.command.mdi("G92.1") self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self.widgets.rbt_offset.emit("toggled") def on_tbtn_edit_offsets_toggled(self, widget, data=None): @@ -795,7 +786,6 @@ def on_tbtn_edit_offsets_toggled(self, widget, data=None): self.gscreen.sensitize_widgets(widgetlist, not state) if not state: # must switch back to manual mode, otherwise jogging is not possible self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() def on_chk_ignore_limits_toggled(self, widget, data=None): if self.widgets.chk_ignore_limits.get_active(): @@ -933,7 +923,6 @@ def on_hal_status_all_homed(self, widget): self.data.all_homed = True self.widgets.ntb_main.set_current_page(_NB_PREVIEW) self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self.gscreen.sensitize_widgets(self.data.sensitive_all_homed, True) self.set_motion_mode(1) self.widgets.statusbar1.remove(self.gscreen.statusbar_id, self.gscreen.homed_status_message) @@ -977,7 +966,6 @@ def on_hal_status_interp_idle(self, widget): self.gscreen.sensitize_widgets(self.data.sensitive_run_idle, True) if self.tool_change: self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self.tool_change = False self.current_line = 0 @@ -997,7 +985,6 @@ def on_hal_status_state_estop(self, widget=None): self.widgets.tbtn_estop.set_label("ESTOP") self.widgets.chk_ignore_limits.set_sensitive(False) self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() def on_hal_status_state_estop_reset(self, widget=None): self.widgets.tbtn_estop.set_active(False) @@ -1022,7 +1009,6 @@ def on_hal_status_state_on(self, widget): self.widgets.rbt_manual.set_active(True) self.widgets.ntb_mode.set_current_page(_MODE_MANUAL) self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() def on_hal_status_mode_manual(self, widget): print("MANUAL Mode") @@ -1041,7 +1027,6 @@ def on_hal_status_mode_mdi(self, widget): if not self.widgets.rbt_mdi.get_sensitive(): self.command.abort() self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self.gscreen.notify(_("INFO"), _("It is not possible to change to MDI Mode at the moment"), INFO_ICON) return else: @@ -1055,7 +1040,6 @@ def on_hal_status_mode_auto(self, widget): if not self.widgets.rbt_auto.get_sensitive(): self.command.abort() self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self.gscreen.notify(_("INFO"), _("It is not possible to change to AUTO Mode at the moment"), INFO_ICON) else: print("AUTO Mode") @@ -1245,7 +1229,6 @@ def reload_tool(self): self.load_tool = True self.tool_change = True self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() command = "M61 Q {0} G43".format(tool_to_load) self.command.mdi(command) self.command.wait_complete() @@ -1411,7 +1394,6 @@ def update_toolinfo(self, tool): return if "G43" in self.data.active_gcodes and self.stat.task_mode != linuxcnc.MODE_AUTO: self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() self.command.mdi("G43") self.command.wait_complete() @@ -1456,12 +1438,10 @@ def on_offset_axis_return(self, widget, result, calc, userdata, userdata2): r = self.axis_to_ref self.gscreen.prefs.putpref("offset_axis_{}".format(r), value, str) self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() command = "G10 L20 P0 {}{}".format(r, value) self.command.mdi(command) self.gscreen.reload_plot() self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() widget.destroy() self.data.entry_dialog = None diff --git a/share/qtvcp/panels/3pcenter/3pcenter_handler.py b/share/qtvcp/panels/3pcenter/3pcenter_handler.py index 5e736833ade..dd3d70b68af 100644 --- a/share/qtvcp/panels/3pcenter/3pcenter_handler.py +++ b/share/qtvcp/panels/3pcenter/3pcenter_handler.py @@ -115,7 +115,6 @@ def set_no_ok(self): def goCenter(self): c.mode(linuxcnc.MODE_MDI) - c.wait_complete() c.mdi('g53 g0 z0') c.mdi('g54 g0 x'+str(round(self.X, 4))+'y'+str(round(self.Y, 4))) @@ -123,7 +122,6 @@ def setCenter(self): offset_X = (hal.get_value("halui.axis.x.pos-relative") - self.X) offset_Y = (hal.get_value("halui.axis.y.pos-relative") - self.Y) c.mode(linuxcnc.MODE_MDI) - c.wait_complete() c.mdi('g10 l20 p1 x'+str(round(offset_X, 4))+'y'+str(round(offset_Y, 4))) self.w.label_4.setText("OK") self.w.label_4.setStyleSheet("background-color: rgba(50, 150, 50, 120);") diff --git a/src/emc/usr_intf/axis/scripts/axis.py b/src/emc/usr_intf/axis/scripts/axis.py index d4fd019696a..52f47034095 100755 --- a/src/emc/usr_intf/axis/scripts/axis.py +++ b/src/emc/usr_intf/axis/scripts/axis.py @@ -1021,13 +1021,13 @@ def manual_ok(do_poll=True): if s.task_state != linuxcnc.STATE_ON: return False return s.interp_state == linuxcnc.INTERP_IDLE or (s.task_mode == linuxcnc.MODE_MDI and s.queued_mdi_commands < vars.max_queued_mdi_commands.get()) -# If LinuxCNC is not already in one of the modes given, switch it to the -# first (task) mode MANUAL,MDI,AUTO +# If AXIS does not already show one of the modes given, show the first +# MANUAL,MDI,AUTO. The mode is AXIS's own (see stat.task_mode): nothing goes +# to task, so there is nothing to wait for. def ensure_mode(m, *p): s.poll() if s.task_mode == m or s.task_mode in p: return True c.mode(m) # task_mode - c.wait_complete() s.poll() return True diff --git a/src/emc/usr_intf/gmoccapy/gmoccapy.py b/src/emc/usr_intf/gmoccapy/gmoccapy.py index b5397d3bf02..9466934332f 100644 --- a/src/emc/usr_intf/gmoccapy/gmoccapy.py +++ b/src/emc/usr_intf/gmoccapy/gmoccapy.py @@ -2908,17 +2908,14 @@ def on_tbtn_on_toggled(self, widget, data=None): def on_rbt_manual_pressed(self, widget, data=None): LOG.debug("mode Manual") self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() def on_rbt_mdi_pressed(self, widget, data=None): LOG.debug("mode MDI") self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() def on_rbt_auto_pressed(self, widget, data=None): LOG.debug("mode Auto") self.command.mode(linuxcnc.MODE_AUTO) - self.command.wait_complete() # If button exit is clicked, press emergency button before closing the application def on_btn_exit_clicked(self, widget, data=None): @@ -3079,7 +3076,6 @@ def on_hal_status_interp_idle(self, widget): if self.tool_change: self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self.tool_change = False self.halcomp["program.current-line"] = 0 @@ -3166,7 +3162,6 @@ def on_hal_status_state_on(self, widget): self.widgets.btn_exit.set_sensitive(False) if self.widgets.ntb_main.get_current_page() != 0: self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() # activate limit override only if limit switch active if any(self.stat.limit): @@ -3238,7 +3233,6 @@ def on_hal_status_mode_mdi(self, widget): if not self.widgets.rbt_mdi.get_sensitive(): self.command.abort() self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self._show_error((linuxcnc.OPERATOR_DISPLAY, _("It is not possible to change to MDI Mode at the moment"))) return else: @@ -3289,7 +3283,6 @@ def on_hal_status_mode_auto(self, widget): if not self.widgets.rbt_auto.get_sensitive(): self.command.abort() self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self._show_error((linuxcnc.OPERATOR_DISPLAY, _("It is not possible to change to Auto Mode at the moment"))) return else: @@ -3441,7 +3434,6 @@ def on_window1_show(self, widget, data=None): self.on_chk_use_tool_measurement_toggled(self.widgets.chk_use_tool_measurement) self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self.initialized = True @@ -3621,7 +3613,6 @@ def on_key_event(self, widget, event, signal): # F3 change to manual mode if keyname == "F3" and signal: self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() # we need to leave here, otherwise the check for jogging # only allowed in manual mode will finish the sub self.last_key_event = keyname, signal @@ -3630,7 +3621,6 @@ def on_key_event(self, widget, event, signal): # F5 should change to mdi mode if keyname == "F5" and signal: self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() # we need to leave here, otherwise the check for jogging # only allowed in manual mode will finish the sub self.last_key_event = keyname, signal @@ -4308,7 +4298,6 @@ def on_tbtn_setup_toggled(self, widget, data=None): self.stat.poll() if widget.get_active(): self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self.widgets.rbt_manual.set_active(True) # save the mode to restore when leaving the settings page self.last_mode = self.stat.task_mode @@ -4376,7 +4365,6 @@ def on_tbtn_setup_toggled(self, widget, data=None): else: # restore mode self.command.mode(self.last_mode) - self.command.wait_complete() widget.set_image(self.widgets.img_settings) @@ -4935,11 +4923,9 @@ def on_btn_back_clicked(self, widget, data=None): result = self.dialogs.yesno_dialog(self, message, _("Attention!")) if result: # user says YES self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() self.command.mdi("G43") self.command.wait_complete() self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self.widgets.ntb_button.set_current_page(_BB_MANUAL) self.widgets.ntb_main.set_current_page(0) self.widgets.ntb_preview.set_current_page(0) @@ -4981,7 +4967,6 @@ def on_tbtn_edit_offsets_toggled(self, widget, data=None): if not state: # we must switch back to manual mode, otherwise jogging is not possible self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() # show virtual keyboard? if state and self.widgets.chk_use_kb_on_offset.get_active(): @@ -4990,10 +4975,8 @@ def on_tbtn_edit_offsets_toggled(self, widget, data=None): def on_btn_zero_g92_clicked(self, widget, data=None): self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() self.command.mdi("G92.1") self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self.widgets.btn_touch.emit("clicked") def _on_btn_set_value_clicked(self, widget, data=None): @@ -5028,12 +5011,10 @@ def _on_btn_set_value_clicked(self, widget, data=None): _("Please enter only numerical values. Values have not been applied")) else: self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() command = "G10 L20 P0 {0}{1:f}".format(axis, offset) self.command.mdi(command) self.widgets.hal_action_reload.emit("activate") self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() self.prefs.putpref("offset_axis_{0}".format(axis), offset, float) def _on_btn_edit_offsets_clicked(self, widget, data=None): @@ -5052,10 +5033,8 @@ def _on_btn_set_selected_clicked(self, widget, data=None): return else: self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() self.command.mdi(system) self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() def on_spbtn_probe_height_value_changed(self, widget, data=None): self.halcomp["probeheight"] = widget.get_value() @@ -5115,11 +5094,9 @@ def on_btn_block_height_clicked(self, widget, data=None): # set coordinate system to new origin origin = self.get_ini_info.get_axis_2_min_limit() + blockheight self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() self.command.mdi("G10 L2 P0 Z{0}".format(origin)) self.widgets.hal_action_reload.emit("activate") self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() # choose a theme to apply def on_theme_choice_changed(self, widget): @@ -5652,7 +5629,6 @@ def reload_tool(self): self.tool_change = True self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() command = "M61 Q {0} G43".format(tool_to_load) self.command.mdi(command) @@ -5771,14 +5747,12 @@ def on_btn_tool_touchoff_clicked(self, widget, data=None): else: command = "G10 L10 P{0} {1}{2}".format(self.stat.tool_in_spindle, axis, value) self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() self.command.mdi(command) self.command.wait_complete() if "G43" in self.active_gcodes: self.command.mdi("G43") self.command.wait_complete() self.command.mode(linuxcnc.MODE_MANUAL) - self.command.wait_complete() # select a tool entering a number def on_btn_select_tool_by_no_clicked(self, widget, data=None): @@ -5803,7 +5777,6 @@ def on_btn_select_tool_by_no_clicked(self, widget, data=None): else: self.tool_change = True self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() command = "T{0} M6".format(int(value)) self.command.mdi(command) # Next two lines fix issue #3129 caused by GStat missing changes in interpreter mode @@ -5829,7 +5802,6 @@ def on_btn_selected_tool_clicked(self, widget, data=None): self.tool_change = True tool = int(tool) self.command.mode(linuxcnc.MODE_MDI) - self.command.wait_complete() if widget == self.widgets.btn_change_tool: command = "T{0} M6".format(tool) diff --git a/src/emc/usr_intf/gscreen/emc_interface.py b/src/emc/usr_intf/gscreen/emc_interface.py index ff4f3dc767f..e2bb6f784cf 100644 --- a/src/emc/usr_intf/gscreen/emc_interface.py +++ b/src/emc/usr_intf/gscreen/emc_interface.py @@ -189,7 +189,6 @@ def quill_up(self): if self.masked: return self.set_motion_mode() self.emccommand.mode(self.emc.MODE_MANUAL) - self.emccommand.wait_complete() self.emccommand.jog(self.emc.JOG_CONTINUOUS, 0, 2, 100) def feed_hold(self, data): @@ -245,7 +244,6 @@ def single_block(self, s): def cycle_start(self): if self.emcstat.task_mode != self.emc.MODE_AUTO: self.emccommand.mode(self.emc.MODE_AUTO) - self.emccommand.wait_complete() self.emcstat.poll() if self.emcstat.paused: self.emccommand.auto(self.emc.AUTO_STEP) @@ -258,7 +256,6 @@ def cycle_start(self): # This restarts the program at the line specified directly (without cyscle start push) def re_start(self,line): self.emccommand.mode(self.emc.MODE_AUTO) - self.emccommand.wait_complete() self.emccommand.auto(self.emc.AUTO_RUN, line) self.restart_line_number = self.restart_reset_line @@ -285,13 +282,11 @@ def set_mdi_mode(self): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_MDI: self.emccommand.mode(self.emc.MODE_MDI) - self.emccommand.wait_complete() def set_auto_mode(self): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_AUTO: self.emccommand.mode(self.emc.MODE_AUTO) - self.emccommand.wait_complete() def get_mode(self): self.emcstat.poll() diff --git a/src/emc/usr_intf/gscreen/mdi.py b/src/emc/usr_intf/gscreen/mdi.py index c4f5083bcc2..16ec72e2e57 100644 --- a/src/emc/usr_intf/gscreen/mdi.py +++ b/src/emc/usr_intf/gscreen/mdi.py @@ -145,7 +145,6 @@ def issue(self): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_MDI: self.emccommand.mode(self.emc.MODE_MDI) - self.emccommand.wait_complete() self.emccommand.mdi(m) def set_tool_touchoff(self,tool,axis,value): @@ -153,7 +152,6 @@ def set_tool_touchoff(self,tool,axis,value): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_MDI: self.emccommand.mode(self.emc.MODE_MDI) - self.emccommand.wait_complete() self.emccommand.mdi(m) self.emccommand.wait_complete() self.emccommand.mdi("g43") @@ -163,7 +161,6 @@ def set_axis_origin(self,axis,value): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_MDI: self.emccommand.mode(self.emc.MODE_MDI) - self.emccommand.wait_complete() self.emccommand.mdi(m) def go_to_position(self,axis,position,feedrate): @@ -171,7 +168,6 @@ def go_to_position(self,axis,position,feedrate): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_MDI: self.emccommand.mode(self.emc.MODE_MDI) - self.emccommand.wait_complete() self.emccommand.mdi(m) def set_spindle_speed(self,value): @@ -179,7 +175,6 @@ def set_spindle_speed(self,value): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_MDI: self.emccommand.mode(self.emc.MODE_MDI) - self.emccommand.wait_complete() self.emccommand.mdi(m) def set_user_system(self,value): @@ -187,7 +182,6 @@ def set_user_system(self,value): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_MDI: self.emccommand.mode(self.emc.MODE_MDI) - self.emccommand.wait_complete() self.emccommand.mdi(m) def index_tool(self,toolnumber): @@ -195,14 +189,12 @@ def index_tool(self,toolnumber): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_MDI: self.emccommand.mode(self.emc.MODE_MDI) - self.emccommand.wait_complete() self.emccommand.mdi("m6 T %f"%(toolnumber)) self.emccommand.mdi("g43 h%f"%(toolnumber)) def arbitrary_mdi(self,command): if self.emcstat.task_mode != self.emc.MODE_MDI: self.emccommand.mode(self.emc.MODE_MDI) - self.emccommand.wait_complete() self.emccommand.mdi(command) class mdi_control: @@ -231,19 +223,16 @@ def set_mdi_mode(self): self.mdi.emcstat.poll() if self.mdi.emcstat.task_mode != self.mdi.emc.MODE_MDI: self.mdi.emccommand.mode(self.mdi.emc.MODE_MDI) - self.mdi.emccommand.wait_complete() def set_axis(self,axis,value): premode = self.mdi.emcstat.task_mode self.mdi.set_axis_origin(axis,value) self.mdi.emccommand.mode(premode) - self.mdi.emccommand.wait_complete() def touchoff(self,tool,axis,value): premode = self.mdi.emcstat.task_mode self.mdi.set_tool_touchoff(tool,axis,value) self.mdi.emccommand.mode(premode) - self.mdi.emccommand.wait_complete() def set_spindle_speed(self,value): self.mdi.set_spindle_speed(value) @@ -256,7 +245,6 @@ def set_user_system(self,system): premode = self.mdi.emcstat.task_mode self.mdi.set_user_system(system) self.mdi.emccommand.mode(premode) - self.mdi.emccommand.wait_complete() def index_tool(self,toolnumber): print("set tool number to :T",toolnumber) diff --git a/src/emc/usr_intf/pyui/commands.py b/src/emc/usr_intf/pyui/commands.py index 96fabe7c811..521ccd260a1 100644 --- a/src/emc/usr_intf/pyui/commands.py +++ b/src/emc/usr_intf/pyui/commands.py @@ -268,7 +268,6 @@ def incremental_jog(self, wname, cmd): def quill_up(self, wname, cmd): self.emccommand.mode(self.emc.MODE_MANUAL) - self.emccommand.wait_complete() self.mdi('G53 G0 Z %f'% float(cmd)) def feed_hold(self, wname, cmd): @@ -323,7 +322,6 @@ def smart_cycle_start(self, wname, cmd=None): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_AUTO: self.emccommand.mode(self.emc.MODE_AUTO) - self.emccommand.wait_complete() self.emcstat.poll() if self.emcstat.paused: self.emccommand.auto(self.emc.AUTO_STEP) @@ -336,7 +334,6 @@ def smart_cycle_start(self, wname, cmd=None): # This restarts the program at the line specified directly (without cyscle start push) def re_start(self, wname, line): self.emccommand.mode(self.emc.MODE_AUTO) - self.emccommand.wait_complete() self.emccommand.auto(self.emc.AUTO_RUN, line) self.restart_line_number = self.restart_reset_line @@ -377,19 +374,16 @@ def set_manual_mode(self): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_MANUAL: self.emccommand.mode(self.emc.MODE_MANUAL) - self.emccommand.wait_complete() def set_mdi_mode(self): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_MDI: self.emccommand.mode(self.emc.MODE_MDI) - self.emccommand.wait_complete() def set_auto_mode(self): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_AUTO: self.emccommand.mode(self.emc.MODE_AUTO) - self.emccommand.wait_complete() def get_mode(self): self.emcstat.poll() diff --git a/src/emc/usr_intf/touchy/emc_interface.py b/src/emc/usr_intf/touchy/emc_interface.py index 25ba4e8f4e0..7eb79f9ea30 100644 --- a/src/emc/usr_intf/touchy/emc_interface.py +++ b/src/emc/usr_intf/touchy/emc_interface.py @@ -227,7 +227,6 @@ def cycle_start(self): if self.emcstat.interp_state == self.emc.INTERP_IDLE: self.emccommand.mode(self.emc.MODE_AUTO) - self.emccommand.wait_complete() if self.sb: self.emccommand.auto(self.emc.AUTO_STEP) else: diff --git a/src/emc/usr_intf/touchy/mdi.py b/src/emc/usr_intf/touchy/mdi.py index 089c84c2f73..b4083ee0cb4 100644 --- a/src/emc/usr_intf/touchy/mdi.py +++ b/src/emc/usr_intf/touchy/mdi.py @@ -153,7 +153,6 @@ def issue(self): self.emcstat.poll() if self.emcstat.task_mode != self.emc.MODE_MDI: self.emccommand.mode(self.emc.MODE_MDI) - self.emccommand.wait_complete() self.emccommand.mdi(m) From 13512041d231d337960b9b7e12b7597bfbf90e43 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Fri, 16 Oct 2026 21:18:54 +0200 Subject: [PATCH 17/27] remove EMC_TASK_SET_MODE and halui's mode request pins The task mode follows what task runs, and nothing sets it any more: task accepted EMC_TASK_SET_MODE and did nothing, and the Python, Tcl and linuxcncrsh mode commands stopped sending it. - NML: drop EMC_TASK_SET_MODE (type 504) and task's handling of it. - shcom: drop sendManual(), sendAuto() and sendMdi(); schedrmt and emclcd no longer switch modes before MDI or opening a program, and emclcd's Test key no longer toggles the mode. - halui: drop halui.mode.manual, .auto and .mdi. The .is-* status pins stay. - Users of the pins: the xhc-hb04 pendant helper starts a program with halui.program.run only, the halui_pyvcp sim panel keeps the mode LEDs, the xhc-whb04b-6 example configuration and docs drop their mode nets, the remote start example needs halui.program.run only. --- configs/sim/axis/halui_pyvcp/pyvcp.hal | 4 --- configs/sim/axis/halui_pyvcp/vcp.xml | 24 ++++++--------- docs/src/code/nml-messages.adoc | 1 - .../getting-started/updating-linuxcnc.adoc | 5 +++- docs/src/gui/halui.adoc | 5 +--- docs/src/hal/halui-examples.adoc | 30 ++++--------------- docs/src/hal/intro.adoc | 3 -- docs/src/man/man1/halui.1.adoc | 9 ++---- docs/src/man/man1/xhc-whb04b-6.1.adoc | 10 +++---- lib/hallib/xhc-hb04.tcl | 3 +- src/emc/nml_intf/emc.cc | 16 ---------- src/emc/nml_intf/emc.hh | 1 - src/emc/nml_intf/emc_nml.hh | 15 ---------- src/emc/task/emctaskmain.cc | 12 ++------ src/emc/task/taskhal.cc | 12 -------- src/emc/task/test_task_probe.cc | 3 -- src/emc/usr_intf/emclcd.cc | 17 +---------- src/emc/usr_intf/emcsched.cc | 2 -- src/emc/usr_intf/halui.cc | 15 ++-------- src/emc/usr_intf/shcom.cc | 24 --------------- src/emc/usr_intf/shcom.hh | 3 -- .../xhc-whb04b-6/example-configuration.hal | 3 -- 22 files changed, 32 insertions(+), 185 deletions(-) diff --git a/configs/sim/axis/halui_pyvcp/pyvcp.hal b/configs/sim/axis/halui_pyvcp/pyvcp.hal index 0554fa8344b..e6e7366d341 100644 --- a/configs/sim/axis/halui_pyvcp/pyvcp.hal +++ b/configs/sim/axis/halui_pyvcp/pyvcp.hal @@ -23,10 +23,6 @@ net flood-off pyvcp.flood.off halui.flood.off net mist-is-on pyvcp.mist.is-on halui.mist.is-on net flood-is-on pyvcp.flood.is-on halui.flood.is-on -net mode-manual pyvcp.mode.manual halui.mode.manual -net mode-auto pyvcp.mode.auto halui.mode.auto -net mode-mdi pyvcp.mode.mdi halui.mode.mdi - net spindle-start pyvcp.spindle.on halui.spindle.0.start net spindle-stop pyvcp.spindle.off halui.spindle.0.stop net spindle-forward pyvcp.spindle.forward halui.spindle.0.forward diff --git a/configs/sim/axis/halui_pyvcp/vcp.xml b/configs/sim/axis/halui_pyvcp/vcp.xml index dac57a1f5d1..b78e24c17d1 100644 --- a/configs/sim/axis/halui_pyvcp/vcp.xml +++ b/configs/sim/axis/halui_pyvcp/vcp.xml @@ -55,11 +55,9 @@ - + "mode.is-manual" 20 @@ -68,11 +66,9 @@ - + "mode.is-auto" 20 @@ -81,11 +77,9 @@ - + "mode.is-mdi" 20 diff --git a/docs/src/code/nml-messages.adoc b/docs/src/code/nml-messages.adoc index 6271df5421b..7432bb9846d 100644 --- a/docs/src/code/nml-messages.adoc +++ b/docs/src/code/nml-messages.adoc @@ -114,7 +114,6 @@ EMC_MOTION_STAT_TYPE EMC_TASK_INIT_TYPE EMC_TASK_HALT_TYPE EMC_TASK_ABORT_TYPE -EMC_TASK_SET_MODE_TYPE EMC_TASK_SET_STATE_TYPE EMC_TASK_PLAN_OPEN_TYPE EMC_TASK_PLAN_RUN_TYPE diff --git a/docs/src/getting-started/updating-linuxcnc.adoc b/docs/src/getting-started/updating-linuxcnc.adoc index 1326b4ec295..18b0950206a 100644 --- a/docs/src/getting-started/updating-linuxcnc.adoc +++ b/docs/src/getting-started/updating-linuxcnc.adoc @@ -284,7 +284,10 @@ the same time without taking the machine away from each other. Tcl process, linuxcncrsh connection) shows, which `task_mode`, `emc_mode` and `get mode` report while task is idle. User interfaces that switch pages on the mode keep working, each with its own page. -* The `halui.mode.manual`, `.mdi` and `.auto` pins do nothing. +* The `halui.mode.manual`, `.mdi` and `.auto` pins are gone. Remove the + nets that connect them from HAL files: a program start button only + needs `halui.program.run`. The `.is-manual`, `.is-mdi` and `.is-auto` + pins stay. * Switching to Manual used to abort a running MDI command. It no longer does: use abort. * Task puts motion into coordinated mode when a run starts and back into diff --git a/docs/src/gui/halui.adoc b/docs/src/gui/halui.adoc index 1d41a5bb31c..dc03c26a080 100644 --- a/docs/src/gui/halui.adoc +++ b/docs/src/gui/halui.adoc @@ -241,15 +241,12 @@ _L_ = axis letter (xyzabcuvw) === Mode -* 'halui.mode.auto' (bool, in) - does nothing, the task mode follows what task runs and cannot be set -* 'halui.mode.is-auto' (bool, out) - indicates a program runs, or is paused +* 'halui.mode.is-auto' (bool, out) - indicates a program runs, or is paused; the task mode follows what task runs and cannot be set * 'halui.mode.is-joint' (bool, out) - indicates joint by joint jog mode is on * 'halui.mode.is-manual' (bool, out) - indicates task is idle: neither a program nor MDI runs * 'halui.mode.is-mdi' (bool, out) - indicates MDI commands run * 'halui.mode.is-teleop' (bool, out) - indicates coordinated jog mode is on * 'halui.mode.joint' (bool, in) - pin for requesting joint by joint jog mode -* 'halui.mode.manual' (bool, in) - does nothing, see 'halui.mode.auto' -* 'halui.mode.mdi' (bool, in) - does nothing, see 'halui.mode.auto' * 'halui.mode.teleop' (bool, in) - pin for requesting coordinated jog mode === Program diff --git a/docs/src/hal/halui-examples.adoc b/docs/src/hal/halui-examples.adoc index 2f237cc14cb..70857000bf6 100644 --- a/docs/src/hal/halui-examples.adoc +++ b/docs/src/hal/halui-examples.adoc @@ -15,34 +15,14 @@ HALUI = halui [[sec:halui-remote-start]] == Remote Start -To connect a remote program start button to LinuxCNC you use the -`halui.program.run` pin and the `halui.mode.auto` pin. -You have to ensure that it is OK to run first by using the `halui.mode.is-auto` pin. -You do this with an `and2` component. The following figure shows how this is done. -When the Remote Run Button is pressed it is connected to both `halui.mode.auto` and `and2.0.in0`. -If it is OK for auto mode the pin `halui.mode.is-auto` will be on. -If both the inputs to the `and2.0` component are on the `and2.0.out` will be on -and this will start the program. - -.Remote Start Example -image::images/remote-start.png["Remote Start Example"] - -The hal commands needed to accomplish the above are: - -[source,hal] ----- -net program-start-btn halui.mode.auto and2.0.in0 <= -net program-run-ok and2.0.in1 <= halui.mode.is-auto -net remote-program-run halui.program.run <= and2.0.out ----- - -Notice on line one that there are two reader pins, this can also be split -up to two lines like this: +To connect a remote program start button to LinuxCNC connect it to the +`halui.program.run` pin. There is no mode to switch to first: LinuxCNC +starts the program when it is idle and refuses the run otherwise, for +instance while MDI runs or a jog is active. [source,hal] ---- -net program-start-btn halui.mode.auto <= -net program-start-btn and2.0.in0 +net remote-program-run halui.program.run <= ---- == Pause & Resume diff --git a/docs/src/hal/intro.adoc b/docs/src/hal/intro.adoc index b9e3bc8cb1b..a21b3456423 100644 --- a/docs/src/hal/intro.adoc +++ b/docs/src/hal/intro.adoc @@ -242,9 +242,6 @@ The same commands used to build the system can be used to make changes as needed This document is aimed at people who already know how to do this kind of hardware system integration, but who do not know how to connect the hardware to LinuxCNC. See the <> section in the HAL UI Examples documentation. -.Remote Start Example (Schema) -image::images/remote-start.png["Remote Start Example (Schema)"] - The traditional hardware design as described above ends at the edge of the main control. Outside the control are a bunch of relatively simple boxes, connected together to do whatever is needed. Inside, the control is a big mystery -- one huge black box that we hope works. diff --git a/docs/src/man/man1/halui.1.adoc b/docs/src/man/man1/halui.1.adoc index 2ba190417c4..c4439e15036 100644 --- a/docs/src/man/man1/halui.1.adoc +++ b/docs/src/man/man1/halui.1.adoc @@ -142,10 +142,9 @@ contact) connect the physical button to a HAL debounce filter first. === Mode -*halui.mode.auto* bool in:: - does nothing. The task mode follows what task runs and cannot be set. *halui.mode.is-auto* bool out:: - a program runs, or is paused + a program runs, or is paused. The task mode follows what task runs and + cannot be set. *halui.mode.is-joint* bool out:: pin showing joint by joint jog mode is on *halui.mode.is-manual* bool out:: @@ -156,10 +155,6 @@ contact) connect the physical button to a HAL debounce filter first. pin showing coordinated jog mode is on *halui.mode.joint* bool in:: pin for requesting joint by joint jog mode -*halui.mode.manual* bool in:: - does nothing, see *halui.mode.auto* -*halui.mode.mdi* bool in:: - does nothing, see *halui.mode.auto* *halui.mode.teleop* bool in:: pin for requesting coordinated jog mode diff --git a/docs/src/man/man1/xhc-whb04b-6.1.adoc b/docs/src/man/man1/xhc-whb04b-6.1.adoc index 6cd5f625ab2..fe06c5acb58 100644 --- a/docs/src/man/man1/xhc-whb04b-6.1.adoc +++ b/docs/src/man/man1/xhc-whb04b-6.1.adoc @@ -235,7 +235,8 @@ Signals for operating program and MDI mode. `whb.halui.program.is-idle` (bool, in):: Connect to `halui.program.is-idle`. Pin indicating no program is running. `whb.halui.mode.auto` (bool, out):: - Connect to `halui.mode.auto`. Pin for requesting auto mode. + Pin for requesting auto mode. Leave unconnected: the task mode cannot be set + and halui has no pin for it. `whb.halui.mode.is-auto` (bool, in):: Connect to `halui.mode.is-auto`. Pin for indicating auto mode is on. `whb.halui.mode.joint` (bool, out):: @@ -243,11 +244,11 @@ Signals for operating program and MDI mode. `whb.halui.mode.is-joint` (bool, in):: Connect to `halui.mode.is-joint`. Pin indicating joint by joint mode is on. `whb.halui.mode.manual` (bool, out):: - Connect to `halui.mode.manual`. Pin for requesting manual mode. + Pin for requesting manual mode. Leave unconnected, see `whb.halui.mode.auto`. `whb.halui.mode.is-manual` (bool, in):: Connect to `halui.mode.is-manual`. Pin indicating manual mode is on. `whb.halui.mode.mdi` (bool, out):: - Connect to `halui.mode.mdi`. Pin for requesting MDI mode. + Pin for requesting MDI mode. Leave unconnected, see `whb.halui.mode.auto`. `whb.halui.mode.is-mdi` (bool, in):: Connect to `halui.mode.is-mdi`. Pin indicating MDI mode is on. `whb.halui.mode.teleop` (bool, out):: @@ -419,9 +420,6 @@ net pdnt.program.run whb.halui.program.run net pdnt.program.stop whb.halui.program.stop halui.program.stop # machine mode related signals -net pdnt.mode.auto whb.halui.mode.auto halui.mode.auto -net pdnt.mode.manual whb.halui.mode.manual halui.mode.manual -net pdnt.mode.mdi whb.halui.mode.mdi halui.mode.mdi net pdnt.mode.joint whb.halui.mode.joint halui.mode.joint net pdnt.mode.teleop whb.halui.mode.teleop halui.mode.teleop net pdnt.mode.is-auto halui.mode.is-auto whb.halui.mode.is-auto diff --git a/lib/hallib/xhc-hb04.tcl b/lib/hallib/xhc-hb04.tcl index 50ad8fe9b84..242ac5e3c8b 100644 --- a/lib/hallib/xhc-hb04.tcl +++ b/lib/hallib/xhc-hb04.tcl @@ -390,8 +390,7 @@ proc std_start_pause_button {} { makenet pendant:program-pause <= pendant_util.pause \ => halui.program.pause makenet pendant:program-run <= pendant_util.run \ - => halui.program.run \ - => halui.mode.auto + => halui.program.run # accommodate existing signames for halui outpins: makenet [existing_outpin_signame halui.program.is-idle pendant:is-idle] \ diff --git a/src/emc/nml_intf/emc.cc b/src/emc/nml_intf/emc.cc index 971b92cc2a8..f5d10088ef4 100644 --- a/src/emc/nml_intf/emc.cc +++ b/src/emc/nml_intf/emc.cc @@ -202,8 +202,6 @@ int emcFormat(NMLTYPE type, void *buffer, CMS * cms) case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: ((EMC_TASK_PLAN_OPTIONAL_STOP *) buffer)->update(cms); break; - case EMC_TASK_SET_MODE_TYPE: - ((EMC_TASK_SET_MODE *) buffer)->update(cms); break; case EMC_TASK_SET_STATE_TYPE: ((EMC_TASK_SET_STATE *) buffer)->update(cms); @@ -430,8 +428,6 @@ const char *emc_symbol_lookup(uint32_t type) return "EMC_TASK_PLAN_SET_BLOCK_DELETE"; case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: return "EMC_TASK_PLAN_OPTIONAL_STOP"; - case EMC_TASK_SET_MODE_TYPE: - return "EMC_TASK_SET_MODE"; case EMC_TASK_SET_STATE_TYPE: return "EMC_TASK_SET_STATE"; case EMC_TASK_STAT_TYPE: @@ -1381,18 +1377,6 @@ void EMC_STAT_MSG::update(CMS * /*cms*/) } -/* -* NML/CMS Update function for EMC_TASK_SET_MODE -* Automatically generated by NML CodeGen Java Applet. -* on Sat Oct 11 13:45:16 UTC 2003 -*/ -// cppcheck-suppress duplInheritedMember -void EMC_TASK_SET_MODE::update(CMS * cms) -{ - EMC_TASK_CMD_MSG::update(cms); - cms->update((int *) &mode, 1); -} - /* * NML/CMS Update function for EMC_JOG_INCR */ diff --git a/src/emc/nml_intf/emc.hh b/src/emc/nml_intf/emc.hh index c4fd823735f..6ee7ddfe2c0 100644 --- a/src/emc/nml_intf/emc.hh +++ b/src/emc/nml_intf/emc.hh @@ -118,7 +118,6 @@ struct PM_CARTESIAN; // NML for EMC_TASK #define EMC_TASK_ABORT_TYPE ((NMLTYPE) 503) -#define EMC_TASK_SET_MODE_TYPE ((NMLTYPE) 504) #define EMC_TASK_SET_STATE_TYPE ((NMLTYPE) 505) #define EMC_TASK_PLAN_OPEN_TYPE ((NMLTYPE) 506) #define EMC_TASK_PLAN_RUN_TYPE ((NMLTYPE) 507) diff --git a/src/emc/nml_intf/emc_nml.hh b/src/emc/nml_intf/emc_nml.hh index 8bdc4976dd8..c97b41ca10c 100644 --- a/src/emc/nml_intf/emc_nml.hh +++ b/src/emc/nml_intf/emc_nml.hh @@ -1115,21 +1115,6 @@ class EMC_TASK_ABORT:public EMC_TASK_CMD_MSG { void update(CMS * cms); }; -class EMC_TASK_SET_MODE:public EMC_TASK_CMD_MSG { - public: - EMC_TASK_SET_MODE() - : EMC_TASK_CMD_MSG(EMC_TASK_SET_MODE_TYPE, sizeof(EMC_TASK_SET_MODE)), - mode(EMC_TASK_MODE::AUTO) - {}; - - // For internal NML/CMS use only. - // Sub-class update() calls base-class update() - // cppcheck-suppress duplInheritedMember - void update(CMS * cms); - - EMC_TASK_MODE mode; -}; - class EMC_TASK_SET_STATE:public EMC_TASK_CMD_MSG { public: EMC_TASK_SET_STATE() diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 5d2147d276b..290a7221afe 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -1172,13 +1172,11 @@ static int emcTaskPlan(NMLmsg *cmd) const NMLTYPE type = cmd ? cmd->_type : 0; int retval = 0; - // Always display messages. A mode change is accepted in any state and - // does nothing, see EMC_TASK_SET_MODE_TYPE in emcTaskIssueCommand(). + // Always display messages switch (type) { case EMC_OPERATOR_ERROR_TYPE: case EMC_OPERATOR_TEXT_TYPE: case EMC_OPERATOR_DISPLAY_TYPE: - case EMC_TASK_SET_MODE_TYPE: return emcTaskIssueCommand(cmd); } @@ -1712,13 +1710,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) retval = 0; break; - // mode and state commands - - case EMC_TASK_SET_MODE_TYPE: - // The task mode reports what task is running (determineMode()) and - // cannot be set. Accept the request so existing clients keep working. - retval = 0; - break; + // state commands case EMC_TASK_SET_STATE_TYPE: retval = emcTaskSetState(reinterpret_cast(cmd)->state); diff --git a/src/emc/task/taskhal.cc b/src/emc/task/taskhal.cc index 920795fd260..73048de6a51 100644 --- a/src/emc/task/taskhal.cc +++ b/src/emc/task/taskhal.cc @@ -401,17 +401,6 @@ static void queue_state(EMC_TASK_STATE state) queue(std::move(msg)); } -// like halui, a mode command for the current mode is not sent at all -static void queue_mode(const EMC_STAT &stat, EMC_TASK_MODE mode) -{ - if (stat.task.mode == mode) { - return; - } - auto msg = std::make_unique(); - msg->mode = mode; - queue(std::move(msg)); -} - static void queue_teleop(int enable) { auto msg = std::make_unique(); @@ -438,7 +427,6 @@ static void queue_program_run(const EMC_STAT &stat) if (stat.task.file[0] == 0) { return; // no program open } - queue_mode(stat, EMC_TASK_MODE::AUTO); auto msg = std::make_unique(); msg->line = 0; queue(std::move(msg)); diff --git a/src/emc/task/test_task_probe.cc b/src/emc/task/test_task_probe.cc index 630e3d585df..df46c0eb0a5 100644 --- a/src/emc/task/test_task_probe.cc +++ b/src/emc/task/test_task_probe.cc @@ -182,9 +182,6 @@ static std::vector> commands() CMD("EMC_TASK_PLAN_REVERSE", EMC_TASK_PLAN_REVERSE, ); CMD("EMC_TASK_PLAN_FORWARD", EMC_TASK_PLAN_FORWARD, ); CMD("EMC_TASK_ABORT", EMC_TASK_ABORT, ); - CMD("EMC_TASK_SET_MODE(MANUAL)", EMC_TASK_SET_MODE, m->mode = EMC_TASK_MODE::MANUAL); - CMD("EMC_TASK_SET_MODE(AUTO)", EMC_TASK_SET_MODE, m->mode = EMC_TASK_MODE::AUTO); - CMD("EMC_TASK_SET_MODE(MDI)", EMC_TASK_SET_MODE, m->mode = EMC_TASK_MODE::MDI); CMD("EMC_TASK_SET_STATE(ESTOP)", EMC_TASK_SET_STATE, m->state = EMC_TASK_STATE::ESTOP); CMD("EMC_TASK_SET_STATE(ESTOP_RESET)", EMC_TASK_SET_STATE, m->state = EMC_TASK_STATE::ESTOP_RESET); CMD("EMC_TASK_SET_STATE(OFF)", EMC_TASK_SET_STATE, m->state = EMC_TASK_STATE::OFF); diff --git a/src/emc/usr_intf/emclcd.cc b/src/emc/usr_intf/emclcd.cc index 67305fa289e..ce3d9225b8f 100644 --- a/src/emc/usr_intf/emclcd.cc +++ b/src/emc/usr_intf/emclcd.cc @@ -926,7 +926,6 @@ static int openProgram(char *s) widgetSetStr(PROG_WIDGET1, s, ""); widgetSetStr(PROG_WIDGET2, s, ""); if (sendTaskPlanInit() != 0) return -1; - sendAuto(); return sendProgramOpen(fname); } @@ -1143,7 +1142,6 @@ static int jog(int jnum, float speed) else stepSize = 1.0; if ((jnum < 0) || (jnum > 5)) return -1; // if (runStatus == rsIdle) { -// sendManual(); switch (jogMode) { case jtCont: if (jogging == 1) { // toggle if driver does not support key down / key up @@ -1240,17 +1238,6 @@ static int stepKey() return sendProgramStep(); } -static int toggleMode() - -{ - switch (emcStatus->task.mode) { - case EMC_TASK_MODE::MANUAL: sendAuto(); break; - case EMC_TASK_MODE::AUTO: sendManual(); break; - case EMC_TASK_MODE::MDI: sendAuto(); break; - } - return 0; -} - static int nextKey() { int temp; @@ -1347,9 +1334,7 @@ static int doKey(keyType k) stepKey(); break; case ktStepRelease: break; - case ktTestPress: - toggleMode(); - break; + case ktTestPress: break; // used to toggle the task mode, which cannot be set case ktTestRelease: break; case ktHelpPress: break; case ktHelpRelease: break; diff --git a/src/emc/usr_intf/emcsched.cc b/src/emc/usr_intf/emcsched.cc index 00465cd1b7c..76d16eb9456 100644 --- a/src/emc/usr_intf/emcsched.cc +++ b/src/emc/usr_intf/emcsched.cc @@ -256,7 +256,6 @@ void updateQueue() { if (interlocksOk()) { sendFeedOverride(((double) q.front().getFeedOverride()) / 100.0); sendSpindleOverride(0, ((double) q.front().getSpindleOverride()) / 100.0); - sendMdi(); sendMdiCmd("G92.1\n"); if (emcCommandWaitDone() != 0) { queueStatus = qsError; @@ -296,7 +295,6 @@ void updateQueue() { if (sendTaskPlanInit() != 0) { queueStatus = qsError; } - sendAuto(); strxcpy(fileStr, defaultPath.c_str()); strxcat(fileStr, q.front().getFileName().c_str()); if (sendProgramOpen(fileStr) != 0) { diff --git a/src/emc/usr_intf/halui.cc b/src/emc/usr_intf/halui.cc index 3a7929f45d2..2ae1f3e5a22 100644 --- a/src/emc/usr_intf/halui.cc +++ b/src/emc/usr_intf/halui.cc @@ -59,12 +59,9 @@ static int axis_mask = 0; FIELD(bool,estop_reset) /* pin for resetting ESTOP */ \ FIELD(bool,estop_is_activated) /* pin for status ESTOP is activated */ \ \ - FIELD(bool,mode_manual) /* pin for requesting manual mode */ \ - FIELD(bool,mode_is_manual) /* pin for manual mode is on */ \ - FIELD(bool,mode_auto) /* pin for requesting auto mode */ \ - FIELD(bool,mode_is_auto) /* pin for auto mode is on */ \ - FIELD(bool,mode_mdi) /* pin for requesting mdi mode */ \ - FIELD(bool,mode_is_mdi) /* pin for mdi mode is on */ \ + FIELD(bool,mode_is_manual) /* pin for manual mode is on: task is idle */ \ + FIELD(bool,mode_is_auto) /* pin for auto mode is on: a program runs */ \ + FIELD(bool,mode_is_mdi) /* pin for mdi mode is on: MDI runs */ \ FIELD(bool,mode_teleop) /* pin for requesting teleop mode */ \ FIELD(bool,mode_is_teleop) /* pin for teleop mode is on */ \ FIELD(bool,mode_joint) /* pin for requesting joint mode */ \ @@ -660,9 +657,6 @@ int halui_hal_init(void) CHK(halui_export_pin_IN_bool(&(halui_data->machine_off), "halui.machine.off")); CHK(halui_export_pin_IN_bool(&(halui_data->estop_activate), "halui.estop.activate")); CHK(halui_export_pin_IN_bool(&(halui_data->estop_reset), "halui.estop.reset")); - CHK(halui_export_pin_IN_bool(&(halui_data->mode_manual), "halui.mode.manual")); - CHK(halui_export_pin_IN_bool(&(halui_data->mode_auto), "halui.mode.auto")); - CHK(halui_export_pin_IN_bool(&(halui_data->mode_mdi), "halui.mode.mdi")); CHK(halui_export_pin_IN_bool(&(halui_data->mode_teleop), "halui.mode.teleop")); CHK(halui_export_pin_IN_bool(&(halui_data->mode_joint), "halui.mode.joint")); CHK(halui_export_pin_IN_bool(&(halui_data->mist_on), "halui.mist.on")); @@ -1393,9 +1387,6 @@ static void check_hal_changes() if (check_bit_changed(new_halui_data.estop_reset, old_halui_data.estop_reset) != 0) sendEstopReset(); - // halui.mode.manual, .auto and .mdi do nothing: the task mode follows - // what task runs - if (check_bit_changed(new_halui_data.mode_teleop, old_halui_data.mode_teleop) != 0) sendTeleop(); diff --git a/src/emc/usr_intf/shcom.cc b/src/emc/usr_intf/shcom.cc index 262ca782f0c..18db82fdee2 100644 --- a/src/emc/usr_intf/shcom.cc +++ b/src/emc/usr_intf/shcom.cc @@ -478,30 +478,6 @@ int sendMachineOff() return emcSendCommandAndWait(state_msg); } -int sendManual() -{ - EMC_TASK_SET_MODE mode_msg; - - mode_msg.mode = EMC_TASK_MODE::MANUAL; - return emcSendCommandAndWait(mode_msg); -} - -int sendAuto() -{ - EMC_TASK_SET_MODE mode_msg; - - mode_msg.mode = EMC_TASK_MODE::AUTO; - return emcSendCommandAndWait(mode_msg); -} - -int sendMdi() -{ - EMC_TASK_SET_MODE mode_msg; - - mode_msg.mode = EMC_TASK_MODE::MDI; - return emcSendCommandAndWait(mode_msg); -} - int sendOverrideLimits(int joint) { EMC_JOINT_OVERRIDE_LIMITS lim_msg; diff --git a/src/emc/usr_intf/shcom.hh b/src/emc/usr_intf/shcom.hh index 9a7abd4fda4..a12a3d5f1b1 100644 --- a/src/emc/usr_intf/shcom.hh +++ b/src/emc/usr_intf/shcom.hh @@ -96,9 +96,6 @@ extern int sendEstop(); extern int sendEstopReset(); extern int sendMachineOn(); extern int sendMachineOff(); -extern int sendManual(); -extern int sendAuto(); -extern int sendMdi(); extern int sendOverrideLimits(int jnum); extern int sendJogStop(int jnum, int jjogmode); extern int sendJogCont(int jnum, int jjogmode, double speed); diff --git a/src/hal/user_comps/xhc-whb04b-6/example-configuration.hal b/src/hal/user_comps/xhc-whb04b-6/example-configuration.hal index 636908c9a2b..efc1f7982f0 100644 --- a/src/hal/user_comps/xhc-whb04b-6/example-configuration.hal +++ b/src/hal/user_comps/xhc-whb04b-6/example-configuration.hal @@ -55,9 +55,6 @@ net pdnt.program.run whb.halui.program.run net pdnt.program.stop whb.halui.program.stop halui.program.stop # machine mode related signals -net pdnt.mode.auto whb.halui.mode.auto halui.mode.auto -net pdnt.mode.manual whb.halui.mode.manual halui.mode.manual -net pdnt.mode.mdi whb.halui.mode.mdi halui.mode.mdi net pdnt.mode.joint whb.halui.mode.joint halui.mode.joint net pdnt.mode.teleop whb.halui.mode.teleop halui.mode.teleop net pdnt.mode.is-auto halui.mode.is-auto whb.halui.mode.is-auto From 1e7313190cc99ea2cc20ce80dc650a0227dc37bb Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Fri, 16 Oct 2026 22:44:13 +0200 Subject: [PATCH 18/27] task: DONE only once a run has ended and motion is back When the last MDI command finished, task reported DONE in the cycle before the run ended, and again before motion was back in joint or world mode. A client waiting for DONE could then see coordinated mode, or have an axis jog refused: linuxcncrsh's test read TELEOP_ENABLE OFF after its MDI commands on CI. Task now reports DONE only when no run is on and motion is in the mode the run went back to (with a 1 s timeout should motion not get there). tests/task-modeless checks that motion is in world mode as soon as an MDI command is DONE, and that a jog right after is accepted. --- src/emc/task/emctaskmain.cc | 18 +++++++++++++++++- tests/task-modeless/test-ui.py | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 290a7221afe..aa2b4b6b68c 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -728,6 +728,12 @@ static const double COORD_WAIT_TIMEOUT = 5.0; static EMC_TRAJ_MODE runPriorMode = EMC_TRAJ_MODE::FREE; static bool runPriorHomed = false; static EMC_TRAJ_MODE idleMode = EMC_TRAJ_MODE::FREE; +// Set by taskRunEnd() until motion is in idleMode. Task is not DONE while +// a run is on or before that, so a client that waits for DONE and then +// jogs finds motion ready. +static bool idleModePending = false; +static double idleModeSince = 0.0; +static const double IDLE_MODE_TIMEOUT = 1.0; // Leave idle for a run. Returns -1, with an operator error, if the run may // not start. @@ -764,6 +770,7 @@ static int taskRunStart(TaskRun run) } coordWaiting = true; coordWaitStart = etime(); + idleModePending = false; if (mdi && taskplanopen) { // what a switch to MDI mode did: MDI does not run with the @@ -790,6 +797,8 @@ static void taskRunEnd() } idleMode = mode; emcTrajSetMode(mode); + idleModePending = true; + idleModeSince = etime(); } // End the run once the interpreter is idle: a program that ran to its end, @@ -3204,6 +3213,12 @@ int main(int argc, char *argv[]) emcStatus->command_type = emcCommand->_type; emcStatus->echo_serial_number = emcCommand->serial_number; + if (idleModePending + && (emcStatus->motion.traj.mode == idleMode + || etime() - idleModeSince > IDLE_MODE_TIMEOUT)) { + idleModePending = false; + } + if (taskPlanError || taskExecuteError || emcStatus->task.execState == EMC_TASK_EXEC::ERROR || emcStatus->motion.status == RCS_STATUS::ERROR || @@ -3217,7 +3232,8 @@ int main(int argc, char *argv[]) mdi_execute_queue.len() == 0 && interp_list.len() == 0 && emcTaskCommand == NULL && - emcStatus->task.interpState == EMC_TASK_INTERP::IDLE) { + emcStatus->task.interpState == EMC_TASK_INTERP::IDLE && + taskRun == TaskRun::NONE && !idleModePending) { emcStatus->status = RCS_STATUS::DONE; emcStatus->task.status = RCS_STATUS::DONE; } else { diff --git a/tests/task-modeless/test-ui.py b/tests/task-modeless/test-ui.py index febae9f2c42..fca07787715 100755 --- a/tests/task-modeless/test-ui.py +++ b/tests/task-modeless/test-ui.py @@ -111,6 +111,23 @@ def modes(): check('halui sees manual', wait(lambda: hal.get_value('task.mode.is-manual'))) check('no errors from MDI', not errors()) +# --- DONE means ready: right after wait_complete() motion is back in world +# mode and a world jog is accepted +for i in range(5): + c.mdi('G0 X%d' % (i % 2)) + r = c.wait_complete() + s.poll() + if r != linuxcnc.RCS_DONE or s.motion_mode != linuxcnc.TRAJ_MODE_TELEOP: + break +check('world mode as soon as MDI is DONE', r == linuxcnc.RCS_DONE and s.motion_mode == linuxcnc.TRAJ_MODE_TELEOP, (r, modes())) +c.jog(linuxcnc.JOG_INCREMENT, False, 1, 10, 0.1) +c.wait_complete() +check('a jog right after MDI is accepted', wait(lambda: abs(s.actual_position[1] - 0.1) < 1e-6, 2) and not errors(), s.actual_position[1]) +c.jog(linuxcnc.JOG_INCREMENT, False, 1, 10, -0.1) +wait(lambda: abs(s.actual_position[1]) < 1e-6) +c.mdi('G0 X1') +wait(idle) + # --- wheel jog while idle after MDI hal.set_p('axis.x.jog-enable', '1') hal.set_p('axis.x.jog-counts', '100') From c9f8e95b8ebd5a8bdc9e933a44a69af714a7c946 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Sun, 18 Oct 2026 05:14:24 +0200 Subject: [PATCH 19/27] gscreen: fix startup crash, use self.inifile for maplinearunits --- src/emc/usr_intf/gscreen/gscreen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emc/usr_intf/gscreen/gscreen.py b/src/emc/usr_intf/gscreen/gscreen.py index 3388bdb7ab6..593f1b1700d 100755 --- a/src/emc/usr_intf/gscreen/gscreen.py +++ b/src/emc/usr_intf/gscreen/gscreen.py @@ -636,7 +636,7 @@ def __init__(self): units=self.inifile.find("AXIS_X","UNITS") if units==None: self.add_alarm_entry(_("No UNITS entry found in [TRAJ] or [AXIS_X] of INI file")) - units = inifile.maplinearunits(units, fallback=1.0) + units = self.inifile.maplinearunits(units, fallback=1.0) if 1.0 == units: self.machine_units_mm=1 conversion=axis_kinds.unit_factors(self.inifile, 1.0/25.4) From 57308dd357d4ed3055e1844db69cadd9c3bb4414 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Sun, 18 Oct 2026 05:14:24 +0200 Subject: [PATCH 20/27] GStat, qtvcp, gladevcp: jog and spindle while paused GStat gets is_jog_ok(), is_spindle_ok(), is_pause_jog_ok() and a pause-jog-ok-changed signal. Jog and spindle action buttons use them, STOP_JOG works while paused, and UPDATE_VAR_FILE saves the parameter file with task_plan_synch() instead of a mode change. --- .../getting-started/updating-linuxcnc.adoc | 20 ++++++++++-- docs/src/gui/gstat.adoc | 20 ++++++++++++ docs/src/gui/qtvcp.adoc | 2 +- lib/python/common/hal_glib.py | 31 +++++++++++++++++++ lib/python/gladevcp/gtk_action.py | 9 ++++-- lib/python/qtvcp/qt_action.py | 9 ++++-- lib/python/qtvcp/widgets/action_button.py | 17 ++++++++-- 7 files changed, 96 insertions(+), 12 deletions(-) diff --git a/docs/src/getting-started/updating-linuxcnc.adoc b/docs/src/getting-started/updating-linuxcnc.adoc index 18b0950206a..92904420d87 100644 --- a/docs/src/getting-started/updating-linuxcnc.adoc +++ b/docs/src/getting-started/updating-linuxcnc.adoc @@ -313,8 +313,24 @@ has stopped the motion. Joints cannot. On resume (or step) LinuxCNC first: Pausing again during the return stops it; the axes can be jogged again from there. An abort keeps the machine where it was jogged to. Reverse -run is refused while the axes are away from the paused position. AXIS -enables its jog and spindle controls while paused. +run is refused while the axes are away from the paused position. + +AXIS, gmoccapy, gscreen, touchy and the QtVCP screens (except QtPlasmaC, +which keeps its own cut recovery) enable their jog and spindle controls +while paused. Custom screens and handler files that allow jogs only in +manual mode should check the new GStat functions instead: + +* `is_jog_ok()`: the machine is on and in manual mode, or a pause has + stopped the motion (`stat.pause_jog_ok`). Jogs while paused are axis + jogs in coordinated mode: do not call `teleop_enable()` first, task + refuses it while a program or MDI command runs. +* `is_spindle_ok()`: the machine is on and in manual mode, or the + interpreter is paused. +* the `pause-jog-ok-changed` signal, to enable and disable jog controls. + +Code that saved the parameter file by switching modes (the QtVCP and +GladeVCP `UPDATE_VAR_FILE` action did) should use `task_plan_synch()`: +the interpreter writes the parameter file whenever it synchs. == Preview renderer now requires OpenGL 3.3 core diff --git a/docs/src/gui/gstat.adoc b/docs/src/gui/gstat.adoc index 434aa36595d..c72cb5985b5 100644 --- a/docs/src/gui/gstat.adoc +++ b/docs/src/gui/gstat.adoc @@ -269,6 +269,11 @@ It is expected to be in the machine's native units regardless of the current uni *program-pause-changed* :: '(returns bool)' - Sent when program is paused/unpaused. +*pause-jog-ok-changed* :: '(returns bool)' - +Sent when a pause of a program or MDI command has stopped the motion, so the +axes may jog, and again when that ends (resume, step or abort). + +See *is_jog_ok*. + *optional-stop-changed* :: '(returns bool)' - Sent when optional stop is set/unset @@ -669,6 +674,21 @@ returns string representing the internal selected axis letter. *is_mdi_mode* :: '(None)' - +*is_pause_jog_ok* :: '(None)' - +returns True while a pause has stopped the motion of a program or MDI command: +the axes (not the joints) may jog. Resume or step brings them back to the +paused position first. + +*is_jog_ok* :: '(None)' - +returns True when the machine is on and jogs are possible: in manual mode, and +for the axes while paused (see *is_pause_jog_ok*). Use this, not +*is_man_mode*, to enable jog controls and keyboard jogging. + +*is_spindle_ok* :: '(None)' - +returns True when the machine is on and spindle commands are possible: in +manual mode and while the interpreter is paused. Resume puts the spindles back +as they were at the pause. + *is_auto_mode* :: '(None)' - *is_on_and_idle* :: '(None)' - diff --git a/docs/src/gui/qtvcp.adoc b/docs/src/gui/qtvcp.adoc index 428ca9ffe8e..9fd4d66a230 100644 --- a/docs/src/gui/qtvcp.adoc +++ b/docs/src/gui/qtvcp.adoc @@ -845,7 +845,7 @@ class HandlerClass: # keyboard jogging from key binding calls # double the rate if fast is true def kb_jog(self, state, joint, direction, fast = False, linear = True): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): return if linear: distance = STATUS.get_jog_increment() diff --git a/lib/python/common/hal_glib.py b/lib/python/common/hal_glib.py index 0d0f9c574fe..74b647be9e8 100644 --- a/lib/python/common/hal_glib.py +++ b/lib/python/common/hal_glib.py @@ -145,6 +145,7 @@ class _GStat(GObject.GObject): 'axis-selection-changed': (GObject.SignalFlags.RUN_FIRST , GObject.TYPE_NONE, (GObject.TYPE_STRING,)), 'program-pause-changed': (GObject.SignalFlags.RUN_FIRST , GObject.TYPE_NONE, (GObject.TYPE_BOOLEAN,)), + 'pause-jog-ok-changed': (GObject.SignalFlags.RUN_FIRST , GObject.TYPE_NONE, (GObject.TYPE_BOOLEAN,)), 'optional-stop-changed': (GObject.SignalFlags.RUN_FIRST , GObject.TYPE_NONE, (GObject.TYPE_BOOLEAN,)), 'block-delete-changed': (GObject.SignalFlags.RUN_FIRST , GObject.TYPE_NONE, (GObject.TYPE_BOOLEAN,)), @@ -436,6 +437,7 @@ def merge(self): if self.stat.call_level == 0: self.old['file'] = self.stat.file self.old['paused']= self.stat.paused + self.old['pause-jog-ok'] = self.stat.pause_jog_ok self.old['line'] = self.stat.motion_line self.old['homed'] = self.stat.homed self.old['tool-in-spindle'] = self.stat.tool_in_spindle @@ -655,6 +657,11 @@ def update(self): paused_new = self.old['paused'] if paused_new != paused_old: self.emit('program-pause-changed',paused_new) + # axes may jog: a pause has stopped the motion + pause_jog_ok_old = old.get('pause-jog-ok', None) + pause_jog_ok_new = self.old['pause-jog-ok'] + if pause_jog_ok_new != pause_jog_ok_old: + self.emit('pause-jog-ok-changed', pause_jog_ok_new) # block delete block_delete_old = old.get('block-delete', None) block_delete_new = self.old['block-delete'] @@ -1028,6 +1035,7 @@ def forced_update(self): # paused paused_new = self.old['paused'] self.emit('program-pause-changed',paused_new) + self.emit('pause-jog-ok-changed', self.old['pause-jog-ok']) # block delete block_delete_new = self.old['block-delete'] self.emit('block-delete-changed',block_delete_new) @@ -1289,6 +1297,26 @@ def is_mdi_mode(self): self.stat.poll() return self.stat.task_mode == linuxcnc.MODE_MDI + # A pause of a program or MDI command has stopped the motion: axes (not + # joints) may jog, resume brings them back to the paused position. + def is_pause_jog_ok(self): + self.stat.poll() + return self.stat.pause_jog_ok + + # Jogs are fine in manual mode and, for axes, while paused. + def is_jog_ok(self): + self.stat.poll() + return self.stat.task_state == linuxcnc.STATE_ON and \ + (self.stat.task_mode == linuxcnc.MODE_MANUAL or self.stat.pause_jog_ok) + + # Spindle commands are fine in manual mode and while paused: resume puts + # the spindles back as they were at the pause. + def is_spindle_ok(self): + self.stat.poll() + return self.stat.task_state == linuxcnc.STATE_ON and \ + (self.stat.task_mode == linuxcnc.MODE_MANUAL or + self.stat.interp_state == linuxcnc.INTERP_PAUSED) + def is_auto_mode(self): self.stat.poll() return self.stat.task_mode == linuxcnc.MODE_AUTO @@ -1417,6 +1445,9 @@ def get_jjogmode(self): return JOGJOINT if self.stat.motion_mode == linuxcnc.TRAJ_MODE_TELEOP: return JOGTELEOP + if self.stat.pause_jog_ok: + # jogs while paused are axis jogs, in coordinated mode + return JOGTELEOP LOG.warning("Unexpected motion_mode {}, ".format(self.stat.motion_mode)) return JOGTELEOP diff --git a/lib/python/gladevcp/gtk_action.py b/lib/python/gladevcp/gtk_action.py index a5981f3a0c7..9796ab09fb3 100644 --- a/lib/python/gladevcp/gtk_action.py +++ b/lib/python/gladevcp/gtk_action.py @@ -238,9 +238,12 @@ def CALL_OWORD(self, code, time=5): LOG.debug('OWORD_COMMAND returns complete : {}'.format(result)) return 0 + # The interpreter writes the parameter file when it synchs: once the + # MDI commands before are done, ask for one. def UPDATE_VAR_FILE(self): - self.ensure_mode(linuxcnc.MODE_MANUAL) - self.ensure_mode(linuxcnc.MODE_MDI) + self.cmd.wait_complete() + self.cmd.task_plan_synch() + self.cmd.wait_complete() def OPEN_PROGRAM(self, fname): self.prefilter_path = str(fname) @@ -529,7 +532,7 @@ def JOG(self, jointnum, direction, rate, distance=0): self.cmd.jog(linuxcnc.JOG_INCREMENT, jjogmode, j_or_a, direction * rate, distance) def STOP_JOG(self, jointnum): - if STATUS.machine_is_on() and STATUS.is_man_mode(): + if STATUS.machine_is_on() and STATUS.is_jog_ok(): jjogmode, j_or_a = self.get_jog_info(jointnum) self.cmd.jog(linuxcnc.JOG_STOP, jjogmode, j_or_a) diff --git a/lib/python/qtvcp/qt_action.py b/lib/python/qtvcp/qt_action.py index 8c81b08a3d6..d6688973199 100644 --- a/lib/python/qtvcp/qt_action.py +++ b/lib/python/qtvcp/qt_action.py @@ -321,9 +321,12 @@ def CALL_OWORD(self, code, time=5): LOG.debug('OWORD_COMMAND returns complete : {}'.format(result)) return 0 + # The interpreter writes the parameter file when it synchs: once the + # MDI commands before are done, ask for one. def UPDATE_VAR_FILE(self): - self.ensure_mode(linuxcnc.MODE_MANUAL) - self.ensure_mode(linuxcnc.MODE_MDI) + self.cmd.wait_complete() + self.cmd.task_plan_synch() + self.cmd.wait_complete() def OPEN_PROGRAM(self, fname): self.prefilter_path = str(fname) @@ -666,7 +669,7 @@ def JOG(self, jointnum, direction, rate, distance=0): self.cmd.jog(linuxcnc.JOG_INCREMENT, jjogmode, j_or_a, direction * rate, distance) def STOP_JOG(self, jointnum): - if STATUS.machine_is_on() and STATUS.is_man_mode(): + if STATUS.machine_is_on() and STATUS.is_jog_ok(): jjogmode, j_or_a = self.get_jog_info(jointnum) self.cmd.jog(linuxcnc.JOG_STOP, jjogmode, j_or_a) diff --git a/lib/python/qtvcp/widgets/action_button.py b/lib/python/qtvcp/widgets/action_button.py index faeba54d228..51143cf289d 100644 --- a/lib/python/qtvcp/widgets/action_button.py +++ b/lib/python/qtvcp/widgets/action_button.py @@ -295,6 +295,9 @@ def spindle_control_test(e,d): STATUS.connect('interp-idle', lambda w: self.setEnabled(STATUS.machine_is_on())) STATUS.connect('interp-run', lambda w: self.setEnabled(False)) STATUS.connect('interp-paused', lambda w: self.setEnabled(False)) + # axes jog while a pause has stopped the motion + STATUS.connect('pause-jog-ok-changed', lambda w, ok: self.setEnabled( + ok or (STATUS.machine_is_on() and STATUS.is_interp_idle()))) if self.jog_joint_pos: self.pressed.connect(lambda: self.jog_action(1)) self.released.connect(lambda: self.jog_action(0)) @@ -385,6 +388,9 @@ def spindle_control_test(e,d): STATUS.connect('state-off', lambda w: self.setEnabled(False)) STATUS.connect('state-estop', lambda w: self.setEnabled(False)) STATUS.connect('state-on', lambda w: self.setEnabled(True)) + # the spindle may be used while paused: resume puts it back + for sig in ('interp-paused', 'interp-reading', 'interp-waiting', 'interp-idle'): + STATUS.connect(sig, lambda w: self.setEnabled(STATUS.is_spindle_ok())) if self.spindle_fwd or self.spindle_rev: STATUS.connect('spindle-control-changed', lambda w, num, e, d, upto: spindle_control_test(e,d)) elif self.spindle_stop: @@ -393,7 +399,12 @@ def spindle_control_test(e,d): STATUS.connect('mode-auto', lambda w: self.setEnabled(False)) STATUS.connect('state-off', lambda w: self.setEnabled(False)) STATUS.connect('state-estop', lambda w: self.setEnabled(False)) - STATUS.connect('spindle-control-changed', lambda w,num, e, d, upto: self.setEnabled(e and not STATUS.is_auto_mode())) + def stop_test(): + return STATUS.is_spindle_on() and \ + (not STATUS.is_auto_mode() or STATUS.is_interp_paused()) + for sig in ('interp-paused', 'interp-reading', 'interp-waiting', 'interp-idle'): + STATUS.connect(sig, lambda w: self.setEnabled(stop_test())) + STATUS.connect('spindle-control-changed', lambda w,num, e, d, upto: self.setEnabled(stop_test())) elif self.limits_override: self.setEnabled(False) #STATUS.connect('override-limits-changed', lambda w, data, group: limits_override_test(data)) @@ -834,7 +845,7 @@ def jog_selected_action(self, direction): if INFO.is_angular(actuator, STATUS.is_joint_mode()): if STATUS.get_jog_increment_angular() != 0: return elif STATUS.get_jog_increment() != 0: return - if direction: + if direction and not STATUS.is_pause_jog_ok(): ACTION.ensure_mode(linuxcnc.MODE_MANUAL) ACTION.DO_JOG(actuator, direction) @@ -852,7 +863,7 @@ def jog_action(self, direction): if INFO.is_angular(actuator, STATUS.is_joint_mode()): if STATUS.get_jog_increment_angular() != 0: return elif STATUS.get_jog_increment() != 0: return - if direction: + if direction and not STATUS.is_pause_jog_ok(): ACTION.ensure_mode(linuxcnc.MODE_MANUAL) ACTION.DO_JOG(actuator, direction) From e2033c195f5fb6403f12070f6775bfe126c2f7fb Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Sun, 18 Oct 2026 05:14:24 +0200 Subject: [PATCH 21/27] gmoccapy: jog while paused Show the jog page while jogs during a pause are possible and restore the previous page on resume or abort. --- src/emc/usr_intf/gmoccapy/gmoccapy.py | 39 +++++++++++++++++++++------ 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/emc/usr_intf/gmoccapy/gmoccapy.py b/src/emc/usr_intf/gmoccapy/gmoccapy.py index 9466934332f..36c5d9bc31a 100644 --- a/src/emc/usr_intf/gmoccapy/gmoccapy.py +++ b/src/emc/usr_intf/gmoccapy/gmoccapy.py @@ -480,6 +480,9 @@ def __init__(self, argv): self.GSTAT.connect("graphics-gcode-properties", self.on_gcode_properties) self.GSTAT.connect("graphics-program-time", self.on_program_time) self.GSTAT.connect("file-loaded", self.on_hal_status_file_loaded) + self.GSTAT.connect("pause-jog-ok-changed", self.on_pause_jog_ok_changed) + # the jog page shown before a pause brought up the jog buttons + self.jog_page_before_pause = None # get if run from line should be used self.run_from_line = self.prefs.getpref("run_from_line", "no_run", str) @@ -1229,7 +1232,7 @@ def _make_jog_increments(self): def _jog_increment_changed(self, widget,): # first cancel any joints jogging JOGMODE = self._get_jog_mode() - if self.stat.task_mode == linuxcnc.MODE_MANUAL: + if self._jog_ok(): for jnum in range(self.stat.joints): self.command.jog(linuxcnc.JOG_STOP, JOGMODE, jnum) self.distance = self._parse_increment(widget.get_property("name")) @@ -1239,9 +1242,9 @@ def _jog_increment_changed(self, widget,): def _on_btn_jog_pressed(self, widget, button_name, shift=False): LOG.debug("Jog Button pressed = {0}".format(button_name)) - # only in manual mode we will allow jogging the axis at this development state + # jogging in manual mode, and of the axes while paused # needed to avoid error on start up, machine not on - if not self.stat.enabled or self.stat.task_mode != linuxcnc.MODE_MANUAL: + if not self._jog_ok(): return joint_no_or_axis_index = self._get_joint_no_or_axis_index(button_name) @@ -1296,8 +1299,8 @@ def _jog_is_angular(self, button_name): def _on_btn_jog_released(self, widget, button_name, shift=False): LOG.debug("Jog Button released = {0}".format(button_name)) - # only in manual mode we will allow jogging the axis at this development state - if not self.stat.enabled or self.stat.task_mode != linuxcnc.MODE_MANUAL: + # jogging in manual mode, and of the axes while paused + if not self._jog_ok(): return joint_no_or_axis_index = self._get_joint_no_or_axis_index(button_name) @@ -1310,6 +1313,26 @@ def _on_btn_jog_released(self, widget, button_name, shift=False): else: self.command.jog(linuxcnc.JOG_STOP, JOGMODE, joint_no_or_axis_index) + # Jogs are fine in manual mode and, for the axes, while a pause of a + # program or MDI command has stopped the motion: resume brings the axes + # back to the paused position. + def _jog_ok(self): + return self.stat.enabled and (self.stat.task_mode == linuxcnc.MODE_MANUAL + or self.stat.pause_jog_ok) + + # While paused, show the axis jog buttons in place of the auto or MDI + # page, and go back to that page when the jogs are no longer possible. + def on_pause_jog_ok_changed(self, widget, ok): + if ok: + if self.widgets.ntb_jog.get_current_page() != 0: + self.jog_page_before_pause = self.widgets.ntb_jog.get_current_page() + self.widgets.ntb_jog.set_current_page(0) + self.widgets.ntb_jog_JA.set_current_page(0) + self._sensitize_widgets(["ntb_jog", "ntb_jog_JA", "vbtb_jog_incr", "hbox_jog_vel"], True) + elif self.jog_page_before_pause is not None: + self.widgets.ntb_jog.set_current_page(self.jog_page_before_pause) + self.jog_page_before_pause = None + def _get_jog_mode(self): # self.stat.motion_mode == # 1 = Joint @@ -3451,7 +3474,7 @@ def on_window1_destroy(self, widget, data=None): def on_focus_out(self, widget, data=None): LOG.debug("focus-out-event") self.stat.poll() - if self.stat.enabled and self.stat.task_mode == linuxcnc.MODE_MANUAL and self.stat.current_vel > 0: + if self._jog_ok() and self.stat.current_vel > 0: # cancel any joints jogging JOGMODE = self._get_jog_mode() for jnum in range(self.stat.joints): @@ -3655,11 +3678,11 @@ def on_key_event(self, widget, event, signal): if self.widgets.tbtn_pause.get_active(): self.widgets.tbtn_pause.set_active(False) - # Only in manual mode jogging with keyboard is allowed + # Jogging with keyboard is allowed in manual mode and while paused # in this case we do not return true, otherwise entering code in MDI history # and the integrated editor will not work # we also check if we are in settings or user page - if self.stat.task_mode != linuxcnc.MODE_MANUAL or not self.widgets.ntb_main.get_current_page() == 0: + if not self._jog_ok() or not self.widgets.ntb_main.get_current_page() == 0: return # This is just to avoid a terminal message, that this keys are not implemented: From 55958b2a004890a6d1d7e5d537f8208c048822b2 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Sun, 18 Oct 2026 05:14:24 +0200 Subject: [PATCH 22/27] touchy, gscreen: jog while paused Don't switch to teleop while paused. Gscreen makes its mode and axis buttons sensitive while paused and returns to the paused mode on resume. --- src/emc/usr_intf/gscreen/emc_interface.py | 5 +++++ src/emc/usr_intf/gscreen/gscreen.py | 25 +++++++++++++++++++++++ src/emc/usr_intf/touchy/emc_interface.py | 2 ++ 3 files changed, 32 insertions(+) diff --git a/src/emc/usr_intf/gscreen/emc_interface.py b/src/emc/usr_intf/gscreen/emc_interface.py index e2bb6f784cf..b791189819d 100644 --- a/src/emc/usr_intf/gscreen/emc_interface.py +++ b/src/emc/usr_intf/gscreen/emc_interface.py @@ -101,6 +101,9 @@ def unhome_selected(self, axis): def jogging(self, b): if self.masked: return + self.emcstat.poll() + # jogs while paused leave the mode shown as it is + if self.emcstat.pause_jog_ok: return self.emccommand.mode(self.emc.MODE_MANUAL) def override_limits(self, b): @@ -135,6 +138,8 @@ def spindle_slower(self, b): def set_motion_mode(self): self.emcstat.poll() + # while paused, axes jog as they are, in coordinated mode + if self.emcstat.pause_jog_ok: return if self.emcstat.motion_mode != self.emc.TRAJ_MODE_TELEOP: self.emccommand.teleop_enable(1) self.emccommand.wait_complete() diff --git a/src/emc/usr_intf/gscreen/gscreen.py b/src/emc/usr_intf/gscreen/gscreen.py index 593f1b1700d..c98f7f85765 100755 --- a/src/emc/usr_intf/gscreen/gscreen.py +++ b/src/emc/usr_intf/gscreen/gscreen.py @@ -2849,6 +2849,30 @@ def on_hal_status_interp_idle(self,widget): #print("set to manual") self.emc.set_manual_mode() + def on_hal_status_pause_jog_ok_changed(self,widget,ok): + """This is a callback function called when jogs of the axes become possible + or impossible during a pause of a program or MDI command. + While they are possible the mode button and the axis buttons are + sensitive, so the manual page and its jogging can be used. + On resume Gscreen goes back to the mode it showed at the pause. + """ + widgets = ["button_mode"] + ["axis_%s"% axis for axis in self.data.axis_list] + if ok: + self.data.pause_mode = self.data.mode_order[0] + self.sensitize_widgets(widgets,True) + return + self.emcstat.poll() + if self.emcstat.interp_state == linuxcnc.INTERP_IDLE: + return + self.sensitize_widgets(widgets,False) + mode = getattr(self.data, 'pause_mode', None) + if mode is not None and self.data.mode_order[0] != mode: + while self.data.mode_order[0] != mode: + a,b,c = self.data.mode_order + self.data.mode_order = b,c,a + self.widgets.button_mode.set_label(self.data.mode_labels[mode]) + self.mode_changed(mode) + def on_hal_status_state_on(self,widget): """This is a callback function called when linuxcnc's state is on. It sensitives widgets in a string list called data.sensitive_on_off @@ -3307,6 +3331,7 @@ def connect_signals(self, handlers): ["","hal_status","interp-idle", "on_hal_status_interp_idle"], ["","hal_status","interp-run", "on_hal_status_interp_run"], + ["","hal_status","pause-jog-ok-changed", "on_hal_status_pause_jog_ok_changed"], ["","hal_status","state-on", "on_hal_status_state_on"], ["","hal_status","state-off", "on_hal_status_state_off"], ["","hal_status","homed", "on_hal_status_axis_homed"], diff --git a/src/emc/usr_intf/touchy/emc_interface.py b/src/emc/usr_intf/touchy/emc_interface.py index 7eb79f9ea30..8eb189dd39d 100644 --- a/src/emc/usr_intf/touchy/emc_interface.py +++ b/src/emc/usr_intf/touchy/emc_interface.py @@ -140,6 +140,8 @@ def spindle_slower(self, b): def set_motion_mode(self): self.emcstat.poll() + # while paused, axes jog as they are, in coordinated mode + if self.emcstat.pause_jog_ok: return if self.emcstat.motion_mode != self.emc.TRAJ_MODE_TELEOP: self.emccommand.teleop_enable(1) self.emccommand.wait_complete() From bf9eb0ddd4787eb0997bc433b7b4f30c3544cd34 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Sun, 18 Oct 2026 05:14:24 +0200 Subject: [PATCH 23/27] qtvcp screens: keyboard jog while paused Use STATUS.is_jog_ok() in kb_jog and only switch to manual mode when not jogging during a pause. --- .../sim/qtvcp_screens/qtaxis_lathe/qtaxis/qtaxis_handler.py | 2 +- .../qtdragon/qtvcp/screens/qtdragon/qtdragon_handler.py | 5 +++-- .../qtvcp_experimental/qtdefault_gladevcp_handler.py | 2 +- configs/sim/woodpecker/1280x1024_5axis/woodpecker_handler.py | 2 +- configs/sim/woodpecker/woodpecker_/woodpecker_handler.py | 2 +- share/qtvcp/screens/blender/blender_handler.py | 2 +- share/qtvcp/screens/qt_cnc/qt_cnc_handler.py | 2 +- share/qtvcp/screens/qt_cnc_9_axis/qt_cnc_9_axis_handler.py | 2 +- share/qtvcp/screens/qtaxis/qtaxis_handler.py | 2 +- share/qtvcp/screens/qtdragon/qtdragon_handler.py | 5 +++-- share/qtvcp/screens/qtdragon_hd/qtdragon_hd_handler.py | 5 +++-- .../screens/qtdragon_hd_vert/qtdragon_hd_vert_handler.py | 5 +++-- share/qtvcp/screens/qtdragon_lathe/qtdragon_lathe_handler.py | 5 +++-- share/qtvcp/screens/qtlathe/qtlathe_handler.py | 2 +- share/qtvcp/screens/qttouchy/qttouchy_handler.py | 2 +- share/qtvcp/screens/tester/tester_handler.py | 2 +- share/qtvcp/screens/woodpecker/woodpecker_handler.py | 2 +- share/qtvcp/screens/x1mill/x1mill_handler.py | 2 +- 18 files changed, 28 insertions(+), 23 deletions(-) diff --git a/configs/sim/qtvcp_screens/qtaxis_lathe/qtaxis/qtaxis_handler.py b/configs/sim/qtvcp_screens/qtaxis_lathe/qtaxis/qtaxis_handler.py index 66e6887f840..66616b51246 100644 --- a/configs/sim/qtvcp_screens/qtaxis_lathe/qtaxis/qtaxis_handler.py +++ b/configs/sim/qtvcp_screens/qtaxis_lathe/qtaxis/qtaxis_handler.py @@ -438,7 +438,7 @@ def launch_log_dialog(self): # keyboard jogging from key binding calls # double the rate if fast is true def kb_jog(self, state, joint, direction, fast = False, linear = True): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): return if linear: distance = STATUS.get_jog_increment() diff --git a/configs/sim/qtvcp_screens/qtdragon/qtvcp/screens/qtdragon/qtdragon_handler.py b/configs/sim/qtvcp_screens/qtdragon/qtvcp/screens/qtdragon/qtdragon_handler.py index a4402a6d515..dddaac263ab 100644 --- a/configs/sim/qtvcp_screens/qtdragon/qtvcp/screens/qtdragon/qtdragon_handler.py +++ b/configs/sim/qtvcp_screens/qtdragon/qtvcp/screens/qtdragon/qtdragon_handler.py @@ -1428,8 +1428,9 @@ def touchoff_error(self, data): self.add_status(data, CRITICAL) def kb_jog(self, state, joint, direction, fast = False, linear = True): - ACTION.SET_MANUAL_MODE() - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_pause_jog_ok(): + ACTION.SET_MANUAL_MODE() + if not STATUS.is_jog_ok(): self.add_status('Machine must be ON and in Manual mode to jog', CRITICAL) return if linear: diff --git a/configs/sim/qtvcp_screens/qtvcp_experimental/qtdefault_gladevcp_handler.py b/configs/sim/qtvcp_screens/qtvcp_experimental/qtdefault_gladevcp_handler.py index 844b780922a..04f9cdaab39 100644 --- a/configs/sim/qtvcp_screens/qtvcp_experimental/qtdefault_gladevcp_handler.py +++ b/configs/sim/qtvcp_screens/qtvcp_experimental/qtdefault_gladevcp_handler.py @@ -119,7 +119,7 @@ def processed_key_event__(self,receiver,event,is_pressed,key,code,shift,cntrl): # keyboard jogging from key binding calls # double the rate if fast is true def kb_jog(self, state, joint, direction, fast = False, linear = True): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): return if linear: distance = STATUS.get_jog_increment() diff --git a/configs/sim/woodpecker/1280x1024_5axis/woodpecker_handler.py b/configs/sim/woodpecker/1280x1024_5axis/woodpecker_handler.py index e4b8725b051..dc3c6bb915e 100644 --- a/configs/sim/woodpecker/1280x1024_5axis/woodpecker_handler.py +++ b/configs/sim/woodpecker/1280x1024_5axis/woodpecker_handler.py @@ -1334,7 +1334,7 @@ def touchoff(self, selector): self.add_status("Touchoff routine is already running", CRITICAL) def kb_jog(self, state, joint, direction, fast = False, linear = True): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): self.add_status('Machine must be ON and in Manual mode to jog', CRITICAL) return if linear: diff --git a/configs/sim/woodpecker/woodpecker_/woodpecker_handler.py b/configs/sim/woodpecker/woodpecker_/woodpecker_handler.py index ab947e24f8b..217a3d486e1 100644 --- a/configs/sim/woodpecker/woodpecker_/woodpecker_handler.py +++ b/configs/sim/woodpecker/woodpecker_/woodpecker_handler.py @@ -914,7 +914,7 @@ def touchoff(self, selector): ACTION.CALL_MDI("G90") def kb_jog(self, state, joint, direction, fast = False, linear = True): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): self.add_status('Machine must be ON and in Manual mode to jog') return if linear: diff --git a/share/qtvcp/screens/blender/blender_handler.py b/share/qtvcp/screens/blender/blender_handler.py index ad38aa84c53..23e26b6b22b 100644 --- a/share/qtvcp/screens/blender/blender_handler.py +++ b/share/qtvcp/screens/blender/blender_handler.py @@ -121,7 +121,7 @@ def change_tool_image(self, num): ##################### def kb_jog(self, state, joint, direction, fast = False): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): return if not INFO.is_angular(joint, STATUS.is_joint_mode()): distance = STATUS.get_jog_increment() diff --git a/share/qtvcp/screens/qt_cnc/qt_cnc_handler.py b/share/qtvcp/screens/qt_cnc/qt_cnc_handler.py index a121d3d1678..1e422559005 100644 --- a/share/qtvcp/screens/qt_cnc/qt_cnc_handler.py +++ b/share/qtvcp/screens/qt_cnc/qt_cnc_handler.py @@ -160,7 +160,7 @@ def set_edit_mode(self, num): ##################### def kb_jog(self, state, joint, direction, fast = False): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): return if not INFO.is_angular(joint, STATUS.is_joint_mode()): distance = STATUS.get_jog_increment() diff --git a/share/qtvcp/screens/qt_cnc_9_axis/qt_cnc_9_axis_handler.py b/share/qtvcp/screens/qt_cnc_9_axis/qt_cnc_9_axis_handler.py index 671268e7c40..286d57198a6 100644 --- a/share/qtvcp/screens/qt_cnc_9_axis/qt_cnc_9_axis_handler.py +++ b/share/qtvcp/screens/qt_cnc_9_axis/qt_cnc_9_axis_handler.py @@ -129,7 +129,7 @@ def processed_key_event__(self,receiver,event,is_pressed,key,code,shift,cntrl): ##################### def kb_jog(self, state, joint, direction, fast = False): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): return if not INFO.is_angular(joint, STATUS.is_joint_mode()): distance = STATUS.get_jog_increment() diff --git a/share/qtvcp/screens/qtaxis/qtaxis_handler.py b/share/qtvcp/screens/qtaxis/qtaxis_handler.py index 931961a1cca..5cb17d66169 100644 --- a/share/qtvcp/screens/qtaxis/qtaxis_handler.py +++ b/share/qtvcp/screens/qtaxis/qtaxis_handler.py @@ -603,7 +603,7 @@ def launch_log_dialog(self): # keyboard jogging from key binding calls # double the rate if fast is true def kb_jog(self, state, joint, direction, fast = False): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): return if not INFO.is_angular(joint, STATUS.is_joint_mode()): distance = STATUS.get_jog_increment() diff --git a/share/qtvcp/screens/qtdragon/qtdragon_handler.py b/share/qtvcp/screens/qtdragon/qtdragon_handler.py index 3ed3825099c..b24b55f712c 100644 --- a/share/qtvcp/screens/qtdragon/qtdragon_handler.py +++ b/share/qtvcp/screens/qtdragon/qtdragon_handler.py @@ -1698,8 +1698,9 @@ def touchoff_error(self, data): self.add_status(data, CRITICAL) def kb_jog(self, state, joint, direction, fast = False): - ACTION.SET_MANUAL_MODE() - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_pause_jog_ok(): + ACTION.SET_MANUAL_MODE() + if not STATUS.is_jog_ok(): self.add_status(_translate("HandlerClass",'Machine must be ON and in Manual mode to jog'), CRITICAL) return if not INFO.is_angular(joint, STATUS.is_joint_mode()): diff --git a/share/qtvcp/screens/qtdragon_hd/qtdragon_hd_handler.py b/share/qtvcp/screens/qtdragon_hd/qtdragon_hd_handler.py index 9e193d9b2ba..f99b482a092 100644 --- a/share/qtvcp/screens/qtdragon_hd/qtdragon_hd_handler.py +++ b/share/qtvcp/screens/qtdragon_hd/qtdragon_hd_handler.py @@ -1756,8 +1756,9 @@ def touchoff_error(self, data): self.add_status(data, CRITICAL) def kb_jog(self, state, joint, direction, fast = False): - ACTION.SET_MANUAL_MODE() - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_pause_jog_ok(): + ACTION.SET_MANUAL_MODE() + if not STATUS.is_jog_ok(): self.add_status(_translate("HandlerClass",'Machine must be ON and in Manual mode to jog'), WARNING) return if not INFO.is_angular(joint, STATUS.is_joint_mode()): diff --git a/share/qtvcp/screens/qtdragon_hd_vert/qtdragon_hd_vert_handler.py b/share/qtvcp/screens/qtdragon_hd_vert/qtdragon_hd_vert_handler.py index 659190920a8..0da71d1e270 100644 --- a/share/qtvcp/screens/qtdragon_hd_vert/qtdragon_hd_vert_handler.py +++ b/share/qtvcp/screens/qtdragon_hd_vert/qtdragon_hd_vert_handler.py @@ -1757,8 +1757,9 @@ def touchoff_error(self, data): self.add_status(data, CRITICAL) def kb_jog(self, state, joint, direction, fast = False): - ACTION.SET_MANUAL_MODE() - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_pause_jog_ok(): + ACTION.SET_MANUAL_MODE() + if not STATUS.is_jog_ok(): self.add_status(_translate("HandlerClass",'Machine must be ON and in Manual mode to jog'), WARNING) return if not INFO.is_angular(joint, STATUS.is_joint_mode()): diff --git a/share/qtvcp/screens/qtdragon_lathe/qtdragon_lathe_handler.py b/share/qtvcp/screens/qtdragon_lathe/qtdragon_lathe_handler.py index 2d44bb07688..c7118dc9f91 100644 --- a/share/qtvcp/screens/qtdragon_lathe/qtdragon_lathe_handler.py +++ b/share/qtvcp/screens/qtdragon_lathe/qtdragon_lathe_handler.py @@ -1701,8 +1701,9 @@ def touchoff_error(self, data): self.add_status(data, CRITICAL) def kb_jog(self, state, joint, direction, fast = False): - ACTION.SET_MANUAL_MODE() - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_pause_jog_ok(): + ACTION.SET_MANUAL_MODE() + if not STATUS.is_jog_ok(): self.add_status(_translate("HandlerClass",'Machine must be ON and in Manual mode to jog'), CRITICAL) return if not INFO.is_angular(joint, STATUS.is_joint_mode()): diff --git a/share/qtvcp/screens/qtlathe/qtlathe_handler.py b/share/qtvcp/screens/qtlathe/qtlathe_handler.py index ae062b4e3be..4b14ceba445 100644 --- a/share/qtvcp/screens/qtlathe/qtlathe_handler.py +++ b/share/qtvcp/screens/qtlathe/qtlathe_handler.py @@ -290,7 +290,7 @@ def slow_jog_clicked(self, state): ##################### def kb_jog(self, state, joint, direction, fast = False): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): return if not INFO.is_angular(joint, STATUS.is_joint_mode()): distance = STATUS.get_jog_increment() diff --git a/share/qtvcp/screens/qttouchy/qttouchy_handler.py b/share/qtvcp/screens/qttouchy/qttouchy_handler.py index 83a5c7c2ea2..4d6ce31b2f4 100644 --- a/share/qtvcp/screens/qttouchy/qttouchy_handler.py +++ b/share/qtvcp/screens/qttouchy/qttouchy_handler.py @@ -263,7 +263,7 @@ def external_mpg(self, count): # keyboard jogging from key binding calls # double the rate if fast is true def kb_jog(self, state, joint, direction, fast = False): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): return if not INFO.is_angular(joint, STATUS.is_joint_mode()): distance = STATUS.get_jog_increment() diff --git a/share/qtvcp/screens/tester/tester_handler.py b/share/qtvcp/screens/tester/tester_handler.py index 5a53ef435e3..4afe41a3269 100644 --- a/share/qtvcp/screens/tester/tester_handler.py +++ b/share/qtvcp/screens/tester/tester_handler.py @@ -116,7 +116,7 @@ def processed_key_event__(self,receiver,event,is_pressed,key,code,shift,cntrl): # keyboard jogging from key binding calls # double the rate if fast is true def kb_jog(self, state, joint, direction, fast = False): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): return if not INFO.is_angular(joint, STATUS.is_joint_mode()): distance = STATUS.get_jog_increment() diff --git a/share/qtvcp/screens/woodpecker/woodpecker_handler.py b/share/qtvcp/screens/woodpecker/woodpecker_handler.py index 6b07b574260..9a8d1a71a1b 100644 --- a/share/qtvcp/screens/woodpecker/woodpecker_handler.py +++ b/share/qtvcp/screens/woodpecker/woodpecker_handler.py @@ -1174,7 +1174,7 @@ def touchoff(self, selector): self.add_status("Touchoff routine is already running", CRITICAL) def kb_jog(self, state, joint, direction, fast = False): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): self.add_status('Machine must be ON and in Manual mode to jog', CRITICAL) return if not INFO.is_angular(joint, STATUS.is_joint_mode()): diff --git a/share/qtvcp/screens/x1mill/x1mill_handler.py b/share/qtvcp/screens/x1mill/x1mill_handler.py index b524ef3ec74..ece950a0be2 100644 --- a/share/qtvcp/screens/x1mill/x1mill_handler.py +++ b/share/qtvcp/screens/x1mill/x1mill_handler.py @@ -158,7 +158,7 @@ def run_from_line_clicked(self): # keyboard jogging from key binding calls # double the rate if fast is true def kb_jog(self, state, joint, direction, fast = False): - if not STATUS.is_man_mode() or not STATUS.machine_is_on(): + if not STATUS.is_jog_ok(): return if not INFO.is_angular(joint, STATUS.is_joint_mode()): distance = STATUS.get_jog_increment() From 2e9ecd7882bb054fc60f594e9eca65c550dab580 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Fri, 13 Nov 2026 02:19:39 +0100 Subject: [PATCH 24/27] tests: task-planner, stale-motion-status and jog-while-paused without modes The planner table has one idle situation instead of Manual, MDI and Auto idle. stale-motion-status no longer waits for coordinated mode after mode(AUTO), and jog-while-paused reads task.mode.is-manual. --- src/emc/motion/command.c | 5 - src/emc/usr_intf/axis/scripts/axis.py | 13 +- tests/jog-while-paused/test-ui.py | 20 +-- tests/stale-motion-status/test-ui.py | 3 +- tests/task-planner/expected | 235 +++++--------------------- tests/task-planner/test-ui.py | 25 +-- 6 files changed, 54 insertions(+), 247 deletions(-) diff --git a/src/emc/motion/command.c b/src/emc/motion/command.c index 4348d444e66..e77255b33c1 100644 --- a/src/emc/motion/command.c +++ b/src/emc/motion/command.c @@ -276,11 +276,6 @@ static bool pause_jog_check(void) { int axis_num = emcmotCommand->axis; - if (!emcmotStatus->paused) { - /* coordinated mode without a pause, as in MDI mode: a jog does - nothing and says nothing, as it always has */ - return false; - } if (axis_num < 0 || axis_num >= EMCMOT_MAX_AXIS) { reportError(_("Can't jog a joint while a coordinated move is paused, jog an axis")); return false; diff --git a/src/emc/usr_intf/axis/scripts/axis.py b/src/emc/usr_intf/axis/scripts/axis.py index 52f47034095..f82c54fa2d1 100755 --- a/src/emc/usr_intf/axis/scripts/axis.py +++ b/src/emc/usr_intf/axis/scripts/axis.py @@ -2891,7 +2891,7 @@ def set_axis_offset(event=None): def brake(event=None): if not spindle_ok(): return - ensure_manual_unless_paused() + ensure_mode(linuxcnc.MODE_MANUAL) c.brake(vars.brake.get()) def flood(event=None): c.flood(vars.flood.get()) @@ -2899,7 +2899,7 @@ def mist(event=None): c.mist(vars.mist.get()) def spindle(event=None): if not spindle_ok(): return - ensure_manual_unless_paused() + ensure_mode(linuxcnc.MODE_MANUAL) d = vars.spindledir.get() if d == 0: c.spindle(d) @@ -2911,7 +2911,7 @@ def spindle_decrease(event=None): c.spindle(linuxcnc.SPINDLE_DECREASE) def spindle_constant(event=None): if not spindle_ok(): return - ensure_manual_unless_paused() + ensure_mode(linuxcnc.MODE_MANUAL) c.spindle(linuxcnc.SPINDLE_CONSTANT) def set_first_line(lineno): if not manual_ok(): return @@ -3277,13 +3277,6 @@ def jog_ok(): s.poll() return (manual_ok(False) and not running(False)) or s.pause_jog_ok -# A mode change while paused is refused in Auto and aborts a paused MDI -# command, and task takes spindle commands while paused as they are. -def ensure_manual_unless_paused(): - s.poll() - if s.interp_state != linuxcnc.INTERP_PAUSED: - ensure_mode(linuxcnc.MODE_MANUAL) - # Spindle commands are fine while idle and while paused. def spindle_ok(): s.poll() diff --git a/tests/jog-while-paused/test-ui.py b/tests/jog-while-paused/test-ui.py index f1cec61b67d..6295882d35f 100755 --- a/tests/jog-while-paused/test-ui.py +++ b/tests/jog-while-paused/test-ui.py @@ -56,18 +56,10 @@ def near(a, b, tol=1e-6): def idle(): - return s.interp_state == linuxcnc.INTERP_IDLE and s.queue == 0 and s.inpos - - -def mdi(cmd): - c.mode(linuxcnc.MODE_MDI) - c.wait_complete() - c.mdi(cmd) + return s.interp_state == linuxcnc.INTERP_IDLE and s.queue == 0 and hal.get_value('task.mode.is-manual') def run_and_pause(prog, at_x): - c.mode(linuxcnc.MODE_AUTO) - c.wait_complete() c.program_open(os.path.abspath(prog)) c.wait_complete() c.auto(linuxcnc.AUTO_RUN, 0) @@ -86,7 +78,7 @@ def run_and_pause(prog, at_x): wait(lambda: all(s.homed[:3]), 10) c.teleop_enable(1) c.wait_complete() -mdi('G0 X0 Y0 Z0') +c.mdi('G0 X0 Y0 Z0') wait(idle) errors() @@ -187,7 +179,7 @@ def at_rest(): s.poll() check('abort keeps the jogged position', near(pos(), (p[0], p[1], p[2] + 3)), pos()) check('pause offset gone after abort', near(s.pause_offset[:3], (0, 0, 0), 0), s.pause_offset[:3]) -mdi('G0 X1') +c.mdi('G0 X1') check('MDI after the abort', wait(lambda: idle() and near(pos(), (1, p[1], p[2] + 3))), pos()) errors() @@ -201,7 +193,7 @@ def at_rest(): c.abort() c.wait_complete() wait(idle) -mdi('G0 X0 Y0 Z0') +c.mdi('G0 X0 Y0 Z0') wait(idle) errors() @@ -217,13 +209,11 @@ def at_rest(): c.abort() c.wait_complete() wait(idle) -mdi('G0 X0 Y0 Z0') +c.mdi('G0 X0 Y0 Z0') wait(idle) errors() # --- an M0 stop is a pause too -c.mode(linuxcnc.MODE_AUTO) -c.wait_complete() c.program_open(os.path.abspath('m0.ngc')) c.wait_complete() c.auto(linuxcnc.AUTO_RUN, 0) diff --git a/tests/stale-motion-status/test-ui.py b/tests/stale-motion-status/test-ui.py index edd6e09b2d2..f3096a26533 100755 --- a/tests/stale-motion-status/test-ui.py +++ b/tests/stale-motion-status/test-ui.py @@ -58,8 +58,7 @@ def settle(what, done): c.mode(linuxcnc.MODE_AUTO) c.wait_complete(60) -settle("auto mode was on", lambda: s.task_mode == linuxcnc.MODE_AUTO - and s.motion_mode == linuxcnc.TRAJ_MODE_COORD) +settle("auto mode was on", lambda: s.task_mode == linuxcnc.MODE_AUTO) c.program_open('test.ngc') c.auto(linuxcnc.AUTO_RUN, 0) diff --git a/tests/task-planner/expected b/tests/task-planner/expected index f4b741fb55e..f2ff9557c39 100644 --- a/tests/task-planner/expected +++ b/tests/task-planner/expected @@ -59,9 +59,6 @@ EMC_TASK_PLAN_RESUME refused EMC_TASK_PLAN_REVERSE refused EMC_TASK_PLAN_FORWARD refused EMC_TASK_ABORT issued -EMC_TASK_SET_MODE(MANUAL) issued -EMC_TASK_SET_MODE(AUTO) issued -> ESTOP/AUTO/IDLE/reading.ngc -EMC_TASK_SET_MODE(MDI) issued -> ESTOP/MDI/IDLE/reading.ngc EMC_TASK_SET_STATE(ESTOP) issued EMC_TASK_SET_STATE(ESTOP_RESET) issued -> OFF/MANUAL/IDLE/reading.ngc EMC_TASK_SET_STATE(OFF) issued @@ -75,7 +72,7 @@ EMC_JOINT_SET_MIN_POSITION_LIMIT refused EMC_JOINT_LOAD_COMP issued EMC_JOINT_HOME refused EMC_JOINT_UNHOME issued -EMC_JOINT_OVERRIDE_LIMITS handled +EMC_JOINT_OVERRIDE_LIMITS issued EMC_JOG_CONT refused EMC_JOG_INCR refused EMC_JOG_STOP refused @@ -86,7 +83,7 @@ EMC_TRAJ_SET_SPINDLE_SCALE issued EMC_TRAJ_SET_FO_ENABLE issued EMC_TRAJ_SET_FH_ENABLE issued EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_TELEOP_ENABLE issued -> OFF/MANUAL/IDLE/reading.ngc +EMC_TRAJ_SET_TELEOP_ENABLE issued EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued EMC_MOTION_SET_DOUT issued EMC_MOTION_SET_AOUT issued @@ -119,7 +116,7 @@ EMC_TRAJ_PROBE issued EMC_TRAJ_RIGID_TAP issued EMC_TASK_PLAN_OPTIONAL_STOP refused EMC_TASK_PLAN_EXECUTE refused -EMC_TASK_PLAN_INIT issued -> OFF/AUTO/IDLE +EMC_TASK_PLAN_INIT issued -> OFF/MANUAL/IDLE EMC_TASK_PLAN_CLOSE issued EMC_TASK_PLAN_RUN refused EMC_TASK_PLAN_STEP refused @@ -128,15 +125,12 @@ EMC_TASK_PLAN_RESUME refused EMC_TASK_PLAN_REVERSE refused EMC_TASK_PLAN_FORWARD refused EMC_TASK_ABORT issued -EMC_TASK_SET_MODE(MANUAL) issued -> OFF/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_MODE(AUTO) issued -EMC_TASK_SET_MODE(MDI) issued -> OFF/MDI/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/AUTO/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/reading.ngc EMC_TASK_SET_STATE(ESTOP_RESET) issued EMC_TASK_SET_STATE(OFF) issued -EMC_TASK_SET_STATE(ON) issued -> ON/AUTO/IDLE/reading.ngc +EMC_TASK_SET_STATE(ON) issued -> ON/MANUAL/IDLE/reading.ngc -[manual] +[idle] EMC_NULL handled EMC_JOINT_SET_BACKLASH issued EMC_JOINT_SET_MAX_POSITION_LIMIT issued @@ -182,98 +176,26 @@ EMC_TRAJ_SET_MODE refused EMC_TOOL_LOAD_TOOL_TABLE queued EMC_TOOL_SET_NUMBER queued EMC_TOOL_SET_OFFSET queued -EMC_SPINDLE_ORIENT refused -EMC_SPINDLE_WAIT_ORIENT_COMPLETE refused +EMC_SPINDLE_ORIENT issued +EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued EMC_TRAJ_PROBE issued EMC_TRAJ_RIGID_TAP issued EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/MANUAL/PAUSED/reading.ngc EMC_TASK_PLAN_EXECUTE issued EMC_TASK_PLAN_INIT issued -> ON/MANUAL/IDLE EMC_TASK_PLAN_CLOSE issued -EMC_TASK_PLAN_RUN handled -EMC_TASK_PLAN_STEP refused +EMC_TASK_PLAN_RUN issued -> ON/AUTO/READING/reading.ngc +EMC_TASK_PLAN_STEP handled -> ON/AUTO/PAUSED/reading.ngc EMC_TASK_PLAN_PAUSE issued -> ON/MANUAL/PAUSED/reading.ngc EMC_TASK_PLAN_RESUME issued EMC_TASK_PLAN_REVERSE issued EMC_TASK_PLAN_FORWARD issued EMC_TASK_ABORT issued -EMC_TASK_SET_MODE(MANUAL) issued -EMC_TASK_SET_MODE(AUTO) issued -> ON/AUTO/IDLE/reading.ngc -EMC_TASK_SET_MODE(MDI) issued -> ON/MDI/IDLE/reading.ngc EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/reading.ngc EMC_TASK_SET_STATE(ESTOP_RESET) issued EMC_TASK_SET_STATE(OFF) issued -> OFF/MANUAL/IDLE/reading.ngc EMC_TASK_SET_STATE(ON) issued -[mdi] -EMC_NULL handled -EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_MAX_POSITION_LIMIT refused -EMC_JOINT_SET_MIN_POSITION_LIMIT refused -EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HOME refused -EMC_JOINT_UNHOME issued -EMC_JOINT_OVERRIDE_LIMITS refused -EMC_JOG_CONT issued -EMC_JOG_INCR issued -EMC_JOG_STOP issued -EMC_TRAJ_SET_SCALE issued -EMC_TRAJ_SET_RAPID_SCALE issued -EMC_TRAJ_SET_MAX_VELOCITY issued -EMC_TRAJ_SET_SPINDLE_SCALE issued -EMC_TRAJ_SET_FO_ENABLE issued -EMC_TRAJ_SET_FH_ENABLE issued -EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_TELEOP_ENABLE issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued -EMC_MOTION_SET_DOUT issued -EMC_MOTION_SET_AOUT issued -EMC_MOTION_ADAPTIVE issued -EMC_AUX_INPUT_WAIT issued -EMC_SET_DEBUG issued -EMC_SPINDLE_SPEED issued -EMC_SPINDLE_ON issued -EMC_SPINDLE_INCREASE issued -EMC_SPINDLE_DECREASE issued -EMC_SPINDLE_CONSTANT issued -EMC_SPINDLE_OFF issued -EMC_SPINDLE_BRAKE_ENGAGE issued -EMC_SPINDLE_BRAKE_RELEASE issued -EMC_COOLANT_MIST_ON issued -EMC_COOLANT_MIST_OFF issued -EMC_COOLANT_FLOOD_ON issued -EMC_COOLANT_FLOOD_OFF issued -EMC_TASK_PLAN_SET_OPTIONAL_STOP issued -EMC_TASK_PLAN_SET_BLOCK_DELETE issued -EMC_TASK_PLAN_SYNCH issued -EMC_TASK_PLAN_OPEN issued -EMC_TRAJ_SET_MODE refused -EMC_TOOL_LOAD_TOOL_TABLE queued -EMC_TOOL_SET_NUMBER refused -EMC_TOOL_SET_OFFSET queued -EMC_SPINDLE_ORIENT issued -EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued -EMC_TRAJ_PROBE issued -EMC_TRAJ_RIGID_TAP issued -EMC_TASK_PLAN_OPTIONAL_STOP issued -EMC_TASK_PLAN_EXECUTE issued -EMC_TASK_PLAN_INIT issued -> ON/MDI/IDLE -EMC_TASK_PLAN_CLOSE issued -EMC_TASK_PLAN_RUN refused -EMC_TASK_PLAN_STEP refused -EMC_TASK_PLAN_PAUSE issued -EMC_TASK_PLAN_RESUME issued -EMC_TASK_PLAN_REVERSE issued -EMC_TASK_PLAN_FORWARD issued -EMC_TASK_ABORT issued -EMC_TASK_SET_MODE(MANUAL) issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_MODE(AUTO) issued -> ON/AUTO/IDLE/reading.ngc -EMC_TASK_SET_MODE(MDI) issued -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MDI/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP_RESET) issued -EMC_TASK_SET_STATE(OFF) issued -> OFF/MDI/IDLE/reading.ngc -EMC_TASK_SET_STATE(ON) issued - [mdi-busy] EMC_NULL handled EMC_JOINT_SET_BACKLASH issued @@ -283,8 +205,8 @@ EMC_JOINT_LOAD_COMP refused EMC_JOINT_HOME refused EMC_JOINT_UNHOME issued EMC_JOINT_OVERRIDE_LIMITS refused -EMC_JOG_CONT issued -EMC_JOG_INCR issued +EMC_JOG_CONT refused +EMC_JOG_INCR refused EMC_JOG_STOP issued EMC_TRAJ_SET_SCALE issued EMC_TRAJ_SET_RAPID_SCALE issued @@ -293,12 +215,12 @@ EMC_TRAJ_SET_SPINDLE_SCALE issued EMC_TRAJ_SET_FO_ENABLE issued EMC_TRAJ_SET_FH_ENABLE issued EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_TELEOP_ENABLE issued -> ON/MANUAL/READING/reading.ngc +EMC_TRAJ_SET_TELEOP_ENABLE refused EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued EMC_MOTION_SET_DOUT issued EMC_MOTION_SET_AOUT issued EMC_MOTION_ADAPTIVE issued -EMC_AUX_INPUT_WAIT issued -> ON/MDI/IDLE/reading.ngc +EMC_AUX_INPUT_WAIT issued -> ON/MANUAL/IDLE/reading.ngc EMC_SET_DEBUG issued EMC_SPINDLE_SPEED issued EMC_SPINDLE_ON issued @@ -321,9 +243,9 @@ EMC_TOOL_LOAD_TOOL_TABLE queued EMC_TOOL_SET_NUMBER refused EMC_TOOL_SET_OFFSET queued EMC_SPINDLE_ORIENT issued -EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued -> ON/MDI/IDLE/reading.ngc -EMC_TRAJ_PROBE issued -> ON/MDI/IDLE/reading.ngc -EMC_TRAJ_RIGID_TAP issued -> ON/MDI/IDLE/reading.ngc +EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TRAJ_PROBE issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TRAJ_RIGID_TAP issued -> ON/MANUAL/IDLE/reading.ngc EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/MDI/PAUSED/reading.ngc EMC_TASK_PLAN_EXECUTE issued EMC_TASK_PLAN_INIT issued -> ON/MDI/READING @@ -334,82 +256,10 @@ EMC_TASK_PLAN_PAUSE issued -> ON/MDI/PAUSED/reading.ngc EMC_TASK_PLAN_RESUME issued EMC_TASK_PLAN_REVERSE issued EMC_TASK_PLAN_FORWARD issued -EMC_TASK_ABORT issued -> ON/MDI/IDLE/reading.ngc -EMC_TASK_SET_MODE(MANUAL) issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_MODE(AUTO) issued -> ON/AUTO/IDLE/reading.ngc -EMC_TASK_SET_MODE(MDI) issued -> ON/MDI/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MDI/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/MDI/IDLE/reading.ngc -EMC_TASK_SET_STATE(OFF) issued -> OFF/MDI/IDLE/reading.ngc -EMC_TASK_SET_STATE(ON) issued - -[auto] -EMC_NULL handled -EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_MAX_POSITION_LIMIT refused -EMC_JOINT_SET_MIN_POSITION_LIMIT refused -EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HOME refused -EMC_JOINT_UNHOME issued -EMC_JOINT_OVERRIDE_LIMITS refused -EMC_JOG_CONT issued -EMC_JOG_INCR issued -EMC_JOG_STOP issued -EMC_TRAJ_SET_SCALE issued -EMC_TRAJ_SET_RAPID_SCALE issued -EMC_TRAJ_SET_MAX_VELOCITY issued -EMC_TRAJ_SET_SPINDLE_SCALE issued -EMC_TRAJ_SET_FO_ENABLE issued -EMC_TRAJ_SET_FH_ENABLE issued -EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_TELEOP_ENABLE issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued -EMC_MOTION_SET_DOUT refused -EMC_MOTION_SET_AOUT refused -EMC_MOTION_ADAPTIVE refused -EMC_AUX_INPUT_WAIT issued -EMC_SET_DEBUG issued -EMC_SPINDLE_SPEED issued -EMC_SPINDLE_ON issued -EMC_SPINDLE_INCREASE issued -EMC_SPINDLE_DECREASE issued -EMC_SPINDLE_CONSTANT issued -EMC_SPINDLE_OFF issued -EMC_SPINDLE_BRAKE_ENGAGE issued -EMC_SPINDLE_BRAKE_RELEASE issued -EMC_COOLANT_MIST_ON issued -EMC_COOLANT_MIST_OFF issued -EMC_COOLANT_FLOOD_ON issued -EMC_COOLANT_FLOOD_OFF issued -EMC_TASK_PLAN_SET_OPTIONAL_STOP issued -EMC_TASK_PLAN_SET_BLOCK_DELETE issued -EMC_TASK_PLAN_SYNCH refused -EMC_TASK_PLAN_OPEN issued -EMC_TRAJ_SET_MODE refused -EMC_TOOL_LOAD_TOOL_TABLE queued -EMC_TOOL_SET_NUMBER refused -EMC_TOOL_SET_OFFSET queued -EMC_SPINDLE_ORIENT issued -EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued -EMC_TRAJ_PROBE issued -EMC_TRAJ_RIGID_TAP issued -EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/AUTO/PAUSED/reading.ngc -EMC_TASK_PLAN_EXECUTE issued -EMC_TASK_PLAN_INIT issued -> ON/AUTO/IDLE -EMC_TASK_PLAN_CLOSE issued -EMC_TASK_PLAN_RUN issued -> ON/AUTO/READING/reading.ngc -EMC_TASK_PLAN_STEP handled -> ON/AUTO/PAUSED/reading.ngc -EMC_TASK_PLAN_PAUSE issued -> ON/AUTO/PAUSED/reading.ngc -EMC_TASK_PLAN_RESUME issued -EMC_TASK_PLAN_REVERSE issued -EMC_TASK_PLAN_FORWARD issued -EMC_TASK_ABORT issued -EMC_TASK_SET_MODE(MANUAL) issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_MODE(AUTO) issued -EMC_TASK_SET_MODE(MDI) issued -> ON/MDI/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/AUTO/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP_RESET) issued -EMC_TASK_SET_STATE(OFF) issued -> OFF/AUTO/IDLE/reading.ngc +EMC_TASK_ABORT issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_STATE(OFF) issued -> OFF/MANUAL/IDLE/reading.ngc EMC_TASK_SET_STATE(ON) issued [auto-reading] @@ -461,7 +311,7 @@ EMC_TOOL_SET_OFFSET refused EMC_SPINDLE_ORIENT refused EMC_SPINDLE_WAIT_ORIENT_COMPLETE refused EMC_TRAJ_PROBE issued -EMC_TRAJ_RIGID_TAP issued -> ON/AUTO/IDLE/reading.ngc +EMC_TRAJ_RIGID_TAP issued -> ON/MANUAL/IDLE/reading.ngc EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/AUTO/PAUSED/reading.ngc EMC_TASK_PLAN_EXECUTE refused EMC_TASK_PLAN_INIT refused @@ -472,13 +322,10 @@ EMC_TASK_PLAN_PAUSE issued -> ON/AUTO/PAUSED/reading.ngc EMC_TASK_PLAN_RESUME issued EMC_TASK_PLAN_REVERSE issued EMC_TASK_PLAN_FORWARD issued -EMC_TASK_ABORT issued -> ON/AUTO/IDLE/reading.ngc -EMC_TASK_SET_MODE(MANUAL) issued -EMC_TASK_SET_MODE(AUTO) issued -> ON/AUTO/IDLE/reading.ngc -EMC_TASK_SET_MODE(MDI) issued -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/AUTO/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/AUTO/IDLE/reading.ngc -EMC_TASK_SET_STATE(OFF) issued -> OFF/AUTO/IDLE/reading.ngc +EMC_TASK_ABORT issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_STATE(OFF) issued -> OFF/MANUAL/IDLE/reading.ngc EMC_TASK_SET_STATE(ON) issued [auto-waiting] @@ -530,9 +377,9 @@ EMC_TOOL_SET_OFFSET refused EMC_SPINDLE_ORIENT refused EMC_SPINDLE_WAIT_ORIENT_COMPLETE refused EMC_TRAJ_PROBE issued -EMC_TRAJ_RIGID_TAP issued -> ON/AUTO/IDLE/waiting.ngc +EMC_TRAJ_RIGID_TAP issued -> ON/MANUAL/IDLE/waiting.ngc EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/AUTO/PAUSED/waiting.ngc -EMC_TASK_PLAN_EXECUTE issued +EMC_TASK_PLAN_EXECUTE refused EMC_TASK_PLAN_INIT refused EMC_TASK_PLAN_CLOSE refused EMC_TASK_PLAN_RUN refused @@ -541,13 +388,10 @@ EMC_TASK_PLAN_PAUSE issued -> ON/AUTO/PAUSED/waiting.ngc EMC_TASK_PLAN_RESUME issued EMC_TASK_PLAN_REVERSE issued EMC_TASK_PLAN_FORWARD issued -EMC_TASK_ABORT issued -> ON/AUTO/IDLE/waiting.ngc -EMC_TASK_SET_MODE(MANUAL) issued -EMC_TASK_SET_MODE(AUTO) issued -> ON/AUTO/IDLE/waiting.ngc -EMC_TASK_SET_MODE(MDI) issued -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/AUTO/IDLE/waiting.ngc -EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/AUTO/IDLE/waiting.ngc -EMC_TASK_SET_STATE(OFF) issued -> OFF/AUTO/IDLE/waiting.ngc +EMC_TASK_ABORT issued -> ON/MANUAL/IDLE/waiting.ngc +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/waiting.ngc +EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/MANUAL/IDLE/waiting.ngc +EMC_TASK_SET_STATE(OFF) issued -> OFF/MANUAL/IDLE/waiting.ngc EMC_TASK_SET_STATE(ON) issued [auto-paused] @@ -599,9 +443,9 @@ EMC_TOOL_SET_OFFSET refused EMC_SPINDLE_ORIENT issued EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued EMC_TRAJ_PROBE issued -EMC_TRAJ_RIGID_TAP issued -> ON/AUTO/IDLE/reading.ngc +EMC_TRAJ_RIGID_TAP issued -> ON/MANUAL/IDLE/reading.ngc EMC_TASK_PLAN_OPTIONAL_STOP issued -EMC_TASK_PLAN_EXECUTE issued +EMC_TASK_PLAN_EXECUTE refused EMC_TASK_PLAN_INIT refused EMC_TASK_PLAN_CLOSE refused EMC_TASK_PLAN_RUN refused @@ -610,11 +454,8 @@ EMC_TASK_PLAN_PAUSE issued EMC_TASK_PLAN_RESUME issued -> ON/AUTO/READING/reading.ngc EMC_TASK_PLAN_REVERSE issued EMC_TASK_PLAN_FORWARD issued -EMC_TASK_ABORT issued -> ON/AUTO/IDLE/reading.ngc -EMC_TASK_SET_MODE(MANUAL) issued -EMC_TASK_SET_MODE(AUTO) issued -> ON/AUTO/IDLE/reading.ngc -EMC_TASK_SET_MODE(MDI) issued -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/AUTO/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/AUTO/IDLE/reading.ngc -EMC_TASK_SET_STATE(OFF) issued -> OFF/AUTO/IDLE/reading.ngc +EMC_TASK_ABORT issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/MANUAL/IDLE/reading.ngc +EMC_TASK_SET_STATE(OFF) issued -> OFF/MANUAL/IDLE/reading.ngc EMC_TASK_SET_STATE(ON) issued diff --git a/tests/task-planner/test-ui.py b/tests/task-planner/test-ui.py index f44ffefe7f9..5e322e2890b 100755 --- a/tests/task-planner/test-ui.py +++ b/tests/task-planner/test-ui.py @@ -55,7 +55,7 @@ def probe_cmd(line): # The three tool commands set task's wait flag (emcTaskPlanSetWait()), and # only a program reading or an MDI command waiting clears it again; an -# abort does not. While it is set, an MDI command in MDI mode is queued +# abort does not. While it is set, an MDI command is queued # rather than issued. So that a probe does not depend on the ones before it, # the flag is cleared, by running a program that ends at once, whenever a # situation is set up afresh and after each tool command. @@ -128,12 +128,6 @@ def idle(): command(c.abort, lambda: s.interp_state == linuxcnc.INTERP_IDLE) -def mode(m): - s.poll() - if s.task_mode != m: - command(c.mode, lambda: s.task_mode == m, m) - - def program(f): s.poll() if s.file != f: @@ -144,7 +138,6 @@ def program(f): def run(f, interp): state(linuxcnc.STATE_ON) idle() - mode(linuxcnc.MODE_AUTO) program(f) command(c.auto, lambda: s.interp_state == interp, linuxcnc.AUTO_RUN, 0) @@ -152,7 +145,6 @@ def run(f, interp): def clear_wait_flag(): state(linuxcnc.STATE_ON) idle() - mode(linuxcnc.MODE_AUTO) program(flush) c.auto(linuxcnc.AUTO_RUN, 0) wait_for("flush.ngc to end", lambda: s.interp_state == linuxcnc.INTERP_IDLE @@ -164,22 +156,17 @@ def set_up(name, afresh=False): clear_wait_flag() # the same program is open in every situation, so that the open file # is part of the situation without being set up again for each one - if name in ('estop', 'off', 'manual', 'mdi', 'mdi-busy', 'auto'): + if name in ('estop', 'off', 'idle', 'mdi-busy'): idle() program(reading) if name == 'estop': - mode(linuxcnc.MODE_MANUAL) state(linuxcnc.STATE_ESTOP) elif name == 'off': - mode(linuxcnc.MODE_AUTO) state(linuxcnc.STATE_OFF) - elif name in ('manual', 'mdi', 'auto'): + elif name == 'idle': state(linuxcnc.STATE_ON) - mode({'manual': linuxcnc.MODE_MANUAL, 'mdi': linuxcnc.MODE_MDI, - 'auto': linuxcnc.MODE_AUTO}[name]) elif name == 'mdi-busy': state(linuxcnc.STATE_ON) - mode(linuxcnc.MODE_MDI) c.mdi("G4 P600") wait_for("MDI running", lambda: s.interp_state != linuxcnc.INTERP_IDLE) elif name == 'auto-reading': @@ -194,8 +181,10 @@ def set_up(name, afresh=False): return situation() -SITUATIONS = ['estop', 'off', 'manual', 'mdi', 'mdi-busy', - 'auto', 'auto-reading', 'auto-waiting', 'auto-paused'] +# Task has no modes to switch between: what it accepts depends on its state +# and on what it runs (nothing, MDI, a program). +SITUATIONS = ['estop', 'off', 'idle', 'mdi-busy', + 'auto-reading', 'auto-waiting', 'auto-paused'] for name in SITUATIONS: expected = set_up(name, afresh=True) From 7913b1e611f47cbb0e4c4d5c4d865d2a669753f9 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 13:38:02 +0100 Subject: [PATCH 25/27] motion: wait for the joints to come to rest before entering joint mode In position is the planner's. The joints follow it through the cubic interpolators and arrive a few cycles later. Since mode changes are deferred instead of dropped, the change to joint mode happened on the first in-position cycle and took pos_cmd mid-spline, so an MDI move from joint mode ended up to 0.0003 mm off its target in about 1 run in 100. Wait until the last four points of each joint's cubic are the same. A moving external offset never rests, so it does not hold the change up. --- src/emc/motion/control.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/emc/motion/control.c b/src/emc/motion/control.c index bd4c7437ead..6511efbae2e 100644 --- a/src/emc/motion/control.c +++ b/src/emc/motion/control.c @@ -1178,7 +1178,19 @@ static void set_operating_mode(void) /* check entering free space mode */ if (!emcmotInternal->coordinating && GET_MOTION_COORD_FLAG()) { - if (GET_MOTION_INPOS_FLAG()) { + /* in position is the planner's; the joints follow it through + the cubics and come to rest a few cycles later. Taking + pos_cmd before that leaves them short of the end. A moving + external offset never rests, so it does not hold this up. */ + int at_rest = 1; + for (joint_num = 0; joint_num < NO_OF_KINS_JOINTS; joint_num++) { + CUBIC_STRUCT *cu = &joints[joint_num].cubic; + if (cu->x0 != cu->x3 || cu->x1 != cu->x3 || cu->x2 != cu->x3) { + at_rest = 0; + } + } + if (GET_MOTION_INPOS_FLAG() + && (at_rest || hal_get_bool(emcmot_hal_data->eoffset_active))) { for (joint_num = 0; joint_num < ALL_JOINTS; joint_num++) { /* point to joint data */ joint = &joints[joint_num]; From 48d6c553bb65b7478c439fbdfb814f68911415c2 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 17 Nov 2026 02:32:32 +0100 Subject: [PATCH 26/27] task: forget the coolant saved at a pause when the run ends The save was dropped by looking at task_paused, which a program that ends normally leaves set: after stepping a program to its end, a paused MDI command would have resumed with that program's coolant. taskRunEnd() clears it, as on the modeless branches. --- src/emc/task/emctaskmain.cc | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index aa2b4b6b68c..947f5eec2f0 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -718,6 +718,12 @@ void readahead_waiting(void) // makes that switch once in position, so a run waits for it before the // first command leaves interp_list (see coordWaiting in emcTaskExecute()). +// The coolant as it was when a program or MDI paused: resume puts it back, +// as motion does with the spindles (pause_restore_spindles()). +static bool pauseCoolantSaved = false; +static int pauseMist = 0; +static int pauseFlood = 0; + // Set by taskRunStart(), cleared once motion is in coordinated mode. static bool coordWaiting = false; static double coordWaitStart = 0.0; @@ -790,6 +796,7 @@ static void taskRunEnd() { taskRun = TaskRun::NONE; coordWaiting = false; + pauseCoolantSaved = false; EMC_TRAJ_MODE mode = all_homed() ? EMC_TRAJ_MODE::TELEOP : EMC_TRAJ_MODE::FREE; if (runPriorHomed == (bool)all_homed()) { @@ -956,18 +963,9 @@ static int taskRunIssue(TaskRun run, NMLmsg *cmd) return retval; } -// The coolant as it was when a program or MDI paused: resume puts it back, -// as motion does with the spindles (pause_restore_spindles()). -static bool pauseCoolantSaved = false; -static int pauseMist = 0; -static int pauseFlood = 0; - +// Coolant across a pause, see pauseCoolantSaved. static void pauseSaveCoolant() { - if (!emcStatus->task.task_paused) { - // what is left of a pause that an abort ended - pauseCoolantSaved = false; - } if (pauseCoolantSaved) { return; } @@ -978,9 +976,6 @@ static void pauseSaveCoolant() static void pauseRestoreCoolant(bool resuming) { - if (!emcStatus->task.task_paused) { - pauseCoolantSaved = false; - } if (!pauseCoolantSaved) { return; } From 845e3964922a2584c3053ae6d96fcff3cff198b1 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 17 Nov 2026 02:39:09 +0100 Subject: [PATCH 27/27] tests: remove the task planner table and its probe tests/task-planner and test_task_probe recorded what the planner did with every command, to show that the refactoring of emcTaskPlan() changed nothing. That work is done. --- src/Makefile | 2 +- src/emc/task/Submakefile | 9 - src/emc/task/test_task_probe.cc | 255 --------------- tests/task-planner/.gitignore | 5 - tests/task-planner/checkresult | 118 ------- tests/task-planner/expected | 461 --------------------------- tests/task-planner/flush.ngc | 2 - tests/task-planner/skip | 3 - tests/task-planner/task-planner.ini | 99 ------ tests/task-planner/test-ui.py | 215 ------------- tests/task-planner/test.sh | 16 - tests/task-planner/tool.tbl.original | 1 - tests/task-planner/waiting.ngc | 3 - 13 files changed, 1 insertion(+), 1188 deletions(-) delete mode 100644 src/emc/task/test_task_probe.cc delete mode 100644 tests/task-planner/.gitignore delete mode 100755 tests/task-planner/checkresult delete mode 100644 tests/task-planner/expected delete mode 100644 tests/task-planner/flush.ngc delete mode 100755 tests/task-planner/skip delete mode 100644 tests/task-planner/task-planner.ini delete mode 100755 tests/task-planner/test-ui.py delete mode 100755 tests/task-planner/test.sh delete mode 100644 tests/task-planner/tool.tbl.original delete mode 100644 tests/task-planner/waiting.ngc diff --git a/src/Makefile b/src/Makefile index 4e5344b0dc4..05715dd7985 100644 --- a/src/Makefile +++ b/src/Makefile @@ -655,7 +655,7 @@ endif $(DIR) $(DESTDIR)$(sampleconfsdir) ((cd ../configs && tar --exclude CVS --exclude .cvsignore --exclude .gitignore -cf - .) | (cd $(DESTDIR)$(sampleconfsdir) && tar -xf -)) - $(EXE) $(filter-out ../bin/rtapi_app ../bin/linuxcnc_module_helper ../bin/pci_write ../bin/pci_read ../bin/test_rtapi_vsnprintf ../bin/test_task_probe, $(filter ../bin/%,$(TARGETS))) $(DESTDIR)$(bindir) + $(EXE) $(filter-out ../bin/rtapi_app ../bin/linuxcnc_module_helper ../bin/pci_write ../bin/pci_read ../bin/test_rtapi_vsnprintf, $(filter ../bin/%,$(TARGETS))) $(DESTDIR)$(bindir) $(EXE) ../scripts/linuxcnc $(DESTDIR)$(bindir) $(EXE) ../scripts/linuxcnc_info $(DESTDIR)$(bindir) $(EXE) ../scripts/setup_designer $(DESTDIR)$(bindir) diff --git a/src/emc/task/Submakefile b/src/emc/task/Submakefile index 7ed45cd7887..f5f3c99dc18 100644 --- a/src/emc/task/Submakefile +++ b/src/emc/task/Submakefile @@ -39,12 +39,3 @@ USERSRCS += $(MILLTASKSRCS) $(ECHO) Linking $(notdir $@) $(CXX) -o $@ $^ $(LDFLAGS) $(PYTHON_EXTRA_LDFLAGS) $(BOOST_PYTHON_LIB) $(PYTHON_LIBS) $(PYTHON_EXTRA_LIBS) -lfmt TARGETS += ../bin/milltask - -# test helper for tests/task-planner, not installed (see ../Makefile) -TESTTASKPROBESRCS := emc/task/test_task_probe.cc -USERSRCS += $(TESTTASKPROBESRCS) - -../bin/test_task_probe: $(call TOOBJS, $(TESTTASKPROBESRCS)) ../lib/liblinuxcnchal.so.0 ../lib/liblinuxcnc.a ../lib/libnml.so.0 ../lib/liblinuxcncini.so.1 - $(ECHO) Linking $(notdir $@) - $(Q)$(CXX) -o $@ $^ -lfmt $(LDFLAGS) -TARGETS += ../bin/test_task_probe diff --git a/src/emc/task/test_task_probe.cc b/src/emc/task/test_task_probe.cc deleted file mode 100644 index df46c0eb0a5..00000000000 --- a/src/emc/task/test_task_probe.cc +++ /dev/null @@ -1,255 +0,0 @@ -/******************************************************************** -* Description: test_task_probe.cc -* Test helper for tests/task-planner: sends task one command at a time, -* with arguments that change as little as possible, so that the test can -* record what the planner does with each command in each task state. -* -* It reads lines from stdin: -* -* list print the names of all the commands it can send -* probe LABEL NAME send command NAME, bracketed by two operator -* display messages "probe-begin LABEL NAME" and -* "probe-end", and print "serial N" with the -* serial number the command was sent with -* -* Every message is sent only once task has taken the previous one, so -* task's EMC_DEBUG_TASK_ISSUE output shows them in order, between the two -* markers. The test reads that output; this helper reports nothing else. -* -* Built into ../bin for run-in-place tests, never installed. -* -* License: GPL Version 2 -* System: Linux -********************************************************************/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "nml_intf/emc.hh" -#include "nml_intf/emc_nml.hh" -#include "nml_intf/emcglb.h" // emc_nmlfile, emcGetArgs() -#include // EMCMOT_MAX_JOINTS -#include -#include "timeutil.hh" - -static RCS_CMD_CHANNEL *cmdChannel; -static RCS_STAT_CHANNEL *statChannel; - -static const EMC_STAT &stat() -{ - statChannel->peek(); - return *static_cast(statChannel->get_address()); -} - -// Send a command and wait until task has taken it. Returns its serial -// number, or -1. -static int send(RCS_CMD_MSG &cmd) -{ - if (cmdChannel->write(&cmd) != 0) { - return -1; - } - const int serial = cmd.serial_number; - const double end = linuxcnc::etime() + 10.0; - while (linuxcnc::etime() < end) { - if (stat().echo_serial_number - serial >= 0) { - return serial; - } - usleep(1000); - } - fprintf(stderr, "test_task_probe: timeout waiting for serial %d\n", serial); - return -1; -} - -static int display(const std::string &text) -{ - EMC_OPERATOR_DISPLAY msg; - snprintf(msg.display, sizeof(msg.display), "%s", text.c_str()); - return send(msg); -} - -// A joint number no machine has: the joint commands that check their -// joint number then do nothing at all. -static const int NO_JOINT = EMCMOT_MAX_JOINTS; - -typedef std::function(const EMC_STAT &)> Maker; - -// The command, built with arguments that leave things as they are where -// that is possible: the values task already has, joint NO_JOINT, spindle 0. -static std::vector> commands() -{ - std::vector> c; - -#define CMD(name, T, body) \ - c.emplace_back(name, [](const EMC_STAT &s) -> std::unique_ptr { \ - auto m = std::make_unique(); \ - (void)s; \ - body; \ - return m; \ - }) - - CMD("EMC_NULL", EMC_NULL, ); - - // joint configuration, for a joint that does not exist - CMD("EMC_JOINT_SET_BACKLASH", EMC_JOINT_SET_BACKLASH, m->joint = NO_JOINT); - CMD("EMC_JOINT_SET_MAX_POSITION_LIMIT", EMC_JOINT_SET_MAX_POSITION_LIMIT, m->joint = NO_JOINT); - CMD("EMC_JOINT_SET_MIN_POSITION_LIMIT", EMC_JOINT_SET_MIN_POSITION_LIMIT, m->joint = NO_JOINT); - CMD("EMC_JOINT_LOAD_COMP", EMC_JOINT_LOAD_COMP, m->joint = NO_JOINT); - CMD("EMC_JOINT_HOME", EMC_JOINT_HOME, m->joint = NO_JOINT); - CMD("EMC_JOINT_UNHOME", EMC_JOINT_UNHOME, m->joint = NO_JOINT); - CMD("EMC_JOINT_OVERRIDE_LIMITS", EMC_JOINT_OVERRIDE_LIMITS, m->joint = NO_JOINT); - - // jogs of a joint or axis that does not exist - CMD("EMC_JOG_CONT", EMC_JOG_CONT, m->joint_or_axis = NO_JOINT; m->jjogmode = 1); - CMD("EMC_JOG_INCR", EMC_JOG_INCR, m->joint_or_axis = NO_JOINT; m->jjogmode = 1); - CMD("EMC_JOG_STOP", EMC_JOG_STOP, m->joint_or_axis = NO_JOINT; m->jjogmode = 1); - - // trajectory settings, set to what they are - CMD("EMC_TRAJ_SET_SCALE", EMC_TRAJ_SET_SCALE, m->scale = s.motion.traj.scale); - CMD("EMC_TRAJ_SET_RAPID_SCALE", EMC_TRAJ_SET_RAPID_SCALE, m->scale = s.motion.traj.rapid_scale); - CMD("EMC_TRAJ_SET_MAX_VELOCITY", EMC_TRAJ_SET_MAX_VELOCITY, m->velocity = s.motion.traj.maxVelocity); - CMD("EMC_TRAJ_SET_SPINDLE_SCALE", EMC_TRAJ_SET_SPINDLE_SCALE, - m->spindle = 0; m->scale = s.motion.spindle[0].spindle_scale); - CMD("EMC_TRAJ_SET_FO_ENABLE", EMC_TRAJ_SET_FO_ENABLE, m->mode = s.motion.traj.feed_override_enabled); - CMD("EMC_TRAJ_SET_FH_ENABLE", EMC_TRAJ_SET_FH_ENABLE, m->mode = s.motion.traj.feed_hold_enabled); - CMD("EMC_TRAJ_SET_SO_ENABLE", EMC_TRAJ_SET_SO_ENABLE, - m->spindle = 0; m->mode = s.motion.spindle[0].spindle_override_enabled); - CMD("EMC_TRAJ_SET_TELEOP_ENABLE", EMC_TRAJ_SET_TELEOP_ENABLE, - m->enable = s.motion.traj.mode == EMC_TRAJ_MODE::TELEOP); - CMD("EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG", EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG, ); - CMD("EMC_MOTION_SET_DOUT", EMC_MOTION_SET_DOUT, m->index = 0; m->start = 0; m->end = 0; m->now = 1); - CMD("EMC_MOTION_SET_AOUT", EMC_MOTION_SET_AOUT, m->index = 0; m->start = 0; m->end = 0; m->now = 1); - CMD("EMC_MOTION_ADAPTIVE", EMC_MOTION_ADAPTIVE, m->status = s.motion.traj.adaptive_feed_enabled); - CMD("EMC_AUX_INPUT_WAIT", EMC_AUX_INPUT_WAIT, - m->index = 0; m->input_type = 0; m->wait_type = 0; m->timeout = 0); - CMD("EMC_SET_DEBUG", EMC_SET_DEBUG, m->debug = s.debug); - - // spindle and coolant, each "on" followed by its "off" - CMD("EMC_SPINDLE_SPEED", EMC_SPINDLE_SPEED, m->spindle = 0; m->speed = s.motion.spindle[0].speed); - CMD("EMC_SPINDLE_ON", EMC_SPINDLE_ON, m->spindle = 0; m->speed = 0); - CMD("EMC_SPINDLE_INCREASE", EMC_SPINDLE_INCREASE, m->spindle = 0); - CMD("EMC_SPINDLE_DECREASE", EMC_SPINDLE_DECREASE, m->spindle = 0); - CMD("EMC_SPINDLE_CONSTANT", EMC_SPINDLE_CONSTANT, m->spindle = 0); - CMD("EMC_SPINDLE_OFF", EMC_SPINDLE_OFF, m->spindle = 0); - CMD("EMC_SPINDLE_BRAKE_ENGAGE", EMC_SPINDLE_BRAKE_ENGAGE, m->spindle = 0); - CMD("EMC_SPINDLE_BRAKE_RELEASE", EMC_SPINDLE_BRAKE_RELEASE, m->spindle = 0); - CMD("EMC_COOLANT_MIST_ON", EMC_COOLANT_MIST_ON, ); - CMD("EMC_COOLANT_MIST_OFF", EMC_COOLANT_MIST_OFF, ); - CMD("EMC_COOLANT_FLOOD_ON", EMC_COOLANT_FLOOD_ON, ); - CMD("EMC_COOLANT_FLOOD_OFF", EMC_COOLANT_FLOOD_OFF, ); - - // the interpreter's settings, set to what they are - CMD("EMC_TASK_PLAN_SET_OPTIONAL_STOP", EMC_TASK_PLAN_SET_OPTIONAL_STOP, - m->state = s.task.optional_stop_state); - CMD("EMC_TASK_PLAN_SET_BLOCK_DELETE", EMC_TASK_PLAN_SET_BLOCK_DELETE, - m->state = s.task.block_delete_state); - CMD("EMC_TASK_PLAN_SYNCH", EMC_TASK_PLAN_SYNCH, ); - CMD("EMC_TASK_PLAN_OPEN", EMC_TASK_PLAN_OPEN, - snprintf(m->file, sizeof(m->file), "%s", s.task.file)); - - // A command the planner has no case for, so refused unless a state - // accepts it without looking, and one the interpreter never queues, - // which would make it look queued. Should it get through, it sets the - // mode motion is in. - CMD("EMC_TRAJ_SET_MODE", EMC_TRAJ_SET_MODE, m->mode = s.motion.traj.mode); - - // Commands that may well change task's state. The test sets the state - // up again after each of them. - CMD("EMC_TOOL_LOAD_TOOL_TABLE", EMC_TOOL_LOAD_TOOL_TABLE, ); - CMD("EMC_TOOL_SET_NUMBER", EMC_TOOL_SET_NUMBER, m->tool = s.io.tool.toolInSpindle); - CMD("EMC_TOOL_SET_OFFSET", EMC_TOOL_SET_OFFSET, m->pocket = 1; m->toolno = 1; m->diameter = 0.25); - CMD("EMC_SPINDLE_ORIENT", EMC_SPINDLE_ORIENT, m->spindle = 0); - CMD("EMC_SPINDLE_WAIT_ORIENT_COMPLETE", EMC_SPINDLE_WAIT_ORIENT_COMPLETE, - m->spindle = 0; m->timeout = 0.001); - CMD("EMC_TRAJ_PROBE", EMC_TRAJ_PROBE, m->pos = s.motion.traj.position); - CMD("EMC_TRAJ_RIGID_TAP", EMC_TRAJ_RIGID_TAP, m->pos = s.motion.traj.position); - CMD("EMC_TASK_PLAN_OPTIONAL_STOP", EMC_TASK_PLAN_OPTIONAL_STOP, ); - CMD("EMC_TASK_PLAN_EXECUTE", EMC_TASK_PLAN_EXECUTE, - snprintf(m->command, sizeof(m->command), "(probe)")); - CMD("EMC_TASK_PLAN_INIT", EMC_TASK_PLAN_INIT, ); - CMD("EMC_TASK_PLAN_CLOSE", EMC_TASK_PLAN_CLOSE, ); - CMD("EMC_TASK_PLAN_RUN", EMC_TASK_PLAN_RUN, m->line = 0); - CMD("EMC_TASK_PLAN_STEP", EMC_TASK_PLAN_STEP, ); - CMD("EMC_TASK_PLAN_PAUSE", EMC_TASK_PLAN_PAUSE, ); - CMD("EMC_TASK_PLAN_RESUME", EMC_TASK_PLAN_RESUME, ); - CMD("EMC_TASK_PLAN_REVERSE", EMC_TASK_PLAN_REVERSE, ); - CMD("EMC_TASK_PLAN_FORWARD", EMC_TASK_PLAN_FORWARD, ); - CMD("EMC_TASK_ABORT", EMC_TASK_ABORT, ); - CMD("EMC_TASK_SET_STATE(ESTOP)", EMC_TASK_SET_STATE, m->state = EMC_TASK_STATE::ESTOP); - CMD("EMC_TASK_SET_STATE(ESTOP_RESET)", EMC_TASK_SET_STATE, m->state = EMC_TASK_STATE::ESTOP_RESET); - CMD("EMC_TASK_SET_STATE(OFF)", EMC_TASK_SET_STATE, m->state = EMC_TASK_STATE::OFF); - CMD("EMC_TASK_SET_STATE(ON)", EMC_TASK_SET_STATE, m->state = EMC_TASK_STATE::ON); - -#undef CMD - return c; -} - -int main(int argc, char *argv[]) -{ - if (emcGetArgs(argc, argv) != 0) { - fprintf(stderr, "usage: %s [-ini INIFILE]\n", argv[0]); - return 1; - } - { - linuxcnc::IniFile inifile(emc_inifile); - if (inifile) { - if (auto nml = inifile.findString("NML_FILE", "EMC")) { - snprintf(emc_nmlfile, sizeof(emc_nmlfile), "%s", nml->c_str()); - } - } - } - - // like shcom's tryNml(): the status needs a moment after connecting - const double end = linuxcnc::etime() + 10.0; - while (true) { - cmdChannel = new RCS_CMD_CHANNEL(emcFormat, "emcCommand", "xemc", emc_nmlfile); - statChannel = new RCS_STAT_CHANNEL(emcFormat, "emcStatus", "xemc", emc_nmlfile); - if (cmdChannel->valid() && statChannel->valid() && statChannel->peek() == EMC_STAT_TYPE) { - break; - } - delete cmdChannel; - delete statChannel; - if (linuxcnc::etime() > end) { - fprintf(stderr, "test_task_probe: can't connect to task\n"); - return 1; - } - usleep(100000); - } - - const auto cmds = commands(); - std::map byName; - for (const auto &c : cmds) { - byName[c.first] = &c.second; - } - - std::string line; - while (std::getline(std::cin, line)) { - char what[32], label[64], name[64]; - int n = sscanf(line.c_str(), "%31s %63s %63s", what, label, name); - if (n >= 1 && strcmp(what, "list") == 0) { - for (const auto &c : cmds) { - printf("%s\n", c.first.c_str()); - } - printf("end\n"); - } else if (n == 3 && strcmp(what, "probe") == 0 && byName.count(name)) { - auto cmd = (*byName[name])(stat()); - int serial = -1; - if (display(std::string("probe-begin ") + label + " " + name) >= 0) { - serial = send(*cmd); - display("probe-end"); - } - printf("serial %d\n", serial); - } else { - printf("error %s\n", line.c_str()); - } - fflush(stdout); - } - return 0; -} diff --git a/tests/task-planner/.gitignore b/tests/task-planner/.gitignore deleted file mode 100644 index 03a2396556e..00000000000 --- a/tests/task-planner/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -tool.tbl -reading.ngc -sim.var -sim.var.bak -planner-table diff --git a/tests/task-planner/checkresult b/tests/task-planner/checkresult deleted file mode 100755 index bbb98459b76..00000000000 --- a/tests/task-planner/checkresult +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env python3 - -# Build the planner table from the test's output and compare it with the -# expected one. -# -# Task prints (EMC_DEBUG_TASK_ISSUE) every command it issues, with its serial -# number, and (EMC_DEBUG_INTERP_LIST) every command it queues for later. -# test_task_probe brackets each probe by two operator display messages, so -# what task did with the probe sits between "probe-begin" and "probe-end". -# The first of these decides: -# -# issued task issued the command (the serial is the probe's) -# queued task queued a command of that type for later -# refused task said it can't do that now -# handled none of these: the planner dealt with it itself, or ignored it -# -# test-ui.py adds the situation the command left task in, when it changed. -# -# The table is written to planner-table; to accept a change of behaviour, -# copy it over expected. - -import os -import re -import sys - -result = sys.argv[1] -here = os.path.dirname(os.path.abspath(sys.argv[0])) - -BEGIN = re.compile(r"^Issuing EMC_OPERATOR_DISPLAY -- \t \(.*,probe-begin\\032(\S+?)\\032(\S+),\)$") -END = re.compile(r"^Issuing EMC_OPERATOR_DISPLAY -- \t \(.*,probe-end,\)$") -ISSUED = re.compile(r"^Issuing (\S+) -- \t \(\s*\+\d+,\+\d+,\s*\+(\d+),") -QUEUED = re.compile(r"^InterpList\(0x[0-9a-f]+\)::append\((\S+)\)") -REFUSED = re.compile(r"can't do that|cannot be executed until|Can't jog a joint while paused") -PROBE = re.compile(r"^PROBE (\S+) (\S+) (\d+) (\S+)$") - -windows = {} # (situation, command) -> lines between the markers -probes = [] # (situation, command, serial, situation afterwards) -current = None -with open(result, errors='replace') as f: - for line in f: - line = line.rstrip('\n') - m = PROBE.match(line) - if m: - probes.append((m.group(1), m.group(2), int(m.group(3)), m.group(4))) - continue - m = BEGIN.match(line) - if m: - current = (m.group(1), m.group(2)) - windows[current] = [] - continue - if END.match(line): - current = None - continue - if current is not None: - windows[current].append(line) - - -def outcome(command, serial, lines): - base = command.split('(')[0] - for line in lines: - m = ISSUED.match(line) - if m and int(m.group(2)) == serial: - return 'issued' - m = QUEUED.match(line) - if m and m.group(1) == base: - return 'queued' - if REFUSED.search(line): - return 'refused' - return 'handled' - - -situations = [] -commands = [] -cells = {} -for situation, command, serial, after in probes: - if situation not in situations: - situations.append(situation) - if command not in commands: - commands.append(command) - lines = windows.get((situation, command)) - if lines is None: - cell = 'missing' - else: - cell = outcome(command, serial, lines) - if after != '-': - cell += ' -> ' + after - cells[(situation, command)] = cell - -if not probes: - print("no probes in the test output") - sys.exit(1) - -width = max(len(c) for c in commands) -table = [] -for situation in situations: - table.append("[%s]" % situation) - for command in commands: - table.append("%-*s %s" % (width, command, cells.get((situation, command), 'missing'))) - table.append("") -text = "\n".join(table) - -with open(os.path.join(here, 'planner-table'), 'w') as f: - f.write(text) - -try: - with open(os.path.join(here, 'expected')) as f: - expected = f.read() -except FileNotFoundError: - print("no expected table; this run's table is in planner-table") - sys.exit(1) - -if expected == text: - sys.exit(0) - -import difflib -sys.stdout.writelines(difflib.unified_diff(expected.splitlines(True), text.splitlines(True), - 'expected', 'planner-table')) -sys.exit(1) diff --git a/tests/task-planner/expected b/tests/task-planner/expected deleted file mode 100644 index f2ff9557c39..00000000000 --- a/tests/task-planner/expected +++ /dev/null @@ -1,461 +0,0 @@ -[estop] -EMC_NULL handled -EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_MAX_POSITION_LIMIT refused -EMC_JOINT_SET_MIN_POSITION_LIMIT refused -EMC_JOINT_LOAD_COMP issued -EMC_JOINT_HOME refused -EMC_JOINT_UNHOME issued -EMC_JOINT_OVERRIDE_LIMITS issued -EMC_JOG_CONT refused -EMC_JOG_INCR refused -EMC_JOG_STOP refused -EMC_TRAJ_SET_SCALE issued -EMC_TRAJ_SET_RAPID_SCALE issued -EMC_TRAJ_SET_MAX_VELOCITY issued -EMC_TRAJ_SET_SPINDLE_SCALE issued -EMC_TRAJ_SET_FO_ENABLE issued -EMC_TRAJ_SET_FH_ENABLE issued -EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_TELEOP_ENABLE issued -EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued -EMC_MOTION_SET_DOUT issued -EMC_MOTION_SET_AOUT issued -EMC_MOTION_ADAPTIVE issued -EMC_AUX_INPUT_WAIT issued -EMC_SET_DEBUG issued -EMC_SPINDLE_SPEED refused -EMC_SPINDLE_ON refused -EMC_SPINDLE_INCREASE refused -EMC_SPINDLE_DECREASE refused -EMC_SPINDLE_CONSTANT refused -EMC_SPINDLE_OFF refused -EMC_SPINDLE_BRAKE_ENGAGE refused -EMC_SPINDLE_BRAKE_RELEASE refused -EMC_COOLANT_MIST_ON refused -EMC_COOLANT_MIST_OFF refused -EMC_COOLANT_FLOOD_ON refused -EMC_COOLANT_FLOOD_OFF refused -EMC_TASK_PLAN_SET_OPTIONAL_STOP issued -EMC_TASK_PLAN_SET_BLOCK_DELETE issued -EMC_TASK_PLAN_SYNCH issued -EMC_TASK_PLAN_OPEN issued -EMC_TRAJ_SET_MODE refused -EMC_TOOL_LOAD_TOOL_TABLE queued -EMC_TOOL_SET_NUMBER queued -EMC_TOOL_SET_OFFSET queued -EMC_SPINDLE_ORIENT refused -EMC_SPINDLE_WAIT_ORIENT_COMPLETE refused -EMC_TRAJ_PROBE issued -EMC_TRAJ_RIGID_TAP issued -EMC_TASK_PLAN_OPTIONAL_STOP refused -EMC_TASK_PLAN_EXECUTE refused -EMC_TASK_PLAN_INIT issued -> ESTOP/MANUAL/IDLE -EMC_TASK_PLAN_CLOSE issued -EMC_TASK_PLAN_RUN refused -EMC_TASK_PLAN_STEP refused -EMC_TASK_PLAN_PAUSE refused -EMC_TASK_PLAN_RESUME refused -EMC_TASK_PLAN_REVERSE refused -EMC_TASK_PLAN_FORWARD refused -EMC_TASK_ABORT issued -EMC_TASK_SET_STATE(ESTOP) issued -EMC_TASK_SET_STATE(ESTOP_RESET) issued -> OFF/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(OFF) issued -EMC_TASK_SET_STATE(ON) issued - -[off] -EMC_NULL handled -EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_MAX_POSITION_LIMIT refused -EMC_JOINT_SET_MIN_POSITION_LIMIT refused -EMC_JOINT_LOAD_COMP issued -EMC_JOINT_HOME refused -EMC_JOINT_UNHOME issued -EMC_JOINT_OVERRIDE_LIMITS issued -EMC_JOG_CONT refused -EMC_JOG_INCR refused -EMC_JOG_STOP refused -EMC_TRAJ_SET_SCALE issued -EMC_TRAJ_SET_RAPID_SCALE issued -EMC_TRAJ_SET_MAX_VELOCITY issued -EMC_TRAJ_SET_SPINDLE_SCALE issued -EMC_TRAJ_SET_FO_ENABLE issued -EMC_TRAJ_SET_FH_ENABLE issued -EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_TELEOP_ENABLE issued -EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued -EMC_MOTION_SET_DOUT issued -EMC_MOTION_SET_AOUT issued -EMC_MOTION_ADAPTIVE issued -EMC_AUX_INPUT_WAIT issued -EMC_SET_DEBUG issued -EMC_SPINDLE_SPEED refused -EMC_SPINDLE_ON refused -EMC_SPINDLE_INCREASE refused -EMC_SPINDLE_DECREASE refused -EMC_SPINDLE_CONSTANT refused -EMC_SPINDLE_OFF refused -EMC_SPINDLE_BRAKE_ENGAGE refused -EMC_SPINDLE_BRAKE_RELEASE refused -EMC_COOLANT_MIST_ON refused -EMC_COOLANT_MIST_OFF refused -EMC_COOLANT_FLOOD_ON refused -EMC_COOLANT_FLOOD_OFF refused -EMC_TASK_PLAN_SET_OPTIONAL_STOP issued -EMC_TASK_PLAN_SET_BLOCK_DELETE issued -EMC_TASK_PLAN_SYNCH issued -EMC_TASK_PLAN_OPEN issued -EMC_TRAJ_SET_MODE refused -EMC_TOOL_LOAD_TOOL_TABLE queued -EMC_TOOL_SET_NUMBER queued -EMC_TOOL_SET_OFFSET queued -EMC_SPINDLE_ORIENT refused -EMC_SPINDLE_WAIT_ORIENT_COMPLETE refused -EMC_TRAJ_PROBE issued -EMC_TRAJ_RIGID_TAP issued -EMC_TASK_PLAN_OPTIONAL_STOP refused -EMC_TASK_PLAN_EXECUTE refused -EMC_TASK_PLAN_INIT issued -> OFF/MANUAL/IDLE -EMC_TASK_PLAN_CLOSE issued -EMC_TASK_PLAN_RUN refused -EMC_TASK_PLAN_STEP refused -EMC_TASK_PLAN_PAUSE refused -EMC_TASK_PLAN_RESUME refused -EMC_TASK_PLAN_REVERSE refused -EMC_TASK_PLAN_FORWARD refused -EMC_TASK_ABORT issued -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP_RESET) issued -EMC_TASK_SET_STATE(OFF) issued -EMC_TASK_SET_STATE(ON) issued -> ON/MANUAL/IDLE/reading.ngc - -[idle] -EMC_NULL handled -EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_MAX_POSITION_LIMIT issued -EMC_JOINT_SET_MIN_POSITION_LIMIT issued -EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HOME issued -EMC_JOINT_UNHOME issued -EMC_JOINT_OVERRIDE_LIMITS issued -EMC_JOG_CONT issued -EMC_JOG_INCR issued -EMC_JOG_STOP issued -EMC_TRAJ_SET_SCALE issued -EMC_TRAJ_SET_RAPID_SCALE issued -EMC_TRAJ_SET_MAX_VELOCITY issued -EMC_TRAJ_SET_SPINDLE_SCALE issued -EMC_TRAJ_SET_FO_ENABLE issued -EMC_TRAJ_SET_FH_ENABLE issued -EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_TELEOP_ENABLE issued -EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued -EMC_MOTION_SET_DOUT issued -EMC_MOTION_SET_AOUT issued -EMC_MOTION_ADAPTIVE issued -EMC_AUX_INPUT_WAIT issued -EMC_SET_DEBUG issued -EMC_SPINDLE_SPEED issued -EMC_SPINDLE_ON issued -EMC_SPINDLE_INCREASE issued -EMC_SPINDLE_DECREASE issued -EMC_SPINDLE_CONSTANT issued -EMC_SPINDLE_OFF issued -EMC_SPINDLE_BRAKE_ENGAGE issued -EMC_SPINDLE_BRAKE_RELEASE issued -EMC_COOLANT_MIST_ON issued -EMC_COOLANT_MIST_OFF issued -EMC_COOLANT_FLOOD_ON issued -EMC_COOLANT_FLOOD_OFF issued -EMC_TASK_PLAN_SET_OPTIONAL_STOP issued -EMC_TASK_PLAN_SET_BLOCK_DELETE issued -EMC_TASK_PLAN_SYNCH issued -EMC_TASK_PLAN_OPEN issued -EMC_TRAJ_SET_MODE refused -EMC_TOOL_LOAD_TOOL_TABLE queued -EMC_TOOL_SET_NUMBER queued -EMC_TOOL_SET_OFFSET queued -EMC_SPINDLE_ORIENT issued -EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued -EMC_TRAJ_PROBE issued -EMC_TRAJ_RIGID_TAP issued -EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/MANUAL/PAUSED/reading.ngc -EMC_TASK_PLAN_EXECUTE issued -EMC_TASK_PLAN_INIT issued -> ON/MANUAL/IDLE -EMC_TASK_PLAN_CLOSE issued -EMC_TASK_PLAN_RUN issued -> ON/AUTO/READING/reading.ngc -EMC_TASK_PLAN_STEP handled -> ON/AUTO/PAUSED/reading.ngc -EMC_TASK_PLAN_PAUSE issued -> ON/MANUAL/PAUSED/reading.ngc -EMC_TASK_PLAN_RESUME issued -EMC_TASK_PLAN_REVERSE issued -EMC_TASK_PLAN_FORWARD issued -EMC_TASK_ABORT issued -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP_RESET) issued -EMC_TASK_SET_STATE(OFF) issued -> OFF/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(ON) issued - -[mdi-busy] -EMC_NULL handled -EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_MAX_POSITION_LIMIT refused -EMC_JOINT_SET_MIN_POSITION_LIMIT refused -EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HOME refused -EMC_JOINT_UNHOME issued -EMC_JOINT_OVERRIDE_LIMITS refused -EMC_JOG_CONT refused -EMC_JOG_INCR refused -EMC_JOG_STOP issued -EMC_TRAJ_SET_SCALE issued -EMC_TRAJ_SET_RAPID_SCALE issued -EMC_TRAJ_SET_MAX_VELOCITY issued -EMC_TRAJ_SET_SPINDLE_SCALE issued -EMC_TRAJ_SET_FO_ENABLE issued -EMC_TRAJ_SET_FH_ENABLE issued -EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_TELEOP_ENABLE refused -EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued -EMC_MOTION_SET_DOUT issued -EMC_MOTION_SET_AOUT issued -EMC_MOTION_ADAPTIVE issued -EMC_AUX_INPUT_WAIT issued -> ON/MANUAL/IDLE/reading.ngc -EMC_SET_DEBUG issued -EMC_SPINDLE_SPEED issued -EMC_SPINDLE_ON issued -EMC_SPINDLE_INCREASE issued -EMC_SPINDLE_DECREASE issued -EMC_SPINDLE_CONSTANT issued -EMC_SPINDLE_OFF issued -EMC_SPINDLE_BRAKE_ENGAGE issued -EMC_SPINDLE_BRAKE_RELEASE issued -EMC_COOLANT_MIST_ON issued -EMC_COOLANT_MIST_OFF issued -EMC_COOLANT_FLOOD_ON issued -EMC_COOLANT_FLOOD_OFF issued -EMC_TASK_PLAN_SET_OPTIONAL_STOP issued -EMC_TASK_PLAN_SET_BLOCK_DELETE issued -EMC_TASK_PLAN_SYNCH issued -EMC_TASK_PLAN_OPEN issued -EMC_TRAJ_SET_MODE refused -EMC_TOOL_LOAD_TOOL_TABLE queued -EMC_TOOL_SET_NUMBER refused -EMC_TOOL_SET_OFFSET queued -EMC_SPINDLE_ORIENT issued -EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TRAJ_PROBE issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TRAJ_RIGID_TAP issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/MDI/PAUSED/reading.ngc -EMC_TASK_PLAN_EXECUTE issued -EMC_TASK_PLAN_INIT issued -> ON/MDI/READING -EMC_TASK_PLAN_CLOSE issued -EMC_TASK_PLAN_RUN refused -EMC_TASK_PLAN_STEP refused -EMC_TASK_PLAN_PAUSE issued -> ON/MDI/PAUSED/reading.ngc -EMC_TASK_PLAN_RESUME issued -EMC_TASK_PLAN_REVERSE issued -EMC_TASK_PLAN_FORWARD issued -EMC_TASK_ABORT issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(OFF) issued -> OFF/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(ON) issued - -[auto-reading] -EMC_NULL handled -EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_MAX_POSITION_LIMIT refused -EMC_JOINT_SET_MIN_POSITION_LIMIT refused -EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HOME refused -EMC_JOINT_UNHOME issued -EMC_JOINT_OVERRIDE_LIMITS refused -EMC_JOG_CONT refused -EMC_JOG_INCR refused -EMC_JOG_STOP refused -EMC_TRAJ_SET_SCALE issued -EMC_TRAJ_SET_RAPID_SCALE issued -EMC_TRAJ_SET_MAX_VELOCITY issued -EMC_TRAJ_SET_SPINDLE_SCALE issued -EMC_TRAJ_SET_FO_ENABLE issued -EMC_TRAJ_SET_FH_ENABLE issued -EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_TELEOP_ENABLE refused -EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued -EMC_MOTION_SET_DOUT refused -EMC_MOTION_SET_AOUT refused -EMC_MOTION_ADAPTIVE refused -EMC_AUX_INPUT_WAIT issued -EMC_SET_DEBUG issued -EMC_SPINDLE_SPEED refused -EMC_SPINDLE_ON refused -EMC_SPINDLE_INCREASE issued -EMC_SPINDLE_DECREASE issued -EMC_SPINDLE_CONSTANT issued -EMC_SPINDLE_OFF refused -EMC_SPINDLE_BRAKE_ENGAGE refused -EMC_SPINDLE_BRAKE_RELEASE refused -EMC_COOLANT_MIST_ON issued -EMC_COOLANT_MIST_OFF issued -EMC_COOLANT_FLOOD_ON issued -EMC_COOLANT_FLOOD_OFF issued -EMC_TASK_PLAN_SET_OPTIONAL_STOP issued -EMC_TASK_PLAN_SET_BLOCK_DELETE issued -EMC_TASK_PLAN_SYNCH refused -EMC_TASK_PLAN_OPEN refused -EMC_TRAJ_SET_MODE refused -EMC_TOOL_LOAD_TOOL_TABLE refused -EMC_TOOL_SET_NUMBER refused -EMC_TOOL_SET_OFFSET refused -EMC_SPINDLE_ORIENT refused -EMC_SPINDLE_WAIT_ORIENT_COMPLETE refused -EMC_TRAJ_PROBE issued -EMC_TRAJ_RIGID_TAP issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/AUTO/PAUSED/reading.ngc -EMC_TASK_PLAN_EXECUTE refused -EMC_TASK_PLAN_INIT refused -EMC_TASK_PLAN_CLOSE refused -EMC_TASK_PLAN_RUN refused -EMC_TASK_PLAN_STEP handled -EMC_TASK_PLAN_PAUSE issued -> ON/AUTO/PAUSED/reading.ngc -EMC_TASK_PLAN_RESUME issued -EMC_TASK_PLAN_REVERSE issued -EMC_TASK_PLAN_FORWARD issued -EMC_TASK_ABORT issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(OFF) issued -> OFF/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(ON) issued - -[auto-waiting] -EMC_NULL handled -EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_MAX_POSITION_LIMIT refused -EMC_JOINT_SET_MIN_POSITION_LIMIT refused -EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HOME refused -EMC_JOINT_UNHOME issued -EMC_JOINT_OVERRIDE_LIMITS refused -EMC_JOG_CONT refused -EMC_JOG_INCR refused -EMC_JOG_STOP refused -EMC_TRAJ_SET_SCALE issued -EMC_TRAJ_SET_RAPID_SCALE issued -EMC_TRAJ_SET_MAX_VELOCITY issued -EMC_TRAJ_SET_SPINDLE_SCALE issued -EMC_TRAJ_SET_FO_ENABLE issued -EMC_TRAJ_SET_FH_ENABLE issued -EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_TELEOP_ENABLE refused -EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued -EMC_MOTION_SET_DOUT refused -EMC_MOTION_SET_AOUT refused -EMC_MOTION_ADAPTIVE refused -EMC_AUX_INPUT_WAIT issued -EMC_SET_DEBUG issued -EMC_SPINDLE_SPEED refused -EMC_SPINDLE_ON refused -EMC_SPINDLE_INCREASE issued -EMC_SPINDLE_DECREASE issued -EMC_SPINDLE_CONSTANT issued -EMC_SPINDLE_OFF refused -EMC_SPINDLE_BRAKE_ENGAGE refused -EMC_SPINDLE_BRAKE_RELEASE refused -EMC_COOLANT_MIST_ON issued -EMC_COOLANT_MIST_OFF issued -EMC_COOLANT_FLOOD_ON issued -EMC_COOLANT_FLOOD_OFF issued -EMC_TASK_PLAN_SET_OPTIONAL_STOP issued -EMC_TASK_PLAN_SET_BLOCK_DELETE issued -EMC_TASK_PLAN_SYNCH refused -EMC_TASK_PLAN_OPEN refused -EMC_TRAJ_SET_MODE refused -EMC_TOOL_LOAD_TOOL_TABLE refused -EMC_TOOL_SET_NUMBER refused -EMC_TOOL_SET_OFFSET refused -EMC_SPINDLE_ORIENT refused -EMC_SPINDLE_WAIT_ORIENT_COMPLETE refused -EMC_TRAJ_PROBE issued -EMC_TRAJ_RIGID_TAP issued -> ON/MANUAL/IDLE/waiting.ngc -EMC_TASK_PLAN_OPTIONAL_STOP issued -> ON/AUTO/PAUSED/waiting.ngc -EMC_TASK_PLAN_EXECUTE refused -EMC_TASK_PLAN_INIT refused -EMC_TASK_PLAN_CLOSE refused -EMC_TASK_PLAN_RUN refused -EMC_TASK_PLAN_STEP handled -EMC_TASK_PLAN_PAUSE issued -> ON/AUTO/PAUSED/waiting.ngc -EMC_TASK_PLAN_RESUME issued -EMC_TASK_PLAN_REVERSE issued -EMC_TASK_PLAN_FORWARD issued -EMC_TASK_ABORT issued -> ON/MANUAL/IDLE/waiting.ngc -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/waiting.ngc -EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/MANUAL/IDLE/waiting.ngc -EMC_TASK_SET_STATE(OFF) issued -> OFF/MANUAL/IDLE/waiting.ngc -EMC_TASK_SET_STATE(ON) issued - -[auto-paused] -EMC_NULL handled -EMC_JOINT_SET_BACKLASH issued -EMC_JOINT_SET_MAX_POSITION_LIMIT refused -EMC_JOINT_SET_MIN_POSITION_LIMIT refused -EMC_JOINT_LOAD_COMP refused -EMC_JOINT_HOME refused -EMC_JOINT_UNHOME issued -EMC_JOINT_OVERRIDE_LIMITS refused -EMC_JOG_CONT refused -EMC_JOG_INCR refused -EMC_JOG_STOP issued -EMC_TRAJ_SET_SCALE issued -EMC_TRAJ_SET_RAPID_SCALE issued -EMC_TRAJ_SET_MAX_VELOCITY issued -EMC_TRAJ_SET_SPINDLE_SCALE issued -EMC_TRAJ_SET_FO_ENABLE issued -EMC_TRAJ_SET_FH_ENABLE issued -EMC_TRAJ_SET_SO_ENABLE issued -EMC_TRAJ_SET_TELEOP_ENABLE refused -EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG issued -EMC_MOTION_SET_DOUT refused -EMC_MOTION_SET_AOUT refused -EMC_MOTION_ADAPTIVE refused -EMC_AUX_INPUT_WAIT issued -EMC_SET_DEBUG issued -EMC_SPINDLE_SPEED issued -EMC_SPINDLE_ON issued -EMC_SPINDLE_INCREASE issued -EMC_SPINDLE_DECREASE issued -EMC_SPINDLE_CONSTANT issued -EMC_SPINDLE_OFF issued -EMC_SPINDLE_BRAKE_ENGAGE issued -EMC_SPINDLE_BRAKE_RELEASE issued -EMC_COOLANT_MIST_ON issued -EMC_COOLANT_MIST_OFF issued -EMC_COOLANT_FLOOD_ON issued -EMC_COOLANT_FLOOD_OFF issued -EMC_TASK_PLAN_SET_OPTIONAL_STOP issued -EMC_TASK_PLAN_SET_BLOCK_DELETE issued -EMC_TASK_PLAN_SYNCH refused -EMC_TASK_PLAN_OPEN refused -EMC_TRAJ_SET_MODE refused -EMC_TOOL_LOAD_TOOL_TABLE refused -EMC_TOOL_SET_NUMBER refused -EMC_TOOL_SET_OFFSET refused -EMC_SPINDLE_ORIENT issued -EMC_SPINDLE_WAIT_ORIENT_COMPLETE issued -EMC_TRAJ_PROBE issued -EMC_TRAJ_RIGID_TAP issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TASK_PLAN_OPTIONAL_STOP issued -EMC_TASK_PLAN_EXECUTE refused -EMC_TASK_PLAN_INIT refused -EMC_TASK_PLAN_CLOSE refused -EMC_TASK_PLAN_RUN refused -EMC_TASK_PLAN_STEP handled -EMC_TASK_PLAN_PAUSE issued -EMC_TASK_PLAN_RESUME issued -> ON/AUTO/READING/reading.ngc -EMC_TASK_PLAN_REVERSE issued -EMC_TASK_PLAN_FORWARD issued -EMC_TASK_ABORT issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP) issued -> ESTOP/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(ESTOP_RESET) issued -> ON/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(OFF) issued -> OFF/MANUAL/IDLE/reading.ngc -EMC_TASK_SET_STATE(ON) issued diff --git a/tests/task-planner/flush.ngc b/tests/task-planner/flush.ngc deleted file mode 100644 index 524219889f8..00000000000 --- a/tests/task-planner/flush.ngc +++ /dev/null @@ -1,2 +0,0 @@ -(ends at once: running it clears the wait flag) -M2 diff --git a/tests/task-planner/skip b/tests/task-planner/skip deleted file mode 100755 index 6d7f0bdb110..00000000000 --- a/tests/task-planner/skip +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# The probe helper is built with the run-in-place tree only. -command -v test_task_probe > /dev/null diff --git a/tests/task-planner/task-planner.ini b/tests/task-planner/task-planner.ini deleted file mode 100644 index 850985025f3..00000000000 --- a/tests/task-planner/task-planner.ini +++ /dev/null @@ -1,99 +0,0 @@ -[EMC] -VERSION = 1.1 -# EMC_DEBUG_TASK_ISSUE | EMC_DEBUG_INTERP_LIST: what the test reads -DEBUG = 0x00000810 -RCS_DEBUG = 0x05400f01 - -[DISPLAY] -DISPLAY = ./test-ui.py - -[RS274NGC] -PARAMETER_FILE = sim.var - -[EMCMOT] -EMCMOT = motmod -COMM_TIMEOUT = 4.0 -BASE_PERIOD = 0 -SERVO_PERIOD = 1000000 - -[TASK] -TASK = milltask -CYCLE_TIME = 0.001 -MDI_QUEUED_COMMANDS=10000 - -[HAL] -HALFILE = LIB:core_sim.hal - -[EMCIO] -TOOL_TABLE = tool.tbl - -[TRAJ] -NO_FORCE_HOMING=1 -AXES = 3 -COORDINATES = X Y Z -HOME = 0 0 0 -LINEAR_UNITS = inch -ANGULAR_UNITS = degree -DEFAULT_LINEAR_VELOCITY = 1.2 -MAX_LINEAR_VELOCITY = 4 - -[KINS] -KINEMATICS = trivkins -JOINTS = 3 - -[AXIS_X] -MIN_LIMIT = -40.0 -MAX_LIMIT = 40.0 -MAX_VELOCITY = 4 -MAX_ACCELERATION = 1000.0 - -[JOINT_0] -TYPE = LINEAR -HOME = 0.000 -MAX_VELOCITY = 4 -MAX_ACCELERATION = 1000.0 -BACKLASH = 0.000 -INPUT_SCALE = 4000 -OUTPUT_SCALE = 1.000 -MIN_LIMIT = -40.0 -MAX_LIMIT = 40.0 -FERROR = 0.050 -MIN_FERROR = 0.010 - -[AXIS_Y] -MIN_LIMIT = -40.0 -MAX_LIMIT = 40.0 -MAX_VELOCITY = 4 -MAX_ACCELERATION = 1000.0 - -[JOINT_1] -TYPE = LINEAR -HOME = 0.000 -MAX_VELOCITY = 4 -MAX_ACCELERATION = 1000.0 -BACKLASH = 0.000 -INPUT_SCALE = 4000 -OUTPUT_SCALE = 1.000 -MIN_LIMIT = -40.0 -MAX_LIMIT = 40.0 -FERROR = 0.050 -MIN_FERROR = 0.010 - -[AXIS_Z] -MIN_LIMIT = -4.0 -MAX_LIMIT = 4.0 -MAX_VELOCITY = 4 -MAX_ACCELERATION = 1000.0 - -[JOINT_2] -TYPE = LINEAR -HOME = 0.0 -MAX_VELOCITY = 4 -MAX_ACCELERATION = 1000.0 -BACKLASH = 0.000 -INPUT_SCALE = 4000 -OUTPUT_SCALE = 1.000 -MIN_LIMIT = -4.0 -MAX_LIMIT = 4.0 -FERROR = 0.050 -MIN_FERROR = 0.010 diff --git a/tests/task-planner/test-ui.py b/tests/task-planner/test-ui.py deleted file mode 100755 index 5e322e2890b..00000000000 --- a/tests/task-planner/test-ui.py +++ /dev/null @@ -1,215 +0,0 @@ -#!/usr/bin/env python3 - -# Bring task into each situation the planner tells apart and have -# test_task_probe send it every command there, one at a time. For each probe -# this prints -# -# PROBE -# -# checkresult then reads, from task's own output, what the planner did with -# the command, and compares the table with the expected one. - -import linuxcnc -import os -import subprocess -import sys -import time - -program_start = time.time() - -def log(msg): - print("%.3f: %s" % (time.time() - program_start, msg)) - sys.stdout.flush() - - -c = linuxcnc.command() -s = linuxcnc.stat() -e = linuxcnc.error_channel() - -probe = subprocess.Popen(['test_task_probe', '-ini', os.environ['INI_FILE_NAME']], - stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True) - -def probe_cmd(line): - probe.stdin.write(line + "\n") - probe.stdin.flush() - return probe.stdout.readline().strip() - -probe.stdin.write("list\n") -probe.stdin.flush() -commands = [] -while True: - name = probe.stdout.readline().strip() - if name == 'end' or name == '': - break - commands.append(name) - -# Commands from EMC_TOOL_LOAD_TOOL_TABLE on (test_task_probe lists them -# last) set the situation up again afterwards, changed or not: they may -# leave something behind that the situation doesn't show, such as a wait -# for the interpreter, a pause pending, or a move in motion. -first_unsafe = commands.index('EMC_TOOL_LOAD_TOOL_TABLE') - -reading = os.path.abspath('reading.ngc') -waiting = os.path.abspath('waiting.ngc') -flush = os.path.abspath('flush.ngc') - -# The three tool commands set task's wait flag (emcTaskPlanSetWait()), and -# only a program reading or an MDI command waiting clears it again; an -# abort does not. While it is set, an MDI command is queued -# rather than issued. So that a probe does not depend on the ones before it, -# the flag is cleared, by running a program that ends at once, whenever a -# situation is set up afresh and after each tool command. -TOOL_COMMANDS = {'EMC_TOOL_LOAD_TOOL_TABLE', 'EMC_TOOL_SET_NUMBER', 'EMC_TOOL_SET_OFFSET'} - -STATE = {linuxcnc.STATE_ESTOP: 'ESTOP', linuxcnc.STATE_ESTOP_RESET: 'OFF', - linuxcnc.STATE_OFF: 'OFF', linuxcnc.STATE_ON: 'ON'} -MODE = {linuxcnc.MODE_MANUAL: 'MANUAL', linuxcnc.MODE_AUTO: 'AUTO', - linuxcnc.MODE_MDI: 'MDI'} -INTERP = {linuxcnc.INTERP_IDLE: 'IDLE', linuxcnc.INTERP_READING: 'READING', - linuxcnc.INTERP_PAUSED: 'PAUSED', linuxcnc.INTERP_WAITING: 'WAITING'} - - -def situation(): - s.poll() - return "%s/%s/%s%s%s" % (STATE[s.task_state], MODE[s.task_mode], - INTERP[s.interp_state], - '/queued-mdi' if s.queued_mdi_commands else '', - '/' + os.path.basename(s.file) if s.file else '') - - -def drain_errors(): - while e.poll(): - pass - - -def wait_for(what, cond, timeout=10.0): - end = time.time() + timeout - while time.time() < end: - s.poll() - if cond(): - return - time.sleep(0.01) - log("timeout waiting for %s, situation %s" % (what, situation())) - sys.exit(1) - - -# Each step only when it is needed: setting up again is most of the time -# this test takes. - -def command(what, cond, *args): - what(*args) - # a program run is EXEC until it ends: wait for the state it is after - if what != c.auto: - c.wait_complete() - wait_for(what.__name__, cond) - - -def state(st): - s.poll() - if st == linuxcnc.STATE_ON and s.task_state != linuxcnc.STATE_ON: - if s.task_state == linuxcnc.STATE_ESTOP: - command(c.state, lambda: s.task_state != linuxcnc.STATE_ESTOP, - linuxcnc.STATE_ESTOP_RESET) - command(c.state, lambda: s.task_state == linuxcnc.STATE_ON, linuxcnc.STATE_ON) - elif st == linuxcnc.STATE_ESTOP and s.task_state != linuxcnc.STATE_ESTOP: - command(c.state, lambda: s.task_state == linuxcnc.STATE_ESTOP, linuxcnc.STATE_ESTOP) - elif st == linuxcnc.STATE_OFF and s.task_state not in (linuxcnc.STATE_OFF, - linuxcnc.STATE_ESTOP_RESET): - if s.task_state == linuxcnc.STATE_ESTOP: - command(c.state, lambda: s.task_state != linuxcnc.STATE_ESTOP, - linuxcnc.STATE_ESTOP_RESET) - else: - command(c.state, lambda: s.task_state != linuxcnc.STATE_ON, linuxcnc.STATE_OFF) - - -def idle(): - s.poll() - if s.interp_state != linuxcnc.INTERP_IDLE or s.queued_mdi_commands: - command(c.abort, lambda: s.interp_state == linuxcnc.INTERP_IDLE) - - -def program(f): - s.poll() - if s.file != f: - c.program_open(f) - c.wait_complete() - - -def run(f, interp): - state(linuxcnc.STATE_ON) - idle() - program(f) - command(c.auto, lambda: s.interp_state == interp, linuxcnc.AUTO_RUN, 0) - - -def clear_wait_flag(): - state(linuxcnc.STATE_ON) - idle() - program(flush) - c.auto(linuxcnc.AUTO_RUN, 0) - wait_for("flush.ngc to end", lambda: s.interp_state == linuxcnc.INTERP_IDLE - and s.exec_state == linuxcnc.EXEC_DONE) - - -def set_up(name, afresh=False): - if afresh: - clear_wait_flag() - # the same program is open in every situation, so that the open file - # is part of the situation without being set up again for each one - if name in ('estop', 'off', 'idle', 'mdi-busy'): - idle() - program(reading) - if name == 'estop': - state(linuxcnc.STATE_ESTOP) - elif name == 'off': - state(linuxcnc.STATE_OFF) - elif name == 'idle': - state(linuxcnc.STATE_ON) - elif name == 'mdi-busy': - state(linuxcnc.STATE_ON) - c.mdi("G4 P600") - wait_for("MDI running", lambda: s.interp_state != linuxcnc.INTERP_IDLE) - elif name == 'auto-reading': - run(reading, linuxcnc.INTERP_READING) - elif name == 'auto-waiting': - run(waiting, linuxcnc.INTERP_WAITING) - elif name == 'auto-paused': - run(reading, linuxcnc.INTERP_READING) - command(c.auto, lambda: s.interp_state == linuxcnc.INTERP_PAUSED, linuxcnc.AUTO_PAUSE) - time.sleep(0.02) - drain_errors() - return situation() - - -# Task has no modes to switch between: what it accepts depends on its state -# and on what it runs (nothing, MDI, a program). -SITUATIONS = ['estop', 'off', 'idle', 'mdi-busy', - 'auto-reading', 'auto-waiting', 'auto-paused'] - -for name in SITUATIONS: - expected = set_up(name, afresh=True) - log("situation %s: %s" % (name, expected)) - for i, cmd in enumerate(commands): - reply = probe_cmd("probe %s %s" % (name, cmd)) - if not reply.startswith('serial ') or int(reply.split()[1]) < 0: - log("probe %s %s failed: %s" % (name, cmd, reply)) - sys.exit(1) - serial = int(reply.split()[1]) - time.sleep(0.05) - after = situation() - print("PROBE %s %s %d %s" % (name, cmd, serial, - after if after != expected else '-')) - sys.stdout.flush() - if after != expected or i >= first_unsafe: - if set_up(name, afresh=cmd in TOOL_COMMANDS) != expected: - log("cannot set up %s again after %s: %s" % (name, cmd, situation())) - sys.exit(1) - drain_errors() - -probe.stdin.close() -probe.wait() - -c.state(linuxcnc.STATE_ESTOP) -c.wait_complete() -log("done") -sys.exit(0) diff --git a/tests/task-planner/test.sh b/tests/task-planner/test.sh deleted file mode 100755 index a5e5363414c..00000000000 --- a/tests/task-planner/test.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -cp -f tool.tbl.original tool.tbl - -# A program long enough that the interpreter is still reading while the -# test probes: tiny moves, far more of them than task reads ahead. -{ - echo "G1 F1" - for _ in $(seq 5000); do - echo "X0.001" - echo "X0" - done - echo "M2" -} > reading.ngc - -exec linuxcnc -r task-planner.ini diff --git a/tests/task-planner/tool.tbl.original b/tests/task-planner/tool.tbl.original deleted file mode 100644 index b9efc8ef48f..00000000000 --- a/tests/task-planner/tool.tbl.original +++ /dev/null @@ -1 +0,0 @@ -T1 P1 D0.25 Z0.5 ;probe tool diff --git a/tests/task-planner/waiting.ngc b/tests/task-planner/waiting.ngc deleted file mode 100644 index 9949fb236ed..00000000000 --- a/tests/task-planner/waiting.ngc +++ /dev/null @@ -1,3 +0,0 @@ -(one long move: the interpreter is done reading, task waits for motion) -G1 X1 F0.1 -M2