chenxy 4 жил өмнө
parent
commit
87c753a8bb
38 өөрчлөгдсөн 2264 нэмэгдсэн , 886 устгасан
  1. 3 0
      Curtain.Net.Sockets/Curtain.Net.Sockets.net4.csproj
  2. 5 0
      Curtain.Net.Sockets/PLC/ConvertTool.cs
  3. 9 1
      Curtain.Net.Sockets/PLC/Core/PLCResult.cs
  4. 1 0
      Curtain.Net.Sockets/PLC/Model/Melsec/MelsecA1EAsciiModel.cs
  5. 2 0
      Curtain.Net.Sockets/PLC/Model/PLCModel.cs
  6. 1 0
      Curtain.Net.Sockets/PLC/Model/Siemens/SiemensS7_1200Model.cs
  7. 1 0
      Curtain.Net.Sockets/PLC/Model/Siemens/SiemensS7_200SmartModel.cs
  8. 19 19
      Curtain.Net.Sockets/PLC/PLCSocket.cs
  9. 8 7
      Curtain.Net.Sockets/PLC/SocketClient.cs
  10. 19 0
      HG5020.1-2/PLC_S/Core/PLC_S_Core.cs
  11. 8 0
      HG5020.1-2/PLC_S/Core/PLC_Server.cs
  12. 8 0
      HG5020.1-2/PLC_S/PLC_S_1.csproj
  13. 42 0
      HG5020.1-2/PLC_S/PLC_S_INI/PLC_S_GC_DM1_.ini
  14. 457 0
      HG5020.1-2/PLC_S/ServerModel/GoodsCode_DM2201.cs
  15. 456 0
      HG5020.1-2/PLC_S/ServerModel/GoodsCode_DM2205.cs
  16. 7 7
      HG5020.1-2/PLC_S/ServerModel/GoodsCode_XW.cs
  17. 823 798
      HG5020.1-2/PLC_WF/F_Main.Designer.cs
  18. 207 2
      HG5020.1-2/PLC_WF/F_Main.cs
  19. 54 4
      HG5020.1-2/PLC_WF/F_PLC_M.Designer.cs
  20. 115 46
      HG5020.1-2/PLC_WF/F_PLC_M.cs
  21. 4 2
      HG5020.1-2/PLC_WF/PLC_WF_1.csproj
  22. 3 0
      HG5020.1-2/PLC_WS/PLC_WS_1.csproj
  23. 3 0
      HG5020.3/PLC_S/PLC_S.csproj
  24. 3 0
      HG5020.3/PLC_WF/PLC_WF.csproj
  25. 3 0
      HG5020.3/PLC_WS/PLC_WS.csproj
  26. 3 0
      HG5020.3/TEST_HPGP/TEST_HPGP.csproj
  27. BIN
      doc/恒洁3车间-对接设置210118.xlsx
  28. BIN
      lib/Curtain.Core.net4.dll
  29. BIN
      lib/Curtain.DataAccess.net4.dll
  30. BIN
      lib/Curtain.Framework.net4.dll
  31. BIN
      lib/Newtonsoft.Json.dll
  32. BIN
      lib/Oracle.ManagedDataAccess.dll
  33. BIN
      lib/bak/Curtain.Core.net4.dll
  34. BIN
      lib/bak/Curtain.DataAccess.net4.dll
  35. BIN
      lib/bak/Curtain.Framework.net4.dll
  36. BIN
      lib/bak/ICSharpCode.SharpZipLib.dll
  37. BIN
      lib/bak/Newtonsoft.Json.dll
  38. BIN
      lib/bak/Oracle.ManagedDataAccess.dll

+ 3 - 0
Curtain.Net.Sockets/Curtain.Net.Sockets.net4.csproj

@@ -40,6 +40,9 @@
   <PropertyGroup>
     <StartupObject />
   </PropertyGroup>
+  <PropertyGroup>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
   <ItemGroup>
     <Compile Include="PLC\ConvertTool.cs" />
     <Compile Include="PLC\Core\ServerMessage.cs" />

+ 5 - 0
Curtain.Net.Sockets/PLC/ConvertTool.cs

@@ -11,6 +11,11 @@ namespace Curtain.Net.Sockets.PLC
     public static class ConvertTool
     {
         #region Siemens S7
+        /// <summary>
+        /// Siemens S7 字节反转
+        /// </summary>
+        /// <param name="data"></param>
+        /// <returns></returns>
         public static byte[] ReverseBy2(byte[] data)
         {
             int count = data.Length;

+ 9 - 1
Curtain.Net.Sockets/PLC/Core/PLCResult.cs

@@ -75,7 +75,15 @@ namespace Curtain.Net.Sockets.PLC
             this.Message = result.Message;
             this.MessageDetail = result.MessageDetail;
         }
-    }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+		public override string ToString()
+		{
+			return $"PLCResult[{Successed}][{Message}]";
+		}
+	}
 
     /// <summary>
     /// 返回结果

+ 1 - 0
Curtain.Net.Sockets/PLC/Model/Melsec/MelsecA1EAsciiModel.cs

@@ -137,6 +137,7 @@ namespace Curtain.Net.Sockets.PLC.Model.Melsec
         /// </summary>
         /// <typeparam name="TValue"></typeparam>
         /// <param name="plc_m"></param>
+        /// <param name="encoding"></param>
         public override void SetReadValueFromBytes<TValue>(PLCMessage<TValue> plc_m, Encoding encoding = null)
         {
             if (plc_m.PLCError || plc_m.ContentBytes == null || plc_m.ContentBytes.Length == 0)

+ 2 - 0
Curtain.Net.Sockets/PLC/Model/PLCModel.cs

@@ -83,6 +83,7 @@ namespace Curtain.Net.Sockets.PLC.Model
         /// </summary>
         /// <typeparam name="TValue"></typeparam>
         /// <param name="plc_m"></param>
+        /// <param name="encoding"></param>
         void SetReadValueFromBytes<TValue>(PLCMessage<TValue> plc_m, Encoding encoding = null);
         #endregion
 
@@ -288,6 +289,7 @@ namespace Curtain.Net.Sockets.PLC.Model
         /// </summary>
         /// <typeparam name="TValue"></typeparam>
         /// <param name="plc_m"></param>
+        /// <param name="encoding"></param>
         public virtual void SetReadValueFromBytes<TValue>(PLCMessage<TValue> plc_m, Encoding encoding)
         {
             throw new NotSupportedException(typeof(TValue).Name);

+ 1 - 0
Curtain.Net.Sockets/PLC/Model/Siemens/SiemensS7_1200Model.cs

@@ -198,6 +198,7 @@ namespace Curtain.Net.Sockets.PLC.Model.Siemens
         /// </summary>GetReadMessage
         /// <typeparam name="TValue"></typeparam>
         /// <param name="plc_m"></param>
+        /// <param name="encoding"></param>
         public override void SetReadValueFromBytes<TValue>(PLCMessage<TValue> plc_m, Encoding encoding = null)
         {
             //byte[] data = plc_m.ContentBytes;

+ 1 - 0
Curtain.Net.Sockets/PLC/Model/Siemens/SiemensS7_200SmartModel.cs

@@ -204,6 +204,7 @@ namespace Curtain.Net.Sockets.PLC.Model.Siemens
         /// </summary>GetReadMessage
         /// <typeparam name="TValue"></typeparam>
         /// <param name="plc_m"></param>
+        /// <param name="encoding"></param>
         public override void SetReadValueFromBytes<TValue>(PLCMessage<TValue> plc_m, Encoding encoding = null)
         {
             //byte[] data = plc_m.ContentBytes;

+ 19 - 19
Curtain.Net.Sockets/PLC/PLCSocket.cs

@@ -233,21 +233,21 @@ namespace Curtain.Net.Sockets.PLC
             if (data == null || data.Length == 0)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no command";
+                plcResult.Message = "c:send no command";
                 return plcResult;
             }
 
             if (Socket == null)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no socket";
+                plcResult.Message = "c:send no socket";
                 return plcResult;
             }
 
             if (!Socket.Connected)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no connected";
+                plcResult.Message = "c:send no connected";
                 return plcResult;
             }
 
@@ -259,7 +259,7 @@ namespace Curtain.Net.Sockets.PLC
             catch (Exception ex)
             {
                 plcResult.Successed = false;
-                plcResult.Message = ex.Message;
+                plcResult.Message = "c:send " + ex.Message;
                 plcResult.MessageDetail = ex.ToString();
                 Socket?.Close();
                 Socket = null;
@@ -279,21 +279,21 @@ namespace Curtain.Net.Sockets.PLC
             if (data == null || data.Length == 0)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no command";
+                plcResult.Message = "c:begin send no command";
                 return plcResult;
             }
 
             if (Socket == null)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no socket";
+                plcResult.Message = "c:begin send no socket";
                 return plcResult;
             }
 
             if (!Socket.Connected)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no connected";
+                plcResult.Message = "c:begin send no connected";
                 return plcResult;
             }
 
@@ -308,7 +308,7 @@ namespace Curtain.Net.Sockets.PLC
             catch (Exception ex)
             {
                 plcResult.Successed = false;
-                plcResult.Message = ex.Message;
+                plcResult.Message = "c:begin send " + ex.Message;
                 plcResult.MessageDetail = ex.ToString();
                 sas?.Close();
                 sas = null;
@@ -346,7 +346,7 @@ namespace Curtain.Net.Sockets.PLC
                 catch (Exception ex)
                 {
                     sas.Result.Successed = false;
-                    sas.Result.Message = ex.Message;
+                    sas.Result.Message = "c:send callback " + ex.Message;
                     sas.Result.MessageDetail = ex.ToString();
                     Socket.Close();
                     Socket = null;
@@ -368,21 +368,21 @@ namespace Curtain.Net.Sockets.PLC
             if (length == 0)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no length";
+                plcResult.Message = "c:receive no length";
                 return plcResult;
             }
 
             if (Socket == null)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no socket";
+                plcResult.Message = "c:receive no socket";
                 return plcResult;
             }
 
             if (!Socket.Connected)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no connected";
+                plcResult.Message = "c:receive no connected";
                 return plcResult;
             }
 
@@ -395,7 +395,7 @@ namespace Curtain.Net.Sockets.PLC
             catch (Exception ex)
             {
                 plcResult.Successed = false;
-                plcResult.Message = ex.Message;
+                plcResult.Message = "c:receive " + ex.Message;
                 plcResult.MessageDetail = ex.ToString();
                 Socket?.Close();
                 Socket = null;
@@ -415,21 +415,21 @@ namespace Curtain.Net.Sockets.PLC
             if (length == 0)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no length";
+                plcResult.Message = "c:begin receive no length";
                 return plcResult;
             }
 
             if (Socket == null)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no socket";
