Exemplo n.º 1
0
def setUpModule():
    global mtr

    setup_ophyd()

    mtr = EpicsMotor(motor_recs[0])
    mtr.wait_for_connection()
Exemplo n.º 2
0
def setUpModule():
    global mtr

    setup_ophyd()

    mtr = EpicsMotor(motor_recs[0])
    mtr.wait_for_connection()
Exemplo n.º 3
0
Arquivo: plans.py Projeto: pcdshub/ued
def motor_pv_scan(detectors, pvname, start, stop, num, events=None):
    """
    Scan over a motor record as a UI test utility
    """
    mot = EpicsMotor(pvname, name=pvname)
    config_in_scan(detectors, [mot], events)

    mot.wait_for_connection()
    return (yield from scan(detectors, mot, start, stop, num))
Exemplo n.º 4
0
    def __init__(self, prefix, **kwargs):
        self.zpsth = EpicsMotor(prefix + '{SC210:1-Ax:1}Mtr', name='zpsth')

        super().__init__(prefix, **kwargs)

        # if theta changes, update the pseudo position
        self.theta0.subscribe(self.parameter_updated)
Exemplo n.º 5
0
    def test_write_pv_timestamp_monitor(self):
        mtr = EpicsMotor(config.motor_recs[0])
        mtr.wait_for_connection()

        sp = EpicsSignal(mtr.user_setpoint.pvname, auto_monitor=True)

        sp_value0 = sp.get()
        ts0 = sp.timestamp
        sp.put(sp_value0 + 0.1, wait=True)
        time.sleep(0.1)

        sp_value1 = sp.get()
        ts1 = sp.timestamp
        self.assertGreater(ts1, ts0)
        self.assertAlmostEqual(sp_value0 + 0.1, sp_value1)

        sp.put(sp.value - 0.1, wait=True)
Exemplo n.º 6
0
    def test_write_pv_timestamp_no_monitor(self):
        mtr = EpicsMotor(config.motor_recs[0], name='test')
        mtr.wait_for_connection()

        sp = EpicsSignal(mtr.user_setpoint.pvname, name='test')

        sp_value0 = sp.get()
        ts0 = sp.timestamp
        sp.put(sp_value0 + 0.1, wait=True)
        time.sleep(0.1)

        sp_value1 = sp.get()
        ts1 = sp.timestamp
        self.assertGreater(ts1, ts0)
        self.assertAlmostEqual(sp_value0 + 0.1, sp_value1)

        sp.put(sp.value - 0.1, wait=True)
Exemplo n.º 7
0
    def test_pvpos(self):
        motor_record = self.sim_pv
        mrec = EpicsMotor(motor_record, name='pvpos_mrec')
        print('mrec', mrec.describe())
        mrec.wait_for_connection()

        class MyPositioner(PVPositioner):
            '''Setpoint, readback, done, stop. No put completion'''
            setpoint = C(EpicsSignal, '.VAL')
            readback = C(EpicsSignalRO, '.RBV')
            done = C(EpicsSignalRO, '.MOVN')
            stop_signal = C(EpicsSignal, '.STOP')

            stop_value = 1
            done_value = 0

        m = MyPositioner(motor_record, name='pos_no_put_compl')
        m.wait_for_connection()

        m.read()

        mrec.move(0.1, wait=True)
        time.sleep(0.1)
        self.assertEqual(m.position, 0.1)

        m.stop()
        m.limits

        repr(m)
        str(m)

        mc = copy(m)
        self.assertEqual(mc.describe(), m.describe())

        m.read()
Exemplo n.º 8
0
    def test_read_pv_timestamp_monitor(self):
        mtr = EpicsMotor(config.motor_recs[0])
        mtr.wait_for_connection()

        sp = EpicsSignal(mtr.user_setpoint.pvname, auto_monitor=True)
        rbv = EpicsSignalRO(mtr.user_readback.pvname, auto_monitor=True)

        rbv_value0 = rbv.get()
        ts0 = rbv.timestamp
        sp.put(sp.value + 0.1, wait=True)
        time.sleep(0.1)

        rbv_value1 = rbv.get()
        ts1 = rbv.timestamp
        self.assertGreater(ts1, ts0)
        self.assertAlmostEqual(rbv_value0 + 0.1, rbv_value1)

        sp.put(sp.value - 0.1, wait=True)
Exemplo n.º 9
0
    def test_read_pv_timestamp_no_monitor(self):
        mtr = EpicsMotor(config.motor_recs[0])
        mtr.wait_for_connection()

        sp = EpicsSignal(mtr.user_setpoint.pvname)
        rbv = EpicsSignalRO(mtr.user_readback.pvname)

        rbv_value0 = rbv.get()
        ts0 = rbv.timestamp
        sp.put(sp.value + 0.1, wait=True)
        time.sleep(0.1)

        rbv_value1 = rbv.get()
        ts1 = rbv.timestamp
        self.assertGreater(ts1, ts0)
        self.assertAlmostEqual(rbv_value0 + 0.1, rbv_value1)

        sp.put(sp.value - 0.1, wait=True)
Exemplo n.º 10
0
class PositioningStackNonMicroscope(PositioningStack):
    """ 
        NOTE: if USR50 is used as Ry, , the zero position must be set correctly so that Rx is 
        pointing in the x direction once homed, this position is at -6.0
    """
    # coarse y, Kohzu
    #yc = EpicsMotor('XF:16IDC-ES:Scan1{Ax:YC}Mtr', name='ss1_yc')
    # this is the Standa stepper stage
    #rx = EpicsMotor('XF:16IDC-ES:Scan1{Ax:RX}Mtr', name='ss1_rx')
    ry = EpicsMotor('XF:16IDC-ES:Scan1{Ax:RY}Mtr', name='ss1_ry')
Exemplo n.º 11
0
    def test_pvpos(self):
        motor_record = self.sim_pv
        mrec = EpicsMotor(motor_record, name='pvpos_mrec')
        print('mrec', mrec.describe())
        mrec.wait_for_connection()

        class MyPositioner(PVPositioner):
            '''Setpoint, readback, done, stop. No put completion'''
            setpoint = C(EpicsSignal, '.VAL')
            readback = C(EpicsSignalRO, '.RBV')
            done = C(EpicsSignalRO, '.MOVN')
            stop_signal = C(EpicsSignal, '.STOP')

            stop_value = 1
            done_value = 0

        m = MyPositioner(motor_record, name='pos_no_put_compl')
        m.wait_for_connection()

        m.read()

        mrec.move(0.1, wait=True)
        time.sleep(0.1)
        self.assertEqual(m.position, 0.1)

        m.stop()
        m.limits

        repr(m)
        str(m)

        mc = copy(m)
        self.assertEqual(mc.describe(), m.describe())

        m.read()
Exemplo n.º 12
0
class PositioningStackMicroscope(PositioningStack):
    """ this is the stack assembled in Apr 2019
        
    """
    # Newport
    x = EpicsMotor('XF:16IDC-ES:Scan2{Ax:X}Mtr', name='ss_x')
    y = EpicsMotor('XF:16IDC-ES:Scan2{Ax:Y}Mtr', name='ss_y')
    ry = EpicsMotor('XF:16IDC-ES:Scan2{Ax:RY}Mtr', name='ss_ry')
    # SmarAct stages
    sx = EpicsMotor('XF:16IDC-ES:Scan2-Gonio{Ax:sX}Mtr', name='ss_sx')
    sz = EpicsMotor('XF:16IDC-ES:Scan2-Gonio{Ax:sZ}Mtr', name='ss_sz')
    tx = EpicsMotor('XF:16IDC-ES:Scan2-Gonio{Ax:tX}Mtr', name='ss_tx')
    tz = EpicsMotor('XF:16IDC-ES:Scan2-Gonio{Ax:tZ}Mtr', name='ss_tz')
