Skip to content

Commit 129288a

Browse files
committed
made update_period optional on Updater
1 parent 111287a commit 129288a

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

src/fastcs/attributes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ async def put(self, controller: Any, attr: AttrW, value: Any) -> None:
2626
class Updater(Protocol):
2727
"""Protocol for updating the cached readback value of an ``Attribute``."""
2828

29-
update_period: float
29+
# If update period is None then the attribute will not be updated as a task.
30+
update_period: float | None
3031

3132
async def update(self, controller: Any, attr: AttrR) -> None:
3233
pass

src/fastcs/backend.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def _add_attribute_updater_tasks(
124124
for attribute in single_mapping.attributes.values():
125125
match attribute:
126126
case AttrR(updater=Updater(update_period=update_period)) as attribute:
127+
if update_period is None:
128+
continue
127129
callback = _create_updater_callback(
128130
attribute, single_mapping.controller
129131
)

src/fastcs/backends/epics/gui.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
from pydantic import ValidationError
2828

2929
from fastcs.attributes import Attribute, AttrR, AttrRW, AttrW
30-
from fastcs.backends.epics.util import EpicsNameOptions, _convert_attribute_name_to_pv_name
30+
from fastcs.backends.epics.util import (
31+
EpicsNameOptions,
32+
_convert_attribute_name_to_pv_name,
33+
)
3134
from fastcs.cs_methods import Command
3235
from fastcs.datatypes import Bool, Float, Int, String
3336
from fastcs.exceptions import FastCSException
@@ -65,13 +68,17 @@ def _get_pv(self, attr_path: list[str], name: str):
6568
]
6669
+ [
6770
_convert_attribute_name_to_pv_name(
68-
attr_name, self.epics_name_options.pv_naming_convention, is_attribute=False
71+
attr_name,
72+
self.epics_name_options.pv_naming_convention,
73+
is_attribute=False,
6974
)
7075
for attr_name in attr_path
7176
]
7277
+ [
7378
_convert_attribute_name_to_pv_name(
74-
name, self.epics_name_options.pv_naming_convention, is_attribute=True
79+
name,
80+
self.epics_name_options.pv_naming_convention,
81+
is_attribute=True,
7582
),
7683
],
7784
)

src/fastcs/backends/epics/ioc.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class EpicsIOCOptions:
3030
name_options: EpicsNameOptions = EpicsNameOptions()
3131

3232

33-
3433
class EpicsIOC:
3534
def __init__(
3635
self, pv_prefix: str, mapping: Mapping, options: EpicsIOCOptions | None = None
@@ -74,7 +73,7 @@ def _add_sub_controller_pvi_info(self, pv_prefix: str, parent: BaseController):
7473
_convert_attribute_name_to_pv_name(
7574
path,
7675
self._name_options.pv_naming_convention,
77-
is_attribute=False
76+
is_attribute=False,
7877
)
7978
for path in child.path
8079
]
@@ -96,7 +95,9 @@ def _create_and_link_attribute_pvs(self, pv_prefix: str, mapping: Mapping) -> No
9695
]
9796
for attr_name, attribute in single_mapping.attributes.items():
9897
pv_name = _convert_attribute_name_to_pv_name(
99-
attr_name, self._name_options.pv_naming_convention, is_attribute=True
98+
attr_name,
99+
self._name_options.pv_naming_convention,
100+
is_attribute=True,
100101
)
101102
_pv_prefix = self._name_options.pv_separator.join(
102103
[pv_prefix] + formatted_path
@@ -169,7 +170,9 @@ def _create_and_link_command_pvs(self, pv_prefix: str, mapping: Mapping) -> None
169170
]
170171
for attr_name, method in single_mapping.command_methods.items():
171172
pv_name = _convert_attribute_name_to_pv_name(
172-
attr_name, self._name_options.pv_naming_convention, is_attribute=True
173+
attr_name,
174+
self._name_options.pv_naming_convention,
175+
is_attribute=True,
173176
)
174177
_pv_prefix = self._name_options.pv_separator.join(
175178
[pv_prefix] + formatted_path

src/fastcs/backends/epics/util.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,16 @@ def _convert_attribute_name_to_pv_name(
5151
return attr_name.title().replace("_", "")
5252
elif naming_convention == PvNamingConvention.CAPITALIZED:
5353
return attr_name.upper().replace("_", "-")
54-
elif naming_convention == PvNamingConvention.CAPITALIZED_CONTROLLER_PASCAL_ATTRIBUTE:
54+
elif (
55+
naming_convention == PvNamingConvention.CAPITALIZED_CONTROLLER_PASCAL_ATTRIBUTE
56+
):
5557
if is_attribute:
56-
return _convert_attribute_name_to_pv_name(attr_name, PvNamingConvention.PASCAL, is_attribute)
57-
return _convert_attribute_name_to_pv_name(attr_name, PvNamingConvention.CAPITALIZED)
58+
return _convert_attribute_name_to_pv_name(
59+
attr_name, PvNamingConvention.PASCAL, is_attribute
60+
)
61+
return _convert_attribute_name_to_pv_name(
62+
attr_name, PvNamingConvention.CAPITALIZED
63+
)
5864
return attr_name
5965

6066

0 commit comments

Comments
 (0)