From 6b7a07bcbe147be7ed64994c40bcc5b0a2042aae Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 05 七月 2021 11:23:35 +0800
Subject: [PATCH] 代码合并-温居城

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs |  291 ++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 213 insertions(+), 78 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
index 7e25ab5..c2f9703 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
@@ -20,12 +20,14 @@
                 ///鍚勭鏉′欢鐨刅iew
                 LogicView.AddOutputInputView inputView = new LogicView.AddOutputInputView();
                 inputView.FLayoutView(viewLayout);
+                //娣诲姞娌℃湁寤舵椂锛岄殣钘忓欢鏃舵寜閽�;
+                inputView.btnDelay.Visible = false;
                 ///璁板綍鏉′欢绫诲瀷
                 inputView.btnClick.Name = inputCondition.condition_type;
                 ///璁板綍鏉′欢绱㈠紩
-                inputView.btnClick.Tag = inputCondition.sid;
+                inputView.btnClick.Tag = inputCondition;
                 ///鏉′欢鐘舵�佹暟缁�
-                List<Dictionary<string, string>> dicList = inputCondition.condition as List<Dictionary<string, string>>;
+                List<Dictionary<string, string>> dicList = inputCondition.condition;
                 //鏄剧ず鏉′欢鍚勭绫诲瀷鐘舵��
                 switch (inputCondition.condition_type)
                 {
@@ -123,9 +125,9 @@
                     case "3":
                         {
                             //鐢╯id鎵惧埌璁惧锛�
-                            var device = LogicMethod.GetDevice(inputCondition.sid);
+                            var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid);
                             //鐢ㄨ澶囩殑functionType绫诲瀷鎵惧埌瀵瑰簲鍥炬爣锛�
-                            inputView.btnIcon.UnSelectedImagePath = LogicMethod.GetIconPath(device.spk);
+                            inputView.btnIcon.UnSelectedImagePath = LogicMethod.CurrLogicMethod.GetIconPath(device.spk);
                             //鏄剧ず璁惧鍚嶇О
                             inputView.btnText.Text = device.name;
                             //鏀瑰彉璁惧鍚嶇О鏄剧ず鎺т欢瀹藉害
@@ -268,7 +270,7 @@
                                                     {
                                                         if (value == "true")
                                                         {
-                                                            str+= Language.StringByID(StringId.youren)+";";
+                                                            str += Language.StringByID(StringId.youren) + ";";
                                                         }
                                                         else
                                                         {
@@ -313,6 +315,65 @@
                                         }
                                     }
                                     break;
+                                case SPK.SenesorEnvironment:
+                                    {
+                                        string strtext = "";
+                                        foreach (var dic in dicList)
+                                        {
+                                            string key = dic["key"];
+                                            string value = dic["value"];
+                                            string comparator = dic["comparator"];
+                                            switch (key)
+                                            {
+
+                                                case "temperature":
+                                                    {
+                                                        if (comparator == ">")
+                                                        {
+                                                            strtext = ">" + value + "鈩�";
+                                                        }
+                                                        else if (comparator == "<")
+                                                        {
+                                                            strtext = "<" + value + "鈩�";
+                                                        }
+
+                                                    }
+                                                    break;
+                                                case "humidity":
+                                                    {
+                                                        if (comparator == ">")
+                                                        {
+                                                            strtext = ">" + value + "%";
+                                                        }
+                                                        else if (comparator == "<")
+                                                        {
+                                                            strtext = "<" + value + "%";
+                                                        }
+
+                                                    }
+                                                    break;
+                                                case "co2":
+                                                    {
+                                                        strtext = Language.StringByID(StringId.co2) + new PublicInterface { }.GetString("co2", value);
+                                                    }
+                                                    break;
+                                                case "pm25":
+                                                    {
+                                                        strtext = Language.StringByID(StringId.pm25) + new PublicInterface { }.GetString("pm25", value);
+                                                    }
+                                                    break;
+                                                case "tvoc":
+                                                    {
+                                                        strtext = Language.StringByID(StringId.tvoc) + new PublicInterface { }.GetString("tvoc", value);
+                                                    }
+                                                    break;
+                                            }
+                                            inputView.btnState.Text = strtext;
+                                        }
+
+
+                                    }
+                                    break;
 
                             }
                         }
