Skip to content

Commit

Permalink
Merge pull request #71 from lnls-sirius/PR-fbp-dclink-tests-update
Browse files Browse the repository at this point in the history
Pr fbp dclink tests update
  • Loading branch information
xresende authored Jun 19, 2018
2 parents 66cd853 + 3772268 commit 7b49d6d
Show file tree
Hide file tree
Showing 39 changed files with 2,179 additions and 1,463 deletions.
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.0
1.7.0
1 change: 1 addition & 0 deletions siriuspy/siriuspy/bsmp/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def __init__(self, stream):
if len(stream) < 5:
raise _SerialErrPckgLen("BSMP Package too short.")
if not Package.verify_checksum(stream):
# print('resp: ', [hex(ord(c)) for c in stream])
raise _SerialErrCheckSum(
"Inconsistent message. Checksum does not check.")
self._stream = stream
Expand Down
187 changes: 143 additions & 44 deletions siriuspy/siriuspy/csdevice/pwrsupply.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@

# --- power supply enums ---

ps_models = ('FBP', 'FAC', 'FAC_2S', 'FAC_2P4S', 'FAP', 'FAP_4P', 'FAP_2P2S',
'FBP_SOFB', 'Commercial', )
ps_models = ('Empty',
'FBP', 'FBP_DCLink',
'FAC_ACDC', 'FAC_DCDC',
'FAC_2S_ACDC', 'FAC_2S_DCDC',
'FAC_2P4S_ACDC', 'FAC_2P4S_DCDC',
'FAP',
'FAP_4P_Master', 'FAP_4P_Slave',
'FAP_2P2S_MASTER', 'FAP_2P2S_SLAVE',
'FBP_SOFB',
'Commercial',
'FP')
ps_dsblenbl = ('Dsbl', 'Enbl')
ps_interface = ('Remote', 'Local', 'PCHost')
ps_openloop = ('Open', 'Closed')
ps_openloop = ('Close', 'Open')
ps_pwrstate_sel = ('Off', 'On')
ps_pwrstate_sts = ('Off', 'On', 'Initializing')
ps_states = ('Off', 'Interlock', 'Initializing',
Expand All @@ -44,8 +53,7 @@
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
)
'Reserved', 'Reserved', 'Reserved', 'Reserved',)
ps_hard_interlock_FBP = (
'Sobre-corrente na carga', 'Sobre-tensão na carga',
'Sobre-tensão no DC-Link', 'Sub-tensão no DC-Link',
Expand All @@ -57,8 +65,7 @@
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
)
'Reserved', 'Reserved', 'Reserved', 'Reserved',)
ps_soft_interlock_FBP_DCLink = (
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
Expand All @@ -67,46 +74,70 @@
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
)
'Reserved', 'Reserved', 'Reserved', 'Reserved',)
ps_hard_interlock_FBP_DCLink = (
'Falha na fonte 1', 'Falha na fonte 2',
'Falha na fonte 3', 'Sensor de fumaça',
'Interlock externo', 'Sobre-tensão na fonte 1'
'Sobre-tensão na fonte 2', 'Sobre-tensão na fonte 3',
'Falha na fonte 3', 'Sobre-tensão da saída do bastidor DC-Link',
'Sobre-tensão da fonte 1', 'Sobre-tensão na fonte 2',
'Sobre-tensão na fonte 3', 'Sub-tensão da saída do bastidor DC-Link',
'Sub-tensão na fonte 1', 'Sub-tensão na fonte 2',
'Sub-tensão na fonte 3', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Sub-tensão na fonte 3', 'Sensor de fumaça',
'Interlock externo', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
)
'Reserved', 'Reserved', 'Reserved', 'Reserved',)
ps_soft_interlock_FAC = (
'Sobre-temperatura nos indutores', 'Sobre-temperatura nos indutores',
'Falha no DCCT 1', 'Falha no DCCT 2',
'Alta diferença entre DCCTs',
'Falha na leitura da corrente na carga do DCCT 1',
'Falha na leitura da corrente na carga do DCCT 2',
'Falha na leitura da corrente na carga do DCCT 2', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved'
)
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',)
ps_hard_interlock_FAC = (
'Sobre-corrente na carga', 'Sobre-corrente na carga',
'Sobre-tensão no DC-Link', 'Sub-tensão no DC-Link',
'Falha nos drivers do módulo', 'Reserved',
'Falha nos drivers do módulo', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',)
ps_soft_interlock_FAC_ACDC = (
'Sobre-temperatura no dissipador', 'Sobre-temperatura nos indutores',
'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',)
ps_hard_interlock_FAC_ACDC = (
'Sobre-tensão no banco de capacitores',
'Sobre-tensão na saída do retificador',
'Sub-tensão na saída do retificador',
'Sobre-corrente na saída do retificador',
'Falha no driver do IGBT', 'Falha no contator de entrada AC trifásica',
'Reserved', 'Reserved',
)
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',
'Reserved', 'Reserved', 'Reserved', 'Reserved',)
ps_cycle_type = ('Sine', 'DampedSine', 'Trapezoidal')
ps_sync_mode = ('Off', 'Cycle', 'RmpEnd', 'MigEnd')


