From e42e8364112e97d89eeaecd13f043dff42179949 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 27 五月 2025 17:19:02 +0800
Subject: [PATCH] 1.enum修改为enum class, 理顺CLoadPort各成员变量在调度中的判定作用;

---
 SourceCode/Bond/Servo/ServoDlg.cpp |   91 ++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 81 insertions(+), 10 deletions(-)

diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index cb8666e..6ce2bf0 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -25,6 +25,10 @@
 /* 创建终端的定时器 */
 #define TIMER_ID_CREATE_TERMINAL		1
 
+/* 运行时间定时器 */
+#define TIMER_ID_UPDATE_RUMTIME			2
+
+
 
 // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
 
@@ -79,6 +83,7 @@
 	m_pPageLog = nullptr;
 	m_pPageRecipe = nullptr;
 	m_pTopToolbar = nullptr;
+	m_pMyStatusbar = nullptr;
 }
 
 void CServoDlg::DoDataExchange(CDataExchange* pDX)
@@ -162,6 +167,22 @@
 						m_pPanelAttributes->ShowWindow(SW_SHOW);
 						Resize();
 					}
+				}
+			}
+			else if (RX_CODE_MASTER_STATE_CHANGED == code) {
+				SERVO::MASTERSTATE state = theApp.m_model.getMaster().getState();
+				if (state == SERVO::MASTERSTATE::READY) {
+					m_pMyStatusbar->setBackgroundColor(STATUSBAR_BK_NORMAL);
+					m_pMyStatusbar->setForegroundColor(RGB(0, 0, 0));
+					KillTimer(TIMER_ID_UPDATE_RUMTIME);
+					CString strText;
+					GetRuntimeFormatText(strText, "");
+					m_pMyStatusbar->setRunTimeText((LPTSTR)(LPCTSTR)strText);
+				}
+				else if (state == SERVO::MASTERSTATE::RUNNING) {
+					m_pMyStatusbar->setBackgroundColor(STATUSBAR_BK_RUNNING);
+					m_pMyStatusbar->setForegroundColor(RGB(255, 255, 255));
+					SetTimer(TIMER_ID_UPDATE_RUMTIME, 500, nullptr);
 				}
 			}
 
@@ -258,6 +279,13 @@
 	m_pPanelAttributes = new CPanelAttributes();
 	m_pPanelAttributes->Create(IDD_PANEL_ATTRIBUTES, this);
 	
+
+	// statusbar
+	m_pMyStatusbar = new CMyStatusbar();
+	m_pMyStatusbar->Create(IDD_STATUSBAR, this);
+	m_pMyStatusbar->ShowWindow(SW_SHOW);
+
+
 
 	// 调整初始窗口位置
 	CRect rcWnd;
@@ -512,6 +540,12 @@
 		m_pTopToolbar = nullptr;
 	}
 
+	if (m_pMyStatusbar != nullptr) {
+		m_pMyStatusbar->DestroyWindow();
+		delete m_pMyStatusbar;
+		m_pMyStatusbar = nullptr;
+	}
+
 	if (m_pTerminalDisplayDlg != nullptr) {
 		m_pTerminalDisplayDlg->DestroyWindow();
 		delete m_pTerminalDisplayDlg;
@@ -592,34 +626,39 @@
 }
 
 #define TOOLBAR_HEIGHT		78
