From 38ab16c66df6fc523f2c385fd583a2f2e86a781c Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期三, 29 四月 2020 17:58:45 +0800
Subject: [PATCH] 2020-4-29-1

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlExperienceAccountLogic.cs |  192 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 144 insertions(+), 48 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlExperienceAccountLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlExperienceAccountLogic.cs
index 877cbb2..d181a06 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlExperienceAccountLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlExperienceAccountLogic.cs
@@ -56,6 +56,8 @@
             this.InitRoomData();
             //鍒濆鍖栬澶�
             this.InitDeviceData();
+            //鍒濆鍖栧満鏅�
+            this.InitSceneData();
         }
 
         #endregion
@@ -95,9 +97,8 @@
             }
             System.IO.Directory.CreateDirectory(path);
 
-            //娓呯┖褰撳墠浣忓畢鍒楄〃
-            Config.Instance.HomeFilePathList.Clear();
-            Config.Instance.HomeFilePathList.Add($"House_{homeId}.json");
+            //娉ㄦ剰,杩欓噷涓嶆竻绌哄綋鍓嶄綇瀹呭垪琛�,淇濈暀瀹冧箣鍓嶇殑浣忓畢鍒楄〃
+
             //鍒涘缓涓存椂浣忓畢
             var house = new House() { Id = homeId, Name = Language.StringByID(R.MyInternationalizationString.uMyHome) };
             house.IsVirtually = true;
@@ -116,16 +117,39 @@
         private void InitFloorData()
         {
             Config.Instance.Home.FloorDics = new Dictionary<string, string>();
-            Config.Instance.Home.FloorDics["floorKey1"] = "1F";
-            Config.Instance.Home.FloorDics["floorKey2"] = "2F";
-            Config.Instance.Home.FloorDics["floorKey3"] = "3F";
-            Config.Instance.Home.FloorDics["floorKey4"] = "4F";
-            Config.Instance.Home.FloorDics["floorKey5"] = "5F";
+            //Config.Instance.Home.FloorDics["floorKey1"] = "1F";
+            //Config.Instance.Home.FloorDics["floorKey2"] = "2F";
+            //Config.Instance.Home.FloorDics["floorKey3"] = "3F";
+            //Config.Instance.Home.FloorDics["floorKey4"] = "4F";
+            //Config.Instance.Home.FloorDics["floorKey5"] = "5F";
         }
 
         #endregion
 
         #region 鈻� 鍒濆鍖栨埧闂確________________________
+
+        /// <summary>
+        /// 鑾峰彇鎴块棿鏍锋澘鍒楄〃
+        /// </summary>
+        /// <returns></returns>
+        private Dictionary<string, string> GetRoomSampleList()
+        {
+            var dicRoomName = new Dictionary<string, string>();
+            //瀹㈠巺
+            dicRoomName["KeTing"] = Language.StringByID(R.MyInternationalizationString.uLivingRoom);
+            //闃冲彴
+            dicRoomName["YangTai"] = Language.StringByID(R.MyInternationalizationString.uBalcony);
+            //鍗у
+            dicRoomName["WoShi"] = Language.StringByID(R.MyInternationalizationString.uBedroom);
+            //鐜勫叧
+            dicRoomName["XuanGuan"] = Language.StringByID(R.MyInternationalizationString.uVestibule);
+            //鍘ㄦ埧
+            dicRoomName["ChuFang"] = Language.StringByID(R.MyInternationalizationString.uKitchen);
+            //璧板粖
+            dicRoomName["ZouLang"] = Language.StringByID(R.MyInternationalizationString.uCorridor);
+
+            return dicRoomName;
+        }
 
         /// <summary>
         /// 鍒濆鍖栨埧闂�
@@ -137,19 +161,7 @@
 
             //鑾峰彇鍏ㄩ儴鐨勬ゼ灞備富閿�
             var listFloorKey = this.GetAllFloorKeys();
-            var dicRoomName = new Dictionary<string, string>();
-            //瀹㈠巺
-            dicRoomName.Add("KeTing", Language.StringByID(R.MyInternationalizationString.uLivingRoom));
-            //闃冲彴
-            dicRoomName.Add("YangTai", Language.StringByID(R.MyInternationalizationString.uBalcony));
-            //鍗у
-            dicRoomName.Add("WoShi", Language.StringByID(R.MyInternationalizationString.uBedroom));
-            //鐜勫叧
-            dicRoomName.Add("XuanGuan", Language.StringByID(R.MyInternationalizationString.uVestibule));
-            //鍘ㄦ埧
-            dicRoomName.Add("ChuFang", Language.StringByID(R.MyInternationalizationString.uKitchen));
-            //璧板粖
-            dicRoomName.Add("ZouLang", Language.StringByID(R.MyInternationalizationString.uCorridor));
+            var dicRoomName = this.GetRoomSampleList();
 
             //璁剧疆鍒濆妤煎眰
             Config.Instance.Home.CurrentFloorId = listFloorKey[0];
