From d5088d3bb198c0f53d4716022f010a02ac393977 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 25 八月 2022 15:06:01 +0800
Subject: [PATCH] 2022年08月25日15:04:41

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs |  179 ++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 140 insertions(+), 39 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
index d88fe55..d9f0de4 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
@@ -7,12 +7,27 @@
 {
     public class InpOrOutLogicMethod
     {
+
+        private static InpOrOutLogicMethod s_Current = null;
+
+        public static InpOrOutLogicMethod Current
+        {
+            get
+            {
+                if (s_Current == null)
+                {
+                    s_Current = new InpOrOutLogicMethod();
+
+                }
+                return s_Current;
+            }
+        }
         /// <summary>
         /// 杈撳叆鏉′欢澶勭悊鏂规硶
         /// </summary>
         /// <param name="thisView">褰撳墠鐣岄潰</param>
         /// <param name="viewLayout">涓婁笅婊戝姩鎺т欢</param>
-        public static void InputCondition(FrameLayout thisView, VerticalScrolViewLayout viewLayout)
+        public void InputCondition(FrameLayout thisView, VerticalScrolViewLayout viewLayout)
         {
             for (int i = 0; i < Logic.currlogic.input.Count; i++)
             {
@@ -123,11 +138,12 @@
                         }
                         break;
                     case "3":
+                    case "9"://鍙瀵硅:9
                         {
                             //鐢╯id鎵惧埌璁惧锛�
-                            var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid);
+                            var device = LogicMethod.Current.GetDevice(inputCondition.sid);
                             //鐢ㄨ澶囩殑functionType绫诲瀷鎵惧埌瀵瑰簲鍥炬爣锛�
-                            inputView.btnIcon.UnSelectedImagePath = LogicMethod.CurrLogicMethod.GetIconPath(device.spk);
+                            inputView.btnIcon.UnSelectedImagePath = LogicMethod.Current.GetIconPath(device.spk);
                             //鏄剧ず璁惧鍚嶇О
                             inputView.btnText.Text = device.name;
                             //鏀瑰彉璁惧鍚嶇О鏄剧ず鎺т欢瀹藉害
@@ -358,7 +374,8 @@
                                             }
 
                                         }
-                                    }break;
+                                    }
+                                    break;
                                 case SPK.SenesorMegahealth2:
                                     {
                                         foreach (var dic in dicList)
@@ -445,7 +462,7 @@
                                     break;
                                 case SPK.SensorHumidity:
                                     {
-                                        string str = new InpOrOutLogicMethod { }.GetText(dicList, "humidity");
+                                        string str = this.GetText(dicList, "humidity");
                                         inputView.btnState.Text = str;
 
                                     }
@@ -455,7 +472,7 @@
                                 case SPK.SensorTVOC:
                                 case SPK.SensorHcho:
                                     {
-                                        string strvalue = ""; 
+                                        string strvalue = "";
                                         foreach (var dic in dicList)
                                         {
                                             strvalue = dic["value"];
@@ -475,6 +492,30 @@
                                                 inputView.btnState.Text = Language.StringByID(StringId.kaiqi);
                                             }
 
+                                        }
+                                    }
+                                    break;
+                                case SPK.doorgate:
+                                    {
+                                        if (inputCondition.identifier == "door_call_cloud_event")
+                                        {
+                                            inputView.btnState.Text = Language.StringByID(StringId.shipintonghuahujiao);
+                                        }
+                                        else
+                                        {
+
+                                            foreach (var dic in dicList)
+                                            {
+                                                string key = dic["key"];
+                                                if (key == "user_id")
+                                                {
+                                                    string userId = dic["value"];
+                                                    var FaceItem = this.FaceItem(userId, device.deviceId);
+                                                    inputView.btnState.Text = FaceItem.userName;
+                                                    // Language.StringByID(StringId.kaiqi);
+                                                }
+
+                                            }
                                         }
                                     }
                                     break;
