コード例 #1
0
def test_fly_during():
    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(fly_during_wrapper(plan(), ['foo']))
    expected = 2 * [
        Msg('open_run'),
        Msg('kickoff', 'foo'),
        Msg('wait'),  # inserted
        Msg('null'),
        Msg('complete', 'foo'),
        Msg('wait'),  # inserted
        Msg('collect', 'foo'),  # inserted
        Msg('close_run')
    ]

    strip_group(processed_plan)
    assert processed_plan == expected

    processed_plan = list(fly_during_decorator(['foo'])(plan)())
    strip_group(processed_plan)
    assert processed_plan == expected
コード例 #2
0
 def daq_during_plan():
     yield from bps.configure(daq,
                              events=0,
                              record=record,
                              use_l3t=use_l3t,
                              controls=controls)
     return (yield from bpp.fly_during_wrapper(plan, flyers=[daq]))
コード例 #3
0
ファイル: test_run_engine.py プロジェクト: zyzelda/bluesky
def test_flyer_with_collect_asset_documents(RE):

    from ophyd.sim import det, new_trivial_flyer, trivial_flyer
    from bluesky.preprocessors import fly_during_wrapper
    assert hasattr(new_trivial_flyer, 'collect_asset_docs')
    assert hasattr(trivial_flyer, 'collec_asset_docs') == False
    RE(fly_during_wrapper(count([det], num=5), [new_trivial_flyer, trivial_flyer]))
コード例 #4
0
ファイル: test_run_engine.py プロジェクト: NSLS-II/bluesky
def test_flyer_with_collect_asset_documents(RE):

    from ophyd.sim import det, new_trivial_flyer, trivial_flyer
    from bluesky.preprocessors import fly_during_wrapper
    assert hasattr(new_trivial_flyer, 'collect_asset_docs')
    assert hasattr(trivial_flyer, 'collec_asset_docs') == False
    RE(fly_during_wrapper(count([det], num=5), [new_trivial_flyer, trivial_flyer]))
コード例 #5
0
def set_and_fly(filepaths, flyers, sleeptime=10):
    '''
        Fly on flyers with file prefix for a certain sleep time.
        fileprefix: file prefix
        sleeptime : sleep time to let flyer run for
    '''

    # set the file paths
    for filepath, flyer in zip(filepaths, flyers):
        yield from bps.abs_set(flyer.filepath, filename)

    # now fly
    yield from bpp.fly_during_wrapper(bps.sleep(sleeptime), [flyer])
コード例 #6
0
ファイル: object_plans.py プロジェクト: NSLS-II-HXN/hxnfly
 def cls_plan():
     current_settings = {}
     for key, val in kwargs.items():
         current_settings[key] = getattr(self, key)
         setattr(self, key, val)
     try:
         plan = self._gen()
         plan = bpp.subs_wrapper(plan, subs)
         plan = bpp.stage_wrapper(plan, flyers)
         plan = bpp.fly_during_wrapper(plan, flyers)
         return (yield from plan)
     finally:
         for key, val in current_settings.items():
             setattr(self, key, val)
コード例 #7
0
def daq_during_wrapper(plan, record=None, use_l3t=False, controls=None):
    """
    Run a plan with the `Daq`.

    This can be used with an ordinary ``bluesky`` plan that you'd like the daq
    to run along with. This also stages the daq so that the run start/stop
    will be synchronized with the bluesky runs.

    This must be applied outside the ``run_wrapper``. All configuration must
    be done by supplying config kwargs to this wrapper.

    The `daq_during_decorator` is the same as the `daq_during_wrapper`,
    but it is meant to be used as a function decorator.

    Parameters
    ----------
    plan: ``plan``
        The ``plan`` to use the daq in

    record: ``bool``, optional
        If ``True``, we'll record the data. Otherwise, we'll run without
        recording. Defaults to ``False``, or the last set value for
        ``record``.

    use_l3t: ``bool``, optional
        If ``True``, an ``events`` argument to begin will be reinterpreted
        to only count events that pass the level 3 trigger. Defaults to
        ``False``.

    controls: ``dict{name: device}`` or ``list[device...]``, optional
        If provided, values from these will make it into the DAQ data
        stream as variables. We will check ``device.position`` and
        ``device.value`` for quantities to use and we will update these
        values each time begin is called. To provide a list, all devices
        must have a ``name`` attribute.
    """
    daq = get_daq()
    yield from configure(daq,
                         events=None,
                         duration=None,
                         record=record,
                         use_l3t=use_l3t,
                         controls=controls)
    yield from stage_wrapper(fly_during_wrapper(plan, flyers=[daq]), [daq])
