示例#1
0
 def fieldomni(self, freq, fieldintensity, degreestep=5, poweram1=None, transfer=False):
     sg_output_limit = -5  # unit is dBm set the signal generator output limit
     omnifield = []
     iteration = 5
     degree = 0
     tkinter.messagebox.showinfo(title="提示", message="将要进行频率%f场强%f的测试\n" % (freq, fieldintensity))
     ETSProbe.__init__(self)
     Zeta.__init__(self)
     times = 360 / degreestep
     iteration += times
     if transfer is False:
         field = cal_field(freq, fieldintensity)
         powertarget = field[0]
     else:
         if poweram1 is not None:
             powertarget = poweram1
         else:
             return "wrong input power target"
     frequency = freq * 1000000000
     powersignal = -30
     self.SGPowerSet(powersignal)
     self.SGCWFrec(frequency)
     self.PMSetFreq(frequency)
     self.PABand(frequency)
     self.SGPowerOut("ON")
     self.PAPowerOut("ON")
     time.sleep(2)
     for i in range(5):
         time.sleep(2)
         pmpower = self.PMFetch()
         print("当前第%d循环的功率计读数为%f" % (i + 1, pmpower))
         powerdiff = powertarget - pmpower
         powersignal += powerdiff
         if self.SGInRange(powersignal) and powersignal < sg_output_limit:
             self.SGPowerSet(powersignal)
         else:
             self.SGPowerOut("OFF")
             self.PAPowerOut("OFF")
             return "Error input signal generator power"
     for i in range(times):
         time.sleep(2)
         pmpower = self.PMFetch()
         print("当前第%d循环的功率计读数为%f" % (i + 1, pmpower))
         powerdiff = powertarget - pmpower
         powersignal += powerdiff
         self.SGPowerSet(powersignal)
         if self.ProbeStatus() == 0 and degree == 0:
             omnifield.append([])
             omnifield[i].append(degree)
             omnifield[i].append(self.ProbeField()[3])
             degree += 5
         else:
             omnifield.append([])
             omnifield[i].append(degree)
             self.ZetaRoll(degreestep)
             omnifield[i].append(self.ProbeField()[3])
             i += 1
             degree += 5
     return omnifield
 def FieldProb(self, freq, fieldintensity, transfer=False):
     """Produce the fieldintensity of specified frequency
     :param transfer:
     :param fieldintensity:
     :param freq:
     """
     global powersg
     sg_output_limit = -5  # unit is dBm set the signal generator output limit
     tkinter.messagebox.showinfo(title='提示', message='请连接好电场探头\n')
     field = cal_field(freq, fieldintensity)
     print(field)
     if transfer:
         self.db.BasicCursor.execute("SELECT PowerCal FROM FieldTransfer WHERE Frequency=%f AND Field=%f"
                                 % (freq, fieldintensity))
         powertarget = self.db.BasicCursor.fetchall()[0][0]
         if powertarget == 0:
             tkinter.messagebox.showinfo(title='提示', message='输入场强无法传递\n')
             return
     else:
         powertarget = field[0]
     # change cable module to be updated #
     # angel = self.ct.CTReadAngel()
     # antennachange = ['ETS3160-0316001', 'ETS3160-0316002', 'ETS3160-0316003']
     # if antenna not in antennachange and angel != 90:
     #     self.ct.CTRoll(180)
     tkinter.messagebox.showinfo(title='提示', message="请确定天线更换完毕并且射频线连接正确")
     if transfer:
         self.ct.CTRoll(90)
     else:
         antenna = field[2]
         tkinter.messagebox.showinfo(title='提示', message="请连接%s天线进行测试" % antenna)
         self.ct.CTAntennaRoll(antenna)
     sg_initial = -30
     self.sg.SGPowerSet(sg_initial)  # set the initial power unit dBm
     # frequency set
     frequency = freq * 1e9
     self.sg.SGCWFrec(frequency)
     self.pm.PMSetFreq(frequency)
     self.pa.PAPowerOut('OFF')
     time.sleep(5)
     self.pa.PABand(frequency)
     self.sg.SGPowerOut('On')
     self.pa.PAPowerOut('ON')
     time.sleep(5)
     for i in range(0, 4):  # iterate the power output
         time.sleep(2)  # delay 1 second
         if i == 0:
             powercoup = self.pm.PMFetch()
             print('当前第%d循环的功率计读数为%f' % (i + 1, powercoup))
             powerdiff = powertarget - powercoup
             powersg = sg_initial + powerdiff
             if self.sg.SGInRange(powersg) and powersg < sg_output_limit:
                 self.sg.SGPowerSet(powersg)
             else:
                 tkinter.messagebox.showinfo(title='Alert', message="Error input signal generator power")
                 return "Error input signal generator power"
         else:
             powercoup = self.pm.PMFetch()
             print('当前第%d循环的功率计读数为%f' % (i + 1, powercoup))
             powerdiff = powertarget - powercoup
             powersg += powerdiff
             if self.sg.SGInRange(powersg) and powersg < sg_output_limit:
                 self.sg.SGPowerSet(powersg)
             else:
                 tkinter.messagebox.showinfo(title='Alert', message="Error input signal generator power")
                 return "Error input signal generator power"
     if self.fieldread == 'ETS':
         try:
             self.ETS = ETSProbe()
         except:
             tkinter.messagebox.showinfo(title='提示', message="无ETS探头连接")
         # fieldreading = self.ETS.ProbeField()[3]
         fieldreading = self.ETS.ProbeField()[0]
         self.ETS.RemoveProbe()
     else:
         try:
             fieldreading = float(input('请输入电场探头示值:'))
         except:
             print('输入数据有误')
             try:
                 fieldreading = float(input('请重新输入电场探头示值:'))
             except:
                 print('输入数据有误')
                 fieldreading = float(input('请重新输入电场探头示值:'))
     try:
         self.db.Cursor.execute("INSERT INTO FieldTest (Frequency, Field, FieldResult, TestSeries) "
                            "VALUES (%f, %f, %f, %f)" % (freq, fieldintensity, fieldreading, self.db.TestSeriesNo))
         self.db.Cursor.commit()
     except:
         print('结果写入数据库失败')
     # set return value
     if fieldreading:
         return fieldreading
     else:
         return 'wrong output'
 def fieldomni(self, freq, fieldintensity, degreestep=5, transfer=False):
     if not self.db.Cursor.tables(table='FieldOmni_%sGHz_%sV' % (freq, fieldintensity)).fetchone():
         try:
             self.db.Cursor.execute("Create TABLE FieldOmni_%sGHz_%sV" % (freq, fieldintensity))
             self.db.Cursor.commit()
         except:
             pass
         try:
             self.db.Cursor.execute("alter table FieldOmni_%sGHz_%sV add Degree DOUBLE "
                                    % (freq, fieldintensity))
             self.db.Cursor.commit()
         except:
             pass
         try:
             self.db.Cursor.execute("alter table FieldOmni_%sGHz_%sV add Field DOUBLE "
                                    % (freq, fieldintensity))
             self.db.Cursor.commit()
         except:
             pass
         try:
             self.db.Cursor.execute("alter table FieldOmni_%sGHz_%sV add TestSeriesNo DOUBLE "
                                    % (freq, fieldintensity))
             self.db.Cursor.commit()
         except:
             pass
     sg_output_limit = -5  # unit is dBm set the signal generator output limit
     degree = 0
     tkinter.messagebox.showinfo(title='提示', message='将要进行频率%f场强%f的各向同性测试, 请连接好探头和电机\n'
                                 % (freq, fieldintensity))
     times = int(360 / degreestep)
     if transfer is False:
         field = cal_field(freq, fieldintensity)
         print(field)
         antenna = field[2]
         powertarget = field[0]
         self.ct.CTAntennaRoll(antenna)
     else:
         self.db.BasicCursor.execute("SELECT PowerCal FROM FieldTransfer WHERE Frequency=%f AND Field=%f"
                                 % (freq, fieldintensity))
         powertarget = self.db.BasicCursor.fetchall()[0][0]
         if powertarget == 0:
             tkinter.messagebox.showinfo(title='提示', message='输入场强无法传递\n')
             return
         self.ct.CTRoll(89)
     frequency = freq * 1e9
     powersignal = -30
     self.sg.SGPowerSet(powersignal)
     self.sg.SGCWFrec(frequency)
     self.pm.PMSetFreq(frequency)
     self.pa.PABand(frequency)
     self.sg.SGPowerOut('ON')
     self.pa.PAPowerOut('ON')
     time.sleep(5)
     for i in range(5):
         time.sleep(2)
         pmpower = self.pm.PMFetch()
         print('当前第%d循环的功率计读数为%f' % (i + 1, pmpower))
         powerdiff = powertarget - pmpower
         powersignal += powerdiff
         if self.sg.SGInRange(powersignal) and powersignal < sg_output_limit:
             self.sg.SGPowerSet(powersignal)
         else:
             self.sg.SGPowerOut('OFF')
             self.pa.PAPowerOut('OFF')
             return "Error input signal generator power"
     for i in range(times):
         pmpower = self.pm.PMFetch()
         print('当前第%d循环的功率计读数为%f' % (i + 1, pmpower))
         powerdiff = powertarget - pmpower
         powersignal += powerdiff
         self.sg.SGPowerSet(powersignal)
         time.sleep(3)
         if self.fieldread == 'ETS':
             try:
                 self.ETS = ETSProbe()
             except:
                 tkinter.messagebox.showinfo(title='提示', message="无ETS探头连接")
             fieldreading = self.ETS.ProbeField()[3]
             self.ETS.RemoveProbe()
         else:
             try:
                 fieldreading = float(input('请输入电场探头示值:'))
             except:
                 print('输入数据有误')
                 try:
                     fieldreading = float(input('请重新输入电场探头示值:'))
                 except:
                     print('输入数据有误')
                     fieldreading = float(input('请重新输入电场探头示值:'))
         if degree == 0:
             try:
                 self.db.Cursor.execute("INSERT INTO FieldOmni_%sGHz_%sV (Degree, Field, TestSeriesNo) VALUES"
                                        " (%f, %f, %d)"
                                        % (freq, fieldintensity, degree, fieldreading, self.db.TestSeriesNo))
                 self.db.Cursor.commit()
             except:
                 print('结果写入数据库失败')
             degree += 5
         else:
             try:
                 self.db.Cursor.execute("INSERT INTO FieldOmni_%sGHz_%sV (Degree, Field, TestSeriesNo) VALUES"
                                        " (%f, %f, %d)"
                                        % (freq, fieldintensity, degree, fieldreading, self.db.TestSeriesNo))
                 self.db.Cursor.commit()
                 self.zeta.ZetaRoll(degreestep)
             except:
                 print('结果写入数据库失败')
             degree += 5
