Initial Commit

This commit is contained in:
2023-05-08 15:54:57 -07:00
commit 5924860f6c
166 changed files with 19013 additions and 0 deletions

View File

@ -0,0 +1,27 @@
namespace Adaptation.FileHandlers.json;
public class CSV
{
#nullable enable
public string? FileVersion { get; }
public Info? Info { get; }
public Setup? Setup { get; }
public LayerHeader? LayerHeader { get; }
public ProfileHeader? ProfileHeader { get; }
public Calibration? Calibration { get; }
public RawData? RawData { get; }
internal CSV(csv.CSV csv)
{
FileVersion = csv.FileVersion;
Info = csv.Info is null ? null : new(csv.Info);
Setup = csv.Setup is null ? null : new(csv.Setup);
RawData = csv.RawData is null ? null : new(csv.RawData);
Calibration = csv.Calibration is null ? null : new(csv.Calibration);
LayerHeader = csv.LayerHeader is null ? null : new(csv.LayerHeader);
ProfileHeader = csv.ProfileHeader is null ? null : new(csv.ProfileHeader);
}
}

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
namespace Adaptation.FileHandlers.json;
public class Calibration
{
public int NumberOfCalibrationSets { get; }
public List<DataSet> DataSets { get; }
internal Calibration(csv.Calibration calibration)
{
DataSet dataSet;
Position position;
List<Position> positions;
List<DataSet> dataSets = new();
NumberOfCalibrationSets = int.Parse(calibration.NumberOfCalibrationSets);
DataSets = dataSets;
foreach (csv.DataSet csvDataSet in calibration.DataSets)
{
positions = new();
foreach (csv.Position csvPosition in csvDataSet.Positions)
{
position = new
(
resistivity: double.Parse(csvPosition.Resistivity),
resistance: double.Parse(csvPosition.Resistance),
percentStandardDeviation: double.Parse(csvPosition.PercentStandardDeviation),
number: int.Parse(csvPosition.Number),
name: csvPosition.Name
);
positions.Add(position);
}
dataSet = new
(
@operator: csvDataSet.Operator,
dateTime: DateTime.Parse(csvDataSet.DateTime),
finish: csvDataSet.Finish,
orientation: csvDataSet.Orientation,
northProbeID: csvDataSet.NorthProbeID,
southProbeID: csvDataSet.SouthProbeID,
polarity: csvDataSet.Polarity,
contactRadius: double.Parse(csvDataSet.ContactRadius),
probeSpacing: double.Parse(csvDataSet.ProbeSpacing),
load: double.Parse(csvDataSet.Load),
xStep: double.Parse(csvDataSet.XStep),
name: csvDataSet.Name,
plateId: csvDataSet.PlateId,
type: csvDataSet.Type,
pointsPerSample: int.Parse(csvDataSet.PointsPerSample),
numberOfPairs: int.Parse(csvDataSet.NumberOfPairs),
positions: positions
);
dataSets.Add(dataSet);
}
}
}

View File

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
namespace Adaptation.FileHandlers.json;
public class DataSet
{
public string Operator { get; }
public DateTime DateTime { get; }
public string Finish { get; }
public string Orientation { get; }
public string NorthProbeID { get; }
public string SouthProbeID { get; }
public string Polarity { get; }
public double ContactRadius { get; }
public double ProbeSpacing { get; }
public double Load { get; }
public double XStep { get; }
// public string SampleSet { get; }
public string Name { get; }
public string PlateId { get; }
public string Type { get; }
public int PointsPerSample { get; }
public int NumberOfPairs { get; }
public List<Position> Positions { get; }
public DataSet(string @operator,
DateTime dateTime,
string finish,
string orientation,
string northProbeID,
string southProbeID,
string polarity,
double contactRadius,
double probeSpacing,
double load,
double xStep,
string name,
string plateId,
string type,
int pointsPerSample,
int numberOfPairs,
List<Position> positions)
{
Operator = @operator;
DateTime = dateTime;
Finish = finish;
Orientation = orientation;
NorthProbeID = northProbeID;
SouthProbeID = southProbeID;
Polarity = polarity;
ContactRadius = contactRadius;
ProbeSpacing = probeSpacing;
Load = load;
XStep = xStep;
Name = name;
PlateId = plateId;
Type = type;
PointsPerSample = pointsPerSample;
NumberOfPairs = numberOfPairs;
Positions = positions;
}
}

View File

