stoner_measurement.plugins.command.edit_function_scan.EditFunctionScanCommand¶
- class stoner_measurement.plugins.command.edit_function_scan.EditFunctionScanCommand(parent=None)[source]¶
Bases:
CommandPluginChange a later function-generator scan while a sequence is running.
Use this command when a state scan or trace scan needs an initial function generator configuration that is replaced later in the same sequence. Place the command before the scan step that should use the new points. The target list contains sequence instances whose active scan generator is a
FunctionScanGenerator; both state-scan and trace-plugin instances are supported.The configuration tab provides a Scan plugin selector followed by optional Amplitude, Offset, Periods, Points, Exponent, Phase, and Waveform expressions. Leave a field blank to retain that generator setting exactly as it is. A non-blank field is evaluated in the sequence namespace when this command runs. Waveform accepts
Sine,Triangle,Square, orSawtooth, or an expression resolving to one of those values. Enable Reconfigure scan plugin after editing to call the target plugin’sconfigure()method immediately afterwards.All supplied expressions are evaluated before any setting is changed, so an evaluation error leaves the generator untouched. If evaluation succeeds, the supplied settings are applied together and the scan values are regenerated immediately. This command does not execute the target scan and does not publish scalar outputs.
- Variables:
target_scan (str) – Instance name of the state or trace scan to edit.
amplitude_expr (str) – Optional expression replacing the waveform amplitude.
offset_expr (str) – Optional expression replacing the waveform offset.
periods_expr (str) – Optional expression replacing the number of waveform periods.
points_expr (str) – Optional expression replacing the integer number of scan points.
exponent_expr (str) – Optional expression replacing the waveform exponent.
waveform_expr (str) – Optional waveform name or expression resolving to a waveform name.
phase_expr (str) – Optional expression replacing the phase in degrees.
reconfigure_after_edit (bool) – Whether generated sequence code calls
configure()on the target scan plugin immediately after this command.instance_name (str) – Inherited sequence-instance name for this command.
sequence_engine (SequenceEngine | None) – Inherited reference to the sequence engine and its live namespace.
comment (str) – Inherited optional note displayed beside this step.
- Keyword Parameters:
parent (QObject | None) – Optional Qt parent object.
Examples
With an instance named
edit_function_scanin the sequence, use the QtConsole to inspect or edit it before running. Substitute your instance name if different; result data reflects completed steps:edit_function_scan.target_scan = "field_scan" edit_function_scan.amplitude_expr = "next_amplitude" edit_function_scan.points_expr = "100"
- config_widget(parent: QWidget | None = None) QWidget[source]¶
Return the target picker and optional replacement-expression fields.
- eligible_scans() list[StateScanPlugin | TracePlugin][source]¶
Return sequence state and trace scans using a function generator.
- generate_action_code(indent: int, sub_steps: list, render_sub_step: Callable) list[str][source]¶
Render the edit call followed by optional target reconfiguration.
- 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 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