Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/implementors/simplescan/scan.py: 78%

23 statements  

« prev     ^ index     » next       coverage.py v7.6.5, created at 2024-11-15 02:12 +0000

1#!/usr/bin/env python 

2# -*- coding: utf-8 -*- 

3from marshmallow import Schema, fields, validate 

4from bliss.config.static import get_config 

5 

6from daiquiri.core.schema.validators import OneOf 

7from daiquiri.core.components import ComponentActor 

8from daiquiri.core.hardware.bliss.session import * 

9 

10cfg = get_config() 

11 

12 

13class SimpleScanSchema(Schema): 

14 motor = OneOf(["robz", "roby"], required=True, metadata={"title": "Motor"}) 

15 motor_start = fields.Float(required=True, metadata={"title": "Start Position"}) 

16 motor_end = fields.Float(required=True, metadata={"title": "End Position"}) 

17 npoints = fields.Int(required=True, metadata={"title": "No. Points"}) 

18 time = fields.Float( 

19 validate=validate.Range(min=0.1, max=5), 

20 required=True, 

21 metadata={"title": "Time per Point", "unit": "s"}, 

22 ) 

23 detectors = fields.List( 

24 OneOf(["diode", "simu1", "lima_simulator"]), 

25 required=True, 

26 metadata={"title": "Detectors", "uniqueItems": True, "minItems": 1}, 

27 ) 

28 

29 

30class ScanActor(ComponentActor): 

31 schema = SimpleScanSchema 

32 name = "simple-scan" 

33 desc = "Simple ascan" 

34 

35 def method(self, **kwargs): 

36 print("AddscanActor", kwargs) 

37 kwargs["motor"] = cfg.get(kwargs["motor"]) 

38 kwargs["detectors"] = [cfg.get(d) for d in kwargs["detectors"]] 

39 

40 # this is the bliss function 

41 simple_scan(**kwargs) 

42 

43 return "im a return value"