@@ -332,7 +393,7 @@
                                 {
                                     case "outdoor_temp":
                                         {
-                                            strvalue = value;
+                                            strvalue = value + "鈩�";
                                             if (comparator == ">")
                                             {
                                                 strtext = Language.StringByID(StringId.wendugaoyu);
@@ -346,7 +407,7 @@
                                         break;
                                     case "outdoor_humity":
                                         {
-                                            strvalue = value;
+                                            strvalue = value + "%";
                                             if (comparator == ">")
                                             {
                                                 strtext = Language.StringByID(StringId.shidugaoyu);
@@ -361,7 +422,7 @@
                                     case "pm2.5":
                                         {
                                             strtext = Language.StringByID(StringId.PM25);
-                                            strvalue = new OutdoorEnvironment { }.GetString(value);
+                                            strvalue = new PublicInterface { }.GetString("pm25", value);
                                         }
                                         break;
 
@@ -407,57 +468,40 @@
                             }
                         }
                         break;
-                    case "9":
-                        {
-                            inputView.btnIcon.UnSelectedImagePath = "LogicIcon/changesinoutdoor.png";
-                            foreach (var dic in dicList)
-                            {
-                                string strtext = "";
-                                string value = dic["value"];
-                                switch (value)
-                                {
-                                    case "excellent":
-                                        {
-                                            strtext = Language.StringByID(StringId.kongqiyou);
-
-                                        }
-                                        break;
-                                    case "good":
-                                        {
-
-                                            strtext = Language.StringByID(StringId.kongqiliang);
-
-                                        }
-                                        break;
-                                    case "poor":
-                                        {
-                                            strtext = Language.StringByID(StringId.kongqicha);
-                                        }
-                                        break;
-
-                                }
-                                inputView.btnText.TextID = StringId.kongqizhiliang;
-                                inputView.btnState.Text = strtext;
-                            }
-                        }
-                        break;
 
                 }
                 //鍐嶆缂栬緫鏉′欢鐘舵�佺偣鍑讳簨浠�
                 inputView.btnClick.MouseUpEventHandler += (sen, e) =>
                 {
                     Button button = (Button)sen;
+                    //褰撳墠缂栬緫鐨勬潯浠�
+                    Input ckcliInput = 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 == inputView.btnClick.Tag.ToString())
+                        if (input.sid == ckcliInput.sid)
                         {
-                            //鐢ㄦ埛鍙兘鍒犻櫎鏁版嵁锛屼娇鍒楄〃绱㈠紩鍙戠敓鏀瑰彉锛�
-                            //閫氳繃鍞竴sid閲嶆柊鏌ユ壘鍒扮储寮曚笖鏇存柊绱㈠紩鍊�
-                            indexVulae = index;
-                            break;
+                            if (button.Name == "3")
+                            {
+                                //鏈変簺璁惧姣旇緝鐗规畩锛堜緥濡傦細娴锋灄浼犳劅鍣ㄨ繕鏄鍒ゆ柇灞炴�у�硷紝娓╂箍搴﹀睘鎬ц繕瑕佸垽鏂瘮杈冨叧绯伙紝鎵嶈兘纭鏄惁宸茬粡瀛樺湪璇ユ潯浠讹紝鍏朵粬璁惧鏉′欢鐩存帴鐢╯id鍒ゆ柇鍗冲彲锛�
+                                //鍔犱竴绾у垽鏂槸涓哄吋瀹圭壒娈婅澶�
+                                if (new ConditionDeviceFunList { }.IsContainsAll(ckcliInput.condition, input.condition))
+                                {
+                                    //鐢ㄦ埛鍙兘鍒犻櫎鏁版嵁锛屼娇鍒楄〃绱㈠紩鍙戠敓鏀瑰彉锛�
+                                    //閫氳繃鍞竴sid閲嶆柊鏌ユ壘鍒扮储寮曚笖鏇存柊绱㈠紩鍊�
+                                    indexVulae = index;
+                                    break;
+                                }
+                            }
+                            else
+                            {
+                                //鐢ㄦ埛鍙兘鍒犻櫎鏁版嵁锛屼娇鍒楄〃绱㈠紩鍙戠敓鏀瑰彉锛�
+                                //閫氳繃鍞竴sid閲嶆柊鏌ユ壘鍒扮储寮曚笖鏇存柊绱㈠紩鍊�
+                                indexVulae = index;
+                                break;
+                            }
                         }
                     }
                     //鏍囪缂栬緫鐘舵��
@@ -470,7 +514,7 @@
                                 Input _input = Logic.currlogic.input[indexVulae];
                                 if (_input.condition_type == "1")
                                 {
-                                    var dicLists = _input.condition as List<Dictionary<string, string>>;
+                                    var dicLists = _input.condition;
                                     foreach (var dic in dicLists)
                                     {
                                         string keyValue = dic["key"];
@@ -520,11 +564,78 @@
                         case "3":
                             {
                                 //鐢╯id鎵惧埌璁惧锛�
-                                var device = LogicMethod.GetDevice(inputCondition.sid);
-                                ConditionDeviceFunList deviceFunList = new ConditionDeviceFunList();
-                                MainPage.BasePageView.AddChidren(deviceFunList);
-                                deviceFunList.Show(device, indexVulae, edit);
-                                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                                var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid);
+                                if (device.spk == SPK.SenesorEnvironment)
+                                {
+                                    //杩欎釜璁惧姣旇緝鐗规畩
+                                    ConditionDeviceFunList conditionDeviceFunList = new ConditionDeviceFunList();
+                                    ///褰撳墠鐨勭储寮曞�兼暟鎹璞�
+                                    Input inputedit = Logic.currlogic.input[indexVulae];
+                                    ///鐘舵�佸��
+                                    string stateValue = "";
+                                    foreach (var dic in inputedit.condition)
+                                    {
+                                        string key = dic["key"];
+                                        string comparator = dic["comparator"];
+                                        stateValue = dic["value"];
+                                        switch (key)
+                                        {
+
+                                            case "temperature":
+                                                {
+                                                    int titleInt = 0;
+                                                    if (comparator == ">")
+                                                    {
+                                                        titleInt = StringId.wendugaoyu;
+                                                    }
+                                                    else if (comparator == "<")
+                                                    {
+                                                        titleInt = StringId.wendudiyu;
+                                                    }
+                                                    conditionDeviceFunList.InputBoxAction(device, titleInt, indexVulae, true, stateValue);
+                                                }
+                                                break;
+                                            case "humidity":
+                                                {
+                                                    int titleInt = 0;
+                                                    if (comparator == ">")
+                                                    {
+                                                        titleInt = StringId.shidugaoyu;
+                                                    }
+                                                    else if (comparator == "<")
+                                                    {
+                                                        titleInt = StringId.shidudiyu;
+                                                    }
+                                                    conditionDeviceFunList.InputBoxAction(device, titleInt, indexVulae, true, stateValue);
+                                                }
+                                                break;
+                                            case "co2":
+                                                {
+                                                    conditionDeviceFunList.PmCo2TvocAction(thisView, device, "co2", StringId.co2, indexVulae, true, stateValue);
+                                                }
+                                                break;
+                                            case "pm25":
+                                                {
+                                                    conditionDeviceFunList.PmCo2TvocAction(thisView, device, "pm25", StringId.pm25, indexVulae, true, stateValue);
+
+                                                }
+                                                break;
+                                            case "tvoc":
+                                                {
+                                                    conditionDeviceFunList.PmCo2TvocAction(thisView, device, "tvoc", StringId.tvoc, indexVulae, true, stateValue);
+                                                }
+                                                break;
+                                        }
+                                    }
+
+                                }
+                                else
+                                {
+                                    ConditionDeviceFunList deviceFunList = new ConditionDeviceFunList();
+                                    MainPage.BasePageView.AddChidren(deviceFunList);
+                                    deviceFunList.Show(device, indexVulae, edit);
+                                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                                }
                             }
                             break;
                         case "4":
@@ -599,15 +710,6 @@
                                 MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                             }
                             break;
-                        case "9":
-                            {
-
-                                AirQuality airQuality = new AirQuality();
-                                MainPage.BasePageView.AddChidren(airQuality);
-                                airQuality.Show();
-                                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
-                            }
-                            break;
                     }
                 };
                 ///鍒犻櫎鎺т欢
