Exemple #1
0
    def freq_counter_impedance(self, *impedance):
        if test_flag != 'test':
            if len(impedance) == 2:
                ch = str(impedance[0])
                imp = str(impedance[1])
                if imp in impedance_dict:
                    flag = impedance_dict[imp]
                    if ch == 'CH1':
                        self.device_write(":INPut1:IMPedance " + str(flag))
                    elif ch == 'CH2':
                        self.device_write(":INPut2:IMPedance " + str(flag))
                    elif ch == 'CH3':
                        general.message('The impedance for CH3 is only 50 Ohm')
            elif len(impedance) == 1:
                ch = str(impedance[0])
                if ch == 'CH1':
                    raw_answer = float(self.device_query(":INPut1:IMPedance?"))
                    answer = cutil.search_keys_dictionary(
                        impedance_dict, raw_answer)
                    return answer
                elif ch == 'CH2':
                    raw_answer = float(self.device_query(":INPut2:IMPedance?"))
                    answer = cutil.search_keys_dictionary(
                        impedance_dict, raw_answer)
                    return answer
                elif ch == 'CH3':
                    answer = '50'
                    general.message('The impedance for CH3 is only 50 Ohm')
                    return answer
            else:
                general.message('Invalid argument')
                sys.exit()

        elif test_flag == 'test':
            if len(impedance) == 2:
                ch = str(impedance[0])
                imp = str(impedance[1])
                assert (ch == 'CH1' or ch == 'CH2'
                        or ch == 'CH3'), 'Invalid channel is given'
                assert (imp in impedance_dict), 'Invalid impedance is given'
            elif len(impedance) == 1:
                ch = str(impedance[0])
                assert (ch == 'CH1' or ch == 'CH2'
                        or ch == 'CH3'), 'Invalid channel is given'
                answer = test_impedance
                return answer
            else:
                assert (1 == 2), "Incorrect impedance argument"
Exemple #2
0
    def oscilloscope_acquisition_type(self, *ac_type):
        if test_flag != 'test': 
            if  len(ac_type) == 1:
                at = str(ac_type[0])
                if at in ac_type_dic:
                    flag = ac_type_dic[at]
                    self.device_write(":ACQuire:TYPE " + str(flag))
                else:
                    general.message("Invalid acquisition type")
                    sys.exit()
            elif len(ac_type) == 0:
                raw_answer = str(self.device_query(":ACQuire:TYPE?"))
                answer  = cutil.search_keys_dictionary(ac_type_dic, raw_answer)
                return answer
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(ac_type) == 1:
                at = str(ac_type[0])
                if at in ac_type_dic:
                    flag = ac_type_dic[at]
                else:
                    assert(1 == 2), "Invalid acquisition type"
            elif len(ac_type) == 0:
                answer = test_acquisition_type
                return answer
            else:
                assert (1 == 2), 'Invalid acquisition type argument'
Exemple #3
0
    def freq_counter_start_mode(self, *mode):
        if test_flag != 'test':
            if len(mode) == 1:
                md = str(mode[0])
                if md in startarm_dic:
                    flag = startarm_dic[md]
                    self.device_write(":FREQuency:ARM:START:SOURce " +
                                      str(flag))
                else:
                    general.message("Invalid start arm mode")
                    sys.exit()
            elif len(mode) == 0:
                raw_answer = self.device_query(":FREQuency:ARM:START:SOURce?")
                answer = cutil.search_keys_dictionary(startarm_dic, raw_answer)
                return answer
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(mode) == 1:
                md = str(mode[0])
                if md in startarm_dic:
                    flag = startarm_dic[md]
                else:
                    assert (1 == 2), "Invalid start arm mode"
            elif len(mode) == 0:
                answer = test_gate_start_mode
                return answer
            else:
                assert (1 == 2), "Invalid argument"
Exemple #4
0
    def power_supply_range(self, *range):
        if test_flag != 'test':
            if len(range) == 1:
                rng = str(range[0])
                if rng in range_dict:
                    flag = range_dict[rng]
                    self.device_write('RNGE ' + str(flag))
                else:
                    general.message("Incorrect range")
                    sys.exit()

            elif len(range) == 0:
                raw_answer = int(self.device_query('RNGE?'))
                answer = cutil.search_keys_dictionary(range_dict, raw_answer)
                return answer
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(range) == 1:
                rng = str(range[0])
                assert (rng in range_dict), "Incorrect range"

            elif len(range) == 0:
                answer = test_range
                return answer
            else:
                assert (1 == 2), "Invalid argument"
