예제 #1
0
파일: motor.py 프로젝트: gitcyc/pypvserver
def test(motor_record='XF:31IDA-OP{Tbl-Ax:X1}Mtr'):
    config.setup_logging([__name__, 'pypvserver.motor'])
    server = config.get_server()
    mrec = EpicsMotor(motor_record)

    # give the motor time to connect
    time.sleep(1.0)

    logger.info('--> PV Positioner, using put completion and a DONE pv')
    # PV positioner, put completion, done pv
    pos = PVPositioner(mrec.field_pv('VAL'),
                       readback=mrec.field_pv('RBV'),
                       done=mrec.field_pv('MOVN'), done_val=0,
                       stop=mrec.field_pv('STOP'), stop_val=1,
                       put_complete=True,
                       limits=(-2, 2),
                       )

    ppv_motor = PypvMotor('m1', pos, server=server)
    print(ppv_motor.severity)
    record_name = ppv_motor.full_pvname
    for i in range(2):
        epics.caput(record_name, i, wait=True)
        print(pos.position)
    return ppv_motor
예제 #2
0
파일: cas_motor.py 프로젝트: ericdill/ophyd
def test():
    loggers = ('ophyd.controls.cas',
               )

    config.setup_loggers(loggers)

    logger = config.logger
    session = config.session
    server = session.cas

    motor_record = config.motor_recs[0]
    mrec = EpicsMotor(motor_record)

    logger.info('--> PV Positioner, using put completion and a DONE pv')
    # PV positioner, put completion, done pv
    pos = PVPositioner(mrec.field_pv('VAL'),
                       readback=mrec.field_pv('RBV'),
                       done=mrec.field_pv('MOVN'), done_val=0,
                       stop=mrec.field_pv('STOP'), stop_val=1,
                       put_complete=True,
                       limits=(-2, 2),
                       egu='unknown',
                       )

    def updated(value=None, **kwargs):
        print('Updated to: %s' % value)

    cas_motor = CasMotor('m1', pos, server=server)
    print(cas_motor.severity)
    record_name = cas_motor.full_pvname
    for i in range(2):
        epics.caput(record_name, i, wait=True)
        print(pos.position)
    return cas_motor
예제 #3
0
파일: motor.py 프로젝트: NSLS-II/pypvserver
def test(motor_record='XF:31IDA-OP{Tbl-Ax:X1}Mtr'):
    config.setup_logging([__name__, 'pypvserver.motor'])
    server = config.get_server()
    mrec = EpicsMotor(motor_record)

    # give the motor time to connect
    time.sleep(1.0)

    logger.info('--> PV Positioner, using put completion and a DONE pv')
    # PV positioner, put completion, done pv
    pos = PVPositioner(
        mrec.field_pv('VAL'),
        readback=mrec.field_pv('RBV'),
        done=mrec.field_pv('MOVN'),
        done_val=0,
        stop=mrec.field_pv('STOP'),
        stop_val=1,
        put_complete=True,
        limits=(-2, 2),
    )

    ppv_motor = PypvMotor('m1', pos, server=server)
    print(ppv_motor.severity)
    record_name = ppv_motor.full_pvname
    for i in range(2):
        epics.caput(record_name, i, wait=True)
        print(pos.position)
    return ppv_motor
