Ejemplo n.º 1
0
    def FillPortsList(self, event):
        self.data_file_name_value = self.data_file_name.GetValue()

        if check_value_is_valid_file(self.data_file_name_value,
                                     "Generic graph data file") == 0:
            return 0

        self.graph_type_value = self.graph_type.GetValue()
        if self.graph_type_value in generic_graph_types.keys():
            self.graph_type_value = generic_graph_types[self.graph_type_value]
        else:
            error_message("Graph type not selected", "Graph type error")
            return 0

        if str(self.graph_type_value) != "NN":
            error_message("Graph type invalid", "Graph type error")
            return 0

        file_table_result, list_of_s_param = opentouchstonefile(
            self.data_file_name_value, filter_label=None)

        self.ports_checkboxlist.Clear()

        for port in list_of_s_param:
            self.ports_checkboxlist.Append(port)
Ejemplo n.º 2
0
    def OnPlotGraph(self, event):
        data_file_name = self.data_file_name.GetValue()
        if check_value_is_valid_file(data_file_name, "Data IP1 file") == 0:
            return None

        graph_title = self.graph_title.GetValue()

        graph_x, graph_y, dummy = self.check_and_return_Axis_ranges()
        if graph_x is None or graph_y is None:
            return None

        graph_animated = self.graph_animated.GetValue()

        # dlg = wx.TextEntryDialog(self, "Insert Spurius Frequencies (MHz) - comma separated")
        # dlg.ShowModal()
        # result = dlg.GetValue()
        # dlg.Destroy()
        # IF_Frequency_selected = eval("[" + result + "]")
        # IF_Frequency_selected = [unit.convertion_to_base(x, unit.MHz) for x in IF_Frequency_selected]
        IF_Frequency_selected = [
            unit.convertion_to_base(x, human_readable_frequency_unit)
            for x in self.return_checked_ports()
        ]
        # IF_Frequency_selected = self.return_checked_ports()

        current_font_style = self.Parent.GrandParent.get_selected_settings()
        calculate_all_IP1(data_file_name,
                          graph_title,
                          graph_x,
                          graph_y,
                          IF_Frequency_selected,
                          graph_animated,
                          font_style=current_font_style)
        try:
            pass
            # calculate_all_IP1(data_file_name,
            #                   graph_title,
            #                   graph_x,
            #                   graph_y,
            #                   IF_Frequency_selected,
            #                   graph_animated,
            #                   font_style=current_font_style)
            # # self.instrument_label.SetLabel(response)
        except SplineError:
            error_message("Impossible to build spline", "Spline Error")
        except PointNotFound:
            error_message("IP1 point not found", "IP1 error")

        try:
            last_svg = ""
            result_folder = os.path.dirname(data_file_name)
            for svg_file in buildfitsfileslist(result_folder):
                last_svg = svg_file
                execute = [
                    inkscape_exec, "-f", svg_file, '-M', svg_file[:-4] + '.emf'
                ]
                print("saving " + svg_file[:-4] + '.emf')
                subprocess.call(execute)
        except:
            print("Error saving " + last_svg)
Ejemplo n.º 3
0
    def check_values(self):
        self.data_file_name_value = self.data_file_name.GetValue()

        if check_value_is_valid_file(self.data_file_name_value,
                                     "Data Harmonic file") == 0:
            return 0

        self.graph_type_value = "IP1"
Ejemplo n.º 4
0
    def check_values(self):
        self.data_file_name_value = self.data_file_name.GetValue()

        if check_value_is_valid_file(self.data_file_name_value,
                                     "Generic graph data file") == 0:
            return 0

        self.graph_type_value = self.graph_type.GetValue()
        if self.graph_type_value in generic_graph_types.keys():
            self.graph_type_value = generic_graph_types[self.graph_type_value]
        else:
            error_message("Graph type not selected", "Graph type error")
            return 0
Ejemplo n.º 5
0
    def FillSpuriousFreqList(self, event):
        self.data_file_name_value = self.data_file_name.GetValue()

        if check_value_is_valid_file(self.data_file_name_value,
                                     "IP1 data file") == 0:
            return 0

        file_table_result, unit_value, data_file_directory = openSpuriusfile(
            self.data_file_name_value)

        freq = []
        for row in file_table_result:
            freq.append(
                unit.convertion_from_base(row[frequency_RF_index],
                                          human_readable_frequency_unit))

        freq = list(set(freq))

        freq.sort()

        self.spurious_freq_checkboxlist.Clear()

        for f in freq:
            self.spurious_freq_checkboxlist.Append(str(f))
