mrDarker
2025-09-04 f5d3efdcec2d59e4adf6a3ae534082023e2df345
SourceCode/Bond/Servo/PageRecipe.cpp
@@ -5,6 +5,9 @@
#include "Servo.h"
#include "afxdialogex.h"
#include "PageRecipe.h"
#include "MsgDlg.h"
#include "InputDialog.h"
#include "RecipeDeviceBindDlg.h"
// CPageRecipe 对话框
@@ -20,9 +23,110 @@
{
}
void CPageRecipe::InitListCtrlHeaderForMaster()
{
   m_listPPID.DeleteAllItems();
   while (m_listPPID.DeleteColumn(0));
   CString strIniFile, strItem;
   strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
   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);
   }
   m_listPPID.InsertColumn(0, _T(""), LVCFMT_RIGHT, 0); // 隐藏列
   m_listPPID.InsertColumn(1, _T("No."), LVCFMT_LEFT, width[1]);
   m_listPPID.InsertColumn(2, _T("PPID"), LVCFMT_LEFT, width[2]);
   m_listPPID.InsertColumn(3, _T("真空烘烤"), LVCFMT_LEFT, width[6]);
   m_listPPID.InsertColumn(4, _T("Bonder1"), LVCFMT_LEFT, width[4]);
   m_listPPID.InsertColumn(5, _T("Bonder2"), LVCFMT_LEFT, width[5]);
   m_listPPID.InsertColumn(6, _T("后烘冷却"), LVCFMT_LEFT, width[7]);
   m_listPPID.InsertColumn(7, _T("精度检查"), LVCFMT_LEFT, width[8]);
   m_listPPID.InsertColumn(8, _T("EFEM"), LVCFMT_LEFT, width[3]);
   m_listPPID.InsertColumn(9, _T("创建时间"), LVCFMT_LEFT, width[9]);
   m_listPPID.InsertColumn(10, _T("描述"), LVCFMT_LEFT, width[10]);
}
void CPageRecipe::InitListCtrlHeaderForDevice()
{
   m_listPPID.DeleteAllItems();
   while (m_listPPID.DeleteColumn(0));
   CString strIniFile, strItem;
   strIniFile.Format(_T("%s\\configuration.ini"), (LPCTSTR)theApp.m_strAppDir);
   int width[] = { 0, 60, 100, 100, 150 };
   for (int i = 0; i < 5; i++) {
      strItem.Format(_T("Col_Device_%d_Width"), i);
      width[i] = GetPrivateProfileInt(_T("PageRecipeListCtrl"), strItem, width[i], strIniFile);
   }
   m_listPPID.InsertColumn(0, _T(""), LVCFMT_RIGHT, width[0]);
   m_listPPID.InsertColumn(1, _T("No."), LVCFMT_CENTER, width[1]);
   m_listPPID.InsertColumn(2, _T("Recipe ID"), LVCFMT_CENTER, width[2]);
   m_listPPID.InsertColumn(3, _T("Recipe 名称"), LVCFMT_CENTER, width[3]);
   m_listPPID.InsertColumn(4, _T("Recipe 参数"), LVCFMT_CENTER, width[4]);
}
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) {
         // 先更新PPID,再整体更新内容
         if (mgr.updatePPID(oldRecipe.strPPID, newRecipe.strPPID)) {
            success = mgr.updateRecipe(newRecipe);
            if (!success) {
               AfxMessageBox(_T("已更改PPID,但更新配方内容失败,请检查日志"));
            }
         }
         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 || pListCtrl->m_hWnd == nullptr) {
   if (pListCtrl == nullptr || !::IsWindow(pListCtrl->m_hWnd)) {
      return;
   }
@@ -32,16 +136,84 @@
   // 遍历数据并插入到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++){
         int nRecipeID = recipe.vecDeviceList.at(j).nRecipeID;
         std::string strDeviceName = recipe.vecDeviceList.at(j).strDeviceName;
         std::string strRecipeName = RecipeManager::getInstance().getDeviceRecipeName(strDeviceName, nRecipeID);
         CString str;
         if (strRecipeName.empty()) {
            str.Format(_T("%d"), recipe.vecDeviceList.at(j).nRecipeID);
         }
         else {
            str.Format(_T("%s"), CA2T(strRecipeName.c_str()));
         }
         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()));
   }
   // 获取列数
   int nColCount = m_listPPID.GetHeaderCtrl()->GetItemCount();
   m_listPPID.SetColumnWidth(nColCount - 1, LVSCW_AUTOSIZE_USEHEADER);
}
void CPageRecipe::FillRecipeListToListCtrl(SERVO::CRecipeList* pList)
{
   CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_PPID);
   if (pListCtrl == nullptr || !::IsWindow(pListCtrl->m_hWnd)) {
      return;
   }
   CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
   if (pComboBox == nullptr || !::IsWindow(pComboBox->m_hWnd)) {
      return;
   }
   int nEqSel = pComboBox->GetCurSel();
   if (nEqSel == CB_ERR) {
      return;
   }
   auto& mgr = RecipeManager::getInstance();
   SERVO::CEquipment* pEq = (SERVO::CEquipment*)pComboBox->GetItemDataPtr(nEqSel);
   if (pEq == nullptr) {
      return;
   }
   // 清空当前CListCtrl中的所有项
   pListCtrl->DeleteAllItems();
   if (pList == nullptr) {
      return;
   }
   // 遍历数据并插入到CListCtrl中
   std::map<int, short>& ids = pList->getIds();
   for (auto item : ids) {
      int index = m_listPPID.InsertItem(m_listPPID.GetItemCount(), _T(""));
      m_listPPID.SetItemText(index, 1, std::to_string(item.first).c_str());
      m_listPPID.SetItemText(index, 2, std::to_string(item.second).c_str());
      std::string strRecipeName = mgr.getDeviceRecipeName(pEq->getName(), item.second);
      if (strRecipeName.empty()) {
         strRecipeName = std::to_string(item.second);
         mgr.addDeviceRecipe(pEq->getName(), item.second, strRecipeName);
      }
      m_listPPID.SetItemText(index, 3, strRecipeName.c_str());
   }
   // 获取列数
