Beispiel #1
0
 def oscilloscope_run_stop(self):
     if test_flag != 'test':
         self.device_write(":RUN")
         general.wait('500 ms')
         self.device_write(":STOP")
     elif test_flag == 'test':
         pass
Beispiel #2
0
    def script(self, conn, param_1, param_2, param_3, param_4):
        """
        function that contains our experimental script
        We use four parameters to modify the script in GUI
        Param_1 - number of points
        Param_2 - time between consecutive points
        Param_3 - noise level in dummy data
        Param_4 - blank
        """
        import atomize.general_modules.general_functions as general
        # firstly import general module to be able to plot data
        # Plot_xy script, dummy data
        start_time = time.time()

        xs = np.array([])
        ys = np.array([])
        i = 0
        # always test our self.command attribute for stopping the script when neccessary
        while i < param_1 and self.command != 'exit':
            # poll() checks whether there is data in the Pipe to read
            # we use it to stop the script if the exit command was sent from the main window
            # we read data by conn.recv() only when there is the data to read
            if conn.poll() == True:
                self.command = conn.recv()
            # script loop
            xs = np.append(xs, i)
            ys = np.append(ys, np.random.randint(0, param_3 + 1))
            general.plot_1d('Plot XY Test', xs, ys, label='test data')
            general.wait(str(param_2) + ' ms')
            i = i + 1
        general.message(str(time.time() - start_time))
Beispiel #3
0
 def device_write(self, command):
     if self.status_flag == 1:
         general.wait('900 ms')  # very important to have timeout here
         command = str(command)
         self.device.write(command.encode())
     else:
         self.status_flag = 0
         general.message("No Connection")
         sys.exit()
Beispiel #4
0
 def device_query(self, command):
     if self.status_flag == 1:
         if config['interface'] == 'gpib':
             self.device.write(command)
             general.wait('50 ms')
             answer = self.device.read().decode()
     else:
         general.message("No Connection")
         self.status_flag = 0
         sys.exit()
Beispiel #5
0
    def __init__(self):
        if test_flag != 'test':
            if config['interface'] == 'rs232':
                try:
                    self.status_flag = 1
                    rm = pyvisa.ResourceManager()
                    self.device = rm.open_resource(
                        config['serial_address'],
                        write_termination=config['write_termination'],
                        baud_rate=config['baudrate'],
                        data_bits=config['databits'],
                        parity=config['parity'],
                        stop_bits=config['stopbits'])
                    self.device.timeout = config['timeout']  # in ms

                    try:
                        # test should be here
                        self.device_write('*CLS')
                        # device is slow, we need to wait a little bit
                        general.wait('50 ms')
                        answer = int(self.device_query('*TST?'))
                        if answer == 0:
                            self.status_flag = 1
                        else:
                            general.message(
                                'During internal device test errors are found')
                            self.status_flag = 0
                            sys.exit()
                    except pyvisa.VisaIOError:
                        self.status_flag = 0
                        general.message("No connection")
                        sys.exit()
                    except BrokenPipeError:
                        general.message("No connection")
                        self.status_flag = 0
                        sys.exit()
                except pyvisa.VisaIOError:
                    general.message("No connection")
                    sys.exit()
                except BrokenPipeError:
                    general.message("No connection")
                    self.status_flag = 0
                    sys.exit()

            # measure field in Gauss
            self.device_write('UNIT 1')
            # device is slow, we need to wait a little bit
            general.wait('50 ms')

        elif test_flag == 'test':
            pass