示例#4
0
    def FieldProb(self, freq, fieldintensity, fieldread=None, cal=None, powerspec=-100):
        """Produce the fieldintensity of specified frequency
        :param powerspec:
        :param cal:
        :param fieldread:
        :param fieldintensity:
        :param freq:
        """
        global powersg
        sg_output_limit = -5  # unit is dBm set the signal generator output limit
        app = QApplication(sys.argv)
        fieldreading = []

        if fieldread == "ETS":
            ms = QMessageBox(QMessageBox.Warning, "提示", "请连接好ETS探头")
            ms.show()
            app.exec_()
            ETSProbe.__init__(self)
        elif fieldread == "Narda" or None == fieldread:
            ms = QMessageBox(QMessageBox.Warning, "提示", "请连接好Narda探头")
            ms.show()
            app.exec_()
        else:
            ms = QMessageBox(QMessageBox.Warning, "Alert", "Wrong fieldread 参数")
            ms.show()
            app.exec_()
            return "Wrong fieldread 参数"

        field = cal_field(freq, fieldintensity)
        print(field)
        # p_meter_disp_dbm, coupler, antenna, e_cal_1w
        if cal is not None:
            print(powerspec)
            powertarget = powerspec
        else:
            powertarget = field[0]
        antenna = field[2]
        ms = QMessageBox(QMessageBox.Warning, "提示", "请连接%s天线进行测试" % antenna)
        ms.show()
        app.exec_()
        # self.CTAntennaChange(antenna)
        ms = QMessageBox(QMessageBox.Warning, "提示", "请确定天线更换完毕并且射频线连接正确")
        ms.show()
        app.exec_()

        self.CTAntennaRoll(antenna)
        sg_initial = -30
        self.SGPowerSet(sg_initial)  # set the initial power unit dBm

        # frequency set
        frequency = freq * 1000000000
        self.SGCWFrec(frequency)
        self.PMSetFreq(frequency)
        self.PABand(frequency)
        self.SGPowerOut("On")
        self.PAPowerOut("ON")

        for i in range(0, 6):  # iterate the power output
            time.sleep(2)  # delay 1 second
            if i == 0:
                powercoup = self.PMFetch()
                print("当前第%d循环的功率计读数为%f" % (i + 1, powercoup))
                powerdiff = powertarget - powercoup
                powersg = sg_initial + powerdiff
                if self.SGInRange(powersg) and powersg < sg_output_limit:
                    self.SGPowerSet(powersg)
                else:
                    ms = QMessageBox(QMessageBox.Warning, "Alert", "Error input signal generator power")
                    ms.show()
                    app.exec_()
                    if fieldread == "ETS":
                        self.RemoveProbe()
                    return "Error input signal generator power"
            elif i <= 9:
                powercoup = self.PMFetch()
                print("当前第%d循环的功率计读数为%f" % (i + 1, powercoup))
                powerdiff = powertarget - powercoup
                powersg += powerdiff
                if self.SGInRange(powersg) and powersg < sg_output_limit:
                    self.SGPowerSet(powersg)
                elif 3 > powerdiff > 1:
                    ms = QMessageBox(QMessageBox.Warning, "提示", "功放到达1dB压缩点")
                    ms.show()
                    app.exec_()
                    break
                else:
                    ms = QMessageBox(QMessageBox.Warning, "Alert", "Error input signal generator power")
                    ms.show()
                    app.exec_()
                    if fieldread == "ETS":
                        self.RemoveProbe()
                    return "Error input signal generator power"
        if fieldread is None or fieldread == "Narda":
            fieldreading = float(input("请输入电厂探头示值:"))
        elif fieldread == "ETS":
            fieldreading.append(freq)
            fieldreading.append(self.ProbeField()[3])
            fieldreading.append(powertarget)
            fieldreading.append(field[4])
            ms = QMessageBox(QMessageBox.Warning, "提示", "请确定测试完毕")
            ms.show()
            app.exec_()
            self.RemoveProbe()
        else:
            self.PAPowerOut("OFF")
            self.SGPowerOut("OFF")
        self.PAPowerOut("OFF")
        self.SGPowerOut("OFF")

        try:
            self.Cursor.execute(
                "INSERT INTO FieldTest (Frequency, Field, FieldResult, TestSeries) "
                "VALUES (%f, %f, %f, %f)" % (freq, fieldintensity, fieldreading, self.TestSeriesNo)
            )
            self.Cursor.commit()
        except:
            print("结果写入数据库失败")
        # set return value
        if fieldreading:
            return fieldreading
        else:
            return "wrong output"
