コード例 #1
0
        protected override int RunLoop()
        {
            //in case of manual operations
            Platform.AssertAutoMode(this);

            if (!DoGTCylinder.SetDo(this, true, ignoreOrWaringOrError: true))
            {
                ThrowException($"GT Cylinder SET Fail!");
            }


            //safe height check
            if (Platform.CurPos[2] > 1)
            {
                Log($"{Name} {Platform.Name} Z Height Error: {Platform.CurPos[2]:F2} > 1", LogLevel.Error);
            }

            //read barcode
            VioTransInp.WaitVioAndClear(this);
            {
                var pos = $"Barcode{Project.TypeId}";
                if (Platform.ExistsPos(pos))
                {
                    Platform.Jump(pos, 0);
                    ReadBarcode();
                }
            }
            VioBarcodeFinish.SetVio(this);

            //measure down gt
            VioTransFinish.WaitVioAndClear(this);
            {
                //measure down pos
                MeasureDownGt();

                //reset z axis
                Platform.MoveAbs(2, "Wait");
                Platform.Home(2);

                if (!CfgSettings.Common.OptimizeDownWait)
                {
                    Platform.MoveAbs("Wait", checkLimit: false);
                }
                else
                {
                    Platform.MoveAbs(2, "Wait", checkLimit: false);
                    var pos = $"Barcode{Project.TypeId}";
                    if (Platform.ExistsPos(pos))
                    {
                        Platform.Jump(pos, 0);
                    }

                    Log($"{Platform.Name} Wait At {pos}");
                }
            }
            //set vio finish
            VioMeasureFinish.SetVio(this);

            return(0);
        }
コード例 #2
0
ファイル: MeasureTask.cs プロジェクト: xusongfei/LeadChina
        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);
        }
コード例 #3
0
        protected override int RunLoop()
        {
            //in case of manual operations
            Platform.AssertAutoMode(this);
            Platform.LocateInPos("Wait");


            //check safe height
            var safeHeight = Platform["GtWork"].Data()[2] - Project.Height - 6;

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

            //wait vio start
            VioTransFinish.WaitVioAndClear(this);
            {
                //move wait
                Platform.MoveAbs("Wait");

                //measure up test positions
                bool isFirst = true;
                foreach (var pos in Project.UpTestPositions)
                {
                    //transform gt work
                    var newpos = AddPosOffset(pos);

                    var gtWorkZ = Platform["GtWork"].Data()[2] - Project.Height;
                    var gtWork  = new PosXYZ(Platform.GetPos("P->UP", newpos.Data()))
                    {
                        Z = gtWorkZ
                    };
                    Log($"Transform {pos.Name} {pos.Description} {newpos} To {gtWork}");

                    //move gt work
                    if (isFirst)
                    {
                        isFirst = false;
                        Platform.Jump(gtWork, 0);
                    }
                    else
                    {
                        var maxJumpHeight = -Platform.CurPos[2];
                        if (PlatformJumpHeight < maxJumpHeight)
                        {
                            Log($"{Platform.Name} Jump Height {PlatformJumpHeight} > {maxJumpHeight}", LogLevel.Warning);
                            PlatformJumpHeight = maxJumpHeight + 0.5;
                        }

                        Platform.Jump(gtWork, PlatformJumpHeight);
                    }

                    //read gt raw
                    Thread.Sleep(CfgSettings.Common.GtReadDelay);
                    var gtRaw = GtController?.ReadData();
                    if (gtRaw != null)
                    {
                        Product.RawDataUp.Add(new PosXYZ()
                        {
                            Name        = pos.Name,
                            Description = pos.Description,
                            X           = pos.X,
                            Y           = pos.Y,
                            Z           = gtRaw[0],
                            OffsetX     = gtRaw[0],
                            OffsetZ     = gtWorkZ,
                        });
                    }
                }

                //move wait
                if (Project.UpTestPositions.Count > 0)
                {
                    Platform.Jump("Wait", PlatformJumpHeight);
                }
            }
            //set vio finish
            VioMeasureFinish.SetVio(this);

            return(0);
        }