From 9a0b765c583bd69929de3a7495138b3e878e4543 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 05 九月 2023 16:14:27 +0800
Subject: [PATCH] 0-10v更新,网关在线状态更新

---
 HDL-ON_Android/Properties/AndroidManifest.xml                   |    2 
 HDL_ON/UI/UI2/1-HomePage/HomePage.cs                            |   84 +---
 HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs            |  208 +++++++----
 HDL-ON_iOS/HDL-ON_iOS.csproj                                    |    1 
 HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs               |    8 
 HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs         |  120 ++++--
 HDL_ON/DAL/Mqtt/MqttClient.cs                                   |    2 
 HDL-ON_Android/HDL-ON_Android.csproj                            |    1 
 HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs                         |   18 
 HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs                   |   82 ++++
 HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs  |  165 ++++++---
 HDL_ON/Entity/Function/Function.cs                              |    5 
 HDL-ON_iOS/Resources/Phone/Collection/GatewayOnlineTipIcon.png  |    0 
 HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs   |    3 
 HDL_ON/UI/UI2/FuntionControlView/Light/RGBWPageBLL.cs           |  172 ++++++---
 HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs  |   14 
 HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs               |   74 ++++
 HDL_ON/DAL/DriverLayer/Control.cs                               |   30 +
 HDL_ON/UI/MainPage.cs                                           |    2 
 HDL_ON/UI/UI1-Login/LoginPage.cs                                |    2 
 HDL-ON_Android/Assets/Phone/Collection/GatewayOnlineTipIcon.png |    0 
 21 files changed, 665 insertions(+), 328 deletions(-)

diff --git a/HDL-ON_Android/Assets/Phone/Collection/GatewayOnlineTipIcon.png b/HDL-ON_Android/Assets/Phone/Collection/GatewayOnlineTipIcon.png
new file mode 100644
index 0000000..ecfcb33
--- /dev/null
+++ b/HDL-ON_Android/Assets/Phone/Collection/GatewayOnlineTipIcon.png
Binary files differ
diff --git a/HDL-ON_Android/HDL-ON_Android.csproj b/HDL-ON_Android/HDL-ON_Android.csproj
index 4b32131..a3ffafd 100644
--- a/HDL-ON_Android/HDL-ON_Android.csproj
+++ b/HDL-ON_Android/HDL-ON_Android.csproj
@@ -457,6 +457,7 @@
     <AndroidAsset Include="Assets\h5\static\img\equal-plant-ic.7ef6befa.png" />
     <AndroidAsset Include="Assets\h5\static\img\coal-save-ic.6c5fd125.png" />
     <AndroidAsset Include="Assets\h5\static\font\SourceHanSansCN-Normal.otf" />
+    <AndroidAsset Include="Assets\Phone\Collection\GatewayOnlineTipIcon.png" />
   </ItemGroup>
   <ItemGroup>
     <AndroidResource Include="Resources\values\colors.xml" />
diff --git a/HDL-ON_Android/Properties/AndroidManifest.xml b/HDL-ON_Android/Properties/AndroidManifest.xml
index eac25b1..340f490 100644
--- a/HDL-ON_Android/Properties/AndroidManifest.xml
+++ b/HDL-ON_Android/Properties/AndroidManifest.xml
@@ -1,5 +1,5 @@
 锘�<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.1.2" package="com.hdl.onpro" xmlns:tools="http://schemas.android.com/tools" android:versionCode="202308171">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.1.2" package="com.hdl.onpro" xmlns:tools="http://schemas.android.com/tools" android:versionCode="202308281">
 	<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="29" />
 	<uses-permission android:name="android.permission.RECEIVE_SMS" />
 	<!--鍙嬬洘-->
diff --git a/HDL-ON_iOS/HDL-ON_iOS.csproj b/HDL-ON_iOS/HDL-ON_iOS.csproj
index 1088494..6386747 100644
--- a/HDL-ON_iOS/HDL-ON_iOS.csproj
+++ b/HDL-ON_iOS/HDL-ON_iOS.csproj
@@ -1611,6 +1611,7 @@
       <BundleResource Include="Resources\h5\static\img\equal-plant-ic.7ef6befa.png" />
       <BundleResource Include="Resources\h5\static\img\coal-save-ic.6c5fd125.png" />
       <BundleResource Include="Resources\h5\static\font\SourceHanSansCN-Normal.otf" />
+      <BundleResource Include="Resources\Phone\Collection\GatewayOnlineTipIcon.png" />
     </ItemGroup>
     <ItemGroup>
       <ITunesArtwork Include="iTunesArtwork" />
diff --git a/HDL-ON_iOS/Resources/Phone/Collection/GatewayOnlineTipIcon.png b/HDL-ON_iOS/Resources/Phone/Collection/GatewayOnlineTipIcon.png
new file mode 100644
index 0000000..ecfcb33
--- /dev/null
+++ b/HDL-ON_iOS/Resources/Phone/Collection/GatewayOnlineTipIcon.png
Binary files differ
diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 85737d2..6955fab 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -732,8 +732,18 @@
                 }
                 else
                 {
-                    var pm = new DAL.Server.HttpServerRequest();
-                    var pack = pm.RefreshDeviceStatus(new List<string>() { function.deviceId });
+                    var pm = new HttpServerRequest();
+                    try
+                    {
+                        pm.RefreshDeviceStatus(new List<string>() { function.deviceId });
+                    }catch(Exception ex)
+                    {
+                        MainPage.Log($"杩滅▼璇诲彇璁惧鐘舵�佸紓甯�:{ex.Message}");
+                    }
+                    finally
+                    {
+                        pm = null;
+                    }
                 }
             }
         }
@@ -1312,16 +1322,6 @@
                         }
                         MainPage.Log(localFunction.name);
 
-                        if (Ins.GatewayOnline_Local && isCloudData)//鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�
-                        {
-                            if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(localFunction.spk) && !SPK.MusicSpkList().Contains(localFunction.spk))
-                            {
-                                //MainPage.Log($"A鍗忚鏇存柊鐘舵��:鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�........");
-
-                                return;
-                            }
-                        }
-
                         //if (SPK.MusicSpkList().Contains(localFunction.spk))
                         //{
                         //    if (updateTemp.status.Count < 3)
@@ -1342,6 +1342,11 @@
                         {
                             localFunction.online = updateTemp.online;
                         }
+                        if (SPK.LightSpkList().Contains(localFunction.spk))
+                        {
+                            localFunction.updateTime = DateTime.Now;
+                        }
+                       
 
                         //鏇存柊鐣岄潰鐘舵��
                         switch (localFunction.spk)
