private bool RunDisplayTest(TestItem testItem, Bitmap bitmap, Bitmap bmpDisp, ref List <IntPoint> ptCorners) { string imageName = string.Format("{0}{1}_{2:yyyyMMddHHmmss}_{3}.bmp", IMAGE_SAVE_PATH, SerialNumber, DateTime.Now, testItem.TestName); if (testItem.RGB == Color.FromArgb(255, 255, 255)) { //Process Image to 1bpp to increase SNR Bitmap m_orig = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.PixelFormat.Format1bppIndexed); // only support the 32bppArgb for Aforge Blob Counter Bitmap processbmp = m_orig.Clone(new Rectangle(0, 0, m_orig.Width, m_orig.Height), System.Drawing.Imaging.PixelFormat.Format32bppArgb); ip.GetDisplayCornerfrombmp(processbmp, out ptCorners); } if (ptCorners == null) { return(false); } // save original image // bitmap: the first bitmap, bmpDisp: the second bitmap. if (bmpDisp == null) { bmpDisp = bitmap; } bmpDisp.Save(imageName); // cropping screen image Bitmap srcimg = new Bitmap(System.Drawing.Image.FromFile(imageName, true)); Bitmap updateimg = CroppingImage((Bitmap)srcimg.Clone(), ptCorners); args.Image = updateimg; dataChange.Invoke(this, args); // 截取区域图像 Bitmap cropimg = ip.croppedimage(srcimg, ptCorners, dut.ui_width, dut.ui_height); cropimg.Save(imageName + "_cropped.bmp"); args.Image = new Bitmap(cropimg); dataChange.Invoke(this, args); Bitmap bmpCroping = null; if (bmpDisp != bitmap) { bmpCroping = ip.croppedimage(bitmap, ptCorners, dut.ui_width, dut.ui_height); } else { bmpCroping = cropimg; } // anaylse ColorimeterResult colorimeterRst = new ColorimeterResult(bmpCroping, cropimg); colorimeterRst.Analysis(ref testItem, dut); //if (this.config.IsOnlineShopfloor) //{ // UploadItemDataToSFC(testItem, "Camera"); //} this.DrawZone(cropimg, testItem.TestName); return(testItem.RunUnifAndMura()); //testItem.Run(); }
private void UploadItemDataToSFC(TestItem testItem, string testDevice) /////upSFC { string path = @"C:\eBook_Test\1_WIP_INFO.txt"; using (StreamReader sw = new StreamReader(path)) { sw.ReadLine(); sw.ReadLine(); string readTemp = sw.ReadLine().Trim(); //string readTemp = sw.ReadToEnd().ToString(); sw.Close(); int wipIndex = readTemp.IndexOf(@"WIP_ID="); if (readTemp.Contains("WIP_ID=")) { string wipID = readTemp.Substring(7); dataPath = @"C:\eBook_Test\" + wipID + ".txt"; } if (File.Exists(dataPath) == false) { FileStream stream = File.Create(dataPath); stream.Close(); } } int indexStart = 0, indexEnd = testItem.TestNodes.Count; string name = null; string passfail = "PASS", upperStr = "", lowerStr = ""; if (testDevice == "Camera") { indexStart = 1; indexEnd = 2; } else if (testDevice == "Ca310") { indexStart = 3; indexEnd = testItem.TestNodes.Count; } for (int i = indexStart; i < indexEnd; i++) { ++testNum; name = string.Format("{0}_{1}[{2}]", testItem.TestName, testItem.TestNodes[i].NodeName, testDevice); passfail = testItem.TestNodes[i].Result ? "PASS" : "FAIL"; upperStr = (testItem.TestNodes[i].Upper == double.NaN) ? "_" : testItem.TestNodes[i].Upper.ToString(); lowerStr = (testItem.TestNodes[i].Lower == double.NaN) ? "_" : testItem.TestNodes[i].Lower.ToString(); // int nFlag = SFC.AddTestLog(1, (uint)i, name, upperStr, lowerStr, testItem.TestNodes[i].Value.ToString(), passfail); //int nFlag = SFC.AddTestLog(1, (uint)testNum, name, testItem.TestNodes[i].Value.ToString(), upperStr, lowerStr, passfail); //if (nFlag != 0) //{ // args.StatusInfo = "Fail to upload SFC."; //} string line = string.Format("TEST_ITEM_{0:D2}={1}^{2}^{3}^{4}^{5}^{6}", testNum, name, name, testItem.TestNodes[i].Value.ToString(), upperStr, lowerStr, passfail); // string filePath = @"C:\eBook_Test\1_WIP_INFO.txt"; using (StreamWriter sw = new StreamWriter(dataPath, true)) { sw.WriteLine(line.ToString()); sw.Flush(); sw.Close(); } } /* * for (int i = indexStart; i < indexEnd; i++) * { * name = string.Format("{0}_{1}[{2}]", testItem.TestName, testItem.TestNodes[0].NodeName, testDevice); * passfail = testItem.TestNodes[i].Result ? "PASS" : "FAIL"; * upperStr = (testItem.TestNodes[1].Upper == double.NaN) ? "_" : testItem.TestNodes[1].Upper.ToString(); * lowerStr = (testItem.TestNodes[2].Lower == double.NaN) ? "_" : testItem.TestNodes[2].Lower.ToString(); * * // int nFlag = SFC.AddTestLog(1, (uint)i, name, upperStr, lowerStr, testItem.TestNodes[i].Value.ToString(), passfail); * * // if (nFlag != 0) * { * args.StatusInfo = "Fail to upload SFC."; * } * }*/ }
private void RunCa310Test() { if (mode == TestMode.Ca310) { int index = 0; const string deviceName = "Ca310"; Dictionary <string, CIE1931Value> items = new Dictionary <string, CIE1931Value>(); if (!this.config.IsSimulation) { fixture.RotateOn(); } for (int i = 0; i < xml.Items.Count; i++) { TestItem testItem = xml.Items[i]; log.WriteUartLog(string.Format("Ca310Mode - Set panel to {0}\r\n", testItem.TestName)); if (dut.ChangePanelColor(testItem.RGB.R, testItem.RGB.G, testItem.RGB.B)) { Thread.Sleep(3000); CIE1931Value cie = ca310Hanle.GetCa310Data(); if (ca310Hanle.ErrorMessage != "") { args.StatusInfo = ca310Hanle.ErrorMessage; } log.WriteUartLog(string.Format("Ca310Mode - CIE1931xyY: {0}\r\n", cie.ToString())); testItem.TestNodes[3].Value = cie.x; testItem.TestNodes[4].Value = cie.y; testItem.TestNodes[5].Value = cie.Y; items.Add(testItem.TestName, cie.Copy()); TestResult &= testItem.RunCa310(); // flush UI if (tableDataChange != null) { tableArgs.CurrentDevice = deviceName; tableArgs.Index = index++; tableDataChange(this, tableArgs); } if (this.config.IsOnlineShopfloor && cie.x > 0) // debug { UploadItemDataToSFC(testItem, deviceName); } } else { args.StatusInfo = string.Format("Can't set panel color to {0}\r\n", testItem.TestName); break; } } if (!this.config.IsSimulation) { fixture.RotateOff(); } CA310Datas.Add(items); log.WriteCa310Log(SerialNumber, items); } }
public FeaturePanel(TestItem item) { InitializeComponent(); this.testItem = item; }