Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/core/hardware/bliss/multiposition.py: 92%
24 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
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3from daiquiri.core.hardware.abstract import HardwareProperty
4from daiquiri.core.hardware.abstract.multiposition import (
5 Multiposition as AbstractMultiposition,
6 MultipositionStates,
7)
8from daiquiri.core.hardware.bliss.object import BlissObject
10import logging
12logger = logging.getLogger(__name__)
15class PositionsProperty(HardwareProperty):
16 def translate_from(self, value):
17 positions = []
18 for line in value:
19 target = [
20 {
21 "object": t["axis"].name,
22 "destination": t["destination"],
23 "tolerance": t["tolerance"],
24 }
25 for t in line["target"]
26 ]
27 p = {
28 "position": line["label"],
29 "description": line["description"],
30 "target": target,
31 }
32 positions.append(p)
34 return positions
37class StateProperty(HardwareProperty):
38 def translate_from(self, value):
39 for s in MultipositionStates:
40 if value == s:
41 return s
44class Multiposition(BlissObject, AbstractMultiposition):
45 PROPERTY_MAP = {
46 "position": HardwareProperty("position"),
47 "positions": PositionsProperty("positions_list"),
48 "state": StateProperty("state"),
49 }
51 CALLABLE_MAP = {"stop": "stop"}
53 def _call_move(self, value):
54 logger.debug(f"_call_move multiposition {value}")
55 self._object.move(value, wait=False)