Exemple #1
0
        private List <PnpPart> ExtractParts(string[] lines)
        {
            List <PnpPart> result = new List <PnpPart>();

            lines.Skip(1).All(delegate(string line)
            {
                line = line.Replace("\r", "").Replace("\n", "");

                string[] parsedLine = line.Split('|');

                if (parsedLine.Length == 7)
                {
                    string refId       = parsedLine[0];
                    string packageName = parsedLine[1];
                    double xPosition   = double.Parse(parsedLine[2]);
                    double yPosition   = double.Parse(parsedLine[3]);
                    string layer       = parsedLine[4];
                    double rotation    = double.Parse(parsedLine[5]);
                    string value       = parsedLine[6];

                    PnpPart part = new PnpPart()
                    {
                        ReferenceID = refId,
                        PackageName = packageName,
                        Position    = new Position()
                        {
                            X = xPosition,
                            Y = yPosition
                        },
                        Layer    = Layers.Parse(layer),
                        Rotation = rotation,
                        Value    = value
                    };

                    result.Add(part);
                }

                return(true);
            });

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Selects the best appropriate slot for the given pnp part. Currently
        /// it only looks for on which slot the same component is attached. Later this can
        /// suggest empty slots
        /// </summary>
        /// <param name="part">Pick and place part details which to look for its best place</param>
        /// <returns></returns>
        public static Task <Contracts.FeederSlot> GetAppropriateSlotFor(PnpPart part)
        {
            using (var context = new SmdppEntities()) {
                Package package = context.Packages.FirstOrDefault(q => q.ID == part.PackageID);

                if (package != null)
                {
                    Contracts.FeederSlot slot = context.FeederSlots.Where(q => q.CurrentPartID != null && q.ConnectedPart.Value == part.Value).Select(y => new Contracts.FeederSlot()
                    {
                        ID      = y.ID,
                        Depth   = y.Depth,
                        PickupX = y.PickupX,
                        PickupY = y.PickupY,
                        Width   = y.Width
                    }).FirstOrDefault();

                    return(Task.FromResult(slot));
                }
                else
                {
                    return(null);
                }
            }
        }