From 559890c482f5973f06aafdfec9550fee5ba3c7f2 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 09 十一月 2026 17:02:15 +0800
Subject: [PATCH] feat: CAN 模拟器 TCP 化 + 多设备并发调试 + 后台生命周期管理
---
SimpleUtil/HMI.Simple.Util/MSMQHelper.cs | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/SimpleUtil/HMI.Simple.Util/MSMQHelper.cs b/SimpleUtil/HMI.Simple.Util/MSMQHelper.cs
index 3232d7e..06d9f04 100644
--- a/SimpleUtil/HMI.Simple.Util/MSMQHelper.cs
+++ b/SimpleUtil/HMI.Simple.Util/MSMQHelper.cs
@@ -3,6 +3,15 @@
namespace HMI.Simple.Util
{
+
+ public class MQAlarm
+ {
+ public string Source { get; set; }
+ public string Content { get; set; }
+ public int Level { get; set; }
+ }
+
+
public class MSMQHelper : IDisposable
{
/// <summary>
@@ -40,7 +49,7 @@
// 濡傛灉娑堟伅闃熷垪涓嶅瓨鍦紝鍒欏垱寤烘秷鎭鍨�
this.msgQueue = MessageQueue.Create(this.msmqPath);
}
- this.msgQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });
+ this.msgQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(MQAlarm) });
}
catch (Exception ex)
{
@@ -53,11 +62,11 @@
/// </summary>
/// <param name="MessageID">娑堟伅ID</param>
/// <param name="MsgString">瑕佸彂閫佺殑瀛楃涓�</param>
- public void Send(string MessageID, string MsgString)
+ public void Send(string MessageID, string source, string MsgString, int level)
{
try
{
- this.msgQueue.Send(MsgString, MessageID);
+ this.msgQueue.Send(new MQAlarm { Source = source, Content = MsgString, Level = level }, MessageID);
}
catch (Exception ex)
{
@@ -71,12 +80,12 @@
/// <param name="TimeOut">瓒呮椂鏃堕棿(ms)</param>
/// <param name="MessageID">娑堟伅ID</param>
/// <param name="MsgString">娑堟伅鍐呭</param>
- public void Receive(long TimeOut, out string MessageID, out string MsgString)
+ public void Receive(long TimeOut, out string MessageID, out MQAlarm alarm)
{
try
{
MessageID = string.Empty;
- MsgString = string.Empty;
+ alarm = null;
TimeSpan Time = new TimeSpan(TimeOut);
Message MsgReceived = null;
try
@@ -91,7 +100,7 @@
if (MsgReceived != null)
{
MessageID = MsgReceived.Label;
- MsgString = MsgReceived.Body.ToString();
+ alarm = (MQAlarm)MsgReceived.Body;
}
}
catch (Exception ex)
--
Gitblit v1.9.1