Beispiel #1
0
        private void UploadTestData(string xmlfile)
        {
            try
            {
                if (!xmlfile.Contains(".xml"))
                {
                    return;
                }

                //Save test data to server
                if (xmlfile.Contains("TxO"))
                {
                    TxOTable dtTxO = new TxOTable();
                    dtTxO.ReadXml("TxOData", xmlfile);
                    //save to excel
                    dtTxO.SaveTableToExcel(xmlfile.Replace("xml", "xls"));

                    Log.SaveLogToTxt("upload test data: " + xmlfile);
                    if (this.UploadTestDataToServer(dtTxO, "select * from my_databases.txo") == true)
                    {
                        try
                        {
                            File.Move(xmlfile, FolderPath.BackupTestDataPath + Path.GetFileName(xmlfile));
                        }
                        catch
                        {
                            MessageBox.Show("移动测试数据到备份文件夹失败,你可以继续测试。");
                        }
                    }
                    dtTxO = null;
                }

                if (xmlfile.Contains("RxO"))
                {
                    RxOTable dtRxO = new RxOTable();
                    dtRxO.ReadXml("RxOData", xmlfile);
                    //save to excel
                    dtRxO.SaveTableToExcel(xmlfile.Replace("xml", "xls"));

                    Log.SaveLogToTxt("upload test data: " + xmlfile);
                    if (this.UploadTestDataToServer(dtRxO, "select * from my_databases.rxo") == true)
                    {
                        try
                        {
                            File.Move(xmlfile, FolderPath.BackupTestDataPath + Path.GetFileName(xmlfile));
                        }
                        catch
                        {
                            MessageBox.Show("移动测试数据到备份文件夹失败,你可以继续测试。");
                        }
                    }
                    dtRxO = null;
                }
            }
            catch
            {
                MessageBox.Show("上传以前未上传的测试数据到数据库失败,请检测网络。当然你也可以离线测试。");
            }
        }
