mirror of
https://github.com/nqrduck/nqrduck-autotm.git
synced 2024-12-30 11:28:07 +00:00
Implemented absolute stepper movement.
This commit is contained in:
parent
487f7ce0c7
commit
f49cb04139
3 changed files with 48 additions and 12 deletions
|
@ -664,4 +664,35 @@ class AutoTMController(ModuleController):
|
|||
command = f"m{motor_identifier}{steps}"
|
||||
self.send_command(command)
|
||||
|
||||
def on_absolute_move(self, steps : str) -> None:
|
||||
"""This method is called when the absolute move button is pressed.
|
||||
|
||||
Args:
|
||||
steps (str): The number of steps to move the stepper.
|
||||
"""
|
||||
|
||||
# First char is the stepper identifier, m for matching and t for tuning
|
||||
motor_identifier = self.module.model.active_stepper.TYPE.lower()[0]
|
||||
|
||||
# We check if the steps are valid
|
||||
future_position = int(steps)
|
||||
|
||||
if future_position < 0:
|
||||
error = "Could not move stepper. Stepper position cannot be negative"
|
||||
self.module.view.add_info_text(error)
|
||||
return
|
||||
|
||||
if future_position > self.module.model.active_stepper.MAX_STEPS:
|
||||
error = f"Could not move stepper. Stepper position cannot be larger than {self.module.model.active_stepper.MAX_STEPS}"
|
||||
self.module.view.add_info_text(error)
|
||||
return
|
||||
|
||||
# We calculate the number of steps to move
|
||||
stepper_current_position = self.module.model.active_stepper.position
|
||||
steps = future_position - stepper_current_position
|
||||
|
||||
# We send the command to the atm system, the first m identifies this is a move command
|
||||
command = f"m{motor_identifier}{steps}"
|
||||
self.send_command(command)
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1280</width>
|
||||
<height>1011</height>
|
||||
<height>1089</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -95,7 +95,7 @@
|
|||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="stopfrequencyBox">
|
||||
<property name="value">
|
||||
<double>80.200000000000003</double>
|
||||
<double>80.099999999999994</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -182,7 +182,11 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QSpinBox" name="absoluteposBox"/>
|
||||
<widget class="QSpinBox" name="absoluteposBox">
|
||||
<property name="maximum">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="stepperselectBox">
|
||||
|
@ -229,10 +233,10 @@
|
|||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="stepsizeBox">
|
||||
<property name="minimum">
|
||||
<number>-1000</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
<number>50000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>500</number>
|
||||
|
@ -309,7 +313,7 @@
|
|||
<attribute name="title">
|
||||
<string>Electrical</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0">
|
||||
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0,0,0,0,0">
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="generateLUTButton">
|
||||
<property name="text">
|
||||
|
@ -515,7 +519,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>285</width>
|
||||
<width>291</width>
|
||||
<height>83</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
|
|
@ -12,7 +12,7 @@ from PyQt6 import QtCore, QtGui, QtWidgets
|
|||
class Ui_Form(object):
|
||||
def setupUi(self, Form):
|
||||
Form.setObjectName("Form")
|
||||
Form.resize(1280, 1011)
|
||||
Form.resize(1280, 1089)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
|
@ -61,7 +61,7 @@ class Ui_Form(object):
|
|||
self.gridLayout_8 = QtWidgets.QGridLayout()
|
||||
self.gridLayout_8.setObjectName("gridLayout_8")
|
||||
self.stopfrequencyBox = QtWidgets.QDoubleSpinBox(parent=Form)
|
||||
self.stopfrequencyBox.setProperty("value", 80.2)
|
||||
self.stopfrequencyBox.setProperty("value", 80.1)
|
||||
self.stopfrequencyBox.setObjectName("stopfrequencyBox")
|
||||
self.gridLayout_8.addWidget(self.stopfrequencyBox, 1, 1, 1, 1)
|
||||
self.label_13 = QtWidgets.QLabel(parent=Form)
|
||||
|
@ -108,6 +108,7 @@ class Ui_Form(object):
|
|||
self.label_16.setObjectName("label_16")
|
||||
self.gridLayout_4.addWidget(self.label_16, 0, 0, 1, 3)
|
||||
self.absoluteposBox = QtWidgets.QSpinBox(parent=self.mechTab)
|
||||
self.absoluteposBox.setMaximum(1000000)
|
||||
self.absoluteposBox.setObjectName("absoluteposBox")
|
||||
self.gridLayout_4.addWidget(self.absoluteposBox, 6, 1, 1, 1)
|
||||
self.stepperselectBox = QtWidgets.QComboBox(parent=self.mechTab)
|
||||
|
@ -128,8 +129,8 @@ class Ui_Form(object):
|
|||
self.label_20.setObjectName("label_20")
|
||||
self.gridLayout_4.addWidget(self.label_20, 6, 0, 1, 1)
|
||||
self.stepsizeBox = QtWidgets.QSpinBox(parent=self.mechTab)
|
||||
self.stepsizeBox.setMinimum(-1000)
|
||||
self.stepsizeBox.setMaximum(1000)
|
||||
self.stepsizeBox.setMinimum(0)
|
||||
self.stepsizeBox.setMaximum(50000)
|
||||
self.stepsizeBox.setProperty("value", 500)
|
||||
self.stepsizeBox.setObjectName("stepsizeBox")
|
||||
self.gridLayout_4.addWidget(self.stepsizeBox, 3, 1, 1, 1)
|
||||
|
@ -264,7 +265,7 @@ class Ui_Form(object):
|
|||
self.scrollArea.setWidgetResizable(True)
|
||||
self.scrollArea.setObjectName("scrollArea")
|
||||
self.scrollAreaWidgetContents = QtWidgets.QWidget()
|
||||
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 285, 83))
|
||||
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 291, 83))
|
||||
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
|
||||
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
|
||||
self.verticalLayout_2.addWidget(self.scrollArea)
|
||||
|
|
Loading…
Reference in a new issue