@ -0,0 +1,245 @@
using Adaptation.Shared;
using Adaptation.Shared.Methods;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
namespace Adaptation.FileHandlers.json;
public class Description : IDescription, Shared.Properties.IDescription
{
public int Test { get; set; }
public int Count { get; set; }
public int Index { get; set; }
//
public string EventName { get; set; }
public string NullData { get; set; }
public string JobID { get; set; }
public string Sequence { get; set; }
public string MesEntity { get; set; }
public string ReportFullPath { get; set; }
public string ProcessJobID { get; set; }
public string MID { get; set; }
//
public string Date { get; set; }
public string Employee { get; set; }
public string HeaderUniqueId { get; set; }
public string Layer { get; set; }
public string PSN { get; set; }
public string RDS { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
public string UniqueId { get; set; }
public string Zone { get; set; }
//
public string Number { get; set; }
public string Depth { get; set; }
public string Raw { get; set; }
public string Edited { get; set; }
public string Resistivity { get; set; }
public string CD { get; set; }
string IDescription.GetEventDescription() => "File Has been read and parsed";
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics)
{
List<string> results = new();
IDescription description = GetDefault(fileRead, logistics);
string json = JsonSerializer.Serialize(description, description.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
if (@object is not JsonElement jsonElement)
throw new Exception();
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
results.Add(jsonProperty.Name);
return results;
}
List<string> IDescription.GetDetailNames()
{
List<string> results = new()
{
nameof(HeaderUniqueId),
nameof(Layer),
nameof(RDS),
nameof(UniqueId),
nameof(Zone)
};
return results;
}
List<string> IDescription.GetHeaderNames()
{
List<string> results = new()
{
nameof(Date),
nameof(Employee),
nameof(PSN),
nameof(RDS),
nameof(Reactor),
nameof(Recipe)
};
return results;
}
IDescription IDescription.GetDisplayNames()
{
Description result = GetDisplayNames();
return result;
}
List<string> IDescription.GetParameterNames()
{
List<string> results = new()
{ };
return results;
}
JsonProperty[] IDescription.GetDefault(IFileRead fileRead, Logistics logistics)
{
JsonProperty[] results;
IDescription description = GetDefault(fileRead, logistics);
string json = JsonSerializer.Serialize(description, description.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
results = ((JsonElement)@object).EnumerateObject().ToArray();
return results;
}
List<string> IDescription.GetPairedParameterNames()
{
List<string> results = new();
return results;
}
List<string> IDescription.GetIgnoreParameterNames(Test test)
{
List<string> results = new();
return results;
}
IDescription IDescription.GetDefaultDescription(IFileRead fileRead, Logistics logistics)
{
Description result = GetDefault(fileRead, logistics);
return result;
}
Dictionary<string, string> IDescription.GetDisplayNamesJsonElement(IFileRead fileRead)
{
Dictionary<string, string> results = new();
IDescription description = GetDisplayNames();
string json = JsonSerializer.Serialize(description, description.GetType());
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
{
if (!results.ContainsKey(jsonProperty.Name))
results.Add(jsonProperty.Name, string.Empty);
if (jsonProperty.Value is JsonElement jsonPropertyValue)
results[jsonProperty.Name] = jsonPropertyValue.ToString();
}
return results;
}
List<IDescription> IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData)
{
List<IDescription> results = new();
if (iProcessData is null || !iProcessData.Details.Any() || iProcessData is not ProcessData processData)
results.Add(GetDefault(fileRead, logistics));
else
{
string nullData;
Description description;
object configDataNullData = fileRead.NullData;
if (configDataNullData is null)
nullData = string.Empty;
else
nullData = configDataNullData.ToString();
for (int i = 0; i < iProcessData.Details.Count; i++)
{
if (iProcessData.Details[i] is not Detail detail)
continue;
description = new Description
{
Test = (int)tests[i],
Count = tests.Count,
Index = i,
//
EventName = fileRead.EventName,
NullData = nullData,
JobID = fileRead.CellInstanceName,
Sequence = logistics.Sequence.ToString(),
MesEntity = logistics.MesEntity,
ReportFullPath = logistics.ReportFullPath,
ProcessJobID = logistics.ProcessJobID,
MID = logistics.MID,
//
Date = processData.Date.ToString(GetDateFormat()),
Employee = processData.Employee,
Layer = processData.Layer,
PSN = processData.PSN,
RDS = processData.RDS,
Reactor = processData.Reactor,
Recipe = processData.Recipe,
Zone = processData.Zone,
//
UniqueId = detail.UniqueId,
HeaderUniqueId = detail.HeaderUniqueId,
Depth = detail.Depth,
Raw = detail.Raw,
Edited = detail.Edited,
Resistivity = detail.Resistivity,
CD = detail.CD,
};
results.Add(description);
}
}
return results;
}
private static Description GetDisplayNames()
{
Description result = new();
return result;
}
private Description GetDefault(IFileRead fileRead, Logistics logistics)
{
Description result = new()
{
Test = -1,
Count = 0,
Index = -1,
//
EventName = fileRead.EventName,
NullData = fileRead.NullData,
JobID = fileRead.CellInstanceName,
Sequence = logistics.Sequence.ToString(),
MesEntity = fileRead.MesEntity,
ReportFullPath = logistics.ReportFullPath,
ProcessJobID = logistics.ProcessJobID,
MID = logistics.MID,
//
Date = nameof(Date),
Employee = nameof(Employee),
HeaderUniqueId = nameof(HeaderUniqueId),
Layer = nameof(Layer),
PSN = nameof(PSN),
RDS = nameof(RDS),
Reactor = nameof(Reactor),
Recipe = nameof(Recipe),
UniqueId = nameof(UniqueId),
Zone = nameof(Zone),
//
Number = nameof(Number),
Depth = nameof(Depth),
Raw = nameof(Raw),
Edited = nameof(Edited),
Resistivity = nameof(Resistivity),
CD = nameof(CD),
};
return result;
}
internal static string GetDateFormat() => "MM/dd/yyyy hh:mm:ss tt";
}

View File

@ -0,0 +1,25 @@
namespace Adaptation.FileHandlers.json;
public class Descriptor
{
public string Employee { get; private set; }
public string Layer { get; private set; }
public string PSN { get; private set; }
public string RDS { get; private set; }
public string Reactor { get; private set; }
public string Wafer { get; private set; }
public string Zone { get; private set; }
public Descriptor(string employee, string layer, string psn, string rds, string reactor, string wafer, string zone)
{
Employee = employee;
Layer = layer;
PSN = psn;
RDS = rds;
Reactor = reactor;
Wafer = wafer;
Zone = zone;
}
}

View File

@ -0,0 +1,14 @@
namespace Adaptation.FileHandlers.json;
public class Detail
{
public string HeaderUniqueId { get; set; }
public string UniqueId { get; set; }
public string Depth { get; set; }
public string Raw { get; set; }
public string Edited { get; set; }
public string Resistivity { get; set; }
public string CD { get; set; }
}

View File

@ -0,0 +1,130 @@
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
using Adaptation.Shared;
using Adaptation.Shared.Methods;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Text.RegularExpressions;
namespace Adaptation.FileHandlers.json;
public class FileRead : Shared.FileRead, IFileRead
{
private long? _TickOffset;
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), true, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
{
_MinFileLength = 10;
_NullData = string.Empty;
_Logistics = new(this);
if (_FileParameter is null)
throw new Exception(cellInstanceConnectionName);
if (_ModelObjectParameterDefinitions is null)
throw new Exception(cellInstanceConnectionName);
if (_IsDuplicator)
throw new Exception(cellInstanceConnectionName);
}
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults);
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
string IFileRead.GetEventDescription()
{
string result = _Description.GetEventDescription();
return result;
}
List<string> IFileRead.GetHeaderNames()
{
List<string> results = _Description.GetHeaderNames();
return results;
}
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
{
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
return results;
}
JsonProperty[] IFileRead.GetDefault()
{
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
return results;
}
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
{
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
return results;
}
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
{
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
return results;
}
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
if (string.IsNullOrEmpty(eventName))
throw new Exception();
_ReportFullPath = reportFullPath;
DateTime dateTime = DateTime.Now;
results = GetExtractResult(reportFullPath, dateTime);
if (results.Item3 is null)
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, Array.Empty<Test>(), JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
if (results.Item3.Length > 0 && _IsEAFHosted)
WritePDSF(this, results.Item3);
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
return results;
}
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
List<string> headerNames = _Description.GetHeaderNames();
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
results = ReExtract(this, headerNames, keyValuePairs);
return results;
}
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
_TickOffset ??= new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks;
_Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true);
SetFileParameterLotIDToLogisticsMID();
if (_Logistics.FileInfo.Length < _MinFileLength)
results.Item4.Add(_Logistics.FileInfo);
else
{
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, tickOffset: _TickOffset.Value);
if (iProcessData is not ProcessData processData)
throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks));
string mid;
if (!string.IsNullOrEmpty(processData.Zone) && string.IsNullOrEmpty(processData.Reactor) && string.IsNullOrEmpty(processData.RDS) && string.IsNullOrEmpty(processData.PSN))
mid = processData.Zone;
else if (!string.IsNullOrEmpty(processData.Employee) && string.IsNullOrEmpty(processData.Reactor) && string.IsNullOrEmpty(processData.RDS) && string.IsNullOrEmpty(processData.PSN))
mid = processData.Employee;
else
{
mid = string.Concat(processData.Reactor, "-", processData.RDS, "-", processData.PSN);
mid = Regex.Replace(mid, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
}
SetFileParameterLotID(mid);
_Logistics.Update(mid, processData.Reactor);
if (!iProcessData.Details.Any())
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks));
results = iProcessData.GetResults(this, _Logistics, results.Item4);
}
return results;
}
}

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
namespace Adaptation.FileHandlers.json;
public class Info
{
public string Operator { get; }
public string SampleName { get; }
public string SoftwareVersion { get; }
public DateTime DateTime { get; }
public string SystemId { get; }
public string SystemSite { get; }
public int SamplePosition { get; }
public int Units { get; }
public int CommentLength { get; }
public List<string> Comments { get; }
internal Info(csv.Info info)
{
Operator = info.Operator;
SampleName = info.SampleName;
SoftwareVersion = info.SoftwareVersion;
DateTime = DateTime.Parse(info.DateTime);
SystemId = info.SystemId;
SystemSite = info.SystemSite;
SamplePosition = int.Parse(info.SamplePosition);
Units = int.Parse(info.Units);
CommentLength = int.Parse(info.CommentLength);
Comments = info.Comments;
}
}

