Esempio n. 1
0
        public void WriteCa310Log(string sn, Dictionary <string, CIE1931Value> items)
        {
            string csvFileName  = "X2DisplayTest_Ca310_" + DateTime.Now.ToString("yyyy-MM-dd") + ".csv";
            string fullFilePath = Path.Combine(strCa310LogPath, csvFileName);

            if (!File.Exists(fullFilePath))
            {
                FileStream stream = File.Create(fullFilePath);
                stream.Close();
            }

            StringBuilder sbStr = new StringBuilder();

            foreach (string key in items.Keys)
            {
                CIE1931Value cie = items[key];
                sbStr.AppendFormat("{0},{1},{2},{3}\r\n", key, cie.x, cie.y, cie.Y);
            }

            using (StreamWriter sw = new StreamWriter(fullFilePath, true))
            {
                sw.WriteLine(string.Format("{0},x,y,Y", sn));
                sw.WriteLine(sbStr.ToString());
                sw.Flush();
                sw.Close();
            }
        }
Esempio n. 2
0
        public CIE1931Value GetCa310Data()
        {
            if (CIE1931xyY == null)
            {
                CIE1931xyY = new CIE1931Value();
            }
            CIE1931xyY.x = CIE1931xyY.y = CIE1931xyY.Y = 0;

            string result = Measure();

            if (errorInfo == "")
            {
                if (!string.IsNullOrEmpty(result))
                {
                    string[] arrayStr = result.Split(new char[] { ',' });

                    if (arrayStr.Length == 3)
                    {
                        CIE1931xyY.Y = double.Parse(arrayStr[0].Substring(3));
                        CIE1931xyY.x = double.Parse(arrayStr[1].Substring(3));
                        CIE1931xyY.y = double.Parse(arrayStr[2].Substring(3));
                    }
                }
            }
            else
            {
                errorInfo = result;
            }


            return(CIE1931xyY);
        }
Esempio n. 3
0
        public CIE1931Value GetCa310Data()
        {
            if (CIE1931xyY == null)
            {
                CIE1931xyY = new CIE1931Value();
            }
            CIE1931xyY.x = CIE1931xyY.y = CIE1931xyY.Y = 0;

            sw.WriteLine("mes");
            string result = sr.ReadLine();

            if (result.Equals("OK"))
            {
                result = sr.ReadLine();

                if (!string.IsNullOrEmpty(result))
                {
                    string[] arrayStr = result.Split(new char[] { ',' });

                    if (arrayStr.Length == 3)
                    {
                        CIE1931xyY.Y = double.Parse(arrayStr[0].Substring(3));
                        CIE1931xyY.x = double.Parse(arrayStr[1].Substring(3));
                        CIE1931xyY.y = double.Parse(arrayStr[2].Substring(3));
                    }
                }
            }
            else
            {
                errorInfo = result;
            }

            return(CIE1931xyY);
        }
Esempio n. 4
0
 public ColorimeterResult(Bitmap bitmap, ColorPanel panel)
 {
     this.m_bitmap = bitmap;
     this.m_panel  = panel;
     m_pipeline    = new imagingpipeline();
     CIE1931xyY    = new CIE1931Value();
 }
Esempio n. 5
0
        public CIE1931Value Copy()
        {
            CIE1931Value cie = new CIE1931Value();

            cie.x = this.x;
            cie.y = this.y;
            cie.Y = this.Y;

            return(cie);
        }
Esempio n. 6
0
        // calibrate the xyz
        private void CalibrateXYZ()
        {
            List <double[]> xyzList = new List <double[]>();

            this.ReadRGBConfig();
            fixture.RotateOff();
            fixture.IntegratingSphereDown();
            fixture.HoldIn();
            fixture.BatteryOn();
            fixture.RotateOn(); // ready ca310
            while (!dut.CheckDUT())
            {
                System.Threading.Thread.Sleep(100);
            }
            System.Threading.Thread.Sleep(10000);

            foreach (int[] rgb in this.rgbList)
            {
                double[] xyz = new double[3];

                if (rgb.Length == 3)
                {
                    if (dut.ChangePanelColor(rgb[0], rgb[1], rgb[2]))
                    {
                        System.Threading.Thread.Sleep(5000);
                        CIE1931Value cie = ca310Pipe.GetCa310Data();
                        xyz[0] = cie.x; xyz[1] = cie.y; xyz[2] = cie.Y;
                        xyzList.Add(xyz);
                    }
                    else
                    {
                        xyz[0] = 0; xyz[1] = 0; xyz[2] = 0;
                        xyzList.Add(xyz);
                    }
                }
            }

            fixture.RotateOff();
            this.WriteMatrixData(xyzList, "xyz");
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
0
        public void LvCalibrate(Action callBack, System.Windows.Forms.PictureBox cavaus)
        {
            float exposure = 4096;
            float runExp   = exposure;
            float maxExp   = exposure;
            float minExp   = 1;

            new Action(delegate()
            {
                IntegratingSphere sphere = (IntegratingSphere)DevManage.Instance.SelectDevice(typeof(IntegratingSphere).Name);

                try
                {
                    if (ca310Hanle == null)
                    {
                        ca310Hanle = new KonicaCa310();
                        ca310Hanle.Initiaze();
                        if (ca310Pipe.ErrorMessage == "")
                        {
                            System.Windows.Forms.MessageBox.Show("Please switch Ca310 to initial mode.");
                            ca310Hanle.Zero();
                            System.Windows.Forms.MessageBox.Show("Please switch Ca310 to measure mode.");
                        }
                    }

                    fixture.HoldOut();
                    fixture.IntegratingSphereUp();
                    sphere.Lighten();
                    System.Windows.Forms.MessageBox.Show("Software will waitting 5 minutes");
                    System.Threading.Thread.Sleep(300000);
                    fixture.RotateOn();
                    // CIE1931Value value = ca310Pipe.GetCa310Data();
                    CIE1931Value value = ca310Hanle.GetCa310Data();

                    fixture.RotateOff();
                    fixture.CameraDown();
                    fixture.MotorMove(150000);
                    System.Threading.Thread.Sleep(26000);

                    foreach (TestItem item in Items)
                    {
                        if (item.RGB == Color.FromArgb(255, 255, 255))
                        {
                            do
                            {
                                colorimeter.ExposureTime     = runExp;
                                System.Drawing.Bitmap bitmap = colorimeter.GrabImage();

                                if (cavaus != null)
                                {
                                    cavaus.Image = System.Drawing.Image.FromHbitmap(bitmap.GetHbitmap());
                                }

                                double[] rgbMean = this.Mean(ip.bmp2rgb(bitmap));

                                if (rgbMean[0] > 230 || rgbMean[1] > 230 || rgbMean[2] > 230)
                                {
                                    maxExp = runExp;
                                    runExp = (runExp + minExp) / 2;
                                }
                                else if (rgbMean[0] < 215 || rgbMean[1] < 215 || rgbMean[2] < 215)
                                {
                                    minExp = runExp;
                                    runExp = (runExp + maxExp) / 2;
                                }
                                else
                                {
                                    optimalExp    = runExp;
                                    item.Exposure = optimalExp;
                                }

                                if (Math.Abs(minExp) == Math.Abs(maxExp))
                                {
                                    throw new Exception("Luminance calibration fail.");
                                }
                            }while (true);
                        }
                        else
                        {
                            double faction = (redWeight * item.RGB.R + greenWeight * item.RGB.G + blueWeight * item.RGB.B) / 255;

                            if (faction == 0)
                            {
                                item.Exposure = 4000;
                            }

                            item.Exposure = (float)(optimalExp / faction);
                        }
                    }

                    if (callBack != null)
                    {
                        callBack();
                    }
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message);
                }
                finally
                {
                    if (sphere != null)
                    {
                        sphere.Lightoff();
                    }

                    if (fixture != null)
                    {
                        fixture.IntegratingSphereDown();
                        fixture.CameraUp();
                        fixture.Reset();
                    }
                    xml.SaveScript();
                }
            }).BeginInvoke(null, null);
        }
