Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 138: persist all MG properties #139

Merged
merged 5 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2025-14-06 Jan Kotanski <[email protected]>
* persist conditioning, instrument, nexus_path, normalization and output (#139)
* tagged as v3.42.0

2025-02-06 Jan Kotanski <[email protected]>
* add support for value_ref_enabled flag and value_ref_pattern (#134)
* fix ndim value (#136)
Expand Down
2 changes: 1 addition & 1 deletion man/nxsrecconfig.1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "NXSRECCONFIG" "1" "Feb 05, 2025" "3.41" "NXSRecSelector"
.TH "NXSRECCONFIG" "1" "Feb 13, 2025" "3.42" "NXSRecSelector"
.SH NAME
nxsrecconfig \- nxsrecconfig Documentation
.sp
Expand Down
122 changes: 113 additions & 9 deletions nxsrecconfig/ProfileManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,16 @@ def __createMntGrpConf(self, datasources,
if "value_ref_enabled" in props.keys() else {}
valuerefpattern = props["value_ref_pattern"] \
if "value_ref_pattern" in props.keys() else {}
conditioning = props["conditioning"] \
if "conditioning" in props.keys() else {}
instrument = props["instrument"] \
if "instrument" in props.keys() else {}
# nexus_path = props["nexus_path"] \
# if "nexus_path" in props.keys() else {}
normalization = props["normalization"] \
if "normalization" in props.keys() else {}
output = props["output"] \
if "output" in props.keys() else {}
tchannels = set(PoolUtils.getElementNames(
self.__pools, 'ExpChannelList',
['CTExpChannel', 'OneDExpChannel', 'TwoDExpChannel']))
Expand All @@ -611,6 +621,16 @@ def __createMntGrpConf(self, datasources,
if al in valuerefenabled.keys() else None,
valuerefpattern[al]
if al in valuerefpattern.keys() else None,
conditioning[al]
if al in conditioning.keys() else u'',
instrument[al]
if al in instrument.keys() else None,
# nexus_path[al]
# if al in nexus_path.keys() else u'',
normalization[al]
if al in normalization.keys() else 0,
output[al]
if al in output.keys() else True,
)
if self.masterTimerFirst and al == timer:
index = curindex
Expand Down Expand Up @@ -653,6 +673,11 @@ def __setFromMntGrpConf(self, jconf, compdatasources=None):
synchronization = {}
valuerefenabled = {}
valuerefpattern = {}
conditioning = {}
instrument = {}
# nexus_path = {}
normalization = {}
output = {}
self.__clearChannels(dsg, hel, compdatasources)

# fill in dsg, timers hel
Expand All @@ -661,7 +686,10 @@ def __setFromMntGrpConf(self, jconf, compdatasources=None):
avtimers = PoolUtils.getTimers(self.__pools, self.timerFilters)
tangods = self.__readChannels(
conf, timers, dsg, hel, synchronizer, synchronization, idch,
valuerefenabled, valuerefpattern)
valuerefenabled, valuerefpattern, conditioning, instrument,
normalization, output
# , nexus_path
)
self.__readTangoChannels(
conf, tangods, dsg, hel, synchronizer, synchronization)
otimers = self.__reorderTimers(conf, timers, dsg, hel, avtimers)
Expand All @@ -671,6 +699,11 @@ def __setFromMntGrpConf(self, jconf, compdatasources=None):
props["synchronization"] = synchronization
props["value_ref_enabled"] = valuerefenabled
props["value_ref_pattern"] = valuerefpattern
props["conditioning"] = conditioning
props["instrument"] = instrument
# props["nexus_path"] = nexus_path
props["normalization"] = normalization
props["output"] = output

changed = False
jdsg = json.dumps(dsg)
Expand Down Expand Up @@ -731,7 +764,11 @@ def __clearChannels(self, dsg, hel, compdatasources=None):

def __readChannels(self, conf, timers, dsg, hel, synchronizer,
synchronization, idch=None, valuerefenabled=None,
valuerefpattern=None):
valuerefpattern=None, conditioning=None,
instrument=None,
normalization=None, output=None
# , nexus_path=u''
):
""" reads channels from mntgrp configutation

:param conf: mntgrp configuration
Expand All @@ -753,6 +790,14 @@ def __readChannels(self, conf, timers, dsg, hel, synchronizer,
:type valuerefenabled: :obj:`dict` <:obj:`int`, :obj:`bool`>
:param valuerefpattern: channel value ref pattern
:type valuerefpattern: :obj:`dict` <:obj:`int`, :obj:`str`>
:param conditioning: channel conditioning
:type conditioning: :obj:`dict` <:obj:`int`, :obj:`str`>
:param instrument: channel instrument
:type instrument: :obj:`dict` <:obj:`int`, :obj:`str`>
:param normalization: channel normalization
:type normalization: :obj:`dict` <:obj:`int`, :obj:`str`>
:param output: channel output
:type output: :obj:`dict` <:obj:`int`, :obj:`str`>
:returns: tango datasources list with elements (name, label, source)
:rtype: :obj:`list` < [:obj:`str` , :obj:`str` , :obj:`str` ] >
"""
Expand Down Expand Up @@ -797,6 +842,34 @@ def __readChannels(self, conf, timers, dsg, hel, synchronizer,
# ch["value_ref_pattern"])
valuerefpattern[ch['name']] = \
ch["value_ref_pattern"]
if conditioning is not None and \
'conditioning' in ch and \
ch["conditioning"] is not None and \
ch["conditioning"] != u"":
conditioning[ch['name']] = \
ch["conditioning"]
if instrument is not None and \
'instrument' in ch and \
ch["instrument"] is not None:
instrument[ch['name']] = \
ch["instrument"]
# if nexus_path is not None and \
# 'nexus_path' in ch and \
# ch["nexus_path"] is not None:
# nexus_path[ch['name']] = \
# ch["nexus_path"]
if normalization is not None and \
'normalization' in ch and \
ch["normalization"] is not None \
and ch["normalization"] != 0:
normalization[ch['name']] = \
ch["normalization"]
if output is not None and \
'output' in ch and \
ch["output"] is not None and \
ch["output"] is not True:
output[ch['name']] = \
ch["output"]
if 'synchronizer' in ctrl \
and ctrl['synchronizer'].lower() != 'software':
synchronizer[ch['name']] = ctrl['synchronizer']
Expand Down Expand Up @@ -1320,7 +1393,12 @@ def __addDevice(self, device, dontdisplay, cnf,
timer, index, fullnames=None, sources=None,
synchronizer=None, synchronization=None,
valuerefenabled=None,
valuerefpattern=None):
valuerefpattern=None,
conditioning=u'',
instrument=None,
normalization=0, output=True
# , nexus_path=u''
):
""" adds device into configuration dictionary

:param device: device alias
Expand All @@ -1345,6 +1423,14 @@ def __addDevice(self, device, dontdisplay, cnf,
:type valuerefenabled: :obj:`bool`
:param valuerefpattern: value ref pattern
:type valuerefpattern: :obj:`str`
:param conditioning: conditioning
:type conditioning: :obj:`str`
:param instrument: instrument
:type instrument: :obj:`str`
:param normalization: normalization
:type normalization: :obj:`str`
:param output: output
:type output: :obj:`str`
:returns: next device index
:rtype: :obj:`int`
"""
Expand All @@ -1366,7 +1452,12 @@ def __addDevice(self, device, dontdisplay, cnf,
index = self.__addChannel(cnf, ctrl, device, fullname,
dontdisplay, index, source,
valuerefenabled,
valuerefpattern)
valuerefpattern,
conditioning,
instrument,
normalization, output
# , nexus_path
)
else:
describer = Describer(self.__configServer)
sds = describer.dataSources([device])
Expand Down Expand Up @@ -1454,7 +1545,12 @@ def __addController2(cls, cnf, ctrl, fulltimer):

@classmethod
def __addChannel(cls, cnf, ctrl, device, fullname, dontdisplay, index,
source, valuerefenabled=None, valuerefpattern=None):
source, valuerefenabled=None, valuerefpattern=None,
conditioning=u'',
instrument=None,
normalization=0, output=True
# , nexus_path=u''
):
""" adds channel into mngrp configuration dictionary

:param cnf: mntgrp configuration dictionary
Expand All @@ -1475,6 +1571,14 @@ def __addChannel(cls, cnf, ctrl, device, fullname, dontdisplay, index,
:type valuerefenabled: :obj:`bool`
:param valuerefenabled: value rrf pattern
:type valuerefpattern: :obj:`str`
:param conditioning: conditioning
:type conditioning: :obj:`str`
:param instrument: instrument
:type instrument: :obj:`str`
:param normalization: normalization
:type normalization: :obj:`str`
:param output: output
:type output: :obj:`str`
:returns: next index
:rtype: :obj:`int`
"""
Expand All @@ -1491,19 +1595,19 @@ def __addChannel(cls, cnf, ctrl, device, fullname, dontdisplay, index,
dct = {}
dct['_controller_name'] = Utils.tostr(ctrl)
dct['_unit_id'] = u'0'
dct['conditioning'] = u''
dct['conditioning'] = conditioning
dct['data_type'] = dt
dct['data_units'] = ut
dct['enabled'] = True
dct['full_name'] = fullname
dct['index'] = index
index += 1
dct['instrument'] = None
dct['instrument'] = instrument
dct['label'] = Utils.tostr(device)
dct['name'] = Utils.tostr(device)
dct['nexus_path'] = u''
dct['normalization'] = 0
dct['output'] = True
dct['normalization'] = normalization
dct['output'] = output
dct['shape'] = shp

if device in dontdisplay:
Expand Down
2 changes: 1 addition & 1 deletion nxsrecconfig/Release.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
""" NeXus Sardana Recorder Settings - Release """

#: (:obj:`str`) package version
__version__ = "3.41.0"
__version__ = "3.42.0"
8 changes: 8 additions & 0 deletions test/ExtraSettings2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,10 @@ def subtest_switchProfile_importMntGrp(self):
"synchronization": {},
"value_ref_enabled": {},
"value_ref_pattern": {},
"normalization": {},
"conditioning": {},
"output": {},
"instrument": {},
"shape": shapes
}
)
Expand Down Expand Up @@ -2802,6 +2806,10 @@ def test_myswitchProfile_importMntGrp(self):
"synchronization": {},
"value_ref_enabled": {},
"value_ref_pattern": {},
"normalization": {},
"conditioning": {},
"output": {},
"instrument": {},
"shape": shapes
}
)
Expand Down
8 changes: 8 additions & 0 deletions test/ExtraSettings3_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,10 @@ def subtest_switchProfile_importMntGrp(self):
"value_ref_pattern": {},
"synchronizer": {},
"synchronization": {},
"normalization": {},
"conditioning": {},
"output": {},
"instrument": {},
"shape": shapes
}
)
Expand Down Expand Up @@ -2884,6 +2888,10 @@ def test_myswitchProfile_importMntGrp(self):
"value_ref_pattern": {},
"synchronizer": {},
"synchronization": {},
"normalization": {},
"conditioning": {},
"output": {},
"instrument": {},
"shape": shapes
}
)
Expand Down
8 changes: 8 additions & 0 deletions test/ExtraSettings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,10 @@ def subtest_switchProfile_importMntGrp(self):
"synchronization": {},
"value_ref_enabled": {},
"value_ref_pattern": {},
"normalization": {},
"conditioning": {},
"output": {},
"instrument": {},
"shape": shapes
}
)
Expand Down Expand Up @@ -2828,6 +2832,10 @@ def test_myswitchProfile_importMntGrp(self):
"synchronization": {},
"value_ref_enabled": {},
"value_ref_pattern": {},
"normalization": {},
"conditioning": {},
"output": {},
"instrument": {},
"shape": shapes
}
)
Expand Down
4 changes: 4 additions & 0 deletions test/ProfileManager2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6503,6 +6503,10 @@ def test_switchProfile_importMntGrp(self):
"synchronization": {},
"value_ref_enabled": {},
"value_ref_pattern": {},
"normalization": {},
"conditioning": {},
"output": {},
"instrument": {},
"shape": shapes
}
)
Expand Down
4 changes: 4 additions & 0 deletions test/ProfileManager3_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6509,6 +6509,10 @@ def test_switchProfile_importMntGrp(self):
"synchronization": {},
"value_ref_enabled": {},
"value_ref_pattern": {},
"normalization": {},
"conditioning": {},
"output": {},
"instrument": {},
"shape": shapes
}
)
Expand Down
4 changes: 4 additions & 0 deletions test/ProfileManager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6662,6 +6662,10 @@ def test_switchProfile_importMntGrp(self):
"synchronization": {},
"value_ref_enabled": {},
"value_ref_pattern": {},
"normalization": {},
"conditioning": {},
"output": {},
"instrument": {},
"shape": shapes
}
)
Expand Down
Loading