@@ -58,13 +230,17 @@
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_NOTIFY(NM_CLICK, IDC_LIST_PPID, &CPageRecipe::OnClickListPPID)
   ON_NOTIFY(NM_DBLCLK, IDC_LIST_PPID, &CPageRecipe::OnDblclkListPPID)
   ON_CBN_SELCHANGE(IDC_COMBO_EQUIPMENT, &CPageRecipe::OnCbnSelchangeComboEquipment)
END_MESSAGE_MAP()
@@ -73,16 +249,6 @@
BOOL CPageRecipe::OnInitDialog()
{
   CDialogEx::OnInitDialog();
   // 读出列宽
   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++) {
      strItem.Format(_T("Col_%d_Width"), i);
      width[i] = GetPrivateProfileInt("PageRecipeListCtrl", strItem, width[i], strIniFile);
   }
   // TODO:  在此添加额外的初始化
   CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_PPID);
@@ -93,12 +259,7 @@
   HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
   ListView_SetImageList(pListCtrl->GetSafeHwnd(), imageList, LVSIL_SMALL);
   pListCtrl->InsertColumn(0, _T(""), LVCFMT_RIGHT, 0); // 隐藏列
   pListCtrl->InsertColumn(1, _T("No."), LVCFMT_LEFT, width[1]);
   pListCtrl->InsertColumn(2, _T("PPID"), 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);
   InitListCtrlHeaderForMaster();
   // 获取所有数据
   auto vecData = RecipeManager::getInstance().getAllRecipes();
