Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hardware-testing): add __init__.py to modules/ so it gets packed in the build + other Flex stacker QC fixes. #16995

Merged
merged 8 commits into from
Nov 27, 2024
1 change: 1 addition & 0 deletions hardware-testing/hardware_testing/modules/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Module QC Scripts."""
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,15 @@ def __init__(self, port: str, simulating: bool = False) -> None:
if not self._simulating:
self._serial = serial.Serial(port, baudrate=STACKER_FREQ, timeout=60)

def _send_and_recv(self, msg: str, guard_ret: str = "") -> str:
def _send_and_recv(
self, msg: str, guard_ret: str = "", response_required: bool = True
) -> str:
"""Internal utility to send a command and receive the response."""
assert not self._simulating
self._serial.reset_input_buffer()
self._serial.write(msg.encode())
if not response_required:
return "OK\n"
ret = self._serial.readline()
if guard_ret:
if not ret.startswith(guard_ret.encode()):
Expand Down Expand Up @@ -159,7 +164,7 @@ def stop_motor(self) -> None:
"""Stop motor movement."""
if self._simulating:
return
self._send_and_recv("M0\n")
self._send_and_recv("M0\n", response_required=False)

def get_limit_switch(self, axis: StackerAxis, direction: Direction) -> bool:
"""Get limit switch status.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,23 @@ def run(driver: FlexStacker, report: CSVReport, section: str) -> None:

report(section, "trigger-estop", [CSVResult.PASS])

print("try to move X axis...")
driver.move_in_mm(StackerAxis.X, x_limit.opposite().distance(10))
print("X should not move")
report(
section,
"x-move-disabled",
[CSVResult.from_bool(driver.get_limit_switch(StackerAxis.X, x_limit))],
)
print("Check X limit switch...")
limit_switch_triggered = driver.get_limit_switch(StackerAxis.X, x_limit)
if limit_switch_triggered:
report(
section,
"x-move-disabled",
[CSVResult.from_bool(False)],
)
else:
print("try to move X axis back to the limit switch...")
driver.move_in_mm(StackerAxis.X, x_limit.distance(3))
print("X should not move")
report(
section,
"x-move-disabled",
[CSVResult.from_bool(not driver.get_limit_switch(StackerAxis.X, x_limit))],
)

print("try to move Z axis...")
driver.move_in_mm(StackerAxis.Z, z_limit.opposite().distance(10))
Expand All @@ -74,14 +83,23 @@ def run(driver: FlexStacker, report: CSVReport, section: str) -> None:
[CSVResult.from_bool(driver.get_limit_switch(StackerAxis.Z, z_limit))],
)

print("try to move L axis...")
driver.move_in_mm(StackerAxis.L, l_limit.opposite().distance(10))
print("L should not move")
report(
section,
"l-move-disabled",
[CSVResult.from_bool(driver.get_limit_switch(StackerAxis.L, l_limit))],
)
print("Check L limit switch...")
limit_switch_triggered = driver.get_limit_switch(StackerAxis.L, l_limit)
if limit_switch_triggered:
report(
section,
"l-move-disabled",
[CSVResult.from_bool(False)],
)
else:
print("try to move L axis back to the limit switch...")
driver.move_in_mm(StackerAxis.L, l_limit.distance(1))
print("L should not move")
report(
section,
"l-move-disabled",
[CSVResult.from_bool(not driver.get_limit_switch(StackerAxis.L, l_limit))],
)

if not driver._simulating:
ui.get_user_ready("Untrigger the E-Stop")
Expand Down