Exemplo n.º 1
0
        public void LoadPrinted(string filename)
        {
            BOMNumberSet BS = new BOMNumberSet();

            try
            {
                var L = File.ReadAllLines(filename);

                //string Header = "Count,Name,Type,Package,Value,MfgPartNumber,RefDes";

                int idxcount   = 0;
                int idxname    = 1;
                int idxtype    = 2;
                int idxpackage = 3;
                int idxvalue   = 4;
                int idxmfg     = 5;
                int idxrefdes  = 6;
                var Hsplit     = L[0].Split(',');



                for (int l = 1; l < L.Count(); l++)
                {
                    var lsplit   = L[l].Split(',');
                    var refsplit = lsplit[idxrefdes].Split(' ');
                    foreach (var refdes in refsplit)
                    {
                        AddBOMItemInt(lsplit[idxpackage], lsplit[idxname], lsplit[idxvalue], refdes, BS, filename, 0, 0, 0);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 2
0
 public void MergeBOM(BOM B, BOMNumberSet set, double dx, double dy, double cx, double cy, double angle)
 {
     foreach (var a in B.DeviceTree)
     {
         foreach (var b in a.Value)
         {
             foreach (var c in b.Value.RefDes)
             {
                 double X = c.x;
                 double Y = c.y;
                 Helpers.Transform(dx, dy, cx, cy, angle, ref X, ref Y);
                 AddBOMItem(b.Value.PackageName, b.Value.Name, b.Value.Value, c.OriginalName, set, c.SourceBoard, X, Y, (c.angle + angle) % 360);
             }
         }
     }
 }
Exemplo n.º 3
0
        internal string AddRef(string refdes, string source, BOMNumberSet set, double x, double y, double angle)
        {
            if (set == null)
            {
                RefDes.Add(new RefDesc()
                {
                    NameOnBoard = refdes, angle = angle, OriginalName = refdes, SourceBoard = source, x = x, y = y
                });
                return(refdes);
            }
            string newref = set.GetNew(refdes);

            RefDes.Add(new RefDesc()
            {
                NameOnBoard = newref, angle = angle, OriginalName = refdes, SourceBoard = source, x = x, y = y
            });
            return(newref);
        }
Exemplo n.º 4
0
 public void MergeBOM(BOM B, BOMNumberSet set, double dx, double dy, double cx, double cy, double angle)
 {
     foreach (var a in B.DeviceTree)
     {
         foreach (var b in a.Value)
         {
             foreach (var c in b.Value.RefDes)
             {
                 double X = c.x;
                 double Y = c.y;
                 Helpers.Transform(dx, dy, cx, cy, angle, ref X, ref Y);
                 OptionalOut <BOMEntry> bom = new OptionalOut <BOMEntry>();
                 AddBOMItemInt(b.Value.PackageName, b.Value.Name, b.Value.Value, c.OriginalName, set, c.SourceBoard, X, Y, (c.angle + angle) % 360, c.Side, bom);
                 bom.Result.SetCombined(b.Value.Combined());
             }
         }
     }
 }
Exemplo n.º 5
0
        public string AddBOMItem(string package, string device, string value, string refdes, BOMNumberSet set, string SourceBoard, double x, double y, double angle)
        {
            string ID = package + device;

            if (refdes == device)
            {
                ID = package;
            }

            if (DeviceTree.ContainsKey(ID) == false)
            {
                DeviceTree[ID] = new Dictionary <string, BOMEntry>();
            }
            if (DeviceTree[ID].ContainsKey(value) == false)
            {
                DeviceTree[ID][value] = new BOMEntry()
                {
                    Name = device, Value = value, PackageName = package
                }
            }
            ;
            BOMEntry BE = DeviceTree[ID][value];

            return(BE.AddRef(refdes, SourceBoard, set, x, y, angle));
        }
Exemplo n.º 6
0
        private void LoadUltiboard(string bOMFile, string centroids)
        {
            Dictionary <string, BOMEntry.RefDesc> positions = new Dictionary <string, BOMEntry.RefDesc>();



            CSVLoader centroidloader = new CSVLoader();

            centroidloader.LoadFile(centroids);


            int FirstRow = -1;

            for (int i = 0; i < centroidloader.Lines.Count; i++)
            {
                if (centroidloader.Lines[i].columns[0] == "REFDES")
                {
                    FirstRow = i + 1;
                }
            }

            if (FirstRow > -1)
            {
                for (int i = FirstRow; i < centroidloader.Lines.Count; i++)
                {
                    var    Line = centroidloader.Lines[i];
                    string rd = Line.columns[0];
                    double X = 0, Y = 0, Angle = 0;

                    X     = Double.Parse(Line.columns[3]) / 1000000.0;
                    Y     = Double.Parse(Line.columns[4]) / 1000000.0;
                    Angle = Double.Parse(Line.columns[5]);

                    BoardSide Side = BoardSide.Top;
                    if (Line.columns[6] != "TOP")
                    {
                        Side = BoardSide.Bottom;
                    }

                    positions[rd] = new BOMEntry.RefDesc()
                    {
                        angle = Angle, x = X, y = Y, OriginalName = rd, NameOnBoard = rd, SourceBoard = bOMFile, Side = Side
                    };
                }
            }


            BOMNumberSet Set       = new BOMNumberSet();
            CSVLoader    bomloader = new CSVLoader();

            bomloader.LoadFile(bOMFile);

            FirstRow = -1;
            for (int i = 0; i < bomloader.Lines.Count; i++)
            {
                if (bomloader.Lines[i].columns[0] == "VALUE")
                {
                    FirstRow = i + 1;
                }
            }

            if (FirstRow > -1)
            {
                for (int i = FirstRow; i < bomloader.Lines.Count; i++)
                {
                    string value   = bomloader.Lines[i].columns[0];
                    string package = bomloader.Lines[i].columns[1];
                    var    refdes  = bomloader.Lines[i].columns[3].Split(',');
                    foreach (var rd in refdes)
                    {
                        var S = positions[rd];

                        AddBOMItem(package, "", value, rd, Set, bOMFile, S.x, S.y, S.angle, S.Side);
                    }
                }
            }
        }
Exemplo n.º 7
0
        string AddBOMItemInt(string package, string device, string value, string refdes, BOMNumberSet set, string SourceBoard, double x, double y, double angle, BoardSide side = BoardSide.Top)
        {
            string ID = GetID(package, device, refdes);


            if (DeviceTree.ContainsKey(ID) == false)
            {
                DeviceTree[ID] = new Dictionary <string, BOMEntry>();
            }
            if (DeviceTree[ID].ContainsKey(value) == false)
            {
                DeviceTree[ID][value] = new BOMEntry()
                {
                    Name = device, Value = value, PackageName = package
                }
            }
            ;
            BOMEntry BE = DeviceTree[ID][value];

            return(BE.AddRef(refdes, SourceBoard, set, x, y, angle, side));
        }
Exemplo n.º 8
0
        public string AddBOMItemExt(string package, string device, string value, string refdes, BOMNumberSet set, string SourceBoard, double x, double y, double angle, BoardSide side = BoardSide.Top)
        {
            string ID = GetID(package, device, refdes);

            return(AddBOMItemInt(package, device, value, refdes, set, SourceBoard, x, y, angle, side));
        }
Exemplo n.º 9
0
        public void LoadJLC(string bOMFile, string pnPFile)
        {
            Dictionary <string, BOMEntry.RefDesc> positions = new Dictionary <string, BOMEntry.RefDesc>();


            var bomlines = File.ReadAllLines(bOMFile);
            var pnplines = File.ReadAllLines(pnPFile);

            //outlinesBOM.Add("Comment,Designator,Footprint,LCSC Part #");
            var regex = new Regex("(?<=^|,)(\"(?:[^\"]|\"\")*\"|[^,]*)");


            //outlinesPNP.Add("Designator,Mid X,Mid Y,Layer,Rotation");
            for (int i = 1; i < pnplines.Count(); i++)
            {
                var           s     = pnplines[i];
                List <string> items = new List <string>();
                foreach (Match m in regex.Matches(s))
                {
                    items.Add(m.Value);
                }

                var rd    = items[0];
                var X     = ConvertDimension(items[1]);
                var Y     = ConvertDimension(items[2]);
                var Side  = items[3] == "T" ? BoardSide.Top : BoardSide.Bottom;
                var Angle = Double.Parse(items[4]);

                positions[rd] = new BOMEntry.RefDesc()
                {
                    angle = Angle, x = X, y = Y, OriginalName = rd, NameOnBoard = rd, SourceBoard = bOMFile, Side = Side
                };
            }

            BOMNumberSet Set = new BOMNumberSet();

            for (int i = 1; i < bomlines.Count(); i++)
            {
                var           s     = bomlines[i];
                List <string> items = new List <string>();
                foreach (Match m in regex.Matches(s))
                {
                    items.Add(m.Value.Trim());
                }

                var refdesc = items[1].Trim();;
                if (refdesc.StartsWith("\""))
                {
                    refdesc = refdesc.Substring(1, refdesc.Length - 2);
                }
                var rd = refdesc.Split(',');

                var value   = items[0];
                var package = items[2];


                foreach (var rd_ in rd)
                {
                    var S = positions[rd_.Trim()];

                    AddBOMItemExt(package, "", value, rd_, Set, bOMFile, S.x, S.y, S.angle, S.Side);
                }
            }
        }