diff --git a/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_1.py b/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_1.py index e01ed23..aebec23 100644 --- a/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_1.py +++ b/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_1.py @@ -217,7 +217,7 @@ class DDG1(PSIDeviceBase, DelayGeneratorCSAXS): # in the IOC to the expected values. In the past, we've experienced that IOC and HW can go out # of sync. self.burst_delay.put(1) - time.sleep(0.02) # Give HW time to process + time.sleep(0.02) # Give HW time to process self.burst_delay.put(0) time.sleep(0.02) @@ -226,11 +226,10 @@ class DDG1(PSIDeviceBase, DelayGeneratorCSAXS): self.burst_count.put(1) time.sleep(0.02) - self.burst_mode.put(0) - time.sleep(0.02) self.burst_mode.put(1) time.sleep(0.02) - + self.burst_mode.put(0) + time.sleep(0.02) def keep_shutter_open_during_scan(self, open: True) -> None: """ @@ -309,15 +308,11 @@ class DDG1(PSIDeviceBase, DelayGeneratorCSAXS): # c/t0 + self._shutter_to_open_delay + exp_time * burst_count # SHUTTER WIDTH timing consists of the delay for the shutter to open # + the exposure time * frames per trigger - shutter_width = ( - self._shutter_to_open_delay + exp_time * frames_per_trigger - ) + shutter_width = self._shutter_to_open_delay + exp_time * frames_per_trigger # TOTAL EXPOSURE accounts for the shutter to open AND close. In addition, we add - # a short additional delay of 3e-6 to allow for the extra trigger through 'ef' + # a short additional delay of 3e-6 to allow for the extra trigger through 'ef' # (delay of 1e-6, width of 1e-6) - total_exposure_time = ( - 2*self._shutter_to_open_delay + exp_time*frames_per_trigger + 3e-6 - ) + total_exposure_time = 2 * self._shutter_to_open_delay + exp_time * frames_per_trigger + 3e-6 if self.burst_period.get() != shutter_width: # The burst_period has to be slightly longer self.burst_period.put(total_exposure_time) diff --git a/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_2.py b/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_2.py index 1108970..5790d9c 100644 --- a/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_2.py +++ b/csaxs_bec/devices/epics/delay_generator_csaxs/ddg_2.py @@ -29,6 +29,7 @@ from ophyd_devices import DeviceStatus, StatusBase from ophyd_devices.interfaces.base_classes.psi_device_base import PSIDeviceBase from csaxs_bec.devices.epics.delay_generator_csaxs.delay_generator_csaxs import ( + BURSTCONFIG, CHANNELREFERENCE, OUTPUTPOLARITY, STATUSBITS, @@ -37,7 +38,6 @@ from csaxs_bec.devices.epics.delay_generator_csaxs.delay_generator_csaxs import ChannelConfig, DelayGeneratorCSAXS, LiteralChannels, - BURSTCONFIG, ) logger = bec_logger.logger @@ -142,7 +142,7 @@ class DDG2(PSIDeviceBase, DelayGeneratorCSAXS): # in the IOC to the expected values. In the past, we've experienced that IOC and HW can go out # of sync. self.burst_delay.put(1) - time.sleep(0.02) # Give HW time to process + time.sleep(0.02) # Give HW time to process self.burst_delay.put(0) time.sleep(0.02) @@ -151,10 +151,10 @@ class DDG2(PSIDeviceBase, DelayGeneratorCSAXS): self.burst_count.put(1) time.sleep(0.02) - self.burst_mode.put(0) - time.sleep(0.02) self.burst_mode.put(1) time.sleep(0.02) + self.burst_mode.put(0) + time.sleep(0.02) def on_stage(self) -> DeviceStatus | StatusBase | None: """ diff --git a/tests/tests_devices/test_delay_generator_csaxs.py b/tests/tests_devices/test_delay_generator_csaxs.py index 6ba4ecb..230b86e 100644 --- a/tests/tests_devices/test_delay_generator_csaxs.py +++ b/tests/tests_devices/test_delay_generator_csaxs.py @@ -287,19 +287,20 @@ def test_ddg1_stage(mock_ddg1: DDG1): mock_ddg1.stage() shutter_width = mock_ddg1._shutter_to_open_delay + exp_time * frames_per_trigger + total_exposure = 2 * mock_ddg1._shutter_to_open_delay + exp_time * frames_per_trigger + 3e-6 assert np.isclose(mock_ddg1.burst_mode.get(), 1) # burst mode is enabled assert np.isclose(mock_ddg1.burst_delay.get(), 0) - assert np.isclose(mock_ddg1.burst_period.get(), shutter_width) + assert np.isclose(mock_ddg1.burst_period.get(), total_exposure) # Trigger DDG2 through EXT/EN assert np.isclose(mock_ddg1.ab.delay.get(), 2e-3) - assert np.isclose(mock_ddg1.ab.width.get(), 1e-6) + assert np.isclose(mock_ddg1.ab.width.get(), shutter_width) # Shutter channel cd assert np.isclose(mock_ddg1.cd.delay.get(), 0) assert np.isclose(mock_ddg1.cd.width.get(), shutter_width) # MCS channel ef or gate - assert np.isclose(mock_ddg1.ef.delay.get(), 0) + assert np.isclose(mock_ddg1.ef.delay.get(), 1e-6) assert np.isclose(mock_ddg1.ef.width.get(), 1e-6) assert mock_ddg1.staged == ophyd.Staged.yes