View File

@ -0,0 +1,55 @@
namespace Adaptation.FileHandlers.json;
public class Layer
{
public int FirstPoint { get; }
public int? LastPoint { get; }
public string Type { get; }
public string Smoothing { get; }
public string Apply { get; }
public int SOrder { get; }
public int GOrder { get; }
public string Correction { get; }
public string Conversion { get; }
public string JunctionOption { get; }
public int JunctionConstant { get; }
public double CurrentDensity { get; }
public string M1M2Tolerance { get; }
public string Sheet { get; }
public string Dose { get; }
public Layer(int firstPoint,
int? lastPoint,
string type,
string smoothing,
string apply,
int sOrder,
int gOrder,
string correction,
string conversion,
string junctionOption,
int junctionConstant,
double currentDensity,
string m1M2Tolerance,
string sheet,
string dose)
{
FirstPoint = firstPoint;
LastPoint = lastPoint;
Type = type;
Smoothing = smoothing;
Apply = apply;
SOrder = sOrder;
GOrder = gOrder;
Correction = correction;
Conversion = conversion;
JunctionOption = junctionOption;
JunctionConstant = junctionConstant;
CurrentDensity = currentDensity;
M1M2Tolerance = m1M2Tolerance;
Sheet = sheet;
Dose = dose;
}
}

View File

@ -0,0 +1,41 @@
using System.Collections.Generic;
namespace Adaptation.FileHandlers.json;
public class LayerHeader
{
public int NumberOfLayers { get; }
public List<Layer> Layers { get; }
internal LayerHeader(csv.LayerHeader layerHeader)
{
Layer layer;
List<Layer> layers = new();
NumberOfLayers = int.Parse(layerHeader.NumberOfLayers);
Layers = layers;
foreach (csv.Layer csvLayer in layerHeader.Layers)
{
layer = new
(
firstPoint: int.Parse(csvLayer.FirstPoint),
lastPoint: string.IsNullOrEmpty(csvLayer.LastPoint) ? null : int.Parse(csvLayer.LastPoint),
type: csvLayer.Type,
smoothing: csvLayer.Smoothing,
apply: csvLayer.Apply,
sOrder: int.Parse(csvLayer.SOrder),
gOrder: int.Parse(csvLayer.GOrder),
correction: csvLayer.Correction,
conversion: csvLayer.Conversion,
junctionOption: csvLayer.JunctionOption,
junctionConstant: int.Parse(csvLayer.JunctionConstant),
currentDensity: double.Parse(csvLayer.CurrentDensity),
m1M2Tolerance: csvLayer.M1M2Tolerance,
sheet: csvLayer.Sheet,
dose: csvLayer.Dose
);
layers.Add(layer);
}
}
}

View File

@ -0,0 +1,31 @@
namespace Adaptation.FileHandlers.json;
public class Point
{
public double Number { get; }
public double Depth { get; }
public double Resistance { get; }
public double StageX { get; }
public double StageY { get; }
public double StageZ { get; }
public double StageT { get; }
public Point(double number,
double depth,
double resistance,
double stageX,
double stageY,
double stageZ,
double stageT)
{
Number = number;
Depth = depth;
Resistance = resistance;
StageX = stageX;
StageY = stageY;
StageZ = stageZ;
StageT = stageT;
}
}

View File

@ -0,0 +1,25 @@
namespace Adaptation.FileHandlers.json;
public class Position
{
public double Resistivity { get; }
public double Resistance { get; }
public double PercentStandardDeviation { get; }
public int Number { get; }
public string Name { get; }
public Position(double resistivity,
double resistance,
double percentStandardDeviation,
int number,
string name)
{
Resistivity = resistivity;
Resistance = resistance;
PercentStandardDeviation = percentStandardDeviation;
Number = number;
Name = name;
}
}

View File

