Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/core/hardware/tango/shutter.py: 64%

22 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 tango import DevState 

4 

5from daiquiri.core.hardware.abstract import HardwareProperty 

6from daiquiri.core.hardware.abstract.shutter import Shutter as AbstractShutter 

7from daiquiri.core.hardware.tango.object import TangoObject 

8 

9import logging 

10 

11logger = logging.getLogger(__name__) 

12 

13 

14class ShutterStateProperty(HardwareProperty): 

15 def translate_from(self, value): 

16 val_map = { 

17 DevState.CLOSE: "CLOSED", 

18 DevState.DISABLE: "DISABLED", 

19 DevState.OPEN: "OPEN", 

20 DevState.FAULT: "FAULT", 

21 DevState.UNKNOWN: "UNKNOWN", 

22 DevState.RUNNING: "OPEN", # The RUNNING state is not very useful in user point of view 

23 DevState.STANDBY: "STANDBY", 

24 DevState.MOVING: "MOVING", 

25 } 

26 for k, v in val_map.items(): 

27 if k == value: 

28 return v 

29 

30 return "UNKNOWN" 

31 

32 

33class Shutter(TangoObject, AbstractShutter): 

34 CALLABLE_MAP = {"open": "Open", "close": "Close", "reset": "Reset"} 

35 

36 def _get_open_text(self): 

37 return "" 

38 

39 def _get_closed_text(self): 

40 return "" 

41 

42 def _get_valid(self): 

43 return True 

44 

45 PROPERTY_MAP = { 

46 "state": ShutterStateProperty("state"), 

47 "status": HardwareProperty("status"), 

48 "open_text": HardwareProperty("open_text", getter=_get_open_text), 

49 "closed_text": HardwareProperty("closed_text", getter=_get_closed_text), 

50 "valid": HardwareProperty("valid", getter=_get_valid), 

51 }