client: add SecopClient.execCommandFromString
analogous to setParameterFromString to be used in simple clients where values of structured datatypes are just python literals Change-Id: I4936a3c5c0cac45bd7e875c938ce2700b4f4a979 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/36262 Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch> Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
This commit is contained in:
parent
6343edc3cb
commit
8f2973c39d
@ -753,10 +753,13 @@ class SecopClient(ProxyClient):
|
|||||||
data = datatype.import_value(data)
|
data = datatype.import_value(data)
|
||||||
return data, qualifiers
|
return data, qualifiers
|
||||||
|
|
||||||
def execCommandFromString(self, module, command, formatted_argument):
|
def execCommandFromString(self, module, command, formatted_argument=''):
|
||||||
"""call command from string argument
|
"""call command from string argument
|
||||||
|
|
||||||
return formatted data and qualifiers
|
return data as CacheItem which allows to get
|
||||||
|
- result.value # the python value
|
||||||
|
- result.formatted() # a string (incl. units)
|
||||||
|
- result.timestamp
|
||||||
"""
|
"""
|
||||||
self.connect()
|
self.connect()
|
||||||
datatype = self.modules[module]['commands'][command]['datatype'].argument
|
datatype = self.modules[module]['commands'][command]['datatype'].argument
|
||||||
@ -766,11 +769,11 @@ class SecopClient(ProxyClient):
|
|||||||
if formatted_argument:
|
if formatted_argument:
|
||||||
raise WrongTypeError('command has no argument')
|
raise WrongTypeError('command has no argument')
|
||||||
argument = None
|
argument = None
|
||||||
|
# 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:
|
value = datatype.import_value(data) if datatype else None
|
||||||
data = datatype.format_value(data)
|
return CacheItem(value, qualifiers.get('t'), None, datatype)
|
||||||
return data, qualifiers
|
|
||||||
|
|
||||||
def updateValue(self, module, param, value, timestamp, readerror):
|
def updateValue(self, module, param, value, timestamp, readerror):
|
||||||
datatype = self.modules[module]['parameters'][param]['datatype']
|
datatype = self.modules[module]['parameters'][param]['datatype']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user