version as of 2025-01-09 from ultrasound PC
This commit is contained in:
@@ -44,3 +44,4 @@ ERROR = Drivable.Status.ERROR
|
||||
WARN = Drivable.Status.WARN
|
||||
BUSY = Drivable.Status.BUSY
|
||||
IDLE = Drivable.Status.IDLE
|
||||
DISABLED = Drivable.Status.DISABLED
|
||||
|
||||
@@ -760,7 +760,7 @@ class ArrayOf(DataType):
|
||||
|
||||
def __call__(self, value):
|
||||
"""validate an external representation to an internal one"""
|
||||
if isinstance(value, (tuple, list)):
|
||||
try:
|
||||
# check number of elements
|
||||
if self.minlen is not None and len(value) < self.minlen:
|
||||
raise BadValueError(
|
||||
@@ -768,11 +768,12 @@ class ArrayOf(DataType):
|
||||
self.minlen)
|
||||
if self.maxlen is not None and len(value) > self.maxlen:
|
||||
raise BadValueError(
|
||||
'Array too big, holds at most %d elements!' % self.minlen)
|
||||
# apply subtype valiation to all elements and return as list
|
||||
'Array too big, holds at most %d elements!' % self.maxlen)
|
||||
# apply subtype valdiation to all elements and return as list
|
||||
return tuple(self.members(elem) for elem in value)
|
||||
raise BadValueError(
|
||||
'Can not convert %s to ArrayOf DataType!' % repr(value))
|
||||
except TypeError:
|
||||
raise BadValueError('%s can not be converted to ArrayOf DataType!'
|
||||
% type(value).__name__) from None
|
||||
|
||||
def export_value(self, value):
|
||||
"""returns a python object fit for serialisation"""
|
||||
@@ -842,6 +843,7 @@ class TupleOf(DataType):
|
||||
return tuple(sub(elem)
|
||||
for sub, elem in zip(self.members, value))
|
||||
except Exception as exc:
|
||||
print(value)
|
||||
raise BadValueError('Can not validate:', str(exc)) from None
|
||||
|
||||
def export_value(self, value):
|
||||
|
||||
@@ -47,7 +47,7 @@ class SilentError(CommunicationFailedError):
|
||||
|
||||
class HasIO(Module):
|
||||
"""Mixin for modules using a communicator"""
|
||||
io = Attached()
|
||||
io = Attached(mandatory=False)
|
||||
uri = Property('uri for automatic creation of the attached communication module',
|
||||
StringType(), default='')
|
||||
|
||||
|
||||
@@ -500,10 +500,11 @@ class Module(HasAccessibles):
|
||||
# TODO: remove readerror 'property' and replace value with exception
|
||||
pobj = self.parameters[pname]
|
||||
timestamp = timestamp or time.time()
|
||||
changed = pobj.value != value
|
||||
try:
|
||||
value = pobj.datatype(value)
|
||||
changed = pobj.value != value
|
||||
# store the value even in case of error
|
||||
pobj.value = pobj.datatype(value)
|
||||
pobj.value = value
|
||||
except Exception as e:
|
||||
if isinstance(e, DiscouragedConversion):
|
||||
if DiscouragedConversion.log_message:
|
||||
|
||||
@@ -149,6 +149,9 @@ class Parameter(Accessible):
|
||||
|
||||
default None: write if given in config''', NoneOr(BoolType()),
|
||||
export=False, default=None, settable=False)
|
||||
# used in NICOS only ...
|
||||
nicos_category = Property(
|
||||
'''NICOS parameter category''', StringType(), export=True, default='')
|
||||
|
||||
# used on the instance copy only
|
||||
value = None
|
||||
|
||||
Reference in New Issue
Block a user