Skip to content

Commit

Permalink
#26 - tests passing with super()
Browse files Browse the repository at this point in the history
  • Loading branch information
crnbaker committed Jan 8, 2024
1 parent 303e416 commit 7ebe269
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/example_scripts/continuous_averaging_fifo_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
]
Expand Down
4 changes: 2 additions & 2 deletions src/spectrumdevice/devices/mocks/mock_waveform_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
4 changes: 2 additions & 2 deletions src/tests/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion src/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7ebe269

Please # to comment.