| | |
| | | myLoading.Hide (); |
| | | btnCloseLoading.RemoveFromParent (); |
| | | WirelessConfig (new byte [] { 1 });//close |
| | | //2020-07-02 关闭自动搜索线程 |
| | | StopSearchDeviceThead (); |
| | | if (needRefresh) { |
| | | needRefresh = false; |
| | | SearchDeviceList (); |
| | |
| | | curView = null; |
| | | addedCommon.Clear (); |
| | | BackgroundColor = SkinStyle.Current.MainColor; |
| | | //StopSearchDeviceThead (); |
| | | base.RemoveFromParent (); |
| | | } |
| | | |
| | |
| | | }; |
| | | |
| | | var btnSearch = new Button () { |
| | | Width = Application.GetRealWidth (75), |
| | | Height = Application.GetRealHeight (75), |
| | | Width = Application.GetMinRealAverage (75), |
| | | Height = Application.GetMinRealAverage (75), |
| | | X = Application.GetRealWidth (520), |
| | | Y = Application.GetRealHeight (10), |
| | | UnSelectedImagePath = "Item/Refresh.png", |
| | |
| | | //myLoading.Start ("Waiting for new device, Please touch the here to exit the waiting mode."); |
| | | |
| | | this.AddChidren (btnCloseLoading); |
| | | |
| | | //2020-07-02 网关配频模式时,开启自动搜索线程 |
| | | StartSearchDeviceThead (); |
| | | } |
| | | }); |
| | | }); |
| | |
| | | |
| | | } |
| | | |
| | | #region 2020-07-02 |
| | | /// <summary> |
| | | /// 定时搜索设备线程 |
| | | /// </summary> |
| | | Thread searchDeviceThead; |
| | | bool bStartSearch; |
| | | |
| | | /// <summary> |
| | | /// 2020-07-02 |
| | | /// 网关配频模式时,开启自动搜索线程 |
| | | /// </summary> |
| | | void StartSearchDeviceThead () |
| | | { |
| | | StopSearchDeviceThead (); |
| | | CommonPage.LocalPhoneFindDevice = true; |
| | | CommonPage.FindGatewayChilren = true; |
| | | CommonPage.RandomHigh = (byte)new Random ().Next (255); |
| | | CommonPage.RandomLow = (byte)new Random ().Next (255); |
| | | |
| | | bStartSearch = true; |
| | | searchDeviceThead = new Thread ((obj) => { |
| | | while (bStartSearch) { |
| | | try { |
| | | //定时4S |
| | | Thread.Sleep (4000); |
| | | |
| | | var ms = new System.IO.MemoryStream (); |
| | | ms.WriteByte (CommonPage.RandomHigh); |
| | | ms.WriteByte (CommonPage.RandomLow); |
| | | |
| | | var list = CommonPage.DeviceList; |
| | | int tempCount = list.Count; |
| | | string s = ";"; |
| | | for (int i = 0; i < list.Count; i++) { |
| | | Common common = list [i]; |
| | | if (common.SubnetID != gatewayDeicve.SubnetID) |
| | | continue; |
| | | if (s.Contains (";" + common.SubnetID.ToString () + ":" + common.DeviceID.ToString ())) |
| | | continue; |
| | | s += common.SubnetID.ToString () + ":" + common.DeviceID.ToString () + ";"; |
| | | ms.WriteByte (common.SubnetID); |
| | | ms.WriteByte (common.DeviceID); |
| | | } |
| | | Utlis.WriteLine ("SearchDeviceThead搜索非网关设备,网络地址是:" + CommonPage.EndPoint.ToString ()); |
| | | var control = new Control (); |
| | | control.Send (new Target () { |
| | | IPEndPoint = CommonPage.EndPoint, |
| | | Command = Command.ReadDeviceModul, |
| | | SubnetID = gatewayDeicve.SubnetID, |
| | | DeviceID = 0xFF, |
| | | AddData = ms.ToArray () |
| | | }, SendCount.Zero, false); |
| | | |
| | | ms.Close (); |
| | | |
| | | } catch { |
| | | |
| | | } |
| | | } |
| | | }); |
| | | searchDeviceThead.Start (); |
| | | |
| | | |
| | | Utlis.WriteLine ("----StartSearchDeviceThead----"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 暂停搜索设备线程 |
| | | /// </summary> |
| | | void StopSearchDeviceThead () |
| | | { |
| | | CommonPage.LocalPhoneFindDevice = false; |
| | | CommonPage.FindGatewayChilren = false; |
| | | bStartSearch = false; |
| | | if (searchDeviceThead != null) |
| | | searchDeviceThead.Abort (); |
| | | |
| | | Utlis.WriteLine ("----StopSearchDeviceThead----"); |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | ///// <summary> |
| | | ///// 查询当前住宅 网关列表 |
| | | ///// </summary> |
| | |
| | | // //Room.InitAllRoom (); |
| | | //} |
| | | |
| | | |
| | | |
| | | |
| | | ///// <summary> |
| | | ///// 修改URL |