1
czw
9 天以前 8dfba1cab2ea59fca7b2c9cfad2da68e9f49b440
2025Äê6ÔÂ12ÈÕ/AuxAllWCS/Build/Project/´úÂë/½çÃæÊ¼þ.cs
@@ -50,17 +50,19 @@
            try
            {
                HttpSvcHost = new System.Net.HttpListener();
                HttpSvcHost.AuthenticationSchemes = System.Net.AuthenticationSchemes.Anonymous;
                HttpSvcHost.Prefixes.Add("http://10.221.55.117:8808/");
                HttpSvcHost.Start();
                HttpSvcHost.BeginGetContext(HttpSvcListenerCallback, null);
                //HttpSvcHost = new System.Net.HttpListener();
                //HttpSvcHost.AuthenticationSchemes = System.Net.AuthenticationSchemes.Anonymous;
                //HttpSvcHost.Prefixes.Add("http://10.221.55.117:8808/");
                //HttpSvcHost.Start();
                //HttpSvcHost.BeginGetContext(HttpSvcListenerCallback, null);
                LogHelper.Info("<<<<<<<<<<<Runnnnnnnnnnnnninggggg>>>>>>>>>>");
            }
            catch (Exception ex)
            {
                Conn.默认日志.Error(ex.ToString());
            }
            View1_Init(sender, e);
            /// <summary>
            /// ç¨‹åºç‰‡æ®µ:初始化配置
@@ -370,7 +372,7 @@
                    {
                        #region    [脚本][20250531163716255][业务逻辑.处理MES任务线程.ResolveMesTask]
                        //mes ä»»åŠ¡æ‹†åˆ†ã€‚ä¸€æ®µä»»åŠ¡å’Œ å¤šæ®µä»»åŠ¡ã€‚
                        ToWMSMES.ResMesTask();
                        ToWMSMES.ResMesTask(tag);
                        #endregion [脚本][20250531163716255][业务逻辑.处理MES任务线程.ResolveMesTask]
                    }
                    catch (Exception ex)
@@ -763,7 +765,6 @@
                }
                ExitJudgeStack.TryPop(out int exitJudgeVal);
            });
            /// <summary>
            /// ç¨‹åºç‰‡æ®µ:Program1
            /// æè¿°:
@@ -794,35 +795,66 @@
                }
                ExitJudgeStack.TryPop(out int exitJudgeVal);
            });
            //执行多次
            for (int iii = 0; iii < 1; iii++)
            /// <summary>
            /// ç¨‹åºç‰‡æ®µ:Ipping
            /// æè¿°:检测IP地址通断
            /// </summary>
            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                if (IsExitApp) { break; }
                try
                System.Threading.Thread.CurrentThread.IsBackground = true;
                ExitJudgeStack.Push(0);
                //一直执行,直到满足结束条件
                while (true)
                {
                    #region    [脚本][20250323151832119][业务逻辑.Program4]
                    if (IsExitApp) { break; }
                    try
                    {
                        #region    [脚本][20250323151832119][业务逻辑.Ipping]
                    //LogHelper.Info($"<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>");
                    //LogHelper.Info($"<<<<<<<<<<<<<<<<<程序·启动>>>>>>>>>>>>>>");
                    //// ä½¿ç”¨æ‹¦æˆªå™¨
                    //var interceptor = new ConsoleInterceptor();
                    //Console.SetOut(interceptor);
                    //LogHelper.Info($"<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>");
                    //AnsiConsole.Markup("[underline red]Hello[/] World!");
                    // AnsiConsole.Markup("[underline red]Hello[/] World!");
                    #endregion [脚本][20250323151832119][业务逻辑.Program4]
                        //var hkr = AutoThread.InvokeMethod(AutoThread.Instance, "IsMachineOnline", new object[] { "192.168.1.103", 1000 });
                        //Console.WriteLine("192.168.1.103 > " + hkr.ToString());
                        #endregion [脚本][20250323151832119][业务逻辑.Ipping]
                    }
                    catch (Exception ex)
                    {
                        Conn.默认日志.Error(ex.ToString());
                    }
                    finally
                    {
                        System.Threading.Thread.Sleep(3000);
                    }
                }
                catch (Exception ex)
                ExitJudgeStack.TryPop(out int exitJudgeVal);
            });
            /// <summary>
            /// ç¨‹åºç‰‡æ®µ:新线程总线
            /// æè¿°:1
            /// </summary>
            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                System.Threading.Thread.CurrentThread.IsBackground = true;
                ExitJudgeStack.Push(0);
                //一直执行,直到满足结束条件
                while (true)
                {
                    Conn.默认日志.Error(ex.ToString());
                    if (IsExitApp) { break; }
                    try
                    {
                        #region    [脚本][20250708095248653][业务逻辑.新线程总线]
                        AutoThread.InvokeMethod(AutoThread.Instance, "ThreaTotal", new object[] { tag, Device });
                        #endregion [脚本][20250708095248653][业务逻辑.新线程总线]
                    }
                    catch (Exception ex)
                    {
                        Conn.默认日志.Error(ex.ToString());
                    }
                    finally
                    {
                        System.Threading.Thread.Sleep(3000);
                    }
                }
                finally
                {
                    System.Threading.Thread.Sleep(3000);
                }
            }
                ExitJudgeStack.TryPop(out int exitJudgeVal);
            });
        }
        /// <summary>