Ejemplo n.º 6
0
    def OnStart(self, event):

        TaskFrame.OnStart(self, event)
        # load values

        synthetizer_LO_IP = self.notebook.tabLO.instrument_txt_IP.GetValue()
        if check_value_is_IP(synthetizer_LO_IP, "LO Synthetizer IP") == 0:
            return None

        synthetizer_LO_Port = self.notebook.tabLO.instrument_txt_Port.GetValue()
        if check_value_min_max(synthetizer_LO_Port, "LO Synthetizer Port", minimum=0) == 0:
            return None

        synthetizer_LO_Timeout = self.notebook.tabLO.instrument_txt_Timeout.GetValue()
        if check_value_min_max(synthetizer_LO_Timeout, "LO Synthetizer Timeout", minimum=0) == 0:
            return None

        synthetizer_LO_instrType = self.notebook.tabLO.combobox_instrtype.GetValue()

        synthetizer_LO_state = self.notebook.tabLO.instrument_enable_status.GetValue()

        # synthetizer_LO_frequency_min_unit = unit.return_unit(self.notebook.tabLO.synthetizer_frequency_min_unit.GetValue())
        # if check_value_not_none(synthetizer_LO_frequency_min_unit, "Minimum LO Frequency Unit") == 0:
        #    return None

        if synthetizer_LO_state:

            synthetizer_LO_frequency_min = self.notebook.tabLO.synthetizer_frequency_min.GetValue()
            if check_value_min_max(synthetizer_LO_frequency_min, "Minimum LO Frequency", minimum=0) == 0:
                return None
            else:
                synthetizer_LO_frequency_min = eval(self.notebook.tabLO.synthetizer_frequency_min.GetValue())

            # synthetizer_LO_frequency_max_unit = unit.return_unit(self.notebook.tabLO.synthetizer_frequency_max_unit.GetValue())
            # if check_value_not_none(synthetizer_LO_frequency_max_unit, "Maximum LO Frequency Unit") == 0:
            #    return None

            synthetizer_LO_frequency_max = self.notebook.tabLO.synthetizer_frequency_max.GetValue()
            if check_value_min_max(synthetizer_LO_frequency_max, "Maximum LO Frequency", minimum=0) == 0:
                return None
            else:
                synthetizer_LO_frequency_max = eval(self.notebook.tabLO.synthetizer_frequency_max.GetValue())

            # synthetizer_LO_frequency_step_unit = unit.return_unit(self.notebook.tabLO.synthetizer_frequency_step_unit.GetValue())
            # if check_value_not_none(synthetizer_LO_frequency_step_unit, "LO Step Frequency Unit") == 0:
            #    return None

            synthetizer_LO_frequency_unit = unit.return_unit(self.notebook.tabLO.synthetizer_frequency_unit.GetValue())
            if check_value_not_none(synthetizer_LO_frequency_unit, "LO Frequency Unit") == 0:
                return None

            synthetizer_LO_frequency_step = self.notebook.tabLO.synthetizer_frequency_step.GetValue()
            if check_value_min_max(synthetizer_LO_frequency_step, "LO Step Frequency", minimum=0) == 0:
                return None
            else:
                synthetizer_LO_frequency_step = eval(self.notebook.tabLO.synthetizer_frequency_step.GetValue())

            try:
                synthetizer_LO_level_min = eval(self.notebook.tabLO.synthetizer_level_min.GetValue())
            except:
                synthetizer_LO_level_min = 0

            try:
                synthetizer_LO_level_max = eval(self.notebook.tabLO.synthetizer_level_max.GetValue())
            except:
                synthetizer_LO_level_max = 0

            synthetizer_LO_level_step = self.notebook.tabLO.synthetizer_level_step.GetValue()
            if check_value_min_max(synthetizer_LO_level_step, "LO Level Step", minimum=0) == 0:
                return None
            else:
                synthetizer_LO_level_step = eval(self.notebook.tabLO.synthetizer_level_step.GetValue())

            synthetizer_LO_frequency = Frequency_Range(synthetizer_LO_frequency_min, synthetizer_LO_frequency_max,
                                                       synthetizer_LO_frequency_step, synthetizer_LO_frequency_unit)
            synthetizer_LO_frequency.to_base()
            synthetizer_LO_level = Generic_Range(synthetizer_LO_level_min, synthetizer_LO_level_max,
                                                 synthetizer_LO_level_step)
        else:
            synthetizer_LO_frequency = Frequency_Range(0, 0, 1, unit.Hz)
            synthetizer_LO_frequency.to_base()
            synthetizer_LO_level = Generic_Range(0, 0, 1)

        synthetizer_RF_IP = self.notebook.tabRF.instrument_txt_IP.GetValue()
        if check_value_is_IP(synthetizer_RF_IP, "RF Synthetizer IP") == 0:
            return None

        synthetizer_RF_Port = self.notebook.tabRF.instrument_txt_Port.GetValue()
        if check_value_min_max(synthetizer_RF_Port, "RF Synthetizer Port", minimum=0) == 0:
            return None

        synthetizer_RF_Timeout = self.notebook.tabRF.instrument_txt_Timeout.GetValue()
        if check_value_min_max(synthetizer_RF_Timeout, "RF Synthetizer Timeout", minimum=0) == 0:
            return None

        synthetizer_RF_instrType = self.notebook.tabRF.combobox_instrtype.GetValue()

        synthetizer_RF_state = self.notebook.tabRF.instrument_enable_status.GetValue()
        # synthetizer_RF_frequency_min_unit = unit.return_unit(self.notebook.tabRF.synthetizer_frequency_min_unit.GetValue())
        # if check_value_not_none(synthetizer_RF_frequency_min_unit, "Minimum RF Frequency Unit") == 0:
        #    return None
        if synthetizer_RF_state:
            synthetizer_RF_frequency_min = self.notebook.tabRF.synthetizer_frequency_min.GetValue()
            if check_value_min_max(synthetizer_RF_frequency_min, "Minimum RF Frequency", minimum=0) == 0:
                return None
            else:
                synthetizer_RF_frequency_min = eval(self.notebook.tabRF.synthetizer_frequency_min.GetValue())

            # synthetizer_RF_frequency_max_unit = unit.return_unit(self.notebook.tabRF.synthetizer_frequency_max_unit.GetValue())
            # if check_value_not_none(synthetizer_RF_frequency_max_unit, "Maximum RF Frequency Unit") == 0:
            #    return None

            synthetizer_RF_frequency_max = self.notebook.tabRF.synthetizer_frequency_max.GetValue()
            if check_value_min_max(synthetizer_RF_frequency_max, "Maximum RF Frequency", minimum=0) == 0:
                return None
            else:
                synthetizer_RF_frequency_max = eval(self.notebook.tabRF.synthetizer_frequency_max.GetValue())

            # synthetizer_RF_frequency_step_unit = unit.return_unit(self.notebook.tabRF.synthetizer_frequency_step_unit.GetValue())
            # if check_value_not_none(synthetizer_RF_frequency_step_unit, "RF Step Frequency Unit") == 0:
            #    return None

            synthetizer_RF_frequency_step = self.notebook.tabRF.synthetizer_frequency_step.GetValue()
            if check_value_min_max(synthetizer_RF_frequency_step, "RF Step Frequency", minimum=0) == 0:
                return None
            else:
                synthetizer_RF_frequency_step = eval(self.notebook.tabRF.synthetizer_frequency_step.GetValue())

            synthetizer_RF_frequency_unit = unit.return_unit(self.notebook.tabRF.synthetizer_frequency_unit.GetValue())
            if check_value_not_none(synthetizer_RF_frequency_unit, "RF Frequency Unit") == 0:
                return None

            try:
                synthetizer_RF_level_min = eval(self.notebook.tabRF.synthetizer_level_min.GetValue())
            except:
                synthetizer_RF_level_min = 0

            try:
                synthetizer_RF_level_max = eval(self.notebook.tabRF.synthetizer_level_max.GetValue())
            except:
                synthetizer_RF_level_max = 0

            synthetizer_RF_level_step = self.notebook.tabRF.synthetizer_level_step.GetValue()
            if check_value_min_max(synthetizer_RF_level_step, "RF Level Step", minimum=0) == 0:
                return None
            else:
                synthetizer_RF_level_step = eval(self.notebook.tabRF.synthetizer_level_step.GetValue())

            synthetizer_RF_frequency = Frequency_Range(synthetizer_RF_frequency_min, synthetizer_RF_frequency_max,
                                                       synthetizer_RF_frequency_step, synthetizer_RF_frequency_unit)
            synthetizer_RF_frequency.to_base()
            synthetizer_RF_level = Generic_Range(synthetizer_RF_level_min, synthetizer_RF_level_max,
                                                 synthetizer_RF_level_step)
        else:
            synthetizer_RF_frequency = Frequency_Range(0, 0, 1, unit.Hz)
            synthetizer_RF_frequency.to_base()
            synthetizer_RF_level = Generic_Range(0, 0, 1)

        vscd_IP = self.notebook.tabVSCD.instrument_txt_IP.GetValue()
        if check_value_is_IP(vscd_IP, "VSCD IP") == 0:
            return None

        vscd_Port = self.notebook.tabVSCD.instrument_txt_Port.GetValue()
        if check_value_min_max(vscd_Port, "VSCD Port", minimum=0) == 0:
            return None

        vscd_Timeout = self.notebook.tabVSCD.instrument_txt_Timeout.GetValue()
        if check_value_min_max(vscd_Timeout, "VSCD Timeout", minimum=0) == 0:
            return None

        vscd_instrType = self.notebook.tabVSCD.combobox_instrtype.GetValue()

        vscd_state = self.notebook.tabVSCD.instrument_enable_status.GetValue()

        # synthetizer_LO_frequency_min_unit = unit.return_unit(self.notebook.tabLO.synthetizer_frequency_min_unit.GetValue())
        # if check_value_not_none(synthetizer_LO_frequency_min_unit, "Minimum LO Frequency Unit") == 0:
        #    return None

        if vscd_state:

            vscd_frequency_min = self.notebook.tabVSCD.vscd_frequency_min.GetValue()
            if check_value_min_max(vscd_frequency_min, "VSCD Frequency", minimum=0) == 0:
                return None
            else:
                vscd_frequency_min = eval(self.notebook.tabVSCD.vscd_frequency_min.GetValue())

            # synthetizer_LO_frequency_max_unit = unit.return_unit(self.notebook.tabLO.synthetizer_frequency_max_unit.GetValue())
            # if check_value_not_none(synthetizer_LO_frequency_max_unit, "Maximum LO Frequency Unit") == 0:
            #    return None

            vscd_frequency_max = self.notebook.tabVSCD.vscd_frequency_max.GetValue()
            if check_value_min_max(vscd_frequency_max, "VSCD Frequency", minimum=0) == 0:
                return None
            else:
                vscd_frequency_max = eval(self.notebook.tabVSCD.vscd_frequency_max.GetValue())

            # synthetizer_LO_frequency_step_unit = unit.return_unit(self.notebook.tabLO.synthetizer_frequency_step_unit.GetValue())
            # if check_value_not_none(synthetizer_LO_frequency_step_unit, "LO Step Frequency Unit") == 0:
            #    return None

            vscd_frequency_unit = unit.return_unit(self.notebook.tabVSCD.vscd_frequency_unit.GetValue())
            if check_value_not_none(vscd_frequency_unit, "VSCD Frequency Unit") == 0:
                return None

            vscd_frequency_step = self.notebook.tabVSCD.vscd_frequency_step.GetValue()
            if check_value_min_max(vscd_frequency_step, "VSCD Step Frequency", minimum=0) == 0:
                return None
            else:
                vscd_frequency_step = eval(self.notebook.tabVSCD.vscd_frequency_step.GetValue())

            try:
                vscd_level_min = eval(self.notebook.tabVSCD.vscd_level_min.GetValue())
            except:
                vscd_level_min = 0

            try:
                vscd_level_max = eval(self.notebook.tabVSCD.vscd_level_max.GetValue())
            except:
                vscd_level_max = 0

            vscd_level_step = self.notebook.tabVSCD.vscd_level_step.GetValue()
            if check_value_min_max(vscd_level_step, "VSCD Level Step", minimum=0) == 0:
                return None
            else:
                vscd_level_step = eval(self.notebook.tabVSCD.vscd_level_step.GetValue())

            vscd_frequency = Frequency_Range(vscd_frequency_min, vscd_frequency_max,
                                                       vscd_frequency_step, vscd_frequency_unit)
            vscd_frequency.to_base()
            vscd_level = Generic_Range(vscd_level_min, vscd_level_max,
                                                 vscd_level_step)
        else:
            vscd_frequency = Frequency_Range(0, 0, 1, unit.Hz)
            vscd_frequency.to_base()
            vscd_level = Generic_Range(0, 0, 1)


        spectrum_analyzer_IP = self.notebook.tabFSV.instrument_txt_IP.GetValue()
        if check_value_is_IP(spectrum_analyzer_IP, "LO Synthetizer IP") == 0:
            return None

        spectrum_analyzer_Port = self.notebook.tabFSV.instrument_txt_Port.GetValue()
        if check_value_min_max(spectrum_analyzer_Port, "LO Synthetizer Port", minimum=0) == 0:
            return None

        spectrum_analyzer_Timeout = self.notebook.tabFSV.instrument_txt_Timeout.GetValue()
        if check_value_min_max(spectrum_analyzer_Timeout, "LO Synthetizer Timeout", minimum=0) == 0:
            return None

        spectrum_analyzer_instrType = self.notebook.tabFSV.combobox_instrtype.GetValue()

        spectrum_analyzer_state = self.notebook.tabFSV.instrument_enable_status.GetValue()

        if spectrum_analyzer_state:
            spectrum_analyzer_sweep_points = self.notebook.tabFSV.spectrum_analyzer_sweep_points.GetValue()
            if check_value_min_max(spectrum_analyzer_sweep_points, "Sweep points", minimum=0) == 0:
                return None
            else:
                spectrum_analyzer_sweep_points = eval(self.notebook.tabFSV.spectrum_analyzer_sweep_points.GetValue())

            spectrum_analyzer_resolution_bandwidth = self.notebook.tabFSV.spectrum_analyzer_resolution_bandwidth.GetValue()
            if check_value_min_max(spectrum_analyzer_resolution_bandwidth, "Resolution Bandwidth", minimum=0) == 0:
                return None
            else:
                spectrum_analyzer_resolution_bandwidth = eval(
                    self.notebook.tabFSV.spectrum_analyzer_resolution_bandwidth.GetValue())

            spectrum_analyzer_resolution_bandwidth_unit = unit.return_unit(
                self.notebook.tabFSV.spectrum_analyzer_resolution_bandwidth_unit.GetValue())
            if check_value_not_none(spectrum_analyzer_resolution_bandwidth_unit, "Resolution Bandwidth Unit") == 0:
                return None

            spectrum_analyzer_video_bandwidth = self.notebook.tabFSV.spectrum_analyzer_video_bandwidth.GetValue()
            if check_value_min_max(spectrum_analyzer_video_bandwidth, "Video Bandwidth", minimum=0) == 0:
                return None
            else:
                spectrum_analyzer_video_bandwidth = eval(
                    self.notebook.tabFSV.spectrum_analyzer_video_bandwidth.GetValue())

            spectrum_analyzer_video_bandwidth_unit = unit.return_unit(
                self.notebook.tabFSV.spectrum_analyzer_video_bandwidth_unit.GetValue())
            if check_value_not_none(spectrum_analyzer_video_bandwidth_unit, "Video Bandwidth Unit") == 0:
                return None

            spectrum_analyzer_frequency_span = self.notebook.tabFSV.spectrum_analyzer_frequency_span.GetValue()
            if check_value_min_max(spectrum_analyzer_frequency_span, "Frequency Span", minimum=0) == 0:
                return None
            else:
                spectrum_analyzer_frequency_span = eval(
                    self.notebook.tabFSV.spectrum_analyzer_frequency_span.GetValue())

            spectrum_analyzer_frequency_span_unit = unit.return_unit(
                self.notebook.tabFSV.spectrum_analyzer_frequency_span_unit.GetValue())
            if check_value_not_none(spectrum_analyzer_frequency_span_unit, "Frequency Span Unit") == 0:
                return None

            ##spectrum_analyzer_harmonic_number = spectrum_analyzer_harmonic_number
            # spectrum_analyzer_attenuation = self.notebook.tabFSV.spectrum_analyzer_attenuation.GetValue()
            # if check_value_not_none(spectrum_analyzer_attenuation, "Attenuation") == 0:
            #    return None

            gainAmplifier = self.notebook.tabFSV.gainAmplifier.GetValue()  # dB
            if check_value_not_none(gainAmplifier, "Gain Amplifier") == 0:
                return None

            spectrum_analyzer_IF_atten_enable = self.notebook.tabFSV.spectrum_analyzer_IF_atten_enable.GetValue()
            spectrum_analyzer_IF_atten = self.notebook.tabFSV.spectrum_analyzer_IF_atten.GetValue()
            if check_value_not_none(spectrum_analyzer_IF_atten, "Attenuation") == 0:
                return None

            spectrum_analyzer_IF_relative_level = self.notebook.tabFSV.spectrum_analyzer_IF_relative_level.GetValue()
            if check_value_not_none(spectrum_analyzer_IF_relative_level, "Relative Power Level") == 0:
                return None

            spectrum_analyzer_IF_relative_level_enable = self.notebook.tabFSV.spectrum_analyzer_IF_relative_level_enable.GetValue()

            threshold_power = self.notebook.tabFSV.threshold_power.GetValue()  # dB
            if check_value_not_none(threshold_power, "Threshold Power Level") == 0:
                return None
            else:
                threshold_power = eval(self.notebook.tabFSV.threshold_power.GetValue())

            spectrum_analyzer_frequency_marker_unit = unit.return_unit(
                self.notebook.tabFSV.spectrum_analyzer_frequency_marker_unit.GetValue())
            # to check
            if check_value_not_none(spectrum_analyzer_frequency_marker_unit, "Marker Frequency Unit") == 0:
                return None

            FSV_delay = self.notebook.tabFSV.FSV_delay.GetValue()
            if check_value_min_max(FSV_delay, "FSV measure delay", minimum=0) == 0:
                return None
            else:
                FSV_delay = eval(self.notebook.tabFSV.FSV_delay.GetValue())

        m_min_RF = self.notebook.tabSpuriusSetting.m_min_RF.GetValue()
        m_max_RF = self.notebook.tabSpuriusSetting.m_max_RF.GetValue()
        m_step_RF = self.notebook.tabSpuriusSetting.m_step_RF.GetValue()
        n_min_LO = self.notebook.tabSpuriusSetting.n_min_LO.GetValue()
        n_max_LO = self.notebook.tabSpuriusSetting.n_max_LO.GetValue()
        n_step_LO = self.notebook.tabSpuriusSetting.n_step_LO.GetValue()

        IF_low = self.notebook.tabSpuriusSetting.IF_low.GetValue()
        if check_value_min_max(IF_low, "Low Frequency", minimum=0) == 0:
            return None
        else:
            IF_low = eval(self.notebook.tabSpuriusSetting.IF_low.GetValue())

        IF_low_unit = unit.return_unit(self.notebook.tabSpuriusSetting.IF_low_unit.GetValue())
        if check_value_not_none(IF_low_unit, "Low Frequency Unit") == 0:
            return None

        IF_high = self.notebook.tabSpuriusSetting.IF_high.GetValue()
        if check_value_min_max(IF_high, "High Frequency", minimum=0) == 0:
            return None
        else:
            IF_high = eval(self.notebook.tabSpuriusSetting.IF_high.GetValue())

        IF_high_unit = unit.return_unit(self.notebook.tabSpuriusSetting.IF_high_unit.GetValue())
        if check_value_not_none(IF_high_unit, "High Frequency Unit") == 0:
            return None

        spurius_IF_unit = unit.return_unit(self.notebook.tabSpuriusSetting.spurius_IF_unit.GetValue())
        if check_value_not_none(spurius_IF_unit, "Spurius IF Unit") == 0:
            return None

        calibration_file_LO = self.notebook.tabSpuriusSetting.calibration_file_LO.GetValue()
        calibration_file_LO_enable = self.notebook.tabSpuriusSetting.calibration_file_LO_enable.GetValue()
        if calibration_file_LO_enable:
            if check_value_is_valid_file(calibration_file_LO, "LO Calibration file") == 0:
                return None

        calibration_file_RF = self.notebook.tabSpuriusSetting.calibration_file_RF.GetValue()
        calibration_file_RF_enable = self.notebook.tabSpuriusSetting.calibration_file_RF_enable.GetValue()
        if calibration_file_RF_enable:
            if check_value_is_valid_file(calibration_file_RF, "RF Calibration file") == 0:
                return None

        calibration_file_IF = self.notebook.tabSpuriusSetting.calibration_file_IF.GetValue()
        calibration_file_IF_enable = self.notebook.tabSpuriusSetting.calibration_file_IF_enable.GetValue()
        if calibration_file_IF_enable:
            if check_value_is_valid_file(calibration_file_IF, "IF Calibration file") == 0:
                return None

        result_file_name = self.notebook.tabSpuriusSetting.result_file_name.GetValue()

        try:
            SMB_LO = create_instrument(synthetizer_LO_IP, synthetizer_LO_Port, eval(synthetizer_LO_Timeout),
                                       synthetizer_LO_instrType, TEST_MODE=self.runmodeitem.IsChecked(),
                                       enable_state=synthetizer_LO_state)
        except:
            dlg = wx.MessageDialog(None, "LO synthetizer comunication error", 'Error LO synthetizer',
                                   wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            return 0

        try:
            SMB_RF = create_instrument(synthetizer_RF_IP, synthetizer_RF_Port, eval(synthetizer_RF_Timeout),
                                       synthetizer_RF_instrType, TEST_MODE=self.runmodeitem.IsChecked(),
                                       enable_state=synthetizer_RF_state)
        except:
            dlg = wx.MessageDialog(None, "RF synthetizer comunication error", 'Error RF synthetizer',
                                   wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            return 0

        try:
            VSCD = create_instrument(vscd_IP, vscd_Port, eval(vscd_Timeout),
                                       vscd_instrType, TEST_MODE=self.runmodeitem.IsChecked(),
                                       enable_state=vscd_state)
        except:
            dlg = wx.MessageDialog(None, "Downconverter comunication error", 'Error Downconverter',
                                   wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            return 0

        try:
            FSV = create_instrument(spectrum_analyzer_IP, spectrum_analyzer_Port, eval(spectrum_analyzer_Timeout),
                                    spectrum_analyzer_instrType, TEST_MODE=self.runmodeitem.IsChecked(),
                                    instrument_class="FSV", enable_state=spectrum_analyzer_state)
        except:
            dlg = wx.MessageDialog(None, "Spectrum analiser comunication error", 'Error Spectrum analiser',
                                   wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            return 0

        if synthetizer_LO_state:
            n_LO = Generic_Range(n_min_LO, n_max_LO, n_step_LO)
        else:
            n_LO = Generic_Range(0, 0, 1)
        if synthetizer_RF_state:
            m_RF = Generic_Range(m_min_RF, m_max_RF, m_step_RF)
        else:
            m_RF = Generic_Range(0, 0, 1)

        dialog = wx.ProgressDialog("Progress", "Time remaining", maximum=100,
                                   style=wx.PD_CAN_ABORT | wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME)

        self.savesettings(result_file_name)

        spurius_filename = measure_LNA_spurius(
            SMB_LO=SMB_LO,
            SMB_RF=SMB_RF,
            FSV=FSV,
            VSCD=VSCD,
            synthetizer_LO_state=synthetizer_LO_state,
            synthetizer_LO_frequency=synthetizer_LO_frequency,
            synthetizer_LO_level=synthetizer_LO_level,  # dBm
            synthetizer_RF_state=synthetizer_RF_state,
            synthetizer_RF_frequency=synthetizer_RF_frequency,
            synthetizer_RF_level=synthetizer_RF_level,  # dBm
            downconverter_state=vscd_state,
            downconverter_frequency=vscd_frequency,
            downconverter_level=vscd_level,  # dBm
            spectrum_analyzer_state=spectrum_analyzer_state,
            spectrum_analyzer_sweep_points=spectrum_analyzer_sweep_points,
            spectrum_analyzer_resolution_bandwidth=spectrum_analyzer_resolution_bandwidth,
            spectrum_analyzer_resolution_bandwidth_unit=spectrum_analyzer_resolution_bandwidth_unit,
            spectrum_analyzer_video_bandwidth=spectrum_analyzer_video_bandwidth,
            spectrum_analyzer_video_bandwidth_unit=spectrum_analyzer_video_bandwidth_unit,
            spectrum_analyzer_frequency_span=spectrum_analyzer_frequency_span,
            spectrum_analyzer_frequency_span_unit=spectrum_analyzer_frequency_span_unit,
            # spectrum_analyzer_attenuation = spectrum_analyzer_attenuation,
            gainAmplifier=gainAmplifier,  # dB
            spectrum_analyzer_IF_atten_enable=spectrum_analyzer_IF_atten_enable,
            spectrum_analyzer_IF_atten=spectrum_analyzer_IF_atten,
            spectrum_analyzer_IF_relative_level=spectrum_analyzer_IF_relative_level,
            spectrum_analyzer_IF_relative_level_enable=spectrum_analyzer_IF_relative_level_enable,
            threshold_power=threshold_power,  # dB
            spectrum_analyzer_frequency_marker_unit=spectrum_analyzer_frequency_marker_unit,
            FSV_delay=FSV_delay,
            m_RF=m_RF,
            n_LO=n_LO,
            IF_low=IF_low,
            IF_low_unit=IF_low_unit,
            IF_high=IF_high,
            IF_high_unit=IF_high_unit,
            spurius_IF_unit=spurius_IF_unit,
            calibration_file_LO=calibration_file_LO,
            calibration_file_LO_enable=calibration_file_LO_enable,
            calibration_file_RF=calibration_file_RF,
            calibration_file_RF_enable=calibration_file_RF_enable,
            calibration_file_IF=calibration_file_IF,
            calibration_file_IF_enable=calibration_file_IF_enable,
            result_file_name=result_file_name,
            createprogressdialog=False)

        dialog.Destroy()

        try:
            webbrowser.open(os.path.dirname(spurius_filename))
        except:
            pass
Ejemplo n.º 7
0
    def OnStart(self, event):

        TaskFrame.OnStart(self, event)

        synthetizer_LO_state = self.notebook.tabRF.synthetizer_state.GetValue()

        synthetizer_IP = self.notebook.tabRF.instrument_txt_IP.GetValue()
        if check_value_is_IP(synthetizer_IP, "Synthetizer IP") == 0:
            return None

        synthetizer_Port = self.notebook.tabRF.instrument_txt_Port.GetValue()
        if check_value_min_max(synthetizer_Port, "Synthetizer Port",
                               minimum=0) == 0:
            return None

        synthetizer_Timeout = self.notebook.tabRF.instrument_txt_Timeout.GetValue(
        )
        if check_value_min_max(synthetizer_Timeout,
                               "Synthetizer Timeout",
                               minimum=0) == 0:
            return None

        syntetizer_instrType = self.notebook.tabRF.combobox_instrtype.GetValue(
        )

        # synthetizer_frequency_min_unit = unit.return_unit(self.notebook.tabRF.synthetizer_frequency_min_unit.GetValue())
        # if check_value_not_none(synthetizer_frequency_min_unit, "Minimum Frequency Unit") == 0:
        #    return None
        synthetizer_frequency_min = self.notebook.tabRF.synthetizer_frequency_min.GetValue(
        )
        if check_value_min_max(synthetizer_frequency_min,
                               "Minimum Frequency",
                               minimum=0) == 0:
            return None
        else:
            synthetizer_frequency_min = eval(
                self.notebook.tabRF.synthetizer_frequency_min.GetValue())
        # synthetizer_frequency_max_unit = unit.return_unit(self.notebook.tabRF.synthetizer_frequency_max_unit.GetValue())
        # if check_value_not_none(synthetizer_frequency_max_unit, "Maximum Frequency Unit") == 0:
        #    return None
        synthetizer_frequency_max = self.notebook.tabRF.synthetizer_frequency_max.GetValue(
        )
        if check_value_min_max(synthetizer_frequency_max,
                               "Maximum Frequency",
                               minimum=0) == 0:
            return None
        else:
            synthetizer_frequency_max = eval(
                self.notebook.tabRF.synthetizer_frequency_max.GetValue())
        # synthetizer_frequency_step_unit = unit.return_unit(self.notebook.tabRF.synthetizer_frequency_step_unit.GetValue())
        # if check_value_not_none(synthetizer_frequency_step_unit, "Frequency Step Unit") == 0:
        #    return None
        synthetizer_frequency_step = self.notebook.tabRF.synthetizer_frequency_step.GetValue(
        )
        if check_value_min_max(synthetizer_frequency_step,
                               "Frequency Step",
                               minimum=0) == 0:
            return None
        else:
            synthetizer_frequency_step = eval(
                self.notebook.tabRF.synthetizer_frequency_step.GetValue())
        synthetizer_frequency_unit = unit.return_unit(
            self.notebook.tabRF.synthetizer_frequency_unit.GetValue())
        if check_value_not_none(synthetizer_frequency_unit,
                                "Frequency Unit") == 0:
            return None

        try:
            synthetizer_level_min = eval(
                self.notebook.tabRF.synthetizer_level_min.GetValue())
        except:
            synthetizer_level_min = 0

        try:
            synthetizer_level_max = eval(
                self.notebook.tabRF.synthetizer_level_max.GetValue())
        except:
            synthetizer_level_max = 0

        try:
            synthetizer_level_step = eval(
                self.notebook.tabRF.synthetizer_level_step.GetValue())
        except:
            synthetizer_level_step = 0

        pm5_state = self.notebook.tabPM5.pm5_state.GetValue()

        pm5_com_port = self.notebook.tabPM5.instrument_combobox_com_port.GetValue(
        )

        pm5_Timeout = self.notebook.tabPM5.instrument_txt_timeout.GetValue()
        if check_value_min_max(pm5_Timeout, "PM5 Timeout", minimum=0) == 0:
            return None

        pm5_BaudRate = self.notebook.tabPM5.instrument_combobox_baud.GetValue()
        if check_value_min_max(pm5_BaudRate, "COM Baud Rate", minimum=0) == 0:
            return None

        pm5_misure_number = self.notebook.tabPM5.pm5_misure_number.GetValue()

        pm5_misure_delay = self.notebook.tabPM5.pm5_misure_delay.GetValue(
        )  # seconds
        if check_value_min_max(pm5_misure_delay, "Measure Delay",
                               minimum=0) == 0:
            return None
        else:
            pm5_misure_delay = eval(
                self.notebook.tabPM5.pm5_misure_delay.GetValue())

        calibration_file_LO = self.notebook.tabPM5Setting.calibration_file_LO.GetValue(
        )
        calibration_file_LO_enable = self.notebook.tabPM5Setting.calibration_file_LO_enable.GetValue(
        )
        if calibration_file_LO_enable:
            if check_value_is_valid_file(calibration_file_LO,
                                         "LO Calibration file") == 0:
                return None

        result_file_name = self.notebook.tabPM5Setting.result_file_name.GetValue(
        )

        try:
            if synthetizer_LO_state:
                SMB_LO = create_instrument(
                    synthetizer_IP,
                    synthetizer_Port,
                    eval(synthetizer_Timeout),
                    syntetizer_instrType,
                    TEST_MODE=self.runmodeitem.IsChecked())
            else:
                SMB_LO = create_instrument(synthetizer_IP,
                                           synthetizer_Port,
                                           eval(synthetizer_Timeout),
                                           syntetizer_instrType,
                                           TEST_MODE=True)
        except:
            dlg = wx.MessageDialog(None, "LO synthetizer comunication error",
                                   'Error LO synthetizer',
                                   wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            return 0

        try:
            if pm5_state:
                PM5 = create_USB_instrument(
                    pm5_com_port,
                    pm5_Timeout,
                    pm5_BaudRate,
                    TEST_MODE=self.runmodeitem.IsChecked(),
                    instrument_class="PM5")
            else:
                PM5 = create_USB_instrument(pm5_com_port,
                                            pm5_Timeout,
                                            pm5_BaudRate,
                                            TEST_MODE=True,
                                            instrument_class="PM5")
        except:
            dlg = wx.MessageDialog(None, "PM5 comunication error",
                                   'Error mm-submm power meter',
                                   wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            return 0

            # dlg.ShowModal()
            # return 0

        synthetizer_frequency = Frequency_Range(synthetizer_frequency_min,
                                                synthetizer_frequency_max,
                                                synthetizer_frequency_step,
                                                synthetizer_frequency_unit)
        synthetizer_frequency.to_base()
        synthetizer_level = Generic_Range(synthetizer_level_min,
                                          synthetizer_level_max,
                                          synthetizer_level_step)

        self.savesettings(result_file_name)

        dialog = wx.ProgressDialog("Progress",
                                   "Time remaining",
                                   maximum=100,
                                   style=wx.PD_CAN_ABORT | wx.PD_ELAPSED_TIME
                                   | wx.PD_REMAINING_TIME)
        # dialog =None
        measure_100GHz_cal(SMB_LO,
                           PM5,
                           synthetizer_frequency,
                           synthetizer_level,
                           calibration_file_LO,
                           pm5_misure_number,
                           pm5_misure_delay,
                           result_file_name,
                           createprogressdialog=dialog)

        dialog.Destroy()