From 02c39baf5375f1588e9c20dc06d89a0605077672 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 10 二月 2025 10:41:44 +0800
Subject: [PATCH] Merge branch 'liuyang' into clh

---
 SourceCode/Bond/Servo/Servo.cpp |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/SourceCode/Bond/Servo/Servo.cpp b/SourceCode/Bond/Servo/Servo.cpp
index b422966..495b5e7 100644
--- a/SourceCode/Bond/Servo/Servo.cpp
+++ b/SourceCode/Bond/Servo/Servo.cpp
@@ -6,6 +6,11 @@
 #include "Servo.h"
 #include "ServoDlg.h"
 #include "ServoGraph.h"
+#include "AlarmManager.h"
+
+// 声明全局变量,用于管理 GDI+ 初始化
+ULONG_PTR g_diplusToken;
+GdiplusStartupInput g_diplusStartupInput;
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -93,6 +98,25 @@
 	HSMS_Initialize();
 
 
+	// 初始化 GDI+
+	InitGDIPlus();
+
+
+	// 初始化报警管理器
+	try {
+		if (!AlarmManager::getInstance().initAlarmTable()) {
+			AfxMessageBox("初始化报警管理器失败!");
+			return FALSE;
+		}
+	}
+	catch (const std::exception& ex) {
+		CString errorMsg;
+		errorMsg.Format(_T("初始化报警管理器失败:%s"), CString(ex.what()));
+		AfxMessageBox(errorMsg, MB_ICONERROR);
+		return FALSE;
+	}
+
+
 	CServoDlg dlg;
 	m_pMainWnd = &dlg;
 	INT_PTR nResponse = dlg.DoModal();
@@ -129,5 +153,25 @@
 	HSMS_Term();
 	RX_Term();
 
+	// 清理 GDI+
+	TermGDIPlus();
+
+	// 销毁报警表
+	AlarmManager::getInstance().termAlarmTable();
+
 	return CWinApp::ExitInstance();
 }
+
+// 初始化 GDI+
+void CServoApp::InitGDIPlus()
+{
+	// 初始化 GDI+ 图形库
+	GdiplusStartup(&g_diplusToken, &g_diplusStartupInput, NULL);
+}
+
+// 清理 GDI+
+void CServoApp::TermGDIPlus()
+{
+	// 清理 GDI+ 图形库
+	GdiplusShutdown(g_diplusToken);
+}
\ No newline at end of file

--
Gitblit v1.9.3