Beispiel #6
0
    def __init__(self):
        if test_flag != 'test':
            if config['interface'] == 'gpib':
                try:
                    import Gpib
                    self.status_flag = 1
                    self.device = Gpib.Gpib(config['board_address'],
                                            config['gpib_address'])
                    try:
                        #test should be here
                        self.status_flag = 1
                        # Switch off service requests
                        self.device_write('SR0')
                        # Switch to mode 0, i.e. field-controller mode via internal sweep-address-generator
                        self.device_write('MO0')
                        # Set IM0 sweep mode (we don't use it, just to make sure we don't trigger a sweep start inadvertently)
                        self.device_write('IM0')
                        # The device seems to need a bit of time after being switched to remote mode
                        general.wait('1 s')
                    except BrokenPipeError:
                        general.message("No connection")
                        self.device.close()
                        self.status_flag = 0
                        sys.exit()
                except BrokenPipeError:
                    general.message("No connection")
                    self.device.close()
                    self.status_flag = 0
                    sys.exit()

        elif test_flag == 'test':
            pass

        self.act_field = None  # the real current field
        self.is_act_field = False  # set if current field is known
        self.sf = None  # the current center field (CF) setting
        self.sw = None  # the current sweep width (SW) setting
        self.swa = None  # the current sweep address (SWA) setting
        self.is_sw = False  # set if sweep width is known
        self.max_sw = None  # maximum sweep width
        self.swa_step = None  # field step between two sweep addresses (SWAs)
        self.step_incr = None  # how many SWAs to step for a sweep step
        self.start_field = None  # the start field given by the user
        self.field_step = None  # the field steps to be used
        self.is_init = False  # flag, set if magnet_setup() has been called
        self.max_field_dev = 0.  # maximum field deviation (in test run)

        self.max_sw = max_sweep_width
        if self.max_sw > max_field - min_field:
            self.max_sw = max_field - min_field
Beispiel #7
0
 def device_query(self, command):
     if config['interface'] == 'gpib':
         try:
             command = str(str(command) + str(config['read_termination']))
             #print(command)
             self.device.write(command)
             general.wait('50 ms')
             answer = self.device.read().decode("utf-8")
             return answer
         except gpib.GpibError:
             general.message("No answer")
             sys.exit()
     else:
         general.message("No connection")
         sys.exit()
 def device_query(self, command):
     if self.status_flag == 1:
         if config['interface'] == 'rs232':
             answer = self.device.query(command)
             # device is quite slow
             general.wait('10 ms')
         elif config['interface'] == 'ethernet':
             answer = self.device.query(command)
             # device is quite slow
             general.wait('10 ms')
         return answer
     else:
         general.message("No Connection")
         self.status_flag = 0
         sys.exit()
Beispiel #9
0
    def __init__(self):
        if test_flag != 'test':
            if config['interface'] == 'rs232':
                try:
                    self.status_flag = 1
                    rm = pyvisa.ResourceManager()
                    self.device = rm.open_resource(
                        config['serial_address'],
                        read_termination=config['read_termination'],
                        write_termination=config['write_termination'],
                        baud_rate=config['baudrate'],
                        data_bits=config['databits'],
                        parity=config['parity'],
                        stop_bits=config['stopbits'])
                    self.device.timeout = config['timeout']  # in ms
                    try:
                        # test should be here
                        self.device_write('*CLS')
                        # better to have a pause here
                        general.wait('30 ms')
                        # When TOKN OFF, the DC205 responds with
                        # the numeric version  of the token quantity
                        self.device_write('TOKN 0')

                    except pyvisa.VisaIOError:
                        self.status_flag = 0
                        general.message("No connection")
                        sys.exit()
                    except BrokenPipeError:
                        general.message("No connection")
                        self.status_flag = 0
                        sys.exit()
                except pyvisa.VisaIOError:
                    general.message("No connection")
                    self.status_flag = 0
                    sys.exit()
                except BrokenPipeError:
                    general.message("No connection")
                    self.status_flag = 0
                    sys.exit()

            elif config['interface'] != 'rs232':
                general.message('Invalid interface')
                sys.exit()

        elif test_flag == 'test':
            pass
Beispiel #10
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
Beispiel #11
0
 def device_query(self, command):
     if self.status_flag == 1:
         if config['interface'] == 'gpib':
             self.device.write(command)
             general.wait('50 ms')
             answer = self.device.read().decode()
             return answer
         elif config['interface'] == 'rs232':
             answer = self.device.query()
             return answer
         else:
             general.message('Incorrect interface setting')
             self.status_flag = 0
     else:
         general.message("No Connection")
         self.status_flag = 0
         sys.exit()
Beispiel #12
0
    def power_supply_measure(self, channel):
        if test_flag != 'test':
            ch = str(channel)
            if ch in channel_dict:
                raw_answer_1 = self.device_query('VOUT?')
                general.wait('20 ms')
                raw_answer_2 = self.device_query('IOUT?')
                answer = [float(raw_answer_1), float(raw_answer_2)]
                return answer
            else:
                general.message('Invalid channel')
                sys.exit()

        elif test_flag == 'test':
            ch = str(channel)
            assert (ch in channel_dict), 'Invalid channel'
            answer = test_measure
            return answer
