Initial Commit
This commit is contained in:
86
Adaptation/FileHandlers/csv/CSV.cs
Normal file
86
Adaptation/FileHandlers/csv/CSV.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class CSV
|
||||
{
|
||||
|
||||
#nullable enable
|
||||
#pragma warning disable CA1834
|
||||
|
||||
public string? FileVersion { get; set; }
|
||||
public Info? Info { get; set; }
|
||||
public Setup? Setup { get; set; }
|
||||
public LayerHeader? LayerHeader { get; set; }
|
||||
public ProfileHeader? ProfileHeader { get; set; }
|
||||
public Calibration? Calibration { get; set; }
|
||||
public RawData? RawData { get; set; }
|
||||
|
||||
internal static CSV GetCSV(string path)
|
||||
{
|
||||
CSV result;
|
||||
int? endInfo = null;
|
||||
int? endSetup = null;
|
||||
int? endLayers = null;
|
||||
int? startInfo = null;
|
||||
int? startSetup = null;
|
||||
int? endProfiles = null;
|
||||
int? startLayers = null;
|
||||
int? startRawData = null;
|
||||
int? startProfiles = null;
|
||||
int? endCalibration = null;
|
||||
int? startCalibration = null;
|
||||
#if NET
|
||||
string[] lines = File.ReadAllLines(path, System.Text.Encoding.Latin1); // µ³®
|
||||
# else
|
||||
string[] lines = File.ReadAllLines(path, System.Text.Encoding.GetEncoding("ISO-8859-1")); // µ³®
|
||||
# endif
|
||||
string? fileVersion = !lines.Any() ? null : GetFileVersion(lines.First());
|
||||
for (int i = 1; i < lines.Length; i++)
|
||||
{
|
||||
if (lines[i].StartsWith("--INFO--"))
|
||||
startInfo = i + 1;
|
||||
else if (lines[i].StartsWith("--SETUP--"))
|
||||
(endInfo, startSetup) = (i, i + 1);
|
||||
else if (lines[i].StartsWith("--LAYERS--"))
|
||||
(endSetup, startLayers) = (i, i + 1);
|
||||
else if (lines[i].StartsWith("--PROFILES--"))
|
||||
(endLayers, startProfiles) = (i, i + 1);
|
||||
else if (lines[i].StartsWith("--CALIBRATION--"))
|
||||
(endProfiles, startCalibration) = (i, i + 1);
|
||||
else if (lines[i].StartsWith("--RAWDATA--"))
|
||||
(endCalibration, startRawData) = (i, i + 1);
|
||||
}
|
||||
RawData? rawData = startRawData is null ? null : RawData.GetRawData(lines, startRawData.Value, lines.Length);
|
||||
Info? info = startInfo is null || endInfo is null ? null : Info.GetInfo(lines, startInfo.Value, endInfo.Value);
|
||||
Setup? setup = startSetup is null || endSetup is null ? null : Setup.GetSetup(lines, startSetup.Value, endSetup.Value);
|
||||
LayerHeader? layerHeader = startLayers is null || endLayers is null ? null : LayerHeader.GetLayerHeader(lines, startLayers.Value, endLayers.Value);
|
||||
ProfileHeader? profileHeader = startProfiles is null || endProfiles is null ? null : ProfileHeader.GetProfileHeader(lines, startProfiles.Value, endProfiles.Value);
|
||||
Calibration? calibration = startCalibration is null || endCalibration is null ? null : Calibration.GetCalibration(lines, startCalibration.Value, endCalibration.Value);
|
||||
result = new()
|
||||
{
|
||||
FileVersion = fileVersion,
|
||||
Info = info,
|
||||
Setup = setup,
|
||||
LayerHeader = layerHeader,
|
||||
ProfileHeader = profileHeader,
|
||||
Calibration = calibration,
|
||||
RawData = rawData,
|
||||
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string GetFileVersion(string line)
|
||||
{
|
||||
string result;
|
||||
string[] segments = line.Split(',');
|
||||
if (segments.Length < 2)
|
||||
result = string.Empty;
|
||||
else
|
||||
result = segments.Last();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
133
Adaptation/FileHandlers/csv/Calibration.cs
Normal file
133
Adaptation/FileHandlers/csv/Calibration.cs
Normal file
@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class Calibration
|
||||
{
|
||||
|
||||
public string NumberOfCalibrationSets { get; set; }
|
||||
public List<DataSet> DataSets { get; set; }
|
||||
|
||||
#nullable enable
|
||||
#pragma warning disable CA1834
|
||||
|
||||
internal static Calibration? GetCalibration(string[] lines, int start, int stop)
|
||||
{
|
||||
Calibration? result;
|
||||
string first;
|
||||
DataSet dataSet;
|
||||
Position position;
|
||||
string[] segments;
|
||||
int? thirdStart = null;
|
||||
int? secondStart = null;
|
||||
List<Position> positions;
|
||||
List<string> values = new();
|
||||
List<DataSet> dataSets = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
for (int i = start; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
first = segments.First();
|
||||
if (first == "DataSet:")
|
||||
{
|
||||
secondStart = i + 1;
|
||||
break;
|
||||
}
|
||||
_ = stringBuilder.Append(first).Append(",");
|
||||
if (segments.Length > 1)
|
||||
values.Add(segments[1]);
|
||||
else
|
||||
values.Add(string.Empty);
|
||||
}
|
||||
string header = "Number of Calibration Sets,";
|
||||
if (secondStart is null || stringBuilder.Length != header.Length || stringBuilder.ToString() != header)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
result = new()
|
||||
{
|
||||
NumberOfCalibrationSets = values[0],
|
||||
DataSets = dataSets,
|
||||
};
|
||||
for (int x = 0; x < int.MaxValue; x++)
|
||||
{
|
||||
values.Clear();
|
||||
_ = stringBuilder.Clear();
|
||||
if (secondStart is null)
|
||||
break;
|
||||
for (int i = secondStart.Value; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
first = segments.First();
|
||||
if (first == "Resistivity(ohm-cm)")
|
||||
{
|
||||
thirdStart = i + 1;
|
||||
break;
|
||||
}
|
||||
if (first == " Sample Set:")
|
||||
continue;
|
||||
_ = stringBuilder.Append(first).Append(",");
|
||||
if (segments.Length > 1)
|
||||
values.Add(segments[1]);
|
||||
else
|
||||
values.Add(string.Empty);
|
||||
}
|
||||
secondStart = null;
|
||||
header = "Operator,Date & Time,Finish,Orientation,North Probe ID,South Probe ID,Polarity,Contact Radius (µm),Probe Spacing (µm),Load (gm),X Step (µm),Name,Plate ID,Type,Points per Sample,Number of Pairs,";
|
||||
if (thirdStart is null || stringBuilder.Length != header.Length || stringBuilder.ToString() != header)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
positions = new();
|
||||
dataSet = new()
|
||||
{
|
||||
Operator = values[0],
|
||||
DateTime = values[1],
|
||||
Finish = values[2],
|
||||
Orientation = values[3],
|
||||
NorthProbeID = values[4],
|
||||
SouthProbeID = values[5],
|
||||
Polarity = values[6],
|
||||
ContactRadius = values[7],
|
||||
ProbeSpacing = values[8],
|
||||
Load = values[9],
|
||||
XStep = values[10],
|
||||
Name = values[11],
|
||||
PlateId = values[12],
|
||||
Type = values[13],
|
||||
PointsPerSample = values[14],
|
||||
NumberOfPairs = values[15],
|
||||
Positions = positions,
|
||||
};
|
||||
dataSets.Add(dataSet);
|
||||
for (int i = thirdStart.Value; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
first = segments.First();
|
||||
if (first == "DataSet:")
|
||||
{
|
||||
secondStart = i + 1;
|
||||
break;
|
||||
}
|
||||
if (segments.Length < 5)
|
||||
continue;
|
||||
position = new()
|
||||
{
|
||||
Resistivity = segments[0],
|
||||
Resistance = segments[1],
|
||||
PercentStandardDeviation = segments[2],
|
||||
Number = segments[3],
|
||||
Name = segments[4],
|
||||
};
|
||||
positions.Add(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
27
Adaptation/FileHandlers/csv/DataSet.cs
Normal file
27
Adaptation/FileHandlers/csv/DataSet.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class DataSet
|
||||
{
|
||||
|
||||
public string Operator { get; set; }
|
||||
public string DateTime { get; set; }
|
||||
public string Finish { get; set; }
|
||||
public string Orientation { get; set; }
|
||||
public string NorthProbeID { get; set; }
|
||||
public string SouthProbeID { get; set; }
|
||||
public string Polarity { get; set; }
|
||||
public string ContactRadius { get; set; }
|
||||
public string ProbeSpacing { get; set; }
|
||||
public string Load { get; set; }
|
||||
public string XStep { get; set; }
|
||||
// public string SampleSet { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string PlateId { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string PointsPerSample { get; set; }
|
||||
public string NumberOfPairs { get; set; }
|
||||
public List<Position> Positions { get; set; }
|
||||
|
||||
}
|
194
Adaptation/FileHandlers/csv/Description.cs
Normal file
194
Adaptation/FileHandlers/csv/Description.cs
Normal file
@ -0,0 +1,194 @@
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
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 RDS { get; set; }
|
||||
//
|
||||
public string Path { 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(Layer),
|
||||
nameof(RDS),
|
||||
};
|
||||
return results;
|
||||
}
|
||||
|
||||
List<string> IDescription.GetHeaderNames()
|
||||
{
|
||||
List<string> results = new()
|
||||
{
|
||||
nameof(RDS),
|
||||
};
|
||||
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 _)
|
||||
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 string path)
|
||||
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,
|
||||
//
|
||||
Path = path,
|
||||
};
|
||||
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,
|
||||
//
|
||||
RDS = nameof(RDS),
|
||||
//
|
||||
Path = nameof(Path),
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetDateFormat() => "MM/dd/yyyy hh:mm:ss tt";
|
||||
|
||||
}
|
25
Adaptation/FileHandlers/csv/Descriptor.cs
Normal file
25
Adaptation/FileHandlers/csv/Descriptor.cs
Normal file
@ -0,0 +1,25 @@
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
115
Adaptation/FileHandlers/csv/FileRead.cs
Normal file
115
Adaptation/FileHandlers/csv/FileRead.cs
Normal file
@ -0,0 +1,115 @@
|
||||
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;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
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.Details.Any())
|
||||
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks));
|
||||
results = iProcessData.GetResults(this, _Logistics, results.Item4);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
73
Adaptation/FileHandlers/csv/Info.cs
Normal file
73
Adaptation/FileHandlers/csv/Info.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class Info
|
||||
{
|
||||
|
||||
public string Operator { get; set; }
|
||||
public string SampleName { get; set; }
|
||||
public string SoftwareVersion { get; set; }
|
||||
public string DateTime { get; set; }
|
||||
public string SystemId { get; set; }
|
||||
public string SystemSite { get; set; }
|
||||
public string SamplePosition { get; set; }
|
||||
public string Units { get; set; }
|
||||
public string CommentLength { get; set; }
|
||||
public List<string> Comments { get; set; }
|
||||
|
||||
#nullable enable
|
||||
#pragma warning disable CA1834
|
||||
|
||||
internal static Info? GetInfo(string[] lines, int start, int stop)
|
||||
{
|
||||
Info? result;
|
||||
string first;
|
||||
string[] segments;
|
||||
int? secondStart = null;
|
||||
List<string> values = new();
|
||||
List<string> comments = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
for (int i = start; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
first = segments.First();
|
||||
if (first == "Comment:")
|
||||
{
|
||||
secondStart = i + 1;
|
||||
break;
|
||||
}
|
||||
_ = stringBuilder.Append(first).Append(",");
|
||||
if (segments.Length > 1)
|
||||
values.Add(segments[1]);
|
||||
else
|
||||
values.Add(string.Empty);
|
||||
}
|
||||
string header = "Operator,Sample Name,Software Version,Date & Time,System ID,System Site,Sample Position,Units,Comment Length,";
|
||||
if (secondStart is null || stringBuilder.Length != header.Length || stringBuilder.ToString() != header)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
result = new()
|
||||
{
|
||||
Operator = values[0],
|
||||
SampleName = values[1],
|
||||
SoftwareVersion = values[2],
|
||||
DateTime = values[3],
|
||||
SystemId = values[4],
|
||||
SystemSite = values[5],
|
||||
SamplePosition = values[6],
|
||||
Units = values[7],
|
||||
CommentLength = values[8],
|
||||
Comments = comments,
|
||||
};
|
||||
for (int i = secondStart.Value; i < stop; i++)
|
||||
comments.Add(lines[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
22
Adaptation/FileHandlers/csv/Layer.cs
Normal file
22
Adaptation/FileHandlers/csv/Layer.cs
Normal file
@ -0,0 +1,22 @@
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class Layer
|
||||
{
|
||||
|
||||
public string FirstPoint { get; set; }
|
||||
public string LastPoint { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Smoothing { get; set; }
|
||||
public string Apply { get; set; }
|
||||
public string SOrder { get; set; }
|
||||
public string GOrder { get; set; }
|
||||
public string Correction { get; set; }
|
||||
public string Conversion { get; set; }
|
||||
public string JunctionOption { get; set; }
|
||||
public string JunctionConstant { get; set; }
|
||||
public string CurrentDensity { get; set; }
|
||||
public string M1M2Tolerance { get; set; }
|
||||
public string Sheet { get; set; }
|
||||
public string Dose { get; set; }
|
||||
|
||||
}
|
81
Adaptation/FileHandlers/csv/LayerHeader.cs
Normal file
81
Adaptation/FileHandlers/csv/LayerHeader.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class LayerHeader
|
||||
{
|
||||
|
||||
public string NumberOfLayers { get; set; }
|
||||
public List<Layer> Layers { get; set; }
|
||||
|
||||
#nullable enable
|
||||
#pragma warning disable CA1834
|
||||
|
||||
internal static LayerHeader? GetLayerHeader(string[] lines, int start, int stop)
|
||||
{
|
||||
LayerHeader? result;
|
||||
Layer layer;
|
||||
string first;
|
||||
string[] segments;
|
||||
int? secondStart = null;
|
||||
List<Layer> layerCollection = new();
|
||||
List<string> values = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
for (int i = start; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
first = segments.First();
|
||||
if (first == "Layer")
|
||||
{
|
||||
secondStart = i + 1;
|
||||
break;
|
||||
}
|
||||
_ = stringBuilder.Append(first).Append(",");
|
||||
if (segments.Length > 1)
|
||||
values.Add(segments[1]);
|
||||
else
|
||||
values.Add(string.Empty);
|
||||
}
|
||||
string header = "Number of Layers,";
|
||||
if (secondStart is null || stringBuilder.Length != header.Length || stringBuilder.ToString() != header)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
result = new()
|
||||
{
|
||||
NumberOfLayers = values[0],
|
||||
Layers = layerCollection,
|
||||
};
|
||||
for (int i = secondStart.Value; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
if (segments.Length < 15)
|
||||
continue;
|
||||
layer = new()
|
||||
{
|
||||
FirstPoint = segments[0],
|
||||
LastPoint = segments[1],
|
||||
Type = segments[2],
|
||||
Smoothing = segments[3],
|
||||
Apply = segments[4],
|
||||
SOrder = segments[5],
|
||||
GOrder = segments[6],
|
||||
Correction = segments[7],
|
||||
Conversion = segments[8],
|
||||
JunctionOption = segments[9],
|
||||
JunctionConstant = segments[10],
|
||||
CurrentDensity = segments[11],
|
||||
M1M2Tolerance = segments[12],
|
||||
Sheet = segments[13],
|
||||
Dose = segments[14],
|
||||
};
|
||||
layerCollection.Add(layer);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
14
Adaptation/FileHandlers/csv/Point.cs
Normal file
14
Adaptation/FileHandlers/csv/Point.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class Point
|
||||
{
|
||||
|
||||
public string Number { get; set; }
|
||||
public string Depth { get; set; }
|
||||
public string Resistance { get; set; }
|
||||
public string StageX { get; set; }
|
||||
public string StageY { get; set; }
|
||||
public string StageZ { get; set; }
|
||||
public string StageT { get; set; }
|
||||
|
||||
}
|
12
Adaptation/FileHandlers/csv/Position.cs
Normal file
12
Adaptation/FileHandlers/csv/Position.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class Position
|
||||
{
|
||||
|
||||
public string Resistivity { get; set; }
|
||||
public string Resistance { get; set; }
|
||||
public string PercentStandardDeviation { get; set; }
|
||||
public string Number { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
}
|
135
Adaptation/FileHandlers/csv/ProcessData.cs
Normal file
135
Adaptation/FileHandlers/csv/ProcessData.cs
Normal file
@ -0,0 +1,135 @@
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Methods;
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public partial class ProcessData : IProcessData
|
||||
{
|
||||
|
||||
private readonly List<object> _Details;
|
||||
|
||||
List<object> Shared.Properties.IProcessData.Details => _Details;
|
||||
|
||||
private readonly ILog _Log;
|
||||
|
||||
public ProcessData()
|
||||
{
|
||||
}
|
||||
|
||||
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, long tickOffset)
|
||||
{
|
||||
fileInfoCollection.Clear();
|
||||
_Details = new List<object>();
|
||||
_Log = LogManager.GetLogger(typeof(ProcessData));
|
||||
_ = Parse(fileRead, logistics, fileInfoCollection);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private static void OnlyOnce(string directory)
|
||||
{
|
||||
CSV csv;
|
||||
string json;
|
||||
string fileName;
|
||||
string innerDirectory;
|
||||
string fileNameWithoutExtension;
|
||||
foreach (string path in Directory.GetFiles(directory, "*.csv", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
csv = CSV.GetCSV(path);
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
|
||||
innerDirectory = Path.Combine(directory, fileNameWithoutExtension);
|
||||
_ = Directory.CreateDirectory(innerDirectory);
|
||||
fileName = Path.Combine(innerDirectory, $"{fileNameWithoutExtension}.csv");
|
||||
File.Move(path, fileName);
|
||||
fileName = Path.Combine(innerDirectory, $"{fileNameWithoutExtension}.json");
|
||||
json = JsonSerializer.Serialize(csv, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(fileName, json);
|
||||
}
|
||||
foreach (string path in Directory.GetFiles(directory, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
innerDirectory = Path.GetDirectoryName(path);
|
||||
fileName = Path.Combine(innerDirectory, $"{Path.GetFileName(innerDirectory)}{Path.GetExtension(path)}");
|
||||
File.Move(path, fileName);
|
||||
}
|
||||
foreach (string path in Directory.GetFiles(directory, "*.csv", SearchOption.AllDirectories))
|
||||
{
|
||||
innerDirectory = Path.GetDirectoryName(path);
|
||||
Directory.SetLastWriteTime(innerDirectory, new FileInfo(path).LastWriteTime);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060
|
||||
private CSV Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
|
||||
#pragma warning restore IDE0060
|
||||
{
|
||||
CSV result;
|
||||
result = CSV.GetCSV(logistics.ReportFullPath);
|
||||
string directory = Path.GetDirectoryName(logistics.ReportFullPath);
|
||||
#if OnlyOnce
|
||||
OnlyOnce(directory);
|
||||
#endif
|
||||
string fileName = Path.Combine(directory, $"{Path.GetFileNameWithoutExtension(logistics.ReportFullPath)}.json");
|
||||
string json = JsonSerializer.Serialize(result, new JsonSerializerOptions { WriteIndented = true });
|
||||
result = JsonSerializer.Deserialize<CSV>(json);
|
||||
if (result is null)
|
||||
throw new NullReferenceException(nameof(result));
|
||||
File.WriteAllText(fileName, json);
|
||||
#if NotSure
|
||||
fileInfoCollection.Add(new(fileName));
|
||||
#endif
|
||||
fileInfoCollection.Add(logistics.FileInfo);
|
||||
_Details.Add(fileName);
|
||||
return result;
|
||||
}
|
||||
|
||||
#nullable enable
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
13
Adaptation/FileHandlers/csv/Profile.cs
Normal file
13
Adaptation/FileHandlers/csv/Profile.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class Profile
|
||||
{
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Label { get; set; }
|
||||
public string Allocated { get; set; }
|
||||
public string Used { get; set; }
|
||||
public string List { get; set; }
|
||||
|
||||
}
|
102
Adaptation/FileHandlers/csv/ProfileHeader.cs
Normal file
102
Adaptation/FileHandlers/csv/ProfileHeader.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class ProfileHeader
|
||||
{
|
||||
|
||||
public string NumberOfProfiles { get; set; }
|
||||
public List<Profile> Profiles { get; set; }
|
||||
public List<ProfilePoint> ProfilePoints { get; set; }
|
||||
|
||||
#nullable enable
|
||||
#pragma warning disable CA1834
|
||||
|
||||
internal static ProfileHeader? GetProfileHeader(string[] lines, int start, int stop)
|
||||
{
|
||||
ProfileHeader? result;
|
||||
string first;
|
||||
string[] segments;
|
||||
Profile profileInfo;
|
||||
ProfilePoint profile;
|
||||
int? thirdStart = null;
|
||||
int? secondStart = null;
|
||||
List<string> values = new();
|
||||
List<Profile> profiles = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
List<ProfilePoint> profilePoints = new();
|
||||
for (int i = start; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
first = segments.First();
|
||||
if (first == "ID")
|
||||
{
|
||||
secondStart = i + 1;
|
||||
break;
|
||||
}
|
||||
_ = stringBuilder.Append(first).Append(",");
|
||||
if (segments.Length > 1)
|
||||
values.Add(segments[1]);
|
||||
else
|
||||
values.Add(string.Empty);
|
||||
}
|
||||
string header = "Number of Profiles,";
|
||||
if (secondStart is null || stringBuilder.Length != header.Length || stringBuilder.ToString() != header)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
result = new()
|
||||
{
|
||||
NumberOfProfiles = values[0],
|
||||
Profiles = profiles,
|
||||
ProfilePoints = profilePoints,
|
||||
};
|
||||
for (int i = secondStart.Value; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
first = segments.First();
|
||||
if (first == "Point")
|
||||
{
|
||||
thirdStart = i + 1;
|
||||
break;
|
||||
}
|
||||
if (segments.Length < 6)
|
||||
continue;
|
||||
profileInfo = new()
|
||||
{
|
||||
Id = segments[0],
|
||||
Name = segments[1],
|
||||
Label = segments[2],
|
||||
Allocated = segments[3],
|
||||
Used = segments[4],
|
||||
List = segments[5],
|
||||
};
|
||||
profiles.Add(profileInfo);
|
||||
}
|
||||
if (thirdStart is not null)
|
||||
{
|
||||
for (int i = thirdStart.Value; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
if (segments.Length < 6)
|
||||
continue;
|
||||
profile = new()
|
||||
{
|
||||
Number = segments[0],
|
||||
Depth = segments[1],
|
||||
Raw = segments[2],
|
||||
Edited = segments[3],
|
||||
Resistivity = segments[4],
|
||||
CD = segments[5],
|
||||
};
|
||||
profilePoints.Add(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
13
Adaptation/FileHandlers/csv/ProfilePoint.cs
Normal file
13
Adaptation/FileHandlers/csv/ProfilePoint.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class ProfilePoint
|
||||
{
|
||||
|
||||
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; }
|
||||
|
||||
}
|
73
Adaptation/FileHandlers/csv/RawData.cs
Normal file
73
Adaptation/FileHandlers/csv/RawData.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class RawData
|
||||
{
|
||||
|
||||
public string TotalPoints { get; set; }
|
||||
public List<Point> Points { get; set; }
|
||||
|
||||
#nullable enable
|
||||
#pragma warning disable CA1834
|
||||
|
||||
internal static RawData? GetRawData(string[] lines, int start, int stop)
|
||||
{
|
||||
RawData? result;
|
||||
Point point;
|
||||
string first;
|
||||
string[] segments;
|
||||
int? secondStart = null;
|
||||
List<Point> points = new();
|
||||
List<string> values = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
for (int i = start; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
first = segments.First();
|
||||
if (first == "Point")
|
||||
{
|
||||
secondStart = i + 1;
|
||||
break;
|
||||
}
|
||||
_ = stringBuilder.Append(first).Append(",");
|
||||
if (segments.Length > 1)
|
||||
values.Add(segments[1]);
|
||||
else
|
||||
values.Add(string.Empty);
|
||||
}
|
||||
string header = "Total Points,";
|
||||
if (secondStart is null || stringBuilder.Length != header.Length || stringBuilder.ToString() != header)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
result = new()
|
||||
{
|
||||
TotalPoints = values[0],
|
||||
Points = points,
|
||||
};
|
||||
for (int i = secondStart.Value; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
if (segments.Length < 4)
|
||||
continue;
|
||||
point = new()
|
||||
{
|
||||
Number = segments[0],
|
||||
Depth = segments[1],
|
||||
Resistance = segments[2],
|
||||
StageX = segments[3],
|
||||
StageY = segments[4],
|
||||
StageZ = segments[5],
|
||||
StageT = segments[6],
|
||||
};
|
||||
points.Add(point);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
88
Adaptation/FileHandlers/csv/Setup.cs
Normal file
88
Adaptation/FileHandlers/csv/Setup.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class Setup
|
||||
{
|
||||
|
||||
public string Finish { get; set; }
|
||||
public string NorthProbeID { get; set; }
|
||||
public string SouthProbeID { get; set; }
|
||||
public string MeasurementPolarity { get; set; }
|
||||
public string SineBevelAngle { get; set; }
|
||||
public string ContactRadius { get; set; }
|
||||
public string ProbeSpacing { get; set; }
|
||||
public string ProbeLoad { get; set; }
|
||||
public string Orientation { get; set; }
|
||||
public string NumberOfStepSizes { get; set; }
|
||||
public List<Step> Steps { get; set; }
|
||||
|
||||
#nullable enable
|
||||
#pragma warning disable CA1834
|
||||
|
||||
internal static Setup? GetSetup(string[] lines, int start, int stop)
|
||||
{
|
||||
Setup? result;
|
||||
Step step;
|
||||
string first;
|
||||
string[] segments;
|
||||
int? secondStart = null;
|
||||
List<Step> steps = new();
|
||||
List<string> values = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
for (int i = start; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
first = segments.First();
|
||||
if (first == "Step")
|
||||
{
|
||||
secondStart = i + 1;
|
||||
break;
|
||||
}
|
||||
_ = stringBuilder.Append(first).Append(",");
|
||||
if (segments.Length > 1)
|
||||
values.Add(segments[1]);
|
||||
else
|
||||
values.Add(string.Empty);
|
||||
}
|
||||
string header = "Finish,North Probe ID,South Probe ID,Measurement Polarity,Sine Bevel Angle,Contact Radius (µm),Probe Spacing (µm),Probe Load (gm),Orientation,Number of Step Sizes,";
|
||||
if (secondStart is null || stringBuilder.Length != header.Length || stringBuilder.ToString() != header)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
result = new()
|
||||
{
|
||||
Finish = values[0],
|
||||
NorthProbeID = values[1],
|
||||
SouthProbeID = values[2],
|
||||
MeasurementPolarity = values[3],
|
||||
SineBevelAngle = values[4],
|
||||
ContactRadius = values[5],
|
||||
ProbeSpacing = values[6],
|
||||
ProbeLoad = values[7],
|
||||
Orientation = values[8],
|
||||
NumberOfStepSizes = values[9],
|
||||
Steps = steps,
|
||||
};
|
||||
for (int i = secondStart.Value; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
if (segments.Length < 4)
|
||||
continue;
|
||||
step = new()
|
||||
{
|
||||
Number = segments[0],
|
||||
Points = segments[1],
|
||||
X = segments[2],
|
||||
Y = segments[3],
|
||||
};
|
||||
steps.Add(step);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
11
Adaptation/FileHandlers/csv/Step.cs
Normal file
11
Adaptation/FileHandlers/csv/Step.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class Step
|
||||
{
|
||||
|
||||
public string Number { get; set; }
|
||||
public string Points { get; set; }
|
||||
public string X { get; set; }
|
||||
public string Y { get; set; }
|
||||
|
||||
}
|
Reference in New Issue
Block a user