示例#1
0
 /*-------------------------------------------------------------*/
 private void cbxStackType_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbxStackType.SelectedItem.ToString() == PNPconverterTools.stackTypeToString(StackType.Tray18mm))
     {
         nudwuFeedRate.Value   = 18;
         nudwuFeedRate.Enabled = false;
     }
     else
     {
         nudwuFeedRate.Enabled = true;
     }
 }
示例#2
0
 /// <summary>
 /// Sets the footprint to be eddited
 /// </summary>
 /// <param name="footprint">Footprint to be eddited</param>
 public void setFootprint(Footprint footprint)
 {
     tbxMPN.Text               = footprint.manufacturerPartNumber;
     nudwuHeight.Value         = (decimal)footprint.Height;
     nudwuLength.Value         = (decimal)footprint.Length;
     nudwuWidth.Value          = (decimal)footprint.width;
     nudwuRotation.Value       = footprint.rotation;
     bscOffset.valueX          = (decimal)footprint.offsetStackX;
     bscOffset.valueY          = (decimal)footprint.offsetStackY;
     cbxNozzle.SelectedItem    = footprint.nozzle;
     cbxStackType.SelectedItem = PNPconverterTools.stackTypeToString(footprint.stacktype);
     nudwuFeedRate.Value       = (decimal)footprint.feedRate;
 }
示例#3
0
        public FootprintForm()
        {
            InitializeComponent();
            cbxNozzle.DataSource = Enum.GetValues(typeof(Nozzle));

            foreach (StackType stackType_ in Enum.GetValues(typeof(StackType)))
            {
                cbxStackType.Items.Add(PNPconverterTools.stackTypeToString(stackType_));
            }
#if (DEBUG)
            tbxMPN.Text = "TEST";
#endif

            //TO DO: fill cbxKnown with predefined exampels and give the combobox a better name
        }
