From 0c78343d17709102f4a6f49e37034bdebea73536 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 10 Nov 2026 17:31:07 +0100 Subject: [PATCH 01/11] 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/skip | 3 + tests/task-planner/task-planner.ini | 99 ++++ tests/task-planner/test-ui.py | 226 +++++++++ tests/task-planner/test.sh | 16 + tests/task-planner/tool.tbl.original | 1 + tests/task-planner/waiting.ngc | 3 + 13 files changed, 1432 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 100755 tests/task-planner/skip 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 cd63e966b75..abbab9b867d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -658,7 +658,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 1eddd684899..4eee8e1c3f2 100644 --- a/src/emc/task/Submakefile +++ b/src/emc/task/Submakefile @@ -35,3 +35,12 @@ USERSRCS += $(MILLTASKSRCS) $(ECHO) Linking $(notdir $@) $(CXX) -o $@ $^ $(LDFLAGS) $(PYTHON_EXTRA_LDFLAGS) $(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/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/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..a5e5363414c --- /dev/null +++ b/tests/task-planner/test.sh @@ -0,0 +1,16 @@ +#!/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 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 f0f1fb9827ac343fca35b05afc838fd496f1fdf4 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 10 Nov 2026 17:36:59 +0100 Subject: [PATCH 02/11] 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 | 98 ++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 51 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 23c6f7119c5..d126afde070 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -798,12 +798,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: @@ -819,27 +817,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; } @@ -896,20 +888,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 @@ -918,7 +910,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 @@ -928,7 +920,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 @@ -1020,7 +1012,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 @@ -1030,12 +1022,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 @@ -1044,7 +1036,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 @@ -1054,7 +1046,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 @@ -1136,7 +1128,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: @@ -1157,7 +1149,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 @@ -1166,7 +1158,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 @@ -1177,8 +1169,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)); @@ -1232,7 +1224,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; @@ -1306,7 +1298,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: @@ -1379,7 +1371,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: @@ -1468,7 +1460,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: @@ -1487,11 +1479,11 @@ static int emcTaskPlan(void) && (emcTaskPlanIsWait() == 0) && (emcStatus->task.execState != EMC_TASK_EXEC::WAITING_FOR_KINS_SWITCH) ) { - 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(); // not idle while an MDI waits its turn: the status // that echoes it must not read as done @@ -1502,7 +1494,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 @@ -1511,7 +1503,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 @@ -1522,8 +1514,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); @@ -3602,14 +3594,18 @@ int main(int argc, char *argv[]) check_ini_hal_items(emcStatus->motion.traj.joints); // read command - if (0 != emcCommandBuffer->read()) { - // got a new command, so clear out errors - taskPlanError = 0; - taskExecuteError = 0; - taskCommandDone = 0; - } - // run control cycle - if (0 != emcTaskPlan()) { + if (0 != emcCommandBuffer->read()) { + // got a new command, so clear out errors + taskPlanError = 0; + taskExecuteError = 0; + taskCommandDone = 0; + } + // 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 6b8923c8ad31aa1f67cc504ef9c7ca15a8f1ad71 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 10 Nov 2026 17:48:51 +0100 Subject: [PATCH 03/11] 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 d126afde070..8fe6a7d2676 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -798,19 +798,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(); } /* @@ -820,6 +945,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) { @@ -854,43 +983,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; @@ -899,36 +991,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; @@ -954,67 +1027,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: @@ -1025,34 +1037,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()) { @@ -1063,6 +1052,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; @@ -1080,57 +1073,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 @@ -1147,32 +1089,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; @@ -1188,46 +1115,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 @@ -1236,6 +1123,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; @@ -1254,53 +1145,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; @@ -1317,6 +1161,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; @@ -1334,46 +1182,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 @@ -1382,6 +1190,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; @@ -1410,59 +1222,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 @@ -1492,32 +1251,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 435b2fdcfb436024d17595372c811173b0316454 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 20:08:51 +0100 Subject: [PATCH 04/11] 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 -- include/nml_intf/emc.hh | 8 -- include/nml_intf/emc_nml.hh | 138 -------------------------------- src/emc/nml_intf/emc.cc | 133 ------------------------------ 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/include/nml_intf/emc.hh b/include/nml_intf/emc.hh index bb58f1319e7..767e0de79de 100644 --- a/include/nml_intf/emc.hh +++ b/include/nml_intf/emc.hh @@ -61,14 +61,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) @@ -86,8 +81,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) @@ -329,7 +322,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/include/nml_intf/emc_nml.hh b/include/nml_intf/emc_nml.hh index c786f1a9ed5..5f66184fc64 100644 --- a/include/nml_intf/emc_nml.hh +++ b/include/nml_intf/emc_nml.hh @@ -246,93 +246,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() @@ -393,25 +306,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() @@ -541,38 +435,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/nml_intf/emc.cc b/src/emc/nml_intf/emc.cc index cdd8b7f7743..4ae4c2deab9 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: @@ -677,19 +642,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 */ @@ -780,18 +732,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. @@ -804,19 +744,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. @@ -839,18 +766,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. @@ -1783,18 +1698,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. @@ -1904,31 +1807,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. @@ -1989,17 +1867,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/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 8fe6a7d2676..ac1ffd3b70f 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -375,17 +375,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; @@ -397,8 +392,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; @@ -819,9 +812,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: @@ -844,8 +834,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 @@ -898,7 +886,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; @@ -906,7 +893,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: @@ -1319,8 +1305,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: @@ -1553,14 +1537,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 = @@ -1568,38 +1544,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, @@ -1612,11 +1556,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); @@ -1664,17 +1603,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); @@ -2344,8 +2272,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 29ae6412376..7f8f177f22f 100644 --- a/src/emc/task/taskintf.cc +++ b/src/emc/task/taskintf.cc @@ -895,34 +895,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 bd7c03d977fe4eaa1a6605f982438c53366bc0fa Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 20:09:07 +0100 Subject: [PATCH 05/11] 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 ac1ffd3b70f..8dedae08028 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -494,49 +494,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(); @@ -632,20 +599,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 && @@ -745,8 +701,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; } @@ -3142,11 +3098,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 07f2e47f3a05fff5ff17be50835e61cb872c113e Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 20:11:14 +0100 Subject: [PATCH 06/11] 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 | 215 ++++++++++++++---------------------- 1 file changed, 84 insertions(+), 131 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 8dedae08028..d66766325e1 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -374,29 +374,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". @@ -442,33 +419,9 @@ static bool issuingQueuedCommand = false; // which would drop the MDI sent after it and run ON_ABORT_COMMAND twice. static bool queuedMdiAborted = 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 @@ -1418,10 +1371,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 @@ -1468,84 +1420,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 @@ -1559,15 +1514,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); @@ -1576,9 +1532,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, @@ -1587,16 +1543,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". @@ -1620,11 +1576,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 @@ -1676,8 +1634,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; @@ -1690,10 +1648,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: @@ -1745,52 +1703,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: @@ -1810,8 +1767,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: @@ -1819,12 +1775,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->toolno, emc_tool_set_offset_msg->offset, emc_tool_set_offset_msg->diameter, @@ -1832,10 +1787,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 @@ -1857,8 +1812,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) { @@ -1904,10 +1859,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 @@ -1925,8 +1880,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) { @@ -1987,12 +1942,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; @@ -2079,6 +2035,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 @@ -2092,8 +2049,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; @@ -2160,20 +2116,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 ddc4f354df5c3d2acf817cc176bf2a8234d03975 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 20:12:52 +0100 Subject: [PATCH 07/11] 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 d66766325e1..d5be034679b 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -407,7 +407,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 @@ -1182,144 +1182,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) { @@ -1377,7 +1239,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); @@ -2152,133 +2014,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 @@ -2343,7 +2189,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) { @@ -2363,13 +2211,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; queuedMdiAborted = false; @@ -2380,7 +2228,7 @@ static int emcTaskExecute(void) EMC_TASK_EXEC::DONE : 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 @@ -2389,10 +2237,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; @@ -2402,7 +2252,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; @@ -2413,7 +2265,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; @@ -2424,7 +2278,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; @@ -2439,7 +2295,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) @@ -2496,7 +2354,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 @@ -2647,7 +2507,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) { @@ -2705,7 +2567,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 7bd99f0bf1b7b757fdd388096686db4f1fd7f092 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 20:15:38 +0100 Subject: [PATCH 08/11] 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 | 523 +++++++++++++----------------------- 1 file changed, 191 insertions(+), 332 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index d5be034679b..a147811555f 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -700,6 +700,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() @@ -707,16 +729,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 @@ -833,6 +849,141 @@ 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. A kinematics switch task still waits on ends + // in a resynch: a line read before it is read under the + // old kinematics. The switch of an abort routine sets + // no waitFlag, so ask for it here. + if ((mdi_execute_queue.len() == 0) + && (interp_list.len() == 0) + && (emcTaskCommand == NULL) + && (emcTaskPlanIsWait() == 0) + && (emcStatus->task.execState != EMC_TASK_EXEC::WAITING_FOR_KINS_SWITCH)) { + 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(); + // not idle while an MDI waits its turn: the status + // that echoes it must not read as done + emcStatus->task.interpState = EMC_TASK_INTERP::READING; + } + 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() @@ -841,343 +992,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. A kinematics switch task still waits on ends - // in a resynch: a line read before it is read under the - // old kinematics. The switch of an abort routine sets - // no waitFlag, so ask for it here. - if ( - (mdi_execute_queue.len() == 0) - && (interp_list.len() == 0) - && (emcTaskCommand == NULL) - && (emcTaskPlanIsWait() == 0) - && (emcStatus->task.execState != EMC_TASK_EXEC::WAITING_FOR_KINS_SWITCH) - ) { - 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(); - // not idle while an MDI waits its turn: the status - // that echoes it must not read as done - emcStatus->task.interpState = EMC_TASK_INTERP::READING; - 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 581434997db6c8e47694f3be220bcb82798cd29e Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Mon, 16 Nov 2026 20:43:09 +0100 Subject: [PATCH 09/11] 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 | 24 --------- src/emc/motion/axis.h | 1 - src/emc/motion/command.c | 72 --------------------------- src/emc/motion/motion.h | 1 - 6 files changed, 133 deletions(-) diff --git a/docs/src/code/code-notes.adoc b/docs/src/code/code-notes.adoc index 8953da4a6f9..aff45bc9d35 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 6bbaf08ad16..af4107bb4a0 100644 --- a/src/emc/motion/axis.c +++ b/src/emc/motion/axis.c @@ -369,30 +369,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->teleop_vel_req = axis->teleop_tp.max_vel; - axis->teleop_acc_req = axis->teleop_tp.max_acc; - 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 bc00504570d..9f7c0a0fcd4 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 e026776ca9f..c820554a1f1 100644 --- a/src/emc/motion/command.c +++ b/src/emc/motion/command.c @@ -533,7 +533,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"; @@ -574,9 +573,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; @@ -586,7 +582,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) @@ -1055,73 +1050,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 2276bc116cd..4fed9ca8a75 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 2b89446618d16ceeb7b730c6fe547c33021be62a Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 17 Nov 2026 02:39:09 +0100 Subject: [PATCH 10/11] 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 | 258 ----------- tests/task-planner/.gitignore | 5 - tests/task-planner/checkresult | 118 ----- tests/task-planner/expected | 620 --------------------------- tests/task-planner/flush.ngc | 2 - tests/task-planner/skip | 3 - tests/task-planner/task-planner.ini | 99 ----- tests/task-planner/test-ui.py | 226 ---------- tests/task-planner/test.sh | 16 - tests/task-planner/tool.tbl.original | 1 - tests/task-planner/waiting.ngc | 3 - 13 files changed, 1 insertion(+), 1361 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 abbab9b867d..cd63e966b75 100644 --- a/src/Makefile +++ b/src/Makefile @@ -658,7 +658,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 4eee8e1c3f2..1eddd684899 100644 --- a/src/emc/task/Submakefile +++ b/src/emc/task/Submakefile @@ -35,12 +35,3 @@ USERSRCS += $(MILLTASKSRCS) $(ECHO) Linking $(notdir $@) $(CXX) -o $@ $^ $(LDFLAGS) $(PYTHON_EXTRA_LDFLAGS) $(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 630e3d585df..00000000000 --- a/src/emc/task/test_task_probe.cc +++ /dev/null @@ -1,258 +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_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 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 3a4bb810285..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") -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 9059d09922f..00000000000 --- a/tests/task-planner/expected +++ /dev/null @@ -1,620 +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_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_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 handled -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 -> 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_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 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_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 -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/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_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_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/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_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/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_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 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 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 f44ffefe7f9..00000000000 --- a/tests/task-planner/test-ui.py +++ /dev/null @@ -1,226 +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 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 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 From d572ebd79221aca77d089e50e1d2542b6935ee95 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Sun, 6 Dec 2026 16:17:00 +0100 Subject: [PATCH 11/11] task: planner review changes From the review of #4969: - Situation has one field per line, each with a comment, and the comment above it says why it is a snapshot: the readahead at the end of emcTaskPlan() has to go by the situation the command found. - situation() uses designated initializers; its local is machineOn, so it no longer shadows the field on. - isImmediate() uses s.on, s.manual, ... instead of copying them into locals. - The new planner functions, the case blocks this PR changes in emcTaskIssueCommand() and emcTaskExecute(), and the main loop's command handling are indented with spaces. git diff -w shows only the changes above. - A comment in the main loop says how a new command is told apart and that the planner sees each command once. --- src/emc/task/emctaskmain.cc | 1231 ++++++++++++++++++----------------- 1 file changed, 623 insertions(+), 608 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index a147811555f..4760b36a073 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -701,24 +701,36 @@ 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. +// on and in one of the modes, Auto split by what the interpreter does. At +// most one of the fields after 'on' is set. +// +// emcTaskPlan() takes it once, before it handles the command, and goes by +// it for the rest of the cycle: handling a command can change task's state +// (a run starts, an abort ends one), and what the planner does after it +// (the readahead) must still go by the situation the command found. struct Situation { - bool on, manual, mdi, autoIdle, autoReading, autoPaused, autoWaiting; + bool on; // the machine is on + bool manual; // on, in Manual + bool mdi; // on, in MDI + bool autoIdle; // on, in Auto, the interpreter idle + bool autoReading; // on, in Auto, the interpreter reading + bool autoPaused; // on, in Auto, the interpreter paused + bool autoWaiting; // on, in Auto, the interpreter waiting }; 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 machineOn = task.state == EMC_TASK_STATE::ON; + const bool inAuto = machineOn && 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, + .on = machineOn, + .manual = machineOn && task.mode == EMC_TASK_MODE::MANUAL, + .mdi = machineOn && task.mode == EMC_TASK_MODE::MDI, + .autoIdle = inAuto && task.interpState == EMC_TASK_INTERP::IDLE, + .autoReading = inAuto && task.interpState == EMC_TASK_INTERP::READING, + .autoPaused = inAuto && task.interpState == EMC_TASK_INTERP::PAUSED, + .autoWaiting = inAuto && task.interpState == EMC_TASK_INTERP::WAITING, }; } @@ -731,11 +743,8 @@ static Situation situation() */ 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; - switch (type) { - // in any state + // in any state case EMC_JOINT_SET_BACKLASH_TYPE: case EMC_JOINT_UNHOME_TYPE: case EMC_TRAJ_SET_SCALE_TYPE: @@ -755,13 +764,13 @@ static bool isImmediate(NMLTYPE type, const Situation &s) case EMC_AUX_INPUT_WAIT_TYPE: case EMC_TRAJ_RIGID_TAP_TYPE: case EMC_SET_DEBUG_TYPE: - return true; + return true; - // only while the machine is off or in E-stop + // only while the machine is off or in E-stop case EMC_JOINT_LOAD_COMP_TYPE: - return !on; + return !s.on; - // once the machine is on, whatever runs + // once the machine is on, whatever runs case EMC_SPINDLE_INCREASE_TYPE: case EMC_SPINDLE_DECREASE_TYPE: case EMC_SPINDLE_CONSTANT_TYPE: @@ -774,54 +783,54 @@ static bool isImmediate(NMLTYPE type, const Situation &s) case EMC_TASK_PLAN_FORWARD_TYPE: case EMC_TASK_PLAN_RESUME_TYPE: case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: - return on; + return s.on; - // once the machine is on, unless a program is reading or waiting + // 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; + return s.manual || s.mdi || s.autoIdle || s.autoPaused; - // the same, but not in Manual + // the same, but not in Manual case EMC_SPINDLE_ORIENT_TYPE: case EMC_SPINDLE_WAIT_ORIENT_COMPLETE_TYPE: - return mdi || autoIdle || autoPaused; + return s.mdi || s.autoIdle || s.autoPaused; - // unless a program runs + // 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; + return !s.on || s.manual || s.mdi || s.autoIdle; - // not in Auto + // 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; + return !s.on || s.manual || s.mdi; - // Auto only + // Auto only case EMC_TASK_PLAN_RUN_TYPE: - return autoIdle; + return s.autoIdle; case EMC_TASK_PLAN_EXECUTE_TYPE: - return autoIdle || autoPaused || autoWaiting; + return s.autoIdle || s.autoPaused || s.autoWaiting; - // Manual only + // 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; + return s.manual; - // jogs, and in Auto only while the interpreter is idle + // 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; + return s.manual || s.mdi || s.autoIdle; case EMC_TRAJ_SET_TELEOP_ENABLE_TYPE: - return !on || manual || mdi || autoIdle; + return !s.on || s.manual || s.mdi || s.autoIdle; } return false; } @@ -832,16 +841,16 @@ static void queueToolCommand(NMLmsg *cmd) { switch (cmd->_type) { case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - break; + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); + break; case EMC_TOOL_SET_OFFSET_TYPE: - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - break; + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); + break; case EMC_TOOL_SET_NUMBER_TYPE: - emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); - break; + emcTaskQueueCommand(std::make_unique(*static_cast(cmd))); + break; default: - return; + return; } // signify no more reading emcTaskPlanSetWait(); @@ -855,111 +864,111 @@ 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; + // 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; + 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. A kinematics switch task still waits on ends - // in a resynch: a line read before it is read under the - // old kinematics. The switch of an abort routine sets - // no waitFlag, so ask for it here. - if ((mdi_execute_queue.len() == 0) - && (interp_list.len() == 0) - && (emcTaskCommand == NULL) - && (emcTaskPlanIsWait() == 0) - && (emcStatus->task.execState != EMC_TASK_EXEC::WAITING_FOR_KINS_SWITCH)) { - 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(); - // not idle while an MDI waits its turn: the status - // that echoes it must not read as done - emcStatus->task.interpState = EMC_TASK_INTERP::READING; - } - return true; - } - return false; + 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. A kinematics switch task still waits on ends + // in a resynch: a line read before it is read under the + // old kinematics. The switch of an abort routine sets + // no waitFlag, so ask for it here. + if ((mdi_execute_queue.len() == 0) + && (interp_list.len() == 0) + && (emcTaskCommand == NULL) + && (emcTaskPlanIsWait() == 0) + && (emcStatus->task.execState != EMC_TASK_EXEC::WAITING_FOR_KINS_SWITCH)) { + 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(); + // not idle while an MDI waits its turn: the status + // that echoes it must not read as done + emcStatus->task.interpState = EMC_TASK_INTERP::READING; + } + 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; + 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; + 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; } @@ -968,19 +977,19 @@ 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); + 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); + 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); + 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); + 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); + 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); + 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) in auto mode with the interpreter waiting"), name); } } @@ -1004,38 +1013,38 @@ static int emcTaskPlan(NMLmsg *cmd) switch (type) { case 0: case EMC_NULL_TYPE: - // no command - break; + // no command + break; - // Always display messages + // Always display messages case EMC_OPERATOR_ERROR_TYPE: case EMC_OPERATOR_TEXT_TYPE: case EMC_OPERATOR_DISPLAY_TYPE: - return emcTaskIssueCommand(cmd); + return emcTaskIssueCommand(cmd); default: - if (planSpecial(cmd, s, retval)) { - break; - } - if (isImmediate(type, s)) { - retval = emcTaskIssueCommand(cmd); - if (s.autoReading) { - // no readahead this cycle - return retval; - } - break; - } - refuse(type, s); - retval = -1; - break; + if (planSpecial(cmd, s, retval)) { + break; + } + if (isImmediate(type, s)) { + retval = emcTaskIssueCommand(cmd); + if (s.autoReading) { + // no readahead this cycle + return retval; + } + break; + } + refuse(type, s); + retval = -1; + break; } if (s.autoReading) { - readahead_reading(); + readahead_reading(); } else if (s.autoWaiting) { - readahead_waiting(); + readahead_waiting(); } else if (s.mdi) { - mdi_execute_hook(); + mdi_execute_hook(); } return retval; @@ -1915,20 +1924,20 @@ static Waits commandWaits(NMLmsg *cmd) case EMC_TASK_PLAN_RUN_TYPE: case EMC_TASK_PLAN_SYNCH_TYPE: case EMC_TASK_PLAN_EXECUTE_TYPE: - return {ALL, DONE}; + return {ALL, DONE}; case EMC_SYSTEM_CMD_TYPE: - return {ALL, EMC_TASK_EXEC::WAITING_FOR_SYSTEM_CMD}; + return {ALL, EMC_TASK_EXEC::WAITING_FOR_SYSTEM_CMD}; case EMC_TRAJ_DELAY_TYPE: case EMC_AUX_INPUT_WAIT_TYPE: - return {ALL, EMC_TASK_EXEC::WAITING_FOR_DELAY}; + return {ALL, EMC_TASK_EXEC::WAITING_FOR_DELAY}; case EMC_SPINDLE_WAIT_ORIENT_COMPLETE_TYPE: - return {ALL, EMC_TASK_EXEC::WAITING_FOR_SPINDLE_ORIENTED}; + return {ALL, EMC_TASK_EXEC::WAITING_FOR_SPINDLE_ORIENTED}; case EMC_TRAJ_SELECT_KINS_TYPE: - return {ALL, EMC_TASK_EXEC::WAITING_FOR_KINS_SWITCH}; + 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: @@ -1941,7 +1950,7 @@ static Waits commandWaits(NMLmsg *cmd) case EMC_TRAJ_SET_SO_ENABLE_TYPE: case EMC_TOOL_PREPARE_TYPE: case EMC_TOOL_SET_NUMBER_TYPE: - return {IO, DONE}; + return {IO, DONE}; // offsets apply after the motions before them case EMC_TRAJ_SET_OFFSET_TYPE: @@ -1950,23 +1959,23 @@ static Waits commandWaits(NMLmsg *cmd) case EMC_TRAJ_SET_ROTATION_TYPE: case EMC_TRAJ_SET_G68_TYPE: case EMC_MOTION_ADAPTIVE_TYPE: - return {MOTION, DONE}; + 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}; + return {static_cast(cmd)->now ? MOTION : DONE, DONE}; case EMC_MOTION_SET_DOUT_TYPE: - return {static_cast(cmd)->now ? MOTION : DONE, DONE}; + return {static_cast(cmd)->now ? MOTION : DONE, DONE}; // 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}; + return {MOTION, homingWaiting ? EMC_TASK_EXEC::WAITING_FOR_HOMING : DONE}; } if (emc_debug & EMC_DEBUG_TASK_ISSUE) { - log_error("execute: unrecognized command {}:{}\n", - (int)cmd->_type, emc_symbol_lookup(cmd->_type)); + log_error("execute: unrecognized command {}:{}\n", + (int)cmd->_type, emc_symbol_lookup(cmd->_type)); } return {EMC_TASK_EXEC::ERROR, DONE}; } @@ -1976,12 +1985,12 @@ static Waits commandWaits(NMLmsg *cmd) static bool steppingHolds() { if (!stepping) { - return false; + return false; } if (!steppingWait) { - steppingWait = 1; - steppedLine = emcStatus->task.currentLine; - return false; + steppingWait = 1; + steppedLine = emcStatus->task.currentLine; + return false; } return emcStatus->task.currentLine != steppedLine; } @@ -2048,152 +2057,152 @@ static int emcTaskExecute(void) break; case EMC_TASK_EXEC::DONE: - if (steppingHolds()) { - break; - } - if (!emcStatus->motion.traj.queueFull && - emcStatus->task.interpState != EMC_TASK_INTERP::PAUSED) { - if (NULL == emcTaskCommand) { - // need a new command - emcTaskCommand = interp_list.get(); - // interp_list now has line number associated with this-- get - // it - if (NULL != emcTaskCommand) { - emcTaskEager = 1; - emcStatus->task.currentLine = interp_list.get_line_number(); - // callLevel is set by emcTaskUpdate() from the executing - // move's StateTag; the interpreter's live level at dequeue - // time leads motion by the whole read-ahead queue. - // and set it for all subsystems which use queued ids - emcTrajSetMotionId(emcStatus->task.currentLine); - if (emcStatus->motion.traj.queueFull) { - emcStatus->task.execState = - EMC_TASK_EXEC::WAITING_FOR_MOTION_QUEUE; - } else { - emcStatus->task.execState = commandWaits(emcTaskCommand.get()).before; - } - } - } else { - // have an outstanding command - // This is the one emcTaskIssueCommand() call site followed by - // the wait commandWaits() names, i.e. the only one whose commands - // can reach a WAITING_FOR_* state. See issuingQueuedCommand. - issuingQueuedCommand = true; - queuedMdiAborted = false; - const int issue_retval = emcTaskIssueCommand(emcTaskCommand.get()); - issuingQueuedCommand = false; - if (0 != issue_retval) { - emcStatus->task.execState = queuedMdiAborted ? - EMC_TASK_EXEC::DONE : EMC_TASK_EXEC::ERROR; - retval = -1; - } else { - emcStatus->task.execState = commandWaits(emcTaskCommand.get()).after; - emcTaskEager = 1; - } - emcTaskCommand = NULL; // reset it - } - } - break; + if (steppingHolds()) { + break; + } + if (!emcStatus->motion.traj.queueFull && + emcStatus->task.interpState != EMC_TASK_INTERP::PAUSED) { + if (NULL == emcTaskCommand) { + // need a new command + emcTaskCommand = interp_list.get(); + // interp_list now has line number associated with this-- get + // it + if (NULL != emcTaskCommand) { + emcTaskEager = 1; + emcStatus->task.currentLine = interp_list.get_line_number(); + // callLevel is set by emcTaskUpdate() from the executing + // move's StateTag; the interpreter's live level at dequeue + // time leads motion by the whole read-ahead queue. + // and set it for all subsystems which use queued ids + emcTrajSetMotionId(emcStatus->task.currentLine); + if (emcStatus->motion.traj.queueFull) { + emcStatus->task.execState = + EMC_TASK_EXEC::WAITING_FOR_MOTION_QUEUE; + } else { + emcStatus->task.execState = commandWaits(emcTaskCommand.get()).before; + } + } + } else { + // have an outstanding command + // This is the one emcTaskIssueCommand() call site followed by + // the wait commandWaits() names, i.e. the only one whose commands + // can reach a WAITING_FOR_* state. See issuingQueuedCommand. + issuingQueuedCommand = true; + queuedMdiAborted = false; + const int issue_retval = emcTaskIssueCommand(emcTaskCommand.get()); + issuingQueuedCommand = false; + if (0 != issue_retval) { + emcStatus->task.execState = queuedMdiAborted ? + EMC_TASK_EXEC::DONE : EMC_TASK_EXEC::ERROR; + retval = -1; + } else { + emcStatus->task.execState = commandWaits(emcTaskCommand.get()).after; + emcTaskEager = 1; + } + emcTaskCommand = NULL; // reset it + } + } + break; case EMC_TASK_EXEC::WAITING_FOR_MOTION_QUEUE: - if (steppingHolds()) { - break; - } - if (!emcStatus->motion.traj.queueFull) { - if (NULL != emcTaskCommand) { - emcStatus->task.execState = commandWaits(emcTaskCommand.get()).before; - emcTaskEager = 1; - } else { - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcTaskEager = 1; - } - } - break; + if (steppingHolds()) { + break; + } + if (!emcStatus->motion.traj.queueFull) { + if (NULL != emcTaskCommand) { + emcStatus->task.execState = commandWaits(emcTaskCommand.get()).before; + emcTaskEager = 1; + } else { + emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcTaskEager = 1; + } + } + break; case EMC_TASK_EXEC::WAITING_FOR_MOTION: - if (steppingHolds()) { - break; - } - if (emcStatus->motion.status == RCS_STATUS::ERROR) { - // emcOperatorError(0, "error in motion controller"); - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - } else if (emcStatus->motion.status == RCS_STATUS::DONE) { - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcTaskEager = 1; - } - break; + if (steppingHolds()) { + break; + } + if (emcStatus->motion.status == RCS_STATUS::ERROR) { + // emcOperatorError(0, "error in motion controller"); + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + } else if (emcStatus->motion.status == RCS_STATUS::DONE) { + emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcTaskEager = 1; + } + break; case EMC_TASK_EXEC::WAITING_FOR_IO: - if (steppingHolds()) { - break; - } - if (emcStatus->io.status == RCS_STATUS::ERROR) { - // emcOperatorError(0, "error in IO controller"); - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - } else if (emcStatus->io.status == RCS_STATUS::DONE) { - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcTaskEager = 1; - } - break; + if (steppingHolds()) { + break; + } + if (emcStatus->io.status == RCS_STATUS::ERROR) { + // emcOperatorError(0, "error in IO controller"); + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + } else if (emcStatus->io.status == RCS_STATUS::DONE) { + emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcTaskEager = 1; + } + break; case EMC_TASK_EXEC::WAITING_FOR_MOTION_AND_IO: - if (steppingHolds()) { - break; - } - if (emcStatus->motion.status == RCS_STATUS::ERROR) { - // emcOperatorError(0, "error in motion controller"); - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - } else if (emcStatus->io.status == RCS_STATUS::ERROR) { - // emcOperatorError(0, "error in IO controller"); - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - } else if (emcStatus->motion.status == RCS_STATUS::DONE && - emcStatus->io.status == RCS_STATUS::DONE) { - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcTaskEager = 1; - } - break; + if (steppingHolds()) { + break; + } + if (emcStatus->motion.status == RCS_STATUS::ERROR) { + // emcOperatorError(0, "error in motion controller"); + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + } else if (emcStatus->io.status == RCS_STATUS::ERROR) { + // emcOperatorError(0, "error in IO controller"); + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + } else if (emcStatus->motion.status == RCS_STATUS::DONE && + emcStatus->io.status == RCS_STATUS::DONE) { + emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcTaskEager = 1; + } + break; case EMC_TASK_EXEC::WAITING_FOR_SPINDLE_ORIENTED: - 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) - state = emcStatus->motion.spindle[n].orient_state; - } - switch (state) { - case EMCMOT_ORIENT_NONE: - case EMCMOT_ORIENT_COMPLETE: - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcStatus->task.delayLeft = 0; - emcTaskEager = 1; - log_info("wait for orient complete: nothing to do\n"); - break; - - case EMCMOT_ORIENT_IN_PROGRESS: - emcStatus->task.delayLeft = taskExecDelayTimeout - etime(); - if (etime() >= taskExecDelayTimeout) { - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - emcStatus->task.delayLeft = 0; - emcTaskEager = 1; - emcOperatorError("wait for orient complete: TIMED OUT"); - } - break; - - case EMCMOT_ORIENT_FAULTED: - // actually the code in main() should trap this before we get here - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - emcStatus->task.delayLeft = 0; - emcTaskEager = 1; - for (int n = 0; n < emcStatus->motion.traj.spindles; n++){ - if (emcStatus->motion.spindle[n].orient_fault) - emcOperatorError("wait for orient complete: FAULTED code=%d", - emcStatus->motion.spindle[n].orient_fault); - } - } - } - break; + 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) + state = emcStatus->motion.spindle[n].orient_state; + } + switch (state) { + case EMCMOT_ORIENT_NONE: + case EMCMOT_ORIENT_COMPLETE: + emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcStatus->task.delayLeft = 0; + emcTaskEager = 1; + log_info("wait for orient complete: nothing to do\n"); + break; + + case EMCMOT_ORIENT_IN_PROGRESS: + emcStatus->task.delayLeft = taskExecDelayTimeout - etime(); + if (etime() >= taskExecDelayTimeout) { + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + emcStatus->task.delayLeft = 0; + emcTaskEager = 1; + emcOperatorError("wait for orient complete: TIMED OUT"); + } + break; + + case EMCMOT_ORIENT_FAULTED: + // actually the code in main() should trap this before we get here + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + emcStatus->task.delayLeft = 0; + emcTaskEager = 1; + for (int n = 0; n < emcStatus->motion.traj.spindles; n++){ + if (emcStatus->motion.spindle[n].orient_fault) + emcOperatorError("wait for orient complete: FAULTED code=%d", + emcStatus->motion.spindle[n].orient_fault); + } + } + } + break; case EMC_TASK_EXEC::WAITING_FOR_KINS_SWITCH: { @@ -2208,286 +2217,286 @@ static int emcTaskExecute(void) } case EMC_TASK_EXEC::WAITING_FOR_HOMING: - // G28.2 sequencing: wait for the joint home issued in - // emcTaskIssueCommand to actually run to completion (do_homing() only - // 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. - if (steppingHolds()) { - break; - } - { - bool any_homing = false; - bool all_target_homed = true; // success criterion - int lo = (homingWaitJoint < 0) ? 0 : homingWaitJoint; - int hi = (homingWaitJoint < 0) ? (emcStatus->motion.traj.joints - 1) : homingWaitJoint; - for (int j = lo; j <= hi; j++) { - if (emcStatus->motion.joint[j].homing) { - any_homing = true; - } - if (!emcStatus->motion.joint[j].homed) { - all_target_homed = false; - } - } + // G28.2 sequencing: wait for the joint home issued in + // emcTaskIssueCommand to actually run to completion (do_homing() only + // 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. + if (steppingHolds()) { + break; + } + { + bool any_homing = false; + bool all_target_homed = true; // success criterion + int lo = (homingWaitJoint < 0) ? 0 : homingWaitJoint; + int hi = (homingWaitJoint < 0) ? (emcStatus->motion.traj.joints - 1) : homingWaitJoint; + for (int j = lo; j <= hi; j++) { + if (emcStatus->motion.joint[j].homing) { + any_homing = true; + } + if (!emcStatus->motion.joint[j].homed) { + all_target_homed = false; + } + } - bool success; - // "Is homing still running?" must come from motion's aggregate - // homing_active, not from OR-ing the per-joint .homing flags. On a - // machine that homes in several HOME_SEQUENCE groups the sequence - // machine finishes one group and can spend a cycle or more before - // the next group raises .homing, so there is a window in which - // every joint reads .homing == false while the machine is still - // homing. Task samples far coarser than the servo cycle, so it can - // land in that window, conclude homing stopped, and score a - // perfectly good home-all as "did not complete". motion/homing.c - // documents the same deassertion lag in its own words ("The homing - // status variable turns false before homing_active state turns - // false") and guards against it internally for the same reason. - // - // Single-joint Pn and single-sequence machines never hit the gap, - // which is why this only shows up on a multi-sequence home-all. - // The per-joint OR is kept as a belt-and-braces term: it can only - // extend the "still running" window, never shorten it. - const bool homing_running = emcStatus->motion.homing_active || any_homing; - if (homing_running) { - homingStarted = true; - break; // still running; no timeout once started (see HOMING_START_TIMEOUT comment) - } - // A short run (homing in place takes a few servo cycles) can start - // and end between two of task's status reads. On a re-home the - // joints read homed before and after it, so only motion's run - // counter shows that it happened. - if (emcStatus->motion.homing_runs != homingRunsAtIssue) { - homingStarted = true; - } - if (!homingStarted) { - // Never observed homing go active: motion silently rejected - // it (a guard like "must be in joint mode", or - // motion.homing-inhibit, reports an operator error but does - // not fail the NML command -- see emcJointHome's caller), - // or this is the same task cycle it was issued in. Give it - // HOMING_START_TIMEOUT before concluding it was rejected. - if (etime() - homingIssueTime < HOMING_START_TIMEOUT) { - break; - } - emcOperatorError("G28.2 home did not start -- check machine mode, " - "motion.homing-inhibit, and whether a homing " - "cycle is already in progress"); - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - emcTaskEager = 1; - homingWaiting = false; - // Nothing physically moved, so it's safe to restore the - // mode immediately instead of leaving the machine parked - // in FREE. - if (homingPriorMode != EMC_TRAJ_MODE::FREE) { - emcTrajSetMode(homingPriorMode); - } - break; - } - // It ran and has now stopped; did it reach the expected end state? - success = all_target_homed; - - homingWaiting = false; - emcTaskEager = 1; - - // Is it legal to hand the machine back to the coordinated mode it - // was in before the FREE dip? Motion refuses to (re-)enter TELEOP - // or COORD on non-identity kinematics unless *every* joint is - // homed -- switch_to_teleop_mode() (motion.c) and the EMCMOT_COORD - // case (command.c) both gate on - // "kinType != KINEMATICS_IDENTITY && !get_allhomed()". - // - // Restoring unconditionally means motion rejects the request, task - // still reports DONE, and the machine is stranded in FREE with the - // GUI's mode controls greyed out -- recoverable only by cycling the - // controller (PR #4172: Sigma1912's "g28.3 p0" on a gantry gave - // "all joints must be homed before going into coordinated mode", - // then needed F2). Mirror motion's own condition here and abort - // cleanly instead of wedging. - // - // With G28.3 gone from this PR the only command that reaches here - // is a home, which ends with its joints referenced, so on - // non-identity kinematics -- where a coordinated prior mode already - // implies the machine was fully homed -- this gate now guards a - // state no G-code can produce. It is kept because the alternative - // failure is silent: motion defers the COORD/TELEOP transition to - // its controller cycle, so a refused restore leaves no trace task - // could notice, and the operator gets a dead UI with no message. - // - // Mirroring the condition rather than issuing the restore and - // checking whether it took is deliberate: the COORD/TELEOP - // transition is deferred to the controller cycle (see - // "defer transition to controller cycle" in command.c), so an - // immediate read-back would race exactly the way the old - // .homing-based completion test did. - // - // Read the kinematics type from status, not from this file's - // static emcmotConfig: that copy is filled in once just before - // the main loop and never refreshed, while taskintf.cc re-reads - // the motion config whenever config_num changes and republishes - // it as traj.kinematics_type. The two agree today -- kinType is - // written exactly once, in init_comm_buffers() (motion.c), and a - // runtime switchkins change does not alter it (switchkins answers - // KINEMATICS_BOTH for every selectable type) -- so this is a - // matter of reading the copy that is maintained, not of avoiding - // a divergence that exists now. - const bool restore_ok = (homingPriorMode == EMC_TRAJ_MODE::FREE) - || (emcStatus->motion.traj.kinematics_type - == KINEMATICS_IDENTITY) - || all_homed(); - - if (success && !restore_ok) { - // The command itself did what was asked, but it left the - // machine partially referenced and motion will not take - // TELEOP/COORD back in that state. Stay in FREE and fail the - // program rather than report DONE and strand the operator. - emcOperatorError(_("G28.2 home succeeded but left the machine not " - "fully homed -- staying in joint mode, as " - "non-identity kinematics cannot re-enter " - "coordinated motion until every joint is homed")); - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - } else if (success) { - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - if (homingPriorMode != EMC_TRAJ_MODE::FREE) { - emcTrajSetMode(homingPriorMode); - } - } else { - // Homing stopped without reaching the target state (aborted, - // faulted, ESTOP mid-cycle, ...) -- abort the program rather - // than let it continue unreferenced. Deliberately NOT restored to - // homingPriorMode here: an unhomed/partially-homed machine may - // not legally re-enter TELEOP/COORD, and FREE is the safe - // state to leave it in for an operator to intervene from. - emcOperatorError("G28.2 home did not complete for joint %s", - homingWaitJoint < 0 ? "ALL" : "requested"); - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - } - } - break; + bool success; + // "Is homing still running?" must come from motion's aggregate + // homing_active, not from OR-ing the per-joint .homing flags. On a + // machine that homes in several HOME_SEQUENCE groups the sequence + // machine finishes one group and can spend a cycle or more before + // the next group raises .homing, so there is a window in which + // every joint reads .homing == false while the machine is still + // homing. Task samples far coarser than the servo cycle, so it can + // land in that window, conclude homing stopped, and score a + // perfectly good home-all as "did not complete". motion/homing.c + // documents the same deassertion lag in its own words ("The homing + // status variable turns false before homing_active state turns + // false") and guards against it internally for the same reason. + // + // Single-joint Pn and single-sequence machines never hit the gap, + // which is why this only shows up on a multi-sequence home-all. + // The per-joint OR is kept as a belt-and-braces term: it can only + // extend the "still running" window, never shorten it. + const bool homing_running = emcStatus->motion.homing_active || any_homing; + if (homing_running) { + homingStarted = true; + break; // still running; no timeout once started (see HOMING_START_TIMEOUT comment) + } + // A short run (homing in place takes a few servo cycles) can start + // and end between two of task's status reads. On a re-home the + // joints read homed before and after it, so only motion's run + // counter shows that it happened. + if (emcStatus->motion.homing_runs != homingRunsAtIssue) { + homingStarted = true; + } + if (!homingStarted) { + // Never observed homing go active: motion silently rejected + // it (a guard like "must be in joint mode", or + // motion.homing-inhibit, reports an operator error but does + // not fail the NML command -- see emcJointHome's caller), + // or this is the same task cycle it was issued in. Give it + // HOMING_START_TIMEOUT before concluding it was rejected. + if (etime() - homingIssueTime < HOMING_START_TIMEOUT) { + break; + } + emcOperatorError("G28.2 home did not start -- check machine mode, " + "motion.homing-inhibit, and whether a homing " + "cycle is already in progress"); + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + emcTaskEager = 1; + homingWaiting = false; + // Nothing physically moved, so it's safe to restore the + // mode immediately instead of leaving the machine parked + // in FREE. + if (homingPriorMode != EMC_TRAJ_MODE::FREE) { + emcTrajSetMode(homingPriorMode); + } + break; + } + // It ran and has now stopped; did it reach the expected end state? + success = all_target_homed; + + homingWaiting = false; + emcTaskEager = 1; + + // Is it legal to hand the machine back to the coordinated mode it + // was in before the FREE dip? Motion refuses to (re-)enter TELEOP + // or COORD on non-identity kinematics unless *every* joint is + // homed -- switch_to_teleop_mode() (motion.c) and the EMCMOT_COORD + // case (command.c) both gate on + // "kinType != KINEMATICS_IDENTITY && !get_allhomed()". + // + // Restoring unconditionally means motion rejects the request, task + // still reports DONE, and the machine is stranded in FREE with the + // GUI's mode controls greyed out -- recoverable only by cycling the + // controller (PR #4172: Sigma1912's "g28.3 p0" on a gantry gave + // "all joints must be homed before going into coordinated mode", + // then needed F2). Mirror motion's own condition here and abort + // cleanly instead of wedging. + // + // With G28.3 gone from this PR the only command that reaches here + // is a home, which ends with its joints referenced, so on + // non-identity kinematics -- where a coordinated prior mode already + // implies the machine was fully homed -- this gate now guards a + // state no G-code can produce. It is kept because the alternative + // failure is silent: motion defers the COORD/TELEOP transition to + // its controller cycle, so a refused restore leaves no trace task + // could notice, and the operator gets a dead UI with no message. + // + // Mirroring the condition rather than issuing the restore and + // checking whether it took is deliberate: the COORD/TELEOP + // transition is deferred to the controller cycle (see + // "defer transition to controller cycle" in command.c), so an + // immediate read-back would race exactly the way the old + // .homing-based completion test did. + // + // Read the kinematics type from status, not from this file's + // static emcmotConfig: that copy is filled in once just before + // the main loop and never refreshed, while taskintf.cc re-reads + // the motion config whenever config_num changes and republishes + // it as traj.kinematics_type. The two agree today -- kinType is + // written exactly once, in init_comm_buffers() (motion.c), and a + // runtime switchkins change does not alter it (switchkins answers + // KINEMATICS_BOTH for every selectable type) -- so this is a + // matter of reading the copy that is maintained, not of avoiding + // a divergence that exists now. + const bool restore_ok = (homingPriorMode == EMC_TRAJ_MODE::FREE) + || (emcStatus->motion.traj.kinematics_type + == KINEMATICS_IDENTITY) + || all_homed(); + + if (success && !restore_ok) { + // The command itself did what was asked, but it left the + // machine partially referenced and motion will not take + // TELEOP/COORD back in that state. Stay in FREE and fail the + // program rather than report DONE and strand the operator. + emcOperatorError(_("G28.2 home succeeded but left the machine not " + "fully homed -- staying in joint mode, as " + "non-identity kinematics cannot re-enter " + "coordinated motion until every joint is homed")); + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + } else if (success) { + emcStatus->task.execState = EMC_TASK_EXEC::DONE; + if (homingPriorMode != EMC_TRAJ_MODE::FREE) { + emcTrajSetMode(homingPriorMode); + } + } else { + // Homing stopped without reaching the target state (aborted, + // faulted, ESTOP mid-cycle, ...) -- abort the program rather + // than let it continue unreferenced. Deliberately NOT restored to + // homingPriorMode here: an unhomed/partially-homed machine may + // not legally re-enter TELEOP/COORD, and FREE is the safe + // state to leave it in for an operator to intervene from. + emcOperatorError("G28.2 home did not complete for joint %s", + homingWaitJoint < 0 ? "ALL" : "requested"); + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + } + } + break; case EMC_TASK_EXEC::WAITING_FOR_DELAY: - if (steppingHolds()) { - break; - } - // check if delay has passed - emcStatus->task.delayLeft = taskExecDelayTimeout - etime(); - if (etime() >= taskExecDelayTimeout) { - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcStatus->task.delayLeft = 0; - if (emcStatus->task.input_timeout != 0) - emcStatus->task.input_timeout = 1; // timeout occurred - emcTaskEager = 1; - } - // delay can be also be because we wait for an input - // if the index is set (not -1) - if (emcAuxInputWaitIndex >= 0) { - switch (emcAuxInputWaitType) { - case WAIT_MODE_HIGH: - if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] != 0) { - emcStatus->task.input_timeout = 0; // clear timeout flag - emcAuxInputWaitIndex = -1; - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcStatus->task.delayLeft = 0; - } - break; - - case WAIT_MODE_RISE: - if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] == 0) { - emcAuxInputWaitType = WAIT_MODE_HIGH; - } - break; - - case WAIT_MODE_LOW: - if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] == 0) { - emcStatus->task.input_timeout = 0; // clear timeout flag - emcAuxInputWaitIndex = -1; - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcStatus->task.delayLeft = 0; - } - break; - - case WAIT_MODE_FALL: //FIXME: implement different fall mode if needed - if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] != 0) { - emcAuxInputWaitType = WAIT_MODE_LOW; - } - break; - - case WAIT_MODE_IMMEDIATE: - emcStatus->task.input_timeout = 0; // clear timeout flag - emcAuxInputWaitIndex = -1; - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcStatus->task.delayLeft = 0; - break; - - default: - emcOperatorError("Unknown Wait Mode"); - } - } - break; + if (steppingHolds()) { + break; + } + // check if delay has passed + emcStatus->task.delayLeft = taskExecDelayTimeout - etime(); + if (etime() >= taskExecDelayTimeout) { + emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcStatus->task.delayLeft = 0; + if (emcStatus->task.input_timeout != 0) + emcStatus->task.input_timeout = 1; // timeout occurred + emcTaskEager = 1; + } + // delay can be also be because we wait for an input + // if the index is set (not -1) + if (emcAuxInputWaitIndex >= 0) { + switch (emcAuxInputWaitType) { + case WAIT_MODE_HIGH: + if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] != 0) { + emcStatus->task.input_timeout = 0; // clear timeout flag + emcAuxInputWaitIndex = -1; + emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcStatus->task.delayLeft = 0; + } + break; + + case WAIT_MODE_RISE: + if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] == 0) { + emcAuxInputWaitType = WAIT_MODE_HIGH; + } + break; + + case WAIT_MODE_LOW: + if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] == 0) { + emcStatus->task.input_timeout = 0; // clear timeout flag + emcAuxInputWaitIndex = -1; + emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcStatus->task.delayLeft = 0; + } + break; + + case WAIT_MODE_FALL: //FIXME: implement different fall mode if needed + if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] != 0) { + emcAuxInputWaitType = WAIT_MODE_LOW; + } + break; + + case WAIT_MODE_IMMEDIATE: + emcStatus->task.input_timeout = 0; // clear timeout flag + emcAuxInputWaitIndex = -1; + emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcStatus->task.delayLeft = 0; + break; + + default: + emcOperatorError("Unknown Wait Mode"); + } + } + break; case EMC_TASK_EXEC::WAITING_FOR_SYSTEM_CMD: - if (steppingHolds()) { - break; - } + if (steppingHolds()) { + break; + } - // if we got here without a system command pending, say we're done - if (0 == emcSystemCmdPid) { - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - break; - } - // check the status of the system command - pid = waitpid(emcSystemCmdPid, &status, WNOHANG); + // if we got here without a system command pending, say we're done + if (0 == emcSystemCmdPid) { + emcStatus->task.execState = EMC_TASK_EXEC::DONE; + break; + } + // check the status of the system command + pid = waitpid(emcSystemCmdPid, &status, WNOHANG); - if (0 == pid) { - // child is still executing - break; - } + if (0 == pid) { + // child is still executing + break; + } - if (-1 == pid) { - // execution error - log_debug(EMC_DEBUG_TASK_ISSUE, "emcSystemCmd: error waiting for {}\n", - emcSystemCmdPid); - emcSystemCmdPid = 0; - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - break; - } + if (-1 == pid) { + // execution error + log_debug(EMC_DEBUG_TASK_ISSUE, "emcSystemCmd: error waiting for {}\n", + emcSystemCmdPid); + emcSystemCmdPid = 0; + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + break; + } - if (emcSystemCmdPid != pid) { - // somehow some other child finished, which is a coding error - log_debug(EMC_DEBUG_TASK_ISSUE, "emcSystemCmd: error waiting for system command {}, we got {}\n", - emcSystemCmdPid, pid); - emcSystemCmdPid = 0; - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - break; - } - // else child has finished - if (WIFEXITED(status)) { - if (0 == WEXITSTATUS(status)) { - // child exited normally - emcSystemCmdPid = 0; - emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcTaskEager = 1; - } else { - // child exited with non-zero status - log_debug(EMC_DEBUG_TASK_ISSUE, "emcSystemCmd: system command {} exited abnormally with value {}\n", - emcSystemCmdPid, WEXITSTATUS(status)); - emcSystemCmdPid = 0; - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - } - } else if (WIFSIGNALED(status)) { - // child exited with an uncaught signal - log_debug(EMC_DEBUG_TASK_ISSUE, "system command {} terminated with signal {}\n", - emcSystemCmdPid, WTERMSIG(status)); - emcSystemCmdPid = 0; - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - } else if (WIFSTOPPED(status)) { - // child is currently being traced, so keep waiting - } else { - // some other status, we'll call this an error - emcSystemCmdPid = 0; - emcStatus->task.execState = EMC_TASK_EXEC::ERROR; - } - break; + if (emcSystemCmdPid != pid) { + // somehow some other child finished, which is a coding error + log_debug(EMC_DEBUG_TASK_ISSUE, "emcSystemCmd: error waiting for system command {}, we got {}\n", + emcSystemCmdPid, pid); + emcSystemCmdPid = 0; + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + break; + } + // else child has finished + if (WIFEXITED(status)) { + if (0 == WEXITSTATUS(status)) { + // child exited normally + emcSystemCmdPid = 0; + emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcTaskEager = 1; + } else { + // child exited with non-zero status + log_debug(EMC_DEBUG_TASK_ISSUE, "emcSystemCmd: system command {} exited abnormally with value {}\n", + emcSystemCmdPid, WEXITSTATUS(status)); + emcSystemCmdPid = 0; + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + } + } else if (WIFSIGNALED(status)) { + // child exited with an uncaught signal + log_debug(EMC_DEBUG_TASK_ISSUE, "system command {} terminated with signal {}\n", + emcSystemCmdPid, WTERMSIG(status)); + emcSystemCmdPid = 0; + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + } else if (WIFSTOPPED(status)) { + // child is currently being traced, so keep waiting + } else { + // some other status, we'll call this an error + emcSystemCmdPid = 0; + emcStatus->task.execState = EMC_TASK_EXEC::ERROR; + } + break; default: // coding error @@ -2890,25 +2899,31 @@ int main(int argc, char *argv[]) task_beat++; // Task's heartbeat check_ini_hal_items(emcStatus->motion.traj.joints); - // read command - if (0 != emcCommandBuffer->read()) { - // got a new command, so clear out errors - taskPlanError = 0; - taskExecuteError = 0; - taskCommandDone = 0; - } - // 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()) { - taskExecuteError = 1; - } - emcAbortCleanupCheck(); + // read command + if (0 != emcCommandBuffer->read()) { + // got a new command, so clear out errors + taskPlanError = 0; + taskExecuteError = 0; + taskCommandDone = 0; + } + // run control cycle, with the new command if there is one. This is + // the test emcTaskPlan() used to make itself: a command whose serial + // task has not echoed yet is new. The echo is set at the end of this + // cycle, so the planner sees each command once, in the cycle it + // arrives, and handles it then: issues it, queues it (MDI queue, + // interp_list) or refuses it. One command at most per cycle; nothing + // is still being planned when the next one is read. + NMLmsg *newCommand = NULL; + if (emcCommand->serial_number != emcStatus->echo_serial_number) { + newCommand = emcCommand; + } + if (0 != emcTaskPlan(newCommand)) { + taskPlanError = 1; + } + if (0 != emcTaskExecute()) { + taskExecuteError = 1; + } + emcAbortCleanupCheck(); // update subordinate status emcMotionUpdate(&emcStatus->motion);