Ejemplo n.º 1
0
from bluesky.examples import motor, det
# Note: importing from standard_config raises a qt/mpl-related error.
from bluesky.global_state import gs
from bluesky.register_mds import register_mds
from bluesky.scans import AbsScan


register_mds(gs.RE)
gs.RE.md['owner'] = 'demo'
gs.RE.md['group'] = 'demo'
gs.RE.md['config'] = {}
gs.RE.md['beamline_id'] = 'demo'


scan = AbsScan([det], motor, 1, 5, 5)
gs.RE(scan, mood='optimisitc')
Ejemplo n.º 2
0
loop = asyncio.get_event_loop()
loop.set_debug(False)


### Set up a History object to handle peristence (scan ID, etc.)

SEARCH_PATH = []
ENV_VAR = "BLUESKY_HISTORY_LOCATION"
if ENV_VAR in os.environ:
    SEARCH_PATH.append(os.environ[ENV_VAR])
SEARCH_PATH.extend([os.path.expanduser("~/.config/bluesky/bluesky_history.db"), "/etc/bluesky/bluesky_history.db"])


gs.RE.md = get_history()
gs.RE.md["owner"] = getuser()
register_mds(gs.RE)  # subscribes to MDS-related callbacks


def olog_wrapper(logbook, logbooks):
    """Wrap an olog logbook for use with RunEngine

    The admittedly confusing parameter names reflect our understanding of Olog
    conventions.

    Parameters
    ----------
    logbook : pyolog.logbook
        logbook object
    logbooks : list of strings
        names of logbooks to write entries to
Ejemplo n.º 3
0
    try:
        os.makedirs(os.path.dirname(target_path), exist_ok=True)
        if os.path.isfile(target_path):
            print('Found metadata history in existing file.')
        else:
            print('Storing metadata history in a new file.')
        return history.History(target_path)
    except IOError as exc:
        print(exc)
        print('Storing History in memory; it will not persist.')
        return history.History(':memory:')


gs.RE.md = get_history()
gs.RE.md['owner'] = getuser()
register_mds(gs.RE)  # subscribes to MDS-related callbacks


def olog_wrapper(logbook, logbooks):
    """Wrap an olog logbook for use with RunEngine

    The admittedly confusing parameter names reflect our understanding of Olog
    conventions.

    Parameters
    ----------
    logbook : pyolog.logbook
        logbook object
    logbooks : list of strings
        names of logbooks to write entries to
Ejemplo n.º 4
0
class glbl():
    beamline_host_name = BEAMLINE_HOST_NAME
    base = BASE_DIR
    home = HOME_DIR
    _export_tar_dir = _EXPORT_TAR_DIR
    xpdconfig = BLCONFIG_DIR
    import_dir = IMPORT_DIR
    config_base = CONFIG_BASE
    tiff_base = TIFF_BASE
    usrScript_dir = USERSCRIPT_DIR
    yaml_dir = YAML_DIR
    allfolders = ALL_FOLDERS
    archive_dir = USER_BACKUP_DIR
    dk_yaml = DARK_YAML_NAME
    dk_window = DARK_WINDOW
    frame_acq_time = FRAME_ACQUIRE_TIME
    auto_dark = True
    owner = OWNER
    beamline_id = BEAMLINE_ID
    group = GROUP
    _allowed_scanplan_type = ALLOWED_SCANPLAN_TYPE

    # logic to assign correct objects depends on simulation or real experiment
    if not simulation:
        from bluesky.run_engine import RunEngine
        from bluesky.register_mds import register_mds
        # import real object as other names to avoid possible self-referencing later
        from bluesky import Msg as msg
        from bluesky.plans import Count as count
        from bluesky.plans import AbsScanPlan as absScanPlan
        from databroker import DataBroker
        from databroker import get_images as getImages
        from databroker import get_events as getEvents
        from bluesky.callbacks import LiveTable as livetable
        from bluesky.callbacks.broker import verify_files_saved as verifyFiles
        from ophyd import EpicsSignalRO, EpicsSignal
        from bluesky.suspenders import SuspendFloor
        ring_current = EpicsSignalRO('SR:OPS-BI{DCCT:1}I:Real-I',
                                     name='ring_current')
        xpdRE = RunEngine()
        xpdRE.md['owner'] = owner
        xpdRE.md['beamline_id'] = beamline_id
        xpdRE.md['group'] = group
        register_mds(xpdRE)
        beamdump_sus = SuspendFloor(ring_current,
                                    ring_current.get() * 0.9,
                                    resume_thresh=ring_current.get() * 0.9,
                                    sleep=1200)
        #xpdRE.install_suspender(beamdump_sus) # don't enable it untill beam is back
        # real imports
        Msg = msg
        Count = count
        db = DataBroker
        LiveTable = livetable
        get_events = getEvents
        get_images = getImages
        AbsScanPlan = absScanPlan
        verify_files_saved = verifyFiles
        # real collection objects
        area_det = None
        temp_controller = None
        shutter = None

    else:
        simulation = True
        ARCHIVE_BASE_DIR = os.path.join(BASE_DIR, 'userSimulationArchive')
        # mock imports
        Msg = MagicMock()
        Count = MagicMock()
        AbsScanPlan = MagicMock()
        db = MagicMock()
        get_events = MagicMock()
        get_images = MagicMock()
        LiveTable = mock_livetable
        verify_files_saved = MagicMock()
        # mock collection objects
        xpdRE = MagicMock()
        temp_controller = MagicMock()
        shutter = mock_shutter()
        area_det = MagicMock()
        area_det.cam = MagicMock()
        area_det.cam.acquire_time = MagicMock()
        area_det.cam.acquire_time.put = MagicMock(return_value=0.1)
        area_det.cam.acquire_time.get = MagicMock(return_value=0.1)
        area_det.number_of_sets = MagicMock()
        area_det.number_of_sets.put = MagicMock(return_value=1)
        print('==== Simulation being created in current directory:{} ===='.
              format(BASE_DIR))