spc-group / haven

Bluesky tools for beamlines managed by the spectroscopy group
https://haven-spc.readthedocs.io/en/latest/
Other
2 stars 6 forks source link

Add grid_scan plan window #210

Closed Cathyhjj closed 2 months ago

Cathyhjj commented 4 months ago
Cathyhjj commented 4 months ago

Question: whether to add exposure to line_scan & grid_scan

canismarko commented 4 months ago

I'm not sure, I can see reasons to go either way.

I've kind of been ignoring this because it's not clear to me how it would work. I'd love to discuss more, though. It's a question I'm sure we're going to get pretty quickly once we have X-rays again.

Given the amount of work involved, I was planning to see how people use the software first and then put in the time to implement it if it seems necessary.

Maybe we should bring it up with SDK or the group sometime?

Here are some things to consider.

Challenges

1) From Ophyd's point of view, exposure time is the job of the detector not the plan, and different detectors may have different exposure times (or none at all). Without an input for exposure time in the plan window, you just have to set it in the device window as Ophyd expects. We need a way to set the exposure for each detector separately (or not set it at all). Most of the time, though, it will probably be the same for all the detectors so a single input would also be useful. 2) I think it'd be good to reset the exposure time for each detector at the end of the scan to whatever it was when we started. We can used Ophyd's staging mechanism to do this, but we need a way to get the desired value through the queueserver to the Ophyd device when the scan is started.

Possible Solutions

Here are some ideas I had, I'm certainly open to other solutions.

For the first one, the DetectorSelector widget could become more elaborate, with extra widgets for an optional exposure time triggers for each detector. The plan window could then have a global input that the detector selector uses to update its individual exposure times.

For the second one, there could be an extra PV in every detector IOC like "scanExposureTime" which could get set using the set_abs() plan before each scan() plan. Then during staging we could read that value and set it, then reset it during unstaging. Downside is that we'd have to customize every detector IOC.

Alternately, we could make our own versions of the standard plans that change the exposure time after staging. The upside is we don't have to customize IOCs, but the downside is we do have to keep our own parallel versions of all the plans we want to use this way.

Cathyhjj commented 4 months ago

add time_calculator:

detectors = [app.registry[name] for name in detectors] detectors = [det for det in detectors if hasatt(det, "default_time_signal")] time = max([det.default_time_signal.get() for det in detectors])

Cathyhjj commented 4 months ago

det.default_time_signal.set(1).wait(3) to set up default time for testing

Cathyhjj commented 4 months ago

this doesn't seem to trigger in the pytest file

self.ui.detectors_list.selectionModel().selectionChanged.connect(
            self.update_total_time
        )
Cathyhjj commented 4 months ago

self.ui.detectors_list.selectionModel().selectionChanged.emit() in pytest file

Cathyhjj commented 4 months ago

seperate test for time_calculator

Cathyhjj commented 4 months ago

time_converter in util.py under firefly/plans folder, with a documentation string