dodalem pozycjonowanie relatawne. wszystko dziala
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import linuxcnc
|
import linuxcnc
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
from qtpy import uic
|
from qtpy import uic
|
||||||
from qtpy.QtCore import Qt
|
from qtpy.QtCore import Qt
|
||||||
@@ -18,6 +19,10 @@ TOOL_TABLE = getPlugin('tooltable')
|
|||||||
INI_FILE = linuxcnc.ini(os.getenv('INI_FILE_NAME'))
|
INI_FILE = linuxcnc.ini(os.getenv('INI_FILE_NAME'))
|
||||||
CMD = linuxcnc.command()
|
CMD = linuxcnc.command()
|
||||||
|
|
||||||
|
class MoveMode(Enum):
|
||||||
|
ABS = 1
|
||||||
|
WCS = 2
|
||||||
|
REL = 3
|
||||||
|
|
||||||
class UserTab(QWidget):
|
class UserTab(QWidget):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
@@ -31,10 +36,6 @@ class UserTab(QWidget):
|
|||||||
STATUS.g5x_index.notify(self.update_wcs_label)
|
STATUS.g5x_index.notify(self.update_wcs_label)
|
||||||
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)
|
self.edits: list[FloatLineEdit] = self.findChildren(FloatLineEdit)
|
||||||
|
|
||||||
for fle in self.edits:
|
for fle in self.edits:
|
||||||
@@ -47,6 +48,7 @@ class UserTab(QWidget):
|
|||||||
btn.setEnabled(False)
|
btn.setEnabled(False)
|
||||||
btn.clicked.connect(self.move_axis)
|
btn.clicked.connect(self.move_axis)
|
||||||
|
|
||||||
|
|
||||||
def format_float(self):
|
def format_float(self):
|
||||||
if not isinstance(self.sender(), FloatLineEdit):
|
if not isinstance(self.sender(), FloatLineEdit):
|
||||||
return
|
return
|
||||||
@@ -69,9 +71,10 @@ class UserTab(QWidget):
|
|||||||
self.statuslabel_wcs.setText(f"WCS {idx}")
|
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'
|
# 'G54' if ch[0] == 1 else 'G55' if ch[0] == 2 else 'G56' if ch[0] == 3 else 'none'
|
||||||
|
|
||||||
def move_x(self):
|
def move_relative(self):
|
||||||
machine_actions.jog.axis(axis='x', direction=1, distance=0.5)
|
# 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()}")
|
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):
|
def move_axis(self):
|
||||||
@@ -86,43 +89,59 @@ class UserTab(QWidget):
|
|||||||
dest_x = self.fle_abs_x.value()
|
dest_x = self.fle_abs_x.value()
|
||||||
dest_y = self.fle_abs_y.value()
|
dest_y = self.fle_abs_y.value()
|
||||||
dest_z = self.fle_abs_z.value()
|
dest_z = self.fle_abs_z.value()
|
||||||
if "_x" in btn_name:
|
if "x" == btn_name[-1]:
|
||||||
self.move_wcs(x=dest_x, abs=True)
|
self.move_wcs(MoveMode.ABS, x=dest_x)
|
||||||
return
|
return
|
||||||
if "_y" in btn_name:
|
if "y" == btn_name[-1]:
|
||||||
self.move_wcs(y=dest_y, abs=True)
|
self.move_wcs(MoveMode.ABS, y=dest_y)
|
||||||
return
|
return
|
||||||
if "_z" in btn_name:
|
if "z" == btn_name[-1]:
|
||||||
self.move_wcs(z=dest_z, abs=True)
|
self.move_wcs(MoveMode.ABS, z=dest_z)
|
||||||
return
|
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}")
|
LOG.debug(f"fn: move_wcs[ABS] x:{dest_x}, y:{dest_y}, z:{dest_z}")
|
||||||
|
|
||||||
if "wcs" in btn_name:
|
if "wcs" in btn_name:
|
||||||
dest_x = self.fle_wcs_x.value()
|
dest_x = self.fle_wcs_x.value()
|
||||||
dest_y = self.fle_wcs_y.value()
|
dest_y = self.fle_wcs_y.value()
|
||||||
dest_z = self.fle_wcs_z.value()
|
dest_z = self.fle_wcs_z.value()
|
||||||
if "_x" in btn_name:
|
if "x" == btn_name[-1]:
|
||||||
self.move_wcs(x=dest_x)
|
self.move_wcs(MoveMode.WCS, x=dest_x)
|
||||||
return
|
return
|
||||||
if "_y" in btn_name:
|
if "y" == btn_name[-1]:
|
||||||
self.move_wcs(y=dest_y)
|
self.move_wcs(MoveMode.WCS, y=dest_y)
|
||||||
return
|
return
|
||||||
if "_z" in btn_name:
|
if "z" == btn_name[-1]:
|
||||||
self.move_wcs(z=dest_z)
|
self.move_wcs(MoveMode.WCS, z=dest_z)
|
||||||
return
|
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}")
|
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:
|
def move_wcs(self, mode:MoveMode, x=None, y=None, z=None):
|
||||||
mdi_cmd = "G53 G0"
|
match mode:
|
||||||
else:
|
case MoveMode.ABS: mdi_cmd = "G53 G0"
|
||||||
mdi_cmd = "G0"
|
case MoveMode.WCS: mdi_cmd = "G0"
|
||||||
|
case MoveMode.REL: mdi_cmd = "G91 G0"
|
||||||
|
|
||||||
if x is not None:
|
if x is not None:
|
||||||
mdi_cmd += f" X{x}"
|
mdi_cmd += f" X{x}"
|
||||||
@@ -131,6 +150,9 @@ class UserTab(QWidget):
|
|||||||
if z is not None:
|
if z is not None:
|
||||||
mdi_cmd += f" Z{z}"
|
mdi_cmd += f" Z{z}"
|
||||||
|
|
||||||
|
if mode == MoveMode.REL:
|
||||||
|
mdi_cmd += " ;G90"
|
||||||
|
|
||||||
LOG.debug(f"fn: move_wcs. MDI:{mdi_cmd}")
|
LOG.debug(f"fn: move_wcs. MDI:{mdi_cmd}")
|
||||||
machine_actions.issue_mdi(mdi_cmd)
|
machine_actions.issue_mdi(mdi_cmd)
|
||||||
|
|
||||||
|
|||||||
@@ -176,6 +176,19 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
@@ -321,7 +334,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -333,6 +346,150 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_rel">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QLabel{
|
||||||
|
color: rgb(238, 238, 236);
|
||||||
|
font: 16pt "Bebas Kai";
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>RELATIVE</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="FloatLineEdit" name="fle_rel_x">
|
||||||
|
<property name="text">
|
||||||
|
<string> 0.0000</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="security" stdset="0">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rules" stdset="0">
|
||||||
|
<string>[]</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_rel_x">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>GO X</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="FloatLineEdit" name="fle_rel_y">
|
||||||
|
<property name="text">
|
||||||
|
<string> 0.0000</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="rules" stdset="0">
|
||||||
|
<string>[]</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_rel_y">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>GO Y</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||||
|
<item>
|
||||||
|
<widget class="FloatLineEdit" name="fle_rel_z">
|
||||||
|
<property name="text">
|
||||||
|
<string> 0.0000</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="rules" stdset="0">
|
||||||
|
<string>[]</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_rel_z">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>GO Z</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_rel_all">
|
||||||
|
<property name="text">
|
||||||
|
<string>GO XYZ</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|||||||
Reference in New Issue
Block a user