Skip to content

Commit 55700ce

Browse files
committed
Added set_wait_time and ACTION_MEASURE callback
1 parent 4a6ecb8 commit 55700ce

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎pyaml/tuning_tools/tune.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import TYPE_CHECKING
22

33
from .. import PyAMLException
4-
from ..common.constants import ACTION_APPLY, ACTION_RESTORE
4+
from ..common.constants import ACTION_APPLY, ACTION_MEASURE, ACTION_RESTORE
55
from ..common.element import Element, ElementConfigModel
66

77
if TYPE_CHECKING:
@@ -53,7 +53,7 @@ def __set_resp_map(self, mat):
5353
self.__respmatrix = mat
5454
self.__correctionmat = np.linalg.pinv(mat.T)
5555

56-
def measure(self, callback: Callable | None = None):
56+
def measure(self, callback: Callable | None = None, set_wait_time: float = 0):
5757
"""
5858
Measure tune response matrix
5959
@@ -64,6 +64,8 @@ def measure(self, callback: Callable | None = None):
6464
Callback executed after each strength setting. The magnet and step are
6565
passed as input arguement of the callback.
6666
If the callback return false, then the process is aborted.
67+
set_wait_time : float
68+
Wait after quad has been set
6769
"""
6870
quads = self.quads() # Returns attached quad devices
6971
tunemat = np.zeros((len(quads), 2))
@@ -80,10 +82,16 @@ def measure(self, callback: Callable | None = None):
8082
aborted = True
8183
break
8284

85+
time.sleep(set_wait_time)
86+
8387
tune = self.__parent.readback()
8488
dq = tune - initial_tune
8589
tunemat[idx] = dq / delta
8690

91+
if callback and not callback(idx, ACTION_MEASURE, m, tunemat[idx]):
92+
aborted = True
93+
break
94+
8795
# Restore strength
8896
m.strength.set(str)
8997
if callback and not callback(idx, ACTION_RESTORE, m, tunemat[idx]):

0 commit comments

Comments
 (0)