Beispiel #1
0
    def Do_Plot_Normal_Distribution(self):
        global DUT_sn, DUT_time, DUT_result, DUT_case, Test_Configuration, Case_Result
        # print(sn_row,time_row,result_row,case_row)
        # print(case_row)

        f = database_operation()
        if DUT_case == "All":
            QMessageBox.warning(
                self, "Error", "please select a test case", QMessageBox.Yes
            )  #only can analyse the assigned test case and it will be fail when case is all
            return
        if Test_Configuration == "All":
            QMessageBox.warning(
                self, "Error", "please select a test configuration",
                QMessageBox.Yes)  #must select the test confdiguration
            return
        result1_array = []
        sn_array = []
        min1_array = []
        max1_array = []
        b = f.query_database("SELECT Result1 FROM " + table2 +
                             " where Test_Case= " + "\"" + DUT_case + "\"" +
                             " and Test_Configuration=" + "\"" +
                             Test_Configuration + "\"")
        a = f.query_database("SELECT SN FROM " + table2 +
                             " where Test_Case= " + "\"" + DUT_case + "\"" +
                             " and Test_Configuration=" + "\"" +
                             Test_Configuration + "\"")
        c = f.query_database("SELECT SpecMin1 FROM " + table2 +
                             " where Test_Case= " + "\"" + DUT_case + "\"" +
                             " and Test_Configuration=" + "\"" +
                             Test_Configuration + "\"")
        d = f.query_database("SELECT SpecMax1 FROM " + table2 +
                             " where Test_Case= " + "\"" + DUT_case + "\"" +
                             " and Test_Configuration=" + "\"" +
                             Test_Configuration + "\"")
        #Test_Configuration = "All"
        for i in range(len(b)):
            temp = list(
                b[i][:1]
            )  # b[i][:1] remove the ,  from ((32888,),(300002,),.....) to list format
            temp_str = temp[0]  # get the value from the list [32800]
            result1_array.append(
                temp_str
            )  # convert the mysql query result to [x,x,x....] format
            temp = list(a[i][:1])
            temp_str = temp[0]
            sn_array.append(temp_str)
            temp = list(c[i][:1])
            temp_str = temp[0]
            min1_array.append(temp_str)
            temp = list(d[i][:1])
            temp_str = temp[0]
            max1_array.append(temp_str)
        g = curve_plot()
        g.plot_Nor_Distribution(result1_array, min1_array[0], max1_array[0],
                                DUT_case, Test_Configuration)
        Test_Configuration = "All"
Beispiel #2
0
 def save_database(self):
     print('正在点击按钮2')
     self.textEdit_2.setHidden(False)
     self.Test_Case_List.setHidden(True)
     self.test_time_list.setHidden(True)
     self.Result_List.setHidden(True)
     f = database_operation()
     b = f.query_database("SELECT * FROM " + table1)
     chip_sn_time = Excel.Excel_operation.list_chip_sn_time(root)
     print(chip_sn_time)
     one_chip_test_result = []
     for each_chip in Excel.Excel_operation.list_chip_paths(root):
         chip_name = os.path.split(each_chip)[1]
         one_chip_test_result = Excel.Excel_operation.each_chip_test_result(
             each_chip, chip_name)
         one_chip_status = Excel.Excel_operation.summary_one_chip_data(
             one_chip_test_result)
         status_result_table_data = "(\"%s\", \"%s\",\"%s\")" % (''.join(
             one_chip_test_result[:][0][0][1]), ''.join(
                 one_chip_test_result[:][0][0][0]), one_chip_status)
         columns = f.list_col(table1)
         f.insert_data(table1, columns, status_result_table_data)
         print(chip_name + "done")
         for i in range(len(one_chip_test_result[:])):
             result_str = ""
             for j in range(len(one_chip_test_result[:][i])):
                 result_str = ""
                 for k in range(len(one_chip_test_result[:][i][j])):
                     if ''.join(
                             one_chip_test_result[:][i][j]
                         [k]) == "Na" or ''.join(
                             one_chip_test_result[:][i][j][k]) == "Inf":
                         temp = "0"
                     else:
                         temp = ''.join(one_chip_test_result[:][i][j][k])
                     if k == len(one_chip_test_result[:][i][j]) - 1:
                         result_str = result_str + "\"" + temp + "\""
                     else:
                         result_str = result_str + "\"" + temp + "\"" + ","
                 result_str = "(" + result_str + ")"
                 columns = f.list_col(table2)
                 f.insert_data(table2, columns, result_str)
         self.textEdit_2.insertPlainText(chip_name + " Done" + "\n")
         #QApplication.processEvents()                                              #refresh frame
         #print(result_str)
     QMessageBox.information(self, "information", "Import Done",
                             QMessageBox.Yes)
