spectrumdevice.settings
Provides Enums and Dataclasses wrapping the register values provided by the Spectrum API, to be used for configuring hardware and interpreting responses received from hardware.
1"""Provides Enums and Dataclasses wrapping the register values provided by the Spectrum API, to be used for configuring 2hardware and interpreting responses received from hardware.""" 3 4# Christian Baker, King's College London 5# Copyright (c) 2024 School of Biomedical Engineering & Imaging Sciences, King's College London 6# Licensed under the MIT. You may obtain a copy at https://opensource.org/licenses/MIT. 7 8from dataclasses import dataclass 9from enum import Enum 10from typing import List, Optional 11 12from numpy import int16 13from numpy.typing import NDArray 14 15from spectrumdevice.settings.card_dependent_properties import ModelNumber 16from spectrumdevice.settings.card_features import CardFeature, AdvancedCardFeature 17from spectrumdevice.settings.channel import ( 18 InputImpedance, 19 InputCoupling, 20 InputPath, 21 OutputChannelFilter, 22 OutputChannelStopLevelMode, 23) 24from spectrumdevice.settings.device_modes import AcquisitionMode, ClockMode, GenerationMode 25from spectrumdevice.settings.io_lines import IOLineMode, AvailableIOModes 26from spectrumdevice.settings.transfer_buffer import ( 27 TransferBuffer, 28) 29from spectrumdevice.settings.triggering import TriggerSource, ExternalTriggerMode 30from spectrumdevice.settings.status import CARD_STATUS_TYPE, DEVICE_STATUS_TYPE, StatusCode 31from spectrumdevice.settings.pulse_generator import ( 32 PulseGeneratorTriggerSettings, 33 PulseGeneratorTriggerMode, 34 PulseGeneratorTriggerDetectionMode, 35 PulseGeneratorMultiplexer1TriggerSource, 36 PulseGeneratorMultiplexer2TriggerSource, 37 PulseGeneratorOutputSettings, 38) 39 40 41__all__ = [ 42 "AcquisitionSettings", 43 "TriggerSettings", 44 "AcquisitionMode", 45 "ClockMode", 46 "CardFeature", 47 "AdvancedCardFeature", 48 "IOLineMode", 49 "AvailableIOModes", 50 "TransferBuffer", 51 "TriggerSource", 52 "ExternalTriggerMode", 53 "CARD_STATUS_TYPE", 54 "DEVICE_STATUS_TYPE", 55 "StatusCode", 56 "SpectrumRegisterLength", 57 "ModelNumber", 58 "GenerationSettings", 59 "OutputChannelFilter", 60 "OutputChannelStopLevelMode", 61 "GenerationMode", 62 "PulseGeneratorTriggerSettings", 63 "PulseGeneratorTriggerMode", 64 "PulseGeneratorTriggerDetectionMode", 65 "PulseGeneratorMultiplexer1TriggerSource", 66 "PulseGeneratorMultiplexer2TriggerSource", 67 "PulseGeneratorOutputSettings", 68] 69 70 71@dataclass 72class TriggerSettings: 73 """A dataclass collecting all settings related to triggering generation and acquisition. See Spectrum documentation. 74 Note that pulse generators have their own trigger options.""" 75 76 trigger_sources: List[TriggerSource] 77 """The trigger sources to enable""" 78 external_trigger_mode: Optional[ExternalTriggerMode] = None 79 """The external trigger mode (if an external trigger is enabled).""" 80 external_trigger_level_in_mv: Optional[int] = None 81 """The level an external signal must reach to cause a trigger event (if an external trigger is enabled).""" 82 external_trigger_pulse_width_in_samples: Optional[int] = None 83 """The required width of an external trigger pulse (if an external trigger is enabled).""" 84 85 86@dataclass 87class AcquisitionSettings: 88 """A dataclass collecting all settings required to configure an acquisition. See Spectrum documentation.""" 89 90 acquisition_mode: AcquisitionMode 91 """Standard Single mode, Multi FIF mode or an averaging mode.""" 92 sample_rate_in_hz: int 93 """Acquisition rate in samples per second.""" 94 acquisition_length_in_samples: int 95 """The length of the recording in samples per channel.""" 96 pre_trigger_length_in_samples: int 97 """The number of samples of the recording that will have been acquired before the trigger event.""" 98 timeout_in_ms: int 99 """How long to wait for a trigger event before timing out.""" 100 enabled_channels: List[int] 101 """The channel indices to enable for the acquisition.""" 102 vertical_ranges_in_mv: List[int] 103 """The voltage range to apply to each enabled channel in mW.""" 104 vertical_offsets_in_percent: List[int] 105 """The DC offset to apply to each enabled channel as percentages of their vertical ranges.""" 106 input_impedances: List[InputImpedance] 107 """The input impedance settings to apply to each channel""" 108 timestamping_enabled: bool 109 """If True, Measurements will include the time at which the acquisition was triggered. Increases latency by ~10 ms. 110 """ 111 batch_size: int = 1 112 """The number of acquisitions to transfer to the PC before the resulting waveforms are returned by 113 SpectrumDigitiserCard.get_waveforms().""" 114 number_of_averages: int = 1 115 """If an averaging AcquisitionMode is selected, this defines the number of averages.""" 116 input_couplings: Optional[List[InputCoupling]] = None 117 """The coupling (AC or DC) to apply to each channel. Only available on some hardware, so default is None.""" 118 input_paths: Optional[List[InputPath]] = None 119 """The input path (HF or Buffered) to apply to each channel. Only available on some hardware, so default is None.""" 120 121 122@dataclass 123class GenerationSettings: 124 """A dataclass collecting all settings required to configure signal generation. See Spectrum documentation.""" 125 126 generation_mode: GenerationMode 127 """SPC_REP_STD_SINGLE , SPC_REP_STD_SINGLERESTART""" 128 waveform: NDArray[int16] 129 """The waveform to generate.""" 130 sample_rate_in_hz: int 131 """Generation rate in samples per second.""" 132 num_loops: int 133 """In SPC_REP_STD_SINGLE mode: the number of times to repeat the waveform after a trigger is received. In 134 SPC_REP_STD_SINGLERESTART: The number of times to wait for a trigger and generate waveform once.""" 135 enabled_channels: list[int] 136 """List of analog channel indices to enable for signal generation""" 137 signal_amplitudes_in_mv: list[int] 138 """The amplitude of each enabled channel.""" 139 dc_offsets_in_mv: list[int] 140 """The dc offset of each enabled channel.""" 141 output_filters: list[OutputChannelFilter] 142 """The output filter setting for each enabled channel.""" 143 stop_level_modes: list[OutputChannelStopLevelMode] 144 """The behavior of each enabled channel after the waveform ends.""" 145 custom_stop_levels: Optional[list[Optional[int]]] = None 146 """The stop level each channel will use it stop level mode is set to custom.""" 147 148 149class SpectrumRegisterLength(Enum): 150 """Enum defining the possible lengths of a spectrum register.""" 151 152 THIRTY_TWO = 0 153 """32 bit register""" 154 SIXTY_FOUR = 1 155 """64 bit register""" 156 157 def __repr__(self) -> str: 158 return self.name
87@dataclass 88class AcquisitionSettings: 89 """A dataclass collecting all settings required to configure an acquisition. See Spectrum documentation.""" 90 91 acquisition_mode: AcquisitionMode 92 """Standard Single mode, Multi FIF mode or an averaging mode.""" 93 sample_rate_in_hz: int 94 """Acquisition rate in samples per second.""" 95 acquisition_length_in_samples: int 96 """The length of the recording in samples per channel.""" 97 pre_trigger_length_in_samples: int 98 """The number of samples of the recording that will have been acquired before the trigger event.""" 99 timeout_in_ms: int 100 """How long to wait for a trigger event before timing out.""" 101 enabled_channels: List[int] 102 """The channel indices to enable for the acquisition.""" 103 vertical_ranges_in_mv: List[int] 104 """The voltage range to apply to each enabled channel in mW.""" 105 vertical_offsets_in_percent: List[int] 106 """The DC offset to apply to each enabled channel as percentages of their vertical ranges.""" 107 input_impedances: List[InputImpedance] 108 """The input impedance settings to apply to each channel""" 109 timestamping_enabled: bool 110 """If True, Measurements will include the time at which the acquisition was triggered. Increases latency by ~10 ms. 111 """ 112 batch_size: int = 1 113 """The number of acquisitions to transfer to the PC before the resulting waveforms are returned by 114 SpectrumDigitiserCard.get_waveforms().""" 115 number_of_averages: int = 1 116 """If an averaging AcquisitionMode is selected, this defines the number of averages.""" 117 input_couplings: Optional[List[InputCoupling]] = None 118 """The coupling (AC or DC) to apply to each channel. Only available on some hardware, so default is None.""" 119 input_paths: Optional[List[InputPath]] = None 120 """The input path (HF or Buffered) to apply to each channel. Only available on some hardware, so default is None."""
A dataclass collecting all settings required to configure an acquisition. See Spectrum documentation.
The number of samples of the recording that will have been acquired before the trigger event.
The DC offset to apply to each enabled channel as percentages of their vertical ranges.
The input impedance settings to apply to each channel
If True, Measurements will include the time at which the acquisition was triggered. Increases latency by ~10 ms.
The number of acquisitions to transfer to the PC before the resulting waveforms are returned by SpectrumDigitiserCard.get_waveforms().
If an averaging AcquisitionMode is selected, this defines the number of averages.
72@dataclass 73class TriggerSettings: 74 """A dataclass collecting all settings related to triggering generation and acquisition. See Spectrum documentation. 75 Note that pulse generators have their own trigger options.""" 76 77 trigger_sources: List[TriggerSource] 78 """The trigger sources to enable""" 79 external_trigger_mode: Optional[ExternalTriggerMode] = None 80 """The external trigger mode (if an external trigger is enabled).""" 81 external_trigger_level_in_mv: Optional[int] = None 82 """The level an external signal must reach to cause a trigger event (if an external trigger is enabled).""" 83 external_trigger_pulse_width_in_samples: Optional[int] = None 84 """The required width of an external trigger pulse (if an external trigger is enabled)."""
A dataclass collecting all settings related to triggering generation and acquisition. See Spectrum documentation. Note that pulse generators have their own trigger options.
23class AcquisitionMode(Enum): 24 """Enum representing the digitise acquisition modes currently support by spectrumdevice. See Spectrum documentation 25 for more information about each mode.""" 26 27 SPC_REC_STD_SINGLE = SPC_REC_STD_SINGLE 28 """Data acquisition to on-board memory for one single trigger event.""" 29 SPC_REC_FIFO_MULTI = SPC_REC_FIFO_MULTI 30 """Continuous data acquisition for multiple trigger events.""" 31 SPC_REC_STD_AVERAGE = SPC_REC_STD_AVERAGE 32 """Data acquisition to on-board memory for the average of multiple trigger events.""" 33 SPC_REC_FIFO_AVERAGE = SPC_REC_FIFO_AVERAGE 34 """Continuous data acquisition for multiple trigger events, with on-board averaging."""
Enum representing the digitise acquisition modes currently support by spectrumdevice. See Spectrum documentation for more information about each mode.
Data acquisition to on-board memory for one single trigger event.
Continuous data acquisition for multiple trigger events.
Data acquisition to on-board memory for the average of multiple trigger events.
Continuous data acquisition for multiple trigger events, with on-board averaging.
Inherited Members
- enum.Enum
- name
- value
48class ClockMode(Enum): 49 """Enum representing the clock modes currently supported by spectrumdevice. See Spectrum documentation for more 50 information about each mode.""" 51 52 SPC_CM_INTPLL = SPC_CM_INTPLL 53 """Enables internal PLL with 20 MHz internal reference for sample clock generation.""" 54 SPC_CM_EXTERNAL = SPC_CM_EXTERNAL 55 """Enables external clock input for direct sample clock generation.""" 56 SPC_CM_EXTREFCLOCK = SPC_CM_EXTREFCLOCK 57 """Enables internal PLL with external reference for sample clock generation."""
Enum representing the clock modes currently supported by spectrumdevice. See Spectrum documentation for more information about each mode.
Enables internal PLL with 20 MHz internal reference for sample clock generation.
Enables external clock input for direct sample clock generation.
Enables internal PLL with external reference for sample clock generation.
Inherited Members
- enum.Enum
- name
- value
46class CardFeature(Enum): 47 """Enum representing the possible features of all Spectrum devices. A list of features can be read from a device 48 using the feature_list property. See the Spectrum documentation for descriptions of each of the features.""" 49 50 SPCM_FEAT_MULTI = SPCM_FEAT_MULTI 51 SPCM_FEAT_GATE = SPCM_FEAT_GATE 52 SPCM_FEAT_DIGITAL = SPCM_FEAT_DIGITAL 53 SPCM_FEAT_TIMESTAMP = SPCM_FEAT_TIMESTAMP 54 SPCM_FEAT_STARHUB_4_5_6EXTM_8EXTM = SPCM_FEAT_STARHUB_4_5_6EXTM_8EXTM 55 SPCM_FEAT_STARHUB_8_16_16EXTM = SPCM_FEAT_STARHUB_8_16_16EXTM 56 SPCM_FEAT_ABA = SPCM_FEAT_ABA 57 SPCM_FEAT_BASEXIO = SPCM_FEAT_BASEXIO 58 SPCM_FEAT_AMPLIFIER_10V = SPCM_FEAT_AMPLIFIER_10V 59 SPCM_FEAT_STARHUBSYSMASTER = SPCM_FEAT_STARHUBSYSMASTER 60 SPCM_FEAT_DIFFMODE = SPCM_FEAT_DIFFMODE 61 SPCM_FEAT_SEQUENCE = SPCM_FEAT_SEQUENCE 62 SPCM_FEAT_AMPMODULE_10V = SPCM_FEAT_AMPMODULE_10V 63 SPCM_FEAT_STARHUBSYSSLAVE = SPCM_FEAT_STARHUBSYSSLAVE 64 SPCM_FEAT_NETBOX = SPCM_FEAT_NETBOX 65 SPCM_FEAT_REMOTESERVER = SPCM_FEAT_REMOTESERVER 66 SPCM_FEAT_SCAPP = SPCM_FEAT_SCAPP 67 SPCM_FEAT_CUSTOMMOD_MASK = SPCM_FEAT_CUSTOMMOD_MASK
Enum representing the possible features of all Spectrum devices. A list of features can be read from a device using the feature_list property. See the Spectrum documentation for descriptions of each of the features.
Inherited Members
- enum.Enum
- name
- value
77class AdvancedCardFeature(Enum): 78 """Enum representing the possible advanced features of all Spectrum devices. A list of features can be read from a 79 device using the feature_list property. See the Spectrum documentation for descriptions of each of the features. 80 """ 81 82 SPCM_FEAT_EXTFW_SEGSTAT = SPCM_FEAT_EXTFW_SEGSTAT 83 SPCM_FEAT_EXTFW_SEGAVERAGE = SPCM_FEAT_EXTFW_SEGAVERAGE 84 SPCM_FEAT_EXTFW_BOXCAR = SPCM_FEAT_EXTFW_BOXCAR 85 SPCM_FEAT_EXTFW_PULSEGEN = SPCM_FEAT_EXTFW_PULSEGEN
Enum representing the possible advanced features of all Spectrum devices. A list of features can be read from a device using the feature_list property. See the Spectrum documentation for descriptions of each of the features.
Inherited Members
- enum.Enum
- name
- value
79class IOLineMode(Enum): 80 """Enum representing the possible modes that a devices multi-purpose I/O line can support. A list of available 81 modes for each I/O line on a device is provided by the devices available_io_modes property. See the Spectrum 82 documentation for a description of each of the modes.""" 83 84 SPCM_XMODE_DISABLE = SPCM_XMODE_DISABLE 85 SPCM_XMODE_ASYNCIN = SPCM_XMODE_ASYNCIN 86 SPCM_XMODE_ASYNCOUT = SPCM_XMODE_ASYNCOUT 87 SPCM_XMODE_DIGIN = SPCM_XMODE_DIGIN 88 SPCM_XMODE_TRIGIN = SPCM_XMODE_TRIGIN 89 SPCM_XMODE_DIGOUT = SPCM_XMODE_DIGOUT 90 SPCM_XMODE_TRIGOUT = SPCM_XMODE_TRIGOUT 91 SPCM_XMODE_RUNSTATE = SPCM_XMODE_RUNSTATE 92 SPCM_XMODE_ARMSTATE = SPCM_XMODE_ARMSTATE 93 SPCM_XMODE_CONTOUTMARK = SPCM_XMODE_CONTOUTMARK 94 SPCM_XMODE_PULSEGEN = SPCM_XMODE_PULSEGEN
Enum representing the possible modes that a devices multi-purpose I/O line can support. A list of available modes for each I/O line on a device is provided by the devices available_io_modes property. See the Spectrum documentation for a description of each of the modes.
Inherited Members
- enum.Enum
- name
- value
165@dataclass 166class AvailableIOModes: 167 """Stores a list of the available IOLineMode settings on each of the four I/O lines (X0, X1, X2 and X3) on a 168 device. Returned by the available_io_modes() method of a device.""" 169 170 X0: List[IOLineMode] 171 """IO modes available to the XO IO line.""" 172 X1: List[IOLineMode] 173 """IO modes available to the X1 IO line.""" 174 X2: List[IOLineMode] 175 """IO modes available to the X2 IO line.""" 176 X3: List[IOLineMode] 177 """IO modes available to the X3 IO line."""
Stores a list of the available IOLineMode settings on each of the four I/O lines (X0, X1, X2 and X3) on a device. Returned by the available_io_modes() method of a device.
59@dataclass 60class TransferBuffer(ABC): 61 """A buffer for transferring samples between spectrumdevice software and a hardware device. See the 'Definition of the 62 transfer buffer' section of the Spectrum documentation for more information. This implementation of the buffer 63 sets the notify-size equal to the acquisition length.""" 64 65 type: BufferType 66 """Specifies whether the buffer is to be used to transfer samples, timestamps or A/B data.""" 67 direction: BufferDirection 68 """Specifies whether the buffer is to be used to transfer data from the card to the PC, or the PC to the card.""" 69 board_memory_offset_bytes: int 70 """Sets the offset for transfer in board memory. Typically 0. See Spectrum documentation for more information.""" 71 data_array: ndarray 72 """1D numpy array into which samples will be written during transfer.""" 73 notify_size_in_pages: float 74 """The number of transferred pages (4096 bytes) after which a notification of transfer is sent from the device.""" 75 76 @abstractmethod 77 def read_chunk(self, chunk_position_in_bytes: int, chunk_size_in_bytes: int) -> ndarray: 78 raise NotImplementedError() 79 80 @abstractmethod 81 def copy_contents(self) -> ndarray: 82 raise NotImplementedError() 83 84 @property 85 def data_array_pointer(self) -> c_void_p: 86 """A pointer to the data array.""" 87 return self.data_array.ctypes.data_as(c_void_p) 88 89 @property 90 def data_array_length_in_bytes(self) -> int: 91 """The length of the array into which sample will be written, in bytes.""" 92 return self.data_array.size * self.data_array.itemsize 93 94 def __eq__(self, other: object) -> bool: 95 if isinstance(other, TransferBuffer): 96 return ( 97 (self.type == other.type) 98 and (self.direction == other.direction) 99 and (self.board_memory_offset_bytes == other.board_memory_offset_bytes) 100 and (self.data_array == other.data_array).all() 101 ) 102 else: 103 raise NotImplementedError()
A buffer for transferring samples between spectrumdevice software and a hardware device. See the 'Definition of the transfer buffer' section of the Spectrum documentation for more information. This implementation of the buffer sets the notify-size equal to the acquisition length.
Specifies whether the buffer is to be used to transfer samples, timestamps or A/B data.
Specifies whether the buffer is to be used to transfer data from the card to the PC, or the PC to the card.
Sets the offset for transfer in board memory. Typically 0. See Spectrum documentation for more information.
The number of transferred pages (4096 bytes) after which a notification of transfer is sent from the device.
48class TriggerSource(Enum): 49 """An Enum representing the possible trigger sources.""" 50 51 SPC_TMASK_SOFTWARE = SPC_TMASK_SOFTWARE 52 """Enables the software trigger for the OR mask. The card will trigger immediately after start.""" 53 SPC_TMASK_EXT0 = SPC_TMASK_EXT0 54 """Enables the external (analog) trigger 0 for the OR mask.""" 55 SPC_TMASK_EXT1 = SPC_TMASK_EXT1 56 """Enables the X1 (logic) trigger for the OR mask.""" 57 SPC_TMASK_EXT2 = SPC_TMASK_EXT2 58 """Enables the X2 (logic) trigger for the OR mask.""" 59 SPC_TMASK_EXT3 = SPC_TMASK_EXT3 60 """Enables the X3 (logic) trigger for the OR mask.""" 61 SPC_TMASK0_CH0 = SPC_TMASK0_CH0 62 """Enables channel 0 for recognition within the channel OR mask""" 63 SPC_TMASK0_CH1 = SPC_TMASK0_CH1 64 """Enables channel 1 for recognition within the channel OR mask""" 65 SPC_TMASK0_CH2 = SPC_TMASK0_CH2 66 """Enables channel 2 for recognition within the channel OR mask""" 67 SPC_TMASK0_CH3 = SPC_TMASK0_CH3 68 """Enables channel 3 for recognition within the channel OR mask""" 69 SPC_TMASK0_CH4 = SPC_TMASK0_CH4 70 """Enables channel 4 for recognition within the channel OR mask""" 71 SPC_TMASK0_CH5 = SPC_TMASK0_CH5 72 """Enables channel 5 for recognition within the channel OR mask""" 73 SPC_TMASK0_CH6 = SPC_TMASK0_CH6 74 """Enables channel 6 for recognition within the channel OR mask""" 75 SPC_TMASK0_CH7 = SPC_TMASK0_CH7 76 """Enables channel 7 for recognition within the channel OR mask""" 77 SPC_TMASK_NONE = SPC_TMASK_NONE 78 """No trigger source selected."""
An Enum representing the possible trigger sources.
Enables the software trigger for the OR mask. The card will trigger immediately after start.
Enables the external (analog) trigger 0 for the OR mask.
Enables channel 0 for recognition within the channel OR mask
Enables channel 1 for recognition within the channel OR mask
Enables channel 2 for recognition within the channel OR mask
Enables channel 3 for recognition within the channel OR mask
Enables channel 4 for recognition within the channel OR mask
Enables channel 5 for recognition within the channel OR mask
Enables channel 6 for recognition within the channel OR mask
Enables channel 7 for recognition within the channel OR mask
Inherited Members
- enum.Enum
- name
- value
89class ExternalTriggerMode(Enum): 90 """An Enum representing the supported trigger modes. See the Spectrum documentation more Information. 91 92 SPC_TM_NONE: 93 SPC_TM_POS: 94 SPC_TM_NEG: 95 SPC_TM_BOTH: 96 SPC_TM_HIGH: 97 SPC_TM_LOW: 98 SPC_TM_PW_GREATER: 99 SPC_TM_PW_SMALLER: 100 """ 101 102 SPC_TM_NONE = SPC_TM_NONE 103 """Channel is not used for trigger detection.""" 104 SPC_TM_POS = SPC_TM_POS 105 """Trigger detection for positive edges (crossing level 0 from below to above).""" 106 SPC_TM_NEG = SPC_TM_NEG 107 """Trigger detection for negative edges (crossing level 0 from above to below).""" 108 SPC_TM_BOTH = SPC_TM_BOTH 109 """Trigger detection for positive and negative edges (any crossing of level 0).""" 110 SPC_TM_HIGH = SPC_TM_HIGH 111 """Trigger detection for HIGH levels (signal above level 0).""" 112 SPC_TM_LOW = SPC_TM_LOW 113 """Trigger detection for LOW levels (signal below level 0).""" 114 SPC_TM_PW_GREATER = SPC_TM_PW_GREATER 115 """Sets the trigger mode for external trigger to detect pulses that are longer than the pulse width 116 chosen using the devices set_external_trigger_pulse_width_in_samples() method. Can only be used in combination 117 with one of the above modes.""" 118 SPC_TM_PW_SMALLER = SPC_TM_PW_SMALLER 119 """Sets the trigger mode for external trigger to detect pulses that are shorter than the pulse width 120 chosen using the devices set_external_trigger_pulse_width_in_samples() method. Can only be used in combination 121 with one of the above modes."""
An Enum representing the supported trigger modes. See the Spectrum documentation more Information.
SPC_TM_NONE: SPC_TM_POS: SPC_TM_NEG: SPC_TM_BOTH: SPC_TM_HIGH: SPC_TM_LOW: SPC_TM_PW_GREATER: SPC_TM_PW_SMALLER:
Trigger detection for positive edges (crossing level 0 from below to above).
Trigger detection for negative edges (crossing level 0 from above to below).
Trigger detection for positive and negative edges (any crossing of level 0).
Trigger detection for HIGH levels (signal above level 0).
Trigger detection for LOW levels (signal below level 0).
Sets the trigger mode for external trigger to detect pulses that are longer than the pulse width chosen using the devices set_external_trigger_pulse_width_in_samples() method. Can only be used in combination with one of the above modes.
Sets the trigger mode for external trigger to detect pulses that are shorter than the pulse width chosen using the devices set_external_trigger_pulse_width_in_samples() method. Can only be used in combination with one of the above modes.
Inherited Members
- enum.Enum
- name
- value
31class StatusCode(Enum): 32 """An Enum representing the possible status codes that can be returned by a SpectrumDigitiserCard. See the Spectrum 33 documentation for a description of each status.""" 34 35 M2STAT_NONE = M2STAT_NONE 36 M2STAT_CARD_PRETRIGGER = M2STAT_CARD_PRETRIGGER 37 M2STAT_CARD_TRIGGER = M2STAT_CARD_TRIGGER 38 M2STAT_CARD_READY = M2STAT_CARD_READY 39 M2STAT_CARD_SEGMENT_PRETRG = M2STAT_CARD_SEGMENT_PRETRG 40 M2STAT_DATA_BLOCKREADY = M2STAT_DATA_BLOCKREADY 41 M2STAT_DATA_END = M2STAT_DATA_END 42 M2STAT_DATA_OVERRUN = M2STAT_DATA_OVERRUN 43 M2STAT_DATA_ERROR = M2STAT_DATA_ERROR 44 M2STAT_EXTRA_BLOCKREADY = M2STAT_EXTRA_BLOCKREADY 45 M2STAT_EXTRA_END = M2STAT_EXTRA_END 46 M2STAT_EXTRA_OVERRUN = M2STAT_EXTRA_OVERRUN 47 M2STAT_EXTRA_ERROR = M2STAT_EXTRA_ERROR
An Enum representing the possible status codes that can be returned by a SpectrumDigitiserCard. See the Spectrum documentation for a description of each status.
Inherited Members
- enum.Enum
- name
- value
150class SpectrumRegisterLength(Enum): 151 """Enum defining the possible lengths of a spectrum register.""" 152 153 THIRTY_TWO = 0 154 """32 bit register""" 155 SIXTY_FOUR = 1 156 """64 bit register""" 157 158 def __repr__(self) -> str: 159 return self.name
Enum defining the possible lengths of a spectrum register.
Inherited Members
- enum.Enum
- name
- value
111class ModelNumber(Enum): 112 """An Enum representing the integer values returned by a device when its type identifier is queried by reading the 113 SPC_PCITYP register. Only the supported card types are listed (Digitisers: 22xx, 44xx and 59xx family devices; AWGs: 114 M2P 65xx devices).""" 115 116 TYP_M4I2210_X8 = TYP_M4I2210_X8 117 TYP_M4I2211_X8 = TYP_M4I2211_X8 118 TYP_M4I2212_X8 = TYP_M4I2212_X8 119 TYP_M4I2220_X8 = TYP_M4I2220_X8 120 TYP_M4I2221_X8 = TYP_M4I2221_X8 121 TYP_M4I2223_X8 = TYP_M4I2223_X8 122 TYP_M4I2230_X8 = TYP_M4I2230_X8 123 TYP_M4I2233_X8 = TYP_M4I2233_X8 124 TYP_M4I2234_X8 = TYP_M4I2234_X8 125 TYP_M4I2280_X8 = TYP_M4I2280_X8 126 TYP_M4I2281_X8 = TYP_M4I2281_X8 127 TYP_M4I2283_X8 = TYP_M4I2283_X8 128 TYP_M4I2290_X8 = TYP_M4I2290_X8 129 TYP_M4I2293_X8 = TYP_M4I2293_X8 130 TYP_M4I2294_X8 = TYP_M4I2294_X8 131 TYP_M4I4410_X8 = TYP_M4I4410_X8 132 TYP_M4I4411_X8 = TYP_M4I4411_X8 133 TYP_M4I4420_X8 = TYP_M4I4420_X8 134 TYP_M4I4421_X8 = TYP_M4I4421_X8 135 TYP_M4I4450_X8 = TYP_M4I4450_X8 136 TYP_M4I4451_X8 = TYP_M4I4451_X8 137 TYP_M4I4470_X8 = TYP_M4I4470_X8 138 TYP_M4I4471_X8 = TYP_M4I4471_X8 139 TYP_M4I4480_X8 = TYP_M4I4480_X8 140 TYP_M4I4481_X8 = TYP_M4I4481_X8 141 TYP_M4X44XX_X4 = TYP_M4X44XX_X4 142 TYP_M4X4410_X4 = TYP_M4X4410_X4 143 TYP_M4X4411_X4 = TYP_M4X4411_X4 144 TYP_M4X4420_X4 = TYP_M4X4420_X4 145 TYP_M4X4421_X4 = TYP_M4X4421_X4 146 TYP_M4X4450_X4 = TYP_M4X4450_X4 147 TYP_M4X4451_X4 = TYP_M4X4451_X4 148 TYP_M4X4470_X4 = TYP_M4X4470_X4 149 TYP_M4X4471_X4 = TYP_M4X4471_X4 150 TYP_M4X4480_X4 = TYP_M4X4480_X4 151 TYP_M4X4481_X4 = TYP_M4X4481_X4 152 TYP_M2P5911_X4 = TYP_M2P5911_X4 153 TYP_M2P5912_X4 = TYP_M2P5912_X4 154 TYP_M2P5913_X4 = TYP_M2P5913_X4 155 TYP_M2P5916_X4 = TYP_M2P5916_X4 156 TYP_M2P5920_X4 = TYP_M2P5920_X4 157 TYP_M2P5921_X4 = TYP_M2P5921_X4 158 TYP_M2P5922_X4 = TYP_M2P5922_X4 159 TYP_M2P5923_X4 = TYP_M2P5923_X4 160 TYP_M2P5926_X4 = TYP_M2P5926_X4 161 TYP_M2P5930_X4 = TYP_M2P5930_X4 162 TYP_M2P5931_X4 = TYP_M2P5931_X4 163 TYP_M2P5932_X4 = TYP_M2P5932_X4 164 TYP_M2P5933_X4 = TYP_M2P5933_X4 165 TYP_M2P5936_X4 = TYP_M2P5936_X4 166 TYP_M2P5940_X4 = TYP_M2P5940_X4 167 TYP_M2P5941_X4 = TYP_M2P5941_X4 168 TYP_M2P5942_X4 = TYP_M2P5942_X4 169 TYP_M2P5943_X4 = TYP_M2P5943_X4 170 TYP_M2P5946_X4 = TYP_M2P5946_X4 171 TYP_M2P5960_X4 = TYP_M2P5960_X4 172 TYP_M2P5961_X4 = TYP_M2P5961_X4 173 TYP_M2P5962_X4 = TYP_M2P5962_X4 174 TYP_M2P5966_X4 = TYP_M2P5966_X4 175 TYP_M2P5968_X4 = TYP_M2P5968_X4 176 TYP_M2P6530_X4 = TYP_M2P6530_X4 177 TYP_M2P6531_X4 = TYP_M2P6531_X4 178 TYP_M2P6532_X4 = TYP_M2P6532_X4 179 TYP_M2P6536_X4 = TYP_M2P6536_X4 180 TYP_M2P6533_X4 = TYP_M2P6533_X4 181 TYP_M2P6540_X4 = TYP_M2P6540_X4 182 TYP_M2P6541_X4 = TYP_M2P6541_X4 183 TYP_M2P6546_X4 = TYP_M2P6546_X4 184 TYP_M2P6560_X4 = TYP_M2P6560_X4 185 TYP_M2P6561_X4 = TYP_M2P6561_X4 186 TYP_M2P6562_X4 = TYP_M2P6562_X4 187 TYP_M2P6566_X4 = TYP_M2P6566_X4 188 TYP_M2P6568_X4 = TYP_M2P6568_X4 189 TYP_M2P6570_X4 = TYP_M2P6570_X4 190 TYP_M2P6571_X4 = TYP_M2P6571_X4 191 TYP_M2P6576_X4 = TYP_M2P6576_X4
An Enum representing the integer values returned by a device when its type identifier is queried by reading the SPC_PCITYP register. Only the supported card types are listed (Digitisers: 22xx, 44xx and 59xx family devices; AWGs: M2P 65xx devices).
Inherited Members
- enum.Enum
- name
- value
123@dataclass 124class GenerationSettings: 125 """A dataclass collecting all settings required to configure signal generation. See Spectrum documentation.""" 126 127 generation_mode: GenerationMode 128 """SPC_REP_STD_SINGLE , SPC_REP_STD_SINGLERESTART""" 129 waveform: NDArray[int16] 130 """The waveform to generate.""" 131 sample_rate_in_hz: int 132 """Generation rate in samples per second.""" 133 num_loops: int 134 """In SPC_REP_STD_SINGLE mode: the number of times to repeat the waveform after a trigger is received. In 135 SPC_REP_STD_SINGLERESTART: The number of times to wait for a trigger and generate waveform once.""" 136 enabled_channels: list[int] 137 """List of analog channel indices to enable for signal generation""" 138 signal_amplitudes_in_mv: list[int] 139 """The amplitude of each enabled channel.""" 140 dc_offsets_in_mv: list[int] 141 """The dc offset of each enabled channel.""" 142 output_filters: list[OutputChannelFilter] 143 """The output filter setting for each enabled channel.""" 144 stop_level_modes: list[OutputChannelStopLevelMode] 145 """The behavior of each enabled channel after the waveform ends.""" 146 custom_stop_levels: Optional[list[Optional[int]]] = None 147 """The stop level each channel will use it stop level mode is set to custom."""
A dataclass collecting all settings required to configure signal generation. See Spectrum documentation.
In SPC_REP_STD_SINGLE mode: the number of times to repeat the waveform after a trigger is received. In SPC_REP_STD_SINGLERESTART: The number of times to wait for a trigger and generate waveform once.
The behavior of each enabled channel after the waveform ends.
209class OutputChannelFilter(Enum): 210 LOW_PASS_70_MHZ = 0 211 LOW_PASS_20_MHZ = 1 212 LOW_PASS_5_MHZ = 2 213 LOW_PASS_1_MHZ = 3
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum):
... RED = 1
... BLUE = 2
... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.
Inherited Members
- enum.Enum
- name
- value
239class OutputChannelStopLevelMode(Enum): 240 """Behavior of output channel when output is stopped or playback completes.""" 241 242 SPCM_STOPLVL_ZERO = SPCM_STOPLVL_ZERO 243 """ Output level will go to zero.""" 244 SPCM_STOPLVL_LOW = SPCM_STOPLVL_LOW 245 """ Output level will go to minimum possible negative value.""" 246 SPCM_STOPLVL_HIGH = SPCM_STOPLVL_HIGH 247 """ Output level will go to maximum possible positive value.""" 248 SPCM_STOPLVL_HOLDLAST = SPCM_STOPLVL_HOLDLAST 249 """ Output level will stay at the level of the last played sample.""" 250 SPCM_STOPLVL_CUSTOM = SPCM_STOPLVL_CUSTOM 251 """ Output level will go to the value defined using SpectrumAWGChannel.set_stop_level_custom_value()"""
Behavior of output channel when output is stopped or playback completes.
Output level will go to zero.
Output level will go to minimum possible negative value.
Output level will go to maximum possible positive value.
Output level will stay at the level of the last played sample.
Output level will go to the value defined using SpectrumAWGChannel.set_stop_level_custom_value()
Inherited Members
- enum.Enum
- name
- value
37class GenerationMode(Enum): 38 """Enum representing the AWG generation modes currently supported by spectrumdevice. See Spectrum documentation for 39 more information about each mode.""" 40 41 SPC_REP_STD_SINGLE = SPC_REP_STD_SINGLE 42 """Data generation from on-board memory repeating the complete programmed memory either once, infinite or for a 43 defined number of times after one single trigger event.""" 44 SPC_REP_STD_SINGLERESTART = SPC_REP_STD_SINGLERESTART 45 """Data generation from on-board memory. The programmed memory is repeated once after each single trigger event."""
Enum representing the AWG generation modes currently supported by spectrumdevice. See Spectrum documentation for more information about each mode.
Data generation from on-board memory repeating the complete programmed memory either once, infinite or for a defined number of times after one single trigger event.
Data generation from on-board memory. The programmed memory is repeated once after each single trigger event.
Inherited Members
- enum.Enum
- name
- value
144@dataclass 145class PulseGeneratorTriggerSettings: 146 trigger_mode: PulseGeneratorTriggerMode 147 trigger_detection_mode: PulseGeneratorTriggerDetectionMode 148 multiplexer_1_source: PulseGeneratorMultiplexer1TriggerSource 149 multiplexer_1_output_inversion: bool 150 multiplexer_2_source: PulseGeneratorMultiplexer2TriggerSource 151 multiplexer_2_output_inversion: bool
71class PulseGeneratorTriggerMode(Enum): 72 SPCM_PULSEGEN_MODE_GATED = SPCM_PULSEGEN_MODE_GATED 73 """Pulse generator will start if the trigger condition or “gate” is met and will stop, if either the gate becomes 74 inactive or the defined number of LOOPS have been generated. Will reset its loop counter, when the gate becomes LOW. 75 """ 76 SPCM_PULSEGEN_MODE_TRIGGERED = SPCM_PULSEGEN_MODE_TRIGGERED 77 """The pulse generator will start if the trigger condition is met and will replay the defined number of loops 78 before re-arm- ing itself and waiting for another trigger event. Changes in the trigger signal while replaying will 79 be ignored.""" 80 SPCM_PULSEGEN_MODE_SINGLESHOT = SPCM_PULSEGEN_MODE_SINGLESHOT 81 """The pulse generator will start if the trigger condition is met and will replay the defined number of loops once. 82 """
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum):
... RED = 1
... BLUE = 2
... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.
Pulse generator will start if the trigger condition or “gate” is met and will stop, if either the gate becomes inactive or the defined number of LOOPS have been generated. Will reset its loop counter, when the gate becomes LOW.
The pulse generator will start if the trigger condition is met and will replay the defined number of loops before re-arm- ing itself and waiting for another trigger event. Changes in the trigger signal while replaying will be ignored.
The pulse generator will start if the trigger condition is met and will replay the defined number of loops once.
Inherited Members
- enum.Enum
- name
- value
139class PulseGeneratorTriggerDetectionMode(Enum): 140 RISING_EDGE = 0 # this value is not defined in reg as really its just "HIGH" mode on or off 141 SPCM_PULSEGEN_CONFIG_HIGH = SPCM_PULSEGEN_CONFIG_HIGH
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum):
... RED = 1
... BLUE = 2
... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.
Inherited Members
- enum.Enum
- name
- value
97class PulseGeneratorMultiplexer1TriggerSource(PulseGeneratorMultiplexerTriggerSource, Enum): 98 SPCM_PULSEGEN_MUX1_SRC_UNUSED = SPCM_PULSEGEN_MUX1_SRC_UNUSED 99 """Inputs of MUX1 are not used in creating the trigger condition and instead a static logic HIGH is used for MUX1. 100 """ 101 SPCM_PULSEGEN_MUX1_SRC_RUN = SPCM_PULSEGEN_MUX1_SRC_RUN 102 """This input of MUX1 reflects the current run state of the card. If acquisition/output is running the signal is 103 HIGH. If card has stopped the signal is LOW. The signal is identical to XIO output using SPCM_XMODE_RUNSTATE.""" 104 SPCM_PULSEGEN_MUX1_SRC_ARM = SPCM_PULSEGEN_MUX1_SRC_ARM 105 """This input of MUX1 reflects the current ARM state of the card. If the card is armed and ready to receive a 106 trigger the signal is HIGH. If the card isn’t running or the card is still acquiring pretrigger data or the trigger 107 has already been detected. the signal is LOW. The signal is identical to XIO output using SPCM_XMODE_ARMSTATE."""
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum):
... RED = 1
... BLUE = 2
... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.
Inputs of MUX1 are not used in creating the trigger condition and instead a static logic HIGH is used for MUX1.
This input of MUX1 reflects the current run state of the card. If acquisition/output is running the signal is HIGH. If card has stopped the signal is LOW. The signal is identical to XIO output using SPCM_XMODE_RUNSTATE.
This input of MUX1 reflects the current ARM state of the card. If the card is armed and ready to receive a trigger the signal is HIGH. If the card isn’t running or the card is still acquiring pretrigger data or the trigger has already been detected. the signal is LOW. The signal is identical to XIO output using SPCM_XMODE_ARMSTATE.
Inherited Members
- enum.Enum
- name
- value
118class PulseGeneratorMultiplexer2TriggerSource(PulseGeneratorMultiplexerTriggerSource, Enum): 119 SPCM_PULSEGEN_MUX2_SRC_UNUSED = SPCM_PULSEGEN_MUX2_SRC_UNUSED 120 SPCM_PULSEGEN_MUX2_SRC_SOFTWARE = SPCM_PULSEGEN_MUX2_SRC_SOFTWARE 121 SPCM_PULSEGEN_MUX2_SRC_PULSEGEN0 = SPCM_PULSEGEN_MUX2_SRC_PULSEGEN0 122 SPCM_PULSEGEN_MUX2_SRC_PULSEGEN1 = SPCM_PULSEGEN_MUX2_SRC_PULSEGEN1 123 SPCM_PULSEGEN_MUX2_SRC_PULSEGEN2 = SPCM_PULSEGEN_MUX2_SRC_PULSEGEN2 124 SPCM_PULSEGEN_MUX2_SRC_PULSEGEN3 = SPCM_PULSEGEN_MUX2_SRC_PULSEGEN3 125 SPCM_PULSEGEN_MUX2_SRC_XIO0 = SPCM_PULSEGEN_MUX2_SRC_XIO0 126 SPCM_PULSEGEN_MUX2_SRC_XIO1 = SPCM_PULSEGEN_MUX2_SRC_XIO1 127 SPCM_PULSEGEN_MUX2_SRC_XIO2 = SPCM_PULSEGEN_MUX2_SRC_XIO2 128 SPCM_PULSEGEN_MUX2_SRC_XIO3 = SPCM_PULSEGEN_MUX2_SRC_XIO3
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum):
... RED = 1
... BLUE = 2
... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.
Inherited Members
- enum.Enum
- name
- value
206@dataclass 207class PulseGeneratorOutputSettings: 208 period_in_seconds: float 209 duty_cycle: float 210 num_pulses: int 211 delay_in_seconds: float 212 output_inversion: bool