HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-12-20 23fb45dd846ed8b62304c408c6bbe64265d4ac8b
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Shared.Common;
using Shared.Phone.UserView;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.Device
@@ -30,6 +29,10 @@
        /// 设备具体类型的信息
        /// </summary>
        private DeviceEnumInfo deviceEnumInfo = null;
        /// <summary>
        /// 中央空调的版本控件
        /// </summary>
        private NormalViewControl btnAirConditionerVersion = null;
        #endregion
@@ -223,6 +226,9 @@
            //添加【通用信息】行
            this.AddGeneralInformationRow();
            //添加【空调模块版本(空调专用)】行
            this.AddAirConditionerModelVersionRow();
            if (isHdlDevice == true)
            {
                //添加【固件升级】行
@@ -257,21 +263,19 @@
                     if (UserCenterResourse.UserInfo.AuthorityNo == 1)
                     {
                         Action action = null;
                         if (!UserCenterResourse.Option.DoorUnLockByRemote)
                         Action actionNone = null;
                         action = () =>
                         {
                             var userManagement = new Shared.Phone.UserCenter.DoorLock.UserManagement(doorLock);
                             Shared.Phone.UserView.HomePage.Instance.AddChidren(userManagement);
                             Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                             userManagement.Show();
                         };
                         actionNone = () =>
                         {
                             Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock, action);
                         }
                         else
                         {
                             action = async () =>
                             {
                                 var userManagement = new Shared.Phone.UserCenter.DoorLock.UserManagement(doorLock);
                                 Shared.Phone.UserView.HomePage.Instance.AddChidren(userManagement);
                                 Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                                 userManagement.Show();
                             };
                             HdlCheckLogic.Current.CheckSecondarySecurity(action);
                         }
                         };
                         HdlCheckLogic.Current.CheckSecondarySecurity(action, actionNone);
                     }
                     else
                     {
@@ -279,10 +283,21 @@
                         var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                         if (result == false)
                         {
                             var userManagement = new Shared.Phone.UserCenter.DoorLock.UserManagement(doorLock);
                             Shared.Phone.UserView.HomePage.Instance.AddChidren(userManagement);
                             Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                             userManagement.Show();
                             Action action = null;
                             Action actionNone = null;
                             action = () =>
                             {
                                 var userManagement = new Shared.Phone.UserCenter.DoorLock.UserManagement(doorLock);
                                 Shared.Phone.UserView.HomePage.Instance.AddChidren(userManagement);
                                 Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                                 userManagement.Show();
                             };
                             actionNone = () =>
                             {
                                 Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock, action);
                             };
                             HdlCheckLogic.Current.CheckSecondarySecurity(action, actionNone);
                         }
                         else
                         {
@@ -641,7 +656,7 @@
            //添加属性上报监听
            string mainkeys = LocalDevice.Current.GetDeviceMainKeys(this.listNewDevice[0]);
            HdlDeviceAttributeLogic.Current.AddAttributeEvent("HandPullControl", "DeviceStatusReport", (device) =>
            HdlGatewayReceiveLogic.Current.AddAttributeEvent("HandPullControl", ReceiveComandDiv.A设备属性上报, (device) =>
            {
                string checkKey = LocalDevice.Current.GetDeviceMainKeys(device);
                if (mainkeys != checkKey || device.DeviceStatusReport.CluterID != 258)
@@ -719,6 +734,34 @@
        #endregion
        #region ■ 空调模块版本(空调专用)_____________
        /// <summary>
        /// 添加【空调模块版本】行(河东的中央空调)
        /// </summary>
        private void AddAirConditionerModelVersionRow()
        {
            if (this.deviceEnumInfo.ConcreteType != DeviceConcreteType.AirConditioner_ZbGateway)
            {
                //不是中央空调
                return;
            }
            string caption = Language.StringByID(R.MyInternationalizationString.uAirConditionerModelVersion);
            var rowVersion = new FrameRowControl(listview.rowSpace / 2);
            rowVersion.UseClickStatu = false;
            listview.AddChidren(rowVersion);
            rowVersion.AddLeftCaption(caption, 600);
            //版本
            this.btnAirConditionerVersion = rowVersion.AddMostRightView("", 800);
            //底线
            rowVersion.AddBottomLine();
            //获取中央空调模块的版本
            this.ReadAirConditionerVersion();
        }
        #endregion
        #region ■ 固件升级___________________________
        /// <summary>
@@ -753,9 +796,19 @@
            rowUpDate.ButtonClickEvent += (sender, e) =>
            {
                if (this.deviceEnumInfo.ConcreteType != DeviceConcreteType.AirConditioner_ZbGateway)
                {
                    //这个是一般设备的升级
                    var form = new DeviceFirmwareUpdateForm();
                    form.AddForm(listNewDevice[0].DeviceAddr);
                }
                else
                {
                    //中央空调的升级的话,是特殊的
                    var form = new DeviceAirConditioner.ACZbGatewayUpdateMenuForm();
                    form.AddForm((AC)listNewDevice[0], btnNewVersion.Visible);
                }
                btnNewVersion.Visible = false;
                var form = new DeviceFirmwareInfoForm();
                form.AddForm(listNewDevice[0].DeviceAddr);
            };
            //设置设备的版本信息
@@ -909,16 +962,27 @@
        /// <summary>
        /// 删除指定设备
        /// </summary>
        private async void DoDeleteDevice()
        private void DoDeleteDevice()
        {
            //删除设备
            bool result = await Common.LocalDevice.Current.DeleteDevice(listNewDevice);
            if (result == false)
            HdlThreadLogic.Current.RunThread(async () =>
            {
                return;
            }
            //关闭界面
            this.CloseForm();
                //打开进度条
                this.ShowProgressBar();
                //删除设备
                bool result = await Common.LocalDevice.Current.DeleteDevice(listNewDevice);
                //关闭进度条
                this.CloseProgressBar();
                if (result == false)
                {
                    return;
                }
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //关闭界面
                    this.CloseForm();
                });
            });
        }
        #endregion
@@ -927,13 +991,13 @@
        /// <summary>
        /// 画面关闭
        /// </summary>
        public override void CloseForm()
        public override void CloseFormBefore()
        {
            HdlDeviceAttributeLogic.Current.RemoveEvent("HandPullControl");
            HdlGatewayReceiveLogic.Current.RemoveEvent("HandPullControl");
            //移除获取设备硬件信息的监听线程
            HdlDeviceHardInfoLogic.Current.RemoveDeviceHardInfoThread(listNewDevice[0]);
            base.CloseForm();
            base.CloseFormBefore();
        }
        #endregion
@@ -964,8 +1028,56 @@
        #endregion
        #region ■ 界面重新激活事件___________________
        /// <summary>
        /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
        /// </summary>
        public override int FormActionAgainEvent()
        {
            //重新获取中央空调模块的版本
            this.ReadAirConditionerVersion();
            return 0;
        }
        #endregion
        #region ■ 一般方法___________________________
        /// <summary>
        /// 获取中央空调模块的版本
        /// </summary>
        private void ReadAirConditionerVersion()
        {
            if (this.btnAirConditionerVersion == null)
            {
                return;
            }
            //获取中....
            this.btnAirConditionerVersion.TextID = R.MyInternationalizationString.uGetting;
            HdlThreadLogic.Current.RunThread(async () =>
            {
                //读取空调模块版本
                var result = await ((AC)listNewDevice[0]).ReadACFirewareVersionAsync();
                if (result == null || result.readACFirewareVersionResponData == null || result.readACFirewareVersionResponData.Status != 0)
                {
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        //获取失败
                        btnAirConditionerVersion.TextID = R.MyInternationalizationString.uGettingFail;
                    });
                }
                else
                {
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        btnAirConditionerVersion.Text = result.readACFirewareVersionResponData.FirewareVersion.Replace("-", string.Empty);
                    });
                }
            });
        }
        #endregion
    }
}