signal_generator_mixin

A mixin class providing common methods and attributes for signal generators.

ExtendedSourceDeviceConstants dataclass

ExtendedSourceDeviceConstants(
    amplitude_range: ParameterBounds,
    offset_range: ParameterBounds,
    frequency_range: ParameterBounds,
    sample_rate_range: ParameterBounds,
    square_duty_cycle_range: ParameterBounds | None = None,
    pulse_width_range: ParameterBounds | None = None,
    ramp_symmetry_range: ParameterBounds | None = None,
)

Class to hold source device constants.

ParameterBounds

Bases: NamedTuple

flowchart LR tm_devices.driver_mixins.abstract_device_functionality.signal_generator_mixin.ParameterBounds[ParameterBounds] click tm_devices.driver_mixins.abstract_device_functionality.signal_generator_mixin.ParameterBounds href "" "tm_devices.driver_mixins.abstract_device_functionality.signal_generator_mixin.ParameterBounds"

The upper and lower bounds of a parameter.

SignalGeneratorMixin

Bases: _ExtendableMixin, ABC, Generic[_SignalGeneratorFunctionsTypeVar, _SourceDeviceConstantsTypeVar]

flowchart LR tm_devices.driver_mixins.abstract_device_functionality.signal_generator_mixin.SignalGeneratorMixin[SignalGeneratorMixin] tm_devices.driver_mixins.shared_implementations._extension_mixin._ExtendableMixin[_ExtendableMixin] tm_devices.driver_mixins.shared_implementations._extension_mixin._ExtendableMixin --> tm_devices.driver_mixins.abstract_device_functionality.signal_generator_mixin.SignalGeneratorMixin click tm_devices.driver_mixins.abstract_device_functionality.signal_generator_mixin.SignalGeneratorMixin href "" "tm_devices.driver_mixins.abstract_device_functionality.signal_generator_mixin.SignalGeneratorMixin" click tm_devices.driver_mixins.shared_implementations._extension_mixin._ExtendableMixin href "" "tm_devices.driver_mixins.shared_implementations._extension_mixin._ExtendableMixin"

A mixin class which adds methods and properties for generating signals.

source_device_constants abstractmethod property

source_device_constants: _SourceDeviceConstantsTypeVar

The constants defining what functions and memory sizes are allowed for the device.

add_method classmethod

add_method(method: Callable[Concatenate[Self, _P], _T]) -> None

Add a method to the class.

This class method is best used as a decorator on functions in order to add them to a class.

Examples:

>>> from tm_devices.drivers.device import Device
>>>
>>> @Device.add_method
... def print_hello(self: Device, var: str):
...     print("Hello World!")
...     print(f"I am a {self.__class__.__name__}!")
...     print(f"My var is {var}")
Parameters:

add_property classmethod

add_property(method: Callable[Concatenate[_EM, _P], _T]) -> None
add_property(
    method: None = None, /, *, is_cached: bool = False
) -> Callable[[Callable[Concatenate[_EM, _P], _T]], None]
add_property(
    method: Callable[[Self], _T] | None = None, /, *, is_cached: bool = False
) -> Callable[[Callable[[Self], _T]], None] | None

Add a property to the class.

This class method is best used as a decorator on functions in order to add them to a class.

Examples:

>>> from tm_devices.drivers.device import Device
>>>
>>> @Device.add_property
... def foo(self: Device):
...     return "bar"
>>>
>>> @Device.add_property(is_cached=True)
... def foo(self: Device):
...     return self.name + self.address
Parameters:
  • method (Callable[[Self], _T] | None, default: None ) –

    The property to add to the class.

  • is_cached (bool, default: False ) –

    Whether the property is only evaluated once and cached.

generate_burst abstractmethod

generate_burst() -> None

Generate a burst of waveforms by forcing trigger.

generate_function abstractmethod

generate_function(
    frequency: float,
    function: _SignalGeneratorFunctionsTypeVar,
    amplitude: float,
    offset: float,
    channel: str = "all",
    output_signal_path: SignalGeneratorOutputPathsBase | None = None,
    termination: Literal["FIFTY", "HIGHZ"] = "FIFTY",
    duty_cycle: float = 50.0,
    polarity: Literal["NORMAL", "INVERTED"] = "NORMAL",
    symmetry: float = 50.0,
) -> None

