From 3afa6b622356b974a42ff29b1e4f0e35d2bf68f0 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 07 六月 2022 17:03:13 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/wjc' into Dev-Branch

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs           |    4 
 HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs        |   87 +++++++++++++++++++++++++++++
 HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs        |    1 
 HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs    |   27 ++------
 HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs |   13 ++-
 HDL_ON/Common/ApiUtlis.cs                                         |    2 
 HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs              |    2 
 7 files changed, 107 insertions(+), 29 deletions(-)

diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs
index 6ee9f91..22953a6 100644
--- a/HDL_ON/Common/ApiUtlis.cs
+++ b/HDL_ON/Common/ApiUtlis.cs
@@ -172,7 +172,7 @@
                                 var deviceResult2 = Ins.HttpRequest.GetDeviceList("30", Convert.ToInt32(deviceList.pageNo) + 1 + "");
                                 if (deviceResult2.Code == StateCode.SUCCESS)
                                 {
-                                    var deviceList2 = JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString());
+                                    var deviceList2 = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString());
                                     deviceList.pageNo = deviceList2.pageNo;
                                     deviceList.list.AddRange(deviceList2.list);
                                 }
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
index eadc10b..c0a2ba0 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
@@ -78,13 +78,13 @@
             #region  鎵�鏈夌偣鍑讳簨浠�
             //鏃堕棿
             timeView.btnClick.MouseUpEventHandler += (sen, e) =>
-      {
+             {
           TimeTpye timeTpye = new TimeTpye();
           MainPage.BasePageView.AddChidren(timeTpye);
           timeTpye.Show();
           MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
 
-      };
+             };
             
             //鍦烘櫙鐐瑰嚮浜嬩欢
             sceneView.btnClick.MouseUpEventHandler += (sen, e) =>
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
index 2b606ad..7f0cc74 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
@@ -377,6 +377,7 @@
                 //tvoc
                 case SPK.SensorTVOC:
                     {
+                        
                         ///tvoc
                         LogicView.FunTypeView tvocView = new LogicView.FunTypeView();
                         tvocView.btnText.TextID = StringId.tvoc;
@@ -709,7 +710,7 @@
         /// <param name="stateValue">缂栬緫涔嬪墠鐨勭姸鎬佸��,榛樿涓�""</param>
         public void PmCo2TvocAction(FrameLayout frame, Entity.Function device, string key, int title, int index, bool edit, string stateValue = "")
         {
-            if (edit)
+            if (edit) 
             {
                 ///
                 this.function = device;
@@ -723,12 +724,14 @@
                 }
             }
             PublicInterface view = new PublicInterface();
-            var listStr = view.GetViewList(key);
-            view.SingleSelectionShow(frame, listStr, Language.StringByID(title), view.GetString(key, stateValue)
+            //var listStr = view.GetViewList(key);
+            var listStr = view.GetSensorLevelList(device);//2022骞�05鏈�25鏃�10:01:33 浜у搧缁忕悊鍚涚厡瑕佹眰鏀规垚鍔ㄦ��
+            view.SingleSelectionShow(frame, listStr, Language.StringByID(title), view.GetSensorLevelText(device, stateValue,true)
                , (text) =>
                {
                   
-                   var value = view.GetValue(key, text);
+                   //var value = view.GetValue(key, text);
+                   var values = view.GetSensorLevelText(device,text,false);
                    selectedState = device.spk + "_" + key;
                    switch (device.spk)
                    {
@@ -746,7 +749,7 @@
                            }
                            break;
                    }
-                   AddDictionary(key, value, "integer", "in");
+                   AddDictionary(key, values, "integer", "in");
                    Save(device, index, edit);
                });
         }
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
index ecbb380..eef7829 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
@@ -420,31 +420,18 @@
                                     }
                                     break;
                                 case SPK.SensorCO2:
-                                    {
-                                        string str = new InpOrOutLogicMethod { }.GetText(dicList, "co2");
-                                        inputView.btnState.Text = str;
-
-                                    }
-                                    break;
                                 case SPK.SensorPm25:
-                                    {
-                                        string str = new InpOrOutLogicMethod { }.GetText(dicList, "pm25");
-                                        inputView.btnState.Text = str;
-
-                                    }
-                                    break;
                                 case SPK.SensorTVOC:
-                                    {
-                                        string str = new InpOrOutLogicMethod { }.GetText(dicList, "tvoc");
-                                        inputView.btnState.Text = str;
-
-                                    }
-                                    break;
                                 case SPK.SensorHcho:
                                     {
-                                        string str = new InpOrOutLogicMethod { }.GetText(dicList, "hcho");
+                                        string strvalue = ""; 
+                                        foreach (var dic in dicList)
+                                        {
+                                            strvalue = dic["value"];
+                                            break;
+                                        }
+                                        string str = new PublicInterface().GetSensorLevelText(device, strvalue, true);
                                         inputView.btnState.Text = str;
-
                                     }
                                     break;
                                 case SPK.DoorLock:
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs
index d23adfd..ee921ce 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs
@@ -748,6 +748,93 @@
             return list;
         }
         /// <summary>
