From a56b1aade6f788f68a2474f524f004706f0d14a7 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期三, 14 五月 2025 14:15:19 +0800
Subject: [PATCH] 1. 添加配方和PPID管理界面
---
SourceCode/Bond/Servo/Servo.vcxproj | 7 +
SourceCode/Bond/Servo/Servo.vcxproj.filters | 2
SourceCode/Bond/Servo/resource.h | 0
SourceCode/Bond/Servo/Servo.rc | 0
SourceCode/Bond/Servo/PageRecipe.h | 39 +++++++
SourceCode/Bond/Servo/SECSRuntimeManager.cpp | 16 +++
SourceCode/Bond/Servo/ServoDlg.cpp | 18 +++
SourceCode/Bond/Servo/PageRecipe.cpp | 183 ++++++++++++++++++++++++++++++++++++
SourceCode/Bond/Servo/SECSRuntimeManager.h | 2
SourceCode/Bond/Servo/ServoDlg.h | 2
10 files changed, 265 insertions(+), 4 deletions(-)
diff --git a/SourceCode/Bond/Servo/PageRecipe.cpp b/SourceCode/Bond/Servo/PageRecipe.cpp
new file mode 100644
index 0000000..a741eea
--- /dev/null
+++ b/SourceCode/Bond/Servo/PageRecipe.cpp
@@ -0,0 +1,183 @@
+锘�// CPageRecipe.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "stdafx.h"
+#include "Servo.h"
+#include "afxdialogex.h"
+#include "PageRecipe.h"
+#include "SECSRuntimeManager.h"
+
+
+// CPageRecipe 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CPageRecipe, CDialogEx)
+
+CPageRecipe::CPageRecipe(CWnd* pParent /*=nullptr*/)
+ : CDialogEx(IDD_PAGE_RECIPE, pParent)
+{
+
+}
+
+CPageRecipe::~CPageRecipe()
+{
+}
+
+void CPageRecipe::FillDataToListCtrl(const std::vector<std::string>& vecData) {
+ CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_PPID);
+ if (pListCtrl == nullptr || pListCtrl->m_hWnd == nullptr) {
+ return;
+ }
+
+ // 娓呯┖褰撳墠CListCtrl涓殑鎵�鏈夐」
+ pListCtrl->DeleteAllItems();
+
+ // 閬嶅巻鏁版嵁骞舵彃鍏ュ埌CListCtrl涓�
+ int nIndex = 0;
+ for (const auto& row : vecData) {
+ int nNewItem = pListCtrl->InsertItem(nIndex, _T(""));
+
+ CString str;
+ str.Format(_T("%d"), nIndex++);
+ pListCtrl->SetItemText(nNewItem, 1, str); // Recipe No
+ str.Format(_T("%s"), row.c_str());
+ pListCtrl->SetItemText(nNewItem, 2, str); // PPID
+ }
+
+ // 鑾峰彇鍒楁暟
+ int nColCount = pListCtrl->GetHeaderCtrl()->GetItemCount();
+ pListCtrl->SetColumnWidth(nColCount - 1, LVSCW_AUTOSIZE_USEHEADER);
+}
+
+void CPageRecipe::DoDataExchange(CDataExchange* pDX)
+{
+ CDialogEx::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST_PPID, m_listPPID);
+ DDX_Control(pDX, IDC_EDIT_PPID, m_editPPID);
+}
+
+
+BEGIN_MESSAGE_MAP(CPageRecipe, CDialogEx)
+ 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_SAVE, &CPageRecipe::OnBnClickedButtonSave)
+ ON_BN_CLICKED(IDC_BUTTON_REFRESH, &CPageRecipe::OnBnClickedButtonRefresh)
+ ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_PPID, &CPageRecipe::OnLvnItemChangedListPPID)
+END_MESSAGE_MAP()
+
+
+// CPageRecipe 娑堟伅澶勭悊绋嬪簭
+
+BOOL CPageRecipe::OnInitDialog()
+{
+ CDialogEx::OnInitDialog();
+
+ // TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
+ CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_PPID);
+ DWORD dwStyle = pListCtrl->GetExtendedStyle();
+ dwStyle |= LVS_EX_FULLROWSELECT;
+ dwStyle |= LVS_EX_GRIDLINES;
+ pListCtrl->SetExtendedStyle(dwStyle);
+
+ 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("Recipe No"), LVCFMT_LEFT, 100);
+ pListCtrl->InsertColumn(2, _T("PPID"), LVCFMT_LEFT, 100);
+ pListCtrl->SetColumnWidth(2, LVSCW_AUTOSIZE_USEHEADER);
+
+ // 鑾峰彇鎵�鏈夋暟鎹�
+ auto vecData = SECSRuntimeManager::getInstance().getAllPPID();
+ FillDataToListCtrl(vecData);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+void CPageRecipe::OnBnClickedButtonSearch()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ CString strInput;
+ m_editPPID.GetWindowText(strInput);
+
+ int nCount = m_listPPID.GetItemCount();
+ for (int i = 0; i < nCount; ++i) {
+ CString strItemText = m_listPPID.GetItemText(i, 2); // 绗�2鍒椾负PPID
+ if (strItemText == strInput) {
+ m_listPPID.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
+ m_listPPID.EnsureVisible(i, FALSE);
+ break;
+ }
+ }
+}
+
+void CPageRecipe::OnBnClickedButtonModify()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ POSITION pos = m_listPPID.GetFirstSelectedItemPosition();
+ if (!pos) return;
+
+ int nSel = m_listPPID.GetNextSelectedItem(pos);
+
+ CString strNewPPID;
+ m_editPPID.GetWindowText(strNewPPID);
+ m_listPPID.SetItemText(nSel, 2, strNewPPID);
+}
+
+void CPageRecipe::OnBnClickedButtonDelete()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ POSITION pos = m_listPPID.GetFirstSelectedItemPosition();
+ if (!pos) return;
+
+ int nSel = m_listPPID.GetNextSelectedItem(pos);
+ m_listPPID.SetItemText(nSel, 2, _T(""));
+}
+
+void CPageRecipe::OnBnClickedButtonDeleteAll()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ int nCount = m_listPPID.GetItemCount();
+ for (int i = 0; i < nCount; ++i) {
+ m_listPPID.SetItemText(i, 2, _T(""));
+ }
+}
+
+void CPageRecipe::OnBnClickedButtonSave()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ int nCount = m_listPPID.GetItemCount();
+ for (int i = 0; i < nCount; ++i) {
+ std::string strPPID = CT2A(m_listPPID.GetItemText(i, 2));
+ SECSRuntimeManager::getInstance().updatePPIDForRecipe(i, strPPID);
+ }
+
+ //if (!SECSRuntimeManager::getInstance().saveAllPPID(vecData)) {
+ // AfxMessageBox(_T("淇濆瓨澶辫触"));
+ //}
+ //else {
+ // AfxMessageBox(_T("淇濆瓨鎴愬姛"));
+ //}
+}
+
+void CPageRecipe::OnBnClickedButtonRefresh()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ auto vecData = SECSRuntimeManager::getInstance().getAllPPID();
+ FillDataToListCtrl(vecData);
+}
+
+void CPageRecipe::OnLvnItemChangedListPPID(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+ *pResult = 0;
+
+ if ((pNMLV->uChanged & LVIF_STATE) &&
+ (pNMLV->uNewState & LVIS_SELECTED)) {
+
+ int nItem = pNMLV->iItem;
+ CString strPPID = m_listPPID.GetItemText(nItem, 2);
+ m_editPPID.SetWindowText(strPPID);
+ }
+}
\ No newline at end of file
diff --git a/SourceCode/Bond/Servo/PageRecipe.h b/SourceCode/Bond/Servo/PageRecipe.h
new file mode 100644
index 0000000..69f4cab
--- /dev/null
+++ b/SourceCode/Bond/Servo/PageRecipe.h
@@ -0,0 +1,39 @@
+锘�#pragma once
+#include "afxdialogex.h"
+//#include "ListCtrlEx.h"
+
+
+// CPageRecipe 瀵硅瘽妗�
+
+class CPageRecipe : public CDialogEx
+{
+ DECLARE_DYNAMIC(CPageRecipe)
+
+public:
+ CPageRecipe(CWnd* pParent = nullptr); // 鏍囧噯鏋勯�犲嚱鏁�
+ virtual ~CPageRecipe();
+
+private:
+ void FillDataToListCtrl(const std::vector<std::string>& vecData);
+
+// 瀵硅瘽妗嗘暟鎹�
+#ifdef AFX_DESIGN_TIME
+ enum { IDD = IDD_PAGE_RECIPE };
+#endif
+
+protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 鏀寔
+ virtual BOOL OnInitDialog();
+ afx_msg void OnBnClickedButtonSearch();
+ afx_msg void OnBnClickedButtonModify();
+ afx_msg void OnBnClickedButtonDelete();
+ afx_msg void OnBnClickedButtonDeleteAll();
+ afx_msg void OnBnClickedButtonSave();
+ afx_msg void OnBnClickedButtonRefresh();
+ afx_msg void OnLvnItemChangedListPPID(NMHDR* pNMHDR, LRESULT* pResult);
+ DECLARE_MESSAGE_MAP()
+
+private:
+ CListCtrl m_listPPID;
+ CEdit m_editPPID;
+};
diff --git a/SourceCode/Bond/Servo/SECSRuntimeManager.cpp b/SourceCode/Bond/Servo/SECSRuntimeManager.cpp
index 708dcf1..cd4d27b 100644
--- a/SourceCode/Bond/Servo/SECSRuntimeManager.cpp
+++ b/SourceCode/Bond/Servo/SECSRuntimeManager.cpp
@@ -1420,6 +1420,22 @@
}
}
+std::vector<std::string> SECSRuntimeManager::getAllPPID() {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return {};
+ }
+
+ std::string querySQL = "SELECT PPID FROM EqpPPID;";
+ auto rows = m_pDB->fetchResults(querySQL);
+
+ std::vector<std::string> vecResult;
+ for (const auto& row : rows) {
+ vecResult.push_back(row[0]);
+ }
+ return vecResult;
+}
+
bool SECSRuntimeManager::updatePPIDForRecipe(int nRecipeNo, const std::string& strPPID) {
std::lock_guard<std::mutex> lock(m_mutex);
if (m_pDB == nullptr) {
diff --git a/SourceCode/Bond/Servo/SECSRuntimeManager.h b/SourceCode/Bond/Servo/SECSRuntimeManager.h
index 67a194e..af9b16c 100644
--- a/SourceCode/Bond/Servo/SECSRuntimeManager.h
+++ b/SourceCode/Bond/Servo/SECSRuntimeManager.h
@@ -389,6 +389,8 @@
*/
void initPPIDTable();
+ std::vector<std::string> getAllPPID();
+
bool updatePPIDForRecipe(int nRecipeNo, const std::string& strPPID);
std::string getPPIDForRecipe(int nRecipeNo);
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index b9250e7..5de3f29 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj b/SourceCode/Bond/Servo/Servo.vcxproj
index c894f16..a495fc6 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj
+++ b/SourceCode/Bond/Servo/Servo.vcxproj
@@ -133,7 +133,10 @@
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PostBuildEvent>
- <Command>copy "$(TargetDir)$(ProjectName).exe" "\\DESKTOP-IODBVIQ\Servo\Debug\$(ProjectName).exe"</Command>
+ <Command>if exist "\\DESKTOP-IODBVIQ\Servo\Debug\" (
+ xcopy /Y /D "$(OutDir)*.exe" "\\DESKTOP-IODBVIQ\Servo\Debug\"
+ xcopy /Y /D "$(OutDir)*.pdb" "\\DESKTOP-IODBVIQ\Servo\Debug\"
+)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -195,6 +198,7 @@
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="PageRecipe.h" />
<ClInclude Include="PageAlarm.h" />
<ClInclude Include="AlarmManager.h" />
<ClInclude Include="ApredTreeCtrl2.h" />
@@ -289,6 +293,7 @@
<ClInclude Include="VerticalLine.h" />
</ItemGroup>
<ItemGroup>
+ <ClCompile Include="PageRecipe.cpp" />
<ClCompile Include="PageAlarm.cpp" />
<ClCompile Include="AlarmManager.cpp" />
<ClCompile Include="ApredTreeCtrl2.cpp" />
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj.filters b/SourceCode/Bond/Servo/Servo.vcxproj.filters
index e250419..7b38ce8 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj.filters
+++ b/SourceCode/Bond/Servo/Servo.vcxproj.filters
@@ -100,6 +100,7 @@
<ClCompile Include="CArm.cpp" />
<ClCompile Include="CArmTray.cpp" />
<ClCompile Include="ProductionLogManager.cpp" />
+ <ClCompile Include="PageRecipe.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AlarmManager.h" />
@@ -198,6 +199,7 @@
<ClInclude Include="CArm.h" />
<ClInclude Include="CArmTray.h" />
<ClInclude Include="ProductionLogManager.h" />
+ <ClInclude Include="PageRecipe.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Servo.rc" />
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index eeba9a2..af02e73 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -75,6 +75,7 @@
m_pPageGraph2 = nullptr;
m_pPageAlarm = nullptr;
m_pPageLog = nullptr;
+ m_pPageRecipe = nullptr;
}
void CServoDlg::DoDataExchange(CDataExchange* pDX)
@@ -214,6 +215,8 @@
m_pPageGraph1->Create(IDD_PAGE_GRAPH1, this);
m_pPageGraph2 = new CPageGraph2();
m_pPageGraph2->Create(IDD_PAGE_GRAPH2, this);
+ m_pPageRecipe = new CPageRecipe();
+ m_pPageRecipe->Create(IDD_PAGE_RECIPE, this);
m_pPageAlarm = new CPageAlarm();
m_pPageAlarm->Create(IDD_DIALOG_ALARM, this);
m_pPageLog = new CPageLog();
@@ -224,6 +227,7 @@
m_pTab->SetItemMarginLeft(18);
m_pTab->AddItem("状态图", FALSE);
m_pTab->AddItem("连接图", TRUE);
+ m_pTab->AddItem("配方", TRUE);
m_pTab->AddItem("报警", TRUE);
m_pTab->AddItem("日志", TRUE);
m_pTab->SetCurSel(0);
@@ -523,6 +527,12 @@
m_pPageGraph2 = nullptr;
}
+ if (m_pPageRecipe != nullptr) {
+ m_pPageRecipe->DestroyWindow();
+ delete m_pPageRecipe;
+ m_pPageRecipe = nullptr;
+ }
+
if (m_pPageAlarm != nullptr) {
m_pPageAlarm->DestroyWindow();
delete m_pPageAlarm;
@@ -552,6 +562,7 @@
if (GetDlgItem(IDC_TAB1) == nullptr) return;
if (m_pPageGraph1 == nullptr) return;
if (m_pPageGraph2 == nullptr) return;
+ if (m_pPageRecipe == nullptr) return;
if (m_pPageAlarm == nullptr) return;
if (m_pPageLog == nullptr) return;
@@ -596,6 +607,7 @@
m_pPageGraph1->MoveWindow(x, y, rcClient.Width() - x, rcClient.Height() - y);
m_pPageGraph2->MoveWindow(x, y, rcClient.Width() - x, rcClient.Height() - y);
+ m_pPageRecipe->MoveWindow(x, y, rcClient.Width() - x, rcClient.Height() - y);
m_pPageAlarm->MoveWindow(x, y, rcClient.Width() - x, rcClient.Height() - y);
m_pPageLog->MoveWindow(x, y, rcClient.Width() - x, rcClient.Height() - y);
}
@@ -658,9 +670,9 @@
void CServoDlg::ShowChildPage(int index)
{
- ASSERT(0 <= index && index < 4);
- static CWnd* pPages[] = { m_pPageGraph1, m_pPageGraph2, m_pPageAlarm, m_pPageLog };
- for (int i = 0; i < 4; i++) {
+ ASSERT(0 <= index && index < 5);
+ static CWnd* pPages[] = { m_pPageGraph1, m_pPageGraph2, m_pPageRecipe, m_pPageAlarm, m_pPageLog };
+ for (int i = 0; i < 5; i++) {
pPages[i]->ShowWindow(i == index ? SW_SHOW : SW_HIDE);
}
}
\ No newline at end of file
diff --git a/SourceCode/Bond/Servo/ServoDlg.h b/SourceCode/Bond/Servo/ServoDlg.h
index 272028e..f78d8c5 100644
--- a/SourceCode/Bond/Servo/ServoDlg.h
+++ b/SourceCode/Bond/Servo/ServoDlg.h
@@ -6,6 +6,7 @@
#include "BlButton.h"
#include "PageLog.h"
#include "PageAlarm.h"
+#include "PageRecipe.h"
#include "TerminalDisplayDlg.h"
#include "CPanelMaster.h"
#include "CPanelEquipment.h"
@@ -36,6 +37,7 @@
CTerminalDisplayDlg* m_pTerminalDisplayDlg;
CPageGraph1* m_pPageGraph1;
CPageGraph2* m_pPageGraph2;
+ CPageRecipe* m_pPageRecipe;
CPageAlarm* m_pPageAlarm;
CPageLog* m_pPageLog;
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index b61d88b..250b0c7 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ
--
Gitblit v1.9.3