From 9d3e2ee8831bdd443bce96590fc023b8af5c790a Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 25 三月 2025 16:51:02 +0800
Subject: [PATCH] 1.为Glass增加移动路线记录,便于物料生产追踪,数据保存分析等;
---
SourceCode/Bond/Servo/CPageGraph2.cpp | 13 ++
SourceCode/Bond/Servo/CPath.h | 33 ++++++
SourceCode/Bond/Servo/Servo.vcxproj | 2
SourceCode/Bond/Servo/Servo.vcxproj.filters | 2
SourceCode/Bond/Servo/resource.h | 0
SourceCode/Bond/Servo/CGlass.cpp | 50 +++++++++
SourceCode/Bond/Servo/CEquipment.cpp | 19 +++
SourceCode/Bond/Servo/CGlass.h | 5 +
SourceCode/Bond/Servo/CPath.cpp | 125 +++++++++++++++++++++++++
SourceCode/Bond/Servo/Servo.rc | 0
SourceCode/Bond/Servo/CEquipment.h | 1
SourceCode/Bond/Servo/ServoDlg.cpp | 2
12 files changed, 249 insertions(+), 3 deletions(-)
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index 0633bf2..a52da00 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -548,6 +548,7 @@
// 模拟取出第一张Panel,传送到下一环节
+ ULONGLONG time = CToolUnits::getTimestamp();
Lock();
if (m_glassList.empty()) {
Unlock();
@@ -562,6 +563,10 @@
LOGE("<CEquipment>对方拒绝接收Intent.");
}
else if (nRet == FLOW_ACCEPT) {
+ CPath* pPath = pContext->getPathWithSiteID(m_nID);
+ if (pPath != nullptr) {
+ pPath->setOutTime(time);
+ }
m_glassList.pop_front();
pContext->release(); // 添加到列队时addRef, 取出时release
if (m_listener.onDataChanged != nullptr) {
@@ -583,6 +588,7 @@
int CEquipment::glassArrived(CGlass* pGlass)
{
Lock();
+ pGlass->addPath(m_nID);
pGlass->addRef();
m_glassList.push_back(pGlass);
Unlock();
@@ -607,4 +613,17 @@
m_listener.onDataChanged(this, 0);
}
}
+
+ CGlass* CEquipment::getFrontGlass()
+ {
+ CGlass* pGlass = nullptr;
+
+ Lock();
+ if (!m_glassList.empty()) {
+ pGlass = m_glassList.front();
+ }
+ Unlock();
+
+ return pGlass;
+ }
}
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index 60c3490..af939bf 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -94,6 +94,7 @@
virtual BOOL glassWillArrive(CGlass* pGlass);
virtual int outputGlass(int port);
virtual int glassArrived(CGlass* pGlass);
+ CGlass* getFrontGlass();
// 以下为从CC-Link读取到的Bit标志位检测函数
public:
diff --git a/SourceCode/Bond/Servo/CGlass.cpp b/SourceCode/Bond/Servo/CGlass.cpp
index e9847f9..a21bd7b 100644
--- a/SourceCode/Bond/Servo/CGlass.cpp
+++ b/SourceCode/Bond/Servo/CGlass.cpp
@@ -5,12 +5,18 @@
namespace SERVO {
CGlass::CGlass()
{
-
+ m_pPath = nullptr;
}
CGlass::~CGlass()
{
-
+ CPath* pPath = m_pPath;
+ while (pPath != nullptr) {
+ CPath* pTemp = pPath->getNext();
+ delete pPath;
+ pPath = pTemp;
+ }
+ m_pPath = nullptr;
}
std::string& CGlass::getClassName()
@@ -39,18 +45,58 @@
return m_strID;
}
+ CPath* CGlass::getPathWithSiteID(unsigned int nSiteId)
+ {
+ CPath* pPath = m_pPath;
+ while (pPath != nullptr) {
+ if (nSiteId == pPath->getSiteID()) {
+ return pPath;
+ }
+ pPath = pPath->getNext();
+ }
+
+ return nullptr;
+ }
+
+ CPath* CGlass::getPath()
+ {
+ return m_pPath;
+ }
+
+ void CGlass::addPath(unsigned int nSiteId)
+ {
+ CPath* pPath = new CPath(nSiteId);
+ if (m_pPath == nullptr) {
+ m_pPath = pPath;
+ }
+ else {
+ m_pPath->addPath(pPath);
+ }
+ }
+
void CGlass::serialize(CArchive& ar)
{
if (ar.IsStoring())
{
Lock();
WriteString(ar, m_strID);
+ ar << (ULONGLONG)m_pPath;
+ if (m_pPath != nullptr) {
+ m_pPath->serialize(ar);
+ }
Unlock();
}
else
{
Lock();
ReadString(ar, m_strID);
+ ULONGLONG ullPath;
+ ar >> ullPath;
+ if (ullPath != 0) {
+ m_pPath = new CPath();
+ m_pPath->serialize(ar);
+ }
+
Unlock();
}
}
diff --git a/SourceCode/Bond/Servo/CGlass.h b/SourceCode/Bond/Servo/CGlass.h
index fe5a704..e19a9a6 100644
--- a/SourceCode/Bond/Servo/CGlass.h
+++ b/SourceCode/Bond/Servo/CGlass.h
@@ -1,6 +1,7 @@
#pragma once
#include "Context.h"
#include <string>
+#include "CPath.h"
namespace SERVO {
@@ -15,10 +16,14 @@
virtual std::string toString();
void setID(const char* pszID);
std::string& getID();
+ CPath* getPathWithSiteID(unsigned int nSiteId);
+ CPath* getPath();
+ void addPath(unsigned int nSiteId);
void serialize(CArchive& ar);
private:
std::string m_strID;
+ CPath* m_pPath;
};
}
diff --git a/SourceCode/Bond/Servo/CPageGraph2.cpp b/SourceCode/Bond/Servo/CPageGraph2.cpp
index f29a3bb..c7eab0e 100644
--- a/SourceCode/Bond/Servo/CPageGraph2.cpp
+++ b/SourceCode/Bond/Servo/CPageGraph2.cpp
@@ -130,6 +130,19 @@
SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
pEquipment->outputGlass(1);
}
+ else if (nCmd == ID_EQSGRAPHITEM_TEST3) {
+ SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
+ SERVO::CGlass* pGlass = pEquipment->getFrontGlass();
+ if (pGlass != nullptr) {
+ std::string strDescription;
+ SERVO::CPath* pPath = pGlass->getPath();
+ while (pPath != nullptr) {
+ pPath->getDescription(strDescription);
+ AfxMessageBox(strDescription.c_str());
+ pPath = pPath->getNext();
+ }
+ }
+ }
return true;
diff --git a/SourceCode/Bond/Servo/CPath.cpp b/SourceCode/Bond/Servo/CPath.cpp
new file mode 100644
index 0000000..30c004c
--- /dev/null
+++ b/SourceCode/Bond/Servo/CPath.cpp
@@ -0,0 +1,125 @@
+#include "stdafx.h"
+#include "CPath.h"
+#include "ToolUnits.h"
+
+
+namespace SERVO {
+ CPath::CPath()
+ {
+ m_nSiteID = 0;
+ m_timeOut = 0;
+ m_timeIn = CToolUnits::getTimestamp();
+ m_pPrev = nullptr;
+ m_pNext = nullptr;
+ }
+
+ CPath::CPath(unsigned int nSiteId)
+ {
+ m_nSiteID = nSiteId;
+ m_timeOut = 0;
+ m_timeIn = CToolUnits::getTimestamp();
+ m_pPrev = nullptr;
+ m_pNext = nullptr;
+ }
+
+ CPath::~CPath()
+ {
+
+ }
+
+ void CPath::getDescription(std::string& strOut)
+ {
+ strOut.clear();
+ strOut = "CPath<SiteID:";
+ strOut = strOut + std::to_string(m_nSiteID);
+ strOut = strOut + ",InTime:";
+ strOut = strOut + CToolUnits::timeToString2(m_timeIn);
+ strOut = strOut + ",OutTime:";
+ strOut = strOut + (m_timeOut == 0 ? "" : CToolUnits::timeToString2(m_timeOut));
+ strOut = strOut + ">";
+ }
+
+ void CPath::serialize(CArchive& ar)
+ {
+ if (ar.IsStoring()) {
+ ar << m_nSiteID;
+ ar << m_timeIn;
+ ar << m_timeOut;
+ ar << (ULONGLONG)m_pNext;
+ if (m_pNext != nullptr) {
+ m_pNext->serialize(ar);
+ }
+ }
+ else {
+ ar >> m_nSiteID;
+ ar >> m_timeIn;
+ ar >> m_timeOut;
+ ULONGLONG ulNext;
+ ar >> ulNext;
+ if ((CPath*)ulNext != nullptr) {
+ CPath* pPath = new CPath();
+ pPath->serialize(ar);
+ pPath->m_pPrev = this;
+ this->m_pNext = pPath;
+ }
+ }
+ }
+
+ unsigned int CPath::getSiteID()
+ {
+ return m_nSiteID;
+ }
+
+ ULONGLONG CPath::getInTime()
+ {
+ return m_timeIn;
+ }
+
+ void CPath::setOutTime(ULONGLONG time)
+ {
+ m_timeOut = time;
+ }
+
+ ULONGLONG CPath::getOutTime()
+ {
+ return m_timeOut;
+ }
+
+ CPath* CPath::getPrev()
+ {
+ return m_pPrev;
+ }
+
+ CPath* CPath::getNext()
+ {
+ return m_pNext;
+ }
+
+ void CPath::addPath(CPath* pPath)
+ {
+ CPath* pTail = getTailPath();
+ ASSERT(pTail);
+ pTail->m_pNext = pPath;
+ pPath->m_pPrev = this;
+ }
+
+ CPath* CPath::getTailPath()
+ {
+ CPath* pPath = this;
+ while (pPath->m_pNext != nullptr) {
+ pPath = pPath->m_pNext;
+ }
+
+ return pPath;
+ }
+
+ CPath* CPath::getHeadPath()
+ {
+ CPath* pPath = this;
+ while (pPath->m_pPrev != nullptr) {
+ pPath = pPath->m_pPrev;
+ }
+
+ return pPath;
+ }
+}
diff --git a/SourceCode/Bond/Servo/CPath.h b/SourceCode/Bond/Servo/CPath.h
new file mode 100644
index 0000000..b9dcf5f
--- /dev/null
+++ b/SourceCode/Bond/Servo/CPath.h
@@ -0,0 +1,33 @@
+#pragma once
+
+
+namespace SERVO {
+ class CPath
+ {
+ public:
+ CPath();
+ CPath(unsigned int nSiteId);
+ ~CPath();
+
+ public:
+ void getDescription(std::string& strOut);
+ void serialize(CArchive& ar);
+ CPath* getPrev();
+ CPath* getNext();
+ void addPath(CPath* pPath);
+ CPath* getTailPath();
+ CPath* getHeadPath();
+ unsigned int getSiteID();
+ ULONGLONG getInTime();
+ void setOutTime(ULONGLONG time);
+ ULONGLONG getOutTime();
+
+ private:
+ unsigned int m_nSiteID;
+ ULONGLONG m_timeIn;
+ ULONGLONG m_timeOut;
+ CPath* m_pPrev;
+ CPath* m_pNext;
+ };
+}
+
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index cf09ebc..6e6df40 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj b/SourceCode/Bond/Servo/Servo.vcxproj
index 1278d72..587bb17 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj
+++ b/SourceCode/Bond/Servo/Servo.vcxproj
@@ -226,6 +226,7 @@
<ClInclude Include="CPanelAttributes.h" />
<ClInclude Include="CPanelEquipment.h" />
<ClInclude Include="CPanelMaster.h" />
+ <ClInclude Include="CPath.h" />
<ClInclude Include="CPin.h" />
<ClInclude Include="CReadStep.h" />
<ClInclude Include="CSample.h" />
@@ -294,6 +295,7 @@
<ClCompile Include="CPanelAttributes.cpp" />
<ClCompile Include="CPanelEquipment.cpp" />
<ClCompile Include="CPanelMaster.cpp" />
+ <ClCompile Include="CPath.cpp" />
<ClCompile Include="CPin.cpp" />
<ClCompile Include="CReadStep.cpp" />
<ClCompile Include="CSample.cpp" />
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj.filters b/SourceCode/Bond/Servo/Servo.vcxproj.filters
index ef39ee3..ba1c6a6 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj.filters
+++ b/SourceCode/Bond/Servo/Servo.vcxproj.filters
@@ -74,6 +74,7 @@
<ClCompile Include="CPageGraph1.cpp" />
<ClCompile Include="CPageGraph2.cpp" />
<ClCompile Include="CGlass.cpp" />
+ <ClCompile Include="CPath.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AlarmManager.h" />
@@ -146,6 +147,7 @@
<ClInclude Include="CPageGraph1.h" />
<ClInclude Include="CPageGraph2.h" />
<ClInclude Include="CGlass.h" />
+ <ClInclude Include="CPath.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Servo.rc" />
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index 5d96844..28bbd95 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -218,7 +218,7 @@
SetIcon(m_hIcon, FALSE); // 设置小图标
- // 菜单
+ // 菜单
CMenu menu;
menu.LoadMenu(IDR_MENU_APP);
SetMenu(&menu);
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index 3f54a12..90b9c2f 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ
--
Gitblit v1.9.3