+                plcResult.Message = "c:begin receive no socket";
                 return plcResult;
             }
 
             if (!Socket.Connected)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no connected";
+                plcResult.Message = "c:begin receive no connected";
                 return plcResult;
             }
 
@@ -444,7 +444,7 @@ namespace Curtain.Net.Sockets.PLC
             catch (Exception ex)
             {
                 plcResult.Successed = false;
-                plcResult.Message = ex.Message;
+                plcResult.Message = "c:begin receive " + ex.Message;
                 plcResult.MessageDetail = ex.ToString();
                 sas?.Close();
                 sas = null;
@@ -485,7 +485,7 @@ namespace Curtain.Net.Sockets.PLC
                     else
                     {
                         sas.Result.Successed = false;
-                        sas.Result.Message = "other socket has closed";
+                        sas.Result.Message = "c:receive callback other socket has closed";
                         Socket.Close();
                         Socket = null;
                         sas.Set();
@@ -494,7 +494,7 @@ namespace Curtain.Net.Sockets.PLC
                 catch (Exception ex)
                 {
                     sas.Result.Successed = false;
-                    sas.Result.Message = ex.Message;
+                    sas.Result.Message = "c:receive callback " + ex.Message;
                     sas.Result.MessageDetail = ex.ToString();
                     Socket.Close();
                     Socket = null;

+ 8 - 7
Curtain.Net.Sockets/PLC/SocketClient.cs

@@ -183,7 +183,7 @@ namespace Curtain.Net.Sockets.PLC
             if (plc_m == null)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no plc message";
+                plcResult.Message = "c:do command oneway no plc message";
                 return plcResult;
             }
 
@@ -198,7 +198,7 @@ namespace Curtain.Net.Sockets.PLC
                     if (string.IsNullOrEmpty(plc_m.Command))
                     {
                         plcResult.Successed = false;
-                        plcResult.Message = "no command";
+                        plcResult.Message = "c:do command oneway no command";
                         return plcResult;
                     }
                     else
@@ -219,7 +219,7 @@ namespace Curtain.Net.Sockets.PLC
             {
                 //this.Disconnect();
                 plcResult.Successed = false;
-                plcResult.Message = ex.Message;
+                plcResult.Message = "c:do command oneway " + ex.Message;
                 plcResult.MessageDetail = ex.ToString();
             }
             finally
@@ -243,7 +243,7 @@ namespace Curtain.Net.Sockets.PLC
             if (plc_m == null)
             {
                 plcResult.Successed = false;
-                plcResult.Message = "no plc message";
+                plcResult.Message = "c:do command no plc message";
                 return plcResult;
             }
 
@@ -258,7 +258,7 @@ namespace Curtain.Net.Sockets.PLC
                     if (string.IsNullOrEmpty(plc_m.Command))
                     {
                         plcResult.Successed = false;
-                        plcResult.Message = "no command";
+                        plcResult.Message = "c:do command no command";
                         return plcResult;
                     }
                     else
@@ -294,7 +294,7 @@ namespace Curtain.Net.Sockets.PLC
                 if (!PLCModel.CheckHead(plc_m))
                 {
                     plcResult.Successed = false;
-                    plcResult.Message = "response head error";
+                    plcResult.Message = "c:do command response head error";
                     return plcResult;
                 }
 
@@ -325,7 +325,7 @@ namespace Curtain.Net.Sockets.PLC
             {
                 //this.Disconnect();
                 plcResult.Successed = false;
-                plcResult.Message = ex.Message;
+                plcResult.Message = "c:do command " + ex.Message;
                 plcResult.MessageDetail = ex.ToString();
             }
             finally
@@ -435,6 +435,7 @@ namespace Curtain.Net.Sockets.PLC
         /// </summary>
         /// <param name="code"></param>
         /// <param name="number"></param>
+        /// <param name="encoding"></param>
         /// <param name="length"></param>
         /// <returns></returns>
         public virtual PLCResult<string> ReadString(string code, string number, Encoding encoding, int length = 1)

+ 19 - 0
HG5020.1-2/PLC_S/Core/PLC_S_Core.cs

@@ -159,4 +159,23 @@ namespace PLC_S_1
         public string Add_F_Code;
         public string Add_F_CodeNum;
     }
+
+
+    /// <summary>
+    /// 2#2楼打磨前
+    /// </summary>
+    public class PLC_S_GC_DM1
+    {
+        public string IP;
+        public int Port;
+        public int LINE_NO;
+        public int WS_ID;
+        public string WS_NAME;
+        public string WS_USER;
+        public int P_ID;
+        public char Add_GoodsCode;
+        public int Add_GoodsCodeNum;
+        public char Add_FlagCode;
+        public int Add_FlagCodeNum;
+    }
 }

+ 8 - 0
HG5020.1-2/PLC_S/Core/PLC_Server.cs

