更新20260608
This commit is contained in:
@@ -131,22 +131,39 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
|
||||
{
|
||||
var rows = new List<IReadOnlyList<object?>>
|
||||
{
|
||||
new object?[] { "时间(s)", "垂直压力(N)", "水平拉力(N)", "距离(mm)", "摩擦系数" }
|
||||
new object?[] { "时间(s)", "垂直压力(N)", "水平拉力(N)", "距离(mm)", "摩擦系数", "位移直线时间(s)", "距离(mm)" }
|
||||
};
|
||||
|
||||
foreach (var point in points)
|
||||
for (var index = 0; index < points.Count; index++)
|
||||
{
|
||||
var point = points[index];
|
||||
var lineTime = index switch
|
||||
{
|
||||
0 => 0,
|
||||
1 => points[^1].TimeSeconds,
|
||||
_ => (double?)null
|
||||
};
|
||||
var lineDisplacement = index switch
|
||||
{
|
||||
0 => 0,
|
||||
1 => points[^1].DisplacementMm,
|
||||
_ => (double?)null
|
||||
};
|
||||
|
||||
rows.Add(new object?[]
|
||||
{
|
||||
point.TimeSeconds,
|
||||
point.VerticalLoadN,
|
||||
point.HorizontalFrictionN,
|
||||
point.DisplacementMm,
|
||||
point.FrictionCoefficient
|
||||
point.FrictionCoefficient,
|
||||
lineTime,
|
||||
lineDisplacement
|
||||
});
|
||||
}
|
||||
|
||||
var worksheetPart = AddWorksheet(workbookPart, sheets, sheetId, DataSheetName, rows, "A", "E");
|
||||
var worksheetPart = AddWorksheet(workbookPart, sheets, sheetId, DataSheetName, rows, "A", "G");
|
||||
HideColumns(worksheetPart, 6, 7);
|
||||
if (points.Count > 0)
|
||||
{
|
||||
AddChart(worksheetPart, points.Count + 1);
|
||||
@@ -211,6 +228,23 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
|
||||
return columns;
|
||||
}
|
||||
|
||||
private static void HideColumns(WorksheetPart worksheetPart, uint firstColumn, uint lastColumn)
|
||||
{
|
||||
var columns = worksheetPart.Worksheet.GetFirstChild<Columns>();
|
||||
if (columns is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var column in columns.Elements<Column>()
|
||||
.Where(column => column.Min?.Value >= firstColumn && column.Max?.Value <= lastColumn))
|
||||
{
|
||||
column.Hidden = true;
|
||||
}
|
||||
|
||||
worksheetPart.Worksheet.Save();
|
||||
}
|
||||
|
||||
private static Cell CreateCell(int columnIndex, int rowIndex, object? value)
|
||||
{
|
||||
var cell = new Cell { CellReference = $"{GetColumnName(columnIndex)}{rowIndex}" };
|
||||
@@ -312,7 +346,7 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
|
||||
new C.AxisId { Val = coefficientAxisId });
|
||||
var distanceChart = new C.ScatterChart(
|
||||
new C.ScatterStyle { Val = C.ScatterStyleValues.LineMarker },
|
||||
CreateSeries(3, 4, lastRow),
|
||||
CreateSeries(3, 6, 7, Math.Min(lastRow, 3)),
|
||||
new C.AxisId { Val = xAxisId },
|
||||
new C.AxisId { Val = forceAndDistanceAxisId });
|
||||
|
||||
@@ -329,7 +363,7 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
|
||||
new C.Legend(
|
||||
new C.LegendPosition { Val = C.LegendPositionValues.Bottom },
|
||||
new C.Layout()),
|
||||
new C.PlotVisibleOnly { Val = true });
|
||||
new C.PlotVisibleOnly { Val = false });
|
||||
|
||||
return new C.ChartSpace(
|
||||
new C.EditingLanguage { Val = "zh-CN" },
|
||||
@@ -337,9 +371,15 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
|
||||
}
|
||||
|
||||
private static C.ScatterChartSeries CreateSeries(uint index, int yColumnIndex, int lastRow)
|
||||
{
|
||||
return CreateSeries(index, 1, yColumnIndex, lastRow);
|
||||
}
|
||||
|
||||
private static C.ScatterChartSeries CreateSeries(uint index, int xColumnIndex, int yColumnIndex, int lastRow)
|
||||
{
|
||||
var sheet = EscapeSheetName(DataSheetName);
|
||||
var xFormula = $"'{sheet}'!$A$2:$A${lastRow}";
|
||||
var xColumn = GetColumnName(xColumnIndex);
|
||||
var xFormula = $"'{sheet}'!${xColumn}$2:${xColumn}${lastRow}";
|
||||
var yColumn = GetColumnName(yColumnIndex);
|
||||
var yFormula = $"'{sheet}'!${yColumn}$2:${yColumn}${lastRow}";
|
||||
var titleFormula = $"'{sheet}'!${yColumn}$1";
|
||||
|
||||
@@ -735,7 +735,7 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.ViewModel
|
||||
currentRun.Add(point);
|
||||
verticalLoadPoints.Add(new ObservablePoint(standardTime, point.VerticalLoadN));
|
||||
horizontalFrictionPoints.Add(new ObservablePoint(standardTime, point.HorizontalFrictionN));
|
||||
displacementPoints.Add(new ObservablePoint(standardTime, point.DisplacementMm));
|
||||
UpdateLinearDisplacementSeries(point);
|
||||
frictionCoefficientPoints.Add(new ObservablePoint(standardTime, point.FrictionCoefficient));
|
||||
|
||||
UploadProgress = Math.Min(99, currentRun.Count);
|
||||
@@ -1042,15 +1042,15 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.ViewModel
|
||||
private void LogRealtimeCurveSummary(string stage)
|
||||
{
|
||||
var expectedCount = currentRun.Count;
|
||||
var lastPoint = currentRun.Count > 0 ? currentRun[^1] : null;
|
||||
var countsMatch =
|
||||
verticalLoadPoints.Count == expectedCount
|
||||
&& horizontalFrictionPoints.Count == expectedCount
|
||||
&& frictionCoefficientPoints.Count == expectedCount
|
||||
&& displacementPoints.Count == expectedCount;
|
||||
var lastPoint = currentRun.Count > 0 ? currentRun[^1] : null;
|
||||
&& IsLinearDisplacementSeriesSynchronized(lastPoint);
|
||||
|
||||
Log.Information(
|
||||
"实时曲线同步汇总:Stage={Stage}, TestNumber={TestNumber}, DataPointCount={DataPointCount}, ChartCounts=[Vertical:{VerticalCount}, Friction:{FrictionCount}, Coefficient:{CoefficientCount}, Displacement:{DisplacementCount}], CountsMatch={CountsMatch}, LastDataPoint={LastDataPoint}, ChartLast=[Vertical:{VerticalChart}, Friction:{FrictionChart}, Coefficient:{CoefficientChart}, Displacement:{DisplacementChart}]",
|
||||
"实时曲线同步汇总:Stage={Stage}, TestNumber={TestNumber}, DataPointCount={DataPointCount}, ChartCounts=[Vertical:{VerticalCount}, Friction:{FrictionCount}, Coefficient:{CoefficientCount}, DisplacementLine:{DisplacementCount}], DisplacementMode=零点到真实端点直线, CountsMatch={CountsMatch}, LastDataPoint={LastDataPoint}, ChartLast=[Vertical:{VerticalChart}, Friction:{FrictionChart}, Coefficient:{CoefficientChart}, DisplacementEndpoint:{DisplacementChart}]",
|
||||
stage,
|
||||
TestNumber,
|
||||
expectedCount,
|
||||
@@ -1073,7 +1073,7 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.ViewModel
|
||||
verticalLoadPoints.Count == expectedCount
|
||||
&& horizontalFrictionPoints.Count == expectedCount
|
||||
&& frictionCoefficientPoints.Count == expectedCount
|
||||
&& displacementPoints.Count == expectedCount;
|
||||
&& IsLinearDisplacementSeriesSynchronized(point);
|
||||
var valuesMatch =
|
||||
countsMatch
|
||||
&& ChartPointMatches(verticalLoadPoints[^1], point.TimeSeconds, point.VerticalLoadN)
|
||||
@@ -1084,7 +1084,7 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.ViewModel
|
||||
if (!countsMatch || !valuesMatch)
|
||||
{
|
||||
Log.Warning(
|
||||
"实时曲线数据不同步:TestNumber={TestNumber}, PointIndex={PointIndex}, ExpectedCount={ExpectedCount}, Counts=[Vertical:{VerticalCount}, Friction:{FrictionCount}, Coefficient:{CoefficientCount}, Displacement:{DisplacementCount}], ValuesMatch={ValuesMatch}, DataPoint=[Time:{Time:F3}s, Vertical:{Vertical:F3}N, Friction:{Friction:F3}N, Coefficient:{Coefficient:F5}, Displacement:{Displacement:F3}mm], ChartLast=[Vertical:{VerticalChart}, Friction:{FrictionChart}, Coefficient:{CoefficientChart}, Displacement:{DisplacementChart}]",
|
||||
"实时曲线数据不同步:TestNumber={TestNumber}, PointIndex={PointIndex}, ExpectedCount={ExpectedCount}, Counts=[Vertical:{VerticalCount}, Friction:{FrictionCount}, Coefficient:{CoefficientCount}, DisplacementLine:{DisplacementCount}], DisplacementMode=零点到真实端点直线, ValuesMatch={ValuesMatch}, DataPoint=[Time:{Time:F3}s, Vertical:{Vertical:F3}N, Friction:{Friction:F3}N, Coefficient:{Coefficient:F5}, Displacement:{Displacement:F3}mm], ChartLast=[Vertical:{VerticalChart}, Friction:{FrictionChart}, Coefficient:{CoefficientChart}, DisplacementEndpoint:{DisplacementChart}]",
|
||||
TestNumber,
|
||||
expectedCount,
|
||||
expectedCount,
|
||||
@@ -1126,6 +1126,53 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.ViewModel
|
||||
expectedCount);
|
||||
}
|
||||
|
||||
private void UpdateLinearDisplacementSeries(SlipDataPoint endpoint)
|
||||
{
|
||||
if (displacementPoints.Count == 0)
|
||||
{
|
||||
displacementPoints.Add(new ObservablePoint(0, 0));
|
||||
}
|
||||
|
||||
if (endpoint.TimeSeconds <= 0.000001)
|
||||
{
|
||||
while (displacementPoints.Count > 1)
|
||||
{
|
||||
displacementPoints.RemoveAt(displacementPoints.Count - 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var endpointPoint = new ObservablePoint(endpoint.TimeSeconds, endpoint.DisplacementMm);
|
||||
if (displacementPoints.Count == 1)
|
||||
{
|
||||
displacementPoints.Add(endpointPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
displacementPoints[1] = endpointPoint;
|
||||
}
|
||||
|
||||
while (displacementPoints.Count > 2)
|
||||
{
|
||||
displacementPoints.RemoveAt(displacementPoints.Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsLinearDisplacementSeriesSynchronized(SlipDataPoint? endpoint)
|
||||
{
|
||||
if (endpoint is null)
|
||||
{
|
||||
return displacementPoints.Count == 0;
|
||||
}
|
||||
|
||||
var expectedCount = endpoint.TimeSeconds <= 0.000001 ? 1 : 2;
|
||||
return displacementPoints.Count == expectedCount
|
||||
&& ChartPointMatches(displacementPoints[0], 0, 0)
|
||||
&& (expectedCount == 1
|
||||
|| ChartPointMatches(displacementPoints[^1], endpoint.TimeSeconds, endpoint.DisplacementMm));
|
||||
}
|
||||
|
||||
private static bool ChartPointMatches(ObservablePoint chartPoint, double expectedX, double expectedY) =>
|
||||
NearlyEquals(chartPoint.X, expectedX) && NearlyEquals(chartPoint.Y, expectedY);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user