old mode 100755
new mode 100644
| | |
| | | |
| | | /// <summary>
|
| | | /// 温度传感器(设备主键)
|
| | | /// </summary> |
| | | /// </summary> |
| | | public string TemperatrueDevice = string.Empty; |
| | | /// <summary>
|
| | | /// 湿度传感器(设备主键)
|
| | | /// </summary> |
| | | public string HumidityDevice = string.Empty; |
| | | /// <summary> |
| | | /// 温度 |
| | | /// </summary> |
| | | public double Temperatrue; |
| | | /// <summary> |
| | | /// 湿度 |
| | | /// </summary> |
| | | public double Humidity; |
| | | |
| | | /// <summary>
|
| | | /// 当前选择的房间
|
| | | /// </summary> |
| | | private static Room m_CurrentRoom = null; |
| | | /// <summary> |
| | | /// 当前选择的房间 |
| | | /// </summary> |
| | | public static Room CurrentRoom; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public static Room CurrentRoom
|
| | | {
|
| | | get
|
| | | {
|
| | | if (m_CurrentRoom == null && Lists.Count > 0)
|
| | | {
|
| | | return Lists[0];
|
| | | }
|
| | | return m_CurrentRoom;
|
| | | }
|
| | | set { m_CurrentRoom = value; }
|
| | | } |
| | | |
| | | /// <summary> |
| | | /// 房间里所有的设备列表 |
| | |
| | | /// 注:分享过来的房间不能删除,不能编辑该房间,不能对设备(功能)、场景进行增删改 |
| | | /// </summary> |
| | | public bool IsSharedRoom = false; |
| | | |
| | | /// <summary> |
| | | /// 是否可以刷新房间数据了 |
| | | /// 需要等初始化本地设备数据后在可以初始化房间数据 |
| | | /// </summary> |
| | | public static bool CanInitAllRoom; |
| | | |
| | | /// <summary> |
| | | /// 获取喜爱房间的所有设备路径 |
| | |
| | | return sceneList; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取所有房间的所有场景路径 |
| | | /// </summary> |
| | | /// <value>All room scene UIL ist.</value> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<string> AllRoomSceneUIFilepathList |
| | | { |
| | | get |
| | | { |
| | | var pathList = new List<string> { }; |
| | | foreach (var r in Lists) |
| | | { |
| | | if (r.SceneUIFilePathList.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var path in r.SceneUIFilePathList) |
| | | { |
| | | pathList.Add(path); |
| | | } |
| | | } |
| | | return pathList; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 场景列表---不再序列化 |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | public static void InitAllRoom() |
| | | { |
| | | if (CanInitAllRoom == false) |
| | | { |
| | | return; |
| | | } |
| | | Lists.Clear(); |
| | | if (Config.Instance.Home.RoomFilePathList.Contains("Room_Favorite.json") == false) |
| | | { |
| | | //默认添加喜爱的房间--禁止修改房间名 |
| | | var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "Room/r0.png", Id = LoveRoomId }; |
| | | love.Save(true); |
| | | var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "RoomIcon/0.JPG", Id = LoveRoomId }; |
| | | love.Save(false); |
| | | //添加到house 房间路径列表 |
| | | var currentHome = Config.Instance.Home; |
| | | currentHome.RoomFilePathList.Insert(0, love.FileName); |
| | | currentHome.Save(); |
| | | currentHome.Save(false); |
| | | } |
| | | foreach (var roomFilePath in Config.Instance.Home.RoomFilePathList) |
| | | { |
| | |
| | | { |
| | | if (room.IsSharedRoom) |
| | | { |
| | | room.Name = $"({Language.StringByID(R.MyInternationalizationString.Shared)}){room.Name}"; |
| | | room.Name = $"{room.Name}"; |
| | | } |
| | | Lists.Add(room); |
| | | |
| | | } |
| | | } |
| | | Config.Instance.Home.InitFloor(); |
| | | |
| | | RefreshRoomListView(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 刷新房间视图列表 |
| | | /// </summary> |
| | | public static void RefreshRoomListView() |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | Phone.Device.Room.RoomManagement.Instance.Show(); |
| | | }); |
| | | } |
| | | |
| | | /// <summary>
|
| | |
| | | }
|
| | | }
|
| | | homeTemp.Save(false);
|
| | | CanInitAllRoom = true;
|
| | | InitAllRoom();
|
| | | } |
| | | |
| | |
| | | //设备(deviceUI) |
| | | beforeRoom.DeviceUIList.Clear(); |
| | | foreach (var deviceFilePath in beforeRoom.DeviceUIFilePathList) |
| | | {
|
| | | beforeRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFilePath)); |
| | | { |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | //场景(SceneUI) |
| | | beforeRoom.SceneUIList.Clear(); |
| | |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | | public List<Room> GetRoomsByFloorId(string id) |
| | | public List<Room> GetRoomsByFloorId(string id) |
| | | { |
| | | return Lists.FindAll((obj) => obj.FloorId==id); |
| | | if (Config.Instance.Home.FloorDics.Count == 0) |
| | | { |
| | | return Lists; |
| | | } |
| | | return Lists.FindAll((obj) => obj.FloorId == id); |
| | | } |
| | | /// <summary> |
| | | /// 获取当前楼层的房间名称 |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | | public List<string> GetRoomNamesByFloorId(string id) |
| | | public List<string> GetRoomNamesByFloorId(string id) |
| | | { |
| | | List<string> names = new List<string> { }; |
| | | foreach(var r in Lists) |
| | | foreach (var r in Lists) |
| | | { |
| | | if(r.FloorId==id) |
| | | if (r.FloorId == id) |
| | | { |
| | | names.Add(r.Name); |
| | | } |
| | |
| | | /// <returns></returns> |
| | | public List<Room> GetRoomsByFloorIdAppendLoveRoom(string id) |
| | | { |
| | | if (Config.Instance.Home.FloorDics.Count == 0) |
| | | { |
| | | return Lists; |
| | | } |
| | | var r= Lists.FindAll((obj) => obj.FloorId == id); |
| | | r.Insert(0, GetLoveRoom()); |
| | | return r; |
| | |
| | | /// <returns></returns> |
| | | public List<Room> GetRoomsByCurrentFloorIdAppendLoveRoom() |
| | | { |
| | | if(Config.Instance.Home.FloorDics.Count==0) |
| | | { |
| | | return Lists; |
| | | } |
| | | var r = Lists.FindAll((obj) => obj.FloorId == Config.Instance.Home.CurrentFloorId); |
| | | r.Insert(0, GetLoveRoom()); |
| | | return r; |
| | |
| | | /// </summary> |
| | | /// <param name="device">设备对象</param> |
| | | /// <param name="roomId">新房间Id</param> |
| | | public void ChangedRoom(CommonDevice device, string roomId) |
| | | /// <param name="saveRealRoom">是否修改真实物理设备的房间,不出意外,这个值默认为true即可</param> |
| | | public void ChangedRoom(CommonDevice device, string roomId, bool saveRealRoom = true) |
| | | { |
| | | //房间是否修改 |
| | | if (this.IsRoomChanged(device, roomId) == false) |
| | |
| | | var room = this.GetRoomById(roomId); |
| | | if (room != null)
|
| | | {
|
| | | room.AddDevice(device);
|
| | | room.AddDevice(device, saveRealRoom);
|
| | | } |
| | | }
|
| | |
|
| | |
| | | #region ◆ 添加设备________________________ |
| | | |
| | | /// <summary> |
| | | /// 添加设备 |
| | | /// 添加设备(此方法目前只给【我的喜爱】使用) |
| | | /// </summary> |
| | | /// <param name="deviceUIFilePath">Device UIF ile path.</param> |
| | | public void AddDevice(string deviceUIFilePath) |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加设备 |
| | | /// 添加设备(此方法目前只给Room里面使用) |
| | | /// </summary> |
| | | /// <param name="device">要添加的设备对象</param> |
| | | public void AddDevice(CommonDevice device) |
| | | /// <param name="saveRealRoom">是否修改真实物理设备的房间,不出意外,这个值默认为true即可</param> |
| | | public void AddDevice(CommonDevice device, bool saveRealRoom) |
| | | { |
| | | if (device == null) |
| | | { |
| | |
| | | } |
| | | //设备信息保存到本地 |
| | | device.Save(); |
| | | |
| | | //添加自动备份 |
| | | HdlAutoBackupLogic.AddOrEditorFile(device.FilePath); |
| | | |
| | | var deviceUI = Common.LocalDevice.Current.GetDeviceUI(device); |
| | | if (DeviceUIFilePathList.Contains(deviceUI.FileName) == false) |
| | |
| | | |
| | | //添加自动备份 |
| | | HdlAutoBackupLogic.AddOrEditorFile(FileName); |
| | | if (saveRealRoom == true && LocalDevice.Current.GetDevicesCountByMac(device.DeviceAddr) == 1)
|
| | | {
|
| | | //如果只有一个回路,则修改真实物理设备的房间
|
| | | LocalDevice.Current.SaveRealDeviceRoomId(new List<CommonDevice>() { device }, this.Id, false);
|
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取该楼层的场景 |
| | | /// 获取未分配区域设备 |
| | | /// </summary> |
| | | /// <param name="floorId"></param> |
| | | /// <returns></returns> |
| | | public List<SceneUI> GetSceneUIsByFloorId(string floorId) |
| | | public List<DeviceUI> GetUnalloctedDeviceUIs() |
| | | { |
| | | var rooms = GetRoomsByFloorId(floorId); |
| | | if (rooms == null) |
| | | List<DeviceUI> deviceUIs = new List<DeviceUI> { }; |
| | | var dList = AllRoomDeviceUIList; |
| | | var commonDeviceList = Common.LocalDevice.Current.listAllDevice; |
| | | |
| | | if (dList.Count == 0) |
| | | { |
| | | return null; |
| | | } |
| | | var sceneList = new List<SceneUI> { }; |
| | | foreach (var r in rooms) |
| | | foreach (var device in commonDeviceList) |
| | | { |
| | | if (r.SceneUIList.Count == 0) |
| | | if (dList.Find((obj) => obj.CommonDevice == device) == null) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var sceneUI in r.SceneUIList) |
| | | { |
| | | if (sceneUI == null) |
| | | { |
| | | continue; |
| | | } |
| | | sceneList.Add(sceneUI); |
| | | deviceUIs.Add(Common.LocalDevice.Current.GetDeviceUI(device)); |
| | | } |
| | | } |
| | | return sceneList; |
| | | if (deviceUIs.Count == 0) |
| | | { |
| | | return null; |
| | | } |
| | | return deviceUIs; |
| | | } |
| | | |
| | | //public List<DeviceUI> GetUnalloctedDeviceUITypes |
| | | |
| | | #endregion |
| | | |
| | |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | |
| | | var getSceneIdAllData = await ZigBee.Device.Scene.GetSceneNewIdAsync(sceneName); |
| | | if (getSceneIdAllData == null || getSceneIdAllData.getSceneIdData == null) |
| | | { |
| | |
| | | Save(); |
| | | Global.DeleteFilebyHomeId(sceneUI.FileName); |
| | | HdlAutoBackupLogic.DeleteFile(sceneUI.FileName); |
| | | HdlAutoBackupLogic.AddOrEditorFile(FileName); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取该楼层所有场景 |
| | | /// </summary> |
| | |
| | | } |
| | | return sceneUIs; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取该楼层的场景 |
| | | /// </summary> |
| | | /// <param name="floorId"></param> |
| | | /// <returns></returns> |
| | | public List<SceneUI> GetSceneUIsByFloorId(string floorId) |
| | | { |
| | | var rooms = GetRoomsByFloorId(floorId); |
| | | if (rooms == null) |
| | | { |
| | | return null; |
| | | } |
| | | var sceneList = new List<SceneUI> { }; |
| | | foreach (var r in rooms) |
| | | { |
| | | if (r.SceneUIList.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var sceneUI in r.SceneUIList) |
| | | { |
| | | if (sceneUI == null) |
| | | { |
| | | continue; |
| | | } |
| | | sceneList.Add(sceneUI); |
| | | } |
| | | } |
| | | return sceneList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取未分配区域场景 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<SceneUI> GetUnalloctedScenes() |
| | | { |
| | | List<SceneUI> sceneUIs = new List<SceneUI> { }; |
| | | var sList = AllRoomSceneUIFilepathList; |
| | | |
| | | List<string> sfile = new List<string> { }; |
| | | foreach (var path in Global.FileListByHomeId()) |
| | | { |
| | | if (path.StartsWith("Scene_", StringComparison.Ordinal)) |
| | | { |
| | | sfile.Add(path); |
| | | } |
| | | } |
| | | foreach (var path in sfile) |
| | | { |
| | | if (sList.Find((obj) => obj == path) == null) |
| | | { |
| | | var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(path)); |
| | | var tempSceneUI = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneUI>(jsonInfo); |
| | | if (tempSceneUI != null) |
| | | { |
| | | sceneUIs.Add(tempSceneUI); |
| | | } |
| | | } |
| | | } |
| | | if (sceneUIs.Count == 0) |
| | | { |
| | | return null; |
| | | } |
| | | return sceneUIs; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 刷新场景_________________________ |
| | |
| | | }
|
| | |
|
| | | #endregion |
| | | |
| | | |
| | | } |
| | | } |