From b4083a6b047fc9e0964133c87227213c5154e37a Mon Sep 17 00:00:00 2001
From: IPC-610 <IPC-610@DESKTOP-6LEOOS3>
Date: 星期三, 15 一月 2025 15:47:44 +0800
Subject: [PATCH] 11111111

---
 Admin.NET/WCS.Application/PLC/PLCTaskAction.cs |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/Admin.NET/WCS.Application/PLC/PLCTaskAction.cs b/Admin.NET/WCS.Application/PLC/PLCTaskAction.cs
index 61302c7..451a68d 100644
--- a/Admin.NET/WCS.Application/PLC/PLCTaskAction.cs
+++ b/Admin.NET/WCS.Application/PLC/PLCTaskAction.cs
@@ -69,6 +69,7 @@
     /// </summary>
     public static void Init()
     {
+        // var strMsg = new HttpService().RequestPackWcs("LN000001");
         cts.Cancel();
         listPlc = _db.Queryable<WcsPlc>()
             .Where(s => s.Type == PLCTypeEnum.StackingMachine || s.Type == PLCTypeEnum.ConveyorLine || s.Type == PLCTypeEnum.BoxConveyorLine)
@@ -141,7 +142,7 @@
                         }
                         if (!modPlcUtil.Connected)
                         {
-                            Thread.Sleep(10000);
+                            Thread.Sleep(1000);
                             modPlcUtil.Open();
                             continue;
                         }
@@ -161,7 +162,7 @@
                             {
                                 //Console.WriteLine($"{modPlc.IP}璇诲彇{modDevice.DbNumber}.{modDevice.PlcPos}鐨勫�间负锛歿value}");
                                 //鏃犳祦绋嬭烦鍑�
-                                if (value == 0 )// && modPlc.Type!= PLCTypeEnum.BoxConveyorLine
+                                if (value == 0)// && modPlc.Type!= PLCTypeEnum.BoxConveyorLine
                                     continue;
                                 var dto = modDevice.Adapt<WcsDeviceDto>();
                                 dto.Value = value;
@@ -182,7 +183,7 @@
                             }
                         }
 
-                        Thread.Sleep(10000);
+                        Thread.Sleep(1000);
                     }
                     catch (OperationCanceledException)
                     {
@@ -245,7 +246,7 @@
                             HubUtil.PublicPlcConn(modPlc);
                         }
                     }
-                    Thread.Sleep(1000);
+                    Thread.Sleep(10000);
                 }
             }
             catch (OperationCanceledException)
@@ -315,7 +316,7 @@
                                 listPulish.Add(modAlarm);
                             }
                             //鍙栨秷鎶ヨ
-                            else if (value && modAlarm.Status == YesNoEnum.Y)
+                            else if (!value && modAlarm.Status == YesNoEnum.Y)
                             {
                                 modAlarm.AlarmTime = null;
                                 modAlarm.Status = YesNoEnum.N;
@@ -332,7 +333,8 @@
                                 modLog.Id = 0;
                                 listLog.Add(modLog);
                             }
-                            _db.Insertable(listLog).ExecuteCommand();
+                            if (listLog.Count >= 0)
+                                _db.Insertable(listLog).ExecuteCommand();
                             HubUtil.PublicAlarm(listPulish);
                         }
                     }
@@ -374,8 +376,8 @@
                         if (modPlcUtil == null)
                             continue;
                         var plcIp = modPlcUtil.PlcIP;
-                        var listDevice = listPlcDevice.Where(s => s.PlcId == modPlcUtil.PlcId && s.DeviceType == DeviceTypeEnum.Show).ToList(); 
-                        var modPlc = listPlc.FirstOrDefault(s => s.Id == modPlcUtil.PlcId); 
+                        var listDevice = listPlcDevice.Where(s => s.PlcId == modPlcUtil.PlcId && s.DeviceType == DeviceTypeEnum.Show).ToList();
+                        var modPlc = listPlc.FirstOrDefault(s => s.Id == modPlcUtil.PlcId);
                         var listaddress = new Dictionary<string, PLCDataTypeEnum>();
                         foreach (var modDevice in listDevice)
                         {
@@ -434,7 +436,7 @@
                                         {
                                             bl = false;
                                         }
-                                        else 
+                                        else
                                         {
                                             bl = true;
                                         }

--
Gitblit v1.8.0