Skip to content

Commit

Permalink
Merge branch 'master' into fix-timing
Browse files Browse the repository at this point in the history
  • Loading branch information
anacso17 committed Jun 21, 2021
2 parents 3bba116 + 6f8c266 commit c866e18
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 70 deletions.
1 change: 1 addition & 0 deletions siriuspy/siriuspy/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .egun import EGBias, EGFilament, EGHVPS
from .ict import ICT, TranspEff
from .lillrf import LILLRF
from .orbit_interlock import BPMInterlock
from .pwrsupply import PowerSupply, PowerSupplyPU
from .psconv import PSProperty, StrengthConv
from .pssofb import PSCorrSOFB, PSApplySOFB
Expand Down
124 changes: 124 additions & 0 deletions siriuspy/siriuspy/devices/orbit_interlock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
"""."""

import numpy as _np

from .device import Device as _Device
from ..search import BPMSearch as _BPMSearch


class BPMInterlock(_Device):
"""BPM Device"""

_properties = (
# ==============================================================
# General
# +++++++
# General interlock enable:
'IntlkEn-Sel', 'IntlkEn-Sts',
# General interlock clear:
'IntlkClr-Sel',
# Minimum sum threshold enable:
# Habilita interlock de óbita apenas quando threshold da soma
# ultrapassar o valor em "IntlkLmtMinSum-SP"
'IntlkMinSumEn-Sel', 'IntlkMinSumEn-Sts',
# Minimum sum threshold (em contagens da Soma da taxa Monit1):
'IntlkLmtMinSum-SP', 'IntlkLmtMinSum-RB',
# Status Instantâneo:
# Interlock instântaneo, dificilmente será detectado com
# a implementação atual do gateware
'Intlk-Mon',
# Latch do interlock, limpo apenas acionando-se a PV "Clr"
# correspondente
'IntlkLtc-Mon',
# ===============================================================
# Translation (interlock de translação)
# +++++++++++++++++++++++++++++++++++++
# ***************************************************************
# Condição para interlock de translação:
# (posição BPM downstream + posição BPM upstream)/2 > threshold
# BPMs são agrupados 2 a 2 seguindo a ordem do feixe:
# - M1/M2
# - C1-1/C1-2
# - C2/C3-1
# - C3-2/C4
# BPM upstream é sempre o "primeiro" BPM da dupla acima e BPM
# downstream é sempre o "segundo" BPM da dupla.
# ***************************************************************
# Translation interlock enable:
'IntlkTransEn-Sel', 'IntlkTransEn-Sts',
# Translation interlock clear:
'IntlkTransClr-Sel',
# Thresholds (em nm da taxa Monit1):
'IntlkLmtTransMaxX-SP', 'IntlkLmtTransMaxX-RB',
'IntlkLmtTransMinX-SP', 'IntlkLmtTransMinX-RB',
'IntlkLmtTransMaxY-SP', 'IntlkLmtTransMaxY-RB',
'IntlkLmtTransMinY-SP', 'IntlkLmtTransMinY-RB',
# Status Instantâneo:
# XouY mascarado pelo "Enable"
'IntlkTransSmaller-Mon', 'IntlkTransBigger-Mon',
'IntlkTransSmallerX-Mon', 'IntlkTransBiggerX-Mon', # X
'IntlkTransSmallerY-Mon', 'IntlkTransBiggerY-Mon', # Y
'IntlkTransSmallerAny-Mon', 'IntlkTransBiggerAny-Mon', # X ou Y
# limpo apenas acionando-se a PV "Clr" correspondente
'IntlkTransSmallerLtc-Mon', 'IntlkTransBiggerLtc-Mon',
'IntlkTransSmallerLtcX-Mon', 'IntlkTransBiggerLtcX-Mon',
'IntlkTransSmallerLtcY-Mon', 'IntlkTransBiggerLtcY-Mon',
# =============================================================
# Angular (interlock de ângulo)
# +++++++++++++++++++++++++++++
# *************************************************************
# Condição para interlock de ângulo:
# (posição BPM downstream - posição BPM upstream) > threshold
# BPMs são agrupados 2 a 2 seguindo a ordem do feixe:
# - M1/M2
# - C1-1/C1-2
# - C2/C3-1
# - C3-2/C4
# BPM upstream é sempre o "primeiro" BPM da dupla acima e BPM
# downstream é sempre o "segundo" BPM da dupla.
# ************************************************************
# Anglation interlock enable:
'IntlkAngEn-Sel', 'IntlkAngEn-Sts',
# Anglation interlock clear:
'IntlkAngClr-Sel',
# Thresholds (em rad.nm da taxa Monit1.
# Thresholds devem ser calculados como ângulo (em rad)
# entre os 2 BPMs adjacentes * distância (em nm) entre eles):
'IntlkLmtAngMaxX-SP', 'IntlkLmtAngMaxX-RB',
'IntlkLmtAngMinX-SP', 'IntlkLmtAngMinX-RB',
'IntlkLmtAngMaxY-SP', 'IntlkLmtAngMaxY-RB',
'IntlkLmtAngMinY-SP', 'IntlkLmtAngMinY-RB',
# Status Instantâneo:
# X ou Y mascarado pelo "Enable"
'IntlkAngSmaller-Mon', 'IntlkAngBigger-Mon',
'IntlkAngSmallerAny-Mon', 'IntlkAngBiggerAny-Mon', # X ou Y
'IntlkAngSmallerX-Mon', 'IntlkAngBiggerX-Mon', # X
'IntlkAngSmallerY-Mon', 'IntlkAngBiggerY-Mon', # Y
# limpo apenas acionando-se a PV "Clr" correspondente
'IntlkAngSmallerLtc-Mon', 'IntlkAngBiggerLtc-Mon',
'IntlkAngSmallerLtcX-Mon', 'IntlkAngBiggerLtcX-Mon',
'IntlkAngSmallerLtcY-Mon', 'IntlkAngBiggerLtcY-Mon',
# ============================================================
)

