Skip to content

Commit f4c5d40

Browse files
committed
Management of attached devices per CS instance
1 parent 24f57ee commit f4c5d40

25 files changed

+189
-459
lines changed

pyaml/bpm/bpm_model.py

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -12,67 +12,6 @@ class BPMModel(metaclass=ABCMeta):
1212
tilts.
1313
"""
1414

15-
@abstractmethod
16-
def read_position(self) -> NDArray[np.float64]:
17-
"""
18-
Read horizontal and vertical positions from a BPM.
19-
Returns
20-
-------
21-
NDArray[np.float64]
22-
Array of shape (2,) containing the horizontal and vertical
23-
positions
24-
"""
25-
pass
26-
27-
@abstractmethod
28-
def read_tilt(self) -> float:
29-
"""
30-
Read the tilt value from a BPM.
31-
Returns
32-
-------
33-
float
34-
The tilt value of the BPM
35-
"""
36-
pass
37-
38-
@abstractmethod
39-
def read_offset(self) -> NDArray:
40-
"""
41-
Read the offset values from a BPM.
42-
Returns
43-
-------
44-
NDArray[np.float64]
45-
Array of shape (2,) containing the horizontal and vertical
46-
offsets
47-
"""
48-
pass
49-
50-
@abstractmethod
51-
def set_tilt(self, tilt: float):
52-
"""
53-
Set the tilt value of a BPM.
54-
Parameters
55-
----------
56-
tilt : float
57-
The tilt value to set for the BPM
58-
Returns
59-
-------
60-
None
61-
"""
62-
pass
63-
64-
@abstractmethod
65-
def set_offset(self, offset: NDArray[np.float64]):
66-
"""
67-
Set the offset values of a BPM
68-
Parameters
69-
----------
70-
offset_values : NDArray[np.float64]
71-
Array of shape (2,) containing the horizontal and vertical
72-
offsets to set for the BPM
73-
"""
74-
pass
75-
7615
@abstractmethod
7716
def get_pos_devices(self) -> list[DeviceAccess]:
7817
"""
@@ -86,7 +25,7 @@ def get_pos_devices(self) -> list[DeviceAccess]:
8625
pass
8726

8827
@abstractmethod
89-
def get_tilt_device(self) -> DeviceAccess:
28+
def get_tilt_device(self) -> DeviceAccess | None:
9029
"""
9130
Get device handle used for tilt access
9231

pyaml/bpm/bpm_simple_model.py

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -28,66 +28,9 @@ class BPMSimpleModel(BPMModel):
2828

2929
def __init__(self, cfg: ConfigModel):
3030
self._cfg = cfg
31-
3231
self.__x_pos = cfg.x_pos
3332
self.__y_pos = cfg.y_pos
3433

35-
def read_position(self) -> NDArray:
36-
"""
37-
Simulate reading the position values from a BPM.
38-
Returns
39-
-------
40-
np.ndarray
41-
Array of shape (2,) containing the horizontal and vertical
42-
positions
43-
"""
44-
return np.array([self.__x_pos.get(), self.__y_pos.get()])
45-
46-
def read_tilt(self) -> float:
47-
"""
48-
Simulate reading the tilt value from a BPM.
49-
Returns
50-
-------
51-
float
52-
The tilt value of the BPM
53-
"""
54-
raise NotImplementedError("Tilt reading not implemented in this model.")
55-
56-
def read_offset(self) -> NDArray:
57-
"""
58-
Simulate reading the offset values from a BPM.
59-
Returns
60-
-------
61-
np.ndarray
62-
Array of shape (2,) containing the horizontal and vertical
63-
offsets
64-
"""
65-
raise NotImplementedError("Offset reading not implemented in this model.")
66-
67-
def set_tilt(self, tilt: float):
68-
"""
69-
Simulate setting the tilt value of a BPM.
70-
Parameters
71-
----------
72-
tilt : float
73-
The tilt value to set for the BPM
74-
Returns
75-
-------
76-
None
77-
"""
78-
raise NotImplementedError("Tilt setting not implemented in this model.")
79-
80-
def set_offset(self, offset_values: np.ndarray):
81-
"""
82-
Simulate setting the offset values of a BPM
83-
Parameters
84-
----------
85-
offset_values : np.ndarray
86-
Array of shape (2,) containing the horizontal and vertical
87-
offsets to set for the BPM
88-
"""
89-
raise NotImplementedError("Offset setting not implemented in this model.")
90-
9134
def get_pos_devices(self) -> list[DeviceAccess]:
9235
"""
9336
Get device handles used for position reading
@@ -108,7 +51,7 @@ def get_tilt_device(self) -> DeviceAccess:
10851
list[DeviceAccess]
10952
Array of DeviceAcess
11053
"""
111-
return []
54+
return None
11255

11356
def get_offset_devices(self) -> list[DeviceAccess]:
11457
"""
@@ -119,7 +62,7 @@ def get_offset_devices(self) -> list[DeviceAccess]:
11962
list[DeviceAccess]
12063
Array of DeviceAcess
12164
"""
122-
return []
65+
return [None, None]
12366

12467
def __repr__(self):
12568
return __pyaml_repr__(self)

pyaml/bpm/bpm_tiltoffset_model.py

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -41,52 +41,6 @@ def __init__(self, cfg: ConfigModel):
4141
self.__y_offset = cfg.y_offset
4242
self.__tilt = cfg.tilt
4343

44-
def read_tilt(self) -> float:
45-
"""
46-
Simulate reading the tilt value from a BPM.
47-
Returns
48-
-------
49-
float
50-
The tilt value of the BPM
51-
"""
52-
return self.__tilt.get()
53-
54-
def read_offset(self) -> NDArray:
55-
"""
56-
Simulate reading the offset values from a BPM.
57-
Returns
58-
-------
59-
np.ndarray
60-
Array of shape (2,) containing the horizontal and vertical
61-
offsets
62-
"""
63-
return np.array([self.__x_offset.get(), self.__y_offset.get()])
64-
65-
def set_tilt(self, tilt: float):
66-
"""
67-
Simulate setting the tilt value of a BPM.
68-
Parameters
69-
----------
70-
tilt : float
71-
The tilt value to set for the BPM
72-
Returns
73-
-------
74-
None
75-
"""
76-
self.__tilt.set(tilt)
77-
78-
def set_offset(self, offset_values: np.ndarray):
79-
"""
80-
Simulate setting the offset values of a BPM
81-
Parameters
82-
----------
83-
offset_values : np.ndarray
84-
Array of shape (2,) containing the horizontal and vertical
85-
offsets to set for the BPM
86-
"""
87-
self.__x_offset.set(offset_values[0])
88-
self.__y_offset.set(offset_values[1])
89-
9044
def get_pos_devices(self) -> list[DeviceAccess]:
9145
"""
9246
Get device handles used for position reading
@@ -107,7 +61,7 @@ def get_tilt_device(self) -> DeviceAccess:
10761
DeviceAccess
10862
DeviceAcess
10963
"""
110-
return [self.__tilt]
64+
return self.__tilt
11165

11266
def get_offset_devices(self) -> list[DeviceAccess]:
11367
"""

0 commit comments

Comments
 (0)