Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/core/hardware/abstract/multiposition.py: 94%

31 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 

4 

5from daiquiri.core.hardware.abstract import HardwareObject 

6from daiquiri.core.schema.hardware import HardwareSchema 

7from daiquiri.core.schema.validators import RequireEmpty 

8 

9import logging 

10 

11logger = logging.getLogger(__name__) 

12 

13MultipositionStates = ["MOVING", "READY", "UNKNOWN", "ERROR"] 

14 

15 

16class MultipositionAxis(Schema): 

17 axis = fields.Str() 

18 destination = fields.Float() 

19 tolerance = fields.Float() 

20 

21 

22class MultipositionPosition(Schema): 

23 position = fields.Str() 

24 description = fields.Str() 

25 target = fields.Nested(MultipositionAxis, many=True) 

26 

27 

28class MultipositionPropertiesSchema(HardwareSchema): 

29 position = fields.Str(metadata={"readOnly": True}) 

30 positions = fields.Nested( 

31 MultipositionPosition, many=True, metadata={"readOnly": True} 

32 ) 

33 state = fields.Str(metadata={"enum": MultipositionStates, "readOnly": True}) 

34 

35 

36class MultipositionCallablesSchema(HardwareSchema): 

37 move = fields.Str() 

38 stop = RequireEmpty() 

39 

40 

41class Multiposition(HardwareObject): 

42 _type = "multiposition" 

43 _state_ok = [MultipositionStates[0], MultipositionStates[1]] 

44 

45 _properties = MultipositionPropertiesSchema() 

46 _callables = MultipositionCallablesSchema() 

47 

48 def move(self, value): 

49 self.call("move", value) 

50 

51 def stop(self): 

52 self.call("stop", None)