How to use the ophyd.EpicsMotor function in ophyd

To help you get started, we’ve selected a few ophyd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bluesky / ophyd / tests / test_timestamps.py View on Github external
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)
github bluesky / ophyd / tests / test_timestamps.py View on Github external
def test_write_pv_timestamp_no_monitor(self):
        mtr = EpicsMotor(config.motor_recs[0])
        mtr.wait_for_connection()

        sp = EpicsSignal(mtr.user_setpoint.pvname)

        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)
github bluesky / ophyd / tests / test_pseudopos.py View on Github external
# logger.debug('forward %s', pseudo_pos)
        return self.RealPosition(real1=-pseudo_pos.pseudo1,
                                 real2=-pseudo_pos.pseudo2,
                                 real3=-pseudo_pos.pseudo3)

    def inverse(self, real_pos):
        real_pos = self.RealPosition(*real_pos)
        # logger.debug('inverse %s', real_pos)
        return self.PseudoPosition(pseudo1=real_pos.real1,
                                   pseudo2=real_pos.real2,
                                   pseudo3=real_pos.real3)


class Pseudo1x3(PseudoPositioner):
    pseudo1 = C(PseudoSingle, limits=(-10, 10))
    real1 = C(EpicsMotor, motor_recs[0])
    real2 = C(EpicsMotor, motor_recs[1])
    real3 = C(EpicsMotor, motor_recs[2])

    def forward(self, pseudo_pos):
        pseudo_pos = self.PseudoPosition(*pseudo_pos)
        # logger.debug('forward %s', pseudo_pos)
        return self.RealPosition(real1=-pseudo_pos.pseudo1,
                                 real2=-pseudo_pos.pseudo1,
                                 real3=-pseudo_pos.pseudo1)

    def inverse(self, real_pos):
        real_pos = self.RealPosition(*real_pos)
        # logger.debug('inverse %s', real_pos)
        return self.PseudoPosition(pseudo1=-real_pos.real1)
github bluesky / ophyd / examples / xf23id1_conf.py View on Github external
pimte_tot2 = EpicsSignal('XF:23ID1-ES{Dif-Cam:PIMTE}Stats2:Total_RBV',
                         rw=False, name='pimte_tot2')
pimte_tot3 = EpicsSignal('XF:23ID1-ES{Dif-Cam:PIMTE}Stats3:Total_RBV',
                         rw=False, name='pimte_tot3')
pimte_tot4 = EpicsSignal('XF:23ID1-ES{Dif-Cam:PIMTE}Stats4:Total_RBV',
                         rw=False, name='pimte_tot4')
pimte_tot5 = EpicsSignal('XF:23ID1-ES{Dif-Cam:PIMTE}Stats5:Total_RBV',
                         rw=False, name='pimte_tot5')

#
# Endstation motors
#


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

sx   = EpicsMotor('XF:23ID1-ES{Dif-Ax:X}Mtr', name = 'sx')
sy   = EpicsMotor('XF:23ID1-ES{Dif-Ax:Y}Mtr', name = 'sy')
sz   = EpicsMotor('XF:23ID1-ES{Dif-Ax:Z}Mtr', name = 'sz')

nptx = EpicsMotor('XF:23ID1-ES{Dif:Lens-Ax:TopX}Mtr', name = 'nptx')
npty = EpicsMotor('XF:23ID1-ES{Dif:Lens-Ax:TopY}Mtr', name = 'npty')
nptz = EpicsMotor('XF:23ID1-ES{Dif:Lens-Ax:TopZ}Mtr', name = 'nptz')
npbx = EpicsMotor('XF:23ID1-ES{Dif:Lens-Ax:BtmX}Mtr', name = 'npbx')
npby = EpicsMotor('XF:23ID1-ES{Dif:Lens-Ax:BtmY}Mtr', name = 'npby')
npbz = EpicsMotor('XF:23ID1-ES{Dif:Lens-Ax:BtmZ}Mtr', name = 'npbz')


# Setup auto logging
github bluesky / ophyd / examples / pseudo.py View on Github external
def single_pseudo():
    def calc_fwd(pseudo=0.0):
        return [-pseudo, -pseudo, -pseudo]

    def calc_rev(real0=0.0, real1=0.0, real2=0.0):
        return -real0

    def done(**kwargs):
        print('** Finished moving (%s)' % (kwargs, ))

    real0 = EpicsMotor(config.motor_recs[0], name='real0')
    real1 = EpicsMotor(config.motor_recs[1], name='real1')
    real2 = EpicsMotor(config.motor_recs[2], name='real2')

    reals = [real0, real1, real2]

    logger.info('------- Sequential, single pseudo positioner')
    pos = PseudoPositioner('seq',
                           reals,
                           forward=calc_fwd, reverse=calc_rev,
                           concurrent=False
                           )

    logger.info('Move to .2, which is (-.2, -.2, -.2) for real motors')
    pos.move(.2, wait=True)
    logger.info('Position is: %s (moving=%s)' % (pos.position, pos.moving))
    logger.info('Real positions: %s' % ([real.position for real in reals], ))