@ -0,0 +1,558 @@
using Adaptation.Shared;
using Adaptation.Shared.Methods;
using log4net;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
namespace Adaptation.FileHandlers.json;
public partial class ProcessData : IProcessData
{
private readonly List<object> _Details;
public DateTime Date { get; set; }
public string Employee { get; set; }
public string JobID { get; set; }
public string Layer { get; set; }
public string MesEntity { get; set; }
public string PSN { get; set; }
public string RDS { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
public string Zone { get; set; }
List<object> Shared.Properties.IProcessData.Details => _Details;
private readonly ILog _Log;
public ProcessData()
{
}
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, long tickOffset)
{
JobID = logistics.JobID;
fileInfoCollection.Clear();
_Details = new List<object>();
MesEntity = logistics.MesEntity;
_Log = LogManager.GetLogger(typeof(ProcessData));
CSV csv = Parse(fileRead, logistics, fileInfoCollection);
_ = GetImageBytes(csv);
string directory = Path.GetDirectoryName(logistics.ReportFullPath);
string fileName = Path.Combine(directory, $"{Path.GetFileNameWithoutExtension(logistics.ReportFullPath)}.data.json");
string json = JsonSerializer.Serialize(csv, new JsonSerializerOptions { WriteIndented = true });
File.WriteAllText(fileName, json);
if (!string.IsNullOrEmpty(csv.Info?.SampleName) && csv.ProfileHeader.ProfilePoints.Any())
SetValues(logistics, tickOffset, csv);
}
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse)));
Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
List<Test> tests = new();
foreach (object item in _Details)
tests.Add(Test.SRP2100);
List<IDescription> descriptions = fileRead.GetDescriptions(fileRead, tests, this);
if (tests.Count != descriptions.Count)
throw new Exception();
for (int i = 0; i < tests.Count; i++)
{
if (descriptions[i] is not Description description)
throw new Exception();
if (description.Test != (int)tests[i])
throw new Exception();
}
List<Description> fileReadDescriptions = (from l in descriptions select (Description)l).ToList();
string json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType());
JsonElement[] jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(logistics.Logistics1[0], tests.ToArray(), jsonElements, fileInfoCollection);
return results;
}
internal static DateTime GetDateTime(Logistics logistics, long tickOffset, DateTime dateTime)
{
DateTime result;
if (dateTime < logistics.DateTimeFromSequence.AddDays(1) && dateTime > logistics.DateTimeFromSequence.AddDays(-1))
result = new(dateTime.Ticks + tickOffset);
else
result = logistics.DateTimeFromSequence;
return result;
}
private static (string, string) GetReactorAndRDS(string defaultReactor, string defaultRDS, string text, string formattedText, string[] segments)
{
string rds;
string reactor;
if (string.IsNullOrEmpty(text) || segments.Length == 0 || string.IsNullOrEmpty(formattedText))
reactor = defaultReactor;
else
reactor = segments[0];
if (segments.Length <= 1 || !int.TryParse(segments[1], out int rdsValue) || rdsValue < 99)
rds = defaultRDS;
else
rds = segments[1];
if (reactor.Length > 3)
{
rds = reactor;
reactor = defaultReactor;
}
return new(reactor, rds);
}
private static (string, string) GetLayerAndPSN(string defaultLayer, string defaultPSN, string[] segments)
{
string psn;
string layer;
if (segments.Length <= 2)
{
psn = defaultPSN;
layer = defaultLayer;
}
else
{
string[] segmentsB = segments[2].Split('.');
psn = segmentsB[0];
if (segmentsB.Length <= 1)
layer = defaultLayer;
else
{
layer = segmentsB[1];
if (layer.Length > 1 && layer[0] == '0')
layer = layer.Substring(1);
}
}
return (layer, psn);
}
private static string GetZone(string[] segments)
{
string result;
if (segments.Length <= 3)
result = string.Empty;
else
{
result = segments[3];
if (result.Length > 1 && result[0] == '0')
result = result.Substring(1);
}
return result;
}
public static Descriptor GetDescriptor(string text)
{
Descriptor result;
string psn;
string rds;
string zone;
string layer;
string wafer;
string reactor;
string employee;
string defaultPSN = string.Empty;
string defaultRDS = string.Empty;
string defaultZone = string.Empty;
string defaultLayer = string.Empty;
string defaultReactor = string.Empty;
string defaultEmployee = string.Empty;
if (Regex.IsMatch(text, @"^[a-zA-z][0-9]{2,4}$"))
{
wafer = text.ToUpper();
psn = defaultPSN;
rds = defaultRDS;
zone = defaultZone;
layer = defaultLayer;
reactor = defaultReactor;
employee = defaultEmployee;
}
else if (string.IsNullOrEmpty(text) || (text.Length is 2 or 3 && Regex.IsMatch(text, "^[a-zA-z]{2,3}")))
{
wafer = text;
employee = text;
psn = defaultPSN;
rds = defaultRDS;
zone = defaultZone;
layer = defaultLayer;
reactor = defaultReactor;
}
else if (Regex.IsMatch(text, @"^[0-9]{2}[.][0-9]{1}[.]?[0-9]{0,1}"))
{
string[] segments = text.Split('.');
wafer = text;
psn = defaultPSN;
rds = defaultRDS;
layer = segments[1];
reactor = segments[0];
employee = defaultEmployee;
if (segments.Length <= 2)
zone = defaultZone;
else
zone = segments[2];
}
else
{
// Remove illegal characters \/:*?"<>| found in the Batch
wafer = Regex.Replace(text, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
if (wafer.Length > 2 && wafer[0] == '1' && (wafer[1] == 'T' || wafer[1] == 't'))
wafer = wafer.Substring(2);
string[] segments = wafer.Split('-');
// bool hasRDS = Regex.IsMatch(wafer, "[-]?([QP][0-9]{4,}|[0-9]{5,})[-]?");
(reactor, rds) = GetReactorAndRDS(defaultReactor, defaultRDS, text, wafer, segments);
(layer, psn) = GetLayerAndPSN(defaultLayer, defaultPSN, segments);
zone = GetZone(segments);
if (segments.Length <= 4)
employee = defaultEmployee;
else
employee = segments[4];
}
result = new(employee, layer, psn, rds, reactor, wafer, zone);
return result;
}
#pragma warning disable IDE0060
private static CSV Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
#pragma warning restore IDE0060
{
CSV result;
string json = File.ReadAllText(logistics.ReportFullPath);
string directory = Path.GetDirectoryName(logistics.ReportFullPath);
string fileName = Path.Combine(directory, $"{Path.GetFileNameWithoutExtension(logistics.ReportFullPath)}.csv");
csv.CSV csv = JsonSerializer.Deserialize<csv.CSV>(json);
if (csv is null)
throw new NullReferenceException(nameof(csv));
result = new(csv);
if (File.Exists(fileName))
fileInfoCollection.Add(new(fileName));
fileInfoCollection.Add(logistics.FileInfo);
return result;
}
private void SetValues(Logistics logistics, long tickOffset, CSV csv)
{
string psn;
string rds;
string zone;
string layer;
Detail detail;
string reactor;
List<Detail> details = new();
string recipe = csv.Info.SampleName;
string employee = csv.Info.Operator;
string timeFormat = "yyyyMMddHHmmss";
DateTime dateTime = GetDateTime(logistics, tickOffset, csv.Info.DateTime);
string uniqueId = string.Concat(logistics.MesEntity, "_", logistics.DateTimeFromSequence.ToString(timeFormat));
// Remove illegal characters \/:*?"<>| found in the Batch
Descriptor descriptor = GetDescriptor(csv.Info.SampleName);
psn = descriptor.PSN;
rds = descriptor.RDS;
zone = descriptor.Zone;
layer = descriptor.Layer;
reactor = descriptor.Reactor;
if (string.IsNullOrEmpty(employee))
employee = descriptor.Employee;
PSN = psn;
RDS = rds;
Date = dateTime;
Zone = zone;
Layer = layer;
Recipe = recipe;
Reactor = reactor;
Employee = employee;
JobID = logistics.JobID;
foreach (ProfilePoint profilePoint in csv.ProfileHeader.ProfilePoints)
{
detail = new()
{
HeaderUniqueId = uniqueId,
UniqueId = string.Concat(uniqueId, "_Point-", profilePoint.Number),
Depth = profilePoint.Depth.ToString(),
Raw = profilePoint.Raw.ToString(),
Edited = string.Concat(profilePoint.Edited),
Resistivity = string.Concat(profilePoint.Resistivity),
CD = string.Concat(profilePoint.CD),
};
details.Add(detail);
}
_Details.AddRange(details);
}
#nullable enable
#pragma warning disable CA1416
internal static List<Description> GetDescriptions(JsonElement[] jsonElements)
{
List<Description> results = new();
Description? description;
JsonSerializerOptions jsonSerializerOptions = new() { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
foreach (JsonElement jsonElement in jsonElements)
{
if (jsonElement.ValueKind != JsonValueKind.Object)
throw new Exception();
description = JsonSerializer.Deserialize<Description>(jsonElement.ToString(), jsonSerializerOptions);
if (description is null)
continue;
results.Add(description);
}
return results;
}
private static void GetMinMax(List<ProfilePoint> profilePoints, out double maxDepth, out int concentrationMaxD, out int concentrationMinD, out int resistanceEditedMaxD, out int resistanceEditedMinD, out int resistivityMaxD, out int resistivityMinD)
{
maxDepth = 30;
concentrationMaxD = -99;
concentrationMinD = 99;
resistanceEditedMaxD = -99;
resistanceEditedMinD = 99;
resistivityMaxD = -99;
resistivityMinD = 99;
foreach (ProfilePoint profilePoint in profilePoints)
{
if (profilePoint.Depth > 0 && profilePoint.Edited is not null && profilePoint.Resistivity is not null && profilePoint.CD is not null)
{
maxDepth = profilePoint.Depth;
if (Math.Log10(profilePoint.Resistivity.Value) < resistivityMinD)
resistivityMinD = (int)Math.Log10(profilePoint.Resistivity.Value);
if (Math.Ceiling(Math.Log10(profilePoint.Resistivity.Value)) > resistivityMaxD)
resistivityMaxD = (int)Math.Ceiling(Math.Log10(profilePoint.Resistivity.Value));
if (Math.Log10(profilePoint.Edited.Value) < resistanceEditedMinD)
resistanceEditedMinD = (int)Math.Log10(profilePoint.Edited.Value);
if (Math.Ceiling(Math.Log10(profilePoint.Edited.Value)) > resistanceEditedMaxD)
resistanceEditedMaxD = (int)Math.Ceiling(Math.Log10(profilePoint.Edited.Value));
if (Math.Log10(profilePoint.CD.Value) < concentrationMinD)
concentrationMinD = (int)Math.Log10(profilePoint.CD.Value);
if (Math.Ceiling(Math.Log10(profilePoint.CD.Value)) > concentrationMaxD)
concentrationMaxD = (int)Math.Ceiling(Math.Log10(profilePoint.CD.Value));
}
}
}
private static PointF GetPointF(double x, double y) =>
new((float)x, (float)y);
private static RectangleF GetRectangleF(double left, double top, double width, double height) =>
new((float)left, (float)top, (float)width, (float)height);
private static void DrawLine(Graphics graphics, Pen pen, double x1, double y1, double x2, double y2) =>
graphics.DrawLine(pen, (float)x1, (float)y1, (float)x2, (float)y2);
private static void DrawString(Graphics graphics, string s, Font font, Brush brush, double x, double y) =>
graphics.DrawString(s, font, brush, (float)x, (float)y);
private static void FillEllipse(Graphics graphics, Brush brush, double x, double y, double width, double height) =>
graphics.FillEllipse(brush, (float)x, (float)y, (float)width, (float)height);
private static void DrawString(Graphics graphics, string s, Font font, Brush brush, double x, double y, StringFormat stringFormat) =>
graphics.DrawString(s, font, brush, (float)x, (float)y, stringFormat);
internal static byte[] GetImageBytes(CSV csv)
{
if (csv.Info is null)
throw new NullReferenceException(nameof(csv.Info));
if (csv.Setup is null)
throw new NullReferenceException(nameof(csv.Setup));
if (csv.ProfileHeader is null)
throw new NullReferenceException(nameof(csv.ProfileHeader));
if (csv.LayerHeader is null)
throw new NullReferenceException(nameof(csv.LayerHeader));
double maxDepth;
int concentrationMaxD, concentrationMinD, resistanceEditedMaxD, resistanceEditedMinD, resistivityMaxD, resistivityMinD;
GetMinMax(csv.ProfileHeader.ProfilePoints, out maxDepth, out concentrationMaxD, out concentrationMinD, out resistanceEditedMaxD, out resistanceEditedMinD, out resistivityMaxD, out resistivityMinD);
int decades;
byte[] bytes;
double point;
int width = 694;
int height = 714;
int position = -1;
Pen pen = Pens.Black;
int blocksOfDepth = 6;
RectangleF[] rectangles;
double topChartArea = 90;
double widthOfDepthBlock;
double leftChartArea = 60;
double widthOfBlacks = 120;
Brush brush = Brushes.Black;
double widthChartArea = 500;
double heightChartArea = 600;
StringBuilder layers = new();
Font consolas = new("Consolas", 9);
PointF[]? resistivityPoints = null;
StringFormat sfFormatRight = new();
Color backgroundColor = Color.White;
PointF[]? concentrationPoints = null;
Brush resistivityBrush = Brushes.Green;
Brush concentrationBrush = Brushes.Blue;
Brush resistanceRawBrush = Brushes.Black;
Pen resistivityPen = new(Color.Green, 2);
Brush resistanceEditedBrush = Brushes.Red;
double sizeOfBlock = heightChartArea / 18;
Pen concentrationPen = new(Color.Blue, 2);
Brush backgroundBrush = Brushes.WhiteSmoke;
Pen resistanceRawPen = new(Color.Black, 2);
Pen transitionWidthPen = new(Color.Orange);
Pen resistanceEditedPen = new(Color.Red, 2);
Font consolasBold = new("Consolas", 9); // , FontStyle.Bold)
concentrationPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
concentrationPen.DashPattern = new float[] { 5, 4 };
resistanceEditedPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
resistanceEditedPen.DashPattern = new float[] { 1, 3 };
resistanceRawPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
resistanceRawPen.DashPattern = new float[] { 1, 3 };
transitionWidthPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
transitionWidthPen.DashPattern = new float[] { 5, 4 };
sfFormatRight.Alignment = StringAlignment.Far;
Bitmap bitmap = new(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics graphics = Graphics.FromImage(bitmap);
graphics.Clear(backgroundColor);
widthOfDepthBlock = Math.Ceiling(maxDepth / 3) * 3 / 6;
// maxDepth = widthOfDepthBlock * blocksOfDepth;
decades = resistivityMaxD - resistivityMinD;
if (resistanceEditedMaxD - resistanceEditedMinD > decades)
decades = resistanceEditedMaxD - resistanceEditedMinD;
if (concentrationMaxD - concentrationMinD > decades)
decades = concentrationMaxD - concentrationMinD;
rectangles = new RectangleF[1];
rectangles[0] = GetRectangleF(leftChartArea, topChartArea, widthChartArea, heightChartArea);
graphics.FillRectangles(backgroundBrush, rectangles);
rectangles = new RectangleF[18];
rectangles[0] = GetRectangleF(leftChartArea, 10, widthChartArea, 65);
// rectangles[1] = GetRectangleF(leftChartArea + widthChartArea, topChartArea, widthOfBlacks, sizeOfBlock * 5);
rectangles[1] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 0, widthOfBlacks, sizeOfBlock);
rectangles[2] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 1, widthOfBlacks, sizeOfBlock);
rectangles[3] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 2, widthOfBlacks, sizeOfBlock);
rectangles[4] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 3, widthOfBlacks, sizeOfBlock);
rectangles[5] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 4, widthOfBlacks, sizeOfBlock);
rectangles[6] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 5, widthOfBlacks, sizeOfBlock);
rectangles[7] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 6, widthOfBlacks, sizeOfBlock);
rectangles[8] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 7, widthOfBlacks, sizeOfBlock);
rectangles[9] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 8, widthOfBlacks, sizeOfBlock);
rectangles[10] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 9, widthOfBlacks, sizeOfBlock);
rectangles[11] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 10, widthOfBlacks, sizeOfBlock);
rectangles[12] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 11, widthOfBlacks, sizeOfBlock);
rectangles[13] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 12, widthOfBlacks, sizeOfBlock);
rectangles[14] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 13, widthOfBlacks, sizeOfBlock);
rectangles[15] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 14, widthOfBlacks, sizeOfBlock);
rectangles[16] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 15, widthOfBlacks, sizeOfBlock);
rectangles[17] = GetRectangleF(leftChartArea + widthChartArea, topChartArea + sizeOfBlock * 16, widthOfBlacks, sizeOfBlock * 2);
graphics.FillRectangles(Brushes.White, rectangles);
graphics.DrawRectangles(pen, rectangles);
foreach (Layer layer in csv.LayerHeader.Layers)
_ = layers.AppendLine(string.Concat("First Pt. ", layer.FirstPoint, " Last Pt. ", layer.LastPoint, " Type ", layer.Type, " Smoothing ", layer.Smoothing, " Correction ", layer.Correction));
_ = layers.AppendLine(string.Join(" ", csv.Info.Comments));
graphics.DrawString(layers.ToString(), consolas, brush, rectangles[0]);
graphics.DrawString(string.Concat(csv.Info.SystemId, Environment.NewLine, csv.Info.SoftwareVersion), consolas, brush, rectangles[9]);
graphics.DrawString(string.Concat("SURFACE FINISH", Environment.NewLine, csv.Setup.Finish), consolas, brush, rectangles[10]);
graphics.DrawString(string.Concat("ORIENTATION", Environment.NewLine, csv.Setup.Orientation), consolas, brush, rectangles[11]);
graphics.DrawString(string.Concat("BEVEL ANGLE", Environment.NewLine, csv.Setup.SineBevelAngle), consolas, brush, rectangles[12]);
graphics.DrawString(string.Concat("X-STEP (um)", Environment.NewLine, csv.Setup.Steps.First().X), consolas, brush, rectangles[13]);
graphics.DrawString(string.Concat("PROBE LOAD (gm)", Environment.NewLine, csv.Setup.ProbeLoad), consolas, brush, rectangles[14]);
graphics.DrawString(string.Concat("SPACING (um)", Environment.NewLine, csv.Setup.ProbeSpacing), consolas, brush, rectangles[15]);
graphics.DrawString(string.Concat("OPERATOR", Environment.NewLine, csv.Info.Operator), consolas, brush, rectangles[16]);
graphics.DrawString(string.Concat("DATE", Environment.NewLine, csv.Info.DateTime.ToString("dd MMM yy"), Environment.NewLine, "TIME", Environment.NewLine, csv.Info.DateTime.ToString("HH:mm:ss tt")), consolas, brush, rectangles[17]);
DrawLine(graphics, concentrationPen, 13, 6, 13, 40);
graphics.DrawString("C", consolasBold, concentrationBrush, 8, 41);
graphics.DrawString("D", consolasBold, concentrationBrush, 8, 53);
DrawLine(graphics, resistivityPen, 28, 6, 28, 40);
graphics.DrawString("ρ", consolasBold, resistivityBrush, 21, 41);
graphics.DrawString("c", consolasBold, resistivityBrush, 21, 53);
graphics.DrawString("m", consolasBold, resistivityBrush, 21, 62);
DrawLine(graphics, resistanceRawPen, 39, 7, 39, 41);
graphics.DrawString("Ω", consolasBold, resistanceRawBrush, 34, 41);
DrawLine(graphics, resistanceEditedPen, 51, 7, 51, 41);
graphics.DrawString("Ω", consolasBold, resistanceEditedBrush, 46, 41);
graphics.DrawString("E", consolasBold, resistanceEditedBrush, 46, 53);
for (int iLoop = decades - 1; iLoop >= 0; iLoop += -1)
{
for (int iLoop_Sub = 1; iLoop_Sub <= 10; iLoop_Sub++)
DrawLine(graphics, Pens.LightGray, leftChartArea, topChartArea + heightChartArea - (iLoop * heightChartArea / decades) + heightChartArea / decades * Math.Log10(iLoop_Sub), leftChartArea + widthChartArea, topChartArea + heightChartArea - (iLoop * heightChartArea / decades) + heightChartArea / decades * Math.Log10(iLoop_Sub));
}
DrawString(graphics, "0", consolas, brush, leftChartArea - 5, topChartArea + heightChartArea + 5);
for (int iLoop = 0; iLoop <= blocksOfDepth - 1; iLoop++)
{
for (int iLoop_Sub = 1; iLoop_Sub <= 10; iLoop_Sub++)
DrawLine(graphics, Pens.LightGray, leftChartArea + (iLoop * widthChartArea / blocksOfDepth) + iLoop_Sub * widthChartArea / blocksOfDepth / 10, topChartArea, leftChartArea + (iLoop * widthChartArea / blocksOfDepth) + (iLoop_Sub * widthChartArea / blocksOfDepth / 10), topChartArea + heightChartArea);
DrawString(graphics, ((iLoop + 1) * widthOfDepthBlock).ToString("0.0"), consolas, brush, leftChartArea + 13 + (iLoop + 1) * widthChartArea / blocksOfDepth, topChartArea + heightChartArea + 5, sfFormatRight);
}
DrawString(graphics, "(um)", consolas, brush, leftChartArea + widthChartArea + 12, topChartArea + heightChartArea + 5);
for (int iLoop = 0; iLoop <= decades; iLoop++)
{
DrawLine(graphics, pen, leftChartArea, topChartArea + (iLoop * heightChartArea / decades), leftChartArea + widthChartArea, topChartArea + (iLoop * heightChartArea / decades));
DrawString(graphics, (decades - iLoop + concentrationMinD).ToString("0"), consolasBold, concentrationBrush, 20, topChartArea - 10 + (iLoop * heightChartArea / decades), sfFormatRight);
DrawString(graphics, (decades - iLoop + resistivityMinD).ToString("0"), consolasBold, resistivityBrush, 33, topChartArea - 10 + (iLoop * heightChartArea / decades), sfFormatRight);
DrawString(graphics, (decades - iLoop + resistanceEditedMinD).ToString("0"), consolasBold, resistanceRawBrush, 45, topChartArea - 10 + (iLoop * heightChartArea / decades), sfFormatRight);
DrawString(graphics, (decades - iLoop + resistanceEditedMinD).ToString("0"), consolasBold, resistanceEditedBrush, 58, topChartArea - 10 + (iLoop * heightChartArea / decades), sfFormatRight);
}
for (int iLoop = 0; iLoop <= blocksOfDepth; iLoop++)
DrawLine(graphics, pen, leftChartArea + (iLoop * widthChartArea / blocksOfDepth), topChartArea, leftChartArea + (iLoop * widthChartArea / blocksOfDepth), topChartArea + heightChartArea);
foreach (ProfilePoint profilePoint in csv.ProfileHeader.ProfilePoints)
{
if (profilePoint.Depth < 0 || profilePoint.Edited is null || profilePoint.Resistivity is null || profilePoint.CD is null)
continue;
// Rho (Resistivity || Resistivity_ohm_cm) = Green
if (profilePoint.Depth < 0 || profilePoint.Edited.Value == 0 || profilePoint.Resistivity.Value == 0 || profilePoint.CD.Value == 0)
continue;
point = topChartArea + heightChartArea - ((Math.Log10(profilePoint.Resistivity.Value) - resistivityMinD) / decades * heightChartArea);
if (point < (90 - 2))
continue;
if (point > (topChartArea + heightChartArea + 2))
continue;
position += 1;
PointF[]? resistivityOldPoints = resistivityPoints;
resistivityPoints = new PointF[position + 1];
if (resistivityOldPoints != null)
Array.Copy(resistivityOldPoints, resistivityPoints, Math.Min(position + 1, resistivityOldPoints.Length));
PointF[]? concentrationPointsOld = concentrationPoints;
concentrationPoints = new PointF[position + 1];
if (concentrationPointsOld != null)
Array.Copy(concentrationPointsOld, concentrationPoints, Math.Min(position + 1, concentrationPointsOld.Length));
resistivityPoints[position] = GetPointF(leftChartArea + profilePoint.Depth / maxDepth * widthChartArea, topChartArea + heightChartArea - ((Math.Log10(profilePoint.Resistivity.Value) - resistivityMinD) / decades * heightChartArea));
concentrationPoints[position] = GetPointF(leftChartArea + profilePoint.Depth / maxDepth * widthChartArea, topChartArea + heightChartArea - ((Math.Log10(profilePoint.CD.Value) - concentrationMinD) / decades * heightChartArea));
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
FillEllipse(graphics, resistanceRawBrush, leftChartArea + profilePoint.Depth / maxDepth * widthChartArea - 2, topChartArea + heightChartArea - ((Math.Log10(profilePoint.Raw) - resistanceEditedMinD) / decades * heightChartArea) - 2, 3, 3);
FillEllipse(graphics, resistanceEditedBrush, leftChartArea + profilePoint.Depth / maxDepth * widthChartArea - 2, topChartArea + heightChartArea - ((Math.Log10(profilePoint.Edited.Value) - resistanceEditedMinD) / decades * heightChartArea) - 2, 3, 3);
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
}
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
if (resistivityPoints is not null)
graphics.DrawLines(resistivityPen, resistivityPoints);
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
if (concentrationPoints is not null)
graphics.DrawLines(concentrationPen, concentrationPoints);
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
using MemoryStream msMemoryStream = new();
bitmap.Save(msMemoryStream, System.Drawing.Imaging.ImageFormat.Png);
bytes = new byte[Convert.ToInt32(msMemoryStream.Length) + 1];
_ = msMemoryStream.Read(bytes, 0, bytes.Length);
bytes = msMemoryStream.ToArray();
return bytes;
}
}