Exemple #5
0
    def power_supply_rear_mode(self, *mode):
        if test_flag != 'test':
            if len(mode) == 1:
                md = str(mode[0])
                if md in rear_mode_dict:
                    flag = rear_mode_dict[md]
                    self.device_write('SMOD ' + str(flag))
                else:
                    general.message('Incorrect rear mode')
                    sys.exit()
            elif len(mode) == 0:
                raw_answer = int(self.device_query('SMOD?'))
                answer = cutil.search_keys_dictionary(rear_mode_dict,
                                                      raw_answer)
                return answer
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(mode) == 1:
                md = str(mode[0])
                assert (md in rear_mode_dict), "Incorrect rear mode"
            elif len(mode) == 0:
                answer = test_rear_mode
                return answer
            else:
                assert (1 == 2), "Invalid argument"
Exemple #6
0
    def wave_gen_arbitrary_interpolation(self, *mode, channel = '1'):
        if test_flag != 'test':
            ch = channel
            if ch == '1' or ch == '2':
                if len(mode) == 1:
                    md = str(mode[0])
                    if md == 'On':
                        self.device_write(":WGEN" + str(ch) + ":ARBitrary:INTerpolate 1")
                    elif md == 'Off':
                        self.device_write(":WGEN" + str(ch) + ":ARBitrary:INTerpolate 0")
                    else:
                        general.message("Incorrect interpolation control setting is given")
                        sys.exit()
                elif len(mode) == 0:
                    raw_answer = int(self.device_query(":WGEN"+str(ch)+":ARBitrary:INTerpolate?"))
                    answer = cutil.search_keys_dictionary(wave_gen_interpolation_dictionary, raw_answer)
                    return answer
                else:
                    general.message("Invalid argument")
                    sys.exit()
            else:
                general.message("Incorrect wave generator channel")
                sys.exit()

        elif test_flag == 'test':
            ch = channel
            assert(ch == '1' or ch == '2'), "Incorrect wave generator channel"
            if len(mode) == 1:
                md = str(mode[0])
                assert(md == 'On' or md == 'Off'), "Incorrect interpolation control setting is given"
            elif len(mode) == 0:
                answer = test_wave_gen_interpolation
                return answer
            else:
                assert(1 == 2), "Invalid argument"
Exemple #7
0
    def discrete_io_output_state(self, *state):
        if test_flag != 'test':
            if len(state) == 1:
                st = state[0]
                if st in output_state_dict:
                    flag = int(output_state_dict[st], 2)
                    self.device_write_unsigned(50, flag, 0)
                else:
                    general.message("Invalid state")
                    sys.exit()
            elif len(state) == 0:
                raw_answer = bin(int(self.device_read_unsigned(50,
                                                               0))).replace(
                                                                   "0b", "")
                answer = cutil.search_keys_dictionary(output_state_dict,
                                                      raw_answer)
                return answer

        elif test_flag == 'test':
            if len(state) == 1:
                st = state[0]
                assert (st in output_state_dict), "Incorrect state"
            elif len(state) == 0:
                answer = test_output_state
                return answer
            else:
                assert (1 == 2), "Incorrect argument"
Exemple #8
0
    def gaussmeter_units(self, *units):
        if test_flag != 'test':
            if len(units) == 1:
                un = str(units[0])
                if un in units_dict:
                    flag = units_dict[un]
                    self.device_write('UNIT ' + str(flag))
                else:
                    general.message('Incorrect unit')
                    sys.exit()
            elif len(units) == 0:
                raw_answer = int(self.device_query('UNIT?'))
                answer = cutil.search_keys_dictionary(units_dict, raw_answer)
                return answer
            else:
                general.message('Invalid argument')
                sys.exit()

        elif test_flag == 'test':
            if len(units) == 1:
                un = str(units[0])
                assert (un in units_dict), 'Incorrect unit'
            elif len(units) == 0:
                answer = test_unit
                return answer