github bluesky / ophyd / examples / xf23id1_conf.py View on Github external
name='epu2_gap')

epu2_gap = PVPositioner('XF:23ID-ID{EPU:2-Ax:Gap}Pos-SP',
                        readback='XF:23ID-ID{EPU:2-Ax:Gap}Pos-I',
                        stop='SR:C23-ID:G1A{EPU:2-Ax:Gap}-Mtr.STOP',
                        stop_val=1,
                        done='XF:23ID-ID{EPU:2-Ax:Gap}Pos-Sts',
                        done_val=0,
                        name='epu2_gap')

# Slits

slt1_xg   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:XGap}Mtr', name = 'slt1_xg')
slt1_xc   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:XCtr}Mtr', name = 'slt1_xc')
slt1_yg   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:YGap}Mtr', name = 'slt1_yg')
slt1_yc   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:YCtr}Mtr', name = 'slt1_yc')

slt2_xg   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:XGap}Mtr', name = 'slt2_xg')
slt2_xc   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:XCtr}Mtr', name = 'slt2_xc')
slt2_yg   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:YGap}Mtr', name = 'slt2_yg')
slt2_yc   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:YCtr}Mtr', name = 'slt2_yc')

slt3_x    = EpicsMotor('XF:23ID1-OP{Slt:3-Ax:X}Mtr', name    = 'slt3_x')
slt3_y    = EpicsMotor('XF:23ID1-OP{Slt:3-Ax:Y}Mtr', name    = 'slt3_y')

diag2_y   = EpicsMotor('XF:23ID1-BI{Diag:2-Ax:Y}Mtr', name   = 'diag2_y')
diag3_y   = EpicsMotor('XF:23ID1-BI{Diag:3-Ax:Y}Mtr', name   = 'diag3_y')
diag5_y   = EpicsMotor('XF:23ID1-BI{Diag:5-Ax:Y}Mtr', name   = 'diag5_y')
diag6_y   = EpicsMotor('XF:23ID1-BI{Diag:6-Ax:Y}Mtr', name   = 'diag6_y')

sclr_trig = EpicsSignal('XF:23ID1-ES{Sclr:1}.CNT', rw = True,
                        name  = 'sclr_trig')
github bluesky / ophyd / examples / xf23id1_conf.py View on Github external
# Slits

slt1_xg   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:XGap}Mtr', name = 'slt1_xg')
slt1_xc   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:XCtr}Mtr', name = 'slt1_xc')
slt1_yg   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:YGap}Mtr', name = 'slt1_yg')
slt1_yc   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:YCtr}Mtr', name = 'slt1_yc')

slt2_xg   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:XGap}Mtr', name = 'slt2_xg')
slt2_xc   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:XCtr}Mtr', name = 'slt2_xc')
slt2_yg   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:YGap}Mtr', name = 'slt2_yg')
slt2_yc   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:YCtr}Mtr', name = 'slt2_yc')

slt3_x    = EpicsMotor('XF:23ID1-OP{Slt:3-Ax:X}Mtr', name    = 'slt3_x')
slt3_y    = EpicsMotor('XF:23ID1-OP{Slt:3-Ax:Y}Mtr', name    = 'slt3_y')

diag2_y   = EpicsMotor('XF:23ID1-BI{Diag:2-Ax:Y}Mtr', name   = 'diag2_y')
diag3_y   = EpicsMotor('XF:23ID1-BI{Diag:3-Ax:Y}Mtr', name   = 'diag3_y')
diag5_y   = EpicsMotor('XF:23ID1-BI{Diag:5-Ax:Y}Mtr', name   = 'diag5_y')
diag6_y   = EpicsMotor('XF:23ID1-BI{Diag:6-Ax:Y}Mtr', name   = 'diag6_y')

sclr_trig = EpicsSignal('XF:23ID1-ES{Sclr:1}.CNT', rw = True,
                        name  = 'sclr_trig')
sclr_ch1  = EpicsSignal('XF:23ID1-ES{Sclr:1}.S1', rw = False,
                        name = 'sclr_ch1')
sclr_ch2  = EpicsSignal('XF:23ID1-ES{Sclr:1}.S2', rw = False,
                        name = 'sclr_ch2')
sclr_ch3  = EpicsSignal('XF:23ID1-ES{Sclr:1}.S3', rw = False,
                        name = 'sclr_ch3')
sclr_ch4  = EpicsSignal('XF:23ID1-ES{Sclr:1}.S4', rw = False,
                        name = 'sclr_ch4')
sclr_ch5  = EpicsSignal('XF:23ID1-ES{Sclr:1}.S5', rw = False,
                        name = 'sclr_ch5')
github bluesky / ophyd / examples / xf23id1_conf.py View on Github external
stop_val=1,
                        done='XF:23ID-ID{EPU:1-Ax:Gap}Pos-Sts',
                        done_val=0,
                        name='epu2_gap')

