From dc0309e64f02227d8e1468b7326c07955f804612 Mon Sep 17 00:00:00 2001
From: chenqiyang <1406175257@qq.com>
Date: 星期三, 22 六月 2022 11:22:18 +0800
Subject: [PATCH] 修改引用路径

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePirSensorLogic.cs |  900 ++++++++++++++++++++++++++++++------------------------------
 1 files changed, 450 insertions(+), 450 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePirSensorLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePirSensorLogic.cs
old mode 100755
new mode 100644
index 399ef95..5c90c36
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePirSensorLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePirSensorLogic.cs
@@ -1,450 +1,450 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Text;
-using ZigBee.Device;
-using System.Threading.Tasks;
-using Newtonsoft.Json.Linq;
-
-namespace Shared.Phone.UserCenter
-{
-    /// <summary>
-    /// PIR浼犳劅鍣ㄧ殑閫昏緫
-    /// </summary>
-    public class HdlDevicePirSensorLogic
-    {
-        #region 鈻� 鍙橀噺澹版槑___________________________
-
-        /// <summary>
-        /// PIR浼犳劅鍣ㄧ殑閫昏緫
-        /// </summary>
-        private static HdlDevicePirSensorLogic m_Current = null;
-        /// <summary>
-        /// PIR浼犳劅鍣ㄧ殑閫昏緫
-        /// </summary>
-        public static HdlDevicePirSensorLogic Current
-        {
-            get
-            {
-                if (m_Current == null)
-                {
-                    m_Current = new HdlDevicePirSensorLogic();
-                }
-                return m_Current;
-            }
-        }
-        #endregion
-
-        #region 鈻� 鍏夋劅绛夌骇鎬诲埢搴____________________
-
-        /// <summary>
-        /// 鑾峰彇PIR浼犳劅鍣ㄧ殑銆愬厜鎰熺瓑绾ф�诲埢搴︺�戯紝閿欒鏃惰繑鍥�-1
-        /// </summary>
-        /// <param name="iASZone"></param>
-        /// <returns></returns>
-        public async Task<int> GetPirLightAbilitySize(IASZone iASZone)
-        {
-            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
-            if (Common.Config.Instance.Home.IsVirtually == true)
-            {
-                return 100;
-            }
-            var data = await iASZone.GetPIRLightAbilitySizeAsync();
-            //鍏遍�氶敊璇娴�
-            string error = HdlCheckLogic.Current.CheckCommonErrorCode(data);
-            if (error != null)
-            {
-                this.ShowErrorMsg(error);
-                return -1;
-            }
-
-            if (data == null || data.errorMessageBase != null || data.LightLevelCount == -1)
-            {
-                //鑾峰彇浼犳劅鍣ㄥ厜鎰熺瓑绾уけ璐�
-                string msg = Language.StringByID(R.MyInternationalizationString.uGetPirSensorLightPerceptionRegulationFail);
-                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
-                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, data);
-
-                this.ShowErrorMsg(msg);
-                return -1;
-            }
-
-            return data.LightLevelCount;
-        }
-
-        #endregion
-
-        #region 鈻� 鑾峰彇閰嶇疆淇℃伅_______________________
-
-        /// <summary>
-        /// 鑾峰彇PIR浼犳劅鍣ㄧ殑銆愰厤缃俊鎭�戯紝閿欒鏃惰繑鍥瀗ull
-        /// </summary>
-        /// <param name="iASZone"></param>
-        /// <returns></returns>
-        public IASZone.ConfigureParamates GetPirSensorLightSettion(IASZone iASZone)
-        {
-            var data = this.GetPIRSensorParamateAsync(iASZone);
-            if (data == null || data.configureParamates == null)
-            {
-                //鑾峰彇浼犳劅鍣ㄨ缃俊鎭け璐�
-                string msg = Language.StringByID(R.MyInternationalizationString.uGetPirSensorSettionFail);
-                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
-                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, data);
-
-                this.ShowErrorMsg(msg);
-                return null;
-            }
-            return data.configureParamates;
-        }
-
-        /// <summary>
-        /// 鑾峰彇PIR浼犳劅鍣ㄧ殑銆恖ux鍊笺�戯紝閿欒鏃惰繑鍥�-1
-        /// </summary>
-        /// <param name="iASZone"></param>
-        /// <param name="mode"></param>
-        /// <returns></returns>
-        public async Task<int> GetPirSensorLux(IASZone iASZone, ShowErrorMode mode = ShowErrorMode.YES)
-        {
-            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
-            if (Common.Config.Instance.Home.IsVirtually == true)
-            {
-                return 70;
-            }
-            var data = await iASZone.GetPirLuxAbilitySizeAsync();
-            if (data == null || data.pirLux == -1)
-            {
-                //鑾峰彇浼犳劅鍣ㄤ寒搴﹀�煎け璐�
-                string msg = Language.StringByID(R.MyInternationalizationString.uGetPirSensorLuxFail);
-                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
-                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, data);
-                if (mode == ShowErrorMode.YES)
-                {
-                    this.ShowErrorMsg(msg);
-                }
-                return -1;
-            }
-            return data.pirLux;
-        }
-
-        ///<summary >
-        ///PIR浼犳劅鍣ㄥ弬鏁伴厤缃�
-        /// </summary>
-        public IASZone.ParamatesInfo GetPIRSensorParamateAsync(CommonDevice device)
-        {
-            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
-            if (Common.Config.Instance.Home.IsVirtually == true)
-            {
-                return TemplateData.TemplateDeviceDataLogic.Current.GetPirSensorLightSettion(device.DeviceAddr, 200);
-            }
-            var sendData = this.GetPirSensorParamateCommadText(device.DeviceAddr);
-            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0302", 34, 9);
-            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
-            {
-                return null;
-            }
-            var data = result.ReceiptData;
-
-            var tempD = new IASZone.ConfigureParamates();
-
-            var le = data[10].ToString() + data[11].ToString();
-            tempD.levelEnable = le == "01";
-
-            var size = data[12].ToString() + data[13].ToString();
-            tempD.levelSize = Convert.ToInt32(size, 16);
-
-            var cdl = data[14].ToString() + data[15].ToString();
-            tempD.controlDevEnable = cdl == "01";
-
-            tempD.transitionTime = Convert.ToInt32(data[18].ToString() + data[19].ToString() + data[16].ToString() + data[17].ToString(), 16);
-            tempD.iasReportPeriod = Convert.ToInt32(data[22].ToString() + data[23].ToString() + data[20].ToString() + data[21].ToString(), 16);
-            tempD.mode = Convert.ToInt32(data[24].ToString() + data[25].ToString(), 16);
-            tempD.type = Convert.ToInt32(data[26].ToString() + data[27].ToString(), 16);
-            tempD.dimmerOnTime = Convert.ToInt32(data[28].ToString() + data[29].ToString(), 16);
-            tempD.dimmerOffTime = Convert.ToInt32(data[30].ToString() + data[31].ToString(), 16);
-            tempD.dimmerLevel = Convert.ToInt32(data[32].ToString() + data[33].ToString(), 16);
-
-            return new IASZone.ParamatesInfo { configureParamates = tempD };
-        }
-
-        /// <summary>
-        /// 鑾峰彇PIR浼犳劅鍣ㄥ弬鏁伴厤缃殑鍛戒护瀛楃
-        /// </summary>
-        /// <param name="device"></param>
-        /// <returns></returns>
-        private string GetPirSensorParamateCommadText(string DeviceAddr)
-        {
-            var passData = "050103010101";
-            var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
-            var data = new JObject { { "PassData", passData } };
-            jObject.Add("Data", data);
-
-            return jObject.ToString();
-        }
-
-        #endregion
-
-        #region 鈻� 璁剧疆閰嶇疆淇℃伅_______________________
-
-        /// <summary>
-        /// 璁剧疆PIR浼犳劅鍣ㄧ殑銆愰厤缃俊鎭��
-        /// </summary>
-        /// <param name="device">浼犳劅鍣ㄥ璞�</param>
-        /// <param name="configure">鐏厜閰嶇疆</param>
-        /// <returns></returns>
-        public bool SetPirSensorSettion(CommonDevice device, IASZone.ConfigureParamates configure)
-        {
-            var result = this.SetPIRSensorParamateAsync(device, configure);
-            if (result == null || result.responseData == null)
-            {
-                //璁剧疆浼犳劅鍣ㄩ厤缃俊鎭け璐�
-                string msg = Language.StringByID(R.MyInternationalizationString.uSetPirSensorSettionFail);
-                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
-                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
-
-                this.ShowErrorMsg(msg);
-                return false;
-            }
-            if (result.responseData.status != 0)
-            {
-                //璁剧疆浼犳劅鍣ㄩ厤缃俊鎭け璐�
-                string msg = Language.StringByID(R.MyInternationalizationString.uSetPirSensorSettionFail);
-                this.ShowErrorMsg(msg);
-                return false;
-            }
-
-            return true;
-        }
-
-        /// <summary>
-        /// PIR浼犳劅鍣ㄥ弬鏁伴厤缃�
-        /// </summary>
-        /// <param name="device"></param>
-        /// <param name="configureParamates"></param>
-        /// <returns></returns>
-        public IASZone.ResponseAllData SetPIRSensorParamateAsync(CommonDevice device, IASZone.ConfigureParamates configureParamates)
-        {
-            //濡傛灉鏄櫄鎷熶綇瀹�
-            if (Common.Config.Instance.Home.IsVirtually == true)
-            {
-                return TemplateData.TemplateDeviceDataLogic.Current.SetPirSensorLightSettion(device.DeviceAddr, 200, configureParamates, null);
-            }
-            //鍙戦�佹暟鎹�
-            var sendData = this.GetPirSensorSettionCommandText(device.DeviceAddr, configureParamates);
-            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0002", 16, 9);
-            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
-            {
-                return null;
-            }
-            string data = result.ReceiptData;
-            var tempD = new IASZone.ResponseData();
-            tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
-            tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
-
-            //娣诲姞缂撳瓨
-            TemplateData.TemplateDeviceDataLogic.Current.SetPirSensorLightSettion(device.DeviceAddr, 200, configureParamates, result.JsonData[0]);
-
-            return new CommonDevice.ResponseAllData { responseData = tempD };
-        }
-
-        /// <summary>
-        /// 鑾峰彇淇敼PIR浼犳劅鍣ㄩ厤缃殑鍛戒护瀛楃
-        /// </summary>
-        /// <param name="DeviceAddr"></param>
-        /// <param name="configureParamates"></param>
-        /// <returns></returns>
-        public string GetPirSensorSettionCommandText(string DeviceAddr, IASZone.ConfigureParamates configureParamates)
-        {
-            var passData = this.GetPIRSensorSettionPassData(configureParamates);
-            var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
-            var data = new JObject { { "PassData", passData } };
-            jObject.Add("Data", data);
-
-            return jObject.ToString();
-        }
-
-        /// <summary>
-        /// 鑾峰彇淇敼PIR浼犳劅鍣ㄩ厤缃殑鍛戒护瀛楃
-        /// </summary>
-        private string GetPIRSensorSettionPassData(IASZone.ConfigureParamates configureParamates)
-        {
-            string data = "";
-            string dataLength = "10";
-            string dataComand1 = "00";
-            string dataComand2 = "03";
-            string dataSerialNum = "01";
-            string addDataLength = "0C";
-            string levelEnable = "";
-            string levelSize = "";
-            string controlDevEnable = "";
-            string transitionTime = "";
-            string iasReportPeriod = "";
-            string mode = "";
-            string type = "";
-            string dimmerOnTime = "";
-            string dimmerOffTime = "";
-            try
-            {
-                if (configureParamates != null)
-                {
-                    //levelEnable
-                    if (configureParamates.levelEnable)
-                    {
-                        levelEnable = "01";
-                    }
-                    else
-                    {
-                        levelEnable = "00";
-                    }
-                    //鍏夌収绛夌骇
-                    if (configureParamates.levelSize > 0)
-                    {
-                        var tempLevelEnable = Convert.ToString(configureParamates.levelSize, 16);
-                        levelSize = tempLevelEnable.ToString().PadLeft(2, '0');
-                    }
-                    else
-                    {
-                        levelSize = "00";
-                    }
-                    //controlDevEnable
-                    if (configureParamates.controlDevEnable)
-                    {
-                        controlDevEnable = "01";
-                    }
-                    else
-                    {
-                        controlDevEnable = "00";
-                    }
-                    //transitionTime,iasReportPeriod
-                    for (int j = 0; j < 2; j++)
-                    {
-                        var tempBytes = new byte[2];
-                        if (j == 0)
-                        {
-                            for (int i = 0; i < 2; i++)
-                            {
-                                tempBytes[i] = (byte)(configureParamates.transitionTime >> (i * 8) & 0xff);
-                            }
-                        }
-                        else
-                        {
-                            for (int i = 0; i < 2; i++)
-                            {
-                                tempBytes[i] = (byte)(configureParamates.iasReportPeriod >> (i * 8) & 0xff);
-                            }
-                        }
-                        var time1 = Convert.ToString(tempBytes[0], 16);
-                        var time2 = Convert.ToString(tempBytes[1], 16);
-                        if (time1.Length == 1)
-                        {
-                            time1 = "0" + time1;
-                        }
-                        if (time2.Length == 1)
-                        {
-                            time2 = "0" + time2;
-                        }
-                        if (j == 0)
-                        {
-                            transitionTime = (time1 + time2).ToUpper();
-
-                        }
-                        else
-                        {
-                            iasReportPeriod = (time1 + time2).ToUpper();
-                        }
-                    }
-                    //mode
-                    if (configureParamates.mode == 1)
-                    {
-                        mode = "01";
-                    }
-                    else
-                    {
-                        mode = "00";
-                    }
-                    //type
-                    if (configureParamates.type == 1)
-                    {
-                        type = "01";
-                    }
-                    else
-                    {
-                        type = "00";
-                    }
-                    //dimmerOnTime
-                    if (configureParamates.dimmerOnTime > 0)
-                    {
-                        var tempDimmerOnTime = Convert.ToString(configureParamates.dimmerOnTime, 16);
-                        dimmerOnTime = tempDimmerOnTime.ToString().PadLeft(2, '0');
-                    }
-                    else
-                    {
-                        dimmerOnTime = "00";
-                    }
-                    dimmerOnTime = dimmerOnTime.ToUpper();
-                    if (configureParamates.dimmerOffTime > 0)
-                    {
-                        var tempDimmerOffTime = Convert.ToString(configureParamates.dimmerOffTime, 16);
-                        dimmerOffTime = tempDimmerOffTime.ToString().PadLeft(2, '0');
-                    }
-                    else
-                    {
-                        dimmerOffTime = "00";
-                    }
-                    dimmerOffTime = dimmerOffTime.ToUpper();
-                    //dimmerLevel 
-                    string temp = "";
-                    var sbString = new System.Text.StringBuilder();
-                    string temp2 = Convert.ToString(configureParamates.dimmerLevel, 16);
-                    switch (temp2.Length)
-                    {
-                        case 1:
-                            temp = "0" + temp2;
-                            break;
-                        case 2:
-                            temp = temp2;
-                            break;
-                    }
-                    sbString.Append(temp.ToUpper());
-
-                    data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
-                    levelEnable + levelSize + controlDevEnable + transitionTime + iasReportPeriod
-                    + mode + type + dimmerOnTime + dimmerOffTime + sbString;
-                }
-            }
-            catch { };
-
-            return data;
-        }
-
-        #endregion
-
-        #region 鈻� 涓�鑸柟娉昣__________________________
-
-        /// <summary>
-        /// 鏄剧ず閿欒淇℃伅绐楀彛
-        /// </summary>
-        /// <param name="msg"></param>
-        private void ShowErrorMsg(string msg)
-        {
-            Application.RunOnMainThread(() =>
-            {
-                var contr = new ShowMsgControl(ShowMsgType.Error, msg);
-                contr.Show();
-            });
-        }
-
-        /// <summary>
-        /// 鏄剧ずTip淇℃伅绐楀彛
-        /// </summary>
-        /// <param name="msg"></param>
-        private void ShowTipMsg(string msg)
-        {
-            Application.RunOnMainThread(() =>
-            {
-                var contr = new UserCenter.ShowMsgControl(ShowMsgType.Tip, msg);
-                contr.Show();
-            });
-        }
-
-        #endregion
-    }
-}
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+using System.Threading.Tasks;
+using Newtonsoft.Json.Linq;
+
+namespace Shared.Phone.UserCenter
+{
+    /// <summary>
+    /// PIR浼犳劅鍣ㄧ殑閫昏緫
+    /// </summary>
+    public class HdlDevicePirSensorLogic
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// PIR浼犳劅鍣ㄧ殑閫昏緫
+        /// </summary>
+        private static HdlDevicePirSensorLogic m_Current = null;
+        /// <summary>
+        /// PIR浼犳劅鍣ㄧ殑閫昏緫
+        /// </summary>
+        public static HdlDevicePirSensorLogic Current
+        {
+            get
+            {
+                if (m_Current == null)
+                {
+                    m_Current = new HdlDevicePirSensorLogic();
+                }
+                return m_Current;
+            }
+        }
+        #endregion
+
+        #region 鈻� 鍏夋劅绛夌骇鎬诲埢搴____________________
+
+        /// <summary>
+        /// 鑾峰彇PIR浼犳劅鍣ㄧ殑銆愬厜鎰熺瓑绾ф�诲埢搴︺�戯紝閿欒鏃惰繑鍥�-1
+        /// </summary>
+        /// <param name="iASZone"></param>
+        /// <returns></returns>
+        public async Task<int> GetPirLightAbilitySize(IASZone iASZone)
+        {
+            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return 100;
+            }
+            var data = await iASZone.GetPIRLightAbilitySizeAsync();
+            //鍏遍�氶敊璇娴�
+            string error = HdlCheckLogic.Current.CheckCommonErrorCode(data);
+            if (error != null)
+            {
+                this.ShowErrorMsg(error);
+                return -1;
+            }
+
+            if (data == null || data.errorMessageBase != null || data.LightLevelCount == -1)
+            {
+                //鑾峰彇浼犳劅鍣ㄥ厜鎰熺瓑绾уけ璐�
+                string msg = Language.StringByID(R.MyInternationalizationString.uGetPirSensorLightPerceptionRegulationFail);
+                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, data);
+
+                this.ShowErrorMsg(msg);
+                return -1;
+            }
+
+            return data.LightLevelCount;
+        }
+
+        #endregion
+
+        #region 鈻� 鑾峰彇閰嶇疆淇℃伅_______________________
+
+        /// <summary>
+        /// 鑾峰彇PIR浼犳劅鍣ㄧ殑銆愰厤缃俊鎭�戯紝閿欒鏃惰繑鍥瀗ull
+        /// </summary>
+        /// <param name="iASZone"></param>
+        /// <returns></returns>
+        public IASZone.ConfigureParamates GetPirSensorLightSettion(IASZone iASZone)
+        {
+            var data = this.GetPIRSensorParamateAsync(iASZone);
+            if (data == null || data.configureParamates == null)
+            {
+                //鑾峰彇浼犳劅鍣ㄨ缃俊鎭け璐�
+                string msg = Language.StringByID(R.MyInternationalizationString.uGetPirSensorSettionFail);
+                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, data);
+
+                this.ShowErrorMsg(msg);
+                return null;
+            }
+            return data.configureParamates;
+        }
+
+        /// <summary>
+        /// 鑾峰彇PIR浼犳劅鍣ㄧ殑銆恖ux鍊笺�戯紝閿欒鏃惰繑鍥�-1
+        /// </summary>
+        /// <param name="iASZone"></param>
+        /// <param name="mode"></param>
+        /// <returns></returns>
+        public async Task<int> GetPirSensorLux(IASZone iASZone, ShowErrorMode mode = ShowErrorMode.YES)
+        {
+            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return 70;
+            }
+            var data = await iASZone.GetPirLuxAbilitySizeAsync();
+            if (data == null || data.pirLux == -1)
+            {
+                //鑾峰彇浼犳劅鍣ㄤ寒搴﹀�煎け璐�
+                string msg = Language.StringByID(R.MyInternationalizationString.uGetPirSensorLuxFail);
+                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, data);
+                if (mode == ShowErrorMode.YES)
+                {
+                    this.ShowErrorMsg(msg);
+                }
+                return -1;
+            }
+            return data.pirLux;
+        }
+
+        ///<summary >
+        ///PIR浼犳劅鍣ㄥ弬鏁伴厤缃�
+        /// </summary>
+        public IASZone.ParamatesInfo GetPIRSensorParamateAsync(CommonDevice device)
+        {
+            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return TemplateData.TemplateDeviceDataLogic.Current.GetPirSensorLightSettion(device.DeviceAddr, 200);
+            }
+            var sendData = this.GetPirSensorParamateCommadText(device.DeviceAddr);
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0302", 34, 9);
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+            var data = result.ReceiptData;
+
+            var tempD = new IASZone.ConfigureParamates();
+
+            var le = data[10].ToString() + data[11].ToString();
+            tempD.levelEnable = le == "01";
+
+            var size = data[12].ToString() + data[13].ToString();
+            tempD.levelSize = Convert.ToInt32(size, 16);
+
+            var cdl = data[14].ToString() + data[15].ToString();
+            tempD.controlDevEnable = cdl == "01";
+
+            tempD.transitionTime = Convert.ToInt32(data[18].ToString() + data[19].ToString() + data[16].ToString() + data[17].ToString(), 16);
+            tempD.iasReportPeriod = Convert.ToInt32(data[22].ToString() + data[23].ToString() + data[20].ToString() + data[21].ToString(), 16);
+            tempD.mode = Convert.ToInt32(data[24].ToString() + data[25].ToString(), 16);
+            tempD.type = Convert.ToInt32(data[26].ToString() + data[27].ToString(), 16);
+            tempD.dimmerOnTime = Convert.ToInt32(data[28].ToString() + data[29].ToString(), 16);
+            tempD.dimmerOffTime = Convert.ToInt32(data[30].ToString() + data[31].ToString(), 16);
+            tempD.dimmerLevel = Convert.ToInt32(data[32].ToString() + data[33].ToString(), 16);
+
+            return new IASZone.ParamatesInfo { configureParamates = tempD };
+        }
+
+        /// <summary>
+        /// 鑾峰彇PIR浼犳劅鍣ㄥ弬鏁伴厤缃殑鍛戒护瀛楃
+        /// </summary>
+        /// <param name="device"></param>
+        /// <returns></returns>
+        private string GetPirSensorParamateCommadText(string DeviceAddr)
+        {
+            var passData = "050103010101";
+            var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
+            var data = new JObject { { "PassData", passData } };
+            jObject.Add("Data", data);
+
+            return jObject.ToString();
+        }
+
+        #endregion
+
+        #region 鈻� 璁剧疆閰嶇疆淇℃伅_______________________
+
+        /// <summary>
+        /// 璁剧疆PIR浼犳劅鍣ㄧ殑銆愰厤缃俊鎭��
+        /// </summary>
+        /// <param name="device">浼犳劅鍣ㄥ璞�</param>
+        /// <param name="configure">鐏厜閰嶇疆</param>
+        /// <returns></returns>
+        public bool SetPirSensorSettion(CommonDevice device, IASZone.ConfigureParamates configure)
+        {
+            var result = this.SetPIRSensorParamateAsync(device, configure);
+            if (result == null || result.responseData == null)
+            {
+                //璁剧疆浼犳劅鍣ㄩ厤缃俊鎭け璐�
+                string msg = Language.StringByID(R.MyInternationalizationString.uSetPirSensorSettionFail);
+                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+                this.ShowErrorMsg(msg);
+                return false;
+            }
+            if (result.responseData.status != 0)
+            {
+                //璁剧疆浼犳劅鍣ㄩ厤缃俊鎭け璐�
+                string msg = Language.StringByID(R.MyInternationalizationString.uSetPirSensorSettionFail);
+                this.ShowErrorMsg(msg);
+                return false;
+            }
+
+            return true;
+        }
+
+        /// <summary>
+        /// PIR浼犳劅鍣ㄥ弬鏁伴厤缃�
+        /// </summary>
+        /// <param name="device"></param>
+        /// <param name="configureParamates"></param>
+        /// <returns></returns>
+        public IASZone.ResponseAllData SetPIRSensorParamateAsync(CommonDevice device, IASZone.ConfigureParamates configureParamates)
+        {
+            //濡傛灉鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return TemplateData.TemplateDeviceDataLogic.Current.SetPirSensorLightSettion(device.DeviceAddr, 200, configureParamates, null);
+            }
+            //鍙戦�佹暟鎹�
+            var sendData = this.GetPirSensorSettionCommandText(device.DeviceAddr, configureParamates);
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0002", 16, 9);
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+            string data = result.ReceiptData;
+            var tempD = new IASZone.ResponseData();
+            tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
+            tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
+
+            //娣诲姞缂撳瓨
+            TemplateData.TemplateDeviceDataLogic.Current.SetPirSensorLightSettion(device.DeviceAddr, 200, configureParamates, result.JsonData[0]);
+
+            return new CommonDevice.ResponseAllData { responseData = tempD };
+        }
+
+        /// <summary>
+        /// 鑾峰彇淇敼PIR浼犳劅鍣ㄩ厤缃殑鍛戒护瀛楃
+        /// </summary>
+        /// <param name="DeviceAddr"></param>
+        /// <param name="configureParamates"></param>
+        /// <returns></returns>
+        public string GetPirSensorSettionCommandText(string DeviceAddr, IASZone.ConfigureParamates configureParamates)
+        {
+            var passData = this.GetPIRSensorSettionPassData(configureParamates);
+            var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
+            var data = new JObject { { "PassData", passData } };
+            jObject.Add("Data", data);
+
+            return jObject.ToString();
+        }
+
+        /// <summary>
+        /// 鑾峰彇淇敼PIR浼犳劅鍣ㄩ厤缃殑鍛戒护瀛楃
+        /// </summary>
+        private string GetPIRSensorSettionPassData(IASZone.ConfigureParamates configureParamates)
+        {
+            string data = "";
+            string dataLength = "10";
+            string dataComand1 = "00";
+            string dataComand2 = "03";
+            string dataSerialNum = "01";
+            string addDataLength = "0C";
+            string levelEnable = "";
+            string levelSize = "";
+            string controlDevEnable = "";
+            string transitionTime = "";
+            string iasReportPeriod = "";
+            string mode = "";
+            string type = "";
+            string dimmerOnTime = "";
+            string dimmerOffTime = "";
+            try
+            {
+                if (configureParamates != null)
+                {
+                    //levelEnable
+                    if (configureParamates.levelEnable)
+                    {
+                        levelEnable = "01";
+                    }
+                    else
+                    {
+                        levelEnable = "00";
+                    }
+                    //鍏夌収绛夌骇
+                    if (configureParamates.levelSize > 0)
+                    {
+                        var tempLevelEnable = Convert.ToString(configureParamates.levelSize, 16);
+                        levelSize = tempLevelEnable.ToString().PadLeft(2, '0');
+                    }
+                    else
+                    {
+                        levelSize = "00";
+                    }
+                    //controlDevEnable
+                    if (configureParamates.controlDevEnable)
+                    {
+                        controlDevEnable = "01";
+                    }
+                    else
+                    {
+                        controlDevEnable = "00";
+                    }
+                    //transitionTime,iasReportPeriod
+                    for (int j = 0; j < 2; j++)
+                    {
+                        var tempBytes = new byte[2];
+                        if (j == 0)
+                        {
+                            for (int i = 0; i < 2; i++)
+                            {
+                                tempBytes[i] = (byte)(configureParamates.transitionTime >> (i * 8) & 0xff);
+                            }
+                        }
+                        else
+                        {
+                            for (int i = 0; i < 2; i++)
+                            {
+                                tempBytes[i] = (byte)(configureParamates.iasReportPeriod >> (i * 8) & 0xff);
+                            }
+                        }
+                        var time1 = Convert.ToString(tempBytes[0], 16);
+                        var time2 = Convert.ToString(tempBytes[1], 16);
+                        if (time1.Length == 1)
+                        {
+                            time1 = "0" + time1;
+                        }
+                        if (time2.Length == 1)
+                        {
+                            time2 = "0" + time2;
+                        }
+                        if (j == 0)
+                        {
+                            transitionTime = (time1 + time2).ToUpper();
+
+                        }
+                        else
+                        {
+                            iasReportPeriod = (time1 + time2).ToUpper();
+                        }
+                    }
+                    //mode
+                    if (configureParamates.mode == 1)
+                    {
+                        mode = "01";
+                    }
+                    else
+                    {
+                        mode = "00";
+                    }
+                    //type
+                    if (configureParamates.type == 1)
+                    {
+                        type = "01";
+                    }
+                    else
+                    {
+                        type = "00";
+                    }
+                    //dimmerOnTime
+                    if (configureParamates.dimmerOnTime > 0)
+                    {
+                        var tempDimmerOnTime = Convert.ToString(configureParamates.dimmerOnTime, 16);
+                        dimmerOnTime = tempDimmerOnTime.ToString().PadLeft(2, '0');
+                    }
+                    else
+                    {
+                        dimmerOnTime = "00";
+                    }
+                    dimmerOnTime = dimmerOnTime.ToUpper();
+                    if (configureParamates.dimmerOffTime > 0)
+                    {
+                        var tempDimmerOffTime = Convert.ToString(configureParamates.dimmerOffTime, 16);
+                        dimmerOffTime = tempDimmerOffTime.ToString().PadLeft(2, '0');
+                    }
+                    else
+                    {
+                        dimmerOffTime = "00";
+                    }
+                    dimmerOffTime = dimmerOffTime.ToUpper();
+                    //dimmerLevel 
+                    string temp = "";
+                    var sbString = new System.Text.StringBuilder();
+                    string temp2 = Convert.ToString(configureParamates.dimmerLevel, 16);
+                    switch (temp2.Length)
+                    {
+                        case 1:
+                            temp = "0" + temp2;
+                            break;
+                        case 2:
+                            temp = temp2;
+                            break;
+                    }
+                    sbString.Append(temp.ToUpper());
+
+                    data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
+                    levelEnable + levelSize + controlDevEnable + transitionTime + iasReportPeriod
+                    + mode + type + dimmerOnTime + dimmerOffTime + sbString;
+                }
+            }
+            catch { };
+
+            return data;
+        }
+
+        #endregion
+
+        #region 鈻� 涓�鑸柟娉昣__________________________
+
+        /// <summary>
+        /// 鏄剧ず閿欒淇℃伅绐楀彛
+        /// </summary>
+        /// <param name="msg"></param>
+        private void ShowErrorMsg(string msg)
+        {
+            Application.RunOnMainThread(() =>
+            {
+                var contr = new ShowMsgControl(ShowMsgType.Error, msg);
+                contr.Show();
+            });
+        }
+
+        /// <summary>
+        /// 鏄剧ずTip淇℃伅绐楀彛
+        /// </summary>
+        /// <param name="msg"></param>
+        private void ShowTipMsg(string msg)
+        {
+            Application.RunOnMainThread(() =>
+            {
+                var contr = new UserCenter.ShowMsgControl(ShowMsgType.Tip, msg);
+                contr.Show();
+            });
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0