View File

@ -0,0 +1,28 @@
namespace Adaptation.FileHandlers.json;
public class Profile
{
public string Id { get; }
public string Name { get; }
public string Label { get; }
public int Allocated { get; }
public int Used { get; }
public string List { get; }
public Profile(string id,
string name,
string label,
int allocated,
int used,
string list)
{
Id = id;
Name = name;
Label = label;
Allocated = allocated;
Used = used;
List = list;
}
}

View File

@ -0,0 +1,49 @@
using System.Collections.Generic;
namespace Adaptation.FileHandlers.json;
public class ProfileHeader
{
public int NumberOfProfiles { get; }
public List<Profile> Profiles { get; }
public List<ProfilePoint> ProfilePoints { get; }
internal ProfileHeader(csv.ProfileHeader profileHeader)
{
Profile profile;
ProfilePoint profilePoint;
List<Profile> profiles = new();
List<ProfilePoint> profilePoints = new();
NumberOfProfiles = int.Parse(profileHeader.NumberOfProfiles);
Profiles = profiles;
ProfilePoints = profilePoints;
foreach (csv.Profile csvProfile in profileHeader.Profiles)
{
profile = new
(
id: csvProfile.Id,
name: csvProfile.Name,
label: csvProfile.Label,
allocated: int.Parse(csvProfile.Allocated),
used: int.Parse(csvProfile.Used),
list: csvProfile.List
);
profiles.Add(profile);
}
foreach (csv.ProfilePoint csvProfilePoint in profileHeader.ProfilePoints)
{
profilePoint = new
(
number: int.Parse(csvProfilePoint.Number),
depth: double.Parse(csvProfilePoint.Depth),
raw: double.Parse(csvProfilePoint.Raw),
edited: double.Parse(csvProfilePoint.Edited),
resistivity: double.Parse(csvProfilePoint.Resistivity),
cd: double.Parse(csvProfilePoint.CD)
);
profilePoints.Add(profilePoint);
}
}
}

