From 4a9f803ce6896554706b97fe36e0002d18e1f346 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期三, 16 七月 2025 09:35:41 +0800
Subject: [PATCH] 1. [TaskControl] 添加设备启用状态判断(IsEnabled) 2. 在多个工艺任务(如 bake_to_cooling、bond_to_bake 等)中增加 psrEq->IsEnabled() 判断

---
 SourceCode/Bond/Servo/CPageLinkSignal.cpp |   26 ++++++++++++-
 SourceCode/Bond/Servo/resource.h          |    0 
 SourceCode/Bond/Servo/CEquipment.cpp      |   11 +++++
 SourceCode/Bond/Servo/Servo.rc            |    0 
 SourceCode/Bond/Servo/CMaster.cpp         |   20 ++++++++++
 SourceCode/Bond/Servo/CPageLinkSignal.h   |    2 +
 SourceCode/Bond/Servo/CEquipment.h        |    3 +
 7 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index c670d76..26b20d3 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -11,6 +11,7 @@
 
 	CEquipment::CEquipment() : m_nID(0), m_strName(""), m_strDescription(""), m_station(0, 255)
 	{
+		m_bEnable = TRUE;
 		m_listener = { };
 		m_alive = { FALSE, 0, FALSE };
 		m_bCimState = FALSE;
@@ -56,6 +57,16 @@
 		DeleteCriticalSection(&m_criticalSection);
 	}
 
