From c911b82468fcbff3b927f750cefdd1df985085a5 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 19 五月 2025 08:48:00 +0800
Subject: [PATCH] 1.增加调度模式设置(Dispatching mode: 1,EAS, 2:Local)

---
 SourceCode/Bond/Servo/CPageGraph2.cpp       |    8 ++
 SourceCode/Bond/Servo/CEquipmentPage3.cpp   |  118 +++++++++++++++++++++++++++++
 SourceCode/Bond/Servo/Servo.vcxproj         |    2 
 SourceCode/Bond/Servo/Servo.vcxproj.filters |    2 
 SourceCode/Bond/Servo/CEquipmentPage3.h     |   38 +++++++++
 SourceCode/Bond/Servo/resource.h            |    0 
 SourceCode/Bond/Servo/CEquipment.cpp        |   27 ++++++
 SourceCode/Bond/Servo/Servo.rc              |    0 
 SourceCode/Bond/Servo/CEFEM.cpp             |   11 ++
 SourceCode/Bond/Servo/CEquipment.h          |    8 +
 SourceCode/Bond/Servo/Common.h              |    2 
 11 files changed, 215 insertions(+), 1 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEFEM.cpp b/SourceCode/Bond/Servo/CEFEM.cpp
index 99e9b0c..635cbc8 100644
--- a/SourceCode/Bond/Servo/CEFEM.cpp
+++ b/SourceCode/Bond/Servo/CEFEM.cpp
@@ -364,6 +364,17 @@
 				}
 			}
 		}
+
+		{
+			// Dispatching Mode Change Command
+			CEqWriteStep* pStep = new CEqWriteStep();
+			pStep->setName(STEP_EQ_DISPATCHINT_MODE_CHANGE);
+			pStep->setWriteSignalDev(0x071);
+			pStep->setDataDev(0x5c6);
+			if (addStep(STEP_ID_DISPATCHING_MODE_CHANGE_REPLY, pStep) != 0) {
+				delete pStep;
+			}
+		}
 	}
 
 	int CEFEM::onStepEvent(CStep* pStep, int code)
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index f7e2424..1d3f312 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -1063,6 +1063,33 @@
 		return pStep->setDateTime(year, month, day, hour, minute, second);
 	}
 
+	int CEquipment::setDispatchingMode(DISPATCHING_MODE mode, ONWRITED onWritedBlock/* = nullptr*/)
+	{
+		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(STEP_EQ_DISPATCHINT_MODE_CHANGE);
+		if (pStep == nullptr) {
+			return -1;
+		}
+
+		LOGI("<CEquipment-%s>准备设置DispatchingMode<%d>", m_strName.c_str(), (int)mode);
+		if (onWritedBlock != nullptr) {
+			pStep->writeShort((short)mode, onWritedBlock);
+		}
+		else {
+			pStep->writeShort((short)mode, [&, mode](int code) -> int {
+				if (code == WOK) {
+					LOGI("<CEquipment-%s>设置DispatchingMode成功.", m_strName.c_str());
+				}
+				else {
+					LOGI("<CEquipment-%s>设置DispatchingMode失败,code:%d", m_strName.c_str(), code);
+				}
+
+				return 0;
+				});
+		}
+
+		return 0;
+	}
+
 	int CEquipment::masterRecipeListRequest(short unitNo)
 	{
 		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(STEP_EQ_MASTER_RECIPE_LIST_REQ);
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index fe6ed40..b62b420 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -68,6 +68,11 @@
 		BOOL alive;
 	} ALIVE;
 