Beispiel #13
0
    def fc_test_leds(self):
        """
        Function for testing LED indicators.
        """
        if test_flag != 'test':
            while True:
                is_overload = is_remote = False
                answer = self.device_query('LE')

                while answer and answer != 'LE\r\n':
                    if answer == 'LE1\r\n':
                        is_overload = True
                        break
                    elif answer == 'LE2\r\n':
                        general.message(
                            "Probehead thermostat not in equilibrilum.")
                        break
                    elif answer == 'LE4\r\n':
                        is_remote = True
                        break
                    else:
                        break

                    answer = int(answer) + 1

                # If remote LED isn't on we're out of luck...
                if is_remote == False:
                    general.message("Device isn't in remote state.")
                    sys.exit()

                # If there's no overload we're done, otherwise we retry several
                # times before giving up.
                if is_overload == False:
                    break

                if (max_retries - 1) > 0:
                    general.wait('1 s')
                else:
                    general.message("Field regulation loop not balanced.")
                    sys.exit()

        elif test_flag == 'test':
            pass
Beispiel #14
0
    def freq_counter_frequency(self, channel):
        if test_flag != 'test':
            if channel == 'CH1':
                # make sure that the channel is correct
                self.device_write(":FUNC 'FREQ 1'")
                general.wait('30 ms')
                answer = float(self.device_query(':READ?')) / 1000
                self.device_write(':INIT:CONT ON')
                return answer
            elif channel == 'CH2':
                # make sure that the channel is correct
                self.device_write(":FUNC 'FREQ 2'")
                general.wait('30 ms')
                answer = float(self.device_query(':READ?')) / 1000
                self.device_write(':INIT:CONT ON')
                return answer
            elif channel == 'CH3':
                # make sure that the channel is correct
                self.device_write(":FUNC 'FREQ 3'")
                general.wait('30 ms')
                answer = float(self.device_query(':READ?')) / 1000
                self.device_write(':INIT:CONT ON')
                return answer
            else:
                general.message('Invalid argument')
                sys.exit()

        elif test_flag == 'test':
            assert (channel == 'CH1' or channel == 'CH2'
                    or channel == 'CH3'), 'Invalid channel'
            answer = test_frequency
            return answer
Beispiel #15
0
    def delay_gen_amplitude_offset(self, *amplitude_offset):
        if test_flag != 'test':
            if len(amplutide) == 3:
                ch = str(amplutide[0])
                temp_1 = amplutide[1].split(" ")
                temp_2 = amplutide[2].split(" ")
                ampl = float(temp_1[0])
                scaling_1 = temp_1[1]
                ofst = float(temp_2[0])
                scaling_2 = temp_2[1]
                if ch in output_channel_dict:
                    flag_1 = output_channel_dict[ch]
                    if (scaling_1 in ampl_dict) and (scaling_2 in ampl_dict):
                        coef_1 = ampl_dict[scaling_1]
                        coef_2 = ampl_dict[scaling_2]
                        if int(self.device_query('OM ' + str(flag_1))) == 3:
                            general.wait('30 ms')
                            if (ampl/coef_1 + ofst/coef_2) >= var_ampl_min and \
                            (ampl/coef_1 + ofst/coef_2) <= var_ampl_max and (ampl/coef_1) >= var_ampl_min \
                            (ampl/coef_1) <= var_ampl_max and (ofst/coef_2) >= var_ampl_min \
                            (ofst/coef_2) <= var_ampl_max:
                                self.device_write('OA ' + str(flag_1) + ',' + str(ampl/coef_1))
                                self.device_write('OO ' + str(flag_1) + ',' + str(ofst/coef_2))
                            else:
                                general.message("Incorrect amplitude and offset range")
                                sys.exit()
                        else:
                            general.message("You are not in Variable mode")
                            pass
                    else:
                        general.message("Incorrect scaling")
                        sys.exit()
                else:
                    general.message("Invalid channel")
                    sys.exit()
            
            elif len(amplutide) == 1:
                ch = str(amplutide[0])
                if ch in output_channel_dict:
                    flag = output_channel_dict[ch]
                    answer_1 = float(self.device_query('OA ' + str(flag)))
                    answer_2 = float(self.device_query('OO ' + str(flag)))
                    answer = 'Amplitude: ' + str(answer_1) + ' V; ' + 'Offset: ' + str(answer_2) + ' V'
                    return answer
                else:
                    general.message("Invalid channel")
                    sys.exit()
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(amplutide) == 3:
                ch = str(amplutide[0])
                temp_1 = amplutide[1].split(" ")
                temp_2 = amplutide[2].split(" ")
                ampl = float(temp_1[0])
                scaling_1 = temp_1[1]
                ofst = float(temp_2[0])
                scaling_2 = temp_2[1]
                assert(ch in output_channel_dict), 'Invalid channel'
                assert(scaling_1 in ampl_dict), 'Invalid scaling of amplitude setting'
                assert(scaling_2 in ampl_dict), 'Invalid scaling of offset setting'
                coef_1 = ampl_dict[scaling_1]
                coef_2 = ampl_dict[scaling_2]
                assert(ampl/coef_1 >= var_ampl_min and ampl/coef_1 <= var_ampl_max), "Incorrect amplitude range"
                assert(ofst/coef_2 >= var_ampl_min and ofst/coef_2 <= var_ampl_max), "Incorrect offset range"
                assert(ampl/coef_1 + ofst/coef_2 >= var_ampl_min and ampl/coef_1 + ofst/coef_2 <= var_ampl_max), "Incorrect range"

            elif len(amplutide) == 1:
                ch = str(amplutide[0])
                assert(ch in output_channel_dict), 'Invalid channel argument'
                answer = test_amplitude_offset
                return answer
