| | |
| | | /// </summary> |
| | | public class Packet |
| | | { |
| | | ///// <summary> |
| | | ///// 缓冲区大小 |
| | | ///// Link协议现在一个包的数据比较大,缓冲区太小存不完全部数据 2023-07-14 16:03:56 wxr |
| | | ///// </summary> |
| | | //public const int Size = 2000; |
| | | /// <summary> |
| | | /// 缓冲区大小 |
| | | /// Link协议现在一个包的数据比较大,缓冲区太小存不完全部数据 2023-07-14 16:03:56 wxr |
| | | /// </summary> |
| | | public const int Size = 1024 * 10; |
| | | |
| | | /// <summary> |
| | | /// 接收到的数据 |
| | |
| | | /// </summary> |
| | | public System.Net.EndPoint RemoteEndPoint; |
| | | |
| | | public Packet(int lenght) |
| | | public Packet() |
| | | { |
| | | this.Bytes = new byte[lenght]; |
| | | |
| | | this.Bytes = new byte[Size]; |
| | | RemoteEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Any, 0); |
| | | } |
| | | |
| | | |
| | | |
| | | public Packet(byte[] data, System.Net.EndPoint remoteEndPoint) |
| | | { |
| | | this.Bytes = data; |
| | |
| | | |
| | | #if DEBUG |
| | | #else |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"packet {ex.Message} "); |
| | |
| | | light.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[light.bus.LoopId] == 0 ? "off" : "on"); |
| | | if (light.trait_on_off.curValue.ToString() == "on") |
| | | { |
| | | light.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[i+1].ToString()); |
| | | light.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[i + 1].ToString()); |
| | | light.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%"; |
| | | } |
| | | HomePage.UpdataFunctionStates(light); |
| | |
| | | FunctionPage.UpdataStates(lightTeme); |
| | | ClassificationPage.UpdataInfo(lightTeme); |
| | | RGBPage.UpdataStates(lightTeme); |
| | | }else if(lightTeme.spk == SPK.LightCCT) |
| | | } |
| | | else if (lightTeme.spk == SPK.LightCCT) |
| | | { |
| | | lightTeme.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[1] > 0 ? "on" : "off"); |
| | | if (receiveBytes[1] > 0) |
| | |
| | | case Command.ReadACModeACK: |
| | | foreach (var function in FunctionList.List.Functions) |
| | | { |
| | | if (function.bus == null || function.spk != SPK.AcStandard) |
| | | { |
| | | continue; |
| | | } |
| | | if (function.bus == null || function.spk != SPK.AcStandard) |
| | | { |
| | | continue; |
| | | } |
| | | var acFunction = new AC(); |
| | | if (function.bus.SubnetID == subnetID && |
| | | function.bus.DeviceID == deviceID && |
| | | function.bus.DeviceID == deviceID && |
| | | function.bus.LoopId == receiveBytes[0]) |
| | | { |
| | | Console.WriteLine(function.GetBusId()); |
| | | Console.WriteLine(function.GetBusId()); |
| | | function.SetAttrState(FunctionAttributeKey.TempType, receiveBytes[1].ToString()); |
| | | function.SetAttrState(FunctionAttributeKey.RoomTemp, receiveBytes[2].ToString()); |
| | | function.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[8] == 1 ? "on" : "off"); |
| | | acFunction.SetMode(receiveBytes[9],function); |
| | | acFunction.SetFan(receiveBytes[10],function); |
| | | function.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[8] == 1 ? "on" : "off"); |
| | | acFunction.SetMode(receiveBytes[9], function); |
| | | acFunction.SetFan(receiveBytes[10], function); |
| | | function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[11].ToString()); |
| | | function.lastState = ""; |
| | | switch (function.GetAttrState(FunctionAttributeKey.Mode)) |
| | |
| | | { |
| | | function.SetAttrState(FunctionAttributeKey.TempType, receiveBytes[2]); |
| | | function.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[1] % 2 == 0 ? "off" : "on"); |
| | | new FloorHeating().SetModeIndex(receiveBytes[3],function); |
| | | new FloorHeating().SetModeIndex(receiveBytes[3], function); |
| | | |
| | | if (function.Fh_Mode_Temp.ContainsKey("normal")) |
| | | { |
| | |
| | | if (receiveBytes[9] > 128) |
| | | { |
| | | indoorTemp = 1 - (receiveBytes[9] - 128); |
| | | }else |
| | | } |
| | | else |
| | | { |
| | | indoorTemp = receiveBytes[9]; |
| | | } |
| | |
| | | { |
| | | case SPK.SensorTemperature: |
| | | byte[] tempBytes = new byte[] { receiveBytes[24], receiveBytes[25], receiveBytes[26], receiveBytes[27] }; |
| | | sensor.SetAttrState(FunctionAttributeKey.Value,Math.Round(BitConverter.ToSingle(tempBytes, 0), 1).ToString()); |
| | | sensor.SetAttrState(sensor.spk,Math.Round(BitConverter.ToSingle(tempBytes, 0), 1).ToString()); |
| | | sensor.SetAttrState(FunctionAttributeKey.Value, Math.Round(BitConverter.ToSingle(tempBytes, 0), 1).ToString()); |
| | | sensor.SetAttrState(sensor.spk, Math.Round(BitConverter.ToSingle(tempBytes, 0), 1).ToString()); |
| | | break; |
| | | case SPK.SensorHumidity: |
| | | sensor.SetAttrState(FunctionAttributeKey.Value, (Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 10).ToString()); |
| | |
| | | sensor.SetAttrState(sensor.spk, (Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 100).ToString()); |
| | | break; |
| | | case SPK.SensorPm25: |
| | | sensor.SetAttrState(FunctionAttributeKey.Value,Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); |
| | | sensor.SetAttrState(sensor.spk,Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); |
| | | sensor.SetAttrState(FunctionAttributeKey.Value, Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); |
| | | sensor.SetAttrState(sensor.spk, Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); |
| | | break; |
| | | case SPK.SensorCO2: |
| | | sensor.SetAttrState(FunctionAttributeKey.Value, Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); |
| | |
| | | break; |
| | | } |
| | | EnvironmentalPage.LoadEvent_UpdataStatus(sensor); |
| | | //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(sensor); |
| | | //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(sensor); |
| | | } |
| | | } |
| | | } |
| | |
| | | switch (receiveBytes[3]) |
| | | { |
| | | case 1: |
| | | sensor.SetAttrState(FunctionAttributeKey.Value,( (receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]).ToString()); |
| | | sensor.SetAttrState(sensor.spk,( (receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]).ToString()); |
| | | sensor.SetAttrState(FunctionAttributeKey.Value, ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]).ToString()); |
| | | sensor.SetAttrState(sensor.spk, ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]).ToString()); |
| | | break; |
| | | case 2: |
| | | sensor.SetAttrState(FunctionAttributeKey.Value,( -1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8])).ToString()); |
| | | sensor.SetAttrState(sensor.spk,( -1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8])).ToString()); |
| | | sensor.SetAttrState(FunctionAttributeKey.Value, (-1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8])).ToString()); |
| | | sensor.SetAttrState(sensor.spk, (-1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8])).ToString()); |
| | | break; |
| | | case 3: |
| | | byte[] tempBytes = new byte[] { receiveBytes[5], receiveBytes[6], receiveBytes[7], receiveBytes[8] }; |
| | | sensor.SetAttrState(FunctionAttributeKey.Value,( Math.Round(BitConverter.ToSingle(tempBytes, 0), 1)).ToString()); |
| | | sensor.SetAttrState(sensor.spk,( Math.Round(BitConverter.ToSingle(tempBytes, 0), 1)).ToString()); |
| | | sensor.SetAttrState(FunctionAttributeKey.Value, (Math.Round(BitConverter.ToSingle(tempBytes, 0), 1)).ToString()); |
| | | sensor.SetAttrState(sensor.spk, (Math.Round(BitConverter.ToSingle(tempBytes, 0), 1)).ToString()); |
| | | break; |
| | | } |
| | | switch (receiveBytes[4]) |
| | |
| | | } |
| | | break; |
| | | } |
| | | |
| | | //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(sensor); |
| | | |
| | | //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(sensor); |
| | | EnvironmentalPage.LoadEvent_UpdataStatus(sensor); |
| | | } |
| | | } |
| | |
| | | function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[1].ToString()); |
| | | break; |
| | | case 5: |
| | | acFunction.SetFan ( receiveBytes[1],function); |
| | | acFunction.SetFan(receiveBytes[1], function); |
| | | break; |
| | | case 6: |
| | | acFunction.SetMode ( receiveBytes[1],function); |
| | | acFunction.SetMode(receiveBytes[1], function); |
| | | break; |
| | | |
| | | } |
| | |
| | | |
| | | #if DEBUG |
| | | #else |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"Bus Rev Erorr : {ex.Message}"); |
| | |
| | | default: |
| | | break; |
| | | } |
| | | Control_Udp.ReceiveRepeatManager(receiveFlag,usefulBytes); |
| | | Control_Udp.ReceiveRepeatManager(receiveFlag, usefulBytes); |
| | | } |
| | | catch (Exception ex) |
| | | { |