From 85c694b11e858e322d1bd7935e997fa372b3302c Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期三, 31 八月 2022 13:57:47 +0800 Subject: [PATCH] 场景控制增加延时 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs | 99 ++++++++++++++++++++++++++++++++++++------------- 1 files changed, 73 insertions(+), 26 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs index aaf6234..90e9c7c 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs @@ -18,8 +18,11 @@ /// </summary> private bool finish = false; +#if DEBUG + private string SeverAddr = "https://test-gz.hdlcontrol.com"; +#else private string SeverAddr = "https://bahrain-gateway.hdlcontrol.com"; - //private string SeverAddr = "https://test-gz.hdlcontrol.com"; +#endif FrameLayout contentView; @@ -35,11 +38,27 @@ Button btnSave; Button btnClose; + Alert sssAlert = new Alert ("", "Please press the PROG button on Gateway for 3 sec.", "Confirm"); + Action tipLockedAction; + + bool showedLockedTip = false; public MigrationServer () { - loading = new Loading (); + loading = new Loading (); + tipLockedAction = () => { + Application.RunOnMainThread (() => { + if (!showedLockedTip) { + sssAlert.Show (); + showedLockedTip = true; + sssAlert.ResultEventHandler += (sd, dd) => { + showedLockedTip = false; + }; + } + }); + }; + Packet.lockedAction = tipLockedAction; } @@ -47,7 +66,7 @@ public void ShowDialog() { - #region 寮圭獥 +#region 寮圭獥 Dialog dialog = new Dialog (); FrameLayout dialogBodyView = new FrameLayout () { @@ -135,6 +154,8 @@ bottomView.AddChidren (btnClose); btnClose.MouseUpEventHandler += (send2er, e2) => { dialog.Close (); + Packet.lockedAction = null; + }; Button btnBottomLine = new Button () { @@ -158,19 +179,18 @@ btnSave.MouseUpEventHandler += (sender2, e2) => { if (finish) { dialog.Close (); + Packet.lockedAction = null; return; } #if DEBUG - //SetGateWayMqttUrlAddress (1, 0); - //WriteSecretKey (1, 0, new byte [] {1,1,2,3,2,3,4,5,2,3,5,6 }); - //CheckGateway (); + + //var moveAccontResult = Account2New ("12345678"); //var newHomeId = Home2New (); - //if (newHomeId == "") { } else { } - //Account2New (etPwd.Text.Trim()); - //return; + ////杩佺Щ缃戝叧 + //var moveGatewayResult = Gateway2New ("4D59383553502243", newHomeId, 0); #endif if (etPwd.Text.Trim() == "") { @@ -218,6 +238,7 @@ etPwd.Visible = false; btnSave.MouseUpEventHandler = (sender2, e2) => { dialog.Close (); + Packet.lockedAction = null; }; } else { @@ -231,13 +252,13 @@ //3.鎺ユ敹鍗囩骇鏂囦欢鑾峰彇璇锋眰 //杩佺Щ璐﹀彿 - #endregion +#endregion } - #region 浜戠 +#region 浜戠 /// <summary> /// 璐﹀彿鐧诲綍楠岃瘉 /// </summary> @@ -508,7 +529,7 @@ - #endregion +#endregion /// <summary> /// 妫�娴嬩竴绔彛淇℃伅 @@ -542,6 +563,9 @@ gateWayString = CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (gatewayFileName)); common = Newtonsoft.Json.JsonConvert.DeserializeObject<GatewayBase> (gateWayString); + //bool + CommonPage.IsRemote = false; + Control.ControlBytesSendHasReturn (Command.ReadGateway, common.SubnetID, common.DeviceID, new byte [] { CommonPage.RandomHigh, CommonPage.RandomLow }); var bytes = Control.ControlBytesSendHasReturn (Command.readGatewayVision, common.SubnetID, common.DeviceID, new byte [] { }); if(bytes == null) { @@ -567,18 +591,18 @@ btnTipMsg.TextColor = SkinStyle.Current.TextColor; }); result = 100; - } else if (!visionString.Contains ("Ind_V02.35U_2019/06/25")) {//鐩墠鍙厑璁稿崌绾ц繖涓浐浠剁殑缃戝叧 - Application.RunOnMainThread (() => { - btnTipTitle.Text = "The gateway does not support automatic migration. Please contact technical support."; - btnTipTitle.Height = Application.GetRealHeight (150); - btnTipTitle.TextColor = SkinStyle.Current.DelColor; - btnTipMsg.Text = ""; - etPwd.Visible = false; - loading.Hide (); - btnSave.Visible = false; - btnClose.Width = Application.GetRealWidth (500); - }); - return; + //} else if (!visionString.Contains ("Ind_V02.35U_2019/06/25")) {//鐩墠鍙厑璁稿崌绾ц繖涓浐浠剁殑缃戝叧 + // Application.RunOnMainThread (() => { + // btnTipTitle.Text = "The gateway does not support automatic migration. Please contact technical support."; + // btnTipTitle.Height = Application.GetRealHeight (150); + // btnTipTitle.TextColor = SkinStyle.Current.DelColor; + // btnTipMsg.Text = ""; + // etPwd.Visible = false; + // loading.Hide (); + // btnSave.Visible = false; + // btnClose.Width = Application.GetRealWidth (500); + // }); + // return; } else { Application.RunOnMainThread (() => { btnTipMsg.Text = "Upgrading gateway."; @@ -638,8 +662,9 @@ } } } - - + //閲嶆柊璁剧疆涓�涓嬪瓙缃戝彿 + SetSubnetId (common); + System.Threading.Thread.Sleep (1000); if (result == 100) { @@ -933,6 +958,28 @@ } /// <summary> + /// 璁剧疆瀛愮綉鍙� + /// </summary> + /// <param name="gatewayDevice"></param> + private void SetSubnetId (GatewayBase gatewayDevice) + { + string [] macAddress = gatewayDevice.MAC.Split ('.'); + byte [] Musics = new byte [10]; + for (int i = 0; i < macAddress.Length; i++) { + Musics [i] = Convert.ToByte (macAddress [i], 16); + } + try { + Musics [8] = Convert.ToByte (Convert.ToInt32 (gatewayDevice.SubnetID)); + if (Musics [8] < 0 || Musics [8] > 255) { + throw new Exception (); + } + } catch { + return; + } + Control.ControlBytesSend (Command.SetDeviceSubnetID, gatewayDevice.SubnetID, gatewayDevice.DeviceID, Musics); + } + + /// <summary> /// 璁惧缃戝叧寮�鍚繙绋� /// </summary> private bool SetGatewayRemote(byte subnetId, byte deviceId) -- Gitblit v1.8.0