File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
src/opentrons/drivers/flex_stacker
tests/opentrons/drivers/flex_stacker Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,15 @@ def parse_installation_detected(cls, response: str) -> bool:
128
128
)
129
129
return bool (int (match .group (1 )))
130
130
131
+ @classmethod
132
+ def parse_estop_engaged (cls , response : str ) -> bool :
133
+ """Parse estop enagaged."""
134
+ _RE = re .compile (rf"^{ GCODE .GET_ESTOP_ENGAGED } E:(\d)$" )
135
+ match = _RE .match (response )
136
+ if not match :
137
+ raise ValueError (f"Incorrect Response for Estop engaged: { response } " )
138
+ return bool (int (match .group (1 )))
139
+
131
140
@classmethod
132
141
def parse_move_params (cls , response : str ) -> MoveParams :
133
142
"""Parse move params."""
@@ -652,6 +661,16 @@ async def get_installation_detected(self) -> bool:
652
661
)
653
662
return self .parse_installation_detected (response )
654
663
664
+ async def get_estop_engaged (self ) -> bool :
665
+ """Get whether or not the estop was detected by this stacker.
666
+
667
+ :return: True if the estop is trigguered, False otherwise
668
+ """
669
+ response = await self ._connection .send_command (
670
+ GCODE .GET_ESTOP_ENGAGED .build_command ()
671
+ )
672
+ return self .parse_estop_engaged (response )
673
+
655
674
async def move_in_mm (
656
675
self , axis : StackerAxis , distance : float , params : MoveParams | None = None
657
676
) -> MoveResult :
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ class GCODE(str, Enum):
12
12
HOME_AXIS = "G28"
13
13
STOP_MOTORS = "M0"
14
14
ENABLE_MOTORS = "M17"
15
+ GET_ESTOP_ENGAGED = "M112"
15
16
GET_RESET_REASON = "M114"
16
17
DEVICE_INFO = "M115"
17
18
GET_LIMIT_SWITCH = "M119"
Original file line number Diff line number Diff line change @@ -750,3 +750,29 @@ async def test_set_tof_configuration(
750
750
)
751
751
connection .send_command .assert_any_call (set_config )
752
752
connection .reset_mock ()
753
+
754
+
755
+ async def test_get_estop_engaged (
756
+ subject : FlexStackerDriver , connection : AsyncMock
757
+ ) -> None :
758
+ """It should send a get estop command return boolean."""
759
+ connection .send_command .return_value = "M112 E:1"
760
+ response = await subject .get_estop_engaged ()
761
+ assert response
762
+
763
+ estop = types .GCODE .GET_ESTOP_ENGAGED .build_command ()
764
+ connection .send_command .assert_any_call (estop )
765
+ connection .reset_mock ()
766
+
767
+
768
+ async def test_get_install_detected (
769
+ subject : FlexStackerDriver , connection : AsyncMock
770
+ ) -> None :
771
+ """It should send a get install detected command and return boolean."""
772
+ connection .send_command .return_value = "M123 I:1"
773
+ response = await subject .get_installation_detected ()
774
+ assert response
775
+
776
+ install_detect = types .GCODE .GET_INSTALL_DETECTED .build_command ()
777
+ connection .send_command .assert_any_call (install_detect )
778
+ connection .reset_mock ()
You can’t perform that action at this time.
0 commit comments