Beispiel #3
0
 def config_List_clicked(self, qModelIndex):
     global DUT_sn, DUT_time, DUT_result, DUT_case, Test_Configuration, Case_Result
     config_row = qModelIndex.row()
     # print(case_row)
     # 获取当前选中行的数据
     Test_Configuration = str(self.Test_Config_List[config_row])
     temp7 = []
     temp8 = []
     temp9 = []
     temp10 = []
     temp11 = []
     temp12 = []
     temp13 = []
     temp14 = []
     f = database_operation()
     b = f.query_database("SELECT * FROM " + table2 +
                          self.check_query_option("config"))
     self.showData(b)
     return Test_Configuration
Beispiel #4
0
    def showData(self, data):
        #display the data in qtable
        f = database_operation()
        columns = f.list_fileld(table2)  #get the table2 fileld name
        fail_list = []
        temp_fail_list = []
        # 准备数据模型
        self.sm = QtGui.QStandardItemModel()  #set the qtable model

        # 设置数据头栏名称
        for i in range(len(columns)):
            self.sm.setHorizontalHeaderItem(
                i, QtGui.QStandardItem("".join(
                    columns[i])))  #set the head name for the qtable
        #self.sm.setHorizontalHeaderItem(1, QtGui.QStandardItem("NO."))

        # 设置数据条目
        for i in range(len(data)):
            for j in range(len(data[:][i])):
                #value_type=type(data[i][j])                        get the type
                if j == 1:
                    temp = data[i][j].strftime('%Y-%m-%d %H:%M:%S')
                else:
                    if j > 4:
                        temp = str(
                            data[i][j])  #convert the int & double to str
                    else:
                        temp = data[i][j]
                if temp == "fail":  #get the fail row&coulum index
                    temp_fail_list = [i, j]
                    fail_list.append(temp_fail_list)
                    #self.sm.item(i, j).setBackground(QtGui.QBrush(QtGui.QColor(255, 255, 0)))
                self.sm.setItem(
                    i, j, QtGui.QStandardItem(temp))  #set the each cloumn data
        '''           
        self.sm.setItem(0, 0, QtGui.QStandardItem("张三"))
        self.sm.setItem(0, 1, QtGui.QStandardItem("20120202"))

        self.sm.setItem(1, 0, QtGui.QStandardItem("李四"))
        self.sm.setItem(1, 1, QtGui.QStandardItem("20120203000000000000000"))

        self.sm.setItem(2, 0, QtGui.QStandardItem("李四"))
        self.sm.setItem(2, 1, QtGui.QStandardItem("20120203000000000000000"))

        self.sm.setItem(3, 0, QtGui.QStandardItem("李四"))
        self.sm.setItem(3, 1, QtGui.QStandardItem("20120203000000000000000"))

        self.sm.setItem(4, 0, QtGui.QStandardItem("李四"))
        self.sm.setItem(4, 1, QtGui.QStandardItem("20120203000000000000000"))

        self.sm.setItem(5, 0, QtGui.QStandardItem("李四"))
        self.sm.setItem(5, 1, QtGui.QStandardItem("20120203000000000000000"))
     '''

        # 设置条目颜色和字体
        #self.sm.item(0, 0).setForeground(QtGui.QBrush(QtGui.QColor(255, 0, 0)))
        #self.sm.item(0, 0).setFont(QtGui.QFont("Times", 10, QtGui.QFont.Black))
        for i in range(len(fail_list)):
            for j in range(len(data[:][0])):
                self.sm.item(fail_list[i][0], j).setBackground(
                    QtGui.QBrush(QtGui.QColor(
                        255, 255, 0)))  #set the color for the fail item(a row)

    # 按照编号排序
        self.sm.sort(1, QtCore.Qt.DescendingOrder)

        # 将数据模型绑定到QTableView
        self.tableView.setModel(self.sm)

        # QTableView
        self.tableView.setColumnWidth(0, 100)
        self.tableView.setColumnWidth(1, 200)
