From f6b143d9a6f62875e62dae61a0af061139d7a156 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期一, 21 七月 2025 17:23:17 +0800
Subject: [PATCH] 1. 添加新建配方和部分编辑配方绑定的功能
---
SourceCode/Bond/Servo/RecipeManager.cpp | 7
SourceCode/Bond/Servo/resource.h | 0
SourceCode/Bond/Servo/RecipeDeviceBindDlg.h | 9 +
SourceCode/Bond/Servo/RecipeManager.h | 3
SourceCode/Bond/Servo/Servo.rc | 0
SourceCode/Bond/Servo/PageRecipe.h | 9
SourceCode/Bond/Servo/RecipeDeviceBindDlg.cpp | 146 ++++++++++++++----
SourceCode/Bond/Servo/PageRecipe.cpp | 280 +++++++++++++++++++++-------------
8 files changed, 300 insertions(+), 154 deletions(-)
diff --git a/SourceCode/Bond/Servo/PageRecipe.cpp b/SourceCode/Bond/Servo/PageRecipe.cpp
index 74ce16c..2ca1f9f 100644
--- a/SourceCode/Bond/Servo/PageRecipe.cpp
+++ b/SourceCode/Bond/Servo/PageRecipe.cpp
@@ -6,7 +6,7 @@
#include "afxdialogex.h"
#include "PageRecipe.h"
#include "MsgDlg.h"
-
+#include "RecipeDeviceBindDlg.h"
// CPageRecipe 瀵硅瘽妗�
@@ -20,6 +20,60 @@
CPageRecipe::~CPageRecipe()
{
+}
+
+void CPageRecipe::UpdateRecipeByPPID(const CString& strPPID)
+{
+ if (strPPID.IsEmpty()) {
+ AfxMessageBox(_T("璇烽�夋嫨涓�涓厤鏂癸紒"));
+ return;
+ }
+
+ auto& mgr = RecipeManager::getInstance();
+
+ // 鏌ヨ閫変腑閰嶆柟鐨勮缁嗘暟鎹�
+ std::string oldPPID = CT2A(strPPID);
+ RecipeInfo oldRecipe = mgr.getRecipeByPPID(oldPPID);
+ if (oldRecipe.strPPID.empty()) {
+ AfxMessageBox(_T("鑾峰彇閰嶆柟鏁版嵁澶辫触锛�"));
+ return;
+ }
+
+ // 寮瑰嚭缂栬緫瀵硅瘽妗嗭紝骞跺垵濮嬪寲涓哄綋鍓嶅唴瀹�
+ CRecipeDeviceBindDlg dlg(this);
+ dlg.SetRecipeInfo(oldRecipe);
+
+ if (dlg.DoModal() == IDOK) {
+ const RecipeInfo& newRecipe = dlg.GetRecipeInfo();
+
+ bool success = false;
+ // 鍒ゆ柇PPID鏄惁鏈夋敼鍔�
+ if (oldRecipe.strPPID != newRecipe.strPPID) {
+ // 鍏堟洿鏂癙PID锛屽啀鏁翠綋鏇存柊鍐呭
+ if (mgr.updatePPID(oldRecipe.strPPID, newRecipe.strPPID)) {
+ success = mgr.updateRecipe(newRecipe);
+ if (!success) {
+ AfxMessageBox(_T("宸叉洿鏀筆PID锛屼絾鏇存柊閰嶆柟鍐呭澶辫触锛岃妫�鏌ユ棩蹇�"));
+ }
+ }
+ else {
+ AfxMessageBox(_T("鏇存柊PPID澶辫触锛岃妫�鏌ユ棩蹇�"));
+ return;
+ }
+ }
+ else {
+ // 鍙洿鏂板唴瀹�
+ success = mgr.updateRecipe(newRecipe);
+ if (!success) {
+ AfxMessageBox(_T("鏇存柊閰嶆柟澶辫触锛岃妫�鏌ユ棩蹇�"));
+ }
+ }
+
+ if (success) {
+ auto vecData = mgr.getAllRecipes();
+ FillDataToListCtrl(vecData);
+ }
+ }
}
void CPageRecipe::FillDataToListCtrl(const std::vector<RecipeInfo>& vecRecipe) {
@@ -64,7 +118,6 @@
return;
}
-
// 閬嶅巻鏁版嵁骞舵彃鍏ュ埌CListCtrl涓�
std::map<int, short>& ids = pList->getIds();
for (auto item : ids) {
@@ -87,15 +140,16 @@
BEGIN_MESSAGE_MAP(CPageRecipe, CDialogEx)
ON_WM_SIZE()
+ ON_WM_DESTROY()
+ ON_WM_SHOWWINDOW()
+ ON_BN_CLICKED(IDC_BUTTON_NEW, &CPageRecipe::OnBnClickedButtonNew)
ON_BN_CLICKED(IDC_BUTTON_SEARCH, &CPageRecipe::OnBnClickedButtonSearch)
ON_BN_CLICKED(IDC_BUTTON_MODIFY, &CPageRecipe::OnBnClickedButtonModify)
ON_BN_CLICKED(IDC_BUTTON_DELETE, &CPageRecipe::OnBnClickedButtonDelete)
ON_BN_CLICKED(IDC_BUTTON_DELETE_ALL, &CPageRecipe::OnBnClickedButtonDeleteAll)
ON_BN_CLICKED(IDC_BUTTON_REFRESH, &CPageRecipe::OnBnClickedButtonRefresh)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_PPID, &CPageRecipe::OnLvnItemChangedListPPID)
- ON_WM_DESTROY()
ON_CBN_SELCHANGE(IDC_COMBO_EQUIPMENT, &CPageRecipe::OnCbnSelchangeComboEquipment)
- ON_WM_SHOWWINDOW()
END_MESSAGE_MAP()
@@ -172,9 +226,10 @@
// 鎸夐挳绔栫洿鎺掑垪鍦ㄥ彸渚�
CWnd* buttons[] = {
GetDlgItem(IDC_BUTTON_REFRESH),
+ GetDlgItem(IDC_BUTTON_NEW),
+ GetDlgItem(IDC_BUTTON_MODIFY),
GetDlgItem(IDC_BUTTON_DELETE),
- GetDlgItem(IDC_BUTTON_DELETE_ALL),
- GetDlgItem(IDC_BUTTON_MODIFY)
+ GetDlgItem(IDC_BUTTON_DELETE_ALL)
};
for (auto pBtn : buttons) {
@@ -185,74 +240,130 @@
}
}
+void CPageRecipe::OnDestroy()
+{
+ CDialogEx::OnDestroy();
+
+ // 淇濆瓨鍒楀
+ CString strIniFile, strItem, strTemp;
+ strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+ CHeaderCtrl* pHeader = m_listPPID.GetHeaderCtrl();
+ for (int i = 0; i < pHeader->GetItemCount(); i++) {
+ RECT rect;
+ pHeader->GetItemRect(i, &rect);
+ strItem.Format(_T("Col_%d_Width"), i);
+ strTemp.Format(_T("%d"), rect.right - rect.left);
+ WritePrivateProfileString("PageRecipeListCtrl", strItem, strTemp, strIniFile);
+ }
+}
+
+void CPageRecipe::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+ CDialogEx::OnShowWindow(bShow, nStatus);
+
+ if (bShow) {
+ CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
+ if (pComboBox->GetCount() == 0) {
+ SERVO::CMaster& master = theApp.m_model.getMaster();
+ SERVO::CEquipment* pEq[] = {
+ nullptr,
+ master.getEquipment(EQ_ID_EFEM),
+ master.getEquipment(EQ_ID_Bonder1),
+ master.getEquipment(EQ_ID_Bonder2),
+ master.getEquipment(EQ_ID_BAKE_COOLING),
+ master.getEquipment(EQ_ID_VACUUMBAKE),
+ master.getEquipment(EQ_ID_MEASUREMENT),
+ };
+
+ CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
+ for (int i = 0; i < sizeof(pEq) / sizeof(pEq[0]); i++) {
+ pComboBox->InsertString(i,
+ pEq[i] == nullptr ? _T("Master") : pEq[i]->getName().c_str());
+ pComboBox->SetItemDataPtr(i, pEq[i]);
+ }
+ pComboBox->SetCurSel(0);
+ }
+ }
+}
+
+void CPageRecipe::OnBnClickedButtonNew()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ //CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
+ //int nSel = pComboBox->GetCurSel();
+ //SERVO::CEquipment* pEq = (SERVO::CEquipment*)pComboBox->GetItemDataPtr(nSel);
+ //if (pEq == nullptr) {
+ // return;
+ //}
+
+ CRecipeDeviceBindDlg dlg(this);
+ if (dlg.DoModal() == IDOK) {
+ const RecipeInfo& newRecipe = dlg.GetRecipeInfo();
+
+ auto& mgr = RecipeManager::getInstance();
+ if (mgr.ppidExists(newRecipe.strPPID)) {
+ // 宸插瓨鍦紝璇㈤棶鏄惁瑕嗙洊
+ int ret = AfxMessageBox(_T("璇� PPID 宸插瓨鍦紝鏄惁瑕嗙洊鍘熼厤鏂癸紵"), MB_YESNO | MB_ICONQUESTION);
+ if (ret == IDYES) {
+ if (mgr.updateRecipe(newRecipe)) {
+ auto vecData = mgr.getAllRecipes();
+ FillDataToListCtrl(vecData);
+ }
+ else {
+ AfxMessageBox(_T("鏇存柊閰嶆柟澶辫触锛岃妫�鏌ユ棩蹇�"));
+ }
+ }
+ }
+ else {
+ // 涓嶅瓨鍦紝鐩存帴鏂板
+ if (mgr.addRecipe(newRecipe)) {
+ auto vecData = mgr.getAllRecipes();
+ FillDataToListCtrl(vecData);
+ }
+ else {
+ AfxMessageBox(_T("娣诲姞閰嶆柟澶辫触锛岃妫�鏌ユ棩蹇�"));
+ }
+ }
+ }
+}
+
void CPageRecipe::OnBnClickedButtonSearch()
{
CString strKeyword;
GetDlgItemText(IDC_EDIT_KEYWORD, strKeyword);
- AfxMessageBox(strKeyword);
+ strKeyword.Trim();
+
+ std::vector<RecipeInfo> vecData;
+ if (strKeyword.IsEmpty()) {
+ // 鍏抽敭璇嶄负绌猴紝鏄剧ず鍏ㄩ儴閰嶆柟
+ vecData = RecipeManager::getInstance().getAllRecipes();
+ }
+ else {
+ // 鏍规嵁鍏抽敭璇嶆悳绱㈤厤鏂�
+ vecData = RecipeManager::getInstance().getRecipesByKeyword(std::string(CT2A(strKeyword)));
+ }
+
+ // 濡傛灉娌℃湁鏁版嵁锛屽脊鍑烘彁绀�
+ if (vecData.empty()) {
+ AfxMessageBox(_T("鏈壘鍒板尮閰嶇殑閰嶆柟锛�"));
+ return;
+ }
+
+ FillDataToListCtrl(vecData);
}
void CPageRecipe::OnBnClickedButtonModify()
{
// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- /*
POSITION pos = m_listPPID.GetFirstSelectedItemPosition();
if (!pos) {
- AfxMessageBox(_T("璇烽�夋嫨瑕佷慨鏀圭殑閰嶆柟"));
+ AfxMessageBox(_T("璇峰厛閫夋嫨涓�鏉¢厤鏂硅褰曡繘琛屼慨鏀癸紒"));
return;
}
int nSel = m_listPPID.GetNextSelectedItem(pos);
- CString strOldPPID = m_listPPID.GetItemText(nSel, 2);
- CString strOldDesc = m_listPPID.GetItemText(nSel, 3);
-
- CString strNewPPID, strNewDesc;
- m_editPPID.GetWindowText(strNewPPID);
- m_editDesc.GetWindowText(strNewDesc);
-
- // 鍒ょ┖
- if (strOldPPID.IsEmpty() || strNewPPID.IsEmpty()) {
- AfxMessageBox(_T("PPID 涓嶈兘涓虹┖"));
- return;
- }
-
- std::string oldPPID = CT2A(strOldPPID);
- std::string newPPID = CT2A(strNewPPID);
- std::string newDesc = CT2A(strNewDesc);
-
- bool bPPIDChanged = (strOldPPID.Compare(strNewPPID) != 0);
- bool bDescChanged = (strOldDesc.Compare(strNewDesc) != 0);
-
- if (!bPPIDChanged && !bDescChanged) {
- return;
- }
-
- if (bPPIDChanged) {
- // 鏂� PPID 涓嶅彲閲嶅
- if (RecipeManager::getInstance().ppidExists(newPPID)) {
- AfxMessageBox(_T("鏂� PPID 宸插瓨鍦紝璇蜂娇鐢ㄥ叾浠栧��"));
- return;
- }
-
- // 璋冪敤 updatePPID锛屽悓鏃舵洿鏂版弿杩�
- if (RecipeManager::getInstance().updatePPID(oldPPID, newPPID)) {
- m_listPPID.SetItemText(nSel, 2, strNewPPID);
- }
- else {
- AfxMessageBox(_T("鏇存柊澶辫触锛岃妫�鏌ユ棩蹇�"));
- }
- }
-
- if (bDescChanged) {
- // 鏇存柊鎻忚堪
- if (RecipeManager::getInstance().updateDescription(oldPPID, newDesc)) {
- m_listPPID.SetItemText(nSel, 3, strNewDesc);
- }
- else {
- AfxMessageBox(_T("鎻忚堪鏇存柊澶辫触"));
- }
- }
- */
+ CString strPPID = m_listPPID.GetItemText(nSel, 2);
+ UpdateRecipeByPPID(strPPID);
}
void CPageRecipe::OnBnClickedButtonDelete()
@@ -376,56 +487,5 @@
else {
SERVO::CRecipeList* pRecipeList = pEq->getRecipeList(0);
FillRecipeListToListCtrl(pRecipeList);
- }
-
-
-
-}
-
-
-void CPageRecipe::OnDestroy()
-{
- CDialogEx::OnDestroy();
-
- // 淇濆瓨鍒楀
- CString strIniFile, strItem, strTemp;
- strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
- CHeaderCtrl* pHeader = m_listPPID.GetHeaderCtrl();
- for (int i = 0; i < pHeader->GetItemCount(); i++) {
- RECT rect;
- pHeader->GetItemRect(i, &rect);
- strItem.Format(_T("Col_%d_Width"), i);
- strTemp.Format(_T("%d"), rect.right - rect.left);
- WritePrivateProfileString("PageRecipeListCtrl", strItem, strTemp, strIniFile);
- }
-}
-
-
-void CPageRecipe::OnShowWindow(BOOL bShow, UINT nStatus)
-{
- CDialogEx::OnShowWindow(bShow, nStatus);
-
- if (bShow) {
- CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
- if (pComboBox->GetCount() == 0) {
- SERVO::CMaster& master = theApp.m_model.getMaster();
- SERVO::CEquipment* pEq[] = {
- nullptr,
- master.getEquipment(EQ_ID_EFEM),
- master.getEquipment(EQ_ID_Bonder1),
- master.getEquipment(EQ_ID_Bonder2),
- master.getEquipment(EQ_ID_BAKE_COOLING),
- master.getEquipment(EQ_ID_VACUUMBAKE),
- master.getEquipment(EQ_ID_MEASUREMENT),
- };
-
- CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
- for (int i = 0; i < sizeof(pEq) / sizeof(pEq[0]); i++) {
- pComboBox->InsertString(i,
- pEq[i] == nullptr ? _T("Master") : pEq[i]->getName().c_str());
- pComboBox->SetItemDataPtr(i, pEq[i]);
- }
- pComboBox->SetCurSel(0);
- }
}
}
diff --git a/SourceCode/Bond/Servo/PageRecipe.h b/SourceCode/Bond/Servo/PageRecipe.h
index 55baf65..8f489b4 100644
--- a/SourceCode/Bond/Servo/PageRecipe.h
+++ b/SourceCode/Bond/Servo/PageRecipe.h
@@ -13,6 +13,7 @@
virtual ~CPageRecipe();
private:
+ void UpdateRecipeByPPID(const CString& strPPID);
void FillDataToListCtrl(const std::vector<RecipeInfo>& vecRecipe);
void FillRecipeListToListCtrl(SERVO::CRecipeList* pList);
@@ -25,18 +26,18 @@
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 鏀寔
virtual BOOL OnInitDialog();
afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnDestroy();
+ afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+ afx_msg void OnBnClickedButtonNew();
afx_msg void OnBnClickedButtonSearch();
afx_msg void OnBnClickedButtonModify();
afx_msg void OnBnClickedButtonDelete();
afx_msg void OnBnClickedButtonDeleteAll();
afx_msg void OnBnClickedButtonRefresh();
afx_msg void OnLvnItemChangedListPPID(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnCbnSelchangeComboEquipment();
DECLARE_MESSAGE_MAP()
private:
CListCtrl m_listPPID;
-public:
- afx_msg void OnDestroy();
- afx_msg void OnCbnSelchangeComboEquipment();
- afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
};
diff --git a/SourceCode/Bond/Servo/RecipeDeviceBindDlg.cpp b/SourceCode/Bond/Servo/RecipeDeviceBindDlg.cpp
index 60555a8..4d3440d 100644
--- a/SourceCode/Bond/Servo/RecipeDeviceBindDlg.cpp
+++ b/SourceCode/Bond/Servo/RecipeDeviceBindDlg.cpp
@@ -28,6 +28,8 @@
CRecipeDeviceBindDlg::CRecipeDeviceBindDlg(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_DIALOG_RECIPE_DEVICE_BIND, pParent)
+ , m_strPPID(_T(""))
+ , m_strDesc(_T(""))
{
}
@@ -36,15 +38,26 @@
{
}
-void CRecipeDeviceBindDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialogEx::DoDataExchange(pDX);
+const RecipeInfo& CRecipeDeviceBindDlg::GetRecipeInfo() const {
+ return m_recipe;
}
+void CRecipeDeviceBindDlg::SetRecipeInfo(const RecipeInfo& info)
+{
+ m_recipe = info;
+}
+
+void CRecipeDeviceBindDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialogEx::DoDataExchange(pDX);
+ DDX_Text(pDX, IDC_EDIT_PPID, m_strPPID);
+ DDX_Text(pDX, IDC_EDIT_DESC, m_strDesc);
+}
BEGIN_MESSAGE_MAP(CRecipeDeviceBindDlg, CDialogEx)
ON_WM_CLOSE()
ON_WM_SIZE()
+ ON_BN_CLICKED(IDOK, &CRecipeDeviceBindDlg::OnBnClickedOk)
END_MESSAGE_MAP()
@@ -54,42 +67,74 @@
{
CDialogEx::OnInitDialog();
- // TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
- // 璁剧疆鍥哄畾澶у皬锛堜緥濡� 600x400锛�
- SetWindowPos(nullptr, 0, 0, 600, 400, SWP_NOMOVE | SWP_NOZORDER);
+ // TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
+ if (m_recipe.vecDeviceList.empty()) {
+ SetWindowText(_T("鏂板缓閰嶆柟"));
- // 鍒涘缓鎺т欢
- const int totalControlWidth = 340;
- CRect clientRect;
- GetClientRect(&clientRect);
- int xStart = (clientRect.Width() - totalControlWidth) / 2;
+ // 璁剧疆鍥哄畾澶у皬锛堜緥濡� 600x400锛�
+ SetWindowPos(nullptr, 0, 0, 600, 400, SWP_NOMOVE | SWP_NOZORDER);
- const int nRowHeight = 30;
- const int yStart = 30; // 椤堕儴璧峰楂樺害
+ // 鍒涘缓鎺т欢
+ const int totalControlWidth = 340;
+ CRect clientRect;
+ GetClientRect(&clientRect);
+ int xStart = (clientRect.Width() - totalControlWidth) / 2;
- 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];
+ const int nRowHeight = 30;
+ const int yStart = 30; // 椤堕儴璧峰楂樺害
- 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);
+ 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];
- CString strID;
- strID.Format(_T("%d"), meta.nDeviceID);
- pEditID->SetWindowText(strID);
- pEditID->SetReadOnly(TRUE); // 璁惧ID鍙
+ 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);
- 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); // 璁惧鍚嶇О鍙
+ CString strID;
+ strID.Format(_T("%d"), meta.nDeviceID);
+ pEditID->SetWindowText(strID);
+ pEditID->SetReadOnly(TRUE); // 璁惧ID鍙
- 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);
+ 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); // 璁惧鍚嶇О鍙
- // 娣诲姞閫夐」鍒� ComboBox
- m_vecDevices.push_back({ pEditID, pEditName, pCombo });
+ 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 });
+ }
+ }
+ else {
+ SetWindowText(_T("缂栬緫閰嶆柟"));
+
+ m_strPPID = CA2T(m_recipe.strPPID.c_str());
+ m_strDesc = CA2T(m_recipe.strDescription.c_str());
+ UpdateData(FALSE);
+
+ // 璁剧疆璁惧琛屾暟鎹�
+ for (size_t i = 0; i < m_recipe.vecDeviceList.size() && i < m_vecDevices.size(); ++i) {
+ const DeviceRecipe& d = m_recipe.vecDeviceList[i];
+ CString str;
+ // 璁剧疆璁惧ID鍜屽悕绉�
+ str.Format(_T("%d"), d.nDeviceID);
+ m_vecDevices[i].editDeviceID->SetWindowText(str);
+
+ str.Format(_T("%s"), d.strDeviceName.c_str());
+ m_vecDevices[i].editDeviceName->SetWindowText(str);
+
+ /*ComboBox閫夋嫨閰嶆柟ID锛屽悗闈㈤渶瑕佷慨鏀�****/
+ //int nCount = m_vecDevices[i].comboRecipeID->GetCount();
+ //for (int idx = 0; idx < nCount; ++idx) {
+ // if ((int)m_vecDevices[i].comboRecipeID->GetItemData(idx) == d.nRecipeID) {
+ // m_vecDevices[i].comboRecipeID->SetCurSel(idx);
+ // break;
+ // }
+ //}
+ }
}
return TRUE; // return TRUE unless you set the focus to a control
@@ -124,4 +169,41 @@
CDialogEx::OnSize(nType, cx, cy);
// TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
-}
\ No newline at end of file
+}
+
+void CRecipeDeviceBindDlg::OnBnClickedOk()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ UpdateData(TRUE);
+
+ // 鏀堕泦鎵�鏈夎澶囨槧灏�
+ m_recipe.vecDeviceList.clear();
+ for (const auto& dev : m_vecDevices) {
+ DeviceRecipe info;
+ CString strID, strName;
+ dev.editDeviceID->GetWindowText(strID);
+ dev.editDeviceName->GetWindowText(strName);
+
+ int sel = dev.comboRecipeID->GetCurSel();
+ info.nRecipeID = -1;
+ if (sel != CB_ERR) {
+ info.nRecipeID = (int)dev.comboRecipeID->GetItemData(sel);
+ }
+ info.nDeviceID = _ttoi(strID);
+ info.strDeviceName = CT2A(strName);
+
+ m_recipe.vecDeviceList.push_back(info);
+ }
+
+ // 妫�鏌� PPID 鏄惁涓虹┖
+ if (m_strPPID.IsEmpty()) {
+ AfxMessageBox(_T("閰嶆柟 PPID 涓嶈兘涓虹┖"));
+ return;
+ }
+
+ // PPID鍜屾弿杩�
+ m_recipe.strPPID = CT2A(m_strPPID);
+ m_recipe.strDescription = CT2A(m_strDesc);
+
+ CDialogEx::OnOK();
+}
diff --git a/SourceCode/Bond/Servo/RecipeDeviceBindDlg.h b/SourceCode/Bond/Servo/RecipeDeviceBindDlg.h
index 884f048..793a15b 100644
--- a/SourceCode/Bond/Servo/RecipeDeviceBindDlg.h
+++ b/SourceCode/Bond/Servo/RecipeDeviceBindDlg.h
@@ -1,6 +1,6 @@
锘�#pragma once
#include "afxdialogex.h"
-
+#include "RecipeManager.h"
// CRecipeDeviceBindDlg 瀵硅瘽妗�
@@ -12,6 +12,9 @@
CRecipeDeviceBindDlg(CWnd* pParent = nullptr); // 鏍囧噯鏋勯�犲嚱鏁�
virtual ~CRecipeDeviceBindDlg();
+ const RecipeInfo& GetRecipeInfo() const;
+ void SetRecipeInfo(const RecipeInfo& info);
+
// 瀵硅瘽妗嗘暟鎹�
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_DIALOG_RECIPE_DEVICE_BIND };
@@ -22,6 +25,7 @@
virtual BOOL OnInitDialog();
afx_msg void OnClose();
afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnBnClickedOk();
DECLARE_MESSAGE_MAP()
private:
@@ -31,5 +35,8 @@
CComboBox* comboRecipeID;
};
+ CString m_strPPID;
+ CString m_strDesc;
+ RecipeInfo m_recipe;
std::vector<DeviceWidget> m_vecDevices;
};
diff --git a/SourceCode/Bond/Servo/RecipeManager.cpp b/SourceCode/Bond/Servo/RecipeManager.cpp
index 48cbb56..e0a186b 100644
--- a/SourceCode/Bond/Servo/RecipeManager.cpp
+++ b/SourceCode/Bond/Servo/RecipeManager.cpp
@@ -220,7 +220,6 @@
for (const auto& dev : devs) {
DeviceRecipe dr;
- dr.strPPID = info.strPPID;
try {
dr.nDeviceID = std::stoi(dev[0]);
dr.strDeviceName = dev[1];
@@ -294,7 +293,6 @@
auto devs = m_pDB->fetchResults("SELECT device_id, device_name, recipe_id FROM recipe_devices WHERE ppid = '" + ppid + "';");
for (const auto& dev : devs) {
DeviceRecipe dr;
- dr.strPPID = ppid;
try {
dr.nDeviceID = std::stoi(dev[0]);
dr.strDeviceName = dev[1];
@@ -448,8 +446,8 @@
recipe.strDescription = "Main Board Burn-in";
recipe.vecDeviceList = {
- {1, 101, "P1001","Burner A"},
- {2, 102, "P1001", "Burner B"}
+ {1, 101, "Burner A"},
+ {2, 102, "Burner B"}
};
addRecipe(recipe);
@@ -486,7 +484,6 @@
std::getline(ss, description, ',');
std::getline(ss, createTime, ',');
- dev.strPPID = ppid;
auto& recipe = recipeMap[ppid];
recipe.strPPID = ppid;
recipe.strDescription = description;
diff --git a/SourceCode/Bond/Servo/RecipeManager.h b/SourceCode/Bond/Servo/RecipeManager.h
index f25d36c..444a529 100644
--- a/SourceCode/Bond/Servo/RecipeManager.h
+++ b/SourceCode/Bond/Servo/RecipeManager.h
@@ -10,8 +10,7 @@
// 单个设备配方映射信息
struct DeviceRecipe {
int nDeviceID; // 设备ID
- int nRecipeID; // 该设备对应的子配方ID
- std::string strPPID; // 配方ID(主键)
+ int nRecipeID; // 子配方ID
std::string strDeviceName; // 设备名称
};
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index eb383bf..556dfbc 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index ddfba96..af34923 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ
--
Gitblit v1.9.3