Skip to content

Commit

Permalink
Merge pull request #245 from lnls-sirius/standardize-prefix
Browse files Browse the repository at this point in the history
Standardize PV prefix handling
  • Loading branch information
anacso17 authored Dec 15, 2021
2 parents 0078f19 + 262739e commit 67e6b95
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 31 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.24.0
3.24.1
2 changes: 1 addition & 1 deletion as-ap-currinfo/as_ap_currinfo/as_ap_currinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def run(acc):

# define IOC, init pvs database and create app object
_version = _util.get_last_commit_hash()
_ioc_prefix = _vaca_prefix
_ioc_prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
if acc == 'BO':
_ioc_prefix += acc + '-Glob:AP-CurrInfo:'
_log.debug('Creating App Object.')
Expand Down
3 changes: 2 additions & 1 deletion as-ap-currinfo/as_ap_currinfo/lifetime/lifetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def run():

# define IOC, init pvs database and create app object
_version = _util.get_last_commit_hash()
_ioc_prefix = _vaca_prefix + 'SI-Glob:AP-CurrInfo:'
_ioc_prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
_ioc_prefix += 'SI-Glob:AP-CurrInfo:'
app = _SILifetimeApp()
dbase = app.pvs_database
dbase['VersionLifetime-Cte']['value'] = _version
Expand Down
3 changes: 2 additions & 1 deletion as-ap-machshift/as_ap_machshift/as_ap_machshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def run():

# define IOC, init pvs database and create app object
_version = _util.get_last_commit_hash()
_ioc_prefix = _vaca_prefix + 'AS-Glob:AP-MachShift:'
_ioc_prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
_ioc_prefix += 'AS-Glob:AP-MachShift:'
app = _App()
dbase = app.pvs_database
dbase['Version-Cte']['value'] = _version
Expand Down
3 changes: 2 additions & 1 deletion as-ap-opticscorr/as_ap_opticscorr/chrom/chrom.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def run(acc):

# define IOC, init pvs database and create app object
_version = _util.get_last_commit_hash()
_ioc_prefix = _vaca_prefix + acc.upper() + '-Glob:AP-ChromCorr:'
_ioc_prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
_ioc_prefix += acc.upper() + '-Glob:AP-ChromCorr:'
app = _App(acc)
dbase = app.pvs_database
dbase['Version-Cte']['value'] = _version
Expand Down
3 changes: 2 additions & 1 deletion as-ap-opticscorr/as_ap_opticscorr/tune/tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def run(acc):

# define IOC, init pvs database and create app object
_version = _util.get_last_commit_hash()
_ioc_prefix = _vaca_prefix + acc.upper() + '-Glob:AP-TuneCorr:'
_ioc_prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
_ioc_prefix += acc.upper() + '-Glob:AP-TuneCorr:'
app = _App(acc)
dbase = app.pvs_database
dbase['Version-Cte']['value'] = _version
Expand Down
3 changes: 2 additions & 1 deletion as-ap-posang/as_ap_posang/as_ap_posang.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def run(transport_line, correctors_type='ch-sept'):

