stoner_measurement.plugins.monitor.motor_controller.MotorAngleMonitorPlugin¶
- class stoner_measurement.plugins.monitor.motor_controller.MotorAngleMonitorPlugin(parent=None)[source]¶
Bases:
MonitorPluginMonitor motor position and motion state without commanding movement.
Use this passive monitor when other sequence plugins need access to the current motor angle or motion status but should not change the motor target. On connection it opens the application’s preferred motor controller when necessary and starts the standard one-second monitor timer. Disconnecting stops this plugin’s timer while leaving the shared motor-controller engine available to scan, sweep, and set-position plugins.
The configuration page selects which quantities appear in the sequence value catalogue: Angle and Target Angle in degrees, Angular Rate in degrees per second, and the unitless Moving, At Target, and Stable flags. Boolean states are published as
1.0or0.0; unavailable position or motion readings are reported as NaN.By default each read uses the latest state cached by the shared engine, avoiding an extra instrument transaction. Enable Force fresh controller poll when every monitor read must query the hardware directly. Fresh polling improves immediacy but increases communication traffic and may reduce the rate available to other controller operations.
This plugin is a leaf sequence step. A direct sequence execution performs one synchronous
read(), while its timer can continue to updatelast_readingduring an active measurement lifecycle. It never sets velocity, acceleration, direction, or target position.The General tab sets the instance name and comment. Measurement selection and polling options are on Settings.
- Variables:
report_angle (bool) – Publish the measured angle in degrees.
report_target_angle (bool) – Publish the active target angle in degrees.
report_moving (bool) – Publish whether the motor is currently moving.
report_angular_rate (bool) – Publish the measured angular rate in degrees per second.
report_at_target (bool) – Publish the engine’s at-target state.
report_stability (bool) – Publish the engine’s stable-state indication.
force_fresh_poll (bool) – Query the controller during every read instead of using cached engine state.
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
motor_angle_monitorin the sequence, use the QtConsole to inspect or edit it before running. Substitute your instance name if different; result data reflects completed steps:motor_angle_monitor.force_fresh_poll = False motor_angle_monitor.last_reading
- config_widget(parent: QWidget | None = None) QWidget[source]¶
Return a
QWidgetfor 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.
- declared_outputs() PluginOutputs[source]¶
Declare configured outputs and their physical units together.
- 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_availableonce 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 emitsread_error.- Returns:
Mapping of quantity name to measured value.
- Return type:
- 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 byfrom_json()to reconstruct the exact subclass."instance_name"— the currentinstance_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:
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