Skip to content

Commit b03d720

Browse files
committed
Added connect() function, removed init_cs()
1 parent 1ee9ca3 commit b03d720

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

pyaml/accelerator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def __init__(self, cfg: ConfigModel):
5050
else:
5151
# Add as dynacmic attribute
5252
setattr(self, c.name(), c)
53-
c.init_cs()
5453
c.fill_device(cfg.devices)
5554

5655
if cfg.simulators is not None:

pyaml/control/controlsystem.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from ..rf.rf_plant import RFPlant, RWTotalVoltage
2828
from ..rf.rf_transmitter import RFTransmitter
2929
from ..tuning_tools.tune import Tune
30+
from .deviceaccess import DeviceAccess
3031

3132

3233
class ControlSystem(ElementHolder, metaclass=ABCMeta):
@@ -38,8 +39,9 @@ def __init__(self):
3839
ElementHolder.__init__(self)
3940

4041
@abstractmethod
41-
def init_cs(self):
42-
"""Initialize control system"""
42+
def connect(self, dev: DeviceAccess) -> DeviceAccess:
43+
"""Return a new instance of the DeviceAccess object
44+
coming from configuration attached to this CS"""
4345
pass
4446

4547
@abstractmethod

tests/dummy_cs/tango-pyaml/tango/pyaml/controlsystem.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import copy
12
import os
23

34
from pydantic import BaseModel, ConfigDict
45

56
from pyaml.control.controlsystem import ControlSystem
7+
from pyaml.control.deviceaccess import DeviceAccess
68

79
PYAMLCLASS: str = "TangoControlSystem"
810

@@ -21,6 +23,16 @@ def __init__(self, cfg: ConfigModel):
2123
self._cfg = cfg
2224
print(f"Creating dummy TangoControlSystem: {cfg.name}")
2325

26+
def connect(self, dev: DeviceAccess) -> DeviceAccess:
27+
newDev = copy.copy(dev) # Shallow copy the object
28+
newDev._cfg = copy.copy(
29+
dev._cfg
30+
) # Shallow copy the config object to allow a new attribute name
31+
newDev._cfg.attribute = (
32+
"//" + self._cfg.tango_host + "/" + newDev._cfg.attribute
33+
)
34+
return newDev
35+
2436
def name(self) -> str:
2537
return self._cfg.name
2638

0 commit comments

Comments
 (0)