Exemplo n.º 13
0
class ScanningExperimentalModule2():
    """ the zero for Ry must be set correctly so that Rx is pointing in the x direction
        once homed, this position i1s at -6.0
    """
    x = EpicsMotor('XF:16IDC-ES:Scan2{Ax:sX}Mtr', name='ss2_x')
    x1 = EpicsMotor('XF:16IDC-ES:Scan2{Ax:X}Mtr', name='ss2_x1')
    y = EpicsMotor('XF:16IDC-ES:Scan2{Ax:sY}Mtr', name='ss2_y')
    z = EpicsMotor('XF:16IDC-ES:InAir{Mscp:1-Ax:F}Mtr', name='focus')
    # this is the Standa stepper stage
    rx = EpicsMotor('XF:16IDC-ES:Scan2{Ax:RX1}Mtr', name='ss2_rx')
    ry = EpicsMotor('XF:16IDC-ES:Scan2{Ax:RY}Mtr', name='ss2_ry')
Exemplo n.º 14
0
            e = -1.e23
        return self.PseudoPosition(energy=float(e))

    @pseudo_position_argument
    def set(self, position):
        energy, = position
        # print(position, self.position)
        if np.abs(energy - self.position[0]) < .01:
            return MoveStatus(self, energy, success=True, done=True)
        return super().set([float(_) for _ in position])


energy = Energy(prefix='', name='energy',
                read_attrs=['energy', 'ivugap', 'bragg', 'harmonic'],
                configuration_attrs=['enableivu', 'enabledcmgap', 'target_harmonic'])

dcm = energy
ivugap = energy.ivugap
# DCM motor shortcuts. Early scans used the names at right (p2h, etc).
dcm_gap = dcm.dcmgap  # Height in CSS # EpicsMotor('XF12ID:m66', name='p2h')
dcm_pitch = EpicsMotor('XF12ID:m67', name='dcm_pitch')
# dcm_roll = dcm.roll  # Roll in CSS # EpicsMotor('XF12ID:m68', name='p2r')
bragg = dcm.bragg  # Theta in CSS  # EpicsMotor('XF12ID:m65', name='bragg')
# dcm_x = dcm.x  # E Mono X in CSS

dcm_config = DCMInternals('', name='dcm_config')

bragg.read_attrs = ['user_readback']

new_ivu_gap = EpicsMotor('SR:C12-ID:G1{IVU:1-Ax:Gap}-Mtr', name='new_ivu_gap')
Exemplo n.º 15
0
from ophyd import Component as Cpt
from ophyd import (PseudoSingle, EpicsMotor, SoftPositioner, Signal)
from hkl.diffract import E6C  #this works for mu=0
from ophyd.pseudopos import (pseudo_position_argument, real_position_argument)

# Add MuR and MuT to bluesky list of motors and detectors.
muR = EpicsMotor('XF:23ID1-ES{Dif-Ax:MuR}Mtr', name='muR')
# use the line below if very paranoid
# muR = EpicsSignal('XF:23ID1-ES{Dif-Ax:MuR}Mtr.RBV', name='muR')
muT = EpicsMotor('XF:23ID1-ES{Dif-Ax:MuT}Mtr', name='muT')


# TODO: fix upstream!!
class NullMotor(SoftPositioner):
    @property
    def connected(self):
        return True


class Tardis(E6C):  #this works for mu=0
    h = Cpt(PseudoSingle, '')
    k = Cpt(PseudoSingle, '')
    l = Cpt(PseudoSingle, '')

    theta = Cpt(EpicsMotor, 'XF:23ID1-ES{Dif-Ax:Th}Mtr')
    mu = Cpt(NullMotor)

    chi =   Cpt(NullMotor)
    phi =   Cpt(NullMotor)
    delta = Cpt(EpicsMotor, 'XF:23ID1-ES{Dif-Ax:Del}Mtr')
    gamma = Cpt(EpicsMotor, 'XF:23ID1-ES{Dif-Ax:Gam}Mtr')
Exemplo n.º 16
0
    def stop(self, *, success=False):
        return self.gap.stop(success=success)

    @property
    def position(self):
        return self.gap.position


ugap = InsertionDevice('SR:C3-ID:G1{IVU20:1', name='ugap')
ugap.gap.user_readback.name = 'ugap_readback'
ugap.gap.user_setpoint.name = 'ugap_setpoint'

#ugap = UgapPositioner(prefix='', settle_time=3., name='ugap')

# Front End Slits (Primary Slits)
fe_tb = EpicsMotor('FE:C03A-OP{Slt:1-Ax:T}Mtr', name='fe_tb')
fe_bb = EpicsMotor('FE:C03A-OP{Slt:2-Ax:B}Mtr', name='fe_bb')
fe_ib = EpicsMotor('FE:C03A-OP{Slt:2-Ax:I}Mtr', name='fe_ib')
fe_ob = EpicsMotor('FE:C03A-OP{Slt:1-Ax:O}Mtr', name='fe_ob')

# Diamond XBPM motor
# xbpmb_x = EpicsMotor('XF:03IDB-OP{Slt:SSA1-Ax:8}Mtr', name='xbpmb_x')
# xbpmb_y = EpicsMotor('XF:03IDB-OP{Slt:SSA1-Ax:7}Mtr', name='xbpmb_y')

xbpmc_y = EpicsMotor('XF:03IDC-ES{BPM:7-Ax:Y}Mtr', name='xbpmc_y')

xbpmb_y = EpicsMotor('XF:03IDB-OP{Slt:SSA1-Ax:7}Mtr', name='xbpmb_y')
xbpmb_x = EpicsMotor('XF:03IDB-OP{Slt:SSA1-Ax:8}Mtr', name='xbpmb_x')

# Shutter operation
shutter_open = EpicsSignal('XF:03IDB-PPS{PSh}Cmd:Opn-Cmd', name='shutter_open')
Exemplo n.º 17
0
"Define motors related to optics"

from ophyd import EpicsMotor, Device
from ophyd import Component as Cpt

# A Hutch
## Filter
fltr6_y = EpicsMotor('XF:28IDA-OP:0{Fltr:6-Ax:Y}Mtr', name='fltr6_y')

## DLM
dlm_c1_bnd_bi = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:1-Ax:BndBI}Mtr',
                           name='dlm_c1_bnd_bi')
dlm_c1_bnd_bo = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:1-Ax:BndBO}Mtr',
                           name='dlm_c1_bnd_bo')
dlm_c1_bnd_ti = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:1-Ax:BndTI}Mtr',
                           name='dlm_c1_bnd_ti')
dlm_c1_bnd_to = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:1-Ax:BndTO}Mtr',
                           name='dlm_c1_bnd_to')
dlm_c1_p = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:1-Ax:P}Mtr', name='dlm_c1_p')
dlm_c1_xi = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:1-Ax:XI}Mtr',
                       name='dlm_c1_xi')
dlm_c1_xo = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:1-Ax:XO}Mtr',
                       name='dlm_c1_xo')
dlm_c2_bnd_bi = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:2-Ax:BndBI}Mtr',
                           name='dlm_c2_bnd_bi')
dlm_c2_bnd_bo = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:2-Ax:BndBO}Mtr',
                           name='dlm_c2_bnd_bo')
dlm_c2_bnd_ti = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:2-Ax:BndTI}Mtr',
                           name='dlm_c2_bnd_ti')
dlm_c2_bnd_to = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:2-Ax:BndTO}Mtr',
                           name='dlm_c2_bnd_to')
