aps-8id-dys / bluesky

XPCS bluesky instrument configuration
Other
2 stars 0 forks source link

Make the lambda2m HDF plugin optional #8

Closed prjemian closed 1 year ago

prjemian commented 1 year ago

The standard ophyd setup for the Lambda2M has been to use the HDF file writing plugin in the IOC. With the Beamline Data Pipelines project, we've identified that for the fastest data collection process (which are expected to be used by this detector), the process must avoid writing data files completely. For the process faster than file writing, BDP recommends publishing the image from the IOC's PVA plugin and disabling the HDF5 file writer. For the streaming process, we want to disable the HDF5 interface because the files will not be used. Also, we have seen random timeout problems when writing to PVs of the HDF5 plugin which occur, ironically, when only using the image from the PVA plugin.

To preserve configuration for both types of process, we need to make use of the HDF5 plugin optional by the user. This could be exposed in the queueserver by creating a plan to enable/disable the HDF5 plugin.

prjemian commented 1 year ago

Note this pair of methods that manipulate the stage_sigs dict:

method docstring
lambda2M.hdf1.disable_on_stage() when the plugin is staged, ensure that it is disabled
lambda2M.hdf1.enable_on_stage() when the plugin is staged, ensure that it is enabled

Also, the lambda2M.read_attrs list:

In [4]: lambda2M.read_attrs
Out[4]: ['hdf1']

In [5]: lambda2M.stage_sigs
Out[5]: OrderedDict([('cam.acquire', 0), ('cam.image_mode', 1)])
prjemian commented 1 year ago

Needs testing

prjemian commented 1 year ago

Made some good headway for making a detector object that has all possible plugins. Created a function to enable/disable a plugin: https://github.com/aps-8id-dys/bluesky/blob/71dc7e1f2483472ec8ed10c19ad125381752d7b8/instrument/plans/acquire_plans.py#L28-L39

This works, to some extent, but is not comprehensive. It prevents staging of the plugin. For the HDF File writer plugin, additional configuration still applies during acquisition. When the HDF5 plugin is disabled with this function, acquisition of a detector image proceeds (using bp.count()) but ultimately fails:

  File "/home/beams10/8IDIUSER/micromamba/envs/bluesky_2023_1/lib/python3.10/site-packages/ophyd/areadetector/filestore_mixins.py", line 682, in generate_datum
    i = next(self._point_counter)
TypeError: 'NoneType' object is not an iterator

None here is because we disabled the lambda2M.hdf1.stage() method (since we're not using the plugin) so some initialization in the generate_datum() method is not initialized (specifically an iterator namedself._point_counter). Since it isNone`, it is not an interator.

This error comes from some additional configuration in apstools.devices.AD_EpicsFileNameMixin:

        # index each image frame (used in generate_datum() method)
        self._point_counter = itertools.count()

This means, in summary, my idea for disabling the lambda2M.hdf1 plugin ain't workin right.

prjemian commented 1 year ago

Time for Plan B

Plan A

Create a single ophyd-style detector object, configured with all plugins that might be used. Disable the plugins not to be used for any specific acquisition sequence.

Plan B

Create multiple ophyd-style detector instances, each configured with the plugins to be used with that instance.

prjemian commented 1 year ago

Since others also want to use the Lambda2M at the same time as this work, will continue work on Plan A using off-line ADSimDetector with PVA plugin enabled.

prjemian commented 1 year ago

Create two detector instances: