From fdddb786ac2cd2b1d89bab2932aedfec4d05e358 Mon Sep 17 00:00:00 2001
From: tangxu <76880903@qq.com>
Date: 星期三, 26 十月 2022 09:11:57 +0800
Subject: [PATCH] 添加单位类型 重量

---
 Socket/IStation.DataDockingSocket4NT/helper/MsgDataHelper.cs |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 103 insertions(+), 6 deletions(-)

diff --git a/Socket/IStation.DataDockingSocket4NT/helper/HandleDataHelper.cs b/Socket/IStation.DataDockingSocket4NT/helper/MsgDataHelper.cs
similarity index 81%
rename from Socket/IStation.DataDockingSocket4NT/helper/HandleDataHelper.cs
rename to Socket/IStation.DataDockingSocket4NT/helper/MsgDataHelper.cs
index f9d11c1..91ae2b7 100644
--- a/Socket/IStation.DataDockingSocket4NT/helper/HandleDataHelper.cs
+++ b/Socket/IStation.DataDockingSocket4NT/helper/MsgDataHelper.cs
@@ -12,8 +12,41 @@
     /// <summary>
     /// 澶勭悊鏁版嵁杈呭姪绫�
     /// </summary>
-    internal class HandleDataHelper
+    internal class MsgDataHelper
     {
+ 
+        /// <summary>
+        /// 鑾峰彇
+        /// </summary>
+        /// <returns></returns>
+        public static AppParas GetAppParas()
+        {
+            if (_appparas == null)
+            {
+                 var jsonFileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "paras_datadocking_socket_nt.json");
+                var json = FileHelper.ReadAllText(jsonFileName);
+                _appparas = JsonHelper.Json2Object<AppParas>(json);
+            }
+            return _appparas;
+        }
+        private static AppParas _appparas = null;
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+        public static bool IsSrc()
+        {
+            return GetAppParas().Src;
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+        public static bool IsDebug()
+        {
+            return GetAppParas().Debug;
+        }
+
         /// <summary>
         /// 澶勭悊鏁版嵁
         /// </summary>
@@ -29,7 +62,7 @@
             }
             //else if (byteMessage[2] == 0x46)
             //{
-            //    return ReadMessage鐩戞帶鍊�(byteMessage);
+            //    return ReadMessage鐘舵�佸��(byteMessage);
             //}
             else
             {
@@ -39,7 +72,20 @@
         }
 
 
-
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+        internal static IEnumerable<QueryInstructionItem> GetInstructionQuerys()
+        {
+            var appParas = GetAppParas();
+            if (appParas == null)
+            {
+                LogHelper.Error("Socket 鏁版嵁瀵规帴涓紝NT 缂哄皯鏁版嵁瀵规帴閰嶇疆鏂囦欢");
+                return null;
+            }
+            return appParas.InstructionQuerys;
+        }
         /// <summary>
         /// 鑾峰彇鎺у埗鎸囦护(璋冮)
         /// </summary>
@@ -68,12 +114,12 @@
 
 
         /// <summary>
-        /// 鑾峰彇鏌ヨ鎸囦护(鐘舵�佸��)
+        /// 鑾峰彇鏌ヨ鎸囦护(鐘舵�佸��):01-03-00-12-00-04-E4-0C
         /// </summary>
         /// <returns></returns>
         public static byte[] GetMonitorMsg鐘舵�佸��()
         {
-            return new byte[] { 0x01, 0x03, 0x00, 0x19, 0x00, 0x23, 0xD5, 0xD4 };
+            return new byte[] { 0x01, 0x03, 0x00, 0x12, 0x00, 0x04, 0xE4, 0x0C };
         }
 
 
@@ -340,8 +386,57 @@
             return list;
         }
 
+        /// <summary>
+        /// 璇诲彇娑堟伅(鐘舵�佸��)
+        /// </summary>
+        /// <param name="byteMessage"></param>
+        private static List<Model.MonitorDataDockingReceiveRecord> ReadMessage鐘舵�佸��(byte[] byteMessage)
+        {
+            var list = new List<Model.MonitorDataDockingReceiveRecord>();
+            byte start = 0x12;
+            if (byteMessage == null || byteMessage.Length < 8 )
+            {
+                return null;
+            }
+            try
+            {
+                //鏄剧ず娑堟伅
+                //string strMessage = BitConverter.ToString(byteMessage, 0, byteMessage.Length);
+                //DisplayMessage(string.Format(" 鏀跺埌鐨勬秷鎭�:  {0} ", strMessage));
 
-  
+
+                //DisplayMessage(string.Format(" 璁惧鍦板潃: {0} (0x{1})", byteMessage[0], Convert.ToString(byteMessage[0], 16)));
+                //DisplayMessage(string.Format(" 鍔熻兘鐮�: {0} ", byteMessage[1]));
+
+            
+                string msg;
+ 
+                var now = DateTime.Now;
+                //娑蹭綅閲忕▼
+                //list.Add(new Model.MonitorDataDockingReceiveRecord()
+                //{
+                //    SysId =  ,
+                //    RecordType = Model.eMonitorType.General,
+                //    SrcTime = now,
+                //    SrcValue = (GetInt2Byte(byteMessage, 3 + (19 - start), out msg )* 0.1).ToString()
+                //});
+                //璁惧畾棰戠巼
+                list.Add(new Model.MonitorDataDockingReceiveRecord()
+                {
+                    SysId = 1584894751252025344,
+                    RecordType = Model.eMonitorType.General,
+                    SrcTime = now,
+                    SrcValue = (GetInt2Byte(byteMessage, 3 + (20 - start), out msg) * 0.1).ToString()
+                });
+            }
+            catch// (Exception err)
+            { 
+                return null;
+            }
+            return list;
+        }
+
+
         #region MyRegion
         private static int GetInt2Byte(byte[] byteMessage, int startPosition, out string info)
         {
@@ -424,6 +519,8 @@
             //return BitConverter.ToDouble(byteMessage, startPosition);
             return BitConverter.ToSingle(value.Reverse().ToArray(), 0);//閲囩敤浜咺EEE-754浜岃繘鍒舵诞鐐规暟绠楁湳鏍囧噯
         }
+
+
         #endregion
     }
 

--
Gitblit v1.9.3