Beispiel #16
0
    def script(self, conn, param_1, param_2, param_3, param_4):
        """
        function that contains our experimental script
        We use four parameters to modify the script in GUI
        Param_1 - number of points
        Param_2 - time between consecutive points
        Param_3 - noise level in dummy data
        Param_4 - blank
        """
        import numpy as np
        import atomize.general_modules.general_functions as general
        import atomize.device_modules.PB_ESR_500_pro as pb_pro
        import atomize.device_modules.BH_15 as bh

        # A possible use in an experimental script
        pb = pb_pro.PB_ESR_500_Pro()
        bh15 = bh.BH_15()

        bh15.magnet_setup(3473, 1)

        pb.pulser_pulse(name='P0',
                        channel='MW',
                        start='100 ns',
                        length='12 ns')
        pb.pulser_pulse(name='P1',
                        channel='MW',
                        start='300 ns',
                        length='24 ns')
        pb.pulser_pulse(name='P2',
                        channel='TRIGGER',
                        start='500 ns',
                        length='100 ns')

        pb.pulser_update()
        i = 0
        # the idea of automatic and dynamic changing of repetition rate is
        # based on quite big amount of cycles (param_2); 6000*0.3 s = 2000 s
        # and on sending anew value of repetition rate via self.command
        # in each cycle we will check the current value of self.command
        # if the pause inside a loop is not big
        # everything will be dynamic
        # self.command = 'exit' will stop pulse blaster
        while i < param_2 and self.command != 'exit':
            # always test our self.command attribute for stopping the script when neccessary
            if i == 1 or (self.command != 'exit' and self.command != 'start'):
                if i != 1:
                    if self.command[0:2] == 'FR':
                        param_1 = self.command[2:]
                        rep_rate = str(param_1) + ' Hz'
                        pb.pulser_repetitoin_rate(rep_rate)
                        pb.pulser_update()
                    elif self.command[0:2] == 'FI':
                        param_3 = self.command[2:]
                        field = float(param_3)
                        general.message(field)
                        bh15.magnet_field(field)

                self.command = 'start'
            # poll() checks whether there is data in the Pipe to read
            # we use it to stop the script if the exit command was sent from the main window
            # we read data by conn.recv() only when there is the data to read
            general.wait('0.3 s')
            if conn.poll() == True:
                self.command = conn.recv()

            i += 1

        general.message('Finished Cycles')
        if self.command == 'exit':
            general.message('Stop')
            pb.pulser_stop()
Beispiel #17
0
import numpy as np
import atomize.general_modules.general_functions as general
import atomize.device_modules.BH_15 as bh

