Skip to content

Commit

Permalink
Merge pull request #47 from tynanford/master
Browse files Browse the repository at this point in the history
Add record type to channel finder from recceiver
  • Loading branch information
shroffk authored Jan 20, 2021
2 parents 0bcc1a8 + e44e336 commit 568fe66
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions server/cf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ procs = cf
[cf]
# a space-separated list of infotags to set as CF Properties
#infotags = archive foo bar blah
# Turn on optional alias and recordType properties
#alias = on
#recordType = on
15 changes: 12 additions & 3 deletions server/recceiver/cfstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ def _startServiceWithLock(self):
self.client = ChannelFinderClient()
try:
cf_props = [prop['name'] for prop in self.client.getAllProperties()]
reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'iocid'}
if (self.conf.get('alias', 'default') == 'on'):
reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'iocid', 'alias'}
else:
reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'iocid'}
reqd_props.add('alias')
if (self.conf.get('recordType', 'default') == 'on'):
reqd_props.add('recordType')
wl = self.conf.get('infotags', list())
whitelist = [s.strip(', ') for s in wl.split()] \
if wl else wl
Expand Down Expand Up @@ -173,6 +174,8 @@ def _commitWithThread(self, TR):
pvInfo = {}
for rid, (rname, rtype) in TR.addrec.items():
pvInfo[rid] = {"pvName": rname}
if (self.conf.get('recordType', 'default' == 'on')):
pvInfo[rid]['recordType'] = rtype
for rid, (recinfos) in TR.recinfos.items():
# find intersection of these sets
if rid not in pvInfo:
Expand Down Expand Up @@ -335,6 +338,8 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io
{u'name': 'pvStatus', u'owner': owner, u'value': 'Active'},
{u'name': 'time', u'owner': owner, u'value': iocTime}],
ch[u'properties'])
if (conf.get('recordType', 'default') == 'on'):
ch[u'properties'] = __merge_property_list(ch[u'properties'].append({u'name': 'recordType', u'owner': owner, u'value': iocs[channels_dict[ch[u'name']][-1]]["recordType"]}), ch[u'properties'])
channels.append(ch)
_log.debug("Add existing channel to previous IOC: %s", channels[-1])
"""In case alias exist, also delete them"""
Expand All @@ -350,6 +355,8 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io
{u'name': 'pvStatus', u'owner': owner, u'value': 'Active'},
{u'name': 'time', u'owner': owner, u'value': iocTime}],
a[u'properties'])
if (conf.get('recordType', 'default') == 'on'):
ch[u'properties'] = __merge_property_list(ch[u'properties'].append({u'name': 'recordType', u'owner': owner, u'value': iocs[channels_dict[a[u'name']][-1]]["recordType"]}), ch[u'properties'])
channels.append(a)
_log.debug("Add existing alias to previous IOC: %s", channels[-1])

Expand Down Expand Up @@ -438,6 +445,8 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io
{u'name': 'iocid', u'owner': owner, u'value': iocid},
{u'name': 'pvStatus', u'owner': owner, u'value': "Active"},
{u'name': 'time', u'owner': owner, u'value': iocTime}]
if (conf.get('recordType', 'default') == 'on'):
newProps.append({u'name': 'recordType', u'owner': owner, u'value': pvInfoByName[pv]['recordType']})
if pv in pvInfoByName and "infoProperties" in pvInfoByName[pv]:
newProps = newProps + pvInfoByName[pv]["infoProperties"]

Expand Down

0 comments on commit 568fe66

Please sign in to comment.