diff --git a/tests/config/bpms.yaml b/tests/config/bpms.yaml index ec190c7d..b68f02c9 100644 --- a/tests/config/bpms.yaml +++ b/tests/config/bpms.yaml @@ -18,11 +18,11 @@ instruments: model: type: pyaml.bpm.bpm_tiltoffset_model x_pos: - type: tango.pyaml.attribute + type: tango.pyaml.attribute_read_only attribute: srdiag/bpm/c01-01/SA_HPosition unit: mm y_pos: - type: tango.pyaml.attribute + type: tango.pyaml.attribute_read_only attribute: srdiag/bpm/c01-01/SA_VPosition unit: mm x_offset: @@ -42,11 +42,11 @@ instruments: model: type: pyaml.bpm.bpm_simple_model x_pos: - type: tango.pyaml.attribute + type: tango.pyaml.attribute_read_only attribute: srdiag/bpm/c01-02/SA_HPosition unit: mm y_pos: - type: tango.pyaml.attribute + type: tango.pyaml.attribute_read_only attribute: srdiag/bpm/c01-02/SA_VPosition unit: mm - type: pyaml.bpm.bpm @@ -54,11 +54,11 @@ instruments: model: type: pyaml.bpm.bpm_simple_model x_pos: - type: tango.pyaml.attribute + type: tango.pyaml.attribute_read_only attribute: srdiag/bpm/c01-03/SA_HPosition unit: mm y_pos: - type: tango.pyaml.attribute + type: tango.pyaml.attribute_read_only attribute: srdiag/bpm/c01-03/SA_VPosition unit: mm - type: pyaml.magnet.cfm_magnet diff --git a/tests/dummy_cs/tango/tango/pyaml/attribute_read_only.py b/tests/dummy_cs/tango/tango/pyaml/attribute_read_only.py new file mode 100644 index 00000000..cce5bcff --- /dev/null +++ b/tests/dummy_cs/tango/tango/pyaml/attribute_read_only.py @@ -0,0 +1,46 @@ +from pydantic import BaseModel,ConfigDict +from pyaml.control.deviceaccess import DeviceAccess +from pyaml.control.readback_value import Value + +PYAMLCLASS : str = "AttributeReadOnly" + +class ConfigModel(BaseModel): + + model_config = ConfigDict(arbitrary_types_allowed=True,extra="forbid") + + attribute: str + unit: str = "" + +class AttributeReadOnly(DeviceAccess): + """ + Class that implements a default device class that just prints out + values (Debugging purpose) + """ + def __init__(self, cfg: ConfigModel): + super().__init__() + self._cfg = cfg + self._setpoint = cfg.attribute + self._readback = cfg.attribute + self._unit = cfg.unit + self._cache = 0.0 + + def name(self) -> str: + return self._setpoint + + def measure_name(self) -> str: + return self._readback + + def set(self, value: float): + raise Exception(f"{self._cfg.attribute} is read only attribute") + + def set_and_wait(self, value: float): + raise Exception(f"{self._cfg.attribute} is read only attribute") + + def get(self) -> float: + return self._cache + + def readback(self) -> Value: + return Value(self._cache) + + def unit(self) -> str: + return self._unit