Hcsy 7 years ago
parent
commit
0aca4e0687

+ 40 - 0
PLCDataReader/ClassFile/BaseUtil.cs

@@ -0,0 +1,40 @@
+namespace ClassFile
+{
+    class BaseUtil
+    {
+        /// <summary>
+        /// 获取LRC
+        /// </summary>
+        /// <param name="SQL"></param>
+        public static string getLRC(string SENDMESSAGE)
+        {
+            string message = SENDMESSAGE.Trim();
+            if (message.Length % 2 != 0)
+            {
+                message = message + "0";
+            }
+
+            int LRC = 0x0;
+            for (int i = 0; i < message.Length; i = i + 2)
+            {
+                int inside = int.Parse(message.Substring(i, 1).ToString() + message.Substring(i + 1, 1).ToString(), System.Globalization.NumberStyles.HexNumber);
+                LRC += inside;
+            }
+            string _LRC = string.Format("{0:X2}", LRC);
+            string LRCre = "";
+            for (int i = 0; i < _LRC.Length; i++)
+            {
+                int index;
+                if (i != _LRC.Length - 1)
+                {
+                    index = 0xF - int.Parse(_LRC.Substring(i, 1).ToString(), System.Globalization.NumberStyles.HexNumber);
+                }
+                else
+                    index = 0xF - int.Parse(_LRC.Substring(i, 1).ToString(), System.Globalization.NumberStyles.HexNumber) + 1;
+                LRCre += string.Format("{0:X}", index);
+            }
+
+            return LRCre;
+        }
+    }
+}

+ 1 - 34
PLCDataReader/ClassFile/LogManager.cs

@@ -61,39 +61,6 @@ namespace ClassFile
 
 
 
 
 
 
-        /// <summary>
-        /// 获取LRC
-        /// </summary>
-        /// <param name="SQL"></param>
-        public static string getLRC(string SENDMESSAGE)
-        {
-            string message = SENDMESSAGE.Trim();
-            if (message.Length % 2 != 0)
-            {
-                message = message + "0";
-            }
-
-            int LRC = 0x0;
-            for (int i = 0; i < message.Length; i = i + 2)
-            {
-                int inside = int.Parse(message.Substring(i, 1).ToString() + message.Substring(i + 1, 1).ToString(), System.Globalization.NumberStyles.HexNumber);
-                LRC += inside;
-            }
-            string _LRC = string.Format("{0:X2}", LRC);
-            string LRCre = "";
-            for (int i = 0; i < _LRC.Length; i++)
-            {
-                int index;
-                if (i != _LRC.Length - 1)
-                {
-                    index = 0xF - int.Parse(_LRC.Substring(i, 1).ToString(), System.Globalization.NumberStyles.HexNumber);
-                }
-                else
-                    index = 0xF - int.Parse(_LRC.Substring(i, 1).ToString(), System.Globalization.NumberStyles.HexNumber) + 1;
-                LRCre += string.Format("{0:X}", index);
-            }
-
-            return LRCre;
-        }
+       
     }
     }
 }
 }

+ 1 - 0
PLCDataReader/UAS_PLCDataReader.csproj

@@ -59,6 +59,7 @@
     <Reference Include="System.Xml" />
     <Reference Include="System.Xml" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <Compile Include="ClassFile\BaseUtil.cs" />
     <Compile Include="ClassFile\DataHelper.cs" />
     <Compile Include="ClassFile\DataHelper.cs" />
     <Compile Include="ClassFile\LogManager.cs" />
     <Compile Include="ClassFile\LogManager.cs" />
     <Compile Include="MainWindow.cs">
     <Compile Include="MainWindow.cs">