def get_colors(self) -> {Color, Color, Color}:

        first_digit = self.find_nth_digit(0)
        second_digit = self.find_nth_digit(1)
        multiplication_factor = self._find_multiplication_factor()

        return (
            Color.value_of_resistance_digit(first_digit),
            Color.value_of_resistance_digit(second_digit),
            Color.value_of_resistance_digit(multiplication_factor),
        )
    def _route_station_command(self):
        command: Message = self._communication_service.receive_object()
        topic = command.get_topic()

        if topic == Topic.START_STAGE:
            self._send_confirmation_to_station(Topic.START_STAGE, Stage.TRANSPORT_PUCK)

        elif topic == Topic.MOVEMENTS:
            self._move(command.get_payload())
            self._send_confirmation_to_station(Topic.MOVEMENTS, Stage.STAGE_COMPLETED)

        elif topic == Topic.ROTATION:
            self._rotate(command.get_payload())
            self._send_confirmation_to_station(Topic.ROTATION, Stage.STAGE_COMPLETED)

        elif topic == Topic.GRAB_PUCK:
            self._grab_puck(Color.value_of_resistance_digit(command.get_payload()))
            self._send_confirmation_to_station(Topic.GRAB_PUCK, Stage.STAGE_COMPLETED)

        elif topic == Topic.DROP_PUCK:
            self._drop_puck()
            self._gripper_service.elevate_gripper()
            self._send_confirmation_to_station(Topic.DROP_PUCK, Stage.STAGE_COMPLETED)

        elif topic == Topic.STAGE_COMPLETED:
            self._send_confirmation_to_station(
                Topic.STAGE_COMPLETED, Stage.TRANSPORT_PUCK
            )
            raise StageComplete
Exemplo n.º 3
0
    def test_givenNumberFour_whenGettingValueOfResistanceDigit_thenReturnYellow(
            self):
        single_digit = 4

        color = Color.value_of_resistance_digit(single_digit)

        self.assertEqual(color, Color.YELLOW)
Exemplo n.º 4
0
    def test_givenNumberEight_whenGettingValueOfResistanceDigit_thenReturnGrey(
            self):
        single_digit = 8

        color = Color.value_of_resistance_digit(single_digit)

        self.assertEqual(color, Color.GREY)
Exemplo n.º 5
0
    def route_station_command(self):
        command: Message = self._communication_service.receive_object()
        topic = command.get_topic()

        if topic == Topic.START_CYCLE:
            print("Stage started")
            self.send_confirmation_to_station(Topic.START_CYCLE, Stage.TRANSPORT_PUCK)

        elif topic == Topic.MOVEMENTS:
            print("Moving to puck")
            self.move(command.get_payload())

            print("Sending movement confirmation")
            grab_puck_it.send_confirmation_to_station(
                Topic.MOVEMENTS, Stage.STAGE_COMPLETED
            )

        elif topic == Topic.ROTATION:
            print("Rotating")
            self.rotate(command.get_payload())

            print("Sending rotation confirmation")
            grab_puck_it.send_confirmation_to_station(
                Topic.ROTATION, Stage.STAGE_COMPLETED
            )

        elif topic == Topic.GRAB_PUCK:
            print("Grabbing puck")
            self.grab_puck(Color.value_of_resistance_digit(command.get_payload()))

            print("Sending grab puck confirmation to station")
            grab_puck_it.send_confirmation_to_station(
                Topic.GRAB_PUCK, Stage.STAGE_COMPLETED
            )

        elif topic == Topic.DROP_PUCK:
            print("Dropping puck")
            self.drop_puck()

            print("Sending drop puck confirmation to station")
            grab_puck_it.send_confirmation_to_station(
                Topic.DROP_PUCK, Stage.STAGE_COMPLETED
            )

        elif topic == Topic.STAGE_COMPLETED:
            print("Stage completed")
            self.send_confirmation_to_station(
                Topic.STAGE_COMPLETED, Stage.TRANSPORT_PUCK
            )
            raise RuntimeError("Stage complete !")