@@ -623,7 +664,7 @@
                     case "10":
                         {
                             //鐢╯id鎵惧埌鍦烘櫙锛�
-                            var scene = LogicMethod.CurrLogicMethod.GetSecne(inputCondition.sid);
+                            var scene = LogicMethod.Current.GetSecne(inputCondition.sid);
                             inputView.btnIcon.UnSelectedImagePath = "LogicIcon/scene.png";
                             inputView.btnNextIcon.Visible = false;
                             inputView.btnClick.Visible = false;
@@ -638,19 +679,19 @@
                 {
                     Button button = (Button)sen;
                     //褰撳墠缂栬緫鐨勬潯浠�
-                    Input ckcliInput = inputView.btnClick.Tag as Input;
+                    Input clickInput = inputView.btnClick.Tag as Input;
                     //鎵惧埌褰撳墠缂栬緫鐨勭储寮�
                     int indexVulae = 0;
                     for (int index = 0; index < Logic.currlogic.input.Count; index++)
                     {
                         Input input = Logic.currlogic.input[index];
-                        if (input.sid == ckcliInput.sid)
+                        if (input.sid == clickInput.sid)
                         {
-                            if (button.Name == "3")
+                            if (button.Name == "3" || button.Name == "9")
                             {
                                 //鏈変簺璁惧姣旇緝鐗规畩锛堜緥濡傦細娴锋灄浼犳劅鍣ㄨ繕鏄鍒ゆ柇灞炴�у�硷紝娓╂箍搴﹀睘鎬ц繕瑕佸垽鏂瘮杈冨叧绯伙紝鎵嶈兘纭鏄惁宸茬粡瀛樺湪璇ユ潯浠讹紝鍏朵粬璁惧鏉′欢鐩存帴鐢╯id鍒ゆ柇鍗冲彲锛�
                                 //鍔犱竴绾у垽鏂槸涓哄吋瀹圭壒娈婅澶�
-                                if (new ConditionDeviceFunList { }.IsContainsAll(ckcliInput.condition, input.condition))
+                                if (new ConditionDeviceFunList { }.IsContainsAll(clickInput.condition, input.condition))
                                 {
                                     //鐢ㄦ埛鍙兘鍒犻櫎鏁版嵁锛屼娇鍒楄〃绱㈠紩鍙戠敓鏀瑰彉锛�
                                     //閫氳繃鍞竴sid閲嶆柊鏌ユ壘鍒扮储寮曚笖鏇存柊绱㈠紩鍊�
@@ -724,10 +765,11 @@
                                 timeTpye.TimeHorizon(fLayout, edit, indexVulae);
                             }
                             break;
+                        case "9":
                         case "3":
                             {
                                 //鐢╯id鎵惧埌璁惧锛�
-                                var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid);
+                                var device = LogicMethod.Current.GetDevice(inputCondition.sid);
                                 if (device.spk == SPK.SensorEnvironment
                                 || device.spk == SPK.SensorEnvironment2
                                 || device.spk == SPK.SensorEnvironment3
@@ -957,7 +999,7 @@
         /// </summary>
         /// <param name="thisView">褰撳墠鐣岄潰</param>
         /// <param name="viewLayout">涓婁笅婊戝姩鎺т欢</param>
-        public static void OutputTarget(FrameLayout thisView, VerticalScrolViewLayout viewLayout)
+        public void OutputTarget(FrameLayout thisView, VerticalScrolViewLayout viewLayout)
         {
 
             for (int i = 0; i < Logic.currlogic.output.Count; i++)
@@ -980,9 +1022,9 @@
                     case "1":
                         {
                             //鐢╯id鎵惧埌璁惧锛�
-                            var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid);
+                            var device = LogicMethod.Current.GetDevice(outputTarget.sid);
                             //鐢ㄨ澶囩殑functionType绫诲瀷鎵惧埌瀵瑰簲鍥炬爣锛�
-                            targetView.btnIcon.UnSelectedImagePath = LogicMethod.CurrLogicMethod.GetIconPath(device.spk);
+                            targetView.btnIcon.UnSelectedImagePath = LogicMethod.Current.GetIconPath(device.spk);
                             //鏄剧ず璁惧鍚嶇О
                             targetView.btnText.Text = device.name;
                             //鏀瑰彉璁惧鍚嶇О鏄剧ず鎺т欢瀹藉害
@@ -1069,7 +1111,7 @@
                                 case SPK.CurtainRoller:
                                     {
                                         string on_off = GetKeyValue("on_off", dicList);
-                                        string percent = GetKeyValue("percent", dicList); 
+                                        string percent = GetKeyValue("percent", dicList);
                                         if (on_off == "on" && percent != "")
                                         {
                                             stateStr = Language.StringByID(StringId.onLogic) + percent + "%";
@@ -1095,7 +1137,7 @@
                                         if (percent != "" && angle != "")
                                         {
                                             stateStr += Language.StringByID(StringId.onLogic) + percent + "%;";
-                                            stateStr +=Language.StringByID(StringId.Angle)+angle + "掳";
+                                            stateStr += Language.StringByID(StringId.Angle) + angle + "掳";
                                         }
                                         else if (percent != "")
                                         {
@@ -1207,7 +1249,8 @@
 
                                     }
                                     break;
-                                case SPK.FloorHeatStandard:case SPK.HvacFloorHeat:
+                                case SPK.FloorHeatStandard:
+                                case SPK.HvacFloorHeat:
                                     {
                                         string on_off = GetKeyValue("on_off", dicList);
                                         string set_temp = GetKeyValue("set_temp", dicList);
@@ -1339,13 +1382,25 @@
                                         }
                                     }
                                     break;
+                                case SPK.MusicStandard:
+                                case SPK.AvMusic:
+                                    {
+                                        foreach (var dic in dicList)
+                                        {
+                                            if (dic["key"] == "song_name")
+                                            {
+                                                stateStr = dic["value"]?.ToString();
+                                            }
+                                        }
+                                    }
+                                    break;
                             }
                         }
                         break;
                     case "2":
                         {
                             //鐢╯id鎵惧埌鍦烘櫙锛�
-                            var scene = LogicMethod.CurrLogicMethod.GetSecne(outputTarget.sid);
+                            var scene = LogicMethod.Current.GetSecne(outputTarget.sid);
                             targetView.btnIcon.UnSelectedImagePath = "LogicIcon/scene.png";
                             targetView.btnNextIcon.Visible = false;
                             //鏄剧ず鍦烘櫙鍚嶇О
@@ -1355,7 +1410,7 @@
                     case "3":
                         {
                             //鐢╯id鎵惧埌瀹夐槻锛�
-                            var security = LogicMethod.CurrLogicMethod.GetSecurity(outputTarget.sid);
+                            var security = LogicMethod.Current.GetSecurity(outputTarget.sid);
                             targetView.btnIcon.UnSelectedImagePath = "LogicIcon/security.png";
                             targetView.btnDelay.Visible = false;
                             //鏄剧ず瀹夐槻鍚嶇О 
@@ -1417,7 +1472,7 @@
                         case "1":
                             {
                                 //鐢╯id鎵惧埌璁惧锛�
-                                var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid);
+                                var device = LogicMethod.Current.GetDevice(outputTarget.sid);
                                 TargetDeviceFunList deviceFunList = new TargetDeviceFunList();
                                 MainPage.BasePageView.AddChidren(deviceFunList);
                                 deviceFunList.Show(device, indexVulae, edit);
@@ -1479,8 +1534,8 @@
         /// <param name="button1">鏄剧ずBtn</param>
         /// <param name="button2">鏄剧ずBtn</param>
         /// <param name="button3">鏄剧ずBtn</param>
-        /// <param name="button4">鏄剧ずBtn</param>
-        public static void EditState(Entity.Function device, List<Dictionary<string, string>> dicList, Button button1, Button button2, Button button3, Button button4)
+        /// <param name="button4">鏄剧ずBtn</param> 
+        public void EditDeviceState(Entity.Function device, List<Dictionary<string, string>> dicList, Button button1, Button button2, Button button3, Button button4)
         {
             switch (device.spk)
             {
@@ -1611,7 +1666,7 @@
                             }
 
                         }
-                        
+
                     }
                     break;
                 case SPK.CurtainDream:
@@ -1759,7 +1814,8 @@
 
                     }
                     break;
-                case SPK.FloorHeatStandard:case SPK.HvacFloorHeat:
+                case SPK.FloorHeatStandard:
+                case SPK.HvacFloorHeat:
                     {
 
                         foreach (var dic in dicList)
@@ -2057,7 +2113,7 @@
                             string value = dic["value"];
                             switch (dic["key"])
                             {
-                               
+
                                 case "target_status":
                                     {
                                         if (value == "4")
@@ -2109,7 +2165,30 @@
                             {
                                 button1.Text = Language.StringByID(StringId.shi);
                             }
-                           
+
+                        }
+                    }
+                    break;
+                case SPK.MusicStandard:
+                case SPK.AvMusic:
+                    {
+                        foreach (var dic in dicList)
+                        {
+                            if (dic["key"] == "song_name")
+                            {
+                                button1.Text = dic["value"]?.ToString();
+                            }
+                        }
+                    }
+                    break;
+                case SPK.doorgate:
+                    {
+                        foreach (var dic in dicList)
+                        {
+                            if (dic["key"] == "user_id")
+                            {
+                                button2.Text = dic["value"]?.ToString();
+                            }
                         }
                     }
                     break;
@@ -2121,7 +2200,7 @@
         /// <param name="keyValue"></param>
         /// <param name="dicList"></param>
         /// <returns></returns>
-        public static string GetKeyValue(string keyValue, List<Dictionary<string, string>> dicList)
+        public string GetKeyValue(string keyValue, List<Dictionary<string, string>> dicList)
         {
 
             string valueStr = "";
@@ -2140,7 +2219,7 @@
         ///鑾峰彇鑷姩鍖栧悕绉�
         /// </summary>
         /// <returns> 鏂板缓鑷姩鍖栧懡鍚嶈鍒�</returns>
-        public static string GetLogicName(Logic logic)
+        public string GetLogicName(Logic logic)
         {
 
             string name = "";
@@ -2163,16 +2242,17 @@
                         }
                         break;
                     case "3":
+                    case "9":
                         {
                             //鐢╯id鎵惧埌璁惧锛�
-                            var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid);
+                            var device = LogicMethod.Current.GetDevice(inputCondition.sid);
                             name = device.name + "-";
                         }
                         break;
                     case "10":
                         {
                             //鐢╯id鎵惧埌鍦烘櫙锛�
-                            var scene = LogicMethod.CurrLogicMethod.GetSecne(inputCondition.sid);
+                            var scene = LogicMethod.Current.GetSecne(inputCondition.sid);
                             name = scene.name + "-";
                         }
                         break;
@@ -2187,7 +2267,7 @@
                     case "1":
                         {
                             //鐢╯id鎵惧埌璁惧锛�
-                            var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid);
+                            var device = LogicMethod.Current.GetDevice(outputTarget.sid);
                             //鏄剧ず璁惧鍚嶇О
                             name += device.name;
                             string stateStr = "";
@@ -2218,8 +2298,8 @@
                                 case SPK.LightCCT:
                                 case SPK.LightDimming:
                                     {
-                                        string on_off = InpOrOutLogicMethod.GetKeyValue("on_off", dicList);
-                                        string brightness = InpOrOutLogicMethod.GetKeyValue("brightness", dicList);
+                                        string on_off = this.GetKeyValue("on_off", dicList);
+                                        string brightness = this.GetKeyValue("brightness", dicList);
                                         if (on_off == "on" && brightness != "")
                                         {
                                             stateStr = Language.StringByID(StringId.onLogic) + brightness + "%";
@@ -2268,7 +2348,8 @@
                                     break;
                                 case SPK.AcStandard:
                                 case SPK.HvacAC:
-                                case SPK.FloorHeatStandard:case SPK.HvacFloorHeat:
+                                case SPK.FloorHeatStandard:
+                                case SPK.HvacFloorHeat:
                                     {
                                         foreach (var dic in dicList)
                                         {
@@ -2294,7 +2375,7 @@
                     case "2":
                         {
                             //鐢╯id鎵惧埌鍦烘櫙锛�
-                            var scene = LogicMethod.CurrLogicMethod.GetSecne(outputTarget.sid);
+                            var scene = LogicMethod.Current.GetSecne(outputTarget.sid);
                             name += scene.name;
 
                         }
@@ -2302,7 +2383,7 @@
                     case "3":
                         {
                             //鐢╯id鎵惧埌瀹夐槻锛�
-                            var security = LogicMethod.CurrLogicMethod.GetSecurity(outputTarget.sid);
+                            var security = LogicMethod.Current.GetSecurity(outputTarget.sid);
                             name += security.name;
 
                         }
@@ -2423,7 +2504,7 @@
         /// </summary>
         /// <param name="dicList">鐘舵�佹暟鎹垪琛�</param>
         /// <returns></returns>
-        private string GetText(List<Dictionary<string, string>> dicList,string key)
+        private string GetText(List<Dictionary<string, string>> dicList, string key)
         {
             string strtext = "";
             foreach (var dic in dicList)
@@ -2483,7 +2564,8 @@
             }
             return strtext;
         }
-        private void SensorView(FrameLayout thisView, Function device,string key, int indexVulae) {
+        private void SensorView(FrameLayout thisView, Function device, string key, int indexVulae)
+        {
             //杩欎釜璁惧姣旇緝鐗规畩
             ConditionDeviceFunList conditionDeviceFunList = new ConditionDeviceFunList();
             ///褰撳墠鐨勭储寮曞�兼暟鎹璞�
@@ -2548,6 +2630,25 @@
                 }
             }
         }
+        /// <summary>
+        /// 鏌ユ壘鎸囧畾userId
+        /// </summary>
+        /// <param name="userId"></param>
+        /// <returns></returns>
+        public Face FaceItem(string userId, string deviceId)
+        {
+            if (Send.Current.faceList.Count == 0)
+            {
+                Send.Current.GetListHomeFace(deviceId, false);
+            }
+            var face = Send.Current.faceList.Find((o) => { return o.userId == userId; });
+            if (face == null)
+            {
+                face = new Face();
+            }
+            return face;
+        }
+
     }
 }
 

--
Gitblit v1.8.0