From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 17 十二月 2020 09:07:13 +0800
Subject: [PATCH] 新云端Ver1.3

---
 ZigbeeApp/Shared/Phone/Common/Logic/HdlDeviceAttributeLogic.cs |  246 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 162 insertions(+), 84 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAttributeLogic.cs b/ZigbeeApp/Shared/Phone/Common/Logic/HdlDeviceAttributeLogic.cs
similarity index 77%
rename from ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAttributeLogic.cs
rename to ZigbeeApp/Shared/Phone/Common/Logic/HdlDeviceAttributeLogic.cs
index 598fe28..9d29cfb 100644
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAttributeLogic.cs
+++ b/ZigbeeApp/Shared/Phone/Common/Logic/HdlDeviceAttributeLogic.cs
@@ -4,7 +4,7 @@
 using System.Text;
 using ZigBee.Device;
 
-namespace Shared.Phone.UserCenter
+namespace Shared.Phone
 {
     /// <summary>
     /// 璁惧灞炴�х殑閫昏緫绫�
@@ -63,6 +63,95 @@
             jObject.Add("Data", data);
 
             return jObject.ToString();
+        }
+
+        #endregion
+
+        #region 鈻� 璇诲彇璁惧纭欢淇℃伅___________________
+
+        /// <summary>
+        /// 璇诲彇璁惧纭欢淇℃伅
+        /// </summary>
+        /// <param name="device">璁惧鍥炶矾</param>
+        public void ReadDeviceAllHardFirmwareInfo(CommonDevice device)
+        {
+            if (device == null)
+            {
+                return;
+            }
+
+            var jObject = new Newtonsoft.Json.Linq.JObject
+            {
+                { "DeviceAddr",device.DeviceAddr },
+                { "Epoint", device.DeviceEpoint },
+                { "Cluster_ID", (int)Cluster_ID.Basic },
+                { "Command", 108 }
+            };
+            var attriBute = new Newtonsoft.Json.Linq.JArray
+            {
+               new Newtonsoft.Json.Linq.JObject
+               {
+                 { "AttriButeId", 4}//鐢熶骇鍟嗗悕瀛�
+               },
+               new Newtonsoft.Json.Linq.JObject
+               {
+                 { "AttriButeId", 5}//鍨嬪彿鐮�(涔熷彨妯″潡ID)
+               },
+               new Newtonsoft.Json.Linq.JObject
+               {
+                 { "AttriButeId", 6}//鐢熶骇鏃ユ湡
+               },
+                  new Newtonsoft.Json.Linq.JObject
+               {
+                 { "AttriButeId", 7}//鐢垫簮
+               },
+               new Newtonsoft.Json.Linq.JObject
+               {
+                 { "AttriButeId", 13}//搴忓垪鍙�
+               }
+            };
+            var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } };
+            jObject.Add("Data", data);
+
+            HdlGatewayLogic.Current.SendJobjectData(device.CurrentGateWayId, "GetDeviceStatus", jObject.ToString());
+        }
+
+        #endregion
+
+        #region 鈻� 鑾峰彇璁惧鍥轰欢鐗堟湰淇℃伅_______________
+
+        /// <summary>
+        /// 璇诲彇璁惧鍥轰欢鐗堟湰淇℃伅
+        /// </summary>
+        /// <param name="device"></param>
+        public void ReadDeviceFirmwareVersion(OTADevice device)
+        {
+            var jObject = new Newtonsoft.Json.Linq.JObject
+            {
+                { "DeviceAddr",device.DeviceAddr },
+                { "Epoint", device.DeviceEpoint },
+                { "Cluster_ID", (int)Cluster_ID.Ota },
+                { "Command", 108 }
+            };
+            var attriBute = new Newtonsoft.Json.Linq.JArray
+            {
+               new Newtonsoft.Json.Linq.JObject
+               {
+                 { "AttriButeId", (int)AttriButeId.ImgVersion}
+               },
+               new Newtonsoft.Json.Linq.JObject
+               {
+                 { "AttriButeId", (int)AttriButeId.mgHWversion}
+               },
+               new Newtonsoft.Json.Linq.JObject
+               {
+                 { "AttriButeId", (int)AttriButeId.ImgTypeId}
+               }
+            };
+            var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } };
+            jObject.Add("Data", data);
+
+            HdlGatewayLogic.Current.SendJobjectData(device.CurrentGateWayId, "GetDeviceStatus", jObject.ToString());
         }
 
         #endregion
