Ejemplo n.º 1
0
 public bool SetCurrentTapeMeasurement(string type)
 {
     MainForm.cameraView.SetDownCameraFunctionSet(type + "Tape");
     Global.DoBackgroundWork(100);
     return(true);
 }
Ejemplo n.º 2
0
 public void SaveAll(string filename = null)
 {
     filename = filename ?? TapeFilename;
     Global.Serialization(tapeObjs, filename);
 }
Ejemplo n.º 3
0
        public PartLocation GetNextComponentPartLocation(TapeObj tapeObj)
        {
            if (tapeObj == null)
            {
                return(null);
            }
            MainForm.DisplayText("GotoNextPart_m(), tape id: " + tapeObj.ID);

            //Load & Parse Data
            if (!tapeObj.IsFullyCalibrated)
            {
                MainForm.ShowSimpleMessageBox("Tape " + tapeObj.ID + " is not yet calibrated.  Please do so and retry");
                return(null);
            }

            PartLocation targetLocation = tapeObj.GetCurrentPartLocation();

            MainForm.DisplayText("Part " + tapeObj.CurrentPartIndex() + "  Source Location = " + targetLocation, Color.Blue);

            // see if part exists for part based detection
            if (tapeObj.TemplateBased)
            {
                Global.Instance.mainForm.cameraView.DownCameraReset();
                if (!MainForm.Cnc.CNC_XY(targetLocation))
                {
                    return(null);
                }
                var thing = MainForm.GoToClosestThing(Shapes.ShapeTypes.Fiducial, 1, .2, null, tapeObj.TemplateFilename, .75);
                if (thing == null)
                {
                    MainForm.DisplayText("No Part Detected At This Location", Color.Red);
                    return(null);
                }
                MainForm.DisplayText("Part Detected : " + thing);
            }


            if (tapeObj.IsLocationBased)
            {
                targetLocation = GetLocationBasedComponent(tapeObj);
            }
            else
            // enhanced part detection
            if (tapeObj.FirstHole != null)
            {
                SetCurrentTapeMeasurement(tapeObj.TapeType);
                Cnc.CNC_XY(tapeObj.GetNearestCurrentPartHole());
                var hole = MainForm.GoToClosestThing(Shapes.ShapeTypes.Circle, 1.5, .1);
                if (hole == null)
                {
                    MainForm.DisplayText("Unable to detect part hole, aborting");
                    return(null);
                }
                var offset = tapeObj.GetCurrentPartLocation() - tapeObj.GetNearestCurrentPartHole();
                targetLocation = hole.ToPartLocation() + offset;
                MainForm.cameraView.DownCameraReset();
            }

            //------------------- PART SPECIFIC LOGIC GOES HERE --------------------//
            if (tapeObj.PartType == "QFN")
            {
                MainForm.DisplayText("USING ENHANCE PART PICKUP", Color.HotPink);
                if (!MainForm.Cnc.CNC_XY(targetLocation))
                {
                    return(null);
                }
                // setup view
                SetCurrentTapeMeasurement(tapeObj.TapeType);
                MainForm.cameraView.downSettings.FindRectangles = true;

                // MainForm.cameraView.downVideoProcessing.FindRectangles = true;
                // move closer and get exact coordinates plus rotation
                var rect = (Shapes.Rectangle)MainForm.GoToClosestThing(Shapes.ShapeTypes.Rectangle, 1.5, .025);

                if (rect == null)
                {
                    MainForm.cameraView.DownCameraReset();
                    return(null);
                }
                Global.DoBackgroundWork(500);
                var rectAngle = rect.AngleOffsetFrom90();

                targetLocation   = rect.ToPartLocation();
                targetLocation.A = tapeObj.OriginalPartOrientationVector.ToDegrees() + rectAngle;

                MainForm.cameraView.DownCameraReset();
            }

            return(targetLocation);
        }