Spreading Resistance Profile with ChartJS,

Copy-On-Get and nuget bump (Serilog)
This commit is contained in:
2023-05-16 08:20:35 -07:00
parent 6b409294e4
commit e084fdd58f
53 changed files with 2245 additions and 105 deletions

View File

@ -0,0 +1,85 @@
namespace Adaptation.FileHandlers.csv;
public class CSV
{
#nullable disable
#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;
}
}

View File

@ -0,0 +1,132 @@
using System.Text;
namespace Adaptation.FileHandlers.csv;
public class Calibration
{
#nullable disable
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;
}
}

View File

@ -0,0 +1,27 @@
namespace Adaptation.FileHandlers.csv;
public class DataSet
{
#nullable disable
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; }
}

View File

@ -0,0 +1,72 @@
using System.Text;
namespace Adaptation.FileHandlers.csv;
public class Info
{
#nullable disable
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;
}
}

View File

@ -0,0 +1,24 @@
namespace Adaptation.FileHandlers.csv;
public class Layer
{
#nullable disable
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; }
}

View File

@ -0,0 +1,80 @@
using System.Text;
namespace Adaptation.FileHandlers.csv;
public class LayerHeader
{
#nullable disable
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;
}
}

View File

@ -0,0 +1,16 @@
namespace Adaptation.FileHandlers.csv;
public class Point
{
#nullable disable
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; }
}

View File

@ -0,0 +1,14 @@
namespace Adaptation.FileHandlers.csv;
public class Position
{
#nullable disable
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; }
}

View File

@ -0,0 +1,15 @@
namespace Adaptation.FileHandlers.csv;
public class Profile
{
#nullable disable
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; }
}

View File

@ -0,0 +1,101 @@
using System.Text;
namespace Adaptation.FileHandlers.csv;
public class ProfileHeader
{
#nullable disable
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;
}
}

View File

@ -0,0 +1,15 @@
namespace Adaptation.FileHandlers.csv;
public class ProfilePoint
{
#nullable disable
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; }
}

View File

@ -0,0 +1,72 @@
using System.Text;
namespace Adaptation.FileHandlers.csv;
public class RawData
{
#nullable disable
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;
}
}

View File

@ -0,0 +1,87 @@
using System.Text;
namespace Adaptation.FileHandlers.csv;
public class Setup
{
#nullable disable
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;
}
}

View File

@ -0,0 +1,13 @@
namespace Adaptation.FileHandlers.csv;
public class Step
{
#nullable disable
public string Number { get; set; }
public string Points { get; set; }
public string X { get; set; }
public string Y { get; set; }
}