/// <summary> /// Tries to parse given laserscribe against laserscribe format this instance represents. /// </summary> /// <param name="laserscribe">The laserscribe to parse.</param> /// <param name="externalLot">Whether the given laserscribe should belong to an external lot (not from Onsemi) so it cannot contain PROMIS lot ID etc.</param> /// <returns>The information extracted from the laserscribe.</returns> /// <exception cref="System.FormatException">When parsing failed.</exception> /// <exception cref="System.ArgumentNullException">When some argument is <code>null</code>.</exception> public ParsedLaserscribe ParseLaserscribe(string laserscribe, bool externalLot) { if (laserscribe == null) { throw new ArgumentNullException("laserscribe"); } if (laserscribe.Length != mask.Length) { throw new FormatException("laserscribe length does not match format length"); } string actualMask = mask; //pric //if (externalLot) //{ // actualMask = actualMask.Replace('L', '?'); // actualMask = actualMask.Replace('1', '?'); // actualMask = actualMask.Replace('2', '?'); // actualMask = actualMask.Replace('3', '?'); // actualMask = actualMask.Replace('4', '?'); // actualMask = actualMask.Replace('5', '?'); //} string waferLocationCode = string.Empty; string lotId = string.Empty; StringBuilder serialNumberChars = new StringBuilder("?????"); string waferNumber = string.Empty; for (int i = 0; i < actualMask.Length; i++) { char maskChar = actualMask[i]; char parsedChar = laserscribe[i]; switch (maskChar) { case 'L': if(!externalLot) waferLocationCode += parsedChar; lotId += parsedChar; break; case '1': case '2': case '3': case '4': case '5': if (!externalLot) { if (Char.IsDigit(parsedChar)) { int idx = int.Parse(maskChar.ToString()) - 1; serialNumberChars[idx] = parsedChar; } else { throw new FormatException("expected digit on position " + i); } } lotId += parsedChar; break; case 'N': if (Char.IsDigit(parsedChar)) { waferNumber += parsedChar; } break; case 'W': if (Char.IsDigit(parsedChar)) { waferNumber += parsedChar; break; } else { throw new FormatException("expected digit on position " + i); } case 'C': case '?': break; default: if (maskChar != parsedChar) { throw new FormatException("expected char '" + maskChar + "' on position " + i); } break; } } ParsedLaserscribe result = new ParsedLaserscribe(); if ((waferLocationCode.Length != 0) && (waferLocationCode.Length != 2)) { throw new FormatException("wafer location code is not 2 characters long"); } if (waferLocationCode.Length == 0) { result.WaferLocationCode = null; } else { result.WaferLocationCode = waferLocationCode; } result.SerialNumber = serialNumberChars.ToString(); if (result.SerialNumber.Equals("?????")) { // no promis lot ID expected in laserscribe result.SerialNumber = null; } else if (result.SerialNumber.Contains("?")) { // promis lot ID does not contain all characters throw new FormatException("serial number is not 5 digits"); } if (lotId.Length > 0) { result.LotId = lotId; } else { result.LotId = null; } if (waferNumber.Length > 0) { result.WaferNumber = int.Parse(waferNumber); } else { result.WaferNumber = null; } return result; }
/// <summary> /// Tries to parse given laserscribe against laserscribe mask this instance represents. /// </summary> /// <param name="laserscribe">The laserscribe to parse.</param> /// <returns>The information extracted from the laserscribe.</returns> /// <exception cref="System.FormatException">When parsing failed.</exception> /// <exception cref="System.ArgumentNullException">When some argument is <code>null</code>.</exception> public ParsedLaserscribe ParseLaserscribe(string laserscribe) { if (laserscribe == null) { throw new ArgumentNullException("laserscribe"); } if (laserscribe.Length != mask.Length) { throw new FormatException("laserscribe length does not match format length"); } string actualMask = mask; string locationCode = null; string serialNumber = null; string parsedLotId = null; string waferNumber = null; for (int i = 0; i < actualMask.Length; i++) { char maskChar = actualMask[i]; char parsedChar = laserscribe[i]; switch (maskChar) { case 'l': parsedLotId += parsedChar; break; case 'L': locationCode += parsedChar; parsedLotId += parsedChar; break; case 'N': if (Char.IsDigit(parsedChar)) { string serialNumberChar = Convert.ToString(parsedChar); serialNumber += serialNumberChar; parsedLotId += serialNumberChar; } else { throw new FormatException("expected digit on position " + i); } break; case 'W': if (Char.IsDigit(parsedChar)) { waferNumber += parsedChar; break; } else { throw new FormatException("expected digit on position " + i); } case 'C': case '?': break; default: if (maskChar != parsedChar) { throw new FormatException("expected char '" + maskChar + "' on position " + i); } break; } } ParsedLaserscribe result = new ParsedLaserscribe(); if ((locationCode != null) && (locationCode.Length != 2)) { throw new FormatException("wafer location code is not 2 characters long"); } if (serialNumber != null && serialNumber.Length != 5) { throw new FormatException("serial number is not 5 digits"); } result.WaferLocationCode = locationCode; result.SerialNumber = serialNumber; result.LotId = parsedLotId; if (waferNumber != null) result.WaferNumber = Convert.ToInt32(waferNumber); else result.WaferNumber = null; return result; }