def __init__(self, windows, cable_loss):
        # def __init__(self, cable_loss):
        """
        初始化参数
        :param windows: 测试UI窗口
        :param test_bands:测试频段
        :param cable_loss: 线损
        :param chip_set: 芯片平台
        :param downlink_speed: DUT下行速率
        :param uplink_speed: DUT上行速率
        """
        super(WcdmaThroughput, self).__init__()
        self.debug_mode = 1
        self.windows = windows
        self.tree = ElementTree.parse('config.xml')
        self.root = self.tree.getroot()
        self.MAX_TIMES = 3
        self.DURATION = self.root.find('duration').text
        self.my_logging = my_logging.MyLogging()
        self.logger = self.my_logging.get_logger()
        self.local_time = time.strftime("%Y%m%d-%H%M%S")
        self.result_path = 'result'
        if not os.path.exists(self.result_path):
            os.makedirs(self.result_path)
        self.txt_result = 'result\\result_%s.txt' % str(self.local_time)
        self.bands_all = [
            [1, [10563, 10700, 10837]],  # band1
            [2, [9663, 9800, 9937]],  # band2
            [3, [1163, 1337, 1512]],  # band3
            [4, [1538, 1675, 1737]],  # band4
            [5, [4358, 4400, 4457]],  # band5
            [8, [2938, 3013, 3087]]  # band8
        ]
        rm = visa.ResourceManager()
        self.logger.info(rm)
        self.logger.info(rm.list_resources())

        try:
            self.instrument = rm.list_resources()[0]
            self.logger.info("选择设备列表第一个仪器,请确保只有一个GPIB设备连接")
            self.logger.info('Try to connect instrument, address: %s' % self.instrument)
            self.my_instr = rm.open_resource(self.instrument)
            query = self.my_instr.query("*IDN?")
            self.logger.info("Query result: %s" % str(query))
            if query == "":
                self.logger.error("无法连接至8960!")
            else:
                self.logger.info("连接成功!")
        except Exception, e:
            self.logger.error(str(Exception))
            self.logger.error(e)
            self.logger.error("无法识别GPIB设备!")
示例#2
0
# -*- coding: UTF-8 -*-
import my_logging
import os
import openpyxl

logger = my_logging.MyLogging().getlogger()


class SaveListToXlsx():
    def write_xlsx_file(self, *arg):
        '''将传入的列表存入excel表格中
            alldata: 是传入的list数据,要求是一个一维或者二位列表
        '''
        #print('started to write xlsx')
        file_name = 'result.xlsx'
        #        logger.debug(arg)
        alldata, file_path, sheet_name = arg
        if file_name in os.listdir(file_path + '.'):
            wb = openpyxl.load_workbook('%s%s' % (file_path, file_name))
        else:
            wb = openpyxl.Workbook()
        try:
            #如果存在同名的表,就删除
            wb.remove(wb[sheet_name])
        except Exception as e:
            logger.debug(e)
        ws = wb.create_sheet(sheet_name)
        row_num = 1
        for t_row in alldata:
            col_num = 1
            for t_col in t_row:
示例#3
0
    def __init__(self, *args, **kw):
        """
        初始化并调用父类init方法
        :param args: None
        :param kw: None
        """
        super(TestUI, self).__init__(*args, **kw)
        self.tree = ElementTree.parse("config.xml")
        self.root = self.tree.getroot()

        self.Center()
        self.my_logging = my_logging.MyLogging()
        self.logger = self.my_logging.get_logger()
        # 标题
        self.title_text = wx.StaticText(self, - 1, label="WCDMA吞吐量测试", style=wx.ALIGN_CENTER)
        font = self.title_text.GetFont()
        font.PointSize += 5
        font = font.Bold()
        self.title_text.SetFont(font)
        # 测试频段
        self.band_text = wx.StaticText(self, -1, label="选择频段")
        self.bands = [
            [1, [10563, 10700, 10837]],  # band1
            [2, [9663, 9800, 9937]],  # band2
            [3, [1163, 1337, 1512]],  # band3
            [4, [1538, 1675, 1737]],  # band4
            [5, [4358, 4400, 4457]],  # band5
            [8, [2938, 3013, 3087]]  # band8
        ]
        self.test_list = ['band1', 'band2', 'band3', 'band4', 'band5', 'band8']
        self.list_box = wx.ListBox(self, -1, (140, 50), (80, 120), self.test_list, wx.LB_MULTIPLE)
        # 默认选中A版支持频段
        self.list_box.SetSelection(0)
        self.list_box.SetSelection(4)
        self.list_box.SetSelection(5)
        # 衰减设置
        self.cable_loss_text = wx.StaticText(self, -1, label="设置衰减")

        self.cable_loss_grid = wx.grid.Grid(self, -1)
        self.cable_loss_grid.CreateGrid(2, 2)
        self.cable_loss_grid.SetCellValue(0, 0, '800.0')
        self.cable_loss_grid.SetCellValue(1, 0, '1800.0')
        self.cable_loss_grid.SetCellValue(0, 1, '-1.0')
        self.cable_loss_grid.SetCellValue(1, 1, '-1.2')
        self.cable_loss_grid.SetColLabelValue(0, '频率/MHz')
        self.cable_loss_grid.SetColLabelValue(1, '衰减/dB')
        self.cable_loss_grid.HideRowLabels()
        # 芯片
        self.chip_list = ['MTK', 'QUALCOMM']
        self.chip_box = wx.RadioBox(self, -1, '芯片平台', pos=(0, 0),
                                    choices=self.chip_list, style=wx.RA_SPECIFY_COLS)
        self.chip_box.Bind(wx.EVT_RADIOBOX, self.on_select_chip)

        self.downlink_speed = ['42M', '21M']
        self.dl_sp_box = wx.RadioBox(self, -1, '下行速率', pos=(0, 0),
                                     choices=self.downlink_speed, style=wx.RA_SPECIFY_COLS)
        self.dl_sp_box.Bind(wx.EVT_RADIOBOX, self.on_select_down_speed)

        self.uplink_speed = ['11.4M', '5.7M']
        self.ul_sp_box = wx.RadioBox(self, -1, '上行速率', pos=(0, 0),
                                     choices=self.uplink_speed, style=wx.RA_SPECIFY_COLS)
        self.ul_sp_box.Bind(wx.EVT_RADIOBOX, self.on_select_up_speed)

        self.begin_test_button = wx.Button(self, -1, label="开始测试")
        self.Bind(wx.EVT_BUTTON, self.on_begin_test, self.begin_test_button)

        self.output_text = wx.TextCtrl(self, -1, value="Output log...\n",
                                       style=wx.TE_READONLY | wx.TE_MULTILINE)

        box = wx.BoxSizer(wx.VERTICAL)

        box.Add(self.title_text, 0, wx.ALIGN_CENTER)
        # 参数框
        parameter_box = wx.BoxSizer(wx.HORIZONTAL)
        parameter_box.Add(self.band_text, flag=wx.ALL, border=2)
        parameter_box.Add(self.list_box, 1, flag=wx.ALL, border=2)
        parameter_box.Add(self.cable_loss_text, flag=wx.ALL, border=2)
        parameter_box.Add(self.cable_loss_grid, 1, flag=wx.ALL, border=2)
        # 速率框
        speed_box = wx.BoxSizer(wx.VERTICAL)
        speed_box.Add(self.chip_box)
        speed_box.Add(self.dl_sp_box)
        speed_box.Add(self.ul_sp_box)

        parameter_box.Add(speed_box, 1, flag=wx.ALL, border=2)

        box.Add(parameter_box, flag=wx.ALL, border=15)
        check_test_box = wx.BoxSizer(wx.HORIZONTAL)
        self.test_phy_checkbox = wx.CheckBox(self, -1, label="测试物理层")
        self.test_ip_checkbox = wx.CheckBox(self, -1, label="测试IP层")
        self.ip_text = wx.StaticText(self, - 1, label="手机IP地址")
        self.ip_input = wx.TextCtrl(self, -1, value=self.root.find('dut_ip').text)

        check_test_box.Add(self.test_phy_checkbox, flag=wx.ALL, border=2)
        check_test_box.Add(self.test_ip_checkbox, flag=wx.ALL, border=2)
        check_test_box.Add(self.ip_text, flag=wx.ALL, border=2)
        check_test_box.Add(self.ip_input, flag=wx.ALL, border=2)

        box.Add(check_test_box, border=15)
        # 开始按钮
        box.Add(self.begin_test_button, 0, flag=wx.ALIGN_CENTER | wx.ALL, border=5)
        # 输出日志框
        box.Add(self.output_text, 1, wx.EXPAND)

        self.SetSizer(box)
        self.SetAutoLayout(True)

        self.make_menu_bar()
        self.CreateStatusBar()
        self.SetStatusText("Ready to work")