Exemple #9
0
    def freq_counter_gate_mode(self, *mode):
        if test_flag != 'test':
            if  len(mode) == 1:
                md = str(mode[0])
                if md in gate_dic:
                    flag = gate_dic[md]
                    self.device_write("FREQuency:GATE:SOURce "+ str(flag))
                else:
                    general.message("Invalid gate mode")
                    sys.exit()
            elif len(mode) == 0:
                raw_answer = str(self.device_query('FREQuency:GATE:SOURce?'))
                answer = cutil.search_keys_dictionary(gate_dic, raw_answer)
                return answer
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if  len(mode) == 1:
                md = str(mode[0])
                if md in gate_dic:
                    flag = gate_dic[md]
                else:
                    assert(1 == 2), "Invalid gate mode"
            elif len(mode) == 0:
                answer = test_gate
                return answer
            else:
                assert(1 == 2), "Invalid argument"
Exemple #10
0
    def lock_in_ref_slope(self, *mode):
        if test_flag != 'test':
            if len(mode) == 1:
                md = str(mode[0])
                if md in ref_slope_dict:
                    flag = ref_slope_dict[md]
                    self.device_write("RTRG "+ str(flag))
                else:
                    general.message("Invalid mode")
                    sys.exit()
            elif len(mode) == 0:
                raw_answer = int(self.device_query("RTRG?"))
                answer = cutil.search_keys_dictionary(ref_slope_dict, raw_answer)
                return answer
            else:
                general.message("Invalid argumnet")
                sys.exit()

        elif test_flag == 'test':
            if  len(mode) == 1:
                md = str(mode[0])
                if md in ref_slope_dict:
                    pass
                else:
                    assert(1 == 2), "Incorrect ref slope is used"
            elif len(mode) == 0:
                answer = test_ref_slope
                return answer             
Exemple #11
0
    def lock_in_sync_filter(self, *mode):
        if test_flag != 'test':
            if len(mode) == 1:
                md = str(mode[0])
                if md in sync_dict:
                    flag = sync_dict[md]
                    self.device_write("SYNC "+ str(flag))
                else:
                    general.message("Invalid argument")
                    sys.exit()
            elif len(mode) == 0:
                raw_answer = int(self.device_query("SYNC?"))
                answer = cutil.search_keys_dictionary(sync_dict, raw_answer)
                return answer
            else:
                general.message("Invalid argumnet")
                sys.exit()

        elif test_flag == 'test':
            if len(mode) == 1:
                md = str(mode[0])
                if md in sync_dict:
                    pass
                else:
                    assert(1 == 2), "Incorrect sync filter parameter"
            elif len(mode) == 0:
                answer = test_sync
                return answer   
Exemple #12
0
    def tc_lock_keyboard(self, *lock):
        if test_flag != 'test':
            if len(lock) == 1:
                lk = str(lock[0])
                if lk in lock_dict:
                    flag = lock_dict[lk]
                    self.device_query(str(flag))
                else:
                    general.message("Invalid argument")
                    sys.exit()
            elif len(lock) == 0:
                raw_answer = self.device_query('X')
                answer_flag = raw_answer[4:6]
                answer = cutil.search_keys_dictionary(lock_dict, answer_flag)
                return answer
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(lock) == 1:
                lk = str(lock[0])
                if lk in lock_dict:
                    flag = lock_dict[lk]
                else:
                    assert (1 == 2), "Invalid lock argument"
            elif len(lock) == 0:
                answer = test_lock
                return answer
            else:
                assert (1 == 2), "Invalid argument"
Exemple #13
0
    def lock_in_lp_filter(self, *mode):
        if test_flag != 'test':
            if len(mode) == 1:
                md = str(mode[0])
                if md in lp_fil_dict:
                    flag = lp_fil_dict[md]
                    self.device_write("OFSL "+ str(flag))
                else:
                    general.message("Invalid mode")
                    sys.exit()
            elif len(mode) == 0:
                raw_answer = int(self.device_query("OFSL?"))
                answer = cutil.search_keys_dictionary(lp_fil_dict, raw_answer)
                return answer
            else:
                general.message("Invalid argumnet")
                sys.exit()

        elif test_flag == 'test':
            if len(mode) == 1:
                md = str(mode[0])
                if md in lp_fil_dict:
                    pass
                else:
                    assert(1 == 2), "Incorrect low pass filter is used"
            elif len(mode) == 0:
                answer = test_lp_filter
                return answer   
