From 771a0e7b6b1276087515bbe94de28358cb92963b Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期四, 04 六月 2026 10:32:27 +0800
Subject: [PATCH] 优化老化;

---
 HMI.Core/Api/AlarmShowHelper.cs |   47 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/HMI.Core/Api/AlarmShowHelper.cs b/HMI.Core/Api/AlarmShowHelper.cs
index 172a9ef..d911f02 100644
--- a/HMI.Core/Api/AlarmShowHelper.cs
+++ b/HMI.Core/Api/AlarmShowHelper.cs
@@ -1,7 +1,13 @@
-锘縩amespace HMI.Core.Api
+锘縰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)
@@ -12,11 +18,46 @@
             }
         }
 
-        public static bool ShowAlarm(string message)
+        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(message);
+                return shower.ShowAlarm(alarm);
             }
             return false;
         }

--
Gitblit v1.9.1