Exemplo n.º 1
0
        protected override int ResetLoop()
        {
            //load files
            CfgSettings           = Machine.Ins.Settings;
            CfgEnableRelCoordMode = CfgSettings.EnableRelCoordMode;
            Project = MeasureProject.Load(CfgSettings.MeasureProjectFile, typeof(MeasureProjectA)) as MeasureProjectA;
            Project.AssertNoNull(this);

            if (CfgEnableRelCoordMode)
            {
                Platform.AssertPosTeached("FocusOrigin", this);
            }
            Platform.AssertPosTeached("Wait", this);


            //reset vio
            VioMeasureStart.SetVio(this, false);
            VioMeasureFinish.SetVio(this, false);


            //reconnect camera
            try
            {
                Camera.Disconnect();
                var ret = Camera.Connect();
                if (!ret)
                {
                    Log($"{Camera} Connect Error", LogLevel.Error);
                }

                Camera.SwitchProduct(Project.TypeId);
                Log($"{Camera} SwitchProduct {Project.TypeId}");
            }
            catch (Exception ex)
            {
                Log($"{Camera} Server Connect Fail: {ex.Message}", LogLevel.Error);
            }

            //reset platforms
            Platform.EnterAuto(this).Servo();
            Platform.EnterAuto(this).Home();
            Platform.EnterAuto(this).MoveAbs("Wait");
            return(0);
        }
Exemplo n.º 2
0
        protected override int ResetLoop()
        {
            //load files
            CfgSettings = Machine.Ins.Settings;
            Project     = MeasureProject.Load(CfgSettings.MeasureProjectFile, typeof(MeasureProjectA)) as MeasureProjectA;
            Project.AssertNoNull(this);

            Platform.AssertPosTeached("Wait", this);


            //reset vio
            VioMeasureStart.SetVio(this, false);
            VioMeasureFinish.SetVio(this, false);

            var isProductFound = CarrierLoader.IsProductExists();

            if (isProductFound)
            {
                CarrierLoader.ClampVC();
            }
            else
            {
                CarrierLoader.ReleaseVC();
            }


            try
            {
                Product             = new Thermo2ProductA();
                Product.ProductType = Project.ThermoProductType.ToString();
                Product.Description = string.Join("-", new[] { Project.ProductName, CfgSettings.Version });
                Product.SPCItems    = Project.SPCItems;


                //upload data
                if (CfgSettings.Uploader.Enable)
                {
                    //init uploader
                    UploadHelper = DataUploadFactory.Ins.Create(CfgSettings.Uploader.UploaderName, CfgSettings.Uploader);

                    if (UploadHelper == null)
                    {
                        Log($"创建上传模块失败: {CfgSettings.Uploader.UploaderName} 不存在", LogLevel.Error);
                    }
                    else
                    {
                        UploadData();
                    }
                }
            }
            catch (Exception ex)
            {
                Log($"连接FTP ERROR: {ex.Message}", LogLevel.Error);
            }


            //reset
            TestProcessControl.OnTestStartEvent(null);
            MeasureTask = Station.Machine.Find <StationTask>("MeasureTask") as MeasureTask;
            MeasureTask.AssertNoNull(this);
            MeasureTask.WaitResetFinish(this);


            if (isProductFound)
            {
                CarrierLoader.ReleaseVC();
                Station.Machine.Beep();
            }


            //reset platform
            Platform.EnterAuto(this);
            return(0);
        }
Exemplo n.º 3
0
        protected override int RunLoop()
        {
            //start assert
            Platform.AssertAutoMode(this);
            Platform.LocateInPos("Wait");
            Project.AssertNoNull(this);


            //wait start button
            DualStartButton.WaitStart(this, CfgSettings.AutoDryRun);


            //check locate sensor ok
            if (CfgSettings.SensorEnable)
            {
                if (!CarrierLoader.CheckProductSensor())
                {
                    return(0);
                }
            }

            //check fin sensor ok
            if (CfgSettings.FinSensorEnable)
            {
                //select sensor pattern by product
                var    vcSensorPattern     = new[] { true, true, false };
                var    moduleSensorPattern = new[] { true, true, true };
                bool[] sensor;
                if (Project.ThermoProductType == ThermoProductType.VaporChamber)
                {
                    sensor = vcSensorPattern;
                }
                else
                {
                    sensor = moduleSensorPattern;
                }

                if (!FinSensorCheck.CheckByPattern(this, sensor))
                {
                    return(0);
                }
            }


            //create new product, pass to measure task
            Product = new Thermo2ProductA
            {
                ProductType = Project.ThermoProductType.ToString(),
                Description = string.Join("-", new[] { Project.ProductName, CfgSettings.Version }),
                SPCItems    = Project.SPCItems
            };
            Product.ClearSpc();
            MeasureTask.Product = Product;
            Log("TransStart:" + Product, LogLevel.Info);

            TestProcessControl.OnTestStartEvent(Product);
            SetCarrier();
            {
                Platform.MoveAbs("Work");
                VioMeasureStart.SetVio(this);
                {
                    TestProcessControl.OnTestingEvent(Product);
                }
                VioMeasureFinish.WaitVioAndClear(this);
                Platform.MoveAbs("Wait");
            }
            ResetCarrier();


            SaveProductData();
            return(0);
        }