Beispiel #5
0
 def case_clicked(self, qModelIndex):
     #global root
     global DUT_sn, DUT_time, DUT_result, DUT_case, Test_Configuration
     case_row = qModelIndex.row()
     #print(case_row)
     # 获取当前选中行的数据
     DUT_case = str(self.Test_Case_List[case_row])
     temp7 = []
     temp8 = []
     temp9 = []
     temp10 = []
     temp11 = []
     temp12 = []
     temp13 = []
     temp14 = []
     f = database_operation()
     if DUT_case == "All":
         b = f.query_database("SELECT distinct Test_Case FROM " + table2)
         for i in range(len(b)):
             temp7 = list(b[:][i])
             temp8.append("".join(temp7))
         temp8.insert(0, "All")
         self.model_4.setStringList(temp8)
         self.Test_Case_List = temp8
     else:
         b = f.query_database("SELECT distinct Test_Configuration FROM " +
                              table2 + " where Test_Case=" + "\"" +
                              DUT_case + "\"")
         for i in range(len(b)):
             temp13 = list(b[:][i])
             temp14.append("".join(temp13))
         temp14.insert(0, "All")
         self.model_5.setStringList(temp14)
         self.Test_Config_List = temp14
         if DUT_sn != "All" and DUT_time != "All" and DUT_case != "All":
             b = f.query_database("SELECT Status,Test_Configuration FROM " +
                                  table2 + " Where SN=" + "\"" + DUT_sn +
                                  "\"" + " and Time=" + "\"" + DUT_time +
                                  "\"" + " and Test_Case=" + "\"" +
                                  DUT_case + "\"")
             for i in range(len(b)):
                 temp9 = list(
                     b[i][0])  # get the SN and convert form touple to listh
                 temp10.append(
                     "".join(temp9)
                 )  # remove the touple('f','a','n') to 'fan' and add the list
                 temp11 = list(
                     b[i][1])  # get the SN and convert form touple to listh
                 temp12.append(
                     "".join(temp11)
                 )  # remove the touple('f','a','n') to 'fan' and add the list
         # 添加列表数据
             temp10.insert(0, "All")
             temp12.insert(0, "All")
             self.model_6.setStringList(temp10)
             self.Case_Result_List = temp10
             self.model_5.setStringList(temp12)
             self.Test_Config_List = temp12
             self.model_4.setStringList(["All", DUT_case])
             self.Test_Case_List = ["All", DUT_case]
             b = f.query_database("SELECT * FROM " + table2 +
                                  self.check_query_option("case"))
             self.showData(b)
         else:
             if DUT_sn == "All":
                 b = f.query_database("SELECT * FROM " + table2 +
                                      self.check_query_option("case"))
                 self.showData(b)
             else:
                 QMessageBox.warning(self, "Error",
                                     "please select the test time",
                                     QMessageBox.Yes)
                 return
     #c=root + '/' + str(self.Result_List[qModelIndex.row()])
     #df = pd.DataFrame(pd.read_excel(a))
     #self.textEdit.setText(str(df))
     return DUT_case
