继续
This commit is contained in:
@@ -135,13 +135,18 @@ public partial class PumpControlChannel : ObservableObject
|
|||||||
: SetpointAvailable
|
: SetpointAvailable
|
||||||
? RawSetpointValue.ToString()
|
? RawSetpointValue.ToString()
|
||||||
: "--";
|
: "--";
|
||||||
public string Rs485RunStateText => Rs485RunStatusCode switch
|
public string Rs485RunStateText => PendingRs485RunningState switch
|
||||||
{
|
{
|
||||||
0 => "停止",
|
true => "启动确认中",
|
||||||
1 => "运行",
|
false => "停止确认中",
|
||||||
2 => "暂停",
|
null => Rs485RunStatusCode switch
|
||||||
null => "--",
|
{
|
||||||
_ => $"状态{Rs485RunStatusCode}"
|
0 => "停止",
|
||||||
|
1 => "运行",
|
||||||
|
2 => "暂停",
|
||||||
|
null => "--",
|
||||||
|
_ => $"状态{Rs485RunStatusCode}"
|
||||||
|
}
|
||||||
};
|
};
|
||||||
public string PumpGroupName => Key switch
|
public string PumpGroupName => Key switch
|
||||||
{
|
{
|
||||||
@@ -151,22 +156,32 @@ public partial class PumpControlChannel : ObservableObject
|
|||||||
"HemolysisDrainageSinglePump" or "HemolysisReturnSinglePump" or "HemolysisDualLumenPump" => "血细胞破坏",
|
"HemolysisDrainageSinglePump" or "HemolysisReturnSinglePump" or "HemolysisDualLumenPump" => "血细胞破坏",
|
||||||
_ => "其他"
|
_ => "其他"
|
||||||
};
|
};
|
||||||
public string StateText => !StateAvailable
|
public string StateText => PendingRs485RunningState switch
|
||||||
? "未知"
|
{
|
||||||
: !IsRunning
|
true => "启动中",
|
||||||
? "停止"
|
false => "停止中",
|
||||||
: IsFlowEstablished
|
null => !StateAvailable
|
||||||
? "运行"
|
? "未知"
|
||||||
: "启动中";
|
: !IsRunning
|
||||||
|
? "停止"
|
||||||
|
: IsFlowEstablished
|
||||||
|
? "运行"
|
||||||
|
: "启动中"
|
||||||
|
};
|
||||||
public string StateHint => IsRs485Busy
|
public string StateHint => IsRs485Busy
|
||||||
? string.IsNullOrWhiteSpace(Rs485BusyOperation) ? "RS485 操作中" : $"RS485 {Rs485BusyOperation}中"
|
? string.IsNullOrWhiteSpace(Rs485BusyOperation) ? "RS485 操作中" : $"RS485 {Rs485BusyOperation}中"
|
||||||
: !StateAvailable
|
: PendingRs485RunningState switch
|
||||||
? "未收到状态反馈"
|
{
|
||||||
: !IsRunning
|
true => "等待驱动/流量确认",
|
||||||
? "泵未启动"
|
false => "等待停止确认",
|
||||||
: IsFlowEstablished
|
null => !StateAvailable
|
||||||
? "流量已建立"
|
? "未收到状态反馈"
|
||||||
: "等待流量建立";
|
: !IsRunning
|
||||||
|
? "泵未启动"
|
||||||
|
: IsFlowEstablished
|
||||||
|
? "流量已建立"
|
||||||
|
: "等待流量建立"
|
||||||
|
};
|
||||||
public string IndicatorColor => !StateAvailable
|
public string IndicatorColor => !StateAvailable
|
||||||
? "#FF94A6AE"
|
? "#FF94A6AE"
|
||||||
: !IsRunning
|
: !IsRunning
|
||||||
@@ -176,9 +191,17 @@ public partial class PumpControlChannel : ObservableObject
|
|||||||
: "#FFD38A16";
|
: "#FFD38A16";
|
||||||
public string CardPrimaryDisplay => UsesLegacyPlcDirectControl ? StateText : FlowDisplay;
|
public string CardPrimaryDisplay => UsesLegacyPlcDirectControl ? StateText : FlowDisplay;
|
||||||
public string FlowDisplay => !FlowAddress.HasValue ? "-" : FlowAvailable ? $"{FlowValue:F2} L/min" : "--";
|
public string FlowDisplay => !FlowAddress.HasValue ? "-" : FlowAvailable ? $"{FlowValue:F2} L/min" : "--";
|
||||||
public string ActionText => IsRs485Busy ? "处理中" : IsRunning ? "停止" : "启动";
|
public string ActionText => IsRs485Busy
|
||||||
public bool CanToggleRs485Action => IsRunning || HasConfirmedSetpointCalibration;
|
? "处理中"
|
||||||
public string ToggleActionHint => CanToggleRs485Action ? string.Empty : "未完成流量换算标定确认";
|
: PendingRs485RunningState == true || IsRunning
|
||||||
|
? "停止"
|
||||||
|
: "启动";
|
||||||
|
public bool CanToggleRs485Action => PendingRs485RunningState == true || IsRunning || HasConfirmedSetpointCalibration;
|
||||||
|
public string ToggleActionHint => PendingRs485RunningState == true
|
||||||
|
? "启动确认中,可执行停止"
|
||||||
|
: CanToggleRs485Action
|
||||||
|
? string.Empty
|
||||||
|
: "未完成流量换算标定确认";
|
||||||
public string Rs485ReadActionText => IsRs485Busy ? "处理中" : "读取";
|
public string Rs485ReadActionText => IsRs485Busy ? "处理中" : "读取";
|
||||||
public string Rs485WriteActionText => IsRs485Busy ? "处理中" : "写入";
|
public string Rs485WriteActionText => IsRs485Busy ? "处理中" : "写入";
|
||||||
public string SetpointStatusForeground => ResolveSetpointStatusForeground();
|
public string SetpointStatusForeground => ResolveSetpointStatusForeground();
|
||||||
@@ -290,6 +313,16 @@ public partial class PumpControlChannel : ObservableObject
|
|||||||
|
|
||||||
partial void OnRs485RunStatusCodeChanged(ushort? value) => OnPropertyChanged(nameof(Rs485RunStateText));
|
partial void OnRs485RunStatusCodeChanged(ushort? value) => OnPropertyChanged(nameof(Rs485RunStateText));
|
||||||
|
|
||||||
|
partial void OnPendingRs485RunningStateChanged(bool? value)
|
||||||
|
{
|
||||||
|
OnPropertyChanged(nameof(Rs485RunStateText));
|
||||||
|
OnPropertyChanged(nameof(StateText));
|
||||||
|
OnPropertyChanged(nameof(StateHint));
|
||||||
|
OnPropertyChanged(nameof(ActionText));
|
||||||
|
OnPropertyChanged(nameof(CanToggleRs485Action));
|
||||||
|
OnPropertyChanged(nameof(ToggleActionHint));
|
||||||
|
}
|
||||||
|
|
||||||
partial void OnIsRs485BusyChanged(bool value)
|
partial void OnIsRs485BusyChanged(bool value)
|
||||||
{
|
{
|
||||||
OnPropertyChanged(nameof(StateHint));
|
OnPropertyChanged(nameof(StateHint));
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System.IO.Ports;
|
using System.IO.Ports;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -185,18 +185,28 @@ public sealed class Rs485PumpFlowService : IRs485PumpFlowService
|
|||||||
Thread.Sleep(PostCommandVerifyDelayMs);
|
Thread.Sleep(PostCommandVerifyDelayMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TryReadRegister(master, slave, request.PumpSettings.MotorControlRegister, out var motorCommandReadback, out _)
|
||||||
|
&& motorCommandReadback != unchecked((ushort)rawMotorSpeed))
|
||||||
|
{
|
||||||
|
return Failure($"RS485 直接启动失败:控制寄存器回读 {motorCommandReadback},目标 {rawMotorSpeed}");
|
||||||
|
}
|
||||||
|
|
||||||
if (TryReadRegister(master, slave, request.PumpSettings.RunStatusRegister, out var runStatusValue, out _))
|
if (TryReadRegister(master, slave, request.PumpSettings.RunStatusRegister, out var runStatusValue, out _))
|
||||||
{
|
{
|
||||||
if (runStatusValue != 1)
|
if (runStatusValue == 1)
|
||||||
{
|
{
|
||||||
return Failure($"RS485 直启失败:运行状态返回 {runStatusValue},未确认启动");
|
return new Rs485PumpFlowOperationResult
|
||||||
|
{
|
||||||
|
Success = true,
|
||||||
|
Message = $"RS485 直接启动成功,控制值 {rawMotorSpeed}",
|
||||||
|
RunStatus = runStatusValue
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Rs485PumpFlowOperationResult
|
return new Rs485PumpFlowOperationResult
|
||||||
{
|
{
|
||||||
Success = true,
|
Success = true,
|
||||||
Message = $"RS485 直接启动成功,控制值 {rawMotorSpeed}",
|
Message = $"RS485 启动命令已下发,控制值 {rawMotorSpeed},运行状态当前为 {runStatusValue},等待流量确认"
|
||||||
RunStatus = runStatusValue
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,6 +238,12 @@ public sealed class Rs485PumpFlowService : IRs485PumpFlowService
|
|||||||
Thread.Sleep(PostCommandVerifyDelayMs);
|
Thread.Sleep(PostCommandVerifyDelayMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TryReadRegister(master, slave, request.PumpSettings.MotorControlRegister, out var motorCommandReadback, out _)
|
||||||
|
&& motorCommandReadback != 0)
|
||||||
|
{
|
||||||
|
return Failure($"RS485 直接停止失败:控制寄存器回读 {motorCommandReadback},未回到 0");
|
||||||
|
}
|
||||||
|
|
||||||
if (TryReadRegister(master, slave, request.PumpSettings.RunStatusRegister, out var runStatusValue, out _))
|
if (TryReadRegister(master, slave, request.PumpSettings.RunStatusRegister, out var runStatusValue, out _))
|
||||||
{
|
{
|
||||||
if (runStatusValue != 0)
|
if (runStatusValue != 0)
|
||||||
@@ -246,7 +262,8 @@ public sealed class Rs485PumpFlowService : IRs485PumpFlowService
|
|||||||
return new Rs485PumpFlowOperationResult
|
return new Rs485PumpFlowOperationResult
|
||||||
{
|
{
|
||||||
Success = true,
|
Success = true,
|
||||||
Message = "RS485 停止命令已下发,等待流量确认"
|
Message = "RS485 直接停止成功,控制寄存器已回到 0",
|
||||||
|
RunStatus = 0
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -854,7 +854,17 @@ public partial class MainViewModel
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!expectedRunning)
|
||||||
|
{
|
||||||
|
pump.PendingRs485RunningState = null;
|
||||||
|
pump.IsRunning = false;
|
||||||
|
pump.StateAvailable = true;
|
||||||
|
pump.Rs485RunStatusCode = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pump.PendingRs485RunningState = expectedRunning;
|
pump.PendingRs485RunningState = expectedRunning;
|
||||||
|
pump.IsRunning = expectedRunning;
|
||||||
pump.StateAvailable = false;
|
pump.StateAvailable = false;
|
||||||
pump.Rs485RunStatusCode = null;
|
pump.Rs485RunStatusCode = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -696,7 +696,8 @@ public partial class MainViewModel : ObservableObject, IDisposable
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nextState = !pump.IsRunning;
|
var effectiveRunning = pump.PendingRs485RunningState ?? pump.IsRunning;
|
||||||
|
var nextState = !effectiveRunning;
|
||||||
if (await TryTogglePumpControlViaRs485(pump, nextState))
|
if (await TryTogglePumpControlViaRs485(pump, nextState))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user