示例#4
0
        /*-------------------------------------------------------------*/
        private void btnSave_Click(object sender, EventArgs e)
        {
            string    manufacturerPartNumber = tbxMPN.Text;
            float     width     = (float)nudwuWidth.Value;
            float     length    = (float)nudwuLength.Value;
            float     height    = (float)nudwuHeight.Value;
            int       rotation  = Convert.ToInt32(nudwuRotation.Value);
            float     offsetX   = (float)bscOffset.valueX;
            float     offsetY   = (float)bscOffset.valueY;
            float     feedRate  = (float)nudwuFeedRate.Value;
            StackType stackType = PNPconverterTools.stringToStackType(cbxStackType.SelectedItem.ToString());

            footPrint_        = new Footprint(manufacturerPartNumber, width, length, height, rotation, offsetX, offsetY, feedRate, (Nozzle)cbxNozzle.SelectedItem, stackType);
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }
 /// <summary>
 /// Initializes a new <see cref="PickAndPlace.StackControl"/>
 /// </summary>
 /// <param name="stackType">Stack type of the new control</param>
 public StackControl(StackType stackType, int number)
     : this()
 {
     myType            = stackType;
     lblStackType.Text = number.ToString() + ") " + PNPconverterTools.StackTypeToString(stackType);
 }
        /// <summary>
        /// Load a pick and place project from the project.path
        /// </summary>
        /// <param name="project">Project to load data to</param>
        /// <exception cref="PickAndPlace.FileOperationsException">Thrown when data is missing or when a line could not be decoded</exception>
        public static void LoadProject(PnpProject project)
        {
            List <PnpComponent> includedComponents = new List <PnpComponent>();
            List <PnpComponent> excludedComponents = new List <PnpComponent>();

            //project.stackListers = new List<StackList>();
            using (StreamReader reader = new StreamReader(project.Path))
            {
                while (!reader.EndOfStream)
                {
                    string curLine = reader.ReadLine();
                    //# is a line with comment
                    if (curLine.StartsWith("#") || String.IsNullOrWhiteSpace(curLine))
                    {
                        continue;
                    }
                    string[] splitedLine = curLine.Split(new char[] { ',', '=' }, StringSplitOptions.None);
                    switch (splitedLine[0])
                    {
                    case "ProjectName":
                        project.ProjectName = splitedLine[1];
                        break;

                    case "ProjectFolder":
                        project.ProjectFolder = splitedLine[1];
                        break;

                    case "MachineType":
                        project.Machine = (IMachine)Assembly.GetExecutingAssembly().CreateInstance(splitedLine[1]);
                        project.Machine.DefaultSpeed = Convert.ToInt32(splitedLine[3]);
                        for (int i = 5; i < splitedLine.Length; i++)
                        {
                            Nozzle nozzle = PNPconverterTools.StringToNozzle(splitedLine[i]);
                            project.Machine.SetNozzle(i - 5, nozzle);
                        }
                        break;

                    case "originOffsetX":
                        project.HorizontalOriginOffset = float.Parse(splitedLine[1]);
                        project.VerticalOriginOffset   = float.Parse(splitedLine[3]);
                        break;

                    case "boardsX":
                        project.BoardsX = Convert.ToInt32(splitedLine[1]);
                        project.BoardsY = Convert.ToInt32(splitedLine[3]);
                        break;

                    case "distanceX":
                        project.DistanceX = float.Parse(splitedLine[1]);
                        project.DistanceY = float.Parse(splitedLine[3]);
                        break;

                    case "boardDimX":
                        project.BoardWidth  = float.Parse(splitedLine[1]);
                        project.BoardLength = float.Parse(splitedLine[3]);
                        break;

                    case "Designator":
                        //load new component
                        string designator = splitedLine[1];
                        string manufacturerPartNumber_ = splitedLine[3];
                        float  x        = float.Parse(splitedLine[5]);
                        float  y        = float.Parse(splitedLine[7]);
                        int    rotation = Convert.ToInt32(splitedLine[9]);
                        Layer  layer_;
                        if (splitedLine[11] == Layer.Bottom.ToString())
                        {
                            layer_ = Layer.Bottom;
                        }
                        else
                        {
                            layer_ = Layer.Top;
                        }
                        Location     location_ = new Location(x, y, rotation, layer_);
                        string       comment   = splitedLine[13];
                        bool         included  = Convert.ToBoolean(splitedLine[15]);
                        PnpComponent comp      = new PnpComponent(designator, location_, comment, manufacturerPartNumber_);
                        if (included)
                        {
                            includedComponents.Add(comp);
                        }
                        else
                        {
                            excludedComponents.Add(comp);
                        }
                        break;

                    case "Phase":
                        //last part of the file
                        string   remainingLines        = reader.ReadToEnd();
                        string[] remainingLinesSplited = remainingLines.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);
                        //1) make reels from the components:

                        project.IncludedReels = ComponentsToReels(includedComponents, project.Machine.DefaultSpeed);
                        project.ExcludedReels = ComponentsToReels(excludedComponents, project.Machine.DefaultSpeed);

                        List <Reel> completeReelList = new List <Reel>(project.IncludedReels);
                        completeReelList.AddRange(project.ExcludedReels);
                        //the completeReelList contains all reels, however these reels where not splited
                        List <Reel> topReels, bottomReels;
                        Reel.SplitReelList(completeReelList, out topReels, out bottomReels);
                        completeReelList.Clear();
                        completeReelList.AddRange(topReels);
                        completeReelList.AddRange(bottomReels);
                        //topReels and bottomReels contain all reels, also the excluded reels
                        //they will be reused later

                        //2) read each line
                        StackList newStackList = new StackList(project.Machine, Convert.ToInt32(splitedLine[1]));
                        newStackList.Name = "stackList";
                        project.StackListers.Add(newStackList);
                        int index = -1;

                        for (int i = 0; i < remainingLinesSplited.Length; i++)
                        {
                            splitedLine = remainingLinesSplited[i].Split(new char[] { '=', ',' });
                            if (splitedLine[0] != "Phase")
                            {
                                index++;     //Stacks are saved in order (starting at reel 0 -> reel n)
                                string designator_ = splitedLine[1];
                                if (String.IsNullOrWhiteSpace(designator_))
                                {
                                    continue;                                             //empty stack
                                }
                                bool locked = Convert.ToBoolean(splitedLine[5]);
                                //find the reel in the completeReelList
                                Reel matchingReel = completeReelList.Find(reel => reel.GetDesignators().Contains(designator_));
                                matchingReel.Speed = Convert.ToInt32(splitedLine[3]);
                                newStackList.AddReel(matchingReel, locked, index);
                                project.ReelsInStackList.Add(matchingReel);
                            }
                            else
                            {
                                //make a new phase
                                //Phase=X (X=phase number)
                                newStackList      = new StackList(project.Machine, Convert.ToInt32(splitedLine[1]));
                                newStackList.Name = "stackList";
                                project.StackListers.Add(newStackList);
                                index = -1;
                            }
                        }
                        //Reusing topReels and bottomReels
                        Reel.SplitReelList(project.ReelsInStackList, out topReels, out bottomReels);
                        project.TopReels    = topReels;
                        project.BottomReels = bottomReels;

                        break;

                    default:
                        throw new FileOperationsException(String.Format("Unable to read file: {0}{2}Problem with reading folowing line:{2}{1}", project.Path, curLine, Environment.NewLine));
                    }
                }
            }
            if (project.StackListers.Count == 0)
            {
                //no phases saved
                project.IncludedReels = ComponentsToReels(includedComponents, project.Machine.DefaultSpeed);
                project.ExcludedReels = ComponentsToReels(excludedComponents, project.Machine.DefaultSpeed);
            }
            if ((project.HorizontalOriginOffset == -1f) || (project.VerticalOriginOffset == -1f) ||
                (project.BoardsX == -1) || (project.BoardsY == -1) ||
                (project.DistanceX == -1f) || (project.DistanceY == -1f) ||
                (project.BoardWidth == -1f) || (project.BoardLength == -1f) ||
                (project.Machine == null))
            {
                throw new FileOperationsException("Not all data was found in the file");
            }
        }