示例#1
0
文件: Spuriusgui.py 项目: asaba/RFLab
    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
示例#2
0
    def OnStart(self, event):

        TaskFrame.OnStart(self, event)

        # Check all values
        TSC_IP = self.notebook.tabTSC.instrument_txt_IP.GetValue()
        if check_value_is_IP(TSC_IP, "TSC IP") == 0:
            return None

        TSC_Port = self.notebook.tabTSC.instrument_txt_Port.GetValue()
        if check_value_min_max(TSC_Port, "TSC Port", minimum=0) == 0:
            return None

        TSC_Timeout = self.notebook.tabTSC.instrument_txt_Timeout.GetValue()
        if check_value_min_max(TSC_Timeout, "TSC Timeout", minimum=0) == 0:
            return None

        TSC_instrType = self.notebook.tabTSC.combobox_instrtype.GetValue()

        TSC_collecting_delay = self.notebook.tabTSC.TSC_collecting_delay.GetValue(
        )
        if check_value_min_max(TSC_collecting_delay,
                               "Collecting time",
                               minimum=0) == 0:
            return None
        else:
            TSC_collecting_delay = eval(
                self.notebook.tabTSC.TSC_collecting_delay.GetValue())

        TSC_plot_adev = self.notebook.tabTSC.TSC_plot_adev.GetValue()

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

        try:
            TSC = create_instrument(TSC_IP,
                                    TSC_Port,
                                    eval(TSC_Timeout),
                                    TSC_instrType,
                                    TEST_MODE=self.runmodeitem.IsChecked(),
                                    instrument_class="TSC")
        except:
            dlg = wx.MessageDialog(None, "TSC comunication error", 'Error TSC',
                                   wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            return 0

        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)

        TSC_measure(TSC,
                    TSC_collecting_delay,
                    result_file_name,
                    TSC_plot_adev,
                    createprogressdialog=dialog)

        dialog.Destroy()