Exemple #14
0
    def lock_in_time_constant(self, *timeconstant):
        if test_flag != 'test':
            if  len(timeconstant) == 1:
                temp = timeconstant[0].split(' ')
                if float(temp[0]) > 30 and temp[1] == 'ks':
                    general.message("Desired sensitivity cannot be set, the nearest available value is used")
                    self.device_write("OFLT "+ str(21))
                else:
                    number_tc = min(helper_tc_list, key=lambda x: abs(x - int(temp[0])))
                    if int(number_tc) == 1000 and temp[1] == 'us':
                        number_tc = 1
                        temp[1] = 'ms'
                    elif int(number_tc) == 1000 and temp[1] == 'ms':
                        number_tc = 1
                        temp[1] = 's'
                    elif int(number_tc) == 1000 and temp[1] == 's':
                        number_tc = 1
                        temp[1] = 'ks'
                    if int(number_tc) != int(temp[0]):
                        general.message("Desired time constant cannot be set, the nearest available value is used")
                    tc = str(number_tc) + ' ' + temp[1]
                    if tc in timeconstant_dict:
                        flag = timeconstant_dict[tc]
                        self.device_write("OFLT "+ str(flag))
                    else:
                        general.message("Invalid time constant value (too high/too low)")
                        sys.exit()
            elif len(timeconstant) == 0:
                raw_answer = int(self.device_query("OFLT?"))
                answer = cutil.search_keys_dictionary(timeconstant_dict, raw_answer)
                return answer
            else:
                general.message("Invalid Argument")
                sys.exit()

        elif test_flag == 'test':
            if  len(timeconstant) == 1:
                temp = timeconstant[0].split(' ')
                if float(temp[0]) > 30 and temp[1] == 'ks':
                    tc = '30 ks'
                else:
                    number_tc = min(helper_tc_list, key=lambda x: abs(x - int(temp[0])))
                    if int(number_tc) == 1000 and temp[1] == 'us':
                        number_tc = 1
                        temp[1] = 'ms'
                    elif int(number_tc) == 1000 and temp[1] == 'ms':
                        number_tc = 1
                        temp[1] = 's'
                    elif int(number_tc) == 1000 and temp[1] == 's':
                        number_tc = 1
                        temp[1] = 'ks'
                    tc = str(number_tc) + ' ' + temp[1]
                    if tc in timeconstant_dict:
                        pass
                    else:
                        assert(1 == 2), "Incorrect time constant is used"
            elif len(timeconstant) == 0:
                answer = test_timeconstant
                return answer
Exemple #15
0
    def lock_in_sensitivity(self, *sensitivity):
        if test_flag != 'test':
            if len(sensitivity) == 1:
                temp = sensitivity[0].split(' ')
                if float(temp[0]) > 1 and temp[1] == 'V':
                    general.message("Desired sensitivity cannot be set, the nearest available value is used")
                    self.device_write("SCAL "+ str(0))
                else:
                    number_sens = min(helper_sens_list, key=lambda x: abs(x - int(temp[0])))
                    if int(number_sens) == 1000 and temp[1] == 'nV':
                        number_sens = 1
                        temp[1] = 'uV'
                    elif int(number_sens) == 1000 and temp[1] == 'uV':
                        number_sens = 1
                        temp[1] = 'mV'
                    elif int(number_sens) == 1000 and temp[1] == 'mV':
                        number_sens = 1
                        temp[1] = 'V'
                    sens = str(number_sens) + ' ' + temp[1]
                    if int(number_sens) != int(temp[0]):
                        general.message("Desired sensitivity cannot be set, the nearest available value is used")
                    if sens in sensitivity_dict:
                        flag = sensitivity_dict[sens]
                        self.device_write("SCAL "+ str(flag))
                    else:
                        general.message("Invalid sensitivity value (too high/too low)")
                        sys.exit()
            elif len(sensitivity) == 0:
                raw_answer = int(self.device_query("SCAL?"))
                answer = cutil.search_keys_dictionary(sensitivity_dict, raw_answer)
                return answer
            else:
                general.message("Invalid Argument")
                sys.exit()

        elif test_flag == 'test':
            if  len(sensitivity) == 1:
                temp = sensitivity[0].split(' ')
                if float(temp[0]) > 1 and temp[1] == 'V':
                    sens = '1 V'
                else:
                    number_sens = min(helper_sens_list, key=lambda x: abs(x - int(temp[0])))
                    if int(number_sens) == 1000 and temp[1] == 'nV':
                        number_sens = 1
                        temp[1] = 'uV'
                    elif int(number_sens) == 1000 and temp[1] == 'uV':
                        number_sens = 1
                        temp[1] = 'mV'
                    elif int(number_sens) == 1000 and temp[1] == 'mV':
                        number_sens = 1
                        temp[1] = 'V'
                    tc = str(number_sens) + ' ' + temp[1]
                    if tc in sensitivity_dict:
                        pass
                    else:
                        assert(1 == 2), "Incorrect sensitivity is used"
            elif len(sensitivity) == 0:
                answer = test_sensitivity
                return answer
    def power_supply_channel_state(self, *state):
        if test_flag != 'test':
            if len(state) == 2:
                ch = str(state[0])
                st = str(state[1])
                if ch in channel_dict:
                    flag = channel_dict[ch]
                    if flag <= channels:
                        if st in state_dict:
                            self.device_write(':OUTPut CH' + str(flag) + ',' +
                                              str(state_dict[st]))
                        else:
                            general.message("Invalid state argument")
                            sys.exit()
                    else:
                        general.message("Invalid channel")
                        sys.exit()
                else:
                    general.message("Invalid channel")
                    sys.exit()

            elif len(state) == 1:
                ch = str(state[0])
                if ch in channel_dict:
                    flag = channel_dict[ch]
                    if flag <= channels:
                        raw_answer = self.device_query(':OUTPut? CH' +
                                                       str(flag))
                        answer = cutil.search_keys_dictionary(
                            state_dict, raw_answer)
                        return answer
                    else:
                        general.message("Invalid channel")
                        sys.exit()
                else:
                    general.message("Invalid channel")
                    sys.exit()
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(state) == 2:
                ch = str(state[0])
                st = str(state[1])
                assert (ch in channel_dict), 'Invalid channel argument'
                flag = channel_dict[ch]
                assert (flag <= channels), "Invalid channel"
                assert (st in state_dict), 'Invalid state argument'
            elif len(state) == 1:
                ch = str(state[0])
                assert (ch in channel_dict), 'Invalid channel argument'
                flag = channel_dict[ch]
                assert (flag <= channels), "Invalid channel"
                answer = test_state
                return answer
