From db9d120efcfe76bb73df089dca8986eca9ee0e6f Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期三, 10 十二月 2025 10:11:37 +0800
Subject: [PATCH] 1.扫码上报,但未在配置中设置变量;
---
SourceCode/Bond/Servo/HsmsPassive.h | 49 ++++++++++++------------
SourceCode/Bond/Servo/HsmsPassive.cpp | 5 ++
SourceCode/Bond/Servo/Model.cpp | 63 +++++++++++++++++--------------
3 files changed, 65 insertions(+), 52 deletions(-)
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index 1b122ec..3304fa9 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -1924,5 +1924,10 @@
return requestEventReportSend("Panel_End");
}
+int CHsmsPassive::requestEventReportSend_OCR_PanelID_Read_OK()
+{
+ return requestEventReportSend("OCR_PanelID_Read_OK");
+}
+
diff --git a/SourceCode/Bond/Servo/HsmsPassive.h b/SourceCode/Bond/Servo/HsmsPassive.h
index 1863abd..de60213 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.h
+++ b/SourceCode/Bond/Servo/HsmsPassive.h
@@ -1,4 +1,4 @@
-#pragma once
+锘�#pragma once
#include <string>
#include <list>
#include "HsmsAction.h"
@@ -39,7 +39,7 @@
#define CAACK_6 6 /* command performed with errors */
/*
- * 常量数据结构
+ * 甯搁噺鏁版嵁缁撴瀯
*/
typedef struct _EQConstant
{
@@ -48,7 +48,7 @@
} EQConstant;
/*
- * Command 数据结构
+ * Command 鏁版嵁缁撴瀯
*/
typedef struct _CommandParameter
{
@@ -57,7 +57,7 @@
} CommandParameter;
/*
- * Report 数据结构
+ * Report 鏁版嵁缁撴瀯
*/
typedef struct _REPORT
{
@@ -66,7 +66,7 @@
} REPORT;
/*
- * Value 数据结构
+ * Value 鏁版嵁缁撴瀯
*/
typedef struct _VALUE
{
@@ -115,62 +115,62 @@
~CHsmsPassive();
public:
- /* 设置机器型号 最大长度 20 bytes */
+ /* 璁剧疆鏈哄櫒鍨嬪彿 鏈�澶ч暱搴� 20 bytes */
void setEquipmentModelType(const char* pszMode);
- /* 设置软件版本号 最大长度 20 bytes */
+ /* 璁剧疆杞欢鐗堟湰鍙� 鏈�澶ч暱搴� 20 bytes */
void setSoftRev(const char* pszRev);
- /* 添加变量值到ISECS2Item */
+ /* 娣诲姞鍙橀噺鍊煎埌ISECS2Item */
void addVariableValueToItem(ISECS2Item* pParent, SERVO::CVariable* pVariable);
- // 连接Report
+ // 杩炴帴Report
void linkEventReport(unsigned int CEID, unsigned int RPTID);
- // 取消连接report
+ // 鍙栨秷杩炴帴report
void unlinkEventReport(unsigned int CEID);
// define Report
SERVO::CReport* defineReport(unsigned int RPTID, std::vector<unsigned int>& vids);
- // 取消 define report
+ // 鍙栨秷 define report
bool removeReport(int rptid);
void clearAllReport();
- // 从文件中加载CVariable列表
+ // 浠庢枃浠朵腑鍔犺浇CVariable鍒楄〃
int loadVarialbles(const char* pszFilepath);
- // 取得CVariable列表
+ // 鍙栧緱CVariable鍒楄〃
std::vector<SERVO::CVariable*>& getVariables();
- // 取得指定Variable
+ // 鍙栧緱鎸囧畾Variable
SERVO::CVariable* getVariable(int variableId);
SERVO::CVariable* getVariable(const char* pszName);
- // 设置变量值
+ // 璁剧疆鍙橀噺鍊�
void setVariableValue(const char* pszName, __int64 value);
void setVariableValue(const char* pszName, const char* value);
void setVariableValue(const char* pszName, std::vector<SERVO::CVariable>& vars);
- // 从文件中加载CReport列表
+ // 浠庢枃浠朵腑鍔犺浇CReport鍒楄〃
int loadReports(const char* pszFilepath);
- // 取得Report列表
+ // 鍙栧緱Report鍒楄〃
std::vector<SERVO::CReport*>& getReports();
- // 从文件中加载CCollectionEvent列表
+ // 浠庢枃浠朵腑鍔犺浇CCollectionEvent鍒楄〃
int loadCollectionEvents(const char* pszFilepath);
- // 取得CCollectionEvent列表
+ // 鍙栧緱CCollectionEvent鍒楄〃
std::vector<SERVO::CCollectionEvent*>& getCollectionEvents();
- // 取消/删除所有CollectionEvent
+ // 鍙栨秷/鍒犻櫎鎵�鏈塁ollectionEvent
void clearAllCollectionEvent();
- // 取得CCollectionEvent
+ // 鍙栧緱CCollectionEvent
SERVO::CCollectionEvent* getEvent(unsigned short CEID);
- // 取得Report
+ // 鍙栧緱Report
SERVO::CReport* getReport(int rptid);
void setListener(SECSListener listener);
@@ -185,7 +185,7 @@
int unserialize(const char* pszBuffer, int nBufferSize);
public:
- /* request开头的函数为主动发送数据的函数 */
+ /* request寮�澶寸殑鍑芥暟涓轰富鍔ㄥ彂閫佹暟鎹殑鍑芥暟 */
int requestAreYouThere();
int requestAlarmReport(int ALCD, int ALID, const char* ALTX);
int requestEventReportSend(unsigned int CEID);
@@ -201,11 +201,12 @@
int requestEventReportSend_CJ_End();
int requestEventReportSend_Panel_Start();
int requestEventReportSend_Panel_End();
+ int requestEventReportSend_OCR_PanelID_Read_OK();
private:
void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName);
- /* reply开头的函数为回复函数 */
+ /* reply寮�澶寸殑鍑芥暟涓哄洖澶嶅嚱鏁� */
int replyAreYouThere(IMessage* pRecv);
int replyEstablishCommunications(IMessage* pRecv);
int replySelectedEquipmentStatusData(IMessage* pRecv);
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index 8530738..777ce1b 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -1,4 +1,4 @@
-#include "stdafx.h"
+锘�#include "stdafx.h"
#include "Model.h"
#include "Log.h"
#include "Common.h"
@@ -25,7 +25,7 @@
{
if (m_pObservable == nullptr) {
m_pObservable = RX_AllocaObservable([&](IObservableEmitter* e) -> void {
- m_pObservableEmitter = e; // 保存发射器
+ m_pObservableEmitter = e; // 淇濆瓨鍙戝皠鍣�
});
}
@@ -83,7 +83,7 @@
m_configuration.setFilepath((LPTSTR)(LPCTSTR)strIniFile);
m_configuration.getUnitId(strUnitId);
- // 机器型号和软件版本号应从配置中读取,当前先固定值
+ // 鏈哄櫒鍨嬪彿鍜岃蒋浠剁増鏈彿搴斾粠閰嶇疆涓鍙栵紝褰撳墠鍏堝浐瀹氬��
CString strModeType = _T("Master");
CString strSoftRev = _T("1.0.2");
@@ -108,10 +108,10 @@
SECSListener listener;
listener.onEQOffLine = [&](void* pFrom) -> void {
- LOGI("远程请求OffLine");
+ LOGI("杩滅▼璇锋眰OffLine");
};
listener.onEQOnLine = [&](void* pFrom) -> void {
- LOGI("远程请求OnLine");
+ LOGI("杩滅▼璇锋眰OnLine");
};
listener.onCommand = [&](void* pFrom, const char* pszName, std::vector<CommandParameter>& params) -> void {
LOGI("onCommand:%s", pszName);
@@ -120,13 +120,13 @@
}
};
listener.onEQConstantRequest = [&](void* pFrom, std::vector<EQConstant>& eqcs) -> void {
- // 在此填充常量值,目前仅是加1后返回
+ // 鍦ㄦ濉厖甯搁噺鍊硷紝鐩墠浠呮槸鍔�1鍚庤繑鍥�
for (auto& item : eqcs) {
sprintf_s(item.szValue, 256, "Test%d", item.id + 1);
}
};
listener.onEQConstantSend = [&](void* pFrom, std::vector<EQConstant>& eqcs) -> void {
- // 在此保存和设置机器常量值
+ // 鍦ㄦ淇濆瓨鍜岃缃満鍣ㄥ父閲忓��
for (auto& item : eqcs) {
LOGI("onEQConstantRequest: %d, %s", item.id, item.szValue);
}
@@ -296,6 +296,13 @@
};
masterListener.onEqVcrEventReport = [&](void* pMaster, SERVO::CEquipment* pEquipment, SERVO::CVcrEventReport* pReport) {
LOGE("<CModel>onEqVcrEventReport.");
+ if (pReport != nullptr) {
+ m_hsmsPassive.setVariableValue("PanelStartID", pReport->getGlassId().c_str());
+ int nRet = m_hsmsPassive.requestEventReportSend_OCR_PanelID_Read_OK();
+ if (nRet != ER_NOERROR) {
+ LOGE("<CModel>requestEventReportSend_OCR_PanelID_Read_OK failed, ret=%d", nRet);
+ }
+ }
};
masterListener.onEqDataChanged = [&](void* pMaster, SERVO::CEquipment* pEquipment, int code) {
LOGE("<CModel>onEqDataChanged.");
@@ -303,11 +310,11 @@
};
masterListener.onRobotTaskEvent = [&](void* pMaster, SERVO::CRobotTask* pTask, int code) {
if (pTask == nullptr) {
- LOGE("<CModel>onRobotTaskEvent: 空任务指针,忽略事件 code=%d", code);
+ LOGE("<CModel>onRobotTaskEvent: 绌轰换鍔℃寚閽堬紝蹇界暐浜嬩欢 code=%d", code);
return;
}
- // 任务描述与 ID 用于日志
+ // 浠诲姟鎻忚堪涓� ID 鐢ㄤ簬鏃ュ織
SERVO::CGlass* pGlass = (SERVO::CGlass*)pTask->getContext();
const std::string& strDesc = pTask->getDescription();
std::string strClassID;
@@ -319,48 +326,48 @@
}
}
- // 日志输出与状态处理
+ // 鏃ュ織杈撳嚭涓庣姸鎬佸鐞�
switch (code) {
case ROBOT_EVENT_CREATE:
- LOGI("<CModel>onRobotTaskEvent: 新任务创建(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
+ LOGI("<CModel>onRobotTaskEvent: 鏂颁换鍔″垱寤�(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
break;
case ROBOT_EVENT_FINISH:
- LOGI("<CModel>onRobotTaskEvent: 任务完成(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
+ LOGI("<CModel>onRobotTaskEvent: 浠诲姟瀹屾垚(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
break;
case ROBOT_EVENT_ERROR:
- LOGE("<CModel>onRobotTaskEvent: 任务错误(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
+ LOGE("<CModel>onRobotTaskEvent: 浠诲姟閿欒(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
break;
case ROBOT_EVENT_ABORT:
- LOGE("<CModel>onRobotTaskEvent: 任务停止(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
+ LOGE("<CModel>onRobotTaskEvent: 浠诲姟鍋滄(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
break;
case ROBOT_EVENT_RESTORE:
- LOGE("<CModel>onRobotTaskEvent: 任务回撤(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
+ LOGE("<CModel>onRobotTaskEvent: 浠诲姟鍥炴挙(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
break;
default:
- LOGE("<CModel>onRobotTaskEvent: 未知事件 code=%d, 任务=%s", code, strDesc.c_str());
+ LOGE("<CModel>onRobotTaskEvent: 鏈煡浜嬩欢 code=%d, 浠诲姟=%s", code, strDesc.c_str());
break;
}
- // 安全格式化时间
+ // 瀹夊叏鏍煎紡鍖栨椂闂�
auto format_time = [](time_t t) -> std::string {
if (t <= 0 || t == _I64_MIN || t == _I64_MAX) {
return "";
}
- // 使用 localtime_s 确保线程安全
+ // 浣跨敤 localtime_s 纭繚绾跨▼瀹夊叏
tm tmBuf{};
errno_t err = localtime_s(&tmBuf, &t);
if (err != 0 || tmBuf.tm_mon < 0 || tmBuf.tm_mon > 11) {
return "";
}
- // 格式化时间字符串
+ // 鏍煎紡鍖栨椂闂村瓧绗︿覆
char buf[64] = {};
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tmBuf);
return std::string(buf);
};
- // 构造 TransferData 数据结构
+ // 鏋勯�� TransferData 鏁版嵁缁撴瀯
TransferData data;
data.strClassID = strClassID;
data.strCreateTime = format_time(pTask->getCreateTime());
@@ -369,7 +376,7 @@
data.strEndTime = format_time(pTask->getFinishTime());
data.strDescription = pTask->getSimpleDescription();
- // 状态映射
+ // 鐘舵�佹槧灏�
static const char* STATUS_STR[] = {
"Ready", "Running", "Picking", "Picked", "Placing", "Restoring", "Error", "Abort", "Restored", "Completed"
};
@@ -382,12 +389,12 @@
data.strStatus = "Unknown";
}
- // 写入数据库
+ // 鍐欏叆鏁版嵁搴�
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);
+ LOGI("<CModel>onRobotTaskEvent: 浠诲姟璁板綍宸蹭繚瀛橈紝RecordID=%d", nRecordId);
}
notifyPtrAndInt(RX_CODE_EQ_ROBOT_TASK, pTask, nullptr, code);
@@ -435,7 +442,7 @@
m_hsmsPassive.setVariableValue("CJEndID", ((SERVO::CControlJob*)pj)->id().c_str());
m_hsmsPassive.requestEventReportSend_CJ_End();
- // 结批,保存ControlJob
+ // 缁撴壒锛屼繚瀛楥ontrolJob
//
};
masterListener.onPjStart = [&](void* pMaster, void* pj) {
@@ -464,28 +471,28 @@
m_master.setContinuousTransferCount(m_configuration.getContinuousTransferCount());
- // master 设置缓存文件
+ // master 璁剧疆缂撳瓨鏂囦欢
CString strMasterDataFile;
strMasterDataFile.Format(_T("%s\\Master.dat"), (LPTSTR)(LPCTSTR)m_strWorkDir);
m_master.setCacheFilepath((LPTSTR)(LPCTSTR)strMasterDataFile);
m_master.setCompareMapsBeforeProceeding(m_configuration.isCompareMapsBeforeProceeding());
m_master.setJobMode(m_configuration.isJobMode());
- // 加截Job
+ // 鍔犳埅Job
strMasterDataFile.Format(_T("%s\\MasterState.dat"), (LPTSTR)(LPCTSTR)m_strWorkDir);
std::string strPath = std::string((LPTSTR)(LPCTSTR)strMasterDataFile);
m_master.setStateFile(strPath);
- // 加载警告信息
+ // 鍔犺浇璀﹀憡淇℃伅
AlarmManager& alarmManager = AlarmManager::getInstance();
char szBuffer[MAX_PATH];
sprintf_s(szBuffer, MAX_PATH, "%s\\AlarmList.csv", (LPTSTR)(LPCTSTR)m_strWorkDir);
alarmManager.readAlarmFile(szBuffer);
- // Glass数据库
+ // Glass鏁版嵁搴�
strLogDir.Format(_T("%s\\db\\process.db"), (LPTSTR)(LPCTSTR)m_strWorkDir);
std::string path((LPTSTR)(LPCTSTR)strLogDir);
GlassLogDb::Init(path);
--
Gitblit v1.9.3