From 41a6bec8de647720f1a0e751edd5cc5bf978b973 Mon Sep 17 00:00:00 2001 From: Robert Tuck Date: Wed, 7 Aug 2024 09:14:31 +0100 Subject: [PATCH] Simplify the sequencer table as per PR comment --- .../device_setup_plans/setup_panda.py | 36 ++++--------------- .../device_setup_plans/test_setup_panda.py | 28 ++------------- 2 files changed, 9 insertions(+), 55 deletions(-) diff --git a/src/hyperion/device_setup_plans/setup_panda.py b/src/hyperion/device_setup_plans/setup_panda.py index 4d169ff0b..567dceabd 100644 --- a/src/hyperion/device_setup_plans/setup_panda.py +++ b/src/hyperion/device_setup_plans/setup_panda.py @@ -46,13 +46,11 @@ def _get_seq_table( SEQUENCER TABLE: 1. Wait for physical trigger from motion script to mark start of scan / change of direction - 2. Wait for POSA (X2) to be greater than X_START and send 1 trigger - 3. Send out the remaining x_steps - 1 triggers every time_between_steps_ms - 4. Wait for physical trigger from motion script to mark change of direction - 5. Wait for POSA (X2) to be less than X_START + X_STEP_SIZE * x_steps + exposure distance, then - send 1 trigger - 6. Send the remaining x_steps - 1 triggers every time_between_steps_ms - 7. Go back to step one. + 2. Wait for POSA (X2) to be greater than X_START and send x_steps triggers every time_between_steps_ms + 3. Wait for physical trigger from motion script to mark change of direction + 4. Wait for POSA (X2) to be less than X_START + X_STEP_SIZE * x_steps + exposure distance, then + send x_steps triggers every time_between_steps_ms + 5. Go back to step one. For a more detailed explanation and a diagram, see https://github.com/DiamondLightSource/hyperion/wiki/PandA-constant%E2%80%90motion-scanning @@ -92,6 +90,7 @@ def _get_seq_table( rows.append( SeqTableRow( + repeats=num_pulses, trigger=SeqTrigger.POSA_GT, position=start_of_grid_x_counts, time1=PULSE_WIDTH_US, @@ -101,22 +100,12 @@ def _get_seq_table( ) ) - if num_pulses > 1: - rows.append( - SeqTableRow( - repeats=num_pulses - 1, # account for previous 1 pulse at start - time1=PULSE_WIDTH_US, - outa1=True, - time2=delay_between_pulses - PULSE_WIDTH_US, - outa2=False, - ) - ) - # -ve direction scan rows.append(SeqTableRow(trigger=SeqTrigger.BITA_1, time2=1)) rows.append( SeqTableRow( + repeats=num_pulses, trigger=SeqTrigger.POSA_LT, position=end_of_grid_x_counts + exposure_distance_x_counts, time1=PULSE_WIDTH_US, @@ -126,17 +115,6 @@ def _get_seq_table( ) ) - if num_pulses > 1: - rows.append( - SeqTableRow( - repeats=num_pulses - 1, # account for previous 1 pulse at start - time1=PULSE_WIDTH_US, - outa1=True, - time2=delay_between_pulses - PULSE_WIDTH_US, - outa2=False, - ) - ) - table = seq_table_from_rows(*rows) return table diff --git a/tests/unit_tests/device_setup_plans/test_setup_panda.py b/tests/unit_tests/device_setup_plans/test_setup_panda.py index 826bccfda..9d65efe24 100644 --- a/tests/unit_tests/device_setup_plans/test_setup_panda.py +++ b/tests/unit_tests/device_setup_plans/test_setup_panda.py @@ -137,7 +137,7 @@ def test_setup_panda_correctly_configures_table( expected_seq_rows: list[SeqRow] = [ SeqRow(1, SeqTrigger.BITA_1, 0, 0, 0, 1, 0), SeqRow( - 1, + x_steps, SeqTrigger.POSA_GT, int(params.x_start * MM_TO_ENCODER_COUNTS), PULSE_WIDTH_US, @@ -146,25 +146,13 @@ def test_setup_panda_correctly_configures_table( 0, ), ] - if x_steps > 1: - expected_seq_rows.append( - SeqRow( - x_steps - 1, - SeqTrigger.IMMEDIATE, - 0, - PULSE_WIDTH_US, - 1, - SPACE_WIDTH_US, - 0, - ) - ) exposure_distance_counts = exposure_distance_mm * MM_TO_ENCODER_COUNTS expected_seq_rows.extend( [ SeqRow(1, SeqTrigger.BITA_1, 0, 0, 0, 1, 0), SeqRow( - 1, + x_steps, SeqTrigger.POSA_LT, int( (params.x_start + (params.x_steps - 1) * params.x_step_size) @@ -178,18 +166,6 @@ def test_setup_panda_correctly_configures_table( ), ] ) - if x_steps > 1: - expected_seq_rows.append( - SeqRow( - x_steps - 1, - SeqTrigger.IMMEDIATE, - 0, - PULSE_WIDTH_US, - 1, - SPACE_WIDTH_US, - 0, - ) - ) for key in SeqRow._fields: np.testing.assert_array_equal(