From fd1333fbf52e00ff8f0b0d51ec0d707a66cc9141 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 16 六月 2025 11:20:16 +0800
Subject: [PATCH] 1.Robot状态和位置的监控,其中两个arm状态(是否有料),也作为调度的依据。
---
SourceCode/Bond/Servo/CLoadPort.cpp | 301 +++++++++++++++++++++++++++++++------------------
1 files changed, 190 insertions(+), 111 deletions(-)
diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index a61e86e..9e51641 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -17,7 +17,7 @@
{
m_nIndex = 0;
m_portType = PortType::Loading;
- m_portMode = PortMode::InService;
+ m_portMode = PortMode::ReadyToLoad;
m_cassetteType = CassetteType::G1;
m_transferMode = TransferMode::AGVMode;
m_bEnable = FALSE;
@@ -51,8 +51,36 @@
// 加入Pin初始化代码
LOGI("<CLoadPort>initPins");
addPin(SERVO::PinType::INPUT, _T("In"));
- addPin(SERVO::PinType::OUTPUT, _T("Out1"));
- addPin(SERVO::PinType::OUTPUT, _T("Out2"));
+ addPin(SERVO::PinType::OUTPUT, _T("Out"));
+ }
+
+ // 必须要实现的虚函数,在此初始化Slot信息
+ void CLoadPort::initSlots()
+ {
+ m_slot[0].enable();
+ m_slot[0].setPosition(m_nID);
+ m_slot[0].setNo(1);
+ m_slot[0].setName("Slot 1");
+ m_slot[1].enable();
+ m_slot[1].setPosition(m_nID);
+ m_slot[1].setNo(2);
+ m_slot[1].setName("Slot 2");
+ m_slot[2].setPosition(m_nID);
+ m_slot[2].enable();
+ m_slot[2].setNo(3);
+ m_slot[2].setName("Slot 3");
+ m_slot[3].setPosition(m_nID);
+ m_slot[3].enable();
+ m_slot[3].setNo(4);
+ m_slot[3].setName("Slot 4");
+ m_slot[4].setPosition(m_nID);
+ m_slot[4].enable();
+ m_slot[4].setNo(5);
+ m_slot[4].setName("Slot 5");
+ m_slot[5].setPosition(m_nID);
+ m_slot[5].enable();
+ m_slot[5].setNo(6);
+ m_slot[5].setName("Slot 6");
}
void CLoadPort::initSteps()
@@ -347,6 +375,28 @@
void CLoadPort::serialize(CArchive& ar)
{
CEquipment::serialize(ar);
+
+ if (ar.IsStoring()) {
+ ar << m_nIndex;
+ //ar << (int)m_portType;
+ //ar << (int)m_portMode;
+ //ar << (int)m_cassetteType;
+ //ar << (int)m_transferMode;
+ //ar << m_bEnable;
+ //ar << m_bAutoChangeEnable;
+ m_portStatusReport.serialize(ar);
+ }
+ else {
+ int temp;
+ ar >> m_nIndex;
+ //ar >> temp; m_portType = (PortType)temp;
+ //ar >> temp; m_portMode = (PortMode)temp;
+ //ar >> temp; m_cassetteType = (CassetteType)temp;
+ //ar >> temp; m_transferMode = (TransferMode)temp;
+ //ar >> m_bEnable;
+ //ar >> m_bAutoChangeEnable;
+ m_portStatusReport.serialize(ar);
+ }
}
void CLoadPort::getAttributeVector(CAttributeVector& attrubutes)
@@ -374,21 +424,6 @@
int CLoadPort::recvIntent(CPin* pPin, CIntent* pIntent)
{
return __super::recvIntent(pPin, pIntent);
- }
-
- int CLoadPort::outputGlass(int port)
- {
- return __super::outputGlass(port);
- }
-
- BOOL CLoadPort::glassWillArrive(CGlass* pGlass)
- {
- BOOL bRet = __super::glassWillArrive(pGlass);
- if (!bRet) {
- return FALSE;
- }
-
- return (m_glassList.size() < 8);
}
int CLoadPort::sendCassetteCtrlCmd(short cmd,
@@ -877,21 +912,22 @@
LOGI("<CLoadPort-%d>准备设置Port type<%d>", m_nIndex, (int)type);
short value = (short)type;
- if (onWritedBlock != nullptr) {
- pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
- }
- else {
- pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
- if (code == WOK) {
- LOGI("<CLoadPort-%d>设置Port type成功.", m_nIndex);
- }
- else {
- LOGI("<CLoadPort-%d>设置Port type失败,code:%d", m_nIndex, code);
- }
+ pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
+ // test
+ code = WOK;
+ if (code == WOK) {
+ m_portType = type;
+ LOGI("<CLoadPort-%d>设置Port type成功.", m_nIndex);
+ }
+ else {
+ LOGI("<CLoadPort-%d>设置Port type失败,code:%d", m_nIndex, code);
+ }
+ if (onWritedBlock != nullptr) {
+ return onWritedBlock(code);
+ }
- return 0;
- });
- }
+ return 0;
+ });
return 0;
}
@@ -906,21 +942,21 @@
LOGI("<CLoadPort-%d>准备%s Port", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
short value = bEnable ? 1 : 2;
- if (onWritedBlock != nullptr) {
- pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
- }
- else {
- pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
- if (code == WOK) {
- LOGI("<CLoadPort-%d>%s Port成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
- }
- else {
- LOGI("<CLoadPort-%d>%s Port失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
- }
-
- return 0;
- });
- }
+ pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
+ // test
+ code = WOK;
+ if (code == WOK) {
+ m_bEnable = bEnable;
+ LOGI("<CLoadPort-%d>%s Port成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
+ }
+ else {
+ LOGI("<CLoadPort-%d>%s Port失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
+ }
+ if (onWritedBlock != nullptr) {
+ return onWritedBlock(code);
+ }
+ return 0;
+ });
return 0;
}
@@ -935,21 +971,21 @@
LOGI("<CLoadPort-%d>准备设置Port mode<%d>", m_nIndex, (int)mode);
short value = (short)mode;
- if (onWritedBlock != nullptr) {
- pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
- }
- else {
- pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
- if (code == WOK) {
- LOGI("<CLoadPort-%d>设置Port mode成功.", m_nIndex);
- }
- else {
- LOGI("<CLoadPort-%d>设置Port mode失败,code:%d", m_nIndex, code);
- }
-
- return 0;
- });
- }
+ pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
+ // test
+ code = WOK;
+ if (code == WOK) {
+ m_portMode = mode;
+ LOGI("<CLoadPort-%d>设置Port mode成功.", m_nIndex);
+ }
+ else {
+ LOGI("<CLoadPort-%d>设置Port mode失败,code:%d", m_nIndex, code);
+ }
+ if (onWritedBlock != nullptr) {
+ return onWritedBlock(code);
+ }
+ return 0;
+ });
return 0;
}
@@ -964,21 +1000,21 @@
LOGI("<CLoadPort-%d>准备设置Cassette Type<%d>", m_nIndex, (int)type);
short value = (short)type;
- if (onWritedBlock != nullptr) {
- pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
- }
- else {
- pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
- if (code == WOK) {
- LOGI("<CLoadPort-%d>设置Cassette Type成功.", m_nIndex);
- }
- else {
- LOGI("<CLoadPort-%d>设置Cassette Type失败,code:%d", m_nIndex, code);
- }
-
- return 0;
- });
- }
+ pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
+ // test
+ code = WOK;
+ if (code == WOK) {
+ m_cassetteType = type;
+ LOGI("<CLoadPort-%d>设置Cassette Type成功.", m_nIndex);
+ }
+ else {
+ LOGI("<CLoadPort-%d>设置Cassette Type失败,code:%d", m_nIndex, code);
+ }
+ if (onWritedBlock != nullptr) {
+ return onWritedBlock(code);
+ }
+ return 0;
+ });
return 0;
}
@@ -993,21 +1029,21 @@
LOGI("<CLoadPort-%d>准备设置Transfer mode<%d>", m_nIndex, (int)mode);
short value = (short)mode;
- if (onWritedBlock != nullptr) {
- pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
- }
- else {
- pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
- if (code == WOK) {
- LOGI("<CLoadPort-%d>设置Transfer mode成功.", m_nIndex + 1);
- }
- else {
- LOGI("<CLoadPort-%d>设置Transfer mode失败,code:%d", m_nIndex + 1, code);
- }
-
- return 0;
- });
- }
+ pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
+ // test
+ code = WOK;
+ if (code == WOK) {
+ m_transferMode = mode;
+ LOGI("<CLoadPort-%d>设置Transfer mode成功.", m_nIndex + 1);
+ }
+ else {
+ LOGI("<CLoadPort-%d>设置Transfer mode失败,code:%d", m_nIndex + 1, code);
+ }
+ if (onWritedBlock != nullptr) {
+ return onWritedBlock(code);
+ }
+ return 0;
+ });
return 0;
}
@@ -1022,33 +1058,68 @@
LOGI("<CLoadPort-%d>准备%s Auto Change", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
short value = bEnable ? 1 : 2;
- if (onWritedBlock != nullptr) {
- pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
- }
- else {
- pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
- if (code == WOK) {
- LOGI("<CLoadPort-%d>%s Auto Change成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
- }
- else {
- LOGI("<CLoadPort-%d>%s Auto Change失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
- }
-
- return 0;
- });
- }
+ pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
+ // test
+ code = WOK;
+ if (code == WOK) {
+ m_bAutoChangeEnable = bEnable;
+ LOGI("<CLoadPort-%d>%s Auto Change成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
+ }
+ else {
+ LOGI("<CLoadPort-%d>%s Auto Change失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
+ }
+ if (onWritedBlock != nullptr) {
+ return onWritedBlock(code);
+ }
+ return 0;
+ });
return 0;
+ }
+
+ void CLoadPort::localEanblePort(BOOL bEnable)
+ {
+ m_bEnable = bEnable;
+ }
+
+ void CLoadPort::localSetPortType(PortType type)
+ {
+ m_portType = type;
+ }
+
+ void CLoadPort::localSetPortMode(PortMode mode)
+ {
+ m_portMode = mode;
+ }
+
+ void CLoadPort::localSetCessetteType(CassetteType type)
+ {
+ m_cassetteType = type;
+ }
+
+ void CLoadPort::localSetTransferMode(TransferMode mode)
+ {
+ m_transferMode = mode;
+ }
+
+ void CLoadPort::localAutoChangeEnable(BOOL bEnable)
+ {
+ m_bAutoChangeEnable = bEnable;
}
/*
* 生成测试用的玻璃列表
*/
- int CLoadPort::testGenerateGlassList(MaterialsType type, int count, const char* pszPrefix, int startSuffix)
+ int CLoadPort::testGenerateGlassList(MaterialsType type, const char* pszPrefix, int startSuffix)
{
+ static unsigned short nJobSequenceNo = 0;
+ static unsigned short nCassetteSequenceNo = 0;
+ nCassetteSequenceNo++;
+
+
// 如果非空就不生成了
Lock();
- if (!m_glassList.empty()) {
+ if (hasGlass()) {
Unlock();
return -1;
}
@@ -1057,13 +1128,19 @@
char szBuffer[64];
int suffix = startSuffix;
- for (int i = 0; i < count; i++) {
+ for (int i = 0; i < SLOT_MAX; i++) {
+ if (!m_slot[i].isEnable()) continue;
+
CJobDataB jb;
CJobDataS js;
sprintf_s(szBuffer, "%s%d", pszPrefix, suffix++);
jb.setGlassId(szBuffer);
+ jb.setCassetteSequenceNo(nCassetteSequenceNo);
+ jb.setJobSequenceNo(++nJobSequenceNo);
js.setMaterialsType((int)type);
+ js.setCassetteSequenceNo(nCassetteSequenceNo);
+ js.setJobSequenceNo(nJobSequenceNo);
if (type == MaterialsType::G1) {
js.setGlass1Id(szBuffer);
}
@@ -1072,11 +1149,13 @@
}
CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
+ pGlass->addPath(m_nID, 0);
+ pGlass->processEnd(m_nID, 0);
pGlass->setID(szBuffer);
pGlass->setJobDataB(&jb);
pGlass->setType(type);
pGlass->setJobDataS(&js);
- addGlassToList(pGlass);
+ m_slot[i].setContext(pGlass);
}
return 0;
--
Gitblit v1.9.3