@@ -638,7 +740,7 @@
                 ///璁板綍鏉′欢绱㈠紩
                 targetView.btnClick.Tag = outputTarget.sid;
                 ///鏉′欢鐘舵�佹暟缁�
-                List<Dictionary<string, string>> dicList = outputTarget.status as List<Dictionary<string, string>>;
+                List<Dictionary<string, string>> dicList = outputTarget.status;
                 //鏄剧ず鐘舵�佸��
                 string stateStr = "";
                 //鏄剧ず杈撳嚭鏉′欢鍚勭绫诲瀷鐘舵��
@@ -647,14 +749,14 @@
                     case "1":
                         {
                             //鐢╯id鎵惧埌璁惧锛�
-                            var device = LogicMethod.GetDevice(outputTarget.sid);
+                            var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid);
                             //鐢ㄨ澶囩殑functionType绫诲瀷鎵惧埌瀵瑰簲鍥炬爣锛�
-                            targetView.btnIcon.UnSelectedImagePath = LogicMethod.GetIconPath(device.spk);
+                            targetView.btnIcon.UnSelectedImagePath = LogicMethod.CurrLogicMethod.GetIconPath(device.spk);
                             //鏄剧ず璁惧鍚嶇О
                             targetView.btnText.Text = device.name;
                             //鏀瑰彉璁惧鍚嶇О鏄剧ず鎺т欢瀹藉害
                             targetView.btnText.Width = Application.GetRealWidth(80);
