ophyd-async 0.13.4__py3-none-any.whl → 0.13.5__py3-none-any.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.
@@ -3,13 +3,11 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import logging
6
- from enum import Enum, IntEnum
6
+ from enum import IntEnum
7
7
 
8
8
  import numpy.typing as npt
9
9
  from tango import (
10
- AttrDataFormat,
11
10
  AttrWriteType,
12
- CmdArgType,
13
11
  DeviceProxy,
14
12
  DevState,
15
13
  )
@@ -25,7 +23,12 @@ from ophyd_async.core import (
25
23
  SignalX,
26
24
  )
27
25
 
28
- from ._tango_transport import TangoSignalBackend, get_python_type
26
+ from ._tango_transport import (
27
+ CommandProxyReadCharacter,
28
+ TangoSignalBackend,
29
+ get_command_character,
30
+ get_python_type,
31
+ )
29
32
  from ._utils import get_device_trl_and_attr
30
33
 
31
34
  logger = logging.getLogger("ophyd_async")
@@ -148,22 +151,13 @@ async def infer_python_type(
148
151
 
149
152
  if tr_name in dev_proxy.get_command_list():
150
153
  config = await dev_proxy.get_command_config(tr_name)
151
- isarray, py_type, _ = get_python_type(config.in_type)
154
+ py_type = get_python_type(config)
152
155
  elif tr_name in dev_proxy.get_attribute_list():
153
156
  config = await dev_proxy.get_attribute_config(tr_name)
154
- isarray, py_type, _ = get_python_type(config.data_type)
155
- if py_type is Enum:
156
- enum_dict = {label: i for i, label in enumerate(config.enum_labels)}
157
- py_type = IntEnum("TangoEnum", enum_dict)
158
- if config.data_format in [AttrDataFormat.SPECTRUM, AttrDataFormat.IMAGE]:
159
- isarray = True
157
+ py_type = get_python_type(config)
160
158
  else:
161
159
  raise RuntimeError(f"Cannot find {tr_name} in {device_trl}")
162
-
163
- if py_type is CmdArgType.DevState:
164
- py_type = DevState
165
-
166
- return npt.NDArray[py_type] if isarray else py_type
160
+ return py_type
167
161
 
168
162
 
169
163
  async def infer_signal_type(
@@ -190,11 +184,13 @@ async def infer_signal_type(
190
184
 
191
185
  if tr_name in dev_proxy.get_command_list():
192
186
  config = await dev_proxy.get_command_config(tr_name)
193
- if config.in_type == CmdArgType.DevVoid:
194
- return SignalX
195
- elif config.in_type != config.out_type:
196
- logger.debug("Commands with different in and out dtypes are not supported")
197
- return None
198
- else:
187
+ command_character = get_command_character(config)
188
+ if command_character == CommandProxyReadCharacter.READ:
189
+ return SignalR
190
+ elif command_character == CommandProxyReadCharacter.WRITE:
191
+ return SignalW
192
+ elif command_character == CommandProxyReadCharacter.READ_WRITE:
199
193
  return SignalRW
194
+ elif command_character == CommandProxyReadCharacter.EXECUTE:
195
+ return SignalX
200
196
  raise RuntimeError(f"Unable to infer signal character for {trl}")