| | |
| | | using System.Net.NetworkInformation; |
| | | using System.Windows.Documents; |
| | | using System.Text.RegularExpressions; |
| | | using GZ.Device.PLC; |
| | | |
| | | 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 |
| | | { |
| | | |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Error($"InvokeMethod > cacheKey-{ex.Message}", ex); |
| | | LogHelper.Error($"InvokeMethod > cacheKey:{cacheKey}-{ex.Message}", ex); |
| | | throw ex; |
| | | } |
| | | } |
| | |
| | | // return _repository; |
| | | // } |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// é
ç½®åå§åã |
| | | /// </summary> |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | 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 |
| | |
| | | |
| | | 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"); |
| | | } |
| | | |
| | | |
| | | 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); |
| | |
| | | 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 |
| | |
| | | } |
| | | } |
| | | } |
| | | task1 = null; |
| | | task2 = null; |
| | | LogHelper.Info($"rgv å¤ç宿ãtaskend 125"); |
| | | #endregion |
| | | } |
| | |
| | | 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()) |
| | |
| | | else if (dev.deviceType == 6) |
| | | { |
| | | var close = (System.UInt16)System.Convert.ChangeType(Conn.é»è®¤Redis.GetValue(dev.deviceName + "." + (V ? "RD1203" : "RD1204")), typeof(System.UInt16)); |
| | | LogHelper.Info($"{dev.deviceName}{(V ? "å·¦" : "å³")} å
æ
{(goin ? "å
³é" : "å¼å¯")} ç³è¯·ã å
³éç¶æï¼{close}ï¼"); |
| | | |
| | | var canDo = (System.UInt16)System.Convert.ChangeType(Conn.é»è®¤Redis.GetValue(dev.deviceName + "." + (locindex == 0 ? "RD1200" : locindex == 1 ? "RD1201" : "RD1202")), typeof(System.UInt16)); |
| | | if (close == 0) |
| | | LogHelper.Info($"{dev.deviceName}{(V ? "å·¦" : "å³")} å
æ
{(goin ? "å
³é" : "å¼å¯")} ç³è¯·ã宿± å
³éç¶æï¼{close}ï¼ å
许æä½ç¶æï¼{canDo}"); |
| | | if (close == 0 && canDo == 1) |
| | | { |
| | | continuuuuu = true; |
| | | } |
| | |
| | | } |
| | | |
| | | } |
| | | requires1 = null; |
| | | timeMorhours = null; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | private void sa2008(Tag tag) |
| | | { |
| | | var rdisTcode = RedisHelper.Get<string>($"Arrive{2008}BarcodeLast", out string msg); |
| | | LogHelper.Info($"2008 æçå·{tag.SA2030.Ræçç } redis Arrive{2008}BarcodeLastæçå·ï¼{rdisTcode} å¹é
æ ¡éªã"); |
| | | if (!string.IsNullOrEmpty(tag.ssxè¾é线.s2008.Ræçç ) && rdisTcode != tag.ssxè¾é线.s2008.Ræçç ) |
| | | var ntr = tag.ssxè¾é线.s2008.Ræçç ; |
| | | LogHelper.Info($"2008 æçå·{ntr} redis Arrive{2008}BarcodeLastæçå·ï¼{rdisTcode} å¹é
æ ¡éªã"); |
| | | if (!string.IsNullOrEmpty(ntr) && rdisTcode != ntr) |
| | | { |
| | | var ntr = tag.ssxè¾é线.s2008.Ræçç ; |
| | | var str = Settings.apiHelper.Post(Settings.MESbaseUrl + "mom-basic/dataTransmission/json/service/224", JsonConvert.SerializeObject(new |
| | | { |
| | | cntrCode = ntr, |
| | |
| | | LogHelper.Info($"循ç¯{i}次>> æ¸
空æ§å¶å°ã"); |
| | | i = 0; |
| | | } |
| | | |
| | | LogHelper.Info($"_methodCache>>>>"+ _methodCache.Count+">>>>"+JsonConvert.SerializeObject(_methodCache.Keys)); |
| | | |
| | | //Console.WriteLine($"SA2030 ä»»å¡ç¶æï¼ =====>"); |
| | | //Console.WriteLine($"SA2030 ä»»å¡ç¶æï¼{tag.SA2030.RtaskState}- 空é²{tag.SA2030.R5空é²} - barcode:{tag.SA2030.Ræçç }"); |
| | |
| | | Console.WriteLine($"ip= {ip.ToString()}"); |
| | | new HttpServer(ip.ToString()).HttpServerRun(); |
| | | new TcpServer(ip.ToString()); |
| | | var server = new EnhancedWebSocketServer($"http://{ip.ToString()}:8809/").StartAsync(); |
| | | //var server = new EnhancedWebSocketServer($"http://{ip.ToString()}:8809/").StartAsync(); |
| | | //var client = new WebSocketClient($"http://{ip.ToString()}:8809/").ConnectAsync(); |
| | | break; |
| | | } |