Beispiel #1
0
    def test_probe_sets_tx_for_two_cards_complete_apertures(self):
        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=128),
            ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=128)
        ]

        # Run.
        probe = self._create_probe(hw_subapertures, 0)
        tx_aperture = Subaperture(0, 256)
        tx_delays = list(range(0, 256))
        carrier_frequency = 14e6
        n_periods = 1
        probe.transmit_and_record(tx_aperture=tx_aperture,
                                  tx_delays=tx_delays,
                                  carrier_frequency=carrier_frequency,
                                  n_tx_periods=n_periods)
        # Verify.
        self.assertEqual(Subaperture(0, 128),
                         hw_subapertures[0].card.tx_aperture)
        self.assertEqual(Subaperture(0, 128),
                         hw_subapertures[1].card.tx_aperture)
        self._assert_card_delays(
            [list(range(0, 128)), list(range(128, 256))], hw_subapertures)
        for hws in hw_subapertures:
            self.assertEqual(carrier_frequency, hws.card.tx_frequency)
            self.assertEqual(n_periods, hws.card.tx_periods)
Beispiel #2
0
    def test_single_element_aperture_card2(self):
        # Two cards, single element aperture near left bofder of the second card aperture
        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=128),
            ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=64)
        ]

        # Run.
        probe = self._create_probe(hw_subapertures, 0)
        tx_aperture = Subaperture(128, 1)
        tx_delays = [1]
        carrier_frequency = 8e6
        n_periods = 1
        probe.transmit_and_record(tx_aperture=tx_aperture,
                                  tx_delays=tx_delays,
                                  carrier_frequency=carrier_frequency,
                                  n_tx_periods=n_periods)
        # Verify.
        self.assertIsNone(hw_subapertures[0].card.tx_aperture)
        self.assertEqual(Subaperture(0, 1),
                         hw_subapertures[1].card.tx_aperture)
        self._assert_card_delays([[0.0] * 128, [1] + [0.0] * 127],
                                 hw_subapertures)
        self.assertEqual(carrier_frequency,
                         hw_subapertures[1].card.tx_frequency)
        self.assertEqual(n_periods, hw_subapertures[1].card.tx_periods)
Beispiel #3
0
    def test_probe_sets_tx_for_single_card_hw_offset(self):
        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=34,
                                     size=32)
        ]

        # Run.
        probe = self._create_probe(hw_subapertures, 0)
        tx_aperture = Subaperture(0, 16)
        tx_delays = list(range(0, 16))
        carrier_frequency = 5e6
        n_periods = 1
        probe.transmit_and_record(tx_aperture=tx_aperture,
                                  tx_delays=tx_delays,
                                  carrier_frequency=carrier_frequency,
                                  n_tx_periods=n_periods)
        # Verify.
        self.assertEqual(Subaperture(34, 16),
                         hw_subapertures[0].card.tx_aperture)
        self.assertEqual(carrier_frequency,
                         hw_subapertures[0].card.tx_frequency)
        self.assertEqual(n_periods, hw_subapertures[0].card.tx_periods)
        self._assert_card_delays([
            34 * [0.0] + tx_delays + [0.0] * (128 - (34 + len(tx_delays))),
        ], hw_subapertures)
Beispiel #4
0
 def test_probe_sets_tx_for_single_card_hw_offset(self):
     # Set.
     hw_subapertures = [
         ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=34,
                                  size=32)
     ]
     # Run.
     probe = self._create_probe(hw_subapertures, 0)
     tx_aperture = Subaperture(0, 16)
     probe.set_tx_aperture(tx_aperture=tx_aperture)
     # Verify.
     self.assertEqual(Subaperture(34, 16),
                      hw_subapertures[0].card.tx_aperture)
Beispiel #5
0
    def test_probe_sets_tx_for_single_card(self):
        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(
                card=Us4OEMCardMock(0, n_rx_channels=32, n_tx_channels=128),
                origin=0,
                size=32  # Determines the size of the probe's aperture.
            )
        ]
        # Run.
        probe = self._create_probe(hw_subapertures, 0)
        tx_aperture = Subaperture(0, 32)
        tx_delays = list(range(0, 32))
        carrier_frequency = 5e6
        n_periods = 1
        probe.transmit_and_record(tx_aperture=tx_aperture,
                                  tx_delays=tx_delays,
                                  carrier_frequency=carrier_frequency,
                                  n_tx_periods=n_periods)
        # Verify.
        self.assertEqual(tx_aperture, hw_subapertures[0].card.tx_aperture)
        self.assertEqual(carrier_frequency,
                         hw_subapertures[0].card.tx_frequency)
        self.assertEqual(n_periods, hw_subapertures[0].card.tx_periods)

        self._assert_card_delays([tx_delays + [0.0] * 96], hw_subapertures)
Beispiel #6
0
    def test_probe_sets_tx_for_two_cards_only_second_card_aperture(self):
        # Two cards, tx aperture only on the second card

        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=128),
            ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=64)
        ]

        # Run.
        probe = self._create_probe(hw_subapertures, 0)
        tx_aperture = Subaperture(130, 32)
        tx_delays = list(range(0, 32))
        carrier_frequency = 8e6
        n_periods = 1
        probe.transmit_and_record(tx_aperture=tx_aperture,
                                  tx_delays=tx_delays,
                                  carrier_frequency=carrier_frequency,
                                  n_tx_periods=n_periods)
        # Verify.
        self.assertEqual(Subaperture(2, 32),
                         hw_subapertures[1].card.tx_aperture)
        self.assertIsNone(hw_subapertures[0].card.tx_aperture)
        self._assert_card_delays([
            [0.0] * 128,
            [0.0] * 2 + list(range(0, 32)) + [0.0] * (128 -
                                                      (2 + len(tx_delays))),
        ], hw_subapertures)
        self.assertEqual(carrier_frequency,
                         hw_subapertures[1].card.tx_frequency)
        self.assertEqual(n_periods, hw_subapertures[1].card.tx_periods)
