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 sleep to gridscan validity check #503

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
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
3 changes: 1 addition & 2 deletions src/mx_bluesky/hyperion/device_setup_plans/setup_panda.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
MM_TO_ENCODER_COUNTS = 200000
GENERAL_TIMEOUT = 60
TICKS_PER_MS = 1000 # Panda sequencer prescaler will be set to us
PULSE_WIDTH_US = 50
olliesilvester marked this conversation as resolved.
Show resolved Hide resolved


class Enabled(Enum):
Expand Down Expand Up @@ -78,8 +79,6 @@ def _get_seq_table(

delay_between_pulses = time_between_steps_ms * TICKS_PER_MS

PULSE_WIDTH_US = 1

assert delay_between_pulses > PULSE_WIDTH_US

# BITA_1 trigger wired from TTLIN1, this is the trigger input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ def wait_for_gridscan_valid(fgs_motors: FastGridScanCommon, timeout=0.5):
LOGGER.info("Waiting for valid fgs_params")
SLEEP_PER_CHECK = 0.1
times_to_check = int(timeout / SLEEP_PER_CHECK)
yield from bps.sleep(0.1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: I think I would like to be certain this is the issue before we introduce new sleeps. Can you test it out on the hardware? If this is the issue we should probably spend a bit of time thinking about a cleaner way of handling it, maybe by pushing it into the device more

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I can try and test this on a Tuesday, I guess by forcing Hyperion to go from valid to invalid params every time. The scan invalid PV is added to the archiver too now, which should help

for _ in range(times_to_check):
scan_invalid = yield from bps.rd(fgs_motors.scan_invalid)
pos_counter = yield from bps.rd(fgs_motors.position_counter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from mx_bluesky.hyperion.device_setup_plans.setup_panda import (
MM_TO_ENCODER_COUNTS,
PULSE_WIDTH_US,
disarm_panda_for_gridscan,
set_panda_directory,
setup_panda_for_flyscan,
Expand Down Expand Up @@ -139,8 +140,6 @@ def test_setup_panda_correctly_configures_table(
][0]

table = table_msg.args[0]

PULSE_WIDTH_US = 1
SPACE_WIDTH_US = int(time_between_x_steps_ms * 1000 - PULSE_WIDTH_US)
expected_seq_rows: list[SeqRow] = [
SeqRow(1, SeqTrigger.BITA_1, 0, 0, 0, 1, 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ def wrapped_gridscan_and_move():
"mx_bluesky.hyperion.experiment_plans.flyscan_xray_centre_plan.bps.sleep",
autospec=True,
)
def test_GIVEN_scan_already_valid_THEN_wait_for_GRIDSCAN_returns_immediately(
def test_GIVEN_scan_already_valid_THEN_wait_for_GRIDSCAN_returns_after_short_sleep(
self, patch_sleep: MagicMock, RE: RunEngine
):
test_fgs: ZebraFastGridScan = i03.zebra_fast_grid_scan(fake_with_ophyd_sim=True)
Expand All @@ -838,7 +838,7 @@ def test_GIVEN_scan_already_valid_THEN_wait_for_GRIDSCAN_returns_immediately(

RE(wait_for_gridscan_valid(test_fgs))

patch_sleep.assert_not_called()
patch_sleep.assert_called_once_with(0.1)

@patch(
"mx_bluesky.hyperion.experiment_plans.flyscan_xray_centre_plan.bps.sleep",
Expand Down