Beispiel #1
0
        public bool SetAsFeeder(TapeObj t)
        {
            string input    = Microsoft.VisualBasic.Interaction.InputBox("Number of components on reel", "Reel size", "Default", -1, -1);
            int    reelSize = int.Parse(input);

            if (reelSize < 1)
            {
                return(false);
            }
            ;

            t.AvailableParts.Clear();

            NamedLocation ReturnLocation;

            for (int i = 1; i < reelSize + 1; i++)
            {
                ReturnLocation = new NamedLocation();

                ReturnLocation.X = Cnc.CurrentX;
                ReturnLocation.Y = Cnc.CurrentY;
                ReturnLocation.A = t.OriginalPartOrientationVector.ToDegrees();

                ReturnLocation.Name = t.ID + "_" + i.ToString();
                t.AvailableParts.Add(ReturnLocation);
            }

            t.IsFullyCalibrated = true;
            t.IsLocationBased   = true;

            return(true);
        }
Beispiel #2
0
        public void AddLocation(PartLocation p, string name)
        {
            var nl = new NamedLocation(p, name);

            nl.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ChildPropertyChangedCallback);
            _locations.Add(nl);
        }
Beispiel #3
0
        public bool SetLastHole(TapeObj t)
        {
            if (t.FirstHole == null) {
                MainForm.DisplayText("First hole not set", Color.Red);
                return false;
            }

            var originalPos = Cnc.XYLocation;

            MainForm.cameraView.SetDownCameraFunctionSet(t.TapeType);

            var holepos = MainForm.FindPositionAndMoveToClosest(Shapes.ShapeTypes.Circle, 1.8, 0.1); //find this hole with high precision

            MainForm.cameraView.SetDownCameraFunctionSet("");

            if (holepos == null)
            {
                //MainForm.DisplayText("Cannot find hole", Color.Red);
                //return false;
                switch (MainForm.ShowMessageBox("Cannot find hole, use manual position?", "Hole not found", MessageBoxButtons.YesNo))
                {
                    case DialogResult.No:
                        return false;
                }
                holepos = originalPos;
            }

            double distance = t.FirstHole.DistanceTo(holepos);

            if ((Math.Abs(distance % t.PartPitch) > 0.4) && ((t.PartPitch - Math.Abs(distance % t.PartPitch)) > 0.4)) {
            //                MainForm.DisplayText("Part pitch and hole position does not make sense, please redo", Color.Red);
                switch (MainForm.ShowMessageBox("Part pitch and hole position seems inconsistent, continue?", "Inconsistency", MessageBoxButtons.YesNo))
                {
                    case DialogResult.No:
                        return false;
                }
            }
            t.LastHole = holepos;

            /* Calculate tape angle given the first and last hole
             * the first hole is always considered to be the furthest away from the reel
             */
            double Xd = t.LastHole.X - t.FirstHole.X;
            double Yd = t.LastHole.Y - t.FirstHole.Y;
            t.SetTapeOrientation(Xd, Yd);
            double TapeAngle = t.TapeOrientation.ToRadians();

            /* Calculate the X and Y movements required to get to the next hole */
            double XMove = Math.Abs(t.PartPitch) * Math.Cos(TapeAngle);
            double YMove = Math.Abs(t.PartPitch) * Math.Sin(TapeAngle);

            /* Calculate the distance to the part from the hole given the angle */
            double XHoleToSpacing = Math.Abs(t.HoleToPartSpacingX) * Math.Cos(-TapeAngle) + Math.Abs(t.HoleToPartSpacingY) * Math.Sin(-TapeAngle);
            double YHoleToSpacing = Math.Abs(t.HoleToPartSpacingY) * Math.Cos(TapeAngle) + Math.Abs(t.HoleToPartSpacingX) * Math.Sin(TapeAngle);

            t.AvailableParts.Clear();
            if (t.PartPitch <= 0)
            {
                MainForm.ShowSimpleMessageBox("Part pitch not set, aborting");
                return false;
            }

            NamedLocation ReturnLocation;
            for (int i = 0; i < (Math.Round(t.LastHole.DistanceTo(t.FirstHole) / t.PartPitch)); i++)
            {
                ReturnLocation = new NamedLocation();

                ReturnLocation.X = t.FirstHole.X + i * XMove + XHoleToSpacing;
                ReturnLocation.Y = t.FirstHole.Y + i * YMove + YHoleToSpacing;
                ReturnLocation.A = t.OriginalPartOrientationVector.ToDegrees();

                ReturnLocation.Name = t.ID + "_" + i.ToString();
                t.AvailableParts.Add(ReturnLocation);

            }

            t.IsFeeder = false;
            t.IsFullyCalibrated = true;
            t.IsLocationBased = true;
            return true;
        }
