Beispiel #1
0
def laser_mod_polarity_CMD(args):
    '''Sets laser modulation polarity'''

    check = "'01' if args[0].upper() == laser('SOUR:AM:MPOL?') else '00')"
    final = "laser('SOUR:AM:MPOL '+args[0].upper())"
    result = command(args, [['PASS', 'INVERT']], final, check)

    return return_code(result)
Beispiel #2
0
def laser_mains_CMD(args):
    '''Switches laser ON or OFF'''

    check = "'01' if test_args[0].upper() == laser('SOUR:AM:STAT?')[1] else '00'"
    final = "laser('SOUR:AM:STAT '+test_args[0].upper())"
    result = command(args, [['ON', 'OFF']], final, None, check)

    return return_code(result)
Beispiel #3
0
def laser_power_CMD(args):
    '''Sets amplitude of laser beam'''

    check = "'01' if float(test_args[0]) == LASER_POWER else '00'"
    final = "arduino.setLaserPower(float(test_args[0]))"
    update = "LASER_POWER = float(test_args[0])"
    result = command(args, [[0, 100]], final, update, check)

    return return_code(result)
Beispiel #4
0
def laser_mode_CMD(args):
    '''Sets laser operation mode'''

    check_1 = "'26' if (args[0].lower() == 'gated' and (LASER_MODULATION not in ['square', 'pulse'])) else '00'"
    check_2 = "'01' args[0].lower() == LASER_MODE else '00')"
    final = "LASER_MODE = args[0].lower(); arduino.setOperationMode(LASER_MODE)"
    result = command(args, [['GATED', 'MASTER', 'INDEP']], final, check_1,
                     check_2)

    return return_code(result)
Beispiel #5
0
def handleResponse(data):
    '''
    Simple function that tests the valid of received data before parsing

    Arguments:
        data <str> - data received from socket to be tested

    Returns:
        Resulting string from parsed and executed arguments
        Error codes (see local file errors.txt)
    '''
    if len(data) <= 2: return return_code('10')
    if len(data) >= 128: return return_code('11')
    if data[-2:] != '\r\n': return return_code('12')

    words = [word for word in data[:-2].split(' ') if len(word) != 0]
    if len(words) == 0: return return_code('13')
    if len(words) >= 8: return return_code('14')
    
    return parse(words)
Beispiel #6
0
def query(list):
    '''HANDLES ALL LASER QUERY RESPONSES'''

    if list[0] != '00': return return_code(list[0])
    return (list[1] + '\r\n').encode(encoding='ascii')
Beispiel #7
0
def parse(args):
    if args[0] not in rulebook.keys(): return return_code('20')
    if args[0][0] == '?':
        return rulebook[args[0]]()
    else:
        return rulebook[args[0]](args[1:])