Commit 9ba3662d authored by jemian's avatar jemian
Browse files

update and sync with my private gitlab project

parent 4734dd51
print(__file__)
import sys
# ensure BlueSky is available
......
print(__file__)
# Make ophyd listen to pyepics.
from ophyd import setup_ophyd
setup_ophyd()
......
print(__file__)
# set up the data broker (db)
import os
......@@ -29,10 +31,16 @@ mds = MDS(mds_config)
fs = FileStore(fs_config)
db = Broker(mds, fs)
#------------------------------------------------------------------
# NOTE: this is a do-at-least-once per beam line to avoid creating a new file store
# from filestore.utils import install_sentinels
# install_sentinels(fs.config, version=1)
#------------------------------------------------------------------
from databroker.core import register_builtin_handlers
register_builtin_handlers(fs)
# Subscribe metadatastore to documents.
# If this is removed, data is not saved to metadatastore.
from bluesky.global_state import gs
gs.RE.subscribe('all', mds.insert)
RE = gs.RE # convenience alias
print(__file__)
'''
ensure that PyEpics is available
......@@ -5,4 +7,3 @@ Do this early in the setup so other setup can benefit.
'''
import epics
print(__file__)
from ophyd import (PVPositioner, EpicsMotor, EpicsSignal, EpicsSignalRO,
PVPositionerPC, Device)
from ophyd import Component as Cpt
......
print(__file__)
from ophyd import (EpicsScaler, EpicsSignal, EpicsSignalRO,
Device, DeviceStatus)
from ophyd import Component as Cpt
......@@ -7,3 +9,4 @@ import time
## Beam Monitor Counts
#bs_bm2 = EpicsSignalRO('BL14B:Det:BM2', name='bs_bm2')
noisy = EpicsSignalRO('xxx:userCalc1', name='noisy')
scaler = EpicsScaler('xxx:scaler1', name='scaler')
print(__file__)
# Set up default complex devices
# FIXME: how to get the PVs to the inner parts?
# TODO: How to build this up from previously-configured motors?
#class SlitAxis(Device):
# lo = Cpt(EpicsMotor, '')
# hi = Cpt(EpicsMotor, '')
#class XY_Slit(Device):
# h = Cpt(SlitAxis, '')
# v = Cpt(SlitAxis, '')
#slit1 = XY_Slit()
print(__file__)
# Bluesky plans (scans)
print(__file__)
# Set up default metadata
RE.md['beamline_id'] = 'developer'
RE.md['proposal_id'] = None
RE.md['pid'] = os.getpid()
# Add a callback that prints scan IDs at the start of each scan.
......
print(__file__)
# EPICS area detector(s)
from ophyd import SingleTrigger, AreaDetector, SimDetector
from ophyd import HDF5Plugin
from ophyd.areadetector.filestore_mixins import FileStoreHDF5IterativeWrite
from ophyd import Component, Device, EpicsSignalWithRBV
from ophyd.areadetector import ADComponent
class MyHDF5Plugin(HDF5Plugin, FileStoreHDF5IterativeWrite):
file_number_sync = None
def get_frames_per_point(self):
return self.parent.cam.num_images.get()
class MyDetector(SingleTrigger, SimDetector):
hdf1 = Component(
MyHDF5Plugin,
"HDF1:",
root="/", # for databroker filestore
write_path_template="/tmp", # for EPICS area detector
fs=fs,
)
simdet = MyDetector('13SIM1:', name='simdet')
simdet.read_attrs = ['hdf1', 'cam']
simdet.hdf1.read_attrs = [] # 'image' gets added dynamically
#simdet = SimDetector('13SIM1:')
"""
example::
RE(count([simdet], num=1))
imgs = db.get_images(db[-1], 'simdet_image')
imgs[0][0]
data_uid = simdet.read()['simdet_image']['value']
fs.retrieve(data_uid)
In [15]: %history
simdet.describe()
RE(count([simdet]))
db.get_images(db[-1], 'simdet_image')
images = _
images[0]
images[0][0]
simdet.cam.num_images.set(2)
RE(count([simdet]))
db.get_images(db[-1], 'simdet_image')
images = _
images[0][0]
images[0]
images[0][1]
%history
"""
print(__file__)
'''
write every scan to a NeXus file
......
print(__file__)
import pyRestTable
from ophyd.epics_motor import EpicsMotor
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment