예제 #1
0
        public Engine(Config config)
        {
            this.config      = config;
            this.colorimeter = new Colorimeter();
            this.xml         = new Xml(this.config.ScriptName);

            if (!this.config.IsSimulation)
            {
                this.fixture = new Fixture(this.config.FixturePortName);
                //this.ca310Pipe = new Ca310Pipe(System.Windows.Forms.Application.StartupPath);
                IDevice intergrate = new IntegratingSphere(this.fixture, this.config.LCP3005PortName);
                DevManage.Instance.AddDevice(fixture);
                DevManage.Instance.AddDevice(intergrate);
            }

            dut  = (DUT)Activator.CreateInstance(Type.GetType("DUTclass." + this.config.ProductType));
            mode = (TestMode)Enum.Parse(typeof(TestMode), this.config.TestMode);

            ip              = new imagingpipeline();
            args            = new DataChangeEventArgs();
            tableArgs       = new TableViewEventArgs();
            tableArgs.Items = xml.Items;

            log          = new Testlog();
            SerialNumber = "";

            if (!System.IO.Directory.Exists(IMAGE_SAVE_PATH))
            {
                System.IO.Directory.CreateDirectory(IMAGE_SAVE_PATH);
            }
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
0
 public IntegratingSpherePanel(IntegratingSphere sphere)
 {
     InitializeComponent();
     this.sphere = sphere;
 }
예제 #5
0
 public LuminanceCalibration(KonicaCa310 pipe, Fixture fixture, Colorimeter colorimeter, IntegratingSphere integrate)
 {
     this.ca310Pipe = pipe;
     this.fixture   = fixture;
     this.camera    = colorimeter;
     this.integrate = integrate;
     this.ReadProfile();
 }