+#define STATUSBAR_HEIGHT	38
 void CServoDlg::Resize()
 {
 	CRect rcClient, rcItem;
 	CWnd* pItem = nullptr;
-	int x, y;
+	int x, y, y2;
 	GetClientRect(&rcClient);
 
 	x = 0;
 	y = 0;
+	y2 = rcClient.bottom - STATUSBAR_HEIGHT;
 	m_pTopToolbar->MoveWindow(0, 0, rcClient.Width(), TOOLBAR_HEIGHT);
 	y += TOOLBAR_HEIGHT;
+
+
+	
 
 	int nPanelWidth = 0;
 	if (m_pPanelMaster != nullptr) {
 		nPanelWidth = m_pPanelMaster->getPanelWidth();
-		m_pPanelMaster->MoveWindow(x, y, nPanelWidth, rcClient.Height());
+		m_pPanelMaster->MoveWindow(x, y, nPanelWidth, y2 - y);
 		x += nPanelWidth;
 	}
 
 	if (m_pPanelEquipment != nullptr && m_pPanelEquipment->IsWindowVisible()) {
 		nPanelWidth = m_pPanelEquipment->getPanelWidth();
-		m_pPanelEquipment->MoveWindow(x, y, nPanelWidth, rcClient.Height());
+		m_pPanelEquipment->MoveWindow(x, y, nPanelWidth, y2 - y);
 		x += nPanelWidth;
 	}
 
 	if (m_pPanelAttributes != nullptr && m_pPanelAttributes->IsWindowVisible()) {
 		nPanelWidth = m_pPanelAttributes->getPanelWidth();
-		m_pPanelAttributes->MoveWindow(x, y, nPanelWidth, rcClient.Height());
+		m_pPanelAttributes->MoveWindow(x, y, nPanelWidth, y2 - y);
 		x += nPanelWidth;
 	}
 
@@ -630,11 +669,14 @@
 	y += rcItem.Height();
 
 
-	m_pPageGraph1->MoveWindow(x, y, rcClient.Width() - x, rcClient.Height() - y);
-	m_pPageGraph2->MoveWindow(x, y, rcClient.Width() - x, rcClient.Height() - y);
-	m_pPageRecipe->MoveWindow(x, y, rcClient.Width() - x, rcClient.Height() - y);
-	m_pPageAlarm->MoveWindow(x, y, rcClient.Width() - x, rcClient.Height() - y);
-	m_pPageLog->MoveWindow(x, y, rcClient.Width() - x, rcClient.Height() - y);
+	m_pPageGraph1->MoveWindow(x, y, rcClient.Width() - x, y2 - y);
+	m_pPageGraph2->MoveWindow(x, y, rcClient.Width() - x, y2 - y);
+	m_pPageRecipe->MoveWindow(x, y, rcClient.Width() - x, y2 - y);
+	m_pPageAlarm->MoveWindow(x, y, rcClient.Width() - x, y2 - y);
+	m_pPageLog->MoveWindow(x, y, rcClient.Width() - x, y2 - y);
+
+
+	m_pMyStatusbar->MoveWindow(0, y2, rcClient.Width(), STATUSBAR_HEIGHT);
 }
 
 void CServoDlg::OnClose()
@@ -673,6 +715,17 @@
 		m_pTerminalDisplayDlg->Create(IDD_DIALOG_TERMINAL_DISPLAY, this);
 	}
 
+	if (TIMER_ID_UPDATE_RUMTIME == nIDEvent) {
+		static int index = 0; index++;
+		if (index >= 4) index = 0;
+		static char* status[] = {"|", "/", "--", "\\"};
+
+		CString strText;
+		GetRuntimeFormatText(strText, status[index]);
+		m_pMyStatusbar->setRunTimeText((LPTSTR)(LPCTSTR)strText);
+	}
+
+
 	CDialogEx::OnTimer(nIDEvent);
 }
 
@@ -709,7 +762,6 @@
 		theApp.m_model.getMaster().start();
 		m_pTopToolbar->GetBtn(IDC_BUTTON_RUN)->EnableWindow(FALSE);
 		m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(TRUE);
-
 	}
 	else if (id == IDC_BUTTON_STOP) {
 		theApp.m_model.getMaster().stop();
@@ -723,4 +775,23 @@
 		dlg.DoModal();
 	}
 	return 0;
+}
+
+CString& CServoDlg::GetRuntimeFormatText(CString& strText, const char* pszSuffix)
+{
+	ULONGLONG ullRunTime = (ULONGLONG)(theApp.m_model.getMaster().getRunTime() * 0.001);
+	int h, m, s;
+	h = int(ullRunTime / 3600);
+	m = int((ullRunTime % 3600) / 60);
+	s = int(ullRunTime % 60);
+
+	SERVO::MASTERSTATE state = theApp.m_model.getMaster().getState();
+	if (state == SERVO::MASTERSTATE::RUNNING) {
+		strText.Format(_T("正在运行:%02d:%02d:%02d   %s"), h, m, s, pszSuffix);
+	}
+	else {
+		strText.Format(_T("已运行:%02d:%02d:%02d   %s"), h, m, s, pszSuffix);
+	}
+
+	return strText;
 }
\ No newline at end of file

--
Gitblit v1.9.3