stoner_measurement.plugins.monitor.pressure_controller.PressureMonitorPlugin

class stoner_measurement.plugins.monitor.pressure_controller.PressureMonitorPlugin(parent=None)[source]

Bases: MonitorPlugin

Publish live pressure-controller and MFC values into the sequence namespace.

Use this passive monitor to record vacuum pressure and mass-flow-controller (MFC) readings alongside measurements. On Settings, select pressure and MFC channel lists; blank lists mean all channels known to the shared engine. Enable pressure, gauge-enabled state, requested flow, actual flow and/or target-pressure outputs. Force fresh controller poll requests a hardware update on each read instead of using cached state.

Connection opens the preferred pressure controller and/or MFC if needed and starts monitoring. Disconnect stops this monitor while leaving shared controllers connected. Outputs use names such as pressure_1 and flow_actual_1 in last_reading. Pressure and flow units come from the controller; enabled flags are 1 or 0 and unavailable readings are NaN.

The General tab sets the instance name and comment. Measurement selection and polling options are on Settings.

Variables:
  • pressure_channels (list[int] | None) – Gauge channels; None selects known channels.

  • mfc_channels (list[int] | None) – MFC channels; None selects known channels.

  • report_pressures (bool) – Publish measured pressures.

  • report_gauge_enabled (bool) – Publish gauge enable states.

  • report_flow_setpoints (bool) – Publish requested flows.

  • report_flow_actual (bool) – Publish measured flows.

  • report_target_pressures (bool) – Publish MFC pressure targets.

  • force_fresh_poll (bool) – Request new controller state on every read; 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.

  • last_reading (dict[str, float]) – Inherited read-only access to the latest cached readings.

  • monitor_interval (int) – Inherited timer polling interval in milliseconds; initially 1000.

Keyword Parameters:

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

Examples

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

pressure_monitor.pressure_channels = [1, 2]
pressure_monitor.mfc_channels = [1]
pressure_monitor.last_reading
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
configure() → None[source]

No-op: the shared pressure engine owns the hardware configuration.

connect() → None[source]

Open owned resources; repeated calls must first release existing ones.

The shared lifecycle wrapper calls disconnect() before retrying a previous connection attempt, including a partially failed attempt. Resource-owning plugins must implement idempotent disconnect() that also closes partially opened resources and clears their references. The default is a no-op for plugins without hardware resources.

property controller_features: frozenset[str]

Return controller feature flags required by this plugin.

declared_outputs() → PluginOutputs[source]

Declare configured outputs and their physical units together.

disconnect(a0: QMetaObject.Connection) → bool[source]
disconnect(self)
property name: str

Unique human-readable name for this plugin.

property quantity_names: list[str]

Ordered list of quantity identifiers returned by read().

Returns:

Names matching the keys in the dict returned by read().

Return type:

(list[str])

read(*, force_poll: bool = False) → dict[str, float][source]

Perform a single synchronous hardware read and return the results.

Subclasses implement acquisition only. The base class wraps overrides to cache a copy and emit data_available once after a successful outermost read. Direct, timer and generated calls share this behaviour. Failed reads propagate without replacing the last successful reading; the polling callback additionally emits read_error.

Returns:

Mapping of quantity name to measured value.

Return type:

(dict[str, float])

Raises:

Exception – Any hardware communication error; callers should handle exceptions appropriately.

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.monitor import MonitorPlugin
>>> class _ConstMonitor(MonitorPlugin):
...     @property
...     def name(self): return "Const"
...     @property
...     def quantity_names(self): return ["x"]
...     @property
...     def units(self): return {"x": "au"}
...     def read(self): return {"x": 42.0}
>>> m = _ConstMonitor()
>>> m.read()
{'x': 42.0}
to_json() → dict[str, object][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
property units: dict[str, str]

Mapping of quantity name to physical unit string.

Returns:

E.g. {"temperature": "K", "pressure": "Pa"}.

Return type:

(dict[str, str])