stoner_measurement.plugins.command.make_safe.MakeSafeCommand

class stoner_measurement.plugins.command.make_safe.MakeSafeCommand(parent=None)[source]

Bases: CommandPlugin

Make the selected temperature, magnet, and motor systems safe.

Use this command to perform the application’s defined shutdown actions at a chosen sequence position. On General, select Temperature, Magnet, and/or Motor; all three are selected initially. Enable Always make safe to also execute these actions at the start of the generated script’s finally block, including when the sequence fails.

For a connected temperature controller, heater outputs and ranges are set to zero and control loops switched off. Supported gas-auto and needle-valve controls are disabled or closed. A connected magnet is ramped to zero, with a five-minute wait for the target, before its heater is switched off. The motor is sent home using the shortest route. Temperature and magnet actions are skipped if their controllers are disconnected.

Actions run in temperature, magnet, then motor order. A failure propagates and prevents later actions in this call; this is not a guarantee that every system has reached a safe state. The command publishes no scalar outputs.

Variables:
  • temperature (bool) – Switch off temperature control; defaults to True.

  • magnet (bool) – Ramp to zero and switch off the magnet heater; defaults to True.

  • motor (bool) – Send the motor home; defaults to True.

  • always_make_safe (bool) – Also run during generated sequence cleanup; 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 make_safe in the sequence, use the QtConsole to inspect or edit it before running. Substitute your instance name if different; result data reflects completed steps:

make_safe.temperature = True
make_safe.magnet = True
make_safe.motor = False
make_safe.always_make_safe = True
config_widget(parent: QWidget | None = None) → QWidget[source]

Return a QWidget for configuring this plugin.

The default implementation returns a simple label. Override this method to provide a richer configuration interface. This method is called by the default config_tabs() implementation to supply the single tab widget.

Keyword Parameters:

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

Returns:

The configuration widget for this plugin.

Return type:

(QWidget)

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.trace import DummyPlugin
>>> plugin = DummyPlugin()
>>> widget = plugin.config_widget()
>>> widget is not None
True
property controller_features: frozenset[str]

Return controller feature flags required by this plugin.

execute() → None[source]

Perform the command action.

Called by the generated sequence script once per sequence step occurrence. The method has access to the full sequence engine namespace via engine_namespace and can evaluate Python expressions against it using eval().

The plugin instance is also callable — invoking plugin() is equivalent to calling plugin.execute().

Raises:

Exception – Any exception raised here propagates to the sequence engine and is reported as a script error attributed to this plugin.

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.command import CommandPlugin
>>> class _Log(CommandPlugin):
...     @property
...     def name(self): return "Logger"
...     def execute(self):
...         self.log.info("sequence step reached")
>>> p = _Log()
>>> p.execute()  # no error when detached (uses fallback logger)
>>> p()          # equivalent — __call__ delegates to execute()
generate_finally_code(indent: int) → list[str][source]

Return optional lines to run before lifecycle disconnects in finally.

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