From 0b05e3525e2767bc9eb314ce5d0d59a8e4073f6e Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期三, 23 七月 2025 10:52:57 +0800
Subject: [PATCH] 1.Port状态 map图对话框,增加全选和全不选。增加 Process Start和Process Cancel按钮,并下发相关指定到Cassette

---
 SourceCode/Bond/Servo/Servo.vcxproj            |    2 
 SourceCode/Bond/Servo/PortConfigurationDlg.cpp |   92 +++++++++++++++++++++-
 SourceCode/Bond/Servo/Servo.vcxproj.filters    |    2 
 SourceCode/Bond/Servo/resource.h               |    0 
 SourceCode/Bond/Servo/CCustomCheckBox.cpp      |   56 ++++++++++++++
 SourceCode/Bond/Servo/CCustomCheckBox.h        |   28 +++++++
 SourceCode/Bond/Servo/Servo.rc                 |    0 
 SourceCode/Bond/Servo/CLoadPort.cpp            |    4 
 SourceCode/Bond/Servo/PortConfigurationDlg.h   |   12 +++
 9 files changed, 190 insertions(+), 6 deletions(-)

diff --git a/SourceCode/Bond/Servo/CCustomCheckBox.cpp b/SourceCode/Bond/Servo/CCustomCheckBox.cpp
new file mode 100644
index 0000000..56a4612
--- /dev/null
+++ b/SourceCode/Bond/Servo/CCustomCheckBox.cpp
@@ -0,0 +1,56 @@
+#include "stdafx.h"
+#include "CCustomCheckBox.h"
+
+
+CCustomCheckBox::CCustomCheckBox()
+    : m_bgColor(RGB(255, 255, 255)), m_textColor(RGB(0, 0, 0))
+{
+    m_brush.CreateSolidBrush(m_bgColor);
+}
+
+CCustomCheckBox::~CCustomCheckBox()
+{
+
+}
+
+void CCustomCheckBox::SetBackgroundColor(COLORREF color)
+{
+    m_bgColor = color;
+    if (m_brush.GetSafeHandle())
+        m_brush.DeleteObject();
+    m_brush.CreateSolidBrush(m_bgColor);
+    Invalidate();
+}
+
+void CCustomCheckBox::SetTextColor(COLORREF color)
+{
+    m_textColor = color;
+    Invalidate();
+}
+
+void CCustomCheckBox::SetNotifyHwnd(HWND hWnd)
+{
+    m_hNotifyWnd = hWnd;
+}
+
+void CCustomCheckBox::OnClicked()
+{
+    BOOL bChecked = (GetCheck() == BST_CHECKED);
+
+    // 你可以定义自己的自定义消息
+    if (m_hNotifyWnd && ::IsWindow(m_hNotifyWnd)) {
+        ::PostMessage(m_hNotifyWnd, WM_CHECKBOX_STATE_CHANGED, GetDlgCtrlID(), bChecked);
+    }
+}
+
+BEGIN_MESSAGE_MAP(CCustomCheckBox, CButton)
+    ON_WM_CTLCOLOR_REFLECT()
+    ON_CONTROL_REFLECT(BN_CLICKED, &CCustomCheckBox::OnClicked)
+END_MESSAGE_MAP()
+
+HBRUSH CCustomCheckBox::CtlColor(CDC* pDC, UINT /*nCtlColor*/)
+{
+    pDC->SetBkMode(TRANSPARENT);
+    pDC->SetTextColor(m_textColor);
+    return (HBRUSH)m_brush.GetSafeHandle();
+}
\ No newline at end of file
diff --git a/SourceCode/Bond/Servo/CCustomCheckBox.h b/SourceCode/Bond/Servo/CCustomCheckBox.h
new file mode 100644
index 0000000..c7928f0
--- /dev/null
+++ b/SourceCode/Bond/Servo/CCustomCheckBox.h
@@ -0,0 +1,28 @@
+#pragma once
+
+
+#define WM_CHECKBOX_STATE_CHANGED       WM_USER + 1003
+
+class CCustomCheckBox : public CButton
+{
+public:
+    CCustomCheckBox();
+    virtual ~CCustomCheckBox();
+
+public:
+    void SetBackgroundColor(COLORREF color);
+    void SetTextColor(COLORREF color);
+    void SetNotifyHwnd(HWND hWnd);  // 设置消息接收窗口
+
+protected:
+    afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
+    afx_msg void OnClicked();
+    DECLARE_MESSAGE_MAP()
+
+private:
+    COLORREF m_bgColor;
+    COLORREF m_textColor;
+    CBrush   m_brush;
+    HWND     m_hNotifyWnd;
+};
+
diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index 5de17db..37f3139 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -350,10 +350,11 @@
 		CEquipment::onTimer(nTimerid);
 
 		// 模拟测试
