Exemple #1
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Parses out the line and gets the required information from it
        /// </summary>
        /// <param name="processedLineStr">a line string without block terminator or format parameters</param>
        /// <param name="stateMachine">The state machine containing the implied modal values</param>
        /// <returns>z success, nz fail</returns>
        public override int ParseLine(string processedLineStr, ExcellonFileStateMachine stateMachine)
        {
            int  outInt       = -1;
            int  nextStartPos = 0;
            bool retBool;

            //DebugMessage("Excellon ParseLine(TChange) started");

            if (processedLineStr == null)
            {
                return(100);
            }
            if (processedLineStr.StartsWith("T") == false)
            {
                return(200);
            }

            // now the TCode line will have an T tag

            // LOOK FOR THE T TAG
            nextStartPos = 0;
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(processedLineStr, 'T', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > processedLineStr.Length))
            {
                // this is not an error - just means we did not find one
            }
            else
            {
                // this will have a integer number
                retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetInteger(processedLineStr, nextStartPos, ref outInt, ref nextStartPos);
                if (retBool != true)
                {
                    LogMessage("Excellon ParseLine(T) failed on call to ParseNumberFromString_TillNonDigit_RetInteger");
                    return(333);
                }
                else
                {
                    // set the value now
                    toolNumber = outInt;
                }
            }

            return(0);
        }
Exemple #2
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Parses out the line and gets the required information from it
        /// </summary>
        /// <param name="processedLineStr">a line string without block terminator or format parameters</param>
        /// <param name="stateMachine">The state machine containing the implied modal values</param>
        /// <returns>z success, nz fail</returns>
        public override int ParseLine(string processedLineStr, ExcellonFileStateMachine stateMachine)
        {
            int  outInt       = -1;
            int  nextStartPos = 0;
            bool retBool;

            //DebugMessage("Excellon ParseLine(M) started");

            if (processedLineStr == null)
            {
                return(100);
            }
            if (processedLineStr.StartsWith("G") == false)
            {
                return(200);
            }

            // now the GCode line will have an G tag

            // LOOK FOR THE G TAG
            nextStartPos = 0;
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(processedLineStr, 'G', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > processedLineStr.Length))
            {
                // this is not an error - just means we did not find one
                LogMessage("Excellon ParseLine(G) failed on call to FindCharacterReturnNextPos  no next char found.");
                return(101);
            }
            else
            {
                // this will have a integer number
                retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetInteger(processedLineStr, nextStartPos, ref outInt, ref nextStartPos);
                if (retBool != true)
                {
                    LogMessage("Excellon ParseLine(G) failed on call to ParseNumberFromString_TillNonDigit_RetInteger");
                    return(333);
                }
                else
                {
                    // set the value now
                    currentGCode = outInt;
                }

                // validate the GCode
                switch (currentGCode)
                {
                case 0:
                    // this is not ok, it is Rout Mode
                    LogMessage("Excellon ParseLine(G) code G00, routing mode is not supported");
                    return(1091);

                case 5:
                    // this is ok, it is just Drill Mode
                    return(0);

                case 90:
                    // this is ok, it is just absolute mode
                    return(0);

                case 91:
                    // this is not ok, it is incrememtal mode
                    LogMessage("Excellon ParseLine(G) code G91, incremental mode is not supported");
                    return(1095);

                default:
                    LogMessage("Excellon ParseLine(G) unknown code G" + CurrentGCode.ToString());
                    return(102);
                }
            }
        }