CONV_NM2UM = 1e-3 # [nm] --> [um]

def __init__(self, devname):
"""."""
# call base class constructor
if not _BPMSearch.is_valid_devname(devname):
raise ValueError(devname + ' is no a valid BPM or PBPM name.')
super().__init__(devname, properties=BPMInterlock._properties)

@property
def enabled(self):
""".General interlock enable."""
return self['IntlkEn-Sts']

@enabled.setter
def enabled(self, value):
self['IntlkEn-Sel'] = int(value)

def cmd_reset(self):
"""General interlock clear."""
self['IntlkClr-Sel'] = 1
13 changes: 8 additions & 5 deletions siriuspy/siriuspy/devices/sofb.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,18 +650,21 @@ def autocorrsts(self):
def correct_orbit_manually(self, nr_iters=10, residue=5):
"""."""
self.cmd_turn_off_autocorr()
for _ in range(nr_iters):
for i in range(nr_iters):
resx = self.orbx - self.refx
resy = self.orby - self.refy
resx = _np.linalg.norm(resx[self.bpmxenbl])
resy = _np.linalg.norm(resy[self.bpmyenbl])
if resx < residue and resy < residue:
break
self.cmd_calccorr()
_time.sleep(0.5)
self.cmd_applycorr_all()
self.wait_apply_delta_kick()
_time.sleep(0.2)
self.cmd_reset()
self.wait_buffer()
resx = _np.std(self.orbx - self.refx)
resy = _np.std(self.orby - self.refy)
if resx < residue and resy < residue:
break
return i, resx, resy

