Skip to content

Commit ae978a9

Browse files
committed
Remove tango polling
1 parent bdab4fa commit ae978a9

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

src/fastcs/backends/tango/dsr.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,12 @@ def _wrap_updater_fget(
2525
attr_name: str, attribute: AttrR, controller: BaseController
2626
) -> Callable[[Any], Any]:
2727
async def fget(tango_device: Device):
28-
assert attribute.updater is not None
29-
30-
await attribute.updater.update(controller, attribute)
3128
tango_device.info_stream(f"called fget method: {attr_name}")
3229
return attribute.get()
3330

3431
return fget
3532

3633

37-
def _tango_polling_period(attribute: AttrR) -> int:
38-
if attribute.updater is not None:
39-
# Convert to integer milliseconds
40-
return int(attribute.updater.update_period * 1000)
41-
42-
return -1 # `tango.server.attribute` default for `polling_period`
43-
44-
4534
def _tango_display_format(attribute: Attribute) -> str:
4635
match attribute.datatype:
4736
case Float(prec):
@@ -54,10 +43,8 @@ def _wrap_updater_fset(
5443
attr_name: str, attribute: AttrW, controller: BaseController
5544
) -> Callable[[Any, Any], Any]:
5645
async def fset(tango_device: Device, val):
57-
assert attribute.sender is not None
58-
59-
await attribute.sender.put(controller, attribute, val)
6046
tango_device.info_stream(f"called fset method: {attr_name}")
47+
await attribute.process_without_display_update(val)
6148

6249
return fset
6350

@@ -84,7 +71,6 @@ def _collect_dev_attributes(mapping: Mapping) -> dict[str, Any]:
8471
),
8572
access=AttrWriteType.READ_WRITE,
8673
format=_tango_display_format(attribute),
87-
polling_period=_tango_polling_period(attribute),
8874
)
8975
case AttrR():
9076
collection[d_attr_name] = server.attribute(
@@ -95,7 +81,6 @@ def _collect_dev_attributes(mapping: Mapping) -> dict[str, Any]:
9581
attr_name, attribute, single_mapping.controller
9682
),
9783
format=_tango_display_format(attribute),
98-
polling_period=_tango_polling_period(attribute),
9984
)
10085
case AttrW():
10186
collection[d_attr_name] = server.attribute(
@@ -146,7 +131,6 @@ def _collect_dev_init(mapping: Mapping) -> dict[str, Callable]:
146131
async def init_device(tango_device: Device):
147132
await server.Device.init_device(tango_device) # type: ignore
148133
tango_device.set_state(DevState.ON)
149-
await mapping.controller.connect()
150134

151135
return {"init_device": init_device}
152136

@@ -186,13 +170,13 @@ def run(self, options: TangoDSROptions | None = None) -> None:
186170

187171
class_bases = (server.Device,)
188172
pytango_class = type(options.dev_class, class_bases, class_dict)
189-
register_dev(options.dev_name, options.dev_class, options.dsr_instance)
190173

191174
dsr_args = _collect_dsr_args(options)
192175

193176
server.run(
194177
(pytango_class,),
195178
[options.dev_class, options.dsr_instance, *dsr_args],
179+
green_mode=server.GreenMode.Asyncio,
196180
)
197181

198182

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Spin up a local minimal tango cs
2+
3+
version: "3.7"
4+
services:
5+
mysql:
6+
image: registry.gitlab.com/tango-controls/docker/mysql:5
7+
environment:
8+
- MYSQL_ROOT_PASSWORD=root
9+
10+
tango-cs:
11+
hostname: localhost
12+
image: registry.gitlab.com/tango-controls/docker/tango-cs:9
13+
ports:
14+
- "10000:10000"
15+
environment:
16+
- TANGO_HOST=localhost:10000
17+
- MYSQL_HOST=mysql:3306
18+
- MYSQL_USER=tango
19+
- MYSQL_PASSWORD=tango
20+
- MYSQL_DATABASE=tango
21+
depends_on:
22+
- mysql

0 commit comments

Comments
 (0)