+		/*
 		if (m_nIndex == 0) {
 			static int ii = 0;
 			ii++;
-			if (ii == 50) {
+			if (ii == 20) {
 				char szBuffer[64];
 				CStep* pStep = getStepWithName(STEP_EQ_PORT1_INUSE);
 				CPortStatusReport portStatusReport;
@@ -363,6 +364,7 @@
 				decodePortStatusReport(pStep, szBuffer, 64);
 			}
 		}
+		*/
 	}
 
 	void CLoadPort::serialize(CArchive& ar)
diff --git a/SourceCode/Bond/Servo/PortConfigurationDlg.cpp b/SourceCode/Bond/Servo/PortConfigurationDlg.cpp
index 891aaac..62b883a 100644
--- a/SourceCode/Bond/Servo/PortConfigurationDlg.cpp
+++ b/SourceCode/Bond/Servo/PortConfigurationDlg.cpp
@@ -12,6 +12,9 @@
 #include "ServoCommo.h"
 
 
+
+#define CHECKBOX_ALL_ID        0x1234
+
 // CPortConfigurationDlg 瀵硅瘽妗�
 
 IMPLEMENT_DYNAMIC(CPortConfigurationDlg, CDialogEx)
@@ -25,6 +28,8 @@
     m_pPort[2] = dynamic_cast<SERVO::CLoadPort*>(theApp.m_model.m_master.getEquipment(EQ_ID_LOADPORT3));
     m_pPort[3] = dynamic_cast<SERVO::CLoadPort*>(theApp.m_model.m_master.getEquipment(EQ_ID_LOADPORT4));
     m_nCurSelPort = -1;
+    m_pCheckBox = nullptr;
+    m_bCheckedAll = FALSE;
 }
 
 CPortConfigurationDlg::~CPortConfigurationDlg()
@@ -91,6 +96,7 @@
             }
         }
     }
+    m_pCheckBox->SetCheck(IsCheckedAll() ? BST_CHECKED : BST_UNCHECKED);
 }
 
 void CPortConfigurationDlg::InitGrid()
@@ -123,7 +129,8 @@
     m_wndGrid.SetColumnWidth(nColIdx, 50);
     m_wndGrid.SetItemText(0, nColIdx++, _T("Slot ID"));
     m_wndGrid.SetColumnWidth(nColIdx, 60);
-    m_wndGrid.SetItemText(0, nColIdx++, _T("鍚敤"));
+    m_wndGrid.SetItemText(0, nColIdx++, _T("Glass ID"));
+
 
     // 璁剧疆琛屼负鏍峰紡
     m_wndGrid.SetFixedRowSelection(FALSE);
@@ -146,6 +153,17 @@
     for (int i = 0; i < nRows; ++i) {
         m_wndGrid.SetRowHeight(i, nEachRowHeight);
     }
+
+    CRect rect;
+    BOOL bOK = m_wndGrid.GetCellRect(0, 1, rect);
+    m_pCheckBox = new CCustomCheckBox();
+    m_pCheckBox->Create(_T("閫夋嫨鎵�鏈�"),
+        WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, // 鑷姩鍕鹃��
+        CRect(0, 0, 150, 32), &m_wndGrid, CHECKBOX_ALL_ID);
+    m_pCheckBox->SetFont(GetFont());
+    m_pCheckBox->MoveWindow(rect.left + 5, rect.top + 3, 150, rect.Height() - 6);
+    m_pCheckBox->SetBackgroundColor(g_nGridFixCellColor);
+    m_pCheckBox->SetNotifyHwnd(GetSafeHwnd());
 }
 
 void CPortConfigurationDlg::DoDataExchange(CDataExchange* pDX)
