From 6c92ade0aeb6a505f2ab8108dcbdab20e37a9fac Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期三, 28 一月 2026 21:29:47 +0800
Subject: [PATCH] 1.EQStatusChange事件上报
---
SourceCode/Bond/Servo/CEqStatusStep.h | 3 +++
SourceCode/Bond/Servo/CEqStatusStep.cpp | 18 +++++++++++++++++-
SourceCode/Bond/Servo/CEquipment.cpp | 10 ++++++++++
SourceCode/Bond/Servo/CMaster.cpp | 5 +++++
SourceCode/Bond/Servo/CMaster.h | 2 ++
SourceCode/Bond/Servo/Model.cpp | 15 ++++++++++-----
SourceCode/Bond/Servo/CEquipment.h | 2 ++
SourceCode/Bond/x64/Debug/ReportList.txt | 2 +-
SourceCode/Bond/x64/Debug/VariableList.txt | 2 ++
9 files changed, 52 insertions(+), 7 deletions(-)
diff --git a/SourceCode/Bond/Servo/CEqStatusStep.cpp b/SourceCode/Bond/Servo/CEqStatusStep.cpp
index 3f8195a..e63cc7d 100644
--- a/SourceCode/Bond/Servo/CEqStatusStep.cpp
+++ b/SourceCode/Bond/Servo/CEqStatusStep.cpp
@@ -8,6 +8,7 @@
CEqStatusStep::CEqStatusStep() : CReadStep()
{
m_nStatusDev = 0;
+ m_nUnitId = 0;
for (int i = 0; i < STATUS_MAX; i++) {
m_nStatus[i] = 0;
m_nReasonCode[i] = 0;
@@ -49,6 +50,20 @@
return -1;
}
+
+ int CEqStatusStep::getReasonCode(unsigned int uint) const
+ {
+ if (uint < STATUS_MAX) {
+ return m_nReasonCode[uint];
+ }
+
+ return -1;
+ }
+
+ unsigned int CEqStatusStep::getUnitId() const
+ {
+ return m_nUnitId;
+ }
int CEqStatusStep::onReadData()
{
CReadStep::onReadData();
@@ -60,10 +75,11 @@
return -1;
}
- unsigned int unitId = (unsigned int)CToolUnits::toInt16(&szBuffer[0]);
+ const unsigned int unitId = (unsigned int)CToolUnits::toInt16(&szBuffer[0]);
if (unitId >= STATUS_MAX) {
return -2;
}
+ m_nUnitId = unitId;
if (unitId == 0) {
m_nStatus[unitId] = CToolUnits::toInt16(&szBuffer[2 + unitId * 4]);
diff --git a/SourceCode/Bond/Servo/CEqStatusStep.h b/SourceCode/Bond/Servo/CEqStatusStep.h
index 3423e84..78aaa2c 100644
--- a/SourceCode/Bond/Servo/CEqStatusStep.h
+++ b/SourceCode/Bond/Servo/CEqStatusStep.h
@@ -18,11 +18,14 @@
virtual int onComplete();
virtual int onTimeout();
void setStatusDev(int nDev);
+ unsigned int getUnitId() const;
int getStatus(unsigned int uint);
+ int getReasonCode(unsigned int uint) const;
std::string& getStatusDescription(unsigned int unid, std::string& strDescription);
private:
int m_nStatusDev;
+ unsigned int m_nUnitId;
int m_nStatus[STATUS_MAX];
int m_nReasonCode[STATUS_MAX];
};
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index 36217c3..4d39fbb 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -779,6 +779,16 @@
return 1;
}
+ else if (pStep->getName().compare(STEP_STATUS) == 0) {
+ SERVO::CEqStatusStep* pEqStatusStep = (SERVO::CEqStatusStep*)pStep;
+ if (m_listener.onEqStatusChanged != nullptr) {
+ const unsigned int unitId = pEqStatusStep->getUnitId();
+ const int status = pEqStatusStep->getStatus(unitId);
+ const int reason = pEqStatusStep->getReasonCode(unitId);
+ m_listener.onEqStatusChanged(this, (int)unitId, status, reason);
+ }
+ return 1;
+ }
else if (isCimMessageConfirmStep(pStep)) {
SERVO::CEqReadIntStep* pEqReadIntStep = (SERVO::CEqReadIntStep*)pStep;
int value = pEqReadIntStep->getValue();
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index 0ed9452..e59fa8a 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -61,6 +61,7 @@
typedef std::function<void(void* pEiuipment, const std::vector<CParam>& params)> ONPROCESSDATAREPORT;
typedef std::function<void(void* pEiuipment, int port, CJobDataS* pJobDataS)> ONRECEIVEDJOB;
typedef std::function<void(void* pEiuipment, int port, CJobDataS* pJobDataS)> ONSENTOUTJOB;
+ typedef std::function<void(void* pEiuipment, int unitId, int status, int reason)> ONEQSTATUSCHANGED;
typedef struct _EquipmentListener
{
@@ -79,6 +80,7 @@
ONPROCESSDATAREPORT onProcessDataReport;
ONRECEIVEDJOB onReceivedJob;
ONSENTOUTJOB onSentOutJob;
+ ONEQSTATUSCHANGED onEqStatusChanged;
} EquipmentListener;
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index bd2e9ab..13146b8 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -1935,6 +1935,11 @@
m_listener.onJobSentOut(this, (CEquipment*)pEquipment, port, pJobDataS);
}
};
+ listener.onEqStatusChanged = [&](void* pEquipment, int unitId, int status, int reason) {
+ if (m_listener.onEqStatusChanged != nullptr) {
+ m_listener.onEqStatusChanged(this, (CEquipment*)pEquipment, unitId, status, reason);
+ }
+ };
pEquipment->setListener(listener);
pEquipment->setCcLink(&m_cclink);
m_listEquipment.push_back(pEquipment);
diff --git a/SourceCode/Bond/Servo/CMaster.h b/SourceCode/Bond/Servo/CMaster.h
index 3db1a19..2e9c280 100644
--- a/SourceCode/Bond/Servo/CMaster.h
+++ b/SourceCode/Bond/Servo/CMaster.h
@@ -72,6 +72,7 @@
typedef std::function<void(void* pMaster, CEquipment* pEquipment, const std::vector<CParam>& params)> ONSVDATAREPORT;
typedef std::function<void(void* pMaster, CEquipment* pEquipment, int port, CJobDataS* pJobDataS)> ONJOBRECEIVED;
typedef std::function<void(void* pMaster, CEquipment* pEquipment, int port, CJobDataS* pJobDataS)> ONJOBSENTOUT;
+ typedef std::function<void(void* pMaster, CEquipment* pEquipment, int unitId, int status, int reason)> ONEQSTATUSCHANGED;
typedef std::function<void(void* pMaster, int round)> ONCTROUNDEND;
typedef std::function<void(void* pMaster, void* pj)> ONPJSTART;
typedef std::function<void(void* pMaster)> ONCONTROLJOBCHANGED;
@@ -90,6 +91,7 @@
ONPROCESSDATAREPORTEX onProcessDataReport;
ONJOBRECEIVED onJobReceived;
ONJOBSENTOUT onJobSentOut;
+ ONEQSTATUSCHANGED onEqStatusChanged;
ONCTROUNDEND onCTRoundEnd;
ONPJSTART onCjStart;
ONPJSTART onCjEnd;
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index e5afc98..2c1b261 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -813,11 +813,6 @@
// SubEqp events (per equipment, ignore slot distinction except payload)
static std::map<int, SERVO::PROCESS_STATE> s_prevSubEqpState;
- const auto prevEqState = s_prevSubEqpState[eqId];
- if (prevEqState != state) {
- // state change
- m_hsmsPassive.requestEventReportSend("SubEqpStateChange");
- }
if (state == SERVO::PROCESS_STATE::Processing) {
m_hsmsPassive.requestEventReportSend_SubEqpStart();
}
@@ -841,6 +836,16 @@
}
});
};
+ masterListener.onEqStatusChanged = [&](void* pMaster, SERVO::CEquipment* pEquipment, int unitId, int status, int reason) {
+ (void)pMaster;
+ if (pEquipment == nullptr) return;
+ m_hsmsPassive.withVariableLock([&] {
+ m_hsmsPassive.setVariableValue("SubEqpName", pEquipment->getName().c_str());
+ m_hsmsPassive.setVariableValue("SubEqpSlot", unitId);
+ m_hsmsPassive.setVariableValue("EquipmentStatus", (__int64)status);
+ m_hsmsPassive.requestEventReportSend("SubEqpStateChange");
+ });
+ };
masterListener.onSVDataReport = [&](void* pMaster, SERVO::CEquipment* pEquipment, const std::vector<CParam>& params) {
(void)pMaster;
const int eqId = pEquipment ? pEquipment->getID() : 0;
diff --git a/SourceCode/Bond/x64/Debug/ReportList.txt b/SourceCode/Bond/x64/Debug/ReportList.txt
index b4d31bc..7ec2058 100644
--- a/SourceCode/Bond/x64/Debug/ReportList.txt
+++ b/SourceCode/Bond/x64/Debug/ReportList.txt
@@ -49,7 +49,7 @@
67000,(500,5018,5019,6700,6701,6702,6703)
10015,(5018,5019)
10016,(5018,5019)
-10017,(500,5018,5019)
+10017,(500,5018,5019,5024)
12000,(500,5018,5019)
12001,(500,5018,5019)
12002,(500,5018,5019)
diff --git a/SourceCode/Bond/x64/Debug/VariableList.txt b/SourceCode/Bond/x64/Debug/VariableList.txt
index 06499c8..cf7d8fe 100644
--- a/SourceCode/Bond/x64/Debug/VariableList.txt
+++ b/SourceCode/Bond/x64/Debug/VariableList.txt
@@ -40,3 +40,5 @@
5021,PortState,U1,Port transfer/state code for PortStateChange
5022,PortId,U1,Unified port ID for all Port events
5023,MaterialId,A50,Material/Glass ID for Received/SentOut events
+5024,EquipmentStatus,U1,Equipment status (SubEqpStateChange): 1=PM;2=Down(BM);3=Pause;4=Idle;5=Run;6=Job Change;7=ETC
+
--
Gitblit v1.9.3