-                          
+
                             //鍖哄埆涓嶅悓璁惧锛屾樉绀轰笉鍚岃澶囩姸鎬�
                             switch (device.spk)
                             {
@@ -699,7 +801,7 @@
                                         {
                                             stateStr = brightness + "%";
                                         }
-                                      
+
                                     }
                                     break;
                                 case SPK.CurtainSwitch:
@@ -932,7 +1034,7 @@
                     case "2":
                         {
                             //鐢╯id鎵惧埌鍦烘櫙锛�
-                            var scene = LogicMethod.GetSecne(outputTarget.sid);
+                            var scene = LogicMethod.CurrLogicMethod.GetSecne(outputTarget.sid);
                             targetView.btnIcon.UnSelectedImagePath = "LogicIcon/scene.png";
                             targetView.btnNextIcon.Visible = false;
                             //鏄剧ず鍦烘櫙鍚嶇О
@@ -957,7 +1059,7 @@
                 }
                 else
                 {
-                    targetView.btnText.Text = new InpOrOutLogicMethod { }.GetTimeText(outputTarget.delay)+ stateStr;
+                    targetView.btnText.Text = new InpOrOutLogicMethod { }.GetTimeText(outputTarget.delay) + stateStr;
                 }
                 //鍐嶆缂栬緫鏉′欢鐘舵�佺偣鍑讳簨浠�
                 targetView.btnClick.MouseUpEventHandler += (sen, e) =>
@@ -983,7 +1085,7 @@
                         case "1":
                             {
                                 //鐢╯id鎵惧埌璁惧锛�
-                                var device = LogicMethod.GetDevice(outputTarget.sid);
+                                var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid);
                                 TargetDeviceFunList deviceFunList = new TargetDeviceFunList();
                                 MainPage.BasePageView.AddChidren(deviceFunList);
                                 deviceFunList.Show(device, indexVulae, edit);
@@ -1023,7 +1125,7 @@
                             targetView.btnText.Text = new InpOrOutLogicMethod { }.GetTimeText(outputTarget.delay) + stateStr;
                         }
                     });
-                 
+
                 };
                 ///鍒犻櫎鎺т欢
                 targetView.btnDel.MouseUpEventHandler += (sender, e) =>
@@ -1086,7 +1188,11 @@
                                     break;
                                 case "brightness":
                                     {
-
+                                        if (button2 == null)
+                                        {
+                                            //鎬曡皟璇曡蒋浠朵贡涓婁笢瑗垮鑷存姏寮傚父
+                                            break;
+                                        }
                                         button2.Text = value + "%";
                                     }
                                     break;
@@ -1149,11 +1255,21 @@
                                     break;
                                 case "set_temp":
                                     {
+                                        if (button2 == null)
+                                        {
+                                            //鎬曡皟璇曡蒋浠朵贡涓婁笢瑗垮鑷存姏寮傚父
+                                            break;
+                                        }
                                         button2.Text = value + "鈩�";
                                     }
                                     break;
                                 case "mode":
                                     {
+                                        if (button3 == null)
+                                        {
+                                            //鎬曡皟璇曡蒋浠朵贡涓婁笢瑗垮鑷存姏寮傚父
+                                            break;
+                                        }
                                         switch (value)
                                         {
                                             case "cool":
@@ -1184,6 +1300,11 @@
                                     break;
                                 case "fan":
                                     {
+                                        if (button4 == null)
+                                        {
+                                            //鎬曡皟璇曡蒋浠朵贡涓婁笢瑗垮鑷存姏寮傚父
+                                            break;
+                                        }
                                         switch (value)
                                         {
                                             case "high":
@@ -1246,11 +1367,21 @@
                                     break;
                                 case "set_temp":
                                     {
+                                        if (button2 == null)
+                                        {
+                                            //鎬曡皟璇曡蒋浠朵贡涓婁笢瑗垮鑷存姏寮傚父
+                                            break;
+                                        }
                                         button2.Text = value + "鈩�";
                                     }
                                     break;
                                 case "mode":
                                     {
+                                        if (button3 == null)
+                                        {
+                                            //鎬曡皟璇曡蒋浠朵贡涓婁笢瑗垮鑷存姏寮傚父
+                                            break;
+                                        }
                                         switch (value)
                                         {
                                             case "day":
@@ -1482,7 +1613,7 @@
                     case "3":
                         {
                             //鐢╯id鎵惧埌璁惧锛�
-                            var device = LogicMethod.GetDevice(inputCondition.sid);
+                            var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid);
                             name = device.name + "-";
                         }
                         break;
@@ -1497,7 +1628,7 @@
                     case "1":
                         {
                             //鐢╯id鎵惧埌璁惧锛�
-                            var device = LogicMethod.GetDevice(outputTarget.sid);
+                            var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid);
                             //鏄剧ず璁惧鍚嶇О
                             name += device.name;
                             string stateStr = "";
@@ -1602,7 +1733,7 @@
                     case "2":
                         {
                             //鐢╯id鎵惧埌鍦烘櫙锛�
-                            var scene = LogicMethod.GetSecne(outputTarget.sid);
+                            var scene = LogicMethod.CurrLogicMethod.GetSecne(outputTarget.sid);
                             name += scene.name;
 
                         }
@@ -1620,7 +1751,7 @@
         /// <param name="fLayout">鍦ㄥ摢涓晫闈㈡樉绀�</param>
         /// <param name="edit">锛坱rue=缂栬緫锛沠alse=鏂板缓锛�</param>
         /// <param name="index">缂栬緫鏉′欢鐨勭储寮�</param>
-        private void Delayed(FrameLayout thisFLayout, Output output,Action<int>action)
+        private void Delayed(FrameLayout thisFLayout, Output output, Action<int> action)
         {
             FrameLayout fLayout = new FrameLayout
             {
@@ -1666,12 +1797,12 @@
                 string second = timePointView.GetmStringList()[index2].Split(' ')[0];
                 int minuetIntValue = int.Parse(minuet);
                 int secondIntValue = int.Parse(second);
-                timepoint = minuetIntValue*60+secondIntValue;
+                timepoint = minuetIntValue * 60 + secondIntValue;
             };
             //纭畾鐐瑰嚮浜嬩欢
             timePointView.btnConfirm.MouseUpEventHandler += (sender, e3) =>
             {
-                if (timepoint==0)
+                if (timepoint == 0)
                 {
                     //鎻愮ず
                     return;
@@ -1709,7 +1840,11 @@
                     state = seconds.ToString() + Language.StringByID(StringId.s);
                 }
             }
+            if (!string.IsNullOrEmpty(state)) {
+                state = Language.StringByID(StringId.delayLogic) + state;
+            }
             return state;
         }
+
     }
 }

--
Gitblit v1.8.0