MCPcopy Create free account
hub / github.com/LabPy/lantz / Scan

Class Scan

lantz/ui/blocks/scan.py:60–145  ·  view source on GitHub ↗

A backend that iterates over an list of values, calling a `body` function in each step.

Source from the content-addressed store, hash-verified

58
59
60class Scan(Backend):
61 """A backend that iterates over an list of values,
62 calling a `body` function in each step.
63 """
64
65 #: Signal emitted before starting a new iteration
66 #: Parameters: loop counter, step value, overrun
67 iteration = QtCore.Signal(int, int, bool)
68
69 #: Signal emitted when the loop finished.
70 #: The parameter is used to inform if the loop was canceled.
71 loop_done = QtCore.Signal(bool)
72
73 #: The function to be called. It requires three parameters.
74 #: counter - the iteration number.
75 #: current value - the current value of the scan.
76 #: overrun - a boolean indicating if the time required for the operation
77 #: is longer than the interval.
78 #: :type: (int, int, bool) -> None
79 body = None
80
81 #: To be called before the body. Same signature as body
82 _pre_body = None
83
84 #: To be called after the body. Same signature as body
85 _post_body = None
86
87 def __init__(self, **kwargs):
88 super().__init__(**kwargs)
89 self._active = False
90 self._internal_func = None
91
92 def stop(self):
93 """Request the scanning to be stop.
94 Will stop when the current iteration is finished.
95 """
96 self._active = False
97
98 def start(self, body, interval=0, steps=(), timeout=0):
99 """Request the scanning to be started.
100
101 :param body: function to be called at each iteration.
102 If None, the class body will be used.
103 :param interval: interval between starts of the iteration.
104 If the body takes too long, the iteration will
105 be as fast as possible and the overrun flag will be True
106 :param steps: iterable
107 :param timeout: total time in seconds that the scanning will take.
108 If overdue, the scanning will be stopped.
109 If 0, there is no timeout.
110 """
111 self._active = True
112 body = body or self.body
113
114 iterations = len(steps)
115
116 def internal(counter, overrun=False, schedule=QtCore.QTimer.singleShot):
117 if not self._active:

Callers 1

scan.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected