improve and fix errors with parameter limits

- in order to work properly, readonly=True in limit parameters
  has to be set before creating the write_* method
- more explicit: Use e.g. target_max=Limit()
- fix an error in the loop over the base classes when creating
  the check_* method
- more concise error message when a limit is violated
+ fix an error in playground when using persistent parameters

Change-Id: Ibd557b55d6c0d9a2612cda4460b16e3c70e1bc9e
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31017
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
2023-05-04 12:50:25 +02:00
parent 85166344d2
commit 3b95013b69
6 changed files with 73 additions and 42 deletions

View File

@ -29,7 +29,7 @@ import pytest
from frappy.datatypes import BoolType, FloatRange, StringType, IntRange, ScaledInteger
from frappy.errors import ProgrammingError, ConfigError, RangeError
from frappy.modules import Communicator, Drivable, Readable, Module
from frappy.params import Command, Parameter
from frappy.params import Command, Parameter, Limit
from frappy.rwhandler import ReadHandler, WriteHandler, nopoll
from frappy.lib import generalConfig
@ -795,17 +795,17 @@ stdlim = {
class Lim(Module):
a = Parameter('', FloatRange(-10, 10), readonly=False, default=0)
a_min = Parameter()
a_max = Parameter()
a_min = Limit()
a_max = Limit()
b = Parameter('', FloatRange(0, None), readonly=False, default=0)
b_min = Parameter()
b_min = Limit()
c = Parameter('', IntRange(None, 100), readonly=False, default=0)
c_max = Parameter()
c_max = Limit()
d = Parameter('', FloatRange(-5, 5), readonly=False, default=0)
d_limits = Parameter()
d_limits = Limit()
e = Parameter('', IntRange(0, 8), readonly=False, default=0)
@ -872,8 +872,8 @@ def test_limit_inheritance():
raise ValueError('value is not a multiple of 0.25')
class Mixin:
a_min = Parameter()
a_max = Parameter()
a_min = Limit()
a_max = Limit()
class Mod(Mixin, Base):
def check_a(self, value):