commands must be specified explicitely
no more automatic definition by just declaring do_<command> Change-Id: Ided91b5ae6fe657a6134f1cc14cc6484570a3646 Reviewed-on: https://forge.frm2.tum.de/review/18206 Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
parent
fc948972cc
commit
5ffe953c5c
@ -29,8 +29,6 @@ from __future__ import print_function
|
|||||||
# from these base classes (how to do this?)
|
# from these base classes (how to do this?)
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import types
|
|
||||||
import inspect
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from six import add_metaclass # for py2/3 compat
|
from six import add_metaclass # for py2/3 compat
|
||||||
@ -301,16 +299,9 @@ class ModuleMeta(type):
|
|||||||
setattr(newtype, 'commands', getattr(newtype, 'commands', {}))
|
setattr(newtype, 'commands', getattr(newtype, 'commands', {}))
|
||||||
for attrname in attrs:
|
for attrname in attrs:
|
||||||
if attrname.startswith('do_'):
|
if attrname.startswith('do_'):
|
||||||
if attrname[3:] in newtype.commands:
|
if attrname[3:] not in newtype.commands:
|
||||||
continue
|
raise ProgrammingError('%r: command %r has to be specified '
|
||||||
value = getattr(newtype, attrname)
|
'explicitly!' % (name, attrname[3:]))
|
||||||
if isinstance(value, types.MethodType):
|
|
||||||
argspec = inspect.getargspec(value)
|
|
||||||
if argspec[0] and argspec[0][0] == 'self':
|
|
||||||
del argspec[0][0]
|
|
||||||
newtype.commands[attrname[3:]] = Command(
|
|
||||||
getattr(value, '__doc__'), argspec.args,
|
|
||||||
None) # XXX: how to find resulttype?
|
|
||||||
attrs['__constructed__'] = True
|
attrs['__constructed__'] = True
|
||||||
return newtype
|
return newtype
|
||||||
|
|
||||||
@ -549,6 +540,15 @@ class Drivable(Writable):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
Status = Enum(Readable.Status, BUSY=300)
|
Status = Enum(Readable.Status, BUSY=300)
|
||||||
|
|
||||||
|
commands = {
|
||||||
|
'stop': Command(
|
||||||
|
'cease driving, go to IDLE state',
|
||||||
|
arguments=[],
|
||||||
|
result=None
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
overrides = {
|
overrides = {
|
||||||
'status' : Override(datatype=TupleOf(EnumType(Status), StringType())),
|
'status' : Override(datatype=TupleOf(EnumType(Status), StringType())),
|
||||||
}
|
}
|
||||||
|
@ -173,6 +173,10 @@ class PyTangoDevice(Module):
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commands = {
|
||||||
|
'reset': Command('Tango reset command', arguments=[], result=None),
|
||||||
|
}
|
||||||
|
|
||||||
tango_status_mapping = {
|
tango_status_mapping = {
|
||||||
PyTango.DevState.ON: Drivable.Status.IDLE,
|
PyTango.DevState.ON: Drivable.Status.IDLE,
|
||||||
PyTango.DevState.ALARM: Drivable.Status.WARN,
|
PyTango.DevState.ALARM: Drivable.Status.WARN,
|
||||||
@ -646,6 +650,10 @@ class Motor(Actuator):
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commands = {
|
||||||
|
'reference': Command('Do a reference run', arguments=[], result=None),
|
||||||
|
}
|
||||||
|
|
||||||
def read_refpos(self, maxage=0):
|
def read_refpos(self, maxage=0):
|
||||||
return float(self._getProperty('refpos'))
|
return float(self._getProperty('refpos'))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user