stoner_measurement.plugins.command.loop_control.BreakIfCommand

class stoner_measurement.plugins.command.loop_control.BreakIfCommand(parent=None, condition: str = 'True')[source]

Bases: _ConditionalLoopControlCommand

End the containing scan or sweep when a condition becomes true.

Use this command inside a scan or sweep when the remaining points should be abandoned after a runtime condition is met. The condition is evaluated in the live sequence namespace at the command’s position in each loop iteration. A true result executes Python’s break statement, ending the nearest containing scan or sweep; a false result lets the sequence continue normally.

The configuration tab contains the standard instance-name field and a Condition editor. Enter a Python expression that uses values already available in the sequence namespace, such as a measured output or a controller state. A blank condition is stored as True. This command must remain inside a scan or sweep in the sequence tree because break is not valid at the top level.

The command emits its conditional loop-control statement when the sequence script is generated. Calling execute() directly does nothing because loop control can only be applied by the generated code.

Variables:
  • condition (str) – Python expression evaluated before deciding whether to end the current scan or sweep. Defaults to "True".

  • statement (str) – Loop-control statement emitted into generated code. Always "break" for this plugin.

  • instance_name (str) – Inherited sequence-instance name. Defaults to "break_if".

  • 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.

  • condition (str) – Initial Python condition expression. Defaults to "True".

Examples

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

break_if.condition = "counter.value > maximum_value"
property name: str

Return the command’s human-readable name.

statement = 'break'