diff --git a/SubjuGator/drivers/sub_actuator_board/sub_actuator_board/__init__.py b/SubjuGator/drivers/sub_actuator_board/sub_actuator_board/__init__.py index 8d260d68e..30ae9ac9d 100644 --- a/SubjuGator/drivers/sub_actuator_board/sub_actuator_board/__init__.py +++ b/SubjuGator/drivers/sub_actuator_board/sub_actuator_board/__init__.py @@ -1,5 +1,6 @@ from .handle import ActuatorBoard from .packets import ( + ActuatorPacketId, ActuatorPollRequestPacket, ActuatorPollResponsePacket, ActuatorSetPacket, diff --git a/SubjuGator/drivers/sub_actuator_board/sub_actuator_board/packets.py b/SubjuGator/drivers/sub_actuator_board/sub_actuator_board/packets.py index 9a146f363..2d7f50314 100644 --- a/SubjuGator/drivers/sub_actuator_board/sub_actuator_board/packets.py +++ b/SubjuGator/drivers/sub_actuator_board/sub_actuator_board/packets.py @@ -1,20 +1,34 @@ from dataclasses import dataclass +from enum import IntEnum from mil_usb_to_can.sub9 import Packet +class ActuatorPacketId(IntEnum): + """ + Enumerator representing each controllable actuator. + """ + + #: The dropper actuator. + DROPPER = 0 + #: The torpedo launcher actuator. + TORPEDO_LAUNCHER = 1 + #: The ball drop actuator. Only one actuator is used for both balls. + BALL_DROP = 2 + + @dataclass class ActuatorSetPacket(Packet, msg_id=0x03, subclass_id=0x00, payload_format="BB"): """ Packet used by the actuator board to set a specific valve. Attributes: - address (int): The actuator ID to set. + address (ActuatorPacketId): The actuator ID to set. open (bool): Whether to open the specified actuator. ``True`` requests opening, ``False`` requests closing. """ - address: int + address: ActuatorPacketId open: bool @@ -29,8 +43,6 @@ class ActuatorPollRequestPacket( Packet used by the actuator board to request the status of all valves. """ - pass - @dataclass class ActuatorPollResponsePacket( diff --git a/SubjuGator/drivers/sub_actuator_board/test/simulated_board_test.py b/SubjuGator/drivers/sub_actuator_board/test/simulated_board_test.py index 8c4665f09..014bd090c 100755 --- a/SubjuGator/drivers/sub_actuator_board/test/simulated_board_test.py +++ b/SubjuGator/drivers/sub_actuator_board/test/simulated_board_test.py @@ -28,11 +28,11 @@ def test_correct_response(self): self.assertFalse(self.get_srv(GetValveRequest(0)).opened) self.assertTrue(self.set_srv(SetValveRequest(0, False)).success) self.assertFalse(self.get_srv(GetValveRequest(0)).opened) - self.assertTrue(self.set_srv(SetValveRequest(3, True)).success) - self.assertTrue(self.get_srv(GetValveRequest(3)).opened) + self.assertTrue(self.set_srv(SetValveRequest(1, True)).success) + self.assertTrue(self.get_srv(GetValveRequest(1)).opened) self.assertFalse(self.get_srv(GetValveRequest(0)).opened) - self.assertTrue(self.set_srv(SetValveRequest(4, False)).success) - self.assertFalse(self.get_srv(GetValveRequest(4)).opened) + self.assertTrue(self.set_srv(SetValveRequest(2, False)).success) + self.assertFalse(self.get_srv(GetValveRequest(2)).opened) self.assertFalse(self.get_srv(GetValveRequest(0)).opened) diff --git a/docs/subjugator/reference.rst b/docs/subjugator/reference.rst index 2ed8e1296..6d0134f4f 100644 --- a/docs/subjugator/reference.rst +++ b/docs/subjugator/reference.rst @@ -100,6 +100,11 @@ ActuatorBoardSimulation .. autoclass:: sub_actuator_board.ActuatorBoardSimulation :members: +ActuatorPacketId +^^^^^^^^^^^^^^^^ +.. autoclass:: sub_actuator_board.ActuatorPacketId + :members: + ActuatorSetPacket ^^^^^^^^^^^^^^^^^ .. attributetable:: sub_actuator_board.ActuatorSetPacket