# --- power supply constants definition class ---


Const.add_field('Models', ps_models)
Const.add_field('DsblEnbl', ps_dsblenbl)
Const.add_field('Interface', ps_interface)
Expand All @@ -125,20 +156,20 @@ def get_ps_current_unit():
"""Return power supply current unit."""
global _default_ps_current_unit
if _default_ps_current_unit is None:
_default_ps_current_unit = _PSSearch.get_splims_unit(ispulsed=False)
_default_ps_current_unit = _PSSearch.get_splims_unit('FBP')
return _default_ps_current_unit


def get_pu_current_unit():
"""Return pulsed power supply 'current' unit."""
global _default_pu_current_unit
if _default_pu_current_unit is None:
_default_pu_current_unit = _PSSearch.get_splims_unit(ispulsed=True)
_default_pu_current_unit = _PSSearch.get_splims_unit('')
return _default_pu_current_unit


def get_common_propty_database():
"""Return database entries to all power-supply-like devices."""
def get_basic_propty_database():
"""Return database entries to all BSMP-like devices."""
db = {
'Version-Cte': {'type': 'str', 'value': 'UNDEF'},
'CtrlMode-Mon': {'type': 'enum', 'enums': ps_interface,
Expand All @@ -148,10 +179,30 @@ def get_common_propty_database():
'value': _et.idx.Off},
'PwrState-Sts': {'type': 'enum', 'enums': ps_pwrstate_sts,
'value': _et.idx.Off},
'CtrlLoop-Sel': {'type': 'enum', 'enums': ps_openloop,
'value': Const.OpenLoop.Open},
'CtrlLoop-Sts': {'type': 'enum', 'enums': ps_openloop,
'value': Const.OpenLoop.Open},
'OpMode-Sel': {'type': 'enum', 'enums': ps_opmode,
'value': _et.idx.SlowRef},
'OpMode-Sts': {'type': 'enum', 'enums': ps_opmode,
'value': _et.idx.SlowRef},
# PRU
'PRUSyncMode-Mon': {'type': 'enum', 'enums': ps_sync_mode,
'value': Const.SyncMode.Off},
'PRUBlockIndex-Mon': {'type': 'int', 'value': 0},
'PRUSyncPulseCount-Mon': {'type': 'int', 'value': 0},
'PRUCtrlQueueSize-Mon': {'type': 'int', 'value': 0,
'high': 50, 'hihi': 50},

}
return db


