1
1
"""Test TOF Sensor Functional."""
2
2
3
3
from typing import List , Union
4
+
4
5
from hardware_testing .data import ui
5
6
from hardware_testing .data .csv_report import (
6
7
CSVReport ,
11
12
from hardware_testing .modules .flex_stacker_dvt_qc .utils import labware_detected
12
13
13
14
from .driver import FlexStackerInterface as FlexStacker
15
+ from .utils import NUMBER_OF_BINS , NUMBER_OF_ZONES
14
16
from opentrons .drivers .flex_stacker .types import (
15
17
Direction ,
16
18
StackerAxis ,
@@ -59,6 +61,7 @@ async def test_tof_sensors_labware_detection(
59
61
"""Test that we can detect labware with the TOF sensor."""
60
62
open = not await stacker ._driver .get_hopper_door_closed ()
61
63
if open :
64
+ print ("Failed: Make sure to close the stacker door." )
62
65
report (
63
66
section ,
64
67
f"tof-{ sensor .name } -histogram-{ labware } " ,
@@ -72,19 +75,19 @@ async def test_tof_sensors_labware_detection(
72
75
return
73
76
74
77
print (f"Getting histogram for { sensor } ." )
75
- bins = [40 , 80 ]
76
- zones = [0 , 1 , 2 , 3 ]
77
- status = await stacker ._driver .get_tof_sensor_status (sensor )
78
- print (status )
78
+ bins = list (range (NUMBER_OF_BINS ))
79
+ zones = list (range (NUMBER_OF_ZONES ))
79
80
histogram = await stacker ._driver .get_tof_histogram (sensor )
80
- detected = not labware_detected (histogram .bins , sensor , bins , zones )
81
+ diff = labware_detected (histogram .bins , sensor , bins , zones )
82
+ labware_expected = labware != "empty"
83
+ result = labware_expected == bool (diff )
81
84
report (
82
85
section ,
83
86
f"tof-{ sensor .name } -histogram-{ labware } " ,
84
87
[
85
- detected ,
88
+ result ,
86
89
"HISTOGRAM" ,
87
- CSVResult .from_bool (detected ),
90
+ CSVResult .from_bool (result ),
88
91
histogram .bins ,
89
92
],
90
93
)
@@ -102,28 +105,32 @@ async def run(stacker: FlexStacker, report: CSVReport, section: str) -> None:
102
105
await stacker .home_axis (StackerAxis .Z , Direction .RETRACT )
103
106
104
107
print ("Test that we have no labware on the X" )
105
- ui .get_user_ready ("Make sure there is no labware on the stacker gripper position." )
108
+ ui .get_user_ready ("Make sure there is no labware on the stacker gripper position" )
109
+ await stacker .home_axis (StackerAxis .X , Direction .RETRACT )
106
110
await test_tof_sensors_labware_detection (
107
111
stacker , report , section , TOFSensor .X , "empty"
108
112
)
109
113
110
- print ("Test that we detect tiprack on the X" )
111
- ui .get_user_ready ("Add 1 tiprack to the stacker X." )
114
+ print ("Test that we detect tiprack on the X home position" )
115
+ await stacker .home_axis (StackerAxis .X , Direction .EXTEND )
116
+ ui .get_user_ready ("Add 1 tiprack to the stacker X" )
117
+ await stacker .home_axis (StackerAxis .X , Direction .RETRACT )
112
118
await test_tof_sensors_labware_detection (
113
119
stacker , report , section , TOFSensor .X , "tiprack"
114
120
)
121
+ await stacker .home_axis (StackerAxis .X , Direction .EXTEND )
115
122
116
123
print ("Test that we have no labware on the Z" )
117
124
ui .get_user_ready (
118
- "Make sure there is no labware in the stacker and close the hopper door. "
125
+ "Make sure there is no labware in the stacker and close the hopper door"
119
126
)
120
127
await stacker .close_latch ()
121
128
await test_tof_sensors_labware_detection (
122
129
stacker , report , section , TOFSensor .Z , "empty"
123
130
)
124
131
125
132
print ("Test that we detect tiprack on the Z" )
126
- ui .get_user_ready ("Add 1 tiprack to the stacker Z and close the hopper door. " )
133
+ ui .get_user_ready ("Add 1 tiprack to the stacker Z and close the hopper door" )
127
134
await test_tof_sensors_labware_detection (
128
135
stacker , report , section , TOFSensor .Z , "tiprack"
129
136
)
0 commit comments