Exemple #17
0
    def discrete_io_input_state(self):
        if test_flag != 'test':
            raw_answer = bin(int(self.device_read_unsigned(51, 0))).replace(
                "0b", "")
            answer = cutil.search_keys_dictionary(input_state_dict, raw_answer)
            return answer

        elif test_flag == 'test':
            answer = test_input_state
            return answer
Exemple #18
0
    def power_supply_interlock(self, *interlock):
        if test_flag != 'test':
            if len(interlock) == 0:
                raw_answer = int(self.device_query('ILOC?'))
                answer = cutil.search_keys_dictionary(lock_dict, raw_answer)
                return answer
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(interlock) == 0:
                answer = test_lock
                return answer
            else:
                assert (1 == 2), "Invalid argument"
Exemple #19
0
    def delay_gen_output_polarity(self, *polarity):
        if test_flag != 'test':
            if len(polarity) == 2:
                ch = str(polarity[0])
                plr = str(polarity[1])
                if ch in output_channel_dict:
                    flag_1 = output_channel_dict[ch]
                    if plr in polarity_dict:
                        flag_2 = polarity_dict[plr]
                        if int(self.device_query('OM ' + str(flag_1))) != 3:
                            general.wait('30 ms')
                            self.device_write('OP ' + str(flag_1) + ',' + str(flag_2))
                        else:
                            general.message("You are in Variable mode")
                    else:
                        general.message("Incorrect polarity")
                        sys.exit()
                else:
                    general.message("Invalid channel")
                    sys.exit()    
            
            elif len(polarity) == 1:
                ch = str(polarity[0])
                if ch in output_channel_dict:
                    flag = output_channel_dict[ch]
                    raw_answer = int(self.device_query('OP ' + str(flag)))
                    answer = cutil.search_keys_dictionary(polarity_dict, raw_answer)
                    return answer
                else:
                    general.message("Invalid channel")
                    sys.exit()
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(polarity) == 2:
                ch = str(polarity[0])
                plr = str(polarity[1])
                assert(ch in output_channel_dict), 'Invalid channel argument'
                assert(plr in polarity_dict), 'Invalid polarity argument'

            elif len(polarity) == 1:
                ch = str(polarity[0])
                assert(ch in output_channel_dict), 'Invalid channel argument'
                answer = test_polarity
                return answer
