Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
36 changes: 19 additions & 17 deletions siriuspy/siriuspy/clientconfigdb/types/as_corrloop_params.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""Parameters of the IOCs of the AP discipline."""
from copy import deepcopy as _dcopy

_off = 0
_on = 1
from siriuspy.optics.constants import SI as _SI


_SI_HARM_NR = _SI.harmonic_number


def get_dict():
Expand Down Expand Up @@ -90,11 +92,11 @@ def get_dict():
['SI-Glob:DI-BbBProc-L:CSET3', [0.0]*31, 0.0],
['SI-Glob:DI-BbBProc-L:FB_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-L:CF_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-L:FB_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-L:CF_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-L:DRIVE0_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-L:DRIVE1_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-L:DRIVE2_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-L:FB_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-L:CF_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-L:DRIVE0_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-L:DRIVE1_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-L:DRIVE2_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-L:DRIVE0_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-L:DRIVE1_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-L:DRIVE2_PATTERN', '', 0.0],
Expand Down Expand Up @@ -128,17 +130,17 @@ def get_dict():
['SI-Glob:DI-BbBProc-H:CSET3', [0.0]*31, 0.0],
['SI-Glob:DI-BbBProc-H:FB_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-H:CF_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-H:FB_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-H:CF_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-H:FB_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-H:CF_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-H:CLEAN_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-H:CLEAN_ENABLE', 0, 0.0],
['SI-Glob:DI-BbBProc-H:CLEAN_PERIOD', 0.0, 0.0],
['SI-Glob:DI-BbBProc-H:CLEAN_SPAN', 0.0, 0.0],
['SI-Glob:DI-BbBProc-H:CLEAN_TUNE', 0.0, 0.0],
['SI-Glob:DI-BbBProc-H:CLEAN_AMPL', 0.0, 0.0],
['SI-Glob:DI-BbBProc-H:DRIVE0_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-H:DRIVE1_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-H:DRIVE2_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-H:DRIVE0_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-H:DRIVE1_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-H:DRIVE2_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-H:DRIVE0_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-H:DRIVE1_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-H:DRIVE2_PATTERN', '', 0.0],
Expand Down Expand Up @@ -172,17 +174,17 @@ def get_dict():
['SI-Glob:DI-BbBProc-V:CSET3', [0.0]*31, 0.0],
['SI-Glob:DI-BbBProc-V:FB_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-V:CF_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-V:FB_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-V:CF_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-V:FB_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-V:CF_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-V:CLEAN_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-V:CLEAN_ENABLE', 0, 0.0],
['SI-Glob:DI-BbBProc-V:CLEAN_PERIOD', 0.0, 0.0],
['SI-Glob:DI-BbBProc-V:CLEAN_SPAN', 0.0, 0.0],
['SI-Glob:DI-BbBProc-V:CLEAN_TUNE', 0.0, 0.0],
['SI-Glob:DI-BbBProc-V:CLEAN_AMPL', 0.0, 0.0],
['SI-Glob:DI-BbBProc-V:DRIVE0_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-V:DRIVE1_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-V:DRIVE2_MASK', [0]*864, 0.0],
['SI-Glob:DI-BbBProc-V:DRIVE0_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-V:DRIVE1_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-V:DRIVE2_MASK', [0]*_SI_HARM_NR, 0.0],
['SI-Glob:DI-BbBProc-V:DRIVE0_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-V:DRIVE1_PATTERN', '', 0.0],
['SI-Glob:DI-BbBProc-V:DRIVE2_PATTERN', '', 0.0],
Expand Down
7 changes: 6 additions & 1 deletion siriuspy/siriuspy/clientconfigdb/types/as_diagnostics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
"""Diagnostic equipments configuration."""
from copy import deepcopy as _dcopy

from siriuspy.optics.constants import SI as _SI


_SI_HARM_NR = _SI.harmonic_number


def get_dict():
"""Return configuration type dictionary."""
Expand Down Expand Up @@ -423,7 +428,7 @@ def get_dict():
[':GENTriggerHwDly-SP', 0, 0.0],
[':PMTriggerHwDly-SP', 0, 0.0],
# [':INFOClkFreq-SP', 220910069.0, 0.0],
[':INFOHarmonicNumber-SP', 864, 0.0],
[':INFOHarmonicNumber-SP', _SI_HARM_NR, 0.0],
[':INFOTbTRate-SP', 382, 0.0],
[':INFOFOFBRate-SP', 8786, 0.0],
[':INFOMONITRate-SP', 21929856, 0.0],
Expand Down
6 changes: 3 additions & 3 deletions siriuspy/siriuspy/clientconfigdb/types/global_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as _np

from siriuspy.optics.constants import SI as _SI
from siriuspy.pwrsupply.csdev import \
DEFAULT_WFM_FBP as _DEFAULT_WFM_FBP, \
MAX_WFMSIZE_FBP as _MAX_WFMSIZE_FBP, \
Expand All @@ -11,9 +12,8 @@
from siriuspy.clientconfigdb.types.as_diagnostics import _bpms


_OFF = 0
_ON = 1
_SLOWREF = 0
_SI_HARM_NR = _SI.harmonic_number


def get_dict():
Expand Down Expand Up @@ -2714,7 +2714,7 @@ def get_dict():
_pvs_as_injection = [
[
'AS-Glob:AP-InjCtrl:BucketListAllowedMask-SP',
_np.ones(864, dtype=int),
_np.ones(_SI_HARM_NR, dtype=int),
0.0
],
]
Expand Down
7 changes: 4 additions & 3 deletions siriuspy/siriuspy/currinfo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ..clientarch import ClientArchiver as _ClientArch
from ..envars import VACA_PREFIX as _vaca_prefix
from ..epics import PV as _PV, SiriusPVTimeSerie as _SiriusPVTimeSerie
from ..optics.constants import SI as _SI, BO as _BO
from ..oscilloscope import Keysight as _Keysight, Scopes as _Scopes
from ..pwrsupply.csdev import Const as _PSc
from ..search import LLTimeSearch as _LLTimeSearch
Expand Down Expand Up @@ -201,7 +202,7 @@ def _update_pvs(self, *args):
class BOCurrInfoApp(_CurrInfoApp):
"""Main Class."""

HARMNUM = 828
HARMNUM = _BO.harmonic_number
INTCURR_INTVL = 53.5 * 1e-3 / 3600 # [h]
MAX_CURRENT = 3.0 # [A]
ENERGY2TIME = { # energy: time[s]
Expand Down Expand Up @@ -376,8 +377,8 @@ def _update_pvs(self):
class SICurrInfoApp(_CurrInfoApp):
"""Main Class."""

HARMNUM = 864
HARMNUM_RATIO = 864 / 828
HARMNUM = _SI.harmonic_number
HARMNUM_RATIO = _SI.harmonic_number / _BO.harmonic_number
CURR_THRESHOLD = 0.02 # [mA]
MAX_CURRENT = 1.0 # [A]

Expand Down
31 changes: 23 additions & 8 deletions siriuspy/siriuspy/devices/sofb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

import numpy as _np

from ..optics.constants import (
SI as _SI,
BO as _BO,
TB as _TB,
TS as _TS,
accelerators as _accelerators,
)

from ..sofb.csdev import SOFBFactory
from ..sofb.utils import si_calculate_bump as _si_calculate_bump
from .device import Device as _Device
Expand Down Expand Up @@ -34,17 +42,18 @@ def __new__(
raise NotImplementedError(devname)

# SOFB object
data = SOFBFactory.create(devname[:2])
acc = _accelerators.accelerators[devname[:2]]
data = SOFBFactory.create(acc)

if data.acc == 'SI':
if acc == _SI:
return SISOFB(
devname,
data,
props2init=props2init,
auto_monitor=auto_monitor,
auto_monitor_mon=auto_monitor_mon,
)
elif data.isring:
elif acc == _BO:
return BOSOFB(
devname,
data,
Expand Down Expand Up @@ -147,7 +156,8 @@ def __init__(
raise NotImplementedError(devname)

# SOFB object
self._data = data or SOFBFactory.create(devname[:2])
acc = _accelerators[devname[:2]]
self._data = data or SOFBFactory.create(acc)
# call base class constructor
super().__init__(
devname,
Expand All @@ -156,6 +166,11 @@ def __init__(
auto_monitor_mon=auto_monitor_mon,
)

@property
def acc(self):
"""Accelerator."""
return self._data.acc

@property
def data(self):
"""."""
Expand Down Expand Up @@ -1018,12 +1033,12 @@ def drivedata_bpm(self):
@property
def orbx(self):
"""."""
return self['SlowOrbX-Mon'] if self._data.isring else None
return self['SlowOrbX-Mon'] if self.acc.isring else None

@property
def orby(self):
"""."""
return self['SlowOrbY-Mon'] if self._data.isring else None
return self['SlowOrbY-Mon'] if self.acc.isring else None

@property
def kickrf(self):
Expand Down Expand Up @@ -1063,13 +1078,13 @@ def mancorrgainrf(self, value):
@property
def rfenbl(self):
"""."""
if self._data.acc_idx == self._data.Rings.SI:
if self.acc == _SI:
return bool(self['RFEnbl-Sts'])

@rfenbl.setter
def rfenbl(self, value):
"""."""
if self._data.acc_idx == self._data.Rings.SI:
if self.acc == _SI:
self['RFEnbl-Sel'] = value

@property
Expand Down
9 changes: 5 additions & 4 deletions siriuspy/siriuspy/devices/timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as _np
from mathphys.functions import get_namedtuple as _get_namedtuple

from ..optics.constants import SI as _SI
from ..search import HLTimeSearch as _HLTimeSearch
from ..timesys.csdev import (
Const as _TIConst,
Expand Down Expand Up @@ -148,13 +149,13 @@ def injection_count(self):
def fill_bucketlist(self, stop, start=1, step=30, timeout=10):
"""Fill bucket list."""
if (step > 0) and (start > stop):
stop += 864
stop += _SI.harmonic_number
if (step < 0) and (stop > start):
stop -= 864
stop -= _SI.harmonic_number
value = _np.arange(start, stop, step)
value = (value - 1) % 864 + 1
value = (value - 1) % _SI.harmonic_number + 1
self.bucketlist = value
rb_value = _np.zeros(864)
rb_value = _np.zeros(_SI.harmonic_number)
rb_value[: len(value)] = value
return self.wait('BucketList-RB', rb_value, timeout=timeout)

Expand Down
7 changes: 5 additions & 2 deletions siriuspy/siriuspy/devices/tune.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Tune devices."""

