Exemplo n.º 1
0
    def tool_select(self, group, index, orientation):

        tool_num = self.stat.tool_in_spindle.getValue()
        issue_mdi("G10 L1 P{} Q{}".format(tool_num, orientation))

        self.tool_image[tool_num] = [group, index]
        self.dm.setData('tool-touch-off.tool-image-table', self.tool_image)
Exemplo n.º 2
0
    def issueMDI(self):
        window = QApplication.instance().activeWindow()

        try:
            cmd = self._mdi_cmd.format(ch=self._data_channels)
        except IndexError:
            LOG.exception("Failed to format MDI command.")
            return

        vars = PARSE_VARS.findall(self._mdi_cmd)
        for cmd_word, object_name in vars:

            try:

                # get the value from the GUI input widget
                wid = getattr(window, object_name)

                try:
                    # QSpinBox, QSlider, QDial
                    val = wid.value()
                except AttributeError:
                    # QLabel, QLineEdit
                    val = wid.text()

                cmd = cmd.replace("{}#<{}>".format(cmd_word, object_name),
                                  "{}{}".format(cmd_word, val))
            except:
                LOG.exception(
                    "Couldn't expand '{}' variable.".format(object_name))
                return

        issue_mdi(cmd)
Exemplo n.º 3
0
 def loadTool(self):
     if int(self.toolNumberInput.text()) != self._loadedTool:
         # proceed with tool change
         issue_mdi("M6 T{} G43".format(self.toolNumberInput.text()))
     else:
         self.spindleStates.setCurrentIndex(SpindleState.SPINDLE_LOADED)
         self.spindleSpeed.setFocus()
Exemplo n.º 4
0
    def saveOffsetTable(self, offset_table, columns):
        """ Stores the offset table in memory.

        Args:
            offset_table (dict) : Dictionary of dictionaries containing
                the tool data to write to the file.
            columns (str | list) : A list of data columns to write.
                If `None` will use the value of ``self.columns``.
        """
        self.g5x_offset_table = offset_table

        for index in range(len(self.rows)):
            mdi_list = list()
            mdi_list.append("G10 L2")
            mdi_list.append("P{}".format(index+1))

            for char in columns:

                column_index = self.columns.index(char)

                mdi_list.append("{}{}".format(char, self.g5x_offset_table[index][column_index]))

            mdi_command = " ".join(mdi_list)

            issue_mdi(mdi_command)
Exemplo n.º 5
0
    def heartBeat(self):
        """Supports heart beat on the MDI History execution queue.
        Issue the next command from the queue.
        Double check machine is in ok state to accept next command.
        Issue the command and if success mark command as being active.
        Mark last command as done.
        """
        # check if machine is idle and ready to run another command
        if STAT.interp_state != linuxcnc.INTERP_IDLE:
            # RS274NGC interpreter not in a state to execute, bail
            return

        # scan for the next command to execute from bottom up.
        if self.mdi_listorder_natural:
            list_length = range(self.count())
        else:
            list_length = range(self.count() - 1, 0, -1)

        for list_item in list_length:
            row_item = self.item(list_item)
            row_item_data = row_item.data(MDIHistory.MDQQ_ROLE)

            if row_item_data == MDIHistory.MDIQ_RUNNING:
                # machine is in idle state so the running command is done
                row_item.setData(MDIHistory.MDQQ_ROLE, MDIHistory.MDIQ_DONE)
                row_item.setIcon(QIcon())

            elif row_item_data == MDIHistory.MDIQ_TODO:
                self.clearSelection()
                self.setCurrentItem(row_item)
                cmd = str(row_item.text()).strip()
                row_item.setData(MDIHistory.MDQQ_ROLE, MDIHistory.MDIQ_RUNNING)
                row_item.setIcon(self.icon_run)
                issue_mdi(cmd)
                break
Exemplo n.º 6
0
 def submit(self):
     cmd = str(self.text()).strip()
     issue_mdi(cmd)
     self.setText('')
     cmds = self.model.stringList()
     if cmd not in cmds:
         cmds.append(cmd)
         self.model.setStringList(cmds)
Exemplo n.º 7
0
    def loadSelectedTool(self):
        """Loads the currently selected tool"""
        # see: https://forum.linuxcnc.org/41-guis/36042?start=50#151820
        current_row = self.selectedRow()
        if current_row == -1:
            # no row selected
            return

        tnum = self.tool_model.toolDataFromRow(current_row)['T']
        issue_mdi("T%s M6" % tnum)
Exemplo n.º 8
0
    def toolTouchOff(self):
        if self.btnTools.isChecked():
            self.btnTools.click()
        self.updateHalPinsWithCurrentSettings()

        offset_by = 0
        if self.applyYOffsetCheckbox.isChecked():
            offset_by = self.yOffsetSpinner.getValue()

        issue_mdi("o<tool_touch_off> call [{}]".format(offset_by))
Exemplo n.º 9
0
    def set_method(self):
        system = self.system_combo.currentData()
        axis = self.axis_combo.currentData()
        coords = self.coords_input.value()

        offset_mdi = "G10 L20 {} {}{:f}".format(system, axis, coords)

        if issue_mdi.ok():
            issue_mdi(offset_mdi)
        else:
            self.log.debug("Error issuing MDI: {}".format(issue_mdi.ok.msg))
