更新单位
This commit is contained in:
@@ -749,7 +749,7 @@
|
|||||||
x:Name="HoldTorqueInput"
|
x:Name="HoldTorqueInput"
|
||||||
Text="{Binding HoldTorqueInput, UpdateSourceTrigger=PropertyChanged}" TextChanged="HoldTorqueInput_TextChanged" />
|
Text="{Binding HoldTorqueInput, UpdateSourceTrigger=PropertyChanged}" TextChanged="HoldTorqueInput_TextChanged" />
|
||||||
<TextBlock Grid.Column="2"
|
<TextBlock Grid.Column="2"
|
||||||
Text="Ncm"
|
Text="mN.m"
|
||||||
Style="{StaticResource MutedText}"
|
Style="{StaticResource MutedText}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Margin="8,0,0,0" />
|
Margin="8,0,0,0" />
|
||||||
@@ -1091,7 +1091,7 @@
|
|||||||
|
|
||||||
<TextBlock Grid.Row="5" Text="扭矩保护" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
|
<TextBlock Grid.Row="5" Text="扭矩保护" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
|
||||||
<TextBox Grid.Row="5" Grid.Column="1" x:Name="TorqueProtectionInput" Text="{Binding TorqueProtectionInput, UpdateSourceTrigger=PropertyChanged}" Margin="0,14,10,0" />
|
<TextBox Grid.Row="5" Grid.Column="1" x:Name="TorqueProtectionInput" Text="{Binding TorqueProtectionInput, UpdateSourceTrigger=PropertyChanged}" Margin="0,14,10,0" />
|
||||||
<TextBlock Grid.Row="5" Grid.Column="2" Text="Ncm" Style="{StaticResource MutedText}" Margin="0,14,0,0" VerticalAlignment="Center" />
|
<TextBlock Grid.Row="5" Grid.Column="2" Text="mN.m" Style="{StaticResource MutedText}" Margin="0,14,0,0" VerticalAlignment="Center" />
|
||||||
|
|
||||||
<TextBlock Grid.Row="6" Text="转速系数" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
|
<TextBlock Grid.Row="6" Text="转速系数" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
|
||||||
<TextBox Grid.Row="6" Grid.Column="1" x:Name="SpeedCoefficientInput" Text="{Binding SpeedCoefficientInput, UpdateSourceTrigger=PropertyChanged}" Margin="0,14,10,0" />
|
<TextBox Grid.Row="6" Grid.Column="1" x:Name="SpeedCoefficientInput" Text="{Binding SpeedCoefficientInput, UpdateSourceTrigger=PropertyChanged}" Margin="0,14,10,0" />
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
private const double TenthsRegisterScale = 10.0;
|
private const double TenthsRegisterScale = 10.0;
|
||||||
private const int MaxTorqueSampleCount = 120;
|
private const int MaxTorqueSampleCount = 120;
|
||||||
private const double MinimumTorqueChangeThreshold = 0.05;
|
private const double MinimumTorqueChangeThreshold = 0.05;
|
||||||
|
private const string TorqueUnit = "mN.m";
|
||||||
|
|
||||||
private static readonly ushort[] RealtimeRegisterAddresses =
|
private static readonly ushort[] RealtimeRegisterAddresses =
|
||||||
[
|
[
|
||||||
@@ -188,7 +189,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
private string _finalAxialForceText = "--";
|
private string _finalAxialForceText = "--";
|
||||||
private string _displacementStatusText = "状态:待复位";
|
private string _displacementStatusText = "状态:待复位";
|
||||||
private string _realtimeSpeedText = "0 r/min";
|
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 _realtimePressureText = "0.000 MPa";
|
||||||
private string _noLoadSpeedRecordText = "0 r/min";
|
private string _noLoadSpeedRecordText = "0 r/min";
|
||||||
private string _noLoadSpeedErrorRateText = "0.00 %";
|
private string _noLoadSpeedErrorRateText = "0.00 %";
|
||||||
@@ -198,7 +199,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
private string _finalSpeedTorqueText = "最终:-- / --";
|
private string _finalSpeedTorqueText = "最终:-- / --";
|
||||||
private string _speedTorqueAxisPositionText = "0.000 mm";
|
private string _speedTorqueAxisPositionText = "0.000 mm";
|
||||||
private string _speedTorqueDisplacementText = "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 _speedTorqueMaxDisplacementText = "0.000 mm";
|
||||||
private string _speedTorqueFinalDisplacementText = "--";
|
private string _speedTorqueFinalDisplacementText = "--";
|
||||||
private string _torqueCurveStatusText = "保持时间曲线:未启动";
|
private string _torqueCurveStatusText = "保持时间曲线:未启动";
|
||||||
@@ -1152,23 +1153,23 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
CreateRecordPoint("转速/扭矩实时测试", "手/自动速度", $"{FormatSpeedSetting(_parameterConfig.SpeedTorqueSpeed)} mm/min", "mm/min"),
|
CreateRecordPoint("转速/扭矩实时测试", "手/自动速度", $"{FormatSpeedSetting(_parameterConfig.SpeedTorqueSpeed)} mm/min", "mm/min"),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "手动位移", $"{FormatDisplacement(_parameterConfig.SpeedTorqueManualDisplacement)} mm", "mm"),
|
CreateRecordPoint("转速/扭矩实时测试", "手动位移", $"{FormatDisplacement(_parameterConfig.SpeedTorqueManualDisplacement)} mm", "mm"),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "扭矩系数", FormatConfigNumber(_parameterConfig.TorqueCoefficient), string.Empty),
|
CreateRecordPoint("转速/扭矩实时测试", "扭矩系数", FormatConfigNumber(_parameterConfig.TorqueCoefficient), string.Empty),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "扭矩保护", $"{FormatTorque(_parameterConfig.TorqueProtection)} Ncm", "Ncm"),
|
CreateRecordPoint("转速/扭矩实时测试", "扭矩保护", $"{FormatTorque(_parameterConfig.TorqueProtection)} {TorqueUnit}", TorqueUnit),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "保持扭矩设置", $"{FormatTorque(_parameterConfig.HoldTorque)} Ncm", "Ncm"),
|
CreateRecordPoint("转速/扭矩实时测试", "保持扭矩设置", $"{FormatTorque(_parameterConfig.HoldTorque)} {TorqueUnit}", TorqueUnit),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "扭矩保持时间设置", $"{FormatConfigNumber(_parameterConfig.TorqueHoldTime)} s", "s"),
|
CreateRecordPoint("转速/扭矩实时测试", "扭矩保持时间设置", $"{FormatConfigNumber(_parameterConfig.TorqueHoldTime)} s", "s"),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "转速系数", FormatConfigNumber(_parameterConfig.SpeedCoefficient), string.Empty),
|
CreateRecordPoint("转速/扭矩实时测试", "转速系数", FormatConfigNumber(_parameterConfig.SpeedCoefficient), string.Empty),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "低速停止设置", $"{FormatSpeed(_parameterConfig.SpeedStopThreshold)} r/min", "r/min"),
|
CreateRecordPoint("转速/扭矩实时测试", "低速停止设置", $"{FormatSpeed(_parameterConfig.SpeedStopThreshold)} r/min", "r/min"),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "压力系数", FormatConfigNumber(_parameterConfig.PressureCoefficient), string.Empty),
|
CreateRecordPoint("转速/扭矩实时测试", "压力系数", FormatConfigNumber(_parameterConfig.PressureCoefficient), string.Empty),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "实时压力", $"{FormatPressure(_realtimePressure)} MPa", "MPa"),
|
CreateRecordPoint("转速/扭矩实时测试", "实时压力", $"{FormatPressure(_realtimePressure)} MPa", "MPa"),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "最大扭矩采集", $"{FormatTorque(_speedTorquePeakTorque)} Ncm", "Ncm"),
|
CreateRecordPoint("转速/扭矩实时测试", "最大扭矩采集", $"{FormatTorque(_speedTorquePeakTorque)} {TorqueUnit}", TorqueUnit),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "最大位移", $"{FormatDisplacement(_maxSpeedTorqueDisplacement)} mm", "mm"),
|
CreateRecordPoint("转速/扭矩实时测试", "最大位移", $"{FormatDisplacement(_maxSpeedTorqueDisplacement)} mm", "mm"),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "最终位移", _finalSpeedTorqueDisplacement.HasValue ? $"{FormatDisplacement(_finalSpeedTorqueDisplacement.Value)} mm" : "--", "mm", _finalSpeedTorqueDisplacement.HasValue ? "记录" : "待停止"),
|
CreateRecordPoint("转速/扭矩实时测试", "最终位移", _finalSpeedTorqueDisplacement.HasValue ? $"{FormatDisplacement(_finalSpeedTorqueDisplacement.Value)} mm" : "--", "mm", _finalSpeedTorqueDisplacement.HasValue ? "记录" : "待停止"),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "最终转速", _finalSpeed.HasValue ? $"{FormatSpeed(_finalSpeed.Value)} r/min" : "--", "r/min", _finalSpeed.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.Result, string.Empty, "记录"),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "保持时间内最小扭矩", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.MinTorqueNcm)} Ncm" : "--", "Ncm"),
|
CreateRecordPoint("转速/扭矩实时测试", "保持时间内最小扭矩", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.MinTorqueMilliNewtonMeters)} {TorqueUnit}" : "--", TorqueUnit),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "保持时间内最大扭矩", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.MaxTorqueNcm)} Ncm" : "--", "Ncm"),
|
CreateRecordPoint("转速/扭矩实时测试", "保持时间内最大扭矩", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.MaxTorqueMilliNewtonMeters)} {TorqueUnit}" : "--", TorqueUnit),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "保持时间内平均扭矩", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.AverageTorqueNcm)} Ncm" : "--", "Ncm"),
|
CreateRecordPoint("转速/扭矩实时测试", "保持时间内平均扭矩", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.AverageTorqueMilliNewtonMeters)} {TorqueUnit}" : "--", TorqueUnit),
|
||||||
CreateRecordPoint("转速/扭矩实时测试", "保持时间内波动值", curve.Samples.Count >= 2 ? $"{FormatTorque(curve.FluctuationNcm)} Ncm" : "--", "Ncm")
|
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, 1).Value = "保持时间(s)";
|
||||||
sheet.Cell(3, 2).Value = curve.HoldTimeSeconds;
|
sheet.Cell(3, 2).Value = curve.HoldTimeSeconds;
|
||||||
sheet.Cell(4, 1).Value = "判定阈值(Ncm)";
|
sheet.Cell(4, 1).Value = $"判定阈值({TorqueUnit})";
|
||||||
sheet.Cell(4, 2).Value = curve.ChangeThresholdNcm;
|
sheet.Cell(4, 2).Value = curve.ChangeThresholdMilliNewtonMeters;
|
||||||
sheet.Cell(5, 1).Value = "曲线判定";
|
sheet.Cell(5, 1).Value = "曲线判定";
|
||||||
sheet.Cell(5, 2).Value = curve.Result;
|
sheet.Cell(5, 2).Value = curve.Result;
|
||||||
sheet.Cell(6, 1).Value = "最小扭矩(Ncm)";
|
sheet.Cell(6, 1).Value = $"最小扭矩({TorqueUnit})";
|
||||||
sheet.Cell(6, 2).Value = curve.Samples.Count >= 2 ? curve.MinTorqueNcm : string.Empty;
|
sheet.Cell(6, 2).Value = curve.Samples.Count >= 2 ? curve.MinTorqueMilliNewtonMeters : string.Empty;
|
||||||
sheet.Cell(7, 1).Value = "最大扭矩(Ncm)";
|
sheet.Cell(7, 1).Value = $"最大扭矩({TorqueUnit})";
|
||||||
sheet.Cell(7, 2).Value = curve.Samples.Count >= 2 ? curve.MaxTorqueNcm : string.Empty;
|
sheet.Cell(7, 2).Value = curve.Samples.Count >= 2 ? curve.MaxTorqueMilliNewtonMeters : string.Empty;
|
||||||
sheet.Cell(8, 1).Value = "平均扭矩(Ncm)";
|
sheet.Cell(8, 1).Value = $"平均扭矩({TorqueUnit})";
|
||||||
sheet.Cell(8, 2).Value = curve.Samples.Count >= 2 ? curve.AverageTorqueNcm : string.Empty;
|
sheet.Cell(8, 2).Value = curve.Samples.Count >= 2 ? curve.AverageTorqueMilliNewtonMeters : string.Empty;
|
||||||
sheet.Cell(9, 1).Value = "波动值(Ncm)";
|
sheet.Cell(9, 1).Value = $"波动值({TorqueUnit})";
|
||||||
sheet.Cell(9, 2).Value = curve.Samples.Count >= 2 ? curve.FluctuationNcm : string.Empty;
|
sheet.Cell(9, 2).Value = curve.Samples.Count >= 2 ? curve.FluctuationMilliNewtonMeters : string.Empty;
|
||||||
sheet.Range(3, 1, 9, 1).Style.Font.SetBold();
|
sheet.Range(3, 1, 9, 1).Style.Font.SetBold();
|
||||||
|
|
||||||
sheet.Cell(11, 1).Value = "时间(s)";
|
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.Fill.SetBackgroundColor(XLColor.FromHtml("#D9EAF7"));
|
||||||
sheet.Range(11, 1, 11, 2).Style.Font.SetBold();
|
sheet.Range(11, 1, 11, 2).Style.Font.SetBold();
|
||||||
|
|
||||||
@@ -1347,7 +1348,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
TorqueSamplePayload sample = curve.Samples[i];
|
TorqueSamplePayload sample = curve.Samples[i];
|
||||||
int row = 12 + i;
|
int row = 12 + i;
|
||||||
sheet.Cell(row, 1).Value = sample.ElapsedSeconds;
|
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)
|
if (curve.Samples.Count > 0)
|
||||||
@@ -1397,8 +1398,8 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
|
|
||||||
if (curve.Samples.Count > 0)
|
if (curve.Samples.Count > 0)
|
||||||
{
|
{
|
||||||
double min = curve.Samples.Min(sample => sample.TorqueNcm);
|
double min = curve.Samples.Min(sample => sample.TorqueMilliNewtonMeters);
|
||||||
double max = curve.Samples.Max(sample => sample.TorqueNcm);
|
double max = curve.Samples.Max(sample => sample.TorqueMilliNewtonMeters);
|
||||||
double range = max - min;
|
double range = max - min;
|
||||||
if (range < 0.01)
|
if (range < 0.01)
|
||||||
{
|
{
|
||||||
@@ -1425,7 +1426,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
TorqueSamplePayload sample = curve.Samples[i];
|
TorqueSamplePayload sample = curve.Samples[i];
|
||||||
double x = plot.Left + plot.Width * (sample.ElapsedSeconds - firstElapsed) / elapsedRange;
|
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);
|
var point = new System.Windows.Point(x, y);
|
||||||
if (i == 0)
|
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, 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, $"{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, $"{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
|
else
|
||||||
{
|
{
|
||||||
@@ -2323,14 +2324,14 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
private void UpdateSpeedTorqueDisplay(string status)
|
private void UpdateSpeedTorqueDisplay(string status)
|
||||||
{
|
{
|
||||||
RealtimeSpeedText = $"{FormatSpeed(_realtimeSpeed)} r/min";
|
RealtimeSpeedText = $"{FormatSpeed(_realtimeSpeed)} r/min";
|
||||||
RealtimeTorqueText = $"{FormatTorque(GetScaledTorque())} Ncm";
|
RealtimeTorqueText = $"{FormatTorque(GetScaledTorque())} {TorqueUnit}";
|
||||||
RealtimePressureText = $"{FormatPressure(_realtimePressure)} MPa";
|
RealtimePressureText = $"{FormatPressure(_realtimePressure)} MPa";
|
||||||
string finalSpeed = _finalSpeed.HasValue ? $"{FormatSpeed(_finalSpeed.Value)} r/min" : "--";
|
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}";
|
FinalSpeedTorqueText = $"最终:{finalSpeed} / {finalTorque}";
|
||||||
SpeedTorqueAxisPositionText = $"{FormatDisplacement(_speedTorqueAxisPosition)} mm";
|
SpeedTorqueAxisPositionText = $"{FormatDisplacement(_speedTorqueAxisPosition)} mm";
|
||||||
SpeedTorqueDisplacementText = $"{FormatDisplacement(_speedTorqueDisplacement)} mm";
|
SpeedTorqueDisplacementText = $"{FormatDisplacement(_speedTorqueDisplacement)} mm";
|
||||||
SpeedTorquePeakTorqueText = $"{FormatTorque(_speedTorquePeakTorque)} Ncm";
|
SpeedTorquePeakTorqueText = $"{FormatTorque(_speedTorquePeakTorque)} {TorqueUnit}";
|
||||||
SpeedTorqueMaxDisplacementText = $"{FormatDisplacement(_maxSpeedTorqueDisplacement)} mm";
|
SpeedTorqueMaxDisplacementText = $"{FormatDisplacement(_maxSpeedTorqueDisplacement)} mm";
|
||||||
SpeedTorqueFinalDisplacementText = _finalSpeedTorqueDisplacement.HasValue ? $"{FormatDisplacement(_finalSpeedTorqueDisplacement.Value)} mm" : "--";
|
SpeedTorqueFinalDisplacementText = _finalSpeedTorqueDisplacement.HasValue ? $"{FormatDisplacement(_finalSpeedTorqueDisplacement.Value)} mm" : "--";
|
||||||
SpeedTorqueStatusText = status;
|
SpeedTorqueStatusText = status;
|
||||||
@@ -2370,7 +2371,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
TorqueSamples.Add(new TorqueSamplePayload
|
TorqueSamples.Add(new TorqueSamplePayload
|
||||||
{
|
{
|
||||||
ElapsedSeconds = elapsedSeconds,
|
ElapsedSeconds = elapsedSeconds,
|
||||||
TorqueNcm = value
|
TorqueMilliNewtonMeters = value
|
||||||
});
|
});
|
||||||
|
|
||||||
int sampleLimit = GetTorqueSampleLimit();
|
int sampleLimit = GetTorqueSampleLimit();
|
||||||
@@ -2411,7 +2412,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
.Select(sample => new TorqueSamplePayload
|
.Select(sample => new TorqueSamplePayload
|
||||||
{
|
{
|
||||||
ElapsedSeconds = sample.ElapsedSeconds,
|
ElapsedSeconds = sample.ElapsedSeconds,
|
||||||
TorqueNcm = sample.TorqueNcm
|
TorqueMilliNewtonMeters = sample.TorqueMilliNewtonMeters
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
@@ -2421,7 +2422,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
return new TorqueCurvePayload
|
return new TorqueCurvePayload
|
||||||
{
|
{
|
||||||
HoldTimeSeconds = _parameterConfig.TorqueHoldTime,
|
HoldTimeSeconds = _parameterConfig.TorqueHoldTime,
|
||||||
ChangeThresholdNcm = threshold,
|
ChangeThresholdMilliNewtonMeters = threshold,
|
||||||
Result = "未设置保持时间,未判定",
|
Result = "未设置保持时间,未判定",
|
||||||
Samples = samples
|
Samples = samples
|
||||||
};
|
};
|
||||||
@@ -2432,25 +2433,25 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
return new TorqueCurvePayload
|
return new TorqueCurvePayload
|
||||||
{
|
{
|
||||||
HoldTimeSeconds = _parameterConfig.TorqueHoldTime,
|
HoldTimeSeconds = _parameterConfig.TorqueHoldTime,
|
||||||
ChangeThresholdNcm = threshold,
|
ChangeThresholdMilliNewtonMeters = threshold,
|
||||||
Result = "采样不足,未判定",
|
Result = "采样不足,未判定",
|
||||||
Samples = samples
|
Samples = samples
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
double min = samples.Min(sample => sample.TorqueNcm);
|
double min = samples.Min(sample => sample.TorqueMilliNewtonMeters);
|
||||||
double max = samples.Max(sample => sample.TorqueNcm);
|
double max = samples.Max(sample => sample.TorqueMilliNewtonMeters);
|
||||||
double average = samples.Average(sample => sample.TorqueNcm);
|
double average = samples.Average(sample => sample.TorqueMilliNewtonMeters);
|
||||||
double fluctuation = max - min;
|
double fluctuation = max - min;
|
||||||
|
|
||||||
return new TorqueCurvePayload
|
return new TorqueCurvePayload
|
||||||
{
|
{
|
||||||
HoldTimeSeconds = _parameterConfig.TorqueHoldTime,
|
HoldTimeSeconds = _parameterConfig.TorqueHoldTime,
|
||||||
ChangeThresholdNcm = threshold,
|
ChangeThresholdMilliNewtonMeters = threshold,
|
||||||
MinTorqueNcm = min,
|
MinTorqueMilliNewtonMeters = min,
|
||||||
MaxTorqueNcm = max,
|
MaxTorqueMilliNewtonMeters = max,
|
||||||
AverageTorqueNcm = average,
|
AverageTorqueMilliNewtonMeters = average,
|
||||||
FluctuationNcm = fluctuation,
|
FluctuationMilliNewtonMeters = fluctuation,
|
||||||
Result = fluctuation > threshold ? "有变化" : "无明显变化",
|
Result = fluctuation > threshold ? "有变化" : "无明显变化",
|
||||||
Samples = samples
|
Samples = samples
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -212,22 +212,22 @@ public sealed class TorqueSamplePayload
|
|||||||
{
|
{
|
||||||
public double ElapsedSeconds { get; init; }
|
public double ElapsedSeconds { get; init; }
|
||||||
|
|
||||||
public double TorqueNcm { get; init; }
|
public double TorqueMilliNewtonMeters { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class TorqueCurvePayload
|
public sealed class TorqueCurvePayload
|
||||||
{
|
{
|
||||||
public double HoldTimeSeconds { get; init; }
|
public double HoldTimeSeconds { get; init; }
|
||||||
|
|
||||||
public double ChangeThresholdNcm { get; init; }
|
public double ChangeThresholdMilliNewtonMeters { get; init; }
|
||||||
|
|
||||||
public double MinTorqueNcm { get; init; }
|
public double MinTorqueMilliNewtonMeters { get; init; }
|
||||||
|
|
||||||
public double MaxTorqueNcm { get; init; }
|
public double MaxTorqueMilliNewtonMeters { get; init; }
|
||||||
|
|
||||||
public double AverageTorqueNcm { get; init; }
|
public double AverageTorqueMilliNewtonMeters { get; init; }
|
||||||
|
|
||||||
public double FluctuationNcm { get; init; }
|
public double FluctuationMilliNewtonMeters { get; init; }
|
||||||
|
|
||||||
public string Result { get; init; } = string.Empty;
|
public string Result { get; init; } = string.Empty;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace DentistryHandpieces;
|
|||||||
|
|
||||||
public sealed class TorqueTrendControl : FrameworkElement
|
public sealed class TorqueTrendControl : FrameworkElement
|
||||||
{
|
{
|
||||||
|
private const string TorqueUnit = "mN.m";
|
||||||
|
|
||||||
public static readonly DependencyProperty SamplesProperty =
|
public static readonly DependencyProperty SamplesProperty =
|
||||||
DependencyProperty.Register(
|
DependencyProperty.Register(
|
||||||
nameof(Samples),
|
nameof(Samples),
|
||||||
@@ -62,11 +64,11 @@ public sealed class TorqueTrendControl : FrameworkElement
|
|||||||
if (samples.Count == 0)
|
if (samples.Count == 0)
|
||||||
{
|
{
|
||||||
DrawText(drawingContext, "等待扭矩数据", 15, Color.FromRgb(82, 97, 111), new Point(plot.Left + 8, plot.Top + 8));
|
DrawText(drawingContext, "等待扭矩数据", 15, Color.FromRgb(82, 97, 111), new Point(plot.Left + 8, plot.Top + 8));
|
||||||
DrawText(drawingContext, "Ncm", 13, Color.FromRgb(82, 97, 111), new Point(12, plot.Top));
|
DrawText(drawingContext, TorqueUnit, 13, Color.FromRgb(82, 97, 111), new Point(12, plot.Top));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<double> values = samples.Select(sample => sample.TorqueNcm).ToList();
|
List<double> values = samples.Select(sample => sample.TorqueMilliNewtonMeters).ToList();
|
||||||
double min = values.Min();
|
double min = values.Min();
|
||||||
double max = values.Max();
|
double max = values.Max();
|
||||||
double range = max - min;
|
double range = max - min;
|
||||||
@@ -96,7 +98,7 @@ public sealed class TorqueTrendControl : FrameworkElement
|
|||||||
for (int i = 0; i < samples.Count; i++)
|
for (int i = 0; i < samples.Count; i++)
|
||||||
{
|
{
|
||||||
double x = samples.Count == 1 ? plot.Right : plot.Left + plot.Width * (samples[i].ElapsedSeconds - samples[0].ElapsedSeconds) / elapsedRange;
|
double x = samples.Count == 1 ? plot.Right : plot.Left + plot.Width * (samples[i].ElapsedSeconds - samples[0].ElapsedSeconds) / elapsedRange;
|
||||||
double y = plot.Bottom - (samples[i].TorqueNcm - min) / range * plot.Height;
|
double y = plot.Bottom - (samples[i].TorqueMilliNewtonMeters - min) / range * plot.Height;
|
||||||
Point point = new(x, y);
|
Point point = new(x, y);
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@@ -118,7 +120,7 @@ public sealed class TorqueTrendControl : FrameworkElement
|
|||||||
double currentY = plot.Bottom - (current - min) / range * plot.Height;
|
double currentY = plot.Bottom - (current - min) / range * plot.Height;
|
||||||
var currentPen = new Pen(new SolidColorBrush(Color.FromRgb(15, 118, 110)), 1.2);
|
var currentPen = new Pen(new SolidColorBrush(Color.FromRgb(15, 118, 110)), 1.2);
|
||||||
drawingContext.DrawLine(currentPen, new Point(plot.Left, currentY), new Point(plot.Right, currentY));
|
drawingContext.DrawLine(currentPen, new Point(plot.Left, currentY), new Point(plot.Right, currentY));
|
||||||
DrawText(drawingContext, $"当前 {current:0.##} Ncm", 13, Color.FromRgb(15, 118, 110), new Point(plot.Right - 96, Math.Max(plot.Top, currentY - 22)));
|
DrawText(drawingContext, $"当前 {current:0.##} {TorqueUnit}", 13, Color.FromRgb(15, 118, 110), new Point(plot.Right - 112, Math.Max(plot.Top, currentY - 22)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnSamplesChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
|
private static void OnSamplesChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
|
||||||
@@ -155,14 +157,14 @@ public sealed class TorqueTrendControl : FrameworkElement
|
|||||||
if (sample is TorqueSamplePayload torqueSample
|
if (sample is TorqueSamplePayload torqueSample
|
||||||
&& !double.IsNaN(torqueSample.ElapsedSeconds)
|
&& !double.IsNaN(torqueSample.ElapsedSeconds)
|
||||||
&& !double.IsInfinity(torqueSample.ElapsedSeconds)
|
&& !double.IsInfinity(torqueSample.ElapsedSeconds)
|
||||||
&& !double.IsNaN(torqueSample.TorqueNcm)
|
&& !double.IsNaN(torqueSample.TorqueMilliNewtonMeters)
|
||||||
&& !double.IsInfinity(torqueSample.TorqueNcm))
|
&& !double.IsInfinity(torqueSample.TorqueMilliNewtonMeters))
|
||||||
{
|
{
|
||||||
values.Add(torqueSample);
|
values.Add(torqueSample);
|
||||||
}
|
}
|
||||||
else if (sample is double value && !double.IsNaN(value) && !double.IsInfinity(value))
|
else if (sample is double value && !double.IsNaN(value) && !double.IsInfinity(value))
|
||||||
{
|
{
|
||||||
values.Add(new TorqueSamplePayload { ElapsedSeconds = values.Count, TorqueNcm = value });
|
values.Add(new TorqueSamplePayload { ElapsedSeconds = values.Count, TorqueMilliNewtonMeters = value });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user