Skip to content

Commit 6cc2ef4

Browse files
committed
added option to add attributes through a method on the controller
1 parent cdc2dcf commit 6cc2ef4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/fastcs/controller.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ def __init__(self, path: list[str] | None = None) -> None:
1212

1313
self._bind_attrs()
1414

15+
@property
16+
def additional_attributes(self) -> dict[str, Attribute] | None:
17+
"""FastCS will look for attributes on the controller, but additional attribtues
18+
be provided here."""
19+
return None
20+
1521
@property
1622
def path(self) -> list[str]:
1723
"""Path prefix of attributes, recursively including parent ``Controller``s."""

src/fastcs/mapping.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ def _get_single_mapping(controller: BaseController) -> SingleMapping:
5454
case Attribute(enabled=True):
5555
attributes[attr_name] = attr
5656

57+
attributes.update(controller.additional_attributes or {})
58+
5759
return SingleMapping(
5860
controller, scan_methods, put_methods, command_methods, attributes
5961
)

0 commit comments

Comments
 (0)