@@ -226,7 +315,7 @@
 
         #endregion
 
-        #region 鈻� PM2.5_______________________________
+        #region 鈻� PM2.5______________________________
         /// <summary>
         /// SendPmSensorComand
         /// </summary>
@@ -273,87 +362,6 @@
                  { "AttriButeId", (int)AttriButeId.MeasuredValue}
                }
             };
-            var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } };
-            jObject.Add("Data", data);
-            device.Gateway?.Send("GetDeviceStatus", jObject.ToString());
-        }
-
-        #endregion
-
-        #region 鈻� 鏅捐。鏋禵______________________________
-        /// <summary>
-        /// SendAirerComand
-        ///鍥炶矾2:璇诲彇鐓ф槑寮�鍏崇姸鎬�
-        ///鍥炶矾3:璇诲彇椋庡共寮�鍏崇姸鎬佸拰鏃堕棿鍊� 
-        ///鍥炶矾4:璇诲彇鐑樺共寮�鍏崇姸鎬佸拰鏃堕棿鍊�
-        ///鍥炶矾5:璇诲彇娑堟瘨寮�鍏崇姸鎬佸拰鏃堕棿鍊�
-        /// </summary>
-        /// <param name="device">璁惧</param>
-        /// <param name="ctrlEpoint">鎺у埗绔偣</param>
-        public void SendAirerComand(CommonDevice device, int ctrlEpoint)
-        {
-            if (device == null)
-            {
-                return;
-            }
-            new System.Threading.Thread(() =>
-            {
-                SendAirerStatuComand(device, ctrlEpoint);
-                System.Threading.Thread.Sleep(300);
-            })
-            { IsBackground = true }.Start();
-        }
-
-        /// <summary>
-        /// SendAirerStatuComand
-        /// </summary>
-        /// <param name="device">璁惧</param>
-        private void SendAirerStatuComand(CommonDevice device, int ctrlEpoint = 1)
-        {
-            if (device == null)
-            {
-                return;
-            }
-            var jObject = new Newtonsoft.Json.Linq.JObject
-            {
-                { "DeviceAddr",device.DeviceAddr },
-                { "Epoint", ctrlEpoint },
-                { "Cluster_ID", (int)Cluster_ID.Switch},
-                { "Command", 108 }
-            };
-            Newtonsoft.Json.Linq.JArray attriBute = new Newtonsoft.Json.Linq.JArray();
-
-            //鏅捐。鏋剁殑鏅捐。鏋剁殑锛堢儤骞诧紝椋庡共锛屾秷姣�,鐓ф槑鐘舵�佽鍙栵級
-            attriBute = new Newtonsoft.Json.Linq.JArray
-             {
-                new Newtonsoft.Json.Linq.JObject
-               {
-                    //鏅捐。鏋剁殑鐓ф槑寮�鍏崇姸鎬�
-                 { "AttriButeId", (int)AttriButeId.Switch}
-               }
-             };
-
-            //if (device.DeviceEpoint != 2)
-            //{
-            //鐢变簬璁惧涓嶆敮鎸佹椂闂村姛鑳斤紝鍚庢湡鎵嶆敮鎸侊紝娉ㄦ剰澶勭悊鏃堕棿瑕佹牴鎹儤骞诧紝椋庡共锛屾秷姣掓槸鍚﹀紑鎵嶅彂閫佺浉搴斿ぇ鏃堕棿璇诲彇鏁版嵁
-            //attriBute = new Newtonsoft.Json.Linq.JArray {
-            //        new Newtonsoft.Json.Linq.JObject
-            //       {
-            //            //鏅捐。鏋剁殑寮�鍏崇姸鎬侊紙鐑樺共锛岄骞诧紝娑堟瘨锛�
-            //         { "AttriButeId", (int)AttriButeId.Switch}
-            //       },
-            //           new Newtonsoft.Json.Linq.JObject
-            //       {
-            //            //鏅捐。鏋剁殑鏅捐。鏋剁殑锛堢儤骞诧紝椋庡共锛屾秷姣掞級鍓╀綑鏃堕棿
-            //         { "AttriButeId", (int)AttriButeId.AirerRemainTime}
-            //       },
-            //       new Newtonsoft.Json.Linq.JObject
-            //       {
-            //           //鏅捐。鏋剁殑锛堢儤骞诧紝椋庡共锛屾秷姣掞級鏃堕棿
-            //         { "AttriButeId", (int)AttriButeId.AirerTime}
-            //       }
-            //    };
-            //}
             var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } };
             jObject.Add("Data", data);
             device.Gateway?.Send("GetDeviceStatus", jObject.ToString());
