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,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,56 @@
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,62 @@
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,31 @@
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,39 @@
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,27 @@
namespace Adaptation.FileHandlers.json;
public class Log10
{
#nullable enable
public double Depth { get; }
public double ResistanceRaw { get; }
public double? ResistanceEdited { get; }
public double? Resistivity { get; }
public double? Concentration { get; }
public Log10(double depth,
double raw,
double? edited,
double? resistivity,
double? cd)
{
Depth = Math.Log10(depth);
ResistanceRaw = Math.Log10(raw);
ResistanceEdited = edited is null ? null : Math.Log10(edited.Value);
Resistivity = resistivity is null ? null : Math.Log10(resistivity.Value);
Concentration = cd is null ? null : Math.Log10(cd.Value);
}
}

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,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,52 @@
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();
csv.ProfilePoint csvProfilePoint;
ProfilePoint? lastProfilePoint = null;
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);
}
for (int i = 0; i < profileHeader.ProfilePoints.Count; i++)
{
csvProfilePoint = profileHeader.ProfilePoints[i];
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),
lastProfilePoint: lastProfilePoint
);
profilePoints.Add(profilePoint);
lastProfilePoint = profilePoint;
}
}
}

View File

@ -0,0 +1,44 @@
namespace Adaptation.FileHandlers.json;
public class ProfilePoint
{
#nullable enable
public int Number { get; }
public double Depth { get; }
public double ResistanceRaw { get; }
public double? ResistanceEdited { get; }
public double? Resistivity { get; }
public double? Concentration { get; }
public double? DeltaPercent { get; }
public ProfilePoint? LastProfilePoint { get; }
public Log10? Log10 { get; }
public ProfilePoint(int number,
double depth,
double raw,
double? edited,
double? resistivity,
double? cd,
ProfilePoint? lastProfilePoint)
{
Number = number;
Depth = depth;
ResistanceRaw = raw;
ResistanceEdited = edited;
Resistivity = resistivity;
Concentration = cd;
DeltaPercent = lastProfilePoint is null ? null : (lastProfilePoint.ResistanceRaw - raw) / raw;
LastProfilePoint = lastProfilePoint;
Log10 = new
(
depth: depth,
raw: raw,
edited: edited,
resistivity: resistivity,
cd: cd
);
}
}

View File

@ -0,0 +1,31 @@
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,47 @@
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;
}
}