From 43b0d5870d528f23ecd6aeceb6cfd4325188b46f Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 01 七月 2021 15:50:43 +0800
Subject: [PATCH] Revert "1"

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs |  383 ++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 270 insertions(+), 113 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
index 6d5a498..3cbd448 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
@@ -55,48 +55,149 @@
                 //鍦扮儹
                 case SPK.FloorHeatStandard:
                     {
-                        LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
-                        lightSwitchView.btnText.TextID = StringId.switchLogic;
-                        lightSwitchView.btnState.Text = "";
-                        fLayout.AddChidren(lightSwitchView.FLayoutView());
-                        lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
-                        {
-                            FrameLayout frame = new FrameLayout
-                            {
-                                BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
-                            };
-                            this.AddChidren(frame);
-                            LogicView.SwitchView switchView = new LogicView.SwitchView();
-                            switchView.FLayoutView(frame, 2, lightSwitchView.btnState.Text, (strValue) =>
-                            {
-                                int id = 0;
-                                switch (strValue)
-                                {
-                                    case "on":
-                                        {
-                                            id = StringId.onLogic;
-                                        }
-                                        break;
-                                    case "off":
-                                        {
-                                            id = StringId.offLogic;
-                                        }
-                                        break;
-                                }
-                                //鏄剧ず鏂囨湰
-                                lightSwitchView.btnState.TextID = id;
-                                selectedState = device.functionType + "_" + strValue;
-                                //璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�;
-                                string keyVlaue = "on_off";
-                                AddDictionary(keyVlaue, strValue);
 
-                            });
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.switchLogic;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.onLogic, StringId.offLogic);
                         };
                         if (edit)
                         {
-                            GetEditState(device, index, lightSwitchView.btnState, null, null, null);
+                            GetEditState(device, index, view.btnState, null, null, null);
+                        }
+                    }
+                    break;
+                //姘存蹈浼犳劅鍣�
+                case SPK.SensorWater:
+                    {
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.luoshuiandwuluoshui;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.luoshui, StringId.wuluoshui);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, null, null, null);
                         }
 
+                    }
+                    break;
+                //鐑熼浘浼犳劅鍣�
+                case SPK.SensorSmoke:
+                //鐕冩皵浼犳劅鍣�
+                case SPK.SensorGas:
+                    {
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.xieluoandwuxieluo;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.xieluo, StringId.wuxieluo);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, null, null, null);
+                        }
+
+                    }
+                    break;
+                //骞叉帴鐐�
+                case SPK.SensorDryContact:
+                    {
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.switchLogic;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.onLogic, StringId.offLogic);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, null, null, null);
+                        }
+
+                    }
+                    break;
+                //绾㈠鐝婃爮浼犳劅鍣�
+                case SPK.SensorShanLan:
+                //绾㈠瀵瑰皠浼犳劅鍣�
+                case SPK.SensorDuiShe:
+                //绾㈠绉诲姩浼犳劅鍣�
+                case SPK.SensorPir:
+                    {
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.yourenandwuren;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.youren, StringId.wuren);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, null, null, null);
+                        }
+                    }
+                    break;
+                //闂ㄧ獥浼犳劅鍣�
+                case SPK.SensorDoorWindow:
+                    {
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.kaiqiandbihe;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.kaiqi, StringId.bihe);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, null, null, null);
+                        }
+                    }
+                    break;
+                //瓒呭0娉紶鎰熷櫒
+                case SPK.SensoruUtrasonic:
+                    {
+
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.yourenandwuren;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.youren, StringId.wuren);
+                        };
+                        LogicView.FunTypeView view1 = new LogicView.FunTypeView();
+                        view1.frameLayout.Y = view.frameLayout.Bottom;
+                        view1.btnText.TextID = StringId.fangchaigongneng;
+                        fLayout.AddChidren(view1.FLayoutView());
+                        view1.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view1.btnState, StringId.zaixian, StringId.buzaixian);
+                        };
+
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, view1.btnState, null, null);
+                        }
+                    }
+                    break;
+                //姣背娉紶鎰熷櫒
+                case SPK.SenesorMegahealth:
+                    {
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.mubiaozhuangtai ;//鐩爣鐘舵��
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.wuren, StringId.diedao);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, null, null, null);
+                        }
                     }
                     break;
 
@@ -139,53 +240,138 @@
                     return;
                 }
                 LogicMethod.RemoveAllView();
-                AddLogic addLogic = new AddLogic();
-                MainPage.BasePageView.AddChidren(addLogic);
-                addLogic.Show();
-                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+
+                if (MainView.IsGatewayType)
+                { //A缃戝叧
+                    var addLogic = new AddLogic();
+                    MainPage.BasePageView.AddChidren(addLogic);
+                    addLogic.Show();
+                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                }
+                else
+                {
+                    //涓�绔彛缃戝叧
+                    var onePortAutomation = new OnePortAutomation();
+                    MainPage.BasePageView.AddChidren(onePortAutomation);
+                    onePortAutomation.Show();
+                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                }
             };
 
             #endregion
 
         }
         /// <summary>
-        /// 寮�鍏冲姛鑳藉睍寮�鐣岄潰
+        /// 璁惧閫夋嫨鏉′欢鐣岄潰
         /// </summary>
-        /// <param name="frame"></param>
-        /// <param name="device"></param>
-        /// <param name="button"></param>
-        /// <param name="len"></param>
-        public void SwitchViewMethod(FrameLayout frame, Entity.Function device, Button button, int len)
-        {
-
+        /// <param name="device">璁惧</param>
+        /// <param name="button">閫変腑鐘舵�佹樉绀烘枃鏈珺tn鎺т欢</param>
+        /// <param name="btnText1">灞炴�х姸鎬佸�兼枃鏈�1</param>
+        /// <param name="btnText2">灞炴�х姸鎬佸�兼枃鏈�2</param>
+        private void DeviceView(Entity.Function device,Button button,int btnText1,int btnText2) { 
+            FrameLayout frame = new FrameLayout { BackgroundColor = CSS.CSS_Color.viewTrans60lucence };
+            this.AddChidren(frame);
             LogicView.SwitchView switchView = new LogicView.SwitchView();
-            switchView.FLayoutView(frame, len, button.Text, (Action<string>)((strValue) =>
+            switchView.FLayoutView(frame, btnText1, btnText2, button.Text, (intValue) =>
             {
-                int id = 0;
-                switch (strValue)
+                //璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�;
+                string keyVlaue = "on_off";
+                string value = "";
+                switch (device.spk)
                 {
-                    case "on":
+                    //浼犳劅鍣�
+                    case SPK.SensorWater:
+                    case SPK.SensorSmoke:
+                    case SPK.SensorGas:
+                    case SPK.SensorDryContact:
+                    case SPK.SensorShanLan:
+                    case SPK.SensorDuiShe:
+                    case SPK.SensorPir:
+                    case SPK.SensorDoorWindow:
+                    case SPK.SensoruUtrasonic:
                         {
-                            id = StringId.onLogic;
+                            keyVlaue = "status";
                         }
                         break;
-                    case "off":
+                    case SPK.SenesorMegahealth:
                         {
-                            id = StringId.offLogic;
+                            keyVlaue = "action_state";
                         }
                         break;
-                }
-                button.TextID = id;
-                keyVlaue = "on_off";
-                Dictionary<string, string> dic = new Dictionary<string, string>();
-                LogicMethod.dictionary(dic, "key", "on_off");
-                LogicMethod.dictionary(dic, "comparator", "=");
-                LogicMethod.dictionary(dic, "data_type", "string");
-                LogicMethod.dictionary(dic, "value", strValue);
-                AddDictionaryData(dicSateteList, keyVlaue, dic);
-                selectedState = device.spk + "_" + strValue;
 
-            }));
+                }
+                switch (intValue)
+                {
+                    case StringId.xieluo:
+                    case StringId.luoshui:
+                        {
+                            value = "alarm";
+                        }
+                        break;
+                    case StringId.wuxieluo:
+                    case StringId.wuluoshui:
+                        {
+                            value = "normal";
+                        }
+                        break;
+                    case StringId.onLogic:
+                        {
+                            value = "on";
+                        }
+                        break;
+                    case StringId.offLogic:
+                        {
+                            value = "off";
+                        }
+                        break;
+                    case StringId.youren:
+                        {
+                            value = "true";
+                        }
+                        break;
+                    case StringId.wuren:
+                        {
+                            if (device.spk == SPK.SenesorMegahealth)
+                            {
+                                value = "uninhabited";
+                            }
+                            else
+                            {
+                                value = "false";
+                            }
+                        }
+                        break;
+                    case StringId.kaiqi:
+                        {
+                            value = "open";
+                        }
+                        break;
+                    case StringId.bihe:
+                        {
+                            value = "close";
+                        }
+                        break;
+                    case StringId.zaixian:
+                        {
+                            keyVlaue = "dismantle";
+                            value = "true";
+                        }; break;
+                    case StringId.buzaixian:
+                        {
+                            keyVlaue = "dismantle";
+                            value = "false";
+                        }; break;
+                    case StringId.diedao:
+                        {
+                            value = "fall";
+                        }; break;
+                }
+                //鏄剧ず鏂囨湰
+                button.TextID = intValue;
+                selectedState = device.spk + "_" + value;
+                AddDictionary(keyVlaue, value, "string");
+
+            });
 
         }
         /// <summary>