Exemple #3
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Parses out the line and gets the required information from it
        /// </summary>
        /// <param name="processedLineStr">a line string without block terminator or format parameters</param>
        /// <param name="stateMachine">The state machine containing the implied modal values</param>
        /// <returns>z success, nz fail</returns>
        public override int ParseLine(string processedLineStr, GerberFileStateMachine stateMachine)
        {
            int  outInt       = -1;
            int  nextStartPos = 0;
            bool retBool;

            //LogMessage("ParseLine(G) started");

            if (processedLineStr == null)
            {
                return(100);
            }
            if (processedLineStr.StartsWith("G") == false)
            {
                return(200);
            }

            // now the GCode line will have an G tag

            // LOOK FOR THE G TAG
            nextStartPos = 0;
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(processedLineStr, 'G', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > processedLineStr.Length))
            {
                // this is an error - we have to find one
                LogMessage("ParseLine(G) failed on call to FindCharacterReturnNextPos");
                return(332);
            }
            // this will have a float number
            retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetInteger(processedLineStr, nextStartPos, ref outInt, ref nextStartPos);
            if (retBool != true)
            {
                LogMessage("ParseLine(G) failed on call to ParseNumberFromString_TillNonDigit_RetInteger");
                return(333);
            }

            switch (outInt)
            {
            case 1:
            {
                // This is just an linear interpolation
                currentGCode = outInt;
                break;
            }

            case 4:
            {
                // This is just an Ignore data block we can just ignore its contents
                // set the value now
                currentGCode = outInt;
                break;
            }

            case 70:
            {
                // This is INCHES mode
                currentGCode = outInt;
                stateMachine.GerberFileUnits = ApplicationUnitsEnum.INCHES;
                break;
            }

            case 71:
            {
                // This is Millimeters mode
                currentGCode = outInt;
                stateMachine.GerberFileUnits = ApplicationUnitsEnum.MILLIMETERS;
                break;
            }

            case 75:
            {
                // This is just circular interpolation enabled
                // we ignore it
                currentGCode = outInt;
                break;
            }

            case 90:
            {
                // This is absolute coordinates enabled
                currentGCode = outInt;
                stateMachine.GerberFileCoordinateMode = GerberCoordinateModeEnum.COORDINATE_ABSOLUTE;
                break;
            }

            case 91:
            {
                // This is incremental coordinates enabled
                currentGCode = outInt;
                stateMachine.GerberFileCoordinateMode = GerberCoordinateModeEnum.COORDINATE_INCREMENTAL;
                break;
            }

            default:
            {
                LogMessage("ParseLine(G) failed. Unknown GCode of" + outInt.ToString());
                return(334);
            }
            }
            return(0);
        }
Exemple #4
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Populate the object from an Aperture Definition pararameter
        /// </summary>
        /// <param name="adParamBlock">The AD string param block, no param, or block
        /// delimiters. Just the AD block</param>
        /// <param name="nextStartPos">the next start position after all of the ADX leading text</param>
        /// <returns>z success, nz fail</returns>
        public override int PopulateFromParameter(string adParamBlock, int nextStartPos)
        {
            float outFloat = 0;
            bool  retBool;

            if (adParamBlock == null)
            {
                return(100);
            }
            if (adParamBlock.StartsWith(GerberFile.RS274_AD_CMD) == false)
            {
                return(200);
            }

            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                LogMessage("PopulateFromParameter (C) malformed adParamBlock. No data after comma");
                return(722);
            }

            // set this now
            DefinitionBlock = adParamBlock;

            // od x <XAxisHoleDimension> x <YAxisHoleDimension>
            retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetFloat(adParamBlock, nextStartPos, ref outFloat, ref nextStartPos);
            if (retBool != true)
            {
                LogMessage("PopulateFromParameter (Ca) failed on call to ParseNumberFromString_TillNonDigit_RetFloat");
                return(133);
            }
            else
            {
                // set the value now
                outerDiameter = outFloat;
            }
            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                // we are done
                return(0);
            }
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(adParamBlock, 'X', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                // this is not an error - just means we are all done
                return(0);
            }
            // ###
            // These are optional
            // ###
            retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetFloat(adParamBlock, nextStartPos, ref outFloat, ref nextStartPos);
            if (retBool != true)
            {
                LogMessage("PopulateFromParameter (Ce) failed on call to ParseNumberFromString_TillNonDigit_RetFloat");
                return(135);
            }
            else
            {
                // set the value now
                HoleDiameter = outFloat;
            }

            return(0);
        }