Exemplo n.º 18
0
from ophyd import EpicsMotor, EpicsSignalRO

run_report(__file__, text='most motor definitions')

from BMM.motors import FMBOEpicsMotor, XAFSEpicsMotor, VacuumEpicsMotor, EndStationEpicsMotor

mcs8_motors = list()

## front end slits
fe_slits_horizontal1 = EpicsMotor('FE:C06B-OP{Slt:1-Ax:Hrz}Mtr',
                                  name='fe_slits_horizontal1')
fe_slits_incline1 = EpicsMotor('FE:C06B-OP{Slt:1-Ax:Inc}Mtr',
                               name='fe_slits_incline1')
fe_slits_o = EpicsMotor('FE:C06B-OP{Slt:1-Ax:O}Mtr', name='fe_slits_o')
fe_slits_t = EpicsMotor('FE:C06B-OP{Slt:1-Ax:T}Mtr', name='fe_slits_t')
fe_slits_horizontal2 = EpicsMotor('FE:C06B-OP{Slt:2-Ax:Hrz}Mtr',
                                  name='fe_slits_horizontal2')
fe_slits_incline2 = EpicsMotor('FE:C06B-OP{Slt:2-Ax:Inc}Mtr',
                               name='fe_slits_incline2')
fe_slits_i = EpicsMotor('FE:C06B-OP{Slt:2-Ax:I}Mtr', name='fe_slits_i')
fe_slits_b = EpicsMotor('FE:C06B-OP{Slt:2-Ax:B}Mtr', name='fe_slits_b')
fe_slits_hsize = EpicsSignalRO('FE:C06B-OP{Slt:12-Ax:X}size',
                               name='fe_slits_hsize')
fe_slits_vsize = EpicsSignalRO('FE:C06B-OP{Slt:12-Ax:Y}size',
                               name='fe_slits_vsize')
fe_slits_hcenter = EpicsSignalRO('FE:C06B-OP{Slt:12-Ax:X}center',
                                 name='fe_slits_hcenter')
fe_slits_vcenter = EpicsSignalRO('FE:C06B-OP{Slt:12-Ax:Y}center',
                                 name='fe_slits_vcenter')

