From 81d64c0584be86ad7255ddfe7ee24be905fc67f1 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期一, 23 六月 2025 14:57:59 +0800
Subject: [PATCH] 1. 在配置文件中添加设备名称 2. 配方绑定界面显示需要的设备ID和设备名称

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

diff --git a/SourceCode/Bond/Servo/RecipeDeviceBindDlg.cpp b/SourceCode/Bond/Servo/RecipeDeviceBindDlg.cpp
index fec07da..60555a8 100644
--- a/SourceCode/Bond/Servo/RecipeDeviceBindDlg.cpp
+++ b/SourceCode/Bond/Servo/RecipeDeviceBindDlg.cpp
@@ -5,7 +5,22 @@
 #include "Servo.h"
 #include "afxdialogex.h"
 #include "RecipeDeviceBindDlg.h"
+#include "RecipeManager.h"
+#include "Common.h"
 
+#define IDC_EDIT_DEVICEID_BASE     3000
+#define IDC_EDIT_DEVICENAME_BASE   3050
+#define IDC_COMBO_RECIPEID_BASE    3100
+
+// 缁戝畾鐣岄潰闇�瑕佹樉绀虹殑璁惧
+static const std::vector<DeviceMetaInfo> g_vecBindDevices = {
+    { EQ_ID_VACUUMBAKE,      EQ_NAME_VACUUMBAKE },
+    { EQ_ID_Bonder1,         EQ_NAME_BONDER1 },
+    { EQ_ID_Bonder2,         EQ_NAME_BONDER2 },
+    { EQ_ID_BAKE_COOLING,    EQ_NAME_BAKE_COOLING },
+    { EQ_ID_MEASUREMENT,     EQ_NAME_MEASUREMENT },
+    { EQ_ID_EFEM,            EQ_NAME_EFEM }
+};
 
 // CRecipeDeviceBindDlg 瀵硅瘽妗�
 
@@ -28,7 +43,85 @@
 
 
 BEGIN_MESSAGE_MAP(CRecipeDeviceBindDlg, CDialogEx)
+    ON_WM_CLOSE()
+    ON_WM_SIZE()
 END_MESSAGE_MAP()
 
 
 // CRecipeDeviceBindDlg 娑堟伅澶勭悊绋嬪簭
+
+BOOL CRecipeDeviceBindDlg::OnInitDialog()
+{
+	CDialogEx::OnInitDialog();
+
+	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
+    // 璁剧疆鍥哄畾澶у皬锛堜緥濡� 600x400锛�
+    SetWindowPos(nullptr, 0, 0, 600, 400, SWP_NOMOVE | SWP_NOZORDER);
+
+	// 鍒涘缓鎺т欢
+    const int totalControlWidth = 340;
+    CRect clientRect;
+    GetClientRect(&clientRect);
+    int xStart = (clientRect.Width() - totalControlWidth) / 2;
+
+    const int nRowHeight = 30;
+    const int yStart = 30; // 椤堕儴璧峰楂樺害
+
+    const int nRowCount = static_cast<int>(g_vecBindDevices.size());
+    for (int i = 0; i < nRowCount; ++i) {
+        int y = yStart + i * nRowHeight;
+        const auto& meta = g_vecBindDevices[i];
+
+        CEdit* pEditID = new CEdit();
+        pEditID->Create(WS_CHILD | WS_VISIBLE | WS_BORDER, CRect(xStart, y, xStart + 100, y + 25), this, IDC_EDIT_DEVICEID_BASE + i);
+
+        CString strID;
+        strID.Format(_T("%d"), meta.nDeviceID);
+        pEditID->SetWindowText(strID);
+		pEditID->SetReadOnly(TRUE);     // 璁惧ID鍙
+
+        CEdit* pEditName = new CEdit();
+        pEditName->Create(WS_CHILD | WS_VISIBLE | WS_BORDER, CRect(xStart + 110, y, xStart + 210, y + 25), this, IDC_EDIT_DEVICENAME_BASE + i);
+        pEditName->SetWindowText(CA2T(meta.strDeviceName));
+		pEditName->SetReadOnly(TRUE);   // 璁惧鍚嶇О鍙
+
+        CComboBox* pCombo = new CComboBox();
+        pCombo->Create(WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST, CRect(xStart + 220, y, xStart + 340, y + 300), this, IDC_COMBO_RECIPEID_BASE + i);
+
+		// 娣诲姞閫夐」鍒� ComboBox
+		m_vecDevices.push_back({ pEditID, pEditName, pCombo });
+    }
+
+	return TRUE;  // return TRUE unless you set the focus to a control
+	// 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+void CRecipeDeviceBindDlg::OnClose()
+{
+    // TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
+    CDialogEx::OnClose();
+
+    // 娓呯悊鎺т欢
+    for (auto& device : m_vecDevices) {
+        if (device.editDeviceID) {
+            device.editDeviceID->DestroyWindow();
+            delete device.editDeviceID;
+        }
+        if (device.editDeviceName) {
+            device.editDeviceName->DestroyWindow();
+            delete device.editDeviceName;
+        }
+        if (device.comboRecipeID) {
+            device.comboRecipeID->DestroyWindow();
+            delete device.comboRecipeID;
+        }
+    }
+    m_vecDevices.clear();
+}
+
+void CRecipeDeviceBindDlg::OnSize(UINT nType, int cx, int cy)
+{
+    CDialogEx::OnSize(nType, cx, cy);
+
+    // TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
+}
\ No newline at end of file

--
Gitblit v1.9.3