@@ -1606,6 +1611,7 @@
                                 break;
                         }
 
+                        
                         HomePage.UpdataFunctionStates(localFunction);
                         RoomPage.UpdataStates(localFunction);
                         FunctionPage.UpdataStates(localFunction);
diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs
index 3b1d20a..9c11563 100644
--- a/HDL_ON/DAL/Mqtt/MqttClient.cs
+++ b/HDL_ON/DAL/Mqtt/MqttClient.cs
@@ -553,7 +553,7 @@
                                 {
                                     var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey);
                                     var revString = Encoding.UTF8.GetString(bytes);
-                                    MainPage.Log($"mqtt 鐘舵�佹洿鏂�:{revString}");
+                                    //MainPage.Log($"mqtt 鐘舵�佹洿鏂�:{revString}");
                                     Control.Ins.UpdataFunctionStatus(revString, null, true);
                                     //Control.Ins.MsgInfoList.Add($"mqtt 鐘舵�佹洿鏂�:{revString}");
                                     //Control.Ins.MsgInfoList.Add(revString + "\r\n");
diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs
index 53702aa..711418f 100644
--- a/HDL_ON/Entity/Function/Function.cs
+++ b/HDL_ON/Entity/Function/Function.cs
@@ -1017,6 +1017,11 @@
         /// 鏇存柊鏃堕棿
         /// </summary>
         public DateTime refreshTime = DateTime.MinValue;
+        /// <summary>
+        /// 鏈�鍚庢洿鏂扮姸鎬佺殑鏃堕棿
+        /// </summary>
+        [Newtonsoft.Json.JsonIgnore]
+        public DateTime updateTime = DateTime.MinValue;
 
         /// <summary>
         /// 鑾峰彇鏈湴鎺у埗鏁版嵁
diff --git a/HDL_ON/UI/MainPage.cs b/HDL_ON/UI/MainPage.cs
index 76549d3..7108839 100644
--- a/HDL_ON/UI/MainPage.cs
+++ b/HDL_ON/UI/MainPage.cs
@@ -631,6 +631,8 @@
             if (msg.Contains("鏀跺埌鏁版嵁")
                 || msg.Contains("鍙戦��")
                 || msg.Contains("璇诲彇鍔熻兘鐘舵��")
+                //|| msg.Contains("A鍗忚鏇存柊鐘舵��")
+                || msg.Contains("000102FE8CBF6BFF020400050000")
                 //|| true
                 )
                 Console.WriteLine(msg);
diff --git a/HDL_ON/UI/UI1-Login/LoginPage.cs b/HDL_ON/UI/UI1-Login/LoginPage.cs
index ebf1170..261bd09 100644
--- a/HDL_ON/UI/UI1-Login/LoginPage.cs
+++ b/HDL_ON/UI/UI1-Login/LoginPage.cs
@@ -386,7 +386,7 @@
             };
 #endif
 
-#region 鐧诲綍鏂瑰紡閫夋嫨
+            #region 鐧诲綍鏂瑰紡閫夋嫨
             btnPhoneLogin = new Button()
             {
                 X = Application.GetRealWidth(28),
diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs
index 67e453b..8c3b34a 100644
--- a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs
+++ b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs
@@ -30,7 +30,7 @@
         /// <summary>
         /// 杩炴帴鐘舵�佹彁绀�
         /// </summary>
-        Button btnLinkStateTip;
+        FrameLayout divLinkStateTip;
         /// <summary>
         /// 瀹夐槻鐘舵�佸浘鏍�
         /// </summary>
@@ -213,69 +213,35 @@
                     IsBold = true
                 };
                 topView.AddChidren(btnResidenceName);
-                btnLinkStateTip = new Button()
+
+                divLinkStateTip = new FrameLayout()
                 {
-                    //X = Application.GetRealWidth(16),
-                    Y = btnResidenceName.Bottom,
-                    Height = Application.GetRealWidth(14),
-                    //BackgroundColor = CSS_Color.LinkTipFail,
-                    TextAlignment = TextAlignment.Center,
+                    Y = Application.GetRealHeight(113) - Application.GetRealWidth(24),
+                    Height = Application.GetRealWidth(24),
+                    BackgroundColor = 0xFFFF4747,
+                    Visible = false,
+                };
+                topView.AddChidren(divLinkStateTip);
+                Button btnLinkStateIcon = new Button()
+                {
+                    X = Application.GetRealWidth(16),
+                    Gravity = Gravity.CenterVertical,
+                    Width = Application.GetRealWidth(20),
+                    Height = Application.GetRealWidth(20),
+                    UnSelectedImagePath = "Collection/GatewayOnlineTipIcon.png"
+                };
+                divLinkStateTip.AddChidren(btnLinkStateIcon);
+
+                var btnLinkStateTip = new Button()
+                {
+                    X = btnLinkStateIcon.Right + Application.GetRealWidth(4),
+                    TextAlignment = TextAlignment.CenterLeft,
                     TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                     TextColor = CSS_Color.MainBackgroundColor,
+                    TextID = StringId.NetworkAnomaly,
                 };
-                topView.AddChidren(btnLinkStateTip);
-                //btnLinkStateTip.Width = btnLinkStateTip.GetTextWidth();
+                divLinkStateTip.AddChidren(btnLinkStateTip);
                 //鏇存柊閾炬帴鐘舵�乮con棰滆壊
