示例#1
0
        public void FocusCalibrate(Action callBack)
        {
            new Action(delegate()
            {
                IntegratingSphere intergrate = (IntegratingSphere)DevManage.Instance.SelectDevice(typeof(IntegratingSphere).Name);

                if (fixture != null)
                {
                    fixture.RotateOff();
                    fixture.IntegratingSphereUp();
                    intergrate.Lighten();
                    fixture.HoldIn();
                    fixture.BatteryOn();
                    while (!dut.CheckDUT())
                    {
                        Thread.Sleep(100);
                    }
                    Thread.Sleep(8000);
                    dut.ChangePanelColor(255, 255, 255);
                    colorimeter.StopVideo();
                }

                if (callBack != null)
                {
                    callBack();
                }
            }).BeginInvoke(null, null);
        }
示例#2
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);
        }