|
|
|
|
@@ -81,6 +81,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
private const double TenthsRegisterScale = 10.0;
|
|
|
|
|
private const int MaxTorqueSampleCount = 120;
|
|
|
|
|
private const double MinimumTorqueChangeThreshold = 0.05;
|
|
|
|
|
private const string TorqueUnit = "mN.m";
|
|
|
|
|
|
|
|
|
|
private static readonly ushort[] RealtimeRegisterAddresses =
|
|
|
|
|
[
|
|
|
|
|
@@ -188,7 +189,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
private string _finalAxialForceText = "--";
|
|
|
|
|
private string _displacementStatusText = "状态:待复位";
|
|
|
|
|
private string _realtimeSpeedText = "0 r/min";
|
|
|
|
|
private string _realtimeTorqueText = "0.00 Ncm";
|
|
|
|
|
private string _realtimeTorqueText = $"0.00 {TorqueUnit}";
|
|
|
|
|
private string _realtimePressureText = "0.000 MPa";
|
|
|
|
|
private string _noLoadSpeedRecordText = "0 r/min";
|
|
|
|
|
private string _noLoadSpeedErrorRateText = "0.00 %";
|
|
|
|
|
@@ -198,7 +199,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
private string _finalSpeedTorqueText = "最终:-- / --";
|
|
|
|
|
private string _speedTorqueAxisPositionText = "0.000 mm";
|
|
|
|
|
private string _speedTorqueDisplacementText = "0.000 mm";
|
|
|
|
|
private string _speedTorquePeakTorqueText = "0.00 Ncm";
|
|
|
|
|
private string _speedTorquePeakTorqueText = $"0.00 {TorqueUnit}";
|
|
|
|
|
private string _speedTorqueMaxDisplacementText = "0.000 mm";
|
|
|
|
|
private string _speedTorqueFinalDisplacementText = "--";
|
|
|
|
|
private string _torqueCurveStatusText = "保持时间曲线:未启动";
|
|
|
|
|
@@ -1152,23 +1153,23 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "手/自动速度", $"{FormatSpeedSetting(_parameterConfig.SpeedTorqueSpeed)} mm/min", "mm/min"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "手动位移", $"{FormatDisplacement(_parameterConfig.SpeedTorqueManualDisplacement)} mm", "mm"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "扭矩系数", FormatConfigNumber(_parameterConfig.TorqueCoefficient), string.Empty),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "扭矩保护", $"{FormatTorque(_parameterConfig.TorqueProtection)} Ncm", "Ncm"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "保持扭矩设置", $"{FormatTorque(_parameterConfig.HoldTorque)} Ncm", "Ncm"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "扭矩保护", $"{FormatTorque(_parameterConfig.TorqueProtection)} {TorqueUnit}", TorqueUnit),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "保持扭矩设置", $"{FormatTorque(_parameterConfig.HoldTorque)} {TorqueUnit}", TorqueUnit),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "扭矩保持时间设置", $"{FormatConfigNumber(_parameterConfig.TorqueHoldTime)} s", "s"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "转速系数", FormatConfigNumber(_parameterConfig.SpeedCoefficient), string.Empty),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "低速停止设置", $"{FormatSpeed(_parameterConfig.SpeedStopThreshold)} r/min", "r/min"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "压力系数", FormatConfigNumber(_parameterConfig.PressureCoefficient), string.Empty),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "实时压力", $"{FormatPressure(_realtimePressure)} MPa", "MPa"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "最大扭矩采集", $"{FormatTorque(_speedTorquePeakTorque)} Ncm", "Ncm"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "最大扭矩采集", $"{FormatTorque(_speedTorquePeakTorque)} {TorqueUnit}", TorqueUnit),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "最大位移", $"{FormatDisplacement(_maxSpeedTorqueDisplacement)} mm", "mm"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "最终位移", _finalSpeedTorqueDisplacement.HasValue ? $"{FormatDisplacement(_finalSpeedTorqueDisplacement.Value)} mm" : "--", "mm", _finalSpeedTorqueDisplacement.HasValue ? "记录" : "待停止"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "最终转速", _finalSpeed.HasValue ? $"{FormatSpeed(_finalSpeed.Value)} r/min" : "--", "r/min", _finalSpeed.HasValue ? "记录" : "待停止"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "最终扭矩", _finalTorque.HasValue ? $"{FormatTorque(_finalTorque.Value)} Ncm" : "--", "Ncm", _finalTorque.HasValue ? "记录" : "待停止"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "最终扭矩", _finalTorque.HasValue ? $"{FormatTorque(_finalTorque.Value)} {TorqueUnit}" : "--", TorqueUnit, _finalTorque.HasValue ? "记录" : "待停止"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "保持时间曲线判定", curve.Result, string.Empty, "记录"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "保持时间内最小扭矩", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.MinTorqueNcm)} Ncm" : "--", "Ncm"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "保持时间内最大扭矩", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.MaxTorqueNcm)} Ncm" : "--", "Ncm"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "保持时间内平均扭矩", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.AverageTorqueNcm)} Ncm" : "--", "Ncm"),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "保持时间内波动值", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.FluctuationNcm)} Ncm" : "--", "Ncm")
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "保持时间内最小扭矩", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.MinTorqueMilliNewtonMeters)} {TorqueUnit}" : "--", TorqueUnit),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "保持时间内最大扭矩", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.MaxTorqueMilliNewtonMeters)} {TorqueUnit}" : "--", TorqueUnit),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "保持时间内平均扭矩", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.AverageTorqueMilliNewtonMeters)} {TorqueUnit}" : "--", TorqueUnit),
|
|
|
|
|
CreateRecordPoint("转速/扭矩实时测试", "保持时间内波动值", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.FluctuationMilliNewtonMeters)} {TorqueUnit}" : "--", TorqueUnit)
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
@@ -1323,22 +1324,22 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
|
|
|
|
|
sheet.Cell(3, 1).Value = "保持时间(s)";
|
|
|
|
|
sheet.Cell(3, 2).Value = curve.HoldTimeSeconds;
|
|
|
|
|
sheet.Cell(4, 1).Value = "判定阈值(Ncm)";
|
|
|
|
|
sheet.Cell(4, 2).Value = curve.ChangeThresholdNcm;
|
|
|
|
|
sheet.Cell(4, 1).Value = $"判定阈值({TorqueUnit})";
|
|
|
|
|
sheet.Cell(4, 2).Value = curve.ChangeThresholdMilliNewtonMeters;
|
|
|
|
|
sheet.Cell(5, 1).Value = "曲线判定";
|
|
|
|
|
sheet.Cell(5, 2).Value = curve.Result;
|
|
|
|
|
sheet.Cell(6, 1).Value = "最小扭矩(Ncm)";
|
|
|
|
|
sheet.Cell(6, 2).Value = curve.Samples.Count >= 2 ? curve.MinTorqueNcm : string.Empty;
|
|
|
|
|
sheet.Cell(7, 1).Value = "最大扭矩(Ncm)";
|
|
|
|
|
sheet.Cell(7, 2).Value = curve.Samples.Count >= 2 ? curve.MaxTorqueNcm : string.Empty;
|
|
|
|
|
sheet.Cell(8, 1).Value = "平均扭矩(Ncm)";
|
|
|
|
|
sheet.Cell(8, 2).Value = curve.Samples.Count >= 2 ? curve.AverageTorqueNcm : string.Empty;
|
|
|
|
|
sheet.Cell(9, 1).Value = "波动值(Ncm)";
|
|
|
|
|
sheet.Cell(9, 2).Value = curve.Samples.Count >= 2 ? curve.FluctuationNcm : string.Empty;
|
|
|
|
|
sheet.Cell(6, 1).Value = $"最小扭矩({TorqueUnit})";
|
|
|
|
|
sheet.Cell(6, 2).Value = curve.Samples.Count >= 2 ? curve.MinTorqueMilliNewtonMeters : string.Empty;
|
|
|
|
|
sheet.Cell(7, 1).Value = $"最大扭矩({TorqueUnit})";
|
|
|
|
|
sheet.Cell(7, 2).Value = curve.Samples.Count >= 2 ? curve.MaxTorqueMilliNewtonMeters : string.Empty;
|
|
|
|
|
sheet.Cell(8, 1).Value = $"平均扭矩({TorqueUnit})";
|
|
|
|
|
sheet.Cell(8, 2).Value = curve.Samples.Count >= 2 ? curve.AverageTorqueMilliNewtonMeters : string.Empty;
|
|
|
|
|
sheet.Cell(9, 1).Value = $"波动值({TorqueUnit})";
|
|
|
|
|
sheet.Cell(9, 2).Value = curve.Samples.Count >= 2 ? curve.FluctuationMilliNewtonMeters : string.Empty;
|
|
|
|
|
sheet.Range(3, 1, 9, 1).Style.Font.SetBold();
|
|
|
|
|
|
|
|
|
|
sheet.Cell(11, 1).Value = "时间(s)";
|
|
|
|
|
sheet.Cell(11, 2).Value = "扭矩(Ncm)";
|
|
|
|
|
sheet.Cell(11, 2).Value = $"扭矩({TorqueUnit})";
|
|
|
|
|
sheet.Range(11, 1, 11, 2).Style.Fill.SetBackgroundColor(XLColor.FromHtml("#D9EAF7"));
|
|
|
|
|
sheet.Range(11, 1, 11, 2).Style.Font.SetBold();
|
|
|
|
|
|
|
|
|
|
@@ -1347,7 +1348,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
TorqueSamplePayload sample = curve.Samples[i];
|
|
|
|
|
int row = 12 + i;
|
|
|
|
|
sheet.Cell(row, 1).Value = sample.ElapsedSeconds;
|
|
|
|
|
sheet.Cell(row, 2).Value = sample.TorqueNcm;
|
|
|
|
|
sheet.Cell(row, 2).Value = sample.TorqueMilliNewtonMeters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (curve.Samples.Count > 0)
|
|
|
|
|
@@ -1397,8 +1398,8 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
|
|
|
|
|
if (curve.Samples.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
double min = curve.Samples.Min(sample => sample.TorqueNcm);
|
|
|
|
|
double max = curve.Samples.Max(sample => sample.TorqueNcm);
|
|
|
|
|
double min = curve.Samples.Min(sample => sample.TorqueMilliNewtonMeters);
|
|
|
|
|
double max = curve.Samples.Max(sample => sample.TorqueMilliNewtonMeters);
|
|
|
|
|
double range = max - min;
|
|
|
|
|
if (range < 0.01)
|
|
|
|
|
{
|
|
|
|
|
@@ -1425,7 +1426,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
{
|
|
|
|
|
TorqueSamplePayload sample = curve.Samples[i];
|
|
|
|
|
double x = plot.Left + plot.Width * (sample.ElapsedSeconds - firstElapsed) / elapsedRange;
|
|
|
|
|
double y = plot.Bottom - (sample.TorqueNcm - min) / range * plot.Height;
|
|
|
|
|
double y = plot.Bottom - (sample.TorqueMilliNewtonMeters - min) / range * plot.Height;
|
|
|
|
|
var point = new System.Windows.Point(x, y);
|
|
|
|
|
if (i == 0)
|
|
|
|
|
{
|
|
|
|
|
@@ -1445,7 +1446,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
DrawChartText(context, min.ToString("0.##", CultureInfo.InvariantCulture), 12, textBrush, new System.Windows.Point(16, plot.Bottom - 10), false);
|
|
|
|
|
DrawChartText(context, $"{firstElapsed:0.#}s", 12, textBrush, new System.Windows.Point(plot.Left, plot.Bottom + 10), false);
|
|
|
|
|
DrawChartText(context, $"{lastElapsed:0.#}s", 12, textBrush, new System.Windows.Point(plot.Right - 28, plot.Bottom + 10), false);
|
|
|
|
|
DrawChartText(context, "Ncm", 12, textBrush, new System.Windows.Point(18, plot.Top + 16), false);
|
|
|
|
|
DrawChartText(context, TorqueUnit, 12, textBrush, new System.Windows.Point(18, plot.Top + 16), false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@@ -2323,14 +2324,14 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
private void UpdateSpeedTorqueDisplay(string status)
|
|
|
|
|
{
|
|
|
|
|
RealtimeSpeedText = $"{FormatSpeed(_realtimeSpeed)} r/min";
|
|
|
|
|
RealtimeTorqueText = $"{FormatTorque(GetScaledTorque())} Ncm";
|
|
|
|
|
RealtimeTorqueText = $"{FormatTorque(GetScaledTorque())} {TorqueUnit}";
|
|
|
|
|
RealtimePressureText = $"{FormatPressure(_realtimePressure)} MPa";
|
|
|
|
|
string finalSpeed = _finalSpeed.HasValue ? $"{FormatSpeed(_finalSpeed.Value)} r/min" : "--";
|
|
|
|
|
string finalTorque = _finalTorque.HasValue ? $"{FormatTorque(_finalTorque.Value)} Ncm" : "--";
|
|
|
|
|
string finalTorque = _finalTorque.HasValue ? $"{FormatTorque(_finalTorque.Value)} {TorqueUnit}" : "--";
|
|
|
|
|
FinalSpeedTorqueText = $"最终:{finalSpeed} / {finalTorque}";
|
|
|
|
|
SpeedTorqueAxisPositionText = $"{FormatDisplacement(_speedTorqueAxisPosition)} mm";
|
|
|
|
|
SpeedTorqueDisplacementText = $"{FormatDisplacement(_speedTorqueDisplacement)} mm";
|
|
|
|
|
SpeedTorquePeakTorqueText = $"{FormatTorque(_speedTorquePeakTorque)} Ncm";
|
|
|
|
|
SpeedTorquePeakTorqueText = $"{FormatTorque(_speedTorquePeakTorque)} {TorqueUnit}";
|
|
|
|
|
SpeedTorqueMaxDisplacementText = $"{FormatDisplacement(_maxSpeedTorqueDisplacement)} mm";
|
|
|
|
|
SpeedTorqueFinalDisplacementText = _finalSpeedTorqueDisplacement.HasValue ? $"{FormatDisplacement(_finalSpeedTorqueDisplacement.Value)} mm" : "--";
|
|
|
|
|
SpeedTorqueStatusText = status;
|
|
|
|
|
@@ -2370,7 +2371,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
TorqueSamples.Add(new TorqueSamplePayload
|
|
|
|
|
{
|
|
|
|
|
ElapsedSeconds = elapsedSeconds,
|
|
|
|
|
TorqueNcm = value
|
|
|
|
|
TorqueMilliNewtonMeters = value
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
int sampleLimit = GetTorqueSampleLimit();
|
|
|
|
|
@@ -2411,7 +2412,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
.Select(sample => new TorqueSamplePayload
|
|
|
|
|
{
|
|
|
|
|
ElapsedSeconds = sample.ElapsedSeconds,
|
|
|
|
|
TorqueNcm = sample.TorqueNcm
|
|
|
|
|
TorqueMilliNewtonMeters = sample.TorqueMilliNewtonMeters
|
|
|
|
|
})
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
@@ -2421,7 +2422,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
return new TorqueCurvePayload
|
|
|
|
|
{
|
|
|
|
|
HoldTimeSeconds = _parameterConfig.TorqueHoldTime,
|
|
|
|
|
ChangeThresholdNcm = threshold,
|
|
|
|
|
ChangeThresholdMilliNewtonMeters = threshold,
|
|
|
|
|
Result = "未设置保持时间,未判定",
|
|
|
|
|
Samples = samples
|
|
|
|
|
};
|
|
|
|
|
@@ -2432,25 +2433,25 @@ public sealed class MainWindowViewModel : ObservableObject
|
|
|
|
|
return new TorqueCurvePayload
|
|
|
|
|
{
|
|
|
|
|
HoldTimeSeconds = _parameterConfig.TorqueHoldTime,
|
|
|
|
|
ChangeThresholdNcm = threshold,
|
|
|
|
|
ChangeThresholdMilliNewtonMeters = threshold,
|
|
|
|
|
Result = "采样不足,未判定",
|
|
|
|
|
Samples = samples
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double min = samples.Min(sample => sample.TorqueNcm);
|
|
|
|
|
double max = samples.Max(sample => sample.TorqueNcm);
|
|
|
|
|
double average = samples.Average(sample => sample.TorqueNcm);
|
|
|
|
|
double min = samples.Min(sample => sample.TorqueMilliNewtonMeters);
|
|
|
|
|
double max = samples.Max(sample => sample.TorqueMilliNewtonMeters);
|
|
|
|
|
double average = samples.Average(sample => sample.TorqueMilliNewtonMeters);
|
|
|
|
|
double fluctuation = max - min;
|
|
|
|
|
|
|
|
|
|
return new TorqueCurvePayload
|
|
|
|
|
{
|
|
|
|
|
HoldTimeSeconds = _parameterConfig.TorqueHoldTime,
|
|
|
|
|
ChangeThresholdNcm = threshold,
|
|
|
|
|
MinTorqueNcm = min,
|
|
|
|
|
MaxTorqueNcm = max,
|
|
|
|
|
AverageTorqueNcm = average,
|
|
|
|
|
FluctuationNcm = fluctuation,
|
|
|
|
|
ChangeThresholdMilliNewtonMeters = threshold,
|
|
|
|
|
MinTorqueMilliNewtonMeters = min,
|
|
|
|
|
MaxTorqueMilliNewtonMeters = max,
|
|
|
|
|
AverageTorqueMilliNewtonMeters = average,
|
|
|
|
|
FluctuationMilliNewtonMeters = fluctuation,
|
|
|
|
|
Result = fluctuation > threshold ? "有变化" : "无明显变化",
|
|
|
|
|
Samples = samples
|
|
|
|
|
};
|
|
|
|
|
|