View File

@ -0,0 +1,28 @@
namespace Adaptation.FileHandlers.json;
public class ProfilePoint
{
public int Number { get; }
public double Depth { get; }
public double Raw { get; }
public double? Edited { get; }
public double? Resistivity { get; }
public double? CD { get; }
public ProfilePoint(int number,
double depth,
double raw,
double? edited,
double? resistivity,
double? cd)
{
Number = number;
Depth = depth;
Raw = raw;
Edited = edited;
Resistivity = resistivity;
CD = cd;
}
}

View File

@ -0,0 +1,33 @@
using System.Collections.Generic;
namespace Adaptation.FileHandlers.json;
public class RawData
{
public int TotalPoints { get; }
public List<Point> Points { get; }
internal RawData(csv.RawData rawData)
{
Point point;
List<Point> points = new();
TotalPoints = int.Parse(rawData.TotalPoints);
Points = points;
foreach (csv.Point csvPoint in rawData.Points)
{
point = new
(
number: double.Parse(csvPoint.Number),
depth: double.Parse(csvPoint.Depth),
resistance: double.Parse(csvPoint.Resistance),
stageX: double.Parse(csvPoint.StageX),
stageY: double.Parse(csvPoint.StageY),
stageZ: double.Parse(csvPoint.StageZ),
stageT: double.Parse(csvPoint.StageT)
);
points.Add(point);
}
}
}

