From 86074f0cd259814f2c5103e47360b6dd13f064f7 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 27 六月 2025 08:52:03 +0800
Subject: [PATCH] 1.Graph刷新问题; 2.AttributeVector造成的闪退问题;

---
 SourceCode/Bond/Servo/CStep.h         |    1 
 SourceCode/Bond/Servo/ServoGraph.cpp  |    7 +++
 SourceCode/Bond/Servo/CEquipment.cpp  |   18 ++-------
 SourceCode/Bond/Servo/ServoGraph.h    |    1 
 SourceCode/Bond/Servo/CLoadPort.cpp   |    4 -
 SourceCode/Bond/Servo/CPageGraph1.cpp |   13 ++----
 SourceCode/Bond/Servo/CBonder.cpp     |   11 +++++
 SourceCode/Bond/Servo/CStep.cpp       |   11 +++++
 8 files changed, 39 insertions(+), 27 deletions(-)

diff --git a/SourceCode/Bond/Servo/CBonder.cpp b/SourceCode/Bond/Servo/CBonder.cpp
index bacba68..7fe8a94 100644
--- a/SourceCode/Bond/Servo/CBonder.cpp
+++ b/SourceCode/Bond/Servo/CBonder.cpp
@@ -433,6 +433,17 @@
 	void CBonder::onTimer(UINT nTimerid)
 	{
 		CEquipment::onTimer(nTimerid);
+
+		// test
+		/*
+		static int i[2] = { 0, 0 };
+		i[m_nIndex]++;
+
+		if (i[m_nIndex] == 15) {
+			char szBuffer[26];
+			decodeJobProcessStartReport(getStep(STEP_ID_JOB_PROCESS_START_REPORT), szBuffer, 26);
+		}
+		*/
 	}
 
 	void CBonder::serialize(CArchive& ar)
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index 5a34f60..81b6bbf 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -1409,11 +1409,8 @@
 
 		// 缓存Attribute,用于调试时显示信息
 		unsigned int weight = 201;
-		CAttributeVector attrubutes;
+		CAttributeVector& attrubutes = pStep->attributeVector();
 		processData.getAttributeVector(attrubutes, weight);
-		pStep->addAttributeVector(attrubutes);
-
-
 		onProcessData(&processData);
 
 		return nRet;
@@ -1427,11 +1424,8 @@
 
 		// 缓存Attribute,用于调试时显示信息
 		unsigned int weight = 201;
-		CAttributeVector attrubutes;
+		CAttributeVector& attrubutes = pStep->attributeVector();
 		jobDataS.getAttributeVector(attrubutes, weight);
-		pStep->addAttributeVector(attrubutes);
-
-
 		onReceivedJob(port, &jobDataS);
 
 		return nRet;
@@ -1451,11 +1445,8 @@
 
 		// 缓存Attribute,用于调试时显示信息
 		unsigned int weight = 201;
-		CAttributeVector attrubutes;
+		CAttributeVector& attrubutes = pStep->attributeVector();
 		jobDataS.getAttributeVector(attrubutes, weight);
-		pStep->addAttributeVector(attrubutes);
-
-
 		onSentOutJob(port, &jobDataS);
 
 		return nRet;
@@ -1601,9 +1592,8 @@
 
 		// 缓存Attribute,用于调试时显示信息
 		unsigned int weight = 201;
-		CAttributeVector attrubutes;
+		CAttributeVector& attrubutes = pStep->attributeVector();
 		vcrEventReport.getAttributeVector(attrubutes, weight);
-		pStep->addAttributeVector(attrubutes);
 
 		// 0426, 先固定返回1(OK)
 		((CReadStep*)pStep)->setReturnCode((short)VCR_Reply_Code::OK);
diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index c6591e7..25d2306 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -893,10 +893,8 @@
 
 		// 缓存Attribute,用于调试时显示信息
 		unsigned int weight = 201;
-		CAttributeVector attrubutes;
+		CAttributeVector& attrubutes = pStep->attributeVector();
 		m_portStatusReport.getAttributeVector(attrubutes, weight);
-		pStep->addAttributeVector(attrubutes);
-
 
 		LOGI("<CCassetteTranserStateStep>decodePortStatusReport<Status:%d, CassetteSequenceNo:%d>",
 			m_portStatusReport.getPortStatus(), m_portStatusReport.getCassetteSequenceNo());
diff --git a/SourceCode/Bond/Servo/CPageGraph1.cpp b/SourceCode/Bond/Servo/CPageGraph1.cpp
index b213879..cb5ac2d 100644
--- a/SourceCode/Bond/Servo/CPageGraph1.cpp
+++ b/SourceCode/Bond/Servo/CPageGraph1.cpp
@@ -272,10 +272,7 @@
 	}
 
 	m_pGraph->UpdateIndicateBox1Colors(id, newBackgroundColor, newFrameColor1, newFrameColor2);
