Пример #1
0
        private static Component createComponentFromMatch(string pageLine,
                                                          string componentIndicator, enumComponentType componentType,
                                                          int componentSeqNum, List <Regex> list)
        {
            Component component = null;

            foreach (Regex item in list)
            {
                Match itemMatch = item.Match(pageLine);
                if (itemMatch.Success)
                {
                    component = new Component
                    {
                        ID             = componentIndicator,
                        Type           = componentType,
                        SequenceNumber = componentSeqNum,
                        Value          = itemMatch.Value
                    };
                    break;
                }
            }
            if (component == null)
            {
                component = new Component
                {
                    ID    = componentIndicator,
                    Type  = enumComponentType.UNKNOWN,
                    Value = pageLine
                };
            }
            return(component);
        }
Пример #2
0
        /// <summary>
        /// 新增芯片引脚
        /// </summary>
        /// <param name="compIdx"></param>
        /// <param name="footList"></param>
        /// <returns></returns>
        private bool AddComponentFoots(int compIdx, enumComponentType compType, List <LineFoot> footList)
        {
            string strSql = string.Empty;

            foreach (LineFoot item in footList)
            {
                strSql += string.Format("insert into lineFoot (component,footType,pinsType,name,locX,locY,color,innerId) values ({0},{1},{2},'{3}',{4},{5},{6},{7});",
                                        compIdx, (int)compType, (int)item.PinsType, item.Name == null ? string.Empty : item.Name, item.LocX, item.LocY, item.Color == null ? 0 : item.Color.ToArgb(), item.InnerIdx);
            }
            return(footList.Count == SQLiteHelper.ExecuteNonQuery(STR_CONNECTION, strSql));
        }
Пример #3
0
        private static void findBillOfMaterials(Dictionary <int, string[]> pdfTextDict)
        {
            List <Component> componentList = new List <Component>();

            foreach (int page in pdfTextDict.Keys)
            {
                string[] pageLines = pdfTextDict[page];

                for (int lineIndex = 0; lineIndex < pageLines.Length; lineIndex++)
                {
                    string pageLine = pageLines[lineIndex];

                    //potential BOM Found
                    //description: loose indicator match that checks "[character][number(s)][whitespace]"
                    Match indicatorMatch = indicatorRegex.Match(pageLine);
                    if (indicatorMatch.Success)
                    {
                        //get the matched component indicator
                        string componentIndicator = indicatorMatch.Value;

                        enumComponentType componentType = enumComponentType.UNKNOWN;

                        int componentSeqNum = -1;

                        if (indicatorMatch.Groups.Count == 3)
                        {
                            componentType = matchComponentType(indicatorMatch.Groups[1].Value);

                            if (!Int32.TryParse(indicatorMatch.Groups[2].Value, out componentSeqNum))
                            {
                                componentSeqNum = -1;
                            }
                        }

                        Component component = matchComponentTypeByValue(pageLine,
                                                                        componentIndicator, componentType, componentSeqNum);

                        if (component != null && component.Type != enumComponentType.UNKNOWN)
                        {
                            Console.WriteLine("id=" + component.ID + ", type=" + component.Type + ",value=" + component.Value);
                            componentList.Add(component);
                        }
                    }
                }
            }
        }
Пример #4
0
        private static Component matchComponentTypeByValue(string pageLine,
                                                           string componentIndicator, enumComponentType componentType, int componentSeqNum)
        {
            Component component = null;

            if (!componentType.Equals(enumComponentType.UNKNOWN))
            {
                List <Regex> compTypeRegexList = componentValueRegexDict[componentType];

                component = createComponentFromMatch(pageLine,
                                                     componentIndicator, componentType, componentSeqNum,
                                                     compTypeRegexList);
            }
            else
            {
                foreach (var key in componentValueRegexDict.Keys)
                {
                    List <Regex> list = componentValueRegexDict[key];

                    component = createComponentFromMatch(pageLine,
                                                         componentIndicator, key, -1, list);
                    if (component != null && !component.Type.Equals(enumComponentType.UNKNOWN))
                    {
                        break;
                    }
                }
            }
            return(component);
        }