From fd381da2f50420d8c861ad9cf213d7b1586f0188 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 18 九月 2025 18:06:18 +0800
Subject: [PATCH] 1.Port物料选择控件完善; 2.继续处理CControlJobManagerDlg的功能;
---
SourceCode/Bond/Servo/CCjPage2.cpp | 238 +++++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 198 insertions(+), 40 deletions(-)
diff --git a/SourceCode/Bond/Servo/CCjPage2.cpp b/SourceCode/Bond/Servo/CCjPage2.cpp
index e827a19..5e79f6a 100644
--- a/SourceCode/Bond/Servo/CCjPage2.cpp
+++ b/SourceCode/Bond/Servo/CCjPage2.cpp
@@ -15,7 +15,7 @@
CCjPage2::CCjPage2(CWnd* pParent /*=nullptr*/)
: CCjPageBase(IDD_CJ_PAGE2, pParent)
{
-
+ m_nSelRadioId = 0;
}
CCjPage2::~CCjPage2()
@@ -36,6 +36,8 @@
ON_BN_CLICKED(IDC_RADIO2, &CCjPage2::OnBnClickedRadio2)
ON_BN_CLICKED(IDC_RADIO3, &CCjPage2::OnBnClickedRadio3)
ON_BN_CLICKED(IDC_RADIO4, &CCjPage2::OnBnClickedRadio4)
+ ON_NOTIFY(CSGN_SEL_CHANGED, IDC_GRID1, &CCjPage2::OnGridSelChanged)
+ ON_NOTIFY(CSGN_MAT_CHANGED, IDC_GRID1, &CCjPage2::OnGridMatChanged)
END_MESSAGE_MAP()
@@ -60,15 +62,29 @@
m_grid.SubclassDlgItem(IDC_GRID1, this);
m_grid.InitGrid(4, 8);
m_grid.SetColumnWidths(100, 220);
- m_grid.SetRowHeight(28);
- m_grid.SetHeaderHeight(32);
+ m_grid.SetRowHeight(32);
+ m_grid.SetHeaderHeight(36);
m_grid.EnableColumnResize(FALSE); // 绂佹鎷栧姩鍒楀
+ m_grid.SetShowMaterialToggle(TRUE);
+ m_grid.DisableSystemScrollbars();
+ m_grid.ResizeWindowToFitAll(TRUE); // TRUE=鍖呭惈闈炲鎴峰尯锛堣竟妗嗐�佹爣棰樻爮锛�
+ m_grid.SetNoScrollbarsMode(TRUE); // 褰诲簳绂佺敤婊氬姩鏉�
+ m_grid.FitWindowToContentNoScroll(TRUE); // 绐楀彛灏哄鍒氬ソ瀹圭撼鍏ㄩ儴鍐呭锛堜笉鍑虹幇婊氬姩鏉★級
m_grid.SetPortInfo(0, _T("Port 1"), _T(""));
m_grid.SetPortInfo(1, _T("Port 2"), _T(""));
m_grid.SetPortInfo(2, _T("Port 3"), _T(""));
m_grid.SetPortInfo(3, _T("Port 4"), _T(""));
+
+ // 娴嬭瘯鏁版嵁
+ char szBuffer[256];
+ for (int port = 0; port < 4; port++) {
+ for (int slot = 0; slot < 8; slot++) {
+ sprintf_s(szBuffer, 256, "Gls%04d%04d", port + 1, slot + 1);
+ m_grid.SetSlotGlass(port, slot, TRUE, szBuffer, CCarrierSlotGrid::MAT_G1);
+ }
+ }
UpdatePjData();
@@ -98,16 +114,16 @@
// 璁╂帶浠剁獥鍙e昂瀵歌嚜鍔ㄥ尮閰嶅綋鍓嶅垪瀹�/琛屾暟锛堜笉鍑虹幇婊氬姩鏉★級
if (::IsWindow(m_grid.m_hWnd)) {
- CSize best = m_grid.CalcBestWindowSize(TRUE); // 璁$畻鍒板惈闈炲鎴峰尯鐨勬渶缁堢獥鍙eぇ灏�
+ CSize best = m_grid.CalcBestWindowSize(TRUE, -1, 2, 2);
pItem->MoveWindow(rcItem.left, rcItem.top, best.cx, best.cy);
pItem->Invalidate();
}
}
-void CCjPage2::OnApply()
+int CCjPage2::OnApply()
{
//SERVO::CProcessJob*
- if (m_pContext == nullptr) return;
+ if (m_pContext == nullptr) return -1;
PJWarp* pPjWarp = (PJWarp*)m_pContext;
SERVO::CProcessJob* pProcessJob = (SERVO::CProcessJob*)pPjWarp->pj;
@@ -116,7 +132,7 @@
char szBuffer[256];
GetDlgItemText(IDC_EDIT_PJ_ID, szBuffer, 256);
for (auto item : m_pjWarps) {
- if (item.pj != m_pContext) {
+ if (item.pj != pProcessJob) {
SERVO::CProcessJob* temp = (SERVO::CProcessJob*)item.pj;
if (temp->id().compare(std::string(szBuffer)) == 0) {
bOkName = FALSE;
@@ -126,7 +142,7 @@
}
if (!bOkName) {
AfxMessageBox("涓嶈兘浣跨敤鍜屽叾瀹働rocess Job鐩稿悓鐨処D");
- return;
+ return -1;
}
@@ -149,11 +165,31 @@
}
+ // 鏇存柊Port
+ int port = -1;
+ static int ids[] = { IDC_RADIO1, IDC_RADIO2, IDC_RADIO3, IDC_RADIO4 };
+ for (int i = 0; i < 4; i++) {
+ int state = ((CButton*)GetDlgItem(ids[i]))->GetCheck();
+ if (state == BST_CHECKED) port = i;
+ }
+ pPjWarp->port = port;
+
+ if (pPjWarp->port != -1) {
+ for (int i = 0; i < 8; i++) {
+ pPjWarp->checkSlot[i] = m_grid.GetSlotChecked(pPjWarp->port, i);
+ pPjWarp->material[i] = m_grid.GetSlotMaterialType(pPjWarp->port, i);
+ }
+ }
+
+
ContentChanged(1);
+ return 0;
}
void CCjPage2::UpdatePjData()
{
+ if (m_pContext == nullptr) return;
+
m_bContentChangedLock = TRUE;
CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_RECIPE);
@@ -163,24 +199,51 @@
pComboBox->AddString(CString(recipe.c_str()));
}
- if (m_pContext) {
- PJWarp* pPjWarp = (PJWarp*)m_pContext;
- SERVO::CProcessJob* pProcessJob = (SERVO::CProcessJob*)pPjWarp->pj;
- SetDlgItemText(IDC_EDIT_PJ_ID, pProcessJob->id().c_str());
- int idx = pComboBox->FindStringExact(-1, pProcessJob->recipeSpec().c_str());
- if (idx != CB_ERR) pComboBox->SetCurSel(idx);
+
+ // ComboBox
+ PJWarp* pPjWarp = (PJWarp*)m_pContext;
+ SERVO::CProcessJob* pProcessJob = (SERVO::CProcessJob*)pPjWarp->pj;
+ SetDlgItemText(IDC_EDIT_PJ_ID, pProcessJob->id().c_str());
+ int idx = pComboBox->FindStringExact(-1, pProcessJob->recipeSpec().c_str());
+ if (idx != CB_ERR) pComboBox->SetCurSel(idx);
+
+
+ // 4涓猚heckbox
+ static int ids[] = { IDC_RADIO1, IDC_RADIO2, IDC_RADIO3, IDC_RADIO4};
+ static char* pszUsed[] = { "Port1(宸插崰鐢�)", "Port2(宸插崰鐢�)", "Port3(宸插崰鐢�)", "Port4(宸插崰鐢�)" };
+ static char* pszUnUsed[] = { "Port1(鍙敤)", "Port2(鍙敤)", "Port3(鍙敤)", "Port4(鍙敤)" };
+
+ int portIndex = -1;
+ bool enable[] = {true, true, true, true};
+ bool checked[] = { false, false, false, false };
+ for (auto item : m_pjWarps) {
+ if (0 <= item.port && item.port <= 4 && item.pj != ((PJWarp*)m_pContext)->pj) {
+ enable[item.port] = false;
+ }
+ }
+ if (0 <= ((PJWarp*)m_pContext)->port && ((PJWarp*)m_pContext)->port <= 3) {
+ checked[((PJWarp*)m_pContext)->port] = true;
+ portIndex = ((PJWarp*)m_pContext)->port;
+ m_nSelRadioId = ids[((PJWarp*)m_pContext)->port];
}
- // 绀轰緥锛氳缃甈ort淇℃伅銆侀攣鍒椼�佸~鍏匞lass
- /*
- m_grid.SetPortInfo(0, _T("Port 1"), _T(""));
- m_grid.SetPortInfo(1, _T("Port 2"), _T(""));
- m_grid.SetPortInfo(2, _T("Port 3"), _T("Carrier C"));
- m_grid.SetPortInfo(3, _T("Port 4"), _T("Carrier D"));
- m_grid.SetPortAllocated(2, TRUE, _T("ProcessJob 1"));
- m_grid.SetSlotGlass(0, 0, TRUE, _T("A00123"), CCarrierSlotGrid::MAT_G1);
- m_grid.SetSlotGlass(0, 1, TRUE, _T("A00124"), CCarrierSlotGrid::MAT_G1);
- */
+ for (int i = 0; i < 4; i++) {
+ CButton* pButton = (CButton*)GetDlgItem(ids[i]);
+ pButton->SetCheck(checked[i] ? BST_CHECKED : BST_UNCHECKED);
+ pButton->SetWindowText(enable[i] ? pszUnUsed[i] : pszUsed[i]);
+ pButton->EnableWindow(enable[i]);
+
+ m_grid.SetPortAllocated(i, !checked[i], _T(""));
+ }
+
+
+ // 璁剧疆鍕鹃�夋暟鎹�
+ if (portIndex != -1) {
+ for (int i = 0; i < 8; i++) {
+ m_grid.SetSlotChecked(portIndex, i, ((PJWarp*)m_pContext)->checkSlot[i]);
+ m_grid.SetSlotMaterialType(portIndex, i, ((PJWarp*)m_pContext)->material[i]);
+ }
+ }
m_bContentChangedLock = FALSE;
}
@@ -197,32 +260,127 @@
void CCjPage2::OnBnClickedRadio1()
{
- m_grid.SetPortAllocated(0, FALSE, _T(""));
- m_grid.SetPortAllocated(1, TRUE, _T(""));
- m_grid.SetPortAllocated(2, TRUE, _T(""));
- m_grid.SetPortAllocated(3, TRUE, _T(""));
+ BOOL lock[] = {TRUE, TRUE, TRUE, TRUE};
+ if (IDC_RADIO1 == m_nSelRadioId) {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, 0);
+ m_nSelRadioId = 0;
+ }
+ else {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO1);
+ m_nSelRadioId = IDC_RADIO1;
+ lock[0] = FALSE;
+ }
+
+ for (int i = 0; i < 4; i++) {
+ m_grid.SetPortAllocated(i, lock[i], _T(""));
+ }
+
+ ContentChanged(0);
}
void CCjPage2::OnBnClickedRadio2()
{
- m_grid.SetPortAllocated(0, TRUE, _T(""));
- m_grid.SetPortAllocated(1, FALSE, _T(""));
- m_grid.SetPortAllocated(2, TRUE, _T(""));
- m_grid.SetPortAllocated(3, TRUE, _T(""));
+ BOOL lock[] = { TRUE, TRUE, TRUE, TRUE };
+ if (IDC_RADIO2 == m_nSelRadioId) {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, 0);
+ m_nSelRadioId = 0;
+ }
+ else {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO2);
+ m_nSelRadioId = IDC_RADIO2;
+ lock[1] = FALSE;
+ }
+
+ for (int i = 0; i < 4; i++) {
+ m_grid.SetPortAllocated(i, lock[i], _T(""));
+ }
+
+ ContentChanged(0);
}
void CCjPage2::OnBnClickedRadio3()
{
- m_grid.SetPortAllocated(0, TRUE, _T(""));
- m_grid.SetPortAllocated(1, TRUE, _T(""));
- m_grid.SetPortAllocated(2, FALSE, _T(""));
- m_grid.SetPortAllocated(3, TRUE, _T(""));
+ BOOL lock[] = { TRUE, TRUE, TRUE, TRUE };
+ if (IDC_RADIO3 == m_nSelRadioId) {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, 0);
+ m_nSelRadioId = 0;
+ }
+ else {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO3);
+ m_nSelRadioId = IDC_RADIO3;
+ lock[2] = FALSE;
+ }
+
+ for (int i = 0; i < 4; i++) {
+ m_grid.SetPortAllocated(i, lock[i], _T(""));
+ }
+
+ ContentChanged(0);
}
void CCjPage2::OnBnClickedRadio4()
{
- m_grid.SetPortAllocated(0, TRUE, _T(""));
- m_grid.SetPortAllocated(1, TRUE, _T(""));
- m_grid.SetPortAllocated(2, TRUE, _T(""));
- m_grid.SetPortAllocated(3, FALSE, _T(""));
+ BOOL lock[] = { TRUE, TRUE, TRUE, TRUE };
+ if (IDC_RADIO4 == m_nSelRadioId) {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, 0);
+ m_nSelRadioId = 0;
+ }
+ else {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO4);
+ m_nSelRadioId = IDC_RADIO4;
+ lock[3] = FALSE;
+ }
+
+ for (int i = 0; i < 4; i++) {
+ m_grid.SetPortAllocated(i, lock[i], _T(""));
+ }
+
+ ContentChanged(0);
+}
+
+void CCjPage2::OnGridSelChanged(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ auto* nm = reinterpret_cast<CSG_SEL_CHANGE*>(pNMHDR);
+ const int port = nm->port;
+ const int slot = nm->slot;
+ const BOOL chk = nm->checked;
+
+ // 杩欓噷鍐欎綘鐨勪笟鍔¢�昏緫
+ // 渚嬪锛氭洿鏂扮姸鎬佹爮 / 鍚屾鍏跺畠鎺т欢 / 缁熻鏁伴噺
+ ContentChanged(0);
+
+ /*
+ if (m_pContext != nullptr) {
+ PJWarp* pjWarp = (PJWarp*)m_pContext;
+ for (int i = 0; i < 8; i++) {
+ pjWarp->checkSlot[i] = m_grid.GetSlotChecked(port, i);
+ pjWarp->material[i] = m_grid.GetSlotMaterialType(port, i);
+ }
+ }
+ */
+
+ *pResult = 0;
+}
+
+void CCjPage2::OnGridMatChanged(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ auto* nm = reinterpret_cast<CSG_MAT_CHANGE*>(pNMHDR);
+ const int port = nm->port;
+ const int slot = nm->slot;
+ const int mat = nm->material; // 1/2
+
+ // 渚嬪锛氬嵆鍒诲埛鏂板彸渚ч瑙�/璁板綍鏃ュ織绛�
+ ContentChanged(0);
+
+ /*
+ if (m_pContext != nullptr) {
+ PJWarp* pjWarp = (PJWarp*)m_pContext;
+ for (int i = 0; i < 8; i++) {
+ pjWarp->checkSlot[i] = m_grid.GetSlotChecked(port, i);
+ pjWarp->material[i] = m_grid.GetSlotMaterialType(port, i);
+ }
+ }
+ */
+
+ *pResult = 0;
}
--
Gitblit v1.9.3