From d099a65ce3f5f8ed9ba345f8f3bdcf617fa4af75 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期三, 08 十一月 2023 09:55:40 +0800
Subject: [PATCH] 更改udp
---
HDL_ON/DAL/DriverLayer/Packet.cs | 58 +++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/HDL_ON/DAL/DriverLayer/Packet.cs b/HDL_ON/DAL/DriverLayer/Packet.cs
index 19e93d7..99f46b8 100644
--- a/HDL_ON/DAL/DriverLayer/Packet.cs
+++ b/HDL_ON/DAL/DriverLayer/Packet.cs
@@ -12,10 +12,11 @@
/// </summary>
public class Packet
{
- /// <summary>
- /// 缂撳啿鍖哄ぇ灏�
- /// </summary>
- public const int Size = 1024 + 200;
+ ///// <summary>
+ ///// 缂撳啿鍖哄ぇ灏�
+ ///// Link鍗忚鐜板湪涓�涓寘鐨勬暟鎹瘮杈冨ぇ锛岀紦鍐插尯澶皬瀛樹笉瀹屽叏閮ㄦ暟鎹� 2023-07-14 16:03:56 wxr
+ ///// </summary>
+ //public const int Size = 2000;
/// <summary>
/// 鎺ユ敹鍒扮殑鏁版嵁
@@ -27,11 +28,15 @@
/// </summary>
public System.Net.EndPoint RemoteEndPoint;
- public Packet()
+ public Packet(int lenght)
{
- this.Bytes = new byte[Size];
+ this.Bytes = new byte[lenght];
+
RemoteEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Any, 0);
}
+
+
+
public Packet(byte[] data, System.Net.EndPoint remoteEndPoint)
{
this.Bytes = data;
@@ -53,8 +58,11 @@
/// </summary>
public virtual void Manager()
{
+#if DEBUG
+#else
try
- {
+ {
+#endif
//瀵逛簬鎿嶄綔鏁版嵁搴撶殑鏃堕棿姣旇緝闀跨殑锛屽彲浠ュ垱寤哄彟涓�涓嚎绋嬪鐞�
if (!"HDLMIRACLE".Equals(Encoding.ASCII.GetString(Bytes, 4, 10)))
{
@@ -102,11 +110,15 @@
#endif
//澶勭悊鏄惁瑕侀噸鍙戞暟鎹�
ManagerReceive(subnetID, deviceID, command, usefulBytes);
- }
+
+#if DEBUG
+#else
+ }
catch (Exception ex)
{
MainPage.Log($"packet {ex.Message} ");
}
+#endif
}
/// <summary>
@@ -118,8 +130,11 @@
/// <param name="receiveBytes"></param>
void UdpPacket_DataProcessing(byte subnetID, byte deviceID, Command command, byte[] receiveBytes)
{
+#if DEBUG
+#else
try
{
+#endif
switch (command)
{
case Command.SetSingleLightACK:
@@ -323,17 +338,27 @@
case SPK.CurtainRoller:
RollingShutterPage.UpdataState(curtain);
break;
+ case SPK.CurtainShades:
+ VenetianBlindsPage.UpdataState(curtain);
+ break;
}
}
}
break;
case Command.SetACModeACK:
case Command.ReadACModeACK:
- foreach (var function in FunctionList.List.GetAcList())
+ foreach (var function in FunctionList.List.Functions)
{
+ if (function.bus == null || function.spk != SPK.AcStandard)
+ {
+ continue;
+ }
var acFunction = new AC();
- if (function.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
+ if (function.bus.SubnetID == subnetID &&
+ function.bus.DeviceID == deviceID &&
+ function.bus.LoopId == receiveBytes[0])
{
+ 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");
@@ -379,7 +404,7 @@
FunctionPage.UpdataStates(function);
HomePage.UpdataFunctionStates(function);
ClassificationPage.UpdataInfo(function);
- Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(function.sid, function.status);
+ Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(function);
}
}
@@ -652,7 +677,9 @@
}
function.lastState = "";
- function.lastState += " " + function.GetAttrState(FunctionAttributeKey.SetTemp) + acFunction.GetTempUnitString(function);
+ function.lastState += acFunction.GetModeAttrText(function.GetAttrState(FunctionAttributeKey.Mode)) +
+ acFunction.GetModeAttrText(function.GetAttrState(FunctionAttributeKey.FanSpeed)) +
+ " " + function.GetAttrState(FunctionAttributeKey.SetTemp) + acFunction.GetTempUnitString(function);
RoomPage.UpdataStates(function);
FunctionPage.UpdataStates(function);
HomePage.UpdataFunctionStates(function);
@@ -726,11 +753,16 @@
}
break;
}
- }
+
+#if DEBUG
+#else
+ }
catch (Exception ex)
{
MainPage.Log($"Bus Rev Erorr : {ex.Message}");
}
+#endif
+
}
/// <summary>
/// byte杞�16杩涘埗瀛楃涓�
--
Gitblit v1.8.0