@@ -26,6 +26,14 @@ namespace PLC_S_1
 
             switch (PLC_S_S.PLCServiceType)
             {
+                // 打磨型号【2-7改洗交接】 2201 2202
+                case "GC_DM2201":
+                    ServerSocket = new GoodsCode_DM2201();
+                    break;
+                // 打磨完成【2-0改洗】 2205
+                case "GC_DM2205":
+                    ServerSocket = new GoodsCode_DM2205();
+                    break;
                 // 小件-成检-物料架 5101
                 case "GC_XW":
                     ServerSocket = new GoodsCode_XW();

+ 8 - 0
HG5020.1-2/PLC_S/PLC_S_1.csproj

@@ -30,6 +30,9 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
+  <PropertyGroup>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
   <ItemGroup>
     <Compile Include="Core\IWindowsServer.cs" />
     <Compile Include="Proxy\ISmartDevice.cs" />
@@ -37,6 +40,8 @@
     <Compile Include="Proxy\SmartDeviceProxy.cs" />
     <Compile Include="Proxy\WCFProxy.cs" />
     <Compile Include="Proxy\WCFProxySetting.cs" />
+    <Compile Include="ServerModel\GoodsCode_DM2205.cs" />
+    <Compile Include="ServerModel\GoodsCode_DM2201.cs" />
     <Compile Include="ServerModel\GoodsCode_XW.cs" />
     <Compile Include="Core\IShowLog.cs" />
     <Compile Include="Core\PLC_S_Core.cs" />
@@ -71,6 +76,9 @@
     <Reference Include="System.ServiceModel" />
   </ItemGroup>
   <ItemGroup>
+    <None Include="PLC_S_INI\PLC_S_GC_DM1_.ini">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
     <None Include="PLC_S_INI\PLC_S_GC_XW.ini">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>

+ 42 - 0
HG5020.1-2/PLC_S/PLC_S_INI/PLC_S_GC_DM1_.ini

@@ -0,0 +1,42 @@
+;产品型号(计件1-7改洗交接)
+[GC_DM1_1]
+IP=172.18.26.38
+Port=8080
+LINE_NO=1
+WS_ID=2201
+WS_NAME=2#打磨1线
+WS_USER=
+P_ID=63
+Add_GoodsCode=D
+Add_GoodsCodeNum=800
+Add_FlagCode=D
+Add_FlagCodeNum=801
+
+;产品型号(计件1-7改洗交接)
+[GC_DM1_2]
+IP=172.18.26.39
+Port=8080
+LINE_NO=2
+WS_ID=2202
+WS_NAME=2#打磨2线
+WS_USER=
+P_ID=63
+Add_GoodsCode=D
+Add_GoodsCodeNum=800
+Add_FlagCode=D
+Add_FlagCodeNum=801
+
+
+;(计件2-0改洗)
+[GC_DM1_5]
+IP=172.18.26.40
+Port=8080
+LINE_NO=0
+WS_ID=2205
+WS_NAME=2#打磨完成
+WS_USER=
+P_ID=2
+Add_GoodsCode=D
+Add_GoodsCodeNum=800
+Add_FlagCode=D
+Add_FlagCodeNum=801

+ 457 - 0
HG5020.1-2/PLC_S/ServerModel/GoodsCode_DM2201.cs

@@ -0,0 +1,457 @@
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+
+using Curtain.DataAccess;
+using Curtain.Extension.ExObjectConvert;
+using Curtain.Extension.ExSystemData;
+using Curtain.Framework.Json;
+using Curtain.Helpers;
+using Curtain.Log;
+using Curtain.Net.Sockets.PLC;
+using Curtain.Net.Sockets.PLC.Model;
+using Curtain.Net.Sockets.PLC.Model.Melsec;
+
+using PLC_S_1.Proxy;
+
+namespace PLC_S_1.ServerModel
+{
+    /// <summary>
+    /// 返回产品型号,计件(1-7改洗交接) 0:复位 1:成功 2:条码格式错误或不存在 3:产品不可到达 4:MES系统异常 5:产品型号识别码未设置
+    /// </summary>
+    public class GoodsCode_DM2201 : SocketServer<SimpleSocketServerModel>, IShowFormLog, IWindowsServer
+    {
+        public Dictionary<string, PLC_S_GC_DM1> PLC_FLAGS = new Dictionary<string, PLC_S_GC_DM1>();
+        public const string M_NAME = "GC_DM1_";
+        private MES_S _mes_s = null;
+
+        private readonly Logger logger = Logger.CreateLogger(M_NAME);
+        private readonly LogInfo logger_t = new LogInfo();
+        private readonly LogInfo logger_e = new LogInfo();
+
+        //private bool 
+
+        public int Interval
+        {
+            get;
+            set;
+        }
+        public string EPTS_CODE
+        {
+            get;
+            set;
+        }
+        public GoodsCode_DM2201()
+        {
+            logger.FileExistDays = 30;
+            logger.FilePrefix = "";
+            logger.FileSuffix = M_NAME;
+            logger.LevelOneFile = true;
+            logger.FileNameWithoutDate = true;
+
+            logger_t.SubFolderFormat = "<name>";
+            logger_t.FileExistDays = 30;
+            logger_t.LevelOneFile = true;
+
+            logger_e.FileExistDays = 10;
+
+            this.Model.FormatType = CommandFormatType.StartStopChar;
+
+            this.ServerStarting += ServerSocket_ServerStarting;
+            this.ServerStarted += ServerSocket_ServerStarted;
+            this.ServerStoping += ServerSocket_ServerStoping;
+            this.ServerStoped += ServerSocket_ServerStoped;
+
+            this.ServerMessage += ServerSocket_ServerMessage;
+            this.Received += ServerSocket_Received;
+
+            _mes_s = MES_S.Get();
+        }
+
+        #region Server
+        public IFormLogShow FormLogShow
+        {
+            get;
+            set;
+        }
+
+        private void ServerSocket_ServerStarting(object sender, CancelEventArgs e)
+        {
+            try
+            {
+                
+                logger.OutputTrace($"{M_NAME}_ServerStarting");
+            }
+            catch { }
+        }
+        private void ServerSocket_ServerStarted(object sender, EventArgs e)
+        {
+            try
+            {
+                
+                logger.OutputTrace($"{M_NAME}_ServerStarted");
+            }
+            catch { }
+        }
+        private void ServerSocket_ServerStoping(object sender, CancelEventArgs e)
+        {
+            try
+            {
+                
+                logger.OutputTrace($"{M_NAME}_ServerStoping");
+            }
+            catch { }
+        }
+        private void ServerSocket_ServerStoped(object sender, EventArgs e)
+        {
+            try
+            {
+                
+                logger.OutputTrace($"{M_NAME}_ServerStoped");
+            }
+            catch { }
+        }
+        private void ServerSocket_ServerMessage(object sender, ServerMessageEventArgs e)
+        {
+            try
+            {
+                
+                string message = e.ToString();
+                string cip = e?.Client?.IP;
+                if (e.Type == ServerMessageType.Debug)
+                {
+                    Logger.Debug(message, $"{M_NAME}-T[{cip}]", logger_t);
+                }
+                if (e.Type == ServerMessageType.Error)
+                {
+                    Logger.Error(e.Exception, message, $"{M_NAME}-E[{cip}]", logger_e);
+                }
+                if (e.Type == ServerMessageType.Trace)
+                {
+                    Logger.Trace(message, $"{M_NAME}-T[{cip}]", logger_t);
+                }
+                if (e.Type == ServerMessageType.Warning)
+                {
+                    Logger.Warn(message, $"{M_NAME}-E[{cip}]", logger_e);
+                }
+                FormLogShow?.ShowLog("ServerMessage=" + message);
+            }
+            catch { }
+        }
+        #endregion
+
+        /// <summary>
+        /// 返回产品型号
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ServerSocket_Received(object sender, ReceiveSession e)
+        {
+            PLC_S_GC_DM1 plc_s = null;
+            string cIP = e?.Client?.IP;
+            string logKeyT = $"{M_NAME}-T[{cIP}]";
+            string logKeyE = $"{M_NAME}-E[{cIP}]";
+
+            
+
+            SocketClient<MelsecA1EAsciiModel> plc = null;
+            Logger LoggerT = Logger.CreateLogger(logKeyT, logger_t);
+            lock (LoggerT)
+            {
+                try
+                {
+                    LoggerT.BeginTracking();
+
+                    string outputMessage = e.ToString();
+                    Logger.Trace(outputMessage, logKeyT, logger_t);
+                    FormLogShow?.ShowLog(outputMessage);
+
+                    if (string.IsNullOrWhiteSpace(e.Content))
+                    {
+                        outputMessage = "接收数据为空";
+                        Logger.Warn(outputMessage, logKeyT, logger_t);
+                        Logger.Warn(outputMessage, logKeyE, logger_e);
+                        FormLogShow?.ShowLog(outputMessage);
+                        return;
+                    }
+
+                    outputMessage = e.Content;
+                    Logger.Trace(outputMessage, logKeyT, logger_t);
+                    FormLogShow?.ShowLog(outputMessage);
+
+                    string[] c = e.Content.Split('#');
+                    string flag = null;
+                    if (c.Length > 0)
+                    {
+                        flag = c[0];
+                    }
+                    string barcode = null;
+                    if (c.Length > 1)
+                    {
+                        barcode = c[1];
+                    }
+
+                    if (string.IsNullOrWhiteSpace(flag))
+                    {
+                        outputMessage = $"[{e.Content}]接收设备代码为空";
+                        Logger.Warn(outputMessage, logKeyT, logger_t);
+                        Logger.Warn(outputMessage, logKeyE, logger_e);
+                        FormLogShow?.ShowLog(outputMessage);
+                        return;
+                    }
+
+                    plc_s = GetPLC_S_DM(flag, e, logKeyE);
+                    if (plc_s == null)
+                    {
+                        outputMessage = $"[{e.Content}]设备代码[{flag}]未找到ini配置或有错误";
+                        Logger.Error(null, outputMessage, logKeyT, logger_t);
+                        Logger.Error(null, outputMessage, logKeyE, logger_e);
+                        FormLogShow?.ShowLog(outputMessage);
+                        return;
+                    }
+
+                    outputMessage = $"[{e.Content}]PLC_Connect={JsonHelper.FromObject(plc_s)}";
+                    Logger.Trace(outputMessage, logKeyT, logger_t);
+                    FormLogShow?.ShowLog(outputMessage);
+
+                    plc = new SocketClient<MelsecA1EAsciiModel>();
+                    plc.Connect(plc_s.IP, plc_s.Port);
+                    //outputMessage = $"[{e.Content}]PLC_Connect=[{plc_s.IP}:{plc_s.Port}]";
+                    //Logger.Trace(outputMessage, logKeyT, logger_t);
+                    //FormLogShow?.ShowLog(outputMessage);
+
+                    plc.Write<int>(plc_s.Add_GoodsCode, plc_s.Add_GoodsCodeNum, 0);
+                    plc.Write<int>(plc_s.Add_FlagCode, plc_s.Add_FlagCodeNum, 0);
+
+                    if (string.IsNullOrWhiteSpace(barcode) ||
+                        barcode == "0" ||
+                        barcode.Length != 11 ||
+                        barcode.StartsWith("0"))
+                    {
+                        outputMessage = $"[{e.Content}]接收条码格式错误";
+                        Logger.Warn(outputMessage, logKeyT, logger_t);
+                        Logger.Warn(outputMessage, logKeyE, logger_e);
+                        FormLogShow?.ShowLog(outputMessage);
+                        // 0:复位 1:成功 2:条码格式错误或不存在 3:产品不可到达 4:MES系统异常 5:产品型号识别码未设置
+                        SendFlag(plc_s, e, logKeyT, logKeyE, plc, 2);
+                        return;
+                    }
+
+                    DataRow codeRow = GetGoodsCode(barcode, e, logKeyE, plc_s);
+                    if (codeRow == null)
+                    {
+                        outputMessage = $"[{e.Content}]此条码[{barcode}]不存在";
+                        Logger.Warn(outputMessage, logKeyT, logger_t);
+                        Logger.Warn(outputMessage, logKeyE, logger_e);
+                        FormLogShow?.ShowLog(outputMessage);
+                        // 0:复位 1:成功 2:条码格式错误或不存在 3:产品不可到达 4:MES系统异常 5:产品型号识别码未设置
+                        SendFlag(plc_s, e, logKeyT, logKeyE, plc, 2);
+                        return;
+                    }
+
+                    string code = codeRow["goodscode"].ToString();
+                    string plc_code = codeRow["plc_code"].ToString();
+                    string p_id = codeRow["p_id"].ToString();
+
+                    outputMessage = $"[{e.Content}]产品型号={code}[{plc_code}]";
+                    Logger.Trace(outputMessage, logKeyT, logger_t);
+                    FormLogShow?.ShowLog(outputMessage);
+
+                    if (string.IsNullOrWhiteSpace(plc_code))
+                    {
+                        outputMessage = $"[{e.Content}]此条码[{barcode}]未设置型号代码";
+                        Logger.Error(null, outputMessage, logKeyT, logger_t);
+                        Logger.Error(null, outputMessage, logKeyE, logger_e);
+                        FormLogShow?.ShowLog(outputMessage);
+                        // 0:复位 1:成功 2:条码格式错误或不存在 3:产品不可到达 4:MES系统异常 5:产品型号识别码未设置
+                        SendFlag(plc_s, e, logKeyT, logKeyE, plc, 5);
+                        return;
+                    }
+
+                    //outputMessage = $"[{e.Content}]SET_GoodsCode=[{plc_code}]{plc_s.Add_GoodsCode + plc_s.Add_GoodsCodeNum}";
+                    //Logger.Trace(outputMessage, logKeyT, logger_t);
+                    //FormLogShow?.ShowLog(outputMessage);
+                    plc.Write<int>(plc_s.Add_GoodsCode, plc_s.Add_GoodsCodeNum, (plc_code.ToInt32()));
+                    outputMessage = $"[{e.Content}]END_GoodsCode=[{plc_code}]{plc_s.Add_GoodsCode + plc_s.Add_GoodsCodeNum}";
+                    Logger.Trace(outputMessage, logKeyT, logger_t);
+                    FormLogShow?.ShowLog(outputMessage);
+
+                    if (p_id != plc_s.P_ID + "")
+                    {
+                        string result = SmartDeviceProxy.Instance.Invoke<string>(
+                            p => p.AddWorkPieceByStatus3(_mes_s.AccountCode,
+                            plc_s.WS_USER, null, plc_s.P_ID, barcode, plc_s.WS_NAME));
+
+                        outputMessage = $"[{e.Content}]MES_Result=[{result}]";
+                        Logger.Trace(outputMessage, logKeyT, logger_t);
+                        FormLogShow?.ShowLog(outputMessage);
+
+                        // 返回状态(成功、失败)
+                        if (result != "OK")
+                        {
+                            int plc_flag = 3;
+                            if (result == "EE")
+                            {
+                                plc_flag = 4;
+                                outputMessage = $"[{EPTS_CODE}]result=[{result}]MES服务端异常(详情参见MES端日志)";
+                            }
+                            else if (result == "EU-01")
+                            {
+                                outputMessage = $"[{EPTS_CODE}]result=[{result}]无效的帐套或工号(详情参见MES端日志)";
+                            }
+                            else
+                            {
+                                outputMessage = $"[{EPTS_CODE}]result=[{result}]其他错误(详情参见MES端日志)";
+                            }
+                            Logger.Error(null, outputMessage, logKeyT, logger_t);
+                            Logger.Error(null, outputMessage, logKeyE, logger_e);
+                            FormLogShow?.ShowLog(outputMessage);
+
+                            SendFlag(plc_s, e, logKeyT, logKeyE, plc, plc_flag);
+                            return;
+                        }
+                    }
+
+                    SendFlag(plc_s, e, logKeyT, logKeyE, plc, 1);
+                }
+                catch (Exception ex)
+                {
+                    FormLogShow?.ShowLog($"[{e.Content}]ERROR={ex.Message}");
+                    if (plc_s != null)
+                    {
+                        Logger.Error(ex, $"[{e.Content}]ERROR", logKeyT, logger_t);
+                        Logger.Error(ex, $"[{e.Content}]ERROR", logKeyE, logger_e);
+                        // 1.条码格式错误,2.条码不存在,3.产品型号没有设置标识码,4.MES系统异常
+                        SendFlag(plc_s, e, logKeyT, logKeyE, plc, 4);
+                    }
+                    else
+                    {
+                        Logger.Error(ex, $"[{e.Content}]ERROR-NOFLAG", logKeyT, logger_t);
+                        Logger.Error(ex, $"[{e.Content}]ERROR-NOFLAG", logKeyE, logger_e);
+                    }
+                }
+                finally
+                {
+                    LoggerT?.EndTracking();
+
+                    plc?.Disconnect();
+                    plc?.Close();
+                    //e.ReturnMessage("0000");
+                }
+            }
+        }
+
+        private void SendFlag(PLC_S_GC_DM1 plc_s, ReceiveSession e, string loggerNameT,
+            string loggerNameE, SocketClient<MelsecA1EAsciiModel> plc, int errorcode)
+        {
+            try
+            {
+                //using (SocketClient<SiemensS7_1200Model> plc = new SocketClient<SiemensS7_1200Model>())
+                {
+                    //0:复位 1:成功 2:条码格式错误或不存在 3:产品不可到达 4:MES系统异常 5:产品型号识别码未设置
+                    string outputMessage = $"[{e.Content}]SET_F_CODE=[{errorcode}]{plc_s.Add_FlagCode}{plc_s.Add_FlagCodeNum}[1:成功 2:条码格式错误或不存在 3:产品不可到达 4:MES系统异常 5:产品型号识别码未设置]";
+                    Logger.Trace(outputMessage, loggerNameT, logger_t);
+                    FormLogShow?.ShowLog(outputMessage);
+                    PLCResult result = plc?.Write<int>(plc_s.Add_FlagCode, plc_s.Add_FlagCodeNum, errorcode);
+                    outputMessage = $"[{e.Content}]END_F_CODE=[{result}]";
+                    Logger.Trace(outputMessage, loggerNameT, logger_t);
+                    FormLogShow?.ShowLog(outputMessage);
+                }
+            }
+            catch (Exception ex)
+            {
+                Logger.Error(ex, $"[{e.Content}]ERROR-SendFlag", loggerNameT, logger_t);
+                Logger.Error(ex, $"[{e.Content}]ERROR-SendFlag", loggerNameE, logger_e);
+                FormLogShow?.ShowLog($"[{e.Content}]ERROR-SendFlag={ex.Message}");
+            }
+        }
+
+        private DataRow GetGoodsCode(string barcode, ReceiveSession e, string loggerName, PLC_S_GC_DM1 plc_s)
+        {
+            IDataAccess dataAccess = null;
+            try
+            {
+                dataAccess = PLC_S_DataAccess.GetDataAccess(e);
+
+                string sql = "select t.usercode,t.procedureid,t.workstationname from tp_mst_workstation t where t.workstationid=:ws_id";
+                DataTable dataTable = dataAccess.ExecuteDatatable(sql, new CDAParameter(":ws_id", plc_s.WS_ID));
+                if (dataTable.HasData() && dataTable.Rows.Count > 0)
+                {
+                    plc_s.WS_USER = dataTable.Rows[0]["usercode"] + "";
+                }
+
+                string sqlString = "select gdd.goodscode \n" +
+                ",(select t.PLC_CODE from T_PLC_SET_2201DM t where t.WS_ID = :WS_ID and t.LINE_NO = :LINE_NO and t.GOODSID=gdd.GOODSID) plc_code\n" +
+                ",(select p.flowprocedureid from tp_pm_inproduction p where p.barcode=:barcode) p_id\n" +
+                "  from tp_pm_groutingdailydetail gdd\n" +
+                //" inner join tp_mst_goods g\n" +
+                //"    on g.goodsid = gdd.goodsid\n" +
+                " where gdd.barcode = :barcode";
+                CDAParameter[] ps = new CDAParameter[]
+                {
+                    new CDAParameter(":barcode", barcode),
+                    new CDAParameter(":WS_ID", plc_s.WS_ID),
+                    new CDAParameter(":LINE_NO", plc_s.LINE_NO),
+                };
+                dataTable = dataAccess.ExecuteDatatable(sqlString, ps);
+                if (dataTable.HasData() && dataTable.Rows.Count > 0)
+                {
+                    return dataTable.Rows[0];
+                }
+                return null;
+            }
+            catch (Exception ex)
+            {
+                Logger.Error(ex, $"[{e.Content}]ERROR-GetGoodsCode", loggerName, logger_e);
+                FormLogShow?.ShowLog($"[{e.Content}]ERROR-GetGoodsCode={ex.Message}");
+                return null;
+            }
+            finally
+            {
+                dataAccess?.Close();
+            }
+        }
+
+        private PLC_S_GC_DM1 GetPLC_S_DM(string flag, ReceiveSession e, string loggerName)
+        {
+            try
+            {
+                flag = M_NAME + flag;
+                if (PLC_FLAGS.ContainsKey(flag))
+                {
+                    return PLC_FLAGS[flag];
+                }
+                else
+                {
+                    PLC_S_GC_DM1 plc_s = new PLC_S_GC_DM1();
+                    INIHelper ini = INIHelper.Create($@"PLC_S_INI\PLC_S_{M_NAME}.ini");
+
+                    plc_s.IP = ini.Read(flag, "IP");
+                    plc_s.Port = ini.Read(flag, "Port").ToInt32();
+                    plc_s.LINE_NO = ini.Read(flag, "LINE_NO").ToInt32();
+                    plc_s.WS_ID = ini.Read(flag, "WS_ID").ToInt32();
+
+                    plc_s.WS_NAME = ini.Read(flag, "WS_NAME");
+                    plc_s.WS_USER = ini.Read(flag, "WS_USER");
+                    plc_s.P_ID = ini.Read(flag, "P_ID").ToInt32();
+
+                    plc_s.Add_GoodsCode = ini.Read(flag, "Add_GoodsCode")[0];
+                    plc_s.Add_FlagCode = ini.Read(flag, "Add_FlagCode")[0];
+                    plc_s.Add_GoodsCodeNum = ini.Read(flag, "Add_GoodsCodeNum").ToInt32();
+                    plc_s.Add_FlagCodeNum = ini.Read(flag, "Add_FlagCodeNum").ToInt32();
+
+                    PLC_FLAGS.Add(flag, plc_s);
+                    return plc_s;
+                }
+            }
+            catch (Exception ex)
+            {
+                Logger.Error(ex, $"[{e.Content}]ERROR-GetPLC_S_DM", loggerName, logger_e);
+                FormLogShow?.ShowLog($"[{e.Content}]ERROR-GetPLC_S_DM={ex.Message}");
+                return null;
+            }
+        }
+    }
+}

+ 456 - 0
HG5020.1-2/PLC_S/ServerModel/GoodsCode_DM2205.cs

@@ -0,0 +1,456 @@
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+
+using Curtain.DataAccess;
+using Curtain.Extension.ExObjectConvert;
+using Curtain.Extension.ExSystemData;
+using Curtain.Framework.Json;
+using Curtain.Helpers;
+using Curtain.Log;
+using Curtain.Net.Sockets.PLC;
+using Curtain.Net.Sockets.PLC.Model;
+using Curtain.Net.Sockets.PLC.Model.Melsec;
+
+using PLC_S_1.Proxy;
+
+namespace PLC_S_1.ServerModel
+{
+    /// <summary>
+    /// 返回产品型号,计件(2-0改洗) 0:复位 1:成功 2:条码格式错误或不存在 3:产品不可到达 4:MES系统异常
+    /// </summary>
+    public class GoodsCode_DM2205 : SocketServer<SimpleSocketServerModel>, IShowFormLog, IWindowsServer
+    {
+        public Dictionary<string, PLC_S_GC_DM1> PLC_FLAGS = new Dictionary<string, PLC_S_GC_DM1>();
+        public const string M_NAME = "GC_DM1_";
+        private MES_S _mes_s = null;
+
+        private readonly Logger logger = Logger.CreateLogger(M_NAME);
+        private readonly LogInfo logger_t = new LogInfo();
+        private readonly LogInfo logger_e = new LogInfo();
+
+        //private bool 
+
+        public int Interval
+        {
+            get;
+            set;
+        }
+        public string EPTS_CODE
+        {
+            get;
+            set;
+        }
+        public GoodsCode_DM2205()
+        {
+            logger.FileExistDays = 30;
+            logger.FilePrefix = "";
+            logger.FileSuffix = M_NAME;
+            logger.LevelOneFile = true;
+            logger.FileNameWithoutDate = true;
+
+            logger_t.SubFolderFormat = "<name>";
+            logger_t.FileExistDays = 30;
+            logger_t.LevelOneFile = true;
+
+            logger_e.FileExistDays = 10;
+
+            this.Model.FormatType = CommandFormatType.StartStopChar;
+
+            this.ServerStarting += ServerSocket_ServerStarting;
+            this.ServerStarted += ServerSocket_ServerStarted;
+            this.ServerStoping += ServerSocket_ServerStoping;
+            this.ServerStoped += ServerSocket_ServerStoped;
+
+            this.ServerMessage += ServerSocket_ServerMessage;
+            this.Received += ServerSocket_Received;
+
+            _mes_s = MES_S.Get();
+        }
+
+        #region Server
+        public IFormLogShow FormLogShow
+        {
+            get;
+            set;
+        }
+
+        private void ServerSocket_ServerStarting(object sender, CancelEventArgs e)
+        {
+            try
+            {
+                //
+                logger.OutputTrace($"{M_NAME}_ServerStarting");
+            }
+            catch { }
+        }
+        private void ServerSocket_ServerStarted(object sender, EventArgs e)
+        {
+            try
+            {
+                //
+                logger.OutputTrace($"{M_NAME}_ServerStarted");
+            }
+            catch { }
+        }
+        private void ServerSocket_ServerStoping(object sender, CancelEventArgs e)
+        {
+            try
+            {
+                
+                logger.OutputTrace($"{M_NAME}_ServerStoping");
+            }
+            catch { }
+        }
+        private void ServerSocket_ServerStoped(object sender, EventArgs e)
+        {
+            try
+            {
+                
+                logger.OutputTrace($"{M_NAME}_ServerStoped");
+            }
+            catch { }
+        }
+        private void ServerSocket_ServerMessage(object sender, ServerMessageEventArgs e)
+        {
+            try
+            {
+                
+                string message = e.ToString();
+                string cip = e?.Client?.IP;
+                if (e.Type == ServerMessageType.Debug)
+                {
+                    Logger.Debug(message, $"{M_NAME}-T[{cip}]", logger_t);
+                }
+                if (e.Type == ServerMessageType.Error)
+                {
+                    Logger.Error(e.Exception, message, $"{M_NAME}-E[{cip}]", logger_e);
+                }
+                if (e.Type == ServerMessageType.Trace)
+                {
+                    Logger.Trace(message, $"{M_NAME}-T[{cip}]", logger_t);
+                }
+                if (e.Type == ServerMessageType.Warning)
+                {
+                    Logger.Warn(message, $"{M_NAME}-E[{cip}]", logger_e);
+                }
+                FormLogShow?.ShowLog("ServerMessage=" + message);
+            }
+            catch { }
+        }
+        #endregion
+
+        /// <summary>
+        /// 返回产品型号
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ServerSocket_Received(object sender, ReceiveSession e)
+        {
+            PLC_S_GC_DM1 plc_s = null;
+            string cIP = e?.Client?.IP;
+            string logKeyT = $"{M_NAME}-T[{cIP}]";
+            string logKeyE = $"{M_NAME}-E[{cIP}]";
+
+            //
+
+            SocketClient<MelsecA1EAsciiModel> plc = null;
+            Logger LoggerT = Logger.CreateLogger(logKeyT, logger_t);
+            lock (LoggerT)
+            {
+                try
+                {
+                    LoggerT.BeginTracking();
+
+                    string outputMessage = e.ToString();
+                    Logger.Trace(outputMessage, logKeyT, logger_t);
+                    FormLogShow?.ShowLog(outputMessage);
+
+                    if (string.IsNullOrWhiteSpace(e.Content))
+                    {
+                        outputMessage = "接收数据为空";
+                        Logger.Warn(outputMessage, logKeyT, logger_t);
+                        Logger.Warn(outputMessage, logKeyE, logger_e);
+                        FormLogShow?.ShowLog(outputMessage);
+                        return;
+                    }
+
+                    outputMessage = e.Content;
+                    Logger.Trace(outputMessage, logKeyT, logger_t);
+                    FormLogShow?.ShowLog(outputMessage);
+
+                    string[] c = e.Content.Split('#');
+                    string flag = null;
+                    if (c.Length > 0)
+                    {
+                        flag = c[0];
+                    }
+                    string barcode = null;
+                    if (c.Length > 1)
+                    {
+                        barcode = c[1];
+                    }
+
+                    if (string.IsNullOrWhiteSpace(flag))
+                    {
+                        outputMessage = $"[{e.Content}]接收设备代码为空";
+                        Logger.Warn(outputMessage, logKeyT, logger_t);
+                        Logger.Warn(outputMessage, logKeyE, logger_e);
+                        FormLogShow?.ShowLog(outputMessage);
+                        return;
+                    }
+
+                    plc_s = GetPLC_S_DM(flag, e, logKeyE);
+                    if (plc_s == null)
+                    {
+                        outputMessage = $"[{e.Content}]设备代码[{flag}]未找到ini配置或有错误";
+                        Logger.Error(null, outputMessage, logKeyT, logger_t);
+                        Logger.Error(null, outputMessage, logKeyE, logger_e);
+                        FormLogShow?.ShowLog(outputMessage);
+                        return;
+                    }
+
+                    outputMessage = $"[{e.Content}]PLC_Connect={JsonHelper.FromObject(plc_s)}";
+                    Logger.Trace(outputMessage, logKeyT, logger_t);
+                    FormLogShow?.ShowLog(outputMessage);
+
+                    plc = new SocketClient<MelsecA1EAsciiModel>();
+                    plc.Connect(plc_s.IP, plc_s.Port);
+                    //outputMessage = $"[{e.Content}]PLC_Connect=[{plc_s.IP}:{plc_s.Port}]";
+                    //Logger.Trace(outputMessage, logKeyT, logger_t);
+                    //FormLogShow?.ShowLog(outputMessage);
+
+                    plc.Write<int>(plc_s.Add_FlagCode, plc_s.Add_FlagCodeNum, 0);
+
+                    if (string.IsNullOrWhiteSpace(barcode) ||
+                        barcode == "0" ||
+                        barcode.Length != 11 ||
+                        barcode.StartsWith("0"))
+                    {
+                        outputMessage = $"[{e.Content}]接收条码格式错误";
+                        Logger.Warn(outputMessage, logKeyT, logger_t);
+                        Logger.Warn(outputMessage, logKeyE, logger_e);
+                        FormLogShow?.ShowLog(outputMessage);
+                        // 0:复位 1:成功 2:条码格式错误或不存在 3:产品不可到达 4:MES系统异常 5:产品型号识别码未设置
+                        SendFlag(plc_s, e, logKeyT, logKeyE, plc, 2);
+                        return;
+                    }
+
+                    DataRow codeRow = GetGoodsCode(barcode, e, logKeyE, plc_s);
+                    if (codeRow == null)
+                    {
+                        outputMessage = $"[{e.Content}]此条码[{barcode}]不存在";
+                        Logger.Warn(outputMessage, logKeyT, logger_t);
+                        Logger.Warn(outputMessage, logKeyE, logger_e);
+                        FormLogShow?.ShowLog(outputMessage);
+                        // 0:复位 1:成功 2:条码格式错误或不存在 3:产品不可到达 4:MES系统异常 5:产品型号识别码未设置
+                        SendFlag(plc_s, e, logKeyT, logKeyE, plc, 2);
+                        return;
+                    }
+
+                    string code = codeRow["goodscode"].ToString();
+                    //string plc_code = codeRow["plc_code"].ToString();
+                    string p_id = codeRow["p_id"].ToString();
+
+                    //outputMessage = $"[{e.Content}]产品型号={code}[{plc_code}]";
+                    //Logger.Trace(outputMessage, logKeyT, logger_t);
+                    //FormLogShow?.ShowLog(outputMessage);
+
+                    //if (string.IsNullOrWhiteSpace(plc_code))
+                    //{
+                    //    outputMessage = $"[{e.Content}]此条码[{barcode}]未设置型号代码";
+                    //    Logger.Error(null, outputMessage, logKeyT, logger_t);
+                    //    Logger.Error(null, outputMessage, logKeyE, logger_e);
+                    //    FormLogShow?.ShowLog(outputMessage);
+                    //    // 0:复位 1:成功 2:条码格式错误或不存在 3:产品不可到达 4:MES系统异常 5:产品型号识别码未设置
+                    //    SendError(plc_s, e, logKeyT, logKeyE, plc, 5);
+                    //    return;
+                    //}
+
+                    ////outputMessage = $"[{e.Content}]SET_GoodsCode=[{plc_code}]{plc_s.Add_GoodsCode + plc_s.Add_GoodsCodeNum}";
+                    ////Logger.Trace(outputMessage, logKeyT, logger_t);
+                    ////FormLogShow?.ShowLog(outputMessage);
+                    //plc.Write<int>(plc_s.Add_GoodsCode, plc_s.Add_GoodsCodeNum, (plc_code.ToInt32()));
+                    //outputMessage = $"[{e.Content}]END_GoodsCode=[{plc_code}]{plc_s.Add_GoodsCode + plc_s.Add_GoodsCodeNum}";
+                    //Logger.Trace(outputMessage, logKeyT, logger_t);
+                    //FormLogShow?.ShowLog(outputMessage);
+
+                    if (p_id != plc_s.P_ID + "")
+                    {
+                        string result = SmartDeviceProxy.Instance.Invoke<string>(
+                            p => p.AddWorkPieceByStatus3(_mes_s.AccountCode,
+                            plc_s.WS_USER, null, plc_s.P_ID, barcode, plc_s.WS_NAME));
+
+                        outputMessage = $"[{e.Content}]MES_Result=[{result}]";
+                        Logger.Trace(outputMessage, logKeyT, logger_t);
+                        FormLogShow?.ShowLog(outputMessage);
+
+                        // 返回状态(成功、失败)
+                        if (result != "OK")
+                        {
+                            int plc_flag = 3;
+                            if (result == "EE")
+                            {
+                                plc_flag = 4;
+                                outputMessage = $"[{EPTS_CODE}]result=[{result}]MES服务端异常(详情参见MES端日志)";
+                            }
+                            else if (result == "EU-01")
+                            {
+                                outputMessage = $"[{EPTS_CODE}]result=[{result}]无效的帐套或工号(详情参见MES端日志)";
+                            }
+                            else
+                            {
+                                outputMessage = $"[{EPTS_CODE}]result=[{result}]其他错误(详情参见MES端日志)";
+                            }
+                            Logger.Error(null, outputMessage, logKeyT, logger_t);
+                            Logger.Error(null, outputMessage, logKeyE, logger_e);
+                            FormLogShow?.ShowLog(outputMessage);
+
+                            SendFlag(plc_s, e, logKeyT, logKeyE, plc, plc_flag);
+                            return;
+                        }
+                    }
+
+                    SendFlag(plc_s, e, logKeyT, logKeyE, plc, 1);
+                }
+                catch (Exception ex)
+                {
+                    FormLogShow?.ShowLog($"[{e.Content}]ERROR={ex.Message}");
+                    if (plc_s != null)
+                    {
+                        Logger.Error(ex, $"[{e.Content}]ERROR", logKeyT, logger_t);
+                        Logger.Error(ex, $"[{e.Content}]ERROR", logKeyE, logger_e);
+                        // 1.条码格式错误,2.条码不存在,3.产品型号没有设置标识码,4.MES系统异常
+                        SendFlag(plc_s, e, logKeyT, logKeyE, plc, 4);
+                    }
+                    else
+                    {
+                        Logger.Error(ex, $"[{e.Content}]ERROR-NOFLAG", logKeyT, logger_t);
+                        Logger.Error(ex, $"[{e.Content}]ERROR-NOFLAG", logKeyE, logger_e);
+                    }
+                }
+                finally
+                {
+                    LoggerT?.EndTracking();
+
+                    plc?.Disconnect();
+                    plc?.Close();
+                    //e.ReturnMessage("0000");
+                }
+            }
+        }
+
+        private void SendFlag(PLC_S_GC_DM1 plc_s, ReceiveSession e, string loggerNameT,
+            string loggerNameE, SocketClient<MelsecA1EAsciiModel> plc, int errorcode)
+        {
+            try
+            {
+                //using (SocketClient<SiemensS7_1200Model> plc = new SocketClient<SiemensS7_1200Model>())
+                {
+                    //0:复位 1:成功 2:条码格式错误或不存在 3:产品不可到达 4:MES系统异常 5:产品型号识别码未设置
+                    string outputMessage = $"[{e.Content}]SET_F_CODE=[{errorcode}]{plc_s.Add_FlagCode + plc_s.Add_FlagCodeNum}[1:成功 2:条码格式错误或不存在 3:产品不可到达 4:MES系统异常]";
+                    Logger.Trace(outputMessage, loggerNameT, logger_t);
+                    FormLogShow?.ShowLog(outputMessage);
+                    PLCResult result = plc?.Write<int>(plc_s.Add_FlagCode, plc_s.Add_FlagCodeNum, errorcode);
+                    outputMessage = $"[{e.Content}]END_F_CODE=[{result}]";
+                    Logger.Trace(outputMessage, loggerNameT, logger_t);
+                    FormLogShow?.ShowLog(outputMessage);
+                }
+            }
+            catch (Exception ex)
+            {
+                Logger.Error(ex, $"[{e.Content}]ERROR-SendFlag", loggerNameT, logger_t);
+                Logger.Error(ex, $"[{e.Content}]ERROR-SendFlag", loggerNameE, logger_e);
+                FormLogShow?.ShowLog($"[{e.Content}]ERROR-SendFlag={ex.Message}");
+            }
+        }
+
+        private DataRow GetGoodsCode(string barcode, ReceiveSession e, string loggerName, PLC_S_GC_DM1 plc_s)
+        {
+            IDataAccess dataAccess = null;
+            try
+            {
+                dataAccess = PLC_S_DataAccess.GetDataAccess(e);
+
+                string sql = "select t.usercode,t.procedureid,t.workstationname from tp_mst_workstation t where t.workstationid=:ws_id";
+                DataTable dataTable = dataAccess.ExecuteDatatable(sql, new CDAParameter(":ws_id", plc_s.WS_ID));
+                if (dataTable.HasData() && dataTable.Rows.Count > 0)
+                {
+                    plc_s.WS_USER = dataTable.Rows[0]["usercode"] + "";
+                }
+
+                string sqlString = "select gdd.goodscode \n" +
+                //",(select t.PLC_CODE from T_PLC_SET_2201DM t where t.WS_ID = :WS_ID and t.LINE_NO = :LINE_NO and t.GOODSID=gdd.GOODSID) plc_code\n" +
+                ",(select p.flowprocedureid from tp_pm_inproduction p where p.barcode=:barcode) p_id\n" +
+                "  from tp_pm_groutingdailydetail gdd\n" +
+                //" inner join tp_mst_goods g\n" +
+                //"    on g.goodsid = gdd.goodsid\n" +
+                " where gdd.barcode = :barcode";
+                CDAParameter[] ps = new CDAParameter[]
+                {
+                    new CDAParameter(":barcode", barcode),
+                    new CDAParameter(":WS_ID", plc_s.WS_ID),
+                    new CDAParameter(":LINE_NO", plc_s.LINE_NO),
+                };
+                dataTable = dataAccess.ExecuteDatatable(sqlString, ps);
+                if (dataTable.HasData() && dataTable.Rows.Count > 0)
+                {
+                    return dataTable.Rows[0];
+                }
+                return null;
+            }
+            catch (Exception ex)
+            {
+                Logger.Error(ex, $"[{e.Content}]ERROR-GetGoodsCode", loggerName, logger_e);
+                FormLogShow?.ShowLog($"[{e.Content}]ERROR-GetGoodsCode={ex.Message}");
+                return null;
+            }
+            finally
+            {
+                dataAccess?.Close();
+            }
+        }
+
+        private PLC_S_GC_DM1 GetPLC_S_DM(string flag, ReceiveSession e, string loggerName)
+        {
+            try
+            {
+                flag = M_NAME + flag;
+                if (PLC_FLAGS.ContainsKey(flag))
+                {
+                    return PLC_FLAGS[flag];
+                }
+                else
+                {
+                    PLC_S_GC_DM1 plc_s = new PLC_S_GC_DM1();
+                    INIHelper ini = INIHelper.Create($@"PLC_S_INI\PLC_S_{M_NAME}.ini");
+
+                    plc_s.IP = ini.Read(flag, "IP");
+                    plc_s.Port = ini.Read(flag, "Port").ToInt32();
+                    plc_s.LINE_NO = ini.Read(flag, "LINE_NO").ToInt32();
+                    plc_s.WS_ID = ini.Read(flag, "WS_ID").ToInt32();
+
+                    plc_s.WS_NAME = ini.Read(flag, "WS_NAME");
+                    plc_s.WS_USER = ini.Read(flag, "WS_USER");
+                    plc_s.P_ID = ini.Read(flag, "P_ID").ToInt32();
+
+                    plc_s.Add_GoodsCode = ini.Read(flag, "Add_GoodsCode")[0];
+                    plc_s.Add_FlagCode = ini.Read(flag, "Add_FlagCode")[0];
+                    plc_s.Add_GoodsCodeNum = ini.Read(flag, "Add_GoodsCodeNum").ToInt32();
+                    plc_s.Add_FlagCodeNum = ini.Read(flag, "Add_FlagCodeNum").ToInt32();
+
+                    PLC_FLAGS.Add(flag, plc_s);
+                    return plc_s;
+                }
+            }
+            catch (Exception ex)
+            {
+                Logger.Error(ex, $"[{e.Content}]ERROR-GetPLC_S_DM", loggerName, logger_e);
+                FormLogShow?.ShowLog($"[{e.Content}]ERROR-GetPLC_S_DM={ex.Message}");
+                return null;
+            }
+        }
+    }
+}

+ 7 - 7
HG5020.1-2/PLC_S/ServerModel/GoodsCode_XW.cs

@@ -29,7 +29,7 @@ namespace PLC_S_1.ServerModel
         private readonly LogInfo logger_t = new LogInfo();
         private readonly LogInfo logger_e = new LogInfo();
 
-        private bool _S_STOP = false;
+        //private bool 
 
         public int Interval
         {
@@ -77,7 +77,7 @@ namespace PLC_S_1.ServerModel
         {
             try
             {
-                _S_STOP = false;
+                
                 logger.OutputTrace($"{M_NAME}_ServerStarting");
             }
             catch { }
@@ -86,7 +86,7 @@ namespace PLC_S_1.ServerModel
         {
             try
             {
-                _S_STOP = false;
+                
                 logger.OutputTrace($"{M_NAME}_ServerStarted");
             }
             catch { }
@@ -95,7 +95,7 @@ namespace PLC_S_1.ServerModel
         {
             try
             {
-                _S_STOP = false;
+                
                 logger.OutputTrace($"{M_NAME}_ServerStoping");
             }
             catch { }
@@ -104,7 +104,7 @@ namespace PLC_S_1.ServerModel
         {
             try
             {
-                _S_STOP = false;
+                
                 logger.OutputTrace($"{M_NAME}_ServerStoped");
             }
             catch { }
@@ -113,7 +113,7 @@ namespace PLC_S_1.ServerModel
         {
             try
             {
-                _S_STOP = false;
+                
                 string message = e.ToString();
                 string cip = e?.Client?.IP;
                 if (e.Type == ServerMessageType.Debug)
@@ -150,7 +150,7 @@ namespace PLC_S_1.ServerModel
             string logKeyT = $"{M_NAME}-T[{cIP}]";
             string logKeyE = $"{M_NAME}-E[{cIP}]";
 
-            _S_STOP = false;
+            
 
             SocketClient<MelsecA1EAsciiModel> plc = null;
             Logger LoggerT = null;

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 823 - 798
HG5020.1-2/PLC_WF/F_Main.Designer.cs


+ 207 - 2
HG5020.1-2/PLC_WF/F_Main.cs

@@ -1,8 +1,11 @@
 using System;
+using System.Collections.Generic;
 using System.Configuration.Install;
 using System.Data;
+using System.Diagnostics;
 using System.Drawing;
 using System.ServiceProcess;
+using System.Text.RegularExpressions;
 using System.Windows.Forms;
 
 using Curtain.DataAccess;
@@ -41,6 +44,10 @@ namespace PLC_WF_1
             //dataTable.Rows.Add("EPTS_HPGP", "[HPGP]高压注浆", "3#5F@高压成型");
             //dataTable.Rows.Add("GC", "[GC]产品型号【放水件、包盖子】", "3#1F@放水件、包盖子");
 
+            dataTable.Rows.Add("GC_DM2201", "[GC_DM2201]打磨型号【2-7改洗交接】", "2#打磨前");
+            dataTable.Rows.Add("GC_DM2205", "[GC_DM2205]打磨完成【2-0改洗】", "2#打磨完成");
+
+
             // 小件-成检-物料架 5101
             dataTable.Rows.Add("GC_XW", "[GC_XW]产品型号【小件-成检-物料架】", "1#小件@成检-物料架");
 
@@ -131,6 +138,12 @@ namespace PLC_WF_1
 
                 SetESControl();
                 txtStatus.Text = (PLC_Server.ServerSocket?.Started ?? false ? "启动" : "停止");
+                if (_fff != null)
+                {
+                    _fff.Text = $"[{PLC_Server.PLC_S_S.DisplayName}]";
+                    (PLC_Server.ServerSocket as IShowFormLog).FormLogShow = _fff;
+                    _fff.ShowFormLog = (PLC_Server.ServerSocket as IShowFormLog);
+                }
             }
             catch (Exception ex)
             {
@@ -152,6 +165,7 @@ namespace PLC_WF_1
             }
         }
 
+        private F_Log _fff = null;
         private void btnLog_Click(object sender, EventArgs e)
         {
             try
@@ -160,9 +174,12 @@ namespace PLC_WF_1
                 {
                     if (showFormLog == null)
                     {
+                        _fff = new F_Log();
+                        _fff.Show();
                         return;
                     }
                     F_Log f = showFormLog.FormLogShow as F_Log;
+                    _fff = f;
                     if (f == null)
                     {
                         f = new F_Log();
@@ -172,6 +189,11 @@ namespace PLC_WF_1
                     }
                     f.Show();
                 }
+                else
+                {
+                    _fff = new F_Log();
+                    _fff.Show();
+                }
             }
             catch (Exception ex)
             {
@@ -376,7 +398,7 @@ namespace PLC_WF_1
         {
             if (!_hasClose)
             {
-                DialogResult dr = MessageBox.Show("是否退出?", this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
+                DialogResult dr = MessageBox.Show("是否退出?", this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button3);
                 if (dr == DialogResult.Cancel)
                 {
                     e.Cancel = true;
@@ -1132,6 +1154,10 @@ namespace PLC_WF_1
                         F_PLC_M<SiemensS7_1200Model> fs = new F_PLC_M<SiemensS7_1200Model>();
                         fs.Show();
                         break;
+                    case "SiemensS7_200Smart":
+                        F_PLC_M<SiemensS7_200SmartModel> fss = new F_PLC_M<SiemensS7_200SmartModel>();
+                        fss.Show();
+                        break;
                     case "SimpleSocketClientModel":
                         F_PLC_M<SimpleSocketClientModel> fs1 = new F_PLC_M<SimpleSocketClientModel>();
                         fs1.Show();
@@ -1145,5 +1171,184 @@ namespace PLC_WF_1
                 MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
-    }
+
+        //取得服务的启动类型的当前状态,返回启动类型的状态値
+
+        //2:自动,3:手动,4:禁用 ......
+
+        //sServiceName服务名称
+
+        //sState输出相关的状态代码,失败则为错误消息
+
+        public int GetWindowsServiceStartType(string sServiceName )
+        {
+            string sState = "";
+
+            try
+            {
+                System.Diagnostics.ProcessStartInfo objProcessInf = new System.Diagnostics.ProcessStartInfo();
+
+                objProcessInf.FileName = "cmd.exe";
+
+                objProcessInf.UseShellExecute = false;
+
+                objProcessInf.RedirectStandardError = true;
+                objProcessInf.RedirectStandardInput = true;
+                objProcessInf.RedirectStandardOutput = true;
+
+                objProcessInf.CreateNoWindow = true;
+
+                objProcessInf.Arguments = "/c sc qc " + sServiceName;
+
+                System.Diagnostics.Process objProcess = System.Diagnostics.Process.Start(objProcessInf);
+
+                String sStateValue = objProcess.StandardOutput.ReadToEnd();
+
+                if (sStateValue.IndexOf("AUTO_START") > 0)
+                {
+                    sState = "AUTO_START";
+                    return 1;
+                }
+
+                if (sStateValue.IndexOf("DEMAND_START") > 0)
+                {
+                    sState = "DEMAND_START";
+                    return 2;
+                }
+
+                if (sStateValue.IndexOf("DISABLED") > 0)
+                {
+                    sState = "DISABLED";
+                    return 3;
+                }
+
+                return 0;
+
+            }
+            catch (Exception e)
+            {
+                sState = e.Message;
+                return -1;
+            }
+        }
+        void KillProcess(string MainWindowTitle)
+        {
+            //productName = productName.ToLower();
+            Process[] allProcess = Process.GetProcesses();
+            foreach (Process p in allProcess)
+            {
+                if(p.MainWindowTitle.StartsWith(MainWindowTitle, true, null))
+                //if (p.ProcessName.ToLower().StartsWith(processname))
+                {
+                    try
+                    {
+                        for (int i = 0; i < p.Threads.Count; i++)
+                        {
+                            p.Threads[i].Dispose();
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        //Logger.Error(ex);
+                    }
+                    try
+                    {
+                        p.Kill();
+                    }
+                    catch (Exception ex)
+                    {
+                        //Logger.Error(ex);
+                    }
+                    //break;
+                }
+            }
+        }
+
+        private void btnStopAll_Click(object sender, EventArgs e)
+        {
+            //KillProcess("Finance");
+            //return;
+            try
+            {
+                List<string> mms = new List<string>();
+                // 获取系统服务列表
+                ServiceController[] services = ServiceController.GetServices();
+                // 遍历系统服务列表
+                foreach (ServiceController service in services)
+                {
+                    // 服务名称
+                    string name = service.ServiceName;
+                    try
+                    {
+                        if (name.StartsWith("DK.PLC["))
+                        {
+                            if (service.Status == ServiceControllerStatus.Running)
+                            {
+                                //int ss = GetWindowsServiceStartType(name);
+                                //if (ss == 1)
+                                //{
+                                //    service.Start();
+                                //}
+                                service.Stop();
+                            }
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        mms.Add(name + "[" + ex.Message + "]");
+                    }
+                }
+                if (mms.Count > 0)
+                {
+                    MessageBox.Show(string.Join("; ", mms), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
+            }
+        }
+
+        private void btnStartAll_Click(object sender, EventArgs e)
+        {
+            try
+            {
+                List<string> mms = new List<string>();
+                // 获取系统服务列表
+                ServiceController[] services = ServiceController.GetServices();
+                // 遍历系统服务列表
+                foreach (ServiceController service in services)
+                {
+                    // 服务名称
+                    string name = service.ServiceName;
+                    try
+                    {
+                        if (name.StartsWith("DK.PLC["))
+                        {
+                            if (service.Status == ServiceControllerStatus.Stopped)
+                            {
+                                int ss = GetWindowsServiceStartType(name);
+                                if (ss == 1)
+                                {
+                                    service.Start();
+                                }
+                            }
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        mms.Add(name + "[" + ex.Message + "]");
+                    }
+                }
+                if (mms.Count > 0)
+                {
+                    MessageBox.Show(string.Join("; ", mms), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
+            }
+        }
+	}
 }

+ 54 - 4
HG5020.1-2/PLC_WF/F_PLC_M.Designer.cs

@@ -29,7 +29,6 @@ namespace PLC_WF_1
         /// </summary>
         private void InitializeComponent()
         {
-            //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(F_PLC_M<TClientModel>));
             this.btnClear = new System.Windows.Forms.Button();
             this.btnDoOneWay = new System.Windows.Forms.Button();
             this.btnDo = new System.Windows.Forms.Button();
@@ -70,6 +69,10 @@ namespace PLC_WF_1
             this.btnW_short = new System.Windows.Forms.Button();
             this.btnW_byte = new System.Windows.Forms.Button();
             this.btnW_bool = new System.Windows.Forms.Button();
+            this.button1 = new System.Windows.Forms.Button();
+            this.button2 = new System.Windows.Forms.Button();
+            this.button3 = new System.Windows.Forms.Button();
+            this.button4 = new System.Windows.Forms.Button();
             this.grbRead.SuspendLayout();
             this.grbWrite.SuspendLayout();
             this.SuspendLayout();
@@ -113,7 +116,7 @@ namespace PLC_WF_1
             this.txtMessage.Multiline = true;
             this.txtMessage.Name = "txtMessage";
             this.txtMessage.ScrollBars = System.Windows.Forms.ScrollBars.Both;
-            this.txtMessage.Size = new System.Drawing.Size(444, 227);
+            this.txtMessage.Size = new System.Drawing.Size(444, 262);
             this.txtMessage.TabIndex = 10;
             // 
             // txtLength
@@ -482,12 +485,56 @@ namespace PLC_WF_1
             this.btnW_bool.UseVisualStyleBackColor = true;
             this.btnW_bool.Click += new System.EventHandler(this.btnW_bool_Click);
             // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(183, 278);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(60, 23);
+            this.button1.TabIndex = 13;
+            this.button1.Text = "str(UTF8)";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(18, 274);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(60, 23);
+            this.button2.TabIndex = 0;
+            this.button2.Text = "str(UTF8)";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // button3
+            // 
+            this.button3.Location = new System.Drawing.Point(84, 274);
+            this.button3.Name = "button3";
+            this.button3.Size = new System.Drawing.Size(81, 23);
+            this.button3.TabIndex = 0;
+            this.button3.Text = "str(Unicode)";
+            this.button3.UseVisualStyleBackColor = true;
+            this.button3.Click += new System.EventHandler(this.button3_Click);
+            // 
+            // button4
+            // 
+            this.button4.Location = new System.Drawing.Point(249, 278);
+            this.button4.Name = "button4";
+            this.button4.Size = new System.Drawing.Size(81, 23);
+            this.button4.TabIndex = 13;
+            this.button4.Text = "str(Unicode)";
+            this.button4.UseVisualStyleBackColor = true;
+            this.button4.Click += new System.EventHandler(this.button4_Click);
+            // 
             // F_PLC_M
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(798, 279);
+            this.ClientSize = new System.Drawing.Size(798, 314);
             this.Controls.Add(this.txtMessage);
+            this.Controls.Add(this.button3);
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.button4);
+            this.Controls.Add(this.button1);
             this.Controls.Add(this.grbWrite);
             this.Controls.Add(this.grbRead);
             this.Controls.Add(this.btnClear);
@@ -498,7 +545,6 @@ namespace PLC_WF_1
             this.Controls.Add(this.textBox1);
             this.Controls.Add(this.btnClose);
             this.Controls.Add(this.btnConn);
-            //this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.MaximizeBox = false;
             this.Name = "F_PLC_M";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
@@ -554,5 +600,9 @@ namespace PLC_WF_1
         private System.Windows.Forms.Button btnW_byte;
         private System.Windows.Forms.Button btnW_bool;
         private System.Windows.Forms.TextBox txtW_Len;
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.Button button2;
+        private System.Windows.Forms.Button button3;
+        private System.Windows.Forms.Button button4;
     }
 }

+ 115 - 46
HG5020.1-2/PLC_WF/F_PLC_M.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Text;
 using System.Windows.Forms;
 
 using Curtain.Framework.Json;
@@ -56,11 +57,11 @@ namespace PLC_WF_1
         #region R
         private void btnR_bool_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult<bool> rr = _client.Read<bool>(this.txtCode.Text, txtNumber.Text, Convert.ToInt32(txtLength.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -71,11 +72,11 @@ namespace PLC_WF_1
 
         private void btnR_byte_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult<byte> rr = _client.Read<byte>(this.txtCode.Text, txtNumber.Text, Convert.ToInt32(txtLength.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -86,11 +87,11 @@ namespace PLC_WF_1
 
         private void btnR_short_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult<short> rr = _client.Read<short>(this.txtCode.Text, txtNumber.Text, Convert.ToInt32(txtLength.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -101,11 +102,11 @@ namespace PLC_WF_1
 
         private void btnR_ushort_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult<ushort> rr = _client.Read<ushort>(this.txtCode.Text, txtNumber.Text, Convert.ToInt32(txtLength.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -116,11 +117,11 @@ namespace PLC_WF_1
 
         private void btnR_int_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult<int> rr = _client.Read<int>(this.txtCode.Text, txtNumber.Text, Convert.ToInt32(txtLength.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -131,11 +132,11 @@ namespace PLC_WF_1
 
         private void btnR_uint_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult<uint> rr = _client.Read<uint>(this.txtCode.Text, txtNumber.Text, Convert.ToInt32(txtLength.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -146,11 +147,11 @@ namespace PLC_WF_1
 
         private void btnR_long_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult<long> rr = _client.Read<long>(this.txtCode.Text, txtNumber.Text, Convert.ToInt32(txtLength.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -161,11 +162,11 @@ namespace PLC_WF_1
 
         private void btnR_ulong_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult<ulong> rr = _client.Read<ulong>(this.txtCode.Text, txtNumber.Text, Convert.ToInt32(txtLength.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -176,11 +177,11 @@ namespace PLC_WF_1
 
         private void btnR_float_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult<float> rr = _client.Read<float>(this.txtCode.Text, txtNumber.Text, Convert.ToInt32(txtLength.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -191,11 +192,11 @@ namespace PLC_WF_1
 
         private void btnR_double_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult<double> rr = _client.Read<double>(this.txtCode.Text, txtNumber.Text, Convert.ToInt32(txtLength.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -206,11 +207,11 @@ namespace PLC_WF_1
 
         private void btnR_string_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult<string> rr = _client.Read<string>(this.txtCode.Text, txtNumber.Text, Convert.ToInt32(txtLength.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -223,12 +224,12 @@ namespace PLC_WF_1
         #region W
         private void btnW_bool_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult rr = _client.Write<bool>(this.txtW_Code.Text, txtW_Num.Text,
                     ((string.IsNullOrWhiteSpace(txtW_Value.Text) || txtW_Value.Text == "0") ? false : true));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -239,11 +240,11 @@ namespace PLC_WF_1
 
         private void btnW_byte_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult rr = _client.Write<byte>(this.txtW_Code.Text, txtW_Num.Text, Convert.ToByte(txtW_Value.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -254,11 +255,11 @@ namespace PLC_WF_1
 
         private void btnW_short_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult rr = _client.Write<short>(this.txtW_Code.Text, txtW_Num.Text, Convert.ToInt16(txtW_Value.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -269,11 +270,11 @@ namespace PLC_WF_1
 
         private void btnW_ushort_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult rr = _client.Write<ushort>(this.txtW_Code.Text, txtW_Num.Text, Convert.ToUInt16(txtW_Value.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -284,11 +285,11 @@ namespace PLC_WF_1
 
         private void btnW_int_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult rr = _client.Write<int>(this.txtW_Code.Text, txtW_Num.Text, Convert.ToInt32(txtW_Value.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -299,11 +300,11 @@ namespace PLC_WF_1
 
         private void btnW_uint_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult rr = _client.Write<uint>(this.txtW_Code.Text, txtW_Num.Text, Convert.ToUInt32(txtW_Value.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -314,11 +315,11 @@ namespace PLC_WF_1
 
         private void btnW_long_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult rr = _client.Write<long>(this.txtW_Code.Text, txtW_Num.Text, Convert.ToInt64(txtW_Value.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -329,11 +330,11 @@ namespace PLC_WF_1
 
         private void btnW_ulong_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult rr = _client.Write<ulong>(this.txtW_Code.Text, txtW_Num.Text, Convert.ToUInt64(txtW_Value.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -344,11 +345,11 @@ namespace PLC_WF_1
 
         private void btnW_float_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult rr = _client.Write<float>(this.txtW_Code.Text, txtW_Num.Text, Convert.ToSingle(txtW_Value.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -359,11 +360,11 @@ namespace PLC_WF_1
 
         private void btnW_double_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 PLCResult rr = _client.Write<double>(this.txtW_Code.Text, txtW_Num.Text, Convert.ToDouble(txtW_Value.Text));
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -375,14 +376,14 @@ namespace PLC_WF_1
 
         private void btnW_string_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 //PLCResult rr = _client.Write<string>(txtW_Code.Text, txtW_Num.Text,
                 //    txtW_Value.Text, Convert.ToInt32(txtW_Len.Text));
                 PLCResult rr = _client.Write<string>(txtW_Code.Text, txtW_Num.Text,
                     txtW_Value.Text);
-                this.txtMessage.Text = JsonHelper.FromObject(rr);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
             }
             catch (Exception ex)
             {
@@ -395,7 +396,7 @@ namespace PLC_WF_1
         #region DO
         private void btnDo_Click(object sender, EventArgs e)
         {
-            this.txtMessage.Text = null;
+            //this.txtMessage.Text = null;
             try
             {
                 if (sender is Button bb)
@@ -420,7 +421,7 @@ namespace PLC_WF_1
                         //this.txtMessage.Text = "ok";
                         //return;
                     }
-                    this.txtMessage.Text = JsonHelper.FromObject(rr);
+                    this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
                 }
             }
             catch (Exception ex)
@@ -430,5 +431,73 @@ namespace PLC_WF_1
             }
         }
         #endregion
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            //this.txtMessage.Text = null;
+            try
+            {
+                //PLCResult rr = _client.Write<string>(txtW_Code.Text, txtW_Num.Text,
+                //    txtW_Value.Text, Convert.ToInt32(txtW_Len.Text));
+                PLCResult rr = _client.Write(txtW_Code.Text, txtW_Num.Text,
+                    txtW_Value.Text, System.Text.Encoding.UTF8);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
+            }
+            catch (Exception ex)
+            {
+                this.txtMessage.Text = ex.ToString();
+                _client?.Close();
+            }
+        }
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+            //this.txtMessage.Text = null;
+            try
+            {
+                PLCResult<string> rr = _client.ReadString(this.txtCode.Text, txtNumber.Text, Encoding.UTF8,
+                    Convert.ToInt32(txtLength.Text));
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
+            }
+            catch (Exception ex)
+            {
+                this.txtMessage.Text = ex.ToString();
+                _client?.Close();
+            }
+        }
+
+        private void button3_Click(object sender, EventArgs e)
+        {
+            //this.txtMessage.Text = null;
+            try
+            {
+                PLCResult<string> rr = _client.ReadString(this.txtCode.Text, txtNumber.Text, Encoding.Unicode,
+                    Convert.ToInt32(txtLength.Text));
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
+            }
+            catch (Exception ex)
+            {
+                this.txtMessage.Text = ex.ToString();
+                _client?.Close();
+            }
+        }
+
+        private void button4_Click(object sender, EventArgs e)
+        {
+            //this.txtMessage.Text = null;
+            try
+            {
+                //PLCResult rr = _client.Write<string>(txtW_Code.Text, txtW_Num.Text,
+                //    txtW_Value.Text, Convert.ToInt32(txtW_Len.Text));
+                PLCResult rr = _client.Write(txtW_Code.Text, txtW_Num.Text,
+                    txtW_Value.Text, System.Text.Encoding.Unicode);
+                this.txtMessage.Text += JsonHelper.FromObject(rr) + "\r\n";
+            }
+            catch (Exception ex)
+            {
+                this.txtMessage.Text = ex.ToString();
+                _client?.Close();
+            }
+        }
     }
 }

+ 4 - 2
HG5020.1-2/PLC_WF/PLC_WF_1.csproj

@@ -43,6 +43,9 @@
   <PropertyGroup />
   <PropertyGroup />
   <PropertyGroup />
+  <PropertyGroup>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="Curtain.Core.net4">
       <HintPath>..\..\lib\Curtain.Core.net4.dll</HintPath>
@@ -56,8 +59,7 @@
     <Reference Include="ICSharpCode.SharpZipLib">
       <HintPath>..\..\lib\ICSharpCode.SharpZipLib.dll</HintPath>
     </Reference>
-    <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
+    <Reference Include="Newtonsoft.Json">
       <HintPath>..\..\lib\Newtonsoft.Json.dll</HintPath>
     </Reference>
     <Reference Include="Oracle.ManagedDataAccess">

+ 3 - 0
HG5020.1-2/PLC_WS/PLC_WS_1.csproj

@@ -34,6 +34,9 @@
   <PropertyGroup>
     <ApplicationIcon>s2_128.ico</ApplicationIcon>
   </PropertyGroup>
+  <PropertyGroup>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="Curtain.Framework.net4">
       <HintPath>..\..\lib\Curtain.Framework.net4.dll</HintPath>

+ 3 - 0
HG5020.3/PLC_S/PLC_S.csproj

@@ -30,6 +30,9 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
+  <PropertyGroup>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
   <ItemGroup>
     <Compile Include="EPTS\DefectiveArea\EPTS_DefectiveArea_OUT.cs" />
     <Compile Include="EPTS\DefectiveArea\INI_DA_OUT.cs" />

+ 3 - 0
HG5020.3/PLC_WF/PLC_WF.csproj

@@ -43,6 +43,9 @@
   <PropertyGroup />
   <PropertyGroup />
   <PropertyGroup />
+  <PropertyGroup>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="Curtain.Core.net4">
       <HintPath>..\..\lib\Curtain.Core.net4.dll</HintPath>

+ 3 - 0
HG5020.3/PLC_WS/PLC_WS.csproj

@@ -34,6 +34,9 @@
   <PropertyGroup>
     <ApplicationIcon>s2_128.ico</ApplicationIcon>
   </PropertyGroup>
+  <PropertyGroup>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="Curtain.Framework.net4">
       <HintPath>..\..\lib\Curtain.Framework.net4.dll</HintPath>

+ 3 - 0
HG5020.3/TEST_HPGP/TEST_HPGP.csproj

@@ -31,6 +31,9 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
+  <PropertyGroup>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="Curtain.DataAccess.net4">
       <HintPath>..\..\lib\Curtain.DataAccess.net4.dll</HintPath>

BIN
doc/恒洁3车间-对接设置210118.xlsx


BIN
lib/Curtain.Core.net4.dll


BIN
lib/Curtain.DataAccess.net4.dll


BIN
lib/Curtain.Framework.net4.dll


BIN
lib/Newtonsoft.Json.dll


BIN
lib/Oracle.ManagedDataAccess.dll


BIN
lib/bak/Curtain.Core.net4.dll


BIN
lib/bak/Curtain.DataAccess.net4.dll


BIN
lib/bak/Curtain.Framework.net4.dll


BIN
lib/bak/ICSharpCode.SharpZipLib.dll


BIN
lib/bak/Newtonsoft.Json.dll


BIN
lib/bak/Oracle.ManagedDataAccess.dll


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно