1
czw
5 天以前 0d783a041e71c91e24c338ee43a1b5f62d7954f2
2025Äê6ÔÂ12ÈÕ/AuxAllWCS/Build/Project/´úÂë/VS×Ô¶¨ÒåÀà/AutoThread.cs
@@ -30,9 +30,34 @@
using System.Net.NetworkInformation;
using System.Windows.Documents;
using System.Text.RegularExpressions;
using GZ.Device.PLC;
using S7.Net;
namespace GZ.Projects.AuxAllWCS
{
    public static class ExtendClass
    {
        public static void Disnull(this TaskRepository repository)
        {
            repository.dbcontext.Dispose();
            repository = null;
        }
        public static void Disnull(this LocRepository repository)
        {
            repository.dbcontext.Dispose();
            repository = null;
        }
        public static void Disnull(this TaskActRepository repository)
        {
            repository.dbcontext.Dispose();
            repository = null;
        }
        public static void Disnull(this SYSRepository repository)
        {
            repository.dbcontext.Dispose();
            repository = null;
        }
    }
    public partial class AutoThread
    {
@@ -126,6 +151,7 @@
        //        return _repository;
        //    }
        //}
        /// <summary>
        /// é…ç½®åˆå§‹åŒ–。
        /// </summary>
@@ -152,9 +178,11 @@
        }
        public void ThreaTotal(Tag tag, Device device)
        {
            List<Task> tasks = new List<Task>();
            LogHelper.Info("ThreaTotal çº¿ç¨‹æ€»çº¿å¯åЍ");
            tasks.Add(GetTask(delegate (Tag tag1, Device device1)
            {
                try
@@ -216,9 +244,27 @@
            tasks.Add(GetTask(ThreadMXC5, tag, 3000));
            tasks.Add(GetTask(ThreadMXC6, tag, 3000));
            tasks.Add(GetTask(ThreadS7helper, tag, 3000));
            LogHelper.Info("ThreaTotal çº¿ç¨‹æ€»çº¿runing");
            Task.WaitAll(tasks.ToArray());
            LogHelper.Info("ThreaTotal çº¿ç¨‹æ€»çº¿over");
        }
        public static ConcurrentDictionary<string, S7.Net.Plc> keyValuePairs = new ConcurrentDictionary<string, S7.Net.Plc>();
        private void ThreadS7helper(Tag tag)
        {
            //var plc = new Plc(CpuType.S71500,);
            //foreach (var item in collection)
            //{
            //    S7.Net.Plc plc = new Plc(CpuType.S71500, item.address, 0, 1);
            //    Link(plc);
            //    PLCS.Add(item.deviceName, plc);
            //}
        }
        void taskssss1(Tag tag)
        {
            sa1025(tag);
@@ -238,7 +284,7 @@
            sa3010(tag);
        }
        public static ConcurrentDictionary<string, bool> Iponlines = new ConcurrentDictionary<string, bool>();
        //public static ConcurrentDictionary<string, bool> Iponlines = new ConcurrentDictionary<string, bool>();
        public bool IsMachineOnline(string hostNameOrIp, int timeout = 1000)
        {
            //device.p发那科1下线.Config.IP
@@ -1213,6 +1259,8 @@
                        }
                    }
                }
                task1 = null;
                task2 = null;
                LogHelper.Info($"rgv å¤„理完成。taskend 125");
                #endregion
            }
@@ -1236,7 +1284,6 @@
            TaskRepository taskRepository = new TaskRepository();
            try
            {
                var requires1 = taskActRepository.FindList(x => taskCOdes.Contains(x.S_ACTION_CODE) && x.N_CREATEMETHOD == 0).OrderBy(x => x.T_CREATE).ToList();
                var timeMorhours = requires1.FindAll(x => DateTime.Now.Subtract(x.T_CREATE).TotalHours > 1);
                if (timeMorhours.Any())
@@ -1681,6 +1728,8 @@
                    }
                }
                requires1 = null;
                timeMorhours = null;
            }
            catch (Exception ex)
            {