From 2ee440d9e85eccd73d2c3d4cbfe42cb8c1c25ec0 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期六, 28 六月 2025 14:35:24 +0800
Subject: [PATCH] 1.在stroedJob和Fetchout Job中增加Port的校验; 2.在物料调度中增加检测物料是否已经处理完成的校验;

---
 SourceCode/Bond/Servo/Model.cpp |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index 27056bd..c2acb85 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -190,8 +190,16 @@
 		}
 
 		// 任务描述与 ID 用于日志
+		SERVO::CGlass* pGlass = (SERVO::CGlass*)pTask->getContext();
 		const std::string& strDesc = pTask->getDescription();
-		const std::string& strClassID = pTask->getId();
+		std::string strClassID;
+		if (pGlass != nullptr) {
+			strClassID = pGlass->getID();
+			if (pGlass->getBuddy() != nullptr) {
+				strClassID += "/";
+				strClassID += pGlass->getBuddy()->getID();
+			}
+		}
 
 		// 日志输出与状态处理
 		switch (code) {
@@ -203,11 +211,12 @@
 			break;
 		case ROBOT_EVENT_ERROR:
 			LOGE("<CModel>onRobotTaskEvent: 任务错误(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
-			pTask->error();
 			break;
 		case ROBOT_EVENT_ABORT:
 			LOGE("<CModel>onRobotTaskEvent: 任务停止(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
-			pTask->abort();
+			break;
+		case ROBOT_EVENT_RESTORE:
+			LOGE("<CModel>onRobotTaskEvent: 任务回撤(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
 			break;
 		default:
 			LOGE("<CModel>onRobotTaskEvent: 未知事件 code=%d, 任务=%s", code, strDesc.c_str());
@@ -216,7 +225,7 @@
 
 		// 安全格式化时间
 		auto format_time = [](time_t t) -> std::string {
-			if (t < 0 || t == _I64_MIN || t == _I64_MAX) { 
+			if (t <= 0 || t == _I64_MIN || t == _I64_MAX) { 
 				return "";
 			}
 
@@ -244,23 +253,26 @@
 
 		// 状态映射
 		static const char* STATUS_STR[] = {
-			"Unknown", "Ready", "Running", "Picking", "Placing", "Restoring", "Error", "Abort", "Completed"
+			"Ready", "Running", "Picking", "Picked", "Placing", "Restoring", "Error", "Abort", "Restored", "Completed"
 		};
 		auto state = pTask->getState();
 		int index = static_cast<int>(state);
-		if (index > 0 && index < static_cast<int>(std::size(STATUS_STR))) {
+		if (index >= 0 && index < static_cast<int>(std::size(STATUS_STR))) {
 			data.strStatus = STATUS_STR[index];
 		}
 		else {
-			data.strStatus = STATUS_STR[0];
+			data.strStatus = "Unknown";
 		}
 
 		// 写入数据库
-		int nRecordId = 0;
-		TransferManager::getInstance().addTransferRecord(data, nRecordId);
-
+		if (code == ROBOT_EVENT_FINISH || code == ROBOT_EVENT_ERROR
+			|| code == ROBOT_EVENT_ABORT || code == ROBOT_EVENT_RESTORE) {
+			int nRecordId = 0;
+			TransferManager::getInstance().addTransferRecord(data, nRecordId);
+			LOGI("<CModel>onRobotTaskEvent: 任务记录已保存,RecordID=%d", nRecordId);
+		}
 		notifyPtrAndInt(RX_CODE_EQ_ROBOT_TASK, pTask, nullptr, code);
-		LOGI("<CModel>onRobotTaskEvent: 任务记录已保存,RecordID=%d", nRecordId);
+
 	};
 	m_master.setListener(masterListener);
 

--
Gitblit v1.9.3