Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pyaml/bpm/bpm.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
"""Beam-position monitor elements and their runtime interfaces."""

import copy
from typing import Self
from typing import TYPE_CHECKING, Self

from ..common.abstract import ReadFloatArray, ReadWriteFloatArray, ReadWriteFloatScalar
from ..common.element import Element, __pyaml_repr__
from ..common.exception import PyAMLException
from ..validation import DynamicValidation, register_schema

if TYPE_CHECKING:
from ..common.holders.element_holder import ElementHolder

PYAMLCLASS = "BPM"


Expand Down Expand Up @@ -176,7 +179,7 @@ def attach(
obj._peer = peer
return obj

def _fill_device(self, holder) -> None:
def _fill_device(self, holder: "ElementHolder") -> None:
holder._fill_bpm(self)

def get_pos_devices(self) -> list[str | None]:
Expand Down
6 changes: 6 additions & 0 deletions pyaml/common/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ def attached_to(self) -> str:
"""
return "None" if self._peer is None else f"{self._peer.__class__.__name__}:{self._peer.name()}"

def _fill_device(self, holder: "ElementHolder"):
"""
Add this element to a holder (Simultor or ControlSystem)
"""
raise PyAMLException(f"__fill_device() is not implemented for {self.__class__.__name__}")

def post_init(self):
"""
Perform post-construction initialization after attachment.
Expand Down
7 changes: 6 additions & 1 deletion pyaml/configuration/unbound_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
known and the concrete element can be instantiated.
"""

from typing import TYPE_CHECKING

from pydantic import BaseModel

from ..common.element import Element
from ..common.exception import PyAMLConfigException

if TYPE_CHECKING:
from ..common.holders.element_holder import ElementHolder


class UnboundElement(Element):
"""
Expand Down Expand Up @@ -54,7 +59,7 @@ def __repr__(self):
self._module_name,
)

def _fill_device(self, holder) -> None:
def _fill_device(self, holder: "ElementHolder") -> None:
holder._fill_unbound_element(self)

def instantiate(self, holder) -> Element:
Expand Down
7 changes: 5 additions & 2 deletions pyaml/diagnostics/tune_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

import copy
from typing import Self
from typing import TYPE_CHECKING, Self

from numpy.typing import NDArray

Expand All @@ -15,6 +15,9 @@
from ..validation import DynamicValidation, register_schema
from .atune_monitor import ABetatronTuneMonitor

if TYPE_CHECKING:
from ..common.holders.element_holder import ElementHolder

PYAMLCLASS = "BetatronTuneMonitor"


Expand Down Expand Up @@ -90,7 +93,7 @@ def set_harmonic(self, h: int):
"""
self._h = float(h)

def _fill_device(self, holder) -> None:
def _fill_device(self, holder: "ElementHolder") -> None:
holder._fill_betatron_tune_monitor(self)

@property
Expand Down
7 changes: 6 additions & 1 deletion pyaml/magnet/cfm_magnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
provide separate strength and hardware access for those components.
"""

from typing import TYPE_CHECKING

from scipy.constants import speed_of_light

from ..common import abstract
Expand All @@ -24,6 +26,9 @@
from .skewsext import SkewSext
from .vcorrector import VCorrector

if TYPE_CHECKING:
from ..common.holders.element_holder import ElementHolder

_fmap: dict = {
"B0": HCorrector,
"A0": VCorrector,
Expand Down Expand Up @@ -131,7 +136,7 @@ def __init__(
# Attach
self._peer = peer

def _fill_device(self, holder) -> None:
def _fill_device(self, holder: "ElementHolder") -> None:
holder._fill_combined_function_magnet(self)

def get_model_name(self) -> str:
Expand Down
7 changes: 5 additions & 2 deletions pyaml/magnet/magnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

import copy
from typing import Self
from typing import TYPE_CHECKING, Self

import numpy as np
from scipy.constants import speed_of_light
Expand All @@ -16,6 +16,9 @@
from ..common.element import Element
from .model import MagnetModel

if TYPE_CHECKING:
from ..common.holders.element_holder import ElementHolder


class Magnet(Element):
"""
Expand Down Expand Up @@ -131,7 +134,7 @@ def attach(
obj._peer = peer
return obj

def _fill_device(self, holder) -> None:
def _fill_device(self, holder: "ElementHolder") -> None:
holder._fill_magnet(self)

def set_energy(self, energy: float):
Expand Down
7 changes: 6 additions & 1 deletion pyaml/magnet/serialized_magnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
This module defines magnet elements composed of multiple serialized magnets.
"""

from typing import TYPE_CHECKING

import numpy as np
from scipy.constants import speed_of_light

Expand All @@ -16,6 +18,9 @@
from .magnet import Magnet
from .model import MagnetModel

if TYPE_CHECKING:
from ..common.holders.element_holder import ElementHolder

# Define the main class name for this module
PYAMLCLASS = "SerializedMagnets"

Expand Down Expand Up @@ -257,7 +262,7 @@ def __init__(
# Attach
self._peer = peer

def _fill_device(self, holder) -> None:
def _fill_device(self, holder: "ElementHolder") -> None:
holder._fill_serialized_magnets(self)

def __create_virtual_magnet(self, name: str) -> Magnet:
Expand Down
7 changes: 5 additions & 2 deletions pyaml/rf/rf_plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
"""

import copy
from typing import Self
from typing import TYPE_CHECKING, Self

from .. import PyAMLException
from ..common import abstract
from ..common.element import Element, __pyaml_repr__
from ..validation import DynamicValidation, register_schema
from .rf_transmitter import RFTransmitter

if TYPE_CHECKING:
from ..common.holders.element_holder import ElementHolder

# Define the main class name for this module
PYAMLCLASS = "RFPlant"

Expand Down Expand Up @@ -115,7 +118,7 @@ def attach(
obj._peer = peer
return obj

def _fill_device(self, holder) -> None:
def _fill_device(self, holder: "ElementHolder") -> None:
holder._fill_rf_plant(self)


Expand Down
Loading