コード例 #1
0
    def auto():
        """Change mode to Auto

        ActionButton syntax:
        ::

            machine.mode.auto

        """
        setTaskMode(linuxcnc.MODE_AUTO)
コード例 #2
0
    def mdi():
        """Change mode to MDI

        ActionButton syntax:
        ::

            machine.mode.mdi

        """
        setTaskMode(linuxcnc.MODE_MDI)
コード例 #3
0
    def manual():
        """Change mode to Manual

        ActionButton syntax:
        ::

            machine.mode.manual

        """
        setTaskMode(linuxcnc.MODE_MANUAL)
コード例 #4
0
ファイル: program_actions.py プロジェクト: NeoTech/qtpyvcp
def load(fname, add_to_recents=True):
    setTaskMode(linuxcnc.MODE_AUTO)
    filter_prog = INFO.getFilterProgram(fname)
    if not filter_prog:
        LOG.debug('Loading NC program: %s', fname)
        CMD.program_open(fname.encode('utf-8'))
    else:
        LOG.debug('Loading file with filter program: %s', fname)
        openFilterProgram(fname, filter_prog)

    if add_to_recents:
        addToRecents(fname)
コード例 #5
0
def issue_mdi(command, reset=True):
    """Issue an MDI command.

        An MDI command can be issued any time the machine is homed (if not
        NO_FORCE_HOMING in the INI) and the interpreter is IDLE.  The task
        mode will automatically be switched to MDI prior to issuing the command
        and will be returned to the previous mode when the interpreter becomes IDLE.

    Args:
        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))
コード例 #6
0
def load(fname, add_to_recents=True):
    if not fname:
        # load a blank file. Maybe should load [DISPLAY] OPEN_FILE
        clear()

    setTaskMode(linuxcnc.MODE_AUTO)
    filter_prog = INFO.getFilterProgram(fname)
    if not filter_prog:
        LOG.debug('Loading NC program: %s', fname)
        CMD.program_open(fname.encode('utf-8'))
        CMD.wait_complete()
    else:
        LOG.debug('Loading file with filter program: %s', fname)
        openFilterProgram(fname, filter_prog)

    if add_to_recents:
        addToRecents(fname)
コード例 #7
0
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)
コード例 #8
0
def run(start_line=0):
    """Runs the loaded program, optionally starting from a specific line.

    ActionButton syntax::

        program.run
        program.run:line

    Args:
        start_line (int, optional) : The line to start program from. Defaults to 0.
    """
    if STAT.state == linuxcnc.RCS_EXEC and STAT.paused:
        CMD.auto(linuxcnc.AUTO_RESUME)
    elif setTaskMode(linuxcnc.MODE_AUTO):
        CMD.auto(linuxcnc.AUTO_RUN, start_line)
コード例 #9
0
def _unhome_joint(jnum):
    setTaskMode(linuxcnc.MODE_MANUAL)
    CMD.teleop_enable(False)
    CMD.unhome(jnum)
コード例 #10
0
def _resetMode(interp_state):
    global PREVIOUS_MODE
    if PREVIOUS_MODE is not None and interp_state == linuxcnc.INTERP_IDLE:
        if setTaskMode(PREVIOUS_MODE):
            LOG.debug("Successfully reset task_mode after MDI")
        PREVIOUS_MODE = None