Exemple #20
0
    def delay_gen_output_mode(self, *mode):
        if test_flag != 'test':
            if len(mode) == 2:
                ch = str(mode[0])
                md = str(mode[1])
                if ch in output_channel_dict:
                    flag_1 = output_channel_dict[ch]
                    if md in mode_dict:
                        flag_2 = mode_dict[md]
                        self.device_write('OM ' + str(flag_1) + ',' + str(flag_2))
                    else:
                        general.message("Incorrect mode")
                        sys.exit()
                else:
                    general.message("Invalid channel")
                    sys.exit()    
            
            elif len(mode) == 1:
                ch = str(mode[0])
                if ch in output_channel_dict:
                    flag = output_channel_dict[ch]
                    raw_answer = int(self.device_query('OM ' + str(flag)))
                    answer = cutil.search_keys_dictionary(mode_dict, raw_answer)
                    return answer
                else:
                    general.message("Invalid channel")
                    sys.exit()
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(mode) == 2:
                ch = str(mode[0])
                md = str(mode[1])
                assert(ch in output_channel_dict), 'Invalid channel argument'
                assert(md in mode_dict), 'Invalid mode argument'

            elif len(mode) == 1:
                ch = str(mode[0])
                assert(ch in output_channel_dict), 'Invalid channel argument'
                answer = test_mode
                return answer
Exemple #21
0
    def delay_gen_impedance(self, *impedance):
        if test_flag != 'test':
            if len(impedance) == 2:
                ch = str(impedance[0])
                imp = str(impedance[1])
                if ch in input_output_channel_dict:
                    flag_1 = input_output_channel_dict[ch]
                    if imp in impedance_dict:
                        flag_2 = impedance_dict[imp]
                        self.device_write('TZ ' + str(flag_1) + ',' + str(flag_2))
                    else:
                        general.message("Incorrect impedance")
                        sys.exit()
                else:
                    general.message("Invalid channel")
                    sys.exit()    
            
            elif len(impedance) == 1:
                ch = str(impedance[0])
                if ch in input_output_channel_dict:
                    flag = input_output_channel_dict[ch]
                    raw_answer = int(self.device_query('TZ ' + str(flag)))
                    answer = cutil.search_keys_dictionary(impedance_dict, raw_answer)
                    return answer
                else:
                    general.message("Invalid channel")
                    sys.exit()
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(impedance) == 2:
                ch = str(impedance[0])
                imp = str(impedance[1])
                assert(ch in input_output_channel_dict), 'Invalid channel argument'
                assert(imp in impedance_dict), 'Invalid impedance argument'

            elif len(impedance) == 1:
                ch = str(impedance[0])
                assert(ch in input_output_channel_dict), 'Invalid channel argument'
                answer = test_impedance
                return answer
Exemple #22
0
    def tc_state(self, *mode):
        if test_flag != 'test':
            if len(mode) == 1:
                md = str(mode[0])
                if md in state_dict:
                    flag = state_dict[md]
                    if flag == 2 or flag == 3:
                        raw_answer = self.device_query('X')
                        answer = raw_answer[2:4]
                        if answer == 'A5' or answer == 'A6' or answer == 'A7' or answer == 'A8':
                            general.message(
                                'Cannot set state to GAS AUTO while in AutoGFS phase.'
                            )
                        else:
                            self.device_query("A" + str(flag))
                    else:
                        self.device_query("A" + str(flag))
                else:
                    general.message("Invalid temperature controller state")
                    sys.exit()
            elif len(mode) == 0:
                raw_answer = self.device_query('X')
                answer_flag = int(raw_answer[3:4])
                answer = cutil.search_keys_dictionary(state_dict, answer_flag)
                return answer
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(mode) == 1:
                md = str(mode[0])
                if md in state_dict:
                    flag = state_dict[md]
                else:
                    assert (1 == 2), "Invalid heater range"
            elif len(mode) == 0:
                answer = test_mode
                return answer
            else:
                assert (1 == 2), "Invalid heater range"
Exemple #23
0
    def tc_heater_range(self, *heater):
        if test_flag != 'test':
            if len(heater) == 1:
                hr = str(heater[0])
                if hr in heater_dict:
                    flag = heater_dict[hr]
                    if int(loop_config) in loop_list:
                        self.device_write("RANGE " + str(loop_config) + ',' +
                                          str(flag))
                    else:
                        general.message('Invalid loop')
                        sys.exit()
                else:
                    general.message("Invalid heater range")
                    sys.exit()
            elif len(heater) == 0:
                raw_answer = int(
                    self.device_query("RANGE? " + str(loop_config)))
                answer = cutil.search_keys_dictionary(heater_dict, raw_answer)
                return answer
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(heater) == 1:
                hr = str(heater[0])
                if hr in heater_dict:
                    flag = heater_dict[hr]
                    assert (int(loop_config)
                            in loop_list), 'Invalid loop argument'
                else:
                    assert (1 == 2), "Invalid heater range"
            elif len(heater) == 0:
                answer = test_heater_range
                return answer
            else:
                assert (1 == 2), "Invalid heater range"
