Ejemplo n.º 1
0
        /// <summary>
        /// Load程序后,第一次加载显示Pattern内容后,拍摄Mark点校正Pattern原点及轨迹命令坐标
        /// </summary>
        /// <param name="patternOldOrigin">Pattern原点被校正前的位置</param>
        /// <param name="coordinateTransformer">根据Mark点拍摄结果生成的坐标校正器</param>
        /// <param name="patternNewOrigin">Pattern原点被校正后的位置</param>
        public override void Correct(PointD patternOldOrigin, CoordinateTransformer coordinateTransformer, PointD patternNewOrigin)
        {
            // 校正前的机械坐标
            PointD pOrigin = (patternOldOrigin.ToSystem() + Origin).ToMachine();
            PointD pHend   = (patternOldOrigin.ToSystem() + HorizontalEnd).ToMachine();
            PointD pVend   = (patternOldOrigin.ToSystem() + VerticalEnd).ToMachine();

            // 校正后的机械坐标
            pOrigin = coordinateTransformer.Transform(pOrigin);
            pHend   = coordinateTransformer.Transform(pHend);
            pVend   = coordinateTransformer.Transform(pVend);
            // 相对系统坐标
            Origin.X        = (pOrigin.ToSystem() - patternNewOrigin.ToSystem()).X;
            Origin.Y        = (pOrigin.ToSystem() - patternNewOrigin.ToSystem()).Y;
            HorizontalEnd.X = (pHend.ToSystem() - patternNewOrigin.ToSystem()).X;
            HorizontalEnd.Y = (pHend.ToSystem() - patternNewOrigin.ToSystem()).Y;
            VerticalEnd.X   = (pVend.ToSystem() - patternNewOrigin.ToSystem()).X;
            VerticalEnd.Y   = (pVend.ToSystem() - patternNewOrigin.ToSystem()).Y;

            foreach (DoCmdLine doCmdLine in DoCmdLineList)
            {
                PointD p = (patternOldOrigin.ToSystem() + doCmdLine.Origin).ToMachine();
                p = coordinateTransformer.Transform(p);
                doCmdLine.Origin.X = (p.ToSystem() - patternNewOrigin.ToSystem()).X;
                doCmdLine.Origin.Y = (p.ToSystem() - patternNewOrigin.ToSystem()).Y;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load程序后,第一次加载显示Pattern内容后,拍摄Mark点校正Pattern原点及轨迹命令坐标
        /// </summary>
        /// <param name="patternOldOrigin">Pattern原点被校正前的位置</param>
        /// <param name="coordinateTransformer">根据Mark点拍摄结果生成的坐标校正器</param>
        /// <param name="patternNewOrigin">Pattern原点被校正后的位置</param>
        public void Correct(PointD patternOldOrigin, CoordinateTransformer coordinateTransformer, PointD patternNewOrigin)
        {
            // 校正前的机械坐标
            PointD pStart = (patternOldOrigin.ToSystem() + Start).ToMachine();
            PointD pEnd   = (patternOldOrigin.ToSystem() + End).ToMachine();

            // 校正后的机械坐标
            pStart = coordinateTransformer.Transform(pStart);
            pEnd   = coordinateTransformer.Transform(pEnd);
            // 相对系统坐标
            Start.X = (pStart.ToSystem() - patternNewOrigin.ToSystem()).X;
            Start.Y = (pStart.ToSystem() - patternNewOrigin.ToSystem()).Y;
            End.X   = (pEnd.ToSystem() - patternNewOrigin.ToSystem()).X;
            End.Y   = (pEnd.ToSystem() - patternNewOrigin.ToSystem()).Y;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load程序后,第一次加载显示Pattern内容后,拍摄Mark点校正Pattern原点及轨迹命令坐标
        /// </summary>
        /// <param name="patternOldOrigin">Pattern原点被校正前的位置</param>
        /// <param name="coordinateTransformer">根据Mark点拍摄结果生成的坐标校正器</param>
        /// <param name="patternNewOrigin">Pattern原点被校正后的位置</param>
        public override void Correct(PointD patternOldOrigin, CoordinateTransformer coordinateTransformer, PointD patternNewOrigin)
        {
            //根据拍照目标位置更新系统坐标
            //if (!this.modelFindPrm.IsUnStandard)
            //{
            //    VectorD v = modelFindPrm.TargetInMachine.ToSystem() - patternNewOrigin.ToSystem();
            //    PosInPattern.X = v.X;
            //    PosInPattern.Y = v.Y;
            //}
            //else
            //{
            //    PointD oldPosMachine = (PosInPattern + patternOldOrigin.ToSystem()).ToMachine();
            //    PointD newPosMachine = coordinateTransformer.Transform(oldPosMachine);
            //    VectorD v = newPosMachine.ToSystem() - patternNewOrigin.ToSystem();
            //    PosInPattern.X = v.X;
            //    PosInPattern.Y = v.Y;
            //}

            // 此时已经传入了坐标校正器和新的pattern原点,可以直接用旧的理论坐标转换为新的理论坐标
            // 语义层使用 TargetInMachine 有风险,可能为null,或是之前的目标值。
            PointD  oldPosMachine = (PosInPattern + patternOldOrigin.ToSystem()).ToMachine();
            PointD  newPosMachine = coordinateTransformer.Transform(oldPosMachine);
            VectorD v             = newPosMachine.ToSystem() - patternNewOrigin.ToSystem();

            PosInPattern.X = v.X;
            PosInPattern.Y = v.Y;
        }
Ejemplo n.º 4
0
        public override void Correct(PointD patternOldOrigin, CoordinateTransformer coordinateTransformer, PointD patternNewOrigin)
        {
            PointD  oldPosMachine = (PosInPattern + patternOldOrigin.ToSystem()).ToMachine();
            PointD  newPosMachine = coordinateTransformer.Transform(oldPosMachine);
            VectorD v             = newPosMachine.ToSystem() - patternNewOrigin.ToSystem();

            this.PosInPattern.X = v.X;
            this.PosInPattern.Y = v.Y;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Load程序后,第一次加载显示Pattern内容后,拍摄Mark点校正Pattern原点及轨迹命令坐标
        /// </summary>
        /// <param name="patternOldOrigin">Pattern原点被校正前的位置</param>
        /// <param name="coordinateTransformer">根据Mark点拍摄结果生成的坐标校正器</param>
        /// <param name="patternNewOrigin">Pattern原点被校正后的位置</param>
        public override void Correct(PointD patternOldOrigin, CoordinateTransformer coordinateTransformer, PointD patternNewOrigin)
        {
            // 校正前的机械坐标
            PointD p1 = (patternOldOrigin.ToSystem() + point1).ToMachine();
            PointD p2 = (patternOldOrigin.ToSystem() + point2).ToMachine();
            PointD p3 = (patternOldOrigin.ToSystem() + point3).ToMachine();

            // 校正后的机械坐标
            p1 = coordinateTransformer.Transform(p1);
            p2 = coordinateTransformer.Transform(p2);
            p3 = coordinateTransformer.Transform(p3);
            // 相对系统坐标
            point1.X = (p1.ToSystem() - patternNewOrigin.ToSystem()).X;
            point1.Y = (p1.ToSystem() - patternNewOrigin.ToSystem()).Y;
            point2.X = (p2.ToSystem() - patternNewOrigin.ToSystem()).X;
            point2.Y = (p2.ToSystem() - patternNewOrigin.ToSystem()).Y;
            point3.X = (p3.ToSystem() - patternNewOrigin.ToSystem()).X;
            point3.Y = (p3.ToSystem() - patternNewOrigin.ToSystem()).Y;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Load程序后,第一次加载显示Pattern内容后,拍摄Mark点校正Pattern原点及轨迹命令坐标
        /// </summary>
        /// <param name="patternOldOrigin">Pattern原点被校正前的位置</param>
        /// <param name="coordinateTransformer">根据Mark点拍摄结果生成的坐标校正器</param>
        /// <param name="patternNewOrigin">Pattern原点被校正后的位置</param>
        public override void Correct(PointD patternOldOrigin, CoordinateTransformer coordinateTransformer, PointD patternNewOrigin)
        {
            // 校正前的机械坐标
            PointD p = (patternOldOrigin.ToSystem() + position).ToMachine();

            // 校正后的机械坐标
            p = coordinateTransformer.Transform(p);
            // 相对系统坐标
            position.X = (p.ToSystem() - patternNewOrigin.ToSystem()).X;
            position.Y = (p.ToSystem() - patternNewOrigin.ToSystem()).Y;
        }
Ejemplo n.º 7
0
        private void correctPoint(PointD point, PointD patternOldOrigin, CoordinateTransformer coordinateTransformer, PointD patternNewOrigin)
        {
            // 校正前的机械坐标
            PointD pMachine = (patternOldOrigin.ToSystem() + point).ToMachine();

            // 校正后的机械坐标
            pMachine = coordinateTransformer.Transform(pMachine);
            // 相对系统坐标
            point.X = (pMachine.ToSystem() - patternNewOrigin.ToSystem()).X;
            point.Y = (pMachine.ToSystem() - patternNewOrigin.ToSystem()).Y;
        }
Ejemplo n.º 8
0
 /// <summary>
 /// 编程界面校准
 /// </summary>
 /// <param name="patternOldOrigin"></param>
 /// <param name="coordinateTransformer"></param>
 /// <param name="patternNewOrigin"></param>
 public void Correct(PointD patternOldOrigin, CoordinateTransformer coordinateTransformer, PointD patternNewOrigin)
 {
     foreach (PointD item in this.symbolPoints)
     {
         // 校正前的机械坐标
         PointD newPoint = (patternOldOrigin.ToSystem() + item).ToMachine();
         // 校正后的机械坐标
         newPoint = coordinateTransformer.Transform(newPoint);
         // 相对系统坐标
         item.X = (newPoint.ToSystem() - patternNewOrigin.ToSystem()).X;
         item.Y = (newPoint.ToSystem() - patternNewOrigin.ToSystem()).Y;
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Load程序后,第一次加载显示Pattern内容后,拍摄Mark点校正Pattern原点及轨迹命令坐标
        /// </summary>
        /// <param name="patternOldOrigin">Pattern原点被校正前的位置</param>
        /// <param name="coordinateTransformer">根据Mark点拍摄结果生成的坐标校正器</param>
        /// <param name="patternNewOrigin">Pattern原点被校正后的位置</param>
        public override void Correct(PointD patternOldOrigin, CoordinateTransformer coordinateTransformer, PointD patternNewOrigin)
        {
            // 校正前的机械坐标
            PointD pStart  = (patternOldOrigin.ToSystem() + start).ToMachine();
            PointD pMiddle = (patternOldOrigin.ToSystem() + middle).ToMachine();
            PointD pEnd    = (patternOldOrigin.ToSystem() + end).ToMachine();
            PointD pCenter = (patternOldOrigin.ToSystem() + center).ToMachine();

            // 校正后的机械坐标
            pStart  = coordinateTransformer.Transform(pStart);
            pMiddle = coordinateTransformer.Transform(pMiddle);
            pEnd    = coordinateTransformer.Transform(pEnd);
            pCenter = coordinateTransformer.Transform(pCenter);
            // 相对系统坐标
            start.X  = (pStart.ToSystem() - patternNewOrigin.ToSystem()).X;
            start.Y  = (pStart.ToSystem() - patternNewOrigin.ToSystem()).Y;
            middle.X = (pMiddle.ToSystem() - patternNewOrigin.ToSystem()).X;
            middle.Y = (pMiddle.ToSystem() - patternNewOrigin.ToSystem()).Y;
            end.X    = (pEnd.ToSystem() - patternNewOrigin.ToSystem()).X;
            end.Y    = (pEnd.ToSystem() - patternNewOrigin.ToSystem()).Y;
            center.X = (pCenter.ToSystem() - patternNewOrigin.ToSystem()).X;
            center.Y = (pCenter.ToSystem() - patternNewOrigin.ToSystem()).Y;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 校正本级Pattern,且递归校正子Pattern
        /// </summary>
        /// <param name="pattern"></param>
        /// <param name="patternOldOrigin"></param>
        /// <param name="patternNewOrigin"></param>
        /// <param name="coordinateTransformer"></param>
        public void correctPatternRecursive(Pattern pattern, PointD patternOldOrigin, PointD patternNewOrigin, CoordinateTransformer coordinateTransformer)
        {
            // 校正轨迹命令坐标
            foreach (CmdLine cmdLine in pattern.CmdLineList)
            {
                cmdLine.Correct(patternOldOrigin, coordinateTransformer, patternNewOrigin);
            }

            // 校正子Pattern的原点
            foreach (var child in pattern.getChildren())
            {
                PointD childOldOriginPos = new PointD(child.GetOriginPos());
                PointD childNewOriginPos = coordinateTransformer.Transform(childOldOriginPos);
                // Pattern原点为相对Workpiece的系统坐标
                child.Origin.X = (childNewOriginPos.ToSystem() - pattern.Program.Workpiece.GetOriginSys()).X;
                child.Origin.Y = (childNewOriginPos.ToSystem() - pattern.Program.Workpiece.GetOriginSys()).Y;
                List <MarkCmdLine> childMarks = child.GetMarkCmdLines();
                // 有Mark的拼版只校准拼版原点位置和拼版Mark的拍照位置
                if (childMarks.Count > 0)
                {
                    foreach (MarkCmdLine item in childMarks)
                    {
                        PointD  oldPosInMachine = item.PosInPattern + childOldOriginPos;
                        PointD  newPosInMachine = coordinateTransformer.Transform(oldPosInMachine);
                        VectorD v = newPosInMachine - childNewOriginPos;
                        item.PosInPattern.X = v.X;
                        item.PosInPattern.Y = v.Y;
                    }
                }
                else
                {
                    // 递归校正子Pattern
                    correctPatternRecursive(child, childOldOriginPos, childNewOriginPos, coordinateTransformer);
                }
            }
        }
Ejemplo n.º 11
0
        public override void Correct(PointD patternOldOrigin, CoordinateTransformer coordinateTransformer, PointD patternNewOrigin)
        {
            PointD  oldPosMachine = (PosInPattern + patternOldOrigin.ToSystem()).ToMachine();
            PointD  newPosMachine = coordinateTransformer.Transform(oldPosMachine);
            VectorD v             = newPosMachine.ToSystem() - patternNewOrigin.ToSystem();

            this.PosInPattern.X = v.X;
            this.PosInPattern.Y = v.Y;
            if (this.MeasureContent.HasFlag(MeasureContents.GlueHeight) && this.MeasureHeightCmdLines != null && this.MeasureHeightCmdLines.Count == 2)
            {
                foreach (var item in this.MeasureHeightCmdLines)
                {
                    item.Correct(patternOldOrigin, coordinateTransformer, patternNewOrigin);
                }
            }
        }
Ejemplo n.º 12
0
        private PointD CalcuDotsCenter(List <DotCmdLine> dotCmdLines)
        {
            //double
            if (dotCmdLines.Count < 2)
            {
                return(null);
            }
            PointD center = new PointD();
            PointD org1   = dotCmdLines[0].OrgOffset;
            PointD real1  = dotCmdLines[0].Position;
            PointD org2   = dotCmdLines[1].OrgOffset;
            PointD real2  = dotCmdLines[1].Position;

            CoordinateTransformer transformer = new CoordinateTransformer();

            transformer.SetMarkPoint(org1, org2, real1, real2);
            center = transformer.Transform(new PointD(0, 0));
            return(center);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 根据拍照得到Workpiece1 和Workpiece2,将patternMarksZero 转换为实际位置
        /// </summary>
        /// <param name="marks"></param>
        public bool TransPoint(List <MarkCmd> marks)
        {
            if (marks.Count != 2)
            {
                MessageBox.Show("校正文件mark必须两个mark点");
                return(false);
            }
            try
            {
                this.patternMarksTransed.Clear();
                this.workpieceMark1Transed          = (ResultAmphnol)this.workpieceMark1Zero.Clone();
                this.workpieceMark1Transed.position = marks[0].ModelFindPrm.TargetInMachine;

                this.workpieceMark2Transed          = (ResultAmphnol)this.workpieceMark2Zero.Clone();
                this.workpieceMark2Transed.position = marks[1].ModelFindPrm.TargetInMachine;

                this.workPieceMark1 = marks[0].ModelFindPrm.TargetInMachine.Clone() as PointD;
                this.workPieceMark2 = marks[1].ModelFindPrm.TargetInMachine.Clone() as PointD;

                CoordinateTransformer transformer = new CoordinateTransformer();
                //根据拍照的workpiece Mark校正所有的 pattern Mark的点位
                transformer.SetMarkPoint(this.workpieceMark1Zero.position, this.workpieceMark2Zero.position, this.workPieceMark1, this.workPieceMark2);

                foreach (ResultAmphnol item in this.patternMarksZero)
                {
                    ResultAmphnol amphnol = (ResultAmphnol)item.Clone();
                    amphnol.position = transformer.Transform(amphnol.position);
                    this.patternMarksTransed.Add(amphnol);
                }
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Load程序后,第一次加载显示Pattern内容后,拍摄Mark点校正Pattern原点及轨迹命令坐标
        /// </summary>
        /// <param name="pattern"></param>
        /// <param name="onStart"></param>
        /// <param name="onFinished"></param>
        /// <param name="onError"></param>
        /// <param name="mustCorrect">必须校正,即使NeedMarkCorrect为false</param>
        /// <returns>-1:执行失败,1:不需要校正,0:校正成功</returns>
        public int Correct(Pattern pattern)
        {
            if (pattern == null)
            {
                Log.Print(TAG, "pattern is null.");
                return(-1);
            }

            //if (!pattern.NeedMarkCorrect)
            //{
            //    Log.Print(TAG, "pattern NeedMarkCorrect : false");
            //    return 1;
            //}
            var tuple        = this.getMarksRecursive(pattern);
            var markCmdLines = tuple.Item2;

            if (markCmdLines.Count <= 0)
            {
                return(1);
            }
            //if (pattern.GetMarkCmdLines().Count <= 0)
            //{
            //    Log.Print(TAG, "pattern marks count : 0");
            //    return 1;
            //}

            // 拍摄Mark点
            Result ret = Result.OK;

            foreach (MarkCmdLine markCmdLine in markCmdLines)
            {
                ret = executeMark(tuple.Item1, markCmdLine);
                if (!ret.IsOk)
                {
                    return(-1);
                }
            }

            // 生成坐标校正器
            CoordinateTransformer coordinateTransformer = new CoordinateTransformer();

            if (markCmdLines.Count == 1)
            {
                if (markCmdLines[0].ModelFindPrm.IsUnStandard)
                {
                    PointD p     = new PointD(markCmdLines[0].ModelFindPrm.ReferenceX, markCmdLines[0].ModelFindPrm.ReferenceY);
                    PointD refXY = (p + tuple.Item1.GetOriginSys()).ToMachine();

                    if (markCmdLines[0].ModelFindPrm.UnStandardType == 0)
                    {
                        coordinateTransformer.SetMarkPoint(refXY, markCmdLines[0].ModelFindPrm.ReferenceA,
                                                           markCmdLines[0].ModelFindPrm.TargetInMachine, markCmdLines[0].ModelFindPrm.Angle);
                    }
                    else
                    {
                        PointD p2     = new PointD(markCmdLines[0].ModelFindPrm.ReferenceX2, markCmdLines[0].ModelFindPrm.ReferenceY2);
                        PointD refXY2 = (p2 + tuple.Item1.GetOriginSys()).ToMachine();
                        coordinateTransformer.SetMarkPoint(refXY, refXY2,
                                                           markCmdLines[0].ModelFindPrm.TargetInMachine, markCmdLines[0].ModelFindPrm.TargetInMachine2);
                    }
                }
                else
                {
                    coordinateTransformer.SetMarkPoint(
                        markCmdLines[0].ModelFindPrm.PosInMachine,
                        markCmdLines[0].ModelFindPrm.TargetInMachine);
                }
            }
            else if (markCmdLines.Count == 2)
            {
                coordinateTransformer.SetMarkPoint(
                    markCmdLines[0].ModelFindPrm.PosInMachine,
                    markCmdLines[1].ModelFindPrm.PosInMachine,
                    markCmdLines[0].ModelFindPrm.TargetInMachine,
                    markCmdLines[1].ModelFindPrm.TargetInMachine);
            }


            // 校正Pattern原点
            PointD patternOldOrigin = new PointD(pattern.GetOriginPos());
            PointD patternNewOrigin = coordinateTransformer.Transform(patternOldOrigin);

            if (pattern is Workpiece)
            {//workpiece原点为机械坐标
                Workpiece w = pattern as Workpiece;
                w.OriginPos.X = patternNewOrigin.X;
                w.OriginPos.Y = patternNewOrigin.Y;
                FluidProgram.Current.GetWorkPieceCmdLine().Origin.X = w.OriginPos.X;
                FluidProgram.Current.GetWorkPieceCmdLine().Origin.Y = w.OriginPos.Y;
            }
            else
            {//Pattern原点为相对workpiece的系统坐标
                VectorD v = patternNewOrigin.ToSystem() - pattern.Program.Workpiece.GetOriginPos().ToSystem();
                pattern.Origin.X = v.X;
                pattern.Origin.Y = v.Y;
            }

            //// 校正轨迹命令坐标
            //foreach (CmdLine cmdLine in pattern.CmdLineList)
            //{
            //    cmdLine.Correct(patternOldOrigin, coordinateTransformer, patternNewOrigin);
            //}

            //// 校正子Pattern的原点
            //foreach (var item in pattern.Children)
            //{
            //    PointD newOriginPos = coordinateTransformer.Transform(item.GetOriginPos());
            //    // Pattern原点为相对Workpiece的系统坐标
            //    item.Origin.X = (newOriginPos.ToSystem() - pattern.Program.Workpiece.GetOriginSys()).X;
            //    item.Origin.Y = (newOriginPos.ToSystem() - pattern.Program.Workpiece.GetOriginSys()).Y;
            //}

            correctPatternRecursive(pattern, patternOldOrigin, patternNewOrigin, coordinateTransformer);

            //pattern.NeedMarkCorrect = false;
            return(0);
        }