def VnaMeasure(ui, ip, port): # Disable button after click ui.measure_vna.setEnabled(False) ui.left_button.setEnabled(False) ui.right_button.setEnabled(False) channel = VnaChannel(ip, port, 1) # One channel # channel.reset() channel.set_four_channels() sdata = [] # Clean sdata for each measure for idx, spar in enumerate([SParameters.S11, SParameters.S12, SParameters.S21, SParameters.S22]): print "Now measuring: " + str(spar) channel.set_sweep_type(SweepType.LINEAR) channel.channel = idx + 1 points = str(ui.points_field.text()) fmat = DataFormat.LOG # By default we use MLOG fmat_index = ui.format_combobox.currentIndex() formats = [DataFormat.LOG, DataFormat.LIN, DataFormat.LIN_PHASE, DataFormat.PHASE, DataFormat.GDELAY, DataFormat.SMITH_LIN_PHASE, DataFormat.SMITH_LOG_PHASE, DataFormat.SMITH_RE_IM, DataFormat.SMITH_R_JX, DataFormat.SMITH_G_JB] fmat = formats[fmat_index] if ui.center_span_radio.isChecked(): groupbox = ui.bottom_layout.itemAt(3).widget() center_freq = float(groupbox.findChild(QtGui.QLineEdit, "center_field").text()) span_freq = float(groupbox.findChild(QtGui.QLineEdit, "span_field").text()) channel.set_center_span(center_freq, span_freq) channel.set_traces(1) channel.set_points(points) channel.set_sparam(1, spar) channel.set_format(fmat) # set the selected format channel.activate_channel() channel.activate_trace(1) channel.set_continuous(True) elif ui.start_stop_radio.isChecked(): groupbox = ui.bottom_layout.itemAt(3).widget() freq_start = float(groupbox.findChild(QtGui.QLineEdit, "freqstart_field").text()) freq_stop = float(groupbox.findChild(QtGui.QLineEdit, "freqstop_field").text()) channel.set_start_stop(freq_start, freq_stop) channel.set_traces(1) channel.set_points(points) channel.set_sparam(1, spar) channel.set_format(fmat) # set the selected format channel.activate_channel() channel.activate_trace(1) channel.set_continuous(True) if ui.autoscale_checkbox.isChecked(): channel.auto_scale() # Autoscale f = str(ui.vna_file_field.text()) retrieve_data(ip, port, f, fmat, channel.executor) for ch, sparam in zip([1,2,3,4], [SParameters.S11, SParameters.S12, SParameters.S21, SParameters.S22]): channel.channel = ch channel.set_sparam(1, sparam) channel.channel = 1 channel.executor.close() # Reenable buttons once measure has finished ui.measure_vna.setEnabled(True) ui.left_button.setEnabled(True) ui.right_button.setEnabled(True)
def VnaMeasureSingle(ui, ip, port): ui.measure_vna.setEnabled(False) ui.left_button.setEnabled(False) ui.right_button.setEnabled(False) channel = VnaChannel(ip, port, 1) # One channel # channel.reset() channel.set_sweep_type(SweepType.LINEAR) if ui.s11_radio.isChecked(): spar = SParameters.S11 elif ui.s12_radio.isChecked(): spar = SParameters.S12 elif ui.s21_radio.isChecked(): spar = SParameters.S21 elif ui.s22_radio.isChecked(): spar = SParameters.S22 points = str(ui.points_field.text()) fmat = DataFormat.LOG # By default we use MLOG fmat_index = ui.format_combobox.currentIndex() formats = [DataFormat.LOG, DataFormat.LIN, DataFormat.LIN_PHASE, DataFormat.PHASE, DataFormat.GDELAY, DataFormat.SMITH_LIN_PHASE, DataFormat.SMITH_LOG_PHASE, DataFormat.SMITH_RE_IM, DataFormat.SMITH_R_JX, DataFormat.SMITH_G_JB] fmat = formats[fmat_index] channel.set_one_channel() if ui.center_span_radio.isChecked(): groupbox = ui.bottom_layout.itemAt(3).widget() center_freq = float(groupbox.findChild(QtGui.QLineEdit, "center_field").text()) span_freq = float(groupbox.findChild(QtGui.QLineEdit, "span_field").text()) channel.set_center_span(center_freq, span_freq) channel.set_traces(1) channel.set_points(points) channel.set_sparam(1, spar) channel.set_format(fmat) # set the selected format channel.activate_channel() channel.activate_trace(1) channel.set_continuous(True) elif ui.start_stop_radio.isChecked(): groupbox = ui.bottom_layout.itemAt(3).widget() freq_start = float(groupbox.findChild(QtGui.QLineEdit, "freqstart_field").text()) freq_stop = float(groupbox.findChild(QtGui.QLineEdit, "freqstop_field").text()) channel.set_start_stop(freq_start, freq_stop) channel.set_traces(1) channel.set_points(points) channel.set_sparam(1, spar) channel.set_format(fmat) # set the selected format channel.activate_channel() channel.activate_trace(1) channel.set_continuous(True) if ui.autoscale_checkbox.isChecked(): channel.auto_scale() # Autoscale f = str(ui.vna_file_field.text()) channel.executor.close() # Reenable buttons once measure has finished ui.measure_vna.setEnabled(True) ui.left_button.setEnabled(True) ui.right_button.setEnabled(True) thread.start_new_thread(retrieve_data_single, (ip, port, f))