Skip to content

Commit 322e142

Browse files
Updates to Stacker TOF data collection script (#19024)
# Overview made labware, test, and labware numbers arguments in the test to make collecting labware data easier. Commands like: `python3 -m hardware_testing.scripts.stacker_tof_data_collection -t PVT_STACKER -x 0 -z 1 -l armadillo-96-pcr ` are now possible to directly set the test name, number of x and z labware and type of labware ## Test Plan and Hands on Testing Tested and collected data on two stackers. ## Changelog - fixed bug where 2 stackers connected would write their values in both csv output files ## Review requests ## Risk assessment
1 parent 74c3aef commit 322e142

File tree

1 file changed

+57
-27
lines changed

1 file changed

+57
-27
lines changed

hardware-testing/hardware_testing/scripts/stacker_tof_data_collection.py

Lines changed: 57 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,37 @@ def build_arg_parser() -> argparse.ArgumentParser:
4040
default=1,
4141
)
4242
arg_parser.add_argument(
43-
"-n",
44-
"--labware_amount",
43+
"-x",
44+
"--labware_amount_x",
4545
type=int,
4646
required=False,
47-
help="Sets the labware amount",
47+
help="Sets the labware amount for the X a-lxis",
4848
default=0,
4949
)
50+
arg_parser.add_argument(
51+
"-z",
52+
"--labware_amount_z",
53+
type=int,
54+
required=False,
55+
help="Sets the labware amount for the Z axis",
56+
default=0,
57+
)
58+
arg_parser.add_argument(
59+
"-l",
60+
"--labware_name",
61+
type=str,
62+
required=False,
63+
help="Sets the name of labware",
64+
default="baseline",
65+
)
66+
arg_parser.add_argument(
67+
"-t",
68+
"--test_name",
69+
type=str,
70+
required=False,
71+
help="Sets the name of the test",
72+
default="tof_data_collection",
73+
)
5074
arg_parser.add_argument(
5175
"-s",
5276
"--simulate",
@@ -61,13 +85,23 @@ class Stacker_TOF_Data_Collection:
6185
"""Class to collect TOF Sensor data."""
6286

6387
def __init__(
64-
self, simulate: bool, samples: int, interval: int, labware_amount: int
88+
self,
89+
simulate: bool,
90+
samples: int,
91+
interval: int,
92+
labware_amount_x: int,
93+
labware_amount_z: int,
94+
labware_name: str,
95+
test_name: str,
6596
) -> None:
6697
"""Init."""
6798
self.simulate = simulate
6899
self.samples = samples
69100
self.interval = interval
70-
self.labware_amount = labware_amount
101+
self.labware_amount_x = labware_amount_x
102+
self.labware_amount_z = labware_amount_z
103+
self.labware_name = labware_name
104+
self.test_name = test_name
71105
self.api: Optional[OT3API] = None
72106
self.mount: Optional[OT3Mount] = None
73107
self.home: Optional[Point] = None
@@ -134,25 +168,14 @@ async def stacker_setup(self) -> None:
134168

135169
def file_setup(self) -> None:
136170
"""Setup where the test output is stored."""
137-
class_name = self.__class__.__name__
138-
self.test_name = class_name.lower()
139171
self.test_header = self.dict_keys_to_line(self.test_data)
140172
self.test_id = data.create_run_id()
141173
self.test_date = "run-" + datetime.utcnow().strftime("%y-%m-%d")
142-
self.test_path = data.create_folder_for_test_data(self.test_name)
143-
if self.labware_amount == 0:
144-
self.labware_name = "baseline"
145-
self.labware_amount_z = self.labware_amount
146-
elif self.labware_amount == 1:
147-
self.labware_name = "nest-96-pcr"
148-
self.labware_amount_z = self.labware_amount
149-
elif self.labware_amount == 3:
150-
self.labware_name = "tiprack"
151-
self.labware_amount = 1
152-
self.labware_amount_z = 3
174+
class_name = self.__class__.__name__
175+
self.test_path = data.create_folder_for_test_data(class_name.lower())
153176
for stacker in self.stackers:
154177
self.test_tag = (
155-
f"labx{self.labware_amount}_labz{self.labware_amount_z}_{stacker}"
178+
f"labx{self.labware_amount_x}_labz{self.labware_amount_z}_{stacker}"
156179
)
157180
test_file = data.create_file_name(
158181
self.labware_name, self.test_id, self.test_tag
@@ -203,7 +226,7 @@ async def read_stacker_tof(self) -> None:
203226
test_data["Stacker_SN"] = self.stackers[i]
204227
test_data["Axis"] = str(axis.lower())
205228
test_data["Platform_Position"] = pos.lower()
206-
test_data["Labware_Num_X"] = str(self.labware_amount)
229+
test_data["Labware_Num_X"] = str(self.labware_amount_x)
207230
test_data["Labware_Num_Z"] = str(self.labware_amount_z)
208231
test_data["Sample"] = str(sample)
209232
test_data["Zone"] = str(zone)
@@ -214,12 +237,13 @@ async def read_stacker_tof(self) -> None:
214237
# Update the csv with new values
215238
test_data_str = self.dict_values_to_line(test_data)
216239
for test_file in self.test_files:
217-
data.append_data_to_file(
218-
test_name=self.test_name,
219-
run_id=self.test_date,
220-
file_name=test_file,
221-
data=test_data_str,
222-
)
240+
if self.stackers[i] in test_file:
241+
data.append_data_to_file(
242+
test_name=self.test_name,
243+
run_id=self.test_date,
244+
file_name=test_file,
245+
data=test_data_str,
246+
)
223247
time.sleep(self.interval)
224248
print("")
225249

@@ -255,6 +279,12 @@ async def run(self) -> None:
255279
arg_parser = build_arg_parser()
256280
args = arg_parser.parse_args()
257281
test = Stacker_TOF_Data_Collection(
258-
args.simulate, args.samples, args.interval, args.labware_amount
282+
args.simulate,
283+
args.samples,
284+
args.interval,
285+
args.labware_amount_x,
286+
args.labware_amount_z,
287+
args.labware_name,
288+
args.test_name,
259289
)
260290
asyncio.run(test.run())

0 commit comments

Comments
 (0)