frappy_demo.test: add simple writable
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
from frappy.datatypes import FloatRange, StringType, ValueType, TupleOf, StructOf, ArrayOf, StatusType, BoolType
|
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.modules import Communicator, Drivable, Parameter, Property, Readable, Module, Attached, Writable
|
||||||
from frappy.params import Command
|
from frappy.params import Command
|
||||||
from frappy.dynamic import Pinata
|
from frappy.dynamic import Pinata
|
||||||
from frappy.errors import RangeError, HardwareError
|
from frappy.errors import RangeError, HardwareError
|
||||||
@@ -171,3 +171,12 @@ class Commands(Module):
|
|||||||
"""array argument. raises an error when sum is negativ"""
|
"""array argument. raises an error when sum is negativ"""
|
||||||
if sum(a) < 0:
|
if sum(a) < 0:
|
||||||
raise RangeError('sum must be >= 0')
|
raise RangeError('sum must be >= 0')
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleWritable(Writable):
|
||||||
|
def write_target(self, target):
|
||||||
|
self.value = target
|
||||||
|
if target < 0:
|
||||||
|
self.status = ERROR, 'negative'
|
||||||
|
else:
|
||||||
|
self.status = IDLE, ''
|
||||||
|
|||||||
Reference in New Issue
Block a user