From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点

---
 HMI.Core/Api/AlarmShowHelper.cs |   65 ++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/HMI.Core/Api/AlarmShowHelper.cs b/HMI.Core/Api/AlarmShowHelper.cs
new file mode 100644
index 0000000..d911f02
--- /dev/null
+++ b/HMI.Core/Api/AlarmShowHelper.cs
@@ -0,0 +1,65 @@
+锘縰sing HMI.Core.Entity;
+using System;
+using System.Collections.Generic;
+
+namespace HMI.Core.Api
+{
+    public class AlarmShowHelper
+    {
+        private static List<IAlarmHandler> handlers;
+
+        private static IAlarmShow shower;
+
+        public static void Register(IAlarmShow shower)
+        {
+            if (AlarmShowHelper.shower == null)
+            {
+                AlarmShowHelper.shower = shower;
+            }
+        }
+
+        public static void UnRegister(IAlarmShow shower)
+        {
+            if (AlarmShowHelper.shower == shower)
+            {
+                AlarmShowHelper.shower = null;
+            }
+        }
+
+        public static void AddHandler(IAlarmHandler handler)
+        {
+            if (handlers == null)
+            {
+                handlers = new List<IAlarmHandler>();
+            }
+            if (!handlers.Contains(handler))
+            {
+                handlers.Add(handler);
+            }
+        }
+
+        public static bool ShowAlarm(AlarmText alarm)
+        {
+            if (handlers != null)
+            {
+                foreach (var handler in handlers)
+                {
+                    try
+                    {
+                        handler.HandleAlarm(alarm);
+                    }
+                    catch (Exception ex)
+                    {
+
+                    }
+                }
+            }
+
+            if (shower != null)
+            {
+                return shower.ShowAlarm(alarm);
+            }
+            return false;
+        }
+    }
+}

--
Gitblit v1.9.1