fixups
Change-Id: I120865555596b2671c6e8aa65841f3ea984c7e03
This commit is contained in:
parent
357056d478
commit
5992ba3c35
@ -188,7 +188,7 @@ class Client(object):
|
||||
# XXX: further notification-callbacks needed ???
|
||||
|
||||
def populateNamespace(self, namespace):
|
||||
self.connection.send(ListDevicesRequest())
|
||||
self.connection.send(ListModulesRequest())
|
||||
# reply = self.connection.read()
|
||||
# self.log.info("found devices %r" % reply)
|
||||
# create proxies, populate cache....
|
||||
|
@ -86,8 +86,8 @@ class DemoEncoder(MessageEncoder):
|
||||
def _encode_ProtocollError(self, msgtype, msgname, msgargs):
|
||||
return '~ProtocolError~ %s.%s.%r' % (msgtype, msgname, msgargs)
|
||||
|
||||
def _encode_NoSuchDeviceError(self, device):
|
||||
return '~NoSuchDeviceError~ %s' % device
|
||||
def _encode_NoSuchModuleError(self, device):
|
||||
return '~NoSuchModuleError~ %s' % device
|
||||
|
||||
def _encode_NoSuchParamError(self, device, param):
|
||||
return '~NoSuchParameterError~ %s:%s' % (device, param)
|
||||
|
@ -344,13 +344,13 @@ class DemoEncoder_MZ(MessageEncoder):
|
||||
return '\n'.join(r)
|
||||
|
||||
return {
|
||||
ListDevicesRequest: lambda msg: "list",
|
||||
ListDevicesReply: lambda msg: "list=%s" % ','.join(sorted(msg.list_of_devices)),
|
||||
ListModulesRequest: lambda msg: "list",
|
||||
ListModulesReply: lambda msg: "list=%s" % ','.join(sorted(msg.list_of_devices)),
|
||||
GetVersionRequest: lambda msg: "version",
|
||||
GetVersionReply: lambda msg: "version=%r" % msg.version,
|
||||
ListDeviceParamsRequest: lambda msg: "list %s" % msg.device,
|
||||
ListModuleParamsRequest: lambda msg: "list %s" % msg.device,
|
||||
# do not include a '.' as param name!
|
||||
ListDeviceParamsReply: lambda msg: "list %s=%s" % (msg.device, ','.join(sorted(msg.params.keys()))),
|
||||
ListModuleParamsReply: lambda msg: "list %s=%s" % (msg.device, ','.join(sorted(msg.params.keys()))),
|
||||
ReadValueRequest: lambda msg: "read %s" % msg.device,
|
||||
ReadValueReply: lambda msg: "read %s=%r" % (msg.device, msg.value),
|
||||
WriteValueRequest: lambda msg: "write %s=%r" % (msg.device, msg.value),
|
||||
@ -360,8 +360,8 @@ class DemoEncoder_MZ(MessageEncoder):
|
||||
WriteParamRequest: lambda msg: "write %s:%s=%r" % (msg.device, msg.param, msg.value),
|
||||
WriteParamReply: lambda msg: "write %s:%s=%r" % (msg.device, msg.param, msg.readback_value),
|
||||
# extensions
|
||||
ReadAllDevicesRequest: lambda msg: "",
|
||||
ReadAllDevicesReply: lambda msg: "",
|
||||
ReadAllModulesRequest: lambda msg: "",
|
||||
ReadAllModulesReply: lambda msg: "",
|
||||
ListParamPropsRequest: lambda msg: "readprop %s:%s" % (msg.device, msg.param),
|
||||
ListParamPropsReply: lambda msg: ["readprop %s:%s" % (msg.device, msg.param)] + ["%s:%s:%s=%s" % (msg.device, msg.param, k, v) for k, v in sorted(msg.props.items())],
|
||||
ReadPropertyRequest: lambda msg: "readprop %s:%s:%s" % (msg.device, msg.param, msg.prop),
|
||||
@ -379,7 +379,7 @@ class DemoEncoder_MZ(MessageEncoder):
|
||||
ProtocolError: lambda msg: "",
|
||||
CommandFailedError: lambda msg: "error CommandError %s:%s %s" % (msg.device, msg.param, msg.error),
|
||||
NoSuchCommandError: lambda msg: "error NoSuchCommand %s:%s" % (msg.device, msg.param, msg.error),
|
||||
NoSuchDeviceError: lambda msg: "error NoSuchModule %s" % msg.device,
|
||||
NoSuchModuleError: lambda msg: "error NoSuchModule %s" % msg.device,
|
||||
NoSuchParamError: lambda msg: "error NoSuchParameter %s:%s" % (msg.device, msg.param),
|
||||
ParamReadonlyError: lambda msg: "",
|
||||
UnsupportedFeatureError: lambda msg: "",
|
||||
|
@ -72,7 +72,7 @@ ERRORREPLY = 'error' # +errorclass +json_extended_info
|
||||
HELPREQUEST = 'help' # literal
|
||||
HELPREPLY = 'helping' # +line number +json_text
|
||||
ERRORCLASSES = [
|
||||
'NoSuchDevice',
|
||||
'NoSuchModule',
|
||||
'NoSuchParameter',
|
||||
'NoSuchCommand',
|
||||
'CommandFailed',
|
||||
|
@ -72,7 +72,7 @@ ERRORREPLY = 'error' # +errorclass +json_extended_info
|
||||
HELPREQUEST = 'help' # literal
|
||||
HELPREPLY = 'helping' # +line number +json_text
|
||||
ERRORCLASSES = [
|
||||
'NoSuchDevice',
|
||||
'NoSuchModule',
|
||||
'NoSuchParameter',
|
||||
'NoSuchCommand',
|
||||
'CommandFailed',
|
||||
|
@ -55,7 +55,7 @@ class SCPEncoder(MessageEncoder):
|
||||
r.append(
|
||||
"replies copy the request and are prefixed with an errorcode:")
|
||||
r.append(
|
||||
"0=OK,3=NoSuchCommand,4=NosuchDevice,5=NoSuchParam,6=SyntaxError,7=BadValue,8=Readonly,9=Forbidden,@=Async"
|
||||
"0=OK,3=NoSuchCommand,4=NosuchModule,5=NoSuchParam,6=SyntaxError,7=BadValue,8=Readonly,9=Forbidden,@=Async"
|
||||
)
|
||||
r.append("extensions: @-prefix as error-code,")
|
||||
r.append("'<module>/+' subscribe all params of module")
|
||||
@ -68,12 +68,12 @@ class SCPEncoder(MessageEncoder):
|
||||
return '\n'.join(r)
|
||||
|
||||
return {
|
||||
ListDevicesRequest: lambda msg: "devices?",
|
||||
ListDevicesReply: lambda msg: "0 devices=" + repr(list(msg.list_of_devices)),
|
||||
ListModulesRequest: lambda msg: "devices?",
|
||||
ListModulesReply: lambda msg: "0 devices=" + repr(list(msg.list_of_devices)),
|
||||
GetVersionRequest: lambda msg: "version?",
|
||||
GetVersionReply: lambda msg: "0 version=%r" % msg.version,
|
||||
ListDeviceParamsRequest: lambda msg: "%s/parameters?" % msg.device,
|
||||
ListDeviceParamsReply: lambda msg: "0 %s/parameters=%r" % (msg.device, list(msg.params)),
|
||||
ListModuleParamsRequest: lambda msg: "%s/parameters?" % msg.device,
|
||||
ListModuleParamsReply: lambda msg: "0 %s/parameters=%r" % (msg.device, list(msg.params)),
|
||||
ReadValueRequest: lambda msg: "%s/value?" % msg.device,
|
||||
ReadValueReply: lambda msg: "0 %s/value?%r" % (msg.device, msg.value),
|
||||
WriteValueRequest: lambda msg: "%s/value=%r" % (msg.device, msg.value),
|
||||
@ -83,8 +83,8 @@ class SCPEncoder(MessageEncoder):
|
||||
WriteParamRequest: lambda msg: "%s/%s=%r" % (msg.device, msg.param, msg.value),
|
||||
WriteParamReply: lambda msg: "0 %s/%s=%r" % (msg.device, msg.param, msg.readback_value),
|
||||
# extensions
|
||||
ReadAllDevicesRequest: lambda msg: "*/value?",
|
||||
ReadAllDevicesReply: lambda msg: ["0 %s/value=%s" % (m.device, m.value) for m in msg.readValueReplies],
|
||||
ReadAllModulesRequest: lambda msg: "*/value?",
|
||||
ReadAllModulesReply: lambda msg: ["0 %s/value=%s" % (m.device, m.value) for m in msg.readValueReplies],
|
||||
ListParamPropsRequest: lambda msg: "%s/%s/?" % (msg.device, msg.param),
|
||||
ListParamPropsReply: lambda msg: ["0 %s/%s/%s" % (msg.device, msg.param, p) for p in msg.props],
|
||||
AsyncDataUnit: lambda msg: "@ %s/%s=%r" % (msg.devname, msg.pname, msg.value),
|
||||
@ -106,7 +106,7 @@ class SCPEncoder(MessageEncoder):
|
||||
# violates spec ! we would need the original request here....
|
||||
NoSuchCommandError: lambda msg: "3 %s/%s" % (msg.device, msg.command),
|
||||
# violates spec ! we would need the original request here....
|
||||
NoSuchDeviceError: lambda msg: "4 %s/ %r" % (msg.device, msg.error),
|
||||
NoSuchModuleError: lambda msg: "4 %s/ %r" % (msg.device, msg.error),
|
||||
# violates spec ! we would need the original request here....
|
||||
NoSuchParamError: lambda msg: "5 %s/%s %r" % (msg.device, msg.param, msg.error),
|
||||
# violates spec ! we would need the original request here....
|
||||
@ -151,16 +151,16 @@ class SCPEncoder(MessageEncoder):
|
||||
if dev is None:
|
||||
# 'server' commands
|
||||
if par == 'devices':
|
||||
return ListDevicesRequest()
|
||||
return ListModulesRequest()
|
||||
elif par == 'version':
|
||||
return GetVersionRequest()
|
||||
return ProtocolError()
|
||||
if par == 'parameters':
|
||||
return ListDeviceParamsRequest(dev)
|
||||
return ListModuleParamsRequest(dev)
|
||||
elif par == 'value':
|
||||
return ReadValueRequest(dev)
|
||||
elif dev == '*' and par == 'value':
|
||||
return ReadAllDevicesRequest()
|
||||
return ReadAllModulesRequest()
|
||||
else:
|
||||
return ReadParamRequest(dev, par)
|
||||
elif op == '=':
|
||||
@ -173,12 +173,12 @@ class SCPEncoder(MessageEncoder):
|
||||
# reply
|
||||
if dev == '':
|
||||
if par == 'devices':
|
||||
return ListDevicesReply(val)
|
||||
return ListModulesReply(val)
|
||||
elif par == 'version':
|
||||
return GetVersionReply(val)
|
||||
return ProtocolError(encoded)
|
||||
if par == 'parameters':
|
||||
return ListDeviceParamsReply(dev, val)
|
||||
return ListModuleParamsReply(dev, val)
|
||||
if par == 'value':
|
||||
if op == '?':
|
||||
return ReadValueReply(dev, val)
|
||||
@ -201,7 +201,7 @@ class SCPEncoder(MessageEncoder):
|
||||
elif err == '3':
|
||||
return NoSuchCommandError(dev, par)
|
||||
elif err == '4':
|
||||
return NoSuchDeviceError(dev, encoded)
|
||||
return NoSuchModuleError(dev, encoded)
|
||||
elif err == '5':
|
||||
return NoSuchParamError(dev, par, val)
|
||||
elif err == '7':
|
||||
|
@ -75,7 +75,7 @@ class Message(object):
|
||||
elif self.pars:
|
||||
r = 'Parameter' if self.pars != ['*'] else 'Parameters'
|
||||
elif self.devs:
|
||||
r = 'Device' if self.devs != ['*'] else 'Devices'
|
||||
r = 'Module' if self.devs != ['*'] else 'Modules'
|
||||
|
||||
t = ''
|
||||
if self.MSGTYPE in [
|
||||
@ -166,14 +166,14 @@ class HelpMessage(Message):
|
||||
MSGTYPE = HELP
|
||||
|
||||
|
||||
class NoSuchDeviceError(ErrorMessage):
|
||||
class NoSuchModuleError(ErrorMessage):
|
||||
|
||||
def __init__(self, *devs):
|
||||
ErrorMessage.__init__(
|
||||
self,
|
||||
devs=devs,
|
||||
errorstring="Device %r does not exist" % devs[0],
|
||||
errortype='NoSuchDevice')
|
||||
errorstring="Module %r does not exist" % devs[0],
|
||||
errortype='NoSuchModule')
|
||||
|
||||
|
||||
class NoSuchParamError(ErrorMessage):
|
||||
@ -183,7 +183,7 @@ class NoSuchParamError(ErrorMessage):
|
||||
self,
|
||||
devs=(dev, ),
|
||||
params=params,
|
||||
errorstring="Device %r has no parameter %r" % (dev, params[0]),
|
||||
errorstring="Module %r has no parameter %r" % (dev, params[0]),
|
||||
errortype='NoSuchParam')
|
||||
|
||||
|
||||
@ -194,7 +194,7 @@ class ParamReadonlyError(ErrorMessage):
|
||||
self,
|
||||
devs=(dev, ),
|
||||
params=params,
|
||||
errorstring="Device %r, parameter %r is not writeable!" %
|
||||
errorstring="Module %r, parameter %r is not writeable!" %
|
||||
(dev, params[0]),
|
||||
errortype='ParamReadOnly')
|
||||
|
||||
|
@ -115,9 +115,9 @@ class Server(object):
|
||||
devname = section[len('device '):]
|
||||
devopts = dict(item for item in parser.items(section))
|
||||
if 'class' not in devopts:
|
||||
self.log.error('Device %s needs a class option!')
|
||||
self.log.error('Module %s needs a class option!')
|
||||
raise ConfigError(
|
||||
'cfgfile %r: Device %s needs a class option!' %
|
||||
'cfgfile %r: Module %s needs a class option!' %
|
||||
(self._cfgfile, devname))
|
||||
# try to import the class, raise if this fails
|
||||
devopts['class'] = get_class(devopts['class'])
|
||||
@ -141,15 +141,15 @@ class Server(object):
|
||||
self._dispatcher = self._buildObject(
|
||||
'Dispatcher', Dispatcher, dict(equipment_id=equipment_id))
|
||||
self._processInterfaceOptions(interfaceopts)
|
||||
self._processDeviceOptions(deviceopts)
|
||||
self._processModuleOptions(deviceopts)
|
||||
|
||||
def _processDeviceOptions(self, deviceopts):
|
||||
def _processModuleOptions(self, deviceopts):
|
||||
# check devices opts by creating them
|
||||
devs = []
|
||||
for devname, devopts in deviceopts:
|
||||
devclass = devopts.pop('class')
|
||||
# create device
|
||||
self.log.debug('Creating Device %r' % devname)
|
||||
self.log.debug('Creating Module %r' % devname)
|
||||
export = devopts.pop('export', '1')
|
||||
export = export.lower() in ('1', 'on', 'true', 'yes')
|
||||
if 'default' in devopts:
|
||||
|
@ -23,7 +23,7 @@
|
||||
import random
|
||||
|
||||
from secop.datatypes import EnumType, TupleOf, FloatRange, get_datatype, StringType
|
||||
from secop.modules import Readable, Device, Drivable, PARAM
|
||||
from secop.modules import Readable, Module, Drivable, PARAM
|
||||
from secop.protocol import status
|
||||
|
||||
try:
|
||||
|
@ -33,7 +33,7 @@ from secop.lib.sequence import SequencerMixin, Step
|
||||
from secop.protocol import status
|
||||
from secop.datatypes import *
|
||||
from secop.errors import SECoPServerError, ConfigError, ProgrammingError, CommunicationError, HardwareError, DisabledError
|
||||
from secop.modules import PARAM, CMD, OVERRIDE, Device, Readable, Drivable
|
||||
from secop.modules import PARAM, CMD, OVERRIDE, Module, Readable, Drivable
|
||||
|
||||
|
||||
class GarfieldMagnet(SequencerMixin, Drivable):
|
||||
|
@ -41,7 +41,7 @@ from secop.lib import lazy_property, mkthread
|
||||
from secop.protocol import status
|
||||
from secop.datatypes import *
|
||||
from secop.errors import SECoPServerError, ConfigError, ProgrammingError, CommunicationError, HardwareError
|
||||
from secop.modules import PARAM, CMD, OVERRIDE, Device, Readable, Drivable
|
||||
from secop.modules import PARAM, CMD, OVERRIDE, Module, Readable, Drivable
|
||||
|
||||
|
||||
# Only export these classes for 'from secop_mlz import *'
|
||||
@ -148,7 +148,7 @@ def describe_dev_error(exc):
|
||||
return fulldesc
|
||||
|
||||
|
||||
class PyTangoDevice(Device):
|
||||
class PyTangoDevice(Module):
|
||||
"""
|
||||
Basic PyTango device.
|
||||
|
||||
@ -883,7 +883,7 @@ class PartialDigitalOutput(NamedDigitalOutput):
|
||||
self.read_value()
|
||||
|
||||
|
||||
class StringIO(PyTangoDevice, Device):
|
||||
class StringIO(PyTangoDevice, Module):
|
||||
"""
|
||||
StringIO abstracts communication over a hardware bus that sends and
|
||||
receives strings.
|
||||
|
@ -38,10 +38,10 @@ class SecopError(Exception):
|
||||
Exception.__init__(self, message, text)
|
||||
|
||||
|
||||
class UnknownDeviceError(SecopError):
|
||||
class UnknownModuleError(SecopError):
|
||||
|
||||
def __init__(self, message, args):
|
||||
SecopError.__init__(self, "NoSuchDevice", args[0])
|
||||
SecopError.__init__(self, "NoSuchModule", args[0])
|
||||
|
||||
|
||||
class UnknownParamError(SecopError):
|
||||
@ -142,7 +142,7 @@ class SecopLineHandler(lineserver.LineHandler):
|
||||
try:
|
||||
return secNodeDict[d]
|
||||
except KeyError:
|
||||
raise UnknownDeviceError("", (d))
|
||||
raise UnknownModuleError("", (d))
|
||||
|
||||
def get_param(self, d, p):
|
||||
if p == "":
|
||||
@ -228,7 +228,7 @@ class SecopLineHandler(lineserver.LineHandler):
|
||||
try:
|
||||
devList = wildcard(secNodeDict, path[0])
|
||||
except KeyError as e:
|
||||
raise UnknownDeviceError("", (e.message))
|
||||
raise UnknownModuleError("", (e.message))
|
||||
for d in devList:
|
||||
devDict = secNodeDict[d]
|
||||
try:
|
||||
@ -274,7 +274,7 @@ class SecopLineHandler(lineserver.LineHandler):
|
||||
try:
|
||||
devList = wildcard(secNodeDict, path[0])
|
||||
except KeyError as e:
|
||||
raise UnknownDeviceError("", (e.message))
|
||||
raise UnknownModuleError("", (e.message))
|
||||
for d in devList:
|
||||
devDict = secNodeDict[d]
|
||||
if len(path) == 1:
|
||||
|
@ -54,7 +54,7 @@ def test_describing_data_decode(clientobj):
|
||||
assert {'modules':{}, 'properties':{}} == clientobj._decode_substruct(['modules'],{})
|
||||
describing_data = {'equipment_id': 'eid',
|
||||
'modules': ['LN2', {'commands': [],
|
||||
'interfaces': ['Readable', 'Device'],
|
||||
'interfaces': ['Readable', 'Module'],
|
||||
'parameters': ['value', {'datatype': ['double'],
|
||||
'description': 'current value',
|
||||
'readonly': True,
|
||||
@ -69,7 +69,7 @@ def test_describing_data_decode(clientobj):
|
||||
'readonly': True,
|
||||
}
|
||||
},
|
||||
'properties': {'interfaces': ['Readable', 'Device']}
|
||||
'properties': {'interfaces': ['Readable', 'Module']}
|
||||
}
|
||||
},
|
||||
'properties': {'equipment_id': 'eid',
|
||||
|
Loading…
x
Reference in New Issue
Block a user