+	void CEquipment::SetEnable(BOOL bEnable)
+	{
+		m_bEnable = bEnable;
+	}
+
+	BOOL CEquipment::IsEnabled() const
+	{
+		return m_bEnable;
+	}
+
 	void CEquipment::setListener(EquipmentListener listener)
 	{
 		m_listener = listener;
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index 3fec1cc..1a35b85 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -76,6 +76,8 @@
 		virtual ~CEquipment();
 
 	public:
+		void SetEnable(BOOL bEnable);
+		BOOL IsEnabled() const;
 		virtual const char* getClassName() = 0;
 		virtual void setListener(EquipmentListener listener);
 		void setCcLink(CCCLinkIEControl* pCcLink);
@@ -248,6 +250,7 @@
 		void setProcessState(PROCESS_STATE state);
 
 	protected:
+		BOOL m_bEnable;
 		EquipmentListener m_listener;
 		int m_nID;
 		std::string m_strName;
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 752192c..7ef3579 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -1409,6 +1409,10 @@
 		MaterialsType primaryType/* = MaterialsType::G1*/, MaterialsType secondaryType/* = MaterialsType::G2*/,
 		int armNo/* = 1*/)
 	{
+		if (!pSrcEq->IsEnabled()) { 
+			return nullptr;
+		}
+
 		CRobotTask* pTask = nullptr;
 		CSlot* pSrcSlot, * pTarSlot;
 		pTarSlot = pTarEq->getAvailableSlotForGlass(primaryType);
@@ -1433,6 +1437,10 @@
 
 	CRobotTask* CMaster::createTransferTask_bonder_to_bakecooling(CEquipment* pSrcEq, CEquipment* pTarEq)
 	{
+		if (!pSrcEq->IsEnabled()) {
+			return nullptr;
+		}
+
 		std::vector<int> slots = {1, 3};
 
 		CRobotTask* pTask = nullptr;
@@ -1454,6 +1462,10 @@
 
 	CRobotTask* CMaster::createTransferTask_bake_to_cooling(CEquipment* pSrcEq)
 	{
+		if (!pSrcEq->IsEnabled()) {
+			return nullptr;
+		}
+
 		std::vector<int> slotsTar = { 2, 4 };
 		std::vector<int> slotsSrc = { 1, 3 };
 
@@ -1476,6 +1488,10 @@
 
 	CRobotTask* CMaster::createTransferTask_bakecooling_to_measurement(CEquipment* pSrcEq, CEquipment* pTarEq)
 	{
+		if (!pSrcEq->IsEnabled()) {
+			return nullptr;
+		}
+
 		std::vector<int> slots = { 2, 4 };
 
 		CRobotTask* pTask = nullptr;
@@ -1497,6 +1513,10 @@
 
 	CRobotTask* CMaster::createTransferTask_restore(CEquipment* pEqSrc, CLoadPort** pPorts)
 	{
+		if (!pEqSrc->IsEnabled()) {
+			return nullptr;
+		}
+
 		CRobotTask* pTask = nullptr;
 		CSlot* pSrcSlot, * pTarSlot = nullptr, * pTempSlot;
 		pSrcSlot = pEqSrc->getInspFailSlot();
diff --git a/SourceCode/Bond/Servo/CPageLinkSignal.cpp b/SourceCode/Bond/Servo/CPageLinkSignal.cpp
index b06b015..b86ca5d 100644
--- a/SourceCode/Bond/Servo/CPageLinkSignal.cpp
+++ b/SourceCode/Bond/Servo/CPageLinkSignal.cpp
@@ -19,6 +19,7 @@
 
 CPageLinkSignal::CPageLinkSignal(CWnd* pParent /*=nullptr*/)
 	: CHMPropertyPage(IDD_PAGE_LINK_SIGNAL, pParent)
+	, m_bEnable(TRUE)
 {
 	m_pEquipment = nullptr;
 }
@@ -30,6 +31,7 @@
 void CPageLinkSignal::DoDataExchange(CDataExchange* pDX)
 {
 	CHMPropertyPage::DoDataExchange(pDX);
+	DDX_Check(pDX, IDC_CHECK_ENABLE, m_bEnable);
 }
 
 
@@ -38,6 +40,7 @@
 	ON_WM_DESTROY()
 	ON_WM_SIZE()
 	ON_WM_TIMER()
+	ON_BN_CLICKED(IDC_CHECK_ENABLE, &CPageLinkSignal::OnClickedCheckEnable)
 END_MESSAGE_MAP()
 
 
@@ -56,6 +59,12 @@
 
 	KillTimer(TIMER_ID_SIGNAL_UPDATE);
 	SetTimer(TIMER_ID_SIGNAL_UPDATE, TIMER_INTERVAL_MS, nullptr);
+
+
+	if (m_pEquipment) {
+		m_bEnable = m_pEquipment->IsEnabled();
+		UpdateData(FALSE);
+	}
 
 	return TRUE;  // return TRUE unless you set the focus to a control
 				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
@@ -139,6 +148,14 @@
 			BTN_Y - 36,
 			rcItem.Width(), rcItem.Height());
 	}
+
+	pItem = GetDlgItem(IDC_CHECK_ENABLE);
+	if (pItem) {
+		int nCheckboxX = max(0, BTN_X - 50);
+		int nCheckboxY = max(0, BTN_Y - rcItem.Height() - 30);
+		pItem->GetWindowRect(&rcItem);
+		pItem->MoveWindow(nCheckboxX, nCheckboxY, rcItem.Width(), rcItem.Height());
+	}
 }
 
 void CPageLinkSignal::OnTimer(UINT_PTR nIDEvent)
@@ -158,7 +175,7 @@
 
 	for (int nRow = 0; nRow < 8; ++nRow) {
 		for (int nCol = 0; nCol < 8; ++nCol) {
-			BOOL bCurrentState = m_pEquipment->isLinkSignalUpstreamOn(nRow, nCol);
+			BOOL bCurrentState = m_pEquipment->isLinkSignalUpstreamOn(nRow, nCol) && m_pEquipment->IsEnabled();
 			UpdateSignalState(nRow, nCol, bCurrentState);
 		}
 	}
@@ -177,4 +194,9 @@
 	}
 }
 
-
+void CPageLinkSignal::OnClickedCheckEnable()
+{
+	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	UpdateData(TRUE);
+	m_pEquipment->SetEnable(m_bEnable);
+}
diff --git a/SourceCode/Bond/Servo/CPageLinkSignal.h b/SourceCode/Bond/Servo/CPageLinkSignal.h
index c671159..8b40ce2 100644
--- a/SourceCode/Bond/Servo/CPageLinkSignal.h
+++ b/SourceCode/Bond/Servo/CPageLinkSignal.h
@@ -21,6 +21,7 @@
 private:
 	SERVO::CEquipment* m_pEquipment;
 	CBlButton* m_pBtn[8][8];
+	BOOL m_bEnable;
 
 // 瀵硅瘽妗嗘暟鎹�
 #ifdef AFX_DESIGN_TIME
@@ -37,4 +38,5 @@
 	afx_msg void OnDestroy();
 	afx_msg void OnSize(UINT nType, int cx, int cy);
 	afx_msg void OnTimer(UINT_PTR nIDEvent);
+	afx_msg void OnClickedCheckEnable();
 };
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index 63b6347..302c2ea 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index 2f6ca12..ee344ec 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ

--
Gitblit v1.9.3