Skip to content

Commit

Permalink
Merge pull request #377 from lnls-sirius/PR-add-ps-ioc-fbp-pvs
Browse files Browse the repository at this point in the history
Pr add ps ioc fbp pvs
  • Loading branch information
xresende authored Feb 20, 2020
2 parents d89a6e2 + 9cde127 commit e1b43eb
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 107 deletions.
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.15.0
1.16.0
1 change: 1 addition & 0 deletions siriuspy/siriuspy/clientarch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import siriuspy.envars as _envars
from .client import ClientArchiver
from .pvarch import PVArch


SERVER_URL = _envars.SRVURL_ARCHIVER
17 changes: 15 additions & 2 deletions siriuspy/siriuspy/clientarch/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def getPVsInfo(self, pvnames):
if isinstance(pvnames, (list, tuple)):
pvnames = ','.join(pvnames)
url = self._create_url(method='getPVStatus', pv=pvnames)
return self._make_request(url).json()
req = self._make_request(url)
if not req.ok:
return None
return req.json()

def getAllPVs(self, pvnames):
"""."""
Expand Down Expand Up @@ -95,7 +98,7 @@ def getData(self, pvname, timestamp_start, timestamp_stop):
pvname -- name of pv.
timestamp_start -- timestamp of interval start
Example: (2019-05-23T13:32:27.570Z)
timestamp_stop -- timestamp of interval start
timestamp_stop -- timestamp of interval stop
Example: (2019-05-23T14:32:27.570Z)
"""
tstart = _parse.quote(timestamp_start)
Expand All @@ -112,6 +115,16 @@ def getData(self, pvname, timestamp_start, timestamp_stop):
severity = [v['severity'] for v in data]
return timestamp, value, status, severity

def getPVDetails(self, pvname):
"""."""
url = self._create_url(
method='getPVDetails', pv=pvname)
req = self._make_request(url)
if not req.ok:
return None
data = req.json()
return data

def _make_request(self, url, need_login=False):
if self.session is not None:
req = self.session.get(url)
Expand Down
90 changes: 90 additions & 0 deletions siriuspy/siriuspy/clientarch/pvarch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""."""

from .client import ClientArchiver as _ClientArchiver


class PVArch:
"""PVArch."""

def __init__(self, pvname, client_archiver=None):
"""."""
self.pvname = pvname
self.is_scalar = None
self.nelms = None
self.units = None
self.is_paused = None
self.host_name = None
self.connected = None
self.avg_bytes_per_event = None
self.estimated_storage_rate_kb_hour = None
self.estimated_storage_rate_mb_day = None
self.estimated_storage_rate_gb_year = None

self.connector = client_archiver

def login(self, **kwargs):
"""."""
self.connect()
self.connector.login(**kwargs)

def connect(self):
"""."""
if self.connector is None:
self.connector = _ClientArchiver()

def update(self):
"""."""
self.connect()
data = self.connector.getPVDetails(self.pvname)
for datum in data:
# print(datum)
field, value = datum['name'], datum['value']
if field == 'Is this a scalar:':
self.is_scalar = (value.lower() == 'yes')
elif field == 'Number of elements:':
self.nelms = int(value)
elif field == 'Units:':
self.units = value
elif field == 'Is this PV paused:':
self.is_paused = (value.lower() == 'yes')
elif field == 'Host name':
self.host_name = value
elif field == 'Host name':
self.host_name = value
elif field == 'Is this PV currently connected?':
self.connected = (value.lower() == 'yes')
elif field == 'Average bytes per event':
self.avg_bytes_per_event = float(value)
elif field == 'Estimated storage rate (KB/hour)':
self.estimated_storage_rate_kb_hour = float(value)
elif field == 'Estimated storage rate (MB/day)':
self.estimated_storage_rate_mb_day = float(value)
elif field == 'Estimated storage rate (GB/year)':
self.estimated_storage_rate_gb_year = float(value)

def getData(self, timestamp_start, timestamp_stop):
"""."""
self.connect()
timestamp, value, status, severity = \
self.connector.getData(self.pvname, timestamp_start, timestamp_stop)
return timestamp, value, status, severity