-
-
-#if DEBUG
-                int ddd = 0;
-                btnResidenceName.MouseUpEventHandler = (sender, e) =>
-                {
-                    //827a98c98da7469b8bc19bb6a3c7651906
-                    //St_00009073b431d8b2490c9df0c5cb0e73
-                    //Com.Hdl.HdlToLc.InitData(Shared.Application.Activity,false, "827a98c98da7469b8bc19bb6a3c7651906");
-                    //Com.Hdl.HdlToLc.OpenActivity();
-                    //new System.Threading.Thread(() =>
-                    //{
-                    //    var http = new HttpServerRequest();
-                    //    var pack = http.GetLcSubAccountToken();
-                    //    if (pack.Code == StateCode.SUCCESS)
-                    //    {
-                    //        if(pack.Data == null || string.IsNullOrEmpty(pack.Data.ToString()))
-                    //        {
-                    //            Application.RunOnMainThread(() =>
-                    //            {
-                    //                new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip), Language.StringByID(StringId.huoqushujushibao));
-                    //            });
-                    //        }
-                    //        Com.Utils.HdlToLcUtils.Instance.HomeId = DB_ResidenceData.Instance.CurrentRegion.id;
-                    //        Com.Utils.HdlToLcUtils.Instance.Token = UserInfo.Current.AccessToken;
-                    //        Com.Utils.HdlToLcUtils.Instance.SubAccessToken = pack.Data.ToString();
-                    //        Application.RunOnMainThread(() =>
-                    //        {
-                    //            //Com.Utils.HdlToLcUtils.Instance.OpenActivity();
-                    //            //Com.Utils.HdlToLcUtils.Instance.Play()
-                    //            var backTemp = new AddLcCam();
-                    //            backTemp.backAction = () =>
-                    //            {
-                    //                //Load3tyBrandDeviceList();
-                    //            };
-                    //            Com.Utils.HdlToLcUtils.Instance.AddCamera(backTemp);
-                    //        });
-                    //    }
-                    //    else
-                    //    {
-                    //        Application.RunOnMainThread(() =>
-                    //        {
-                    //            new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip), Language.StringByID(StringId.huoqushujushibao) + $"({pack.Code})");
-                    //        });
-                    //    }
-                    //})
-                    //{ IsBackground = true }.Start();
-                };
-#endif
-
                 environmentalView = new FrameLayout()
                 {
                     Y = Application.GetRealHeight(1) + btnResidenceName.Bottom,
diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
index 1c14381..6706f8e 100644
--- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
+++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
@@ -269,15 +269,15 @@
 
             if (!Control.Ins.GatewayOnline_Local && !Control.Ins.GatewayOnline_Cloud)
             {
-                bodyView.btnLinkStateTip.BackgroundColor = CSS.CSS_Color.LinkTipFail;
-                bodyView.btnLinkStateTip.TextID = StringId.NetworkAnomaly;
-                bodyView.environmentalView.Y = Application.GetRealHeight(8) + btnResidenceName.Bottom;
+                bodyView.divLinkStateTip.Visible = true;
             }
+            //else if ()
+            //{
+            //    bodyView.divLinkStateTip.Visible = true;
+            //}
             else
             {
-                bodyView.btnLinkStateTip.BackgroundColor = 0x00000000;
-                bodyView.btnLinkStateTip.Text = "";
-                bodyView.environmentalView.Y = Application.GetRealHeight(1) + btnResidenceName.Bottom;
+                bodyView.divLinkStateTip.Visible = false;
             }
         }
 
@@ -351,11 +351,17 @@
             }
         }
 