from ..optics.constants import SI as _SI

from .device import Device as _Device, DeviceSet as _DeviceSet


Expand Down Expand Up @@ -55,8 +57,9 @@ def rev_harmonic(self):
@rev_harmonic.setter
def rev_harmonic(self, value):
"""Revolution harmonic."""
if not 0 <= int(value) <= 864:
raise ValueError('rev_harmonic must be in range [0, 864]')
hnumber = _SI.harmonic_number
if not 0 <= int(value) <= hnumber:
raise ValueError(f'rev_harmonic must be in range [0, {hnumber}]')
self['RevN-SP'] = int(value)

@property
Expand Down
7 changes: 5 additions & 2 deletions siriuspy/siriuspy/diagbeam/bpm/csdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as _np

from ... import csdev as _csdev
from siriuspy.optics.constants import SI as _SI


# --- Enumeration Types ---
Expand Down Expand Up @@ -79,9 +80,11 @@ def get_bpm_database(prefix=''):
'INFOFOFBRate-RB': {
'type': 'int', 'value': 1910, 'low': 0, 'high': 2**31-1},
'INFOHarmonicNumber-SP': {
'type': 'int', 'value': 864, 'low': 0, 'high': 2**31-1},
'type': 'int', 'value': _SI.harmonic_number,
'low': 0, 'high': 2**31-1},
'INFOHarmonicNumber-RB': {
'type': 'int', 'value': 864, 'low': 0, 'high': 2**31-1},
'type': 'int', 'value': _SI.harmonic_number,
'low': 0, 'high': 2**31-1},
'INFOMONITRate-SP': {
'type': 'int', 'value': 21965000, 'low': 0, 'high': 2**31-1},
'INFOMONITRate-RB': {
Expand Down
4 changes: 3 additions & 1 deletion siriuspy/siriuspy/fpmosc/csdev.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Define PVs, constants and properties of Filling Pattern SoftIOCs."""

from .. import csdev as _csdev
from ..optics.constants import SI as _SI


# --- Const class ---

Expand All @@ -9,7 +11,7 @@ class Const(_csdev.Const):
"""Const class defining Filling Pattern constants."""

FP_MAX_ARR_SIZE = 40000
FP_HARM_NUM = 864
FP_HARM_NUM = _SI.harmonic_number
FP_MAX_UPDT_TIME = 600 # [s]
DEVNAME = 'SI-Glob:DI-FPMOsc'

Expand Down
3 changes: 2 additions & 1 deletion siriuspy/siriuspy/fpmosc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from ..callbacks import Callback as _Callback
from ..envars import VACA_PREFIX as _VACA_PREFIX
from ..epics import PV as _PV
from ..optics.constants import SI as _SI
from ..oscilloscope import Keysight as _Keysight, ScopeSignals as _ScopeSignals
from .csdev import Const as _Const, get_si_fpmosc_database as _get_database

Expand Down Expand Up @@ -88,7 +89,7 @@ def write(self, reason, value):
if not isinstance(value, (_np.ndarray, list, tuple)):
return False
value = _np.array(value)
if value.size != 864 or value.min() < 0:
if value.size != _SI.harmonic_number or value.min() < 0:
return False
self._fillpat_ref = value / value.sum()
self.run_callbacks('FillPatternRef-RB', self._fillpat_ref)
Expand Down
9 changes: 6 additions & 3 deletions siriuspy/siriuspy/injctrl/csdev.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Injection Control App."""

from .. import csdev as _csdev
from ..optics.constants import SI as _SI
from ..util import ClassProperty as _classproperty
from ..search import PSSearch as _PSSearch

Expand Down Expand Up @@ -68,7 +69,7 @@ class Const(_csdev.Const):
)

MIN_BKT = 1
MAX_BKT = 864
MAX_BKT = _SI.harmonic_number

RF_RMP_TIMEOUT = 3*60 # [s]
TI_INJ_TIMEOUT = 3*60 # [s]
Expand Down Expand Up @@ -257,10 +258,12 @@ def get_injctrl_propty_database():
'type': 'int', 'value': 1, 'unit': 'bucket index',
'lolim': _ct.MIN_BKT, 'hilim': _ct.MAX_BKT},
'BucketListStop-SP': {
'type': 'int', 'value': 864, 'unit': 'bucket index',
'type': 'int', 'value': _SI.harmonic_number,
'unit': 'bucket index',
'lolim': _ct.MIN_BKT, 'hilim': _ct.MAX_BKT, },
'BucketListStop-RB': {
'type': 'int', 'value': 864, 'unit': 'bucket index',
'type': 'int', 'value': _SI.harmonic_number,
'unit': 'bucket index',
'lolim': _ct.MIN_BKT, 'hilim': _ct.MAX_BKT},
'BucketListStep-SP': {
'type': 'int', 'value': 29, 'unit': 'buckets',
Expand Down
Loading
Loading