Beispiel #1
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);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Emark 数据
        /// </summary>
        /// <param name=""></param>
        private bool GetEmarkData(string barcode)
        {
            string filePath = FluProgram.FluidProgram.Current.RuntimeSettings.CustomParam.AmphnolParam.DataEmarkPathDir;
            string userName = FluProgram.FluidProgram.Current.RuntimeSettings.CustomParam.AmphnolParam.EmarkUserName;
            string password = FluProgram.FluidProgram.Current.RuntimeSettings.CustomParam.AmphnolParam.EmarkPassword;
            //打开共享文件夹映射路径
            string msg;
            //获取当前最新条码文件(可能存在重复取最新的)
            string barcodeFilePath = "";

            try
            {
                barcodeFilePath = GetBarcodeFilePath(barcode, filePath);
            }
            catch (Exception)
            {
                // 连接不上再重新连接
                int status = WNetConnection.DosConnect(filePath, userName, password, out msg);
                if (status != 0 && status != 1219)
                {
                    MessageBox.Show(msg);
                    return(false);
                }
                barcodeFilePath = GetBarcodeFilePath(barcode, filePath);
            }

            if (barcodeFilePath.Length < 2)
            {
                MessageBox.Show("未找到" + barcode + "的fiducial mark文件。");
                return(false);
            }
            string[] textLines;
            FileUtils.ReadLines(barcodeFilePath, out textLines);
            //将解析的pattern点位
            List <ResultAmphnol> patternMarks   = new List <ResultAmphnol>();
            ResultAmphnol        workpieceMark1 = new ResultAmphnol();
            ResultAmphnol        workpieceMark2 = new ResultAmphnol();

            patternMarks.Clear();
            foreach (string line in textLines)
            {
                string[] res = line.Split(',');
                if (res.Length > 3) // 第一行不要
                {
                    continue;
                }
                ResultAmphnol amphnol = new ResultAmphnol();
                amphnol.lable = res[0];
                double x, y;
                x = double.Parse(res[1]);
                y = double.Parse(res[2]);
                amphnol.position = new PointD(x, y);
                patternMarks.Add(amphnol);
                if (amphnol.lable.Contains("P1"))
                {
                    workpieceMark1 = amphnol;
                }
                if (amphnol.lable.Contains("P2"))
                {
                    workpieceMark2 = amphnol;
                }
            }
            //都减去workpieceMark1 的坐标
            this.patternMarksZero.Clear();
            if (workpieceMark1 == null || workpieceMark2 == null)
            {
                MessageBox.Show("解析共享坐标文件错误");
                return(false);
            }

            if (Math.Abs(workpieceMark1.position.X) > 450 || Math.Abs(workpieceMark2.position.X) > 450 || Math.Abs(workpieceMark1.position.Y) > 900 || Math.Abs(workpieceMark2.position.Y) > 900)
            {
                MessageBox.Show("获取治具Mark坐标异常,请检查fiducial-mark数据");
                return(false);
            }

            this.workpieceMark1Zero          = (ResultAmphnol)workpieceMark1.Clone();
            this.workpieceMark1Zero.position = PointZeroRel(workpieceMark1.position, workpieceMark1.position);
            this.workpieceMark2Zero          = (ResultAmphnol)workpieceMark2.Clone();
            this.workpieceMark2Zero.position = PointZeroRel(workpieceMark1.position, workpieceMark2.position);
            foreach (ResultAmphnol item in patternMarks)
            {
                ResultAmphnol amphnol = (ResultAmphnol)item.Clone();
                amphnol.position = PointZeroRel(workpieceMark1.position, amphnol.position);
                this.patternMarksZero.Add(amphnol);
            }
            return(true);
        }