Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_setpoint_but_no_done(self):
class MyPositioner(PVPositioner):
setpoint = C(EpicsSignal, '.VAL')
self.assertRaises(ValueError, MyPositioner)
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(rbv_value0 + 0.1, wait=True)
time.sleep(0.2)
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)
def test_timeout(self):
class SubSubDevice(Device):
cpt5 = Component(EpicsSignal, '5')
class SubDevice(Device):
cpt4 = Component(EpicsSignal, '4')
subsub1 = Component(SubSubDevice, 'sub_')
class MyDevice(Device):
sub1 = Component(EpicsSignal, '1')
sub2 = Component(SubDevice, '_')
cpt3 = Component(EpicsSignal, '3')
device = MyDevice('prefix:', name='dev')
with self.assertRaises(TimeoutError) as cm:
device.wait_for_connection(timeout=1e-6)
ex_msg = str(cm.exception)
self.assertIn('dev.sub1', ex_msg)
def test_timeout(self):
class SubSubDevice(Device):
cpt5 = Component(EpicsSignal, '5')
class SubDevice(Device):
cpt4 = Component(EpicsSignal, '4')
subsub1 = Component(SubSubDevice, 'sub_')
class MyDevice(Device):
sub1 = Component(EpicsSignal, '1')
sub2 = Component(SubDevice, '_')
cpt3 = Component(EpicsSignal, '3')
device = MyDevice('prefix:', name='dev')
with self.assertRaises(TimeoutError) as cm:
device.wait_for_connection(timeout=1e-6)
ex_msg = str(cm.exception)
self.assertIn('dev.sub1', ex_msg)
self.assertIn('dev.sub2.cpt4', ex_msg)
self.assertIn('dev.sub2.subsub1.cpt5', ex_msg)
self.assertIn('dev.cpt3', ex_msg)
self.assertIn('prefix:1', ex_msg)
self.assertIn('prefix:_4', ex_msg)
self.assertIn('prefix:_sub_5', ex_msg)
self.assertIn('prefix:3', ex_msg)
self.high.put(high, wait=True)
self.process.put(1, wait=True)
status = self.status.get(use_monitor=False)
retval = self.retval.get(use_monitor=False)
if status != 'Success':
raise RuntimeError(f'RPC function failed: {status}')
return retval
class GroupDevice(ophyd.Device):
get_random = Cpt(get_randomDevice, 'get_random:',
doc='A configurable random number')
exit = Cpt(EpicsSignal, 'exit', doc='Poke me to exit')
random1 = Cpt(EpicsSignal, 'random1',
doc='Random integer between 1 and 100')
random2 = Cpt(EpicsSignal, 'random2',
doc='A nice random integer between 1000 and 2000')
# -------end autogenerated Devices---
if __name__ == '__main__':
ioc_options, run_options = ioc_arg_parser(
default_prefix='integration:',
desc='Run an IOC.')
ioc = Group(**ioc_options)
print('import ophyd')
print('from ophyd import Component as Cpt, EpicsSignal')
print('# Auto-generated Device from here on:')
print('# -----------------------------------')
fm = config.fake_motors[0]
if 0:
pos0 = PVPositioner(fm['setpoint'],
readback=fm['readback'],
act=fm['actuate'], act_val=1,
stop=fm['stop'], stop_val=1,
done=fm['moving'], done_val=1,
put_complete=False,
)
else:
motor_record = config.motor_recs[0]
pos0 = EpicsMotor(motor_record)
det = [EpicsSignal(pv, rw=False)
for pv in config.fake_sensors]
# pos0_traj = [0, 0.1, 0.2]
pos0_traj = np.linspace(0, 1, 5)
traj, data = simple_scan(motors=[pos0],
trajectories=[pos0_traj],
triggers=[],
detectors=det,
dwell_time=1.0)
print(traj, data)
diag5_cam = EpicsSignal('XF:23ID1-BI{Diag:5-Cam:1}cam1:Acquire_RBV',
write_pv='XF:23ID1-BI{Diag:5-Cam:1}cam1:Acquire',
rw=True, name='diag5_cam_trigger')
#
#simdet_filename = EpicsSignal('XF:31IDA-BI{Cam:Tbl}TIFF1:FullFileName_RBV',
# rw=False, string=True, name='simdet_filename')
diag3_tot1 = EpicsSignal('XF:23ID1-BI{Diag:3-Cam:1}Stats1:Total_RBV',
rw=False, name='diag3_tot1')
diag3_tot5 = EpicsSignal('XF:23ID1-BI{Diag:3-Cam:1}Stats5:Total_RBV',
rw=False, name='diag3_tot5')
diag5_tot1 = EpicsSignal('XF:23ID1-BI{Diag:5-Cam:1}Stats1:Total_RBV',
rw=False, name='diag5_tot1')
diag5_tot5 = EpicsSignal('XF:23ID1-BI{Diag:5-Cam:1}Stats5:Total_RBV',
rw=False, name='diag5_tot5')
pimte_cam = EpicsSignal('XF:23ID1-ES{Dif-Cam:PIMTE}cam1:Acquire_RBV',
write_pv='XF:23ID1-ES{Dif-Cam:PIMTE}cam1:Acquire',
rw=True, name='pimte_cam_trigger')
pimte_tot1 = EpicsSignal('XF:23ID1-ES{Dif-Cam:PIMTE}Stats1:Total_RBV',
rw=False, name='pimte_tot1')
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')
# '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])
# AreaDetector Beam Instrumentation
# diag3_cam = ProsilicaDetector('XF:23ID1-BI{Diag:3-Cam:1}')
# For now, access as simple 'signals'
diag3_cam = EpicsSignal('XF:23ID1-BI{Diag:3-Cam:1}cam1:Acquire_RBV',
write_pv='XF:23ID1-BI{Diag:3-Cam:1}cam1:Acquire',
rw=True, name='diag3_cam_trigger')
diag5_cam = EpicsSignal('XF:23ID1-BI{Diag:5-Cam:1}cam1:Acquire_RBV',
write_pv='XF:23ID1-BI{Diag:5-Cam:1}cam1:Acquire',
rw=True, name='diag5_cam_trigger')
#
#simdet_filename = EpicsSignal('XF:31IDA-BI{Cam:Tbl}TIFF1:FullFileName_RBV',
# rw=False, string=True, name='simdet_filename')
diag3_tot1 = EpicsSignal('XF:23ID1-BI{Diag:3-Cam:1}Stats1:Total_RBV',
rw=False, name='diag3_tot1')
diag3_tot5 = EpicsSignal('XF:23ID1-BI{Diag:3-Cam:1}Stats5:Total_RBV',
rw=False, name='diag3_tot5')
diag5_tot1 = EpicsSignal('XF:23ID1-BI{Diag:5-Cam:1}Stats1:Total_RBV',
rw=False, name='diag5_tot1')
diag5_tot5 = EpicsSignal('XF:23ID1-BI{Diag:5-Cam:1}Stats5:Total_RBV',
rw=False, name='diag5_tot5')
#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])
# AreaDetector Beam Instrumentation
# diag3_cam = ProsilicaDetector('XF:23ID1-BI{Diag:3-Cam:1}')
# For now, access as simple 'signals'
diag3_cam = EpicsSignal('XF:23ID1-BI{Diag:3-Cam:1}cam1:Acquire_RBV',
write_pv='XF:23ID1-BI{Diag:3-Cam:1}cam1:Acquire',
rw=True, name='diag3_cam_trigger')
diag5_cam = EpicsSignal('XF:23ID1-BI{Diag:5-Cam:1}cam1:Acquire_RBV',
write_pv='XF:23ID1-BI{Diag:5-Cam:1}cam1:Acquire',
rw=True, name='diag5_cam_trigger')
#
#simdet_filename = EpicsSignal('XF:31IDA-BI{Cam:Tbl}TIFF1:FullFileName_RBV',
# rw=False, string=True, name='simdet_filename')
diag3_tot1 = EpicsSignal('XF:23ID1-BI{Diag:3-Cam:1}Stats1:Total_RBV',
rw=False, name='diag3_tot1')
diag3_tot5 = EpicsSignal('XF:23ID1-BI{Diag:3-Cam:1}Stats5:Total_RBV',
rw=False, name='diag3_tot5')
rw=True, name='diag3_cam_trigger')
diag5_cam = EpicsSignal('XF:23ID1-BI{Diag:5-Cam:1}cam1:Acquire_RBV',
write_pv='XF:23ID1-BI{Diag:5-Cam:1}cam1:Acquire',
rw=True, name='diag5_cam_trigger')
#
#simdet_filename = EpicsSignal('XF:31IDA-BI{Cam:Tbl}TIFF1:FullFileName_RBV',
# rw=False, string=True, name='simdet_filename')
diag3_tot1 = EpicsSignal('XF:23ID1-BI{Diag:3-Cam:1}Stats1:Total_RBV',
rw=False, name='diag3_tot1')
diag3_tot5 = EpicsSignal('XF:23ID1-BI{Diag:3-Cam:1}Stats5:Total_RBV',
rw=False, name='diag3_tot5')
diag5_tot1 = EpicsSignal('XF:23ID1-BI{Diag:5-Cam:1}Stats1:Total_RBV',
rw=False, name='diag5_tot1')
diag5_tot5 = EpicsSignal('XF:23ID1-BI{Diag:5-Cam:1}Stats5:Total_RBV',
rw=False, name='diag5_tot5')
pimte_cam = EpicsSignal('XF:23ID1-ES{Dif-Cam:PIMTE}cam1:Acquire_RBV',
write_pv='XF:23ID1-ES{Dif-Cam:PIMTE}cam1:Acquire',
rw=True, name='pimte_cam_trigger')
pimte_tot1 = EpicsSignal('XF:23ID1-ES{Dif-Cam:PIMTE}Stats1:Total_RBV',
rw=False, name='pimte_tot1')
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',