From 8f392cc88b0768b74efca3b68785cf5aa1c38e70 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期三, 06 十一月 2024 14:28:20 +0800
Subject: [PATCH] 代码更新

---
 wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/AGV/AgvAndEquiWorkFJ.cs |  144 ++++++++++++++++++++++++++++-------------------
 1 files changed, 85 insertions(+), 59 deletions(-)

diff --git a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/AGV/AgvAndEquiWorkFJ.cs b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/AGV/AgvAndEquiWorkFJ.cs
index 8d74c6d..e47f899 100644
--- a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/AGV/AgvAndEquiWorkFJ.cs
+++ b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/AGV/AgvAndEquiWorkFJ.cs
@@ -18,81 +18,107 @@
         /// </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 == "姝f瀬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($"姝f瀬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($"姝f瀬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;
+            //    }
+
+            //});
 
 
         }

--
Gitblit v1.9.3