Beispiel #4
0
        public bool SetAsFeeder(TapeObj t)
        {
            string input = Microsoft.VisualBasic.Interaction.InputBox("Number of components on reel", "Reel size", "5000", -1, -1);
            if (input == "") { return false;  }
            int reelSize = int.Parse(input);

            if (reelSize < 1) { return false; };

            t.AvailableParts.Clear();

            NamedLocation ReturnLocation;
            for (int i = 1; i < reelSize+1; i++)
            {
                ReturnLocation = new NamedLocation();

                ReturnLocation.X = Cnc.CurrentX;
                ReturnLocation.Y = Cnc.CurrentY;
                ReturnLocation.A = t.OriginalPartOrientationVector.ToDegrees();

                ReturnLocation.Name = t.ID + "_" + i.ToString();
                t.AvailableParts.Add(ReturnLocation);

            }

            t.IsFullyCalibrated = true;
            t.IsLocationBased = true;
            t.IsFeeder = true;

            return true;
        }
Beispiel #5
0
        public bool SetLastHole(TapeObj t)
        {
            if (t.FirstHole == null)
            {
                MainForm.DisplayText("First hole not set", Color.Red);
                return(false);
            }

            var originalPos = Cnc.XYLocation;

            MainForm.cameraView.SetDownCameraFunctionSet(t.TapeType);

            var holepos = MainForm.FindPositionAndMoveToClosest(Shapes.ShapeTypes.Circle, 1.8, 0.1); //find this hole with high precision

            MainForm.cameraView.SetDownCameraFunctionSet("");

            if (holepos == null)
            {
                //MainForm.DisplayText("Cannot find hole", Color.Red);
                //return false;
                switch (MainForm.ShowMessageBox("Cannot find hole, use manual position?", "Hole not found", MessageBoxButtons.YesNo))
                {
                case DialogResult.No:
                    return(false);
                }
                holepos = originalPos;
            }

            double distance = t.FirstHole.DistanceTo(holepos);

            if ((Math.Abs(distance % t.PartPitch) > 0.4) && ((t.PartPitch - Math.Abs(distance % t.PartPitch)) > 0.4))
            {
//                MainForm.DisplayText("Part pitch and hole position does not make sense, please redo", Color.Red);
                switch (MainForm.ShowMessageBox("Part pitch and hole position seems inconsistent, continue?", "Inconsistency", MessageBoxButtons.YesNo))
                {
                case DialogResult.No:
                    return(false);
                }
            }
            t.LastHole = holepos;

            /* Calculate tape angle given the first and last hole
             * the first hole is always considered to be the furthest away from the reel
             */
            double Xd = t.LastHole.X - t.FirstHole.X;
            double Yd = t.LastHole.Y - t.FirstHole.Y;

            t.SetTapeOrientation(Xd, Yd);
            double TapeAngle = t.TapeOrientation.ToRadians();

            /* Calculate the X and Y movements required to get to the next hole */
            double XMove = Math.Abs(t.PartPitch) * Math.Cos(TapeAngle);
            double YMove = Math.Abs(t.PartPitch) * Math.Sin(TapeAngle);

            /* Calculate the distance to the part from the hole given the angle */
            double XHoleToSpacing = Math.Abs(t.HoleToPartSpacingX) * Math.Cos(-TapeAngle) + Math.Abs(t.HoleToPartSpacingY) * Math.Sin(-TapeAngle);
            double YHoleToSpacing = Math.Abs(t.HoleToPartSpacingY) * Math.Cos(TapeAngle) + Math.Abs(t.HoleToPartSpacingX) * Math.Sin(TapeAngle);

            t.AvailableParts.Clear();

            NamedLocation ReturnLocation;

            for (int i = 0; i < (Math.Round(t.LastHole.DistanceTo(t.FirstHole) / t.PartPitch)); i++)
            {
                ReturnLocation = new NamedLocation();

                ReturnLocation.X = t.FirstHole.X + i * XMove + XHoleToSpacing;
                ReturnLocation.Y = t.FirstHole.Y + i * YMove + YHoleToSpacing;
                ReturnLocation.A = t.OriginalPartOrientationVector.ToDegrees();

                ReturnLocation.Name = t.ID + "_" + i.ToString();
                t.AvailableParts.Add(ReturnLocation);
            }

            t.IsFullyCalibrated = true;
            t.IsLocationBased   = true;
            return(true);
        }
Beispiel #6
0
 public void AddLocation(double x, double y, string name)
 {
     var nl = new NamedLocation(x, y, name);
     nl.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ChildPropertyChangedCallback);
     _locations.Add(nl);
 }