@@ -139,10 +300,11 @@
   // 按钮竖直排列在右侧
   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_REFRESH)
      GetDlgItem(IDC_BUTTON_DELETE_ALL)
   };
   for (auto pBtn : buttons) {
@@ -153,74 +315,177 @@
   }
}
void CPageRecipe::OnDestroy()
{
   CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
   int nSel = pComboBox->GetCurSel();
   SERVO::CEquipment* pEq = (SERVO::CEquipment*)pComboBox->GetItemDataPtr(nSel);
   // 保存列宽
   CString strIniFile, strItem, strTemp;
   strIniFile.Format(_T("%s\\configuration.ini"), (LPCTSTR)theApp.m_strAppDir);
   CHeaderCtrl* pHeader = m_listPPID.GetHeaderCtrl();
   if (!pHeader || pHeader->GetItemCount() == 0) {
      return;
   }
   for (int i = 0; i < pHeader->GetItemCount(); i++) {
      RECT rect;
      if (!pHeader->GetItemRect(i, &rect)) {
         continue;
      }
      if (pEq == nullptr) {
         strItem.Format(_T("Col_%d_Width"), i);
      }
      else {
         strItem.Format(_T("Col_Device_%d_Width"), i);
      }
      strTemp.Format(_T("%d"), rect.right - rect.left);
      WritePrivateProfileString(_T("PageRecipeListCtrl"), strItem, strTemp, strIniFile);
   }
   CDialogEx::OnDestroy();
}
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]);
            if (pEq[i]) {
               pEq[i]->masterRecipeListRequest(0, nullptr);
            }
         }
         pComboBox->SetCurSel(0);
      }
   }
}
void CPageRecipe::OnBnClickedButtonNew()
{
   // TODO: 在此添加控件通知处理程序代码
   //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: 在此添加控件通知处理程序代码
   /*
   CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
   if (pComboBox == nullptr || !::IsWindow(pComboBox->m_hWnd)) {
      return;
   }
   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);
   int nLine = m_listPPID.GetNextSelectedItem(pos);
   CString strID = m_listPPID.GetItemText(nLine, 2);
   CString strNewPPID, strNewDesc;
   m_editPPID.GetWindowText(strNewPPID);
   m_editDesc.GetWindowText(strNewDesc);
   // 判空
   if (strOldPPID.IsEmpty() || strNewPPID.IsEmpty()) {
      AfxMessageBox(_T("PPID 不能为空"));
      return;
   int nSel = pComboBox->GetCurSel();
   SERVO::CEquipment* pEq = (SERVO::CEquipment*)pComboBox->GetItemDataPtr(nSel);
   if (pEq == nullptr) {
      UpdateRecipeByPPID(strID);
   }
   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 已存在,请使用其他值"));
   else {
      CInputDialog dlg(_T("修改配方名称"), _T("请输入配方名称:"));
      if (dlg.DoModal() != IDOK) {
         return;
      }
      // 调用 updatePPID,同时更新描述
      if (RecipeManager::getInstance().updatePPID(oldPPID, newPPID)) {
         m_listPPID.SetItemText(nSel, 2, strNewPPID);
      CString strText = dlg.GetInputText();
      if (strText.IsEmpty()) {
         AfxMessageBox(_T("配方名称不能为空!"));
         return;
      }
      else {
         AfxMessageBox(_T("更新失败,请检查日志"));
      if (RecipeManager::getInstance().updateDeviceRecipe(pEq->getName(), _ttoi(strID), std::string(CT2A(strText)))) {
         m_listPPID.SetItemText(nLine, 3, strText);
      }
   }
   if (bDescChanged) {
      // 更新描述
      if (RecipeManager::getInstance().updateDescription(oldPPID, newDesc)) {
         m_listPPID.SetItemText(nSel, 3, strNewDesc);
      }
      else {
         AfxMessageBox(_T("描述更新失败"));
      }
   }
   */
}
void CPageRecipe::OnBnClickedButtonDelete()
@@ -272,35 +537,112 @@
void CPageRecipe::OnBnClickedButtonRefresh()
{
   // TODO: 在此添加控件通知处理程序代码
   auto vecData = RecipeManager::getInstance().getAllRecipes();
   FillDataToListCtrl(vecData);
}
   CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
   int nSel = pComboBox->GetCurSel();
   SERVO::CEquipment* pEq = (SERVO::CEquipment*)pComboBox->GetItemDataPtr(nSel);
