From 91a2974fc7bce6e8bbd903992efae13709b0d186 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 20 五月 2025 09:48:17 +0800
Subject: [PATCH] 1.修改替换CEqVcrEventStep为(CEqReadStep)

---
 SourceCode/Bond/Servo/CEquipment.cpp      |   23 +++++++++++
 SourceCode/Bond/Servo/CVcrEventReport.h   |    4 +
 SourceCode/Bond/Servo/CEFEM.cpp           |   19 +++++++++
 SourceCode/Bond/Servo/CVcrEventReport.cpp |   26 ++++++++++++
 SourceCode/Bond/Servo/CEquipment.h        |    8 ++++
 5 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEFEM.cpp b/SourceCode/Bond/Servo/CEFEM.cpp
index 1b792f1..91772f7 100644
--- a/SourceCode/Bond/Servo/CEFEM.cpp
+++ b/SourceCode/Bond/Servo/CEFEM.cpp
@@ -235,11 +235,29 @@
 
 		{
 			// VCR1 Event Report
+			/*
 			CEqVcrEventStep* pStep = new CEqVcrEventStep();
 			pStep->setName(STEP_EQ_VCR1_EVENT_REPORT);
 			pStep->setWriteSignalDev(0x4a);
 			pStep->setReturnDev(0x91e);
 			pStep->setVcrEventReportDev(0x5fef);
+			if (addStep(STEP_ID_VCR1_EVENT_REPORT, pStep) != 0) {
+				delete pStep;
+			}
+			*/
+
+			// VCR Event Report
+			// 机器上报扫码结果,扫码器预计安装在巡边检机器上
+			CEqReadStep* pStep = new CEqReadStep(0x5fef, 15 * 2,
+				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
+					if (code == ROK && pszData != nullptr && size > 0) {
+						decodeVCREventReport((CStep*)pFrom, pszData, size);
+					}
+					return -1;
+				});
+			pStep->setName(STEP_EQ_VCR1_EVENT_REPORT);
+			pStep->setProp("Port", (void*)1);
+			pStep->setWriteSignalDev(0x4a);
 			if (addStep(STEP_ID_VCR1_EVENT_REPORT, pStep) != 0) {
 				delete pStep;
 			}
@@ -465,7 +483,6 @@
 				delete pStep;
 			}
 		}
-
 	}
 
 	int CEFEM::onStepEvent(CStep* pStep, int code)
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index 4bc9ffc..ad9ab25 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -595,6 +595,7 @@
 				panelNo = (value & 0xffff);
 				LOGI("Cim Message Confirm(msgID = %d, panel no.=%d).", msgId, panelNo);
 			}
+			/*
 			else if (isVcrEventStep(pStep)) {
 				SERVO::CEqVcrEventStep* pEqVcrEventStep = (SERVO::CEqVcrEventStep*)pStep;
 				CVcrEventReport* pVcrEventReport = pEqVcrEventStep->getVcrEventReport();
@@ -607,6 +608,7 @@
 				pEqVcrEventStep->setReturnCode(1);		
 				return 1;
 			}
+			*/
 		}
 
 
@@ -1362,6 +1364,27 @@
 		return index;
 	}
 
