Exemplo n.º 1
0
def dhv(val = None):
    if not val is None:
        if val.upper() == 'UP':
            dhv1_up = sics.get_raw_value('dhv1 upper')
            dhv2_up = sics.get_raw_value('dhv2 upper')
            res = sics.run_command('drive dhv1 ' + str(dhv1_up) + ' dhv2 ' + str(dhv2_up))
            if res.find('Full Stop') >= 0:
                raise Exception, res
        elif val.upper() == 'DOWN':
            dhv1_down = sics.get_raw_value('dhv1 lower')
            dhv2_down = sics.get_raw_value('dhv2 lower')
            res = sics.run_command('drive dhv1 ' + str(dhv1_down) + ' dhv2 ' + str(dhv2_down))
            if res.find('Full Stop') >= 0:
                raise Exception, res
    else:
        dhv1_up = sics.get_raw_value('dhv1 upper')
        dhv1_down = sics.get_raw_value('dhv1 lower')
        dhv1 = sics.get_raw_value('dhv1')
        dhv2_up = sics.get_raw_value('dhv2 upper')
        dhv2_down = sics.get_raw_value('dhv2 lower')
        dhv2 = sics.get_raw_value('dhv2')
        if abs(dhv1_up - dhv1) <= 5 and (dhv2_up - dhv2) <= 5:
            return 'UP'
        elif abs(dhv1 - dhv1_down) <= 5 and (dhv2 - dhv2_down) <= 5:
            return 'DOWN'
        else:
            return 'ERROR'
Exemplo n.º 2
0
def _is_within_precision_(dev, target, precision = None):
    if precision is None:
        try:
            precision = sics.get_raw_value(dev + ' precision')
        except:
            precision = 0
    cv = sics.get_raw_value(dev)
    if abs(cv - target) <= precision:
        return True
    else:
        return False
Exemplo n.º 3
0
    def check_nvs_lambda(self, val):
        timeout = 600
        interval = 2
        count = 0
        while count < timeout :
            try:
                cur = sics.get_raw_value('nvs_lambda')
                if sics.isInterrupt():
                    break
#                 pre = sics.get_raw_value('nvs_lambda precision')
                pre = 0.1
                if abs(cur - val) < pre:
                    log('wavelength is ' + str(cur))
                    return True
                else:
                    try:
                        time.sleep(interval)
                        count += interval
                    except KeyboardInterrupt as ei:
                        log('Interrupted')
                        raise Exception, 'interrupted'
                        break;
            except:
                try:
                    time.sleep(interval)
                    count += interval
                except KeyboardInterrupt as ei:
                    log('Interrupted')
                    raise Exception, 'interrupted'
                    break;
        if sics.isInterrupt():
            sics.clearInterrupt()
            raise Exception, 'interrupted'
        sics.execute('stopexe nvs_lambda')
        log('WARNING: timeout in driving nvs_lambda, but choose to continue.')
Exemplo n.º 4
0
 def getter():
     if useController:
         controller = sics.getSicsController().findComponentController(path)
         return controller.getValue().getStringData()
     elif useRaw:
         return str(sics.get_raw_value(path))
     else:
         return sics.getValue(path).getStringData()
Exemplo n.º 5
0
def curtaind(val = None):
    if not val is None :
        if not _is_within_precision_('curtaind', val, .1):
            dhv('DOWN')
            sics.drive('curtaind', val)
            dhv('UP')
        else:
            log('curtaind is already at ' + str(val) + ', skipped')
    return sics.get_raw_value('curtaind')
Exemplo n.º 6
0
 def getter():
     if useController:
         controller = sics.getSicsController().findComponentController(path)
         if refresh:
             controller.getValue(True)
         return controller.getValue().getFloatData()
     elif useRaw:
         return float(sics.get_raw_value(path))
     else:
         return sics.getValue(path, refresh).getFloatData()
Exemplo n.º 7
0
def bs5(val = None):
    if not val is None:
        if val.upper() == 'IN':
            sics.drive('bs5', 65)
        elif val.upper() == 'OUT':
            sics.drive('bs5', 0)
    cur = sics.get_raw_value('bs5')
    if cur >= 63 and cur <= 67:
        return 'IN'
    else :
        return 'OUT'
Exemplo n.º 8
0
def __bs__(id, val = None):
    bs_name = 'bs' + str(id)
    if not val is None:
        if type(val) is int or type(val) is float or str(val).isdigit():
            sics.drive(bs_name, val)
        elif str(val).upper() == 'IN':
            sics.drive(bs_name, 65)
        elif str(val).upper() == 'OUT':
            sics.drive(bs_name, 0)
    cur = sics.get_raw_value(bs_name)
    if cur >= 63 and cur <= 67:
        return 'IN'
    else :
        return 'OUT'    
