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

1class stanza.base.mixins.InstrumentChannelMixin

Mixin class that provides the default InstrumentChannel implementation.

1add_channel(
2 channel_name_or_channel: str | stanza.base.channels.InstrumentChannel | None,
3 channel: stanza.base.channels.InstrumentChannel | None = None
4) -> 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
1get_channel(channel_name: str) -> stanza.base.channels.InstrumentChannel

Get a channel by name.

1remove_channel(channel_name: str) -> None

Remove a channel from the instrument.

1class stanza.base.mixins.ControlInstrumentMixin

Bases: stanza.base.mixins.InstrumentChannelMixin

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

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

Set voltage on a specific channel using parameter system.

1get_voltage(channel_name: str) -> float

Get current voltage on a specific channel using parameter system.

1get_slew_rate(channel_name: str) -> float

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

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

Set slew rate on a specific channel using parameter system.

1class stanza.base.mixins.MeasurementInstrumentMixin

Bases: stanza.base.mixins.InstrumentChannelMixin

Mixin class that provides default MeasurementInstrument implementations.

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

Context manager that handles preparation, avoiding nested calls.

1prepare_measurement() -> None

Override in subclasses for actual preparation logic.

1teardown_measurement() -> None

Optional override in subclasses for actual teardown logic.

1measure(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.