+        object lockObj = new object();
+
         /// <summary>
         /// 鏇存柊鏄剧ず鐘舵��
         /// </summary>
         public static void UpdataFunctionStates(Function function)
         {
+            if(bodyView == null)
+            {
+                return;
+            }
             Application.RunOnMainThread(() =>
             {
                 try
diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs b/HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs
index 8e87e01..0069a00 100644
--- a/HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs
+++ b/HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs
@@ -4,13 +4,85 @@
 {
     public partial class FunctionPage
     {
+        System.Threading.Thread updateUiThread;
+        object lockObj = new object();
         /// <summary>
         /// 鏇存柊鍔熻兘鍒楄〃鐣岄潰鍔熻兘鐘舵��
         /// </summary>
         /// <param name="function"></param>
         public static void UpdataStates(Function function)
         {
-            new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView);
+            try
+            {
+                if (bodyView == null)
+                {
+                    return;
+                }
+                //if (SPK.LightSpkList().Contains(function.spk))
+                //{
+
+                //    {
+                //        var localFunction = FunctionList.List.GetLightList().Find((obj) => obj.sid == function.sid);
+                //        {
+                //            if (localFunction != null)
+                //            {
+                //                if (bodyView.updateUiThread == null)
+                //                {
+                //                    bodyView.updateUiThread = new System.Threading.Thread(() =>
+                //                    {
+                //                        lock (bodyView.lockObj)
+                //                        {
+                //                            if (bodyView.updateUiThread == null)
+                //                            {
+                //                                MainPage.Log("绾跨▼琚疆绌轰簡锛侊紒");
+                //                                return;
+                //                            }
+                //                            try
+                //                            {
+                //                                while (true)
+                //                                {
+                //                                    System.Threading.Thread.Sleep(1500);
+                //                                    if (bodyView == null)
+                //                                    {
+                //                                        return;
+                //                                    }
+                //                                    if (DateTime.Now.AddMilliseconds(-1500) > localFunction.updateTime)
+                //                                    {
+                //                                        MainPage.Log("娌℃湁鏂版暟鎹紝鏇存柊UI");
+                //                                        break;
+                //                                    }
+                //                                    else
+                //                                    {
+                //                                        MainPage.Log("鏈夋柊鏁版嵁锛岀户缁瓑寰�");
+                //                                    }
+                //                                }
+                //                                new ClassificaitionPublicBLL().UpdataStates(localFunction, bodyView, functionListView);
+                //                            }
+                //                            catch (Exception ex)
+                //                            {
+                //                                MainPage.Log("FunctionPage UpdateStates error 2 :" + ex.Message);
+                //                            }
+                //                            finally
+                //                            {
+                //                                //bodyView.updateUiThread = null;
+                //                            }
+                //                        }
+                //                    });
+                //                    bodyView.updateUiThread.IsBackground = true;
+                //                    bodyView.updateUiThread.Start();
+                //                }
+                //            }
+                //        }
+                //    }
+                //}
+                //else
+                {
+                    new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView);
+                }
+            }catch(Exception ex)
+            {
+                MainPage.Log("FunctionPage UpdateStates error " + ex.Message);
+            }
         }
 
         public static void UpdataOnline(Function function)
diff --git a/HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs b/HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs
index 5323666..5435079 100644
--- a/HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs
+++ b/HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs
@@ -6,13 +6,93 @@
 {
     public partial class RoomPage
     {
+        System.Threading.Thread updateUiThread;
+        object lockObj = new object();
         /// <summary>
         /// 鏇存柊鍔熻兘鐘舵��
         /// </summary>
         /// <param name="function"></param>
         public static void UpdataStates(Function function)
         {
-            new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView,room);
+
+            try
+            {
+                if (bodyView == null)
+                {
+                    return;
+                }
+                //if (SPK.LightSpkList().Contains(function.spk))
+                //{
+                //    {
+                //        var localFunction = FunctionList.List.GetLightList().Find((obj) => obj.sid == function.sid);
+                //        {
+                //            if (localFunction != null)
+                //            {
+                //                if (bodyView.updateUiThread == null)
+                //                {
+                //                    bodyView.updateUiThread = new System.Threading.Thread(() =>
+                //                    {
+                //                        lock (bodyView.lockObj)
+                //                        {
+                //                            try
+                //                            {
+                //                                while (true)
+                //                                {
+                //                                    try
+                //                                    {
+                //                                        System.Threading.Thread.Sleep(1500);
+                //                                        if (bodyView == null)
+                //                                        {
+                //                                            return;
+                //                                        }
+                //                                        if (bodyView.updateUiThread == null)
+                //                                        {
+                //                                            return;
+                //                                        }
+                //                                        if (DateTime.Now.AddMilliseconds(-1500) > localFunction.updateTime)
+                //                                        {
+                //                                            MainPage.Log("娌℃湁鏂版暟鎹紝鏇存柊UI");
+                //                                            break;
+                //                                        }
+                //                                        else
+                //                                        {
+                //                                            MainPage.Log("鏈夋柊鏁版嵁锛岀户缁瓑寰�");
+                //                                        }
+                //                                    }
+                //                                    catch (Exception ex)
+                //                                    {
+                //                                        MainPage.Log("绾跨▼寮傚父:" + ex.Message);
+                //                                    }
+                //                                }
+                //                                new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView, room);
+                //                            }
+                //                            catch (Exception ex)
+                //                            {
+                //                                MainPage.Log("FunctionPage UpdateStates error 2 :" + ex.Message);
+                //                            }
+                //                            finally
+                //                            {
+                //                                //bodyView.updateUiThread = null;
+                //                            }
+                //                        }
+                //                    });
+                //                    bodyView.updateUiThread.IsBackground = true;
+                //                    bodyView.updateUiThread.Start();
+                //                }
+                //            }
+                //        }
+                //    }
+                //}
+                //else
+                {
+                    new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView,room);
+                }
+            }
+            catch (Exception ex)
+            {
+                MainPage.Log("FunctionPage UpdateStates error " + ex.Message);
+            }
+
         }
         public static void UpdataOnline(Function function)
         {
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
index e730aaa..241ee78 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
@@ -76,13 +76,13 @@
 
             if (sceneFunction.localFunction.spk == SPK.LightRGB || sceneFunction.localFunction.spk == SPK.GroupControl)
             {
-                //var colorfulStatus = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Colorful);
-                //if (colorfulStatus != null)
-                //{
-                //    isColorful = true;
-                //    LoadColorfulRow(colorfulStatus);
-                //    isColorful = colorfulStatus.value == "on";
-                //}
+                var colorfulStatus = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Colorful);
+                if (colorfulStatus != null)
+                {
+                    isColorful = true;
+                    LoadColorfulRow(colorfulStatus);
+                    isColorful = colorfulStatus.value == "on";
+                }
             }
             foreach (var attr in sceneFunction.status)
             {
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs
index ad7b605..c9d675a 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs
@@ -6,52 +6,99 @@
 namespace HDL_ON.UI
 {
     public partial class ColorTureLampPage
-    {
+    {
+        /// <summary>
+        /// 閫氱煡鏇存柊鐣岄潰鐨勬椂闂�
+        /// </summary>
+        DateTime notiyUpdateTime = DateTime.MinValue;
+        System.Threading.Thread updateUiThread;
+        object lockObj = new object();
         /// <summary>
         /// 鏇存柊鍔熻兘鐘舵��
         /// </summary>
         public static void UpdataStatus(Function updataTemp)
-        {
-            Application.RunOnMainThread(() =>
-            {
-                try
-                {
-                    if (bodyView == null)
-                        return;
-                    if (updataTemp.spk == bodyView.function.spk && updataTemp.sid == bodyView.function.sid)
-                    {
-                        if (updataTemp.trait_on_off.curValue.ToString() == "on")
-                        {
-                            bodyView.dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
-                            if (!bodyView.onDimmerBar)
-                            {
-                                bodyView.dimmerBar.Progress = Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness));
-                            }
-                            if (updataTemp.GetAttrState(FunctionAttributeKey.Brightness) != "0")
-                            {
-                                bodyView.btnBrightnessText.Text = updataTemp.GetAttrState(FunctionAttributeKey.Brightness) + "%";
-                                bodyView.btnBrightnessText.Y = ((100 - Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness))) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80);
-                            }
-                        }
-                        else
-                        {
-                            bodyView.dimmerBar.SetProgressBarColors(CSS_Color.DividingLineColor, CSS_Color.DividingLineColor);
-                        }
-                        bodyView.btnSwitch.IsSelected = updataTemp.trait_on_off.curValue.ToString() == "on";
-                        bodyView.barColorTemplatrue.Enable = updataTemp.trait_on_off.curValue.ToString() == "on";
-                        var cct = 27;
-                        int.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.CCT), out cct);
-                        bodyView.barColorTemplatrue.Progress = cct / 100;
-                        //璁剧疆鍒濆鍊�
-                        bodyView.barColorTemplatrue.SetCustomText(bodyView.barColorTemplatrue.Progress * 100 + "K");
-
-                    }
-                }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"{bodyView.GetType().Name } UpdataStates error : {ex.Message}");
-                }
-            });
+        { 
+            if(bodyView == null)
+            {
+                return;
+            }
+            lock (bodyView.lockObj)
+            {
+                MainPage.Log($"鏀跺埌鏇存柊" + DateTime.Now.Ticks);
+                bodyView.notiyUpdateTime = DateTime.Now;
+                if (bodyView.updateUiThread == null)
+                {
+                    bodyView.updateUiThread = new System.Threading.Thread(() =>
+                    {
+                        while (true)
+                        {
+                            System.Threading.Thread.Sleep(1500);
+                            if (bodyView == null)
+                            {
+                                return;
+                            }
+                            if (DateTime.Now.AddMilliseconds(-1500) > bodyView.notiyUpdateTime)
+                            {
+                                MainPage.Log("娌℃湁鏂版暟鎹紝鏇存柊UI");
+                                break;
+                            }
+                            else
+                            {
+                                MainPage.Log("鏈夋柊鏁版嵁锛岀户缁瓑寰�");
+                            }
+                        }
+
+                        Application.RunOnMainThread(() =>
+                        {
+                            try
+                            {
+                                if (bodyView == null)
+                                    return;
+                                if (updataTemp.spk == bodyView.function.spk && updataTemp.sid == bodyView.function.sid)
+                                {
+                                    if (updataTemp.trait_on_off.curValue.ToString() == "on")
+                                    {
+                                        bodyView.dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
+                                        if (!bodyView.onDimmerBar)
+                                        {
+                                            bodyView.dimmerBar.Progress = Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness));
+                                        }
+                                        if (updataTemp.GetAttrState(FunctionAttributeKey.Brightness) != "0")
+                                        {
+                                            bodyView.btnBrightnessText.Text = updataTemp.GetAttrState(FunctionAttributeKey.Brightness) + "%";
+                                            bodyView.btnBrightnessText.Y = ((100 - Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness))) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80);
+                                        }
+                                    }
+                                    else
+                                    {
+                                        bodyView.dimmerBar.SetProgressBarColors(CSS_Color.DividingLineColor, CSS_Color.DividingLineColor);
+                                    }
+                                    bodyView.btnSwitch.IsSelected = updataTemp.trait_on_off.curValue.ToString() == "on";
+                                    bodyView.barColorTemplatrue.Enable = updataTemp.trait_on_off.curValue.ToString() == "on";
+                                    var cct = 27;
+                                    int.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.CCT), out cct);
+                                    bodyView.barColorTemplatrue.Progress = cct / 100;
+                                    //璁剧疆鍒濆鍊�
+                                    bodyView.barColorTemplatrue.SetCustomText(bodyView.barColorTemplatrue.Progress * 100 + "K");
+
+                                }
+                            }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log($"{bodyView.GetType().Name} UpdataStates error : {ex.Message}");
+                            }
+                            finally
+                            {
+                                bodyView.updateUiThread = null;
+                            }
+
+                        });
+
+                        bodyView.updateUiThread.IsBackground = true;
+                        bodyView.updateUiThread.Start();
+                    });
+                }
+            }
         }
 
         void LoadEventList()
@@ -181,9 +228,9 @@
                     curDimmerStatus = onDimmerBar = true;
                 };
                 dimmerBar.OnProgressChangedEvent = (sender, e) =>
-                {
-                    //dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
-                if (!btnSwitch.IsSelected)
+                {
+                    //dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
+                    if (!btnSwitch.IsSelected)
                     {
                         dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
                     }
@@ -196,20 +243,20 @@
                         d.Add(FunctionAttributeKey.Brightness, e.ToString());
                         Control.Ins.SendWriteCommand(function, d);
                     }
-                    else
-                    {
-                        if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds)
-                        {
-                            function.refreshTime = DateTime.Now;
-                            new System.Threading.Thread(() =>
-                            {
-                                System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                                d.Add(FunctionAttributeKey.Brightness, e.ToString());
-                                Control.Ins.SendWriteCommand(function, d);
-                            })
-                            { IsBackground = true }.Start();
-                        }
-                    }
+                    //else
+                    //{
+                    //    if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds)
+                    //    {
+                    //        function.refreshTime = DateTime.Now;
+                    //        new System.Threading.Thread(() =>
+                    //        {
+                    //            System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
+                    //            d.Add(FunctionAttributeKey.Brightness, e.ToString());
+                    //            Control.Ins.SendWriteCommand(function, d);
+                    //        })
+                    //        { IsBackground = true }.Start();
+                    //    }
+                    //}
 
 
                     btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80);
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs
index 4a6cf52..765396b 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs
@@ -8,40 +8,87 @@
     public partial class DimmerPage
     {
         /// <summary>
+        /// 閫氱煡鏇存柊鐣岄潰鐨勬椂闂�
+        /// </summary>
+        DateTime notiyUpdateTime = DateTime.MinValue;
+        System.Threading.Thread updateUiThread;
+        object lockObj = new object();
+        
+        /// <summary>
         /// 鏇存柊鍔熻兘鐘舵��
         /// </summary>
         public static void UpdataStates(Function updataTemp)
         {
-            Application.RunOnMainThread((() =>
+            if (bodyView == null)
             {
-                try
+                return;
+            }
+            lock (bodyView.lockObj)
+            {
+                MainPage.Log($"鏀跺埌鏇存柊" + DateTime.Now.Ticks);
+                bodyView.notiyUpdateTime = DateTime.Now;
+                if (bodyView.updateUiThread == null)
                 {
-                    if (bodyView == null)
-                        return;
-                    if (updataTemp.spk == bodyView.function.spk && updataTemp.sid == bodyView.function.sid)
+                    bodyView.updateUiThread = new System.Threading.Thread(() =>
                     {
-                        bodyView.btnBrightnessText.Text = updataTemp.GetAttrState(FunctionAttributeKey.Brightness) + "%";
-                        if (updataTemp.trait_on_off.curValue.ToString() == "on")
+                        while (true)
                         {
-                            bodyView.dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
-                            if (!bodyView.onDimmerBar)
+                            System.Threading.Thread.Sleep(1500);
+                            if (bodyView == null)
                             {
-                                bodyView.dimmerBar.Progress = Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness));
-                                bodyView.btnBrightnessText.Y = ((100 - Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness))) * Application.GetRealHeight(288 - 16 - 16) / 100) + Application.GetRealWidth(40);
+                                return;
+                            }
+                            if (DateTime.Now.AddMilliseconds(-1500) > bodyView.notiyUpdateTime)
+                            {
+                                MainPage.Log("娌℃湁鏂版暟鎹紝鏇存柊UI");
+                                break;
+                            }
+                            else
+                            {
+                                MainPage.Log("鏈夋柊鏁版嵁锛岀户缁瓑寰�");
                             }
                         }
-                        else
-                        {
-                            bodyView.dimmerBar.SetProgressBarColors(CSS_Color.DividingLineColor, CSS_Color.DividingLineColor);
-                        }
-                        bodyView.btnSwitch.IsSelected = updataTemp.trait_on_off.curValue.ToString() == "on";
-                    }
+
+                        Application.RunOnMainThread(() =>{
+                            try
+                            {
+                                if (bodyView == null)
+                                    return;
+                                if (updataTemp.spk == bodyView.function.spk && updataTemp.sid == bodyView.function.sid)
+                                {
+                                    bodyView.btnBrightnessText.Text = updataTemp.GetAttrState(FunctionAttributeKey.Brightness) + "%";
+                                    if (updataTemp.trait_on_off.curValue.ToString() == "on")
+                                    {
+                                        bodyView.dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
+                                        if (!bodyView.onDimmerBar)
+                                        {
+                                            bodyView.dimmerBar.Progress = Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness));
+                                            bodyView.btnBrightnessText.Y = ((100 - Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness))) * Application.GetRealHeight(288 - 16 - 16) / 100) + Application.GetRealWidth(40);
+                                        }
+                                    }
+                                    else
+                                    {
+                                        bodyView.dimmerBar.SetProgressBarColors(CSS_Color.DividingLineColor, CSS_Color.DividingLineColor);
+                                    }
+                                    bodyView.btnSwitch.IsSelected = updataTemp.trait_on_off.curValue.ToString() == "on";
+                                }
+                            }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log($"{bodyView.GetType().Name} UpdataStates error : {ex.Message}");
+                            }
+                            finally
+                            {
+                                bodyView.updateUiThread = null;
+                            }
+                        });
+
+
+                        bodyView.updateUiThread.IsBackground = true;
+                        bodyView.updateUiThread.Start();
+                    });
                 }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"{bodyView.GetType().Name } UpdataStates error : {ex.Message}");