View File

@ -0,0 +1,49 @@
using System.Collections.Generic;
namespace Adaptation.FileHandlers.json;
public class Setup
{
public string Finish { get; }
public string NorthProbeID { get; }
public string SouthProbeID { get; }
public string MeasurementPolarity { get; }
public double SineBevelAngle { get; }
public double ContactRadius { get; }
public double ProbeSpacing { get; }
public double ProbeLoad { get; }
public string Orientation { get; }
public int NumberOfStepSizes { get; }
public List<Step> Steps { get; }
internal Setup(csv.Setup setup)
{
Step step;
List<Step> steps = new();
Finish = setup.Finish;
NorthProbeID = setup.NorthProbeID;
SouthProbeID = setup.SouthProbeID;
MeasurementPolarity = setup.MeasurementPolarity;
SineBevelAngle = double.Parse(setup.SineBevelAngle);
ContactRadius = double.Parse(setup.ContactRadius);
ProbeSpacing = double.Parse(setup.ProbeSpacing);
ProbeLoad = double.Parse(setup.ProbeLoad);
Orientation = setup.Orientation;
NumberOfStepSizes = int.Parse(setup.NumberOfStepSizes);
Steps = steps;
foreach (csv.Step csvStep in setup.Steps)
{
Step step1 = new
(
number: int.Parse(csvStep.Number),
points: int.Parse(csvStep.Points),
x: double.Parse(csvStep.X),
y: double.Parse(csvStep.Y)
);
step = step1;
steps.Add(step);
}
}
}

View File

@ -0,0 +1,22 @@
namespace Adaptation.FileHandlers.json;
public class Step
{
public int Number { get; }
public int Points { get; }
public double X { get; }
public double Y { get; }
public Step(int number,
int points,
double x,
double y)
{
Number = number;
Points = points;
X = x;
Y = y;
}
}