Skip to content

Commit

Permalink
Merge pull request #149 from PandABlocks/639-removed-access-from-rows
Browse files Browse the repository at this point in the history
Removed access from table rows
  • Loading branch information
evalott100 authored Nov 8, 2024
2 parents 355a6ab + 5a7f3f4 commit 1e1e8cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/pandablocks_ioc/_pvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,28 @@ def _extract_number_at_end_of_string(

def q_group_formatter(
panda_field: str,
access: str,
access: str | None,
channel: Literal["VAL", "NAME"],
other_fields: dict[str, str] | None = None,
vectorize: bool = True,
) -> dict:
other_fields = other_fields or {}

panda_field_lower = panda_field.lower().replace(":", "_")
access_name = "" if access is None else f".{access}"

# Backwards compatible `pvi.someblock1` field.
pvi_field = f"pvi.{panda_field_lower}.{access}"
pvi_field = f"pvi.{panda_field_lower}{access_name}"

# New `value.someblock[1]` field.
if vectorize:
stripped_name, stripped_number = _extract_number_at_end_of_string(
panda_field_lower
)
value_number = "" if stripped_number is None else f"[{stripped_number}]"
value_field = f"value.{stripped_name}{value_number}.{access}"
value_field = f"value.{stripped_name}{value_number}{access_name}"
else:
value_field = f"value.{panda_field_lower}.{access}"
value_field = f"value.{panda_field_lower}{access_name}"

return {
block_name_suffixed: {
Expand Down
2 changes: 1 addition & 1 deletion src/pandablocks_ioc/_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def set_rows(
"Q:group",
{
self.pva_table_name: q_group_formatter(
pva_row_name, "r", "VAL", other_fields=trigger
pva_row_name, None, "VAL", other_fields=trigger
)
},
)
Expand Down

0 comments on commit 1e1e8cd

Please sign in to comment.