def cmd_turn_on_autocorr(self, timeout=None):
"""."""
Expand Down
32 changes: 16 additions & 16 deletions siriuspy/siriuspy/pwrsupply/csdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -2018,10 +2018,10 @@ def _get_ps_FAP_4P_propty_database():
'IGBT2PWMDutyCycleMod4-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'p.u.'},
'VoltageInputMod1-Mon': {'type': 'float', 'value': 0.0,
'VoltageInputIIBMod1-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'VoltageOutputMod1-Mon': {'type': 'float', 'value': 0.0,
'VoltageOutputIIBMod1-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'IGBT1CurrentIIBMod1-Mon': {'type': 'float', 'value': 0.0,
Expand Down Expand Up @@ -2064,10 +2064,10 @@ def _get_ps_FAP_4P_propty_database():
'AlarmsIIBMod1Labels-Cte': {'type': 'string',
'count': len(_et.IIB_ALARMS_FAP_4P),
'value': _et.IIB_ALARMS_FAP_4P},
'VoltageInputMod2-Mon': {'type': 'float', 'value': 0.0,
'VoltageInputIIBMod2-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'VoltageOutputMod2-Mon': {'type': 'float', 'value': 0.0,
'VoltageOutputIIBMod2-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'IGBT1CurrentIIBMod2-Mon': {'type': 'float', 'value': 0.0,
Expand Down Expand Up @@ -2110,10 +2110,10 @@ def _get_ps_FAP_4P_propty_database():
'AlarmsIIBMod2Labels-Cte': {'type': 'string',
'count': len(_et.IIB_ALARMS_FAP_4P),
'value': _et.IIB_ALARMS_FAP_4P},
'VoltageInputMod3-Mon': {'type': 'float', 'value': 0.0,
'VoltageInputIIBMod3-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'VoltageOutputMod3-Mon': {'type': 'float', 'value': 0.0,
'VoltageOutputIIBMod3-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'IGBT1CurrentIIBMod3-Mon': {'type': 'float', 'value': 0.0,
Expand Down Expand Up @@ -2156,10 +2156,10 @@ def _get_ps_FAP_4P_propty_database():
'AlarmsIIBMod3Labels-Cte': {'type': 'string',
'count': len(_et.IIB_ALARMS_FAP_4P),
'value': _et.IIB_ALARMS_FAP_4P},
'VoltageInputMod4-Mon': {'type': 'float', 'value': 0.0,
'VoltageInputIIBMod4-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'VoltageOutputMod4-Mon': {'type': 'float', 'value': 0.0,
'VoltageOutputIIBMod4-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'IGBT1CurrentIIBMod4-Mon': {'type': 'float', 'value': 0.0,
Expand Down Expand Up @@ -2307,10 +2307,10 @@ def _get_ps_FAP_2P2S_propty_database():
'IGBT2PWMDutyCycleMod4-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'p.u.'},
'VoltageInputMod1-Mon': {'type': 'float', 'value': 0.0,
'VoltageInputIIBMod1-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'VoltageOutputMod1-Mon': {'type': 'float', 'value': 0.0,
'VoltageOutputIIBMod1-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'IGBT1CurrentIIBMod1-Mon': {'type': 'float', 'value': 0.0,
Expand Down Expand Up @@ -2351,10 +2351,10 @@ def _get_ps_FAP_2P2S_propty_database():
'AlarmsIIBMod1Labels-Cte': {'type': 'string',
'count': len(_et.IIB_ALARMS_FAP_2P2S),
'value': _et.IIB_ALARMS_FAP_2P2S},
'VoltageInputMod2-Mon': {'type': 'float', 'value': 0.0,
'VoltageInputIIBMod2-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'VoltageOutputMod2-Mon': {'type': 'float', 'value': 0.0,
'VoltageOutputIIBMod2-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'IGBT1CurrentIIBMod2-Mon': {'type': 'float', 'value': 0.0,
Expand Down Expand Up @@ -2397,10 +2397,10 @@ def _get_ps_FAP_2P2S_propty_database():
'AlarmsIIBMod2Labels-Cte': {'type': 'string',
'count': len(_et.IIB_ALARMS_FAP_2P2S),
'value': _et.IIB_ALARMS_FAP_2P2S},
'VoltageInputMod3-Mon': {'type': 'float', 'value': 0.0,
'VoltageInputIIBMod3-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'VoltageOutputMod3-Mon': {'type': 'float', 'value': 0.0,
'VoltageOutputIIBMod3-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'IGBT1CurrentIIBMod3-Mon': {'type': 'float', 'value': 0.0,
Expand Down Expand Up @@ -2441,10 +2441,10 @@ def _get_ps_FAP_2P2S_propty_database():
'AlarmsIIBMod3Labels-Cte': {'type': 'string',
'count': len(_et.IIB_ALARMS_FAP_2P2S),
'value': _et.IIB_ALARMS_FAP_2P2S},
'VoltageInputMod4-Mon': {'type': 'float', 'value': 0.0,
'VoltageInputIIBMod4-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'VoltageOutputMod4-Mon': {'type': 'float', 'value': 0.0,
'VoltageOutputIIBMod4-Mon': {'type': 'float', 'value': 0.0,
'prec': PS_CURRENT_PRECISION,
'unit': 'V'},
'IGBT1CurrentIIBMod4-Mon': {'type': 'float', 'value': 0.0,
Expand Down
32 changes: 16 additions & 16 deletions siriuspy/siriuspy/pwrsupply/psctrl/psmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ class PSModelFAP_4P(_PSModel):
'IGBT2PWMDutyCycleMod3-Mon': _c.V_DUTY_CYCLE_2_3,
'IGBT1PWMDutyCycleMod4-Mon': _c.V_DUTY_CYCLE_1_4,
'IGBT2PWMDutyCycleMod4-Mon': _c.V_DUTY_CYCLE_2_4,
'VoltageInputMod1-Mon': _c.V_V_INPUT_IIB_1,
'VoltageOutputMod1-Mon': _c.V_V_OUTPUT_IIB_1,
'VoltageInputIIBMod1-Mon': _c.V_V_INPUT_IIB_1,
'VoltageOutputIIBMod1-Mon': _c.V_V_OUTPUT_IIB_1,
'IGBT1CurrentIIBMod1-Mon': _c.V_I_IGBT_1_IIB_1,
'IGBT2CurrentIIBMod1-Mon': _c.V_I_IGBT_2_IIB_1,
'IGBT1TemperatureIIBMod1-Mon': _c.V_TEMP_IGBT_1_IIB_1,
Expand All @@ -591,8 +591,8 @@ class PSModelFAP_4P(_PSModel):
'RelativeHumidityIIBMod1-Mon': _c.V_RH_IIB_1,
'IntlkIIBMod1-Mon': _c.V_IIB_INTERLOCKS_1,
'AlarmsIIBMod1-Mon': _c.V_IIB_ALARMS_1,
'VoltageInputMod2-Mon': _c.V_V_INPUT_IIB_2,
'VoltageOutputMod2-Mon': _c.V_V_OUTPUT_IIB_2,
'VoltageInputIIBMod2-Mon': _c.V_V_INPUT_IIB_2,
'VoltageOutputIIBMod2-Mon': _c.V_V_OUTPUT_IIB_2,
'IGBT1CurrentIIBMod2-Mon': _c.V_I_IGBT_1_IIB_2,
'IGBT2CurrentIIBMod2-Mon': _c.V_I_IGBT_2_IIB_2,
'IGBT1TemperatureIIBMod2-Mon': _c.V_TEMP_IGBT_1_IIB_2,
Expand All @@ -607,8 +607,8 @@ class PSModelFAP_4P(_PSModel):
'RelativeHumidityIIBMod2-Mon': _c.V_RH_IIB_2,
'IntlkIIBMod2-Mon': _c.V_IIB_INTERLOCKS_2,
'AlarmsIIBMod2-Mon': _c.V_IIB_ALARMS_2,
'VoltageInputMod3-Mon': _c.V_V_INPUT_IIB_3,
'VoltageOutputMod3-Mon': _c.V_V_OUTPUT_IIB_3,
'VoltageInputIIBMod3-Mon': _c.V_V_INPUT_IIB_3,
'VoltageOutputIIBMod3-Mon': _c.V_V_OUTPUT_IIB_3,
'IGBT1CurrentIIBMod3-Mon': _c.V_I_IGBT_1_IIB_3,
'IGBT2CurrentIIBMod3-Mon': _c.V_I_IGBT_2_IIB_3,
'IGBT1TemperatureIIBMod3-Mon': _c.V_TEMP_IGBT_1_IIB_3,
Expand All @@ -623,8 +623,8 @@ class PSModelFAP_4P(_PSModel):
'RelativeHumidityIIBMod3-Mon': _c.V_RH_IIB_3,
'IntlkIIBMod3-Mon': _c.V_IIB_INTERLOCKS_3,
'AlarmsIIBMod3-Mon': _c.V_IIB_ALARMS_3,
'VoltageInputMod4-Mon': _c.V_V_INPUT_IIB_4,
'VoltageOutputMod4-Mon': _c.V_V_OUTPUT_IIB_4,
'VoltageInputIIBMod4-Mon': _c.V_V_INPUT_IIB_4,
'VoltageOutputIIBMod4-Mon': _c.V_V_OUTPUT_IIB_4,
'IGBT1CurrentIIBMod4-Mon': _c.V_I_IGBT_1_IIB_4,
'IGBT2CurrentIIBMod4-Mon': _c.V_I_IGBT_2_IIB_4,
'IGBT1TemperatureIIBMod4-Mon': _c.V_TEMP_IGBT_1_IIB_4,
Expand Down Expand Up @@ -686,8 +686,8 @@ class PSModelFAP_2P2S(_PSModel):
'IGBT2PWMDutyCycleMod3-Mon': _c.V_DUTY_CYCLE_2_3,
'IGBT1PWMDutyCycleMod4-Mon': _c.V_DUTY_CYCLE_1_4,
'IGBT2PWMDutyCycleMod4-Mon': _c.V_DUTY_CYCLE_2_4,
'VoltageInputMod1-Mon': _c.V_V_INPUT_IIB_1,
'VoltageOutputMod1-Mon': _c.V_V_OUTPUT_IIB_1,
'VoltageInputIIBMod1-Mon': _c.V_V_INPUT_IIB_1,
'VoltageOutputIIBMod1-Mon': _c.V_V_OUTPUT_IIB_1,
'IGBT1CurrentIIBMod1-Mon': _c.V_I_IGBT_1_IIB_1,
'IGBT2CurrentIIBMod1-Mon': _c.V_I_IGBT_2_IIB_1,
'IGBT1TemperatureIIBMod1-Mon': _c.V_TEMP_IGBT_1_IIB_1,
Expand All @@ -702,8 +702,8 @@ class PSModelFAP_2P2S(_PSModel):
'RelativeHumidityIIBMod1-Mon': _c.V_RH_IIB_1,
'IntlkIIBMod1-Mon': _c.V_IIB_INTERLOCKS_1,
'AlarmsIIBMod1-Mon': _c.V_IIB_ALARMS_1,
'VoltageInputMod2-Mon': _c.V_V_INPUT_IIB_2,
'VoltageOutputMod2-Mon': _c.V_V_OUTPUT_IIB_2,
'VoltageInputIIBMod2-Mon': _c.V_V_INPUT_IIB_2,
'VoltageOutputIIBMod2-Mon': _c.V_V_OUTPUT_IIB_2,
'IGBT1CurrentIIBMod2-Mon': _c.V_I_IGBT_1_IIB_2,
'IGBT2CurrentIIBMod2-Mon': _c.V_I_IGBT_2_IIB_2,
'IGBT1TemperatureIIBMod2-Mon': _c.V_TEMP_IGBT_1_IIB_2,
Expand All @@ -718,8 +718,8 @@ class PSModelFAP_2P2S(_PSModel):
'RelativeHumidityIIBMod2-Mon': _c.V_RH_IIB_2,
'IntlkIIBMod2-Mon': _c.V_IIB_INTERLOCKS_2,
'AlarmsIIBMod2-Mon': _c.V_IIB_ALARMS_2,
'VoltageInputMod3-Mon': _c.V_V_INPUT_IIB_3,
'VoltageOutputMod3-Mon': _c.V_V_OUTPUT_IIB_3,
'VoltageInputIIBMod3-Mon': _c.V_V_INPUT_IIB_3,
'VoltageOutputIIBMod3-Mon': _c.V_V_OUTPUT_IIB_3,
'IGBT1CurrentIIBMod3-Mon': _c.V_I_IGBT_1_IIB_3,
'IGBT2CurrentIIBMod3-Mon': _c.V_I_IGBT_2_IIB_3,
'IGBT1TemperatureIIBMod3-Mon': _c.V_TEMP_IGBT_1_IIB_3,
Expand All @@ -734,8 +734,8 @@ class PSModelFAP_2P2S(_PSModel):
'RelativeHumidityIIBMod3-Mon': _c.V_RH_IIB_3,
'IntlkIIBMod3-Mon': _c.V_IIB_INTERLOCKS_3,
'AlarmsIIBMod3-Mon': _c.V_IIB_ALARMS_3,
'VoltageInputMod4-Mon': _c.V_V_INPUT_IIB_4,
'VoltageOutputMod4-Mon': _c.V_V_OUTPUT_IIB_4,
'VoltageInputIIBMod4-Mon': _c.V_V_INPUT_IIB_4,
'VoltageOutputIIBMod4-Mon': _c.V_V_OUTPUT_IIB_4,
'IGBT1CurrentIIBMod4-Mon': _c.V_I_IGBT_1_IIB_4,
'IGBT2CurrentIIBMod4-Mon': _c.V_I_IGBT_2_IIB_4,
'IGBT1TemperatureIIBMod4-Mon': _c.V_TEMP_IGBT_1_IIB_4,
Expand Down
Loading

0 comments on commit c866e18

Please sign in to comment.