From 2d7e131c2e7f547df8d5e0d56fcea85cd49c712e Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 21 二月 2025 14:17:15 +0800
Subject: [PATCH] 1.增加Equipment Status(机器和机器单元状态)获取;
---
SourceCode/Bond/Servo/CEqStatusStep.h | 28 +++++++
SourceCode/Bond/Servo/CEqModeStep.cpp | 14 ++-
SourceCode/Bond/Servo/Servo.vcxproj | 2
SourceCode/Bond/Servo/Servo.vcxproj.filters | 2
SourceCode/Bond/Servo/CEqStatusStep.cpp | 122 ++++++++++++++++++++++++++++++
SourceCode/Bond/Servo/CEquipment.cpp | 11 ++
SourceCode/Bond/Servo/CMaster.cpp | 8 ++
SourceCode/Bond/Servo/CEquipment.h | 1
8 files changed, 181 insertions(+), 7 deletions(-)
diff --git a/SourceCode/Bond/Servo/CEqModeStep.cpp b/SourceCode/Bond/Servo/CEqModeStep.cpp
index e869c74..149075d 100644
--- a/SourceCode/Bond/Servo/CEqModeStep.cpp
+++ b/SourceCode/Bond/Servo/CEqModeStep.cpp
@@ -20,11 +20,14 @@
CStep::onReadData();
DWordContainer dc;
- m_pCclink->ReadDWordData(m_station, DeviceType::W, m_nModeDev, 1, dc);
- m_nMode = dc.at(0);
- std::string strTemp;
- LOGI("<CEqModeStep> Equipment Mode Changed<%s>\n",
- getModeDescription(strTemp).c_str());
+ if (0 == m_pCclink->ReadDWordData(m_station, DeviceType::W, m_nModeDev, 1, dc)
+ && dc.size() >= 1) {
+ m_nMode = dc.at(0);
+ std::string strTemp;
+ LOGI("<CEqModeStep> Equipment Mode Changed<%s>\n",
+ getModeDescription(strTemp).c_str());
+ }
+
return 0;
}
@@ -58,7 +61,6 @@
4 : Cold Run Mode
5 : ETC."
*/
-
std::string& CEqModeStep::getModeDescription(std::string& strDescription)
{
switch (m_nMode) {
diff --git a/SourceCode/Bond/Servo/CEqStatusStep.cpp b/SourceCode/Bond/Servo/CEqStatusStep.cpp
new file mode 100644
index 0000000..edf4572
--- /dev/null
+++ b/SourceCode/Bond/Servo/CEqStatusStep.cpp
@@ -0,0 +1,122 @@
+#include "stdafx.h"
+#include "CEqStatusStep.h"
+#include "Log.h"
+#include "ToolUnits.h"
+
+
+namespace SERVO {
+ CEqStatusStep::CEqStatusStep() : CStep()
+ {
+ m_nStatusDev = 0;
+ for (int i = 0; i < STATUS_MAX; i++) {
+ m_nStatus[i] = 7;
+ m_nReasonCode[i] = 0;
+ }
+
+
+ }
+
+ CEqStatusStep::~CEqStatusStep()
+ {
+
+ }
+
+ int CEqStatusStep::onReadData()
+ {
+ CStep::onReadData();
+
+ char szBuffer[64];
+ int nRet = m_pCclink->ReadData2(m_station, DeviceType::W,
+ m_nStatusDev, 64, szBuffer);
+ if (0 == nRet) {
+ unsigned int unitId = (unsigned int)CToolUnits::toInt16(&szBuffer[0]);
+ if (unitId < STATUS_MAX) {
+ if (unitId == 0) {
+ m_nStatus[unitId] = CToolUnits::toInt16(&szBuffer[2 + unitId * 4]);
+ m_nReasonCode[unitId] = CToolUnits::toInt16(&szBuffer[2 + unitId * 4 + 2]);
+ }
+ else {
+ m_nStatus[unitId] = CToolUnits::toInt16(&szBuffer[2 + 3 * 2 + unitId * 4]);
+ m_nReasonCode[unitId] = CToolUnits::toInt16(&szBuffer[2 + 3 * 2 + unitId * 4 + 2]);
+ }
+
+ for (int i = 0; i < 64; i++) {
+ TRACE("bbb %d, %x\n", i, szBuffer[i]);
+ }
+ TRACE("cccc %d %d %d\n", unitId, m_nStatus[unitId], m_nReasonCode[unitId]);
+ std::string strTemp;
+ LOGI("<CEqStatusStep> Equipment Status Changed<Unit:%d, %s, ReasonCode=%d>\n",
+ unitId, getStatusDescription(unitId, strTemp).c_str(), m_nReasonCode[unitId]);
+ }
+ }
+
+
+ return 0;
+ }
+
+ int CEqStatusStep::onComplete()
+ {
+ CStep::onComplete();
+ LOGI("<CEqStatusStep> onComplete.");
+
+ return 0;
+ }
+
+ int CEqStatusStep::onTimeout()
+ {
+ CStep::onTimeout();
+ LOGI("<CEqStatusStep> onTimeout.");
+
+ return 0;
+ }
+
+ void CEqStatusStep::setStatusDev(int nDev)
+ {
+ m_nStatusDev = nDev;
+ }
+
+ /*
+ Lower (1byte, 0~7) : Status
+ 1 : PM
+ 2 : Down(BM)
+ 3 : Pause
+ 4 : Idle
+ 5: Run
+ 6: Job Change
+ 7 : ETC
+ */
+ std::string& CEqStatusStep::getStatusDescription(unsigned int unid, std::string& strDescription)
+ {
+ if (unid < STATUS_MAX) {
+ switch (m_nStatus[unid]) {
+ case 1:
+ strDescription = _T("PM");
+ break;
+ case 2:
+ strDescription = _T("Down(BM)");
+ break;
+ case 3:
+ strDescription = _T("Pause");
+ break;
+ case 4:
+ strDescription = _T("Idle");
+ break;
+ case 5:
+ strDescription = _T("Run");
+ break;
+ case 6:
+ strDescription = _T("Job Change");
+ break;
+ case 7:
+ strDescription = _T("ETC");
+ break;
+ default:
+ strDescription = _T("");
+ break;
+ }
+ }
+
+
+ return strDescription;
+ }
+}
diff --git a/SourceCode/Bond/Servo/CEqStatusStep.h b/SourceCode/Bond/Servo/CEqStatusStep.h
new file mode 100644
index 0000000..09fc8f4
--- /dev/null
+++ b/SourceCode/Bond/Servo/CEqStatusStep.h
@@ -0,0 +1,28 @@
+#pragma once
+#include "CStep.h"
+
+
+namespace SERVO {
+#define UNIT_MAX 6
+#define STATUS_MAX (UNIT_MAX + 1)
+
+ class CEqStatusStep : public CStep
+ {
+ public:
+ CEqStatusStep();
+ ~CEqStatusStep();
+
+ public:
+ virtual int onReadData();
+ virtual int onComplete();
+ virtual int onTimeout();
+ void setStatusDev(int nDev);
+ std::string& getStatusDescription(unsigned int unid, std::string& strDescription);
+
+ private:
+ int m_nStatusDev;
+ 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 b435ca9..d3bc8da 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -240,11 +240,20 @@
// 以下根据信号做流程处理
+ CStep* pStep;
// Equipment Mode Change Report
index = 0x360;
bFlag = isBitOn(pszData, size, index);
- CStep* pStep = getStep(0x360);
+ pStep = getStep(index);
+ if (pStep != nullptr) {
+ pStep->onSignal(bFlag);
+ }
+
+ // Equipment Status Change Report
+ index = 0x361;
+ bFlag = isBitOn(pszData, size, index);
+ pStep = getStep(index);
if (pStep != nullptr) {
pStep->onSignal(bFlag);
}
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index a19fcca..c10084a 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -2,6 +2,7 @@
#include "Log.h"
#include "CCLinkIEControl.h"
#include "CEqModeStep.h"
+#include "CEqStatusStep.h"
#include <map>
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 70cb1b8..248d0dc 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -81,6 +81,14 @@
delete pStep;
}
}
+ {
+ CEqStatusStep* pStep = new CEqStatusStep();
+ pStep->setWriteSignalDev(0x31);
+ pStep->setStatusDev(0x4a68);
+ if (pEquipment->addStep(0x361, pStep) != 0) {
+ delete pStep;
+ }
+ }
pEquipment->init();
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj b/SourceCode/Bond/Servo/Servo.vcxproj
index 3e215be..a607a04 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj
+++ b/SourceCode/Bond/Servo/Servo.vcxproj
@@ -201,6 +201,7 @@
<ClInclude Include="CCLinkPerformance\CCLinkIEControl.h" />
<ClInclude Include="CCLinkPerformance\PerformanceMelsec.h" />
<ClInclude Include="CEqModeStep.h" />
+ <ClInclude Include="CEqStatusStep.h" />
<ClInclude Include="CStep.h" />
<ClInclude Include="DevicePropertyDlg.h" />
<ClInclude Include="CEFEM.h" />
@@ -233,6 +234,7 @@
<ClCompile Include="CCLinkPerformance\CCLinkIEControl.cpp" />
<ClCompile Include="CCLinkPerformance\PerformanceMelsec.cpp" />
<ClCompile Include="CEqModeStep.cpp" />
+ <ClCompile Include="CEqStatusStep.cpp" />
<ClCompile Include="CStep.cpp" />
<ClCompile Include="DevicePropertyDlg.cpp" />
<ClCompile Include="CEFEM.cpp" />
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj.filters b/SourceCode/Bond/Servo/Servo.vcxproj.filters
index 1580241..ae2ad88 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj.filters
+++ b/SourceCode/Bond/Servo/Servo.vcxproj.filters
@@ -38,6 +38,7 @@
<ClCompile Include="DevicePropertyDlg.cpp" />
<ClCompile Include="CStep.cpp" />
<ClCompile Include="CEqModeStep.cpp" />
+ <ClCompile Include="CEqStatusStep.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AlarmManager.h" />
@@ -74,6 +75,7 @@
<ClInclude Include="DevicePropertyDlg.h" />
<ClInclude Include="CStep.h" />
<ClInclude Include="CEqModeStep.h" />
+ <ClInclude Include="CEqStatusStep.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Servo.rc" />
--
Gitblit v1.9.3