Beispiel #2
0
        public bool ParallelBeginTest()
        {
            try
            {
                Log.SaveLogToTxt("Begin to test...");
                Log.SaveLogToTxt("Power on all equipments.");
                foreach (string key in this.usedEquipments.Keys)
                {
                    this.usedEquipments[key].OutPutSwitch(true);
                }
                Log.SaveLogToTxt("Enable full function for module.");
                dut.FullFunctionEnable();

                Log.SaveLogToTxt("Try to get test condition from server.");
                testItemsObject = new Dictionary <string, ITest>();
                DataTable dataTable_Condition = this.BuildConditionTable();

                //create testdata table
                if (TestPlanParaByPN.ItemName.Contains("TR"))
                {
                    txoTable = new TxOTable();
                    rxoTable = new RxOTable();
                }
                else if (TestPlanParaByPN.ItemName.Contains("TX"))
                {
                    txoTable = new TxOTable();
                }
                else if (TestPlanParaByPN.ItemName.Contains("RX"))
                {
                    rxoTable = new RxOTable();
                }
                else
                {
                    Log.SaveLogToTxt("Test plan is not for function test.");
                }

                string beginTime = DateTime.Now.ToString();

                for (int row = 0; row < dataTable_Condition.Rows.Count; row++)//遍历测试环境条件
                {
                    if (txoTable != null)
                    {
                        //create testdata table new row, set the default value for new row, excepte for ID column
                        drOfTxOTable = txoTable.NewRow();
                        for (int i = 1; i < txoTable.Columns.Count; i++)
                        {
                            drOfTxOTable[i] = Algorithm.MyNaN;
                        }
                    }

                    if (rxoTable != null)
                    {
                        drOfRxOTable = rxoTable.NewRow();
                        for (int i = 1; i < rxoTable.Columns.Count; i++)
                        {
                            drOfRxOTable[i] = Algorithm.MyNaN;
                        }
                    }

                    DataRow dr = dataTable_Condition.Rows[row];
                    ConditionParaByTestPlan.SetValue(dr);

                    Log.SaveLogToTxt("Begin to config environment.");
                    Log.SaveLogToTxt("Temp = " + ConditionParaByTestPlan.Temp + " VCC = " + ConditionParaByTestPlan.VCC.ToString("f3") + " Channel = " + ConditionParaByTestPlan.Channel);
                    //myDataIO.WriterLog(ctrlType_Condition, SNID, "", StrStartTime, StrStartTime, Convert.ToSingle(StrCurrentTemp), Convert.ToSingle(StrCurrentVcc), CurrentChannel, false, out CurrentLogId);
                    if (!this.ConfigEnvironment(ConditionParaByTestPlan.Temp, ConditionParaByTestPlan.VCC, ConditionParaByTestPlan.Channel,
                                                ConditionParaByTestPlan.TempOffset, ConditionParaByTestPlan.TempWaitingTimes, GlobalParaByPN.OverLoadPoint))
                    {
                        Log.SaveLogToTxt("Failed to config environment.");
                        return(false);
                    }
                    ConditionParaByTestPlan.LastTemp = ConditionParaByTestPlan.Temp;

                    Log.SaveLogToTxt("Try to get test model list under this condition.");
                    string table      = "TopoTestModel";
                    string expression = "select B.ItemName,A.*,C.* , A.ID AS TestmodelID,c.ItemName as AppType from  TopoTestModel A,GlobalAllTestModelList B,GlobalAllAppModelList C where C.ID=B.PID AND A.PID="
                                        + ConditionParaByTestPlan.ID + " and A.IgnoreFlag=0  AND A.GID=B.ID order by SEQ ASC";
                    DataTable dataTable_TestItems     = myDataIO.GetDataTable(expression, table);// 获得TestModelList
                    DataTable dataTable_TestItemsPara = GetCurrentConditionPrameter(dataTable_TestItems);
                    if (ConditionParaByTestPlan.CtrlType == 2)
                    {
                        supply.OutPutSwitch(false);
                        supply.OutPutSwitch(true);
                        dut.FullFunctionEnable();
                        //parallel test for FMT
                        Parallel.For(0, dataTable_TestItems.Rows.Count, (int i, ParallelLoopState pls) =>// 遍历Condition中的TestModel
                        {
                            DataRow dr_TestItem         = dataTable_TestItems.Rows[i];
                            string ID_TestItem          = dr_TestItem["TestmodelID"].ToString();
                            string name_TestItem        = dr_TestItem["ItemName"].ToString();
                            string type_TestItem        = dr_TestItem["AppType"].ToString();
                            bool isFailedBreak_TestItem = Convert.ToBoolean(dr_TestItem["Failbreak"]);

                            DataRow[] drs = dataTable_TestItemsPara.Select("TestmodelId='" + ID_TestItem + "'");
                            Dictionary <string, string> inPara_TestItem = new Dictionary <string, string>();
                            Log.SaveLogToTxt("Try to get test parameter for " + name_TestItem + ".");
                            for (int j = 0; j < drs.Length; j++)
                            {
                                inPara_TestItem.Add(drs[j]["ItemName"].ToString().Trim().ToUpper(), drs[j]["ItemValue"].ToString().Trim().ToUpper());
                                Log.SaveLogToTxt(drs[j]["ItemName"].ToString() + " " + drs[j]["ItemValue"].ToString());
                            }
                            Log.SaveLogToTxt("Test " + name_TestItem + "...");
                            if (!RunTestItem(name_TestItem, ID_TestItem, type_TestItem, inPara_TestItem))
                            {
                                //bool result_TestItem = false;
                                //pls.Break();
                            }
                            //GC.Collect();
                        });
                    }
                    else
                    {
                        //onebyone test for adjust
                        for (int i = 0; i < dataTable_TestItems.Rows.Count; i++)// 遍历Condition中的TestModel
                        {
                            DataRow dr_TestItem            = dataTable_TestItems.Rows[i];
                            string  ID_TestItem            = dr_TestItem["TestmodelID"].ToString();
                            string  name_TestItem          = dr_TestItem["ItemName"].ToString();
                            string  type_TestItem          = dr_TestItem["AppType"].ToString();
                            bool    isFailedBreak_TestItem = Convert.ToBoolean(dr_TestItem["Failbreak"]);

                            DataRow[] drs = dataTable_TestItemsPara.Select("TestmodelId='" + ID_TestItem + "'");
                            Dictionary <string, string> inPara_TestItem = new Dictionary <string, string>();
                            Log.SaveLogToTxt("Try to get test parameter for " + name_TestItem + ".");
                            for (int j = 0; j < drs.Length; j++)
                            {
                                inPara_TestItem.Add(drs[j]["ItemName"].ToString(), drs[j]["ItemValue"].ToString());
                                Log.SaveLogToTxt(drs[j]["ItemName"].ToString() + " " + drs[j]["ItemValue"].ToString());
                            }
                            Log.SaveLogToTxt("Test " + name_TestItem + "...");
                            if (!RunTestItem(name_TestItem, ID_TestItem, type_TestItem, inPara_TestItem))
                            {
                                //bool result_TestItem = false;
                            }
                            GC.Collect();
                        }
                    }

                    if (drOfTxOTable != null)
                    {
                        drOfTxOTable["Family"]       = GlobalParaByPN.Family;
                        drOfTxOTable["PartNumber"]   = GlobalParaByPN.PN;
                        drOfTxOTable["SerialNumber"] = TestPlanParaByPN.SN;
                        drOfTxOTable["Channel"]      = ConditionParaByTestPlan.Channel;
                        drOfTxOTable["Temp"]         = ConditionParaByTestPlan.Temp;
                        drOfTxOTable["Station"]      = "TXO";
                        drOfTxOTable["Time"]         = beginTime;
                        drOfTxOTable["Status"]       = 0;
                        txoTable.Rows.Add(drOfTxOTable);
                    }

                    if (drOfRxOTable != null)
                    {
                        drOfRxOTable["Family"]       = GlobalParaByPN.Family;
                        drOfRxOTable["PartNumber"]   = GlobalParaByPN.PN;
                        drOfRxOTable["SerialNumber"] = TestPlanParaByPN.SN;
                        drOfRxOTable["Channel"]      = ConditionParaByTestPlan.Channel;
                        drOfRxOTable["Temp"]         = ConditionParaByTestPlan.Temp;
                        drOfRxOTable["Station"]      = "RXO";
                        drOfRxOTable["Time"]         = beginTime;
                        drOfRxOTable["Status"]       = 0;
                        rxoTable.Rows.Add(drOfRxOTable);
                    }
                    drOfTxOTable = null;
                    drOfRxOTable = null;
                }

                //Save test data to xml file
                if (txoTable != null)
                {
                    txoTable.WriteXml("TxOData", FilePath.TxODataXml);
                }

                if (rxoTable != null)
                {
                    rxoTable.WriteXml("RxOData", FilePath.RxODataXml);
                }
                txoTable = null;
                rxoTable = null;

                foreach (string key in testItemsObject.Keys)
                {
                    if (!testItemsObject[key].SaveTestData())
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                Log.SaveLogToTxt(ex.Message);
                Log.SaveLogToTxt(ex.StackTrace);
                Log.SaveLogToTxt("Failed to test.");
                return(false);
            }
        }