Skip to content

Commit

Permalink
Refactor PvaDictConverter to be less PVI specific
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Feb 19, 2024
1 parent 348438f commit 5ab25c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/ophyd_async/epics/_backend/_p4p.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,13 @@ def descriptor(self, source: str, value) -> Descriptor:
return dict(source=source, dtype="object", shape=[]) # type: ignore


class PvaStructureConverter(PvaConverter):
class PvaDictConverter(PvaConverter):

def value(self, value):
return value.get("pvi")
return value

def descriptor(self, source: str, value) -> Descriptor:
# This is wrong, but defer until we know how to actually describe a structure
return dict(source=source, dtype="object", shape=[]) # type: ignore
raise NotImplementedError("Describing Dict signals not currently supported")


class DisconnectedPvaConverter(PvaConverter):
Expand Down Expand Up @@ -216,7 +215,7 @@ def make_converter(datatype: Optional[Type], values: Dict[str, Any]) -> PvaConve
elif "NTTable" in typeid:
return PvaTableConverter()
elif "structure" in typeid:
return PvaStructureConverter()
return PvaDictConverter()
else:
raise TypeError(f"{pv}: Unsupported typeid {typeid}")

Expand Down
4 changes: 2 additions & 2 deletions src/ophyd_async/epics/pvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ async def pvi_get(
timeout, and therefore can be used for error reporting."""
backend: SignalBackend = PvaSignalBackend(None, read_pv, read_pv)
await backend.connect(timeout=timeout)
pv_info: Dict[str, Dict[str, str]] = await backend.get_value()

d: Dict[str, Dict[str, Dict[str, str]]] = await backend.get_value()
pv_info = d.get("pvi") or {}
result = {}

for attr_name, attr_info in pv_info.items():
Expand Down

0 comments on commit 5ab25c0

Please sign in to comment.