|
|
@@ -394,6 +394,39 @@ namespace BPASmartClient.DosingSystem |
|
|
|
} |
|
|
|
Task.WaitAll(tasks.ToArray(),TimeSpan.FromSeconds(5)); |
|
|
|
} |
|
|
|
|
|
|
|
public void ShutDown() |
|
|
|
{ |
|
|
|
TaskManage.GetInstance.StopTask("设备下发配方"); |
|
|
|
TaskManage.GetInstance.StopTask("下发设备参数"); |
|
|
|
TaskManage.GetInstance.StopTask("控制传送带"); |
|
|
|
List<Task> tasks = new(); |
|
|
|
tasks.Add(SimensSend.GetInstance.SendSimens.WriteAsync("M0.0", false)); |
|
|
|
tasks.Add(SimensSend.GetInstance.SendSimens.WriteAsync("M0.1", false)); |
|
|
|
var writeTasks = DeviceInquire.GetInstance.DeviceLists.Values.Select(async item => |
|
|
|
{ |
|
|
|
bool writeSuccessful = false; |
|
|
|
int maxRetries = 3; |
|
|
|
int retryCount = 0; |
|
|
|
|
|
|
|
while (!writeSuccessful && retryCount < maxRetries) |
|
|
|
{ |
|
|
|
var result = await item.modbusTcp.WriteAsync<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0); |
|
|
|
|
|
|
|
if (result.IsSuccess) |
|
|
|
{ |
|
|
|
writeSuccessful = true; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
retryCount++; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
tasks.AddRange(writeTasks); |
|
|
|
Task.WaitAll(tasks.ToArray(), TimeSpan.FromSeconds(5)); |
|
|
|
} |
|
|
|
private void MatchRun() |
|
|
|
{ |
|
|
|
|
|
|
|