예제 #4
0
def put_complete_test():
    motor_record = config.motor_recs[0]
    mrec = EpicsMotor(motor_record)

    logger.info('--> PV Positioner, using put completion and a DONE pv')
    # PV positioner, put completion, done pv
    pos = PVPositioner(mrec.field_pv('VAL'),
                       readback=mrec.field_pv('RBV'),
                       done=mrec.field_pv('MOVN'), done_val=0,
                       put_complete=True,
                       )

    high_lim = pos._setpoint.high_limit
    try:
        pos.check_value(high_lim + 1)
    except ValueError as ex:
        logger.info('Check value for single failed, as expected (%s)' % ex)
    else:
        print('high lim is %f' % high_lim)
        raise ValueError('check_value should have failed')

    stat = pos.move(1, wait=False)
    logger.info('--> post-move request, moving=%s' % pos.moving)

    while not stat.done:
        logger.info('--> moving... %s error=%s' % (stat, stat.error))
        time.sleep(0.1)

    pos.move(-1, wait=True)
    logger.info('--> synchronous move request, moving=%s' % pos.moving)

    logger.info('--> PV Positioner, using put completion and no DONE pv')
    # PV positioner, put completion, no done pv
    pos = PVPositioner(mrec.field_pv('VAL'),
                       readback=mrec.field_pv('RBV'),
                       put_complete=True,
                       )

    stat = pos.move(2, wait=False)
    logger.info('--> post-move request, moving=%s' % pos.moving)

    while not stat.done:
        logger.info('--> moving... %s' % stat)
        time.sleep(0.1)

    pos.move(0, wait=True)
    logger.info('--> synchronous move request, moving=%s' % pos.moving)
예제 #5
0
def put_complete_test():
    motor_record = config.motor_recs[0]
    mrec = EpicsMotor(motor_record)

    logger.info('--> PV Positioner, using put completion and a DONE pv')
    # PV positioner, put completion, done pv
    pos = PVPositioner(mrec.field_pv('VAL'),
                       readback=mrec.field_pv('RBV'),
                       done=mrec.field_pv('MOVN'), done_val=0,
                       put_complete=True,
                       )

    pos.move(1, wait=False)
    logger.info('--> post-move request, moving=%s' % pos.moving)

    while pos.moving:
        logger.info('--> moving...')
        time.sleep(0.1)

    pos.move(-1, wait=True)
    logger.info('--> synchronous move request, moving=%s' % pos.moving)

    logger.info('--> PV Positioner, using put completion and no DONE pv')
    # PV positioner, put completion, no done pv
    pos = PVPositioner(mrec.field_pv('VAL'),
                       readback=mrec.field_pv('RBV'),
                       put_complete=True,
                       )

    pos.move(2, wait=False)
    logger.info('--> post-move request, moving=%s' % pos.moving)

    while pos.moving:
        logger.info('--> moving...')
        time.sleep(0.1)

    pos.move(0, wait=True)
    logger.info('--> synchronous move request, moving=%s' % pos.moving)
예제 #6
0
from ophyd.controls import PVPositioner, EpicsMotor

#motors for xrf, tomo, etc. go here

#High Flux KB mirrors

##pseudo motors (should these be in the 'endstation' or in the 'pseudomotor' configuration?)
m2_pitch = EpicsMotor('XF:05IDD-OP:1{Mir:2-Ax:P}Mtr', name='m2_pitch')
m2_roll = EpicsMotor('XF:05IDD-OP:1{Mir:2-Ax:R}Mtr', name='m2_roll')
m2_vertical = EpicsMotor('XF:05IDD-OP:1{Mir:2-Ax:Y}Mtr', name='m2_vertical')
#m2_x, m3_x, m3_pitch will need to be added here

##real motors
m2_xu = EpicsMotor('XF:05IDD-OP:1{Mir:2-Ax:XU}Mtr', name='m2_xu')
m2_xd = EpicsMotor('XF:05IDD-OP:1{Mir:2-Ax:XD}Mtr', name='m2_xd')
m2_z = EpicsMotor('XF:05IDD-OP:1{Mir:2-Ax:Z}Mtr', name='m2_z')
#m2_yui, m2_ydo, m2_ydi, m2_ydo are not included here yet; they should no be scanned independently

m3_xu = EpicsMotor('XF:05IDD-OP:1{Mir:3-Ax:XU}Mtr', name='m3_xu')
m3_xd = EpicsMotor('XF:05IDD-OP:1{Mir:3-Ax:XD}Mtr', name='m3_xd')
m3_y = EpicsMotor('XF:05IDD-OP:1{Mir:3-Ax:Y}Mtr', name='m3_y')

