| | |
| | | this.InitRoomData();
|
| | | //初始化设备
|
| | | this.InitDeviceData();
|
| | | //初始化场景
|
| | | this.InitSceneData();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | }
|
| | | 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;
|
| | |
| | | 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>
|
| | | /// 初始化房间
|
| | |
| | |
|
| | | //获取全部的楼层主键
|
| | | 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];
|
| | |
| | | {
|
| | | //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;
|
| | | }
|
| | |
|
| | |
| | | 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
|
| | |
| | | {
|
| | | 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℃
|