WIP validation of params on device
This commit is contained in:
1 parent
d9d7ca10f8
commit
b8da5ef397
1 file changed
+12
-10
@@ -7,7 +7,7 @@ from .http import TIMESTAMP_ID, HttpDeviceController, HttpDeviceSignal, HttpOphy
|
||||
|
||||
|
||||
class ValidatedHttpParams(Device):
|
||||
valid = Cpt(Signal)
|
||||
valid = Cpt(Signal, kind=Kind.normal)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -38,22 +38,20 @@ class ValidatedHttpParams(Device):
|
||||
if controller is None:
|
||||
raise TypeError("HttpDeviceSignal must be used in a device with a HttpDeviceController")
|
||||
self._controller = controller
|
||||
for attr in self.configuration_attrs:
|
||||
getattr(self, attr).subscribe(self._validate, run=False)
|
||||
|
||||
def _validate(self, **kwargs):
|
||||
print(f"validating {kwargs}")
|
||||
print(f"validating {self.read_configuration()}")
|
||||
|
||||
|
||||
class GridscanParameters(ValidatedHttpParams):
|
||||
grid_elem_count_y = Cpt(Signal, kind=Kind.config, dtype=int)
|
||||
grid_elem_size_y_um = Cpt(Signal, kind=Kind.config, dtype=float)
|
||||
time_sec = Cpt(Signal, kind=Kind.config, dtype=float)
|
||||
grid_elem_size_x_um = Cpt(Signal, kind=Kind.config, dtype=float)
|
||||
grid_elem_count_x = Cpt(Signal, kind=Kind.config, dtype=int)
|
||||
|
||||
@grid_elem_count_y.sub_value
|
||||
@grid_elem_size_y_um.sub_value
|
||||
@time_sec.sub_value
|
||||
@grid_elem_size_x_um.sub_value
|
||||
@grid_elem_count_x.sub_value
|
||||
def _validate(self, **kwargs):
|
||||
self._controller._rest_post()
|
||||
time_sec = Cpt(Signal, kind=Kind.config, dtype=float)
|
||||
|
||||
|
||||
class ScreeningParameters(ValidatedHttpParams):
|
||||
@@ -90,6 +88,10 @@ class AerotechController(HttpDeviceController):
|
||||
class Aerotech(HttpOphydDevice):
|
||||
controller_class = AerotechController
|
||||
|
||||
gridscan_config = Cpt(GridscanParameters, kind=Kind.config)
|
||||
screening_config = Cpt(ScreeningParameters, kind=Kind.config)
|
||||
rotation_config = Cpt(RotationScanParameters, kind=Kind.config)
|
||||
|
||||
x = Cpt(HttpDeviceSignal, axis_identifier="x", tolerance=0.01)
|
||||
y = Cpt(HttpDeviceSignal, axis_identifier="y", tolerance=0.01)
|
||||
z = Cpt(HttpDeviceSignal, axis_identifier="z", tolerance=0.01)
|
||||
|
||||
Reference in new issue
Block a user