| | |
| | | /// </summary> |
| | | public static void AgvAndEquiWorkFJ() |
| | | { |
| | | // Console.WriteLine($"心跳调度JOP:开始时间:{DateTime.Now}"); |
| | | // Console.WriteLine($"心跳调度JOP:开始时间:{DateTime.Now}"); |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_plcinfodetailRepository plcdetailRep = new dt_plcinfodetailRepository(Context); |
| | | Idt_plcinfoheadRepository plcheadRep = new dt_plcinfoheadRepository(Context); |
| | | PLCClient agvplcZ = WCSService.Clients.Find(v => v.PLCName == "正极AGV调度"); |
| | | PLCClient agvplcF = WCSService.Clients.Find(v => v.PLCName == "负极AGV调度"); |
| | | PLCClient agvplc = WCSService.Clients.Find(v => v.PLCName == "组装AGV调度"); |
| | | List<Task> taskList = new List<Task>(); |
| | | var tokenSource = new CancellationTokenSource(); |
| | | //var token = tokenSource.Token; |
| | | |
| | | Task.Run(() => |
| | | { |
| | | try |
| | | while (true) |
| | | { |
| | | if (WCSService.Clients == null || agvplc == null) |
| | | try |
| | | { |
| | | return; |
| | | WriteLog.GetLog().Write($"开始时间:{DateTime.Now} --------------", $"AGV心跳"); |
| | | if (agvplc != null) |
| | | { |
| | | OperateResult W_AGV_XTZZ = agvplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true); ; |
| | | } |
| | | if (agvplcZ != null) |
| | | { |
| | | OperateResult W_AGV_XTZ = agvplcZ.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true); |
| | | } |
| | | if (agvplcF != null) |
| | | { |
| | | OperateResult W_AGV_XTF = agvplcF.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true); |
| | | } |
| | | Thread.Sleep(300); |
| | | WriteLog.GetLog().Write($"结束时间:{DateTime.Now} --------------", $"AGV心跳"); |
| | | } |
| | | OperateResult W_AGV_XTZZ = agvplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true); |
| | | // Console.WriteLine($"组装AGV调度:[{W_AGV_XTZZ.IsSuccess}],时间:{DateTime.Now}"); |
| | | if (!W_AGV_XTZZ.IsSuccess) |
| | | catch (Exception ex) |
| | | { |
| | | return; |
| | | //throw new Exception(ex.Message); |
| | | } |
| | | |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | }); |
| | | Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | if (WCSService.Clients == null || agvplcZ == null) |
| | | { |
| | | return; |
| | | } |
| | | OperateResult W_AGV_XTZ = agvplcZ.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true); |
| | | // Console.WriteLine($"正极AGV调度:[{W_AGV_XTZ.IsSuccess}],时间:{DateTime.Now}"); |
| | | if (!W_AGV_XTZ.IsSuccess) |
| | | { |
| | | return; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | }); |
| | | Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | if (WCSService.Clients == null || agvplcF == null) |
| | | { |
| | | return; |
| | | } |
| | | OperateResult W_AGV_XTF = agvplcF.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true); |
| | | //Console.WriteLine($"负极AGV调度:[{W_AGV_XTF.IsSuccess}],时间:{DateTime.Now}"); |
| | | if (!W_AGV_XTF.IsSuccess) |
| | | { |
| | | return; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | //Task.Run(() => |
| | | //{ |
| | | // try |
| | | // { |
| | | // if (WCSService.Clients == null || agvplc == null) |
| | | // { |
| | | // return; |
| | | // } |
| | | // OperateResult W_AGV_XTZZ = agvplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true); |
| | | // // Console.WriteLine($"组装AGV调度:[{W_AGV_XTZZ.IsSuccess}],时间:{DateTime.Now}"); |
| | | // if (!W_AGV_XTZZ.IsSuccess) |
| | | // { |
| | | // return; |
| | | // } |
| | | |
| | | }); |
| | | // } |
| | | // catch (Exception) |
| | | // { |
| | | |
| | | // throw; |
| | | // } |
| | | //}); |
| | | //Task.Run(() => |
| | | //{ |
| | | // try |
| | | // { |
| | | // if (WCSService.Clients == null || agvplcZ == null) |
| | | // { |
| | | // return; |
| | | // } |
| | | // OperateResult W_AGV_XTZ = agvplcZ.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true); |
| | | // // Console.WriteLine($"正极AGV调度:[{W_AGV_XTZ.IsSuccess}],时间:{DateTime.Now}"); |
| | | // if (!W_AGV_XTZ.IsSuccess) |
| | | // { |
| | | // return; |
| | | // } |
| | | // } |
| | | // catch (Exception) |
| | | // { |
| | | |
| | | // throw; |
| | | // } |
| | | //}); |
| | | //Task.Run(() => |
| | | //{ |
| | | // try |
| | | // { |
| | | // if (WCSService.Clients == null || agvplcF == null) |
| | | // { |
| | | // return; |
| | | // } |
| | | // OperateResult W_AGV_XTF = agvplcF.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true); |
| | | // //Console.WriteLine($"负极AGV调度:[{W_AGV_XTF.IsSuccess}],时间:{DateTime.Now}"); |
| | | // if (!W_AGV_XTF.IsSuccess) |
| | | // { |
| | | // return; |
| | | // } |
| | | // } |
| | | // catch (Exception) |
| | | // { |
| | | |
| | | // throw; |
| | | // } |
| | | |
| | | //}); |
| | | |
| | | |
| | | } |