| | |
| | | case Command.ReadCurtainStutasACK: |
| | | foreach (var curtain in DB_ResidenceData.residenceData.functionList.curtains) |
| | | { |
| | | if (curtain.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]) |
| | | if (curtain.bus_Data.SubnetID == subnetID && curtain.bus_Data.DeviceID == deviceID) |
| | | { |
| | | switch(receiveBytes[1]) |
| | | if (receiveBytes[0] == 17) |
| | | { |
| | | case 0: |
| | | curtain.on_off = "stop"; |
| | | break; |
| | | case 1: |
| | | if (receiveBytes[1] > 1) |
| | | { |
| | | curtain.on_off = "on"; |
| | | curtain.lastState = Language.StringByID(StringId.Open); |
| | | break; |
| | | case 2: |
| | | } |
| | | else |
| | | { |
| | | curtain.on_off = "off"; |
| | | curtain.lastState = Language.StringByID(StringId.Close); |
| | | break; |
| | | default: |
| | | if (receiveBytes[1] > 1) |
| | | { |
| | | } |
| | | curtain.openLevel = receiveBytes[1]; |
| | | curtain.lastState = Language.StringByID(StringId.Open) + curtain.openLevel + "%"; |
| | | } |
| | | else |
| | | { |
| | | if (curtain.bus_Data.LoopID != receiveBytes[0]) |
| | | continue; |
| | | switch (receiveBytes[1]) |
| | | { |
| | | case 0: |
| | | curtain.on_off = "stop"; |
| | | break; |
| | | case 1: |
| | | curtain.on_off = "on"; |
| | | } |
| | | else |
| | | { |
| | | curtain.lastState = Language.StringByID(StringId.Open); |
| | | break; |
| | | case 2: |
| | | curtain.on_off = "off"; |
| | | } |
| | | curtain.openLevel = receiveBytes[1]; |
| | | curtain.lastState = Language.StringByID(StringId.Open) + curtain.openLevel + "%"; |
| | | break; |
| | | curtain.lastState = Language.StringByID(StringId.Close); |
| | | break; |
| | | } |
| | | } |
| | | RoomPage.UpdataStates(curtain); |
| | | FunctionPage.UpdataStates(curtain); |
| | | HomePage.UpdataFunctionStates(curtain); |
| | | ClassificationPage.UpdataInfo(curtain); |
| | | RollingShutterPage.UpdataState(curtain); |
| | | switch (curtain.functionType) |
| | | { |
| | | case FunctionType.Curtain: |
| | |
| | | } |
| | | } |
| | | break; |
| | | case Command.ReadDeviceLoopInfoACK: |
| | | FunctionType dt = (FunctionType)(11 * 256 + receiveBytes[1]); |
| | | string tag = receiveBytes[1] + "_" + subnetID + "_" + deviceID + "_" + receiveBytes[2]; |
| | | |
| | | foreach (var sensor in DB_ResidenceData.residenceData.functionList.sensorsEnvironmentalScience) |
| | | { |
| | | if (sensor.bus_Data != null) |
| | | { |
| | | if ((int)sensor.functionType % 256 == receiveBytes[1] && sensor.bus_Data.SubnetID == subnetID && |
| | | sensor.bus_Data.DeviceID == deviceID && sensor.bus_Data.LoopID == receiveBytes[2]) |
| | | { |
| | | switch (dt) |
| | | { |
| | | case FunctionType.Temp: |
| | | byte[] tempBytes = new byte[] { receiveBytes[24], receiveBytes[25], receiveBytes[26], receiveBytes[27] }; |
| | | sensor.values = Math.Round(BitConverter.ToSingle(tempBytes, 0), 1); |
| | | break; |
| | | case FunctionType.Humidity: |
| | | sensor.values = Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 10; |
| | | break; |
| | | case FunctionType.TVOC: |
| | | sensor.values = Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 100; |
| | | break; |
| | | case FunctionType.PM25: |
| | | sensor.values = Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]); |
| | | break; |
| | | case FunctionType.CO2: |
| | | sensor.values = Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]); |
| | | break; |
| | | } |
| | | EnvironmentalSciencePage.LoadEvent_UpdataStatus(sensor); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case Command.New_Analog_Quantity_BROADCAST: |
| | | string tag1 = receiveBytes[1] + "_" + subnetID + "_" + deviceID + "_" + receiveBytes[2]; |
| | | foreach (var sensor in DB_ResidenceData.residenceData.functionList.sensorsEnvironmentalScience) |
| | | { |
| | | if (sensor.bus_Data != null) |
| | | { |
| | | if ((int)sensor.functionType % 256 == receiveBytes[1] && sensor.bus_Data.SubnetID == subnetID && |
| | | sensor.bus_Data.DeviceID == deviceID && sensor.bus_Data.LoopID == receiveBytes[2]) |
| | | { |
| | | //0保留 1无符号4Byte整形 2有符号4Byte整形 3Float形(代±) |
| | | switch (receiveBytes[3]) |
| | | { |
| | | case 1: |
| | | sensor.values = (receiveBytes[5]*256 * 256 * 256)+ (receiveBytes[6] * 256 * 256)+ (receiveBytes[7] * 256)+ receiveBytes[8]; |
| | | break; |
| | | case 2: |
| | | sensor.values = -1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]); |
| | | break; |
| | | case 3: |
| | | byte[] tempBytes = new byte[] { receiveBytes[5], receiveBytes[6], receiveBytes[7], receiveBytes[8] }; |
| | | sensor.values = Math.Round(BitConverter.ToSingle(tempBytes, 0), 1); |
| | | break; |
| | | } |
| | | switch (receiveBytes[4]) |
| | | { |
| | | case 2: |
| | | if (receiveBytes[1] == 5)//TVOC需求除以100000 |
| | | sensor.values /= 100000; |
| | | break; |
| | | } |
| | | EnvironmentalSciencePage.LoadEvent_UpdataStatus(sensor); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | string tempFileName = nameValueCollection["Command"].Replace("Get", ""); |
| | | if ("AllFiles" == tempFileName) |
| | | { |
| | | byte[] bytes = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(FileUtils.ReadFiles())); |
| | | byte[] bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(FileUtils.ReadFiles())); |
| | | outputStream.Write(bytes, 0, bytes.Length); |
| | | outputStream.Flush(); |
| | | } |