Exemple #24
0
    def tc_sensor(self, *sensor):
        if test_flag != 'test':
            if len(sensor) == 2:
                sens = str(sensor[0])
                state = str(sensor[1])
                if state in state_dict:
                    flag = state_dict[state]
                else:
                    general.message('Incorrect state')
                    sys.exit()
                if sens in channel_dict:
                    if sens == '1':
                        self.device_write_unsigned(384, flag, 0)
                    elif sens == '2':
                        self.device_write_unsigned(1408, flag, 0)
                    elif sens == '3':
                        self.device_write_unsigned(2432, flag, 0)
                    elif sens == '4':
                        self.device_write_unsigned(3456, flag, 0)
                else:
                    general.message('Incorrect loop')
                    sys.exit()
            elif len(sensor) == 1:
                sens = str(sensor[0])
                if sens in channel_dict:
                    if sens == '1':
                        raw_answer = int(self.device_read_unsigned(384, 0))
                        answer = cutil.search_keys_dictionary(
                            state_dict, raw_answer)
                        return answer
                    elif sens == '2':
                        raw_answer = int(self.device_read_unsigned(1408, 0))
                        answer = cutil.search_keys_dictionary(
                            state_dict, raw_answer)
                        return answer
                    elif sens == '3':
                        raw_answer = int(self.device_read_unsigned(2432, 0))
                        answer = cutil.search_keys_dictionary(
                            state_dict, raw_answer)
                        return answer
                    elif sens == '4':
                        raw_answer = int(self.device_read_unsigned(3456, 0))
                        answer = cutil.search_keys_dictionary(
                            state_dict, raw_answer)
                        return answer
                else:
                    general.message('Incorrect loop')
                    sys.exit()
            else:
                general.message('Invalid argument')
                sys.exit()

        elif test_flag == 'test':
            if len(sensor) == 2:
                sens = str(sensor[0])
                state = str(sensor[1])
                assert (sens in channel_dict), 'Invalid loop'
                assert (state in state_dict), 'Invalid state'
            elif len(sensor) == 1:
                sens = str(sensor[0])
                assert (sens in channel_dict), 'Invalid loop'
                answer = test_loop_state
                return answer
Exemple #25
0
    def tc_lock_keyboard(self, *lock):
        if test_flag != 'test':
            if len(lock) == 1:
                lk = str(lock[0])
                if lk in lock_dict:
                    flag = lock_dict[lk]
                    if flag == 0:
                        self.device_write('LOCK 1,123')
                        self.device_write('MODE 1')
                    elif flag == 1:
                        self.device_write('LOCK 1,123')
                        self.device_write('MODE 2')
                    elif flag == 2:
                        self.device_write('LOCK 0,123')
                        self.device_write('MODE 1')
                    elif flag == 3:
                        self.device_write('LOCK 0,123')
                        self.device_write('MODE 2')
                else:
                    general.message("Invalid argument")
                    sys.exit()
            elif len(lock) == 0:
                raw_answer1 = self.device_query('LOCK?')
                if config['interface'] == 'gpib':
                    answer1 = int(raw_answer1.decode()[0])
                elif config['interface'] == 'rs232':
                    answer1 = int(raw_answer1[0])
                answer2 = int(self.device_query('MODE?'))
                if answer1 == 1 and answer2 == 1:
                    answer_flag = 0
                    answer = cutil.search_keys_dictionary(
                        lock_dict, answer_flag)
                    return answer
                elif answer1 == 1 and answer2 == 2:
                    answer_flag = 1
                    answer = cutil.search_keys_dictionary(
                        lock_dict, answer_flag)
                    return answer
                elif answer1 == 0 and answer2 == 1:
                    answer_flag = 2
                    answer = cutil.search_keys_dictionary(
                        lock_dict, answer_flag)
                    return answer
                elif answer1 == 0 and answer2 == 2:
                    answer_flag = 3
                    answer = cutil.search_keys_dictionary(
                        lock_dict, answer_flag)
                    return answer
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(lock) == 1:
                lk = str(lock[0])
                if lk in lock_dict:
                    flag = lock_dict[lk]
                else:
                    assert (1 == 2), "Invalid lock argument"
            elif len(lock) == 0:
                answer = test_lock
                return answer
            else:
                assert (1 == 2), "Invalid argument"