Exemple #5
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Parses out the line and gets the required information from it
        /// </summary>
        /// <param name="processedLineStr">a line string without block terminator or format parameters</param>
        /// <param name="stateMachine">The state machine containing the implied modal values</param>
        /// <returns>z success, nz fail</returns>
        public override int ParseLine(string processedLineStr, ExcellonFileStateMachine stateMachine)
        {
            float outFloat     = 0;
            int   outInt       = 0;
            int   nextStartPos = 0;
            bool  retBool;

            //LogMessage("ParseLine(XY) started");

            if (processedLineStr == null)
            {
                return(100);
            }
            if (processedLineStr.StartsWith("R") == false)
            {
                return(200);
            }

            // now the line will have some combination of R, X and Y tags in some order
            // LOOK FOR THE X TAG
            nextStartPos = 0;
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(processedLineStr, 'R', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > processedLineStr.Length))
            {
                // we have to have this
                LogMessage("ParseLine(R) lineNumber=" + LineNumber.ToString() + " failed. No R repeat quantity found.");
                return(3331);
            }
            else
            {
                // this will have a integer number
                retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetInteger(processedLineStr, nextStartPos, ref outInt, ref nextStartPos);
                if (retBool != true)
                {
                    LogMessage("ParseLine(R) failed on call to ParseNumberFromString_TillNonDigit_RetInteger");
                    return(3332);
                }
                else
                {
                    // set the value now
                    repeatCount = outInt;
                }
            }


            // LOOK FOR THE X TAG
            nextStartPos = 0;
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(processedLineStr, 'X', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > processedLineStr.Length))
            {
                // we have to have this
                LogMessage("ParseLine(R) lineNumber=" + LineNumber.ToString() + " failed. No X coordinate found.");
                return(1331);
            }
            else
            {
                // this will have a float number
                retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetFloat(processedLineStr, nextStartPos, ref outFloat, ref nextStartPos);
                if (retBool != true)
                {
                    // just means not found
                }
                else
                {
                    // set the value now
                    xOffset = DecimalScaleNumber(outFloat, stateMachine.ExcellonFileManager.DrillingNumberOfDecimalPlaces, stateMachine.ExcellonFileManager.DrillingCoordinateZerosMode);
                }
            }

            // LOOK FOR THE Y TAG
            nextStartPos = 0;
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(processedLineStr, 'Y', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > processedLineStr.Length))
            {
                // just means not found
            }
            else
            {
                // this will have a float number
                retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetFloat(processedLineStr, nextStartPos, ref outFloat, ref nextStartPos);
                if (retBool != true)
                {
                    LogMessage("ParseLine(R) failed on call to ParseNumberFromString_TillNonDigit_RetFloat");
                    return(2332);
                }
                else
                {
                    // set the value now
                    yOffset = DecimalScaleNumber(outFloat, stateMachine.ExcellonFileManager.DrillingNumberOfDecimalPlaces, stateMachine.ExcellonFileManager.DrillingCoordinateZerosMode);
                }
            }
            return(0);
        }
Exemple #6
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Populate the object from an Aperture Definition pararameter
        /// </summary>
        /// <param name="adParamBlock">The AD string param block, no param, or block
        /// delimiters. Just the AD block</param>
        /// <param name="nextStartPos">the next start position after all of the ADX leading text</param>
        /// <returns>z success, nz fail</returns>
        public override int PopulateFromParameter(string adParamBlock, int nextStartPos)
        {
            float outFloat = 0;
            bool  retBool;

            if (adParamBlock == null)
            {
                return(100);
            }
            if (adParamBlock.StartsWith(GerberFile.RS274_AD_CMD) == false)
            {
                return(200);
            }

            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                LogMessage("PopulateFromParameter (P) malformed adParamBlock. No data after comma");
                return(722);
            }

            // set this now
            DefinitionBlock = adParamBlock;

            // OutsideDimension x NumSides X <degreesRotation> x <HoleDiameter> x <YAxisHoleDimension>
            retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetFloat(adParamBlock, nextStartPos, ref outFloat, ref nextStartPos);
            if (retBool != true)
            {
                LogMessage("PopulateFromParameter (Pa) failed on call to ParseNumberFromString_TillNonDigit_RetFloat");
                return(163);
            }
            else
            {
                // set the value now
                outsideDimension = outFloat;
            }
            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                LogMessage("PopulateFromParameter (Pb) failed on call to ParseNumberFromString_TillNonDigit_RetFloat");
                return(1631);
            }
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(adParamBlock, 'X', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                LogMessage("PopulateFromParameter (Pc) failed on call to ParseNumberFromString_TillNonDigit_RetFloat");
                return(1631);
            }
            retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetFloat(adParamBlock, nextStartPos, ref outFloat, ref nextStartPos);
            if (retBool != true)
            {
                LogMessage("PopulateFromParameter (Pd) failed on call to ParseNumberFromString_TillNonDigit_RetFloat");
                return(164);
            }
            else
            {
                int workingNumSides = (int)outFloat;
                if (workingNumSides < 3)
                {
                    LogMessage("PopulateFromParameter (Pe) failed numSides < 3 is " + workingNumSides.ToString());
                    return(165);
                }
                // set the value now
                numSides = workingNumSides;
            }
            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                // we are done
                return(0);
            }
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(adParamBlock, 'X', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                // this is not an error - just means we are all done
                return(0);
            }
            // ###
            // These are optional
            // ###
            retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetFloat(adParamBlock, nextStartPos, ref outFloat, ref nextStartPos);
            if (retBool != true)
            {
                LogMessage("PopulateFromParameter (Pe) failed on call to ParseNumberFromString_TillNonDigit_RetFloat");
                return(166);
            }
            else
            {
                // set the value now
                DegreesRotation = outFloat;
            }
            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                // this is not an error - just means we are all done
                return(0);
            }
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(adParamBlock, 'X', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                // this is not an error - just means we are all done
                return(0);
            }
            retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetFloat(adParamBlock, nextStartPos, ref outFloat, ref nextStartPos);
            if (retBool != true)
            {
                // this is not an error - just means we are all done
                return(0);
            }
            else
            {
                // set the value now
                HoleDiameter = outFloat;
            }

            return(0);
        }