def get_common_propty_database():
"""Return database entries to all power-supply-like devices."""
db = get_basic_propty_database()
db.update({
'Current-SP': {'type': 'float', 'value': 0.0,
'prec': default_ps_current_precision},
'Current-RB': {'type': 'float', 'value': 0.0,
Expand Down Expand Up @@ -195,18 +246,7 @@ def get_common_propty_database():
'WfmData-RB': {'type': 'float', 'count': MAX_WFMSIZE,
'value': list(DEFAULT_WFMDATA),
'prec': default_ps_current_precision},
# Hw
'OpenLoop-Mon': {'type': 'enum', 'enums': ps_openloop,
'value': Const.OpenLoop.Open},
# PRU
'PRUSyncMode-Mon': {'type': 'enum', 'enums': ps_sync_mode,
'value': Const.SyncMode.Off},
'PRUBlockIndex-Mon': {'type': 'int', 'value': 0},
'PRUSyncPulseCount-Mon': {'type': 'int', 'value': 0},
'PRUCtrlQueueSize-Mon': {'type': 'int', 'value': 0,
'high': 50, 'hihi': 50},

}
})
return db


Expand Down Expand Up @@ -305,12 +345,12 @@ def get_ma_propty_database(maname):
current_alarm = ('Current-SP', 'Current-RB',
'CurrentRef-Mon', 'Current-Mon', )
current_pvs = current_alarm # + ('WfmData-SP', 'WfmData-RB')
unit = _MASearch.get_splims_unit(ispulsed=False)
magfunc_dict = _MASearch.conv_maname_2_magfunc(maname)
psnames = _MASearch.conv_psmaname_2_psnames(maname)
psmodel = _PSSearch.conv_psname_2_psmodel(psnames[0])
unit = _MASearch.get_splims_unit(psmodel=psmodel)
magfunc_dict = _MASearch.conv_maname_2_magfunc(maname)
pstype = _PSSearch.conv_psname_2_pstype(psnames[0])
# TODO: generalize
propty_db = get_ps_propty_database('FBP', pstype)
propty_db = get_ps_propty_database(psmodel, pstype)
db = {}

for psname, magfunc in magfunc_dict.items():
Expand Down Expand Up @@ -376,9 +416,10 @@ def get_pm_propty_database(maname):
else:
propty_db = get_common_pu_propty_database()

propty_db = get_common_pu_propty_database()
psnames = _MASearch.conv_psmaname_2_psnames(maname)
psmodel = _PSSearch.conv_psname_2_psmodel(psnames[0])
current_alarm = ('Voltage-SP', 'Voltage-RB', 'Voltage-Mon', )
unit = _MASearch.get_splims_unit(ispulsed=True)
unit = _MASearch.get_splims_unit(psmodel=psmodel)
magfunc_dict = _MASearch.conv_maname_2_magfunc(maname)
db = {}
for psname, magfunc in magfunc_dict.items():
Expand Down Expand Up @@ -436,6 +477,34 @@ def _get_ps_FBP_propty_database():
return propty_db


def _get_ps_FBP_DCLink_propty_database():
"""Return database with FBP_DCLink pwrsupply model PVs."""
propty_db = get_basic_propty_database()
db_ps = {
'Voltage-SP': {'type': 'float', 'value': 0.0,
'lolim': 0.0, 'hilim': 100.0, 'prec': 4},
'Voltage-RB': {'type': 'float', 'value': 0.0,
'lolim': 0.0, 'hilim': 100.0, 'prec': 4},
'VoltageRef-Mon': {'type': 'float', 'value': 0.0,
'lolim': 0.0, 'hilim': 100.0, 'prec': 4},
'Voltage-Mon': {'type': 'float', 'value': 0.0, 'prec': 4},
'Voltage1-Mon': {'type': 'float', 'value': 0.0, 'prec': 4},
'Voltage2-Mon': {'type': 'float', 'value': 0.0, 'prec': 4},
'Voltage3-Mon': {'type': 'float', 'value': 0.0, 'prec': 4},
'VoltageDig-Mon': {'type': 'int', 'value': 0,
'lolim': 0, 'hilim': 255},
'IntlkSoftLabels-Cte': {'type': 'string',
'count': len(ps_soft_interlock_FBP_DCLink),
'value': ps_soft_interlock_FBP_DCLink},
'IntlkHardLabels-Cte': {'type': 'string',
'count': len(ps_hard_interlock_FBP_DCLink),
'value': ps_hard_interlock_FBP_DCLink},
'ModulesStatus-Mon': {'type': 'int', 'value': 0},
}
propty_db.update(db_ps)
return propty_db