@@ -926,7 +958,24 @@
                    Device.A2030取货交互?.Stop();
                    Device.RGV?.Stop();
                    Device.p发那科2下线?.Stop();
                    Device.p发那科3上线?.Stop();
                    Device.D定子1号机械手?.Stop();
                    Device.D定子2号机械手?.Stop();
                    Device.S2027Read?.Stop();
                    Device.S2020Read?.Stop();
                    Device.S2013Read?.Stop();
                    Device.S2027Write?.Stop();
                    Device.S2020Write?.Stop();
                    Device.S2013Write?.Stop();
                    Device.S2001Write?.Stop();
                    Device.S2008Write?.Stop();
                    Device.S3001Read?.Stop();
                    Device.S3006Read?.Stop();
                    Device.S3005Read?.Stop();
                    Device.S3010Read?.Stop();
                    Device.A3001放货交互?.Stop();
                    Device.A3005取货交互?.Stop();
                    Device.A3006放货交互?.Stop();
                    Device.A3010取货交互?.Stop();
                }
                catch (Exception ex)
                {
@@ -978,7 +1027,24 @@
                        || (Device.A2030取货交互 == null ? false : Device.A2030取货交互.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.RGV == null ? false : Device.RGV.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.p发那科2下线 == null ? false : Device.p发那科2下线.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.p发那科3上线 == null ? false : Device.p发那科3上线.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.D定子1号机械手 == null ? false : Device.D定子1号机械手.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.D定子2号机械手 == null ? false : Device.D定子2号机械手.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.S2027Read == null ? false : Device.S2027Read.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.S2020Read == null ? false : Device.S2020Read.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.S2013Read == null ? false : Device.S2013Read.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.S2027Write == null ? false : Device.S2027Write.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.S2020Write == null ? false : Device.S2020Write.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.S2013Write == null ? false : Device.S2013Write.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.S2001Write == null ? false : Device.S2001Write.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.S2008Write == null ? false : Device.S2008Write.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.S3001Read == null ? false : Device.S3001Read.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.S3006Read == null ? false : Device.S3006Read.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.S3005Read == null ? false : Device.S3005Read.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.S3010Read == null ? false : Device.S3010Read.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.A3001放货交互 == null ? false : Device.A3001放货交互.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.A3005取货交互 == null ? false : Device.A3005取货交互.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.A3006放货交互 == null ? false : Device.A3006放货交互.State != GZ.Device.PLC.PlcRunState.Stoped)
                        || (Device.A3010取货交互 == null ? false : Device.A3010取货交互.State != GZ.Device.PLC.PlcRunState.Stoped)
                    )
                    {
                        System.Threading.Thread.Sleep(1000);
@@ -1054,13 +1120,12 @@
        #endregion
        #region Http服务监听
        private async void HttpSvcListenerCallback(IAsyncResult ar)
        private void HttpSvcListenerCallback(IAsyncResult ar)
        {
            System.Net.HttpListenerContext context = null;
            try
            {
                HttpSvcHost.BeginGetContext(HttpSvcListenerCallback, null);
                context = HttpSvcHost.EndGetContext(ar);
                System.Net.HttpListenerContext context = HttpSvcHost.EndGetContext(ar);
                System.Net.HttpListenerRequest request = context.Request;
                System.Net.HttpListenerResponse response = context.Response;
                switch (request.LocalEndPoint.ToString())
@@ -1070,28 +1135,21 @@
                            using (var reader = new System.IO.StreamReader(request.InputStream, System.Text.Encoding.UTF8))
                            {
                                string requestJson = reader.ReadToEnd();
                                System.Net.HttpStatusCode statusCode = 0;
                                string respstr = await Task.Run(() =>
                                {
                                    return HttpSvcListenerCallback_he(request.HttpMethod, request.Url.AbsolutePath, requestJson, out statusCode);
                                });
                                string respstr = HttpSvcListenerCallback_he(request.HttpMethod, request.Url.AbsolutePath, requestJson, out System.Net.HttpStatusCode statusCode);
                                string logContent = "";
                                logContent += $"\r\n[{request.HttpMethod}]{request.Url.AbsolutePath}";
                                logContent += $"\r\n[request]{requestJson}";
                                logContent += $"\r\n[response]{respstr}";
                                _ = Task.Run(() =>
                                {
                                    Conn.默认日志?.Info(logContent);
                                });
                                Conn.默认日志?.Info(logContent);
                                byte[] bytstr = Encoding.UTF8.GetBytes(respstr);
                                response.StatusCode = (int)statusCode;
                                response.SendChunked = false;
                                response.ContentLength64 = bytstr.Length;
                                response.OutputStream.Write(bytstr, 0, bytstr.Length);
                                // å¼‚步写入响应
                                await response.OutputStream.WriteAsync(bytstr, 0, bytstr.Length);
                                response.Close();
                            }
                            break;
                        }
@@ -1100,10 +1158,6 @@
            catch (Exception ex)
            {
                Conn.默认日志.Error(ex.ToString());
            }
            finally
            {
                context?.Response.Close();
            }
        }
        private System.String HttpSvcListenerCallback_he(System.String method, System.String path, System.String requestJson, out System.Net.HttpStatusCode statusCode)
@@ -1172,7 +1226,7 @@
                        {
                            switch (path)
                            {
                                case var _ when System.Text.RegularExpressions.Regex.IsMatch(path, @"\.(html|ico|js|css)(\?.*)?$", System.Text.RegularExpressions.RegexOptions.IgnoreCase):
                                case "/inddddddddddddddddd":
                                    {
                                        statusCode = System.Net.HttpStatusCode.OK;
                                        // å¤åˆ¶åˆ°case ä¸Š