bh15 = bh.BH_15()

bh15.magnet_setup(2000, 10)
#general.message(bh15.device_write('SS175.000'))
#general.message(bh15.device_query('LE'))

i = 0
while i < 5:

    a = float(bh15.magnet_field(0 + 10 * i))
    general.message(bh15.magnet_field())
    general.wait('200 ms')
    i = i + 1

#Plot_xy Test
#for i in range(1000):
#   start_time = time.time()
#   xs = np.append(xs, i);
#   ys = np.append(ys, sr.lock_in_get_data());
#ys = np.append(ys, np.random.randint(10,size=1));
#   general.plot_1d('SR 860', xs, ys, label='test data')
#   general.wait('30 ms')

#   general.message(str(time.time() - start_time))

# Append_y Test
#for i in range(100):
    def __init__(self):
        if test_flag != 'test':
            if config['interface'] == 'rs232':
                try:
                    self.status_flag = 1
                    rm = pyvisa.ResourceManager()
                    self.device = rm.open_resource(
                        config['serial_address'],
                        read_termination=config['read_termination'],
                        write_termination=config['write_termination'],
                        baud_rate=config['baudrate'],
                        data_bits=config['databits'],
                        parity=config['parity'],
                        stop_bits=config['stopbits'])
                    self.device.timeout = config['timeout']  # in ms
                    try:
                        # test should be here
                        self.device_write('*CLS')
                        general.wait('50 ms')
                    except pyvisa.VisaIOError:
                        self.status_flag = 0
                        general.message("No connection")
                        sys.exit()
                    except BrokenPipeError:
                        general.message("No connection")
                        self.status_flag = 0
                        sys.exit()
                except pyvisa.VisaIOError:
                    general.message("No connection")
                    self.status_flag = 0
                    sys.exit()
                except BrokenPipeError:
                    general.message("No connection")
                    self.status_flag = 0
                    sys.exit()

            elif config['interface'] == 'ethernet':
                try:
                    self.status_flag = 1
                    rm = pyvisa.ResourceManager()
                    self.device = rm.open_resource(config['ethernet_address'])
                    self.device.timeout = config['timeout']  # in ms
                    try:
                        # test should be here
                        self.device_write('*CLS')
                    except pyvisa.VisaIOError:
                        general.message("No connection")
                        self.status_flag = 0
                        sys.exit()
                    except BrokenPipeError:
                        general.message("No connection")
                        self.status_flag = 0
                        sys.exit()
                except pyvisa.VisaIOError:
                    general.message("No connection")
                    self.status_flag = 0
                    sys.exit()
                except BrokenPipeError:
                    general.message("No connection")
                    self.status_flag = 0
                    sys.exit()
        elif test_flag == 'test':
            pass
Beispiel #19
0
#pb.pulser_pulse(name ='P3', channel = 'TRIGGER', start = '572 ns', length = '100 ns')

# DEER CHECK
#pb.pulser_pulse(name = 'P0', channel = 'MW', start = '2100 ns', length = '12 ns')
#pb.pulser_pulse(name = 'P1', channel = 'MW', start = '2440 ns', length = '24 ns')
#pb.pulser_pulse(name = 'P2', channel = 'MW', start = '3780 ns', length = '24 ns')
#PUMP
#pb.pulser_pulse(name = 'P3', channel = 'AWG', start = '3580 ns', length = '24 ns')
#pb.pulser_pulse(name = 'P4', channel = 'TRIGGER_AWG', start = '526 ns', length = '24 ns')
#DETECTION
#pb.pulser_pulse(name = 'P5', channel = 'TRIGGER', start = '4780 ns', length = '100 ns')

pb.pulser_repetitoin_rate('1000 Hz')

pb.pulser_update()
pb.pulser_visualize()

i = 0
for i in general.to_infinity():

    pb.pulser_update()
    #pb.pulser_visualize()

    general.wait('1000 ms')

    if i > 1000:
        break
        pb.pulser_stop()

