Пример #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();
            }
        }
Пример #2
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);
        }
Пример #3
0
 public ColorimeterResult(Bitmap bitmap, ColorPanel panel)
 {
     this.m_bitmap = bitmap;
     this.m_panel  = panel;
     m_pipeline    = new imagingpipeline();
     CIE1931xyY    = new CIE1931Value();
 }
Пример #4
0
        private void LvCalibration(Action callBack)
        {
            try
            {
                fixture.IntegratingSphereUp();
                Thread.Sleep(1000);
                fixture.RotateOn();
                Thread.Sleep(1000);
                CIE1931Value value = ca310Pipe.GetCa310Data();
                fixture.RotateOff();
                Thread.Sleep(1000);

                for (int i = 0; i < 10; i++)
                {
                    colorimeter.ExposureTime = 10 * (i + 1);
                    Bitmap   bitmap  = colorimeter.GrabImage();
                    double[] rgbMean = this.Mean(ip.bmp2rgb(bitmap));

                    if (Math.Abs(rgbMean[0] - 220) < 3 &&
                        Math.Abs(rgbMean[1] - 220) < 3 &&
                        Math.Abs(rgbMean[2] - 220) < 3)
                    {
                        xml.SetWhiteExposure(colorimeter.ExposureTime);
                        break;
                    }
                }

                fixture.IntegratingSphereDown();
                Thread.Sleep(1000);
            }
            catch (Exception ex)
            {
                //  MessageBox.Show(ex.Message);
            }
        }
Пример #5
0
        private void RunCa310Test()
        {
            if (flagCa310Mode)
            {
                Dictionary <string, CIE1931Value> items = new Dictionary <string, CIE1931Value>();
                fixture.RotateOn();
                Thread.Sleep(1000);

                foreach (TestItem testItem in xml.Items)
                {
                    log.WriteUartLog(string.Format("Ca310Mode - Set panel to {0}\r\n", testItem.TestName));

                    if (dut.ChangePanelColor(testItem.TestName))
                    {
                        Thread.Sleep(3000);
                        CIE1931Value cie = ca310Pipe.GetCa310Data();
                        log.WriteUartLog(string.Format("Ca310Mode - CIE1931xyY: {0}\r\n", cie.ToString()));
                        items.Add(testItem.TestName, cie.Copy());
                    }
                    else
                    {
                        args.StatusInfo = string.Format("Can't set panel color to {0}\r\n", testItem.TestName);
                        break;
                    }
                }
                fixture.RotateOff();
                Thread.Sleep(1000);
                log.WriteCa310Log(SerialNumber, items);
            }
        }
Пример #6
0
        // calibrate the xyz
        private void CalibrateXYZ()
        {
            List <double[]> xyzList = new List <double[]>();

            this.ReadRGBConfig();
            fixture.RotateOn(); // ready ca310

            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(1000);
                        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");
        }
Пример #7
0
        public CIE1931Value Copy()
        {
            CIE1931Value cie = new CIE1931Value();

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

            return(cie);
        }
Пример #8
0
        public override void Calibration(float exposure = 0)
        {
            try {
                runExp = exposure;
                fixture.IntegratingSphereUp();
                fixture.RotateOn();
                System.Threading.Thread.Sleep(1000);
                CIE1931Value value = ca310Pipe.GetCa310Data();
                fixture.RotateOff();
                System.Threading.Thread.Sleep(1000);

                do
                {
                    camera.ExposureTime = runExp;
                    System.Drawing.Bitmap bitmap = camera.GrabImage();
                    double[] rgbMean             = this.Mean(this.BitmapToRGB(bitmap));

                    if (rgbMean[0] > 225 || rgbMean[1] > 255 || rgbMean[2] > 255)
                    {
                        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;
                    }
                }while (true);

                fixture.IntegratingSphereDown();
                System.Threading.Thread.Sleep(1000);
            }
            catch (Exception e) {
            }
        }
Пример #9
0
        private void RunTest()
        {
            try
            {
                DateTime startTime, stopTime;
                startTime = DateTime.Now;

                if (m_flagCa310Mode)
                {
                    Dictionary <string, CIE1931Value> items = new Dictionary <string, CIE1931Value>();
                    fixture.RotateOn();
                    Thread.Sleep(1000);
                    foreach (TestItem testItem in xml.Items)
                    {
                        log.WriteUartLog(string.Format("Ca310Mode - Set panel to {0}\r\n", testItem.TestName));

                        if (dut.ChangePanelColor(testItem.TestName))
                        {
                            Thread.Sleep(3000);
                            CIE1931Value cie = ca310Pipe.GetCa310Data();
                            log.WriteUartLog(string.Format("Ca310Mode - CIE1931xyY: {0}\r\n", cie.ToString()));
                            items.Add(testItem.TestName, cie.Copy());
                        }
                        else
                        {
                            string str = string.Format("Can't set panel color to {0}\r\n", testItem.TestName);
                            sslStatus.Text = str;
                            pf             = false;
                            break;
                        }
                    }
                    fixture.RotateOff();
                    Thread.Sleep(1000);
                    log.WriteCa310Log(serialNumber, items);
                }

                foreach (TestItem testItem in xml.Items)
                {
                    log.WriteUartLog(string.Format("Set panel to {0}\r\n", testItem.TestName));

                    if (dut.ChangePanelColor(testItem.TestName))
                    {
                        Thread.Sleep(3000);
                        m_colorimeter.ExposureTime = testItem.Exposure;
                        Bitmap bitmap = m_colorimeter.GrabImage();
                        pf &= this.DisplayTest(displaycornerPoints, bitmap, (ColorPanel)Enum.Parse(typeof(ColorPanel), testItem.TestName));
                        //this.Invoke(new Action<Bitmap, PictureBox>(this.refreshtestimage), bitmap, picturebox_test);
                    }
                    else
                    {
                        string str = string.Format("Can't set panel color to {0}\r\n", testItem.TestName);
                        sslStatus.Text = str;
                        pf             = false;
                        break;
                    }
                }

                if (pf)
                {
                    log.WriteUartLog("Test result is PASS\r\n");
                    this.Invoke(new Action(delegate() {
                        tbox_pf.Visible   = true;
                        tbox_pf.BackColor = Color.Green;
                        tbox_pf.Text      = "Pass";
                    }));
                }
                else
                {
                    log.WriteUartLog("Test result is FAIL\r\n");
                    this.Invoke(new Action(delegate() {
                        tbox_pf.Visible   = true;
                        tbox_pf.BackColor = Color.Red;
                        tbox_pf.Text      = "Fail";
                    }));
                }
                log.UartFlush();

                stopTime = DateTime.Now;
                log.WriteCsv(serialNumber, startTime, stopTime, xml.Items);
                //SFC.CreateResultFile(1, pf ? "PASS" : "FAIL");

                while (dut.checkDUT())
                {
                    this.Invoke(new Action(delegate(){
                        sslStatus.Text = "Please take out DUT.";
                    }));
                    Thread.Sleep(100);

                    if (m_flagExit)
                    {
                        break;
                    }
                }

                tbox_dut_connect.Text      = "TBD";
                tbox_dut_connect.BackColor = Color.FromArgb(224, 224, 224);
                tbox_sn.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }