zoukankan      html  css  js  c++  java
  • PCB 电测试--测试点数自动输出到流程指示中(读取TGZ Stephdr文件)

    好不容易实现了 《PCB 无需解压,直接读取Genesis TGZ指定文件 》

    正好这里有一项需求:PCB电测试--测试点数自动输出到流程指示中

    一.自动输出测试点小结;

        1.由于历史原因;各工厂差异,测试点数统计单位差异,有的工厂为PCS计算测试点,有些工厂一年前是按PCS计算测试点,而最新测试点是以PNL计算;

            而流程指示中统一为PNL为测试点单位统计,在制作前,要识别此坑,不要往里面跳了。

        2.另一个,有些客户来的CAM资料是Set为单位,工程CAM制作时是不会再拆为PCS作业,而之前的规则是以PCS计算测试点的,而此测试点数是以SET计算测试点,

           而转为PNL测试点时,无法准确测试点数的单位到底是SET还是PCS,可能导致转为PNL测试点错误。

        3.基于以上2点问题,解决方法是:读取TGZ  Stephdr拼板及工程标准命名规范识别PNL中拼了多少个SET,多少个PCS。计算出转换值。

    二.读取TGZ  Stephdr文件

            /// <summary>
            /// 读取stephdr
            private void readStephdr()
            {
                Dictionary<string, List<STEP_REPEAT>> dicStepRepeat = new Dictionary<string, List<STEP_REPEAT>>();
                string tarFilePath = @"F:2p00802ya0.tgz";
                string FileName = Path.GetFileNameWithoutExtension(tarFilePath);
                string FindDir = $@"{FileName}/steps/";  //以/斜杆结尾为文件夹
                using (Stream stream = File.OpenRead(tarFilePath))
                {
                    IReader reader = ReaderFactory.Open(stream);
                    while (reader.MoveToNextEntry())
                    {
                        Match matchresult = Regex.Match(reader.Entry.Key, $@"^{FindDir}([ws]+)/stephdr$");
                        if (matchresult.Success)
                        {
                            string StepName = matchresult.Groups[1].Value;
                            using (EntryStream st = reader.OpenEntryStream())
                            {
                                byte[] byData = new byte[reader.Entry.Size];
                                st.Read(byData, 0, byData.Length);
                                string STEP_REPEAT_txt = System.Text.Encoding.Default.GetString(byData);
                                List<STEP_REPEAT> STEP_REPEATlist = Info2STEP_REPEAT(STEP_REPEAT_txt);
                                dicStepRepeat.Add(StepName, STEP_REPEATlist);
                            }
                        }
                    }
                }
                List<STEP_REPEAT> STEP_REPEATpnl = new List<STEP_REPEAT>();
                if (dicStepRepeat.ContainsKey("pnl"))
                {
                    STEP_REPEATpnl = dicStepRepeat["pnl"];
                    getAllChild_STEP_REPEAT(STEP_REPEATpnl, dicStepRepeat);
                }
                int count_ = getStepCount(STEP_REPEATpnl, ".*", false);
            }
            /// <summary>
            /// 获取PNL中有多个拼板个数
            /// </summary>
            /// <param name="STEP_REPEATpnl">PNL STEP_REPEAT信息</param>
            /// <param name="Fillter">过滤Step名</param>
            /// <param name="NotRecursion">是否递归深入搜索</param>
            /// <returns></returns>
            public int getStepCount(List<STEP_REPEAT> STEP_REPEATpnl, string Fillter = "(cam|set|flip).*", bool NotRecursion = false)
            {
                if (STEP_REPEATpnl == null || STEP_REPEATpnl.Count == 0)
                    return 1;
                int SumCount = 0;
                foreach (var item in STEP_REPEATpnl)
                {
                    if (Regex.IsMatch(item.NAME, Fillter))
                    {
                        if (NotRecursion)
                            SumCount += item.NX * item.NX;
                        else
                            SumCount += item.NX * item.NX * getStepCount(item.STEP_REPEAT_List, Fillter);
                    }
                }
                return SumCount;
            }
            /// <summary>
            /// 获取PNL做为父节点 获取拼板关系(PNL->SET->CAM) 递规实现
            /// </summary>
            /// <param name="STEP_REPEATpnl"></param>
            /// <param name="dicStepRepeat"></param>
            public void getAllChild_STEP_REPEAT(List<STEP_REPEAT> STEP_REPEATpnl, Dictionary<string, List<STEP_REPEAT>> dicStepRepeat)
            {
                if (STEP_REPEATpnl == null || STEP_REPEATpnl.Count == 0)
                    return;
                foreach (var item in STEP_REPEATpnl)
                {
                    if (dicStepRepeat.ContainsKey(item.NAME))
                    {
                        item.STEP_REPEAT_List = dicStepRepeat[item.NAME];
                        getAllChild_STEP_REPEAT(item.STEP_REPEAT_List, dicStepRepeat);
                    }
                }
            }
            /// <summary>
            /// 读取Step Stephdr文件信息到Mod
            /// </summary>
            /// <param name="STEP_REPEAT_txt"></param>
            /// <returns></returns>
            public List<STEP_REPEAT> Info2STEP_REPEAT(string STEP_REPEAT_txt)
            {
                List<STEP_REPEAT> STEP_REPEATlist = new List<winTool.STEP_REPEAT>();
                string[] lines = STEP_REPEAT_txt.Split('
    ');
                bool isStart = false;
                STEP_REPEAT ModStep = new STEP_REPEAT();
                foreach (var item in lines)
                {
                    if (isStart)
                    {
                        string[] itemArray = item.Split('=');
                        if (itemArray.Length == 2)
                        {
    
                            string itemKey = itemArray[0].Trim();
                            string itemVal = itemArray[1].Trim();
                            switch (itemKey)
                            {
                                case "NAME":
                                    ModStep.NAME = itemVal.ToLower();
                                    break;
                                case "X":
                                    ModStep.X = Double.Parse(itemVal);
                                    break;
                                case "Y":
                                    ModStep.Y = Double.Parse(itemVal);
                                    break;
                                case "DX":
                                    ModStep.DX = Double.Parse(itemVal);
                                    break;
                                case "DY":
                                    ModStep.DY = Double.Parse(itemVal);
                                    break;
                                case "NX":
                                    ModStep.NX = int.Parse(itemVal);
                                    break;
                                case "NY":
                                    ModStep.NY = int.Parse(itemVal);
                                    break;
                                case "ANGLE":
                                    ModStep.ANGLE = Double.Parse(itemVal);
                                    break;
                                case "MIRROR":
                                    ModStep.MIRROR = itemVal == "YES" ? true : false;
                                    break;
                            }
                        }
                        else if (item.StartsWith("}"))
                        {
                            isStart = false;
                            STEP_REPEATlist.Add(ModStep);
                        }
                    }
                    else if (!isStart && item.StartsWith("STEP-REPEAT") && item.EndsWith("{"))
                    {
                        isStart = true;
                        ModStep = new STEP_REPEAT();
                    }
                }
                return STEP_REPEATlist;
            }

    Stephdr  Mod类

        public class STEP_REPEAT
        {
            public string NAME { get; set; }
            public double X { get; set; }
            public double Y { get; set; }
            public double DX { get; set; }
            public double DY { get; set; }
            public int NX { get; set; }
            public int NY { get; set; }
            public double ANGLE { get; set; }
            public bool MIRROR { get; set; }
            public List<STEP_REPEAT> STEP_REPEAT_List { get; set; }
        }

    三.读取 ZIP 测试点文件

            private void readTestPoint()
            {
                int resultCount = 0;
                string tarFilePath = @"F:4a00n0nb.zip";
                string FileName = Path.GetFileNameWithoutExtension(tarFilePath);
                using (Stream stream = File.OpenRead(tarFilePath))
                {
                    IReader reader = ReaderFactory.Open(stream);
                    while (reader.MoveToNextEntry())
                    {
                        if (reader.Entry.Key.EndsWith("profile.cmb"))
                        {
                            using (EntryStream st = reader.OpenEntryStream())
                            {
                                byte[] byData = new byte[reader.Entry.Size];
                                st.Read(byData, 0, byData.Length);
                                string result = System.Text.Encoding.Default.GetString(byData);
                                resultCount = int.Parse(result);
                                break;
                            }
                        }
                    }
                }
            }
  • 相关阅读:
    Problem with the SSL CA cert (path? access rights?)
    亚马逊ec2使用nginx运行tp5报502
    MySQL 5.7 聚合函数列需要先group by
    Apache服务器HTTPS未完全正确配置的处理
    《将博客搬至CSDN》
    pytorch 8 CNN 卷积神经网络
    pytorch 7 optimizer 优化器 加速训练
    pytorch 6 batch_train 批训练
    pytorch 7 save_reload 保存和提取神经网络
    pytorch 6 build_nn_quickly 快速搭建神经网络
  • 原文地址:https://www.cnblogs.com/pcbren/p/9379076.html
Copyright © 2011-2022 走看看