Ejemplo n.º 1
0
def zero():
    """Shut down all (static) power supplies."""
    ps = ['hrf_0a', 'hrf_0b', 'hrf_1', 'hsf_0a', 'hsf_0b', 'hsf_1', 'sf_0a',
          'sf_0b', 'sf_1', 'gf0', 'gf1', 'gf2', 'gf4', 'gf5', 'gf6', 'gf7',
          'gf8', 'gf9', 'gf10']
    for powersupply in ps:
        powersupply = session.getDevice(powersupply)
        move(powersupply, 0.001)
Ejemplo n.º 2
0
    def test_stop(self, session, log):
        """Check stop() command."""
        motor = session.getDevice('motor')
        tdev = session.getDevice('tdev')
        tdev._stop_exception = NicosError('expected failed stop')

        stop()
        with log.assert_warns('expected failed stop'):
            stop(motor, tdev)
        # check stop moving motor
        move(motor, 10)
        stop(motor)
Ejemplo n.º 3
0
def miezescan(echolist, counttime):
    """Iterate over a list of echotimes -> measure one S(Q,t) curve

    echolist: list of echotimes
    counttime: counting time (the **same** for all list entries)
    """
    echotime = session.getDevice('echotime')
    with manualscan(echotime, counttime):
        for etime in echolist:
            move(echotime, etime)
            set_cascade()
            count(counttime)
Ejemplo n.º 4
0
 def test_wait(self, session, log):
     """Check wait() command."""
     motor = session.getDevice('motor')
     tdev = session.getDevice('tdev')
     tdev._status_exception = NicosError('expected failed status')
     move(motor, 10)
     wait(motor, 0.1)
     # session.log.error('expl. devices: %r', session.explicit_devices)
     wait()
     with log.assert_errors(r'expected failed status'):
         wait(tdev)
         tdev._status_exception = None
Ejemplo n.º 5
0
    def test_move(self, session, log):
        """Check move() command."""
        motor = session.getDevice('motor')
        for pos in (min(motor.userlimits), 0, max(motor.userlimits)):
            move(motor, pos)
            motor.wait()
            assert motor.curvalue == pos

        assert raises(LimitError, move, motor, max(motor.userlimits) + 1)

        assert raises(UsageError, move)
        assert raises(UsageError, move, motor, 1, motor)
Ejemplo n.º 6
0
 def test_fix_and_release(self, session, log):
     """Check fix() and release() commands."""
     motor = session.getDevice('motor')
     move(motor, 0)
     fix(motor)
     move(motor, 10)
     stop(motor)
     release(motor)
     assert motor.curvalue == 0
     assert raises(UsageError, release)
     assert raises(UsageError, release, ())
     assert raises(UsageError, unfix, ())
Ejemplo n.º 7
0
    def test_waitfor(self, session, log):
        """Check waitfor() command."""
        motor = session.getDevice('motor')
        assert motor.read() == 0.
        waitfor(motor, '== 0')
        motor.speed = 10
        move(motor, 2)
        waitfor(motor, '> 1.2')
        assert raises(NicosTimeoutError, waitfor, motor, '< 1', 0.1)
        waitfor(motor, '> 1', 0.1)

        # check waitfor wrong condition syntax
        assert raises(UsageError, waitfor, motor, '>')
Ejemplo n.º 8
0
def set_flipper_off():
    """Shut down flippers.

    After shutting down the neutrons are guided through instrument for
    image mode (MIEZE)
    """
    ps = ['sf_0a', 'sf_0b', 'cbox_0a_fg_amp', 'cbox_0b_fg_amp']
    reg = ['cbox_0a_reg_amp', 'cbox_0b_reg_amp']
    for powersupply in ps:
        powersupply = session.getDevice(powersupply)
        move(powersupply, 0.01)
    for regulator in reg:
        regulator = session.getDevice(regulator)
        stop(regulator)
