Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change type of Polarization-Mon in IDFF #1082

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion siriuspy/siriuspy/devices/idff.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def check_valid_value(self, value):
'List of corrlabels in config is not consistent')

# check nrpts in tables
param = 'pparameter' if polarization == 'none' else 'kparameter'
pol_none = _IDSearch.POL_NONE_STR
param = 'pparameter' if polarization == pol_none else 'kparameter'
nrpts_corrtables = {len(table) for table in corrtable.values()}
nrpts_kparameter = set([len(table[param]), ])
symm_diff = nrpts_corrtables ^ nrpts_kparameter
Expand Down
5 changes: 3 additions & 2 deletions siriuspy/siriuspy/idff/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def calculate_setpoints(
if self._value:
setpoints = dict()
idff = self._value['polarizations'][polarization]
if polarization == 'none':
if polarization == _IDSearch.POL_NONE_STR:
params = idff['pparameter']
param_value = pparameter_value
else:
Expand Down Expand Up @@ -248,7 +248,8 @@ def check_valid_value(self, value):
'List of corrlabels in config is not consistent')

# check nrpts in tables
param = 'pparameter' if polarization == 'none' else 'kparameter'
pol_none = _IDSearch.POL_NONE_STR
param = 'pparameter' if polarization == pol_none else 'kparameter'
nrpts_corrtables = {len(table) for table in corrtable.values()}
nrpts_kparameter = set([len(table[param]), ])
symm_diff = nrpts_corrtables ^ nrpts_kparameter
Expand Down
5 changes: 4 additions & 1 deletion siriuspy/siriuspy/idff/csdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, idname):
fname = fname.lower()
self.autosave_fname = _os.path.join(ioc_fol, fname+'.txt')
qsnames = _IDSearch.conv_idname_2_idff_qsnames(idname)
self.pol_sts = _IDSearch.conv_idname_2_polarizations_sts(self.idname)
self.has_qscorrs = True if qsnames else False

def get_propty_database(self):
Expand All @@ -70,7 +71,9 @@ def get_propty_database(self):
'unit': 'Hz', 'prec': 3,
'lolim': self.DEFAULT_LOOP_FREQ_MIN,
'hilim': self.DEFAULT_LOOP_FREQ_MAX},
'Polarization-Mon': {'type': 'string', 'value': 'none'},
'Polarization-Mon': {
'type': 'enum', 'enums': self.pols_sts,
'value': self.pols_sts.index(_IDSearch.POL_UNDEF_STR)},
'ConfigName-SP': {'type': 'string', 'value': ''},
'ConfigName-RB': {'type': 'string', 'value': ''},
'CorrConfig-Cmd': {'type': 'int', 'value': 0},
Expand Down
20 changes: 13 additions & 7 deletions siriuspy/siriuspy/idff/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import time as _time

import epics as _epics
import numpy as _np

from ..search import IDSearch as _IDSearch
from ..util import update_bit as _updt_bit
from ..callbacks import Callback as _Callback
from ..clientconfigdb import ConfigDBException as _ConfigDBException
Expand All @@ -30,7 +29,7 @@ def __init__(self, idname):
self._loop_state = _Const.DEFAULT_LOOP_STATE
self._loop_freq = _Const.DEFAULT_LOOP_FREQ
self._control_qs = _Const.DEFAULT_CONTROL_QS
self._polarization = 'none'
self._polarization = self._const.pol_sts.index(_IDSearch.POL_UNDEF_STR)
self._config_name = ''
self.read_autosave_file()

Expand Down Expand Up @@ -291,9 +290,16 @@ def _do_sleep(self, time0, tplanned):

def _do_update_polarization(self):
new_pol, *_ = self._idff.get_polarization_state()
if new_pol is not None and new_pol != self._polarization:
self._polarization = new_pol
self.run_callbacks('Polarization-Mon', new_pol)
if new_pol is None:
self._update_log('ERR: new polarization is None')
return
try:
new_pol_idx = self._const.pol_sts.index(new_pol)
except ValueError:
self._update_log('ERR: could not find index of polarization')
if new_pol_idx != self._polarization:
self._polarization = new_pol_idx
self.run_callbacks('Polarization-Mon', new_pol_idx)

def _do_update_correctors(self):
try:
Expand All @@ -306,7 +312,7 @@ def _do_update_correctors(self):
# print('setpoints: ', setpoints)
# print()
except ValueError as err:
self._update_log('ERR:'+str(err))
self._update_log('ERR: ' + str(err))

def _do_implement_correctors(self):
corrdevs = None
Expand Down
Loading