epu2_gap = PVPositioner('XF:23ID-ID{EPU:2-Ax:Gap}Pos-SP',
                        readback='XF:23ID-ID{EPU:2-Ax:Gap}Pos-I',
                        stop='SR:C23-ID:G1A{EPU:2-Ax:Gap}-Mtr.STOP',
                        stop_val=1,
                        done='XF:23ID-ID{EPU:2-Ax:Gap}Pos-Sts',
                        done_val=0,
                        name='epu2_gap')

# Slits

slt1_xg   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:XGap}Mtr', name = 'slt1_xg')
slt1_xc   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:XCtr}Mtr', name = 'slt1_xc')
slt1_yg   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:YGap}Mtr', name = 'slt1_yg')
slt1_yc   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:YCtr}Mtr', name = 'slt1_yc')

slt2_xg   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:XGap}Mtr', name = 'slt2_xg')
slt2_xc   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:XCtr}Mtr', name = 'slt2_xc')
slt2_yg   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:YGap}Mtr', name = 'slt2_yg')
slt2_yc   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:YCtr}Mtr', name = 'slt2_yc')

slt3_x    = EpicsMotor('XF:23ID1-OP{Slt:3-Ax:X}Mtr', name    = 'slt3_x')
slt3_y    = EpicsMotor('XF:23ID1-OP{Slt:3-Ax:Y}Mtr', name    = 'slt3_y')

diag2_y   = EpicsMotor('XF:23ID1-BI{Diag:2-Ax:Y}Mtr', name   = 'diag2_y')
diag3_y   = EpicsMotor('XF:23ID1-BI{Diag:3-Ax:Y}Mtr', name   = 'diag3_y')
diag5_y   = EpicsMotor('XF:23ID1-BI{Diag:5-Ax:Y}Mtr', name   = 'diag5_y')
diag6_y   = EpicsMotor('XF:23ID1-BI{Diag:6-Ax:Y}Mtr', name   = 'diag6_y')
github bluesky / ophyd / examples / interactive.py View on Github external
# run this with: ipython -i interactive.py

import config
import time

from ophyd import EpicsMotor
from ophyd import (mov, movr, set_pos, wh_pos, set_lm, log_pos, log_pos_diff)


rec1, rec2, rec3 = config.motor_recs[:3]
m1 = EpicsMotor(rec1)
m2 = EpicsMotor(rec2)
m3 = EpicsMotor(rec3)


# wait for positioners to connect...
time.sleep(1.0)

print()
print('Moving m1 to 0.3:')
mov(m1, 0.3)

print()
print('Moving m1 to 0.0:')
mov(m1, 0.0)

print()
print('Moving m1 to 0.3 (relative):')
movr(m1, 0.3)
github bluesky / ophyd / examples / xf23id1_conf.py View on Github external
done='XF:23ID-ID{EPU:1-Ax:Gap}Pos-Sts',
                        done_val=0,
                        name='epu2_gap')

epu2_gap = PVPositioner('XF:23ID-ID{EPU:2-Ax:Gap}Pos-SP',
                        readback='XF:23ID-ID{EPU:2-Ax:Gap}Pos-I',
                        stop='SR:C23-ID:G1A{EPU:2-Ax:Gap}-Mtr.STOP',
                        stop_val=1,
                        done='XF:23ID-ID{EPU:2-Ax:Gap}Pos-Sts',
                        done_val=0,
                        name='epu2_gap')

# Slits

slt1_xg   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:XGap}Mtr', name = 'slt1_xg')
slt1_xc   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:XCtr}Mtr', name = 'slt1_xc')
slt1_yg   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:YGap}Mtr', name = 'slt1_yg')
slt1_yc   = EpicsMotor('XF:23ID1-OP{Slt:1-Ax:YCtr}Mtr', name = 'slt1_yc')

slt2_xg   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:XGap}Mtr', name = 'slt2_xg')
slt2_xc   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:XCtr}Mtr', name = 'slt2_xc')
slt2_yg   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:YGap}Mtr', name = 'slt2_yg')
slt2_yc   = EpicsMotor('XF:23ID1-OP{Slt:2-Ax:YCtr}Mtr', name = 'slt2_yc')

slt3_x    = EpicsMotor('XF:23ID1-OP{Slt:3-Ax:X}Mtr', name    = 'slt3_x')
slt3_y    = EpicsMotor('XF:23ID1-OP{Slt:3-Ax:Y}Mtr', name    = 'slt3_y')

diag2_y   = EpicsMotor('XF:23ID1-BI{Diag:2-Ax:Y}Mtr', name   = 'diag2_y')
diag3_y   = EpicsMotor('XF:23ID1-BI{Diag:3-Ax:Y}Mtr', name   = 'diag3_y')
diag5_y   = EpicsMotor('XF:23ID1-BI{Diag:5-Ax:Y}Mtr', name   = 'diag5_y')
diag6_y   = EpicsMotor('XF:23ID1-BI{Diag:6-Ax:Y}Mtr', name   = 'diag6_y')