Exemple #7
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Parses out the line and gets the required information from it
        /// </summary>
        /// <param name="processedLineStr">a line string without block terminator or format parameters</param>
        /// <param name="stateMachine">The state machine containing the implied modal values</param>
        /// <returns>z success, nz fail</returns>
        public override int ParseLine(string processedLineStr, GerberFileStateMachine stateMachine)
        {
            float outFloat     = 0;
            int   nextStartPos = 0;
            bool  retBool;

            LogMessage("ParseLine(OF) started");

            if (processedLineStr == null)
            {
                return(100);
            }
            if (processedLineStr.StartsWith(GerberFile.RS274_OF_CMD) == false)
            {
                return(200);
            }

            // now the line will have some combination of A and B tags in some order
            // LOOK FOR THE A TAG
            nextStartPos = 0;
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(processedLineStr, 'A', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > processedLineStr.Length))
            {
                // just means not found
            }
            else
            {
                retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetFloat(processedLineStr, nextStartPos, ref outFloat, ref nextStartPos);
                if (retBool != true)
                {
                    // this is not an error - just means we are all done
                    return(0);
                }
                else
                {
                    // set the value now
                    xOffset = outFloat;
                }
            }

            // LOOK FOR THE B TAG
            nextStartPos = 0;
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(processedLineStr, 'B', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > processedLineStr.Length))
            {
                // just means not found
            }
            else
            {
                retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetFloat(processedLineStr, nextStartPos, ref outFloat, ref nextStartPos);
                if (retBool != true)
                {
                    // this is not an error - just means we are all done
                    return(0);
                }
                else
                {
                    // set the value now
                    yOffset = outFloat;
                }
            }
            return(0);
        }
Exemple #8
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Populate the object from an Aperture Definition prarameter
        /// </summary>
        /// <param name="adParamBlock">The AD string param block, no param, or block
        /// delimiters. Just the AD block</param>
        /// <returns>z success, nz fail</returns>
        public int PopulateFromParameter(string adParamBlock)
        {
            //DebugMessage("PopulateFromParameter() started");
            int  outInt       = -1;
            int  nextStartPos = -1;
            bool retBool;

            if (adParamBlock == null)
            {
                return(100);
            }
            if (adParamBlock.StartsWith(GerberFile.RS274_AD_CMD) == false)
            {
                return(200);
            }

            // convert to a character array
            char[] adChars = adParamBlock.ToCharArray();
            if (adChars == null)
            {
                return(300);
            }
            if (adChars.Length < 5)
            {
                return(400);
            }
            // we have to have a 'D' here to define the D number
            if (adChars[2] != 'D')
            {
                return(200);
            }

            // get the D number
            retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetInteger(adParamBlock, 3, ref outInt, ref nextStartPos);
            if (retBool != true)
            {
                LogMessage("PopulateFromParameter failed on call to ParseNumberFromString_TillNonDigit_RetInteger");
                return(322);
            }
            else
            {
                // set the dNumber now
                dNumber = outInt;
            }

            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                LogMessage("PopulateFromParameter malformed adParamBlock. No data after Dnumber");
                return(422);
            }

            // at this point we have to take care. if the aperature definitition contains one of a
            // specific set of chars then we are dealing with a normal aperture. If it does not it must
            // be a named aperture referring to a macro

            // set the aperture object
            adCodeAperture = GetApertureObjFromString(adParamBlock.Substring(nextStartPos));
            nextStartPos++;
            if (adCodeAperture == null)
            {
                LogMessage("PopulateFromParameter failed on call to GetApertureObjFromCharacter");
                return(522);
            }
            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                LogMessage("PopulateFromParameter malformed adParamBlock. No data after ADType");
                return(622);
            }

            // re-sync and position just after the ',' char in the aperture parameter definition
            nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(adParamBlock, ',', nextStartPos);
            if ((nextStartPos < 0) || (nextStartPos > adParamBlock.Length))
            {
                if ((adCodeAperture is GerberAperture_Macro) == false)
                {
                    // have to have this for normal apertures
                    LogMessage("PopulateFromParameter malformed adParamBlock. No data after comma");
                    return(722);
                }
                else
                {
                    // we are a macro aperture with no params
                    nextStartPos = adParamBlock.Length;
                }
            }

            // now let the aperture object populate itself
            int retInt = adCodeAperture.PopulateFromParameter(adParamBlock, nextStartPos);

            if (retInt != 0)
            {
                LogMessage("PopulateFromParameter call to adCodeAperture.PopulateFromParameter returned " + retInt.ToString());
                return(723);
            }

            return(0);
        }