Condition

From SweepMe! Wiki
Jump to navigation Jump to search

Condition is a Module that performs actions depending on whether a condition is fulfilled. For example, a measurement point can be skipped, the remaining points of a sweep can be skipped, or the current branch of the sequence can be left so that the procedure continues with the next one.

Usage

A Condition module can hold several conditions. Each condition has its own tab:

  • Click Add (next to the tabs) to add a further condition. New conditions are named Cond1, Cond2, and so on.
  • Double-click a tab to rename it. Each name can only be used once per module.
  • Drag a tab to change the order of the conditions. The conditions are evaluated in the order of the tabs.
  • Click Remove at the bottom of a tab to delete this condition. The button is only shown if the module holds more than one condition.

Each condition consists of:

  1. Execution: when the condition is evaluated, see Execution.
  2. If: the value to be checked, e.g. a measured value or the sweep value of another module. Click the field to get a list of all parameters in parameter syntax {...}. You can also type in your own text.
  3. an operator, see Operators.
  4. a value to compare with, see Values.
  5. Then: a list of actions that are performed if the condition is True.
  6. Else: a list of actions that are performed if the condition is False.
  7. Notes: an optional text to document the purpose of the condition.

The Then and Else lists can be empty. To edit a list, right-click into it:

  • Add function... opens a list of all available actions, see Actions.
  • Remove, Move up, and Move down change the selected action.

Several actions are performed from top to bottom. The selected action can also be moved by drag and drop or with the keys Page Up, Page Down, Home, and End, and it can be removed with the key Del.

More complex conditions are possible in conjunction with the module Calc: create a variable that is True or False based on multiple values, and let the Condition module check whether the result of Calc is True.

GUI of the Condition module
GUI of the Condition module

Debug

To find out why a condition does not behave as expected, right-click into the tab of the condition (outside of the Then and Else lists) and check Debug. Each time the condition is evaluated, the variable, the operator, the value, the types of variable and value, and the result are printed to the Debug widget. The option is set for each condition separately.

Operators

The following operators can be used:

  • > (greater than)
  • < (less than)
  • >= (greater or equal)
  • <= (less or equal)
  • == (equal)
  • != (unequal)
  • is (identity)
  • is not (not identity)
  • in (contained in list or set)
  • not in (not contained in list or set)

Values

The fields If and the value field next to the operator are handled in the same way:

  • If the field contains exactly one parameter {...}, e.g. one selected from the list of the If field, the current value of this parameter is used.
  • Otherwise, all parameters {...} in the text are replaced by their current values and the result is evaluated as a Python expression. This way, numbers like 5 or 1e-3, the values True and False, lists like [1, 2, 3], or calculations that contain parameters can be used.
  • If the text cannot be evaluated, it is used as a string. For example, open is compared as the string 'open'.

Both values are compared by Python, so the types must fit to each other. For example, a number cannot be compared with a string using >. If the comparison fails, an error message is shown in the Debug widget.

Actions

Right-click into the Then or Else list and select Add function... to get a list of all actions, sorted alphabetically. The list contains the actions of the Condition module, the standard actions of SweepMe!, and the actions that are provided by other modules, drivers, widgets, and CustomFunction scripts of the current sequence.

skip_point

Skips a single measurement point. This works best if the condition is related to the sweep value of a module in the branch and is evaluated before the point is measured, e.g. with Execution "Before each point (in 'start')".

skip_sweeps_below

All remaining variations of modules that are below the Condition module in the sequencer are skipped, and the procedure continues with the next variation of a module above the Condition module.

skip_current_branch

All variations that remain in the current branch of the sequencer are skipped, and the procedure continues with the first variation of the next branch.

stop

Stops the measurement, same as clicking the button "Stop".

pause, resume, toggle_pause

pause pauses the measurement, same as clicking the button "Pause". resume continues a paused measurement, and toggle_pause switches between both states.

run

Starts a measurement, same as clicking the button "Run". This action is also offered in the list, but it has no use within a running measurement.

Actions of modules, drivers, widgets, and scripts

Modules, drivers, widgets, and CustomFunction scripts can provide their own actions. Their names start with the label of the module or widget, for example:

  • smu1.driver.reset: the action "reset" of the driver used in the module with the label "SMU1"
  • waferprober1.skip_current_wafer: an action of the WaferProber module with the label "WaferProber1"
  • customfunction1.script.myscript.my_action: an action of the CustomFunction script "myscript" in the module "CustomFunction1"
  • names starting with widget: are actions of widgets

The names are always shown in lower case. If you rename a module, the names of its actions change as well, so you need to select the actions again. The same actions can be assigned to the trigger buttons of the ControlWidgets module.

Sequences created with older module versions use the action names SkipPoint, SkipSweepsBelow, SkipCurrentBranch, Stop, and Pause. These names are still understood.

Execution

The parameter 'Execution' defines when the Condition is checked:

  • Always: At every possible step (see below).
  • Before branch (in 'configure'): Before the branch is entered and before configure() of child items is called. Can be used to stop a sweep or to skip a branch at the earliest possible moment.
  • Before each point (in 'start'): At the beginning of a measurement point in the start() phase.
    In module versions before 2024-04-16 this option was called "At the beginning".
  • Before branch and each point (in 'configure' + in 'start'): Combines both of the above.
    In module versions before 2024-04-16 this option was called "Before point".
  • After each point (in 'finish'): After the measurement point is finished and new data has been acquired, in the finish phase of the sequencer procedure.
    In module versions before 2024-04-16 this option was called "At the end".
  • Never: No execution will be done. Can be used to switch off this condition.

From SweepMe! 1.5.8.8, conditions with "Before branch" are evaluated during the configure step as described above.

Applications

  • Conditional sweeping: Create different branches for multiple measurement modes, and choose which branches to run based on the sample.
  • Stop a measurement: Automatically halt the entire measurement if a predefined critical value is reached, ensuring safety and precision.
  • Pause a measurement: Temporarily pause the sequence to allow for system stabilization or manual intervention before proceeding.