## collimating mirror
Exemplo n.º 19
0
class SolutionScatteringExperimentalModule():

    ctrl = SolutionScatteringControlUnit('XF:16IDC-ES:Sol{ctrl}',
                                         name='sol_ctrl')
    pcr_v_enable = EpicsSignal("XF:16IDC-ES:Sol{ctrl}SampleAligned"
                               )  # 1 means PCR tube holder can go up
    pcr_holder_down = EpicsSignal("XF:16IDC-ES:Sol{ctrl}HolderDown")
    EMready = EpicsSignal("XF:16IDC-ES:Sol{ctrl}EMSolReady")
    HolderPresent = EpicsSignal("XF:16IDC-ES:Sol{ctrl}HolderPresent")
    DoorOpen = EpicsSignal("XF:16IDC-ES:Sol{ctrl}DoorOpen")

    sample_y = EpicsMotor('XF:16IDC-ES:Sol{Enc-Ax:Yu}Mtr', name='sol_sample_y')
    holder_x = EpicsMotor('XF:16IDC-ES:Sol{Enc-Ax:Xl}Mtr', name='sol_holder_x')

    # the needles are designated 1 (upstream) and 2
    # the flow cells are designated 1 (bottom), 2 and 3
    # needle 1 is connected to the bottom flowcell, needle 2 connected to the top, HPLC middle
    flowcell_nd = {'upstream': 'top', 'downstream': 'bottom'}

    # the center flow flow cell should be aligned to the beam
    # the addtional positions are for the standard sample, a empty space for checking scattering background,
    #    and for the scintillator for check the beam shape
    # this information should be verified every time we setup for solution scattering
    flowcell_pos = {
        'bottom': 4.8,
        'middle': 0.165,
        'top': -4.1,
        "std": -12.,
        "empty": -15.,
        "scint": -17.
    }

    # this is the 4-port valve piosition necessary for the wash the needle
    p4_needle_to_wash = {'upstream': 1, 'downstream': 0}
    # this is the 4-port valve piosition necessary to load throug the needle
    p4_needle_to_load = {'upstream': 0, 'downstream': 1}
    needle_dirty_flag = {'upstream': True, 'downstream': True}
    tube_holder_pos = "down"
    bypass_tube_pos_ssr = False  # if true, ignore the optical sensor for tube holder position

    # need to home holder_x position to 0; use home_holder()
    # tube postion 1 is on the inboard side
    drain_pos = 0.
    park_pos = 33.0

    disable_flow_cell_move = False

    # selection valve in the syringe pump box, see sol_devices.py
    sel_valve = {'water': 1, 'N2': 0}
    # time needed to pump enough water to fill the drain well
    # assume that tube is empty
    wash_duration = 1.
    drain_duration = 2.

    # drain valve
    drain = {'upstream': ctrl.sv_drain1, 'downstream': ctrl.sv_drain2}

    # syringe pump
    default_piston_pos = 150
    default_pump_speed = 1500
    # SC changed the value from 600 on 7/9/17
    default_load_pump_speed = 350
    vol_p4_to_cell = {'upstream': -120, 'downstream': -120}
    # 2019/02/14, chaned from 132 to 127
    vol_tube_to_cell = {'upstream': 125, 'downstream': 125}
    vol_sample_headroom = 5  #2019/02/14 reduced from 13
    vol_flowcell_headroom = 15  #2019/02/14
    #mean_thresh = {'upstream': 75, 'downstream': 80} # Mean thresh added on 5/25/19 by SC
    #min_thresh = {'upstream': 12, 'downstream': 12} # Mean thresh added on 5/25/19 by SC
    #camera_trigger_thresh = 20

    # these numbers are for the 2016 version tube holder
    #tube1_pos = -15.95     # relative to well position
    #tube_spc = -9.0      # these are mechanically determined and should not change
    # 2017 march version of tube holder with alterate tube/empty holes
    Ntube = 18
    tube1_pos = -18.75  #12/20/17 by JB
    tube_spc = -5.8417  # these are mechanically determined and should not change

    default_dry_time = 30
    default_wash_repeats = 5

    # set up camera
    cam = setup_cam("XF:16IDA-BI{Cam:OAM}", "camOAM")

    def __init__(self):
        # important to home the stages !!!!!
        #     home sample y (SmarAct) from controller
        #     home sample_x and holder_x manually
        #          move stage to default position and set_current_position(0)
        #          sample_x: beam centered on cell,   holder_x: needles aligned to washing wells/drains
        #
        # load configuration
        #self.load_config(default_solution_scattering_config_file)
        self.return_piston_pos = self.default_piston_pos
        self.ctrl.pump_spd.put(self.default_pump_speed)
        self.ctrl.water_pump_spd.put(0.9)
        self.load_vol = 0

        self.holder_x.acceleration.put(0.2)
        self.holder_x.velocity.put(25)
        #self.sample_x.acceleration.put(0.2)
        #self.sample_x.velocity.put(5)

        self.int_handler = signal.getsignal(signal.SIGINT)

    def enable_ctrlc(self):
        if threading.current_thread() is threading.main_thread():
            signal.signal(signal.SIGINT, self.int_handler)
            print("ctrl-C re-enabled ...")
        else:
            print("not in the main thread, cannot change ctrl-C handler ... ")

    def disable_ctrlc(self):
        if threading.current_thread() is threading.main_thread():
            self.int_hanlder = signal.getsignal(signal.SIGINT)
            signal.signal(signal.SIGINT, signal.SIG_IGN)
            print("ctrl-C disabled ...")
        else:
            print("not in the main thread, cannot change ctrl-C handler ... ")

    # needle vs tube position
    # this applies for the tube holder that has the alternate tube/empty pattern
    # in the current design the even tube position is on the downstream side
    def verify_needle_for_tube(self, tn, nd):
        # if both are allowed, simpluy return nd
        #return nd
        if tn % 2 == 0:  # even tube number
            return ("upstream")
        else:  # odd tube number
            return ("downstream")

    def move_door(self, state):
        """ state = 'open'/'close'
        """
        if state not in ['open', 'close']:
            raise Exception("the door state should be either open or close.")

        if state == 'open':
            setSignal(sol.ctrl.sv_door_lower, 1)  #, sol.DoorOpen)
        else:
            setSignal(sol.ctrl.sv_door_lower, 0)  #, sol.DoorOpen)

    # homing procedure without encoder strip [obsolete]:
    #     reduce motor current, drive sol.holder_x in the possitive direction to hit the hard stop
    #     move the motor back by 0.5mm, set the current position to 37.5 ("park" position)
    #     set software limits:
    #          caput("XF:16IDC-ES:Sol{Enc-Ax:Xl}Mtr.LLM", -119)
    #          caput("XF:16IDC-ES:Sol{Enc-Ax:Xl}Mtr.HLM", 31.5)
    #     change the motor current back
    # keep motor current low?
    def home_holder(self):
        mot = sol.holder_x

        self.move_door('open')
        mot.velocity.put(25)
        caput(mot.prefix + ".HLM", mot.position + 160)
        # move holder_x to hard limit toward the door
        mot.move(mot.position + 155)
        while mot.moving:
            sleep(0.5)

        # washing well position will be set to zero later
        # the value of the park position is also the distance between "park" and "wash"
        mot.move(mot.position - self.park_pos + 0.5)

        pv = 'XF:16IDC-ES:Sol{ctrl}SampleAligned'

        while caget(pv) == 0:
            mot.move(mot.position - 0.1)
        p1 = mot.position

        mot.move(p1 - 1)
        while caget(pv) == 0:
            mot.move(mot.position + 0.1)
        p2 = mot.position

        mot.move((p1 + p2) / 2)
        while mot.moving:
            sleep(0.5)
        mot.set_current_position(0)
        #caput(mot.prefix+".LLM", self.tube1_pos+self.tube_spc*(self.Ntube-1)-0.5)
        caput(mot.prefix + ".HLM", self.park_pos + 0.5)
        caput(mot.prefix + ".LLM",
              self.tube1_pos + self.tube_spc * (self.Ntube - 1) - 0.5)

        self.move_door('close')

    def save_config(self):
        pass

    def load_config(self, fn):
        pass

    def floating_threshold(self):
        base_mean = self.cam.stats1.mean_value.get()
        base_min = self.cam.stats1.min_value.get()
        mean_thresh = base_mean + 10
        min_thresh = base_min + 10
        return mean_thresh, min_thresh

    def select_flow_cell(self, cn):
        if self.disable_flow_cell_move:
            print("flow cell motion disabled !!!")
        else:
            #self.sample_y.home('forward')
            print('move to flow cell %s ...' % cn)
            self.sample_y.move(self.flowcell_pos[cn])

    def select_tube_pos(self, tn):
        ''' 1 argument accepted: 
            position 1 to 18 from, 1 on the inboard side
            position 0 is the washing well 
        '''
        # any time the sample holder is moving, the solution EM is no longer ready
        setSignal(self.EMready, 0)

        if tn not in range(0, self.Ntube + 1) and tn != 'park':
            raise RuntimeError(
                'invalid tube position %d, must be 0 (drain) or 1-18, or \'park\' !!'
                % tn)
        if self.pcr_holder_down.get() != 1:
            self.move_tube_holder("down")
            #raise RuntimeError('Cannot move holder when it is not down!!')

        self.tube_pos = tn
        if tn == 'park':
            self.move_door('open')
            self.holder_x.move(self.park_pos)
            print('move to PCR tube holder park position ...')
        else:
            pos = self.drain_pos
            if tn > 0:
                pos += (self.tube1_pos + self.tube_spc * (tn - 1))
            print('move to PCR tube position %d ...' % tn)
            self.holder_x.move(pos)

        while self.holder_x.moving:
            sleep(0.5)
        print('motion completed.')
        if tn == 'park':
            setSignal(self.EMready, 1)
        elif self.DoorOpen.get() == 1:
            self.move_door('close')

    def move_tube_holder(self, pos, retry=5):
        '''1 argument accepted:
           'up' or 'down'
           up allowed only when the hodler is anligned to needle
        '''
        if pos == 'down':
            print('moving PCR tube holder down ...')
            while retry > 0:
                self.ctrl.sv_pcr_tubes.put('down')
                self.ctrl.wait()
                # wait for the pneumatic actuator to settle
                #addtition of new position sensor for sample holder actuator 12/2017:
                if self.pcr_holder_down.get() == 1:
                    break
                sleep(0.5)
                retry -= 1
            if retry == 0:
                raise Exception("could not move the holder down.")
            self.tube_holder_pos = "down"
        elif pos == 'up':
            # if self.pcr_v_enable.get()==0 and (self.holder_x.position**2>1e-4 and self.tube_pos!=12):
            # revised by LY, 2017Mar23, to add bypass
            if self.pcr_v_enable.get(
            ) == 0 and self.bypass_tube_pos_ssr == False:
                raise RuntimeError(
                    'attempting to raise PCR tubes while mis-aligned !!')
            print('moving PCR tube holder up ...')
            self.ctrl.sv_pcr_tubes.put('up')
            self.ctrl.wait()
            self.tube_holder_pos = "up"

    def wash_needle(self, nd, repeats=-1, dry_duration=-1, option=None):
        """ option: "wash only", skip drying
                    "dry only", skip washing
        """
        if nd not in ('upstream', 'downstream'):
            raise RuntimeError(
                'unrecoganized neelde (must be \'upstream\' or \'downstream\') !!',
                nd)

        if dry_duration < 0:
            dry_duration = self.default_dry_time
        if repeats < 0:
            repeats = self.default_wash_repeats

        self.select_tube_pos(0)

        self.ctrl.vc_4port.put(self.p4_needle_to_wash[nd])
        self.move_tube_holder('up')

        if option != "dry only":
            # the selection valve might leak water, disable ctrl-C until the valve is switched back to N2
            self.disable_ctrlc()
            self.ctrl.sv_sel.put(self.sel_valve['water'])
            for n in range(repeats):
                print("current wash loop %d of %d" % (n + 1, repeats))
                # first turn on watch to fill the drain well
                self.ctrl.water_pump.put('on')
                sleep(self.wash_duration)
                # now turn on the drain but keep flushing water
                self.drain[nd].put('on')
                sleep(self.drain_duration)
                # turn off water first
                self.ctrl.water_pump.put('off')
                self.drain[nd].put('off')
            self.ctrl.sv_sel.put(self.sel_valve['N2'])
            self.enable_ctrlc()

        if option != "wash only":
            self.drain[nd].put('on')
            self.ctrl.sv_sel.put(self.sel_valve['N2'])
            self.ctrl.sv_N2.put('on')
            countdown("drying for ", dry_duration)
            self.ctrl.sv_N2.put('off')
            self.drain[nd].put('off')

            self.needle_dirty_flag[nd] = False

        self.move_tube_holder('down')

    def reload_syringe_pump(self):
        # make room to load sample from the PCR tube
        if np.fabs(self.ctrl.piston_pos.get() - self.default_piston_pos) < 1.:
            return

        print(time.asctime(), ": reloading the syringe pump.")
        self.ctrl.pump_spd.put(self.default_pump_speed)
        self.ctrl.valve_pos.put("res")
        self.ctrl.pump_mvA(self.default_piston_pos)
        self.ctrl.wait()
        print(time.asctime(), ": finished reloading the syringe pump.")

    def prepare_to_load_sample(self, tn, nd=None):
        nd = self.verify_needle_for_tube(tn, nd)
        if self.needle_dirty_flag[nd]:
            self.wash_needle(nd)
        self.select_tube_pos(tn)

    def load_water(self, nd=None):
        #loading water for reference measurement
        self.ctrl.vc_4port.put(self.p4_needle_to_load[nd])
        # make room to load sample from teh PCR tube
        self.ctrl.pump_spd.put(self.default_pump_speed)
        self.ctrl.valve_pos.put("res")
        print('loading water')
        self.ctrl.pump_mvA(self.default_piston_pos)
        self.ctrl.wait()
        self.ctrl.valve_pos.put("sam")
        print('towards cell')
        # fill the tubing with water only upto the end of the flow channel
        self.ctrl.pump_mvR(self.vol_p4_to_cell[nd])
        self.ctrl.wait()
        self.ctrl.pump_mvR(-45)

    def load_sample(self, vol, nd=None):
        nd = self.verify_needle_for_tube(self.tube_pos, nd)
        if nd not in ('upstream', 'downstream'):
            raise RuntimeError(
                'unrecoganized neelde (must be \'upstream\' or \'downstream\') !!',
                nd)

        self.needle_dirty_flag[nd] = True

        self.ctrl.vc_4port.put(self.p4_needle_to_load[nd])
        # make room to load sample from teh PCR tube
        self.ctrl.pump_spd.put(self.default_pump_speed)
        self.ctrl.valve_pos.put("res")
        self.ctrl.pump_mvA(self.default_piston_pos)
        self.ctrl.wait()
        self.ctrl.valve_pos.put("sam")
        print('4p valve to flowcell')
        # fill the tubing with water only upto the end of the flow channel
        self.ctrl.pump_mvR(self.vol_p4_to_cell[nd])
        self.ctrl.wait()

        self.return_piston_pos = self.ctrl.piston_pos.get()
        a = self.return_piston_pos
        self.ctrl.pump_spd.put(self.default_load_pump_speed)
        self.move_tube_holder('up')
        print("loading sample")
        self.load_vol = vol
        self.ctrl.pump_mvR(vol)
        #self.ctrl.pump_mvR(self.vol_tube_to_cell[nd]) ## load the sample fron the PCR tube into the cell
        self.ctrl.wait()
        self.move_tube_holder('down')
        if self.pcr_holder_down.get() == 0:
            raise RuntimeError('sample holder is not down!!')
        else:
            print('Sample holder is down.')
        #self.ctrl.pump_mvA(self.return_piston_pos+self.vol_tube_to_cell[nd])
        #self.ctrl.wait()

    def prepare_to_measure(self, nd, wait=True):
        """ move the sample from the injection needle to just before the sample cell
            self.return_piston_pos is the piston position before the sample aspirated into the needle 
        """
        print("moving sample closer to cell")
        self.ctrl.pump_mvA(self.return_piston_pos + self.vol_tube_to_cell[nd])
        if wait:
            self.ctrl.wait()

    def prepare_to_return_sample(self, wait=True):
        """ move the sample back to the injection needle
            self.return_piston_pos is the piston position before the sample aspirated into the needle 
        """
        self.ctrl.pump_mvA(self.return_piston_pos + self.load_vol)
        if wait:
            self.ctrl.wait()

    def check_pilatus_detectors(self):
        """ make sure that only externally triggered Pilatus are used in data collection
        """
        for det in DETS:
            if det.__class__ != LIXPilatusExt:
                raise Exception(
                    "only LIXPilatusExt can be used in data collection: {det.__class__}"
                )

    def collect_data(self,
                     vol=45,
                     exp=2,
                     repeats=3,
                     sample_name='test',
                     check_sname=True):
        self.check_pilatus_detectors()
        mean_thresh, min_thresh = self.floating_threshold()
        nd = self.verify_needle_for_tube(self.tube_pos, nd=None)

        pilatus_ct_time(exp)
        pilatus_number_reset(True)
        #print(self.mean_thresh[nd])
        #print(self.min_thresh[nd])
        change_sample(sample_name, check_sname=check_sname)
        set_pil_num_images(repeats)

        # pump_spd unit is ul/min
        self.ctrl.pump_spd.put(
            60. * vol / (repeats * exp)
        )  # *0.85) # this was necesary when there is a delay between frames

        # stage the pilatus detectors first to be sure that the detector are ready
        stage_pilatus(multitrigger=False)
        pilatus_trigger_lock.acquire()
        self.ctrl.pump_mvR(vol + self.vol_flowcell_headroom)
        # monitor sample arrival on the camera [update on 5/25/19 to use mean and min thresh]
        threading.Thread(target=self.cam.watch_for_change,
                         args=(
                             mean_thresh,
                             min_thresh,
                             pilatus_trigger_lock,
                         )).start()
        #args=(self.mean_thresh[nd], self.min_thresh[nd], pilatus_trigger_lock,)).start() Threshold changed from fixed to floating --SC 6/10/19

        em1.averaging_time.put(0.25)
        em2.averaging_time.put(0.25)
        em1.acquire.put(1)
        em2.acquire.put(1)
        sd.monitors = [em1.sum_all.mean_value, em2.sum_all.mean_value]
        # num=1 due to stage_pilatus(multitrigger=False)
        RE(ct(DETS, num=1))
        sd.monitors = []
        change_sample()

        self.ctrl.wait()
        self.ctrl.pump_spd.put(self.default_pump_speed)

    def return_sample(self):
        ''' assuming that the sample has just been measured
            dump the sample back into the PCR tube
        '''
        self.ctrl.valve_pos.put("sam")
        self.move_tube_holder('up')
        self.ctrl.pump_mvA(self.return_piston_pos)
        self.ctrl.wait()
        self.move_tube_holder('down')

    def measure(self,
                tn,
                nd=None,
                vol=50,
                exp=5,
                repeats=3,
                sample_name='test',
                delay=0,
                returnSample=True,
                washCell=True,
                concurrentOp=False,
                check_sname=True):
        ''' tn: tube number: 1-18
            exp: exposure time
            repeats: # of exposures
            returnSample: if False, the sample is washed into the drain, can save time
            concurrentOp: wash the other cell while the scattering measurement takes place
            washCell: wash cell after the measurements, ignored if running concurrent ops 
            delay: pause after load_sample, may be useful for temperature control    
        '''

        nd = self.verify_needle_for_tube(tn, nd)
        # this should have been completed already in normal ops
        if self.needle_dirty_flag[nd]:
            self.wash_needle(nd)

        self.select_tube_pos(tn)
        # load_sample() knows which injection needle to use
        # headroom may need to be adjusted depending on the mode of operations
        # can be minimal if sample cam is used to trigger data collection, but never zero
        print('loading')
        self.load_sample(vol + self.vol_sample_headroom)
        print('done')
        # this is where operations can be concurrent on both flow channels
        if concurrentOp:
            # the other needle
            nd1 = self.verify_needle_for_tube(tn + 1, nd)
            th = threading.Thread(target=self.wash_needle, args=(nd1, ))
            th.start()

        # move the sample to just before the flow cell
        self.select_flow_cell(self.flowcell_nd[nd])
        self.prepare_to_measure(nd)
        if delay > 0:
            countdown("delay before exposure:", delay)

        print('****************')
        print('collecting data %s' % sample_name)
        self.collect_data(vol,
                          exp,
                          repeats,
                          sample_name,
                          check_sname=check_sname)

        if returnSample:
            # move the sample back to the end of the injection needle
            self.prepare_to_return_sample()

        if concurrentOp:
            # get the syringe pump ready for the next step
            self.reload_syringe_pump()
            # make sure wash_needel() is completed for the other needle
            th.join()
        # end of concurrent operations

        if returnSample:
            self.select_tube_pos(tn)
            self.return_sample()
        if washCell and not concurrentOp:
            th = threading.Thread(target=self.wash_needle, args=(nd, ))
            th.start()
            self.reload_syringe_pump()
            th.join()

    def mov_delay(self, length):
        while self.ctrl.ready.get() == 0:
            sleep(0.2)
        self.ctrl.ready.put(0)
        #mov_all(self.sample_x,-length,wait=False,relative=True)

    ## This is specific to the multi-position holder for "sticky" samples
    def meas_opencell(self, exp, repeats, sample_name='test'):
        pilatus_ct_time(exp)
        pilatus_number_reset(False)

        DETS = [em1, em2, pil1M, pilW1, pilW2]
        set_pil_num_images(repeats)
        length = 7.5
        #self.ctrl.wait()
        #self.sample_x.velocity.put(length/((repeats*exp)+4))
        th = threading.Thread(target=self.mov_delay, args=(length, ))
        th.start()
        RE(count_fs(DETS, num=1))
