Skip to content

Commit

Permalink
NDArray: More explicit docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Willemsen committed Sep 4, 2023
1 parent 527ac82 commit be269a7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ophyd/v2/_p4p.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ def descriptor(self, source: str, value) -> Descriptor:

def metadata_fields(self) -> List[str]:
"""
PVA request string for metadata.
Fields to request from PVA for metadata.
"""
return ["alarm", "timeStamp"]

def value_fields(self) -> List[str]:
"""
PVA request string for value only.
Fields to request from PVA for the value.
"""
return ["value"]

Expand Down Expand Up @@ -260,6 +260,10 @@ async def get_descriptor(self) -> Descriptor:
return self.converter.descriptor(self.source, value)

def _pva_request_string(self, fields: List[str]) -> str:
"""
Converts a list of requested fields into a PVA request string which can be
passed to p4p.
"""
return f"field({','.join(fields)})"

async def get_reading(self) -> Reading:
Expand All @@ -283,8 +287,12 @@ def set_callback(self, callback: Optional[ReadingValueCallback[T]]) -> None:
async def async_callback(v):
callback(self.converter.reading(v), self.converter.value(v))

request: str = self._pva_request_string(
self.converter.value_fields() + self.converter.metadata_fields()
)

self.subscription = self.ctxt.monitor(
self.read_pv, async_callback, request="field(value,alarm,timeStamp)"
self.read_pv, async_callback, request=request
)
else:
if self.subscription:
Expand Down

0 comments on commit be269a7

Please sign in to comment.