Example #1
0
        // ========================================================================================
        // PrepareForFastPlacement_m: Called before starting fast placement

        public bool PrepareForFastPlacement_m(string TapeID, int ComponentCount)
        {
            int TapeNum;

            if (!IdValidates_m(TapeID, out TapeNum))
            {
                FastParametersOk = false;
                return(false);
            }
            int first;

            if (!int.TryParse(Grid.Rows[TapeNum].Cells["Next_Column"].Value.ToString(), out first))
            {
                MainForm.ShowMessageBox(
                    "Bad data at next column",
                    "Sloppy programmer error",
                    MessageBoxButtons.OK);
                FastParametersOk = false;
                return(false);
            }
            int last = first + ComponentCount - 1;
            // measure holes
            double LastX  = 0.0;
            double LastY  = 0.0;
            double FirstX = 0.0;
            double FirstY = 0.0;

            if (!GetPartHole_m(TapeNum, last, out LastX, out LastY))
            {
                FastParametersOk = false;
                return(false);
            }
            if (last != first)
            {
                if (!GetPartHole_m(TapeNum, first, out FirstX, out FirstY))
                {
                    FastParametersOk = false;
                    return(false);
                }
            }
            else
            {
                FirstX = LastX;
                FirstY = LastY;
            }

            FastXpos = FirstX;
            FastYpos = FirstY;
            if (ComponentCount > 1)
            {
                FastXstep = (LastX - FirstX) / (double)(ComponentCount - 1);
                FastYstep = (LastY - FirstY) / (double)(ComponentCount - 1);
            }
            else
            {
                FastXstep = 0.0;
                FastYstep = 0.0;
            }

            MainForm.DisplayText("Fast parameters:");
            MainForm.DisplayText("First X: " + FirstX.ToString() + ", Y: " + FirstY.ToString());
            MainForm.DisplayText("Last X: " + LastX.ToString() + ", Y: " + LastY.ToString());
            MainForm.DisplayText("Step X: " + FastXstep.ToString() + ", Y: " + FastYstep.ToString());

            return(true);
        }
Example #2
0
        // ========================================================================================
        // PrepareForFastPlacement_m: Called before starting fast placement

        public bool PrepareForFastPlacement_m(string TapeID, int ComponentCount)
        {
            int TapeNum;

            if (!IdValidates_m(TapeID, out TapeNum))
            {
                FastParametersOk = false;
                return(false);
            }
            if (MainForm.UseCoordinatesDirectly(TapeNum))
            {
                return(true);
            }


            int first;

            if (!int.TryParse(Grid.Rows[TapeNum].Cells["NextPart_Column"].Value.ToString(), out first))
            {
                MainForm.ShowMessageBox(
                    "Bad data at next column",
                    "Sloppy programmer error",
                    MessageBoxButtons.OK);
                FastParametersOk = false;
                return(false);
            }
            int last = first + ComponentCount - 1;
            // measure holes
            double LastX  = 0.0;
            double LastY  = 0.0;
            double FirstX = 0.0;
            double FirstY = 0.0;

            if (!GetPartHole_m(TapeNum, last, out LastX, out LastY))
            {
                FastParametersOk = false;
                return(false);
            }
            if (last != first)
            {
                if (!GetPartHole_m(TapeNum, first, out FirstX, out FirstY))
                {
                    FastParametersOk = false;
                    return(false);
                }
            }
            else
            {
                FirstX = LastX;
                FirstY = LastY;
            }

            FastXpos = FirstX;
            FastYpos = FirstY;
            if (ComponentCount > 1)
            {
                // get pitch
                double pitch = 0;
                if (!double.TryParse(Grid.Rows[TapeNum].Cells["Pitch_Column"].Value.ToString().Replace(',', '.'), out pitch))
                {
                    MainForm.ShowMessageBox(
                        "Bad data at Pitch column, tape ID: " + Grid.Rows[TapeNum].Cells["Id_Column"].Value.ToString(),
                        "Data error",
                        MessageBoxButtons.OK);
                    return(false);
                }
                // if pitch == 2
                if ((pitch < 2.01) && (pitch > 1.99))
                {
                    int starthole      = (first + 1) / 2;
                    int lasthole       = (last + 1) / 2;
                    int HoleIncrements = lasthole - starthole;
                    if (HoleIncrements == 0)
                    {
                        FastXstep = 0.0;
                        FastYstep = 0.0;
                    }
                    else
                    {
                        FastXstep = (LastX - FirstX) / (double)HoleIncrements;
                        FastYstep = (LastY - FirstY) / (double)HoleIncrements;
                    }
                }
                else
                {
                    // normal case
                    FastXstep = (LastX - FirstX) / (double)(ComponentCount - 1);
                    FastYstep = (LastY - FirstY) / (double)(ComponentCount - 1);
                }
            }
            else
            {
                FastXstep = 0.0;
                FastYstep = 0.0;
            }

            MainForm.DisplayText("Fast parameters:");
            MainForm.DisplayText("First X: " + FirstX.ToString() + ", Y: " + FirstY.ToString());
            MainForm.DisplayText("Last X: " + LastX.ToString() + ", Y: " + LastY.ToString());
            MainForm.DisplayText("Step X: " + FastXstep.ToString() + ", Y: " + FastYstep.ToString());

            return(true);
        }
