Ejemplo n.º 1
0
def test_steps(comment=''):
    flyers = [pb9.enc1, pba2.adc6, pba2.adc7]
    plan = bp.relative_scan([hhm.theta, pb9.enc1, pba2.adc6, pba2.adc7],
                            hhm.theta, -0.1, 0.1, 5)
    plan = bp.fly_during_wrapper(plan, flyers)
    plan = bp.pchain(plan)
    yield from plan
Ejemplo n.º 2
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
Ejemplo n.º 3
0
def execute_loop_trajectory(comment='', **metadata):

    flyers = [pb9.enc1, pba2.adc6, pba2.adc7]

    def inner():
        md = {
            'plan_args': {},
            'plan_name': 'execute_trajectory',
            'comment': comment
        }
        md.update(**metadata)
        yield from bp.open_run(md=md)

        # TODO Replace this with actual status object logic.
        hhm.enable_loop.put("1")
        ttime.sleep(2)
        while (hhm.theta.moving == True or hhm.enable_loop_rbv.value == 1):
            ttime.sleep(.1)
        #write_file(comment, [flyers[0].filepath.value, flyers[1].filepath.value, flyers[2].filepath.value] , '')

        yield from bp.close_run()

    for flyer in flyers:
        yield from bp.stage(flyer)
    yield from bp.stage(hhm)

    yield from bp.fly_during_wrapper(inner(), flyers)

    yield from bp.unstage(hhm)
    for flyer in flyers:
        yield from bp.unstage(flyer)
Ejemplo n.º 4
0
def execute_xia_trajectory(comment='', **metadata):
    flyers = [pb9.enc1, pb4.di]

    def inner():
        md = {
            'plan_args': {},
            'plan_name': 'execute_xia_trajectory',
            'comment': comment
        }
        md.update(**metadata)
        yield from bp.open_run(md=md)

        # TODO Replace this with actual status object logic.

        xia1.start_mapping_scan()
        hhm.enable_loop.put("0")
        hhm.start_trajectory.put("1")
        ttime.sleep(3)
        finished = 0
        while (hhm.theta.moving == True or finished == 0):
            finished = 0
            ttime.sleep(.1)
            if (hhm.theta.moving == False):
                ttime.sleep(.5)
                finished = 1

        xia1.stop_scan()
        #write_file(comment, [flyers[0].filepath.value, flyers[1].filepath.value, flyers[2].filepath.value] , '')

        yield from bp.close_run()

    for flyer in flyers:
        yield from bp.stage(flyer)
    yield from bp.stage(hhm)
    #yield from bp.stage(xia1)

    yield from bp.fly_during_wrapper(inner(), flyers)

    #yield from bp.unstage(xia1)
    yield from bp.unstage(hhm)
    for flyer in flyers:
        yield from bp.unstage(flyer)
Ejemplo n.º 5
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
Ejemplo n.º 6
0
def energy_multiple_scans(start, stop, repeats, comment='', **metadata):
    """
    Example
    -------
    >>> RE(energy_scan(11350, 11450, 2))
    """
    flyers = [pb9.enc1, pba2.adc6, pba2.adc7]

    def inner():
        md = {
            'plan_args': {},
            'plan_name': 'energy_multiple_scans',
            'comment': comment
        }
        md.update(**metadata)
        yield from bp.open_run(md=md)

        for i in range(0, repeats):
            print('Run:', i + 1)
            hhm_en.energy.move(start)
            ttime.sleep(2)
            while (hhm_en.energy.moving == True):
                ttime.sleep(.1)
            hhm_en.energy.move(stop)
            ttime.sleep(2)
            while (hhm_en.energy.moving == True):
                ttime.sleep(.1)
        #write_file(comment, [flyers[0].filepath.value, flyers[1].filepath.value, flyers[2].filepath.value] , '')

        yield from bp.close_run()

    for flyer in flyers:
        yield from bp.stage(flyer)
    yield from bp.stage(hhm)

    yield from bp.fly_during_wrapper(inner(), flyers)

    yield from bp.unstage(hhm)
    for flyer in flyers:
        yield from bp.unstage(flyer)
Ejemplo n.º 7
0
def tune(detectors, motor, start, stop, num, comment='', **metadata):
    """
    Example
    -------
    >>> RE(tune([pba2.adc7],-2, 2, 5, ''), LivePlot('pba2_adc7_volt', 'hhm_pitch'))
    """

    flyers = detectors  #[pba2.adc6, pba2.adc7]
    # Start with a step scan.
    plan = bp.relative_scan(flyers,
                            motor,
                            start,
                            stop,
                            num,
                            md={'comment': comment})
    plan = bp.fly_during_wrapper(plan, flyers)

    #for flyer in flyers:
    #    yield from bp.stage(flyer)

    plan = bp.pchain(plan)
    yield from plan
Ejemplo n.º 8
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
Ejemplo n.º 9
0
def hhm_theta_scan(start,
                   stop,
                   num,
                   flyers=[pb9.enc1, pba2.adc6, pba2.adc7],
                   comment='',
                   **metadata):
    """
    Example
    -------
    >>> RE(hhm_theta_scan(-0.1, 0.1, 2, [pb4.di, xia]))
    """
    def inner():
        md = {'plan_args': {}, 'plan_name': 'step scan', 'comment': comment}
        md.update(**metadata)
        yield from bp.open_run(md=md)

    # Start with a step scan.
    plan = bp.relative_scan([hhm_en.energy],
                            hhm_en.energy,
                            start,
                            stop,
                            num,
                            md={'comment': comment})
    # Wrap it in a fly scan with the Pizza Box.
    plan = bp.fly_during_wrapper(plan, flyers)
    # Working around a bug in fly_during_wrapper, stage and unstage the pizza box manually.

    for flyer in flyers:
        yield from bp.stage(flyer)
    yield from bp.stage(hhm)

    plan = bp.pchain(plan)
    #plan = bp.pchain(bp.stage(pb9.enc1), bp.stage(pba2.adc6), bp.stage(pba2.adc7),
    #                 plan,
    #                 bp.unstage(pb9.enc1), bp.unstage(pba2.adc6), bp.unstage(pba2.adc7))
    yield from plan