Skip to content

Commit

Permalink
Merge pull request DiamondLightSource/hyperion#1180 from DiamondLight…
Browse files Browse the repository at this point in the history
…Source/1178_setup_panda_PCAP

Panda grid scans: Set up position capture
  • Loading branch information
DominicOram authored Feb 28, 2024
2 parents ef593ec + dadb78a commit 2a0c334
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/hyperion/device_setup_plans/setup_panda.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class Enabled(Enum):
DISABLED = "ZERO"


class PcapArm(Enum):
ARMED = "Arm"
DISARMED = "Disarm"


def get_seq_table(
parameters: PandAGridScanParams,
exposure_distance_mm,
Expand Down Expand Up @@ -154,6 +159,9 @@ def setup_panda_for_flyscan(

yield from bps.abs_set(panda.seq[1].table, table, group="panda-config")

# Wait here since we need PCAP to be enabled before armed
yield from bps.abs_set(panda.pcap.enable, Enabled.ENABLED.value, wait=True) # type: ignore

yield from arm_panda_for_gridscan(panda, group="panda-config")

yield from bps.wait(group="panda-config", timeout=GENERAL_TIMEOUT)
Expand All @@ -163,14 +171,17 @@ def arm_panda_for_gridscan(panda: PandA, group="arm_panda_gridscan"):
yield from bps.abs_set(panda.seq[1].enable, Enabled.ENABLED.value, group=group) # type: ignore
yield from bps.abs_set(panda.pulse[1].enable, Enabled.ENABLED.value, group=group) # type: ignore
yield from bps.abs_set(panda.counter[1].enable, Enabled.ENABLED.value, group=group) # type: ignore
yield from bps.abs_set(panda.pcap.arm, PcapArm.ARMED.value, group=group) # type: ignore


def disarm_panda_for_gridscan(panda, group="disarm_panda_gridscan") -> MsgGenerator:
yield from bps.abs_set(panda.pcap.arm, PcapArm.DISARMED.value, group=group) # type: ignore
yield from bps.abs_set(panda.counter[1].enable, Enabled.DISABLED.value, group=group) # type: ignore
yield from bps.abs_set(panda.seq[1].enable, Enabled.DISABLED.value, group=group)
yield from bps.abs_set(
panda.clock[1].enable, Enabled.DISABLED.value, group=group
) # While disarming the clock shouldn't be necessery,
# it will stop the eiger continuing to trigger if something in the sequencer table goes wrong
yield from bps.abs_set(panda.pulse[1].enable, Enabled.DISABLED.value, group=group)
yield from bps.abs_set(panda.pcap.enable, Enabled.DISABLED.value, group=group) # type: ignore
yield from bps.wait(group=group, timeout=GENERAL_TIMEOUT)
6 changes: 3 additions & 3 deletions tests/unit_tests/device_setup_plans/test_setup_panda.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def test_setup_panda_performs_correct_plans(mock_load_device):
"setup", mock_load_device
)
mock_load_device.assert_called_once()
assert num_of_sets == 7
assert num_of_waits == 2
assert num_of_sets == 9
assert num_of_waits == 3


@pytest.mark.parametrize(
Expand Down Expand Up @@ -156,5 +156,5 @@ def test_setup_panda_correctly_configures_table(
# all the blocks which were enabled on setup are also disabled on tidyup
def test_disarm_panda_disables_correct_blocks():
num_of_sets, num_of_waits = run_simulating_setup_panda_functions("disarm")
assert num_of_sets == 4
assert num_of_sets == 6
assert num_of_waits == 1

0 comments on commit 2a0c334

Please sign in to comment.