Exemplo n.º 1
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.º 2
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);
                }
            }
        }