diff --git a/CHANGES.rst b/CHANGES.rst index e5f730e4..fde197bc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -34,11 +34,16 @@ release expected by 2024-03-01 New Features ------------ +* Add options to instrument configuration (iconfig.yml): + + * After every run, verify that files were saved, print a confirmation message. + * Debugging and message options. + * Add package(s) to environment: * ophyd-registry -* Build ``registry`` of all ophyd objects. +* Build ``oregistry`` of all ophyd objects. Maintenance ------------ diff --git a/bluesky/instrument/framework/initialize.py b/bluesky/instrument/framework/initialize.py index 49fdb551..caff6a4b 100644 --- a/bluesky/instrument/framework/initialize.py +++ b/bluesky/instrument/framework/initialize.py @@ -1,5 +1,5 @@ """ -initialize the bluesky framework +Initialize the bluesky framework. """ __all__ = """ @@ -7,8 +7,8 @@ bp bps bpp summarize_plan np - registry - """.split() + oregistry +""".split() import logging @@ -31,7 +31,6 @@ from bluesky.utils import ProgressBarManager from bluesky.utils import ts_msg_hook from IPython import get_ipython -from ophyd.signal import EpicsSignalBase from ophydregistry import Registry import databroker import ophyd @@ -96,18 +95,19 @@ def get_md_path(): # At the end of every run, verify that files were saved and # print a confirmation message. -# from bluesky.callbacks.broker import verify_files_saved -# RE.subscribe(post_run(verify_files_saved), 'stop') +if iconfig.get("VERIFY_FILES_SAVED", False): + from bluesky.callbacks.broker import post_run + from bluesky.callbacks.broker import verify_files_saved -# Uncomment the following lines to turn on -# verbose messages for debugging. -# ophyd.logger.setLevel(logging.DEBUG) + RE.subscribe(post_run(verify_files_saved), "stop") +ophyd.logger.setLevel(iconfig.get("LOGGING", {}).get("OPHYD_LOGGER_LEVEL", "WARNING")) ophyd.set_cl(iconfig.get("OPHYD_CONTROL_LAYER", "PyEpics").lower()) logger.info(f"using ophyd control layer: {ophyd.cl.name}") -# diagnostics -# RE.msg_hook = ts_msg_hook +if iconfig.get("ADD_DIAGNOSTIC_MESSAGES", False): + # Log bluesky Message objects in RunEngine (follow plan's progress). + RE.msg_hook = ts_msg_hook if iconfig.get("RUN_ENGINE_SCAN_ID_PV") is not None: from ..epics_signal_config import epics_scan_id_source @@ -119,4 +119,4 @@ def get_md_path(): RE.md["scan_id"] = scan_id_epics.get() # Create a registry of ophyd devices -registry = Registry(auto_register=True) +oregistry = Registry(auto_register=True) diff --git a/bluesky/instrument/iconfig.yml b/bluesky/instrument/iconfig.yml index 79a51d5f..fda198aa 100644 --- a/bluesky/instrument/iconfig.yml +++ b/bluesky/instrument/iconfig.yml @@ -28,6 +28,7 @@ AD_MOUNT_PATH: /tmp BLUESKY_MOUNT_PATH: /tmp/docker_ioc/iocad/tmp # permissions +ADD_DIAGNOSTIC_MESSAGES: false ALLOW_AREA_DETECTOR_WARMUP: true ENABLE_AREA_DETECTOR_IMAGE_PLUGIN: true ENABLE_CALCS: true @@ -35,6 +36,7 @@ USE_PROGRESS_BAR: false WRITE_NEXUS_DATA_FILES: true NEXUS_WARN_MISSING_CONTENT: false NEXUS_FILE_EXTENSION: hdf +VERIFY_FILES_SAVED: False WRITE_SPEC_DATA_FILES: true # ---------------------------------- @@ -52,9 +54,11 @@ WRITE_SPEC_DATA_FILES: true LOGGING: # MAX_BYTES: 1000000 NUMBER_OF_PREVIOUS_BACKUPS: 9 - # LOG_PATH: /tmp # If LOG_PATH undefined, this session will log into PWD/logs/ - # where PWD is present working directory when session is started + # where PWD is present working directory when session is started. + # LOG_PATH: /tmp + # Use "DEBUG" to turn on verbose messages for debugging. + OPHYD_LOGGER_LEVEL: WARNING # default timeouts (seconds) PV_READ_TIMEOUT: &TIMEOUT 15