Skip to navigation

stanza.base.mixins

Module Contents

Classes

NameDescription
InstrumentChannelMixinMixin class that provides the default InstrumentChannel implementation.
ControlInstrumentMixinMixin class that provides the default ControlInstrument implementation using channel parameters.
MeasurementInstrumentMixinMixin class that provides default MeasurementInstrument implementations.

API

class stanza.base.mixins.InstrumentChannelMixin

Mixin class that provides the default InstrumentChannel implementation.

add_channel(
channel_name_or_channel: str | stanza.base.channels.InstrumentChannel | None,
channel: stanza.base.channels.InstrumentChannel | None = None
) -> None

Add a channel to the instrument.

Can be called as:

  • add_channel(channel) - uses channel.name as key
  • add_channel(channel_name, channel) - uses provided name as key
get_channel(channel_name: str) -> stanza.base.channels.InstrumentChannel

Get a channel by name.

remove_channel(channel_name: str) -> None

Remove a channel from the instrument.

class stanza.base.mixins.ControlInstrumentMixin

Bases: stanza.base.mixins.InstrumentChannelMixin

Mixin class that provides the default ControlInstrument implementation using channel parameters.

set_voltage(
channel_name: str, voltage: float
) -> None

Set voltage on a specific channel using parameter system.

get_voltage(channel_name: str) -> float

Get current voltage on a specific channel using parameter system.

get_slew_rate(channel_name: str) -> float

Get current slew rate on a specific channel using parameter system.

set_slew_rate(
channel_name: str, slew_rate: float
) -> None

Set slew rate on a specific channel using parameter system.

class stanza.base.mixins.MeasurementInstrumentMixin

Bases: stanza.base.mixins.InstrumentChannelMixin

Mixin class that provides default MeasurementInstrument implementations.

prepare_measurement_context() -> collections.abc.Generator[None, None, None]

Context manager that handles preparation, avoiding nested calls.

prepare_measurement() -> None

Optional override in subclasses for actual preparation logic.

teardown_measurement() -> None

Optional override in subclasses for actual teardown logic.

measure(channel_name: str) -> float

Default measurement that reads the ‘current’ parameter from the first channel.

Subclasses are expected to expose channels via get_channel(int) and a ‘current’ Parameter on each channel whose getter performs the measurement.