Exemplo n.º 20
0
from ophyd import EpicsMotor

th = EpicsMotor('XF:04IDD-ES:1{Dif:ISD-Ax:th}Mtr',
                name='th',
                labels=['optics'])
zeta = EpicsMotor('XF:04IDD-ES:1{Dif:ISD-Ax:zeta}Mtr',
                  name='zeta',
                  labels=['optics'])
Exemplo n.º 21
0

class MCM(Device):
    x = Cpt(MCMBase, '', ch_name='-Ax:X}Mtr')
    y = Cpt(MCMBase, '', ch_name='-Ax:Y}Mtr')
    z = Cpt(MCMBase, '', ch_name='-Ax:Z}Mtr')
    theta = Cpt(MCMBase, '', ch_name='-Ax:Rx}Mtr')
    phi = Cpt(MCMBase, '', ch_name='-Ax:Ry}Mtr')
    chi = Cpt(MCMBase, '', ch_name='-Ax:Rz}Mtr')


dcm = DCM('XF:10IDA-OP{Mono:DCM', name='dcm')
vfm = VFM('XF:10IDD-OP{VFM:1', name='vfm')
hfm = HFM('XF:10IDD-OP{HFM:1', name='hfm')
hrm2 = HRM2('XF:10IDB-OP{Mono:HRM2', name='hrm2')

