Skip to content

Commit

Permalink
Add a hint to PandA if we can't find a block (#668)
Browse files Browse the repository at this point in the history
* Add a hint to PandA if we can't find a block

* Address review comments
  • Loading branch information
coretl authored and evalott100 committed Nov 27, 2024
1 parent 2d23de8 commit a236d26
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ Fixes #ISSUE

### Checks for reviewer
- [ ] Would the PR title make sense to a user on a set of release notes
- [ ] If the change requires a bump in an IOC version, is that specified in a `##Changes` section in the body of the PR
- [ ] If the change requires a bump in the PandABlocks-ioc version, is the `ophyd_async.fastcs.panda._hdf_panda.MINIMUM_PANDA_IOC` variable updated to match
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
5 changes: 4 additions & 1 deletion src/ophyd_async/fastcs/panda/_hdf_panda.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from ._control import PandaPcapController
from ._writer import PandaHDFWriter

MINIMUM_PANDA_IOC = "0.11.4"


class HDFPanda(CommonPandaBlocks, StandardDetector):
def __init__(
Expand All @@ -18,8 +20,9 @@ def __init__(
config_sigs: Sequence[SignalR] = (),
name: str = "",
):
error_hint = f"Is PandABlocks-ioc at least version {MINIMUM_PANDA_IOC}?"
# This has to be first so we make self.pcap
connector = fastcs_connector(self, prefix)
connector = fastcs_connector(self, prefix, error_hint)
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

0 comments on commit a236d26

Please sign in to comment.