Looper
The conditional loop executor: decides automatically, from measurement results, whether to repeat, jump or end an experiment loop.
Overview
Looper is a tab in the top dock of the experiment browser (Browser)
(quatm/GUI/looper/). It manages groups of experiment tasks, executes the items of a group
in order, and decides whether to jump or to stop based on the measurement results. Loop
definitions are persisted in configuration/browser/looper/loopfile.json, and the same file
is shared with the experiment console on the browser side
(Web remote control).
Core logic
LoopManager.run_loop(): loop from the start group forever until terminate
└─→ run the items of the group in order
├─ Task: submit to the experiment queue and advance after it finishes
│ (max count / max consecutive count can be set; reaching either ends the loop)
└─ Conditional: read a data-stream field → compare (> >= == != =< <)
├─ true → jump to the given item / end of group / end of loop
└─ false → jump to the else item
Components
| Component | Description |
|---|---|
LoopGroup | A loop group (one tab), containing the item list and the loop builder |
LoopItem | Item base class (delete/up/down/run counter/indicator LED) |
TaskItem | Task item: points to a staged task, supports max count/max consecutive/skip |
ListItem | Task list item: expands a task list and runs the tasks one by one |
ConditionalItem | Data condition item: compares a field and then jumps (if/else) |
ConditionalReachedItem | Reached-index condition item: jumps once the current time reaches the N-th cycle’s h5 save time |
ConditionalDateTimeItem | Time condition item |
CallerItem / GroupItem | Inter-group jump and end-of-group items |
DataManager | Subscribes to data streams and accumulates the latest measurement values |
LoopManager | The loop executor (run_loop() / terminate(), running in a background thread) |
AutoSaveEditor | Configuration of the automatic HDF5 save schedule |
How to use
Operate interactively through the Looper tab in the experiment browser (Browser):
- Add a group: create a new tab (
New Tab #N), which can be renamed; - Add items: each group can contain Task / List / Conditional / ConditionalDateTime / ConditionalReached / Caller and other items;
- Configure items: for Task, select the staged task number and set the maximum count; for
Conditional, select the data field, comparison operator and threshold, and configure the
if/else jump targets (item index /
end box/end loop); - Run: select the starting group and click run;
LoopManagerexecutes in a background thread and the terminate button stops it at any time.
# core classes (used internally by the GUI)
from quatm.GUI.looper import Looper, LoopManager
looper = Looper(parent=browser)
looper.loopManager.run_loop() # start looping from the start group
looper.loopManager.terminate() # terminate the loop
Persistence and sharing
- Loop definitions are saved automatically to
configuration/browser/looper/loopfile.json({group name: [item dictionaries, ...]}) and restored automatically when the browser restarts; - The desktop GUI and the web remote-control platform share the same file, so changes made on either side are immediately visible on the other; the browser side likewise supports group management, Task/Conditional item editing and starting/stopping loops.