zaber-motion 7.15.0__py3-none-win32.whl → 8.0.1__py3-none-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zaber_motion/__init__.py +1 -0
- zaber_motion/ascii/__init__.py +0 -1
- zaber_motion/ascii/axis.py +29 -0
- zaber_motion/ascii/axis_settings.py +27 -0
- zaber_motion/ascii/device.py +28 -0
- zaber_motion/ascii/device_settings.py +26 -0
- zaber_motion/ascii/lockstep.py +0 -45
- zaber_motion/ascii/pvt_sequence.py +0 -181
- zaber_motion/ascii/servo_tuner.py +28 -104
- zaber_motion/ascii/stream.py +0 -275
- zaber_motion/binary/connection.py +17 -4
- zaber_motion/dto/__init__.py +1 -0
- zaber_motion/dto/ascii/__init__.py +0 -1
- zaber_motion/dto/ascii/response.py +4 -1
- zaber_motion/dto/ascii/simple_tuning.py +18 -17
- zaber_motion/dto/ascii/unknown_response_event.py +4 -1
- zaber_motion/dto/requests/__init__.py +2 -0
- zaber_motion/dto/requests/get_command_unit_conversion_response.py +54 -0
- zaber_motion/dto/requests/set_simple_tuning.py +31 -31
- zaber_motion/dto/requests/unit_convert_native_request.py +91 -0
- zaber_motion/dto/unit_conversion_descriptor.py +93 -0
- zaber_motion/library.py +1 -1
- zaber_motion/microscopy/objective_changer.py +1 -69
- zaber_motion/unit_table.py +114 -0
- zaber_motion/version.py +1 -1
- {zaber_motion-7.15.0.dist-info → zaber_motion-8.0.1.dist-info}/METADATA +1 -1
- {zaber_motion-7.15.0.dist-info → zaber_motion-8.0.1.dist-info}/RECORD +31 -29
- zaber_motion_bindings/zaber-motion-core-windows-386.dll +0 -0
- zaber_motion/dto/ascii/lockstep_axes.py +0 -108
- {zaber_motion-7.15.0.dist-info → zaber_motion-8.0.1.dist-info}/LICENSE.txt +0 -0
- {zaber_motion-7.15.0.dist-info → zaber_motion-8.0.1.dist-info}/WHEEL +0 -0
- {zaber_motion-7.15.0.dist-info → zaber_motion-8.0.1.dist-info}/top_level.txt +0 -0
|
@@ -21,17 +21,17 @@ class SetSimpleTuning:
|
|
|
21
21
|
|
|
22
22
|
paramset: ServoTuningParamset = next(first for first in ServoTuningParamset)
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
load_inertia: float = 0
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
load_inertia_units: UnitsAndLiterals = Units.NATIVE
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
carriage_inertia_units: UnitsAndLiterals = Units.NATIVE
|
|
29
29
|
|
|
30
30
|
motor_inertia_units: UnitsAndLiterals = Units.NATIVE
|
|
31
31
|
|
|
32
32
|
tuning_params: List[ServoTuningParam] = field(default_factory=list)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
carriage_inertia: Optional[float] = None
|
|
35
35
|
|
|
36
36
|
motor_inertia: Optional[float] = None
|
|
37
37
|
|
|
@@ -42,10 +42,10 @@ class SetSimpleTuning:
|
|
|
42
42
|
device=0,
|
|
43
43
|
axis=0,
|
|
44
44
|
paramset=next(first for first in ServoTuningParamset),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
load_inertia=0,
|
|
46
|
+
load_inertia_units=Units.NATIVE,
|
|
47
|
+
carriage_inertia=None,
|
|
48
|
+
carriage_inertia_units=Units.NATIVE,
|
|
49
49
|
motor_inertia=None,
|
|
50
50
|
motor_inertia_units=Units.NATIVE,
|
|
51
51
|
tuning_params=[],
|
|
@@ -68,10 +68,10 @@ class SetSimpleTuning:
|
|
|
68
68
|
'device': int(self.device),
|
|
69
69
|
'axis': int(self.axis),
|
|
70
70
|
'paramset': self.paramset.value,
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
71
|
+
'loadInertia': float(self.load_inertia),
|
|
72
|
+
'loadInertiaUnits': units_from_literals(self.load_inertia_units).value,
|
|
73
|
+
'carriageInertia': float(self.carriage_inertia) if self.carriage_inertia is not None else None,
|
|
74
|
+
'carriageInertiaUnits': units_from_literals(self.carriage_inertia_units).value,
|
|
75
75
|
'motorInertia': float(self.motor_inertia) if self.motor_inertia is not None else None,
|
|
76
76
|
'motorInertiaUnits': units_from_literals(self.motor_inertia_units).value,
|
|
77
77
|
'tuningParams': [item.to_dict() for item in self.tuning_params] if self.tuning_params is not None else [],
|
|
@@ -84,10 +84,10 @@ class SetSimpleTuning:
|
|
|
84
84
|
device=data.get('device'), # type: ignore
|
|
85
85
|
axis=data.get('axis'), # type: ignore
|
|
86
86
|
paramset=ServoTuningParamset(data.get('paramset')), # type: ignore
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
load_inertia=data.get('loadInertia'), # type: ignore
|
|
88
|
+
load_inertia_units=Units(data.get('loadInertiaUnits')), # type: ignore
|
|
89
|
+
carriage_inertia=data.get('carriageInertia'), # type: ignore
|
|
90
|
+
carriage_inertia_units=Units(data.get('carriageInertiaUnits')), # type: ignore
|
|
91
91
|
motor_inertia=data.get('motorInertia'), # type: ignore
|
|
92
92
|
motor_inertia_units=Units(data.get('motorInertiaUnits')), # type: ignore
|
|
93
93
|
tuning_params=[ServoTuningParam.from_dict(item) for item in data.get('tuningParams')], # type: ignore
|
|
@@ -128,27 +128,27 @@ class SetSimpleTuning:
|
|
|
128
128
|
if not isinstance(self.paramset, ServoTuningParamset):
|
|
129
129
|
raise ValueError(f'Property "Paramset" of "SetSimpleTuning" is not an instance of "ServoTuningParamset".')
|
|
130
130
|
|
|
131
|
-
if self.
|
|
132
|
-
raise ValueError(f'Property "
|
|
131
|
+
if self.load_inertia is None:
|
|
132
|
+
raise ValueError(f'Property "LoadInertia" of "SetSimpleTuning" is None.')
|
|
133
133
|
|
|
134
|
-
if not isinstance(self.
|
|
135
|
-
raise ValueError(f'Property "
|
|
134
|
+
if not isinstance(self.load_inertia, (int, float, decimal.Decimal)):
|
|
135
|
+
raise ValueError(f'Property "LoadInertia" of "SetSimpleTuning" is not a number.')
|
|
136
136
|
|
|
137
|
-
if self.
|
|
138
|
-
raise ValueError(f'Property "
|
|
137
|
+
if self.load_inertia_units is None:
|
|
138
|
+
raise ValueError(f'Property "LoadInertiaUnits" of "SetSimpleTuning" is None.')
|
|
139
139
|
|
|
140
|
-
if not isinstance(self.
|
|
141
|
-
raise ValueError(f'Property "
|
|
140
|
+
if not isinstance(self.load_inertia_units, (Units, str)):
|
|
141
|
+
raise ValueError(f'Property "LoadInertiaUnits" of "SetSimpleTuning" is not Units.')
|
|
142
142
|
|
|
143
|
-
if self.
|
|
144
|
-
if not isinstance(self.
|
|
145
|
-
raise ValueError(f'Property "
|
|
143
|
+
if self.carriage_inertia is not None:
|
|
144
|
+
if not isinstance(self.carriage_inertia, (int, float, decimal.Decimal)):
|
|
145
|
+
raise ValueError(f'Property "CarriageInertia" of "SetSimpleTuning" is not a number.')
|
|
146
146
|
|
|
147
|
-
if self.
|
|
148
|
-
raise ValueError(f'Property "
|
|
147
|
+
if self.carriage_inertia_units is None:
|
|
148
|
+
raise ValueError(f'Property "CarriageInertiaUnits" of "SetSimpleTuning" is None.')
|
|
149
149
|
|
|
150
|
-
if not isinstance(self.
|
|
151
|
-
raise ValueError(f'Property "
|
|
150
|
+
if not isinstance(self.carriage_inertia_units, (Units, str)):
|
|
151
|
+
raise ValueError(f'Property "CarriageInertiaUnits" of "SetSimpleTuning" is not Units.')
|
|
152
152
|
|
|
153
153
|
if self.motor_inertia is not None:
|
|
154
154
|
if not isinstance(self.motor_inertia, (int, float, decimal.Decimal)):
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# This file is generated. Do not modify by hand.
|
|
2
|
+
# pylint: disable=line-too-long, unused-argument, f-string-without-interpolation, too-many-branches, too-many-statements, unnecessary-pass
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import Any, Dict, List
|
|
5
|
+
import decimal
|
|
6
|
+
from collections.abc import Iterable
|
|
7
|
+
import zaber_bson
|
|
8
|
+
from ..unit_conversion_descriptor import UnitConversionDescriptor
|
|
9
|
+
from ...units import Units, UnitsAndLiterals, units_from_literals
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class UnitConvertNativeRequest:
|
|
14
|
+
|
|
15
|
+
value: float = 0
|
|
16
|
+
|
|
17
|
+
values: List[float] = field(default_factory=list)
|
|
18
|
+
|
|
19
|
+
unit: UnitsAndLiterals = Units.NATIVE
|
|
20
|
+
|
|
21
|
+
conversion: UnitConversionDescriptor = field(default_factory=UnitConversionDescriptor.zero_values)
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def zero_values() -> 'UnitConvertNativeRequest':
|
|
25
|
+
return UnitConvertNativeRequest(
|
|
26
|
+
value=0,
|
|
27
|
+
values=[],
|
|
28
|
+
unit=Units.NATIVE,
|
|
29
|
+
conversion=UnitConversionDescriptor.zero_values(),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
@staticmethod
|
|
33
|
+
def from_binary(data_bytes: bytes) -> 'UnitConvertNativeRequest':
|
|
34
|
+
"""" Deserialize a binary representation of this class. """
|
|
35
|
+
data = zaber_bson.loads(data_bytes) # type: Dict[str, Any]
|
|
36
|
+
return UnitConvertNativeRequest.from_dict(data)
|
|
37
|
+
|
|
38
|
+
def to_binary(self) -> bytes:
|
|
39
|
+
"""" Serialize this class to a binary representation. """
|
|
40
|
+
self.validate()
|
|
41
|
+
return zaber_bson.dumps(self.to_dict()) # type: ignore
|
|
42
|
+
|
|
43
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
44
|
+
return {
|
|
45
|
+
'value': float(self.value),
|
|
46
|
+
'values': [float(item) for item in self.values] if self.values is not None else [],
|
|
47
|
+
'unit': units_from_literals(self.unit).value,
|
|
48
|
+
'conversion': self.conversion.to_dict(),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@staticmethod
|
|
52
|
+
def from_dict(data: Dict[str, Any]) -> 'UnitConvertNativeRequest':
|
|
53
|
+
return UnitConvertNativeRequest(
|
|
54
|
+
value=data.get('value'), # type: ignore
|
|
55
|
+
values=data.get('values'), # type: ignore
|
|
56
|
+
unit=Units(data.get('unit')), # type: ignore
|
|
57
|
+
conversion=UnitConversionDescriptor.from_dict(data.get('conversion')), # type: ignore
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
def validate(self) -> None:
|
|
61
|
+
"""" Validates the properties of the instance. """
|
|
62
|
+
if self.value is None:
|
|
63
|
+
raise ValueError(f'Property "Value" of "UnitConvertNativeRequest" is None.')
|
|
64
|
+
|
|
65
|
+
if not isinstance(self.value, (int, float, decimal.Decimal)):
|
|
66
|
+
raise ValueError(f'Property "Value" of "UnitConvertNativeRequest" is not a number.')
|
|
67
|
+
|
|
68
|
+
if self.values is not None:
|
|
69
|
+
if not isinstance(self.values, Iterable):
|
|
70
|
+
raise ValueError('Property "Values" of "UnitConvertNativeRequest" is not iterable.')
|
|
71
|
+
|
|
72
|
+
for i, values_item in enumerate(self.values):
|
|
73
|
+
if values_item is None:
|
|
74
|
+
raise ValueError(f'Item {i} in property "Values" of "UnitConvertNativeRequest" is None.')
|
|
75
|
+
|
|
76
|
+
if not isinstance(values_item, (int, float, decimal.Decimal)):
|
|
77
|
+
raise ValueError(f'Item {i} in property "Values" of "UnitConvertNativeRequest" is not a number.')
|
|
78
|
+
|
|
79
|
+
if self.unit is None:
|
|
80
|
+
raise ValueError(f'Property "Unit" of "UnitConvertNativeRequest" is None.')
|
|
81
|
+
|
|
82
|
+
if not isinstance(self.unit, (Units, str)):
|
|
83
|
+
raise ValueError(f'Property "Unit" of "UnitConvertNativeRequest" is not Units.')
|
|
84
|
+
|
|
85
|
+
if self.conversion is None:
|
|
86
|
+
raise ValueError(f'Property "Conversion" of "UnitConvertNativeRequest" is None.')
|
|
87
|
+
|
|
88
|
+
if not isinstance(self.conversion, UnitConversionDescriptor):
|
|
89
|
+
raise ValueError(f'Property "Conversion" of "UnitConvertNativeRequest" is not an instance of "UnitConversionDescriptor".')
|
|
90
|
+
|
|
91
|
+
self.conversion.validate()
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# This file is generated. Do not modify by hand.
|
|
2
|
+
# pylint: disable=line-too-long, unused-argument, f-string-without-interpolation, too-many-branches, too-many-statements, unnecessary-pass
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Any, Dict, Optional
|
|
5
|
+
import decimal
|
|
6
|
+
import zaber_bson
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class UnitConversionDescriptor:
|
|
11
|
+
"""
|
|
12
|
+
Information about unit conversion.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
dimension: str
|
|
16
|
+
"""
|
|
17
|
+
Name of the dimension being converted.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
conversion_function: str
|
|
21
|
+
"""
|
|
22
|
+
Internal name of conversion function used.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
scale: float
|
|
26
|
+
"""
|
|
27
|
+
Scale factor used in conversion, if applicable.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
resolution: Optional[int] = None
|
|
31
|
+
"""
|
|
32
|
+
Microstep resolution used in conversion, if applicable.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def zero_values() -> 'UnitConversionDescriptor':
|
|
37
|
+
return UnitConversionDescriptor(
|
|
38
|
+
dimension="",
|
|
39
|
+
conversion_function="",
|
|
40
|
+
scale=0,
|
|
41
|
+
resolution=None,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
@staticmethod
|
|
45
|
+
def from_binary(data_bytes: bytes) -> 'UnitConversionDescriptor':
|
|
46
|
+
"""" Deserialize a binary representation of this class. """
|
|
47
|
+
data = zaber_bson.loads(data_bytes) # type: Dict[str, Any]
|
|
48
|
+
return UnitConversionDescriptor.from_dict(data)
|
|
49
|
+
|
|
50
|
+
def to_binary(self) -> bytes:
|
|
51
|
+
"""" Serialize this class to a binary representation. """
|
|
52
|
+
self.validate()
|
|
53
|
+
return zaber_bson.dumps(self.to_dict()) # type: ignore
|
|
54
|
+
|
|
55
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
56
|
+
return {
|
|
57
|
+
'dimension': str(self.dimension or ''),
|
|
58
|
+
'conversionFunction': str(self.conversion_function or ''),
|
|
59
|
+
'scale': float(self.scale),
|
|
60
|
+
'resolution': int(self.resolution) if self.resolution is not None else None,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
def from_dict(data: Dict[str, Any]) -> 'UnitConversionDescriptor':
|
|
65
|
+
return UnitConversionDescriptor(
|
|
66
|
+
dimension=data.get('dimension'), # type: ignore
|
|
67
|
+
conversion_function=data.get('conversionFunction'), # type: ignore
|
|
68
|
+
scale=data.get('scale'), # type: ignore
|
|
69
|
+
resolution=data.get('resolution'), # type: ignore
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
def validate(self) -> None:
|
|
73
|
+
"""" Validates the properties of the instance. """
|
|
74
|
+
if self.dimension is not None:
|
|
75
|
+
if not isinstance(self.dimension, str):
|
|
76
|
+
raise ValueError(f'Property "Dimension" of "UnitConversionDescriptor" is not a string.')
|
|
77
|
+
|
|
78
|
+
if self.conversion_function is not None:
|
|
79
|
+
if not isinstance(self.conversion_function, str):
|
|
80
|
+
raise ValueError(f'Property "ConversionFunction" of "UnitConversionDescriptor" is not a string.')
|
|
81
|
+
|
|
82
|
+
if self.scale is None:
|
|
83
|
+
raise ValueError(f'Property "Scale" of "UnitConversionDescriptor" is None.')
|
|
84
|
+
|
|
85
|
+
if not isinstance(self.scale, (int, float, decimal.Decimal)):
|
|
86
|
+
raise ValueError(f'Property "Scale" of "UnitConversionDescriptor" is not a number.')
|
|
87
|
+
|
|
88
|
+
if self.resolution is not None:
|
|
89
|
+
if not isinstance(self.resolution, (int, float, decimal.Decimal)):
|
|
90
|
+
raise ValueError(f'Property "Resolution" of "UnitConversionDescriptor" is not a number.')
|
|
91
|
+
|
|
92
|
+
if int(self.resolution) != self.resolution:
|
|
93
|
+
raise ValueError(f'Property "Resolution" of "UnitConversionDescriptor" is not integer value.')
|
zaber_motion/library.py
CHANGED
|
@@ -5,7 +5,7 @@ from typing import Optional
|
|
|
5
5
|
from ..call import call, call_async, call_sync
|
|
6
6
|
from ..dto import requests as dto
|
|
7
7
|
from ..dto.measurement import Measurement
|
|
8
|
-
from ..ascii import
|
|
8
|
+
from ..ascii import Device, Axis
|
|
9
9
|
from ..units import Units, LengthUnits
|
|
10
10
|
|
|
11
11
|
|
|
@@ -39,74 +39,6 @@ class ObjectiveChanger:
|
|
|
39
39
|
self._focus_axis: Axis = focus_axis
|
|
40
40
|
self.__verify_is_changer()
|
|
41
41
|
|
|
42
|
-
@staticmethod
|
|
43
|
-
def find(
|
|
44
|
-
connection: Connection,
|
|
45
|
-
turret_address: int = 0,
|
|
46
|
-
focus_address: int = 0
|
|
47
|
-
) -> 'ObjectiveChanger':
|
|
48
|
-
"""
|
|
49
|
-
Deprecated: Use microscope's `Find` method instead or instantiate manually.
|
|
50
|
-
|
|
51
|
-
Finds an objective changer on a connection.
|
|
52
|
-
In case of conflict, specify the optional device addresses.
|
|
53
|
-
Devices on the connection must be identified.
|
|
54
|
-
|
|
55
|
-
Args:
|
|
56
|
-
connection: Connection on which to detect the objective changer.
|
|
57
|
-
turret_address: Optional device address of the turret device (X-MOR).
|
|
58
|
-
focus_address: Optional device address of the focus device (X-LDA).
|
|
59
|
-
|
|
60
|
-
Returns:
|
|
61
|
-
New instance of objective changer.
|
|
62
|
-
"""
|
|
63
|
-
request = dto.ObjectiveChangerRequest(
|
|
64
|
-
interface_id=connection.interface_id,
|
|
65
|
-
turret_address=turret_address,
|
|
66
|
-
focus_address=focus_address,
|
|
67
|
-
)
|
|
68
|
-
response = call(
|
|
69
|
-
"objective_changer/detect",
|
|
70
|
-
request,
|
|
71
|
-
dto.ObjectiveChangerCreateResponse.from_binary)
|
|
72
|
-
return ObjectiveChanger(
|
|
73
|
-
Device(connection, response.turret),
|
|
74
|
-
Axis(Device(connection, response.focus_address), response.focus_axis))
|
|
75
|
-
|
|
76
|
-
@staticmethod
|
|
77
|
-
async def find_async(
|
|
78
|
-
connection: Connection,
|
|
79
|
-
turret_address: int = 0,
|
|
80
|
-
focus_address: int = 0
|
|
81
|
-
) -> 'ObjectiveChanger':
|
|
82
|
-
"""
|
|
83
|
-
Deprecated: Use microscope's `Find` method instead or instantiate manually.
|
|
84
|
-
|
|
85
|
-
Finds an objective changer on a connection.
|
|
86
|
-
In case of conflict, specify the optional device addresses.
|
|
87
|
-
Devices on the connection must be identified.
|
|
88
|
-
|
|
89
|
-
Args:
|
|
90
|
-
connection: Connection on which to detect the objective changer.
|
|
91
|
-
turret_address: Optional device address of the turret device (X-MOR).
|
|
92
|
-
focus_address: Optional device address of the focus device (X-LDA).
|
|
93
|
-
|
|
94
|
-
Returns:
|
|
95
|
-
New instance of objective changer.
|
|
96
|
-
"""
|
|
97
|
-
request = dto.ObjectiveChangerRequest(
|
|
98
|
-
interface_id=connection.interface_id,
|
|
99
|
-
turret_address=turret_address,
|
|
100
|
-
focus_address=focus_address,
|
|
101
|
-
)
|
|
102
|
-
response = await call_async(
|
|
103
|
-
"objective_changer/detect",
|
|
104
|
-
request,
|
|
105
|
-
dto.ObjectiveChangerCreateResponse.from_binary)
|
|
106
|
-
return ObjectiveChanger(
|
|
107
|
-
Device(connection, response.turret),
|
|
108
|
-
Axis(Device(connection, response.focus_address), response.focus_axis))
|
|
109
|
-
|
|
110
42
|
def change(
|
|
111
43
|
self,
|
|
112
44
|
objective: int,
|
zaber_motion/unit_table.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# ===== THIS FILE IS GENERATED FROM A TEMPLATE ===== #
|
|
2
2
|
# ============== DO NOT EDIT DIRECTLY ============== #
|
|
3
|
+
from typing import List
|
|
3
4
|
|
|
4
5
|
from .call import call_sync
|
|
5
6
|
from .dto import requests as dto
|
|
7
|
+
from .dto.unit_conversion_descriptor import UnitConversionDescriptor
|
|
6
8
|
from .units import UnitsAndLiterals
|
|
7
9
|
|
|
8
10
|
|
|
@@ -84,3 +86,115 @@ class UnitTable:
|
|
|
84
86
|
request,
|
|
85
87
|
dto.DoubleResponse.from_binary)
|
|
86
88
|
return response.value
|
|
89
|
+
|
|
90
|
+
@staticmethod
|
|
91
|
+
def convert_to_native_units(
|
|
92
|
+
conversion: UnitConversionDescriptor,
|
|
93
|
+
value: float,
|
|
94
|
+
to_unit: UnitsAndLiterals
|
|
95
|
+
) -> float:
|
|
96
|
+
"""
|
|
97
|
+
Converts a value from one unit to native units given unit conversion descriptor.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
conversion: The unit conversion data retrieved from device or axis.
|
|
101
|
+
value: The value to be converted.
|
|
102
|
+
to_unit: The unit which the value is being converted to.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
The converted value. Throws ConversionFailedException if unit is incompatible.
|
|
106
|
+
"""
|
|
107
|
+
request = dto.UnitConvertNativeRequest(
|
|
108
|
+
conversion=conversion,
|
|
109
|
+
value=value,
|
|
110
|
+
unit=to_unit,
|
|
111
|
+
)
|
|
112
|
+
response = call_sync(
|
|
113
|
+
"units/convert_to_native_unit",
|
|
114
|
+
request,
|
|
115
|
+
dto.DoubleResponse.from_binary)
|
|
116
|
+
return response.value
|
|
117
|
+
|
|
118
|
+
@staticmethod
|
|
119
|
+
def convert_from_native_units(
|
|
120
|
+
conversion: UnitConversionDescriptor,
|
|
121
|
+
value: float,
|
|
122
|
+
from_unit: UnitsAndLiterals
|
|
123
|
+
) -> float:
|
|
124
|
+
"""
|
|
125
|
+
Converts a value from one unit to native units given unit conversion descriptor.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
conversion: The unit conversion data retrieved from device or axis.
|
|
129
|
+
value: The value to be converted.
|
|
130
|
+
from_unit: The unit which the value is being converted from.
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
The converted value. Throws ConversionFailedException if unit is incompatible.
|
|
134
|
+
"""
|
|
135
|
+
request = dto.UnitConvertNativeRequest(
|
|
136
|
+
conversion=conversion,
|
|
137
|
+
value=value,
|
|
138
|
+
unit=from_unit,
|
|
139
|
+
)
|
|
140
|
+
response = call_sync(
|
|
141
|
+
"units/convert_from_native_unit",
|
|
142
|
+
request,
|
|
143
|
+
dto.DoubleResponse.from_binary)
|
|
144
|
+
return response.value
|
|
145
|
+
|
|
146
|
+
@staticmethod
|
|
147
|
+
def convert_to_native_units_batch(
|
|
148
|
+
conversion: UnitConversionDescriptor,
|
|
149
|
+
values: List[float],
|
|
150
|
+
to_unit: UnitsAndLiterals
|
|
151
|
+
) -> List[float]:
|
|
152
|
+
"""
|
|
153
|
+
Converts values from one unit to native units given unit conversion descriptor.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
conversion: The unit conversion data retrieved from device or axis.
|
|
157
|
+
values: The value to be converted.
|
|
158
|
+
to_unit: The unit which the value is being converted to.
|
|
159
|
+
|
|
160
|
+
Returns:
|
|
161
|
+
The converted values. Throws ConversionFailedException if unit is incompatible.
|
|
162
|
+
"""
|
|
163
|
+
request = dto.UnitConvertNativeRequest(
|
|
164
|
+
conversion=conversion,
|
|
165
|
+
values=values,
|
|
166
|
+
unit=to_unit,
|
|
167
|
+
)
|
|
168
|
+
response = call_sync(
|
|
169
|
+
"units/convert_to_native_unit_batch",
|
|
170
|
+
request,
|
|
171
|
+
dto.DoubleArrayResponse.from_binary)
|
|
172
|
+
return response.values
|
|
173
|
+
|
|
174
|
+
@staticmethod
|
|
175
|
+
def convert_from_native_units_batch(
|
|
176
|
+
conversion: UnitConversionDescriptor,
|
|
177
|
+
values: List[float],
|
|
178
|
+
from_unit: UnitsAndLiterals
|
|
179
|
+
) -> List[float]:
|
|
180
|
+
"""
|
|
181
|
+
Converts values from one unit to native units given unit conversion descriptor.
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
conversion: The unit conversion data retrieved from device or axis.
|
|
185
|
+
values: The value to be converted.
|
|
186
|
+
from_unit: The unit which the value is being converted from.
|
|
187
|
+
|
|
188
|
+
Returns:
|
|
189
|
+
The converted values. Throws ConversionFailedException if unit is incompatible.
|
|
190
|
+
"""
|
|
191
|
+
request = dto.UnitConvertNativeRequest(
|
|
192
|
+
conversion=conversion,
|
|
193
|
+
values=values,
|
|
194
|
+
unit=from_unit,
|
|
195
|
+
)
|
|
196
|
+
response = call_sync(
|
|
197
|
+
"units/convert_from_native_unit_batch",
|
|
198
|
+
request,
|
|
199
|
+
dto.DoubleArrayResponse.from_binary)
|
|
200
|
+
return response.values
|
zaber_motion/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "
|
|
1
|
+
__version__ = "8.0.1"
|