黄学彪
2019-11-18 1b565ce5fc003551b2db3a624f81221ac1df46b9
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs
@@ -31,7 +31,11 @@
        /// <summary>
        /// 主题间的超时时间 -100:中断线程(单位:秒)
        /// </summary>
        private int topTimeOut = 60;
        private int topTimeOut = 120;
        /// <summary>
        /// 超时最大时间
        /// </summary>
        private int topMaxTime = 120;
        /// <summary>
        /// 画面ID,标记它由哪个界面调用并打开的
        /// </summary>
@@ -40,6 +44,10 @@
        /// 网关ID
        /// </summary>
        private string gatewayId = string.Empty;
        /// <summary>
        /// 真实网关
        /// </summary>
        private ZbGateway realGateway = null;
        /// <summary>
        /// 进度条
        /// </summary>
@@ -69,6 +77,7 @@
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice));
            this.gatewayId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
            HdlGatewayLogic.Current.GetRealGateway(ref this.realGateway, this.gatewayId);
            //初始化中部控件
            this.InitMiddleFrame();
@@ -140,16 +149,13 @@
                        return;
                    }
                    //让网关允许入网
                    GatewayResourse.NowSelectGateway.AddNewDeviceToGateway(255);
                    this.realGateway.AddNewDeviceToGateway(255);
                    System.Threading.Thread.Sleep(1000);
                }
            });
            //添加监视设备新上报的事件
            GatewayResourse.NowSelectGateway.GwResDataAction += this.AdjustGatewayResultData;
            //开启连接的假想动画效果线程
            this.StartConcetionAnimeteThread();
            this.realGateway.GwResDataAction += this.AdjustGatewayResultData;
        }
        #endregion
@@ -168,7 +174,7 @@
            if (result == -1)
            {
                //停止接收
                GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData;
                this.realGateway.GwResDataAction -= this.AdjustGatewayResultData;
                Application.RunOnMainThread(() =>
                {
@@ -205,7 +211,7 @@
                //给新设备设置主键属性
                Common.LocalDevice.Current.SetNewDeviceMainKeys(device, jobject);
                device.CurrentGateWayId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
                device.CurrentGateWayId = HdlGatewayLogic.Current.GetGatewayId(this.realGateway);
                //将DeviceInfo的属性设置到主属性中
                Common.LocalDevice.Current.SetDeviceInfoToMain(device, device);
@@ -260,7 +266,7 @@
                    this.waitDeviceTimeOut--;
                }
                //停止接收
                GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData;
                this.realGateway.GwResDataAction -= this.AdjustGatewayResultData;
                System.Threading.Thread.Sleep(500);
                //目前就弄一个
@@ -366,7 +372,7 @@
        {
            if (topic == gatewayId + "/Device/DeviceAnnounce_Respon")
            {
                this.topTimeOut = 60;
                this.topTimeOut = topMaxTime;
                //网关告知客户端有设备声明
                this.SetDeviceProgressValue(1);
                return 2;
@@ -379,10 +385,11 @@
                if (info.Result != 0)
                {
                    //出现未知错误,请重新入网
                    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork));
                    return -1;
                    //this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork));
                    HdlLogLogic.Current.WriteLog(-1, resultData);
                    return 2;
                }
                this.topTimeOut = 60;
                this.topTimeOut = topMaxTime;
                //设置进度值
                this.SetDeviceProgressValue(2);
                return 2;
@@ -395,10 +402,11 @@
                if (info.Result != 0)
                {
                    //出现未知错误,请重新入网
                    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork));
                    return -1;
                    //this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork));
                    HdlLogLogic.Current.WriteLog(-1, resultData);
                    return 2;
                }
                this.topTimeOut = 60;
                this.topTimeOut = topMaxTime;
                //设置进度值
                this.SetDeviceProgressValue(3);
                return 2;
@@ -412,9 +420,10 @@
                {
                    //出现未知错误,请重新入网
                    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork));
                    return -1;
                    //HdlLogLogic.Current.WriteLog(-1, resultData);
                    return 2;
                }
                this.topTimeOut = 60;
                this.topTimeOut = topMaxTime;
                //设置进度值
                this.SetDeviceProgressValue(4);
                return 2;
@@ -427,10 +436,11 @@
                if (info.Result != 0)
                {
                    //出现未知错误,请重新入网
                    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork));
                    return -1;
                    //this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork));
                    HdlLogLogic.Current.WriteLog(-1, resultData);
                    return 2;
                }
                this.topTimeOut = 60;
                this.topTimeOut = topMaxTime;
                //设置进度值
                this.SetDeviceProgressValue(5);
                return 2;
@@ -455,6 +465,11 @@
                //进度条
                decimal result = value / 6;
                int width = (int)(result * Application.GetRealWidth(559));
                if (btnProgressBar.Width >= width)
                {
                    //有些设备会上报两次,这里不能让它的进度条往回走
                    return;
                }
                btnProgressBar.Width = width;
                //文本显示
@@ -506,13 +521,13 @@
        {
            base.CloseForm();
            //停止接收
            GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData;
            this.realGateway.GwResDataAction -= this.AdjustGatewayResultData;
            HdlThreadLogic.Current.RunThread(() =>
            {
                System.Threading.Thread.Sleep(1200);
                //关闭入网模式
                GatewayResourse.NowSelectGateway.AddNewDeviceToGateway(0);
                this.realGateway.AddNewDeviceToGateway(0);
            });
        }