#High flux sample stages
#Aero_x = EpicsMotor('XF:05IDD-ES:1{Stg:XY-Ax:X}Mtr', name = 'Aero_x')
Aero_x = EpicsMotor('XF:05IDD-ES:1{Stg:Smpl1-Ax:X}Mtr', name='Aero_x')
Aero_y = EpicsMotor('XF:05IDD-ES:1{Stg:Smpl1-Ax:Y}Mtr', name='Aero_y')
#PI = EpicsMotor('XF:05IDD-OP:1{Stg:Smpl1-Ax:Z}Mtr', name = 'PI')
PI = EpicsMotor('XF:05IDD-ES:1{Stg:Smpl1-Ax:Z}Mtr', name='PI')
예제 #7
0
                        name='m1b2_rol',
                        **kwargs)

m1b2 = [m1b2_z, m1b2_y, m1b2_x, m1b2_pit, m1b2_yaw, m1b2_rol]

# VLS-PGM

pgm_energy = PVPositioner('XF:23ID1-OP{Mono}Enrgy-SP',
                          readback='XF:23ID1-OP{Mono}Enrgy-I',
                          stop='XF:23ID1-OP{Mono}Cmd:Stop-Cmd',
                          stop_val=1,
                          put_complete=True,
                          name='pgm_energy',
                          limits=(200, 2200))

pgm_mir_pit = EpicsMotor('XF:23ID1-OP{Mono-Ax:MirP}Mtr', name='pgm_mir_pit')
pgm_grt_pit = EpicsMotor('XF:23ID1-OP{Mono-Ax:GrtP}Mtr', name='pgm_grt_pit')
pgm_mir_x = EpicsMotor('XF:23ID1-OP{Mono-Ax:MirX}Mtr', name='pgm_mir_x')
pgm_grt_x = EpicsMotor('XF:23ID1-OP{Mono-Ax:GrtX}Mtr', name='pgm_grt_x')

pgm_energy_sp = EpicsSignal('XF:23ID1-OP{Mono}Enrgy-SP', name='pgm_energy_sp')
pgm_energy_i = EpicsSignal('XF:23ID1-OP{Mono}Enrgy-I', name='pgm_energy_i')

# M3A Mirror

m3a_x = EpicsMotor('XF:23ID1-OP{Mir:3-Ax:XAvg}Mtr', name='m3a_x')
m3a_pit = EpicsMotor('XF:23ID1-OP{Mir:3-Ax:P}Mtr', name='m3a_pit')
m3a_bdr = EpicsMotor('XF:23ID1-OP{Mir:3-Ax:Bdr}Mtr', name='m3a_bdr')

# Fast CCD Shutter
예제 #8
0
# args = ('XF:23IDA-OP:1{Mir:1-Ax:Z}Mtr_POS_SP',
#        {'readback': 'XF:23IDA-OP:1{Mir:1-Ax:Z}Mtr_MON',
#         'act': 'XF:23IDA-OP:1{Mir:1}MOVE_CMD.PROC',
#         'act_val': 1,
#         'stop': 'XF:23IDA-OP:1{Mir:1}STOP_CMD.PROC',
#         'stop_val': 1,
#         'done': 'XF:23IDA-OP:1{Mir:1}BUSY_STS',
#         'done_val': 0,
#         'name': 'm1a_z',
#        })
# m1a_z = PVPositioner(args[0], **args[1])

# Slits

slt_wb_tb = EpicsMotor('XF:05IDA-OP:1{Slt:1-Ax:T}Mtr', name='slt_wb_tb')
slt_wb_bb = EpicsMotor('XF:05IDA-OP:1{Slt:1-Ax:B}Mtr', name='slt_wb_bb')
slt_wb_ib = EpicsMotor('XF:05IDA-OP:1{Slt:1-Ax:I}Mtr', name='slt_wb_ib')
slt_wb_ob = EpicsMotor('XF:05IDA-OP:1{Slt:1-Ax:O}Mtr', name='slt_wb_ob')

slt_pb_ib = EpicsMotor('XF:05IDA-OP:1{Slt:2-Ax:I}Mtr', name='slt_pb_ib')
slt_pb_ob = EpicsMotor('XF:05IDA-OP:1{Slt:2-Ax:O}Mtr', name='slt_pb_ob')


