黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/Common/Logic/HdlDeviceCurtainLogic.cs
File was renamed from ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCurtainLogic.cs
@@ -1,13 +1,12 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Shared.Phone.TemplateData;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using ZigBee.Device;
namespace Shared.Phone.UserCenter
namespace Shared.Phone
{
    /// <summary>
    /// 窗帘的逻辑
@@ -51,7 +50,7 @@
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                //添加缓存
                TemplateDeviceDataLogic.Current.SetCurtainHandPullControl(device, bolStatu, null);
                HdlTemplateDeviceDataLogic.Current.SetCurtainHandPullControl(device, bolStatu, null);
                return true;
            }
            //获取发送的命令字符
@@ -68,7 +67,7 @@
                //切换手拉控制失败
                string msg = Language.StringByID(R.MyInternationalizationString.uChangeHandPullControlFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowTipMsg(msg);
                return false;
            }
@@ -82,7 +81,7 @@
                return false;
            }
            //添加缓存
            TemplateDeviceDataLogic.Current.SetCurtainHandPullControl(device, bolStatu, result.JsonData[0]);
            HdlTemplateDeviceDataLogic.Current.SetCurtainHandPullControl(device, bolStatu, result.JsonData[0]);
            return true;
        }
@@ -118,7 +117,7 @@
        {
            var result = this.SetCurtainDirectionAsync(rollershade, bolStatu);
            //检测网关返回的共通错误状态码
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            string error = HdlCheckLogic.Current.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowTipMsg(error);
@@ -129,7 +128,7 @@
                //窗帘方向设置失败
                string msg = Language.StringByID(R.MyInternationalizationString.uSetCurtainDirectionFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowTipMsg(msg);
                return false;
            }
@@ -153,7 +152,7 @@
            //如果当前是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return TemplateDeviceDataLogic.Current.SetCurtainDirection(device, isDirectionReversed, null);
                return HdlTemplateDeviceDataLogic.Current.SetCurtainDirection(device, isDirectionReversed, null);
            }
            //获取编辑窗帘方向的命令字符
            var sendData = this.GetCurtainDirectionCommadText(device.DeviceAddr, device.DeviceEpoint, isDirectionReversed);
@@ -164,7 +163,7 @@
            }
            //添加缓存
            TemplateDeviceDataLogic.Current.SetCurtainDirection(device, isDirectionReversed, result.JsonData[0]);
            HdlTemplateDeviceDataLogic.Current.SetCurtainDirection(device, isDirectionReversed, result.JsonData[0]);
            var tempData = JsonConvert.DeserializeObject<CommonDevice.SetWritableValueResponData>(result.ReceiptData);
            return new CommonDevice.SetWritableValueResponAllData { setWritableValueResponData = tempData };
@@ -205,7 +204,7 @@
            //如果当前是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return TemplateData.TemplateDeviceDataLogic.Current.SetCurtainLimitPoint(rollershade, upLimit, downLimit, curtainLength, null);
                return HdlTemplateDeviceDataLogic.Current.SetCurtainLimitPoint(rollershade, upLimit, downLimit, curtainLength, null);
            }
            //获取编辑开合帘限位的命令字符
            var sendData = this.GetAutoOpenCurtainLimitPointCommandText(rollershade.DeviceAddr, rollershade.DeviceEpoint, upLimit, downLimit);
@@ -215,7 +214,7 @@
                //设置窗帘限位点失败
                string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainLimitFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowTipMsg(msg);
                return false;
            }
@@ -229,7 +228,7 @@
            }
            //添加缓存
            TemplateDeviceDataLogic.Current.SetCurtainLimitPoint(rollershade, upLimit, downLimit, curtainLength, result.JsonData[0]);
            HdlTemplateDeviceDataLogic.Current.SetCurtainLimitPoint(rollershade, upLimit, downLimit, curtainLength, result.JsonData[0]);
            return true;
        }
@@ -298,7 +297,7 @@
                //result = await HdlDeviceAttributeLogic.Current.WriteDeviceAttribute(rollershade, 258, 24, 65, sendData);
            }
            //检测网关返回的共通错误状态码
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            string error = HdlCheckLogic.Current.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowTipMsg(error);
@@ -309,7 +308,7 @@
                //设置窗帘限位点失败
                string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainLimitFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowTipMsg(msg);
                return false;
            }
@@ -334,7 +333,7 @@
        {
            var result = await rollershade.DeleteCurtainLimitsAsync(limiType);
            //检测网关返回的共通错误状态码
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            string error = HdlCheckLogic.Current.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowTipMsg(error);
@@ -345,7 +344,7 @@
                //重置窗帘限位点失败
                string msg = Language.StringByID(R.MyInternationalizationString.uDeleteCurtainLimitFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowTipMsg(msg);
                return false;
            }
@@ -413,14 +412,17 @@
        /// </summary>
        /// <param name="rollershade">窗帘对象</param>
        /// <returns></returns>
        public async Task<bool> RestoreCurtain(Rollershade rollershade)
        public async Task<bool> RestoreCurtain(Rollershade rollershade, ShowErrorMode showError = ShowErrorMode.YES)
        {
            var result = await rollershade.RestoreCurtainLimitAsync();
            //检测网关返回的共通错误状态码
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            string error = HdlCheckLogic.Current.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowTipMsg(error);
                if (showError == ShowErrorMode.YES)
                {
                    this.ShowTipMsg(error);
                }
                return false;
            }
            if (result == null || result.setWritableValueResponData == null)
@@ -428,15 +430,21 @@
                //重置窗帘失败
                string msg = Language.StringByID(R.MyInternationalizationString.uRestoreCurtainFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                this.ShowTipMsg(msg);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                if (showError == ShowErrorMode.YES)
                {
                    this.ShowTipMsg(msg);
                }
                return false;
            }
            if (result.setWritableValueResponData.Status != 0)
            {
                //重置窗帘失败
                string msg = Language.StringByID(R.MyInternationalizationString.uRestoreCurtainFail);
                this.ShowTipMsg(msg);
                if (showError == ShowErrorMode.YES)
                {
                    this.ShowTipMsg(msg);
                }
                return false;
            }
            return true;