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
12 changes: 6 additions & 6 deletions tests/config/bpms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -42,23 +42,23 @@ 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
name: BPM_C01-03
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
Expand Down
46 changes: 46 additions & 0 deletions tests/dummy_cs/tango/tango/pyaml/attribute_read_only.py
Original file line number Diff line number Diff line change
@@ -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
Loading