Esempio n. 1
0
        private bool CheckShopFloor()
        {
            bool     flag    = false;
            int      status  = -1;
            DateTime timeNow = DateTime.Now;

            do
            {
                // do something to check shopfloor
                if (this.config.IsOnlineShopfloor)
                {
                    SFC.SFCInit();
                    status = SFC.ReportStatus(this.SerialNumber, 1);

                    if (status == 0)
                    {
                        flag = true;
                        break;
                    }
                }
                else
                {
                    flag = true;
                    break;
                }
            }while (DateTime.Now.Subtract(timeNow).TotalMilliseconds < 5000);

            return(flag);
        }
Esempio n. 2
0
        private void RunSignalSequence()
        {
            //args.PassOrFail = "READY";
            testNum           = 0;
            args.SerialNumber = SerialNumber = "";

            if (!this.config.IsSimulation)
            {
                //args.PassOrFail = "READY";
                //if (this.config.IsScanSerialNumber) {
                //    args.StatusInfo = "Checking SN, please type in 16 digit SN.扫描SN";
                //    while (SerialNumber.Length != SNLength) { Thread.Sleep(100); }
                //}
                args.StatusInfo = "Waitting double-satrt pressed...按双启";
                fixture.CheckDoubleStart();
                fixture.BatteryOn();
            }

            if (mode != TestMode.Manual)
            {
                args.StatusInfo = "Checking DUT";
                while (!dut.CheckDUT())
                {
                    Thread.Sleep(100);
                }                                              // check dut
                log.WriteUartLog(string.Format("DUT connected, DeviceID: {0}\r\n", dut.DeviceID));
            }
            else
            {
                args.StatusInfo = "DUT connected.";
                log.WriteUartLog("DUT connected.");
            }

            IsDutReady = true;

            if (!this.config.IsScanSerialNumber)
            {
                args.StatusInfo = "Checking SN";
                do
                {
                    SerialNumber = dut.GetSerialNumber();
                    Thread.Sleep(100);
                }while (SerialNumber.Length != SNLength);
                args.SerialNumber = SerialNumber;
            }
            else
            {
                if (this.config.IsScanSerialNumber)
                {
                    args.StatusInfo = "Checking SN, please type in 16 digit SN.扫描SN";
                    while (SerialNumber.Length != SNLength)
                    {
                        Thread.Sleep(100);
                    }
                }
            }


            string strProduct = SerialNumber.Substring(6, 2);

            if (strProduct.Equals("78"))
            {
                if (config.ProductType.Equals("Bran") == false)
                {
                    System.Windows.Forms.MessageBox.Show("请检查产品类型是否和选定类型一致!");
                }
            }
            else if (strProduct.Equals("79"))
            {
                if (config.ProductType.Equals("Hodor") == false)
                {
                    System.Windows.Forms.MessageBox.Show("请检查产品类型是否和选定类型一致!");
                }
            }
            log.SerialNumber = SerialNumber;
            log.WriteUartLog(string.Format("Serial number: {0}\r\n", SerialNumber));
            args.StatusInfo = string.Format("Serial number: {0}", SerialNumber);

            // check shopfloor
            args.StatusInfo = "Checking Shopfloor";
            IsShopFlowReady = this.CheckShopFloor();

            if (!IsShopFlowReady)
            {
                args.StatusInfo = "Shopfloor system is not working";
                log.WriteUartLog("Shopfloor system is not working.\r\n");
                System.Windows.Forms.MessageBox.Show("请检查SFC是否打开或者产品是否已经过站!");
            }
            else
            {
                log.WriteUartLog("Shopfloor has connected.\r\n");
                args.StatusInfo = "Testing...";
                args.PassOrFail = "TESTING";

                if (tableDataChange != null)
                {
                    string[] devNames = new string[] { "Camera", "Ca310" };

                    foreach (string dev in devNames)
                    {
                        tableArgs.Index = -1;
                        foreach (TestItem item in tableArgs.Items)
                        {
                            item.TestNodes[0].Value = 0;
                            item.TestNodes[1].Value = 0;
                            item.TestNodes[2].Value = 0;
                            item.TestNodes[3].Value = 0;
                            item.TestNodes[4].Value = 0;
                            item.TestNodes[5].Value = 0;
                            tableArgs.Index++;
                            tableArgs.CurrentDevice = dev;
                            tableDataChange(this, tableArgs);
                        }
                    }
                }

                // run Ca310 if the mode is Ca310Mode
                CA310Datas.Clear();
                TestResult = true;
                this.RunCa310Test();

                DateTime        startTime = DateTime.Now, stopTime;
                List <IntPoint> ptCorners = new List <IntPoint>();


                int          index      = 0;
                const string deviceName = "Camera";

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

                    bool flag = false;

                    if (mode == TestMode.Manual)
                    {
                        if (flagCavus)
                        {
                            colorimeter.PlayVideo();
                        }
                        System.Windows.Forms.MessageBox.Show(string.Format("Please set panel to \"{0}\"", testItem.TestName));
                        flag = true;
                        if (flagCavus)
                        {
                            colorimeter.StopVideo(); Thread.Sleep(1000);
                        }
                    }
                    else
                    {
                        args.StatusInfo = string.Format("Set panel to \"{0}\"", testItem.TestName);
                        flag            = dut.ChangePanelColor(testItem.RGB.R, testItem.RGB.G, testItem.RGB.B);
                    }

                    if (flag)
                    {
                        if (mode != TestMode.Manual)
                        {
                            Thread.Sleep(3000);
                        }

                        colorimeter.Shutter = (float)testItem.Exposure;
                        colorimeter.ConfigCamera(Color.FromName(testItem.TestName));
                        Bitmap bitmap     = new Bitmap(colorimeter.GrabImage());
                        Bitmap bmpDisplay = null;

                        if (testItem.TestName != "White" && testItem.TestName != "Black")
                        {
                            colorimeter.RefushShutter(Color.FromName(testItem.TestName));
                            bmpDisplay = new Bitmap(colorimeter.GrabImage());
                            args.Image = new Bitmap(bmpDisplay);
                        }
                        else
                        {
                            args.Image = new Bitmap(bitmap);
                        }

                        dataChange.Invoke(this, args);
                        TestResult &= this.RunDisplayTest(testItem, bitmap, bmpDisplay, ref ptCorners);

                        if (ptCorners == null || ptCorners.Count == 0)
                        {
                            break;
                        }

                        if (this.config.IsOnlineShopfloor)
                        {
                            UploadItemDataToSFC(testItem, deviceName);
                        }

                        // flush UI
                        if (tableDataChange != null)
                        {
                            tableArgs.CurrentDevice = deviceName;
                            tableArgs.Index         = index++;
                            tableDataChange(this, tableArgs);
                        }
                    }
                    else
                    {
                        args.StatusInfo = string.Format("Can't set panel color to {0}\r\n", testItem.TestName);
                        //dataChange.Invoke(this, args);
                        break;
                    }
                }
                args.StatusInfo = "Test finished.";
                args.PassOrFail = TestResult ? "PASS" : "FAIL";
                dataChange(this, args);
                log.WriteUartLog(string.Format("Test result is {0}\r\n", (TestResult ? "PASS" : "FAIL")));
                log.UartFlush();

                stopTime = DateTime.Now;
                log.WriteCsv(SerialNumber, startTime, stopTime, xml.Items, this.config.ProductType);
                log.writeCSVData(SerialNumber, startTime, stopTime, this.config.ProductType, xml.Items, CA310Datas);
                log.WriteCamareCsv(SerialNumber, startTime, stopTime, this.config.ProductType);

                if (this.config.IsOnlineShopfloor)
                {
                    SFC.CreateResultFile(1, TestResult ? "PASS" : "FAIL");
                }

                if (!this.config.IsSimulation)
                {
                    fixture.HoldOut();
                }
            }
        }