Compare commits

...

2 Commits

Author SHA1 Message Date
GukSang.Jin
3a9710e6fa 更新 2026-06-10 16:52:15 +08:00
GukSang.Jin
b7cf3ab0aa 更新 2026-06-10 15:20:43 +08:00

View File

@@ -139,6 +139,7 @@ public sealed class MainWindowViewModel : ObservableObject
SpeedTorqueManualDisplacementRegister,
TorqueCoefficientRegister,
TorqueProtectionRegister,
HoldTorqueRegister,
SpeedCoefficientRegister,
SpeedStopThresholdRegister,
PressureCoefficientRegister,
@@ -154,7 +155,8 @@ public sealed class MainWindowViewModel : ObservableObject
SpeedTorqueResetEnabledCoil,
SpeedTorqueResetDoneCoil,
AxialResetEnabledCoil,
AxialResetDoneCoil
AxialResetDoneCoil,
NoLoadSpeedRecordCoil
];
private readonly IPlcCoilService _plcCoilService;
@@ -482,7 +484,7 @@ public sealed class MainWindowViewModel : ObservableObject
return;
}
QueueTenthsTestPageInputWrite(TestPageInputParameter.HoldTorque, HoldTorqueRegister, "保持扭矩设置", value);
QueueFloatTestPageInputWrite(TestPageInputParameter.HoldTorque, HoldTorqueRegister, "保持扭矩设置", value);
}
}
@@ -878,7 +880,7 @@ public sealed class MainWindowViewModel : ObservableObject
double speedTorqueManualDisplacement = ReadFloatValue(values, SpeedTorqueManualDisplacementRegister, "1号手动位移输入");
double torqueCoefficient = ReadFloatValue(values, TorqueCoefficientRegister, "扭矩系数");
double torqueProtection = ReadFloatValue(values, TorqueProtectionRegister, "扭矩保护输入");
double holdTorque = ScaleTenthsFromPlc(await _plcRegisterService.ReadUInt16Async(config, HoldTorqueRegister));
double holdTorque = ReadFloatValue(values, HoldTorqueRegister, "保持扭矩设置");
double torqueHoldTime = ScaleTenthsFromPlc(await _plcRegisterService.ReadUInt16Async(config, TorqueHoldTimeRegister));
double speedCoefficient = ReadFloatValue(values, SpeedCoefficientRegister, "转速系数");
double speedStopThreshold = ReadFloatValue(values, SpeedStopThresholdRegister, "低速停止设置");
@@ -1989,7 +1991,7 @@ public sealed class MainWindowViewModel : ObservableObject
await WriteChangedFloatAsync(SpeedCoefficientRegister, "转速系数", current.SpeedCoefficient, updated.SpeedCoefficient);
await WriteChangedFloatAsync(SpeedStopThresholdRegister, "低速停止", current.SpeedStopThreshold, updated.SpeedStopThreshold);
await WriteChangedFloatAsync(PressureCoefficientRegister, "压力系数", current.PressureCoefficient, updated.PressureCoefficient);
await WriteChangedTenthsAsync(HoldTorqueRegister, "保持扭矩设置", current.HoldTorque, updated.HoldTorque);
await WriteChangedFloatAsync(HoldTorqueRegister, "保持扭矩设置", current.HoldTorque, updated.HoldTorque);
return changedItems;
@@ -2432,8 +2434,24 @@ public sealed class MainWindowViewModel : ObservableObject
return;
}
if (!await PulsePlcAsync(NoLoadSpeedRecordCoil, "空载转速测试"))
try
{
await _plcCoilService.WriteCoilAsync(
_parameterConfig.ToPlcConnectionConfig(),
NoLoadSpeedRecordCoil,
true);
Log.Information(
"PLC动作成功{ActionName}M{CoilAddress}=1",
"空载转速测试",
NoLoadSpeedRecordCoil);
}
catch (Exception ex)
{
StatusText = $"PLC 空载转速测试失败:{OperatorMessageFormatter.FromException(ex)}";
Log.Error(
ex,
"PLC动作失败空载转速测试M{CoilAddress}",
NoLoadSpeedRecordCoil);
return;
}
@@ -3624,15 +3642,27 @@ public sealed class MainWindowViewModel : ObservableObject
private void FinalizeNoLoadSpeedRunIfDue()
{
if (_activeNoLoadSpeedRun is null
|| !_noLoadCaptureDeadline.HasValue
|| DateTime.Now < _noLoadCaptureDeadline.Value)
|| !_noLoadCaptureDeadline.HasValue)
{
return;
}
// 实际转速达到设定转速的 98%:立即结束
bool speedReached = _parameterConfig.NoLoadSpeedSetting > 0
&& _realtimeSpeed >= _parameterConfig.NoLoadSpeedSetting * 0.98;
// 转速未达标且未超时:继续等待
if (!speedReached && DateTime.Now < _noLoadCaptureDeadline.Value)
{
return;
}
// 转速已达标或已超时:结束测试
AppendLatestSample(_activeNoLoadSpeedRun);
_activeNoLoadSpeedRun.CompletedAt = DateTime.Now;
_activeNoLoadSpeedRun.CompletionStatus = "记录完成";
_activeNoLoadSpeedRun.CompletionStatus = speedReached
? "状态:达到系统转速,记录完成"
: "记录完成";
_activeNoLoadSpeedRun.NoLoadSpeedRpm = _noLoadSpeedRecord;
_activeNoLoadSpeedRun.NoLoadSpeedErrorRatePercent = _noLoadSpeedErrorRate;
_completedRuns.Add(_activeNoLoadSpeedRun);
@@ -3641,6 +3671,27 @@ public sealed class MainWindowViewModel : ObservableObject
NoLoadSpeedTestButtonText = "测试";
PersistCurrentPayloadSnapshot("空载转速记录完成");
UpdateDataCaptureStatus();
_ = Task.Run(async () =>
{
try
{
await _plcCoilService.WriteCoilAsync(
_parameterConfig.ToPlcConnectionConfig(),
NoLoadSpeedRecordCoil,
false);
Log.Information(
"PLC复位成功空载转速测试M{CoilAddress}=0",
NoLoadSpeedRecordCoil);
}
catch (Exception ex)
{
Log.Error(
ex,
"PLC复位失败空载转速测试M{CoilAddress}",
NoLoadSpeedRecordCoil);
}
});
}
private void PrepareSessionForNewRun()