s1 = Blades('XF:10IDA-OP{Slt:1', name='s1')
s2 = Blades('XF:10IDC-OP{Slt:4', name='s2')
s3 = Blades('XF:10IDD-OP{Slt:5', name='s3')

bpm1 = XYMotor('XF:10IDA-OP{BPM:1', name='bpm1')
bpm1_diag = EpicsMotor('XF:10IDA-BI{BPM:1-Ax:YFoil}Mtr', name='bpm1_diag')
bpm2 = XYMotor('XF:10IDC-OP{BPM:2', name='bpm2')
bpm2_diag = EpicsMotor('XF:10IDC-BI{BPM:2-Ax:Y}Mtr', name='bpm2_diag')

ssa = SSA('XF:10IDB-OP{SSA:1', name='ssa')
k3 = Table('XF:10IDC-OP{Tbl:1', name='k3')
ph = Pinhole('XF:10IDD-OP{Pinh:1', name='ph')

mcm = MCM('XF:10IDD-OP{MCM:1', name='mcm')
Exemplo n.º 22
0
class PositioningStack():
    # coarse x, Misumi
    xc = EpicsMotor('XF:16IDC-ES:Scan{Ax:XC}Mtr', name='ss_xc')
    # Newport pusher
    z = EpicsMotor('XF:16IDC-ES:Scan{Ax:Z}Mtr', name='ss_z')
                            ['inb', 46, 'out', 46, 'bot', 38, 'top', 33]
                        },
                        name='dcslt')

m4slt = BaffleSlitClass('XF:02IDC-OP{Mir:4-Slt:18_U_1',
                        locations={
                            'close': ['inb', 5, 'out', 5, 'bot', 5, 'top', -8],
                            'open': ['inb', 0, 'out', 10, 'bot', 0, 'top', 0]
                        },
                        name='m4slt')

#Definition of Device Groups

diagnostics = PreDefinedPositionsGroup(
    [m3diag, gcdiag], {'test_location': ['m3diag', 'out', 'gcdiag', 'out']},
    name='diagnostics')

#Below is some carry over definitions for devices that should be defined above but which are yet to be.

m4_diag1 = EpicsMotor('XF:02IDC-OP{Mir:4-Diag:17_U_1-Ax:1}Mtr',
                      name='m4_diag1')
m4_diag2 = EpicsMotor('XF:02IDC-OP{Mir:4-Diag:17_U_1-Ax:2}Mtr',
                      name='m4_diag2')
m4_diag3 = EpicsMotor('XF:02IDC-OP{Mir:4-Diag:17_U_1-Ax:3}Mtr',
                      name='m4_diag3')

m5_RPD = EpicsMotor('XF:02IDD-ES{Mir:5-Ax:RPD}Mtr', name='m5_RPD')

SC_QPD = EpicsMotor('XF:02IDD-ES{SC:1-Ax:QPD}Mtr', name='SC_QPD')
SC_IO = EpicsMotor('XF:02IDD-ES{SC:1-Ax:IO}Mtr', name='m5_RPD')
Exemplo n.º 24
0
'''A simple test for :class:`EpicsMotor`'''

import config
from ophyd import EpicsMotor


def callback(sub_type=None, timestamp=None, value=None, **kwargs):
    logger.info('[callback] [%s] (type=%s) value=%s', timestamp, sub_type,
                value)


def done_moving(**kwargs):
    logger.info('Done moving %s', kwargs)


logger = config.logger

motor_record = config.motor_recs[0]

m1 = EpicsMotor(motor_record)
m1.wait_for_connection()

m1.subscribe(callback, event_type=m1.SUB_DONE)
m1.subscribe(callback, event_type=m1.SUB_READBACK)

logger.info('---- test #1 ----')
logger.info('--> move to 1')
m1.move(1)
logger.info('--> move to 0')
m1.move(0)
"Define all the motors on the beamline"

from ophyd import EpicsMotor
import ophyd
from ophyd import EpicsSignal

th_cal = EpicsMotor('XF:28IDC-ES:1{Dif:2-Ax:Th}Mtr', name='th_cal')
tth_cal = EpicsMotor('XF:28IDC-ES:1{Dif:2-Ax:2Th}Mtr', name='tth_cal')

# Tim test with Sanjit. Delete it if anything goes wrong
ss_stg2_x = EpicsMotor('XF:28IDC-ES:1{Stg:Smpl2-Ax:X}Mtr', name='ss_stg2_x')
# Sanjit Inlcuded this. Delete it if anything goes wrong
ss_stg2_y = EpicsMotor('XF:28IDC-ES:1{Stg:Smpl2-Ax:Y}Mtr', name='ss_stg2_y')
ss_stg2_z = EpicsMotor('XF:28IDC-ES:1{Stg:Smpl2-Ax:Z}Mtr', name='ss_stg2_z')