# HFM Mirror

hfm_x = EpicsMotor('XF:05IDA-OP:1{Mir:1-Ax:X}Mtr', name='hfm_x')
hfm_y = EpicsMotor('XF:05IDA-OP:1{Mir:1-Ax:Y}Mtr', name='hfm_y')
hfm_pit = EpicsMotor('XF:05IDA-OP:1{Mir:1-Ax:P}Mtr', name='hfm_pit')
hfm_bdr = EpicsMotor('XF:05IDA-OP:1{Mir:1-Ax:Bend}Mtr', name='hfm_bdr')
예제 #9
0
from ophyd.controls import PVPositioner, EpicsMotor

# Diffo angles

delta = EpicsMotor('XF:23ID1-ES{Dif-Ax:Del}Mtr', name='delta')
gamma = EpicsMotor('XF:23ID1-ES{Dif-Ax:Gam}Mtr', name='gamma')
theta = EpicsMotor('XF:23ID1-ES{Dif-Ax:Th}Mtr', name='theta')

# Sample positions

sx = EpicsMotor('XF:23ID1-ES{Dif-Ax:X}Mtr', name='sx')
sy = PVPositioner('XF:23ID1-ES{Dif-Ax:SY}Pos-SP',
                  readback='XF:23ID1-ES{Dif-Ax:SY}Pos-RB',
                  stop='XF:23ID1-ES{Dif-Cryo}Cmd:Stop-Cmd',
                  stop_val=1,
                  put_complete=True,
                  name='sy')

sz = PVPositioner('XF:23ID1-ES{Dif-Ax:SZ}Pos-SP',
                  readback='XF:23ID1-ES{Dif-Ax:SZ}Pos-RB',
                  stop='XF:23ID1-ES{Dif-Cryo}Cmd:Stop-Cmd',
                  stop_val=1,
                  put_complete=True,
                  name='sz')

cryoangle = PVPositioner('XF:23ID1-ES{Dif-Cryo}Pos:Angle-SP',
                         readback='XF:23ID1-ES{Dif-Cryo}Pos:Angle-RB',
                         name='cryoangle')

# Nano-positioners
예제 #10
0
import numpy as np

from ophyd.controls import EpicsMotor, EpicsScaler, PVPositioner, EpicsSignal
from ophyd.controls import SimDetector

from scan1d import scan1d
#from examples.dumb_scan import simple_scan


slt1_i = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:I}Mtr', name='slt1_i')
slt1_o = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:O}Mtr', name='slt1_o')
m1 = EpicsMotor('XF:31IDA-OP{Tbl-Ax:X1}Mtr', name='m1')
m2 = EpicsMotor('XF:31IDA-OP{Tbl-Ax:X2}Mtr', name='m2')
m7 = PVPositioner('XF:31IDA-OP{Tbl-Ax:FakeMtr}-SP',
                   readback='XF:31IDA-OP{Tbl-Ax:FakeMtr}-I',
                   act='XF:31IDA-OP{Tbl-Ax:FakeMtr}Cmd:Go-Cmd', act_val=1,
                   stop='XF:31IDA-OP{Tbl-Ax:FakeMtr}Cmd:Stop-Cmd', stop_val=1,
                   done='XF:31IDA-OP{Tbl-Ax:FakeMtr}Sts:Moving-Sts', done_val=1,
                   put_complete=False,
                   name='m7'
                   )
sensor1 = EpicsSignal('XF:31IDA-BI{Dev:1}E-I', rw=False, name='sensor1')
sensor2 = EpicsSignal('XF:31IDA-BI{Dev:2}E-I', rw=False, name='sensor2')
sclr_trig = EpicsSignal('XF:23ID2-ES{Sclr:1}.CNT', rw=True, name='sclr_trig')
sclr_ch1 = EpicsSignal('XF:23ID2-ES{Sclr:1}.S1', rw=False, name='sclr_ch1')
sca = EpicsScaler('XF:23ID2-ES{Sclr:1}', name='sca')

