Skip to content

Commit 568fe66

Browse files
authored
Merge pull request #47 from tynanford/master
Add record type to channel finder from recceiver
2 parents 0bcc1a8 + e44e336 commit 568fe66

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

server/cf.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ procs = cf
3737
[cf]
3838
# a space-separated list of infotags to set as CF Properties
3939
#infotags = archive foo bar blah
40+
# Turn on optional alias and recordType properties
41+
#alias = on
42+
#recordType = on

server/recceiver/cfstore.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ def _startServiceWithLock(self):
7272
self.client = ChannelFinderClient()
7373
try:
7474
cf_props = [prop['name'] for prop in self.client.getAllProperties()]
75+
reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'iocid'}
7576
if (self.conf.get('alias', 'default') == 'on'):
76-
reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'iocid', 'alias'}
77-
else:
78-
reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'iocid'}
77+
reqd_props.add('alias')
78+
if (self.conf.get('recordType', 'default') == 'on'):
79+
reqd_props.add('recordType')
7980
wl = self.conf.get('infotags', list())
8081
whitelist = [s.strip(', ') for s in wl.split()] \
8182
if wl else wl
@@ -173,6 +174,8 @@ def _commitWithThread(self, TR):
173174
pvInfo = {}
174175
for rid, (rname, rtype) in TR.addrec.items():
175176
pvInfo[rid] = {"pvName": rname}
177+
if (self.conf.get('recordType', 'default' == 'on')):
178+
pvInfo[rid]['recordType'] = rtype
176179
for rid, (recinfos) in TR.recinfos.items():
177180
# find intersection of these sets
178181
if rid not in pvInfo:
@@ -335,6 +338,8 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io
335338
{u'name': 'pvStatus', u'owner': owner, u'value': 'Active'},
336339
{u'name': 'time', u'owner': owner, u'value': iocTime}],
337340
ch[u'properties'])
341+
if (conf.get('recordType', 'default') == 'on'):
342+
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'])
338343
channels.append(ch)
339344
_log.debug("Add existing channel to previous IOC: %s", channels[-1])
340345
"""In case alias exist, also delete them"""
@@ -350,6 +355,8 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io
350355
{u'name': 'pvStatus', u'owner': owner, u'value': 'Active'},
351356
{u'name': 'time', u'owner': owner, u'value': iocTime}],
352357
a[u'properties'])
358+
if (conf.get('recordType', 'default') == 'on'):
359+
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'])
353360
channels.append(a)
354361
_log.debug("Add existing alias to previous IOC: %s", channels[-1])
355362

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

0 commit comments

Comments
 (0)