# RPI DIFFRACTOMETER motors ### Change th only after changing in other plans
th = EpicsMotor('XF:28IDC-ES:1{Dif:1-Ax:Th}Mtr', name='th')
tth = EpicsMotor('XF:28IDC-ES:1{Dif:1-Ax:2ThI}Mtr', name='tth')
diff_x = EpicsMotor('XF:28IDC-ES:1{Dif:1-Ax:X}Mtr', name='diff_x')
diff_y = EpicsMotor('XF:28IDC-ES:1{Dif:1-Ax:Y}Mtr', name='diff_y')
diff_tth_i = EpicsMotor('XF:28IDC-ES:1{Dif:1-Ax:2ThI}Mtr', name='diff_tth_i')
diff_tth_o = EpicsMotor('XF:28IDC-ES:1{Dif:1-Ax:2ThO}Mtr', name='diff_tth_o')

hrm_y = EpicsMotor('XF:28IDC-OP:1{Mono:HRM-Ax:Y}Mtr', name='hrm_y')
hrm_b = EpicsMotor('XF:28IDC-OP:1{Mono:HRM-Ax:P}Mtr', name='hrm_b')
hrm_r = EpicsMotor('XF:28IDC-OP:1{Mono:HRM-Ax:R}Mtr', name='hrm_r')

shctl1 = EpicsMotor('XF:28IDC-ES:1{Sh2:Exp-Ax:5}Mtr', name='shctl1')


class FilterBank(ophyd.Device):
Exemplo n.º 26
0
    '''HXN X/Y positioner device'''
    x = Cpt(EpicsMotor, '-Ax:X}Mtr')
    y = Cpt(EpicsMotor, '-Ax:Y}Mtr')


class HxnXYPitchPositioner(MotorBundle):
    '''HXN X/Y/Pitch positioner'''
    x = Cpt(EpicsMotor, '-Ax:X}Mtr')
    y = Cpt(EpicsMotor, '-Ax:Y}Mtr')
    p = Cpt(EpicsMotor, '-Ax:P}Mtr')


bpm1 = HxnXYPositioner('XF:03IDA-OP{BPM:1', name='bpm1')
bpm2 = HxnXYPositioner('XF:03IDA-OP{BPM:2', name='bpm2')

bpm3_x = EpicsMotor('XF:03IDA-OP{BPM:3-Ax:X}Mtr', name='bpm3_x')
fs1_y = EpicsMotor('XF:03IDA-OP{FS:1-Ax:Y}Mtr', name='fs1_y')
bpm4_y = EpicsMotor('XF:03IDA-OP{BPM:4-Ax:Y}Mtr', name='bpm4_y')
bpm5_y = EpicsMotor('XF:03IDA-OP{BPM:5-Ax:Y}Mtr', name='bpm5_y')

# Diagnostic Manipulators
fl1_y = EpicsMotor('XF:03IDA-OP{Flr:1-Ax:Y}Mtr', name='fl1_y')
fl2_y = EpicsMotor('XF:03IDA-OP{Flr:2-Ax:Y}Mtr', name='fl2_y')

crl = HxnXYPitchPositioner('XF:03IDA-OP{Lens:CRL', name='crl')

# # nanoBPM2@SSA1
# nano2y = EpicsMotor('XF:03IDB-OP{BPM:6-Ax:Y}Mtr', name='nano2y')
#
# # nanoBPM3@SSA2
# nano3y = EpicsMotor('XF:03IDC-OP{BPM:7-Ax:Y}Mtr', name='nano3y')
from ophyd import EpicsMotor, Device, Component as Cpt

det1_x = EpicsMotor('XF:04BMC-ES{DET:1-Ax:X}Mtr', name='det1_x')
Exemplo n.º 28
0
"""
lesson 3 : create the motor and scaler
"""

__all__ = [
    'm1',
    'scaler',
]

from ...session_logs import logger
logger.info(__file__)

from ophyd import EpicsMotor
from ophyd.scaler import ScalerCH

P = "sky:"
m1 = EpicsMotor(f"{P}m1", name="m1")
scaler = ScalerCH(f"{P}scaler1", name="scaler")

m1.wait_for_connection()
scaler.wait_for_connection()

scaler.select_channels(None)
Exemplo n.º 29
0
"""
APS only: connect with facility information
"""

__all__ = [
    'aps',
    # 'undulator',
]

from ..session_logs import logger
logger.info(__file__)

from ophyd import EpicsMotor, EpicsSignal
from ophyd.scaler import ScalerCH