示例#3
0
    def OnPlotSpectrum(self, event):
        # Function to plot the spectrum for actual parameters
        self.testmode = False
        try:
            if self.Parent.GrandParent.runmodeitem.IsChecked():
                dlg = wx.MessageDialog(
                    None, 'Test mode. Instruments comunication disabled',
                    "Test mode", wx.OK | wx.ICON_ERROR)
                dlg.ShowModal()
                self.testmode = True
        except:
            pass

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

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

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

        spectrum_analyzer_instrType = self.combobox_instrtype.GetValue()

        spectrum_analyzer_state = self.instrument_enable_status.GetValue()

        if spectrum_analyzer_state:
            spectrum_analyzer_sweep_points = self.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.spectrum_analyzer_sweep_points.GetValue())

            spectrum_analyzer_resolution_bandwidth = self.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.spectrum_analyzer_resolution_bandwidth.GetValue())

            spectrum_analyzer_resolution_bandwidth_unit = unit.return_unit(
                self.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.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.spectrum_analyzer_video_bandwidth.GetValue())

            spectrum_analyzer_video_bandwidth_unit = unit.return_unit(
                self.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.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.spectrum_analyzer_frequency_span.GetValue())

            spectrum_analyzer_frequency_span_unit = unit.return_unit(
                self.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.gainAmplifier.GetValue()  # dB
            if check_value_not_none(gainAmplifier, "Gain Amplifier") == 0:
                return None

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

            spectrum_analyzer_IF_relative_level = self.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.spectrum_analyzer_IF_relative_level_enable.GetValue(
            )

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

            spectrum_analyzer_frequency_marker_unit = unit.return_unit(
                self.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.FSV_delay.GetValue()
            if check_value_min_max(FSV_delay, "FSV measure delay",
                                   minimum=0) == 0:
                return None
            else:
                FSV_delay = eval(self.FSV_delay.GetValue())

            spectrum_analyzer_central_frequency = self.spectrum_analyzer_central_frequency.GetValue(
            )
            if check_value_min_max(spectrum_analyzer_central_frequency,
                                   "Central Frequency",
                                   minimum=0) == 0:
                return None
            else:
                spectrum_analyzer_video_bandwidth = eval(
                    self.spectrum_analyzer_video_bandwidth.GetValue())

            spectrum_analyzer_central_frequency_unit = unit.return_unit(
                self.spectrum_analyzer_central_frequency_unit.GetValue())
            # to check
            if check_value_not_none(spectrum_analyzer_central_frequency_unit,
                                    "Central Frequency Unit") == 0:
                return None

        try:
            FSV = create_instrument(spectrum_analyzer_IP,
                                    spectrum_analyzer_Port,
                                    eval(spectrum_analyzer_Timeout),
                                    spectrum_analyzer_instrType,
                                    TEST_MODE=self.testmode,
                                    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

        FSV_reset_setup(FSV, spectrum_analyzer_sweep_points,
                        spectrum_analyzer_resolution_bandwidth,
                        spectrum_analyzer_resolution_bandwidth_unit,
                        spectrum_analyzer_video_bandwidth,
                        spectrum_analyzer_video_bandwidth_unit,
                        spectrum_analyzer_frequency_span,
                        spectrum_analyzer_frequency_span_unit,
                        spectrum_analyzer_IF_atten_enable,
                        spectrum_analyzer_IF_atten,
                        spectrum_analyzer_IF_relative_level_enable,
                        spectrum_analyzer_IF_relative_level)

        table_value = build_table_value_from_x_y(
            *readFSV_sweep(FSV, FSV_delay, spectrum_analyzer_central_frequency,
                           spectrum_analyzer_central_frequency_unit))

        x_max, x_min, y_max, y_min, z_max, z_min = return_max_min_from_data_table_row(
            table_value, 0, 2, None)

        axis_x_legend = "CF {central_frequency} {central_frequency_unit} -  - Span {span} {span_unit}".format(
            central_frequency=str(spectrum_analyzer_central_frequency),
            central_frequency_unit=unit.return_unit_str(
                spectrum_analyzer_central_frequency_unit),
            span=str(spectrum_analyzer_frequency_span),
            span_unit=unit.return_unit_str(
                spectrum_analyzer_frequency_span_unit))

        axis_y_legend = "Ref.Level {ref_level} dBm  - Attenuation {attenuation} dB".format(
            ref_level=str(spectrum_analyzer_IF_relative_level)
            if spectrum_analyzer_IF_relative_level_enable else "0",
            attenuation=str(spectrum_analyzer_IF_atten)
            if spectrum_analyzer_IF_atten_enable else "0",
        )
        graph_x = Graph_Axis_Range(x_min, x_max, (x_max - x_min) / 10, unit.Hz,
                                   axis_x_legend)
        graph_y = Graph_Axis_Range(y_min, y_max, (y_max - y_min) / 10, unit.dB,
                                   axis_y_legend)
        graph_z = Graph_Axis_Range(0, 0, 1, unit.Hz)

        fig = plt.figure()

        plot_XY_Single(fig1,
                       table_value,
                       graph_group_index=[1],
                       x_index=0,
                       y_index=2,
                       z_index=None,
                       legend_index=[(0, -1, "", 0)],
                       legend_title=None,
                       graph_title="SA Sweep",
                       graph_type="GG",
                       graph_x=graph_x,
                       graph_y=graph_y,
                       graph_z=graph_z,
                       save=False)
示例#4
0
    def OnStart(self, event):
        TaskFrame.OnStart(self, event)

        PM_IP = self.notebook.tabPowerMeter.instrument_txt_IP.GetValue()
        if check_value_is_IP(PM_IP, "PM IP") == 0:
            return None

        PM_Port = self.notebook.tabPowerMeter.instrument_txt_Port.GetValue()
        if check_value_min_max(PM_Port, "PM Port", minimum=0) == 0:
            return None

        PM_Timeout = self.notebook.tabPowerMeter.instrument_txt_Timeout.GetValue(
        )
        if check_value_min_max(PM_Timeout, "PM Timeout", minimum=0) == 0:
            return None

        PM_instrType = self.notebook.tabPowerMeter.combobox_instrtype.GetValue(
        )

        power_meter_misure_number = self.notebook.tabPowerMeter.power_meter_misure_number.GetValue(
        )
        if power_meter_misure_number > 0:
            pm_misure_number = power_meter_misure_number
        else:
            dlg = wx.MessageDialog(None, "PM number of measures is invalid",
                                   'Error PM', wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            return 0

        power_meter_misure_delay = self.notebook.tabPowerMeter.power_meter_misure_delay.GetValue(
        )
        if check_value_min_max(power_meter_misure_delay,
                               "Measures delay",
                               minimum=0) == 0:
            return None
        else:
            pm_misure_delay = eval(self.notebook.tabPowerMeter.
                                   power_meter_misure_delay.GetValue())

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

        try:
            PM = create_instrument(PM_IP,
                                   PM_Port,
                                   eval(PM_Timeout),
                                   PM_instrType,
                                   TEST_MODE=self.runmodeitem.IsChecked())
        except:
            dlg = wx.MessageDialog(None, "PM comunication error", 'Error PM',
                                   wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            return 0

        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
        continous_measure_PM(PM,
                             pm_misure_number,
                             pm_misure_delay,
                             result_file_name,
                             createprogressdialog=dialog)

        dialog.Destroy()
示例#5
0
    def OnStart(self, event):

        TaskFrame.OnStart(self, event)

        create_dummy_cable = self.notebook.tabCalCableSetting.create_dummycable_cb.GetValue(
        )

        if create_dummy_cable:
            info_message("Dummy cable creation mode. \n No instrument used.",
                         "Dummy Cable Mode")

        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(
        )

        syntetizer_enable_state = self.notebook.tabRF.instrument_enable_status.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_fixed = eval(
                self.notebook.tabRF.synthetizer_level_fixed.GetValue())
        except:
            synthetizer_level_fixed = 0

        power_meter_IP = self.notebook.tabPowerMeter.instrument_txt_IP.GetValue(
        )
        if check_value_is_IP(power_meter_IP, "Power meter IP") == 0:
            return None

        power_meter_Port = self.notebook.tabPowerMeter.instrument_txt_Port.GetValue(
        )
        if check_value_min_max(power_meter_Port, "Power meter Port",
                               minimum=0) == 0:
            return None

        power_meter_Timeout = self.notebook.tabPowerMeter.instrument_txt_Timeout.GetValue(
        )
        if check_value_min_max(power_meter_Timeout,
                               "Power meter Timeout",
                               minimum=0) == 0:
            return None

        power_meter_instrType = self.notebook.tabPowerMeter.combobox_instrtype.GetValue(
        )

        power_meter_enable_state = self.notebook.tabPowerMeter.instrument_enable_status.GetValue(
        )

        power_meter_make_zero = self.notebook.tabPowerMeter.power_meter_make_zero.GetValue(
        )
        power_meter_make_zero_delay = self.notebook.tabPowerMeter.power_meter_misure_delay.GetValue(
        )
        if check_value_min_max(power_meter_make_zero_delay,
                               "Make Zero Delay",
                               minimum=0) == 0:
            return None
        else:
            power_meter_make_zero_delay = eval(
                self.notebook.tabPowerMeter.power_meter_misure_delay.GetValue(
                ))

        power_meter_misure_number = self.notebook.tabPowerMeter.power_meter_misure_number.GetValue(
        )

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

        SAB_IP = self.notebook.tabSAB.instrument_txt_IP.GetValue()
        if check_value_is_IP(SAB_IP, "SwitchAttBox IP") == 0:
            return None

        SAB_Port = self.notebook.tabSAB.instrument_txt_Port.GetValue()
        if check_value_min_max(SAB_Port, "SwitchAttBox Port", minimum=0) == 0:
            return None

        SAB_Timeout = self.notebook.tabSAB.instrument_txt_Timeout.GetValue()
        if check_value_min_max(SAB_Timeout, "SwitchAttBox Timeout",
                               minimum=0) == 0:
            return None

        SAB_enable_state = self.notebook.tabSAB.instrument_enable_status.GetValue(
        )

        SAB_instrType = self.notebook.tabSAB.combobox_instrtype.GetValue()

        SAB_switch01_delay = self.notebook.tabSAB.SAB_switch01_delay.GetValue()
        if check_value_min_max(SAB_switch01_delay, "Switch 1 Delay",
                               minimum=0) == 0:
            return None
        else:
            SAB_switch01_delay = eval(
                self.notebook.tabSAB.SAB_switch01_delay.GetValue())

        SAB_switch02_delay = self.notebook.tabSAB.SAB_switch02_delay.GetValue()
        if check_value_min_max(SAB_switch02_delay, "Switch 2 Delay",
                               minimum=0) == 0:
            return None
        else:
            SAB_switch02_delay = eval(
                self.notebook.tabSAB.SAB_switch02_delay.GetValue())
        result_file_name = self.notebook.tabCalCableSetting.result_file_name.GetValue(
        )
        dummy_cable_power_level = self.notebook.tabCalCableSetting.output_level.GetValue(
        )

        if create_dummy_cable:
            if check_value_not_none(dummy_cable_power_level,
                                    "Power Level (Dummy Cable)") == 0:
                return None

        try:
            SMB_RF = create_instrument(synthetizer_IP,
                                       synthetizer_Port,
                                       eval(synthetizer_Timeout),
                                       syntetizer_instrType,
                                       TEST_MODE=self.runmodeitem.IsChecked(),
                                       enable_state=syntetizer_enable_state
                                       and not create_dummy_cable)
        except:
            dlg = wx.MessageDialog(None, "Synthetizer comunication error",
                                   'Error Synthetizer', wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            return 0

        try:
            NRP2 = create_instrument(power_meter_IP,
                                     power_meter_Port,
                                     eval(power_meter_Timeout),
                                     power_meter_instrType,
                                     TEST_MODE=self.runmodeitem.IsChecked(),
                                     instrument_class="NRP2",
                                     enable_state=power_meter_enable_state
                                     and not create_dummy_cable)
        except:
            dlg = wx.MessageDialog(None, "Power meter comunication error",
                                   'Error Power meter', wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            return 0

        try:
            SAB = create_instrument(SAB_IP,
                                    SAB_Port,
                                    eval(SAB_Timeout),
                                    SAB_instrType,
                                    TEST_MODE=self.runmodeitem.IsChecked(),
                                    instrument_class="SAB",
                                    enable_state=SAB_enable_state
                                    and not create_dummy_cable)
        except:
            dlg = wx.MessageDialog(None, "SwitchAttBox comunication error",
                                   'Error SwitchAttBox', wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            return 0

        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)

        synthetizer_frequency = Frequency_Range(synthetizer_frequency_min,
                                                synthetizer_frequency_max,
                                                synthetizer_frequency_step,
                                                synthetizer_frequency_unit)
        synthetizer_frequency.to_base()

        calibration_file_result = measure_calibration_cable(
            SMB_RF,
            NRP2,
            SAB,
            synthetizer_frequency,
            synthetizer_level_fixed,
            power_meter_make_zero,
            power_meter_make_zero_delay,
            power_meter_misure_number,
            power_meter_misure_delay,
            SAB_switch01_delay,
            SAB_switch02_delay,
            result_file_name,
            dummy_cable_power_level,
            create_dummy_cable,
            createprogressdialog=dialog)

        dialog.Destroy()

        try:
            webbrowser.open(os.path.dirname(calibration_file_result))
        except:
            pass
示例#6
0
    def OnStart(self, event):

        TaskFrame.OnStart(self, event)

        create_dummy_cable = self.notebook.tabCalCableSetting.create_dummycable_cb.GetValue()

        if create_dummy_cable:
            info_message("Dummy cable creation mode. \n No instrument used.", "Dummy Cable Mode")

        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()

        syntetizer_enable_state = self.notebook.tabRF.instrument_enable_status.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_fixed = eval(self.notebook.tabRF.synthetizer_level_fixed.GetValue())
        except:
            synthetizer_level_fixed = 0

        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

            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())

        result_file_name = self.notebook.tabCalCableSetting.result_file_name.GetValue()
        dummy_cable_power_level = self.notebook.tabCalCableSetting.output_level.GetValue()

        if create_dummy_cable:
            if check_value_not_none(dummy_cable_power_level, "Power Level (Dummy Cable)") == 0:
                return None

        try:
            SMB_RF = create_instrument(synthetizer_IP, synthetizer_Port, eval(synthetizer_Timeout),
                                       syntetizer_instrType, TEST_MODE=self.runmodeitem.IsChecked(),
                                       enable_state=syntetizer_enable_state and not create_dummy_cable)
        except:
            dlg = wx.MessageDialog(None, "Synthetizer comunication error", 'Error Synthetizer', 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

        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)

        synthetizer_frequency = Frequency_Range(synthetizer_frequency_min, synthetizer_frequency_max,
                                                synthetizer_frequency_step, synthetizer_frequency_unit)
        synthetizer_frequency.to_base()

        calibration_file_result = measure_calibration_cable(SMB_RF,
                                                            FSV,
                                                            synthetizer_frequency,
                                                            synthetizer_level_fixed,
                                                            spectrum_analyzer_state,
                                                            spectrum_analyzer_sweep_points,
                                                            spectrum_analyzer_resolution_bandwidth,
                                                            spectrum_analyzer_resolution_bandwidth_unit,
                                                            spectrum_analyzer_video_bandwidth,
                                                            spectrum_analyzer_video_bandwidth_unit,
                                                            spectrum_analyzer_frequency_span,
                                                            spectrum_analyzer_frequency_span_unit,
                                                            # spectrum_analyzer_attenuation,
                                                            gainAmplifier,
                                                            spectrum_analyzer_IF_atten_enable,
                                                            spectrum_analyzer_IF_atten,
                                                            spectrum_analyzer_IF_relative_level,
                                                            spectrum_analyzer_IF_relative_level_enable,
                                                            threshold_power,
                                                            spectrum_analyzer_frequency_marker_unit,
                                                            FSV_delay,
                                                            result_file_name,
                                                            dummy_cable_power_level,
                                                            create_dummy_cable,
                                                            createprogressdialog=dialog)

        dialog.Destroy()

        try:
            webbrowser.open(os.path.dirname(calibration_file_result))
        except:
            pass
示例#7
0
文件: PM5gui.py 项目: asaba/RFLab
    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()