@@ -503,7 +511,7 @@
                 colorDevice.ReadLevel();
                 System.Threading.Thread.Sleep(300);
                 colorDevice.ReadColorTemperature();
-                if (LocalDevice.Current.IsMiniLight(device) == true)
+                if (HdlDeviceCommonLogic.Current.IsMiniLight(device) == true)
                 {
                     //mini澶滅伅闇�瑕佽鍙栬渹楦e櫒鐘舵��
                     System.Threading.Thread.Sleep(300);
@@ -576,5 +584,75 @@
         }
 
         #endregion
+
+        #region 鈻� 璇诲彇璁惧鍥哄畾灞炴�__________________
+
+        /// <summary>
+        /// 璇诲彇璁惧鍥哄畾灞炴��(false:涓嶉渶瑕佸彂閫佸懡浠�)
+        /// </summary>
+        /// <param name="i_device">璁惧鍥炶矾</param>
+        public bool ReadDeviceAllFixedAttribute(CommonDevice i_device)
+        {
+            if (i_device == null)
+            {
+                return false;
+            }
+            var localDevice = HdlDeviceCommonLogic.Current.GetDevice(i_device.DeviceAddr, i_device.DeviceEpoint);
+            if (localDevice == null)
+            {
+                //ota涔熶細璺戣繘鏉�
+                return false;
+            }
+
+            Newtonsoft.Json.Linq.JObject jObject = null;
+            Newtonsoft.Json.Linq.JArray attriBute = null;
+            //绐楀笜
+            if (localDevice.Type == DeviceType.WindowCoveringDevice
+                && ((Rollershade)localDevice).WcdType == -1)
+            {
+                this.GetCurtainFixedAttributeComand(localDevice, ref jObject, ref attriBute);
+            }
+            if (jObject == null)
+            {
+                //涓嶉渶瑕佸彂閫�
+                return false;
+            }
+            //鍙戦��
+            var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } };
+            jObject.Add("Data", data);
+            localDevice.Gateway?.Send(("GetDeviceStatus"), jObject.ToString());
+
+            return true;
+        }
+
+        #region 鑾峰彇绐楀笜鍥哄畾灞炴�у懡浠_
+
+        /// <summary>
+        /// 鑾峰彇绐楀笜鍥哄畾灞炴�у懡浠�
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <param name="jObject">鏍囬鏁版嵁</param>
+        /// <param name="attriBute">灞炴�ф暟鎹�</param>
+        private void GetCurtainFixedAttributeComand(CommonDevice device, ref Newtonsoft.Json.Linq.JObject jObject, ref Newtonsoft.Json.Linq.JArray attriBute)
+        {
+            jObject = new Newtonsoft.Json.Linq.JObject
+            {
+               { "DeviceAddr",device.DeviceAddr },
+               { "Epoint", device.DeviceEpoint },
+               { "Cluster_ID", (int)Cluster_ID.WindowCovering },
+               { "Command", 108 }
+            };
+            attriBute = new Newtonsoft.Json.Linq.JArray
+            {
+               new Newtonsoft.Json.Linq.JObject
+               {
+                  { "AttriButeId", (int)AttriButeId.WindowCoveringType }
+               }
+            };
+        }
+
+        #endregion
+
+        #endregion
     }
 }

--
Gitblit v1.8.0