From 5edb485d226790306097e40ea954efb2ed90dd21 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 11 八月 2025 16:05:09 +0800
Subject: [PATCH] 1.EAP:查询CJSpace和PJSpace功能模拟,Master对EAP查询机器变量的回复;
---
SourceCode/Bond/Servo/PageRecipe.cpp | 323 +++++++++++++++++++++++++++++++++--------------------
1 files changed, 199 insertions(+), 124 deletions(-)
diff --git a/SourceCode/Bond/Servo/PageRecipe.cpp b/SourceCode/Bond/Servo/PageRecipe.cpp
index 74ce16c..a625647 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 瀵硅瘽妗�
@@ -22,6 +22,60 @@
{
}
+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) {
CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_PPID);
if (pListCtrl == nullptr || !::IsWindow(pListCtrl->m_hWnd)) {
@@ -34,16 +88,25 @@
// 閬嶅巻鏁版嵁骞舵彃鍏ュ埌CListCtrl涓�
for (int i = 0; i < static_cast<int>(vecRecipe.size()); ++i) {
const RecipeInfo& recipe = vecRecipe[i];
+ if (recipe.vecDeviceList.empty() || recipe.vecDeviceList.size() > 6){
+ continue;
+ }
m_listPPID.InsertItem(i, _T("")); // 绗�0鍒楃┖鐧�
CString strNo;
strNo.Format(_T("%d"), i + 1);
m_listPPID.SetItemText(i, 1, strNo);
-
m_listPPID.SetItemText(i, 2, CA2T(recipe.strPPID.c_str()));
- m_listPPID.SetItemText(i, 3, CA2T(recipe.strDescription.c_str()));
- m_listPPID.SetItemText(i, 4, CA2T(recipe.strCreateTime.c_str()));
+
+ for (int j = 0; j < recipe.vecDeviceList.size(); j++){
+ CString str;
+ str.Format(_T("%d"), recipe.vecDeviceList.at(j).nRecipeID);
+ m_listPPID.SetItemText(i, j + 3, str);
+ }
+
+ m_listPPID.SetItemText(i, 9, CA2T(recipe.strCreateTime.c_str()));
+ m_listPPID.SetItemText(i, 10, CA2T(recipe.strDescription.c_str()));
}
// 鑾峰彇鍒楁暟
@@ -63,7 +126,6 @@
if (pList == nullptr) {
return;
}
-
// 閬嶅巻鏁版嵁骞舵彃鍏ュ埌CListCtrl涓�
std::map<int, short>& ids = pList->getIds();
@@ -87,15 +149,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()
@@ -108,12 +171,11 @@
// 璇诲嚭鍒楀
CString strIniFile, strItem;
strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
- int width[8] = { 0, 80, 180, 80, 80, 100, 80, 180 };
- for (int i = 0; i < 8; i++) {
+ int width[12] = { 0, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 180 };
+ for (int i = 0; i < 12; i++) {
strItem.Format(_T("Col_%d_Width"), i);
width[i] = GetPrivateProfileInt("PageRecipeListCtrl", strItem, width[i], strIniFile);
}
-
// TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_PPID);
@@ -127,10 +189,15 @@
pListCtrl->InsertColumn(0, _T(""), LVCFMT_RIGHT, 0); // 闅愯棌鍒�
pListCtrl->InsertColumn(1, _T("No."), LVCFMT_LEFT, width[1]);
pListCtrl->InsertColumn(2, _T("PPID/Recipe ID"), LVCFMT_LEFT, width[2]);
- pListCtrl->InsertColumn(3, _T("鎻忚堪"), LVCFMT_LEFT, width[3]);
- pListCtrl->InsertColumn(4, _T("鍒涘缓鏃堕棿"), LVCFMT_LEFT, width[4]);
- pListCtrl->SetColumnWidth(4, LVSCW_AUTOSIZE_USEHEADER);
-
+ pListCtrl->InsertColumn(3, _T("鐪熺┖鐑樼儰"), LVCFMT_LEFT, width[6]);
+ pListCtrl->InsertColumn(4, _T("Bonder1"), LVCFMT_LEFT, width[4]);
+ pListCtrl->InsertColumn(5, _T("Bonder2"), LVCFMT_LEFT, width[5]);
+ pListCtrl->InsertColumn(6, _T("鍚庣儤鍐峰嵈"), LVCFMT_LEFT, width[7]);
+ pListCtrl->InsertColumn(7, _T("绮惧害妫�鏌�"), LVCFMT_LEFT, width[8]);
+ pListCtrl->InsertColumn(8, _T("EFEM"), LVCFMT_LEFT, width[3]);
+ pListCtrl->InsertColumn(9, _T("鍒涘缓鏃堕棿"), LVCFMT_LEFT, width[9]);
+ pListCtrl->InsertColumn(10, _T("鎻忚堪"), LVCFMT_LEFT, width[10]);
+ pListCtrl->SetColumnWidth(10, LVSCW_AUTOSIZE_USEHEADER);
// 鑾峰彇鎵�鏈夋暟鎹�
auto vecData = RecipeManager::getInstance().getAllRecipes();
@@ -172,9 +239,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 +253,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()
@@ -316,10 +440,10 @@
else {
// enable port
CMsgDlg msgDlg("璇风瓑寰�", "姝e湪鑾峰彇閰嶆柟...");
- pEq->masterRecipeListRequest(0, [&](int status) -> void {
- if (status == SS_FAILED) {
+ pEq->masterRecipeListRequest(0, [&, pEq](int status) -> void {
+ if (status == SS_FAILED || status == SS_TIMEOUT) {
CString strMsg;
- strMsg.Format(_T("鑾峰彇閰嶆柟澶辫触锛�"));
+ strMsg.Format(status == SS_FAILED ? _T("鑾峰彇閰嶆柟澶辫触锛�") : _T("鑾峰彇閰嶆柟瓒呮椂锛�"));
msgDlg.DelayClose(3000);
msgDlg.SetIcon(MSG_BOX_ERROR);
msgDlg.SetTitle(_T("鎿嶄綔澶辫触"));
@@ -336,8 +460,10 @@
msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
msgDlg.SetMarquee(FALSE, 0);
msgDlg.SetCompleteCode(0);
+ SERVO::CRecipeList* pRecipeList = pEq->getRecipeList(0);
+ FillRecipeListToListCtrl(pRecipeList);
}
- });
+ });
msgDlg.DoModal();
}
}
@@ -376,56 +502,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);
- }
}
}
--
Gitblit v1.9.3