黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/Common/Logic/HdlDeviceCurtainLogic.cs
@@ -1,6 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Shared.Phone.TemplateData;
using System;
using System.Collections.Generic;
using System.Text;
@@ -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;
            }
            //获取发送的命令字符
@@ -82,7 +81,7 @@
                return false;
            }
            //添加缓存
            TemplateDeviceDataLogic.Current.SetCurtainHandPullControl(device, bolStatu, result.JsonData[0]);
            HdlTemplateDeviceDataLogic.Current.SetCurtainHandPullControl(device, bolStatu, result.JsonData[0]);
            return true;
        }
@@ -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);
@@ -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;
        }
@@ -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.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowTipMsg(error);
                if (showError == ShowErrorMode.YES)
                {
                    this.ShowTipMsg(error);
                }
                return false;
            }
            if (result == null || result.setWritableValueResponData == null)
@@ -429,14 +431,20 @@
                string msg = Language.StringByID(R.MyInternationalizationString.uRestoreCurtainFail);
                //拼接上【网关回复超时】的Msg
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowTipMsg(msg);
                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;