Beispiel #6
0
 def result_clicked(self, qModelIndex):
     #global root
     global DUT_sn, DUT_time, DUT_result, DUT_case, Test_Configuration
     result_row = qModelIndex.row()
     print(result_row)
     #print(result_row)
     # 获取当前选中行的数据
     DUT_result = str(self.Result_List[result_row])
     print(self.Result_List)
     print(DUT_result)
     f = database_operation()
     temp2 = []
     temp4 = []
     temp6 = []
     if DUT_result == "All":
         b = f.query_database("SELECT * FROM " + table1)
         for i in range(len(b)):
             temp1 = list(
                 b[i][1])  # get the SN and convert form touple to listh
             temp2.append(
                 "".join(temp1)
             )  # remove the touple('f','a','n') to 'fan' and add the list
             temp3 = list(b[i][0].strftime('%Y-%m-%d %H:%M:%S'))
             temp4.append("".join(temp3))
             temp5 = list(b[i][2])
             temp6.append("".join(temp5))
         temp2.insert(0, "All")
         temp4.insert(0, "All")
         temp6.insert(0, "All")
         self.model_1.setStringList(temp2)
         self.sn_list = temp2
         self.model_2.setStringList(temp4)
         self.test_time_list = temp4
         self.model_3.setStringList(temp6)
         self.Result_List = temp6
     else:
         b = f.query_database("SELECT * FROM " + table1 + " Where result=" +
                              "\"" + DUT_result + "\"")
         for i in range(len(b)):
             temp1 = list(
                 b[i][1])  #get the SN and convert form touple to listh
             temp2.append(
                 "".join(temp1)
             )  #remove the touple('f','a','n') to 'fan' and add the list
             temp3 = list(b[i][0].strftime('%Y-%m-%d %H:%M:%S'))
             temp4.append("".join(temp3))
             temp5 = list(b[i][2])
             temp6.append("".join(temp5))
     # 添加列表数据
         temp2.insert(0, "All")
         self.model_1.setStringList(temp2)
         self.sn_list = temp2
         temp4.insert(0, "All")
         self.model_2.setStringList(temp4)
         self.test_time_list = temp4
         if DUT_result == "pass":
             self.model_3.setStringList(["All", "pass"])
             self.Result_List = ["All", "pass"]
         else:
             self.model_3.setStringList(["All", "fail"])
             self.Result_List = ["All", "fail"]
         print(self.Result_List)
     #print(DUT_sn)
     #c=root + '/' + str(self.Result_List[qModelIndex.row()])
     #df = pd.DataFrame(pd.read_excel(a))
     #self.textEdit.setText(str(df))
     #print(DUT_result)
     QApplication.processEvents()
     return DUT_result
