Refactor QS408M and PDSF File Handlers

- Updated Detail class to include JsonSourceGenerationOptions and JsonSerializable attributes for source generation.
- Modified ProcessData class to utilize source generation context for Description deserialization.
- Renamed RowSourceGenerationContext to QS408MRowSourceGenerationContext for clarity.
- Updated Run class to use QS408MRunSourceGenerationContext for serialization.
- Enhanced Description class with source generation attributes.
- Refactored FileRead class to use source generation context for Description deserialization.
- Added new methods in ProcessDataStandardFormat for JSON element array extraction.
- Introduced new PDSF file handler classes: Body, Constant, FileRead, Footer, Header, Row, Run, and Site.
- Implemented logic for parsing and handling PDSF data structures.
- Added unit tests for PDSF processing to ensure functionality.
This commit is contained in:
2025-09-15 11:37:05 -07:00
parent 515df7ec37
commit d07755c3a0
29 changed files with 869 additions and 204 deletions

View File

@ -110,10 +110,10 @@ public class FileRead : Shared.FileRead, IFileRead
return results;
}
private void SendData(string reportFullPath, DateTime dateTime, List<QS408M.Description> descriptions)
private void SendData(string reportFullPath, DateTime dateTime, JsonElement[] jsonElements, List<QS408M.Description> descriptions)
{
string checkDirectory;
WSRequest wsRequest = new(this, _Logistics, descriptions);
WSRequest wsRequest = new(this, _Logistics, jsonElements, descriptions);
int weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
string directory = Path.Combine(_OpenInsightMetrologyViewerFileShare, dateTime.Year.ToString(), $"WW{weekOfYear:00}");
checkDirectory = Path.Combine(directory, _Logistics.Sequence.ToString());
@ -139,14 +139,15 @@ public class FileRead : Shared.FileRead, IFileRead
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
string[] lines = File.ReadAllLines(reportFullPath);
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath, lines);
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
SetFileParameterLotIDToLogisticsMID();
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(reportFullPath, lines, processDataStandardFormat);
List<QS408M.Description> descriptions = QS408M.ProcessData.GetDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
SendData(reportFullPath, dateTime, descriptions);
SendData(reportFullPath, dateTime, jsonElements, descriptions);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics), tests, jsonElements, new List<FileInfo>());
return results;
}

View File

@ -4,6 +4,7 @@ using Adaptation.Shared.Properties;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
@ -37,7 +38,7 @@ public class WSRequest
[Obsolete("For json")] public WSRequest() { }
#pragma warning disable IDE0060
internal WSRequest(IFileRead fileRead, Logistics logistics, List<QS408M.Description> descriptions, string processDataStandardFormat = null)
internal WSRequest(IFileRead fileRead, Logistics logistics, JsonElement[] jsonElements, List<QS408M.Description> descriptions, string processDataStandardFormat = null)
#pragma warning restore IDE0060
{
Id = -1;
@ -48,10 +49,10 @@ public class WSRequest
Details = new List<QS408M.Detail>();
//Header
{
Batch = x.Lot;
Batch = x.Lot; // different name
Cassette = x.Cassette;
Date = x.Date;
Op = x.Employee;
Op = x.Employee; // different name
Layer = x.Layer;
MeanThickness = x.MeanThickness;
PSN = x.PSN;
@ -87,14 +88,14 @@ public class WSRequest
}
}
internal static long GetHeaderId(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string openInsightMetrologyViewerFileShare, int weekOfYear, WS.Results results, List<QS408M.Description> descriptions)
internal static long GetHeaderId(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string openInsightMetrologyViewerFileShare, int weekOfYear, WS.Results results, JsonElement[] jsonElements, List<QS408M.Description> descriptions)
{
long result;
if (results is not null && results.HeaderId is not null)
result = results.HeaderId.Value;
else
{
WSRequest wsRequest = new(fileRead, logistics, descriptions);
WSRequest wsRequest = new(fileRead, logistics, jsonElements, descriptions);
string directory = Path.Combine(openInsightMetrologyViewerFileShare, logistics.DateTimeFromSequence.Year.ToString(), $"WW{weekOfYear:00}");
(_, WS.Results wsResults) = WS.SendData(openInsightMetrologyViewerAPI, logistics.Sequence, directory, wsRequest);
if (wsResults.Success is null || !wsResults.Success.Value)