Ejemplo n.º 9
0
def zero():
    """Shut down all (static) power supplies."""
    ps = [
        'hrf_0a', 'hrf_0b', 'hrf_1a', 'hrf_1b', 'hsf_0a', 'hsf_0b', 'hsf_1',
        'sf_0a', 'sf_0b', 'sf_1', 'gf1', 'gf2', 'gf4', 'gf5', 'gf6', 'gf7',
        'gf8', 'gf9', 'gf10', 'nse0', 'nse1'
    ]
    for powersupply in ps:
        powersupply = session.getDevice(powersupply)
        move(powersupply, 0.001)
    wait()

    # Stop regulation and turn fg_amp off
    stop('cbox_0a_reg_amp', 'cbox_0b_reg_amp', 'cbox_1_reg_amp')
    maw('cbox_0a_fg_amp', 0.001, 'cbox_0b_fg_amp', 0.001, 'cbox_1_fg_amp',
        0.001)
Ejemplo n.º 10
0
def NewExperiment(proposal, title='', localcontact='', user='', **parameters):
    """Start a new experiment with the given proposal number and title.

    You should also give a argument for the local contact and the primary user.
    More users can be added later with `AddUser`.  Example:

    >>> NewExperiment(541, 'Spin waves', 'L. Contact', 'F. User <*****@*****.**>')

    When configured, proposal information will be automatically filled in from
    the proposal database.
    """
    if user:
        voice_output = session.getDevice('voice_output')
        device.move(voice_output, voice_output.read(0) ^ 1)
        session.log.info('Welcome to GALAXI, %s!', user)
    basic.NewExperiment(proposal, title, localcontact, user, **parameters)
Ejemplo n.º 11
0
def lubricate_liftingctr(startpos, endpos):
    """Lubricate the lifting counter, while going from *startpos* to *endpos*.

    Example:

    >>> lubricate_liftingctr(0, 20)
    """
    ldev = session.getDevice('lubrication')
    motor = session.getDevice('liftingctr')
    maw(motor, startpos)
    session.log.info('Switching output on for 10 sec...')
    move(ldev, 1)
    session.delay(10)
    move(ldev, 0)
    session.log.info('Waiting 15 sec...')
    session.delay(15)
    maw(motor, endpos)
    session.log.info('Lubrication is done.')
Ejemplo n.º 12
0
def set_cascade():
    """Set Cascade Frequency Generator Freqs and Trigger."""
    echotime = session.getDevice('echotime')
    psd_chop_freq = session.getDevice('psd_chop_freq')
    psd_timebin_freq = session.getDevice('psd_timebin_freq')
    fg_burst = session.getDevice('fg_burst')
    tau = echotime.target
    f1 = echotime.currenttable[tau]['cbox_0a_fg_freq']
    f2 = echotime.currenttable[tau]['cbox_0b_fg_freq']
    move(psd_chop_freq, 2 * (f2 - f1))
    move(psd_timebin_freq, 32 * (f2 - f1))
    move(fg_burst, 'arm')
    move(fg_burst, 'trigger')
Ejemplo n.º 13
0
 def test_stop_privileged(self, session, log):
     # Change the user level to lower access rights to check that the stop
     # on higher level requesting devices will be ignored
     AddSetup('device')
     motor = session.getDevice('motor')
     pdev = session.getDevice('privdev')
     speed = pdev.speed
     pdev.speed = motor.speed = 0.1
     move(pdev, 10, motor, 10)
     with session.withUserLevel(GUEST):
         assert pdev.status(0)[0] == devstatus.BUSY
         assert motor.status(0)[0] == devstatus.BUSY
         assert raises(AccessError, pdev.stop)
         stop(pdev, motor)
         wait(motor)
         assert motor.status(0)[0] == devstatus.OK
         assert pdev.status(0)[0] == devstatus.BUSY
     stop(pdev)
     wait(pdev)
     assert pdev.status(0)[0] == devstatus.OK
     pdev.speed = motor.speed = speed
