From 56b417e5bcdf4f34ddcda8c7e56fbac6584e615e Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期一, 07 十二月 2020 17:24:54 +0800
Subject: [PATCH] 2020-12-7-02

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs |  102 +++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 82 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 17ebb5e..81b0ae6 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)
@@ -123,7 +129,6 @@
         /// <returns></returns>
         public static List<HDL_ON.Entity.Function> GetGatewayDeviceList()
         {
-
             return HDL_ON.Entity.DB_ResidenceData.functionList.GetAllFunction();
         }
         /// <summary>
@@ -145,11 +150,11 @@
             List<HDL_ON.Entity.Function> lists = GetGatewayDeviceList();
             foreach (var dev in lists)
             {
-                if (dev.roomIdList.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;
@@ -207,12 +212,12 @@
             string roomName = "";
             List<HDL_ON.Entity.Room> roomLists = GetGatewayRoomList();
 
-            foreach (var dev in device.roomIdList)
+            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 + ",";
                 }
             }
 
@@ -229,8 +234,29 @@
             switch (functionType)
             {
                 case FunctionType.Relay:
+                case FunctionType.RGB:
+                case FunctionType.RGBW:
+                case FunctionType.ColorTemperature:
+                case FunctionType.Dimmer:
                     {
                         strPath = "LogicIcon/lightloguc.png";
+                    }
+                    break;
+                case FunctionType.Curtain:
+                case FunctionType.RollingShutter:
+                case FunctionType.MotorCurtain:
+                    {
+                        strPath = "LogicIcon/curtainlogic.png";
+                    }
+                    break;
+                case FunctionType.AC:
+                    {
+                        strPath = "LogicIcon/airconditionerlogic.png";
+                    }
+                    break;
+                case FunctionType.FloorHeating:
+                    {
+                        strPath = "LogicIcon/heatlogic.png";
                     }
                     break;
 
@@ -246,13 +272,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.ColorTemperature || 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.MotorCurtain|| device.functionType == FunctionType.RollingShutter);
             if (curtainjosn != null)
             {
                 deviceStrTypeList.Add(Language.StringByID(StringId.Curtain));
@@ -262,6 +288,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;
 
@@ -278,10 +309,23 @@
             {
                 functionTypeList.Add(FunctionType.Relay);
                 functionTypeList.Add(FunctionType.Dimmer);
+                functionTypeList.Add(FunctionType.RGB);
+                functionTypeList.Add(FunctionType.RGBW);
+                functionTypeList.Add(FunctionType.ColorTemperature);
             }
             else if (deviceType == Language.StringByID(StringId.Curtain))
             {
                 functionTypeList.Add(FunctionType.Curtain);
+                functionTypeList.Add(FunctionType.RollingShutter);
+                functionTypeList.Add(FunctionType.MotorCurtain);
+            }
+            else if (deviceType == Language.StringByID(StringId.AC))
+            {
+                functionTypeList.Add(FunctionType.AC);
+            }
+            else if (deviceType == Language.StringByID(StringId.FloorHeating))
+            {
+                functionTypeList.Add(FunctionType.FloorHeating);
             }
             return functionTypeList;
 
@@ -296,11 +340,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.ColorTemperature);
+                        deviceTypeList.Add(FunctionType.Curtain);
+                        deviceTypeList.Add(FunctionType.RollingShutter);
+                        deviceTypeList.Add(FunctionType.MotorCurtain);
+                        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.ColorTemperature);
+                        deviceTypeList.Add(FunctionType.Curtain);
+                        deviceTypeList.Add(FunctionType.RollingShutter);
+                        deviceTypeList.Add(FunctionType.MotorCurtain);
+                        deviceTypeList.Add(FunctionType.AC);
+                        deviceTypeList.Add(FunctionType.FloorHeating);
                     }
                     break;
             }

--
Gitblit v1.8.0