using Adaptation.Shared; using System; using System.Collections.Generic; using System.IO; using System.Text.Json; using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.QS408M; #nullable enable internal class Complete { public Complete(Header header, Body body, Footer footer) { Header = header; Body = body; Footer = footer; } public Header Header { get; } public Body Body { get; } public Footer Footer { get; } internal static string GetBefore(string text, int[] i, string search) { string str; string str1; int num = text.IndexOf(search, i[0]); if (num <= -1) { str = text.Substring(i[0]); i[0] = text.Length; str1 = str.Trim(); } else { str = text.Substring(i[0], num - i[0]); i[0] = num + search.Length; str1 = str.Trim(); } return str1; } internal static string GetToEOL(string text, int[] i) { string result; if (text.IndexOf("\n", i[0]) > -1) result = GetBefore(text, i, "\n"); else result = GetBefore(text, i, Environment.NewLine); return result; } internal static int ScanPast(string text, int[] i, string search) { int result; int num = text.IndexOf(search, i[0]); if (num <= -1) result = text.Length; else result = num + search.Length; return result; } internal static Complete? Get(Logistics logistics, List fileInfoCollection, Header[] lastHeader) { Complete? result; int[] i = new int[] { 0 }; string text = File.ReadAllText(logistics.ReportFullPath); Header? header = Header.Get(lastHeader, text, i); if (header is null) result = null; else { Body? body = Body.Get(text, i); if (body is null) result = null; else { Footer? footer = Footer.Get(text, i); if (footer is null) result = null; else { result = new(header, body, footer); FileInfo fileInfo = new($"{logistics.ReportFullPath}.json"); string json = JsonSerializer.Serialize(result, CompleteSourceGenerationContext.Default.Complete); File.WriteAllText(fileInfo.FullName, json); File.SetLastWriteTime(fileInfo.FullName, logistics.DateTimeFromSequence); fileInfoCollection.Add(fileInfo); } } } return result; } } // 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 [JsonSourceGenerationOptions(WriteIndented = true)] [JsonSerializable(typeof(Complete))] internal partial class CompleteSourceGenerationContext : JsonSerializerContext { }