stoner_measurement.plugins.command.pressure_gauge_channel.PressureGaugeChannelCommand

class stoner_measurement.plugins.command.pressure_gauge_channel.PressureGaugeChannelCommand(parent=None)[source]

Bases: CommandPlugin

Enable or disable a pressure gauge channel using runtime expressions.

Use this command to switch a controllable gauge channel on or off at a particular step. On General, enter Channel expression and Enabled expression. They are evaluated in the live sequence namespace on each execution and converted to an integer channel and Boolean enable state. Blank fields revert to 1 and True respectively.

The action uses the shared pressure engine and the connected driver’s channel-control capability. Configure the controller in the pressure panel first. This command publishes no readings; use Pressure Monitor to record the resulting gauge state.

Variables:
  • channel_expr (str) – Integer channel expression; defaults to “1”.

  • enabled_expr (str) – Boolean enable expression; defaults to “True”.

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

pressure_gauge_channel.channel_expr = "1"
pressure_gauge_channel.enabled_expr = "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()
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