+	int CEquipment::decodeVCREventReport(CStep* pStep, const char* pszData, size_t size)
+	{
+		CVcrEventReport vcrEventReport;
+		vcrEventReport.unserialize(pszData, size);
+		LOGI("<CEquipment-%s>decodeVCREventReport<Result:%d, GlassId:%s>\n", m_strName.c_str(),
+			vcrEventReport.getVcrResult(),
+			vcrEventReport.getGlassId().c_str());
+
+
+		// 缓存Attribute,用于调试时显示信息
+		unsigned int weight = 201;
+		CAttributeVector attrubutes;
+		vcrEventReport.getAttributeVector(attrubutes, weight);
+		pStep->addAttributeVector(attrubutes);
+
+		// 0426, 先固定返回1(OK)
+		((CReadStep*)pStep)->setReturnCode((short)VCR_Reply_Code::OK);
+
+		return 0;
+	}
+
 	int CEquipment::onPreStoredJob(int port, CJobDataB* pJobDataB)
 	{
 		LOGI("<CEquipment-%s>onPreStoredJob:port:%d|GlassId:%s",
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index 90b7a12..81b7bc0 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -98,6 +98,13 @@
 		Batch_put
 	};
 
+	enum VCR_Reply_Code {
+		OK = 1,
+		NG,
+		Job_Data_Request,
+		VCR_Mismatch
+	};
+
 	// Robot cmd param
 #define ROBOT_CMD_PARAM_SIZE		16			/* 防止以后修改ROBOT_CMD_PARAM为不是4的整数倍 */
 	typedef struct _ROBOT_CMD_PARAM {
@@ -232,6 +239,7 @@
 		int decodeSentOutJobReport(CStep* pStep, int port, const char* pszData, size_t size);
 		int decodeFetchedOutJobReport(CStep* pStep, int port, const char* pszData, size_t size);
 		int decodeStoredJobReport(CStep* pStep, int port, const char* pszData, size_t size);
+		int decodeVCREventReport(CStep* pStep, const char* pszData, size_t size);
 		int addJobDataB(CJobDataB* pJobDataB);
 		int removeJobDataB(int nCassetteSequenceNo, int nJobSequenceNo);
 		CJobDataB* getJobDataB(int nCassetteSequenceNo, int nJobSequenceNo);
diff --git a/SourceCode/Bond/Servo/CVcrEventReport.cpp b/SourceCode/Bond/Servo/CVcrEventReport.cpp
index 914b0d0..248cd03 100644
--- a/SourceCode/Bond/Servo/CVcrEventReport.cpp
+++ b/SourceCode/Bond/Servo/CVcrEventReport.cpp
@@ -71,7 +71,7 @@
 		return 15 * 2;
 	}
 
-	int CVcrEventReport::unserialize(char* pszBuffer, int nBufferSize)
+	int CVcrEventReport::unserialize(const char* pszBuffer, int nBufferSize)
 	{
 		if (nBufferSize < 640) return -1;
 
@@ -97,6 +97,30 @@
 		return 15 * 2;
 	}
 
+	void CVcrEventReport::getAttributeVector(CAttributeVector& attrubutes, int beginWeight)
+	{
+		unsigned int weight = beginWeight;
+		std::string strTemp;
+
+		attrubutes.addAttribute(new CAttribute("GlassId",
+			m_strGlassId.c_str(), "", weight++));
+
+		attrubutes.addAttribute(new CAttribute("CassetteSequenceNo",
+			std::to_string(m_nCassetteSequenceNo).c_str(), "", weight++));
+
+		attrubutes.addAttribute(new CAttribute("JobSequenceNo",
+			std::to_string(m_nJobSequenceNo).c_str(), "", weight++));
+
+		attrubutes.addAttribute(new CAttribute("UnitNo",
+			std::to_string(m_nUnitNo).c_str(), "", weight++));
+
+		attrubutes.addAttribute(new CAttribute("VcrNo",
+			std::to_string(m_nVcrNo).c_str(), "", weight++));
+
+		attrubutes.addAttribute(new CAttribute("VcrResult",
+			std::to_string(m_nVcrResult).c_str(), "", weight++));
+	}
+
 	std::string& CVcrEventReport::getVcrResultDescription(std::string& strDescription)
 	{
 		static char* pszDescription[4] = {
diff --git a/SourceCode/Bond/Servo/CVcrEventReport.h b/SourceCode/Bond/Servo/CVcrEventReport.h
index 275cf30..8ff3992 100644
--- a/SourceCode/Bond/Servo/CVcrEventReport.h
+++ b/SourceCode/Bond/Servo/CVcrEventReport.h
@@ -1,5 +1,6 @@
 #pragma once
 #include <string>
+#include "CAttributeVector.h"
 
 
 namespace SERVO {
@@ -18,7 +19,8 @@
 		short getVcrResult();
 		std::string& getVcrResultDescription(std::string& strDescription);
 		int serialize(char* pszBuffer, int nBufferSize);
-		int unserialize(char* pszBuffer, int nBufferSize);
+		int unserialize(const char* pszBuffer, int nBufferSize);
+		void getAttributeVector(CAttributeVector& attrubutes, int beginWeight);
 
 	private:
 		std::string m_strGlassId;			// Read Data

--
Gitblit v1.9.3