黄学彪
2019-11-25 5727cf0b9b54da0a191dd1e23cb5abf21320fbff
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>
@@ -130,7 +134,7 @@
            btnProgressView.Text = "0%";
            frameProgress.AddChidren(btnProgressView);
            new System.Threading.Thread(() =>
            HdlThreadLogic.Current.RunThread(() =>
            {
                //蓝才刚说有时候网关会收不到入网的命令,所以发三次
                for (int i = 0; i < 3; i++)
@@ -143,13 +147,10 @@
                    GatewayResourse.NowSelectGateway.AddNewDeviceToGateway(255);
                    System.Threading.Thread.Sleep(1000);
                }
            })
            { IsBackground = true }.Start();
            });
            //添加监视设备新上报的事件
            GatewayResourse.NowSelectGateway.GwResDataAction += this.AdjustGatewayResultData;
            //开启连接的假想动画效果线程
            this.StartConcetionAnimeteThread();
        }
        #endregion
@@ -251,7 +252,7 @@
            }
            this.isDeviceThreadStart = true;
            new System.Threading.Thread(() =>
            HdlThreadLogic.Current.RunThread(() =>
            {
                while (this.waitDeviceTimeOut >= 0)
                {
@@ -279,8 +280,7 @@
                        break;
                    }
                });
            })
            { IsBackground = true }.Start();
            });
        }
        /// <summary>
@@ -331,7 +331,7 @@
            btnRound.Y = Application.GetMinRealAverage(475);
            bodyFrameLayout.AddChidren(btnRound);
            new System.Threading.Thread(() =>
            HdlThreadLogic.Current.RunThread(() =>
            {
                int index = 1;
                while (this.Parent != null)
@@ -350,8 +350,7 @@
                        }
                    });
                }
            })
            { IsBackground = true }.Start();
            });
        }
        #endregion
@@ -368,7 +367,7 @@
        {
            if (topic == gatewayId + "/Device/DeviceAnnounce_Respon")
            {
                this.topTimeOut = 60;
                this.topTimeOut = topMaxTime;
                //网关告知客户端有设备声明
                this.SetDeviceProgressValue(1);
                return 2;
@@ -381,10 +380,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;
@@ -397,10 +397,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;
@@ -414,9 +415,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;
@@ -429,10 +431,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;
@@ -457,12 +460,17 @@
                //进度条
                decimal result = value / 6;
                int width = (int)(result * Application.GetRealWidth(559));
                if (btnProgressBar.Width >= width)
                {
                    //有些设备会上报两次,这里不能让它的进度条往回走
                    return;
                }
                btnProgressBar.Width = width;
                //文本显示
                btnProgressView.Text = ((int)(result * 100)) + "%";
                //文本显示的那个图片框移动
                frameProgress.X = ControlCommonResourse.XXLeft + btnProgressBar.Right - frameProgress.Width / 2;
                frameProgress.X = Application.GetRealWidth(262) + btnProgressBar.Right - frameProgress.Width / 2;
            });
        }
@@ -476,7 +484,7 @@
                return;
            }
            this.isTopicTimeOutThreadStart = true;
            new System.Threading.Thread(() =>
            HdlThreadLogic.Current.RunThread(() =>
            {
                while (this.Parent != null && this.topTimeOut >= 0)
                {
@@ -494,8 +502,7 @@
                        this.CloseForm();
                    });
                }
            })
            { IsBackground = true }.Start();
            });
        }
        #endregion
@@ -511,13 +518,12 @@
            //停止接收
            GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData;
            new System.Threading.Thread(() =>
            HdlThreadLogic.Current.RunThread(() =>
            {
                System.Threading.Thread.Sleep(1200);
                //关闭入网模式
                GatewayResourse.NowSelectGateway.AddNewDeviceToGateway(0);
            })
            { IsBackground = true }.Start();
            });
        }
        #endregion