From 3c08c6a18196f5802c623959bfcecdb7707cd13d Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 03 八月 2023 13:30:07 +0800
Subject: [PATCH] 0-10v小模块bug修复,

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/LogicSeriesSettingPage.cs |  125 +++++++++++++++++++++++++++++++----------
 1 files changed, 93 insertions(+), 32 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicSeriesSettingPage.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicSeriesSettingPage.cs
index c25a654..a8dc5e0 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicSeriesSettingPage.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicSeriesSettingPage.cs
@@ -26,10 +26,58 @@
             };
             bodyView.AddChidren(contentView);
 
+            #region 鎵惧嚭鎵�鏈夊簭鍒楃殑oid
+            List<string> oidList = new List<string>();
+
+            foreach (var rgb in list)
+            {
+                var oid = rgb.sid.Substring(0, 16);
+                if (!oidList.Contains(oid))
+                {
+                    oidList.Add(oid);
+                }
+            }
+
             var seriesList = FunctionList.List.GetSeries();
 
-            foreach(var rgb in list)
+            foreach(var temp in seriesList)
             {
+                var oid = temp.sid.Substring(0, 16);
+                if (!oidList.Contains(oid))
+                {
+                    oidList.Add(oid);
+                }
+            }
+            #endregion
+
+
+            //Dictionary<string, List<string>> deviceList = new Dictionary<string, List<string>>();
+            //foreach(var oid in oidList)
+            //{
+            //    var sidList = FunctionList.List.
+
+            //    if (!deviceList.ContainsKey(oid))
+            //    {
+            //        deviceList.Add(oid)
+            //    }
+            //}
+
+            foreach(var oid in oidList)
+            {
+                Function rgb = null;
+                rgb = list.Find((obj) => obj.sid.Substring(0, 16) == oid);
+                if(rgb == null)
+                {
+                    rgb = FunctionList.List.GetLightList().Find((obj) => obj.spk == SPK.LightRGB && obj.sid.Substring(0, 16) == oid);
+                    if (rgb == null)
+                    {
+                        rgb = FunctionList.List.GetLightList().Find((obj) => obj.spk == SPK.LightCCT && obj.sid.Substring(0, 16) == oid);
+                        if (rgb == null)
+                        {
+                            rgb = FunctionList.List.GetLightList().Find((obj) => obj.spk == SPK.LightDimming && obj.sid.Substring(0, 16) == oid);
+                        }
+                    }
+                }
                 var titleView = new FrameLayout()
                 {
                     Height = Application.GetRealHeight(44),
@@ -49,37 +97,40 @@
                 };
                 titleView.AddChidren(btnViewTitle);
 
-                var autoColorfulView = new FrameLayout()
+                if (rgb.GetAttribute(FunctionAttributeKey.Colorful) != null)
                 {
-                    Height = Application.GetRealHeight(44),
-                    BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
-                };
-                contentView.AddChidren(autoColorfulView);
-                autoColorfulView.AddChidren(new Button() { Width = Application.GetRealWidth(343), Gravity = Gravity.BottomCenter, Height = 1, BackgroundColor = CSS.CSS_Color.DividingLineColor, Y = Application.GetRealHeight(44) - 1 });
+                    var autoColorfulView = new FrameLayout()
+                    {
+                        Height = Application.GetRealHeight(44),
+                        BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
+                    };
+                    contentView.AddChidren(autoColorfulView);
+                    autoColorfulView.AddChidren(new Button() { Width = Application.GetRealWidth(343), Gravity = Gravity.BottomCenter, Height = 1, BackgroundColor = CSS.CSS_Color.DividingLineColor, Y = Application.GetRealHeight(44) - 1 });
 
-                Button btnAutoColorfulRight = new Button()
-                {
-                    X = Application.GetRealWidth(339),
-                    Gravity = Gravity.CenterVertical,
-                    Width = Application.GetMinRealAverage(16),
-                    Height = Application.GetMinRealAverage(16),
-                    UnSelectedImagePath = "Public/Right.png",
-                };
-                autoColorfulView.AddChidren(btnAutoColorfulRight);
+                    Button btnAutoColorfulRight = new Button()
+                    {
+                        X = Application.GetRealWidth(339),
+                        Gravity = Gravity.CenterVertical,
+                        Width = Application.GetMinRealAverage(16),
+                        Height = Application.GetMinRealAverage(16),
+                        UnSelectedImagePath = "Public/Right.png",
+                    };
+                    autoColorfulView.AddChidren(btnAutoColorfulRight);
 
-                var btnAutoColorfulTitle = new Button()
-                {
-                    X = Application.GetRealWidth(16),
-                    TextAlignment = TextAlignment.CenterLeft,
-                    TextSize = CSS.CSS_FontSize.TextFontSize,
-                    TextColor = CSS.CSS_Color.FirstLevelTitleColor,
-                    TextID = StringId.Auto,
-                };
-                autoColorfulView.AddChidren(btnAutoColorfulTitle);
-                btnAutoColorfulTitle.MouseUpEventHandler = (sender, e) =>
-                {
-                    LoadEditDialog_OnOff(rgb.sid,true);
-                };
+                    var btnAutoColorfulTitle = new Button()
+                    {
+                        X = Application.GetRealWidth(16),
+                        TextAlignment = TextAlignment.CenterLeft,
+                        TextSize = CSS.CSS_FontSize.TextFontSize,
+                        TextColor = CSS.CSS_Color.FirstLevelTitleColor,
+                        TextID = StringId.Auto,
+                    };
+                    autoColorfulView.AddChidren(btnAutoColorfulTitle);
+                    btnAutoColorfulTitle.MouseUpEventHandler = (sender, e) =>
+                    {
+                        LoadEditDialog_OnOff(rgb.sid, true);
+                    };
+                }
 
                 var rgbSeriesList = seriesList.FindAll((obj) => obj.sid.Substring(0, 16) == rgb.sid.Substring(0, 16));
                 foreach(var rgbSeries in rgbSeriesList)
@@ -252,6 +303,10 @@
 
 
                 Output outputDevice = new Output();
+                outputDevice.target_type = "1";
+                outputDevice.sid = sid;
+                outputDevice.delay = "0";
+
                 List<Dictionary<string, string>> dicSateteList = new List<Dictionary<string, string>>();
 
                 Dictionary<string, string> diction = new Dictionary<string, string>();
@@ -268,10 +323,16 @@
 
                 outputDevice.status = dicSateteList;
 
-                var oldTemp = Logic.currlogic.output.Find((obj) => obj.sid.Substring(0, 16) == sid.Substring(0, 16));
-                if (oldTemp != null)
+                try
                 {
-                    Logic.currlogic.output.Remove(oldTemp);
+                    var oldTemp = Logic.currlogic.output.Find((obj) => obj.sid != null && obj.sid.Length > 16 && obj.sid.Substring(0, 16) == sid.Substring(0, 16));
+                    if (oldTemp != null)
+                    {
+                        Logic.currlogic.output.Remove(oldTemp);
+                    }
+                }catch(Exception ex)
+                {
+                    MainPage.Log($"鑷姩鍖栦繚瀛樿窇椹伅鏁版嵁寮傚父:{ex.Message}");
                 }
                 Logic.currlogic.output.Add(outputDevice);
 

--
Gitblit v1.8.0