@@ -161,6 +179,10 @@
 BEGIN_MESSAGE_MAP(CPortConfigurationDlg, CDialogEx)
     ON_CBN_SELCHANGE(IDC_COMBO_PORT, &CPortConfigurationDlg::OnSelchangeComboPort)
     ON_BN_CLICKED(IDC_BUTTON_APPLY, &CPortConfigurationDlg::OnBnClickedButtonApply)
+    ON_MESSAGE(WM_CHECKBOX_STATE_CHANGED, &CPortConfigurationDlg::OnCheckAllClicked)
+    ON_WM_DESTROY()
+    ON_BN_CLICKED(IDC_BUTTON_PROCESS_START, &CPortConfigurationDlg::OnBnClickedButtonProcessStart)
+    ON_BN_CLICKED(IDC_BUTTON_PROCESS_CANCEL, &CPortConfigurationDlg::OnBnClickedButtonProcessCancel)
 END_MESSAGE_MAP()
 
 
@@ -203,7 +225,8 @@
 	LoadPortConfigToUI(m_pPort[0]);     // 榛樿鍔犺浇绗竴涓鍙g殑閰嶇疆
 
 	// 璁剧疆瀵硅瘽妗嗘爣棰�
-    if (0 <= m_nCurSelPort && m_nCurSelPort <= 3) {
+    BOOL bAutoPopup = 0 <= m_nCurSelPort && m_nCurSelPort <= 3;
+    if (bAutoPopup) {
         CString strTitle;
         strTitle.Format(_T("%s Configuration"), ports[m_nCurSelPort]);
         SetWindowText(strTitle);
@@ -211,6 +234,11 @@
     else {
         SetWindowText(_T("Port Configuration"));
     }
+
+
+    // Porcess Start / Process Cancel 鎸夐挳鐘舵��
+    GetDlgItem(IDC_BUTTON_PROCESS_START)->EnableWindow(FALSE);
+    GetDlgItem(IDC_BUTTON_PROCESS_CANCEL)->EnableWindow(FALSE);
 
 
 	return TRUE;  // return TRUE unless you set the focus to a control
@@ -284,7 +312,7 @@
 	}
 
     // 鑾峰彇 Grid 琛ㄦ牸涓� Slot 鐘舵�侊紙绗�1~8琛岋級
-    for (int i = 1; i <= 8; ++i) {
+    for (int i = 1; i <= SLOT_MAX; ++i) {
         SERVO::CGlass* pGlass = (SERVO::CGlass*)m_wndGrid.GetItemData(i, 0);
         if (pGlass != nullptr) {
             CGridCellCheck* pCheck = dynamic_cast<CGridCellCheck*>(m_wndGrid.GetCell(i, 1));
@@ -300,6 +328,60 @@
         }
     }
 
+    GetDlgItem(IDC_BUTTON_PROCESS_START)->EnableWindow(TRUE);
+    GetDlgItem(IDC_BUTTON_PROCESS_CANCEL)->EnableWindow(TRUE);
+}
 
-    OnOK();
-}
\ No newline at end of file
+void CPortConfigurationDlg::OnDestroy()
+{
+    CDialogEx::OnDestroy();
+
+    if (m_pCheckBox != nullptr) {
+        m_pCheckBox->DestroyWindow();
+        delete m_pCheckBox;
+        m_pCheckBox = nullptr;
+    }
+}
+
+LRESULT  CPortConfigurationDlg::OnCheckAllClicked(WPARAM wParam, LPARAM lParam)
+{
+    UINT ctrlID = (UINT)wParam;
+    BOOL bChecked = (BOOL)lParam;
+    for (int i = 1; i <= SLOT_MAX; ++i) {
+        CGridCellCheck* pCheck = dynamic_cast<CGridCellCheck*>(m_wndGrid.GetCell(i, 1));
+        if (pCheck != nullptr) {
+            pCheck->SetCheck(bChecked);
+        }
+    }
+
+
+    return 0;
+}
+
+BOOL CPortConfigurationDlg::IsCheckedAll()
+{
+    for (int i = 1; i <= SLOT_MAX; ++i) {
+        CGridCellCheck* pCheck = dynamic_cast<CGridCellCheck*>(m_wndGrid.GetCell(i, 1));
+        if (pCheck != nullptr) {
+            if (!pCheck->GetCheck()) return FALSE;
+        }
+    }
+
+    return TRUE;
+}
+
+void CPortConfigurationDlg::OnBnClickedButtonProcessStart()
+{
+    int selPort = (0 <= m_nCurSelPort && m_nCurSelPort <= 3) ? m_nCurSelPort
+        : m_comboPort.GetCurSel();
+    if (selPort < 0 || selPort >= 4) return;
+    m_pPort[selPort]->sendCassetteCtrlCmd(CCC_PROCESS_START, nullptr, 0, 0, 0, nullptr, nullptr);
+}
+
+void CPortConfigurationDlg::OnBnClickedButtonProcessCancel()
+{
+    int selPort = (0 <= m_nCurSelPort && m_nCurSelPort <= 3) ? m_nCurSelPort
+        : m_comboPort.GetCurSel();
+    if (selPort < 0 || selPort >= 4) return;
+    m_pPort[selPort]->sendCassetteCtrlCmd(CCC_PROCESS_CANCEL, nullptr, 0, 0, 0, nullptr, nullptr);
+}
diff --git a/SourceCode/Bond/Servo/PortConfigurationDlg.h b/SourceCode/Bond/Servo/PortConfigurationDlg.h
index a8cd23f..0475d2d 100644
--- a/SourceCode/Bond/Servo/PortConfigurationDlg.h
+++ b/SourceCode/Bond/Servo/PortConfigurationDlg.h
@@ -2,6 +2,8 @@
 #include "afxdialogex.h"
 #include "GridCtrl.h"
 #include "CLoadPort.h"