pb.pulser_stop()
Beispiel #20
0
    def power_supply_voltage(self, *voltage):
        if test_flag != 'test':
            if len(voltage) == 2:
                ch = str(voltage[0])
                temp = voltage[1].split(" ")
                vtg = float(temp[0])
                scaling = temp[1]
                if ch in channel_dict:
                    if scaling in voltage_dict:
                        coef = voltage_dict[scaling]
                        smod_check = int(self.device_query('SMOD?'))
                        general.wait('20 ms')
                        if smod_check == 0:
                            if voltage_min > 0 and voltage_max > 0:
                                if vtg / coef >= voltage_min and vtg / coef <= voltage_max:
                                    limit_check = float(
                                        self.device_query('VLIM?'))
                                    general.wait('20 ms')
                                    if vtg / coef <= limit_check:
                                        self.device_write('VSET ' +
                                                          str(vtg / coef))
                                    else:
                                        general.message(
                                            "Voltage setting is higher than voltage limit setting"
                                        )
                                else:
                                    general.message("Incorrect voltage range")
                                    sys.exit()
                            elif voltage_min < 0 and voltage_max < 0:
                                if vtg / coef <= voltage_min and vtg / coef >= voltage_max:
                                    limit_check = float(
                                        self.device_query('VLIM?'))
                                    general.wait('20 ms')
                                    if vtg / coef >= limit_check:
                                        self.device_write('VSET ' +
                                                          str(vtg / coef))
                                    else:
                                        general.message(
                                            "Voltage setting is lower than voltage limit setting"
                                        )
                                else:
                                    general.message("Incorrect voltage range")
                                    sys.exit()
                            else:
                                general.message(
                                    "Incorrect max/min voltage in the module")
                                sys.exit()
                        elif smod_check == 1:
                            general.message(
                                "Voltage setting is controlled by the rear-panel HVSET input"
                            )
                            sys.exit()
                        else:
                            general.message("Incorrect rear_mode setting")
                            sys.exit()
                    else:
                        general.message("Incorrect voltage scaling")
                        sys.exit()
                else:
                    general.message("Incorrect channel")
                    sys.exit()

            elif len(voltage) == 1:
                ch = str(voltage[0])
                if ch in channel_dict:
                    smod_check = int(self.device_query('SMOD?'))
                    general.wait('20 ms')
                    if smod_check == 0:
                        answer = float(self.device_query('VSET?'))
                        return answer
                    elif smod_check == 1:
                        general.message(
                            "Voltage setting is controlled by the rear-panel HVSET input"
                        )
                        answer = float(self.device_query('VSET?'))
                        return answer
                    else:
                        general.message("Incorrect SMOD setting")
                        sys.exit()
                else:
                    general.message("Invalid channel")
                    sys.exit()
            else:
                general.message("Invalid argument")
                sys.exit()

        elif test_flag == 'test':
            if len(voltage) == 2:
                ch = str(voltage[0])
                temp = voltage[1].split(" ")
                vtg = float(temp[0])
                scaling = temp[1]
                assert (ch in channel_dict), 'Invalid channel argument'
                assert (scaling in voltage_dict), 'Invalid scaling argument'
                if voltage_min > 0 and voltage_max > 0:
                    assert (vtg / coef >= voltage_min
                            and vtg / coef <= voltage_max
                            ), "Incorrect voltage range"
                elif voltage_min < 0 and voltage_max < 0:
                    assert (vtg / coef <= voltage_min
                            and vtg / coef >= voltage_max
                            ), "Incorrect voltage range"
                else:
                    assert (1 == 2), "Incorrect max/min voltage in the module"
            elif len(voltage) == 1:
                ch = str(voltage[0])
                assert (ch in channel_dict), 'Invalid channel argument'
                answer = test_voltage
                return answer
Beispiel #21
0
#general.wait('1 s')
#j += 1

###pb.pulser_repetitoin_rate()

#general.message(str(time.time() - start_time))

j = 0
while j < 3:
    #general.message('J CYCLE: ' + str(j))
    i = 0
    while i < 25:
        #general.message('I: ')
        pb.pulser_update()
        pb.pulser_shift()
        ###pb.pulser_increment()
        pb.pulser_visualize()
        general.wait('1 s')
        i += 1
    # '2 kHz'

    pb.pulser_reset()
    #print(pb.pulse_array_init)
    general.wait('1 s')
    j += 1

###pb.pulser_stop()

#print( convertion_to_numpy(pulse_array_init) )
#pb_close()
Beispiel #22
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