callback_db['bec'] = RE.subscribe(bec) peaks = bec.peaks # just as alias for less typing bec.disable_baseline() # At the end of every run, verify that files were saved and # print a confirmation message. # from bluesky.callbacks.broker import verify_files_saved # callback_db['post_run_verify'] = RE.subscribe(post_run(verify_files_saved), 'stop') # convenience imports # Uncomment the following lines to turn on # verbose messages for debugging. # ophyd.logger.setLevel(logging.DEBUG) # diagnostics #RE.msg_hook = ts_msg_hook # set default timeout for all EpicsSignal connections & communications try: EpicsSignalBase.set_defaults( auto_monitor=True, timeout=60, write_timeout=60, connection_timeout=5, ) except Exception as exc: warnings.warn("ophyd version is old, upgrade to 1.5.4+ " "to get set_defaults() method") EpicsSignalBase.set_default_timeout(timeout=10, connection_timeout=5)
logger = logging.getLogger(__name__) logger.info(__file__) print(__file__) from . import iconfig from ophyd.signal import EpicsSignal from ophyd.signal import EpicsSignalBase # set default timeout for all EpicsSignal connections & communications # always first, before ANY ophyd EPICS-based signals are created TIMEOUT = 60 if not EpicsSignalBase._EpicsSignalBase__any_instantiated: EpicsSignalBase.set_defaults( auto_monitor=True, timeout=iconfig.get("PV_TIMEOUT", TIMEOUT), write_timeout=iconfig.get("PV_WRITE_TIMEOUT", TIMEOUT), connection_timeout=iconfig.get("PV_CONNECTION_TIMEOUT", TIMEOUT), ) pvname = iconfig.get("RUN_ENGINE_SCAN_ID_PV") if pvname is None: logger.info("Using RunEngine metadata for scan_id") scan_id_epics = None else: logger.info("Using EPICS PV %s for scan_id", pvname) scan_id_epics = EpicsSignal(pvname, name="scan_id_epics") def epics_scan_id_source(*args, **kwargs): """ Callback function for RunEngine. Returns *next* scan_id to be used.
if timeout is DEFAULT_CONNECTION_TIMEOUT: timeout = self.connection_timeout # print(f'{print_now()}: waiting for {self.name} to connect within {timeout:.4f} s...') start = time.time() self._ensure_connected(self._read_pv, self._write_pv, timeout=timeout) # print(f'{print_now()}: waited for {self.name} to connect for {time.time() - start:.4f} s.') EpicsSignalBase.wait_for_connection = wait_for_connection_base EpicsSignal.wait_for_connection = wait_for_connection ############################################################################### from ophyd.signal import EpicsSignalBase # EpicsSignalBase.set_default_timeout(timeout=10, connection_timeout=10) # old style EpicsSignalBase.set_defaults(timeout=10, connection_timeout=10) # new style EpicsSignal.set_defaults(timeout=10, connection_timeout=10) # new style import nslsii from datetime import datetime # Register bluesky IPython magics. if not is_re_worker_active(): from bluesky.magics import BlueskyMagics get_ipython().register_magics(BlueskyMagics) from bluesky.preprocessors import stage_decorator, run_decorator from databroker.v0 import Broker db = Broker.named("fxi")
def wait_for_connection(self, timeout=DEFAULT_CONNECTION_TIMEOUT): '''Wait for the underlying signals to initialize or connect''' if timeout is DEFAULT_CONNECTION_TIMEOUT: timeout = self.connection_timeout self._ensure_connected(self._read_pv, self._write_pv, timeout=timeout) EpicsSignalBase.wait_for_connection = wait_for_connection_base EpicsSignal.wait_for_connection = wait_for_connection ############################################################################### from ophyd.signal import EpicsSignalBase EpicsSignalBase.set_defaults(connection_timeout=8) import nslsii nslsii.configure_base(get_ipython().user_ns, 'xpeem') from pathlib import Path import appdirs try: from bluesky.utils import PersistentDict except ImportError: import msgpack import msgpack_numpy import zict