Skip to content

Commit 960a6b2

Browse files
start of flex stacker PVT cycling test
1 parent a25db4f commit 960a6b2

File tree

2 files changed

+67
-39
lines changed

2 files changed

+67
-39
lines changed

hardware-testing/hardware_testing/modules/flex_stacker_cycle_qc/__main__.py

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,60 +21,76 @@
2121
from opentrons.hardware_control.modules import FlexStacker
2222

2323
async def build_stacker_report(
24-
is_simulating: bool, port: str = ""
24+
is_simulating: bool, operator: str, port: str = "",
2525
) -> Tuple[CSVReport, FlexStacker]:
2626
"""Report setup for FLEX Stacker Cycle QC Test."""
2727
test_name = Path(__file__).parent.name.replace("_", "-")
28-
ui.print_title(test_name.upper())
29-
3028
stacker = await FlexStacker.build(port=port,
3129
usb_port=None,
3230
execution_manager=None,
33-
loop=asyncio.get_running_loop(),
31+
hw_control_loop=asyncio.get_running_loop(),
3432
simulating=is_simulating)
3533

3634

3735
report = build_report(test_name)
38-
report.set_operator(
39-
"simulating" if is_simulating else input("enter OPERATOR name: ")
40-
)
36+
report.set_operator("simulating" if is_simulating else operator)
4137
return report, stacker
4238

4339

4440
async def _main(cfg: TestConfig) -> None:
4541
# BUILD REPORT
46-
port = []
42+
ports = []
4743
for i in comports():
44+
print(i)
4845
if i.vid == STACKER_VID and i.pid == STACKER_PID:
49-
port.append(i.device)
50-
break
51-
assert port, "could not find connected FLEX Stacker"
52-
report, stacker = await build_stacker_report(cfg.simulate, port=port[0])
46+
ports.append(i.device)
47+
print(f"Found FLEX Stacker on {i.device}")
48+
assert ports, "could not find connected FLEX Stacker"
5349

5450
if not cfg.simulate:
5551
print("Stopping the robot server")
5652
subprocess.run(["systemctl stop opentrons-robot-server"], shell=True)
5753

58-
device_info = await stacker._driver.get_device_info()
59-
report.set_tag(device_info.sn if device_info.sn else "UNKNOWN")
54+
test_name = Path(__file__).parent.name.replace("_", "-")
55+
ui.print_title(test_name.upper())
56+
operator = "simulating" if cfg.simulate else input("enter OPERATOR name: ")
57+
58+
stackers = {}
59+
for p in ports:
60+
report, stacker = await build_stacker_report(cfg.simulate, operator=operator, port=p)
61+
device_sn = stacker.device_info['serial']
62+
report.set_tag(device_sn if device_sn else "UNKNOWN")
63+
stackers[device_sn] = (report, stacker)
6064

61-
# RUN TESTS
65+
# # RUN TESTS
6266
try:
6367
for section, test_run in cfg.tests.items():
6468
ui.print_title(section.value)
65-
await test_run(stacker, report, section.value)
69+
tasks = []
70+
for sn, (report, stacker) in stackers.items():
71+
tasks.append(test_run(stacker, report, section.value))
72+
await asyncio.gather(*tasks) # Run all tasks concurrently
6673
except Exception as e:
6774
ui.print_error(f"An error occurred: {e}")
6875

76+
# try:
77+
# for section, test_run in cfg.tests.items():
78+
# ui.print_title(section.value)
79+
# await test_run(stacker, report, section.value)
80+
# except Exception as e:
81+
# ui.print_error(f"An error occurred: {e}")
82+
83+
6984
# SAVE REPORT
7085
ui.print_title("DONE")
71-
report.save_to_disk()
72-
report.print_results()
86+
for sn, (report, stacker) in stackers.items():
87+
report.save_to_disk()
88+
report.print_results()
7389

7490
# Restart the robot server
75-
if not cfg.simulate:
76-
print("Starting the robot server")
77-
subprocess.run(["systemctl restart opentrons-robot-server &"], shell=True)
91+
# if not cfg.simulate:
92+
# print("Starting the robot server")
93+
# subprocess.run(["systemctl restart opentrons-robot-server &"], shell=True)
7894

7995

8096
if __name__ == "__main__":
Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Test Cycling."""
2-
from typing import List, Union
2+
from typing import List, Union, Tuple
33

44
from hardware_testing.data import ui
55
from hardware_testing.data.csv_report import (
@@ -9,34 +9,46 @@
99
CSVResult,
1010
)
1111

12-
from opentrons.drivers.flex_stacker.types import HardwareRevision
1312
from opentrons.hardware_control.modules import FlexStacker
1413

14+
NUM_CYCLES = 10
1515

1616
def build_csv_lines() -> List[Union[CSVLine, CSVLineRepeating]]:
1717
"""Build CSV Lines."""
1818
return [
19-
CSVLine("cycle", [CSVResult]),
19+
CSVLine("cycle", [int, CSVResult]),
2020
]
2121

22+
def print_cycle(stacker: FlexStacker, cycle: int, total_cycles: int) -> None:
23+
"""Print formater for cycle progress"""
24+
out_str = f"{stacker.device_info['serial']}: Cycle {cycle}/{total_cycles} Completed"
25+
ui.print_info(out_str)
2226

23-
# async def test_gcode(stacker: FlexStacker, report: CSVReport) -> None:
24-
# """Send and receive response for GCODE M115."""
25-
# success = True
26-
# info = await stacker._driver.get_device_info()
27-
# # TODO: update this with PVT/MP revisions
28-
# if info.hw != HardwareRevision.DVT:
29-
# ui.print_warning(f"Hardware Revision is {info.hw}, expected DVT")
30-
# report(
31-
# "CONNECTIVITY",
32-
# "usb-get-device-info",
33-
# [info.fw, info.hw, info.sn, CSVResult.from_bool(success)],
34-
# )
27+
async def test_cycles(stacker: FlexStacker) -> Tuple[bool, int]:
28+
"""Test Cycling Labware on Stacker"""
29+
cycles_completed = 0
30+
31+
for cycle in range(NUM_CYCLES):
32+
try:
33+
await stacker.dispense_labware(15)
34+
await stacker.store_labware(15)
35+
except Exception as e:
36+
ui.print_error(f"{stacker.device_info['serial']}: An error occurred: {e}")
37+
38+
cycles_completed += 1
39+
if (cycles_completed % 5 == 0) and (not cycles_completed==NUM_CYCLES):
40+
print_cycle(stacker, cycles_completed, NUM_CYCLES)
41+
42+
print_cycle(stacker, NUM_CYCLES, NUM_CYCLES)
43+
return (cycles_completed==NUM_CYCLES, cycles_completed)
3544

3645

3746

3847
async def run(stacker: FlexStacker, report: CSVReport, section: str) -> None:
3948
"""Run."""
40-
ui.print_header("Cycle Test")
41-
model = await stacker.get_model()
42-
ui.print_info(f"Model: {model}")
49+
ui.print_header(f"Cycle Test - {stacker.device_info['serial']}")
50+
51+
await stacker.home_all()
52+
cycle_result, cycles_completed = await test_cycles(stacker)
53+
54+
report(section, "cycle", [cycles_completed, CSVResult.from_bool(cycle_result)])

0 commit comments

Comments
 (0)