Skip to content

Commit

Permalink
Merge pull request #372 from lnls-sirius/PR-add-li-psconv
Browse files Browse the repository at this point in the history
Add Linac PS Conversion
  • Loading branch information
xresende authored Feb 14, 2020
2 parents b23550e + 313a0fc commit 00a037d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
24 changes: 20 additions & 4 deletions siriuspy/siriuspy/csdevice/pwrsupply.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,8 @@ def get_pu_propty_database(pstype):
return database


def get_pu_conv_propty_database(pstype):
"""Return database definition for a pulsed power supply type."""
def get_conv_propty_database(pstype):
"""Return strength database definition for a power supply type."""
dbase = dict()
dbase = _insert_strengths(dbase, pstype)
return dbase
Expand Down Expand Up @@ -756,7 +756,6 @@ def _get_ps_LINAC_propty_database():
"""Return LINAC pwrsupply props."""
# NOTE: This is a mirror of the PS IOC database in linac-ioc-ps repo.
version = '2020/02/12'

propty_db = {
# --- ioc metapvs
'Version-Cte': {'type': 'string', 'value': version},
Expand Down Expand Up @@ -1635,6 +1634,7 @@ def _insert_strengths(database, pstype):
'ts-ejeseptum-thin', 'ts-ejeseptum-thick',
'ts-injseptum-thin', 'ts-injseptum-thick',
'si-injdpk', 'si-injnlk', 'si-hping', 'si-vping')
# pulsed
if pstype in pulsed_pstypes:
database['Kick-SP'] = {
'type': 'float', 'value': 0.0, 'prec': prec_kick, 'unit': 'mrad'}
Expand All @@ -1643,6 +1643,15 @@ def _insert_strengths(database, pstype):
database['Kick-Mon'] = {
'type': 'float', 'value': 0.0, 'prec': prec_kick, 'unit': 'mrad'}
return database
# linac spectrometer
if pstype.startswith('li-spect'):
database['Kick-SP'] = {
'type': 'float', 'value': 0.0, 'prec': prec_kick, 'unit': 'deg'}
database['Kick-RB'] = {
'type': 'float', 'value': 0.0, 'prec': prec_kick, 'unit': 'deg'}
database['Kick-Mon'] = {
'type': 'float', 'value': 0.0, 'prec': prec_kick, 'unit': 'deg'}
return database

magfunc = _PSSearch.conv_pstype_2_magfunc(pstype)
if magfunc in {'quadrupole', 'quadrupole-skew'}:
Expand Down Expand Up @@ -1673,7 +1682,6 @@ def _insert_strengths(database, pstype):
database['Energy-Mon'] = {
'type': 'float', 'value': 0.0, 'prec': prec_energy, 'unit': 'GeV'}
elif magfunc in {'corrector-horizontal', 'corrector-vertical'}:
prec = 3
database['Kick-SP'] = {
'type': 'float', 'value': 0.0, 'prec': prec_kick, 'unit': 'urad'}
database['Kick-RB'] = {
Expand All @@ -1683,4 +1691,12 @@ def _insert_strengths(database, pstype):
database['Kick-Mon'] = {
'type': 'float', 'value': 0.0, 'prec': prec_kick, 'unit': 'urad'}

if pstype.startswith('li-'):
if 'KickRef-Mon' in database:
del database['KickRef-Mon']
if 'KLRef-Mon' in database:
del database['KLRef-Mon']
if 'SLRef-Mon' in database:
del database['SLRef-Mon']

return database
8 changes: 7 additions & 1 deletion siriuspy/siriuspy/magnet/normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,15 @@ def _calc_conv_coef(self):
if unit == 'mrad':
self._coef_def2edb = 1e3
return
elif unit == 'urad':
if unit == 'urad':
self._coef_def2edb = 1e6
return
if unit == 'rad':
self._coef_def2edb = 1
return
if unit == 'deg':
self._coef_def2edb = 180.0 / _np.pi
return
self._coef_def2edb = 1.0

def _conv_intfield_2_strength(self, intfields, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/magnet/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def magnet_class(maname):
raise ValueError("Cannot classify {}".format(maname))
if 'PM' == maname.dis:
return 'pulsed'
if maname.dev.startswith('B') or maname.dev.startswith('Spect'):
if maname.dev.startswith('B'):
return 'dipole'
if 'QS' not in maname.dev and \
'SI' == maname.sec and \
Expand Down
4 changes: 3 additions & 1 deletion siriuspy/siriuspy/pwrsupply/psconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from siriuspy.envars import VACA_PREFIX as _VACA_PREFIX
from siriuspy.factory import NormalizerFactory as _NormalizerFactory
from siriuspy.namesys import SiriusPVName as _SiriusPVName
from siriuspy.magnet import util as _mutil


class PSEpicsConn:
Expand Down Expand Up @@ -225,6 +224,9 @@ def _create_connectors(self, proptype, connection_timeout):
'SI-Fam:PS-B1B2-1', proptype, 'Energy', connection_timeout)
psname = self._psname.replace(sub, 'Fam')
conn_fam = PSEpicsConn(psname, proptype, 'KL', connection_timeout)
elif self._psname.startswith('LI'):
conn_dip = PSEpicsConn(
'TB-Fam:PS-B', proptype, 'Energy', connection_timeout)
elif self._psname.startswith('TB'):
# all TB ps other than dipoles need dipole connectors
conn_dip = PSEpicsConn(
Expand Down
2 changes: 1 addition & 1 deletion siriuspy/tests/csdevice/test_pwrsupply.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
'get_common_pu_SI_InjKicker_propty_database',
'get_ps_propty_database',
'get_pu_propty_database',
'get_pu_conv_propty_database',
'get_conv_propty_database',
'get_li_ma_propty_database',
'get_pm_propty_database',
)
Expand Down

0 comments on commit 00a037d

Please sign in to comment.