コード例 #1
0
ファイル: Component.cs プロジェクト: Robyrob/kibom
 private static void DumpDesignatorGroup(DesignatorGroup g)
 {
     foreach (Component c in g.comp_list)
     {
         Console.WriteLine(c.reference);
     }
 }
コード例 #2
0
ファイル: Component.cs プロジェクト: Robyrob/kibom
        // Designator groups contain multiple components with the same designators.
        // Sort the components into batches of identical ones.
        public static List <DesignatorGroup> MergeComponents(List <DesignatorGroup> groups)
        {
            var new_groups = new List <DesignatorGroup>();

            foreach (DesignatorGroup g in groups)
            {
                var new_g = new DesignatorGroup();
                new_g.comp_list  = new List <Component>();
                new_g.designator = g.designator;

                foreach (Component c in g.comp_list)
                {
                    if (new_g.comp_list.Count == 0)
                    {
                        new_g.comp_list.Add(c);
                    }
                    else
                    {
                        // search through existing lists for matching components
                        int found = -1;
                        //if (c.designator == "U")
                        //	System.Diagnostics.Debugger.Break();
                        for (int i = 0; i < new_g.comp_list.Count; i++)
                        {
                            if ((new_g.comp_list[i].value == c.value) &&
                                (new_g.comp_list[i].footprint == c.footprint) &&
                                (new_g.comp_list[i].code == c.code) &&
                                (new_g.comp_list[i].note == c.note) &&
                                (new_g.comp_list[i].part_no == c.part_no) &&
                                (new_g.comp_list[i].precision == c.precision))
                            {
                                found = i;
                                break;
                            }
                        }

                        if (found == -1)                                // create new value group
                        {
                            new_g.comp_list.Add(c);
                        }
                        else                                                    // add to existing group
                        {
                            new_g.comp_list[found].reference += ", " + c.reference;
                            new_g.comp_list[found].count++;
                        }
                    }
                }

                // sort references
                for (int i = 0; i < new_g.comp_list.Count; i++)
                {
                    new_g.comp_list[i].reference = SortCommaSeparatedString(new_g.comp_list[i].reference);
                }

                // start a new designator group
                new_groups.Add(new_g);
            }

            return(new_groups);
        }
コード例 #3
0
ファイル: Component.cs プロジェクト: Robyrob/kibom
        // create groups of components with the same designator, unsorted
        public static List <DesignatorGroup> BuildDesignatorGroups(List <Component> comp_list)
        {
            var groups = new List <DesignatorGroup>();

            foreach (Component comp in comp_list)
            {
                bool found = false;
                for (int i = 0; i < groups.Count; i++)
                {
                    if (groups[i].designator == comp.designator)
                    {
                        groups[i].comp_list.Add(comp);
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    var new_group = new DesignatorGroup();
                    new_group.designator = comp.designator;
                    new_group.comp_list  = new List <Component>();
                    new_group.comp_list.Add(comp);
                    groups.Add(new_group);
                }
            }

            return(groups);
        }