tth = EpicsMotor('29idKappa:m9', name='tth', labels=('motor', ))  # Two Theta
# 1: MOT001 =    NONE   2000  1  2000  200   50  125    0 0x003       th  Theta  # Theta
# 2: MOT002 =    NONE   2000  1  2000  200   50  125    0 0x003      chi  Chi  # Chi
# 3: MOT003 =    NONE   2000  1  2000  200   50  125    0 0x003      phi  Phi  # Phi
kth = EpicsMotor('29idKappa:m8', name='kth', labels=('motor', ))  # K_Theta
kap = EpicsMotor('29idKappa:m7', name='kap', labels=('motor', ))  # Kappa
kphi = EpicsMotor('29idKappa:m1', name='kphi', labels=('motor', ))  # K_Phi
s1at = EpicsMotor('29idb:m9', name='s1at', labels=('motor', ))  # Sl1A top
s1ai = EpicsMotor('29idb:m10', name='s1ai', labels=('motor', ))  # Sl1A inb
s1ao = EpicsMotor('29idb:m11', name='s1ao', labels=('motor', ))  # Sl1A out
s1ab = EpicsMotor('29idb:m12', name='s1ab', labels=('motor', ))  # Sl1A bot
s2ai = EpicsMotor('29idb:m13', name='s2ai', labels=('motor', ))  # Sl2A inb
s2ao = EpicsMotor('29idb:m14', name='s2ao', labels=('motor', ))  # Sl2A out
s2ab = EpicsMotor('29idb:m15', name='s2ab', labels=('motor', ))  # Sl2A bot
s2at = EpicsMotor('29idb:m16', name='s2at', labels=('motor', ))  # Sl2A top
slit3b = EpicsMotor('29idb:m26', name='slit3b',
Exemplo n.º 30
0
#pgm_en = PGMEnergy('XF:23ID1-OP{Mono', name='pgm_en')
pgm_energy = pgm.energy
pgm_energy.name = 'pgm_energy'
pgm.energy.read_attrs = ['readback', 'setpoint']


class SlitsGapCenter(Device):
    xg = Cpt(EpicsMotor, '-Ax:XGap}Mtr')
    xc = Cpt(EpicsMotor, '-Ax:XCtr}Mtr')
    yg = Cpt(EpicsMotor, '-Ax:YGap}Mtr')
    yc = Cpt(EpicsMotor, '-Ax:YCtr}Mtr')


# Slits
slt1 = SlitsGapCenter('XF:23ID2-OP{Slt:1', name='slt1')
slt2 = EpicsMotor('XF:23ID2-OP{Slt:2-Ax:Y}Mtr', name='slt2')

# Diagnostic Manipulators

diag1_y = EpicsMotor('XF:23ID2-BI{Diag:1-Ax:Y}Mtr', name='diag1_y')
diag3_y = EpicsMotor('XF:23ID2-BI{Diag:3-Ax:Y}Mtr', name='diag3_y')
diag4_y = EpicsMotor('XF:23ID2-BI{Diag:4-Ax:Y}Mtr', name='diag4_y')
au_mesh = EpicsMotor('XF:23ID2-BI{AuMesh:1-Ax:Y}Mtr', name='au_mesh')

# IOXAS manipulator

ioxas_x = EpicsMotor('XF:23ID2-BI{IOXAS:1-Ax:X}Mtr', name='ioxas_x')

# Vortex manipulator

vortex_x = EpicsMotor('XF:23ID2-BI{Vortex:1-Ax:X}Mtr', name='vortex_x')
Exemplo n.º 31
0
    status_pv = Cpt(EpicsSignalRO, 'XF:12IDA-BI:2{EM:BPM1}DAC3')
    status = Cpt(Signal, value='')

    def check_status(self):
        if int(self.status_pv.get()) == 7:
            self.status.put('Closed')
        elif int(self.status_pv.get()) == 0:
            self.status.put('Open')
        else:
            raise RuntimeError(f'Shutter "{self.name}" is in a weird state.')

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.check_status()

    def open(self):
        self.open_cpt.put(1)
        self.check_status()

    def close(self):
        self.close_cpt.put(1)
        self.check_status()


fs = SMIFastShutter('', name='fs')

#What is the difference between both
fshutter = EpicsMotor('XF:12IDC:2{Sh:E-Ax:Y}Mtr', name='fshutter')

GV7 = TwoButtonShutter('XF:12IDC-VA:2{Det:1M-GV:7}', name='GV7')
Exemplo n.º 32
0
"""
lesson 2 : create the motor and scaler
"""

__all__ = [
    'm1',
    'scaler',
]

from ...session_logs import logger
logger.info(__file__)

from apstools.devices import use_EPICS_scaler_channels
from ophyd import EpicsMotor
from ophyd.scaler import ScalerCH

m1 = EpicsMotor("sky:m1", name="m1")
scaler = ScalerCH("sky:scaler1", name="scaler")

m1.wait_for_connection()
scaler.wait_for_connection()

scaler.match_names()
use_EPICS_scaler_channels(scaler)
Exemplo n.º 33
0
    x=Cpt(EpicsMotor, 'Ax:X}Mtr')
    y=Cpt(EpicsMotor, 'Ax:Y}Mtr')
    z=Cpt(EpicsMotor, 'Ax:Z}Mtr')      
   
#######################################################
### LIX First Optical Enclosure FOE Optics Hutch A
#######################################################

## White Beam Mirror
wbm = XYPitchMotor('XF:16IDA-OP{Mir:WBM', name='wbm')

## Si(111) Mono DCM
mono = MonoDCM("XF:16IDA-OP{Mono:DCM", name="dcm")

## Beam-viewing screen #3
scn3y = EpicsMotor('XF:16IDA-BI{FS:3-Ax:Y}Mtr', name='scn3y')

## Beam-viewing screen #4
scn4y = EpicsMotor('XF:16IDA-BI{FS:4-Ax:Y}Mtr', name='scn4y')

## KB Mirror System
# Horizontal
hfm = KBMirrorHorizontal('XF:16IDA-OP{Mir:KBH', name="hfm")
# Vertical
vfm = KBMirrorVertical('XF:16IDA-OP{Mir:KBV', name='vfm')

## Slits
mps = Blades('XF:16IDA-OP{Slt:1', name='mps')


#######################################################
Exemplo n.º 34
0
"Define all the motors on the beamline"

from ophyd import EpicsMotor
import ophyd
from ophyd import EpicsSignal

th_cal = EpicsMotor('XF:28IDC-ES:1{Dif:2-Ax:Th}Mtr', name='th_cal')
tth_cal = EpicsMotor('XF:28IDC-ES:1{Dif:2-Ax:2Th}Mtr', name='tth_cal')
ecal_x = EpicsMotor('XF:28IDC-ES:1{Dif:2-Ax:X}Mtr', name='ecal_x')
ecal_y = EpicsMotor('XF:28IDC-ES:1{Dif:2-Ax:Y}Mtr', name='ecal_y')

# Tim test with Sanjit. Delete it if anything goes wrong
ss_stg2_x = EpicsMotor('XF:28IDC-ES:1{Stg:Smpl2-Ax:X}Mtr', name='ss_stg2_x')
# Sanjit Inlcuded this. Delete it if anything goes wrong
ss_stg2_y = EpicsMotor('XF:28IDC-ES:1{Stg:Smpl2-Ax:Y}Mtr', name='ss_stg2_y')
ss_stg2_z = EpicsMotor('XF:28IDC-ES:1{Stg:Smpl2-Ax:Z}Mtr', name='ss_stg2_z')

# RPI DIFFRACTOMETER motors ### Change th only after changing in other plans
th = EpicsMotor('XF:28IDC-ES:1{Dif:1-Ax:Th}Mtr', name='th')
tth = EpicsMotor('XF:28IDC-ES:1{Dif:1-Ax:2ThI}Mtr', name='tth')
diff_x = EpicsMotor('XF:28IDC-ES:1{Dif:1-Ax:X}Mtr', name='diff_x')
diff_y = EpicsMotor('XF:28IDC-ES:1{Dif:1-Ax:Y}Mtr', name='diff_y')
diff_tth_i = EpicsMotor('XF:28IDC-ES:1{Dif:1-Ax:2ThI}Mtr', name='diff_tth_i')
diff_tth_o = EpicsMotor('XF:28IDC-ES:1{Dif:1-Ax:2ThO}Mtr', name='diff_tth_o')

hrm_y = EpicsMotor('XF:28IDC-OP:1{Mono:HRM-Ax:Y}Mtr', name='hrm_y')
hrm_b = EpicsMotor('XF:28IDC-OP:1{Mono:HRM-Ax:P}Mtr', name='hrm_b')
hrm_r = EpicsMotor('XF:28IDC-OP:1{Mono:HRM-Ax:R}Mtr', name='hrm_r')

# PE detector motions
pe1_x = EpicsMotor('XF:28IDC-ES:1{Det:PE1-Ax:X}Mtr', name='pe1_x')
Exemplo n.º 35
0
print(f'Loading {__file__}...')

from ophyd import EpicsMotor
sam_X = EpicsMotor('XF:07ID2-ES1{Stg-Ax:X}Mtr',
                   name='RSoXS Sample Outboard-Inboard',
                   kind='hinted')
sam_Y = EpicsMotor('XF:07ID2-ES1{Stg-Ax:Y}Mtr',
                   name='RSoXS Sample Up-Down',
                   kind='hinted')
sam_Z = EpicsMotor('XF:07ID2-ES1{Stg-Ax:Z}Mtr',
                   name='RSoXS Sample Downstream-Upstream',
                   kind='hinted')
sam_Th = EpicsMotor('XF:07ID2-ES1{Stg-Ax:Yaw}Mtr',
                    name='RSoXS Sample Rotation',
                    kind='hinted')
BSw = BeamStopW = EpicsMotor('XF:07ID2-ES1{BS-Ax:1}Mtr',
                             name='Beam Stop WAXS',
                             kind='hinted')
BSs = BeamStopS = EpicsMotor('XF:07ID2-ES1{BS-Ax:2}Mtr',
                             name='Beam Stop SAXS',
                             kind='hinted')
Det_W = EpicsMotor('XF:07ID2-ES1{Det-Ax:1}Mtr',
                   name='Detector WAXS Translation',
                   kind='hinted')
Det_S = EpicsMotor('XF:07ID2-ES1{Det-Ax:2}Mtr',
                   name='Detector SAXS Translation',
                   kind='hinted')
Shutter_Y = EpicsMotor('XF:07ID2-ES1{FSh-Ax:1}Mtr',
                       name='Shutter Vertical Translation',
                       kind='hinted')
Izero_Y = EpicsMotor('XF:07ID2-ES1{Scr-Ax:1}Mtr',