-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hardware-testing): flex stacker diagnostic script for axes (#16898)
- Loading branch information
1 parent
0dacfb3
commit a34f2be
Showing
6 changed files
with
361 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
hardware-testing/hardware_testing/modules/flex_stacker_evt_qc/test_l_axis.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"""Test L Axis.""" | ||
from typing import List, Union | ||
from hardware_testing.data import ui | ||
from hardware_testing.data.csv_report import ( | ||
CSVReport, | ||
CSVLine, | ||
CSVLineRepeating, | ||
CSVResult, | ||
) | ||
|
||
from .driver import FlexStacker, StackerAxis, Direction | ||
|
||
|
||
class LimitSwitchError(Exception): | ||
"""Limit Switch Error.""" | ||
|
||
pass | ||
|
||
|
||
def build_csv_lines() -> List[Union[CSVLine, CSVLineRepeating]]: | ||
"""Build CSV Lines.""" | ||
return [ | ||
CSVLine("trigger-latch-switch", [CSVResult]), | ||
CSVLine("release/open-latch", [CSVResult]), | ||
CSVLine("hold/close-latch", [CSVResult]), | ||
] | ||
|
||
|
||
def get_latch_held_switch(driver: FlexStacker) -> bool: | ||
"""Get limit switch.""" | ||
held_switch = driver.get_limit_switch(StackerAxis.L, Direction.RETRACT) | ||
print("(Held Switch triggered) : ", held_switch) | ||
return held_switch | ||
|
||
|
||
def close_latch(driver: FlexStacker) -> None: | ||
"""Close latch.""" | ||
driver.move_to_limit_switch(StackerAxis.L, Direction.EXTENT) | ||
|
||
|
||
def open_latch(driver: FlexStacker) -> None: | ||
"""Open latch.""" | ||
driver.move_in_mm(StackerAxis.L, -22) | ||
|
||
|
||
def run(driver: FlexStacker, report: CSVReport, section: str) -> None: | ||
"""Run.""" | ||
if not get_latch_held_switch(driver): | ||
print("Switch is not triggered, try to trigger it by closing latch...") | ||
close_latch(driver) | ||
if not get_latch_held_switch(driver): | ||
print("!!! Held switch is still not triggered !!!") | ||
report(section, "trigger-latch-switch", [CSVResult.FAIL]) | ||
return | ||
|
||
report(section, "trigger-latch-switch", [CSVResult.PASS]) | ||
|
||
ui.print_header("Latch Release/Open") | ||
open_latch(driver) | ||
success = not get_latch_held_switch(driver) | ||
report(section, "release/open-latch", [CSVResult.from_bool(success)]) | ||
|
||
ui.print_header("Latch Hold/Close") | ||
if not success: | ||
print("Latch must be open to close it") | ||
report(section, "hold/close-latch", [CSVResult.FAIL]) | ||
else: | ||
close_latch(driver) | ||
success = get_latch_held_switch(driver) | ||
report(section, "hold/close-latch", [CSVResult.from_bool(success)]) |
81 changes: 81 additions & 0 deletions
81
hardware-testing/hardware_testing/modules/flex_stacker_evt_qc/test_x_axis.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
"""Test X Axis.""" | ||
from typing import List, Union | ||
from hardware_testing.data import ui | ||
from hardware_testing.data.csv_report import ( | ||
CSVReport, | ||
CSVLine, | ||
CSVLineRepeating, | ||
CSVResult, | ||
) | ||
|
||
from .utils import test_limit_switches_per_direction | ||
from .driver import FlexStacker, StackerAxis, Direction | ||
|
||
|
||
def build_csv_lines() -> List[Union[CSVLine, CSVLineRepeating]]: | ||
"""Build CSV Lines.""" | ||
return [ | ||
CSVLine( | ||
"limit-switch-trigger-positive-untrigger-negative", [bool, bool, CSVResult] | ||
), | ||
CSVLine( | ||
"limit-switch-trigger-negative-untrigger-positive", [bool, bool, CSVResult] | ||
), | ||
CSVLine( | ||
"platform-sensor-trigger-positive-untrigger-negative", | ||
[bool, bool, CSVResult], | ||
), | ||
CSVLine( | ||
"platform-sensor-trigger-negative-untrigger-positive", | ||
[bool, bool, CSVResult], | ||
), | ||
] | ||
|
||
|
||
def test_platform_sensors_for_direction( | ||
driver: FlexStacker, direction: Direction, report: CSVReport, section: str | ||
) -> None: | ||
"""Test platform sensors for a given direction.""" | ||
ui.print_header(f"Platform Sensor - {direction} direction") | ||
sensor_result = driver.get_platform_sensor(direction) | ||
opposite_result = not driver.get_platform_sensor(direction.opposite()) | ||
print(f"{direction} sensor triggered: {sensor_result}") | ||
print(f"{direction.opposite()} sensor untriggered: {opposite_result}") | ||
report( | ||
section, | ||
f"platform-sensor-trigger-{direction}-untrigger-{direction.opposite()}", | ||
[ | ||
sensor_result, | ||
opposite_result, | ||
CSVResult.from_bool(sensor_result and opposite_result), | ||
], | ||
) | ||
|
||
|
||
def platform_is_removed(driver: FlexStacker) -> bool: | ||
"""Check if the platform is removed from the carrier.""" | ||
plus_side = driver.get_platform_sensor(Direction.EXTENT) | ||
minus_side = driver.get_platform_sensor(Direction.RETRACT) | ||
return not plus_side and not minus_side | ||
|
||
|
||
def run(driver: FlexStacker, report: CSVReport, section: str) -> None: | ||
"""Run.""" | ||
if not driver._simulating and not platform_is_removed(driver): | ||
print("FAILURE - Cannot start tests with platform on the carrier") | ||
return | ||
|
||
test_limit_switches_per_direction( | ||
driver, StackerAxis.X, Direction.EXTENT, report, section | ||
) | ||
|
||
if not driver._simulating: | ||
ui.get_user_ready("Place the platform on the X carrier") | ||
|
||
test_platform_sensors_for_direction(driver, Direction.EXTENT, report, section) | ||
|
||
test_limit_switches_per_direction( | ||
driver, StackerAxis.X, Direction.RETRACT, report, section | ||
) | ||
|
||
test_platform_sensors_for_direction(driver, Direction.RETRACT, report, section) |
34 changes: 34 additions & 0 deletions
34
hardware-testing/hardware_testing/modules/flex_stacker_evt_qc/test_z_axis.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Test Z Axis.""" | ||
from typing import List, Union | ||
from hardware_testing.data.csv_report import ( | ||
CSVReport, | ||
CSVLine, | ||
CSVLineRepeating, | ||
CSVResult, | ||
) | ||
|
||
from .utils import test_limit_switches_per_direction | ||
from .driver import FlexStacker, StackerAxis, Direction | ||
|
||
|
||
def build_csv_lines() -> List[Union[CSVLine, CSVLineRepeating]]: | ||
"""Build CSV Lines.""" | ||
return [ | ||
CSVLine( | ||
"limit-switch-trigger-positive-untrigger-negative", [bool, bool, CSVResult] | ||
), | ||
CSVLine( | ||
"limit-switch-trigger-negative-untrigger-positive", [bool, bool, CSVResult] | ||
), | ||
] | ||
|
||
|
||
def run(driver: FlexStacker, report: CSVReport, section: str) -> None: | ||
"""Run.""" | ||
test_limit_switches_per_direction( | ||
driver, StackerAxis.Z, Direction.EXTENT, report, section | ||
) | ||
|
||
test_limit_switches_per_direction( | ||
driver, StackerAxis.Z, Direction.RETRACT, report, section | ||
) |
Oops, something went wrong.