黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs
@@ -52,7 +52,7 @@
        }
        /// <summary>
        /// 初始化中部信息
        /// 初始化中部信息 ☆☆☆☆☆
        /// </summary>
        private void InitMiddleFrame()
        {
@@ -79,7 +79,7 @@
                {
                    //获取空调模式失败
                    string msg = Language.StringByID(R.MyInternationalizationString.uGetAcModeFail);
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时");
                    msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, null, "回复超时");
                    this.ShowMassage(ShowMsgType.Tip, msg);
                    this.CloseProgressBar(ShowReLoadMode.YES);
                    return;
@@ -106,28 +106,33 @@
                    var btnOk = new BottomClickButton();
                    btnOk.TextID = R.MyInternationalizationString.uSave;
                    bodyFrameLayout.AddChidren(btnOk);
                    btnOk.ButtonClickEvent += async (sender, e) =>
                     {
                         if (this.oldReportValue == this.reportValue)
                         {
                    btnOk.ButtonClickEvent += (sender, e) =>
                    {
                        if (this.oldReportValue == this.reportValue)
                        {
                            //数据相同,不需要修改
                            this.CloseForm();
                             return;
                         }
                         //将二进制转换为十进制
                         var data = Convert.ToInt32(this.fixValue + this.reportValue, 2);
                         var result = await HdlDeviceAirConditionerLogic.Current.SetAcModeSupport(deviceAc, data);
                         if (result == true)
                         {
                             //更改缓存
                             for (int i = 0; i < this.reportValue.Length; i++)
                             {
                                 deviceAc.listSupportMode[i] = Convert.ToInt32(reportValue[i]);
                             }
                             deviceAc.ReSave();
                             this.CloseForm();
                         }
                     };
                            return;
                        }
                        //将二进制转换为十进制
                        var data = Convert.ToInt32(this.fixValue + this.reportValue, 2);
                        var result = HdlDeviceAirConditionerLogic.Current.SetAcModeSupport(deviceAc, data);
                        if (result == true)
                        {
                            //更改缓存
                            for (int i = 0; i < this.reportValue.Length; i++)
                            {
                                deviceAc.listSupportMode[i] = Convert.ToInt32(reportValue[i].ToString());
                            }
                            deviceAc.ReSave();
                            this.CloseForm();
                        }
                    };
                    //如果是展示模板
                    if (Common.Config.Instance.Home.IsShowTemplate == true)
                    {
                        btnOk.CanClick = false;
                    }
                });
            });
        }
@@ -174,6 +179,11 @@
                    this.reportValue = reportValue.Substring(0, div) + "0" + reportValue.Substring(div + 1);
                }
            };
            //如果是展示模板
            if (Common.Config.Instance.Home.IsShowTemplate == true)
            {
                rowFrame.CanClick = false;
            }
        }
        #endregion
@@ -181,14 +191,27 @@
        #region ■ 读取空调自定义模式_________________
        /// <summary>
        /// 读取空调自定义模式
        /// 读取空调自定义模式 ☆☆☆☆☆
        /// </summary>
        private void ReadAirConditionerModeSupport()
        {
            string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(deviceAc);
            HdlDeviceAttributeLogic.Current.AddAttributeEvent("ReadAirConditionerModeSupport", "DeviceStatusReport", (report) =>
            //如果是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true || Common.Config.Instance.Home.IsShowTemplate == true)
            {
                string checkKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
                var data = HdlTemplateDeviceDataLogic.Current.GetAcModeSupport(deviceAc);
                //转换为二进制
                var value = Convert.ToString(data, 2).PadLeft(16, '0');
                //这五个设置是放在后面的
                this.fixValue = value.Substring(0, value.Length - 5);
                this.reportValue = value.Substring(this.fixValue.Length);
                oldReportValue = reportValue;
                return;
            }
            string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(deviceAc);
            HdlGatewayReceiveLogic.Current.AddAttributeEvent("ReadAirConditionerModeSupport", ReceiveComandDiv.A设备属性上报, (report) =>
            {
                string checkKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(report);
                if (checkKeys != mainkeys || report.DeviceStatusReport.CluterID != 513)
                {
                    return;
@@ -198,7 +221,7 @@
                    var data = report.DeviceStatusReport.AttriBute[i];
                    if (data.AttributeId == 4099)
                    {
                        HdlDeviceAttributeLogic.Current.RemoveEvent("ReadAirConditionerModeSupport");
                        HdlGatewayReceiveLogic.Current.RemoveEvent("ReadAirConditionerModeSupport");
                        //转换为二进制
                        var value = Convert.ToString(data.AttriButeData, 2).PadLeft(16, '0');
                        //这五个设置是放在后面的
@@ -219,11 +242,11 @@
        /// <summary>
        /// 界面关闭
        /// </summary>
        public override void CloseForm()
        public override void CloseFormBefore()
        {
            HdlDeviceAttributeLogic.Current.RemoveEvent("ReadAirConditionerModeSupport");
            HdlGatewayReceiveLogic.Current.RemoveEvent("ReadAirConditionerModeSupport");
            base.CloseForm();
            base.CloseFormBefore();
        }
        #endregion