From 61b2bfa09588f08accb13e98ee4cd73015cb2352 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 03 六月 2025 09:06:17 +0800
Subject: [PATCH] 1.增加任务详情弹出对话框,但具体填充数据;

---
 SourceCode/Bond/Servo/ServoDlg.cpp |  202 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 188 insertions(+), 14 deletions(-)

diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index 3bf1852..17306f8 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -13,6 +13,8 @@
 #include <thread>
 #include <cmath>
 #include "HmTab.h"
+#include "CRobotCmdContainerDlg.h"
+#include "CRobotCmdTestDlg.h"
 
 
 #ifdef _DEBUG
@@ -22,6 +24,10 @@
 
 /* 创建终端的定时器 */
 #define TIMER_ID_CREATE_TERMINAL		1
+
+/* 运行时间定时器 */
+#define TIMER_ID_UPDATE_RUMTIME			2
+
 
 
 // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
@@ -60,7 +66,6 @@
 // CServoDlg 对话框
 
 
-
 CServoDlg::CServoDlg(CWnd* pParent /*=NULL*/)
 	: CDialogEx(IDD_SERVO_DIALOG, pParent)
 {
@@ -76,13 +81,15 @@
 	m_pPageGraph2 = nullptr;
 	m_pPageAlarm = nullptr;
 	m_pPageLog = nullptr;
+	m_pPageRecipe = nullptr;
+	m_pTopToolbar = nullptr;
+	m_pMyStatusbar = nullptr;
+	m_pRobotTaskDlg = nullptr;
 }
 
 void CServoDlg::DoDataExchange(CDataExchange* pDX)
 {
 	CDialogEx::DoDataExchange(pDX);
-	DDX_Control(pDX, IDC_BUTTON_LOG, m_btnLog);
-	DDX_Control(pDX, IDC_BUTTON_ALARM, m_btnAlarm);
 }
 
 BEGIN_MESSAGE_MAP(CServoDlg, CDialogEx)
@@ -112,6 +119,8 @@
 	ON_WM_TIMER()
 	ON_MESSAGE(ID_MSG_PANEL_RESIZE, OnPanelResize)
 	ON_NOTIFY(BYHMTAB_SEL_CHANGED, IDC_TAB1, &CServoDlg::OnTabSelChanged)
+	ON_MESSAGE(ID_MSG_TOOLBAR_BTN_CLICKED, &CServoDlg::OnToolbarBtnClicked)
+	ON_MESSAGE(ID_MSG_STATUSBAR_BTN_CLICKED, &CServoDlg::OnStatusbarBtnClicked)
 END_MESSAGE_MAP()
 
 
@@ -159,6 +168,41 @@
 					if (!m_pPanelAttributes->IsWindowVisible()) {
 						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);
+				}
+			}
+			else if (RX_CODE_EQ_ROBOT_TASK == code) {
+				SERVO::CRobotTask* pTask = theApp.m_model.getMaster().getActiveRobotTask();
+				if (m_pRobotTaskDlg != nullptr) {
+					m_pRobotTaskDlg->SetRobotTask(pTask);
+				}
+				if (pTask == nullptr) {
+					m_pMyStatusbar->setCurTaskBtnText("无");
+				}
+				else {
+					SERVO::CEquipment* pEq1, * pEq2;
+					pEq1 = theApp.m_model.getMaster().getEquipment(pTask->getSrcPosition());
+					pEq2 = theApp.m_model.getMaster().getEquipment(pTask->getTarPosition());
+					if (pEq1 != nullptr && pEq2 != nullptr) {
+						CString strText;
+						strText.Format(_T("%s --> %s"), pEq1->getName().c_str(), pEq2->getName().c_str());
+						m_pMyStatusbar->setCurTaskBtnText((LPTSTR)(LPCTSTR)strText);
 					}
 				}
 			}
@@ -212,11 +256,24 @@
 	SetMenu(&menu);
 
 
+	// toolbar
+	m_pTopToolbar = new CTopToolbar();
+	m_pTopToolbar->Create(IDD_TOP_TOOLBAR, this);
+	m_pTopToolbar->ShowWindow(SW_SHOW);
+	m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(FALSE);
+	m_pTopToolbar->GetBtn(IDC_BUTTON_ALARM)->EnableWindow(FALSE);
+	HMENU hMenu = m_pTopToolbar->GetOperatorMenu();
+	ASSERT(hMenu);
+	::EnableMenuItem(hMenu, ID_OPEATOR_SWITCH, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+	
+
 	// Tab
 	m_pPageGraph1 = new CPageGraph1();
 	m_pPageGraph1->Create(IDD_PAGE_GRAPH1, this);
 	m_pPageGraph2 = new CPageGraph2();
 	m_pPageGraph2->Create(IDD_PAGE_GRAPH2, this);
+	m_pPageRecipe = new CPageRecipe();
+	m_pPageRecipe->Create(IDD_PAGE_RECIPE, this);
 	m_pPageAlarm = new CPageAlarm();
 	m_pPageAlarm->Create(IDD_DIALOG_ALARM, this);
 	m_pPageLog = new CPageLog();
@@ -227,6 +284,7 @@
 	m_pTab->SetItemMarginLeft(18);
 	m_pTab->AddItem("状态图", FALSE);
 	m_pTab->AddItem("连接图", TRUE);
+	m_pTab->AddItem("配方", TRUE);
 	m_pTab->AddItem("报警", TRUE);
 	m_pTab->AddItem("日志", TRUE);
 	m_pTab->SetCurSel(0);
@@ -242,6 +300,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;
@@ -490,6 +555,24 @@
 	CDialogEx::OnDestroy();
 
 
+	if (m_pTopToolbar != nullptr) {
+		m_pTopToolbar->DestroyWindow();
+		delete m_pTopToolbar;
+		m_pTopToolbar = nullptr;
+	}
+
+	if (m_pMyStatusbar != nullptr) {
+		m_pMyStatusbar->DestroyWindow();
+		delete m_pMyStatusbar;
+		m_pMyStatusbar = nullptr;
+	}
+
+	if (m_pRobotTaskDlg != nullptr) {
+		m_pRobotTaskDlg->DestroyWindow();
+		delete m_pRobotTaskDlg;
+		m_pRobotTaskDlg = nullptr;
+	}
+
 	if (m_pTerminalDisplayDlg != nullptr) {
 		m_pTerminalDisplayDlg->DestroyWindow();
 		delete m_pTerminalDisplayDlg;
@@ -526,6 +609,12 @@
 		m_pPageGraph2 = nullptr;
 	}
 
+	if (m_pPageRecipe != nullptr) {
+		m_pPageRecipe->DestroyWindow();
+		delete m_pPageRecipe;
+		m_pPageRecipe = nullptr;
+	}
+
 	if (m_pPageAlarm != nullptr) {
 		m_pPageAlarm->DestroyWindow();
 		delete m_pPageAlarm;
@@ -555,6 +644,7 @@
 	if (GetDlgItem(IDC_TAB1) == nullptr) return;
 	if (m_pPageGraph1 == nullptr) return;
 	if (m_pPageGraph2 == nullptr) return;
+	if (m_pPageRecipe == nullptr) return;
 	if (m_pPageAlarm == nullptr) return;
 	if (m_pPageLog == nullptr) return;
 	
@@ -562,31 +652,40 @@
 	Invalidate();
 }
 
+#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;
 	}
 
@@ -597,10 +696,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_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()
@@ -639,6 +742,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);
 }
 
@@ -661,11 +775,71 @@
 
 void CServoDlg::ShowChildPage(int index)
 {
-	ASSERT(0 <= index && index < 4);
-	static CWnd* pPages[] = { m_pPageGraph1, m_pPageGraph2, m_pPageAlarm, m_pPageLog };
-	for (int i = 0; i < 4; i++) {
+	ASSERT(0 <= index && index < 5);
+	static CWnd* pPages[] = { m_pPageGraph1, m_pPageGraph2, m_pPageRecipe, m_pPageAlarm, m_pPageLog };
+	for (int i = 0; i < 5; i++) {
 		pPages[i]->ShowWindow(i == index ? SW_SHOW : SW_HIDE);
 	}
 }
 
+LRESULT CServoDlg::OnToolbarBtnClicked(WPARAM wParam, LPARAM lParam)
+{
+	int id = (int)lParam;
+	if (id == IDC_BUTTON_RUN) {
+		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();
+		m_pTopToolbar->GetBtn(IDC_BUTTON_RUN)->EnableWindow(TRUE);
+		m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(FALSE);
+	}
+	else if (id == IDC_BUTTON_ROBOT) {
+		SERVO::CEFEM* pEFEM = (SERVO::CEFEM*)theApp.m_model.getMaster().getEquipment(EQ_ID_EFEM);
+		CRobotCmdTestDlg dlg;
+		dlg.SetEFEM(pEFEM);
+		dlg.DoModal();
+	}
+	return 0;
+}
 
+LRESULT CServoDlg::OnStatusbarBtnClicked(WPARAM wParam, LPARAM lParam)
+{
+	int id = (int)lParam;
+	int x = (int)wParam;
+	if (id == IDC_BUTTON_ROBOTTASK) {
+		if (m_pRobotTaskDlg == nullptr) {
+			m_pRobotTaskDlg = new CRobotTaskDlg();
+			m_pRobotTaskDlg->Create(IDD_DIALOG_ROBOT_TASK, this);
+		}
+
+		CRect rcBar;
+		int h = 258;
+		int w = 388;
+		m_pRobotTaskDlg->SetRobotTask(theApp.m_model.getMaster().getActiveRobotTask());
+		m_pMyStatusbar->GetWindowRect(rcBar);
+		m_pRobotTaskDlg->MoveWindow(x, rcBar.top - h, w, h);
+		m_pRobotTaskDlg->ShowWindow(SW_SHOW);
+	}
+	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