Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
def __init__(self, parent=None, filename=''):
super(SubCallButton, self).__init__(parent)
self._filename = filename
issue_mdi.bindOk(widget=self)
self.clicked.connect(self.callSub)
QTimer.singleShot(200, lambda: issue_mdi(cmd))
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)
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)
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)
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))
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)
# scan for the next command to execute from bottom up.
list_length = self.count()-1
while list_length >= 0:
row_item = self.item(list_length)
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:
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
list_length -= 1
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))