From 7ebe2692b210bffbbf13bb4cbcd9f9cea9880a2d Mon Sep 17 00:00:00 2001 From: crnbaker Date: Mon, 8 Jan 2024 14:42:39 +0000 Subject: [PATCH] #26 - tests passing with super() --- src/example_scripts/continuous_averaging_fifo_mode.py | 1 + src/spectrumdevice/devices/mocks/mock_waveform_source.py | 4 ++-- src/tests/configuration.py | 4 ++-- src/tests/test_integration.py | 6 +++++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/example_scripts/continuous_averaging_fifo_mode.py b/src/example_scripts/continuous_averaging_fifo_mode.py index b1a937a..305c64c 100644 --- a/src/example_scripts/continuous_averaging_fifo_mode.py +++ b/src/example_scripts/continuous_averaging_fifo_mode.py @@ -73,6 +73,7 @@ def continuous_averaging_multi_fifo_example( # Retrieve streamed waveform data until desired time has elapsed measurements_list = [] while (monotonic() - start_time) < acquisition_duration_in_seconds: + print(f"Asking for waveforms at {monotonic() - start_time}") measurements_list += [ Measurement(waveforms=frame, timestamp=card.get_timestamp()) for frame in card.get_waveforms() ] diff --git a/src/spectrumdevice/devices/mocks/mock_waveform_source.py b/src/spectrumdevice/devices/mocks/mock_waveform_source.py index dc9c954..7c74af1 100644 --- a/src/spectrumdevice/devices/mocks/mock_waveform_source.py +++ b/src/spectrumdevice/devices/mocks/mock_waveform_source.py @@ -132,9 +132,9 @@ def mock_waveform_source_factory( param_dict: Dict[int, int], notify_size_in_pages: float = 0, ) -> MockWaveformSource: - if acquisition_mode == AcquisitionMode.SPC_REC_FIFO_MULTI: + if acquisition_mode in (AcquisitionMode.SPC_REC_FIFO_MULTI, AcquisitionMode.SPC_REC_FIFO_AVERAGE): return MultiFIFOModeMockWaveformSource(param_dict, notify_size_in_pages) - elif AcquisitionMode.SPC_REC_STD_SINGLE: + elif acquisition_mode == AcquisitionMode.SPC_REC_STD_SINGLE: return SingleModeMockWaveformSource(param_dict) else: raise NotImplementedError(f"Mock waveform source not yet implemented for {acquisition_mode} acquisition mode.") diff --git a/src/tests/configuration.py b/src/tests/configuration.py index e6050ff..a70fcad 100644 --- a/src/tests/configuration.py +++ b/src/tests/configuration.py @@ -12,8 +12,8 @@ class SpectrumTestMode(Enum): # Set to TestMode.MOCK_HARDWARE for software-only testing, even if Spectrum drivers are found on the system # Set to TestMode.REAL_HARDWARE to run tests on a real hardware device as configured below. -SINGLE_CARD_TEST_MODE = SpectrumTestMode.MOCK_HARDWARE -STAR_HUB_TEST_MODE = SpectrumTestMode.MOCK_HARDWARE +SINGLE_CARD_TEST_MODE = SpectrumTestMode.REAL_HARDWARE +STAR_HUB_TEST_MODE = SpectrumTestMode.REAL_HARDWARE # Set IP address of real spectrum device (for use if TestMode.REAL_HARDWARE is set above). Set to None to run tests on # a local (PCIe) card. diff --git a/src/tests/test_integration.py b/src/tests/test_integration.py index 56236d0..54fa3e1 100644 --- a/src/tests/test_integration.py +++ b/src/tests/test_integration.py @@ -43,7 +43,11 @@ def test_standard_single_mode(self) -> None: self.assertEqual(len(measurement.waveforms), 1) self.assertEqual([wfm.shape for wfm in measurement.waveforms], [(ACQUISITION_LENGTH,)]) if self._single_card_mock_mode: - self.assertAlmostEqual(measurement.waveforms[0].max() - measurement.waveforms[0].min(), 0.4, 1) + # mock waveform source generates random values covering full ADC range, which is set to += 0.2 V + expected_pk_to_pk_volts = 0.4 + self.assertAlmostEqual( + measurement.waveforms[0].max() - measurement.waveforms[0].min(), expected_pk_to_pk_volts, 1 + ) self.assertAlmostEqual(measurement.waveforms[0].mean(), 0.0, 1) two_seconds_ago = datetime.datetime.now() - datetime.timedelta(seconds=2)