Exemplo n.º 9
0
def sample(val = None):
    global __sampleMap__
    if not val is None :
        if val <=0 or val > 10:
            raise Exception, 'sample number not supported, must be within 1 to 10, got ' + str(val)
        else:
            sics.drive('samx', __sampleMap__[round(val)])
    raw = sics.get_raw_value('samx')
    samNum = -1;
    for i in xrange(len(__sampleMap__)) :
        if raw > __sampleMap__[i] :
            if i > 0 :
                samNum = i - (raw - __sampleMap__[i]) / (__sampleMap__[i - 1] - __sampleMap__[i])
            break
    if samNum < 0.05 or samNum > 10.95:
        samNum = -1
    return round(samNum, 1)
Exemplo n.º 10
0
def sample(val = None):
    global __sampleMap__, __sampleNum__
    if not val is None :
        if not type(val) is int or not type(val) is float:
            val = float(str(val))
        if val <=0 or val >= 11:
            raise Exception, 'sample number not supported, must be within 1 to 10, got ' + str(val)
        else:
#            sics.drive('samx', __sampleMap__[round(val)])
            sics.drive('samx', __cal_samx__(val))
    raw = sics.get_raw_value('samx')
    samNum = -1;
    for i in xrange(len(__sampleMap__[__sampleNum__])) :
        if raw > __sampleMap__[__sampleNum__][i] :
            if i > 0 :
                samNum = i - (raw - __sampleMap__[__sampleNum__][i]) / (__sampleMap__[__sampleNum__][i - 1] - __sampleMap__[__sampleNum__][i])
            break
    if samNum < 0.05 or samNum > len(__sampleMap__[__sampleNum__]) - 1.05 :
        samNum = -1
    return round(samNum, 1)
Exemplo n.º 11
0
def att(val = None):
    if not val is None :
        sics.drive('att', val)
    return sics.get_raw_value('att')
Exemplo n.º 12
0
Arquivo: bilby.py Projeto: nxi/gumtree
def som(val=None):
    if not val is None:
        sics.drive('som', val)
    return sics.get_raw_value('som')
Exemplo n.º 13
0
Arquivo: bilby.py Projeto: nxi/gumtree
def att_pos(val=None):
    if not val is None:
        sics.drive('att_pos', val)
    return sics.get_raw_value('att_pos')
Exemplo n.º 14
0
pact = Act('previous_step()', '<- Previous Step')
    
par_mono = Par('string', 'PG', options = ['PG', 'Cu'], command = 'chg_mono()')
par_mono.title = 'confirm monochromator type'
def chg_mono():
    global D_space, PG002d, Cu200d
    if (str(par_mono.value) == 'Cu') :
        D_space = Cu200d
    else:
        D_space = PG002d
    if (lambda_fit.value != 0) :
        m1_new.value = math.asin(lambda_fit.value / 2 / D_space) * 180 / math.pi
        m2_new.value = 2 * m1_new.value
try:
    md = sics.get_raw_value('mono_mode', 'str')
    if md == 'cu' :
        par_mono.value = 'Cu'
    elif md == 'pg' :
        par_mono.value = 'PG'
    else:
        raise Exception
    chg_mono()
except:
    try:
        cm1 = sics.getValue('m1').getFloatData()
        d = lmd.value / 2 / math.sin(cm1 * math.pi / 180)
        if d < 2:
            par_mono.value = 'Cu'
        else:
            par_mono.value = 'PG'
Exemplo n.º 15
0
def curtaind(val = None):
    if not val is None :
        dhv('DOWN')
        sics.drive('curtaind', val)
        dhv('UP')
    return sics.get_raw_value('curtaind')
Exemplo n.º 16
0
def som(val = None):
    if not val is None :
        sics.drive('som', val)
    return sics.get_raw_value('som')
Exemplo n.º 17
0
Arquivo: bilby.py Projeto: nxi/gumtree
def samz(val=None):
    if not val is None:
        sics.drive('samz', val)
    return sics.get_raw_value('samz')
Exemplo n.º 18
0
def sapmot(val = None):
    if not val is None:
        if type(val) is float or type(val) is int :
            val = 'D' + str(val)
        sics.run_command('pdrive sapmot ' + str(val))
    return sics.get_raw_value('posname sapmot', str)
Exemplo n.º 19
0
def samx(val = None):
    if not val is None :
        sics.drive('samx', val)
    return sics.get_raw_value('samx') 
Exemplo n.º 20
0
def det(val = None):
    if not val is None :
        dhv('DOWN')
        sics.drive('det', val)
        dhv('UP')
    return sics.get_raw_value('det')