Beispiel #7
0
 def sn_clicked(self, qModelIndex):
     #global root
     #sql_command_option=self.check_query_option("sn")
     global DUT_sn, DUT_time, DUT_result, DUT_case, Test_Configuration, Case_Result  #set the global var
     sn_row = qModelIndex.row()  #get the clicked row index
     #self.model_1.removeRow(sn_row)         #删除点击的行
     # 获取当前选中行的数据
     DUT_sn = str(
         self.sn_list[sn_row])  #get the content with the assigned row
     f = database_operation()  #open the database
     temp2 = []
     temp4 = []
     temp6 = []
     temp7 = []
     temp8 = []
     if DUT_sn == "All":
         DUT_time = DUT_result = DUT_case = Test_Configuration = Case_Result = "All"
         b = f.query_database(
             "SELECT * FROM " +
             table1)  #query all data from status_result table
         for i in range(len(b)):
             temp1 = list(
                 b[i][1])  # get the SN and convert form touple to listh
             temp2.append(
                 "".join(temp1)
             )  # remove the touple('f','a','n') to 'fan' and add the list,joint the f and a with ""
             temp3 = list(b[i][0].strftime('%Y-%m-%d %H:%M:%S'))
             temp4.append("".join(temp3))
             temp5 = list(b[i][2])
             temp6.append("".join(temp5))
         temp2.insert(0, "All")  #add the "all" in first element
         temp4.insert(0, "All")
         temp6.insert(0, "All")
         self.model_1.setStringList(temp2)
         self.sn_list = temp2  #set the qlistlist to assigned list
         self.model_2.setStringList(temp4)
         self.test_time_list = temp4
         self.model_3.setStringList(temp6)
         self.Result_List = temp6
         print(DUT_sn)
         b = f.query_database("SELECT * FROM " + table2)
         self.showData(b)
     else:  #if clicked the assigned DUT S/N need put the configuration and case detail in qlist
         b = f.query_database("SELECT * FROM " + table1 + " Where SN=" +
                              "\"" + DUT_sn + "\"")
         for i in range(len(b)):
             temp1 = list(
                 b[i][1])  #get the SN and convert form touple to listh
             temp2.append(
                 "".join(temp1)
             )  #remove the touple('f','a','n') to 'fan' and add the list
             temp3 = list(b[i][0].strftime('%Y-%m-%d %H:%M:%S'))
             temp4.append("".join(temp3))
             temp5 = list(b[i][2])
             temp6.append("".join(temp5))
     # 添加列表数据
         self.model_2.setStringList(
             temp4)  #display the DUT test time and result in qlist
         self.test_time_list = temp4
         self.model_3.setStringList(temp6)
         self.Result_List = temp6
         b = f.query_database("SELECT Status FROM " + table2 +
                              " Where SN=" + "\"" + DUT_sn + "\"")
         for i in range(len(b)):
             temp7 = list(
                 b[i])  # get the SN and convert form touple to listh
             temp8.append(
                 "".join(temp7)
             )  # remove the touple('f','a','n') to 'fan' and add the list
         # 添加列表数据
         temp8.insert(0, "All")
         self.model_6.setStringList(temp8)
         self.Case_Result_List = temp8
         b = f.query_database("SELECT * FROM " + table2 +
                              self.check_query_option("sn"))
         self.showData(b)
         print(DUT_sn)
     return DUT_sn
Beispiel #8
0
    def query(self):
        print('正在点击按钮2')
        f = database_operation()
        b = f.query_database("SELECT * FROM " + table1)
        b = list(b)
        temp1 = []
        temp2 = []
        temp3 = []
        temp4 = []
        temp5 = []
        temp6 = []
        for i in range(len(b)):
            temp1 = list(
                b[:][i][1])  #get the SN and convert form touple to listh
            temp2.append(
                "".join(temp1)
            )  #remove the touple('f','a','n') to 'fan' and add the list
            temp3 = list(b[:][i][0].strftime('%Y-%m-%d %H:%M:%S'))
            temp4.append("".join(temp3))
            temp5 = list(b[:][i][2])
            temp6.append("".join(temp5))
        temp2.insert(0, "All")
        temp4.insert(0, "All")
        temp6.insert(0, "All")
        # 实例化列表模型,添加数据列表
        self.model_1 = QtCore.QStringListModel()
        self.model_2 = QtCore.QStringListModel()
        self.model_3 = QtCore.QStringListModel()
        self.model_4 = QtCore.QStringListModel()
        self.model_5 = QtCore.QStringListModel()
        self.model_6 = QtCore.QStringListModel()
        # 添加列表数据
        self.model_1.setStringList(temp2)
        self.sn_list.setModel(self.model_1)
        self.sn_list = temp2
        self.model_2.setStringList(temp4)
        self.test_time_list.setModel(self.model_2)
        self.test_time_list = temp4
        self.model_3.setStringList(temp6)
        self.Result_List.setModel(self.model_3)
        self.Result_List = temp6
        temp7 = []
        temp8 = []
        temp9 = []
        temp10 = ["All"]
        temp11 = []
        temp12 = ["All"]

        b = f.query_database("SELECT distinct Test_Case FROM " + table2)
        for i in range(len(b)):
            temp7 = list(b[:][i])
            temp8.append("".join(temp7))
        temp8.insert(0, "All")
        self.model_4.setStringList(temp8)
        self.Test_Case_List.setModel(self.model_4)
        self.Test_Case_List = temp8
        self.model_5.setStringList(temp10)
        self.Test_Config_List.setModel(self.model_5)
        self.Test_Config_List = temp10
        self.model_6.setStringList(temp12)
        self.Case_Result_List.setModel(self.model_6)
        self.Case_Result_List = temp12
