From 20f70e3446df19bf5d0faaae9f7bd58fd0fc4bcc Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期五, 04 八月 2023 12:06:51 +0800 Subject: [PATCH] 轮询备份 --- Crabtree/SmartHome/UI/SimpleControl/MainPage.cs | 64 ++++++++++++++++++++++++++++---- 1 files changed, 56 insertions(+), 8 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs b/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs index ad140ac..5b30b6e 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs @@ -35,11 +35,15 @@ } return loading; } - } + } //public static Button LogoButton = new Button (); - public static string CodeIDString = "20191223"; + public static string CodeIDString = "20230726"; + /// <summary> + /// 缃戝叧鐘舵�� + /// </summary> + public static string GatewayStatus = ""; public static UserInfo LoginUser; @@ -84,6 +88,11 @@ } } + + public static System.Threading.Thread staticReadDeviceStatusThread; + public static bool readDevciesStatus = false; + + /// <summary> /// 鏄剧ず褰撳墠鐣岄潰 /// </summary> @@ -108,12 +117,52 @@ //Pad.UserHomePage.Init (); } else { Phone.UserHomePage.Init (); -#if __IOS__ - //Loading.LodingBackgroundColor = 0x10777777; -#else + //#if __IOS__ + // //Loading.LodingBackgroundColor = 0x10777777; + //#else + // Loading.LodingBackgroundColor = SkinStyle.Current.MainColor; + //#endif + + Loading.TextColor = 0xFFA9A9A9; Loading.LodingBackgroundColor = SkinStyle.Current.MainColor; -#endif } + + staticReadDeviceStatusThread = new System.Threading.Thread (() => { + while (true) { + System.Threading.Thread.Sleep (1000); + if (readDevciesStatus) { + try { + var readList = new List<string> (); + foreach (Room room in Room.Lists) { + if (string.IsNullOrEmpty (room.Name)) { + continue; + } + var list = room.DeviceList.FindAll ((obj) => { + return (obj.Type == DeviceType.LightDimming || obj.Type == DeviceType.LightSwitch || obj.Type == DeviceType.LightLogic + || obj.Type == DeviceType.LightSwitchSocket || obj.Type == DeviceType.LightEnergySwitch || obj.Type == DeviceType.LightEnergySocket + || obj.Type == DeviceType.LightMixDimming || obj.Type == DeviceType.LightMixSwitch || obj.Type == DeviceType.FanModule); + }); + foreach (Common common in list) { + var s = common.Type + "_" + common.SubnetID + "_" + common.DeviceID; + //宸茬粡璇诲彇杩囧綋鍓嶈澶囧氨涓嶅啀璇诲彇 + if (readList.Contains (s)) { + continue; + } + readList.Add (s); + Control.ControlBytesSend (Command.ReadLightEquipmentAllLoopBrightness, common.SubnetID, common.DeviceID, new byte [] { }, SendCount.Zero); + System.Threading.Thread.Sleep (1000); + } + } + readList.Clear (); + } catch { } finally { + } + } + } + }); + staticReadDeviceStatusThread.IsBackground = true; + staticReadDeviceStatusThread.Start (); + + } catch (Exception ex) { //new Alert ("Eorr", ex.Message, "Close").Show(); } @@ -192,8 +241,7 @@ #region var webClient = new WebClient (); if (urlHead == "") { - urlHead = $"{"https://homeautomation.havells.com"}/WebApi/"; - urlHead = "https://developer.hdlcontrol.com/api/"; + urlHead = "https://homeautomation.havells.com/WebApi/"; } else { webClient.Headers.Add ("CONTENT-TYPE", "application/json"); } -- Gitblit v1.8.0