100 lines
3.6 KiB
C#
100 lines
3.6 KiB
C#
using System;
|
|
|
|
namespace Adaptation.FileHandlers.QS408M;
|
|
|
|
#nullable enable
|
|
|
|
public class Header
|
|
{
|
|
|
|
public Header(string title, string recipe, string dateTime, string @operator, string batch, string cassette, bool usedLast, string wafer)
|
|
{
|
|
Title = title;
|
|
Recipe = recipe;
|
|
DateTime = dateTime;
|
|
Operator = @operator;
|
|
Batch = batch;
|
|
Cassette = cassette;
|
|
UsedLast = usedLast;
|
|
Wafer = wafer;
|
|
}
|
|
|
|
public string Title { get; }
|
|
public string Recipe { get; }
|
|
public string DateTime { get; }
|
|
public string Operator { get; }
|
|
public string Batch { get; }
|
|
public string Cassette { get; }
|
|
public bool UsedLast { get; }
|
|
public string Wafer { get; }
|
|
|
|
internal static Header Get() =>
|
|
new(string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
false,
|
|
string.Empty);
|
|
|
|
internal static Header? Get(Header[] lastHeader, string text, int[] i)
|
|
{
|
|
Header? result;
|
|
// occasionally there are multiple blocks of details, get the last one as earlier ones may be aborted runs.
|
|
int index = text.LastIndexOf("Bio-Rad");
|
|
if (index > -1)
|
|
text = text.Substring(index);
|
|
if (string.IsNullOrEmpty(text))
|
|
result = null;
|
|
else
|
|
{
|
|
bool usedLast;
|
|
const string twoSpaces = " ";
|
|
string title = Complete.GetBefore(text, i, "Recipe:");
|
|
string recipeAndDateTime = Complete.GetToEOL(text, i);
|
|
string recipe = recipeAndDateTime.Length < twoSpaces.Length ? recipeAndDateTime.Trim() : !recipeAndDateTime.Contains(twoSpaces) ? recipeAndDateTime.Substring(0, 25).Trim() : recipeAndDateTime.Split(new string[] { twoSpaces }, StringSplitOptions.None)[0].Trim();
|
|
string dateTime = recipeAndDateTime.Substring(recipe.Length).Trim();
|
|
if (dateTime.EndsWith("."))
|
|
dateTime = dateTime.Remove(dateTime.Length - 1, 1);
|
|
i[0] = Complete.ScanPast(text, i, "operator:");
|
|
string @operator = Complete.GetBefore(text, i, "batch:");
|
|
string batch = Complete.GetToEOL(text, i);
|
|
i[0] = Complete.ScanPast(text, i, "cassette:");
|
|
if (!text.Contains("cassette:"))
|
|
title = string.Empty;
|
|
string cassette = Complete.GetBefore(text, i, "wafer:");
|
|
if (string.IsNullOrEmpty(batch))
|
|
{
|
|
i[0] = 0;
|
|
i[0] = Complete.ScanPast(text, i, "wafer:");
|
|
}
|
|
string wafer = Complete.GetToEOL(text, i);
|
|
_ = Complete.GetToEOL(text, i);
|
|
_ = Complete.GetToEOL(text, i);
|
|
if (string.IsNullOrEmpty(wafer))
|
|
throw new Exception("Wafer field is missing.");
|
|
if (!string.IsNullOrEmpty(title))
|
|
usedLast = false;
|
|
else
|
|
{
|
|
title = lastHeader[0].Title;
|
|
recipe = lastHeader[0].Recipe;
|
|
@operator = lastHeader[0].Operator;
|
|
batch = lastHeader[0].Batch;
|
|
cassette = lastHeader[0].Cassette;
|
|
usedLast = true;
|
|
}
|
|
result = new(title: title,
|
|
recipe: recipe,
|
|
dateTime: dateTime,
|
|
@operator: @operator,
|
|
batch: batch,
|
|
cassette: cassette,
|
|
usedLast: usedLast,
|
|
wafer: wafer);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
} |