コード例 #1
0
def test_monitor_during_wrapper(hw):
    det = hw.det

    def plan():
        # can't use 2 * [Msg('open_run'), Msg('null'), Msg('close_run')]
        # because plan_mutator sees the same ids twice and skips them
        yield from [
            Msg('open_run'),
            Msg('null'),
            Msg('close_run'),
            Msg('open_run'),
            Msg('null'),
            Msg('close_run')
        ]

    processed_plan = list(monitor_during_wrapper(plan(), [det]))
    expected = 2 * [
        Msg('open_run'),
        # inserted
        Msg('monitor', det, name=(det.name + '_monitor')),
        Msg('null'),
        Msg('unmonitor', det),  # inserted
        Msg('close_run')
    ]

    strip_group(processed_plan)
    assert processed_plan == expected

    processed_plan = list(monitor_during_decorator([det])(plan)())
    strip_group(processed_plan)
    assert processed_plan == expected
コード例 #2
0
ファイル: test_broker.py プロジェクト: ronpandolfi/databroker
def test_filtering_stream_name(db, RE, hw):
    from ophyd import sim
    # one event stream
    RE.subscribe(db.insert)
    uid, = RE(count([hw.det], num=7), bc=1)
    h = db[uid]
    assert len(list(h.descriptors)) == 1
    assert list(h.stream_names) == ['primary']
    assert len(list(db.get_events(h, stream_name='primary'))) == 7
    assert len(db.get_table(h, stream_name='primary')) == 7
    assert len(list(db.get_events(h, stream_name='primary',
                                  fields=['det']))) == 7
    assert len(db.get_table(h, stream_name='primary', fields=['det'])) == 7
    assert len(list(h.documents(stream_name='primary'))) == 7 + 3
    assert len(h.table(stream_name='primary')) == 7
    assert len(list(h.documents(stream_name='primary',
                                fields=['det']))) == 7 + 3
    assert len(h.table(stream_name='primary', fields=['det'])) == 7
    assert len(db.get_table(h, stream_name='primary', fields=['det',
                                                              'bc'])) == 7

    # two event streams: 'primary' and 'd_monitor'
    d = sim.SynPeriodicSignal(name='d', period=.5)
    uid, = RE(monitor_during_wrapper(count([hw.det], num=7, delay=0.1), [d]))
    h = db[uid]
    assert len(list(h.descriptors)) == 2
    assert set(h.stream_names) == set(['primary', 'd_monitor'])
    assert len(list(db.get_events(h, stream_name='primary'))) == 7
    assert len(list(h.documents(stream_name='primary'))) == 7 + 3

    assert len(db.get_table(h, stream_name='primary')) == 7

    assert len(db.get_table(h)) == 7  # 'primary' by default
    assert len(h.table(stream_name='primary')) == 7
    assert len(h.table()) == 7  # 'primary' by default
コード例 #3
0
def fly_scan(E0, mono_speed, device_dict, parent):
    # Initial settings
    flyer = device_dict['energyFlyer']

    parent.subscribe_callback()
    parent.toLog("A new fly scan is started!", color='blue')

    # Set to fly scan speed
    yield from bps.abs_set(flyer.fly_motor_speed, mono_speed)

    # Do fly scan
    yield from bpp.monitor_during_wrapper(bp.fly([flyer]), [
        device_dict['ENC_fly_counter'], device_dict['I0_fly_counter'],
        device_dict['It_fly_counter'], device_dict['If_fly_counter'],
        device_dict['Ir_fly_counter']
    ])

    # Set to normal speed
    yield from bps.abs_set(flyer.fly_motor_speed, parent._orig_mono_speed)

    # Move to E0
    yield from stop_and_mv(dcm, E0)

    parent.unsubscribe_callback()

    # Decrease remaining scan-number
    num_scan = int(parent.control.number_of_scan_edit.value())
    if num_scan > 1:
        _submit(parent.control.number_of_scan_edit.setValue, num_scan - 1)

        cooling_time = parent.control.flyControl.flyCoolTime.value()
        parent.toLog(
            "Cooling dcm. The next scan starts after {} seconds.".format(
                cooling_time))
        yield from bps.sleep(cooling_time)
コード例 #4
0
ファイル: test_broker.py プロジェクト: ronpandolfi/databroker
def test_order(db, RE, hw):
    from ophyd import sim
    RE.subscribe(db.insert)
    d = sim.SynPeriodicSignal(name='d', period=.5)
    uid, = RE(monitor_during_wrapper(count([hw.det], num=7, delay=0.1), [d]))

    t0 = None
    for name, doc in db[uid].documents():
        # TODO: include datums in here at some point
        if name in ['event']:
            t1 = doc['time']
            if t0:
                assert t1 > t0
            t0 = t1
コード例 #5
0
ファイル: test_new_examples.py プロジェクト: NSLS-II/bluesky
def test_monitor_during_wrapper(hw):
    det = hw.det

    def plan():
        # can't use 2 * [Msg('open_run'), Msg('null'), Msg('close_run')]
        # because plan_mutator sees the same ids twice and skips them
        yield from [Msg('open_run'), Msg('null'), Msg('close_run'),
                    Msg('open_run'), Msg('null'), Msg('close_run')]

    processed_plan = list(monitor_during_wrapper(plan(), [det]))
    expected = 2 * [Msg('open_run'),
                    # inserted
                    Msg('monitor', det, name=(det.name + '_monitor')),
                    Msg('null'),
                    Msg('unmonitor', det),  # inserted
                    Msg('close_run')]

    strip_group(processed_plan)
    assert processed_plan == expected

    processed_plan = list(monitor_during_decorator([det])(plan)())
    strip_group(processed_plan)
    assert processed_plan == expected
コード例 #6
0
def test_monitor(RE, hw):
    from ophyd.sim import SynSignal
    signal = SynSignal(name='signal')
    signal.put(0.0)
    RE(monitor_during_wrapper(count([hw.det], 5), [signal]))
コード例 #7
0
ファイル: test_new_examples.py プロジェクト: NSLS-II/bluesky
def test_monitor(RE, hw):
    RE(monitor_during_wrapper(count([hw.det], 5), [hw.det1]))
コード例 #8
0
ファイル: test_new_examples.py プロジェクト: zyzelda/bluesky
def test_monitor(RE, hw):
    RE(monitor_during_wrapper(count([hw.det], 5), [hw.det1]))