Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/implementors/imageviewer/beamlineparams.py: 79%
38 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-14 02:13 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-14 02:13 +0000
1from marshmallow import Schema, fields, validate
3from daiquiri.core.components.params import ParamHandler, ParamsHandler, ParamSchema
5from bliss.config.static import get_config
7cfg = get_config()
10class FastShutterParam(ParamHandler):
11 def before(self, value):
12 if value:
13 shut = cfg.get("safshut")
14 shut.open()
16 def after(self, value):
17 if value:
18 shut = cfg.get("safshut")
19 shut.close()
22class DetectorDistanceParam(ParamHandler):
23 def before(self, value):
24 det = cfg.get("omega")
25 det.move(value)
28class BeamlineParamsHandler(ParamsHandler):
29 fast_shutter = FastShutterParam()
30 detector_distance = DetectorDistanceParam()
33class DiodeSchema(Schema):
34 name = fields.Str(metadata={"enum": ["d1", "d2", "d3"]})
35 value = fields.Int()
38class ArbMotorSchema(Schema):
39 name = fields.Str(metadata={"enum": ["x", "y", "z"]})
40 value = fields.Int()
43# parallelise these moves
44class BeamlineParamsSchema(ParamSchema):
45 handler = BeamlineParamsHandler()
47 detector_distance = fields.Float(
48 validate=validate.Range(min=20, max=400),
49 metadata={
50 "title": "Detector Distance",
51 "unit": "mm",
52 "description": "Move the detector to specified distance",
53 },
54 )
56 fast_shutter = fields.Bool(
57 metadata={
58 "title": "Fast Shutter",
59 "description": "Open fast shutter before and close after",
60 }
61 )
63 attenuators = fields.Str(
64 metadata={"title": "Attenuators", "enum": ["0.1mm_al", "0.5mm_al", "0.7mm_al"]}
65 )
67 pinhole = fields.Str(metadata={"title": "Pin Hole", "enum": ["10um", "5um", "1um"]})
69 light = fields.Bool(metadata={"title": "Turn off Light"})
71 diode_gain = fields.List(
72 fields.Nested(DiodeSchema), metadata={"title": "Diode Gains"}
73 )
75 arb_motor = fields.List(fields.Nested(ArbMotorSchema), metadata={"title": "Motors"})
77 energy = fields.Float(metadata={"title": "Energy", "unit": "keV"})
79 class Meta:
80 uischema = {
81 "arb_motor": {"ui:field": "arrayTable"},
82 "diode_gain": {"ui:field": "arrayTable"},
83 }