Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a hint to PandA if we can't find a block #668

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/ophyd_async/epics/core/_pvi_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ def _get_signal_details(entry: Entry) -> tuple[type[Signal], str, str]:


class PviDeviceConnector(DeviceConnector):
def __init__(self, prefix: str = "") -> None:
def __init__(self, prefix: str = "", error_hint: str = "") -> None:
# TODO: what happens if we get a leading "pva://" here?
self.prefix = prefix
self.pvi_pv = prefix + "PVI"
self.error_hint = error_hint

def create_children_from_annotations(self, device: Device):
if not hasattr(self, "filler"):
Expand Down Expand Up @@ -85,7 +86,8 @@ async def connect_real(
if e:
self._fill_child(name, e, i)
# Check that all the requested children have been filled
self.filler.check_filled(f"{self.pvi_pv}: {entries}")
suffix = f"\n{self.error_hint}" if self.error_hint else ""
self.filler.check_filled(f"{self.pvi_pv}: {entries}{suffix}")
# Set the name of the device to name all children
device.set_name(device.name)
return await super().connect_real(device, timeout, force_reconnect)
4 changes: 2 additions & 2 deletions src/ophyd_async/fastcs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from ophyd_async.epics.core import PviDeviceConnector


def fastcs_connector(device: Device, uri: str) -> DeviceConnector:
def fastcs_connector(device: Device, uri: str, error_hint: str = "") -> DeviceConnector:
# TODO: add Tango support based on uri scheme
connector = PviDeviceConnector(uri)
connector = PviDeviceConnector(uri, error_hint)
connector.create_children_from_annotations(device)
return connector
4 changes: 3 additions & 1 deletion src/ophyd_async/fastcs/panda/_hdf_panda.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def __init__(
name: str = "",
):
# This has to be first so we make self.pcap
connector = fastcs_connector(self, prefix)
connector = fastcs_connector(
self, prefix, error_hint="Is PandABlocks-ioc at least version 0.11.4?"
coretl marked this conversation as resolved.
Show resolved Hide resolved
)
controller = PandaPcapController(pcap=self.pcap)
writer = PandaHDFWriter(
path_provider=path_provider,
Expand Down
6 changes: 4 additions & 2 deletions tests/fastcs/panda/test_panda_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class CommonPandaBlocksNoData(Device):

class Panda(CommonPandaBlocksNoData):
def __init__(self, uri: str, name: str = ""):
super().__init__(name=name, connector=fastcs_connector(self, uri))
super().__init__(
name=name, connector=fastcs_connector(self, uri, "Is it ok?")
)

yield Panda

Expand Down Expand Up @@ -124,7 +126,7 @@ async def test_panda_with_missing_blocks(panda_pva, panda_t):
match=re.escape(
"mypanda: cannot provision ['pcap'] from PANDAQSRVI:PVI: "
"{'pulse': [None, {'d': 'PANDAQSRVI:PULSE1:PVI'}],"
" 'seq': [None, {'d': 'PANDAQSRVI:SEQ1:PVI'}]}"
" 'seq': [None, {'d': 'PANDAQSRVI:SEQ1:PVI'}]}\nIs it ok?"
),
):
await panda.connect()
Expand Down