From a4924de3136289d10cabbf2f61a228387d44ded7 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期四, 07 十一月 2019 13:48:36 +0800
Subject: [PATCH] Merge branch 'dev-tzy' into DEV_GXC

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAirConditionerLogic.cs |  182 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 182 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAirConditionerLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAirConditionerLogic.cs
new file mode 100755
index 0000000..b8c406b
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAirConditionerLogic.cs
@@ -0,0 +1,182 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter
+{
+    /// <summary>
+    /// 绌鸿皟鐨勯�昏緫
+    /// </summary>
+    public class HdlDeviceAirConditionerLogic
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 绌鸿皟鐨勯�昏緫
+        /// </summary>
+        private static HdlDeviceAirConditionerLogic m_Current = null;
+        /// <summary>
+        /// 绌鸿皟鐨勯�昏緫
+        /// </summary>
+        public static HdlDeviceAirConditionerLogic Current
+        {
+            get
+            {
+                if (m_Current == null)
+                {
+                    m_Current = new HdlDeviceAirConditionerLogic();
+                }
+                return m_Current;
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鎵撳紑绌鸿皟___________________________
+
+        /// <summary>
+        /// 鎵撳紑绌鸿皟
+        /// </summary>
+        /// <param name="device">绌鸿皟瀵硅薄</param>
+        /// <returns></returns>
+        public async Task<bool> OpenAirConditioner(AC device)
+        {
+            var result = await device.Open();
+            //妫�娴嬬綉鍏宠繑鍥炵殑鍏遍�氶敊璇姸鎬佺爜
+            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
+            if (error != null)
+            {
+                this.ShowTipMsg(error);
+                return false;
+            }
+            if (result == null || result.setWritableValueResponData == null || result.setWritableValueResponData.Status != 0)
+            {
+                //鎵撳紑绌鸿皟澶辫触
+                string msg = Language.StringByID(R.MyInternationalizationString.uOpenAirConditionerFail);
+                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+                this.ShowTipMsg(msg);
+                return false;
+            }
+            if (result.setWritableValueResponData.Status != 0)
+            {
+                //鎵撳紑绌鸿皟澶辫触
+                string msg = Language.StringByID(R.MyInternationalizationString.uOpenAirConditionerFail);
+                this.ShowTipMsg(msg);
+                return false;
+            }
+            return true;
+        }
+
+        #endregion
+
+        #region 鈻� 鎵撳紑绌鸿皟___________________________
+
+        /// <summary>
+        /// 鎵撳紑绌鸿皟
+        /// </summary>
+        /// <param name="device">绌鸿皟瀵硅薄</param>
+        /// <returns></returns>
+        public async Task<bool> CloseAirConditioner(AC device)
+        {
+            var result = await device.Close();
+            //妫�娴嬬綉鍏宠繑鍥炵殑鍏遍�氶敊璇姸鎬佺爜
+            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
+            if (error != null)
+            {
+                this.ShowTipMsg(error);
+                return false;
+            }
+            if (result == null || result.setWritableValueResponData == null || result.setWritableValueResponData.Status != 0)
+            {
+                //鍏抽棴绌鸿皟澶辫触
+                string msg = Language.StringByID(R.MyInternationalizationString.uCloseAirConditionerFail);
+                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+                this.ShowTipMsg(msg);
+                return false;
+            }
+            if (result.setWritableValueResponData.Status != 0)
+            {
+                //鍏抽棴绌鸿皟澶辫触
+                string msg = Language.StringByID(R.MyInternationalizationString.uCloseAirConditionerFail);
+                this.ShowTipMsg(msg);
+                return false;
+            }
+            return true;
+        }
+
+        #endregion
+
+        #region 鈻� 璁剧疆绌鸿皟鐨勮嚜瀹氫箟妯″紡_______________
+
+        /// <summary>
+        /// 璁剧疆绌鸿皟鐨勮嚜瀹氫箟妯″紡
+        /// </summary>
+        /// <param name="device">绌鸿皟瀵硅薄</param>
+        /// <param name="data">浠庝簩杩涘埗杞崲鐨勫崄杩涘埗鍊�</param>
+        /// <returns></returns>
+        public async Task<bool> SetAcModeSupport(AC device, int data)
+        {
+            var result = await HdlDeviceAttributeLogic.Current.WriteDeviceAttribute(device, 513, 4099, 25, data);
+            //妫�娴嬬綉鍏宠繑鍥炵殑鍏遍�氶敊璇姸鎬佺爜
+            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
+            if (error != null)
+            {
+                this.ShowTipMsg(error);
+                return false;
+            }
+            if (result == null || result.setWritableValueResponData == null)
+            {
+                //璁剧疆绌鸿皟妯″紡澶辫触
+                string msg = Language.StringByID(R.MyInternationalizationString.uSetAcModeFail);
+                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+                this.ShowTipMsg(msg); ;
+                return false;
+            }
+            if (result.setWritableValueResponData.Status != 0)
+            {
+                //璁剧疆绌鸿皟妯″紡澶辫触
+                string msg = Language.StringByID(R.MyInternationalizationString.uSetAcModeFail);
+                this.ShowTipMsg(msg); ;
+                return false;
+            }
+            return true;
+        }
+
+        #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 ShowMsgControl(ShowMsgType.Tip, msg);
+                contr.Show();
+            });
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0