253 lines
6.4 KiB
C#
253 lines
6.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Adaptation.FileHandlers.QS408M;
|
|
|
|
public class TXT
|
|
{
|
|
|
|
public Header Header { get; set; }
|
|
public Body Body { get; set; }
|
|
public Footer Footer { get; set; }
|
|
|
|
private int _I;
|
|
private readonly string _Data;
|
|
|
|
public TXT(string receivedData)
|
|
{
|
|
_I = 0;
|
|
Site site;
|
|
_Data = receivedData;
|
|
List<Site> sites = new();
|
|
string title = GetBefore("Recipe:");
|
|
string recipe = GetToken();
|
|
string dateTime = GetToEOL();
|
|
if (dateTime.EndsWith("."))
|
|
dateTime = dateTime.Remove(dateTime.Length - 1, 1);
|
|
ScanPast("operator:");
|
|
string @operator = GetBefore("batch:");
|
|
string batch = GetToEOL();
|
|
ScanPast("cassette:");
|
|
string cassette = GetBefore("wafer:");
|
|
if (string.IsNullOrEmpty(batch))
|
|
{
|
|
_I = 0;
|
|
_Data = receivedData;
|
|
ScanPast("wafer:");
|
|
}
|
|
string wafer = GetToEOL();
|
|
_ = GetToEOL();
|
|
_ = GetToEOL();
|
|
if (string.IsNullOrEmpty(wafer))
|
|
throw new Exception("Wafer field is missing.");
|
|
string token = GetToken();
|
|
while (true)
|
|
{
|
|
if (string.IsNullOrEmpty(token) || !char.IsDigit(token[0]))
|
|
break;
|
|
site = new()
|
|
{
|
|
Position = token,
|
|
Thickness = GetToken(),
|
|
};
|
|
sites.Add(site);
|
|
token = GetToken();
|
|
}
|
|
ScanPast("mean thickness =");
|
|
string meanThickness = GetBefore(", std. dev =");
|
|
string stdDev = GetToken();
|
|
string passFail = GetToEOL();
|
|
_ = GetToEOL();
|
|
_ = GetToEOL();
|
|
string line = GetToEOL();
|
|
ScanPast("thickness");
|
|
string radialVariationThickness = GetToEOL();
|
|
Header = new()
|
|
{
|
|
Title = title,
|
|
Recipe = recipe,
|
|
DateTime = dateTime,
|
|
Operator = @operator,
|
|
Batch = batch,
|
|
Cassette = cassette,
|
|
Wafer = wafer,
|
|
};
|
|
Body = new()
|
|
{
|
|
Sites = sites,
|
|
WaferMeanThickness = meanThickness,
|
|
StdDev = stdDev,
|
|
PassFail = passFail,
|
|
};
|
|
Footer = new()
|
|
{
|
|
Line = line,
|
|
RadialVariationThickness = radialVariationThickness,
|
|
};
|
|
}
|
|
|
|
private string GetBefore(string text)
|
|
{
|
|
string str;
|
|
string str1;
|
|
int num = _Data.IndexOf(text, _I);
|
|
if (num <= -1)
|
|
{
|
|
str = _Data.Substring(_I);
|
|
_I = _Data.Length;
|
|
str1 = str.Trim();
|
|
}
|
|
else
|
|
{
|
|
str = _Data.Substring(_I, num - _I);
|
|
_I = num + text.Length;
|
|
str1 = str.Trim();
|
|
}
|
|
return str1;
|
|
}
|
|
|
|
private string GetBefore(string text, bool trim)
|
|
{
|
|
string str;
|
|
string before;
|
|
if (!trim)
|
|
{
|
|
int num = _Data.IndexOf(text, _I);
|
|
if (num <= -1)
|
|
{
|
|
str = _Data.Substring(_I);
|
|
_I = _Data.Length;
|
|
before = str;
|
|
}
|
|
else
|
|
{
|
|
str = _Data.Substring(_I, num - _I);
|
|
_I = num + text.Length;
|
|
before = str;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
before = GetBefore(text);
|
|
}
|
|
return before;
|
|
}
|
|
|
|
private string GetToEOL()
|
|
{
|
|
string result;
|
|
if (_Data.IndexOf("\n", _I) > -1)
|
|
result = GetBefore("\n");
|
|
else
|
|
result = GetBefore(Environment.NewLine);
|
|
return result;
|
|
}
|
|
|
|
private string GetToEOL(bool trim)
|
|
{
|
|
string str;
|
|
if (_Data.IndexOf("\n", _I) > -1)
|
|
str = !trim ? GetBefore("\n", false) : GetToEOL();
|
|
else
|
|
str = !trim ? GetBefore(Environment.NewLine, false) : GetToEOL();
|
|
return str;
|
|
}
|
|
|
|
private string GetToken()
|
|
{
|
|
while (true)
|
|
{
|
|
if (_I >= _Data.Length || !IsNullOrWhiteSpace(_Data.Substring(_I, 1)))
|
|
{
|
|
break;
|
|
}
|
|
_I++;
|
|
}
|
|
int num = _I;
|
|
while (true)
|
|
{
|
|
if (num >= _Data.Length || IsNullOrWhiteSpace(_Data.Substring(num, 1)))
|
|
{
|
|
break;
|
|
}
|
|
num++;
|
|
}
|
|
string str = _Data.Substring(_I, num - _I);
|
|
_I = num;
|
|
return str.Trim();
|
|
}
|
|
|
|
private string GetToText(string text)
|
|
{
|
|
string str = _Data.Substring(_I, _Data.IndexOf(text, _I) - _I).Trim();
|
|
return str;
|
|
}
|
|
|
|
private bool IsBlankLine()
|
|
{
|
|
int num = _Data.IndexOf("\n", _I);
|
|
return IsNullOrWhiteSpace(num > -1 ? _Data.Substring(_I, num - _I) : _Data.Substring(_I));
|
|
}
|
|
|
|
private static bool IsNullOrWhiteSpace(string text)
|
|
{
|
|
bool flag;
|
|
int num = 0;
|
|
while (true)
|
|
{
|
|
if (num >= text.Length)
|
|
{
|
|
flag = true;
|
|
break;
|
|
}
|
|
else if (char.IsWhiteSpace(text[num]))
|
|
{
|
|
num++;
|
|
}
|
|
else
|
|
{
|
|
flag = false;
|
|
break;
|
|
}
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
private string PeekNextLine()
|
|
{
|
|
int num = _I;
|
|
string toEOL = GetToEOL();
|
|
_I = num;
|
|
return toEOL;
|
|
}
|
|
|
|
private void ScanPast(string text)
|
|
{
|
|
int num = _Data.IndexOf(text, _I);
|
|
if (num <= -1)
|
|
{
|
|
_I = _Data.Length;
|
|
}
|
|
else
|
|
{
|
|
_I = num + text.Length;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// Bio-Rad QS400MEPI Recipe: EP_8IN9PT Thu Apr 30 11:29:10 1970
|
|
// operator: J batch: BIORAD#2
|
|
// cassette: wafer: 52-589368-4445
|
|
// --------------------------------------------------------------------------------
|
|
// position thickness position thickness position thickness
|
|
// 1 45.735 2 46.536 3 46.742
|
|
// 4 46.015 5 46.648 6 45.366
|
|
// 7 46.263 8 46.512 9 46.373
|
|
// wafer mean thickness = 46.2433, std. dev = 0.4564 PASS
|
|
// ================================================================================
|
|
|
|
// Radial variation (computation B) PASS:
|
|
|
|
// thickness -2.7474
|