@@ -198,32 +210,41 @@
         {
             //floorKey1   _   KeTing  YangTai  WoShi  XuanGuan  ChuFang  ZouLang
             var list = new List<AddDevicePra>();
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A1璺皟鍏夊櫒, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A220pir浼犳劅鍣�, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A2鎸夐敭闈㈡澘, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A3鎸夐敭闈㈡澘, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A3璺户鐢靛櫒, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A4鎸夐敭闈㈡澘, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鍗峰笜鐢垫満, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A寮�鍚堝笜鐢垫満, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鏂规偊鍗曞紑鍙屾帶闈㈡澘, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鏂规偊鍙屽紑鍥涙帶闈㈡澘, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鏂规偊鍥涘紑鍏帶闈㈡澘, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鏂规偊鏂伴灏忔ā鍧�, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鏂规偊鏂伴闈㈡澘, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鏅鸿兘闂ㄩ攣, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A姘存蹈浼犳劅鍣�, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鐑熼浘浼犳劅鍣�, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鐕冩皵浼犳劅鍣�, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A绌烘皵寮�鍏�, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A绌鸿皟缃戝叧, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A绠�绾�2鎸夐敭闈㈡澘, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A绠�绾�3鎸夐敭闈㈡澘, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A绠�绾�4鎸夐敭闈㈡澘, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A绱ф�ユ寜閿�, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A绾㈠浼犳劅鍣�, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
-            list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A闂ㄧ獥纾佷紶鎰熷櫒, RoomId = "floorKey1_KeTing", DeviceCount = 1 });
+            //鑾峰彇鍏ㄩ儴鐨勬ゼ灞備富閿�
+            var listFloorKey = this.GetAllFloorKeys();
+            foreach (var floorKey in listFloorKey)
+            {
+                //瀹㈠巺
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A2鎸夐敭闈㈡澘, RoomId = floorKey + "_KeTing", DeviceCount = 1 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A3鎸夐敭闈㈡澘, RoomId = floorKey + "_KeTing", DeviceCount = 1 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A4鎸夐敭闈㈡澘, RoomId = floorKey + "_KeTing", DeviceCount = 2 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A绌鸿皟缃戝叧, RoomId = floorKey + "_KeTing", DeviceCount = 1 });
 
+                //闃冲彴
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A220pir浼犳劅鍣�, RoomId = floorKey + "_YangTai", DeviceCount = 1 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鍗峰笜鐢垫満, RoomId = floorKey + "_YangTai", DeviceCount = 1 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A寮�鍚堝笜鐢垫満, RoomId = floorKey + "_YangTai", DeviceCount = 1 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A2鎸夐敭闈㈡澘, RoomId = floorKey + "_YangTai", DeviceCount = 1 });
+
+                //鍗у
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A1璺皟鍏夊櫒, RoomId = floorKey + "_WoShi", DeviceCount = 1 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A3璺户鐢靛櫒, RoomId = floorKey + "_WoShi", DeviceCount = 1 });
+
+                //鐜勫叧
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A绌烘皵寮�鍏�, RoomId = floorKey + "_XuanGuan", DeviceCount = 1 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A1璺皟鍏夊櫒, RoomId = floorKey + "_XuanGuan", DeviceCount = 1 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A闂ㄧ獥纾佷紶鎰熷櫒, RoomId = floorKey + "_XuanGuan", DeviceCount = 1 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鏅鸿兘闂ㄩ攣, RoomId = floorKey + "_XuanGuan", DeviceCount = 1 });
+
+                //鍘ㄦ埧
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A4鎸夐敭闈㈡澘, RoomId = floorKey + "_ChuFang", DeviceCount = 1 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A姘存蹈浼犳劅鍣�, RoomId = floorKey + "_ChuFang", DeviceCount = 1 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鐑熼浘浼犳劅鍣�, RoomId = floorKey + "_ChuFang", DeviceCount = 1 });
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A鐕冩皵浼犳劅鍣�, RoomId = floorKey + "_ChuFang", DeviceCount = 1 });
+
+                //璧板粖
+                list.Add(new AddDevicePra { DeviceType = VirtualDeviceEnum.A4鎸夐敭闈㈡澘, RoomId = floorKey + "_ZouLang", DeviceCount = 1 });
+            }
             return list;
         }
 
