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

Make stage synchronous if arming not started #92

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 10 additions & 5 deletions src/dodal/devices/eiger.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,19 @@ def async_stage(self):
self.arming_status = self.do_arming_chain()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: You should create a placeholder class variable for this that's initialised to a complete status, this helps autocomplete etc.

return self.arming_status

def is_armed(self):
if self.odin.fan.ready.get() == 1 and self.cam.acquire.get() == 1:
return True
else:
return False
olliesilvester marked this conversation as resolved.
Show resolved Hide resolved

def stage(self):
if self.arming_status.done is False:
if not self.arming_status.done:
# Arming has started so wait for it to finish
self.arming_status.wait(60)
else:
if self.odin.fan.ready.get() != 1:
# Arming hasn't started, do it asynchronously
self.async_stage()
elif not self.is_armed():
# Arming hasn't started, do it asynchronously
self.async_stage().wait(timeout=self.GENERAL_STATUS_TIMEOUT)

def unstage(self) -> bool:
assert self.detector_params is not None
Expand Down
1 change: 1 addition & 0 deletions tests/devices/unit_tests/test_eiger.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ def test_if_eiger_isnt_armed_then_stage_calls_async_stage(fake_eiger: EigerDetec

def test_if_eiger_is_armed_then_stage_does_nothing(fake_eiger: EigerDetector):
fake_eiger.odin.fan.ready.sim_put(1)
fake_eiger.cam.acquire.sim_put(1)
fake_eiger.async_stage = MagicMock()
fake_eiger.stage()
fake_eiger.async_stage.assert_not_called()