stoner_measurement.plugins.command.run_again.RunAgainCommand

class stoner_measurement.plugins.command.run_again.RunAgainCommand(parent=None)[source]

Bases: CommandPlugin

Run an existing sequence step again at the command’s current position.

The selected step keeps its original configuration and instance identity. Its normal action code is emitted again, so plugin-type-specific behaviour such as scans, measurements, transforms, and commands is preserved.

Use this command to repeat a measurement without duplicating its settings. On General, select the target step and optionally enable reconnection and configuration to repeat its instrument setup first. Otherwise an instrument target must already be ready. A container repeats its original nested steps too. Results belong to the target instance; this command creates no separate dataset.

Disabled or missing targets and recursive selections are rejected. Direct execute() calls raise an error: the generated sequence inserts the target’s action at the current position.

Variables:
  • target_step (str) – Instance name of the step to repeat.

  • reconnect_and_configure (bool) – Repeat setup before the target action; defaults to False.

  • instance_name (str) – Inherited Python identifier for this instance in the Script tab and QtConsole.

  • comment (str) – Inherited optional note displayed beside this step.

  • sequence_engine (SequenceEngine | None) – Inherited owning engine and its live namespace; None while detached.

Keyword Parameters:

parent (QObject | None) – Optional Qt parent object.

Examples

With an instance named run_again in the sequence, use the QtConsole to inspect or edit it before running. Substitute your instance name if different; result data reflects completed steps:

run_again.target_step = "dummy"
run_again.reconnect_and_configure = False
bind_sequence_steps(steps: list) → None[source]

Bind the nested sequence tree used during code generation.

config_widget(parent: QWidget | None = None) → QWidget[source]

Return the target-step selector and lifecycle option.

eligible_steps() → list[BasePlugin][source]

Return existing sequence steps other than this command instance.

execute() → None[source]

Reject direct calls; generated code executes the target action directly.

generate_action_code(indent: int, sub_steps: list, render_sub_step: Callable) → list[str][source]

Emit the selected step’s normal action code at this position.

property name: str

Unique human-readable name for this plugin.

to_json() → dict[str, Any][source]

Serialise this plugin’s configuration to a JSON-compatible dict.

The returned dict contains at minimum:

  • "type" — the plugin sub-type tag (e.g. "trace", "state").

  • "class" — the fully qualified class path "module:ClassName" used by from_json() to reconstruct the exact subclass.

  • "instance_name" — the current instance_name.

Subclasses should call super().to_json() and then add their own configuration keys to the returned dict.

Returns:

A JSON-serialisable dictionary representing this plugin’s current configuration.

Return type:

(dict[str, Any])

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.trace import DummyPlugin
>>> plugin = DummyPlugin()
>>> d = plugin.to_json()
>>> d["type"]
'trace'
>>> d["instance_name"]
'dummy'
>>> "class" in d
True