-
-	// 鍒锋柊鐣岄潰
-	Invalidate();
-	UpdateWindow();
+	m_pGraph->Invalidata();
 }
 
 BOOL CPageGraph1::OnEraseBkgnd(CDC* pDC)
@@ -375,8 +372,6 @@
 		m_pGraph->UpdateIndicateBoxCoordinates(INDICATE_ROBOT_ARM1, cx + rotatedX1, cy + rotatedY1);
 		m_pGraph->UpdateIndicateBoxCoordinates(INDICATE_ROBOT_ARM2, cx + rotatedX2, cy + rotatedY2);
 
-		Invalidate();
-		UpdateWindow();
 		std::this_thread::sleep_for(std::chrono::milliseconds(16));
 	}
 
@@ -515,10 +510,10 @@
 		MoveRobotToPosition(SERVO::ROBOT_POSITION::Measurement);
 	}
 
-	CString s; s.Format(_T("OnGraphItemClicked %d"), pGraphNmhdr->dwData);
 	SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)m_pGraph->GetIndicateBoxData(pGraphNmhdr->dwData);
 	if (pEquipment != nullptr) {
-		theApp.m_model.notifyPtr(RX_CODE_SELECT_EQUIPMENT, pEquipment);
+		// 鏆傛椂绂佺敤灞曞紑灞炴�ч〉鐨勫姛鑳�
+		// theApp.m_model.notifyPtr(RX_CODE_SELECT_EQUIPMENT, pEquipment);
 	}
 	
 	*pResult = 0;
@@ -596,6 +591,8 @@
 		if (robotData.position != m_lastRobotPosition) {
 			MoveRobotToPosition(robotData.position);
 		}
+
+		m_pGraph->Invalidata();
 	}
 
 	CDialogEx::OnTimer(nIDEvent);
diff --git a/SourceCode/Bond/Servo/CStep.cpp b/SourceCode/Bond/Servo/CStep.cpp
index 4ac3dfd..cf7dff5 100644
--- a/SourceCode/Bond/Servo/CStep.cpp
+++ b/SourceCode/Bond/Servo/CStep.cpp
@@ -59,8 +59,17 @@
 			std::to_string(m_station.nNetNo).c_str(), "", weight++));
 		attrubutes.addAttribute(new CAttribute("Station",
 			std::to_string(m_station.nStNo).c_str(), "", weight++));
-		attrubutes.addAttributeVector(m_attributeVector);
 
+		auto as = m_attributeVector.getAttributes();
+		for (auto item : as) {
+			attrubutes.addAttribute(new CAttribute(item->getName().c_str(),
+				item->getValue().c_str(), item->getDescription().c_str(), item->getWeight()));
+		}
+	}
+
+	CAttributeVector& CStep::attributeVector()
+	{
+		return m_attributeVector;
 	}
 
 	void CStep::init()
diff --git a/SourceCode/Bond/Servo/CStep.h b/SourceCode/Bond/Servo/CStep.h
index 20520f3..6e40acf 100644
--- a/SourceCode/Bond/Servo/CStep.h
+++ b/SourceCode/Bond/Servo/CStep.h
@@ -24,6 +24,7 @@
 		int getID();
 		void setName(const char* pszName);
 		std::string& getName();
+		CAttributeVector& attributeVector();
 		virtual void getAttributeVector(CAttributeVector& attrubutes);
 		virtual void init();
 		virtual void term();
diff --git a/SourceCode/Bond/Servo/ServoGraph.cpp b/SourceCode/Bond/Servo/ServoGraph.cpp
index 8e037e1..9925dcb 100644
--- a/SourceCode/Bond/Servo/ServoGraph.cpp
+++ b/SourceCode/Bond/Servo/ServoGraph.cpp
@@ -722,4 +722,9 @@
 	}
 
 	return nullptr;
-}
\ No newline at end of file
+}
+
+void CServoGraph::Invalidata()
+{
+	::InvalidateRect(m_hWnd, NULL, TRUE);
+}
diff --git a/SourceCode/Bond/Servo/ServoGraph.h b/SourceCode/Bond/Servo/ServoGraph.h
index 0440181..398c638 100644
--- a/SourceCode/Bond/Servo/ServoGraph.h
+++ b/SourceCode/Bond/Servo/ServoGraph.h
@@ -148,6 +148,7 @@
 	LRESULT OnLButtonDown(WPARAM wParam, LPARAM lParam);
 
 public:
+	void Invalidata();
 	void AddImage(int id, char* pszPath, int x, int y);
 	void AddIndicateBox(int id, int x, int y, int width);
 	void AddIndicateBox(int id, int x, int y, int width,

--
Gitblit v1.9.3