/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <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); }
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <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); }
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <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; float outFloat = 0; //DebugMessage("Excellon ParseLine(TTable) 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(TTable) failed on call to ParseNumberFromString_TillNonDigit_RetInteger"); return(333); } else { // set the value now toolNumber = outInt; } } // LOOK FOR THE C TAG nextStartPos = 0; nextStartPos = GerberParseUtils.FindCharacterReturnNextPos(processedLineStr, 'C', nextStartPos); if ((nextStartPos < 0) || (nextStartPos > processedLineStr.Length)) { // this is not an error - just means we did not find one } else { // this will have a float number, but it will already be decimal scaled retBool = GerberParseUtils.ParseNumberFromString_TillNonDigit_RetFloat(processedLineStr, nextStartPos, ref outFloat, ref nextStartPos); if (retBool != true) { LogMessage("Excellon ParseLine(TC) failed on call to ParseNumberFromString_TillNonDigit_RetFloat"); return(233); } else { // set the value now drillDiameter = outFloat; } } return(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); }
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <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); }