@@ -245,6 +266,81 @@
                 var myMethod = thisType.GetMethod(methordName);
                 myMethod.Invoke(this, new object[] { data.DeviceCount, data.RoomId });
             }
+        }
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖栧満鏅痏________________________
+
+        /// <summary>
+        /// 鍒濆鍖栧満鏅�
+        /// </summary>
+        private void InitSceneData()
+        {
+            //鍒锋柊瀹瑰櫒
+            HdlSceneLogic.Current.ReFreshByLocal();
+
+            //鑾峰彇鍏ㄩ儴鐨勬ゼ灞備富閿�
+            var listFloorKey = this.GetAllFloorKeys();
+            //鑾峰彇鍏ㄩ儴鐨勬埧闂存ā鏉垮垪琛�
+            var dicRoom = this.GetRoomSampleList();
+
+            //floorKey1   _   KeTing  YangTai  WoShi  XuanGuan  ChuFang  ZouLang
+            int sceneIdNo = 1;
+            //瀵规瘡涓�涓ゼ灞�
+            foreach (var floorKey in listFloorKey)
+            {
+                //瀵规瘡涓�涓埧闂�
+                foreach (var strKey in dicRoom.Keys)
+                {
+                    var room = HdlRoomLogic.Current.GetRoomById(floorKey + "_" + strKey);
+                    if (room == null)
+                    {
+                        continue;
+                    }
+                    //鐏叏寮�
+                    var listAdjust1 = this.InitVirtualSceneAdjustList(room, 1);
+                    var sceneName = Language.StringByID(R.MyInternationalizationString.uAllLightOpen);
+                    var scene = HdlSceneLogic.Current.AddVirtualScene(sceneIdNo, sceneName, listAdjust1);
+                    sceneIdNo++;
+                    HdlSceneLogic.Current.AddSceneToRoom(room, scene);
+
+                    //鐏叏鍏�
+                    var listAdjust2 = this.InitVirtualSceneAdjustList(room, 0);
+                    var sceneName2 = Language.StringByID(R.MyInternationalizationString.uAllLightClose);
+                    var scene2 = HdlSceneLogic.Current.AddVirtualScene(sceneIdNo, sceneName2, listAdjust2);
+                    sceneIdNo++;
+                    HdlSceneLogic.Current.AddSceneToRoom(room, scene2);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栬櫄鎷熷満鏅殑鎵ц鐩爣(statu 0:鍏� 1:寮�)
+        /// </summary>
+        /// <param name="i_room"></param>
+        /// <param name="statu"></param>
+        /// <returns></returns>
+        private List<Scene.DeviceListData> InitVirtualSceneAdjustList(Room i_room, int statu)
+        {
+            var listBind = new List<Scene.DeviceListData>();
+            foreach (var mainKey in i_room.ListDevice)
+            {
+                var device = LocalDevice.Current.GetDevice(mainKey);
+                if (device == null) { continue; }
+                //鍙缁х數鍣ㄥ拰鐏�
+                if (device.Type == DeviceType.OnOffOutput
+                    || device.Type == DeviceType.DimmableLight)
+                {
+                    var data = new Scene.DeviceListData();
+                    data.Type = 0;
+                    data.DeviceAddr = device.DeviceAddr;
+                    data.Epoint = device.DeviceEpoint;
+                    data.TaskList.Add(new Safeguard.TaskListInfo() { TaskType = 1, Data1 = statu });
+                    listBind.Add(data);
+                }
+            }
+            return listBind;
         }
 
         #endregion
@@ -607,8 +703,8 @@
         {
             for (int i = 0; i < i_DeviceCount; i++)
             {
-                //20涓┖璋�
-                for (int j = 1; j <= 20; j++)
+                //10涓┖璋冨簲璇ュ彲浠ヤ簡
+                for (int j = 1; j <= 10; j++)
                 {
                     var device = new AC() { DeviceAddr = "DeviceAddr" + this.DeviceNumber, DeviceEpoint = j };
                     //瀹ゆ俯榛樿26鈩�

--
Gitblit v1.8.0