Beispiel #1
0
    def test_register_measurement_windows(self):
        raw_card = dummy_modules.dummy_atsaverage.core.AlazarCard()
        card = AlazarCard(raw_card)

        self.assertIs(card.card, raw_card)

        card.register_mask_for_channel('A', 3, 'auto')
        card.register_mask_for_channel('B', 1, 'auto')

        card.default_config = dummy_modules.dummy_atsaverage.config.ScanlineConfiguration(
        )

        card.register_measurement_windows('empty', dict())

        begins = np.arange(100) * 176.5
        lengths = np.ones(100) * 10 * np.pi
        card.register_measurement_windows('otto', dict(A=(begins, lengths)))

        self.assertEqual(set(card._registered_programs.keys()),
                         {'empty', 'otto'})
        self.assertEqual(card._registered_programs['empty'].masks(lambda x: x),
                         [])

        [(result_begins, result_lengths)
         ] = card._registered_programs['otto'].masks(lambda _, b, l: (b, l))
        expected_begins = np.rint(begins / 10).astype(dtype=np.uint64)
        np.testing.assert_equal(result_begins, expected_begins)

        # pi ist genau 3
        np.testing.assert_equal(
            result_lengths if isinstance(result_lengths, np.ndarray) else
            result_lengths.as_ndarray(), 3)
Beispiel #2
0
    def test_arm_operation(self):
        raw_card = dummy_modules.dummy_atsaverage.core.AlazarCard()
        card = AlazarCard(raw_card)

        card.register_mask_for_channel('A', 3, 'auto')
        card.register_mask_for_channel('B', 1, 'auto')

        card.register_operations('otto', [])

        card.default_config = dummy_modules.dummy_atsaverage.config.ScanlineConfiguration(
        )

        with self.assertRaisesRegex(RuntimeError, 'No operations'):
            card.arm_program('otto')

        card.register_operations('otto', ['asd'])

        with self.assertRaisesRegex(RuntimeError, "No masks"):
            card.arm_program('otto')

        begins = np.arange(100) * 176.5
        lengths = np.ones(100) * 10 * np.pi
        card.register_measurement_windows('otto', dict(A=(begins, lengths)))

        card.default_config.totalRecordSize = 17

        with self.assertRaisesRegex(
                ValueError, "total record size is smaller than needed"):
            card.arm_program('otto')

        card.default_config.totalRecordSize = 0

        with mock.patch.object(
                card.card, 'applyConfiguration') as mock_applyConfiguration:
            with mock.patch.object(
                    card.card, 'startAcquisition') as mock_startAcquisition:
                card.arm_program('otto')

                mock_applyConfiguration.assert_called_once_with(
                    card.current_config, True)
                mock_startAcquisition.assert_called_once_with(1)

                mock_applyConfiguration.reset_mock()
                mock_startAcquisition.reset_mock()
                card.arm_program('otto')

                mock_applyConfiguration.assert_not_called()
                mock_startAcquisition.assert_called_once_with(1)