| | |
| | | |
| | | 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> |
| | | /// ç¨åºç段:åå§åé
ç½® |
| | |
| | | { |
| | | #region [èæ¬][20250531163716255][ä¸å¡é»è¾.å¤çMESä»»å¡çº¿ç¨.ResolveMesTask] |
| | | //mes 任塿åã䏿®µä»»å¡å 夿®µä»»å¡ã |
| | | ToWMSMES.ResMesTask(); |
| | | ToWMSMES.ResMesTask(tag); |
| | | #endregion [èæ¬][20250531163716255][ä¸å¡é»è¾.å¤çMESä»»å¡çº¿ç¨.ResolveMesTask] |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | ExitJudgeStack.TryPop(out int exitJudgeVal); |
| | | }); |
| | | |
| | | /// <summary> |
| | | /// ç¨åºç段:Program1 |
| | | /// æè¿°: |
| | |
| | | } |
| | | 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> |
| | |
| | | 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) |
| | | { |
| | |
| | | || (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); |
| | |
| | | #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()) |
| | |
| | | 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; |
| | | } |
| | |
| | | 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) |
| | |
| | | { |
| | | 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 ä¸ |