@@ -208,39 +394,6 @@
                 //鏈夋暟鎹噸鏂拌祴鍊�
                 dicSateteList = dicList;
             }
-            switch (device.spk)
-            {
-                //寮�鍏崇伅鍏� light.Switch
-                case SPK.LightDimming:
-                case SPK.LightRGB:
-                case SPK.LightRGBW:
-                case SPK.LightCCT:
-                case SPK.LightSwitch:
-                //绐楀笜
-                case SPK.CurtainSwitch:
-                case SPK.CurtainRoller:
-                case SPK.CurtainTrietex:
-                //绌鸿皟
-                case SPK.AcStandard:
-                //鍦扮儹
-                case SPK.FloorHeatStandard:
-                    {
-                        foreach (var dic in dicList)
-                        {
-                            string value = dic["value"];
-                            if (value == "on")
-                            {
-                                button1.Text = Language.StringByID(StringId.onLogic);
-                            }
-                            else
-                            {
-                                button1.Text = Language.StringByID(StringId.offLogic);
-                            }
-                        }
-                    }
-                    break;
-
-            }
             InpOrOutLogicMethod.EditState(device, dicList, button1, button2, button3, button4);
         }
         /// <summary>
@@ -248,30 +401,34 @@
         /// </summary>
         /// <param name="KeyValue">璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�</param>
         /// <param name="selectedValue">鐘舵�佸��</param>
-        private void AddDictionary(string KeyValue, string selectedValue)
+        /// <param name="data_type">绫诲瀷</param>
+        /// <param name="comparator">姣旇緝鍏崇郴</param>
+        private void AddDictionary(string KeyValue, string selectedValue,string data_type,string comparator="=")
         {
             //鏁版嵁灏佽
             Dictionary<string, string> dic = new Dictionary<string, string>();
             LogicMethod.dictionary(dic, "key", KeyValue);
-            LogicMethod.dictionary(dic, "comparator", "=");
-            LogicMethod.dictionary(dic, "data_type", "string");
+            LogicMethod.dictionary(dic, "comparator", comparator);
+            LogicMethod.dictionary(dic, "data_type", data_type);
             LogicMethod.dictionary(dic, "value", selectedValue);
-            AddDictionaryList(KeyValue, dic, dicSateteList);
+            AddDictionaryList(KeyValue, comparator,dic);
         }
         /// <summary>
         /// 鏇存柊鏁版嵁鍒楄〃
         /// </summary>
-        /// <param name="keyValue">璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�</param> 
-        /// <param name="dictionary">閫変腑鏁版嵁</param>
-        /// <param name="dicList">瀛樺偍鏁版嵁鍒楄〃</param>
+        /// <param name="keyValue">璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�</param>
+        /// <param name="comparator">姣旇緝鍏崇郴</param>
+        /// <param name="dictionary">娣诲姞閫変腑鏁版嵁</param>
         /// <returns></returns>
-        private void AddDictionaryList(string keyValue, Dictionary<string, string> dictionary, List<Dictionary<string, string>> dicList)
+        private void AddDictionaryList(string keyValue,string comparator, Dictionary<string, string> dictionary) 
         {
             int indexValue = -1;
-            for (int i = 0; i < dicList.Count; i++)
+            for (int i = 0; i < dicSateteList.Count; i++)
             {
-                var dic = dicList[i];
-                if (dic.ContainsValue(keyValue))
+                var dic = dicSateteList[i];
+                string key = dic["key"];
+                string comparatorValue = dic["comparator"];
+                if (key == keyValue && comparatorValue == comparator)
                 {
                     //鍒ゆ柇鏄惁瀛樺湪
                     indexValue = i;
@@ -282,14 +439,14 @@
             if (indexValue != -1)
             {
                 //瀛樺湪绉婚櫎
-                dicList.RemoveAt(indexValue);
+                dicSateteList.RemoveAt(indexValue);
                 //閲嶆柊娣诲姞
-                dicList.Insert(indexValue, dictionary);
+                dicSateteList.Insert(indexValue, dictionary);
             }
             else
             {
                 //鏂版坊鍔�
-                dicList.Add(dictionary);
+                dicSateteList.Add(dictionary);
             }
 
         }

--
Gitblit v1.8.0