From 993e734be337d5acea34cba80c6f0de2db9fe1bc Mon Sep 17 00:00:00 2001
From: czw <selecti@yeah.net>
Date: 星期三, 09 七月 2025 11:29:04 +0800
Subject: [PATCH] 1

---
 2025年6月12日/AuxAllWCS/Build/Project/代码/VS自定义类/AutoThread.cs |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs" "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs"
index a33c81e..eb835b9 100644
--- "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs"
+++ "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs"
@@ -27,6 +27,7 @@
 using System.Threading;
 using System.IO;
 using GZ.Device.Agv;
+using System.Net.NetworkInformation;
 
 namespace GZ.Projects.AuxAllWCS
 {
@@ -133,13 +134,33 @@
             tasks.Add(GetTask(ThreadMXC3, tag, 3000));
             tasks.Add(GetTask(ThreadMXC4, tag, 3000));
             tasks.Add(GetTask(ResetGats, tag, 3000));
-
+            
 
 
 
 
             Task.WaitAll(tasks.ToArray());
         }
+        public static bool IsMachineOnline(string hostNameOrIp, int timeout = 1000)
+        {
+            try
+            {
+                using (var ping = new Ping())
+                {
+                    var reply = ping.Send(hostNameOrIp, timeout);
+                    return reply.Status == IPStatus.Success;
+                }
+            }
+            catch (PingException)
+            {
+                return false;
+            }
+            catch (Exception)
+            {
+                // 鍏朵粬寮傚父澶勭悊
+                return false;
+            }
+        }
 
         private Task GetTask(Action<Tag> action, Tag tag, int i = 2500)
         {

--
Gitblit v1.9.1