Esempio n. 9
0
        public void writeCSVData(string sn, DateTime startTime, DateTime stopTime, string productType, List <TestItem> CameraItems, List <Dictionary <string, CIE1931Value> > Ca310Datas)//
        {
            string csvFileName    = "X2DisplayTest_" + productType + "_" + DateTime.Now.ToString("yyyy-MM-dd") + ".csv";
            string strTestLogPath = strPath_TestLog + "\\" + productType;

            if (!Directory.Exists(strTestLogPath))
            {
                Directory.CreateDirectory(strTestLogPath);
            }

            string fullFilePath = Path.Combine(strTestLogPath, csvFileName);
            bool   flagResult   = true;
            string failItems    = "";

            this.InitCsvDataTitle(fullFilePath, CameraItems);

            StringBuilder nodedata = new StringBuilder();
            StringBuilder data     = new StringBuilder();

            if (string.IsNullOrEmpty(sn))
            {
                data.Append("xxxxxxxxxxxxxxxx");
            }
            else
            {
                data.Append(sn);
            }

            List <TestItem> TempData = new List <TestItem>();

            TempData = CameraItems;
            int index = 0;

            foreach (Dictionary <string, CIE1931Value> CA310Items in Ca310Datas)
            {
                index = 0;
                foreach (string key in CA310Items.Keys)
                {
                    CIE1931Value cie = CA310Items[key];

                    TempData[index].TestNodes[3].Value = cie.x;
                    TempData[index].TestNodes[4].Value = cie.y;
                    TempData[index].TestNodes[5].Value = cie.Y;
                    ++index;
                }
            }

            foreach (TestItem item in TempData)
            {
                foreach (TestNode node in item.TestNodes)
                {
                    if (node.NodeName.Equals(@"luminance") == false && node.NodeName.Equals(@"mura") == false)
                    {
                        bool flag = node.Run();
                        flagResult &= flag;

                        if (!flag)
                        {
                            failItems += string.Format("{0}_{1}", item.TestName, node.NodeName) + ";";
                        }
                        nodedata.AppendFormat("{0},", node.Value);
                    }
                }
            }

            data.AppendFormat(",adminstator,{0},{1},{2:yyyy-MM-dd HH:mm:ss},{3:yyyy-MM-dd HH:mm:ss},",
                              (flagResult ? "PASS" : "FAIL"), failItems, startTime, stopTime);
            data.Append(nodedata.ToString());
            data.AppendLine();

            using (StreamWriter sw = new StreamWriter(fullFilePath, true))
            {
                sw.Write(data.ToString());
                sw.Flush();
                sw.Close();
            }
        }
Esempio n. 10
0
        public override void Calibration(float exposure = 0)
        {
            try {
                runExp = exposure;
                maxExp = exposure;
                fixture.HoldOut();
                integrate.MoveTestPos();
                //System.Windows.Forms.MessageBox.Show("Software will waitting 5 minutes");
                //System.Threading.Thread.Sleep(300000);
                fixture.RotateOn();
                CIE1931Value value = ca310Pipe.GetCa310Data();
                Console.WriteLine(value.ToString());
                fixture.RotateOff();
                fixture.CameraDown();
                fixture.MotorMove(150000);
                System.Threading.Thread.Sleep(26000);

                do
                {
                    camera.ExposureTime = runExp;
                    System.Drawing.Bitmap bitmap = camera.GrabImage();

                    if (this.videoCavaus != null)
                    {
                        this.videoCavaus.Image = System.Drawing.Image.FromHbitmap(bitmap.GetHbitmap());
                    }

                    double[] rgbMean = this.Mean(this.BitmapToRGB(bitmap));

                    if (rgbMean[0] > 230 || rgbMean[1] > 230 || rgbMean[2] > 230)
                    {
                        maxExp = runExp;
                        runExp = (runExp + minExp) / 2;
                    }
                    else if (rgbMean[0] < 215 || rgbMean[1] < 215 || rgbMean[2] < 215)
                    {
                        minExp = runExp;
                        runExp = (runExp + maxExp) / 2;
                    }
                    else
                    {
                        OptimalExposure = runExp;
                        break;
                    }

                    if (Math.Abs(minExp) == Math.Abs(maxExp))
                    {
                        throw new Exception("Luminance calibration fail.");
                    }
                }while (true);
            }
            catch (Exception e) {
                System.Windows.Forms.MessageBox.Show(e.Message);
            }
            finally {
                if (fixture != null)
                {
                    fixture.CameraUp();
                    fixture.Reset();
                }
                if (integrate != null)
                {
                    integrate.MoveReadyPos();
                }
            }
        }