def construct_debug_connection(self):
        return {
            'HOLLYBURN_BODY_FLARE_CONNECTION': DebugConnection('HOLLYBURN_BODY_FLARE_RADIO_ADDRESS',
                                                           DEVICE_TYPE_TO_ID[DeviceType.HOLLYBURN_BODY_FLARE],
                                                           generate_radio_packets=True),

            'HOLLYBURN_NOSE_FLARE_CONNECTION': DebugConnection('HOLLYBURN_NOSE_FLARE_RADIO_ADDRESS',
                                                           DEVICE_TYPE_TO_ID[DeviceType.HOLLYBURN_NOSE_FLARE],
                                                           generate_radio_packets=True),
        }
Ejemplo n.º 2
0
 def construct_debug_connection(self):
     return {
         'TANTALUS_STAGE_1_CONNECTION':
         DebugConnection(
             'TANTALUS_STAGE_1_RADIO_ADDRESS',
             DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_1_FLARE],
             generate_radio_packets=True),
         'TANTALUS_STAGE_2_CONNECTION':
         DebugConnection(
             'TANTALUS_STAGE_2_RADIO_ADDRESS',
             DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_2_FLARE],
             generate_radio_packets=True),
     }
 def construct_debug_connection(self):
     return {
         'CO_PILOT_CONNECTION':
         DebugConnection('CO_PILOT_RADIO_ADDRESS',
                         DEVICE_TYPE_TO_ID[DeviceType.CO_PILOT_FLARE],
                         generate_radio_packets=True),
     }
Ejemplo n.º 4
0
def single_connection_tantalus(test_app):
    yield test_app(TantalusProfile(), {
        'DEBUG_CONNECTION':
        DebugConnection('TANTALUS_STAGE_1_ADDRESS',
                        DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_1_FLARE],
                        generate_radio_packets=False)
    },
                   num_devices=1)
Ejemplo n.º 5
0
def test_multi_connection_commands(qtbot, test_app):
    con_a = DebugConnection(
        'TANTALUS_STAGE_1_ADDRESS',
        DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_1_FLARE],
        generate_radio_packets=False)
    con_b = DebugConnection(
        'TANTALUS_STAGE_2_ADDRESS',
        DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_2_FLARE],
        generate_radio_packets=False)

    con_a.send = MagicMock()
    con_b.send = MagicMock()

    snapshot = get_event_stats_snapshot()
    app = test_app(TantalusProfile(), {
        'DEBUG_CONNECTION_1': con_a,
        'DEBUG_CONNECTION_2': con_b
    },
                   num_devices=2)

    # Fake some other device on same connection
    con_a.device_address = 'OTHER_ADDRESS'
    sample_version = '1234567890123456789012345678901234567890'
    con_a.receive(
        radio_packets.config(0xFFFFFFFF, True,
                             DEVICE_TYPE_TO_ID[DeviceType.CO_PILOT_FLARE],
                             sample_version))

    assert DEVICE_REGISTERED_EVENT.wait(snapshot, num_expected=3) == 3

    # Send commands to each and assert called

    snapshot = get_event_stats_snapshot()
    app.send_command("tantalus_stage_1_flare.arm")
    COMMAND_SENT_EVENT.wait(snapshot)
    con_a.send.assert_called_with('TANTALUS_STAGE_1_ADDRESS', ANY)

    snapshot = get_event_stats_snapshot()
    app.send_command("tantalus_stage_2_flare.arm")
    COMMAND_SENT_EVENT.wait(snapshot)
    con_b.send.assert_called_with('TANTALUS_STAGE_2_ADDRESS', ANY)

    snapshot = get_event_stats_snapshot()
    app.send_command("co_pilot_flare.arm")
    COMMAND_SENT_EVENT.wait(snapshot)
    con_a.send.assert_called_with('OTHER_ADDRESS', ANY)
Ejemplo n.º 6
0
def test_register_after_data(qtbot, test_app):
    con = DebugConnection('TANTALUS_STAGE_1_ADDRESS',
                          DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_1_FLARE],
                          generate_radio_packets=False)
    app = test_app(TantalusProfile(), {'DEBUG_CONNECTION': con}, num_devices=1)
    snapshot = get_event_stats_snapshot()

    # Fake stage 2 on same connection
    con.device_address = 'TANTALUS_STAGE_2_ADDRESS'
    con.receive(
        radio_packets.single_sensor(0xFFFFFFFF, SubpacketIds.PRESSURE, 1))
    assert BUNDLE_ADDED_EVENT.wait(snapshot) == 1

    # Cause device to register
    con.receive(
        radio_packets.config(
            0xFFFFFFFF, True,
            DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_2_FLARE],
            REQUIRED_FLARE))
    assert DEVICE_REGISTERED_EVENT.wait(snapshot) == 1

    assert app.rocket_data.last_value_by_device(
        DeviceType.TANTALUS_STAGE_2_FLARE, DataEntryIds.PRESSURE) == 1
Ejemplo n.º 7
0
def test_multi_connection_receive(qtbot, test_app):
    con_a = DebugConnection(
        'TANTALUS_STAGE_1_ADDRESS',
        DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_1_FLARE],
        generate_radio_packets=False)
    con_b = DebugConnection(
        'TANTALUS_STAGE_2_ADDRESS',
        DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_2_FLARE],
        generate_radio_packets=False)
    snapshot = get_event_stats_snapshot()
    app = test_app(TantalusProfile(), {
        'DEBUG_CONNECTION_1': con_a,
        'DEBUG_CONNECTION_2': con_b
    },
                   num_devices=2)

    con_a.receive(
        radio_packets.single_sensor(0xFFFFFFFF, SubpacketIds.PRESSURE, 1))
    con_b.receive(
        radio_packets.single_sensor(0xFFFFFFFF, SubpacketIds.PRESSURE, 2))

    # Fake some other device on same connection
    con_a.device_address = 'OTHER_ADDRESS'
    sample_version = '1234567890123456789012345678901234567890'
    con_a.receive(
        radio_packets.config(0xFFFFFFFF, True,
                             DEVICE_TYPE_TO_ID[DeviceType.CO_PILOT_FLARE],
                             sample_version))
    con_a.receive(
        radio_packets.single_sensor(0xFFFFFFFF, SubpacketIds.PRESSURE, 3))

    assert DEVICE_REGISTERED_EVENT.wait(snapshot, num_expected=3) == 3
    assert BUNDLE_ADDED_EVENT.wait(snapshot, num_expected=6) == 6

    assert app.rocket_data.last_value_by_device(
        DeviceType.TANTALUS_STAGE_1_FLARE, DataEntryIds.PRESSURE) == 1
    assert app.rocket_data.last_value_by_device(
        DeviceType.TANTALUS_STAGE_2_FLARE, DataEntryIds.PRESSURE) == 2
    assert app.rocket_data.last_value_by_device(DeviceType.CO_PILOT_FLARE,
                                                DataEntryIds.PRESSURE) == 3