Esempio n. 1
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. 2
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();
                }
            }
        }