HDL-ON_Android/Assets/Phone/Collection/GatewayOnlineTipIcon.png
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" /> 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" /> <!--友盟--> 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" /> HDL-ON_iOS/Resources/Phone/Collection/GatewayOnlineTipIcon.png
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); 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"); 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> /// 获取本地控制数据 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); HDL_ON/UI/UI1-Login/LoginPage.cs
@@ -386,7 +386,7 @@ }; #endif #region 登录方式选择 #region 登录方式选择 btnPhoneLogin = new Button() { X = Application.GetRealWidth(28), 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); //更新链接状态icon颜色 #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, 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 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) 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) { 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) { 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); 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 + "%"; }; 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; 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; } } 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((() => { //解决部分安卓手机,刷新图片时会变小问题 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) { //解决部分安卓手机,刷新图片时会变小问题 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") { //解决部分安卓手机,刷新图片时会变小问题 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) { //解决部分安卓手机,刷新图片时会变小问题 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!!"); // } //} }; } } 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") { //解决部分安卓手机,刷新图片时会变小问题 if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheel.png") { bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png"; if (updateTemp.trait_on_off.curValue.ToString() == "on") { //解决部分安卓手机,刷新图片时会变小问题 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) { //解决部分安卓手机,刷新图片时会变小问题 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) { //解决部分安卓手机,刷新图片时会变小问题 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!!"); // } //} }; } }