def __str__(self):
"""."""
rst = ''
rst += '{:<30s}: {:}\n'.format('pvname', self.pvname)
rst += '{:<30s}: {:}\n'.format('is_scalar', self.is_scalar)
rst += '{:<30s}: {:}\n'.format('nelms', self.nelms)
rst += '{:<30s}: {:}\n'.format('units', self.units)
rst += '{:<30s}: {:}\n'.format('is_paused', self.is_paused)
rst += '{:<30s}: {:}\n'.format('host_name', self.host_name)
rst += '{:<30s}: {:}\n'.format('connected', self.connected)
rst += '{:<30s}: {:}\n'.format(
'avg_bytes_per_event', self.avg_bytes_per_event)
rst += '{:<30s}: {:}\n'.format(
'estimated_storage_rate_kb_hour', self.estimated_storage_rate_kb_hour)
rst += '{:<30s}: {:}\n'.format(
'estimated_storage_rate_mb_day', self.estimated_storage_rate_mb_day)
rst += '{:<30s}: {:}\n'.format(
'estimated_storage_rate_gb_year', self.estimated_storage_rate_gb_year)
return rst
91 changes: 71 additions & 20 deletions siriuspy/siriuspy/csdevice/pwrsupply.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,40 +518,85 @@ def get_basic_propty_database():
'WfmUpdateAuto-Sts': {'type': 'enum', 'enums': _et.DSBL_ENBL,
'value': Const.DsblEnbl.Dsbl},
# Power Supply Parameters
# --- PS ---
'ParamPSName-Cte': {'type': 'char', 'count': 64, 'value': ''},
'ParamPSModel-Cte': {'type': 'float', 'value': float('NaN')},
'ParamNrModules-Cte': {'type': 'float', 'value': float('NaN')},
'ParamCommCmdInferface-Cte': {'type': 'float', 'value': float('NaN')},
'ParamCommRS485BaudRate-Cte': {'type': 'float', 'value': float('NaN')},
'ParamPSModel-Cte': {'type': 'float', 'value': 0.0},
'ParamNrModules-Cte': {'type': 'float', 'value': 0.0},
# --- COMM ---
'ParamCommCmdInferface-Cte': {'type': 'float', 'value': 0.0},
'ParamCommRS485BaudRate-Cte': {'type': 'float', 'value': 0.0},
'ParamCommRS485Addr-Cte': {'type': 'float', 'count': 4,
'value': _np.array([float('NaN'), ] * 4)},
'ParamCommRS485TermRes-Cte': {'type': 'float', 'value': float('NaN')},
'ParamCommUDCNetAddr-Cte': {'type': 'float', 'value': float('NaN')},
'value': _np.array([0.0, ] * 4)},
'ParamCommRS485TermRes-Cte': {'type': 'float', 'value': 0.0},
'ParamCommUDCNetAddr-Cte': {'type': 'float', 'value': 0.0},
'ParamCommEthIP-Cte':
{'type': 'float', 'count': 4,
'value': _np.array([float('NaN'), ] * 4)},
'value': _np.array([0.0, ] * 4)},
'ParamCommEthSubnetMask-Cte':
{'type': 'float', 'count': 4,
'value': _np.array([float('NaN'), ] * 4)},
'ParamCommBuzVol-Cte': {'type': 'float', 'value': float('NaN')},
'ParamCtrlFreqCtrlISR-Cte': {'type': 'float', 'value': float('NaN')},
'value': _np.array([0.0, ] * 4)},
'ParamCommBuzVol-Cte':
{'type': 'float', 'value': 0.0, 'unit': '%'},
# --- Control ---
'ParamCtrlFreqCtrlISR-Cte':
{'type': 'float', 'value': 0.0, 'unit': 'Hz'},
'ParamCtrlFreqTimeSlicer-Cte':
{'type': 'float', 'count': 4,
'value': _np.array([float('NaN'), ] * 4)},
'ParamCtrlMaxRef-Cte': {'type': 'float', 'value': float('NaN')},
'ParamCtrlMinRef-Cte': {'type': 'float', 'value': float('NaN')},
'value': _np.array([0.0, ] * 4),
'unit': 'Hz'},
'ParamCtrlMaxRef-Cte':
{'type': 'float', 'value': 0.0, 'unit': 'A/V'},
'ParamCtrlMinRef-Cte':
{'type': 'float', 'value': 0.0, 'unit': 'A/V'},
'ParamCtrlMaxRefOpenLoop-Cte':
{'type': 'float', 'value': float('NaN')},
{'type': 'float', 'value': 0.0},
'ParamCtrlMinRefOpenLoop-Cte':
{'type': 'float', 'value': float('NaN')},
{'type': 'float', 'value': 0.0},
'ParamCtrlSlewRateSlowRef-Cte':
{'type': 'float', 'value': float('NaN')},
{'type': 'float', 'value': 0.0, 'unit': 'Ref/s'},
'ParamCtrlSlewRateSigGenAmp-Cte':
{'type': 'float', 'value': float('NaN')},
{'type': 'float', 'value': 0.0, 'unit': 'Ref/s'},
'ParamCtrlSlewRateSigGenOffset-Cte':
{'type': 'float', 'value': float('NaN')},
{'type': 'float', 'value': 0.0, 'unit': 'Ref/s'},
'ParamCtrlSlewRateWfmRef-Cte':
{'type': 'float', 'value': float('NaN')}})
{'type': 'float', 'value': 0.0, 'unit': 'Ref/s'},
# --- PWM ---
'ParamPWMFreq-Cte':
{'type': 'float', 'value': 0.0, 'unit': 'Hz'},
'ParamPWMDeadTime-Cte':
{'type': 'float', 'value': 0.0, 'unit': 'ns'},
'ParamPWMMaxDuty-Cte':
{'type': 'float', 'value': 0.0, 'unit': '%'},
'ParamPWMMinDuty-Cte':
{'type': 'float', 'value': 0.0, 'unit': '%'},
'ParamPWMMaxDutyOpenLoop-Cte':
{'type': 'float', 'value': 0.0, 'unit': '%'},
'ParamPWMMinDutyOpenLoop-Cte':
{'type': 'float', 'value': 0.0, 'unit': '%'},
'ParamPWMLimDutyShare-Cte':
{'type': 'float', 'value': 0.0, 'unit': '%'},
# --- Analog Variables ---
'ParamAnalogMax-Cte':
{'type': 'float', 'count': 64,
'value': _np.array([0.0, ] * 64)},
'ParamAnalogMin-Cte':
{'type': 'float', 'count': 64,
'value': _np.array([0.0, ] * 64)},
# --- Debounce Manager ---
'ParamHardIntlkDebounceTime-Cte':
{'type': 'float', 'count': 32,
'value': _np.array([0.0, ] * 32), 'unit': 'us'},
'ParamHardIntlkResetTime-Cte':
{'type': 'float', 'count': 32,
'value': _np.array([0.0, ] * 32), 'unit': 'us'},
'ParamSoftIntlkDebounceTime-Cte':
{'type': 'float', 'count': 32,
'value': _np.array([0.0, ] * 32), 'unit': 'us'},
'ParamSoftIntlkResetTime-Cte':
{'type': 'float', 'count': 32,
'value': _np.array([0.0, ] * 32), 'unit': 'us'},
})

