better dummy server for seaweb tests
- new config file dummy - frappy_demo.test.Temp now creates WARN and ERROR status and may be disabled Change-Id: Ibc7bb565f18c2c12cdc2a77bea1ee1bf1cc8bd41
This commit is contained in:
@ -22,11 +22,13 @@
|
||||
|
||||
import random
|
||||
|
||||
from frappy.datatypes import FloatRange, StringType, ValueType, TupleOf, StructOf, ArrayOf
|
||||
from frappy.datatypes import FloatRange, StringType, ValueType, TupleOf, StructOf, ArrayOf, StatusType, BoolType
|
||||
from frappy.modules import Communicator, Drivable, Parameter, Property, Readable, Module, Attached
|
||||
from frappy.params import Command
|
||||
from frappy.dynamic import Pinata
|
||||
from frappy.errors import RangeError, HardwareError
|
||||
from frappy.core import IDLE, WARN, ERROR, DISABLED
|
||||
|
||||
|
||||
class Pin(Pinata):
|
||||
def scanModules(self):
|
||||
@ -105,13 +107,27 @@ class Temp(Drivable):
|
||||
readonly=False,
|
||||
unit='K',
|
||||
)
|
||||
enabled = Parameter('enable', BoolType(), default=True, readonly=False)
|
||||
status = Parameter(datatype=StatusType(Readable, 'DISABLED'))
|
||||
_status = IDLE, ''
|
||||
|
||||
def read_value(self):
|
||||
return round(100 * random.random(), 1)
|
||||
value = round(100 * random.random(), 1)
|
||||
if value > 75:
|
||||
self._status = ERROR, 'sensor break'
|
||||
elif value > 50:
|
||||
self._status = WARN, 'out of calibrated range'
|
||||
else:
|
||||
self._status = IDLE, ''
|
||||
self.read_status()
|
||||
return value
|
||||
|
||||
def write_target(self, target):
|
||||
pass
|
||||
|
||||
def read_status(self):
|
||||
return self._status if self.enabled else (DISABLED, 'disabled')
|
||||
|
||||
|
||||
class Lower(Communicator):
|
||||
"""Communicator returning a lowercase version of the request"""
|
||||
|
Reference in New Issue
Block a user