BCDA-APS / bluesky_training

Bluesky training, including instrument package
https://bcda-aps.github.io/bluesky_training/
Other
11 stars 0 forks source link

BUG: EPICS PV for scan_id not working #224

Closed prjemian closed 10 months ago

prjemian commented 10 months ago

While prepping for the NX School, tried to configure the instrument to use an EPICS PV for the scan_id: https://github.com/BCDA-APS/bluesky_training/blob/badd13d6906faf9aa0c8231c291d49d10469def2/bluesky/instrument/iconfig.yml#L18-L20

After several runs, the PV never updated.. Investigate.

prjemian commented 10 months ago

Tried with one of the general purpose PVs: gp:gp:int20

prjemian commented 10 months ago

It's only used now with queueserver.

$ git grep epics_scan_id_source
bluesky/instrument/epics_signal_config.py:    epics_scan_id_source
bluesky/instrument/epics_signal_config.py:def epics_scan_id_source(*args, **kwargs):
bluesky/instrument/epics_signal_config.py:            "epics_scan_id_source() called when"
bluesky/instrument/framework/metadata.py:    from ..epics_signal_config import epics_scan_id_source
bluesky/instrument/queueserver_framework.py:from .epics_signal_config import epics_scan_id_source
bluesky/instrument/queueserver_framework.py:    RE = bluesky.RunEngine({}, scan_id_source=epics_scan_id_source)

Time to turn this on for any use.

prjemian commented 10 months ago

Need to know if the PV is to be used and it is connected before creating the RE object. The framework.initialize module needs to be re-arranged so that timeouts are configure first, before any PVs are connected, finally the RE is created and configured.

prjemian commented 10 months ago

Re-arrangement is not necessary. The RE.scan_id_source is set in __init__():

        self.scan_id_source = scan_id_source

and used in open_run():

        # Run scan_id calculation method
        self.md['scan_id'] = self.scan_id_source(self.md)

We can set it at any time after: https://github.com/BCDA-APS/bluesky_training/blob/badd13d6906faf9aa0c8231c291d49d10469def2/bluesky/instrument/framework/initialize.py#L56

like this:

        RE.scan_id_source = epics_scan_id_source
prjemian commented 10 months ago

Needs test suite for instrument package.