# define IOC, init pvs database and create app object
_version = _util.get_last_commit_hash()
_ioc_prefix = _vaca_prefix + transport_line.upper() + '-Glob:AP-PosAng:'
_ioc_prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
_ioc_prefix += transport_line.upper() + '-Glob:AP-PosAng:'
app = _App(transport_line, corrs_type=correctors_type)
dbase = app.pvs_database
dbase['Version-Cte']['value'] = _version
Expand Down
10 changes: 5 additions & 5 deletions as-ap-sofb/as_ap_sofb/as_ap_sofb.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,26 @@ def run(acc='SI', debug=False):
app = _SOFB(acc=acc)
db = app.csorb.get_ioc_database()
db.update({'Version-Cte': {'type': 'string', 'value': __version__}})
ioc_prefix = acc.upper() + '-Glob:AP-SOFB:'
ioc_prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
ioc_prefix += acc.upper() + '-Glob:AP-SOFB:'
ioc_name = acc.lower() + '-ap-sofb'
# check if IOC is already running
running = _util.check_pv_online(
pvname=_vaca_prefix + ioc_prefix + sorted(db.keys())[0],
pvname=ioc_prefix + sorted(db.keys())[0],
use_prefix=False, timeout=0.5)
# add PV Properties-Cte with list of all IOC PVs:
db = _csdev.add_pvslist_cte(db)
if running:
_log.error('Another ' + ioc_name + ' is already running!')
return
_util.print_ioc_banner(
ioc_name, db, 'SOFB for ' + acc, __version__,
_vaca_prefix + ioc_prefix)
ioc_name, db, 'SOFB for ' + acc, __version__, ioc_prefix)
# create a new simple pcaspy server and driver to respond client's requests
_log.info('Creating Server.')
server = _pcaspy.SimpleServer()
_attribute_access_security_group(server, db)
_log.info('Setting Server Database.')
server.createPV(_vaca_prefix + ioc_prefix, db)
server.createPV(ioc_prefix, db)
_log.info('Creating Driver.')
driver = _PCASDriver(app)

Expand Down
9 changes: 5 additions & 4 deletions as-ps-diag/as_ps_diag/as_ps_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def run(section='', sub_section='', device='', debug=False):
_log.warning('No devices found. Aborting.')
_sys.exit(0)

prefix = _vaca_prefix
_version = _util.get_last_commit_hash()
prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
pvdb = dict()
for psname in psnames:
_log.debug('{:32s}'.format(psname))
Expand All @@ -121,7 +122,7 @@ def run(section='', sub_section='', device='', debug=False):
raise ValueError('Another instance of this IOC is already running!')

# create app
app = _App(prefix, psnames)
app = _App(psnames)

# create a new simple pcaspy server
_log.info("Creating server with %d devices and '%s' prefix",
Expand All @@ -140,8 +141,8 @@ def run(section='', sub_section='', device='', debug=False):

_util.print_ioc_banner(
'AS PS Diagnostic', pvdb,
'IOC that provides current sp/mon diagnostics for the power supplies.',
'0.2', prefix)
'IOC that provides power supplies diagnostics.',
_version, prefix)

# initiate a new thread responsible for listening for client connections
server_thread = _pcaspy_tools.ServerThread(server)
Expand Down
2 changes: 1 addition & 1 deletion as-ps/as_ps/as_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
STOP_EVENT = False # _multiprocessing.Event()
PCAS_DRIVER = None

_PREFIX = _VACA_PREFIX
_PREFIX = _VACA_PREFIX + ('-' if _VACA_PREFIX else '')
_COMMIT_HASH = __version__


Expand Down
2 changes: 1 addition & 1 deletion as-pu-conv/as_pu_conv/as_pu_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
STOP_EVENT = False # _multiprocessing.Event()
PCAS_DRIVER = None

_PREFIX = _VACA_PREFIX
_PREFIX = _VACA_PREFIX + ('-' if _VACA_PREFIX else '')
_COMMIT_HASH = _util.get_last_commit_hash()


Expand Down
4 changes: 2 additions & 2 deletions as-pu-diag/as_pu_diag/as_pu_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def run(debug=False):
_log.warning('No devices found. Aborting.')
_sys.exit(0)

prefix = _vaca_prefix
prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
pvdb = dict()
for puname in punames:
_log.debug('{:32s}'.format(puname))
Expand All @@ -112,7 +112,7 @@ def run(debug=False):
raise ValueError('Another instance of this IOC is already running!')

# create app
app = _App(prefix, punames)
app = _App(punames)

# create a new simple pcaspy server
_log.info("Creating server with %d devices and '%s' prefix",
Expand Down
4 changes: 2 additions & 2 deletions as-rf-diag/as_rf_diag/as_rf_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def run(debug=False):
# create PV database
devices = _Const.ALL_DEVICES

prefix = _vaca_prefix
prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
pvdb = dict()
for dev in devices:
_log.debug('{:32s}'.format(dev))
Expand All @@ -104,7 +104,7 @@ def run(debug=False):
raise ValueError('Another instance of this IOC is already running!')

# create app
app = _App(prefix, devices)
app = _App(devices)

# create a new simple pcaspy server
_log.info("Creating server with %d devices and '%s' prefix",
Expand Down
7 changes: 4 additions & 3 deletions as-ti-control/as_ti_control/as_ti_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,23 @@ def run(section='as', wait=5, debug=False):
db[ioc_prefix + 'Version-Cte'] = {'type': 'string', 'value': __version__}
# add PV Properties-Cte with list of all IOC PVs:
db = _csdev.add_pvslist_cte(db, prefix=ioc_prefix)
prefix = _vaca_prefix + ('-' if _vaca_prefix else '')

# check if IOC is already running
running = _util.check_pv_online(
pvname=_vaca_prefix + sorted(db.keys())[0],
pvname=prefix + sorted(db.keys())[0],
use_prefix=False, timeout=0.5)
if running:
_log.error('Another ' + ioc_name + ' is already running!')
return
_util.print_ioc_banner(
ioc_name, db, 'High Level Timing IOC.', __version__, _vaca_prefix)
ioc_name, db, 'High Level Timing IOC.', __version__, prefix)

_log.info('Creating Server.')
server = _pcaspy.SimpleServer()
_attribute_access_security_group(server, db)
_log.info('Setting Server Database.')
server.createPV(_vaca_prefix, db)
server.createPV(prefix, db)

_log.info('Waiting 5s for PVs to connect...')
app.wait_for_connection(5)
Expand Down
4 changes: 2 additions & 2 deletions li-ap-diag/li_ap_diag/li_ap_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def run(debug=False):
# create PV database
devices = _Const.ALL_DEVICES

prefix = _vaca_prefix
prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
pvdb = dict()
for dev in devices:
_log.debug('{:32s}'.format(dev))
Expand All @@ -104,7 +104,7 @@ def run(debug=False):
raise ValueError('Another instance of this IOC is already running!')

# create app
app = _App(prefix, devices)
app = _App(devices)

# create a new simple pcaspy server
_log.info("Creating server with %d devices and '%s' prefix",
Expand Down
3 changes: 2 additions & 1 deletion li-ap-energy/li_ap_energy/li_ap_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def run(debug=False):
"""Start the IOC."""
_util.configure_log_file(debug=debug)
_log.info('Starting...')
ioc_prefix = _vaca_prefix + 'LI-Glob:AP-MeasEnergy:'
ioc_prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
ioc_prefix += 'LI-Glob:AP-MeasEnergy:'

# define abort function
_signal.signal(_signal.SIGINT, _stop_now)
Expand Down
2 changes: 1 addition & 1 deletion li-ps-conv/li_ps_conv/li_ps_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
STOP_EVENT = False # _multiprocessing.Event()
PCAS_DRIVER = None

_PREFIX = _VACA_PREFIX
_PREFIX = _VACA_PREFIX + ('-' if _VACA_PREFIX else '')
_COMMIT_HASH = _util.get_last_commit_hash()


Expand Down
3 changes: 2 additions & 1 deletion si-ap-manaca/si_ap_manaca/si_ap_manaca.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def run(debug=False):
"""Start the IOC."""
_util.configure_log_file(debug=debug)
_log.info('Starting...')
ioc_prefix = _vaca_prefix + _csmanaca.PREFIX_IOC
ioc_prefix = _vaca_prefix + ('-' if _vaca_prefix else '')
ioc_prefix += _csmanaca.PREFIX_IOC

# define abort function
_signal.signal(_signal.SIGINT, _stop_now)
Expand Down
2 changes: 1 addition & 1 deletion si-id-conv/si_id_conv/si_id_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
STOP_EVENT = False # _multiprocessing.Event()
PCAS_DRIVER = None

_PREFIX = _VACA_PREFIX
_PREFIX = _VACA_PREFIX + ('-' if _VACA_PREFIX else '')
_COMMIT_HASH = _util.get_last_commit_hash()


Expand Down

0 comments on commit 67e6b95

Please sign in to comment.