From 7c9d38f5bb9c1d9daa8ef7117779be7e1a4d883b Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 23 五月 2025 17:48:40 +0800
Subject: [PATCH] 1.Port Status界面,增加Job Existence Slot控件

---
 SourceCode/Bond/Servo/CPageGraph2.cpp       |    2 
 SourceCode/Bond/Servo/Servo.vcxproj         |    2 
 SourceCode/Bond/Servo/Servo.vcxproj.filters |    2 
 SourceCode/Bond/Servo/CPagePortStatus.cpp   |   23 +++++
 SourceCode/Bond/Servo/resource.h            |    0 
 SourceCode/Bond/Servo/Servo.rc              |    0 
 SourceCode/Bond/Servo/CPagePortStatus.h     |    3 
 SourceCode/Bond/Servo/JobSlotGrid.h         |   37 +++++++++
 SourceCode/Bond/Servo/JobSlotGrid.cpp       |  170 ++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 237 insertions(+), 2 deletions(-)

diff --git a/SourceCode/Bond/Servo/CPageGraph2.cpp b/SourceCode/Bond/Servo/CPageGraph2.cpp
index 467c68e..f5b19e2 100644
--- a/SourceCode/Bond/Servo/CPageGraph2.cpp
+++ b/SourceCode/Bond/Servo/CPageGraph2.cpp
@@ -126,7 +126,7 @@
 		ASSERT(pItem);
 		SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
 
-		CHMPropertyDlg dlg(pEquipment->getName().c_str(), 600, 680);
+		CHMPropertyDlg dlg(pEquipment->getName().c_str(), 658, 788);
 
 		if (_strcmpi(pEquipment->getClassName(), "CLoadPort") == 0) {
 			CPagePortProperty* pPageA = new CPagePortProperty();
diff --git a/SourceCode/Bond/Servo/CPagePortStatus.cpp b/SourceCode/Bond/Servo/CPagePortStatus.cpp
index 198e904..ff38c73 100644
--- a/SourceCode/Bond/Servo/CPagePortStatus.cpp
+++ b/SourceCode/Bond/Servo/CPagePortStatus.cpp
@@ -97,6 +97,16 @@
 		pComboBox->SetCurSel(cassetteStatus - 1);
 	}
 
+	// 鍒涘缓Job Existence Slots鎺т欢
+	m_ctrlJobSlotGrid.Create(AfxRegisterWndClass(0), _T("JobSlotGrid"),
+		WS_CHILD | WS_VISIBLE, CRect(0, 0, 100, 100), this, 1001);
+	m_ctrlJobSlotGrid.SetGridSize(12, 16);
+	m_ctrlJobSlotGrid.SetColors(RGB(34, 177, 76), RGB(200, 200, 200));
+
+	m_ctrlJobSlotGrid.SetSlotStatus(0, 1, true);
+	m_ctrlJobSlotGrid.SetSlotStatus(1, 9, true);
+	m_ctrlJobSlotGrid.SetSlotStatus(4, 9, false);
+	m_ctrlJobSlotGrid.SetSlotStatus(4, 10, true, TRUE);
 
 	return TRUE;  // return TRUE unless you set the focus to a control
 				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
@@ -122,6 +132,17 @@
 void CPagePortStatus::OnSize(UINT nType, int cx, int cy)
 {
 	CHMPropertyPage::OnSize(nType, cx, cy);
+	if (GetDlgItem(IDC_COMBO_PORT_STATUS) == nullptr) return;
 
-	// TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
+
+	// 鍒涘缓Job Existence Slots鎺т欢
+	CRect rcLabel, rcComboBox, rcClient;
+	GetDlgItem(IDC_LABEL_JOB_EXISTENCE_SLOTS)->GetWindowRect(&rcLabel);
+	ScreenToClient(rcLabel);
+	GetDlgItem(IDC_COMBO_CASSETTE_STATUS)->GetWindowRect(&rcComboBox);
+	ScreenToClient(rcComboBox);
+	GetClientRect(rcClient);
+
+	m_ctrlJobSlotGrid.MoveWindow(rcComboBox.left, rcLabel.top, 
+		rcClient.right - 22 - rcComboBox.left, rcClient.bottom - 12 - rcLabel.top);
 }
\ No newline at end of file
diff --git a/SourceCode/Bond/Servo/CPagePortStatus.h b/SourceCode/Bond/Servo/CPagePortStatus.h
index dd1a1a2..5a40b72 100644
--- a/SourceCode/Bond/Servo/CPagePortStatus.h
+++ b/SourceCode/Bond/Servo/CPagePortStatus.h
@@ -1,5 +1,6 @@
 锘�#pragma once
 #include "CHMPropertyPage.h"
+#include "JobSlotGrid.h"
 
 
 // CPagePortStatus 瀵硅瘽妗�
@@ -17,6 +18,8 @@
 
 private:
 	SERVO::CLoadPort* m_pPort;
+	CJobSlotGrid m_ctrlJobSlotGrid;
+
 
 // 瀵硅瘽妗嗘暟鎹�
 #ifdef AFX_DESIGN_TIME