+        /// 鍔ㄦ�佽幏鍙栦紶鎰熷櫒绛夌骇鍒楄〃
+        /// </summary>
+        /// <param name="device">鍔熻兘(sid)</param>
+        /// <returns></returns>
+        public List<string> GetSensorLevelList(Entity.Function device)
+        {
+            List<string> list = new List<string>();
+            var dic = GetSensorLevelDic(device);
+            foreach (var d in dic) {
+                list.Add(d.Key);
+            }
+            return list;
+        }
+        /// <summary>
+        /// 鎸囧畾鑾峰彇绛夌骇鎷兼帴鐨勫瓧绗︿覆
+        /// </summary>
+        /// <param name="device">鍔熻兘(sid)</param>
+        /// <param name="s">鍒濆鍊�</param>
+        /// <param name="isTextBoolean">琛ㄧずtrue(杩斿洖key);false(杩斿洖values)</param>
+        /// <returns></returns>isTextBoolean
+        public string GetSensorLevelText(Entity.Function device, string s, bool isTextBoolean)
+        {
+            if (device == null || device.attrKeyConfigs == null)
+            {
+                return "";
+            }
+            var dic = GetSensorLevelDic(device);
+            if (isTextBoolean)
+            {
+                foreach (var d in dic)
+                {
+                    if (d.Value==s)
+                    {
+                        //濡傛灉values鍊煎瓨鍦紝杩斿洖key鍊�
+                        return d.Key.ToString();
+                    }
+                }
+                
+            }
+            else
+            {
+                foreach (var d in dic)
+                {
+                    if (d.Key==s)
+                    {
+                        //濡傛灉key鍊煎瓨鍦紝杩斿洖values鍊�
+                        return d.Value.ToString();
+                    }
+                }
+            }
+            return "";
+        }
+        /// <summary>
+        /// 鍔ㄦ�佽幏鍙栦紶鎰熷櫒绛夌骇瀛楀吀
+        /// </summary>
+        /// <param name="device">鍔熻兘(sid)</param>
+        /// <returns></returns>
+        public Dictionary<string,string> GetSensorLevelDic(Entity.Function device)
+        {
+            Dictionary<string, string> dic = new Dictionary<string, string>();
+            if (device == null || device.attrKeyConfigs == null)
+            {
+                return dic;
+            }
+            string strKey = "";
+            string strKeyValues = "";   
+            for (int i = 0; i < device.attrKeyConfigs.Count; i++)
+            {
+                var attrKeyConfig = device.attrKeyConfigs[i];
+                foreach (var attrKeyInfo in attrKeyConfig.configs)
+                {
+                    //鍔ㄦ�佹嫾鎺ュ瓧绗︿覆
+                    strKey = attrKeyInfo.desc + ":" + attrKeyInfo.start + "~" + attrKeyInfo.end + attrKeyConfig.unit;
+                    strKeyValues = "(" + attrKeyInfo.start + "," + attrKeyInfo.end + "]";
+                    if (!dic.ContainsKey(strKey))
+                    {
+                        //娌℃湁鍐嶆坊鍔�
+                        dic.Add(strKey, strKeyValues);
+                    }
+                   
+                }
+
+            }
+            return dic;
+        }
+
+        /// <summary>
         /// 妯″紡/椋庨�熶簰鐩歌浆鎹㈠�肩殑鏂规硶
         /// </summary>
         /// <param name="text">鏂囨湰</param>
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs
index dec677f..f5f1c5d 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs
@@ -411,6 +411,7 @@
                             {
                                 //闊充箰鍦ㄦ挱鏀炬椂锛屽啀璁$畻鎾斁鏃堕棿(鐜板湪鏃堕棿=鍘熸潵鏃堕棿+1绉�)
                                 playSecond +=(int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds;
+                                playSecond += 1;//琛ㄧず鍔犱笂绛夊緟鐨勬椂闂�1s
                                 ///姝屾洸璁板綍鏆傛椂鏃堕棿鍐欏叆缂撳瓨锛�
                                 A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.playing_time, playSecond);
                             }
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs
index 5c5590d..0fde19f 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs
@@ -44,7 +44,7 @@
         {
             new System.Threading.Thread(() =>
             {
-                DriverLayer.Control.Ins.SendWriteCommand(function, dic);
+                DriverLayer.Control.Ins.SendWriteCommand(function, dic,false,0);
             })
             { IsBackground = true }.Start();
         }

--
Gitblit v1.8.0