void CPageRecipe::OnLvnItemChangedListPPID(NMHDR* pNMHDR, LRESULT* pResult)
{
   LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
   *pResult = 0;
   int selectedCount = ListView_GetSelectedCount(m_listPPID.GetSafeHwnd());
   GetDlgItem(IDC_BUTTON_MODIFY)->EnableWindow(selectedCount > 0);
   GetDlgItem(IDC_BUTTON_DELETE)->EnableWindow(selectedCount > 0);
   GetDlgItem(IDC_BUTTON_DELETE_ALL)->EnableWindow(selectedCount > 0);
}
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);
   if (pEq == nullptr) {
      // 获取master配方(本地)
      auto vecData = RecipeManager::getInstance().getAllRecipes();
      FillDataToListCtrl(vecData);
   }
   else {
      // enable port
      CMsgDlg msgDlg("请等待", "正在获取配方...");
      pEq->masterRecipeListRequest(0, [&, pEq](int status) -> void {
         if (status == SS_FAILED || status == SS_TIMEOUT) {
            CString strMsg;
            strMsg.Format(status == SS_FAILED ? _T("获取配方失败!") : _T("获取配方超时!"));
            msgDlg.DelayClose(3000);
            msgDlg.SetIcon(MSG_BOX_ERROR);
            msgDlg.SetTitle(_T("操作失败"));
            msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
            msgDlg.SetMarquee(FALSE, 0);
            msgDlg.SetCompleteCode(-1);
         }
         else if (status == SS_COMPLETE) {
            CString strMsg;
            strMsg.Format(_T("获取配方完成!"));
            msgDlg.DelayClose(3000);
            msgDlg.SetIcon(MSG_BOX_SUCCEED);
            msgDlg.SetTitle(_T("操作成功"));
            msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
            msgDlg.SetMarquee(FALSE, 0);
            msgDlg.SetCompleteCode(0);
            SERVO::CRecipeList* pRecipeList = pEq->getRecipeList(0);
            FillRecipeListToListCtrl(pRecipeList);
         }
      });
      msgDlg.DoModal();
   }
}
void CPageRecipe::OnClickListPPID(NMHDR* pNMHDR, LRESULT* pResult)
{
   LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
   // TODO: 在此添加控件通知处理程序代码
   *pResult = 0;
   CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
   if (pComboBox == nullptr) {
      return;
   }
   int nItem = pNMItemActivate->iItem;
   int nEqSel = pComboBox->GetCurSel();
   GetDlgItem(IDC_BUTTON_NEW)->EnableWindow(nEqSel == 0);
   GetDlgItem(IDC_BUTTON_MODIFY)->EnableWindow(nItem > 0);
   GetDlgItem(IDC_BUTTON_DELETE)->EnableWindow(nEqSel == 0 && nItem > 0);
   GetDlgItem(IDC_BUTTON_DELETE_ALL)->EnableWindow(nEqSel == 0 && nItem > 0);
}
void CPageRecipe::OnDblclkListPPID(NMHDR* pNMHDR, LRESULT* pResult)
{
   LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
   // TODO: 在此添加控件通知处理程序代码
   *pResult = 0;
   int nItem = pNMItemActivate->iItem;
   if (nItem < 0) {
      return;
   }
   CString strText = m_listPPID.GetItemText(nItem, 2);
   CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
   int nEqSel = pComboBox->GetCurSel();
   if (nEqSel == CB_ERR) {
      return;
   }
   SERVO::CEquipment* pEq = (SERVO::CEquipment*)pComboBox->GetItemDataPtr(nEqSel);
   if (pEq == nullptr) {
      return;
   }
}
void CPageRecipe::OnCbnSelchangeComboEquipment()
{
   CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
   int nEqSel = pComboBox->GetCurSel();
   int selectedCount = ListView_GetSelectedCount(m_listPPID.GetSafeHwnd());
   GetDlgItem(IDC_BUTTON_NEW)->EnableWindow(nEqSel == 0/* && selectedCount > 0*/);
   GetDlgItem(IDC_BUTTON_MODIFY)->EnableWindow(nEqSel == 0 && selectedCount > 0);
   GetDlgItem(IDC_BUTTON_DELETE)->EnableWindow(nEqSel == 0 && selectedCount > 0);
   GetDlgItem(IDC_BUTTON_DELETE_ALL)->EnableWindow(nEqSel == 0 && selectedCount > 0);
   GetDlgItem(IDC_EDIT_KEYWORD)->EnableWindow(nEqSel == 0);
   GetDlgItem(IDC_BUTTON_SEARCH)->EnableWindow(nEqSel == 0);
   SERVO::CEquipment* pEq = (SERVO::CEquipment*)pComboBox->GetItemDataPtr(nEqSel);
   if (pEq == nullptr) {
      InitListCtrlHeaderForMaster();
      auto vecData = RecipeManager::getInstance().getAllRecipes();
      FillDataToListCtrl(vecData);
   }
   else {
      InitListCtrlHeaderForDevice();
      SERVO::CRecipeList* pRecipeList = pEq->getRecipeList(0);
      FillRecipeListToListCtrl(pRecipeList);
   }
}