コード例 #8
0
ファイル: test_new_examples.py プロジェクト: NSLS-II/bluesky
def test_fly_during():
    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(fly_during_wrapper(plan(), ['foo']))
    expected = 2 * [Msg('open_run'),
                    Msg('kickoff', 'foo'), Msg('wait'),  # inserted
                    Msg('null'),
                    Msg('complete', 'foo'), Msg('wait'),  # inserted
                    Msg('collect', 'foo'),  # inserted
                    Msg('close_run')]

    strip_group(processed_plan)
    assert processed_plan == expected

    processed_plan = list(fly_during_decorator(['foo'])(plan)())
    strip_group(processed_plan)
    assert processed_plan == expected
コード例 #9
0
 def plan():
     yield from fly_during_wrapper(run_wrapper(sleep(1)), [seq])
コード例 #10
0
def adjust_ic_gains( **kwargs):
    sys.stdout = kwargs.pop('stdout', sys.stdout)

    if 'detector_names' not in kwargs:
        detectors = [pba1.adc7, pba2.adc6, pba1.adc1, pba1.adc6]
    else:
        detectors = []
        for d in kwargs['detector_names']:
            detectors.append(globals()[d])
        #TODO replace with dictionary

    current_lut = int(hhm.lut_number_rbv.value)
    traj_manager = trajectory_manager(hhm)
    info = traj_manager.read_info(silent=True)
    if 'max' not in info[str(current_lut)] or 'min' not in info[str(current_lut)]:
        raise Exception(
            'Could not find max or min information in the trajectory.'
            ' Try sending it again to the controller.')

    e_min = int(info[str(current_lut)]['min'])
    e_max = int(info[str(current_lut)]['max'])

    try:
        yield from bps.mv(shutter_ph_2b, 'Open')
    except FailedStatus:
        print('ERROR: Photon shutter failed to open')
    shutter.open()

    scan_positions = np.arange(e_max + 50, e_min - 50, -50)

    plan = bp.list_scan(detectors, hhm.energy, scan_positions)
    flyers = []
    for detector in detectors:
        if hasattr(detector, 'kickoff'):
            flyers.append(detector)
    for jj in range(2):
        plan = bp.list_scan(detectors, hhm.energy, scan_positions)
        #print(f'F>>>>>>>>>>> {flyers}\n D>>>>>>>>>>>>>>>>.{detectors}')
        uid = (yield from bpp.fly_during_wrapper(plan, flyers))
        #print(f' >>>>>> UID {uid}')
        table = db[uid].table()
        for det in detectors:
            name = f'{det.name}_volt'
            current_gain = det.amp.get_gain()[0]
            if det.polarity == 'neg':
                trace_extreme = table[name].min()
            else:
                trace_extreme = table[name].max()

            print(f'Extreme value {trace_extreme} for detector {det.channel}')
            if abs(trace_extreme) > 3.7:
                print(f'Decreasing gain for detector {det.channel}')
                yield from det.amp.set_gain_plan(current_gain-1, False)

            elif abs(trace_extreme) <= 3.7 and abs(trace_extreme) > 0.35:
                print(f'Correct gain for detector {det.channel}')
            elif abs(trace_extreme) <= 0.35:
                print(f'Increasing gain for detector {det.channel}')
                yield from det.amp.set_gain_plan(current_gain + 1, False)

        #print(f'F2>>>>>>>>>>> {flyers}\n D2>>>>>>>>>>>>>>>>.{detectors}')
        yield from bps.sleep(2)
    shutter.close()
    print('[Adjust Gain] Complete\n')
    remove_pb_files(uid)