Revert "support name mangling for parameter/command names"

This reverts commit 99bdafdd0c3293d17e3f23508d2b7762804474e7.
This commit is contained in:
l_samenv 2020-09-25 11:30:23 +02:00
parent f7576cf541
commit 1b4865c608

View File

@ -457,7 +457,8 @@ class SecopClient(ProxyClient):
modules = data['modules'] modules = data['modules']
self.modules = {} self.modules = {}
self.properties = {k: v for k, v in data.items() if k != 'modules'} self.properties = {k: v for k, v in data.items() if k != 'modules'}
self.identifier = defaultdict(dict) # dict <mod name> of dict <internal name> of <secop ident> self.identifier = {} # map (module, parameter) -> identifier
self.internal = {} # map identifier -> (module, parameter)
for modname, moddescr in modules.items(): for modname, moddescr in modules.items():
# separate accessibles into command and parameters # separate accessibles into command and parameters
parameters = {} parameters = {}
@ -468,7 +469,8 @@ class SecopClient(ProxyClient):
datatype = get_datatype(aentry['datainfo'], iname) datatype = get_datatype(aentry['datainfo'], iname)
aentry = dict(aentry, datatype=datatype) aentry = dict(aentry, datatype=datatype)
ident = '%s:%s' % (modname, aname) ident = '%s:%s' % (modname, aname)
self.identifier[modname][iname] = ident self.identifier[modname, iname] = ident
self.internal[ident] = modname, iname
if datatype.IS_COMMAND: if datatype.IS_COMMAND:
commands[iname] = aentry commands[iname] = aentry
else: else:
@ -476,11 +478,6 @@ class SecopClient(ProxyClient):
properties = {k: v for k, v in moddescr.items() if k != 'accessibles'} properties = {k: v for k, v in moddescr.items() if k != 'accessibles'}
self.modules[modname] = dict(accessibles=accessibles, parameters=parameters, self.modules[modname] = dict(accessibles=accessibles, parameters=parameters,
commands=commands, properties=properties) commands=commands, properties=properties)
self.fix_internal_names()
# invert self.identifier
self.internal = {ident: (modname, iname)
for modname, identdict in self.identifier.items()
for iname, ident in identdict.items()}
if changed_modules is not None: if changed_modules is not None:
done = done_main = self.callback(None, 'descriptiveDataChange', None, self) done = done_main = self.callback(None, 'descriptiveDataChange', None, self)
for mname in changed_modules: for mname in changed_modules:
@ -537,7 +534,7 @@ class SecopClient(ProxyClient):
def readParameter(self, module, parameter): def readParameter(self, module, parameter):
"""forced read over connection""" """forced read over connection"""
try: try:
self.request(READREQUEST, self.identifier[module][parameter]) self.request(READREQUEST, self.identifier[module, parameter])
except secop.errors.SECoPError: except secop.errors.SECoPError:
# error reply message is already stored as readerror in cache # error reply message is already stored as readerror in cache
pass pass
@ -556,7 +553,7 @@ class SecopClient(ProxyClient):
self.connect() # make sure we are connected self.connect() # make sure we are connected
datatype = self.modules[module]['parameters'][parameter]['datatype'] datatype = self.modules[module]['parameters'][parameter]['datatype']
value = datatype.export_value(value) value = datatype.export_value(value)
self.request(WRITEREQUEST, self.identifier[module][parameter], value) self.request(WRITEREQUEST, self.identifier[module, parameter], value)
return self.cache[module, parameter] return self.cache[module, parameter]
def execCommand(self, module, command, argument=None): def execCommand(self, module, command, argument=None):
@ -568,7 +565,7 @@ class SecopClient(ProxyClient):
if argument is not None: if argument is not None:
raise secop.errors.BadValueError('command has no argument') raise secop.errors.BadValueError('command has no argument')
# pylint: disable=unsubscriptable-object # pylint: disable=unsubscriptable-object
data, qualifiers = self.request(COMMANDREQUEST, self.identifier[module][command], argument)[2] data, qualifiers = self.request(COMMANDREQUEST, self.identifier[module, command], argument)[2]
datatype = self.modules[module]['commands'][command]['datatype'].result datatype = self.modules[module]['commands'][command]['datatype'].result
if datatype: if datatype:
data = datatype.import_value(data) data = datatype.import_value(data)
@ -590,6 +587,3 @@ class SecopClient(ProxyClient):
if name.startswith('_') and name[1:] not in self.PREDEFINED_NAMES: if name.startswith('_') and name[1:] not in self.PREDEFINED_NAMES:
return name[1:] return name[1:]
return name return name
def fix_internal_names(self):
"""fix forbidden items"""