rework datatypes (setter should not check limits)

- use Datatype.validate for converting and checking limits
  (used also in properties)
- Datatype.__call__ converts and validates, but without checking
  limits (used in setter)
- Datatype.validate may be used to add missing optional struct elements
  from previous value (used in Dispatcher._setParameterValue)
- remove problematic range check
+ use shorter formula for converting float to int in ScaledInteger
  (leftover from python2 compatibility)
+ improve error messages (strip very long repr(value))

Change-Id: Ib85736fe558ec3370ebce4e1c43f957e3bb0497c
This commit is contained in:
2022-11-15 17:39:04 +01:00
parent 09d48ea913
commit 7a870aa56c
6 changed files with 188 additions and 127 deletions

View File

@@ -249,7 +249,7 @@ class Dispatcher:
% (modulename, pname))
# validate!
value = pobj.datatype(value)
value = pobj.datatype.validate(value, previous=pobj.value)
# note: exceptions are handled in handle_request, not here!
getattr(moduleobj, 'write_' + pname)(value)
# return value is ignored here, as already handled