Beispiel #9
0
    def Do_Plot_Series(self):
        global DUT_sn, DUT_time, DUT_result, DUT_case, Test_Configuration, Case_Result
        #print(sn_row,time_row,result_row,case_row)
        #print(case_row)
        print(DUT_case, Test_Configuration)
        f = database_operation()
        if DUT_case == "All":
            QMessageBox.warning(self, "Error", "please select a test case",
                                QMessageBox.Yes)
            return
        if Test_Configuration == "All":
            QMessageBox.warning(self, "Error",
                                "please select a test configuration",
                                QMessageBox.Yes)
            return
        result1_array = []
        sn_array = []
        min1_array = []
        max1_array = []
        b = f.query_database("SELECT Result1 FROM " + table2 +
                             " where Test_Case= " + "\"" + DUT_case + "\"" +
                             " and Test_Configuration=" + "\"" +
                             Test_Configuration + "\"")
        a = f.query_database("SELECT SN FROM " + table2 +
                             " where Test_Case= " + "\"" + DUT_case + "\"" +
                             " and Test_Configuration=" + "\"" +
                             Test_Configuration + "\"")
        c = f.query_database("SELECT SpecMin1 FROM " + table2 +
                             " where Test_Case= " + "\"" + DUT_case + "\"" +
                             " and Test_Configuration=" + "\"" +
                             Test_Configuration + "\"")
        d = f.query_database("SELECT SpecMax1 FROM " + table2 +
                             " where Test_Case= " + "\"" + DUT_case + "\"" +
                             " and Test_Configuration=" + "\"" +
                             Test_Configuration + "\"")
        #b = f.query_database("SELECT Result1 FROM " + table2 + " where Test_Case= " +"\"" + DUT_case + "\"" +" and Status='pass'")
        #a = f.query_database("SELECT SN FROM " + table2 + " where Test_Case= " +"\"" + DUT_case + "\"" +" and Status='pass'")
        #c = f.query_database("SELECT SpecMin1 FROM " + table2 + " where Test_Case= " +"\"" + DUT_case + "\"" +" and Status='pass'")
        #d = f.query_database("SELECT SpecMax1 FROM " + table2 + " where Test_Case= " +"\"" + DUT_case + "\"" +" and Status='pass'")

        for i in range(len(b)):
            temp = list(
                b[i][:1]
            )  #b[i][:1] remove the ,  from ((32888,),(300002,),.....) to list format
            temp_str = temp[0]  #get the value from the list [32800]
            result1_array.append(
                temp_str
            )  #convert the mysql query result to [x,x,x....] format
            temp = list(a[i][:1])
            temp_str = temp[0]
            sn_array.append(temp_str)
            temp = list(c[i][:1])
            temp_str = temp[0]
            min1_array.append(temp_str)
            temp = list(d[i][:1])
            temp_str = temp[0]
            max1_array.append(temp_str)
        array_x = list(a)
        range_length = range(len(result1_array))
        #print(range_length)
        #print(a)
        #print(b)
        plt.figure(figsize=(10, 6))
        plt.title(DUT_case + "\n test configuration:%s \n total quantity=%s" %
                  (Test_Configuration, len(result1_array)))  #set the title
        #plt.bar(range_length, result1_array)
        plt.plot(
            range_length, result1_array, '-b', label='result', linewidth=1.0
        )  #range_length make sure how much x axis value:for example 1~100
        plt.plot(range_length, min1_array, '-r', label='min', linewidth=1.5)
        plt.plot(range_length, max1_array, '-r', label='max', linewidth=1.5)
        plt.xticks(range_length, array_x, rotation=30,
                   fontsize='small')  #assign the x axis vaule with the str
        plt.xlabel('SN')
        plt.ylabel("123")
        plt.legend()
        plt.show()
        Test_Configuration = "All"
        '''