implement Writable as specified.
Change-Id: I8a1b192dcfba91ae1828a2b2e0e2e8bd24538c08
This commit is contained in:
parent
54379a586a
commit
c5671dd26e
@ -36,3 +36,7 @@ sensor="X34598T8"
|
||||
class=secop_demo.modules.CoilTemp
|
||||
sensor="X34598T9"
|
||||
|
||||
|
||||
[device Lower]
|
||||
class=secop_demo.test.Lower
|
||||
|
||||
|
@ -431,7 +431,7 @@ class Readable(Module):
|
||||
datatype=TupleOf(
|
||||
EnumType(**{
|
||||
'IDLE': status.OK,
|
||||
'BUSY': status.BUSY,
|
||||
# 'BUSY': status.BUSY,
|
||||
'WARN': status.WARN,
|
||||
'UNSTABLE': status.UNSTABLE,
|
||||
'ERROR': status.ERROR,
|
||||
@ -481,15 +481,15 @@ class Readable(Module):
|
||||
rfunc = getattr(self, 'read_' + pname, None)
|
||||
if rfunc:
|
||||
try:
|
||||
# self.log.info('polling read_%s -> %r' % (pname, rfunc()))
|
||||
# self.log.info('polling read_%s -> %r' % (pname, rfunc()))
|
||||
rfunc()
|
||||
except Exception: # really all!
|
||||
pass
|
||||
return fastpoll
|
||||
|
||||
|
||||
class Drivable(Readable):
|
||||
"""Basic Drivable Module
|
||||
class Writable(Readable):
|
||||
"""Basic Writable Module
|
||||
|
||||
providing a settable 'target' parameter to those of a Readable
|
||||
"""
|
||||
@ -503,3 +503,41 @@ class Drivable(Readable):
|
||||
}
|
||||
# XXX: CMDS ???? auto deriving working well enough?
|
||||
|
||||
|
||||
class Drivable(Writable):
|
||||
"""Basic Drivable Module
|
||||
|
||||
provides a stop command to interrupt actions.
|
||||
Also status gets extended with a BUSY state indicating a running action.
|
||||
"""
|
||||
|
||||
OVERRIDES = {
|
||||
"status" : OVERRIDE(datatype=TupleOf(
|
||||
EnumType(**{
|
||||
'IDLE': status.OK,
|
||||
'BUSY': status.BUSY,
|
||||
'WARN': status.WARN,
|
||||
'UNSTABLE': status.UNSTABLE,
|
||||
'ERROR': status.ERROR,
|
||||
'UNKNOWN': status.UNKNOWN
|
||||
}), StringType())),
|
||||
}
|
||||
|
||||
def do_stop(self):
|
||||
"""default implementation of the stop command
|
||||
|
||||
by default does nothing."""
|
||||
|
||||
|
||||
class Communicator(Module):
|
||||
"""Basic communication Module
|
||||
|
||||
providing no parameters, but a 'communicate' command.
|
||||
"""
|
||||
|
||||
CMDS = {
|
||||
"communicate" : CMD("provides the simplest mean to communication",
|
||||
arguments=[StringType()],
|
||||
result=StringType()
|
||||
),
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
import random
|
||||
|
||||
from secop.modules import Readable, Drivable, PARAM
|
||||
from secop.modules import Readable, Drivable, Communicator, PARAM
|
||||
from secop.datatypes import FloatRange, StringType
|
||||
|
||||
|
||||
@ -84,3 +84,9 @@ class Temp(Drivable):
|
||||
|
||||
def write_target(self, target):
|
||||
pass
|
||||
|
||||
|
||||
class Lower(Communicator):
|
||||
"""Communicator returning a lowercase version of the request"""
|
||||
def do_communicate(self, request):
|
||||
return str(request).lower()
|
||||
|
Loading…
x
Reference in New Issue
Block a user