+	enum DISPATCHING_MODE {
+		EAS = 1,
+		Local = 2
+	};
+
 	class CEquipment
 	{
 	public:
@@ -146,7 +151,8 @@
 		int setCimMessage(const char* pszMessage, short id, short nTouchPanelNo);
 		int clearCimMessage(short id, short nTouchPanelNo);
 		int setDateTime(short year, short month, short day, short hour, short minute, short second);
-		
+		int setDispatchingMode(DISPATCHING_MODE mode, ONWRITED onWritedBlock = nullptr);
+
 		// 请求主配方列表
 		// unitNo: 0:local; Others:unit No
 		int masterRecipeListRequest(short unitNo);
diff --git a/SourceCode/Bond/Servo/CEquipmentPage3.cpp b/SourceCode/Bond/Servo/CEquipmentPage3.cpp
new file mode 100644
index 0000000..ed1aae9
--- /dev/null
+++ b/SourceCode/Bond/Servo/CEquipmentPage3.cpp
@@ -0,0 +1,118 @@
+锘�// CEquipmentPage3.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "stdafx.h"
+#include "Servo.h"
+#include "CEquipmentPage3.h"
+#include "afxdialogex.h"
+
+
+// CEquipmentPage3 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CEquipmentPage3, CHMPropertyPage)
+
+CEquipmentPage3::CEquipmentPage3(CWnd* pParent /*=nullptr*/)
+	: CHMPropertyPage(IDD_PAGE_EQUIPMENT3, pParent)
+{
+	m_pEquipment = nullptr;
+}
+
+CEquipmentPage3::~CEquipmentPage3()
+{
+}
+
+void CEquipmentPage3::DoDataExchange(CDataExchange* pDX)
+{
+	CHMPropertyPage::DoDataExchange(pDX);
+}
+
+
+BEGIN_MESSAGE_MAP(CEquipmentPage3, CHMPropertyPage)
+	ON_WM_CTLCOLOR()
+	ON_WM_DESTROY()
+	ON_WM_SIZE()
+	ON_BN_CLICKED(IDC_BUTTON_DISPATCHING_MODE_EAP, &CEquipmentPage3::OnBnClickedButtonDispatchingModeEap)
+	ON_BN_CLICKED(IDC_BUTTON_DISPATCHING_MODE_LOCAL, &CEquipmentPage3::OnBnClickedButtonDispatchingModeLocal)
+END_MESSAGE_MAP()
+
+
+// CEquipmentPage3 娑堟伅澶勭悊绋嬪簭
+void CEquipmentPage3::OnApply()
+{
+	__super::OnApply();
+}
+
+void CEquipmentPage3::setEquipment(SERVO::CEquipment* pEquipment)
+{
+	m_pEquipment = pEquipment;
+}
+
+BOOL CEquipmentPage3::OnInitDialog()
+{
+	CHMPropertyPage::OnInitDialog();
+
+	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
+
+	return TRUE;  // return TRUE unless you set the focus to a control
+				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+HBRUSH CEquipmentPage3::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
+{
+	HBRUSH hbr = CHMPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
+
+	// TODO:  鍦ㄦ鏇存敼 DC 鐨勪换浣曠壒鎬�
+
+	// TODO:  濡傛灉榛樿鐨勪笉鏄墍闇�鐢荤瑪锛屽垯杩斿洖鍙︿竴涓敾绗�
+	return hbr;
+}
+
+void CEquipmentPage3::OnDestroy()
+{
+	CHMPropertyPage::OnDestroy();
+
+	// TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
+}
+
+void CEquipmentPage3::OnSize(UINT nType, int cx, int cy)
+{
+	CHMPropertyPage::OnSize(nType, cx, cy);
+
+	// TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
+}
+
+void CEquipmentPage3::OnBnClickedButtonDispatchingModeEap()
+{
+	ASSERT(m_pEquipment);
+	m_pEquipment->setDispatchingMode(SERVO::DISPATCHING_MODE::EAS,
+		[&](int code) -> int {
+			if (code == WOK) {
+				LOGI("<CEquipment-%s>璁剧疆DispatchingMode鎴愬姛.", m_pEquipment->getName().c_str());
+				AfxMessageBox("璁剧疆EAS妯″紡鎴愬姛锛�");
+			}
+			else {
+				LOGI("<CEquipment-%s>璁剧疆DispatchingMode澶辫触锛宑ode:%d", m_pEquipment->getName().c_str(), code);
+				AfxMessageBox("璁剧疆EAS妯″紡澶辫触锛�");
+			}
+
+			return 0;
+		});
+}
+
+void CEquipmentPage3::OnBnClickedButtonDispatchingModeLocal()
+{
+	ASSERT(m_pEquipment);
+	m_pEquipment->setDispatchingMode(SERVO::DISPATCHING_MODE::Local, 
+		[&](int code) -> int {
+			if (code == WOK) {
+				LOGI("<CEquipment-%s>璁剧疆DispatchingMode鎴愬姛.", m_pEquipment->getName().c_str());
+				AfxMessageBox("璁剧疆Local妯″紡鎴愬姛锛�");
+			}
+			else {
+				LOGI("<CEquipment-%s>璁剧疆DispatchingMode澶辫触锛宑ode:%d", m_pEquipment->getName().c_str(), code);
+				AfxMessageBox("璁剧疆Local妯″紡澶辫触锛�");
+			}
+
+			return 0;
+		});
+}
diff --git a/SourceCode/Bond/Servo/CEquipmentPage3.h b/SourceCode/Bond/Servo/CEquipmentPage3.h
new file mode 100644
index 0000000..9e6d3f6
--- /dev/null
+++ b/SourceCode/Bond/Servo/CEquipmentPage3.h
@@ -0,0 +1,38 @@
+锘�#pragma once
+#include "CHMPropertyPage.h"
+#include "CEquipment.h"
+
+
+// CEquipmentPage3 瀵硅瘽妗�
+
+class CEquipmentPage3 : public CHMPropertyPage
+{
+	DECLARE_DYNAMIC(CEquipmentPage3)
+
+public:
+	CEquipmentPage3(CWnd* pParent = nullptr);   // 鏍囧噯鏋勯�犲嚱鏁�
+	virtual ~CEquipmentPage3();
+	virtual void OnApply();
+	void setEquipment(SERVO::CEquipment* pEquipment);
+
+private:
+	SERVO::CEquipment* m_pEquipment;
+
+
+// 瀵硅瘽妗嗘暟鎹�
+#ifdef AFX_DESIGN_TIME
+	enum { IDD = IDD_PAGE_EQUIPMENT3 };
+#endif
+
+protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 鏀寔
+
+	DECLARE_MESSAGE_MAP()
+public:
+	virtual BOOL OnInitDialog();
+	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+	afx_msg void OnDestroy();
+	afx_msg void OnSize(UINT nType, int cx, int cy);
+	afx_msg void OnBnClickedButtonDispatchingModeEap();
+	afx_msg void OnBnClickedButtonDispatchingModeLocal();
+};
diff --git a/SourceCode/Bond/Servo/CPageGraph2.cpp b/SourceCode/Bond/Servo/CPageGraph2.cpp
index ea4010b..68cbbe8 100644
--- a/SourceCode/Bond/Servo/CPageGraph2.cpp
+++ b/SourceCode/Bond/Servo/CPageGraph2.cpp
@@ -8,6 +8,7 @@
 #include "CHMPropertyDlg.h"
 #include "CEquipmentPage1.h"
 #include "CEquipmentPage2.h"
+#include "CEquipmentPage3.h"
 #include "CPagePortProperty.h"
 #include "CPageCassetteCtrlCmd.h"
 #include "CJobDataB.h"
@@ -138,6 +139,13 @@
 		pPage2->Create(IDD_PAGE_EQUIPMENT2);
 		dlg.addPage(pPage2, "Glass");
 
+		if (pEquipment->getID() == EQ_ID_EFEM) {
+			CEquipmentPage3* pPage3 = new CEquipmentPage3();
+			pPage3->setEquipment(pEquipment);
+			pPage3->Create(IDD_PAGE_EQUIPMENT3);
+			dlg.addPage(pPage3, "Dispatching Mode");
+		}
+
 		if (pEquipment->getID() == EQ_ID_LOADPORT1
 			|| pEquipment->getID() == EQ_ID_LOADPORT2) {
 			CPageCassetteCtrlCmd* pPage = new CPageCassetteCtrlCmd();
diff --git a/SourceCode/Bond/Servo/Common.h b/SourceCode/Bond/Servo/Common.h
index 957fc81..20a060e 100644
--- a/SourceCode/Bond/Servo/Common.h
+++ b/SourceCode/Bond/Servo/Common.h
@@ -207,6 +207,7 @@
 #define STEP_EQ_STORED_JOB13			_T("EQStoredJobReport13")
 #define STEP_EQ_STORED_JOB14			_T("EQStoredJobReport14")
 #define STEP_EQ_STORED_JOB15			_T("EQStoredJobReport15")
+#define STEP_EQ_DISPATCHINT_MODE_CHANGE	_T("EQDispatchingModeChangeCommand")
 
 
 
@@ -280,6 +281,7 @@
 #define STEP_ID_FETCHED_OUT_JOB_REPORT13		0x5BB
 #define STEP_ID_FETCHED_OUT_JOB_REPORT14		0x5BC
 #define STEP_ID_FETCHED_OUT_JOB_REPORT15		0x5BD
+#define STEP_ID_DISPATCHING_MODE_CHANGE_REPLY	0x5E2
 #define STEP_ID_PORT1_TYPE_CHANGE				0x600
 #define STEP_ID_PORT2_TYPE_CHANGE				0x601
 #define STEP_ID_PORT3_TYPE_CHANGE				0x602
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index 7cba98a..b65ab0d 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 4e0f9d1..5db43c3 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj
+++ b/SourceCode/Bond/Servo/Servo.vcxproj
@@ -198,6 +198,7 @@
     <Text Include="ReadMe.txt" />
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="CEquipmentPage3.h" />
     <ClInclude Include="CGlassPool.h" />
     <ClInclude Include="PageRecipe.h" />
     <ClInclude Include="CDoubleGlass.h" />
@@ -296,6 +297,7 @@
     <ClInclude Include="VerticalLine.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="CEquipmentPage3.cpp" />
     <ClCompile Include="CGlassPool.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 9ade198..d3871d4 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj.filters
+++ b/SourceCode/Bond/Servo/Servo.vcxproj.filters
@@ -104,6 +104,7 @@
     <ClCompile Include="CDoubleGlass.cpp" />
     <ClCompile Include="CProcessData.cpp" />
     <ClCompile Include="CGlassPool.cpp" />
+    <ClCompile Include="CEquipmentPage3.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="AlarmManager.h" />
@@ -206,6 +207,7 @@
     <ClInclude Include="CDoubleGlass.h" />
     <ClInclude Include="CProcessData.h" />
     <ClInclude Include="CGlassPool.h" />
+    <ClInclude Include="CEquipmentPage3.h" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="Servo.rc" />
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index 40bc4b7..96c0470 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ

--
Gitblit v1.9.3