示例#1
0
    public Plane(Material material, Transform parent, Vector3 size, PlaneParams _planeParams)
    {
        this.planeParams = _planeParams;

        CreateBase(material, parent, size);
    }
        public override void DoCalib()
        {
            OutputStandardHeight = StandardHeight;

            Log("上平台GT高度标定\n----------------------------------------------------------");
            {
                //GT标定高度
                OutputGTCalibPos = Platform1GTCalibPos;
                DataList.Add(OutputGTCalibPos.ToString());

                //标准平面标定
                if (Platform1GTPlaneCalibPos != null)
                {
                    //update z
                    if (Platform1 != null && GtController != null)
                    {
                        bool isFirst = true;

                        foreach (var calibPos in Platform1GTPlaneCalibPos)
                        {
                            //product to up platform
                            var pos = new PosXYZ(calibPos.Data())
                            {
                                Z = Platform1GTCalibPos.Z
                            };
                            if (isFirst)
                            {
                                isFirst = false;
                                Platform1?.EnterAuto(this).Jump(Platform1.GetPos("P->UP", pos.Data()), 0);
                            }
                            else
                            {
                                Platform1?.EnterAuto(this).Jump(Platform1.GetPos("P->UP", pos.Data()), JumpHeight1);
                            }
                            Thread.Sleep(1000);
                            calibPos.Z = GtController.ReadData()[0];
                            DataList.Add(calibPos.ToString());
                        }
                    }

                    var fitplane = PlaneParams.FitPlane(Platform1GTPlaneCalibPos);
                    OutputUpStandardPlane = new PlaneParams()
                    {
                        Normal = fitplane.Normal, Origin = fitplane.Origin
                    };
                    DataList.Add(OutputUpStandardPlane.ToString());
                }
            }

            //复位上平台
            Platform1?.EnterAuto(this).Jump("Wait", JumpHeight1);
            Log("上平台GT高度标定 完成\n----------------------------------------------------------");


            //下GT高度标定

            //复位下平台Z轴
            if (Platform2 != null)
            {
                Platform2.EnterAuto(this).Home(2);
                Platform2.EnterAuto(this).MoveAbs(2, "Wait", checkLimit: false);
            }

            Log("下平台GT1高度标定\n----------------------------------------------------------");
            {
                do_gt2_cy?.SetDo(this, true, ignoreOrWaringOrError: null);
                {
                    //GT1GT2 高度差标定
                    OutputGT1CalibPos = Platform2GT1CalibPos;
                    //update z
                    if (Platform2 != null && GtController != null)
                    {
                        Platform2.EnterAuto(this).Jump(Platform2GT1CalibPos, 0);
                        Thread.Sleep(1000);
                        OutputGT1CalibPos.OffsetZ = GtController.ReadData()[1];
                    }

                    //GT1GT2 高度差标定
                    OutputGT2CalibPos = Platform2GT2CalibPos;
                    //update z
                    if (Platform2 != null && GtController != null)
                    {
                        Platform2.EnterAuto(this).Jump(Platform2GT2CalibPos, JumpHeight2);
                        Thread.Sleep(1000);
                        OutputGT2CalibPos.OffsetZ = GtController.ReadData()[2];
                    }


                    //GT1标准平面标定
                    if (Platform2GT1PlaneCalibPos != null)
                    {
                        //update z
                        if (Platform2 != null && GtController != null)
                        {
                            foreach (var calibPos in Platform2GT1PlaneCalibPos)
                            {
                                //product to up platform
                                var pos = new PosXYZ(calibPos.Data())
                                {
                                    Z = Platform2GT1CalibPos.Z
                                };
                                Platform2.EnterAuto(this).Jump(Platform2.GetPos("P->DOWN1", pos.Data()), JumpHeight2);
                                Thread.Sleep(1000);
                                calibPos.Z = GtController.ReadData()[1];
                                DataList.Add(calibPos.ToString());
                            }
                        }

                        var fitplane = PlaneParams.FitPlane(Platform2GT1PlaneCalibPos);
                        OutputDownStandardPlane = new PlaneParams()
                        {
                            Normal = fitplane.Normal, Origin = fitplane.Origin
                        };
                        DataList.Add(OutputDownStandardPlane.ToString());
                    }

                    //GT2标准平面标定
                    if (Platform2GT2PlaneCalibPos != null)
                    {
                        //update z
                        if (Platform2 != null && GtController != null)
                        {
                            foreach (var calibPos in Platform2GT2PlaneCalibPos)
                            {
                                //product to up platform
                                var pos = new PosXYZ(calibPos.Data())
                                {
                                    Z = Platform2GT2CalibPos.Z
                                };
                                Platform2.EnterAuto(this).Jump(Platform2.GetPos("P->DOWN2", pos.Data()), JumpHeight2);
                                Thread.Sleep(1000);
                                calibPos.Z = GtController.ReadData()[2];
                                DataList.Add(calibPos.ToString());
                            }
                        }

                        var fitplane = PlaneParams.FitPlane(Platform2GT2PlaneCalibPos);
                        OutputDownStandardPlane2 = new PlaneParams()
                        {
                            Normal = fitplane.Normal, Origin = fitplane.Origin
                        };
                        DataList.Add(OutputDownStandardPlane2.ToString());
                    }
                }
                do_gt2_cy?.SetDo(this, false, ignoreOrWaringOrError: null);
            }


            {
                //复位下平台
                //move platform2 wait
                if (Platform2 != null)
                {
                    Platform2.EnterAuto(this).Home(2);
                    Platform2.EnterAuto(this).MoveAbs("Wait", checkLimit: false);
                }
                Log("下平台GT1/2高度标定  完成\n----------------------------------------------------------");
            }

            //output
            DataList.Add(OutputGT1CalibPos.ToString());
            DataList.Add(OutputGT2CalibPos.ToString());
            DataList.Add(OutputStandardHeight.ToString());

            DataList.Add(OutputUpStandardPlane.ToString());
            DataList.Add(OutputDownStandardPlane.ToString());
        }