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

xrun.abort does not close fast shutter #151

Closed
DanOlds opened this issue Oct 30, 2018 · 24 comments
Closed

xrun.abort does not close fast shutter #151

DanOlds opened this issue Oct 30, 2018 · 24 comments
Assignees
Milestone

Comments

@DanOlds
Copy link

DanOlds commented Oct 30, 2018

When xrun.abort is run (after ctrl+c is used to exit a script), the fast shutter is not automatically closed.

Expected Behavior

Ideally, xrun.abort should close the fast shutter to help preserve the detector against unnecessary exposure.

Current Behavior

While the fast shutter can be closed manually using the CS interface, users are often unaware of this issue.

Possible Solution

xrun.abort should close the fast shutter if it is open, and keep it closed if it is already closed.

Steps to Reproduce (for bugs)

  1. Start a run.
  2. ctrl-c once the measurement starts (after dark is collected)
  3. xrun.abort()

Context

This can be a problem for strongly scattering materials, leading to unnecessary detector exposure.

Priority

Many photons died bringing you this request.

Your Environment

28-ID-1 and, presumably, 28-ID-2

@sbillinge
Copy link
Member

sbillinge commented Oct 30, 2018 via email

@CJ-Wright
Copy link
Member

@chiahaoliu should this be run through a message mutator looking at stop docs?

@chiahaoliu
Copy link
Collaborator

@CJ-Wright We have a finalizer that should ensure the fast shutter is closed after a scan. I am wondering what happens if you do

xrun.halt() or xrun.stop()

cc: @DanOlds

@CJ-Wright
Copy link
Member

They should all issue stop documents (except for the emergency stop)

@sbillinge
Copy link
Member

sbillinge commented Oct 31, 2018 via email

@chiahaoliu
Copy link
Collaborator

Tested at beamline yesterday. I confirmed neither xrun.abort(), xrun.stop() or xrun.halt() will close the shutter.

Our current logic is the same as the way @sbillinge described. We only open the shutter before collecting data and use finalize_wrapper to close the shutter. From the documentation, it seems this behavior should happen anyway even if the run is aborted.

Maybe @tacaswell or @danielballan can give some comments?

@CJ-Wright
Copy link
Member

halt shouldn't close the shutter, since that is emergency stop.

@sbillinge sbillinge added this to the 2019 Cycle 1 milestone Jan 3, 2019
@sbillinge
Copy link
Member

This is a good issue to work together with Dan and Tim to have Dan PR a solution as a first issue.

@tacaswell
Copy link

One hook you have to this is to implement a 'stop' method on the shutter that ensures it is closed (which will happen even on halt as it is in the finally block of the RE loop, not done via a message).

However, it looks like you only install that finalize_wrapper if glbl["shutter_control"] is True, is opening the shutter also symmetrically controlled?

@CJ-Wright
Copy link
Member

CJ-Wright commented Jan 22, 2019

yes, we have both open and close plan stubs: https://github.com/xpdAcq/xpdAcq/blob/master/xpdacq/beamtime.py#L145

Edit: more context, yes if the shutter is under xpdAcq control then we open the shutter appropriately

@CJ-Wright
Copy link
Member

@DanOlds would you be able to test this with the new software?

@DanOlds
Copy link
Author

DanOlds commented Feb 5, 2019 via email

@CJ-Wright
Copy link
Member

Thank you!

@DanOlds
Copy link
Author

DanOlds commented Feb 25, 2019

xrun.abort() still does not close the fast shutter.

@danielballan
Copy link

One hook you have to this is to implement a 'stop' method on the shutter that ensures it is closed (which will happen even on halt as it is in the finally block of the RE loop, not done via a message).

This suggestion of @tacaswell's seems the simplest way to ensure that the shutter closes when the RunEngine aborts.

@CJ-Wright
Copy link
Member

CJ-Wright commented Mar 2, 2019

I thought that was what finalize_wrapper did.

@danielballan
Copy link

Oh, no, finalize_wrapper adds messages to be run at the end of a plan even if that plan ends due to error. The stop() method on Device is always called by the RunEngine upon exit, regardless of the plan or the exit mode (success/stop/abort/halt).

@CJ-Wright
Copy link
Member

Right, so I'm confused as to why the messages from the finalize_wrapper aren't being acted upon.

@danielballan
Copy link

Without more context, I can't say. My point is that if the desired outcome is to always close the shutter on exit, implementing stop() is a simpler way. But it may not be the correct approach in your case --- up to you.

@CJ-Wright
Copy link
Member

I guess I'm trying to figure out if there is an error in finalize_wrapper more globally.

@danielballan
Copy link

There are no known problems with finalize_wrapper. If you asking for support on a suspected bug with finalize_wrapper, it would be helpful to see the plan (or ideally an SSCCE reduction of the plan) and DEBUG-level logging output to show what the resultant messages are.

@CJ-Wright
Copy link
Member

Fixed via: NSLS-II-PDF/profile_collection#6 ?

@DanOlds
Copy link
Author

DanOlds commented Mar 20, 2019

Tested and working!

@tacaswell
Copy link

You probably also want to implement resume to re-open the shutter if the user chooses not to stop/abort/halt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants