From 201046a8b83f34ea099a11043ade28d8457d7af9 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期六, 02 八月 2025 10:47:04 +0800
Subject: [PATCH] 1. 添加计算时间戳宏 2. 重写切割两片玻璃函数 3. 添加分组过滤干扰点的函数

---
 SourceCode/Bond/Servo/CRobotTaskDlg.cpp |  122 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 112 insertions(+), 10 deletions(-)

diff --git a/SourceCode/Bond/Servo/CRobotTaskDlg.cpp b/SourceCode/Bond/Servo/CRobotTaskDlg.cpp
index 16fd9da..2b2d50e 100644
--- a/SourceCode/Bond/Servo/CRobotTaskDlg.cpp
+++ b/SourceCode/Bond/Servo/CRobotTaskDlg.cpp
@@ -32,6 +32,8 @@
 	ON_WM_DESTROY()
 	ON_WM_SIZE()
 	ON_WM_ACTIVATE()
+	ON_BN_CLICKED(IDC_BUTTON_ABORT_TASK, &CRobotTaskDlg::OnBnClickedAbortTask)
+	ON_BN_CLICKED(IDC_BUTTON_RESTORE, &CRobotTaskDlg::OnBnClickedRestore)
 END_MESSAGE_MAP()
 
 
@@ -47,15 +49,50 @@
 	GetDlgItem(IDC_LABEL_NO_TASK)->ShowWindow(m_pRobotTask == nullptr ? SW_SHOW : SW_HIDE);
 	GetDlgItem(IDC_LABEL_GET_PUT)->ShowWindow(m_pRobotTask != nullptr ? SW_SHOW : SW_HIDE);
 
-
+	if (m_btnAbortTask.m_hWnd) {
+		m_btnAbortTask.ShowWindow(m_pRobotTask ? SW_SHOW : SW_HIDE);
+	}
+	if (m_btnRestore.m_hWnd) {
+		m_btnRestore.ShowWindow(m_pRobotTask ? SW_SHOW : SW_HIDE);
+	}
+	
 	if (m_pRobotTask != nullptr) {
-		SERVO::CEquipment* pEq1, * pEq2;
-		pEq1 = theApp.m_model.getMaster().getEquipment(m_pRobotTask->getSrcPosition());
-		pEq2 = theApp.m_model.getMaster().getEquipment(m_pRobotTask->getTarPosition());
+		using namespace SERVO;
 
-		CString strText;
-		strText.Format(_T("%s --> %s"), pEq1->getName().c_str(), pEq2->getName().c_str());
-		SetDlgItemText(IDC_LABEL_GET_PUT, strText);
+		CEquipment* pSrcEq = theApp.m_model.getMaster().getEquipment(pRobotTask->getSrcPosition());
+		CEquipment* pDstEq = theApp.m_model.getMaster().getEquipment(pRobotTask->getTarPosition());
+
+		ROBOT_CMD_PARAM& param = pRobotTask->getRobotCmdParam(ACTION_TRANSFER);
+
+		auto format_time = [](time_t t) -> CString {
+			if (t == 0) {
+				return _T("-");
+			}
+			CTime time(t);
+			return time.Format(_T("%Y-%m-%d %H:%M:%S"));
+		};
+
+		CString strDetail;
+		strDetail.Format(
+			_T("浠诲姟 ID: %s\r\n婧愪綅缃�: %s (P%d)\r\n鐩爣浣嶇疆: %s (P%d)\r\n")
+			_T("婧愭Ы浣�: Slot %d\r\n鐩爣妲戒綅: Slot %d\r\n鎵嬭噦缂栧彿: Arm %d\r\n浠诲姟鐘舵��: %s\r\n")
+			_T("鍒涘缓鏃堕棿: %s\r\n鍙栫墖鏃堕棿: %s\r\n鏀剧墖鏃堕棿: %s\r\n缁撴潫鏃堕棿: %s"),
+			pRobotTask->getId().c_str(),
+			pSrcEq ? pSrcEq->getName().c_str() : _T("鏈煡"),
+			param.getPosition,
+			pDstEq ? pDstEq->getName().c_str() : _T("鏈煡"),
+			param.putPosition,
+			param.getSlotNo,
+			param.putSlotNo,
+			param.armNo,
+			pRobotTask->getStateString(),
+			format_time(pRobotTask->getCreateTime()),
+			format_time(pRobotTask->getFetchoutTime()),
+			format_time(pRobotTask->getStoredTime()),
+			format_time(pRobotTask->getFinishTime())
+		);
+
+		SetDlgItemText(IDC_LABEL_GET_PUT, strDetail);
 	}
 }
 
@@ -64,6 +101,22 @@
 	CDialogEx::OnInitDialog();
 
 	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
+	// 鍒涘缓鈥滃仠姝换鍔♀�濇寜閽拰鈥滄挙鍥炩�濇寜閽�
+	m_btnAbortTask.Create(_T("鍋滄浠诲姟"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(0, 0, 100, 30), this, IDC_BUTTON_ABORT_TASK);
+	m_btnRestore.Create(_T("閲嶅彂鎸囦护"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(0, 0, 100, 30), this, IDC_BUTTON_RESTORE);
+
+	// 鍔ㄦ�佹寜閽垱寤哄悗璁剧疆瀛椾綋
+	if (m_fontButton.GetSafeHandle() == nullptr) {
+		m_fontButton.CreatePointFont(110, _T("寰蒋闆呴粦")); // 鎴� "Segoe UI"
+	}
+	m_btnAbortTask.SetFont(&m_fontButton);
+	m_btnRestore.SetFont(&m_fontButton);
+
+	// 璁剧疆 LABEL 鎺т欢鐨勫瓧浣�
+	if (m_fontDetail.GetSafeHandle() == nullptr) {
+		m_fontDetail.CreatePointFont(100, _T("寰蒋闆呴粦"));
+	}
+	GetDlgItem(IDC_LABEL_GET_PUT)->SetFont(&m_fontDetail);
 
 	return TRUE;  // return TRUE unless you set the focus to a control
 				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
@@ -86,6 +139,13 @@
 	CDialogEx::OnDestroy();
 
 	// TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
+	if (m_fontButton.GetSafeHandle()) {
+		m_fontButton.DeleteObject();
+	}
+
+	if (m_fontDetail.GetSafeHandle()) {
+		m_fontDetail.DeleteObject();
+	}
 }
 
 void CRobotTaskDlg::OnSize(UINT nType, int cx, int cy)
@@ -116,9 +176,51 @@
 		(rcClient.Height() - rcItem.Height()) / 2, rcItem.Width(), rcItem.Height());
 
 	pItem = GetDlgItem(IDC_LABEL_GET_PUT);
-	pItem->GetClientRect(&rcItem);
-	pItem->MoveWindow(12,
-		12, rcItem.Width(), rcItem.Height());
+	if (pItem && pItem->m_hWnd) {
+		const int nLabelX = 12;
+		const int nLabelY = 12;
+		const int nLabelWidth = rcClient.Width() - 24;
+		const int nLabelHeight = rcClient.Height() - 24;
+
+		pItem->MoveWindow(nLabelX, nLabelY, nLabelWidth, nLabelHeight);
+	}
+
+	// 璁剧疆鈥滃仠姝换鍔♀�濇寜閽綅缃紙鍙充笅瑙掞級
+	const int nBtnWidth = 100;
+	const int nBtnHeight = 28;
+	const int nMargin = 12;
+	const int nMargin2 = 8;
+	const int x = rcClient.right - nBtnWidth - nMargin;
+	int y = rcClient.bottom - nMargin;
+	if (m_btnAbortTask.m_hWnd != nullptr) {
+		m_btnAbortTask.MoveWindow(x, y - nBtnHeight, nBtnWidth, nBtnHeight);
+		y -= nBtnHeight;
+		y -= nMargin2;
+	}
+
+	// 璁剧疆鈥滃仠姝换鍔♀�濇寜閽綅缃紙鍙充笅瑙掞級
+	if (m_btnRestore.m_hWnd != nullptr) {
+		m_btnRestore.MoveWindow(x, y - nBtnHeight, nBtnWidth, nBtnHeight);
+	}
 }
 
+void CRobotTaskDlg::OnBnClickedAbortTask()
+{
+	int ret = AfxMessageBox(_T("纭瑕佺粓姝㈠綋鍓嶆惉閫佷换鍔″悧?闄ら潪鍙戠敓浜嗗紓甯革紝鍚﹀垯璇蜂笉瑕佹墜鍔ㄧ粓姝换鍔★紒"), MB_OKCANCEL | MB_ICONEXCLAMATION);
+	if (ret != IDOK) {
+		return;
+	}
 
+	theApp.m_model.getMaster().abortCurrentTask();
+}
+
+void CRobotTaskDlg::OnBnClickedRestore()
+{
+	// 鍥炴挙浠诲姟淇敼涓洪噸鍙戜换鍔�
+	int ret = AfxMessageBox(_T("纭瑕侀噸鏂颁笅鍙戜换鍔″悧锛�"), MB_OKCANCEL | MB_ICONEXCLAMATION);
+	if (ret != IDOK) {
+		return;
+	}
+
+	theApp.m_model.getMaster().resendCurrentTask();
+}
\ No newline at end of file

--
Gitblit v1.9.3