def test_serp_scan(): """Note: run this standalone, not inside mfx hutch python.""" import numpy as np from bluesky import RunEngine from bluesky.callbacks.best_effort import BestEffortCallback from ophyd.sim import motor1, motor2 from ophyd.status import StatusBase from pcdsdaq.daq import Daq from pcdsdaq.sim import set_sim_mode class FakeSeq: def trigger(self): print('Triggered the sequencer!') status = StatusBase() status.set_finished() return status set_sim_mode(True) RE = RunEngine({}) bec = BestEffortCallback() RE.subscribe(bec) seq = FakeSeq() daq = Daq(RE=RE) RE(serp_seq_scan(motor1, np.arange(100, 200, 10), motor2, [0, 100], seq))
def test_file_load(): logger.debug('test_file_load') set_sim_mode(True) objs = load(os.path.join(os.path.dirname(__file__), 'conf.yaml')) should_have = ('x', 'unique_device', 'calc_thing', 'daq', 'tst_beampath') err = '{} was overriden by a namespace' for elem in should_have: assert not isinstance(objs[elem], SimpleNamespace), err.format(elem) assert 'tst' in objs assert len(Presets._paths) == 2
def test_exp_override(): logger.debug('test_exp_override') set_sim_mode(True) # Should work with or without hutch name objs = load(os.path.join(os.path.dirname(__file__), 'conf.yaml'), SimpleNamespace(exp='x011')) assert hasattr(objs['x'], 'cats') objs = load(os.path.join(os.path.dirname(__file__), 'conf.yaml'), SimpleNamespace(exp='tstx011')) assert hasattr(objs['x'], 'cats')
def test_conf_platform(): logger.debug('test_conf_platform') set_sim_mode(True) # No platform objs = load_conf({}) assert objs['daq']._plat == 0 # Define default platform objs = load_conf({'daq_platform': {'default': 1}}) assert objs['daq']._plat == 1 # Define host platform hostname = gethostname() objs = load_conf({'daq_platform': {hostname: 2}}) assert objs['daq']._plat == 2 # Define both objs = load_conf({'daq_platform': {'default': 3, hostname: 4}}) assert objs['daq']._plat == 4
def daq(RE): set_sim_mode(True) yield Daq(RE=RE, hutch_name='tst') set_sim_mode(False)
def nosim(reset): set_sim_mode(False)
def sim(reset): set_sim_mode(True)
import os.path import sys from hutch_python.load_conf import load from hutch_python.log_setup import setup_logging from pcdsdaq.sim import set_sim_mode sys.path.insert(0, "/reg/g/pcds/pyps/apps/hutch-python/tst") # Do the normal hutch-python loading set_sim_mode(True) cfg = '/cds/group/pcds/pyps/apps/hutch-python/tst/conf.yml' setup_logging(dir_logs=os.path.join(os.path.dirname(cfg), 'logs')) objs = load(cfg=cfg) # Make some post-adjustments for queue-server # Disable the bec plots for the server process (keep the table) objs['bec'].disable_plots() # Make all objects available to queue-server globals().update(objs) # Additionally expand the plan namespace so that the queue-server sees it globals().update(vars(objs['bp'])) # Additionally expand the experiment object so that the queue-server sees it try: globals().update(vars(objs['user'])) except KeyError: pass
def daq(RE): set_sim_mode(True) sim_pydaq.conn_err = None return Daq(RE=RE, platform=0)