| | |
| | | /// <summary>
|
| | | /// 主题间的超时时间 -100:中断线程(单位:秒)
|
| | | /// </summary>
|
| | | private int topTimeOut = 60;
|
| | | private int topTimeOut = 120;
|
| | | /// <summary>
|
| | | /// 超时最大时间
|
| | | /// </summary>
|
| | | private int topMaxTime = 120;
|
| | | /// <summary>
|
| | | /// 画面ID,标记它由哪个界面调用并打开的
|
| | | /// </summary>
|
| | |
| | | /// 网关ID
|
| | | /// </summary>
|
| | | private string gatewayId = string.Empty;
|
| | | /// <summary>
|
| | | /// 真实网关
|
| | | /// </summary>
|
| | | private ZbGateway realGateway = null;
|
| | | /// <summary>
|
| | | /// 进度条
|
| | | /// </summary>
|
| | |
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_formId">画面ID,标记它由哪个界面调用并打开的</param> |
| | | public void ShowForm(string i_formId) |
| | | { |
| | | this.targetFormId = i_formId; |
| | | |
| | | //设置标题信息 |
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice)); |
| | | |
| | | this.gatewayId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway); |
| | | |
| | | //初始化中部控件 |
| | | this.InitMiddleFrame(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化中部控件 |
| | | /// </summary> |
| | | private void InitMiddleFrame() |
| | | /// <param name="i_formId">画面ID,标记它由哪个界面调用并打开的</param>
|
| | | public void ShowForm(string i_formId)
|
| | | {
|
| | | this.targetFormId = i_formId;
|
| | |
|
| | | //设置标题信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice));
|
| | |
|
| | | this.gatewayId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
|
| | | HdlGatewayLogic.Current.GetRealGateway(ref this.realGateway, this.gatewayId);
|
| | |
|
| | | //初始化中部控件
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部控件
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
| | | bodyFrameLayout.AddChidren(btnSearch);
|
| | |
|
| | | //进度条
|
| | | var btnProRow = new FrameLayout(); |
| | | btnProRow.Gravity = Gravity.CenterHorizontal; |
| | | btnProRow.Y = Application.GetRealHeight(861); |
| | | btnProRow.Width = Application.GetRealWidth(559); |
| | | btnProRow.Height = Application.GetRealHeight(29); |
| | | var btnProRow = new FrameLayout();
|
| | | btnProRow.Gravity = Gravity.CenterHorizontal;
|
| | | btnProRow.Y = Application.GetRealHeight(861);
|
| | | btnProRow.Width = Application.GetRealWidth(559);
|
| | | btnProRow.Height = Application.GetRealHeight(29);
|
| | | btnProRow.BackgroundColor = 0xffe6e6e6;
|
| | | btnProRow.Radius = (uint)Application.GetRealHeight(29) / 2;
|
| | | bodyFrameLayout.AddChidren(btnProRow); |
| | | this.btnProgressBar = new FrameLayout(); |
| | | btnProgressBar.Width = 0; |
| | | btnProgressBar.Height = btnProRow.Height; |
| | | bodyFrameLayout.AddChidren(btnProRow);
|
| | | this.btnProgressBar = new FrameLayout();
|
| | | btnProgressBar.Width = 0;
|
| | | btnProgressBar.Height = btnProRow.Height;
|
| | | btnProgressBar.Radius = btnProRow.Radius;
|
| | | btnProgressBar.BackgroundColor = 0xfffb744a;
|
| | | btnProgressBar.Radius = (uint)Application.GetRealHeight(29) / 2;
|
| | |
| | | btnProgressView.Text = "0%";
|
| | | frameProgress.AddChidren(btnProgressView);
|
| | |
|
| | | new System.Threading.Thread(() =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //蓝才刚说有时候网关会收不到入网的命令,所以发三次
|
| | | for (int i = 0; i < 3; i++)
|
| | |
| | | return;
|
| | | }
|
| | | //让网关允许入网
|
| | | GatewayResourse.NowSelectGateway.AddNewDeviceToGateway(255);
|
| | | this.realGateway.AddNewDeviceToGateway(180);
|
| | | System.Threading.Thread.Sleep(1000);
|
| | | }
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | });
|
| | |
|
| | | //添加监视设备新上报的事件
|
| | | GatewayResourse.NowSelectGateway.GwResDataAction += this.AdjustGatewayResultData; |
| | | //开启连接的假想动画效果线程 |
| | | this.StartConcetionAnimeteThread(); |
| | | this.realGateway.GwResDataAction += this.AdjustGatewayResultData;
|
| | | //开启连接的假想动画效果线程
|
| | | this.StartConcetionAnimeteThread();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | if (result == -1)
|
| | | {
|
| | | //停止接收
|
| | | GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData;
|
| | | this.realGateway.GwResDataAction -= this.AdjustGatewayResultData;
|
| | |
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | |
| | |
|
| | | //给新设备设置主键属性
|
| | | 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);
|
| | |
|
| | |
| | | }
|
| | | this.isDeviceThreadStart = true;
|
| | |
|
| | | new System.Threading.Thread(() =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | while (this.waitDeviceTimeOut >= 0)
|
| | | {
|
| | |
| | | this.waitDeviceTimeOut--;
|
| | | }
|
| | | //停止接收
|
| | | GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData;
|
| | | this.realGateway.GwResDataAction -= this.AdjustGatewayResultData;
|
| | | System.Threading.Thread.Sleep(500);
|
| | |
|
| | | //目前就弄一个
|
| | |
| | | break;
|
| | | }
|
| | | });
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | btnRound.Y = Application.GetMinRealAverage(475);
|
| | | bodyFrameLayout.AddChidren(btnRound);
|
| | |
|
| | | new System.Threading.Thread(() =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | int index = 1;
|
| | | int timeCount = 0;
|
| | | while (this.Parent != null)
|
| | | {
|
| | | System.Threading.Thread.Sleep(500);
|
| | | timeCount++;
|
| | | if (timeCount >= 240)
|
| | | {
|
| | | //120秒后,再次发送网关设备入网命令
|
| | | this.realGateway.AddNewDeviceToGateway(180);
|
| | | timeCount = 0;
|
| | | }
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | if (btnRound != null)
|
| | |
| | | }
|
| | | });
|
| | | }
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | {
|
| | | if (topic == gatewayId + "/Device/DeviceAnnounce_Respon")
|
| | | {
|
| | | this.topTimeOut = 60;
|
| | | this.topTimeOut = topMaxTime;
|
| | | //网关告知客户端有设备声明
|
| | | this.SetDeviceProgressValue(1);
|
| | | return 2;
|
| | |
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | {
|
| | | //出现未知错误,请重新入网
|
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | //进度条
|
| | | 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;
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | return;
|
| | | }
|
| | | this.isTopicTimeOutThreadStart = true;
|
| | | new System.Threading.Thread(() =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | while (this.Parent != null && this.topTimeOut >= 0)
|
| | | {
|
| | |
| | | this.CloseForm();
|
| | | });
|
| | | }
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | |
|
| | | /// <summary>
|
| | | /// 画面关闭
|
| | | /// </summary> |
| | | public override void CloseForm() |
| | | { |
| | | base.CloseForm();
|
| | | /// </summary>
|
| | | public override void CloseFormBefore()
|
| | | {
|
| | | //停止接收
|
| | | GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData;
|
| | | this.realGateway.GwResDataAction -= this.AdjustGatewayResultData;
|
| | |
|
| | | new System.Threading.Thread(() =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | System.Threading.Thread.Sleep(1200);
|
| | | //关闭入网模式
|
| | | GatewayResourse.NowSelectGateway.AddNewDeviceToGateway(0);
|
| | | })
|
| | | { IsBackground = true }.Start(); |
| | | this.realGateway.AddNewDeviceToGateway(0);
|
| | | });
|
| | | base.CloseFormBefore();
|
| | | }
|
| | |
|
| | | #endregion
|