Example #3
0
        // ========================================================================================
        // PrepareForFastPlacement_m: Called before starting fast placement

        public bool PrepareForFastPlacement_m(string TapeID, int ComponentCount)
        {
            int TapeNum;

            if (!IdValidates_m(TapeID, out TapeNum))
            {
                FastParametersOk = false;
                return(false);
            }
            if (MainForm.UseCoordinatesDirectly(TapeNum))
            {
                return(true);
            }


            int first;

            if (!int.TryParse(Grid.Rows[TapeNum].Cells["NextPart_Column"].Value.ToString(), out first))
            {
                MainForm.ShowMessageBox(
                    "Bad data at next column",
                    "Sloppy programmer error",
                    MessageBoxButtons.OK);
                FastParametersOk = false;
                return(false);
            }
            // get pitch
            double pitch = 0;

            if (!double.TryParse(Grid.Rows[TapeNum].Cells["Pitch_Column"].Value.ToString().Replace(',', '.'), out pitch))
            {
                MainForm.ShowMessageBox(
                    "Bad data at Pitch column, tape ID: " + Grid.Rows[TapeNum].Cells["Id_Column"].Value.ToString(),
                    "Data error",
                    MessageBoxButtons.OK);
                return(false);
            }
            int last = first + ComponentCount - 1;

            //adjust for which part to measure - make sure that the one selected is not indexed
            //from the hole at the end of the cut tape strip, as that hole is often cut in half
            if (pitch < 6) //really 4 or less
            {
                --last;
            }
            if (pitch < 3) //really 2 or less
            {
                --last;
            }
            if (last < first)
            {
                last = first;
            }
            // measure holes
            double LastX  = 0.0;
            double LastY  = 0.0;
            double FirstX = 0.0;
            double FirstY = 0.0;

            if (!GetPartHole_m(TapeNum, last, out LastX, out LastY))
            {
                FastParametersOk = false;
                return(false);
            }
            if (last != first)
            {
                if (!GetPartHole_m(TapeNum, first, out FirstX, out FirstY))
                {
                    FastParametersOk = false;
                    return(false);
                }
            }
            else
            {
                FirstX = LastX;
                FirstY = LastY;
            }

            FastXpos = FirstX;
            FastYpos = FirstY;
            //test for a minimum of 2 complete holes - ie don't try to measure hold at the end of the tape, which is likely cut in half
            //measure and divide to calculate pitch for these
            if (last > first)
            {
                // if pitch == 2
                if ((pitch < 2.01) && (pitch > 1.99))
                {
                    int starthole      = (first + 1) / 2;
                    int lasthole       = (last + 1) / 2;
                    int HoleIncrements = lasthole - starthole;
                    if (HoleIncrements == 0)
                    {
                        FastXstep = 0.0;
                        FastYstep = 0.0;
                    }
                    else
                    {
                        FastXstep = (LastX - FirstX) / (double)HoleIncrements;
                        FastYstep = (LastY - FirstY) / (double)HoleIncrements;
                    }
                }
                else
                {
                    // normal case
                    FastXstep = (LastX - FirstX) / (double)(last - first);
                    FastYstep = (LastY - FirstY) / (double)(last - first);
                }
            }
            //if we had more than one component but could not measure multiple holes, just use the canned values for pitch
            else if (ComponentCount > 1)
            {
                switch (Grid.Rows[TapeNum].Cells["Orientation_Column"].Value.ToString())
                {
                case "+Y":
                    FastXstep = 0;
                    FastYstep = pitch;
                    break;

                case "+X":
                    FastXstep = pitch;
                    FastYstep = 0;
                    break;

                case "-Y":
                    FastXstep = 0;
                    FastYstep = -pitch;
                    break;

                case "-X":
                    FastXstep = -pitch;
                    FastYstep = 0;
                    break;

                default:
                    MainForm.ShowMessageBox(
                        "Bad data at Tape #" + TapeNum.ToString() + ", Orientation",
                        "Tape data error",
                        MessageBoxButtons.OK
                        );
                    return(false);
                }
            }
            else
            {
                FastXstep = 0.0;
                FastYstep = 0.0;
            }

            MainForm.DisplayText("Fast parameters:");
            MainForm.DisplayText("First X: " + FirstX.ToString() + ", Y: " + FirstY.ToString());
            MainForm.DisplayText("Last X: " + LastX.ToString() + ", Y: " + LastY.ToString());
            MainForm.DisplayText("Step X: " + FastXstep.ToString() + ", Y: " + FastYstep.ToString());

            return(true);
        }