Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
command (str) : A valid RS274 gcode command string. Multiple MDI commands
can be separated with a ``;`` and will be issued sequentially.
rest (bool, optional): Whether to reset the Task Mode to the state
the machine was in prior to issuing the MDI command.
"""
if reset:
# save the previous mode
global PREVIOUS_MODE
PREVIOUS_MODE = STAT.task_mode
# Force `interp_state` update on next status cycle. This is needed because
# some commands might take less than `cycle_time` (50ms) to complete,
# so status would not even notice that the interp_state had changed and the
# reset mode method would not be called.
STATUS.old['interp_state'] = -1
if setTaskMode(linuxcnc.MODE_MDI):
# issue multiple MDI commands separated by ';'
for cmd in command.strip().split(';'):
LOG.info("Issuing MDI command: %s", cmd)
CMD.mdi(cmd)
else:
LOG.error("Failed to issue MDI command: {}".format(command))
def _unhome_joint(jnum):
setTaskMode(linuxcnc.MODE_MANUAL)
CMD.teleop_enable(False)
CMD.unhome(jnum)
def _home_joint(jnum):
setTaskMode(linuxcnc.MODE_MANUAL)
CMD.teleop_enable(False)
CMD.home(jnum)
def step():
"""Steps program line by line
ActionButton syntax::
program.step
"""
if STAT.state == linuxcnc.RCS_EXEC and STAT.paused:
CMD.auto(linuxcnc.AUTO_STEP)
elif setTaskMode(linuxcnc.MODE_AUTO):
CMD.auto(linuxcnc.AUTO_STEP)
def mdi():
"""Change mode to MDI
ActionButton syntax:
::
machine.mode.mdi
"""
setTaskMode(linuxcnc.MODE_MDI)
def auto():
"""Change mode to Auto
ActionButton syntax:
::
machine.mode.auto
"""
setTaskMode(linuxcnc.MODE_AUTO)