From f5fb6445a547aaba2ed42ebddf482bbb3acaa093 Mon Sep 17 00:00:00 2001 From: crnbaker Date: Wed, 24 Jan 2024 12:12:20 +0000 Subject: [PATCH] #48 fixed minor bugs in AWG code found during HW tests --- ...wg_standard_single_restart_mode_example.py | 30 ++++++------ ...wg_trigger_with_pulse_generator_example.py | 46 ++++++++++--------- .../pulse_generator_example.py | 22 +++++++-- .../abstract_device/abstract_spectrum_card.py | 2 +- .../abstract_spectrum_device.py | 6 +-- src/spectrumdevice/devices/awg/awg_channel.py | 4 +- .../devices/digitiser/digitiser_card.py | 2 +- .../devices/digitiser/digitiser_channel.py | 2 +- .../devices/mocks/mock_abstract_devices.py | 4 +- .../devices/mocks/mock_waveform_source.py | 2 +- .../devices/mocks/timestamps.py | 2 +- .../devices/spectrum_timestamper.py | 2 +- src/spectrumdevice/exceptions.py | 4 +- .../pulse_generator/pulse_generator.py | 19 ++++---- .../settings/card_dependent_properties.py | 2 +- src/spectrumdevice/settings/card_features.py | 2 +- src/spectrumdevice/settings/channel.py | 2 +- src/spectrumdevice/settings/device_modes.py | 2 +- src/spectrumdevice/settings/io_lines.py | 2 +- .../settings/output_channel_pairing.py | 2 +- src/spectrumdevice/settings/status.py | 2 +- src/spectrumdevice/settings/timestamps.py | 2 +- src/spectrumdevice/settings/triggering.py | 2 +- src/tests/test_single_card.py | 8 ++-- src/tests/test_single_channel.py | 3 ++ 25 files changed, 101 insertions(+), 75 deletions(-) diff --git a/src/example_scripts/awg_standard_single_restart_mode_example.py b/src/example_scripts/awg_standard_single_restart_mode_example.py index 4765929..84cefd8 100644 --- a/src/example_scripts/awg_standard_single_restart_mode_example.py +++ b/src/example_scripts/awg_standard_single_restart_mode_example.py @@ -8,7 +8,6 @@ from spectrumdevice.settings import ( TriggerSettings, TriggerSource, - ExternalTriggerMode, GenerationSettings, OutputChannelFilter, ModelNumber, @@ -16,10 +15,11 @@ from spectrumdevice.settings.channel import OutputChannelStopLevelMode from spectrumdevice.settings.device_modes import GenerationMode -PULSE_RATE_HZ = 5000 -NUM_PULSES = 5 -NUM_CYCLES = 2 -FREQUENCY = 20e3 +PULSE_RATE_HZ = 200 +NUM_TRANSMISSIONS = 5 +NUM_CYCLES_PER_TRANSMISSION = 3 +FREQUENCY_HZ = 1e3 +AMPLITUDE_V = 1.0 SAMPLE_RATE = 125000000 @@ -33,12 +33,15 @@ def awg_single_restart_mode_example(mock_mode: bool) -> None: device_number=0, model=ModelNumber.TYP_M2P6560_X4, num_modules=1, num_channels_per_module=1 ) - sample_rate_in_hz = 1000000 - number_of_generations = 3 + sample_rate_in_hz = SAMPLE_RATE + number_of_generations = NUM_TRANSMISSIONS # create a waveform to generate t, analog_wfm = make_full_scale_sine_waveform( - frequency_in_hz=20e3, sample_rate_in_hz=sample_rate_in_hz, num_cycles=1, dtype=int16 + frequency_in_hz=FREQUENCY_HZ, + sample_rate_in_hz=sample_rate_in_hz, + num_cycles=NUM_CYCLES_PER_TRANSMISSION, + dtype=int16, ) # configure signal generation @@ -48,18 +51,17 @@ def awg_single_restart_mode_example(mock_mode: bool) -> None: sample_rate_in_hz=sample_rate_in_hz, num_loops=number_of_generations, enabled_channels=[0], - signal_amplitudes_in_mv=[1000], + signal_amplitudes_in_mv=[int(round((AMPLITUDE_V * 1000)))], dc_offsets_in_mv=[0], output_filters=[OutputChannelFilter.LOW_PASS_70_MHZ], stop_level_modes=[OutputChannelStopLevelMode.SPCM_STOPLVL_ZERO], ) card.configure_generation(generation_settings) - # configure triggering (here we set to software trigger) + # configure triggering (here we configure an external trigger, but actually we will be forcing + # the trigger event to occur from software on line 72) trigger_settings = TriggerSettings( trigger_sources=[TriggerSource.SPC_TMASK_EXT0], - external_trigger_mode=ExternalTriggerMode.SPC_TM_POS, - external_trigger_level_in_mv=200, ) card.configure_trigger(trigger_settings) @@ -67,9 +69,11 @@ def awg_single_restart_mode_example(mock_mode: bool) -> None: # we are using GenerationMode.SPC_REP_STD_SINGLERESTART so the whole waveform will be generated each time the card # is trigger, until "num_loops" triggers have been detected. card.start() + + # force triggers at the requested rate. Remove if real external trigger present. for _ in range(number_of_generations): card.force_trigger() - sleep(100e-3) # here we are waiting 0.1 seconds between triggers + sleep(1 / PULSE_RATE_HZ) print("generated pulse") card.stop() card.disconnect() diff --git a/src/example_scripts/awg_trigger_with_pulse_generator_example.py b/src/example_scripts/awg_trigger_with_pulse_generator_example.py index 880668f..09e0cbf 100644 --- a/src/example_scripts/awg_trigger_with_pulse_generator_example.py +++ b/src/example_scripts/awg_trigger_with_pulse_generator_example.py @@ -2,6 +2,7 @@ from numpy import int16 +from spectrumdevice import SpectrumAWGCard from spectrumdevice.devices.awg.synthesis import make_full_scale_rect_waveform from spectrumdevice.devices.mocks import MockSpectrumAWGCard from spectrumdevice.settings import ( @@ -25,27 +26,28 @@ PulseGeneratorMultiplexer2TriggerSource, ) - -SAMPLE_RATE_IN_HZ = 40000000 -NUM_GENERATIONS = 4 +MOCK_CARD = True +SAMPLE_RATE_IN_HZ = 1000000 +NUM_GENERATIONS = 3 if __name__ == "__main__": # AWG CARD SETUP --------------------------------------------------------------------------------------------------- - # Connect to a real AWG card with the optional pulse generator firmware option unlocked - # card = SpectrumAWGCard(device_number=0) - - # Or a mock AWG card - card = MockSpectrumAWGCard( - device_number=0, - model=ModelNumber.TYP_M2P6560_X4, - num_modules=1, - num_channels_per_module=1, - # make sure the mock card has the pulse generator feature unlocked! - advanced_card_features=[AdvancedCardFeature.SPCM_FEAT_EXTFW_PULSEGEN], - ) + if not MOCK_CARD: + # Connect to a real AWG card with the optional pulse generator firmware option unlocked + card = SpectrumAWGCard(device_number=0) + else: + # Or a mock AWG card + card = MockSpectrumAWGCard( + device_number=0, + model=ModelNumber.TYP_M2P6560_X4, + num_modules=1, + num_channels_per_module=1, + # make sure the mock card has the pulse generator feature unlocked! + advanced_card_features=[AdvancedCardFeature.SPCM_FEAT_EXTFW_PULSEGEN], + ) # Set up the AWG trigger settings using the X1 multipurpose IO Line as a trigger source card_trigger_settings = TriggerSettings( @@ -107,16 +109,20 @@ # continuous output # The period is the length of the whole pulse (high-voltage length + 0V length) # The duty cycle is the high-voltage length divided by the period + + print(f"SAMPLE RATE IS {card.sample_rate_in_hz} Hz") + pulse_output_settings = PulseGeneratorOutputSettings( - period_in_seconds=1e-3, duty_cycle=0.5, num_pulses=NUM_GENERATIONS, delay_in_seconds=0.0, output_inversion=False + period_in_seconds=1e-3, duty_cycle=0.1, num_pulses=NUM_GENERATIONS, delay_in_seconds=0.0, output_inversion=False ) - pulse_gen.configure_output(pulse_output_settings) + pulse_gen.configure_output(pulse_output_settings, coerce=False) # Enable the pulse generator pulse_gen.enable() # Start the AWG so it is waiting for a trigger card.start() + sleep(0.2) # Force a software trigger on the pulse generator, causing pulse to be generated on X1, triggering the AWG pulse_gen.force_trigger() @@ -124,10 +130,8 @@ sleep(1) # Note that there is a delay between a trigger being received and the AWG generating a signal. - # This is in the technical data section of the manual, and for my device is apparently 63 samples + 7 ns - # However I see 74 samples + 7 ns when testing this script, suggesting there is an additional delay of 11 samples - # between the pulse generator and the AWG trigger circuitry - print(f"Expected delay between pulse and signal: {(63 * 1 / SAMPLE_RATE_IN_HZ + 7e-9) * 1e6} microseconds") + # This is in the technical data section of the manual, and for my device is apparently 73 samples + 7 ns + print(f"Expected delay between pulse and signal: {(73 * 1 / SAMPLE_RATE_IN_HZ + 7e-9) * 1e6} microseconds") card.stop() card.disconnect() diff --git a/src/example_scripts/pulse_generator_example.py b/src/example_scripts/pulse_generator_example.py index 6abc5a8..bd2bdbb 100644 --- a/src/example_scripts/pulse_generator_example.py +++ b/src/example_scripts/pulse_generator_example.py @@ -26,9 +26,16 @@ def pulse_generator_example(mock_mode: bool) -> None: advanced_card_features=[AdvancedCardFeature.SPCM_FEAT_EXTFW_PULSEGEN], ) + # Set the card's sample rate. This affects the precision with which pulse timings can be chosen, and the min and max + # allowed pulse periods + card.set_sample_rate_in_hz(100000) + # Enable a single channel of the card. Although not used in this example, the number of enabled channels affects + # the precision with which pulse timings can be chosen and the min and max allowed pulse periods + card.set_enabled_analog_channels([0]) + # Each of the card's four multipurpose IO lines (X0, X1, X2 and X3) has a pulse generator - # Choose the one you would like to use and set it to pulse gen mode. Here we are using X0 (index 0) - io_line_index = 0 + # Choose the one you would like to use and set it to pulse gen mode. Here we are using X1 (index 1) + io_line_index = 1 card.io_lines[io_line_index].set_mode(IOLineMode.SPCM_XMODE_PULSEGEN) # Then get its pulse generator pulse_gen = card.io_lines[io_line_index].pulse_generator @@ -55,9 +62,14 @@ def pulse_generator_example(mock_mode: bool) -> None: # The period is the length of the whole pulse (high-voltage length + 0V length) # The duty cycle is the high-voltage length divided by the period pulse_output_settings = PulseGeneratorOutputSettings( - period_in_seconds=1e-3, duty_cycle=0.5, num_pulses=10, delay_in_seconds=0.0, output_inversion=False + period_in_seconds=1e-3, duty_cycle=0.5, num_pulses=2, delay_in_seconds=0.0, output_inversion=False ) - pulse_gen.configure_output(pulse_output_settings) + pulse_gen.configure_output(pulse_output_settings, coerce=False) + + # Print pulse timings. They may have been coerced to allowed values + print(f"Pulse period: {pulse_gen.period_in_seconds * 1e3} ms") + print(f"Duty cycle: {pulse_gen.duty_cycle}") + # Enable the pulse generator pulse_gen.enable() @@ -69,4 +81,4 @@ def pulse_generator_example(mock_mode: bool) -> None: if __name__ == "__main__": - pulse_generator_example(mock_mode=True) + pulse_generator_example(mock_mode=False) diff --git a/src/spectrumdevice/devices/abstract_device/abstract_spectrum_card.py b/src/spectrumdevice/devices/abstract_device/abstract_spectrum_card.py index 8fa8800..716bc2f 100644 --- a/src/spectrumdevice/devices/abstract_device/abstract_spectrum_card.py +++ b/src/spectrumdevice/devices/abstract_device/abstract_spectrum_card.py @@ -11,7 +11,7 @@ from operator import or_ from typing import Any, List, Optional, Sequence, Tuple -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( M2CMD_DATA_STARTDMA, M2CMD_DATA_STOPDMA, M2CMD_DATA_WAITDMA, diff --git a/src/spectrumdevice/devices/abstract_device/abstract_spectrum_device.py b/src/spectrumdevice/devices/abstract_device/abstract_spectrum_device.py index 47c9638..5cc8662 100644 --- a/src/spectrumdevice/devices/abstract_device/abstract_spectrum_device.py +++ b/src/spectrumdevice/devices/abstract_device/abstract_spectrum_device.py @@ -21,7 +21,7 @@ DOUBLING_CHANNEL_PAIR_COMMANDS, ) from spectrumdevice.settings.triggering import EXTERNAL_TRIGGER_SOURCES -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( M2CMD_CARD_ENABLETRIGGER, M2CMD_CARD_RESET, M2CMD_CARD_START, @@ -185,13 +185,13 @@ def read_spectrum_device_register( Args: spectrum_register (int): Identifier of the register to set. This should be a global constant imported from - spectrum_gmbh.regs. + spectrum_gmbh.py_header.regs. length (`SpectrumRegisterLength`): A `SpectrumRegisterLength` object specifying the length of the register to set, in bits. Returns: value (int): Value of the register. This can be matched to a global constant imported from - spectrum_gmbh.regs, usually using one of the Enums defined in the settings module. + spectrum_gmbh.py_header.regs, usually using one of the Enums defined in the settings module. """ if not SPECTRUM_DRIVERS_FOUND: raise SpectrumDriversNotFound( diff --git a/src/spectrumdevice/devices/awg/awg_channel.py b/src/spectrumdevice/devices/awg/awg_channel.py index 5a37643..911d3db 100644 --- a/src/spectrumdevice/devices/awg/awg_channel.py +++ b/src/spectrumdevice/devices/awg/awg_channel.py @@ -1,4 +1,4 @@ -from typing import Any, cast +from typing import Any from numpy import int16 @@ -49,7 +49,7 @@ def set_dig_out_settings(self, dig_out_settings: DigOutIOLineModeSettings) -> No def _get_io_line_mode_settings_mask(self, mode: IOLineMode) -> int: if mode == IOLineMode.SPCM_XMODE_DIGOUT: - return cast(int, self._dig_out_settings.source_channel.value | self._dig_out_settings.source_bit.value) + return self._dig_out_settings.source_channel.value | self._dig_out_settings.source_bit.value else: return 0 diff --git a/src/spectrumdevice/devices/digitiser/digitiser_card.py b/src/spectrumdevice/devices/digitiser/digitiser_card.py index d6230d6..e173703 100644 --- a/src/spectrumdevice/devices/digitiser/digitiser_card.py +++ b/src/spectrumdevice/devices/digitiser/digitiser_card.py @@ -10,7 +10,7 @@ from numpy import float_, mod, squeeze, zeros from numpy.typing import NDArray -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( M2CMD_CARD_WAITREADY, SPC_AVERAGES, SPC_CARDMODE, diff --git a/src/spectrumdevice/devices/digitiser/digitiser_channel.py b/src/spectrumdevice/devices/digitiser/digitiser_channel.py index 7cd5e57..dec97dd 100644 --- a/src/spectrumdevice/devices/digitiser/digitiser_channel.py +++ b/src/spectrumdevice/devices/digitiser/digitiser_channel.py @@ -7,7 +7,7 @@ from numpy import ndarray -from spectrum_gmbh.regs import SPC_MIINST_MAXADCVALUE +from spectrum_gmbh.py_header.regs import SPC_MIINST_MAXADCVALUE from spectrumdevice.devices.abstract_device import AbstractSpectrumCard from spectrumdevice.devices.abstract_device.abstract_spectrum_channel import AbstractSpectrumAnalogChannel from spectrumdevice.devices.abstract_device.abstract_spectrum_io_line import AbstractSpectrumIOLine diff --git a/src/spectrumdevice/devices/mocks/mock_abstract_devices.py b/src/spectrumdevice/devices/mocks/mock_abstract_devices.py index 750a34f..c01f08c 100644 --- a/src/spectrumdevice/devices/mocks/mock_abstract_devices.py +++ b/src/spectrumdevice/devices/mocks/mock_abstract_devices.py @@ -10,7 +10,7 @@ from threading import Event, Lock, Thread from typing import Any, Dict, Optional, Union, cast -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( SPCM_X0_AVAILMODES, SPCM_X1_AVAILMODES, SPCM_X2_AVAILMODES, @@ -210,7 +210,7 @@ def __init__( param_dict[SPC_MIINST_BYTESPERSAMPLE] = 2 param_dict[SPC_MIINST_MAXADCVALUE] = 128 # Pulse generation: - param_dict[SPC_XIO_PULSEGEN_CLOCK] = 1000 + param_dict[SPC_XIO_PULSEGEN_CLOCK] = 100000 param_dict[SPC_XIO_PULSEGEN_ENABLE] = 0 param_dict[SPC_XIO_PULSEGEN0_CONFIG] = 0 param_dict[SPC_XIO_PULSEGEN1_CONFIG] = 0 diff --git a/src/spectrumdevice/devices/mocks/mock_waveform_source.py b/src/spectrumdevice/devices/mocks/mock_waveform_source.py index 9cdac98..4231a80 100644 --- a/src/spectrumdevice/devices/mocks/mock_waveform_source.py +++ b/src/spectrumdevice/devices/mocks/mock_waveform_source.py @@ -12,7 +12,7 @@ from numpy import ndarray from numpy.random import uniform -from spectrum_gmbh.regs import SPC_DATA_AVAIL_USER_LEN, SPC_DATA_AVAIL_USER_POS +from spectrum_gmbh.py_header.regs import SPC_DATA_AVAIL_USER_LEN, SPC_DATA_AVAIL_USER_POS from spectrumdevice.settings import AcquisitionMode from spectrumdevice.settings.transfer_buffer import PAGE_SIZE_IN_BYTES diff --git a/src/spectrumdevice/devices/mocks/timestamps.py b/src/spectrumdevice/devices/mocks/timestamps.py index 264d2d6..b6c74ef 100644 --- a/src/spectrumdevice/devices/mocks/timestamps.py +++ b/src/spectrumdevice/devices/mocks/timestamps.py @@ -8,7 +8,7 @@ from numpy import uint64 -from spectrum_gmbh.regs import SPC_TIMESTAMP_CMD +from spectrum_gmbh.py_header.regs import SPC_TIMESTAMP_CMD from spectrumdevice.devices.spectrum_timestamper import Timestamper from spectrumdevice.settings.timestamps import TimestampMode from spectrumdevice.spectrum_wrapper import DEVICE_HANDLE_TYPE diff --git a/src/spectrumdevice/devices/spectrum_timestamper.py b/src/spectrumdevice/devices/spectrum_timestamper.py index 0d38d70..461e19c 100644 --- a/src/spectrumdevice/devices/spectrum_timestamper.py +++ b/src/spectrumdevice/devices/spectrum_timestamper.py @@ -10,7 +10,7 @@ from datetime import datetime, timedelta from typing import Tuple, Optional -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( SPC_TIMESTAMP_CMD, SPC_TS_RESET, SPC_M2CMD, diff --git a/src/spectrumdevice/exceptions.py b/src/spectrumdevice/exceptions.py index 40512de..e124205 100644 --- a/src/spectrumdevice/exceptions.py +++ b/src/spectrumdevice/exceptions.py @@ -113,8 +113,8 @@ def __init__( self, param_name: str, requested_value: float, param_min: float, param_max: float, param_step: float ) -> None: super().__init__( - f"The requested {param_name} value of {requested_value} is invalid. It must be between " - f"{param_min} and {param_max} inclusive, and a multiple of {param_step}." + f"The requested {param_name} value of {requested_value} is invalid. At the current sample rate, it must be" + f" between {param_min} and {param_max} inclusive, and a multiple of {param_step}." ) diff --git a/src/spectrumdevice/features/pulse_generator/pulse_generator.py b/src/spectrumdevice/features/pulse_generator/pulse_generator.py index 3c965a3..9d80e06 100644 --- a/src/spectrumdevice/features/pulse_generator/pulse_generator.py +++ b/src/spectrumdevice/features/pulse_generator/pulse_generator.py @@ -16,6 +16,9 @@ SPCM_PULSEGEN_CMD_FORCE, SPC_M2CMD, M2CMD_CARD_WRITESETUP, + SPC_XIO_PULSEGEN_AVAILHIGH_STEP, + SPC_XIO_PULSEGEN_AVAILHIGH_MAX, + SPC_XIO_PULSEGEN_AVAILHIGH_MIN, ) from spectrumdevice.devices.abstract_device.channel_interfaces import SpectrumIOLineInterface from spectrumdevice.exceptions import ( @@ -198,13 +201,13 @@ def set_trigger_mode(self, mode: PulseGeneratorTriggerMode) -> None: @property def min_allowed_period_in_seconds(self) -> float: reg_val = self.read_parent_device_register(SPC_XIO_PULSEGEN_AVAILLEN_MIN) - reg_val = 0 if reg_val == -1 else reg_val + reg_val = 0 if reg_val < 0 else reg_val return self._convert_clock_cycles_to_seconds(reg_val) @property def max_allowed_period_in_seconds(self) -> float: reg_val = self.read_parent_device_register(SPC_XIO_PULSEGEN_AVAILLEN_MAX) - reg_val = iinfo(int16).max if reg_val == -1 else reg_val + reg_val = iinfo(int16).max if reg_val < 0 else reg_val return self._convert_clock_cycles_to_seconds(reg_val) @property @@ -248,23 +251,23 @@ def set_period_in_seconds(self, period: float, coerce: bool = False) -> float: @property def min_allowed_high_voltage_duration_in_seconds(self) -> float: - reg_val = self.read_parent_device_register(SPC_XIO_PULSEGEN_AVAILLEN_MIN) - reg_val = 0 if reg_val == -1 else reg_val + reg_val = self.read_parent_device_register(SPC_XIO_PULSEGEN_AVAILHIGH_MIN) + reg_val = 0 if reg_val < 0 else reg_val return self._convert_clock_cycles_to_seconds(reg_val) @property def max_allowed_high_voltage_duration_in_seconds(self) -> float: - reg_val = self.read_parent_device_register(SPC_XIO_PULSEGEN_AVAILLEN_MAX) - reg_val = iinfo(int16).max if reg_val == -1 else reg_val + reg_val = self.read_parent_device_register(SPC_XIO_PULSEGEN_AVAILHIGH_MAX) + reg_val = iinfo(int16).max if reg_val < 0 else reg_val return self._convert_clock_cycles_to_seconds(reg_val) @property def _allowed_high_voltage_duration_step_size_in_clock_cycles(self) -> int: - return self.read_parent_device_register(SPC_XIO_PULSEGEN_AVAILLEN_STEP) + return self.read_parent_device_register(SPC_XIO_PULSEGEN_AVAILHIGH_STEP) @property def allowed_high_voltage_duration_step_size_in_seconds(self) -> float: - return self._convert_clock_cycles_to_seconds(self._allowed_period_step_size_in_clock_cycles) + return self._convert_clock_cycles_to_seconds(self._allowed_high_voltage_duration_step_size_in_clock_cycles) @property def duration_of_high_voltage_in_seconds(self) -> float: diff --git a/src/spectrumdevice/settings/card_dependent_properties.py b/src/spectrumdevice/settings/card_dependent_properties.py index 85f612a..1f3563b 100644 --- a/src/spectrumdevice/settings/card_dependent_properties.py +++ b/src/spectrumdevice/settings/card_dependent_properties.py @@ -1,6 +1,6 @@ from enum import Enum -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( SPCM_TYPE_AI, SPCM_TYPE_AO, SPCM_TYPE_DI, diff --git a/src/spectrumdevice/settings/card_features.py b/src/spectrumdevice/settings/card_features.py index 866b116..ea7d050 100644 --- a/src/spectrumdevice/settings/card_features.py +++ b/src/spectrumdevice/settings/card_features.py @@ -9,7 +9,7 @@ from typing import List from spectrumdevice.spectrum_wrapper import decode_bitmap_using_list_of_ints -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( SPCM_FEAT_MULTI, SPCM_FEAT_GATE, SPCM_FEAT_DIGITAL, diff --git a/src/spectrumdevice/settings/channel.py b/src/spectrumdevice/settings/channel.py index e8672f4..96a09d3 100644 --- a/src/spectrumdevice/settings/channel.py +++ b/src/spectrumdevice/settings/channel.py @@ -7,7 +7,7 @@ from enum import Enum -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( SPCM_STOPLVL_CUSTOM, SPCM_STOPLVL_HIGH, SPCM_STOPLVL_HOLDLAST, diff --git a/src/spectrumdevice/settings/device_modes.py b/src/spectrumdevice/settings/device_modes.py index 74f720f..608e039 100644 --- a/src/spectrumdevice/settings/device_modes.py +++ b/src/spectrumdevice/settings/device_modes.py @@ -6,7 +6,7 @@ from enum import Enum -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( SPC_REC_FIFO_AVERAGE, SPC_REC_STD_AVERAGE, SPC_REC_STD_SINGLE, diff --git a/src/spectrumdevice/settings/io_lines.py b/src/spectrumdevice/settings/io_lines.py index 83dd7fb..64d25b2 100644 --- a/src/spectrumdevice/settings/io_lines.py +++ b/src/spectrumdevice/settings/io_lines.py @@ -13,7 +13,7 @@ from spectrumdevice.exceptions import SpectrumIOError from spectrumdevice.settings.channel import SpectrumChannelName from spectrumdevice.spectrum_wrapper import decode_bitmap_using_list_of_ints -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( SPCM_XMODE_DISABLE, SPCM_XMODE_ASYNCIN, SPCM_XMODE_ASYNCOUT, diff --git a/src/spectrumdevice/settings/output_channel_pairing.py b/src/spectrumdevice/settings/output_channel_pairing.py index d95b836..7a288c3 100644 --- a/src/spectrumdevice/settings/output_channel_pairing.py +++ b/src/spectrumdevice/settings/output_channel_pairing.py @@ -1,6 +1,6 @@ from enum import Enum -from spectrum_gmbh.regs import SPC_DIFF0, SPC_DIFF2, SPC_DIFF4, SPC_DIFF6, SPC_DOUBLEOUT0, SPC_DOUBLEOUT2 +from spectrum_gmbh.py_header.regs import SPC_DIFF0, SPC_DIFF2, SPC_DIFF4, SPC_DIFF6, SPC_DOUBLEOUT0, SPC_DOUBLEOUT2 class ChannelPairingMode: diff --git a/src/spectrumdevice/settings/status.py b/src/spectrumdevice/settings/status.py index 481f5f1..4042ea7 100644 --- a/src/spectrumdevice/settings/status.py +++ b/src/spectrumdevice/settings/status.py @@ -10,7 +10,7 @@ from typing import List from spectrumdevice.spectrum_wrapper import decode_bitmap_using_list_of_ints -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( M2STAT_NONE, M2STAT_CARD_PRETRIGGER, M2STAT_CARD_TRIGGER, diff --git a/src/spectrumdevice/settings/timestamps.py b/src/spectrumdevice/settings/timestamps.py index b76c694..63534b0 100644 --- a/src/spectrumdevice/settings/timestamps.py +++ b/src/spectrumdevice/settings/timestamps.py @@ -1,7 +1,7 @@ from datetime import datetime from enum import Enum -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( SPC_TSMODE_STANDARD, SPC_TSMODE_STARTRESET, SPC_TSCNT_REFCLOCKPOS, diff --git a/src/spectrumdevice/settings/triggering.py b/src/spectrumdevice/settings/triggering.py index d39631a..cfd162b 100644 --- a/src/spectrumdevice/settings/triggering.py +++ b/src/spectrumdevice/settings/triggering.py @@ -10,7 +10,7 @@ from typing import List from spectrumdevice.spectrum_wrapper import decode_bitmap_using_list_of_ints -from spectrum_gmbh.regs import ( +from spectrum_gmbh.py_header.regs import ( SPC_TMASK_SOFTWARE, SPC_TMASK_EXT0, SPC_TMASK_EXT1, diff --git a/src/tests/test_single_card.py b/src/tests/test_single_card.py index b029240..f5bc6c4 100644 --- a/src/tests/test_single_card.py +++ b/src/tests/test_single_card.py @@ -5,7 +5,7 @@ from numpy import array, iinfo, int16, zeros from numpy.testing import assert_array_equal -from spectrum_gmbh.regs import SPC_CHENABLE +from spectrum_gmbh.py_header.regs import SPC_CHENABLE from spectrumdevice import SpectrumDigitiserAnalogChannel from spectrumdevice.devices.abstract_device.device_interface import SpectrumDeviceInterface from spectrumdevice.devices.awg.awg_channel import SpectrumAWGAnalogChannel @@ -54,6 +54,9 @@ def setUp(self) -> None: self._all_spectrum_channel_identifiers.sort() # Enums are unordered so ensure channels are in ascending order self._expected_num_channels = self._determine_expected_num_channels() + def tearDown(self) -> None: + self._device.disconnect() + @abstractmethod def _create_test_card(self) -> CardInterfaceVar: raise NotImplementedError @@ -62,9 +65,6 @@ def _create_test_card(self) -> CardInterfaceVar: def _determine_expected_num_channels(self) -> int: raise NotImplementedError - def tearDown(self) -> None: - self._device.disconnect() - def test_count_channels(self) -> None: channels = self._device.analog_channels self.assertEqual(self._expected_num_channels, len(channels)) diff --git a/src/tests/test_single_channel.py b/src/tests/test_single_channel.py index 25043bb..fc36d40 100644 --- a/src/tests/test_single_channel.py +++ b/src/tests/test_single_channel.py @@ -38,6 +38,9 @@ def setUp(self) -> None: self._device = create_awg_card_for_testing() self._channel = SpectrumAWGAnalogChannel(channel_number=0, parent_device=self._device) + def tearDown(self) -> None: + self._channel._parent_device.disconnect() + def test_switched_on(self) -> None: self._channel.set_is_switched_on(True) self.assertTrue(self._channel.is_switched_on)