Skip to content

Commit

Permalink
added :LABEL to fields from metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
evalott100 committed Nov 11, 2024
1 parent 2a4f5c2 commit 45d17c7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/fastcs_pandablocks/panda/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,23 @@ def __init__(self, hostname: str, poll_period: float) -> None:
self._raw_panda = RawPanda(hostname)
self._blocks: dict[PandaName, FieldController] = {}

self.connected = False

super().__init__()

@property
def additional_attributes(self):
return self._additional_attributes

async def connect(self) -> None:
if self.connected:
# `connect` needs to be called in `initialise`,
# then FastCS will attempt to call it again.
return
await self._raw_panda.connect()
blocks, fields, labels, initial_values = await self._raw_panda.introspect()
self._blocks = _parse_introspected_data(blocks, fields, labels, initial_values)
self.connected = True

async def initialise(self) -> None:
await self.connect()
Expand Down Expand Up @@ -109,6 +116,7 @@ async def update_field_value(self, panda_name: PandaName, value: str):

@scan(0.1)
async def update(self):
raise RuntimeError("FINALLY CALLED!")
changes = await self._raw_panda.get_changes()
await asyncio.gather(
*[
Expand Down
9 changes: 8 additions & 1 deletion src/fastcs_pandablocks/panda/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def __init__(

self._additional_attributes: dict[str, Attribute] = {}

if label is not None:
self._additional_attributes["label"] = AttrR(
String(),
description="Label from metadata.",
initial_value=label,
)

super().__init__(search_device_for_attributes=False)

def make_sub_fields(
Expand Down Expand Up @@ -641,7 +648,7 @@ def __init__(
super().__init__(panda_name)

# We use a raw string for this since many labels won't fit into
# mbbIn fields because of EPICS limitations.
# `mbbIn` fields because of EPICS limitations.
# Since this is read only it doesn't matter.
self.top_level_attribute = AttrR(
String(),
Expand Down

0 comments on commit 45d17c7

Please sign in to comment.