Generate a predefined waveform given the following parameters.

Parameters:
  • frequency (float) –

    The frequency of the waveform to generate.

  • function (_SignalGeneratorFunctionsTypeVar) –

    The waveform shape to generate.

  • amplitude (float) –

    The amplitude of the signal to generate.

  • offset (float) –

    The offset of the signal to generate.

  • channel (str, default: 'all' ) –

    The channel name to output the signal from, or ‘all’.

  • output_signal_path (SignalGeneratorOutputPathsBase | None, default: None ) –

    The output signal path of the specified channel.

  • termination (Literal['FIFTY', 'HIGHZ'], default: 'FIFTY' ) –

    The impedance this device’s channel expects to see at the received end.

  • duty_cycle (float, default: 50.0 ) –

    The duty cycle percentage within [10.0, 90.0].

  • polarity (Literal['NORMAL', 'INVERTED'], default: 'NORMAL' ) –

    The polarity to set the signal to.

  • symmetry (float, default: 50.0 ) –

    The symmetry to set the signal to, only applicable to certain functions.

get_waveform_constraints abstractmethod

get_waveform_constraints(
    function: SignalGeneratorFunctionBase | None = None,
    waveform_length: int | None = None,
    frequency: float | None = None,
    output_signal_path: str = "DIR",
    load_impedance: LoadImpedanceAFG = HIGHZ,
) -> ExtendedSourceDeviceConstants

Get the constraints that restrict the waveform to certain parameter ranges.

Parameters:
  • function (SignalGeneratorFunctionBase | None, default: None ) –

    The function that needs to be generated.

  • waveform_length (int | None, default: None ) –

    The length of the waveform if no function or arbitrary is provided.

  • frequency (float | None, default: None ) –

    The frequency of the waveform that needs to be generated.

  • output_signal_path (str, default: 'DIR' ) –

    The output signal path that was set on the channel.

  • load_impedance (LoadImpedanceAFG, default: HIGHZ ) –

    The suggested impedance on the source.

setup_burst abstractmethod

setup_burst(
    frequency: float,
    function: _SignalGeneratorFunctionsTypeVar,
    amplitude: float,
    offset: float,
    burst_count: int,
    channel: str = "all",
    output_signal_path: SignalGeneratorOutputPathsBase | None = None,
    termination: Literal["FIFTY", "HIGHZ"] = "FIFTY",
    duty_cycle: float = 50.0,
    polarity: Literal["NORMAL", "INVERTED"] = "NORMAL",
    symmetry: float = 50.0,
) -> None

Set up the device for sending a burst of waveforms given the following parameters.

Parameters:
  • frequency (float) –

    The frequency of the waveform to generate.

  • function (_SignalGeneratorFunctionsTypeVar) –

    The function to generate.

  • amplitude (float) –

    The amplitude of the signal to generate.

  • offset (float) –

    The offset of the signal to generate.

  • burst_count (int) –

    The number of wavelengths to be generated.

  • channel (str, default: 'all' ) –

    The channel number to output the signal from, or ‘all’.

  • output_signal_path (SignalGeneratorOutputPathsBase | None, default: None ) –

    The output signal path of the specified channel.

  • termination (Literal['FIFTY', 'HIGHZ'], default: 'FIFTY' ) –

    The impedance to set the channel to.

  • duty_cycle (float, default: 50.0 ) –

    The duty cycle to set the signal to.

  • polarity (Literal['NORMAL', 'INVERTED'], default: 'NORMAL' ) –

    The polarity to set the signal to.

  • symmetry (float, default: 50.0 ) –

    The symmetry to set the signal to, only applicable to certain functions.

SourceDeviceConstants dataclass

SourceDeviceConstants(
    memory_page_size: int,
    memory_max_record_length: int,
    memory_min_record_length: int,
    functions: type[SignalGeneratorFunctionBase],
)

Class to hold source device constants.