+#include "CCustomCheckBox.h"
+
 
 // CPortConfigurationDlg 瀵硅瘽妗�
 
@@ -15,6 +17,7 @@
 
 public:
 	void setCurSelPort(int sel);
+	BOOL IsCheckedAll();
 
 // 瀵硅瘽妗嗘暟鎹�
 #ifdef AFX_DESIGN_TIME
@@ -26,6 +29,7 @@
 	virtual BOOL OnInitDialog();
 	afx_msg void OnSelchangeComboPort();
 	afx_msg void OnBnClickedButtonApply();
+	afx_msg LRESULT OnCheckAllClicked(WPARAM wParam, LPARAM lParam);
 	DECLARE_MESSAGE_MAP()
 
 private:
@@ -41,4 +45,12 @@
 	CComboBox m_comboPort;
 	CComboBox m_comboRecipe;
 	CComboBox m_comboMaterialsType;
+
+	CCustomCheckBox* m_pCheckBox;
+	BOOL m_bCheckedAll;
+
+public:
+	afx_msg void OnDestroy();
+	afx_msg void OnBnClickedButtonProcessStart();
+	afx_msg void OnBnClickedButtonProcessCancel();
 };
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index 2a76253..b7507b2 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 c3e7398..d3bbe72 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj
+++ b/SourceCode/Bond/Servo/Servo.vcxproj
@@ -200,6 +200,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="CBaseDlg.h" />
+    <ClInclude Include="CCustomCheckBox.h" />
     <ClInclude Include="CEquipmentPage3.h" />
     <ClInclude Include="CGlassPool.h" />
     <ClInclude Include="ChangePasswordDlg.h" />
@@ -342,6 +343,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="CBaseDlg.cpp" />
+    <ClCompile Include="CCustomCheckBox.cpp" />
     <ClCompile Include="CEquipmentPage3.cpp" />
     <ClCompile Include="CGlassPool.cpp" />
     <ClCompile Include="ChangePasswordDlg.cpp" />
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj.filters b/SourceCode/Bond/Servo/Servo.vcxproj.filters
index d4ed655..8b805ea 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj.filters
+++ b/SourceCode/Bond/Servo/Servo.vcxproj.filters
@@ -169,6 +169,7 @@
     <ClCompile Include="InputDialog.cpp" />
     <ClCompile Include="RecipeManager.cpp" />
     <ClCompile Include="RecipeDeviceBindDlg.cpp" />
+    <ClCompile Include="CCustomCheckBox.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="AlarmManager.h" />
@@ -343,6 +344,7 @@
     <ClInclude Include="InputDialog.h" />
     <ClInclude Include="RecipeManager.h" />
     <ClInclude Include="RecipeDeviceBindDlg.h" />
+    <ClInclude Include="CCustomCheckBox.h" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="Servo.rc" />
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index ddfba96..7d6f58e 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ

--
Gitblit v1.9.3