Skip to content

Commit e86f971

Browse files
authored
Removing unnecessary TangoReadable class (#1130)
* Removing unnecessary TangoReadable class. For equivalent functionality, simply inherit from TangoDevice and StandardReadable. Added set_trl method to TangoDeviceConnector to change the trl before connecting the device. Previously this was done by accessing the public trl attribute directly. In TangoDevice, trl was given a default value to allow for setting the trl after initialization. * Minor fix for type checking
1 parent b29c48d commit e86f971

File tree

7 files changed

+24
-28
lines changed

7 files changed

+24
-28
lines changed

src/ophyd_async/tango/core/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
tango_signal_w,
99
tango_signal_x,
1010
)
11-
from ._tango_readable import TangoReadable
1211
from ._tango_transport import (
1312
AttributeProxy,
1413
CommandProxy,
@@ -50,7 +49,6 @@
5049
"tango_signal_w",
5150
"tango_signal_x",
5251
"TangoDevice",
53-
"TangoReadable",
5452
"TangoPolling",
5553
"TangoDeviceConnector",
5654
"TangoLongStringTable",

src/ophyd_async/tango/core/_base_device.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TangoDevice(Device):
2929

3030
def __init__(
3131
self,
32-
trl: str | None,
32+
trl: str = "",
3333
support_events: bool = False,
3434
name: str = "",
3535
auto_fill_signals: bool = True,
@@ -80,6 +80,9 @@ def __init__(
8080
self._support_events = support_events
8181
self._auto_fill_signals = auto_fill_signals
8282

83+
def set_trl(self, trl: str):
84+
self.trl = trl
85+
8386
def create_children_from_annotations(self, device: Device):
8487
if not hasattr(self, "filler"):
8588
self.filler = DeviceFiller(

src/ophyd_async/tango/core/_tango_readable.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/ophyd_async/tango/demo/_counter.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
from typing import Annotated as A
22

3-
from ophyd_async.core import DEFAULT_TIMEOUT, AsyncStatus, SignalR, SignalRW, SignalX
3+
from ophyd_async.core import (
4+
DEFAULT_TIMEOUT,
5+
AsyncStatus,
6+
SignalR,
7+
SignalRW,
8+
SignalX,
9+
StandardReadable,
10+
)
411
from ophyd_async.core import StandardReadableFormat as Format
5-
from ophyd_async.tango.core import TangoPolling, TangoReadable
12+
from ophyd_async.tango.core import TangoDevice, TangoPolling
613

714

8-
class TangoCounter(TangoReadable):
15+
class TangoCounter(TangoDevice, StandardReadable):
916
"""Tango counting device."""
1017

1118
# Enter the name and type of the signals you want to use

src/ophyd_async/tango/demo/_mover.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@
1111
SignalR,
1212
SignalRW,
1313
SignalX,
14+
StandardReadable,
1415
WatchableAsyncStatus,
1516
WatcherUpdate,
1617
observe_value,
1718
wait_for_value,
1819
)
1920
from ophyd_async.core import StandardReadableFormat as Format
20-
from ophyd_async.tango.core import DevStateEnum, TangoPolling, TangoReadable
21+
from ophyd_async.tango.core import DevStateEnum, TangoDevice, TangoPolling
2122

2223

23-
class TangoMover(TangoReadable, Movable, Stoppable):
24+
class TangoMover(TangoDevice, StandardReadable, Movable, Stoppable):
2425
"""Tango moving device."""
2526

2627
# Enter the name and type of the signals you want to use
@@ -32,7 +33,7 @@ class TangoMover(TangoReadable, Movable, Stoppable):
3233
# If a tango name clashes with a bluesky verb, add a trailing underscore
3334
stop_: SignalX
3435

35-
def __init__(self, trl: str | None = "", name=""):
36+
def __init__(self, trl: str = "", name=""):
3637
super().__init__(trl, name=name)
3738
self.add_readables([self.position], Format.HINTED_SIGNAL)
3839
self.add_readables([self.velocity], Format.CONFIG_SIGNAL)

tests/system_tests/tango/test_base_device.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
SignalRW,
2929
SignalW,
3030
SignalX,
31+
StandardReadable,
3132
init_devices,
3233
)
3334
from ophyd_async.core import StandardReadableFormat as Format
34-
from ophyd_async.tango.core import TangoReadable, get_full_attr_trl, get_python_type
35+
from ophyd_async.tango.core import TangoDevice, get_full_attr_trl, get_python_type
3536
from ophyd_async.tango.demo import (
3637
DemoCounter,
3738
DemoMover,
@@ -259,7 +260,7 @@ def enum_cmd(self, value: TestEnum) -> TestEnum:
259260

260261

261262
# --------------------------------------------------------------------
262-
class TestTangoReadable(TangoReadable):
263+
class TestTangoReadable(TangoDevice, StandardReadable):
263264
__test__ = False
264265
justvalue: A[SignalRW[int], Format.HINTED_UNCACHED_SIGNAL]
265266
array: A[SignalRW[Array1D[np.float64]], Format.HINTED_UNCACHED_SIGNAL]
@@ -394,9 +395,9 @@ async def test_connect(tango_test_device):
394395
@pytest.mark.asyncio
395396
async def test_set_trl(tango_test_device):
396397
values, description = await describe_class(tango_test_device)
397-
test_device = TestTangoReadable(name="test_device")
398+
test_device = TestTangoReadable(trl="", name="test_device")
398399

399-
test_device._connector.trl = tango_test_device
400+
test_device._connector.set_trl(tango_test_device)
400401
await test_device.connect()
401402

402403
assert test_device.name == "test_device"

tests/system_tests/tango/test_tango_signals.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ async def test_tango_signal_rw(everything_device_trl: str, everything_signal_inf
287287

288288
# --------------------------------------------------------------------
289289
@pytest.mark.asyncio
290+
@pytest.mark.timeout(2.0)
290291
async def test_tango_signal_x(tango_test_device: str):
291292
timeout = 0.2
292293
signal = tango_signal_x(

0 commit comments

Comments
 (0)