dodalem pozycjonowanie relatawne. wszystko dziala
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import linuxcnc
|
||||
from enum import Enum
|
||||
|
||||
from qtpy import uic
|
||||
from qtpy.QtCore import Qt
|
||||
@@ -18,6 +19,10 @@ TOOL_TABLE = getPlugin('tooltable')
|
||||
INI_FILE = linuxcnc.ini(os.getenv('INI_FILE_NAME'))
|
||||
CMD = linuxcnc.command()
|
||||
|
||||
class MoveMode(Enum):
|
||||
ABS = 1
|
||||
WCS = 2
|
||||
REL = 3
|
||||
|
||||
class UserTab(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
@@ -31,10 +36,6 @@ class UserTab(QWidget):
|
||||
STATUS.g5x_index.notify(self.update_wcs_label)
|
||||
self.update_wcs_label()
|
||||
|
||||
# self.btn_wcs_x.clicked.connect(lambda: self.move_wcs(x=self.fle_wcs_x.value()))
|
||||
# self.btn_wcs_y.clicked.connect(lambda: self.move_wcs(y=self.fle_wcs_y.value()))
|
||||
# self.fle_wcs_x.editingFinished.connect(self._format_x)
|
||||
|
||||
self.edits: list[FloatLineEdit] = self.findChildren(FloatLineEdit)
|
||||
|
||||
for fle in self.edits:
|
||||
@@ -47,6 +48,7 @@ class UserTab(QWidget):
|
||||
btn.setEnabled(False)
|
||||
btn.clicked.connect(self.move_axis)
|
||||
|
||||
|
||||
def format_float(self):
|
||||
if not isinstance(self.sender(), FloatLineEdit):
|
||||
return
|
||||
@@ -69,9 +71,10 @@ class UserTab(QWidget):
|
||||
self.statuslabel_wcs.setText(f"WCS {idx}")
|
||||
# 'G54' if ch[0] == 1 else 'G55' if ch[0] == 2 else 'G56' if ch[0] == 3 else 'none'
|
||||
|
||||
def move_x(self):
|
||||
machine_actions.jog.axis(axis='x', direction=1, distance=0.5)
|
||||
LOG.debug(f"fn: move_x. fle_wcs_x:{self.fle_wcs_x.value()}")
|
||||
def move_relative(self):
|
||||
# machine_actions.jog.axis(axis='x', direction=1, distance=0.5)
|
||||
machine_actions.issue_mdi(f"G91 G0 X{self.fle_rel_x.value()}; G90")
|
||||
LOG.debug(f"fn: move_x. fle_wcs_x:{self.fle_rel_x.value()}")
|
||||
|
||||
|
||||
def move_axis(self):
|
||||
@@ -86,43 +89,59 @@ class UserTab(QWidget):
|
||||
dest_x = self.fle_abs_x.value()
|
||||
dest_y = self.fle_abs_y.value()
|
||||
dest_z = self.fle_abs_z.value()
|
||||
if "_x" in btn_name:
|
||||
self.move_wcs(x=dest_x, abs=True)
|
||||
if "x" == btn_name[-1]:
|
||||
self.move_wcs(MoveMode.ABS, x=dest_x)
|
||||
return
|
||||
if "_y" in btn_name:
|
||||
self.move_wcs(y=dest_y, abs=True)
|
||||
if "y" == btn_name[-1]:
|
||||
self.move_wcs(MoveMode.ABS, y=dest_y)
|
||||
return
|
||||
if "_z" in btn_name:
|
||||
self.move_wcs(z=dest_z, abs=True)
|
||||
if "z" == btn_name[-1]:
|
||||
self.move_wcs(MoveMode.ABS, z=dest_z)
|
||||
return
|
||||
self.move_wcs(dest_x, dest_y, dest_z, abs=True)
|
||||
self.move_wcs(MoveMode.ABS, dest_x, dest_y, dest_z)
|
||||
LOG.debug(f"fn: move_wcs[ABS] x:{dest_x}, y:{dest_y}, z:{dest_z}")
|
||||
|
||||
if "wcs" in btn_name:
|
||||
dest_x = self.fle_wcs_x.value()
|
||||
dest_y = self.fle_wcs_y.value()
|
||||
dest_z = self.fle_wcs_z.value()
|
||||
if "_x" in btn_name:
|
||||
self.move_wcs(x=dest_x)
|
||||
if "x" == btn_name[-1]:
|
||||
self.move_wcs(MoveMode.WCS, x=dest_x)
|
||||
return
|
||||
if "_y" in btn_name:
|
||||
self.move_wcs(y=dest_y)
|
||||
if "y" == btn_name[-1]:
|
||||
self.move_wcs(MoveMode.WCS, y=dest_y)
|
||||
return
|
||||
if "_z" in btn_name:
|
||||
self.move_wcs(z=dest_z)
|
||||
if "z" == btn_name[-1]:
|
||||
self.move_wcs(MoveMode.WCS, z=dest_z)
|
||||
return
|
||||
|
||||
self.move_wcs(dest_x, dest_y, dest_z)
|
||||
self.move_wcs(MoveMode.WCS, dest_x, dest_y, dest_z)
|
||||
LOG.debug(f"fn: move_wcs[WCS] x:{dest_x}, y:{dest_y}, z:{dest_z}")
|
||||
|
||||
if "rel" in btn_name:
|
||||
dest_x = self.fle_rel_x.value()
|
||||
dest_y = self.fle_rel_y.value()
|
||||
dest_z = self.fle_rel_z.value()
|
||||
if "x" == btn_name[-1]:
|
||||
self.move_wcs(MoveMode.REL, x=dest_x)
|
||||
return
|
||||
if "y" == btn_name[-1]:
|
||||
self.move_wcs(MoveMode.REL, y=dest_y)
|
||||
return
|
||||
if "z" == btn_name[-1]:
|
||||
self.move_wcs(MoveMode.REL, z=dest_z)
|
||||
return
|
||||
|
||||
self.move_wcs(MoveMode.REL, dest_x, dest_y, dest_z)
|
||||
LOG.debug(f"fn: move_wcs[REL] x:{dest_x}, y:{dest_y}, z:{dest_z}")
|
||||
|
||||
|
||||
|
||||
def move_wcs(self, x=None, y=None, z=None, abs=False):
|
||||
|
||||
if abs:
|
||||
mdi_cmd = "G53 G0"
|
||||
else:
|
||||
mdi_cmd = "G0"
|
||||
def move_wcs(self, mode:MoveMode, x=None, y=None, z=None):
|
||||
match mode:
|
||||
case MoveMode.ABS: mdi_cmd = "G53 G0"
|
||||
case MoveMode.WCS: mdi_cmd = "G0"
|
||||
case MoveMode.REL: mdi_cmd = "G91 G0"
|
||||
|
||||
if x is not None:
|
||||
mdi_cmd += f" X{x}"
|
||||
@@ -131,6 +150,9 @@ class UserTab(QWidget):
|
||||
if z is not None:
|
||||
mdi_cmd += f" Z{z}"
|
||||
|
||||
if mode == MoveMode.REL:
|
||||
mdi_cmd += " ;G90"
|
||||
|
||||
LOG.debug(f"fn: move_wcs. MDI:{mdi_cmd}")
|
||||
machine_actions.issue_mdi(mdi_cmd)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user