stoner_measurement.plugins.sequence.base.SequencePlugin

class stoner_measurement.plugins.sequence.base.SequencePlugin[source]

Bases: BasePlugin

Abstract base class for plugins that act as containers in the sequence tree.

A SequencePlugin can hold nested sub-steps. The sequence engine and the UI tree widget both recognise SequencePlugin instances as branch nodes that may accept child steps dropped onto them.

Concrete implementations must supply name (from BasePlugin) and execute_sequence().

StateControlPlugin inherits from this class to gain sub-sequence container behaviour, whilst retaining its full instrument-lifecycle API.

Variables:

sub_steps (list) – The sub-step descriptors assigned by the sequence engine when building an execution plan from the sequence tree. Each element is either a plain entry-point name string (for a leaf sub-step) or a (ep_name, [sub-steps…]) tuple (for a nested SequencePlugin sub-step). Defaults to an empty list.

Examples

>>> from stoner_measurement.plugins.sequence import SequencePlugin
>>> issubclass(SequencePlugin, SequencePlugin)
True
declared_outputs() → PluginOutputs[source]

Declare no outputs for a transparent sequence container.

abstractmethod execute_sequence(sub_steps: list) → None[source]

Execute sub_steps at the appropriate point in this plugin’s lifecycle.

The sequence engine calls this method when running a sequence tree. Each element of sub_steps is a zero-argument callable that, when invoked, runs the corresponding nested step (including its own lifecycle and any further sub-steps).

Direct state-scan and state-sweep helpers perform their own setup and cleanup around the callable children. Generated scripts instead own whole-sequence setup and cleanup, then render this container’s action through generate_action_code(). Overriding this direct helper alone does not change generated control flow. Implementations of both paths must agree on child ordering, point metadata and collection.

Parameters:

sub_steps (list) – Ordered list of zero-argument callables, one per nested step.

Examples

>>> from stoner_measurement.plugins.sequence import TopLevelSequence
>>> seq = TopLevelSequence()
>>> called = []
>>> seq.execute_sequence([lambda: called.append(1), lambda: called.append(2)])
>>> called
[1, 2]
generate_action_code(indent: int, sub_steps: list, render_sub_step: Callable) → list[str][source]

Return action code lines by transparently rendering all sub-steps.

A generic SequencePlugin container has no action of its own; it simply delegates to each nested step at the same indentation level. StateControlPlugin overrides this method to wrap sub-steps inside a scan loop.

Parameters:
  • indent (int) – Number of four-space indentation levels for the emitted lines.

  • sub_steps (list) – Raw sub-step descriptors from the sequence tree.

  • render_sub_step (Callable) – Callback (step, indent) -> list[str] provided by the engine.

Returns:

Lines for all nested sub-steps at the same indentation level.

Return type:

(list[str])

Examples

>>> from stoner_measurement.plugins.sequence import TopLevelSequence
>>> seq = TopLevelSequence()
>>> lines = seq.generate_action_code(0, [], lambda s, i: [])
>>> lines
[]
property plugin_type: str

Short tag identifying this plugin as a sequence container.

Returns:

Always "sequence".

Return type:

(str)

property sub_steps: list

Sub-step descriptors assigned by the engine for this node.

Returns:

List of step descriptors (strings or tuples).

Return type:

(list)

Examples

>>> from stoner_measurement.plugins.sequence import TopLevelSequence
>>> seq = TopLevelSequence()
>>> seq.sub_steps
[]