stoner_measurement.plugins.command.wait.WaitCommand

class stoner_measurement.plugins.command.wait.WaitCommand(parent=None)[source]

Bases: CommandPlugin

Pause the sequence for a specified time.

Use this command when the sequence needs to wait before continuing. Common uses include allowing a system to settle after a change, adding a fixed delay between steps, or making the delay depend on values already present in the sequence namespace.

In the configuration panel, set the delay expression to either a fixed number of seconds or a Python expression, for example:

"settling_time * 1.5"

When the step runs, the sequence sleeps for the resulting number of seconds.

The configuration tab contains the standard instance-name field and a single delay expression editor. The Help/About tab uses this docstring to explain that the expression is evaluated in the sequence namespace and converted to a delay in seconds.

Variables:
  • delay_expr (str) – Python expression string that evaluates to a delay in seconds. Defaults to "1.0".

  • 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 wait in the sequence, use the QtConsole to inspect or edit it before running. Substitute your instance name if different; result data reflects completed steps:

wait.delay_expr = "settling_time * 1.5"
config_widget(parent: QWidget | None = None) → QWidget[source]

Return a settings widget with a delay-expression editor.

Displays a QFormLayout containing an SISpinBox that accepts either an SI-aware duration or a Python expression string, and a brief description label.

Keyword Parameters:

parent (QWidget | None) – Optional Qt parent widget.

Returns:

The settings widget for the Settings tab.

Return type:

(QWidget)

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.command.wait import WaitCommand
>>> from qtpy.QtWidgets import QWidget
>>> isinstance(WaitCommand().config_widget(), QWidget)
True
execute(*, delay: float | None = None) → None[source]

Evaluate delay_expr and sleep for the resulting duration.

Keyword Parameters:

delay (float | None) – When provided, this value is used directly as the sleep duration in seconds, overriding the evaluated delay_expr setting.

Raises:
  • RuntimeError – If the plugin is not attached to a sequence engine and delay is not provided.

  • TypeError – If delay_expr does not evaluate to a numeric value and delay is not provided.

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.command.wait import WaitCommand
>>> cmd = WaitCommand()
>>> import time
>>> t0 = time.monotonic()
>>> cmd.execute(delay=0.01)
>>> time.monotonic() - t0 >= 0.01
True
property name: str

Unique identifier for the wait command.

Returns:

"Wait".

Return type:

(str)

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.command.wait import WaitCommand
>>> WaitCommand().name
'Wait'
to_json() → dict[str, Any][source]

Serialise the wait command configuration to a JSON-compatible dict.

Returns:

Base dict from to_json() extended with "delay_expr".

Return type:

(dict[str, Any])

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.command.wait import WaitCommand
>>> d = WaitCommand().to_json()
>>> d["type"]
'command'
>>> "delay_expr" in d
True