Ejemplo n.º 14
0
def setfg(freq_sample, amplitude_sample, offset_sample, shape_sample,
          freq_detector):
    """Set several values of the multi frequency generator at once

    and switch to burst mode.

    example: setfg(100, 0.5, 0.1, 'sin', 200)
    options for shape_samle:
    SINE = 'sin'
    Square = 'squ'
    Ramp = 'ramp' (with symmetry of 50%)
    Triangle = 'tri'

    Used for tisane measurements.
    """

    multifg = session.getDevice('tisane_fg_multi')

    tisane_relais = session.getDevice('tisane_relais')
    maw(tisane_relais, 0)

    template = ':SOUR1:FUNC:SHAP {0};:SOUR1:FREQ {1};:SOUR1:VOLT {2};' \
               ':SOUR1:VOLT:UNIT VPP;:SOUR1:VOLT:OFFS {3};' \
               ':SOUR1:FUNCtion:SQU:DCYCle 50;:SOUR1:AM:STATe OFF;' \
               ':SOUR1:SWEep:STATe OFF;:SOUR1:BURSt:MODE TRIG;' \
               ':OUTP1:LOAD 50;:OUTP1:POL NORM;:TRIG1:SOUR EXT;' \
               ':SOUR1:BURSt:NCYCles 9.9E37;:SOUR2:FUNC:SHAP SQU;' \
               ':SOUR2:FREQ {4};:SOUR2:VOLT 5;:SOUR2:VOLT:UNIT VPP;' \
               ':SOUR2:VOLT:OFFS 1.3;:SOUR2:FUNCtion:SQU:DCYCle 50;' \
               ':SOUR2:AM:STATe OFF;:SOUR2:SWEep:STATe OFF;' \
               ':SOUR2:BURSt:MODE TRIG;:OUTP2:LOAD 50;:OUTP2:POL NORM;' \
               ':TRIG2:SOUR EXT;:SOUR2:BURSt:NCYCles 9.9E37;' \
               ':SOUR1:BURSt:STATe ON;:SOUR2:BURSt:STATe ON;:OUTP1 ON;' \
               ':OUTP2 ON;'.format(shape_sample, freq_sample, amplitude_sample,
                                   offset_sample, freq_detector)
    strings = dict(multifg.strings)
    strings['arm'] = template
    multifg.strings = strings
    move(multifg, 'arm')
Ejemplo n.º 15
0
def chopper_config(wl_min, wl_max, D=22.8, chopper2_pos=3, gap=.1):
    """Configures the chopper.

    The chopper system will be moved to the settings for speed, and chopper
    disc phases according to the given parameters.

    Examples:

    >>> chopper_config(0, 22) # D=22.8, chopper2_pos=3, gap=0.1
    >>> chopper_config(0, 22, 21.455)  # chopper2_pos=3, gap=0.1
    >>> chopper_config(0, 22, 21.455, 1)  # gap=0.1
    >>> chopper_config(0, 22, 21.455, 2, 0.1)

    """
    target = {
        'wlmin': wl_min,
        'wlmax': wl_max,
        'D': D,
        'chopper2_pos': chopper2_pos,
        'gap': gap
    }
    move('chopper', target)
Ejemplo n.º 16
0
    def test_read(self, session, log):
        """Check read() command."""
        motor = session.getDevice('motor')
        coder = session.getDevice('coder')
        exp = session.getDevice('Exp')
        tdev = session.getDevice('tdev')
        tdev._status_exception = NicosError('expected failed status')
        tdev._read_exception = NicosError('expected failed read')

        read()
        read(motor, coder)
        with log.assert_errors(r'expected failed read'):
            read(tdev)
        assert raises(UsageError, read, exp)
        # ensure that target != position to generate a read message containing
        # a 'target' entry
        s = motor.speed
        motor.speed = 0.1
        move(motor, 1)
        stop(motor)
        with log.assert_msg_matches(r'target'):
            read(motor)
        motor.speed = s
Ejemplo n.º 17
0
def setecho(time):
    """Wrap setting of an echotime."""
    echotime = session.getDevice('echotime')
    move(echotime, time)
    #    set_cascade()
    wait(echotime)