Exemple #26
0
    def power_supply_channel_state(self, *state):
        if test_flag != 'test':
            if len(state) == 2:
                ch = str(state[0])
                st = str(state[1])
                if ch in channel_dict:
                    flag = channel_dict[ch]
                    if flag <= channels:
                        if st in state_dict:
                            rng = int(self.device_query('RNGE?'))
                            general.wait('20 ms')
                            iloc = int(self.device_query('ILOC?'))
                            if iloc != 1 and rng == 2:
                                general.message('Safety interlock is open')
                                sys.exit()
                            else:
                                self.device_write('SOUT ' + str(flag))
                        else:
                            general.message("Invalid state argument")
                            sys.exit()
                    else:
                        general.message("Invalid channel")
                        sys.exit()
                else:
                    general.message("Invalid channel")
                    sys.exit()

            elif len(state) == 1:
                ch = str(state[0])
                if ch in channel_dict:
                    flag = channel_dict[ch]
                    if flag <= channels:
                        raw_answer = int(self.device_query('SOUT?'))
                        answer = cutil.search_keys_dictionary(
                            state_dict, raw_answer)
                        return answer
                    else:
                        general.message("Invalid channel")
                        sys.exit()
                else:
                    general.message("Invalid channel")
                    sys.exit()
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(state) == 2:
                ch = str(state[0])
                st = str(state[1])
                assert (ch in channel_dict), 'Invalid channel argument'
                flag = channel_dict[ch]
                assert (flag <= channels), "Invalid channel"
                assert (st in state_dict), 'Invalid state argument'
            elif len(state) == 1:
                ch = str(state[0])
                assert (ch in channel_dict), 'Invalid channel argument'
                flag = channel_dict[ch]
                assert (flag <= channels), "Invalid channel"
                answer = test_state
                return answer
Exemple #27
0
    def delay_gen_delay(self, *delay):
        if test_flag != 'test':
            if len(delay) == 3:
                ch_1 = str(delay[0])
                ch_2 = str(delay[1])
                temp = delay[2].split(" ")
                delay = float(temp[0])
                scaling = temp[1]
                if (ch_1 in delay_channel_dict) and (ch_2 in delay_channel_dict):
                    flag_1 = delay_channel_dict[ch_1]
                    flag_2 = delay_channel_dict[ch_2]
                    if scaling in time_dict:
                        coef = time_dict[scaling]
                        if delay/coef >= delay_min and delay/coef <= delay_max:
                            self.device_write('DT ' + str(flag_1) + ',' + str(flag_2) + ',' + str(delay/coef))
                        else:
                            general.message("Incorrect delay range")
                            sys.exit()
                    else:
                        general.message("Incorrect delay scaling")
                        sys.exit()
                else:
                    general.message("Incorrect channel")
                    sys.exit()

            elif len(delay) == 1:
                ch_1 = str(delay[0])
                if (ch_1 in delay_channel_dict):
                    flag_1 = delay_channel_dict[ch_1]
                    raw_answer = str(self.device_query('DT ' + str(flag_1))).split(',')
                    ch_answer = cutil.search_keys_dictionary(delay_channel_dict, int(raw_answer[0]))
                    delay_answer = float(raw_answer[1])*1000000
                    answer = str(ch_answer) + ' + ' + str(delay_answer)
                    return answer
                else:
                    general.message("Incorrect channel")
                    sys.exit()

            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(delay) == 3:
                ch_1 = str(delay[0])
                ch_2 = str(delay[1])
                temp = delay[2].split(" ")
                delay = float(temp[0])
                scaling = temp[1]
                assert(ch_1 in delay_channel_dict), 'Invalid channel_1 argument'
                assert(ch_2 in delay_channel_dict), 'Invalid channel_2 argument'
                assert(scaling in time_dict), 'Invalid scaling argument'
                coef = time_dict[scaling]
                assert(delay/coef >= delay_min and delay/coef <= delay_max), "Incorrect delay range"

            elif len(delay) == 1:
                ch_1 = str(delay[0])
                assert(ch_1 in delay_channel_dict), 'Incorrect channel'
                answer = test_delay
                return answer
            else:
                assert(1 == 2), 'Invalid argument'