From fb5f023820eb6783bd62d0d69d9afbd00cd3f426 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期一, 07 十二月 2020 16:50:47 +0800
Subject: [PATCH] 2020-12-07-1

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs |  148 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 128 insertions(+), 20 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
index 5a1b895..a8ec927 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
@@ -55,17 +55,22 @@
 
                 logicId = sOidBeginsWith + sTimeSpan;
 
-                logicId += "0A";
-                logicId += "0A01";
-                //0A01 鐗╂ā鍨嬩负閫昏緫锛� 0001 琛ㄧず 1 鍙烽�昏緫鍔熻兘
-                int iTopLogicId = 1;
+                logicId += "15";
+                logicId += "1501";
+                //1501 鐗╂ā鍨嬩负閫昏緫锛� 0001 琛ㄧず 1 鍙烽�昏緫鍔熻兘
+                int maxId = 1;
 
-                Random random = new Random();
-                iTopLogicId = random.Next(0, 255);
-                iTopLogicId += random.Next(0, 255);
 
-                logicId += iTopLogicId.ToString("X4");//閫昏緫鍙� 涓や釜byte 
-                logicId += "1100";
+                for (int i = 0; i < Logic.LogicList.Count; i++)
+                {
+                    string s = Logic.LogicList[i].sid.Substring(20, 4);
+                    int iThisSceneId = Convert.ToInt16(s, 16);
+                    if (iThisSceneId > maxId)
+                        maxId = iThisSceneId ;
+                }
+
+                logicId += (maxId+1).ToString("X4");//閫昏緫鍙� 涓や釜byte 
+                logicId += "0000";
             }
             catch
             {
@@ -73,6 +78,7 @@
             }
             return logicId;
         }
+
         /// <summary>
         /// 灏佽Dictionary瀵硅薄
         /// </summary>
@@ -95,7 +101,7 @@
         /// <returns></returns>
         public static List<HDL_ON.Entity.Room> GetGatewayRoomList() 
         {
-            return HDL_ON.Entity.DB_ResidenceData.rooms;
+            return HDL_ON.Entity.DB_ResidenceData.residenceData.Rooms;
         }
         /// <summary>
         /// 鑾峰彇缃戝叧鎴块棿鍒楄〃
@@ -106,8 +112,8 @@
 
             List<Entity.Room> roomList = new List<Entity.Room>();
             Entity.Room room1 = new Entity.Room();
-            room1.name = name;//榛樿涓�涓埧闂村悕涓�:鍏ㄩ儴鍖哄煙
-            room1.sid = "鍏ㄩ儴鍖哄煙";//榛樿sid鐢ㄨ瘑鍒鎴块棿
+            room1.roomName = name;//榛樿涓�涓埧闂村悕涓�:鍏ㄩ儴鍖哄煙
+            room1.uid = "鍏ㄩ儴鍖哄煙";//榛樿sid鐢ㄨ瘑鍒鎴块棿
             roomList.Add(room1);//榛樿娣诲姞鍒版埧闂村垪琛ㄩ噷
             var roomLists = GetGatewayRoomList();
             foreach (var room in roomLists)
@@ -124,7 +130,7 @@
         public static List<HDL_ON.Entity.Function> GetGatewayDeviceList()
         {
             List<HDL_ON.Entity.Function> list = new List<Entity.Function>();
-            for (int i=0;i<3;i++) {
+            for (int i=0;i<10;i++) {
                 HDL_ON.Entity.Function function = new Entity.Function();
                 switch (i) {
                     case 0: {
@@ -144,7 +150,56 @@
                             function.name = "绌鸿皟";
                             list.Add(function);
                         } break;
-                     
+                    case 3:
+                        {
+                            function.sid = "1234560001212121010282";
+                            function.name = "RGBW";
+                            list.Add(function);
+                        }
+                        break;
+                    case 4:
+                        {
+
+                            function.sid = "1234560001212121010382";
+                            function.name = "CCT鐏�";
+                            list.Add(function);
+                        }
+                        break;
+                    case 5:
+                        {
+                            function.sid = "1234560001212121010482";
+                            function.name = "寮�鍚堝笜";
+                            list.Add(function);
+                        }
+                        break;
+                    case 6:
+                        {
+                            function.sid = "1234560001212121010582";
+                            function.name = "鍗峰笜";
+                            list.Add(function);
+                        }
+                        break;
+                    case 7:
+                        {
+                            function.sid = "1234560001212121040282";
+                            function.name = "鍦扮儹";
+                            list.Add(function);
+                        }
+                        break;
+                    case 8:
+                        {
+                            function.sid = "1234560001212121020282";
+                            function.name = "璋冨叧";
+                            list.Add(function);
+                        }
+                        break;
+                    case 9:
+                        {
+                            function.sid = "1234560001212121020482";
+                            function.name = "RGB";
+                            list.Add(function);
+                        }
+                        break;
                 }
             }
             return list;
@@ -169,11 +224,11 @@
             List<HDL_ON.Entity.Function> lists = GetGatewayDeviceList();
             foreach (var dev in lists)
             {
-                if (dev.roomIds.Find((id) => id == room.sid) != null)
+                if (dev.roomIds.Find((id) => id == room.uid) != null)
                 {
                     deviceLists.Add(dev);
                 }
-                if (room.sid == "鍏ㄩ儴鍖哄煙")
+                if (room.uid == "鍏ㄩ儴鍖哄煙")
                 {
                     //鎴块棿鍚嶄负鍏ㄩ儴鍖哄煙鏃讹紝鏄剧ず缃戝叧鍏ㄩ儴璁惧
                     deviceLists = lists;
@@ -233,10 +288,10 @@
 
             foreach (var dev in device.roomIds)
             {
-                var room = roomLists.Find((c) => c.sid == dev);
+                var room = roomLists.Find((c) => c.uid == dev);
                 if (room != null)
                 {
-                    roomName += room.floorName + "." + room.name + ",";
+                    roomName += room.floorName + "." + room.roomName + ",";
                 }
             }
 
@@ -253,8 +308,29 @@
             switch (functionType)
             {
                 case FunctionType.Relay:
+                case FunctionType.RGB:
+                case FunctionType.RGBW:
+                case FunctionType.CCT:
+                case FunctionType.Dimmer:
                     {
                         strPath = "LogicIcon/lightloguc.png";
+                    }
+                    break;
+                case FunctionType.Curtain:
+                case FunctionType.RollerCurtain:
+                case FunctionType.TrietexCurtain:
+                    {
+                        strPath = "LogicIcon/curtainlogic.png";
+                    }
+                    break;
+                case FunctionType.AC:
+                    {
+                        strPath = "LogicIcon/airconditionerlogic.png";
+                    }
+                    break;
+                case FunctionType.FloorHeating:
+                    {
+                        strPath = "LogicIcon/heatlogic.png";
                     }
                     break;
 
@@ -270,13 +346,13 @@
         {
             List<string> deviceStrTypeList = new List<string>(); 
             deviceStrTypeList.Clear();
-            var lightjosn = deviceList.Find((device) => device.functionType == FunctionType.Relay || device.functionType == FunctionType.Dimmer);
+            var lightjosn = deviceList.Find((device) => device.functionType == FunctionType.Relay || device.functionType == FunctionType.Dimmer|| device.functionType == FunctionType.CCT || device.functionType == FunctionType.RGB|| device.functionType == FunctionType.RGBW);
             if (lightjosn != null)
             {
                 deviceStrTypeList.Add(Language.StringByID(StringId.Lights));
             }
 
-            var curtainjosn = deviceList.Find((device) => device.functionType ==FunctionType.Curtain);
+            var curtainjosn = deviceList.Find((device) => device.functionType ==FunctionType.Curtain|| device.functionType == FunctionType.TrietexCurtain|| device.functionType == FunctionType.RollerCurtain);
             if (curtainjosn != null)
             {
                 deviceStrTypeList.Add(Language.StringByID(StringId.Curtain));
@@ -286,6 +362,11 @@
             if (ac != null)
             {
                 deviceStrTypeList.Add(Language.StringByID(StringId.AC));
+            }
+            var floorHeating = deviceList.Find((device) => device.functionType == FunctionType.FloorHeating);
+            if (ac != null)
+            {
+                deviceStrTypeList.Add(Language.StringByID(StringId.FloorHeating));
             }
             return deviceStrTypeList;
 
@@ -302,10 +383,23 @@
             {
                 functionTypeList.Add(FunctionType.Relay);
                 functionTypeList.Add(FunctionType.Dimmer);
+                functionTypeList.Add(FunctionType.RGB);
+                functionTypeList.Add(FunctionType.RGBW);
+                functionTypeList.Add(FunctionType.CCT);
             }
             else if (deviceType == Language.StringByID(StringId.Curtain))
             {
                 functionTypeList.Add(FunctionType.Curtain);
+                functionTypeList.Add(FunctionType.RollerCurtain);
+                functionTypeList.Add(FunctionType.TrietexCurtain);
+            }
+            else if (deviceType == Language.StringByID(StringId.AC))
+            {
+                functionTypeList.Add(FunctionType.AC);
+            }
+            else if (deviceType == Language.StringByID(StringId.FloorHeating))
+            {
+                functionTypeList.Add(FunctionType.FloorHeating);
             }
             return functionTypeList;
 
@@ -320,15 +414,29 @@
             switch (if_type) {
                 case condition_if: {
                         deviceTypeList.Add(FunctionType.Relay);
+                        deviceTypeList.Add(FunctionType.RGB);
+                        deviceTypeList.Add(FunctionType.RGBW);
+                        deviceTypeList.Add(FunctionType.Dimmer);
+                        deviceTypeList.Add(FunctionType.CCT);
                         deviceTypeList.Add(FunctionType.Curtain);
+                        deviceTypeList.Add(FunctionType.RollerCurtain);
+                        deviceTypeList.Add(FunctionType.TrietexCurtain);
                         deviceTypeList.Add(FunctionType.AC);
+                        deviceTypeList.Add(FunctionType.FloorHeating);
                     }
                     break;
                 case target_if:
                     {
                         deviceTypeList.Add(FunctionType.Relay);
+                        deviceTypeList.Add(FunctionType.RGB);
+                        deviceTypeList.Add(FunctionType.RGBW);
+                        deviceTypeList.Add(FunctionType.Dimmer);
+                        deviceTypeList.Add(FunctionType.CCT);
                         deviceTypeList.Add(FunctionType.Curtain);
+                        deviceTypeList.Add(FunctionType.RollerCurtain);
+                        deviceTypeList.Add(FunctionType.TrietexCurtain);
                         deviceTypeList.Add(FunctionType.AC);
+                        deviceTypeList.Add(FunctionType.FloorHeating);
                     }
                     break;
             }

--
Gitblit v1.8.0