From 9186c2e3f98599fe0aade0f46f391cd325cf4645 Mon Sep 17 00:00:00 2001 From: Matheus Date: Tue, 18 Feb 2025 15:27:50 -0300 Subject: [PATCH 1/8] COMMISS.MNT: change limits klys and SHB limits --- apsuite/commisslib/injbo_optimize_rcds.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apsuite/commisslib/injbo_optimize_rcds.py b/apsuite/commisslib/injbo_optimize_rcds.py index b03f26b8..bce70df7 100644 --- a/apsuite/commisslib/injbo_optimize_rcds.py +++ b/apsuite/commisslib/injbo_optimize_rcds.py @@ -118,8 +118,8 @@ class OptimizeInjBOParams(_RCDSParams): 91, # 'kly1_amp', 76, # 'kly2_amp', 180, # 'shb_phs', - 180, # 'kly1_phs', - 180, # 'kly2_phs', + -150, # 'kly1_phs', + 0, # 'kly2_phs', 80, # 'borf_amp', 160, # 'borf_phs', @@ -172,9 +172,9 @@ class OptimizeInjBOParams(_RCDSParams): 20, # 'shb_amp', 85, # 'kly1_amp', 70, # 'kly2_amp', - -180, # 'shb_phs', + 160, # 'shb_phs', -180, # 'kly1_phs', - -180, # 'kly2_phs', + -20, # 'kly2_phs', 30, # 'borf_amp', 90, # 'borf_phs', From 2fa879976a5ab1ca75180668bd463f9c8abcfbad Mon Sep 17 00:00:00 2001 From: Matheus Date: Tue, 18 Feb 2025 15:29:17 -0300 Subject: [PATCH 2/8] COMMISS.INJBO.ENH: use SP vals when reading positions for posang & LILLRF --- apsuite/commisslib/injbo_optimize_rcds.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apsuite/commisslib/injbo_optimize_rcds.py b/apsuite/commisslib/injbo_optimize_rcds.py index bce70df7..36aaef02 100644 --- a/apsuite/commisslib/injbo_optimize_rcds.py +++ b/apsuite/commisslib/injbo_optimize_rcds.py @@ -396,28 +396,28 @@ def get_current_position(self): pos.append(self.devices['tb_qd2b'].current) elif fun('posx'): - pos.append(self.devices['pos_ang'].delta_posx) + pos.append(self.devices['pos_ang']['DeltaPosX-SP']) elif fun('angx'): - pos.append(self.devices['pos_ang'].delta_angx) + pos.append(self.devices['pos_ang']['DeltaAngX-SP']) elif fun('posy'): - pos.append(self.devices['pos_ang'].delta_posy) + pos.append(self.devices['pos_ang']['DeltaPosY-SP']) elif fun('angy'): - pos.append(self.devices['pos_ang'].delta_angy) + pos.append(self.devices['pos_ang']['DeltaAngY-SP']) elif fun('kckr'): - pos.append(self.devices['injkckr'].strength) + pos.append(self.devices['injkckr']['Kick-SP']) elif fun('shb_amp'): - pos.append(self.devices['li_llrf'].dev_shb.amplitude) + pos.append(self.devices['li_llrf'].dev_shb['SET_AMP']) elif fun('kly1_amp'): - pos.append(self.devices['li_llrf'].dev_klystron1.amplitude) + pos.append(self.devices['li_llrf'].dev_klystron1['SET_AMP']) elif fun('kly2_amp'): - pos.append(self.devices['li_llrf'].dev_klystron2.amplitude) + pos.append(self.devices['li_llrf'].dev_klystron2['SET_AMP']) elif fun('shb_phs'): - pos.append(self.devices['li_llrf'].dev_shb.phase) + pos.append(self.devices['li_llrf'].dev_shb['SET_PHASE']) elif fun('kly1_phs'): - pos.append(self.devices['li_llrf'].dev_klystron1.phase) + pos.append(self.devices['li_llrf'].dev_klystron1['SET_PHASE']) elif fun('kly2_phs'): - pos.append(self.devices['li_llrf'].dev_klystron2.phase) + pos.append(self.devices['li_llrf'].dev_klystron2['SET_AMP']) elif fun('borf_amp'): pos.append(self.devices['bo_llrf'].voltage_bottom) From 10377c806d50e98662c406724d3a04185c91229c Mon Sep 17 00:00:00 2001 From: Matheus Date: Wed, 19 Feb 2025 14:27:52 -0300 Subject: [PATCH 3/8] COMMISS.INJBO.ENH: use PS `set_current` method --- apsuite/commisslib/injbo_optimize_rcds.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apsuite/commisslib/injbo_optimize_rcds.py b/apsuite/commisslib/injbo_optimize_rcds.py index 36aaef02..2c52c550 100644 --- a/apsuite/commisslib/injbo_optimize_rcds.py +++ b/apsuite/commisslib/injbo_optimize_rcds.py @@ -488,24 +488,24 @@ def set_position_to_machine(self, pos): self.pvs["li_slnd21"].value = p elif fun('li_qf1'): - self.devices['li_qf1'].current = p + self.devices['li_qf1'].set_current(p) elif fun('li_qf2'): - self.devices['li_qf2'].current = p + self.devices['li_qf2'].set_current(p) elif fun('li_qf3'): - self.devices['li_qf3'].current = p + self.devices['li_qf3'].set_current(p) elif fun('li_qd1'): - self.devices['li_qd1'].current = p + self.devices['li_qd1'].set_current(p) elif fun('li_qd2'): - self.devices['li_qd2'].current = p + self.devices['li_qd2'].set_current(p) elif fun('tb_qf2a'): - self.devices['tb_qf2a'].current = p + self.devices['tb_qf2a'].set_current(p) elif fun('tb_qf2b'): - self.devices['tb_qf2b'].current = p + self.devices['tb_qf2b'].set_current(p) elif fun('tb_qd2a'): - self.devices['tb_qd2a'].current = p + self.devices['tb_qd2a'].set_current(p) elif fun('tb_qd2b'): - self.devices['tb_qd2b'].current = p + self.devices['tb_qd2b'].set_current(p) elif fun('posx'): self.devices['pos_ang'].delta_posx = p @@ -516,7 +516,7 @@ def set_position_to_machine(self, pos): elif fun('angy'): self.devices['pos_ang'].delta_angy = p elif fun('kckr'): - self.devices['injkckr'].strength = p + self.devices['injkckr'].set_strength(p) elif fun('shb_amp'): self.devices['li_llrf'].dev_shb.amplitude = p From c8fb6fb1889a4d12b22ba70e3014503da14041ed Mon Sep 17 00:00:00 2001 From: Matheus Date: Wed, 19 Feb 2025 15:51:19 -0300 Subject: [PATCH 4/8] COMMISS.INJOPT.ENH: add TB ch, cvs and injsept (alternative to posang knobs) --- apsuite/commisslib/injbo_optimize_rcds.py | 46 +++++++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/apsuite/commisslib/injbo_optimize_rcds.py b/apsuite/commisslib/injbo_optimize_rcds.py index 2c52c550..434cef74 100644 --- a/apsuite/commisslib/injbo_optimize_rcds.py +++ b/apsuite/commisslib/injbo_optimize_rcds.py @@ -59,6 +59,11 @@ class OptimizeInjBOParams(_RCDSParams): 'angy', 'kckr', + "tb_ch1", + "tb_injsept", + "tb_cv1", + "tb_cv2", + 'shb_amp', 'kly1_amp', 'kly2_amp', @@ -114,12 +119,17 @@ class OptimizeInjBOParams(_RCDSParams): +1.0, # 'angy', -19.0, # 'kckr', + +10.0, # tb_ch1 + 0.0, # tb_injsept + +10.0, # tb_cv1 + +10.0, # tb_cv2 + 40, # 'shb_amp', 91, # 'kly1_amp', 76, # 'kly2_amp', 180, # 'shb_phs', - -150, # 'kly1_phs', - 0, # 'kly2_phs', + -150, # 'kly1_phs', + 0, # 'kly2_phs', 80, # 'borf_amp', 160, # 'borf_phs', @@ -169,12 +179,17 @@ class OptimizeInjBOParams(_RCDSParams): -1.0, # 'angy', -25.0, # 'kckr', + -10.0, # tb_ch1 + -776.69, # tb_injsept + -10.0, # tb_cv1 + -10.0, # tb_cv2 + 20, # 'shb_amp', 85, # 'kly1_amp', 70, # 'kly2_amp', - 160, # 'shb_phs', + 160, # 'shb_phs', -180, # 'kly1_phs', - -20, # 'kly2_phs', + -20, # 'kly2_phs', 30, # 'borf_amp', 90, # 'borf_phs', @@ -406,6 +421,15 @@ def get_current_position(self): elif fun('kckr'): pos.append(self.devices['injkckr']['Kick-SP']) + elif fun('tb_ch1'): + pos.append(self.devices['tb_ch1'].current) + elif fun('tb_injsept'): + pos.append(self.devices['tb_injsept'].strength) + elif fun('tb_cv1'): + pos.append(self.devices['tb_cv1'].current) + elif fun('tb_cv2'): + pos.append(self.devices['tb_cv2'].current) + elif fun('shb_amp'): pos.append(self.devices['li_llrf'].dev_shb['SET_AMP']) elif fun('kly1_amp'): @@ -518,6 +542,15 @@ def set_position_to_machine(self, pos): elif fun('kckr'): self.devices['injkckr'].set_strength(p) + elif fun('tb_ch1'): + self.devices['tb_ch1'].set_current(p) + elif fun('tb_injsept'): + self.devices['tb_injsept'].set_strength(p) + elif fun('tb_cv1'): + self.devices['tb_cv1'].set_current(p) + elif fun('tb_cv2'): + self.devices['tb_cv2'].set_current(p) + elif fun('shb_amp'): self.devices['li_llrf'].dev_shb.amplitude = p elif fun('kly1_amp'): @@ -582,6 +615,11 @@ def _create_devices(self): self.devices['pos_ang'] = PosAng(PosAng.DEVICES.TB) self.devices['injkckr'] = PowerSupplyPU( PowerSupplyPU.DEVICES.BO_INJ_KCKR) + # TB PosAng knobs (alternative to PosAng) + self.devices["tb_ch1"] = PowerSupply("TB-04:PS-CH-1") + self.devices["tb_injsept"] = PowerSupplyPU("TB-04:PU-InjSept") + self.devices["tb_cv1"] = PowerSupply("TB-04:PS-CV-1") + self.devices["tb_cv2"] = PowerSupply("TB-04:PS-CV-2") # LI LLRF self.devices['li_llrf'] = LILLRF() # BO LLRF From d8cae96bcbcb0f31302a53c2068e84bb2d4b36db Mon Sep 17 00:00:00 2001 From: Matheus Date: Thu, 20 Feb 2025 13:55:22 -0300 Subject: [PATCH 5/8] COMMISS.INJBO.ENH: avoid PVs waiting time serialization - add `wait_set_pos` method - pos set to devices SP PVs directly - waits all RB vals reach SP vals after --- apsuite/commisslib/injbo_optimize_rcds.py | 44 +++++++++++++++-------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/apsuite/commisslib/injbo_optimize_rcds.py b/apsuite/commisslib/injbo_optimize_rcds.py index 434cef74..4e515821 100644 --- a/apsuite/commisslib/injbo_optimize_rcds.py +++ b/apsuite/commisslib/injbo_optimize_rcds.py @@ -512,24 +512,24 @@ def set_position_to_machine(self, pos): self.pvs["li_slnd21"].value = p elif fun('li_qf1'): - self.devices['li_qf1'].set_current(p) + self.devices['li_qf1'].current = p elif fun('li_qf2'): - self.devices['li_qf2'].set_current(p) + self.devices['li_qf2'].current = p elif fun('li_qf3'): - self.devices['li_qf3'].set_current(p) + self.devices['li_qf3'].current = p elif fun('li_qd1'): - self.devices['li_qd1'].set_current(p) + self.devices['li_qd1'].current = p elif fun('li_qd2'): - self.devices['li_qd2'].set_current(p) + self.devices['li_qd2'].current = p elif fun('tb_qf2a'): - self.devices['tb_qf2a'].set_current(p) + self.devices['tb_qf2a'].current = p elif fun('tb_qf2b'): - self.devices['tb_qf2b'].set_current(p) + self.devices['tb_qf2b'].current = p elif fun('tb_qd2a'): - self.devices['tb_qd2a'].set_current(p) + self.devices['tb_qd2a'].current = p elif fun('tb_qd2b'): - self.devices['tb_qd2b'].set_current(p) + self.devices['tb_qd2b'].current = p elif fun('posx'): self.devices['pos_ang'].delta_posx = p @@ -540,16 +540,16 @@ def set_position_to_machine(self, pos): elif fun('angy'): self.devices['pos_ang'].delta_angy = p elif fun('kckr'): - self.devices['injkckr'].set_strength(p) + self.devices['injkckr'].strength = p elif fun('tb_ch1'): - self.devices['tb_ch1'].set_current(p) + self.devices['tb_ch1'].current = p elif fun('tb_injsept'): - self.devices['tb_injsept'].set_strength(p) + self.devices['tb_injsept'].strength = p elif fun('tb_cv1'): - self.devices['tb_cv1'].set_current(p) + self.devices['tb_cv1'].current = p elif fun('tb_cv2'): - self.devices['tb_cv2'].set_current(p) + self.devices['tb_cv2'].current = p elif fun('shb_amp'): self.devices['li_llrf'].dev_shb.amplitude = p @@ -571,6 +571,8 @@ def set_position_to_machine(self, pos): else: raise ValueError('Wrong specification of knob.') + self.wait_set_pos(pos, timeout=10, rtol=0.05, atol=0.1) + def _create_devices(self): # knobs devices # lenses @@ -643,3 +645,17 @@ def _initialization(self): self.data['currents'] = [] self.prepare_evg() return True + + def wait_set_pos(self, pos, timeout=10, rtol=0.05, atol=0.1): + """.""" + sleep_time = 0.1 + it = int(timeout/sleep_time) + for _ in range(it): + pos_ = self.get_current_position() + if _np.all(_np.isclose(pos_, pos, atol=atol, rtol=rtol)): + break + # return True ? + _time.sleep(sleep_time) + else: + _log.warning('Timed out waiting positions be set.') + # return False ? From 2d89b582317bb1422dec3e821a8c0ec84073c9f3 Mon Sep 17 00:00:00 2001 From: Matheus Date: Fri, 4 Apr 2025 15:53:45 -0300 Subject: [PATCH 6/8] COMMISS.INJBOOPT.ENH: standardize getting positions from RB values instead of SP --- apsuite/commisslib/injbo_optimize_rcds.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apsuite/commisslib/injbo_optimize_rcds.py b/apsuite/commisslib/injbo_optimize_rcds.py index 4e515821..a3d5ddc2 100644 --- a/apsuite/commisslib/injbo_optimize_rcds.py +++ b/apsuite/commisslib/injbo_optimize_rcds.py @@ -411,15 +411,15 @@ def get_current_position(self): pos.append(self.devices['tb_qd2b'].current) elif fun('posx'): - pos.append(self.devices['pos_ang']['DeltaPosX-SP']) + pos.append(self.devices['pos_ang'].delta_posx) elif fun('angx'): - pos.append(self.devices['pos_ang']['DeltaAngX-SP']) + pos.append(self.devices['pos_ang'].delta_angx) elif fun('posy'): - pos.append(self.devices['pos_ang']['DeltaPosY-SP']) + pos.append(self.devices['pos_ang'].delta_posy) elif fun('angy'): - pos.append(self.devices['pos_ang']['DeltaAngY-SP']) + pos.append(self.devices['pos_ang'].delta_angy) elif fun('kckr'): - pos.append(self.devices['injkckr']['Kick-SP']) + pos.append(self.devices['injkckr'].strength) elif fun('tb_ch1'): pos.append(self.devices['tb_ch1'].current) @@ -431,17 +431,17 @@ def get_current_position(self): pos.append(self.devices['tb_cv2'].current) elif fun('shb_amp'): - pos.append(self.devices['li_llrf'].dev_shb['SET_AMP']) + pos.append(self.devices['li_llrf'].dev_shb.amplitude) elif fun('kly1_amp'): - pos.append(self.devices['li_llrf'].dev_klystron1['SET_AMP']) + pos.append(self.devices['li_llrf'].dev_klystron1.amplitude) elif fun('kly2_amp'): - pos.append(self.devices['li_llrf'].dev_klystron2['SET_AMP']) + pos.append(self.devices['li_llrf'].dev_klystron2.amplitude) elif fun('shb_phs'): - pos.append(self.devices['li_llrf'].dev_shb['SET_PHASE']) + pos.append(self.devices['li_llrf'].dev_shb.phase) elif fun('kly1_phs'): - pos.append(self.devices['li_llrf'].dev_klystron1['SET_PHASE']) + pos.append(self.devices['li_llrf'].dev_klystron1.phase) elif fun('kly2_phs'): - pos.append(self.devices['li_llrf'].dev_klystron2['SET_AMP']) + pos.append(self.devices['li_llrf'].dev_klystron2.amplitude) elif fun('borf_amp'): pos.append(self.devices['bo_llrf'].voltage_bottom) From 9f606f4e80974ce5d4240f2b54d8c80fd00d6215 Mon Sep 17 00:00:00 2001 From: Matheus Date: Fri, 4 Apr 2025 15:55:10 -0300 Subject: [PATCH 7/8] COMMISS.INJBOOPT.ENH: use relative tol in `wait_pos` --- apsuite/commisslib/injbo_optimize_rcds.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/apsuite/commisslib/injbo_optimize_rcds.py b/apsuite/commisslib/injbo_optimize_rcds.py index a3d5ddc2..04abc249 100644 --- a/apsuite/commisslib/injbo_optimize_rcds.py +++ b/apsuite/commisslib/injbo_optimize_rcds.py @@ -646,16 +646,25 @@ def _initialization(self): self.prepare_evg() return True - def wait_set_pos(self, pos, timeout=10, rtol=0.05, atol=0.1): - """.""" + def wait_set_pos(self, pos, tol=0.05, timeout=10): + """Wait positions RB reach the the desired SP vals. + + Wait current RB values reach `pos` within a `tol` precision up to + `timeout` seconds. + + Args: + pos (array): reference positions that have been set to SP PVs + tol (float): relative tolerance for comparing values. + i. e. |current_pos - pos| <= tol * |pos|. Defaults to 0.05 + timeout (float): timeout in seconds. Defaults to 10 s. + """ sleep_time = 0.1 it = int(timeout/sleep_time) for _ in range(it): pos_ = self.get_current_position() - if _np.all(_np.isclose(pos_, pos, atol=atol, rtol=rtol)): + if _np.all(_np.isclose(pos_, pos, rtol=tol)): + _log.info('Positions have been set.') break - # return True ? _time.sleep(sleep_time) else: _log.warning('Timed out waiting positions be set.') - # return False ? From 2c1616c45fe4a974a7ce265b508f87accca40101 Mon Sep 17 00:00:00 2001 From: Matheus Date: Fri, 4 Apr 2025 15:59:27 -0300 Subject: [PATCH 8/8] COMMISS.INJBOOPT.BUG: fix typo in getting kly2 phase --- apsuite/commisslib/injbo_optimize_rcds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apsuite/commisslib/injbo_optimize_rcds.py b/apsuite/commisslib/injbo_optimize_rcds.py index 04abc249..23033dfa 100644 --- a/apsuite/commisslib/injbo_optimize_rcds.py +++ b/apsuite/commisslib/injbo_optimize_rcds.py @@ -441,7 +441,7 @@ def get_current_position(self): elif fun('kly1_phs'): pos.append(self.devices['li_llrf'].dev_klystron1.phase) elif fun('kly2_phs'): - pos.append(self.devices['li_llrf'].dev_klystron2.amplitude) + pos.append(self.devices['li_llrf'].dev_klystron2.phase) elif fun('borf_amp'): pos.append(self.devices['bo_llrf'].voltage_bottom)