-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bmp element model reworked for libera bpms
- Loading branch information
1 parent
0f93f33
commit afe7feb
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import functools | ||
from dataclasses import dataclass | ||
|
||
from typing import Sequence, Union | ||
|
||
|
||
@dataclass | ||
class BPMElementPosition: | ||
#: in nanometer | ||
x: int | ||
#: in nanometer | ||
y: int | ||
|
||
|
||
@dataclass | ||
class BPMElementSignalFromButtons: | ||
"""Beam position monitor readings from the buttons | ||
Todo: | ||
find out what the units of these signals are in reality | ||
""" | ||
a: int | ||
b: int | ||
c: int | ||
d: int | ||
|
||
|
||
@dataclass | ||
class BPMElement: | ||
name: str | ||
pos: BPMElementPosition | ||
sig: Union[BPMElementSignalFromButtons, None] | ||
|
||
|
||
@dataclass | ||
class BPMElementList: | ||
bpms: Sequence[BPMElement] | ||
|
||
def get_eleement(self, name: str) -> BPMElement: | ||
@functools.lru_cache(maxsize=1) | ||
def get_dict(): | ||
return {elem.name: elem for elem in self.bpms} | ||
|
||
return get_dict()[name] |