-                }
-            }));
+            }
         }
 
         void LoadEventList()
@@ -117,7 +164,6 @@
                 //20201223 鍒犻櫎婊戝姩鍙戦�佸懡浠わ紝闃叉鎺т欢璺冲姩
                 dimmerBar.OnProgressChangedEvent = (sender, e) =>
                 {
-                   
                     if (!btnSwitch.IsSelected)
                     {
                         dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
@@ -132,20 +178,20 @@
                         d.Add(FunctionAttributeKey.Brightness, e.ToString());
                         Control.Ins.SendWriteCommand(function, d);
                     }
-                    else
-                    {
-                        if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds)
-                        {
-                            function.refreshTime = DateTime.Now;
-                            new System.Threading.Thread(() =>
-                            {
-                                System.Collections.Generic.Dictionary<string, string> dic = new System.Collections.Generic.Dictionary<string, string>();
-                                dic.Add(FunctionAttributeKey.Brightness, e.ToString());
-                                Control.Ins.SendWriteCommand(function, dic);
-                            })
-                            { IsBackground = true }.Start();
-                        }
-                    }
+                    //else
+                    //{
+                    //    if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds)
+                    //    {
+                    //        function.refreshTime = DateTime.Now;
+                    //        new System.Threading.Thread(() =>
+                    //        {
+                    //            System.Collections.Generic.Dictionary<string, string> dic = new System.Collections.Generic.Dictionary<string, string>();
+                    //            dic.Add(FunctionAttributeKey.Brightness, e.ToString());
+                    //            Control.Ins.SendWriteCommand(function, dic);
+                    //        })
+                    //        { IsBackground = true }.Start();
+                    //    }
+                    //}
                     btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(288 - 16 - 16) / 100) + Application.GetRealWidth(40);
                     btnBrightnessText.Text = dimmerBar.Progress + "%";
                 };
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs
index 8269b50..c48a8d5 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs
@@ -349,6 +349,7 @@
 
             dimmerBar.OnProgressChangedEvent = (sender, e) =>
             {
+                return;
                 if (e == 0 && lastBrightness != 0)
                 {
                     lastBrightness = 0;
@@ -443,6 +444,7 @@
 
             dimmerBar.OnProgressChangedEvent = (sender, e) =>
             {
+                return;
                 if (e == 0 && lastBrightness != 0)
                 {
                     lastBrightness = 0;
@@ -764,6 +766,7 @@
 
             dimmerBar.OnProgressChangedEvent = (sender, e) =>
             {
+                return;
                 if (e == 0 && lastBrightness != 0)
                 {
                     lastBrightness = 0;
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs
index 51f0282..4560904 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs
@@ -455,11 +455,12 @@
             new TopViewDiv(bodyView, Language.StringByID(StringId.Lights)).LoadTopView_FunctionTop(function, actionRefresh);
             new System.Threading.Thread(() =>
             {
-                DriverLayer.Control.Ins.SendReadCommand(function);
+                Control.Ins.SendReadCommand(function);
             })
             { IsBackground = true }.Start();
 
-            new System.Threading.Thread(() => {
+            new System.Threading.Thread(() =>
+            {
                 while (true)
                 {
                     System.Threading.Thread.Sleep(1000);
@@ -473,7 +474,8 @@
                     }
                     else
                     {
-                        DriverLayer.Control.Ins.SendReadCommand(function);
+                        System.Threading.Thread.Sleep(1000);
+                        Control.Ins.SendReadCommand(function);
                         curDimmerStatus = true;
                     }
                 }
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs
index 124ed5f..e60c686 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs
@@ -7,78 +7,132 @@
     public partial class RGBPage
     {
         /// <summary>
+        /// 閫氱煡鏇存柊鐣岄潰鐨勬椂闂�
+        /// </summary>
+        DateTime notiyUpdateTime = DateTime.MinValue;
+        System.Threading.Thread updateUiThread;
+        object lockObj = new object();
+
+        public override void RemoveFromParent()
+        {
+            bodyView = null;
+            base.RemoveFromParent();
+        }
+        /// <summary>
         /// 鏇存柊鍔熻兘鐘舵��
         /// </summary>
         public static void UpdataStates(Function updateTemp)
         {
-            Application.RunOnMainThread((() =>
+            if(bodyView == null)
             {
-                try
+                return;
+            }
+            lock (bodyView.lockObj)
+            {
+                MainPage.Log($"鏀跺埌鏇存柊"+ DateTime.Now.Ticks);
+                bodyView.notiyUpdateTime = DateTime.Now;
+                if (bodyView.updateUiThread == null)
                 {
-                    if (bodyView == null)
-                        return;
-                    if (updateTemp.spk == bodyView.function.spk && updateTemp.sid == bodyView.function.sid)
+                    bodyView.updateUiThread = new System.Threading.Thread(() =>
                     {
+                        while (true)
+                        {
+                            System.Threading.Thread.Sleep(1500);
+                            if(bodyView == null)
+                            {
+                                return;
+                            }
+                            if (DateTime.Now.AddMilliseconds(-1500) > bodyView.notiyUpdateTime)
+                            {
+                                MainPage.Log("娌℃湁鏂版暟鎹紝鏇存柊UI");
+                                break;
+                            }
+                            else
+                            {
+                                MainPage.Log("鏈夋柊鏁版嵁锛岀户缁瓑寰�");
+                            }
+                        }
 
-                        if (updateTemp.trait_on_off.curValue.ToString() == "on")
+                        Application.RunOnMainThread((() =>
                         {
-                            //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰�
-                            if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheel.png")
+                            try
                             {
-                                bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png";
-                            }
-                            bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.AuxiliaryColor1;
-                            bodyView.btnSwitch.IsSelected = true;
-                            if (!bodyView.onDimmerBar)
-                            {
-                                bodyView.dimmerBar.Progress = Convert.ToInt32(updateTemp.GetAttrState(FunctionAttributeKey.Brightness));
-                            }
-                        }
-                        //鐘舵�佷竴鏍锋椂,涓嶅啀鍒锋柊瑙嗗浘
-                        else if (updateTemp.trait_on_off.curValue.ToString() == "off" && bodyView.btnSwitch.IsSelected == true)
-                        {
-                            //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰�
-                            if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheelGray.png")
-                            {
-                                bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png";
-                            }
-                            //bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png";
-                            bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.PromptingColor2;
-                            bodyView.btnSwitch.IsSelected = false;
-                            //鑹茬洏鐨勫渾鐐归殣钘�
-                            bodyView.btnWhiteRound.Visible = false;
-                        }
-                        bodyView.btnCurColor.BackgroundColor = (uint)(0xFF000000 + bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGB)));
-                        bodyView.lastColor = bodyView.lightTemp.GetRGBbytes(updateTemp);
-                        if (bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGB)) == 16777215 && bodyView.btnCurColor.BorderColor != 0x00000000)
-                        {
-                            bodyView.btnCurColor.BorderColor = CSS.CSS_Color.PromptingColor2;
-                        }
-                        else
-                        {
-                            bodyView.btnCurColor.BorderColor = 0x00000000;
-                        }
-                        try
-                        {
-                            var colorfulState = updateTemp.GetAttribute(FunctionAttributeKey.Colorful);
-                            if (colorfulState != null)
-                            {
-                                if(bodyView.btnColorfulSwitch!= null)
+                                if (bodyView == null)
+                                    return;
+                                if (updateTemp.spk == bodyView.function.spk && updateTemp.sid == bodyView.function.sid)
                                 {
-                                    bodyView.btnColorfulSwitch.IsSelected = colorfulState.curValue.ToString() == "on";
+
+                                    if (updateTemp.trait_on_off.curValue.ToString() == "on")
+                                    {
+                                        //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰�
+                                        if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheel.png")
+                                        {
+                                            bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png";
+                                        }
+                                        bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.AuxiliaryColor1;
+                                        bodyView.btnSwitch.IsSelected = true;
+                                        if (!bodyView.onDimmerBar)
+                                        {
+                                            bodyView.dimmerBar.Progress = Convert.ToInt32(updateTemp.GetAttrState(FunctionAttributeKey.Brightness));
+                                        }
+                                    }
+                                    //鐘舵�佷竴鏍锋椂,涓嶅啀鍒锋柊瑙嗗浘
+                                    else if (updateTemp.trait_on_off.curValue.ToString() == "off" && bodyView.btnSwitch.IsSelected == true)
+                                    {
+                                        //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰�
+                                        if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheelGray.png")
+                                        {
+                                            bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png";
+                                        }
+                                        //bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png";
+                                        bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.PromptingColor2;
+                                        bodyView.btnSwitch.IsSelected = false;
+                                        //鑹茬洏鐨勫渾鐐归殣钘�
+                                        bodyView.btnWhiteRound.Visible = false;
+                                    }
+                                    bodyView.btnCurColor.BackgroundColor = (uint)(0xFF000000 + bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGB)));
+                                    bodyView.lastColor = bodyView.lightTemp.GetRGBbytes(updateTemp);
+                                    if (bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGB)) == 16777215 && bodyView.btnCurColor.BorderColor != 0x00000000)
+                                    {
+                                        bodyView.btnCurColor.BorderColor = CSS.CSS_Color.PromptingColor2;
+                                    }
+                                    else
+                                    {
+                                        bodyView.btnCurColor.BorderColor = 0x00000000;
+                                    }
+                                    try
+                                    {
+                                        var colorfulState = updateTemp.GetAttribute(FunctionAttributeKey.Colorful);
+                                        if (colorfulState != null)
+                                        {
+                                            if (bodyView.btnColorfulSwitch != null)
+                                            {
+                                                bodyView.btnColorfulSwitch.IsSelected = colorfulState.curValue.ToString() == "on";
+                                            }
+                                        }
+                                    }
+                                    catch (Exception ex)
+                                    {
+                                        MainPage.Log($"鏇存柊RGB 鐐僵寮�鍏崇姸鎬佸紓甯�:{ex.Message}");
+                                    }
                                 }
                             }
-                        }catch(Exception ex)
-                        {
-                            MainPage.Log($"鏇存柊RGB 鐐僵寮�鍏崇姸鎬佸紓甯�:{ex.Message}");
-                        }
-                    }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log($"{bodyView.GetType().Name} UpdataStates error : {ex.Message}");
+                            }
+                            finally
+                            {
+                                bodyView.updateUiThread = null;
+                            }
+                        }));
+
+                    });
+                    bodyView.updateUiThread.IsBackground = true;
+                    bodyView.updateUiThread.Start();
                 }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"{bodyView.GetType().Name } UpdataStates error : {ex.Message}");
-                }
-            }));
+            }
+
         }
 
 
