From 0058d3fd5cf6052016ae744aeca2272623bfb6c8 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期一, 28 十月 2019 17:49:52 +0800
Subject: [PATCH] 2019-10-28-2
---
ZigbeeApp/Shared/Common/Room.cs | 162 ++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 115 insertions(+), 47 deletions(-)
diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs
index 282f05b..363128b 100755
--- a/ZigbeeApp/Shared/Common/Room.cs
+++ b/ZigbeeApp/Shared/Common/Room.cs
@@ -36,7 +36,7 @@
/// 妤煎眰Id
/// 鏂板鏃朵娇鐢℅uid
/// </summary>
- public string FloorId = "Floor1";
+ public string FloorId = string.Empty;
/// <summary>
/// 妤煎眰鍚嶇О
/// </summary>
@@ -44,7 +44,7 @@
{
get
{
- return GetFloorNameById(FloorId);
+ return Config.Instance.Home.GetFloorNameById(FloorId);
}
}
/// <summary>
@@ -134,7 +134,7 @@
{
return new List<string> { };
}
- return GetLoveRoom().DeviceUIFilePathList;
+ return CurrentRoom.GetLoveRoom().DeviceUIFilePathList;
}
}
@@ -349,7 +349,7 @@
/// 鑾峰彇鍠滅埍鎴块棿
/// </summary>
/// <returns></returns>
- public static Room GetLoveRoom()
+ public Room GetLoveRoom()
{
return CurrentRoom.GetRoomById(LoveRoomId);
}
@@ -382,21 +382,8 @@
//璁惧锛坉eviceUI锛�
beforeRoom.DeviceUIList.Clear();
foreach (var deviceFilePath in beforeRoom.DeviceUIFilePathList)
- {
- var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(deviceFilePath));
- var tempDeviceUI = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceUI>(jsonInfo);
- if (tempDeviceUI != null)
- {
- var delCommon = tempDeviceUIList.Find((obj) => obj.CommonDevice != null && tempDeviceUI.CommonDevice != null && obj.CommonDevice.Type == tempDeviceUI.CommonDevice.Type && obj.CommonDevice.CommonDeviceAddrEpoint == tempDeviceUI.CommonDevice.CommonDeviceAddrEpoint);
- if (delCommon != null)
- {
- beforeRoom.DeviceUIList.Add(delCommon);
- }
- else
- {
- beforeRoom.AddDevice(deviceFilePath);
- }
- }
+ {
+ beforeRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFilePath));
}
//鍦烘櫙(SceneUI)
beforeRoom.SceneUIList.Clear();
@@ -460,6 +447,16 @@
public Room GetRoomById(string roomId)
{
return Lists.Find((obj) => obj.Id == roomId);
+ }
+
+ /// <summary>
+ /// 鏍规嵁鎴块棿鍚嶅瓧锛岃幏鍙栨埧闂村璞�
+ /// </summary>
+ /// <returns>The room by name.</returns>
+ /// <param name="roomName">鎴块棿鍚�</param>
+ public Room GetRoomByName(string roomName)
+ {
+ return Lists.Find((obj) => obj.Name == roomName);
}
/// <summary>
@@ -532,6 +529,55 @@
return null;
}
+ /// <summary>
+ /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�
+ /// </summary>
+ /// <param name="id"></param>
+ /// <returns></returns>
+ public List<Room> GetRoomsByFloorId(string id)
+ {
+ return Lists.FindAll((obj) => obj.FloorId==id);
+ }
+ /// <summary>
+ /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂村悕绉�
+ /// </summary>
+ /// <param name="id"></param>
+ /// <returns></returns>
+ public List<string> GetRoomNamesByFloorId(string id)
+ {
+ List<string> names = new List<string> { };
+ foreach(var r in Lists)
+ {
+ if(r.FloorId==id)
+ {
+ names.Add(r.Name);
+ }
+ }
+ return names;
+ }
+
+ /// <summary>
+ /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�(鎷兼帴浜嗐�愬父鐢ㄣ�戝湪绗竴浣�)
+ /// </summary>
+ /// <param name="id"></param>
+ /// <returns></returns>
+ public List<Room> GetRoomsByFloorIdAppendLoveRoom(string id)
+ {
+ var r= Lists.FindAll((obj) => obj.FloorId == id);
+ r.Insert(0, GetLoveRoom());
+ return r;
+ }
+
+ /// <summary>
+ /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�(鎷兼帴浜嗐�愬父鐢ㄣ�戝湪绗竴浣�)
+ /// </summary>
+ /// <returns></returns>
+ public List<Room> GetRoomsByCurrentFloorIdAppendLoveRoom()
+ {
+ var r = Lists.FindAll((obj) => obj.FloorId == Config.Instance.Home.CurrentFloorId);
+ r.Insert(0, GetLoveRoom());
+ return r;
+ }
#endregion
@@ -702,7 +748,6 @@
#endregion
#region 鈼� 鍒犻櫎璁惧_________________________
-
/// <summary>
/// 鍒犻櫎鍔熻兘-璁惧
/// </summary>
@@ -839,6 +884,56 @@
}
return Common.LocalDevice.Current.SortDevice(listDevice);
}
+
+ /// <summary>
+ /// 鑾峰彇鎴块棿璁惧绫诲瀷
+ /// </summary>
+ /// <param name="room"></param>
+ /// <returns></returns>
+ public static List<DeviceType> GetdeviceTypes(Room room)
+ {
+ List<DeviceType> typeList = new List<DeviceType> { };
+ foreach (var deviceUI in room.DeviceUIList)
+ {
+ if (deviceUI == null || deviceUI.CommonDevice == null)
+ {
+ continue;
+ }
+ if (!typeList.Contains(deviceUI.CommonDevice.Type))
+ {
+ typeList.Add(deviceUI.CommonDevice.Type);
+ }
+ }
+ return typeList;
+ }
+
+ /// <summary>
+ /// 鑾峰彇璇ョ被鍨嬬殑璁惧
+ /// </summary>
+ /// <param name="room"></param>
+ /// <param name="deviceType"></param>
+ /// <returns></returns>
+ public static List<DeviceUI> GetDeviceUIs(Room room ,DeviceType deviceType)
+ {
+ List<DeviceUI> typeList = new List<DeviceUI> { };
+ foreach (var deviceUI in room.DeviceUIList)
+ {
+ if (deviceUI == null || deviceUI.CommonDevice == null)
+ {
+ continue;
+ }
+ if(deviceUI.CommonDevice.Type!=deviceType)
+ {
+ continue;
+ }
+ if (!typeList.Contains(deviceUI))
+ {
+ typeList.Add(deviceUI);
+ }
+ }
+ return typeList;
+ }
+
#endregion
@@ -1323,33 +1418,6 @@
}
#endregion
-
- #region 鈼� 妤煎眰___________________________
-
- /// <summary>
- /// 鑾峰彇妤煎眰鍚嶇О
- /// </summary>
- /// <param name="floorId"></param>
- /// <returns></returns>
- public string GetFloorNameById(string floorId)
- {
- if (Config.Instance.Home.FloorDics.Count == 0)
- {
- return null;
- }
-
- foreach (var floor in Config.Instance.Home.FloorDics)
- {
- if (floorId == floor.Key)
- {
- return floor.Value;
- }
- }
- return null;
- }
-
- #endregion
-
}
}
--
Gitblit v1.8.0