| | |
| | | { |
| | | try |
| | | { |
| | | var residenceDataBytes = MyIO.FileUtils.ReadFile("DB_ResidenceData"); |
| | | var residenceDataBytes = FileUtils.ReadFile("DB_ResidenceData"); |
| | | var userConfigString = CommonPage.MyEncodingUTF8.GetString(residenceDataBytes); |
| | | DB_ResidenceData temp = null; |
| | | if (userConfigString != null) |
| | |
| | | instance.residenceName = "妮儿的家"; |
| | | instance.residenceImage = "Classification/Room/Roombg.png"; |
| | | var r = new Room() { sid = "0001", name = "Room-1", floor = "1F", backgroundImage = "Classification/Room/Roombg.png" }; |
| | | /* |
| | | r.functions.Add(new Function() |
| | | { |
| | | sid = "000000000000000000000000000000000001", |
| | | funcType = FunctionType.AC, |
| | | Name = "空调", |
| | | name = "空调", |
| | | roomIdList = new List<string>() { "0001" }, |
| | | lastState = "制冷 中风 18°C" |
| | | lastState = "制冷 中风 18°C", |
| | | bus_Data = "{" +
|
| | | "\"SubnetID\":42" + "," + |
| | | "\"DeviceID\":8" + "," + |
| | | "\"LoopID\":1" + |
| | | "}", |
| | | }); |
| | | r.functions.Add(new Function() |
| | | r.functions.Add(new Dimmer() |
| | | { |
| | | sid = "000000000000000000000000000000000002", |
| | | sid = "0001002019101209000025670400010002", |
| | | funcType = FunctionType.Light, |
| | | Name = "客厅灯", |
| | | name = "客厅灯", |
| | | roomIdList = new List<string>() { "0001" }, |
| | | lastState = "打开20%亮度" |
| | | lastState = "20%", |
| | | bus_Data = "{" +
|
| | | "\"SubnetID\":111" + "," + |
| | | "\"DeviceID\":2" + "," + |
| | | "\"LoopID\":1" + |
| | | "}", |
| | | }); |
| | | r.functions.Add(new Function() |
| | | r.functions.Add(new Light() |
| | | { |
| | | sid = "000000000000000000000000000000000003", |
| | | funcType = FunctionType.Curtain, |
| | | Name = "窗帘", |
| | | name = "窗帘", |
| | | roomIdList = new List<string>() { "0001" }, |
| | | lastState = "打开20%" |
| | | lastState = "20%", |
| | | bus_Data = "{" +
|
| | | "\"SubnetID\":42" + "," + |
| | | "\"DeviceID\":7" + "," + |
| | | "\"LoopID\":1" + |
| | | "}", |
| | | }); |
| | | r.functions.Add(new Function() |
| | | { |
| | | sid = "000000000000000000000000000000000004", |
| | | funcType = FunctionType.FloorHeating, |
| | | Name = "地热", |
| | | name = "地热", |
| | | roomIdList = new List<string>() { "0001" }, |
| | | lastState = "" |
| | | }); |
| | | |
| | | r.functions.Add(new Light() |
| | | { |
| | | sid = "0001002019101209000025670400010005", |
| | | funcType = FunctionType.Light, |
| | | name = "客厅大灯", |
| | | roomIdList = new List<string>() { "0001" }, |
| | | bus_Data = "{" +
|
| | | "\"SubnetID\":111" + "," + |
| | | "\"DeviceID\":6" + "," + |
| | | "\"LoopID\":1" + |
| | | "}", |
| | | }); |
| | | */ |
| | | //-------------------- |
| | | instance.functions.Add(new Function() |
| | | { |
| | | sid = "000000000000000000000000000000000001", |
| | | funcType = FunctionType.AC, |
| | | Name = "空调", |
| | | name = "空调", |
| | | roomIdList = new List<string>() { "0001" }, |
| | | lastState = "制冷 中风 18°C" |
| | | collection = true, |
| | | lastState = "制冷 中风 18°C", |
| | | bus_Data = "{" +
|
| | | "\"SubnetID\":42" + "," + |
| | | "\"DeviceID\":8" + "," + |
| | | "\"LoopID\":1" + |
| | | "}", |
| | | }); |
| | | instance.functions.Add(new Function() |
| | | instance.functions.Add(new Dimmer() |
| | | { |
| | | sid = "000000000000000000000000000000000002", |
| | | sid = "0001002019101209000025670400010002", |
| | | funcType = FunctionType.Light, |
| | | Name = "客厅灯", |
| | | name = "客厅灯", |
| | | roomIdList = new List<string>() { "0001" }, |
| | | lastState = "打开20%亮度" |
| | | lastState = "20%", |
| | | bus_Data = "{" +
|
| | | "\"SubnetID\":111" + "," + |
| | | "\"DeviceID\":2" + "," + |
| | | "\"LoopID\":1" + |
| | | "}", |
| | | }); |
| | | instance.functions.Add(new Light() |
| | | { |
| | | sid = "0001002019101209000025670400010005", |
| | | funcType = FunctionType.Light, |
| | | name = "客厅大灯", |
| | | roomIdList = new List<string>() { "0001" }, |
| | | collection = true, |
| | | bus_Data = "{" +
|
| | | "\"SubnetID\":111" + "," + |
| | | "\"DeviceID\":6" + "," + |
| | | "\"LoopID\":1" + |
| | | "}", |
| | | }); |
| | | instance.functions.Add(new Function() |
| | | { |
| | | sid = "000000000000000000000000000000000003", |
| | | funcType = FunctionType.Curtain, |
| | | Name = "窗帘", |
| | | name = "窗帘", |
| | | roomIdList = new List<string>() { "0001" }, |
| | | lastState = "打开20%" |
| | | lastState = "20%" |
| | | }); |
| | | instance.functions.Add(new Function() |
| | | { |
| | | sid = "000000000000000000000000000000000004", |
| | | funcType = FunctionType.FloorHeating, |
| | | Name = "地热", |
| | | collection = true, |
| | | name = "地热", |
| | | roomIdList = new List<string>() { "0001" }, |
| | | lastState = "" |
| | | }); |
| | |
| | | public void SaveResidenceData() |
| | | { |
| | | var ssd = CommonPage.MyEncodingUTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); |
| | | MyIO.FileUtils.WriteFileByBytes("DB_ResidenceData", ssd); |
| | | FileUtils.WriteFileByBytes("DB_ResidenceData", ssd); |
| | | } |
| | | |
| | | |
| | | |
| | | //public List<Function> busDeviceList = new List<Function>(); |
| | | //public void InitBusDeivces() |
| | | //{ |
| | | // foreach(var room in rooms) |
| | | // { |
| | | // foreach(var function in room.functions) |
| | | // { |
| | | // if (!string.IsNullOrEmpty(function.bus_Data)) |
| | | // { |
| | | // busDeviceList.Add(function); |
| | | // } |
| | | // } |
| | | // } |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 刷新住宅里面的搜索设备状态 |
| | | /// </summary> |
| | | public void RefreshResidenceFunctionStatus() |
| | | { |
| | | foreach (var function in functions) |
| | | { |
| | | if (!string.IsNullOrEmpty(function.bus_Data)) |
| | | { |
| | | if(function.funcType == FunctionType.Light) |
| | | { |
| | | Control.Send("read", function, 3); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |