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
|
class=secop_demo.modules.CoilTemp
|
||||||
sensor="X34598T9"
|
sensor="X34598T9"
|
||||||
|
|
||||||
|
|
||||||
|
[device Lower]
|
||||||
|
class=secop_demo.test.Lower
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ class Readable(Module):
|
|||||||
datatype=TupleOf(
|
datatype=TupleOf(
|
||||||
EnumType(**{
|
EnumType(**{
|
||||||
'IDLE': status.OK,
|
'IDLE': status.OK,
|
||||||
'BUSY': status.BUSY,
|
# 'BUSY': status.BUSY,
|
||||||
'WARN': status.WARN,
|
'WARN': status.WARN,
|
||||||
'UNSTABLE': status.UNSTABLE,
|
'UNSTABLE': status.UNSTABLE,
|
||||||
'ERROR': status.ERROR,
|
'ERROR': status.ERROR,
|
||||||
@ -488,8 +488,8 @@ class Readable(Module):
|
|||||||
return fastpoll
|
return fastpoll
|
||||||
|
|
||||||
|
|
||||||
class Drivable(Readable):
|
class Writable(Readable):
|
||||||
"""Basic Drivable Module
|
"""Basic Writable Module
|
||||||
|
|
||||||
providing a settable 'target' parameter to those of a Readable
|
providing a settable 'target' parameter to those of a Readable
|
||||||
"""
|
"""
|
||||||
@ -503,3 +503,41 @@ class Drivable(Readable):
|
|||||||
}
|
}
|
||||||
# XXX: CMDS ???? auto deriving working well enough?
|
# 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
|
import random
|
||||||
|
|
||||||
from secop.modules import Readable, Drivable, PARAM
|
from secop.modules import Readable, Drivable, Communicator, PARAM
|
||||||
from secop.datatypes import FloatRange, StringType
|
from secop.datatypes import FloatRange, StringType
|
||||||
|
|
||||||
|
|
||||||
@ -84,3 +84,9 @@ class Temp(Drivable):
|
|||||||
|
|
||||||
def write_target(self, target):
|
def write_target(self, target):
|
||||||
pass
|
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