From 9eec81850e418a3c16410b4870910bde142b06e3 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 14 九月 2022 15:50:00 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/Dev-Branch' into wjc

---
 HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs |  260 +++++++++++++++++++++++++++++++--------------------
 1 files changed, 157 insertions(+), 103 deletions(-)

diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
index 8177983..afe7efb 100644
--- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
+++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
@@ -14,46 +14,46 @@
         /// </summary>
         public static void LoadEvent_RefreshDevcieOnline(Function function)
         {
-            //Application.RunOnMainThread(() =>
-            //{
-            //    if (bodyView != null)
-            //    {
-            //        foreach (var view in bodyView.functionViews)
-            //        {
-            //            if (view.Tag.ToString() == function.sid)
-            //            {
-            //                for (int i = 0; i < view.ChildrenCount; i++)
-            //                {
-            //                    if (view.GetChildren(i).GetType() == typeof(Button))
-            //                    {
-            //                        var btn = view.GetChildren(i) as Button;
-            //                        if(btn.Tag == null)
-            //                        {
-            //                            continue;
-            //                        }
-            //                        if (btn.Tag.ToString() == function.sid)
-            //                        {
-            //                            if (function.online)
-            //                            {
-            //                                btn.UnSelectedImagePath = "Collection/Functionbg.png";
-            //                                btn.IsSelected = false;
-            //                            }
-            //                            else
-            //                            {
-            //                                btn.UnSelectedImagePath = "Collection/FunctionOfflineBg.png";
-            //                                btn.IsSelected = false;
-            //                            }
-            //                        }
-            //                        else if (btn.Tag.ToString() == "OnlineTag")
-            //                        {
-            //                            btn.Visible = !function.online;
-            //                        }
-            //                    }
-            //                }
-            //            }
-            //        }
-            //    }
-            //});
+            Application.RunOnMainThread(() =>
+            {
+                if (bodyView != null)
+                {
+                    foreach (var view in bodyView.functionViews)
+                    {
+                        if (view.Tag.ToString() == function.sid)
+                        {
+                            for (int i = 0; i < view.ChildrenCount; i++)
+                            {
+                                if (view.GetChildren(i).GetType() == typeof(Button))
+                                {
+                                    var btn = view.GetChildren(i) as Button;
+                                    if(btn.Tag == null)
+                                    {
+                                        continue;
+                                    }
+                                    if (btn.Tag.ToString() == function.sid)
+                                    {
+                                        if (function.online)
+                                        {
+                                            btn.UnSelectedImagePath = "Collection/Functionbg.png";
+                                            btn.IsSelected = false;
+                                        }
+                                        else
+                                        {
+                                            btn.UnSelectedImagePath = "Collection/FunctionOfflineBg.png";
+                                            btn.IsSelected = false;
+                                        }
+                                    }
+                                    else if (btn.Tag.ToString() == "OnlineTag")
+                                    {
+                                        btn.Visible = !function.online;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            });
         }
         /// <summary>
         /// 鏇存柊涓婚〉澶╂皵
@@ -395,16 +395,63 @@
 
                                 var state = false;
                                 if (function.spk == SPK.CurtainRoller || function.spk == SPK.CurtainShades || function.spk == SPK.CurtainTrietex ||
-                                function.spk == SPK.CurtainSwitch)//绐楀笜璁惧鏍规嵁鐧惧垎姣斿垽鏂紑鍏崇姸鎬�
+                                function.spk == SPK.CurtainSwitch || function.spk == SPK.CurtainDream)//绐楀笜璁惧鏍规嵁鐧惧垎姣斿垽鏂紑鍏崇姸鎬�
                                 {
                                     if (function.GetAttribute(FunctionAttributeKey.Percent) != null)
                                     {
                                         state = function.GetAttrState(FunctionAttributeKey.Percent) != "0";
-                                    }else
+                                    }
+                                    else
                                     {
                                         if (function.GetAttrState(FunctionAttributeKey.OnOff) == "stop")
                                             return;
                                         state = function.trait_on_off.curValue.ToString() == "on";
+                                    }
+                                }
+                                else if (function.spk == SPK.SenesorMegahealth)
+                                {
+
+                                    var tempStatus = function.attributes.Find((sta) => sta.key == FunctionAttributeKey.TargetStatus);
+                                    if (tempStatus != null)
+                                    {
+                                        switch (tempStatus.state)
+                                        {//0绌猴紝1璧帮紝2璺戯紝3鍧愶紝4璺屽�掞紝5绔�
+                                            case "0":
+                                                state = false;
+                                                break;
+                                            case "1":
+                                                state = true;
+                                                break;
+                                            case "2":
+                                                if (function.extSet.labModel)
+                                                {
+                                                    state = true;
+                                                }
+                                                break;
+                                            case "3":
+                                                if (function.extSet.labModel)
+                                                {
+                                                    state = true;
+                                                }
+                                                break;
+                                            case "4":
+                                                state = true;
+                                                break;
+                                            case "5":
+                                                if (function.extSet.labModel)
+                                                {
+                                                    state = true;
+                                                }
+                                                break;
+                                        }
+                                    }
+                                }
+                                else if(function.spk == SPK.SensorHelp)
+                                {
+                                    var tempStatus = function.attributes.Find((sta) => sta.key == FunctionAttributeKey.AlarmStatus);
+                                    if(tempStatus != null)
+                                    {
+                                        state = tempStatus.curValue.ToString() == "alarm";
                                     }
                                 }
                                 else
@@ -427,7 +474,14 @@
                                             {
                                                 if (function.spk != SPK.LightSwitch)
                                                 {
-                                                    btn.Text = function.lastState;
+                                                    if (function.spk == SPK.SensorHelp)
+                                                    {
+                                                        btn.TextID = StringId.InAlarming;
+                                                    }
+                                                    else
+                                                    {
+                                                        btn.Text = function.lastState;
+                                                    }
                                                 }
                                             }
                                         }
@@ -514,16 +568,16 @@
         {
             btnSwitch.MouseUpEventHandler = (sender, e) =>
             {
-                //if (!function.online)//绂荤嚎涓嶅厑璁告搷浣�
-                //{
-                //    new Tip()
-                //    {
-                //        CloseTime = 1,
-                //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
-                //        Direction = AMPopTipDirection.None,
-                //    }.Show(MainPage.BaseView);
-                //    return;
-                //}
+                if (!function.online)//绂荤嚎涓嶅厑璁告搷浣�
+                {
+                    new Tip()
+                    {
+                        CloseTime = 1,
+                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                        Direction = AMPopTipDirection.None,
+                    }.Show(MainPage.BaseView);
+                    return;
+                }
                 btnSwitch.IsSelected = !btnSwitch.IsSelected;
                 new System.Threading.Thread(() =>
                 {
@@ -577,16 +631,16 @@
         {
             btnSwitch.MouseUpEventHandler = (sender, e) =>
             {
-                //if (!function.online)//绂荤嚎涓嶅厑璁告搷浣�
-                //{
-                //    new Tip()
-                //    {
-                //        CloseTime = 1,
-                //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
-                //        Direction = AMPopTipDirection.None,
-                //    }.Show(MainPage.BaseView);
-                //    return;
-                //}
+                if (!function.online)//绂荤嚎涓嶅厑璁告搷浣�
+                {
+                    new Tip()
+                    {
+                        CloseTime = 1,
+                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                        Direction = AMPopTipDirection.None,
+                    }.Show(MainPage.BaseView);
+                    return;
+                }
                 if (DB_ResidenceData.Instance.GatewayType == 1)
                 {
                     btnSwitch.IsSelected = !btnSwitch.IsSelected;
@@ -621,16 +675,16 @@
         {
             btnClose.MouseUpEventHandler = (sender, e) =>
             {
-                //if (!curtain.online)//绂荤嚎涓嶅厑璁告搷浣�
-                //{
-                //    new Tip()
-                //    {
-                //        CloseTime = 1,
-                //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
-                //        Direction = AMPopTipDirection.None,
-                //    }.Show(MainPage.BaseView);
-                //    return;
-                //}
+                if (!curtain.online)//绂荤嚎涓嶅厑璁告搷浣�
+                {
+                    new Tip()
+                    {
+                        CloseTime = 1,
+                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                        Direction = AMPopTipDirection.None,
+                    }.Show(MainPage.BaseView);
+                    return;
+                }
                 btnClose.IsSelected = true;
                 curtain.trait_on_off.curValue = "off";
                 curtain.SetAttrState(FunctionAttributeKey.Percent, 0);
@@ -641,16 +695,16 @@
 
             btnOpen.MouseUpEventHandler = (sender, e) =>
             {
-                //if (!curtain.online)//绂荤嚎涓嶅厑璁告搷浣�
-                //{
-                //    new Tip()
-                //    {
-                //        CloseTime = 1,
-                //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
-                //        Direction = AMPopTipDirection.None,
-                //    }.Show(MainPage.BaseView);
-                //    return;
-                //}
+                if (!curtain.online)//绂荤嚎涓嶅厑璁告搷浣�
+                {
+                    new Tip()
+                    {
+                        CloseTime = 1,
+                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                        Direction = AMPopTipDirection.None,
+                    }.Show(MainPage.BaseView);
+                    return;
+                }
                 btnOpen.IsSelected = true;
                 curtain.trait_on_off.curValue = "on";
                 curtain.SetAttrState(FunctionAttributeKey.Percent, 100);
@@ -671,16 +725,16 @@
             };
             btnUp.MouseUpEventHandler = (sender, e) =>
             {
-                //if (!function.online)//绂荤嚎涓嶅厑璁告搷浣�
-                //{
-                //    new Tip()
-                //    {
-                //        CloseTime = 1,
-                //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
-                //        Direction = AMPopTipDirection.None,
-                //    }.Show(MainPage.BaseView);
-                //    return;
-                //}
+                if (!function.online)//绂荤嚎涓嶅厑璁告搷浣�
+                {
+                    new Tip()
+                    {
+                        CloseTime = 1,
+                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                        Direction = AMPopTipDirection.None,
+                    }.Show(MainPage.BaseView);
+                    return;
+                }
                 new System.Threading.Thread(() =>
                 {
                     System.Threading.Thread.Sleep(2000);
@@ -702,16 +756,16 @@
             };
             btnDown.MouseUpEventHandler = (sender, e) =>
             {
-                //if (!function.online)//绂荤嚎涓嶅厑璁告搷浣�
-                //{
-                //    new Tip()
-                //    {
-                //        CloseTime = 1,
-                //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
-                //        Direction = AMPopTipDirection.None,
-                //    }.Show(MainPage.BaseView);
-                //    return;
-                //}
+                if (!function.online)//绂荤嚎涓嶅厑璁告搷浣�
+                {
+                    new Tip()
+                    {
+                        CloseTime = 1,
+                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                        Direction = AMPopTipDirection.None,
+                    }.Show(MainPage.BaseView);
+                    return;
+                }
                 new System.Threading.Thread(() =>
                 {
                     System.Threading.Thread.Sleep(2000);

--
Gitblit v1.8.0