Exemplo n.º 4
0
        protected override int RunLoop()
        {
            //start assert
            Platform.AssertAutoMode(this);
            Platform.LocateInPos("Wait");
            Project.AssertNoNull(this);


            //safe height check
            var safeHeight    = Platform["SafeHeight"]?.Data()[2];
            var productHeight = Project.Height;

            safeHeight = safeHeight - productHeight;

            if (Platform.CurPos[2] > safeHeight)
            {
                Log($"Platform {Platform.Name} Z SAFE Height Error: {Platform.CurPos[2]:F2} > {safeHeight:F2}", LogLevel.Error);
            }


            //wait start
            VioMeasureStart.WaitVioAndClear(this);
            {
                //assert
                Product.AssertNoNull(this);

                //clear client recv buffer
                try
                {
                    var msg1 = Camera.GetResult("result", 1);
                    Log($"RunLoop Start Clear Client Buffer: {msg1}");
                }
                catch (Exception ex)
                {
                    Log($"RunLoop Start Clear Client Buffer Error: {ex.Message}");
                }


                var    isFirst = true;
                PosXYZ lastPos = null;
                int    index   = 0;
                //start measure loop
                foreach (var pos in Project.CapturePos)
                {
                    var newPos = pos;
                    if (CfgEnableRelCoordMode)
                    {
                        //conver FILE POS TO MOVE POS
                        newPos             = new PosXYZ(Platform.GetPos("MOVE", pos.Data()));
                        newPos.Name        = pos.Name;
                        newPos.Description = pos.Description;
                        Log($"EnableRelCoordMode Transform {pos} To {newPos}");
                    }


                    if (newPos.Z > safeHeight)
                    {
                        Log($"{newPos.Z} > Z limit ERROR", LogLevel.Error);
                    }

                    //optimize jump move
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                            Platform.Jump(newPos, 0, zLimit: -12);
                        }
                        else
                        {
                            //select jumpHeight
                            if (newPos.Z < lastPos.Z)
                            {
                                var jumpHeight = -8 + newPos.Z - lastPos.Z;
                                Platform.Jump(newPos, jumpHeight, zLimit: -12);
                            }
                            else
                            {
                                Platform.Jump(newPos, 0, zLimit: -12);
                            }
                        }
                        lastPos = newPos;
                    }

                    //capture
                    index = TriggerCamera(pos, index);

                    if (CfgSettings.QuitOnProductError)
                    {
                        if (Product.Status == ProductStatus.ERROR)
                        {
                            Log($"Quit {Name} Loop On Error: {Product.Error}");
                            break;
                        }
                    }
                }


                //process result
                try
                {
                    if (string.IsNullOrEmpty(Product.Error))
                    {
                        var result  = Camera.GetResult("result");
                        var msgData = result.Split(',');
                        Product.Status = msgData[0] == "OK" ? ProductStatus.OK : ProductStatus.NG;
                        if (msgData.Length > 2)
                        {
                            var spcItems = new List <Tuple <string, double> >();

                            //parse msgData to spcs
                            for (int i = 1; i < msgData.Length; i++)
                            {
                                if (string.IsNullOrEmpty(msgData[i]))
                                {
                                    continue;
                                }

                                var spc = msgData[i].Split(':');
                                if (spc.Length >= 2)
                                {
                                    try
                                    {
                                        var s   = spc[0].Split('_')[1];
                                        var val = double.Parse(spc[1]);
                                        spcItems.Add(new Tuple <string, double>(s, val));

                                        Product.RawData.Add(val);
                                    }
                                    catch (Exception e)
                                    {
                                        Log($"{spc[0]} {spc[1]} SetSpcError:{e.Message}");
                                    }
                                }
                            }

                            //set spc
                            foreach (var s in spcItems)
                            {
                                Product.SetSpcItem(s.Item1, s.Item2);
                            }
                        }
                        Log($"Camera GetResult: {result}");
                    }

                    Product.SetSpcItem("STS", Product.Status == ProductStatus.OK ? 0 : 2);
                }
                catch (Exception ex)
                {
                    Log($"Camera GetResult Exception: {ex.Message}");
                }

                Platform.MoveAbs("Wait");
            }
            //measure finish
            VioMeasureFinish.SetVio(this);
            return(0);
        }