示例#5
0
 def fieldtransfer(self, cal=0, startfreq=1, stopfreq=18, specfreq=None):
     print(cal, startfreq, specfreq)
     frequency = self.FieldTransferDB(deltable=0)
     field = [10, 20, 30, 40, 50]
     iterationfreq = len(frequency)
     if cal == 0 and specfreq is None and startfreq == 1 and stopfreq == 18:
         """Calibration process, standard probe test"""
         for i in range(iterationfreq):
             for j in range(5):
                 self.TransferInit(frequency[i], field[j])
     elif cal == 0 and specfreq is None and (startfreq != 1 or stopfreq != 18):
         for i in range(iterationfreq):
             for j in range(5):
                 if startfreq <= frequency[i] <= stopfreq:
                     self.TransferInit(frequency[i], field[j])
                 else:
                     pass
     elif cal == 0 and specfreq is not None:
         specfreq = list(specfreq)
         iterationfreq = len(specfreq)
         for i in range(iterationfreq):
             for j in range(5):
                 self.TransferInit(specfreq[i], field[j])
     elif cal == 1 and specfreq is None and startfreq == 1 and stopfreq == 18:
         for i in range(iterationfreq):
             for j in range(5):
                 self.BasicCursor.execute(
                     "SELECT * FROM FieldTransfer WHERE Frequency=%f " "AND Field=%f" % (frequency[i], field[j])
                 )
                 table = self.BasicCursor.fetchall()
                 tkinter.messagebox.showinfo(title="提示", message="将要进行频率%f场强%f的测试\n" % (frequency[i], field[j]))
                 if field[j] == 0:
                     self.BasicCursor.execute(
                         "UPDATE FieldTransfer SET PowerCal=%f WHERE Frequency=%f "
                         "AND Cal=%f" % (0, frequency[i], field[j])
                     )
                     self.BasicCursor.execute(
                         "UPDATE FieldTransfer SET FieldVerify=%f WHERE Frequency=%f "
                         "AND Cal=%f" % (0, frequency[i], field[j])
                     )
                     self.BasicCursor.commit()
                 else:
                     print(self.TransferIteration(table[0][0], table[0][2]))
     elif cal == 1 and specfreq is None and (startfreq != 1 or stopfreq != 18):
         for i in range(iterationfreq):
             for j in range(5):
                 if startfreq <= frequency[i] <= stopfreq:
                     self.BasicCursor.execute(
                         "SELECT * FROM FieldTransfer WHERE Frequency=%f " "AND Field=%f" % (frequency[i], field[j])
                     )
                     table = self.BasicCursor.fetchall()
                     tkinter.messagebox.showinfo(title="提示", message="将要进行频率%f场强%f的测试\n" % (frequency[i], field[j]))
                     print(self.TransferIteration(table[0][0], table[0][2]))
                 else:
                     pass
     elif cal == 2 and specfreq is None and startfreq == 1 and stopfreq == 18:
         for i in range(iterationfreq):
             for j in range(5):
                 self.BasicCursor.execute(
                     "SELECT * FROM FieldTransfer WHERE Frequency=%f " "AND Field=%f" % (frequency[i], field[j])
                 )
                 table = self.BasicCursor.fetchall()
                 tkinter.messagebox.showinfo(title="提示", message="将要进行频率%f场强%f的测试\n" % (frequency[i], field[j]))
                 if table[0][3] != 0:
                     result = self.TransferVerify(table[0][0], table[0][3])
                     if result == "Error input signal generator power":
                         self.BasicCursor.execute(
                             "UPDATE FieldTransfer SET NardaVerify=%f WHERE Frequency=%f "
                             "AND Field=%f" % (0, frequency[i], field[j])
                         )
                         self.BasicCursor.commit()
                     else:
                         self.BasicCursor.execute(
                             "UPDATE FieldTransfer SET NardaVerify=%f WHERE Frequency=%f "
                             "AND Field=%f" % (result, frequency[i], field[j])
                         )
                         self.BasicCursor.commit()
                         print("频率%f场强%f的测试结果为%f" % (frequency[i], field[j], result))
                 else:
                     self.BasicCursor.execute(
                         "UPDATE FieldTransfer SET NardaVerify=%f WHERE Frequency=%f "
                         "AND Field=%f" % (0, frequency[i], field[j])
                     )
                     self.BasicCursor.commit()
     elif cal == 2 and specfreq is None and (startfreq != 1 or stopfreq != 18):
         for i in range(iterationfreq):
             for j in range(5):
                 if startfreq <= frequency[i] <= stopfreq:
                     self.BasicCursor.execute(
                         "SELECT * FROM FieldTransfer WHERE Frequency=%f " "AND Field=%f" % (frequency[i], field[j])
                     )
                     table = self.BasicCursor.fetchall()
                     tkinter.messagebox.showinfo(title="提示", message="将要进行频率%f场强%f的测试\n" % (frequency[i], field[j]))
                     if table[0][3] != 0:
                         result = self.TransferVerify(table[0][0], table[0][3])
                         if result == "Error input signal generator power":
                             self.BasicCursor.execute(
                                 "UPDATE FieldTransfer SET NardaVerify=%f WHERE Frequency=%f "
                                 "AND Field=%f" % (0, frequency[i], field[j])
                             )
                             self.BasicCursor.commit()
                         else:
                             self.BasicCursor.execute(
                                 "UPDATE FieldTransfer SET NardaVerify=%f WHERE Frequency=%f "
                                 "AND Field=%f" % (result, frequency[i], field[j])
                             )
                             self.BasicCursor.commit()
                             print("频率%f场强%f的测试结果为%f" % (frequency[i], field[j], result))
                     else:
                         self.BasicCursor.execute(
                             "UPDATE FieldTransfer SET NardaVerify=%f WHERE Frequency=%f "
                             "AND Field=%f" % (0, frequency[i], field[j])
                         )
                         self.BasicCursor.commit()
                 else:
                     pass
     elif cal == 3 and specfreq is None and startfreq == 1 and stopfreq == 18:
         for i in range(iterationfreq):
             for j in range(5):
                 table1 = cal_field(frequency[i], field[j])
                 antenna = table1[2]
                 self.CTAntennaRoll(antenna)
                 self.BasicCursor.execute(
                     "SELECT * FROM FieldTransfer WHERE Frequency=%f " "AND Field=%f" % (frequency[i], field[j])
                 )
                 table = self.BasicCursor.fetchall()
                 tkinter.messagebox.showinfo(title="提示", message="将要进行频率%f场强%f的测试\n" % (frequency[i], field[j]))
                 if frequency[i] == 4.3:
                     tkinter.messagebox.showinfo(title="提示", message="请注意更换耦合器\n")
                 if table[0][3] != 0:
                     result = self.TransferVerify(table[0][0], table1[0])
                     if result == "Error input signal generator power":
                         self.BasicCursor.execute(
                             "UPDATE FieldTransfer SET NardaSTD=%f WHERE Frequency=%f "
                             "AND Field=%f" % (0, frequency[i], field[j])
                         )
                         self.BasicCursor.commit()
                     else:
                         self.BasicCursor.execute(
                             "UPDATE FieldTransfer SET NardaSTD=%f WHERE Frequency=%f "
                             "AND Field=%f" % (result, frequency[i], field[j])
                         )
                         self.BasicCursor.commit()
                         print("频率%f场强%f的测试结果为%f" % (frequency[i], field[j], result))
                 else:
                     self.BasicCursor.execute(
                         "UPDATE FieldTransfer SET NardaSTD=%f WHERE Frequency=%f "
                         "AND Field=%f" % (0, frequency[i], field[j])
                     )
                     self.BasicCursor.commit()
     elif cal == 3 and specfreq is None and (startfreq != 1 or stopfreq != 18):
         for i in range(iterationfreq):
             for j in range(5):
                 if startfreq <= frequency[i] <= stopfreq:
                     table1 = cal_field(frequency[i], field[j])
                     antenna = table1[2]
                     self.CTAntennaRoll(antenna)
                     self.BasicCursor.execute(
                         "SELECT * FROM FieldTransfer WHERE Frequency=%f " "AND Field=%f" % (frequency[i], field[j])
                     )
                     table = self.BasicCursor.fetchall()
                     tkinter.messagebox.showinfo(title="提示", message="将要进行频率%f场强%f的测试\n" % (frequency[i], field[j]))
                     if frequency[i] == 4.3:
                         tkinter.messagebox.showinfo(title="提示", message="请注意更换耦合器\n")
                     if table[0][3] != 0:
                         result = self.TransferVerify(table[0][0], table1[0])
                         if result == "Error input signal generator power":
                             self.BasicCursor.execute(
                                 "UPDATE FieldTransfer SET NardaSTD=%f WHERE Frequency=%f "
                                 "AND Field=%f" % (0, frequency[i], field[j])
                             )
                             self.BasicCursor.commit()
                         else:
                             self.BasicCursor.execute(
                                 "UPDATE FieldTransfer SET NardaSTD=%f WHERE Frequency=%f "
                                 "AND Field=%f" % (result, frequency[i], field[j])
                             )
                             self.BasicCursor.commit()
                             print("频率%f场强%f的测试结果为%f" % (frequency[i], field[j], result))
                     else:
                         self.BasicCursor.execute(
                             "UPDATE FieldTransfer SET NardaSTD=%f WHERE Frequency=%f "
                             "AND Field=%f" % (0, frequency[i], field[j])
                         )
                         self.BasicCursor.commit()
                 else:
                     pass
     else:
         print("WTF")