@@ -263,25 +317,25 @@
                         d.Add(FunctionAttributeKey.Brightness, e.ToString());
                         Control.Ins.SendWriteCommand(function, d);
                     }
-                    else
-                    {
-                        if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds)
-                        {
-                            function.refreshTime = DateTime.Now;
-                            new System.Threading.Thread(() =>
-                            {
-                                //Control.Send(CommandType_A.write, function);
-                                System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                                d.Add(FunctionAttributeKey.Brightness, e.ToString());
-                                Control.Ins.SendWriteCommand(function, d);
-                            })
-                            { IsBackground = true }.Start();
-                        }
-                        else
-                        {
-                            MainPage.Log("skip dimmer control!!");
-                        }
-                    }
+                    //else
+                    //{
+                    //    if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds)
+                    //    {
+                    //        function.refreshTime = DateTime.Now;
+                    //        new System.Threading.Thread(() =>
+                    //        {
+                    //            //Control.Send(CommandType_A.write, function);
+                    //            System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
+                    //            d.Add(FunctionAttributeKey.Brightness, e.ToString());
+                    //            Control.Ins.SendWriteCommand(function, d);
+                    //        })
+                    //        { IsBackground = true }.Start();
+                    //    }
+                    //    else
+                    //    {
+                    //        MainPage.Log("skip dimmer control!!");
+                    //    }
+                    //}
                 };
             }
         }
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBWPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBWPageBLL.cs
index c2bd28a..369d3b9 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBWPageBLL.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBWPageBLL.cs
@@ -7,64 +7,110 @@
     public partial class RGBWPage
     {
         /// <summary>
+        /// 閫氱煡鏇存柊鐣岄潰鐨勬椂闂�
+        /// </summary>
+        DateTime notiyUpdateTime = DateTime.MinValue;
+        System.Threading.Thread updateUiThread;
+        object lockObj = new object();
+        /// <summary>
         /// 鏇存柊鍔熻兘鐘舵��
         /// </summary>
         public static void UpdataStates(Function updateTemp)
         {
-            Application.RunOnMainThread((() =>
+            if (bodyView == null)
             {
-                try
+                return;
+            }
+            lock (bodyView.lockObj)
+            {
+                MainPage.Log($"鏀跺埌鏇存柊" + DateTime.Now.Ticks);
+                bodyView.notiyUpdateTime = DateTime.Now;
+                if (bodyView.updateUiThread == null)
                 {
-                    if (bodyView == null)
-                        return;
-                    if (updateTemp.spk == bodyView.function.spk && updateTemp.sid == bodyView.function.sid)
+                    bodyView.updateUiThread = new System.Threading.Thread(() =>
                     {
+                        while (true)
+                        {
+                            System.Threading.Thread.Sleep(1500);
+                            if (bodyView == null)
+                            {
+                                return;
+                            }
+                            if (DateTime.Now.AddMilliseconds(-1500) > bodyView.notiyUpdateTime)
+                            {
+                                MainPage.Log("娌℃湁鏂版暟鎹紝鏇存柊UI");
+                                break;
+                            }
+                            else
+                            {
+                                MainPage.Log("鏈夋柊鏁版嵁锛岀户缁瓑寰�");
+                            }
+                        }
+                        Application.RunOnMainThread(() =>
+                        {
+                            try
+                            {
+                                if (bodyView == null)
+                                    return;
+                                if (updateTemp.spk == bodyView.function.spk && updateTemp.sid == bodyView.function.sid)
+                                {
 
-                        if (updateTemp.trait_on_off.curValue.ToString() == "on")
-                        {
-                            //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰�
-                            if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheel.png")
-                            {
-                                bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png";
+                                    if (updateTemp.trait_on_off.curValue.ToString() == "on")
+                                    {
+                                        //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰�
+                                        if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheel.png")
+                                        {
+                                            bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png";
+                                        }
+                                        bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.AuxiliaryColor1;
+                                        bodyView.btnSwitch.IsSelected = true;
+                                        if (!bodyView.onDimmerBar)
+                                        {
+                                            bodyView.dimmerBar.Progress = Convert.ToInt32(updateTemp.GetAttrState(FunctionAttributeKey.Brightness));
+                                        }
+                                    }
+                                    //鐘舵�佷竴鏍锋椂,涓嶅啀鍒锋柊瑙嗗浘
+                                    else if (updateTemp.trait_on_off.curValue.ToString() == "off" && bodyView.btnSwitch.IsSelected == true)
+                                    {
+                                        //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰�
+                                        if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheelGray.png")
+                                        {
+                                            bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png";
+                                        }
+                                        //bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png";
+                                        bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.PromptingColor2;
+                                        bodyView.btnSwitch.IsSelected = false;
+                                        //鑹茬洏鐨勫渾鐐归殣钘�
+                                        bodyView.btnWhiteRound.Visible = false;
+                                    }
+                                    bodyView.btnCurColor.BackgroundColor = (uint)(0xFF000000 + bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGBW)));
+                                    bodyView.lastColor = bodyView.lightTemp.GetRGBWbytes(updateTemp);
+                                    if (bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGBW)) == 16777215 && bodyView.btnCurColor.BorderColor != 0x00000000)
+                                    {
+                                        bodyView.btnCurColor.BorderColor = CSS.CSS_Color.PromptingColor2;
+                                    }
+                                    else
+                                    {
+                                        bodyView.btnCurColor.BorderColor = 0x00000000;
+                                    }
+                                }
                             }
-                            bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.AuxiliaryColor1;
-                            bodyView.btnSwitch.IsSelected = true;
-                            if (!bodyView.onDimmerBar)
+                            catch (Exception ex)
                             {
-                                bodyView.dimmerBar.Progress = Convert.ToInt32(updateTemp.GetAttrState(FunctionAttributeKey.Brightness));
+                                MainPage.Log($"{bodyView.GetType().Name } UpdataStates error : {ex.Message}");
                             }
-                        }
-                        //鐘舵�佷竴鏍锋椂,涓嶅啀鍒锋柊瑙嗗浘
-                        else if (updateTemp.trait_on_off.curValue.ToString() == "off" && bodyView.btnSwitch.IsSelected == true)
-                        {
-                            //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰�
-                            if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheelGray.png")
+                            finally
                             {
-                                bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png";
+                                bodyView.updateUiThread = null;
                             }
-                            //bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png";
-                            bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.PromptingColor2;
-                            bodyView.btnSwitch.IsSelected = false;
-                            //鑹茬洏鐨勫渾鐐归殣钘�
-                            bodyView.btnWhiteRound.Visible = false;
-                        }
-                        bodyView.btnCurColor.BackgroundColor = (uint)(0xFF000000 + bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGBW)));
-                        bodyView.lastColor = bodyView.lightTemp.GetRGBWbytes(updateTemp);
-                        if (bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGBW)) == 16777215 && bodyView.btnCurColor.BorderColor != 0x00000000)
-                        {
-                            bodyView.btnCurColor.BorderColor = CSS.CSS_Color.PromptingColor2;
-                        }
-                        else
-                        {
-                            bodyView.btnCurColor.BorderColor = 0x00000000;
-                        }
-                    }
+                        });
+
+
+                        bodyView.updateUiThread.IsBackground = true;
+                        bodyView.updateUiThread.Start();
+                    });
                 }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"{bodyView.GetType().Name } UpdataStates error : {ex.Message}");
