From 4cc04639fbadde3a7f3b9875353df0d90fc09043 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期六, 18 一月 2020 14:33:40 +0800 Subject: [PATCH] 节前备份 --- HDL_ON/Entity/DB_ResidenceData.cs | 136 ++++++++++++++++++++++++++++++++++++++------- 1 files changed, 114 insertions(+), 22 deletions(-) diff --git a/HDL_ON/Entity/DB_ResidenceData.cs b/HDL_ON/Entity/DB_ResidenceData.cs index b2ba18d..7142a14 100644 --- a/HDL_ON/Entity/DB_ResidenceData.cs +++ b/HDL_ON/Entity/DB_ResidenceData.cs @@ -39,7 +39,7 @@ { 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) @@ -60,69 +60,122 @@ 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 = "" }); @@ -137,7 +190,46 @@ 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 + { + + } + } + } + } } -- Gitblit v1.8.0