|
21 | 21 | from opentrons.hardware_control.modules import FlexStacker
|
22 | 22 |
|
23 | 23 | async def build_stacker_report(
|
24 |
| - is_simulating: bool, port: str = "" |
| 24 | + is_simulating: bool, operator: str, port: str = "", |
25 | 25 | ) -> Tuple[CSVReport, FlexStacker]:
|
26 | 26 | """Report setup for FLEX Stacker Cycle QC Test."""
|
27 | 27 | test_name = Path(__file__).parent.name.replace("_", "-")
|
28 |
| - ui.print_title(test_name.upper()) |
29 |
| - |
30 | 28 | stacker = await FlexStacker.build(port=port,
|
31 | 29 | usb_port=None,
|
32 | 30 | execution_manager=None,
|
33 |
| - loop=asyncio.get_running_loop(), |
| 31 | + hw_control_loop=asyncio.get_running_loop(), |
34 | 32 | simulating=is_simulating)
|
35 | 33 |
|
36 | 34 |
|
37 | 35 | 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) |
41 | 37 | return report, stacker
|
42 | 38 |
|
43 | 39 |
|
44 | 40 | async def _main(cfg: TestConfig) -> None:
|
45 | 41 | # BUILD REPORT
|
46 |
| - port = [] |
| 42 | + ports = [] |
47 | 43 | for i in comports():
|
| 44 | + print(i) |
48 | 45 | 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" |
53 | 49 |
|
54 | 50 | if not cfg.simulate:
|
55 | 51 | print("Stopping the robot server")
|
56 | 52 | subprocess.run(["systemctl stop opentrons-robot-server"], shell=True)
|
57 | 53 |
|
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) |
60 | 64 |
|
61 |
| - # RUN TESTS |
| 65 | + # # RUN TESTS |
62 | 66 | try:
|
63 | 67 | for section, test_run in cfg.tests.items():
|
64 | 68 | 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 |
66 | 73 | except Exception as e:
|
67 | 74 | ui.print_error(f"An error occurred: {e}")
|
68 | 75 |
|
| 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 | + |
69 | 84 | # SAVE REPORT
|
70 | 85 | 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() |
73 | 89 |
|
74 | 90 | # 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) |
78 | 94 |
|
79 | 95 |
|
80 | 96 | if __name__ == "__main__":
|
|
0 commit comments