-                }
-            }));
+            }
         }
 
 
@@ -256,25 +302,25 @@
                         d.Add(FunctionAttributeKey.Brightness, e.ToString());
                         Control.Ins.SendWriteCommand(function, d);
                     }
-                    else
-                    {
-                        if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds)
-                        {
-                            function.refreshTime = DateTime.Now;
-                            new System.Threading.Thread(() =>
-                            {
-                                //Control.Send(CommandType_A.write, function);
-                                System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                                d.Add(FunctionAttributeKey.Brightness, e.ToString());
-                                Control.Ins.SendWriteCommand(function, d);
-                            })
-                            { IsBackground = true }.Start();
-                        }
-                        else
-                        {
-                            MainPage.Log("skip dimmer control!!");
-                        }
-                    }
+                    //else
+                    //{
+                    //    if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds)
+                    //    {
+                    //        function.refreshTime = DateTime.Now;
+                    //        new System.Threading.Thread(() =>
+                    //        {
+                    //            //Control.Send(CommandType_A.write, function);
+                    //            System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
+                    //            d.Add(FunctionAttributeKey.Brightness, e.ToString());
+                    //            Control.Ins.SendWriteCommand(function, d);
+                    //        })
+                    //        { IsBackground = true }.Start();
+                    //    }
+                    //    else
+                    //    {
+                    //        MainPage.Log("skip dimmer control!!");
+                    //    }
+                    //}
                 };
             }
         }

--
Gitblit v1.8.0