def _get_ps_FAC_propty_database():
"""Return database with FAC pwrsupply model PVs."""
# TODO: implement!!!
Expand All @@ -454,6 +523,32 @@ def _get_ps_FAC_propty_database():
return propty_db


def _get_ps_FAC_ACDC_propty_database():
"""Return database with FAC_ACDC pwrsupply model PVs."""
# TODO: MISSING SETPOINT!!!
db = {
'IntlkSoftLabels-Cte': {'type': 'string',
'count': len(ps_soft_interlock_FAC_ACDC),
'value': ps_soft_interlock_FAC_ACDC},
'IntlkHardLabels-Cte': {'type': 'string',
'count': len(ps_hard_interlock_FAC_ACDC),
'value': ps_hard_interlock_FAC_ACDC},
'CapacitorBankVoltage-Mon': {'type': 'float', 'value': 0.0,
'prec': default_ps_current_precision},
'RectifierVoltage-Mon': {'type': 'float', 'value': 0.0,
'prec': default_ps_current_precision},
'RectifierCurrent-Mon': {'type': 'float', 'value': 0.0,
'prec': default_ps_current_precision},
'HeatSinkTemperature-Mon': {'type': 'float', 'value': 0.0,
'prec': default_ps_current_precision},
'InductorsTemperature-Mon': {'type': 'float', 'value': 0.0,
'prec': default_ps_current_precision},
'PWMDutyCycle-Mon': {'type': 'float', 'value': 0.0,
'prec': default_ps_current_precision},
}
return db


def _get_ps_FAC_2S_propty_database():
"""Return database with FAC_2S pwrsupply model PVs."""
# TODO: implement!!!
Expand Down Expand Up @@ -528,6 +623,8 @@ def _set_limits(pstype, database):
def _get_model_db(psmodel):
if psmodel == 'FBP':
database = _get_ps_FBP_propty_database()
elif psmodel in ('FBP_DCLink'):
database = _get_ps_FBP_DCLink_propty_database()
elif psmodel in ('FAC'):
database = _get_ps_FAC_propty_database()
elif psmodel in ('FAC_2S'):
Expand All @@ -544,6 +641,8 @@ def _get_model_db(psmodel):
database = _get_ps_FBP_FOFB_propty_database()
elif psmodel in ('Commercial'):
database = _get_ps_Commercial_propty_database()
elif psmodel in ('FAC_ACDC'):
database = _get_ps_FAC_ACDC_propty_database()
else:
raise ValueError(
'DB for psmodel {} not implemented!'.format(psmodel))
Expand Down
14 changes: 8 additions & 6 deletions siriuspy/siriuspy/magnet/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ def __init__(self, maname):
"""Init method."""
self._maname = _SiriusPVName(maname)
self._splims = _MASearch.conv_maname_2_splims(self._maname)
self._ispulsed = _MASearch.check_maname_ispulsed(self._maname)
self._splims_unit = _MASearch.get_splims_unit(ispulsed=self._ispulsed)
psnames = _MASearch.conv_maname_2_psnames(self._maname)
if self._ispulsed:
self._propty_databases = _get_pm_propty_database(self._maname)
else:
self._propty_databases = _get_ma_propty_database(self._maname)
self._psdata = {}
for psname in psnames:
self._psdata[psname] = _PSData(psname=psname)
psmodel = self._psdata[psnames[0]].psmodel
self._splims_unit = \
_MASearch.get_splims_unit(psmodel=psmodel)
# TODO: cleanup code
if 'PU-' in maname:
self._propty_databases = _get_pm_propty_database(self._maname)
else:
self._propty_databases = _get_ma_propty_database(self._maname)

@property
def maname(self):
Expand Down
Loading

0 comments on commit 7b49d6d

Please sign in to comment.