예제 #1
0
        /// <summary>
        /// 获取最新的fiducial mark文件
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        private bool GetMESData(string barcode)
        {
            string filePath = FluProgram.FluidProgram.Current.RuntimeSettings.CustomParam.AmphnolParam.DataMesPathDir;
            string userName = FluProgram.FluidProgram.Current.RuntimeSettings.CustomParam.AmphnolParam.EmarkUserName;
            string password = FluProgram.FluidProgram.Current.RuntimeSettings.CustomParam.AmphnolParam.EmarkPassword;
            //打开共享文件夹映射路径
            string msg;
            //获取当前最新条码文件(可能存在重复取最新的)
            string barcodeFilePath = "";

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

            if (barcodeFilePath.Length < 2)
            {
                MessageBox.Show("未找到" + barcode + "的mes skip文件。");
                return(false);
            }
            string[] textLines;
            FileUtils.ReadLines(barcodeFilePath, out textLines);
            string[]    splitString = { "<SkipMark>", "</SkipMark>" };
            string[]    res         = textLines[0].Split(splitString, StringSplitOptions.RemoveEmptyEntries);
            List <char> chars       = res[0].ToList();

            this.SkipBoards.Clear();
            for (int i = 0; i < chars.Count; i++)
            {
                if (chars[i] == '1')
                {
                    this.SkipBoards.Add(i + 1);
                }
            }
            return(true);
        }
예제 #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);
        }