return dbase


Expand Down Expand Up @@ -838,6 +883,12 @@ def _get_ps_FBP_propty_database():
'IntlkHardLabels-Cte': {'type': 'string',
'count': len(_et.HARD_INTLCK_FBP),
'value': _et.HARD_INTLCK_FBP},
'LoadVoltage-Mon': {'type': 'float', 'value': 0.0,
'prec': DEFAULT_PS_CURRENT_PRECISION,
'unit': 'V'},
'DCLinkVoltage-Mon': {'type': 'float', 'value': 0.0,
'prec': DEFAULT_PS_CURRENT_PRECISION,
'unit': 'V'},
'SwitchesTemperature-Mon': {'type': 'float', 'value': 0.0,
'prec': 2,
'unit': 'C'},
Expand Down
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/pwrsupply/bsmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class ConstPSBSMP:
# ----- class Analog Variables -----
P_ANALOG_MAX = 46
P_ANALOG_MIN = 47
# ----- Debounding manager -----
# ----- class Debounding manager -----
P_HARD_INTLK_DEBOUNCE_TIME = 48
P_HARD_INTLK_RESET_TIME = 49
P_SOFT_INTLK_DEBOUNCE_TIME = 50
Expand Down
Loading

0 comments on commit e1b43eb

Please sign in to comment.