diff --git a/SourceCode/Bond/Servo/JobSlotGrid.cpp b/SourceCode/Bond/Servo/JobSlotGrid.cpp
new file mode 100644
index 0000000..cf7df72
--- /dev/null
+++ b/SourceCode/Bond/Servo/JobSlotGrid.cpp
@@ -0,0 +1,170 @@
+锘�#include "stdafx.h"
+#include "JobSlotGrid.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+IMPLEMENT_DYNAMIC(CJobSlotGrid, CWnd)
+
+BEGIN_MESSAGE_MAP(CJobSlotGrid, CWnd)
+    ON_WM_PAINT()
+    ON_WM_ERASEBKGND()
+END_MESSAGE_MAP()
+
+CJobSlotGrid::CJobSlotGrid() {
+    // 鍒濆鍖栭粯璁よ鍒楁暟
+    int m_nRows = 12;
+    int m_nCols = 16;
+
+    // 鍒濆鍖栭粯璁ゅ瓧浣�
+    m_fontText.CreatePointFont(60, _T("Arial"));
+
+	// 鍒濆鍖栭粯璁ら鑹�
+    COLORREF m_colorHasJob = RGB(0, 200, 0);      // 榛樿缁胯壊
+    COLORREF m_colorNoJob = RGB(220, 220, 220);   // 榛樿鐏拌壊
+
+    // 鍒濆鍖栭粯璁ょ敾鍒�
+    m_brushHasJob.CreateSolidBrush(m_colorHasJob);
+    m_brushNoJob.CreateSolidBrush(m_colorNoJob);
+}
+
+CJobSlotGrid::~CJobSlotGrid() {
+    if (m_fontText.GetSafeHandle()) {
+        m_fontText.DeleteObject();
+    }
+
+    if (m_brushHasJob.GetSafeHandle()) {
+        m_brushHasJob.DeleteObject();
+    }
+
+    if (m_brushNoJob.GetSafeHandle()) {
+        m_brushNoJob.DeleteObject();
+    }
+}
+
+void CJobSlotGrid::SetGridSize(int nRows, int nCols)
+{
+    m_nRows = nRows;
+    m_nCols = nCols;
+    m_vSlotStatus.assign(nRows, std::vector<bool>(nCols, false));
+
+    // 鍒濆鍖栨枃鏈暟缁�
+    m_vSlotText.assign(nRows, std::vector<CString>(nCols));
+    for (int i = 0; i < nRows; ++i) {
+        for (int j = 0; j < nCols; ++j) {
+            if (i == 0) {
+                m_vSlotText[i][j].Format(_T("%d"), j + 1);
+            }
+            else if (j == 0) {
+                m_vSlotText[i][j].Format(_T("%d"), i + 1);
+            }
+        }
+    }
+
+    Invalidate();
+}
+
+void CJobSlotGrid::SetColors(COLORREF colorHasJob, COLORREF colorNoJob)
+{
+    m_colorHasJob = colorHasJob;
+    m_colorNoJob = colorNoJob;
+
+    if (m_brushHasJob.GetSafeHandle()) {
+        m_brushHasJob.DeleteObject();
+    }
+
+    if (m_brushNoJob.GetSafeHandle()) { 
+        m_brushNoJob.DeleteObject();
+    }
+
+    m_brushHasJob.CreateSolidBrush(m_colorHasJob);
+    m_brushNoJob.CreateSolidBrush(m_colorNoJob);
+
+
+    Invalidate();
+}
+
+void CJobSlotGrid::SetSlotStatus(int nRow, int nCol, bool bHasJob, BOOL bInvalidate/* = TRUE*/)
+{
+    if (nRow >= 0 && nRow < m_nRows && nCol >= 0 && nCol < m_nCols) {
+        m_vSlotStatus[nRow][nCol] = bHasJob;
+        if (bInvalidate) {
+            Invalidate();
+        }
+    }
+}
+
+void CJobSlotGrid::SetSlotText(int nRow, int nCol, const CString& strText)
+{
+    if (nRow >= 0 && nRow < m_nRows && nCol >= 0 && nCol < m_nCols) {
+        m_vSlotText[nRow][nCol] = strText;
+        Invalidate();
+    }
+}
+
+void CJobSlotGrid::SetTextFont(const CString& strFontName, int nPointSize)
+{
+    // 鍒犻櫎鏃у瓧浣�
+    if (m_fontText.GetSafeHandle()) {
+        m_fontText.DeleteObject();
+    }
+
+    // CreatePointFont expects size in 1/10 pt
+    m_fontText.CreatePointFont(nPointSize * 10, strFontName);
+
+    Invalidate();
+}
+
+void CJobSlotGrid::ClearAll()
+{
+    if (m_vSlotStatus.empty()) {
+        return;
+    }
+
+    for (int i = 0; i < m_nRows; ++i) {
+        if (i < (int)m_vSlotStatus.size()) {
+            std::fill(m_vSlotStatus[i].begin(), m_vSlotStatus[i].end(), false);
+        }
+    }
+    Invalidate();
+}
+
+BOOL CJobSlotGrid::OnEraseBkgnd(CDC* pDC) {
+    return TRUE;
+}
+
+void CJobSlotGrid::OnPaint() {
+    CPaintDC dc(this);
+    DrawGrid(&dc);
+}
+
+void CJobSlotGrid::DrawGrid(CDC* pDC)
+{
+    CRect rect;
+    GetClientRect(&rect);
+
+    int nCellWidth = rect.Width() / m_nCols;
+    int nCellHeight = rect.Height() / m_nRows;
+    CFont* pOldFont = pDC->SelectObject(&m_fontText);
+
+    for (int i = 0; i < m_nRows; ++i) {
+        for (int j = 0; j < m_nCols; ++j) {
+            CRect cellRect(j * nCellWidth, i * nCellHeight, (j + 1) * nCellWidth, (i + 1) * nCellHeight);
+
+            // 鑳屾櫙
+            CBrush* pBrush = m_vSlotStatus[i][j] ? &m_brushHasJob : &m_brushNoJob;
+            pDC->FillRect(&cellRect, pBrush);
+
+            // 杈规
+            pDC->DrawEdge(&cellRect, EDGE_SUNKEN, BF_RECT);
+
+            // 鏂囧瓧锛堝眳涓級
+            pDC->SetBkMode(TRANSPARENT);
+            pDC->SetTextColor(RGB(0, 0, 0));
+            pDC->DrawText(m_vSlotText[i][j], &cellRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
+        }
+    }
+
+    pDC->SelectObject(pOldFont);
+}
diff --git a/SourceCode/Bond/Servo/JobSlotGrid.h b/SourceCode/Bond/Servo/JobSlotGrid.h
new file mode 100644
index 0000000..f904aea
--- /dev/null
+++ b/SourceCode/Bond/Servo/JobSlotGrid.h
@@ -0,0 +1,37 @@
+#pragma once
+#include <afxwin.h>
+#include <vector>
+
+class CJobSlotGrid : public CWnd
+{
+    DECLARE_DYNAMIC(CJobSlotGrid)
+
+public:
+    CJobSlotGrid();
+    virtual ~CJobSlotGrid();
+
+    void SetGridSize(int nRows, int nCols);
+    void SetColors(COLORREF colorHasJob, COLORREF colorNoJob);
+    void SetSlotStatus(int nRow, int nCol, bool bHasJob, BOOL bInvalidate = TRUE);
+    void SetSlotText(int nRow, int nCol, const CString& strText);
+    void SetTextFont(const CString& strFontName, int nPointSize);
+    void ClearAll();
+
+protected:
+    afx_msg void OnPaint();
+    afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+    DECLARE_MESSAGE_MAP()
+
+private:
+    int m_nRows;
+    int m_nCols;
+    CFont m_fontText;
+    COLORREF m_colorHasJob;
+    COLORREF m_colorNoJob;
+    CBrush m_brushHasJob;
+    CBrush m_brushNoJob;
+    std::vector<std::vector<bool>> m_vSlotStatus;
+    std::vector<std::vector<CString>> m_vSlotText;
+
+    void DrawGrid(CDC* pDC);
+};
\ No newline at end of file
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index d65ad7f..51aab99 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 592daa4..7343585 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj
+++ b/SourceCode/Bond/Servo/Servo.vcxproj
@@ -202,6 +202,7 @@
     <ClInclude Include="CGlassPool.h" />
     <ClInclude Include="CPagePortStatus.h" />
     <ClInclude Include="CPortStatusReport.h" />
+    <ClInclude Include="JobSlotGrid.h" />
     <ClInclude Include="MsgDlg.h" />
     <ClInclude Include="PageRecipe.h" />
     <ClInclude Include="CDoubleGlass.h" />
@@ -305,6 +306,7 @@
     <ClCompile Include="CGlassPool.cpp" />
     <ClCompile Include="CPagePortStatus.cpp" />
     <ClCompile Include="CPortStatusReport.cpp" />
+    <ClCompile Include="JobSlotGrid.cpp" />
     <ClCompile Include="MsgDlg.cpp" />
     <ClCompile Include="PageRecipe.cpp" />
     <ClCompile Include="CDoubleGlass.cpp" />
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj.filters b/SourceCode/Bond/Servo/Servo.vcxproj.filters
index 81267f5..7b5b0d5 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj.filters
+++ b/SourceCode/Bond/Servo/Servo.vcxproj.filters
@@ -108,6 +108,7 @@
     <ClCompile Include="CPortStatusReport.cpp" />
     <ClCompile Include="MsgDlg.cpp" />
     <ClCompile Include="CPagePortStatus.cpp" />
+    <ClCompile Include="JobSlotGrid.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="AlarmManager.h" />
@@ -215,6 +216,7 @@
     <ClInclude Include="MsgDlg.h" />
     <ClInclude Include="CPagePortStatus.h" />
     <ClInclude Include="ServoCommo.h" />
+    <ClInclude Include="JobSlotGrid.h" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="Servo.rc" />
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index 1c4a361..622c087 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ

--
Gitblit v1.9.3