Skip to content

Commit 161b4c0

Browse files
authored
Merge pull request #100 from python-accelerator-middle-layer/update-example
Updated tune (no yaml) example
2 parents 47f61df + a9e22f8 commit 161b4c0

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

examples/ESRF_tune_example/esrf_tune_example_no_yaml.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import time
33

44
import numpy as np
5-
from pyaml.instrument import ConfigModel as InstrumentConfigModel
6-
from pyaml.instrument import Instrument
75
from tango.pyaml.attribute import Attribute
86
from tango.pyaml.attribute import ConfigModel as AttributeConfig
97
from tango.pyaml.attribute_read_only import (
@@ -19,6 +17,8 @@
1917
TangoControlSystem,
2018
)
2119

20+
from pyaml.accelerator import Accelerator
21+
from pyaml.accelerator import ConfigModel as AcceleratorConfigModel
2222
from pyaml.arrays.magnet import ConfigModel as MagnetArrayConfigModel
2323
from pyaml.arrays.magnet import Magnet
2424
from pyaml.configuration import set_root_folder
@@ -50,7 +50,6 @@
5050

5151
tangocs = ControlSystemConfig(name="live", tango_host="ebs-simu-3:10000")
5252
control = TangoControlSystem(tangocs)
53-
control.init_cs()
5453

5554
qfCurve = CSVCurve(CSVCureveConfig(file="config/sr/magnet_models/QF1_strength.csv"))
5655
qdCurve = CSVCurve(CSVCureveConfig(file="config/sr/magnet_models/QD2_strength.csv"))
@@ -104,9 +103,10 @@
104103

105104
quads = Magnet(MagnetArrayConfigModel(name="quadsForTune", elements=names))
106105

107-
sr = Instrument(
108-
InstrumentConfigModel(
109-
name="sr",
106+
sr = Accelerator(
107+
AcceleratorConfigModel(
108+
machine="sr",
109+
facility="ESRF",
110110
energy=6e9,
111111
controls=[control],
112112
simulators=[simulator],
@@ -137,11 +137,18 @@
137137
correctionmat = np.linalg.pinv(tunemat.T)
138138

139139
# Correct tune on live
140-
qxAtt = AttributeReadOnly(
141-
AttributeReadOnlyConfig(attribute="sys/ringsimulator/ebs/Tune_h", unit="")
142-
)
143-
qyAtt = AttributeReadOnly(
144-
AttributeReadOnlyConfig(attribute="sys/ringsimulator/ebs/Tune_v", unit="")
140+
141+
# Here ,as an example, instead of using the betatron tune monitor object,
142+
# we directly connect to th CS
143+
qxAtt, qyAtt = control.attach(
144+
[
145+
AttributeReadOnly(
146+
AttributeReadOnlyConfig(attribute="sys/ringsimulator/ebs/Tune_h", unit="")
147+
),
148+
AttributeReadOnly(
149+
AttributeReadOnlyConfig(attribute="sys/ringsimulator/ebs/Tune_v", unit="")
150+
),
151+
]
145152
)
146153

147154
print(f"Tune={qxAtt.readback()}, {qyAtt.readback()}")

0 commit comments

Comments
 (0)