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
« 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
5from daiquiri.core.hardware.abstract import HardwareObject
6from daiquiri.core.schema.hardware import HardwareSchema
7from daiquiri.core.schema.validators import RequireEmpty
9import logging
11logger = logging.getLogger(__name__)
13MultipositionStates = ["MOVING", "READY", "UNKNOWN", "ERROR"]
16class MultipositionAxis(Schema):
17 axis = fields.Str()
18 destination = fields.Float()
19 tolerance = fields.Float()
22class MultipositionPosition(Schema):
23 position = fields.Str()
24 description = fields.Str()
25 target = fields.Nested(MultipositionAxis, many=True)
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})
36class MultipositionCallablesSchema(HardwareSchema):
37 move = fields.Str()
38 stop = RequireEmpty()
41class Multiposition(HardwareObject):
42 _type = "multiposition"
43 _state_ok = [MultipositionStates[0], MultipositionStates[1]]
45 _properties = MultipositionPropertiesSchema()
46 _callables = MultipositionCallablesSchema()
48 def move(self, value):
49 self.call("move", value)
51 def stop(self):
52 self.call("stop", None)