Beispiel #7
0
    def test_probe_sets_tx_apeture_two_cards_second_hw_offset(self):
        # Two cards, second one's aperture starts at origin > 0
        # Set.
        hw_subapertures = [
            ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=0,
                                     size=128),
            ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                         n_rx_channels=32,
                                                         n_tx_channels=128),
                                     origin=14,
                                     size=64)
        ]

        # Run.
        probe = self._create_probe(hw_subapertures, 0)
        tx_aperture = Subaperture(0, 192)
        tx_delays = list(range(0, 192))
        carrier_frequency = 8e6
        n_periods = 1
        probe.transmit_and_record(tx_aperture=tx_aperture,
                                  tx_delays=tx_delays,
                                  carrier_frequency=carrier_frequency,
                                  n_tx_periods=n_periods)
        # Verify.
        self.assertEqual(Subaperture(0, 128),
                         hw_subapertures[0].card.tx_aperture)
        self.assertEqual(Subaperture(14, 64),
                         hw_subapertures[1].card.tx_aperture)
        self._assert_card_delays([
            list(range(0, 128)),
            [0.0] * 14 + list(range(128, 192)) + [0.0] * 50
        ], hw_subapertures)
        for hws in hw_subapertures:
            self.assertEqual(carrier_frequency, hws.card.tx_frequency)
            self.assertEqual(n_periods, hws.card.tx_periods)
Beispiel #8
0
 def test_single_element_aperture_card1(self):
     # Two cards, single element aperture near right border of the first card aperture
     # Set.
     hw_subapertures = [
         ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=128),
         ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=64)
     ]
     # Run.
     probe = self._create_probe(hw_subapertures, 0)
     tx_aperture = Subaperture(127, 1)
     probe.set_tx_aperture(tx_aperture=tx_aperture)
     # Verify.
     self.assertEqual(Subaperture(127, 1),
                      hw_subapertures[0].card.tx_aperture)
     self.assertIsNone(hw_subapertures[1].card.tx_aperture)
Beispiel #9
0
 def test_probe_sets_tx_for_two_cards_only_first_card_aperture(self):
     # Two cards, tx aperture only on the first card
     # Set.
     hw_subapertures = [
         ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=128),
         ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=64)
     ]
     # Run.
     probe = self._create_probe(hw_subapertures, 0)
     tx_aperture = Subaperture(16, 64)
     probe.set_tx_aperture(tx_aperture=tx_aperture)
     # Verify.
     self.assertEqual(Subaperture(16, 64),
                      hw_subapertures[0].card.tx_aperture)
     self.assertIsNone(hw_subapertures[1].card.tx_aperture)
Beispiel #10
0
 def test_probe_sets_tx_for_two_cards_complete_apertures(self):
     # Set.
     hw_subapertures = [
         ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=128),
         ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=128)
     ]
     # Run.
     probe = self._create_probe(hw_subapertures, 0)
     tx_aperture = Subaperture(0, 256)
     probe.set_tx_aperture(tx_aperture=tx_aperture)
     # Verify.
     self.assertEqual(Subaperture(0, 128),
                      hw_subapertures[0].card.tx_aperture)
     self.assertEqual(Subaperture(0, 128),
                      hw_subapertures[1].card.tx_aperture)
Beispiel #11
0
 def test_probe_sets_tx_apeture_two_cards_second_hw_offset(self):
     # Two cards, second one's aperture starts at origin > 0
     # Set.
     hw_subapertures = [
         ProbeHardwareSubaperture(card=Us4OEMCardMock(0,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=0,
                                  size=128),
         ProbeHardwareSubaperture(card=Us4OEMCardMock(1,
                                                      n_rx_channels=32,
                                                      n_tx_channels=128),
                                  origin=14,
                                  size=64)
     ]
     # Run.
     probe = self._create_probe(hw_subapertures, 0)
     tx_aperture = Subaperture(0, 192)
     probe.set_tx_aperture(tx_aperture=tx_aperture)
     # Verify.
     self.assertEqual(Subaperture(0, 128),
                      hw_subapertures[0].card.tx_aperture)
     self.assertEqual(Subaperture(14, 64),
                      hw_subapertures[1].card.tx_aperture)
Beispiel #12
0
 def test_probe_sets_tx_for_single_card(self):
     # Set.
     hw_subapertures = [
         ProbeHardwareSubaperture(
             card=Us4OEMCardMock(0, n_rx_channels=32, n_tx_channels=128),
             origin=0,
             size=32  # Determines the size of the probe's aperture.
         )
     ]
     # Run.
     probe = self._create_probe(hw_subapertures, 0)
     tx_aperture = Subaperture(0, 32)
     probe.set_tx_aperture(tx_aperture=tx_aperture)
     # Verify.
     self.assertEqual(tx_aperture, hw_subapertures[0].card.tx_aperture)
Beispiel #13
0
 def set_rx_aperture(self, origin, size):
     if self.mock_data is not None:
         self.rx_apertures.append(Subaperture(origin, size))
Beispiel #14
0
 def set_tx_aperture(self, origin, size):
     self.tx_aperture = Subaperture(origin, size)