m1.set_trajectory(np.linspace(-1,2,10))
m2.set_trajectory(np.linspace(-1,2,10))

# initialize Positioner for Mono Energy
예제 #11
0
TWO_THETA_DIODE_IN = 100.0
TWO_THETA_DIODE_OUT = 60.0

X_HOME = 11.0
Y_HOME = 41.0

gas = XPDGasSwitcher(requested_pos='XF:28IDC-ES:1{Env:02}Pos-SP',
                     current_pos='XF:28IDC-ES:1{Env:02}Pos-I',
                     gasdict={
                         1: 'O2',
                         2: 'N2',
                         3: 'He'
                     })

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')

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')

cs700 = PVPositioner(
    'XF:28IDC-ES:1{Env:01}T-SP',
    readback='XF:28IDC-ES:1{Env:01}T-I',
    #done='XF:28IDC-ES:1{Env:01}Cmd-Busy', done_val=0,
    stop='XF:28IDC-ES:1{Env:01}Cmd-Cmd',
    stop_val=13,
    put_complete=True,
    name='cs700')
예제 #12
0
from ophyd.controls import EpicsMotor

# 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')
dlm_c2_p = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:2-Ax:P}Mtr', name='dlm_c2_p')
dlm_c2_r = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:2-Ax:R}Mtr', name='dlm_c2_r')
dlm_c2_xi = EpicsMotor('XF:28IDA-OP:1{Mono:DLM-C:2-Ax:XI}Mtr',
예제 #13
0
파일: motor.py 프로젝트: ericdill/ophyd
def test():
    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, ))

    loggers = ('ophyd.controls.signal',
               'ophyd.controls.positioner',
               'ophyd.session',
               )

    config.setup_loggers(loggers)
    logger = config.logger

    motor_record = config.motor_recs[0]

    m1 = EpicsMotor(motor_record)
    # m2 = EpicsMotor('MLL:bad_record')
    m1.subscribe(callback, event_type=m1.SUB_DONE)

    m1.subscribe(callback, event_type=m1.SUB_READBACK)
    # print(m1.user_readback.read())
    # print(m1.read())

    logger.info('---- test #1 ----')
    logger.info('--> move to 1')
    m1.move(1)
    logger.info('--> move to 0')
    m1.move(0)

    logger.info('---- test #2 ----')
    logger.info('--> move to 1')
    m1.move(1, wait=False)
    time.sleep(0.2)
    logger.info('--> stop')
    m1.stop()
    logger.info('--> sleep')
    time.sleep(1)
    logger.info('--> move to 0')
    m1.move(0, wait=False, moved_cb=done_moving)
    time.sleep(2)

    logger.debug('limits are: {}'.format(m1.limits))
    low_lim, high_lim = m1.low_limit, m1.high_limit
    try:
        m1.move(high_lim + 1)
    except LimitError as ex:
        logger.debug('Failed move, as expected (%s)' % ex)
    else:
        raise ValueError('Move should have failed')

    try:
        m1.move(low_lim - 1)
        # LimitError is a ValueError, so either can be caught
    except ValueError as ex:
        logger.debug('Failed move, as expected (%s)' % ex)
    else:
        raise ValueError('Move should have failed')

    try:
        m1.check_value(low_lim - 1)
    except ValueError as ex:
        logger.debug('Failed check_value, as expected (%s)' % ex)
    else:
        raise ValueError('check_value should have failed')

    logger.info('--> move to 0')
    stat = m1.move(2, wait=False)

    while not stat.done:
        logger.info('--> moving... %s error=%s' % (stat, stat.error))
        time.sleep(0.1)

    logger.debug(m1.get(as_string=True))
    logger.debug(m1.setpoint_ts)
    logger.debug(m1.timestamp)
    logger.debug(m1.pvname)
    logger.debug(m1.setpoint_pvname)

    fmt = '%%.%df' % m1.precision
    logger.debug('precision formatting: %s '% fmt)

    string_pos = fmt % m1.position
    logger.debug('final position: %s' % string_pos)