xm
2020-04-16 6fa9d69da922c8049f5acfcbb9ce9fd26811024c
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs
@@ -205,6 +205,87 @@
        #endregion
        #region ■ 接近感应___________________________
        /// <summary>
        /// 获取接近感应配置(ui叫接近感应,使用返回值的panelProximitySensorInfo)
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <returns></returns>
        public async Task<Panel.PanelProximitySensorInfo> GetDeviceProximitySensorsSettion(CommonDevice device)
        {
            //借用它的函数
            var panel = new Panel();
            panel.DeviceAddr = device.DeviceAddr;
            panel.DeviceEpoint = device.DeviceEpoint;
            panel.CurrentGateWayId = device.CurrentGateWayId;
            var result = await panel.GetProximitySensorAsync();
            panel = null;
            //共通错误检测
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            if (error != null)
            {
                this.ShowErrorMsg(error);
                return null;
            }
            if (result == null || result.panelProximitySensorInfo == null || string.IsNullOrEmpty(result.errorMessageBase) == false)
            {
                //获取接近感应信息失败
                string msg = Language.StringByID(R.MyInternationalizationString.GetPanelProximityFail);
                this.ShowErrorMsg(msg);
                return null;
            }
            return result.panelProximitySensorInfo;
        }
        /// <summary>
        /// 配置接近传感
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <para>sensorEnable:传感器使能</para>
        /// <returns></returns>
        public async Task<bool> SetProximitySensorStatus(CommonDevice device, bool sensorEnable)
        {
            //借用它的函数
            var panel = new Panel();
            panel.DeviceAddr = device.DeviceAddr;
            panel.DeviceEpoint = device.DeviceEpoint;
            panel.CurrentGateWayId = device.CurrentGateWayId;
            var result = await panel.SetProximitySensor(sensorEnable);
            panel = null;
            //共通错误检测
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            if (error != null)
            {
                this.ShowErrorMsg(error);
                return false;
            }
            if (result == null || result.responseData == null)
            {
                //接近传感配置失败
                string msg = Language.StringByID(R.MyInternationalizationString.SetPannelProximityFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                this.ShowTipMsg(msg);
                return false;
            }
            // 备份设备
            var backData = new Newtonsoft.Json.Linq.JObject
            {
                { "sensorEnable",sensorEnable }
            };
            //备份设备
            await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A面板接近感应功能, backData);
            return true;
        }
        #endregion
        #region ■ 节能模式___________________________
        /// <summary>
        /// 获取设备节能模式的配置状态(ui叫节能模式)
@@ -479,12 +560,12 @@
        #region ■ 修改干接点私有属性_________________
        /// <summary>
        /// 修改干接点私有属性
        /// 修改干接点第三级别的私有属性
        /// </summary>
        /// <param name="panel">干接点对象</param>
        /// <param name="i_value">干接点的第三级别属性的值,具体请参照第三级别属性</param>
        /// <returns></returns>
        public async Task<bool> EditorDryContactFunction(Panel panel, int i_value)
        public async Task<bool> EditorDryContactThirdFunction(Panel panel, int i_value)
        {
            var result = await panel.ConfigureHdlKeyValueAsync((Panel.KeyMode)i_value);
            //共通错误检测
@@ -537,7 +618,7 @@
                return false;
            }
            //备份设备
            await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A干接点私有属性, i_value);
            await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A干接点第三级别私有属性, i_value);
            return true;
        }
@@ -707,7 +788,13 @@
                    errorMsg = UserCenterLogic.CombineGatewayTimeOutMsg(errorMsg, null, "回复超时", false);
                }
                this.ShowTipMsg(errorMsg);
                return false;
            }
            //备份设备
            HdlThreadLogic.Current.RunThread(async () =>
            {
                await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A简约面板震动功能, datainfo);
            }, ShowErrorMode.NO);
            return success;
        }