示例#6
0
    def FieldProd(self, freq, fieldintensity):
        """Produce the fieldintensity of specified frequency"""
        sg_output_limit = -5  # unit is dBm set the signal generator output limit
        field = cal_field(freq, fieldintensity)
        # p_meter_disp_dbm, coupler, antenna, e_cal_1w
        powertarget = field[0]
        coupler = field[1]
        antenna = field[2]
        app = QApplication(sys.argv)
        ms = QMessageBox(QMessageBox.Warning, "提示", "请更换%s耦合器进行测试" % coupler)
        ms.show()
        app.exec_()
        ms = QMessageBox(QMessageBox.Warning, "提示", "请连接%s天线进行测试" % antenna)
        ms.show()
        app.exec_()
        self.CTAntennaChange(antenna)
        ms = QMessageBox(QMessageBox.Warning, "提示", "请确定天线更换完毕并且射频线连接正确")
        ms.show()
        app.exec_()
        self.CTAntennaRoll(antenna)
        sg_initial = -30
        self.SGPowerSet(sg_initial)   # set the initial power unit dBm

        # frequency set
        frequency = freq * 1000000000
        print(self.SGCWFrec(frequency))
        print(self.PMSetFreq(frequency))
        print(self.PABand(frequency))
        self.SGPowerOut('On')
        self.PAPowerOut('ON')

        for i in range(0, 6):  # iterate the power output
            if i == 0:

                powercouple = self.PMFetch()
                print(powercouple)
                powerdiff = powertarget - powercouple
                powersg = sg_initial + powerdiff
                if self.SGInRange(powersg) and powersg < sg_output_limit:
                    self.SGPowerSet(powersg)
                else:
                    ms = QMessageBox(QMessageBox.Warning, 'Alert', "Error input signal generator power")
                    ms.show()
                    app.exec_()
                    break
            else:
                powercouple = self.PMFetch()
                powerdiff = powertarget - powercouple
                powersg += powerdiff
                if self.SGInRange(powersg) and powersg < sg_output_limit:
                    self.SGPowerSet(powersg)
                elif 3 > powerdiff > 1:
                    ms = QMessageBox(QMessageBox.Warning, "提示", "功放到达1dB压缩点")
                    ms.show()
                    app.exec_()
                    break
                else:
                    ms = QMessageBox(QMessageBox.Warning, 'Alert', "Error input signal generator power")
                    ms.show()
                    app.exec_()
        self.PAPowerOut('OFF')
        self.SGPowerOut('OFF')
        print(powercouple)
        return field