| | |
| | | /// </summary>
|
| | | private ZbGateway realGateway = null;
|
| | | /// <summary>
|
| | | /// 进度条
|
| | | /// 进度条控件
|
| | | /// </summary>
|
| | | private FrameLayout btnProgressBar = null;
|
| | | /// <summary>
|
| | | /// 进度值显示文本的整体
|
| | | /// </summary>
|
| | | private FrameLayout frameProgress = null;
|
| | | /// <summary>
|
| | | /// 进度值的显示文本
|
| | | /// </summary>
|
| | | private NormalViewControl btnProgressView = null;
|
| | | private ProgressRowBar btnProgressBar = null;
|
| | | /// <summary>
|
| | | /// 网关是否允许入网的标识
|
| | | /// </summary>
|
| | |
| | | //设置标题信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice));
|
| | |
|
| | | this.gatewayId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
|
| | | this.gatewayId = GatewayResourse.NowSelectGatewayId;
|
| | | HdlGatewayLogic.Current.GetRealGateway(ref this.realGateway, this.gatewayId);
|
| | |
|
| | | //初始化中部控件
|
| | |
| | | this.ClearBodyFrame();
|
| | |
|
| | | //图片
|
| | | var btnPic = new PicViewControl(878, 478);
|
| | | btnPic.Y = Application.GetMinRealAverage(251);
|
| | | btnPic.Gravity = Gravity.CenterHorizontal;
|
| | | btnPic.UnSelectedImagePath = "Instruct/DeviceSearch.png";
|
| | | bodyFrameLayout.AddChidren(btnPic);
|
| | | var framePic = new FrameLayout();
|
| | | framePic.Width = this.GetPictrueRealSize(878);
|
| | | framePic.Height = this.GetPictrueRealSize(478);
|
| | | framePic.Y = Application.GetRealHeight(251);
|
| | | framePic.Gravity = Gravity.CenterHorizontal;
|
| | | framePic.BackgroundImagePath = "Instruct/DeviceSearch.png";
|
| | | bodyFrameLayout.AddChidren(framePic);
|
| | |
|
| | | //正在搜索设备,请稍候…
|
| | | var btnSearch = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(58), false);
|
| | |
| | | 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);
|
| | | btnProRow.BackgroundColor = 0xffe6e6e6;
|
| | | btnProRow.Radius = (uint)Application.GetRealHeight(29) / 2;
|
| | | bodyFrameLayout.AddChidren(btnProRow);
|
| | | this.btnProgressBar = new FrameLayout();
|
| | | btnProgressBar.Width = 0;
|
| | | btnProgressBar.Height = btnProRow.Height;
|
| | | btnProgressBar.BackgroundColor = 0xfffb744a;
|
| | | btnProgressBar.Radius = (uint)Application.GetRealHeight(29) / 2;
|
| | | btnProRow.AddChidren(btnProgressBar);
|
| | | this.btnProgressBar = new ProgressRowBar(559, 29);
|
| | | btnProgressBar.Gravity = Gravity.CenterHorizontal;
|
| | | btnProgressBar.Y = Application.GetRealHeight(861);
|
| | | bodyFrameLayout.AddChidren(btnProgressBar);
|
| | | btnProgressBar.StartMode1(true);
|
| | |
|
| | | //进度值文本
|
| | | this.frameProgress = new FrameLayout();
|
| | | frameProgress.Width = Application.GetRealWidth(84);
|
| | | frameProgress.Height = Application.GetRealHeight(60);
|
| | | frameProgress.Y = Application.GetRealHeight(772);
|
| | | bodyFrameLayout.AddChidren(frameProgress);
|
| | | frameProgress.X = btnProRow.X + btnProgressBar.Right - frameProgress.Width / 2;
|
| | | var btnProgressPic = new PicViewControl(84, 60);
|
| | | btnProgressPic.UnSelectedImagePath = "Item/ProgressMsg.png";
|
| | | frameProgress.AddChidren(btnProgressPic);
|
| | | this.btnProgressView = new NormalViewControl(84, 32, true);
|
| | | btnProgressView.TextSize = 10;
|
| | | btnProgressView.TextAlignment = TextAlignment.Center;
|
| | | btnProgressView.Text = "0%";
|
| | | frameProgress.AddChidren(btnProgressView);
|
| | |
|
| | | //允许设备入网
|
| | | this.StartDeviceCanAddToGateway(false);
|
| | |
|
| | | //添加监视设备新上报的事件
|
| | | this.realGateway.GwResDataAction += this.AdjustGatewayResultData;
|
| | | if (this.realGateway != null)
|
| | | {
|
| | | //允许设备入网
|
| | | this.StartDeviceCanAddToGateway(false);
|
| | | //添加监视设备新上报的事件
|
| | | this.realGateway.GwResDataAction += this.AdjustGatewayResultData;
|
| | | }
|
| | | //开启连接的假想动画效果线程
|
| | | this.StartConcetionAnimeteThread();
|
| | | this.StartConcetionAnimeteThread(framePic);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | |
|
| | | //给新设备设置主键属性
|
| | | Common.LocalDevice.Current.SetNewDeviceMainKeys(device, jobject);
|
| | | device.CurrentGateWayId = HdlGatewayLogic.Current.GetGatewayId(this.realGateway);
|
| | | device.CurrentGateWayId = this.realGateway.GwId;
|
| | | //将DeviceInfo的属性设置到主属性中
|
| | | Common.LocalDevice.Current.SetDeviceInfoToMain(device, device);
|
| | |
|
| | |
| | | /// <summary>
|
| | | /// 开启连接的假想动画效果线程
|
| | | /// </summary>
|
| | | private void StartConcetionAnimeteThread()
|
| | | private void StartConcetionAnimeteThread(FrameLayout framePic)
|
| | | {
|
| | | int iconSize = Application.GetMinRealAverage(23);
|
| | | int iconSize = this.GetPictrueRealSize(23);
|
| | |
|
| | | var listPoint = new List<int>();
|
| | | for (int i = 0; i < 9; i++)
|
| | | {
|
| | | //X轴+Index*(图标大小+间距)
|
| | | listPoint.Add(Application.GetMinRealAverage(394) + i * (iconSize + Application.GetMinRealAverage(10)));
|
| | | listPoint.Add(this.GetPictrueRealSize(300) + i * (iconSize + this.GetPictrueRealSize(10)));
|
| | | }
|
| | |
|
| | | var btnRound = new PicViewControl(iconSize, iconSize, false);
|
| | | btnRound.Radius = (uint)iconSize / 2;
|
| | | btnRound.BackgroundColor = UserCenterColor.Current.ConcetionRoundColor;
|
| | | btnRound.X = listPoint[0];
|
| | | btnRound.Y = Application.GetMinRealAverage(475);
|
| | | bodyFrameLayout.AddChidren(btnRound);
|
| | | btnRound.Y = this.GetPictrueRealSize(225);
|
| | | framePic.AddChidren(btnRound);
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | |
| | | return 0;
|
| | | }
|
| | | //网关告知客户端有设备声明
|
| | | this.SetDeviceProgressValue(1);
|
| | | this.btnProgressBar.SetValue(1, 6);
|
| | | return 2;
|
| | | }
|
| | | else if (topic == gatewayId + "/Device/DeviceGetActiveEP_Respon")
|
| | |
| | | return 2;
|
| | | }
|
| | | //设置进度值
|
| | | this.SetDeviceProgressValue(2);
|
| | | this.btnProgressBar.SetValue(2, 6);
|
| | | return 2;
|
| | | }
|
| | | else if (topic == gatewayId + "/Device/DeviceGetActiveEPSimpleDesc_Respon")
|
| | |
| | | return 2;
|
| | | }
|
| | | //设置进度值
|
| | | this.SetDeviceProgressValue(3);
|
| | | this.btnProgressBar.SetValue(3, 6);
|
| | | return 2;
|
| | | }
|
| | | else if (topic == gatewayId + "/Device/DeviceGetDefaultBind_Respon")
|
| | |
| | | return 2;
|
| | | }
|
| | | //设置进度值
|
| | | this.SetDeviceProgressValue(4);
|
| | | this.btnProgressBar.SetValue(4, 6);
|
| | | return 2;
|
| | | }
|
| | | else if (topic == gatewayId + "/Device/DeviceAutoBindZBCoord_Respon")
|
| | |
| | | return 2;
|
| | | }
|
| | | //设置进度值
|
| | | this.SetDeviceProgressValue(5);
|
| | | this.btnProgressBar.SetValue(5, 6);
|
| | | return 2;
|
| | | }
|
| | | else if (topic == gatewayId + "/DeviceInComingRespon")
|
| | | {
|
| | | this.topTimeOut = topMaxTime;
|
| | | //网关最终上报节点设备信息
|
| | | this.SetDeviceProgressValue(6);
|
| | | this.btnProgressBar.SetValue(6, 6);
|
| | | return 1;
|
| | | }
|
| | | return 0;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置设备的进度值
|
| | | /// </summary>
|
| | | /// <param name="value"></param>
|
| | | private void SetDeviceProgressValue(decimal value)
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //进度条
|
| | | 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 = Application.GetRealWidth(262) + btnProgressBar.Right - frameProgress.Width / 2;
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// </summary>
|
| | | public override void CloseFormBefore()
|
| | | {
|
| | | //停止接收
|
| | | this.realGateway.GwResDataAction -= this.AdjustGatewayResultData;
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | if (this.realGateway != null)
|
| | | {
|
| | | System.Threading.Thread.Sleep(1200);
|
| | | //关闭入网模式
|
| | | this.realGateway.AddNewDeviceToGateway(0);
|
| | | });
|
| | | //停止接收
|
| | | this.realGateway.GwResDataAction -= this.AdjustGatewayResultData;
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | System.Threading.Thread.Sleep(1200);
|
| | | //关闭入网模式
|
| | | this.realGateway.AddNewDeviceToGateway(0);
|
| | | });
|
| | | }
|
| | | base.CloseFormBefore();
|
| | | }
|
| | |
|