Exemplo n.º 10
0
 def submit(self):
     # Only support submit from Return Key if not suppressed
     # This is used to stop standalone behaviour by the MDIHistory widget.
     # MDIHisttory uses its handle to this widget to set
     # mdi_rtnkey_behaviour_supressed = True.
     # MDIHistory will now manage the MDILine submission process
     if not self.mdi_rtnkey_behaviour_supressed:
         cmd = str(self.text()).strip()
         issue_mdi(cmd)
         self.setText('')
         STATUS.mdi_history.setValue(cmd)
Exemplo n.º 11
0
 def reload_tool(self):
     if self.remember_tool_in_spindle and STATUS.all_axes_homed.value and STATUS.enabled.value:
         tnum = self.data_manager.getData('tool-in-spindle', 0)
         LOG.debug("reload_tool: tool in spindle: %i new tool: %i" % (STAT.tool_in_spindle, tnum))
         if STAT.tool_in_spindle == 0 and tnum != STAT.tool_in_spindle:
             LOG.info("Reloading tool in spindle: %i", tnum)
             cmd = "M61 Q{0} G43".format(tnum)
             # give LinuxCNC time to switch modes
             QTimer.singleShot(200, lambda: issue_mdi(cmd))
Exemplo n.º 12
0
    def onReturnPressed(self):
        try:
            val = float(self.text().strip().replace('mm', '').replace('in', ''))
            g5x_index = self.status.stat.g5x_index
            axis = 'XYZABCUVW'[self._anum]

            if self._is_lathe and self._anum == Axis.X:
                if self._lathe_mode == LatheMode.Diameter and not self._g7_active:
                    val = val / 2
                elif self._lathe_mode == LatheMode.Radius and self._g7_active:
                    val = val * 2

            cmd = 'G10 L20 P{0:d} {1}{2:.12f}'.format(g5x_index, axis, val)
            issue_mdi(cmd)
        except Exception:
            LOG.exception("Error setting work coordinate offset.")

        self.blockSignals(True)
        self.clearFocus()
        self.blockSignals(False)
Exemplo n.º 13
0
 def on_feed_unit_per_minute_entry_returnPressed(self):
     cmd = "F{}".format(self.feed_unit_per_minute)
     issue_mdi(cmd)
Exemplo n.º 14
0
 def set_probe_plugged(self, plugged):
     self._probe_plugged = plugged
     if plugged:
         issue_mdi("M6 T{} G43".format(99))
     else:
         issue_mdi("M6 T{} G43".format(0))
Exemplo n.º 15
0
    def callSub(self):
        window = qApp.activeWindow()

        subfile = os.path.join(SUBROUTINE_PATH, self._filename)
        if not os.path.isfile(subfile):
            LOG.error(
                'Subroutine file does not exist: yellow<{}>'.format(subfile))
            return False

        with open(subfile, 'r') as fh:
            lines = fh.readlines()

        args = []
        for line in lines:
            line = line.strip()
            if not line.startswith('#'):
                continue
            result_list = PARSE_POSITIONAL_ARGS.findall(line)
            if len(result_list) == 0:
                continue

            pname, pnumber, default_val, comment = result_list[0]

            if int(pnumber) > 30:
                # only #1-#30 are passed to the sub
                continue

            try:
                # get the value from the GUI input widget
                val = getattr(window, pname).text() or default_val
            except:
                val = default_val
                LOG.warning(
                    'No input for red<{}> parameter, using default value blue<{}>'
                    .format(pname, val))

            if val == '':
                LOG.error(
                    'No value given for parameter red<{}>, and no default specified'
                    .format(pname))
                return False

            try:
                val = float(val)
            except ValueError:
                LOG.error(
                    'Input value "{}" given for parameter "{}" is not a valid number'
                    .format(val, pname))
                return False

            index = int(pnumber) - 1
            while len(args) <= index:
                args.append("[0.0000]")

            args[index] = "[{}]".format(val)

        arg_str = ' '.join(args)
        sub_name = os.path.splitext(self._filename)[0]
        cmd_str = "o<{}> call {}".format(sub_name, arg_str)

        LOG.debug('Calling sub file: yellow<%s> with args blue<%s>', subfile,
                  arg_str)
        issue_mdi(cmd_str)
Exemplo n.º 16
0
 def submit(self):
     cmd = str(self.text()).strip()
     issue_mdi(cmd)
     self.setText('')
     STATUS.mdi_history.setValue(cmd)
Exemplo n.º 17
0
 def on_feed_per_rev_entry_returnPressed(self):
     cmd = "F{}".format(self.feed_per_rev)
     issue_mdi(cmd)
Exemplo n.º 18
0
 def on_rpm_mode_entry_returnPressed(self):
     cmd = "S{}".format(self.rpm_mode)
     issue_mdi(cmd)
Exemplo n.º 19
0
 def on_css_sword_entry_returnPressed(self):
     cmd = "G96 S{}".format(self.css_sword)
     issue_mdi(cmd)