Spectrum-Instrumentation Control#

See also

User guide on the spectrum devices.

Transmit and Receive Devices#

Device interface class.

class console.spcm_control.abstract_device.SpectrumDevice(path: str, log: Logger)[source]#

Bases: ABC

Spectrum device abstract base class.

connect() bool[source]#

Establish card connection.

Raises:
  • ConnectionError – Connection to card already exists

  • ConnectionError – Connection could not be established

abstract dict() dict[source]#

Abstract method which returns variables for logging in dictionary.

disconnect()[source]#

Disconnect card.

abstract get_status() int[source]#

Abstract method to obtain card status.

handle_error(error: int)[source]#

General error handling function.

abstract setup_card()[source]#

Abstract method to setup the card.

abstract start_operation()[source]#

Abstract method to start card operation.

Parameters:
  • data – Replay data in correct spcm format as numpy array, by default None

  • optional – Replay data in correct spcm format as numpy array, by default None

abstract stop_operation()[source]#

Abstract method to stop card operation.

Implementation of receive card.

class console.spcm_control.rx_device.RxCard(path: str, sample_rate: int, channel_enable: list[int], max_amplitude: list[int], impedance_50_ohms: list[int], __name__: str = 'RxCard')[source]#

Bases: SpectrumDevice

Implementation of RX device.

channel_enable: list[int]#
dict() dict[source]#

Returnt class variables which are json serializable as dictionary.

Return type:

Dictionary containing class variables.

get_status() int[source]#

Get the current card status.

Return type:

String with status description.

impedance_50_ohms: list[int]#
log_card_status(include_desc: bool = False) None[source]#

Log current card status.

The status is represented by a list. Each entry represents a possible card status in form of a (sub-)list. It contains the status code, name and (optional) description of the spectrum instrumentation manual.

Parameters:
  • include_desc – Flag which indicates if description string should be contained in status entry, by default False

  • optional – Flag which indicates if description string should be contained in status entry, by default False

max_amplitude: list[int]#
path: str#
sample_rate: int#
setup_card()[source]#

Set up spectrum card in transmit (TX) mode.

At the very beginning, a card reset is performed. The clock mode is set according to the sample rate, defined by the class attribute. Two receive channels are enables and configured by max. amplitude according to class variables and impedance.

Raises:

Warning – The actual set sample rate deviates from the corresponding class attribute to be set, class attribute is overwritten.

start_operation()[source]#

Start card operation.

stop_operation()[source]#

Stop card thread.

Implementation of transmit card.

class console.spcm_control.tx_device.TxCard(path: str, max_amplitude: list[int], filter_type: list[int], sample_rate: int, notify_rate: int = 16, __name__: str = 'TxCard')[source]#

Bases: SpectrumDevice

Implementation of TX device.

Implements abstract base class SpectrumDevice, which requires the abstract methods get_status(), setup_card() and operate(). The TxCard is automatically instantiated by a yaml-loader when loading the configuration file.

The implementation was done and tested with card M2p6546-x4, which has an onboard memory size of 512 MSample, 2 Bytes/sample => 1024 MB.

Overview:#

The TX card operates with a ring buffer on the spectrum card, defined by ring_buffer_size. The ring buffer is filled in fractions of notify_size.

dict() dict[source]#

Returnt class variables which are json serializable as dictionary.

Return type:

Dictionary containing class variables.

filter_type: list[int]#
get_status() int[source]#

Get the current card status.

Return type:

String with status description.

log_card_status(include_desc: bool = False) None[source]#

Log current card status.

The status is represented by a list. Each entry represents a possible card status in form of a (sub-)list. It contains the status code, name and (optional) description of the spectrum instrumentation manual.

Parameters:
  • include_desc – Flag which indicates if description string should be contained in status entry, by default False

  • optional – Flag which indicates if description string should be contained in status entry, by default False

max_amplitude: list[int]#
notify_rate: int = 16#
path: str#
sample_rate: int#
set_gradient_offsets(offsets: Dimensions, high_impedance: list[bool] = [True, True, True]) None[source]#

Set offset values of the gradient output channels.

Parameters:

offsets – Offset values as Dimension datatype as defined in acquisition parameter

Return type:

List of integer values read from card for x, y and z offset values

setup_card() None[source]#

Set up spectrum card in transmit (TX) mode.

At the very beginning, a card reset is performed. The clock mode is set according to the sample rate, defined by the class attribute. All 4 channels are enables and configured by max. amplitude and filter values from class attributes. Digital outputs X0, X1 and X2 are defined which are controlled by the 15th bit of analog outputs 1, 2 and 3.

Raises:

Warning – The actual set sample rate deviates from the corresponding class attribute to be set, class attribute is overwritten.

start_operation(data: UnrolledSequence | None = None) None[source]#

Start transmit (TX) card operation.

Steps: (1) Setup the transmit card (2) Clear emergency stop flag, reset to False (3) Start worker thread (card streaming mode), with provided replay data

Parameters:

data – Sequence replay data as int16 numpy array in correct order. Checkout prepare_sequence function for reference of correct replay data format. This value is None per default

Raises:

ValueError – Raised if replay data is not provided as numpy int16 values

stop_operation() None[source]#

Stop card operation by thread event and stop card.