From be01318968aed5e55c511eedc6c1f72a961c3f13 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 19 六月 2025 14:49:02 +0800
Subject: [PATCH] 1.重新梳理JobDataS的传递和更新;
---
SourceCode/Bond/Servo/CLoadPort.cpp | 593 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 527 insertions(+), 66 deletions(-)
diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index c7c6040..cbae095 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -16,12 +16,13 @@
CLoadPort::CLoadPort() : CEquipment()
{
m_nIndex = 0;
- m_nType = 1;
- m_nMode = 1;
- m_nCassetteType = 1;
- m_nTransferMode = 1;
+ m_portType = PortType::Loading;
+ m_portMode = PortMode::ReadyToLoad;
+ m_cassetteType = CassetteType::G1;
+ m_transferMode = TransferMode::AGVMode;
m_bEnable = FALSE;
m_bAutoChangeEnable = FALSE;
+ m_nNextCassetteSequenceNo = 0;
}
CLoadPort::~CLoadPort()
@@ -51,8 +52,18 @@
// 加入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()
+ {
+ for (int i = 0; i < SLOT_MAX; i++) {
+ m_slot[i].enable();
+ m_slot[i].setPosition(m_nID);
+ m_slot[i].setNo(i + 1);
+ m_slot[i].setName((std::string("Slot") + std::to_string(i+1)).c_str());
+ }
}
void CLoadPort::initSteps()
@@ -82,13 +93,13 @@
// Type
static char* pszName[] = { STEP_EQ_PORT1_TYPE, STEP_EQ_PORT2_TYPE, STEP_EQ_PORT3_TYPE, STEP_EQ_PORT4_TYPE };
static int dev[] = { 0x6010 , 0x6020, 0x6030, 0x6040 };
- static int writeSignalDev[] = { 0xa0, 0xa1, 0xa2, 0xa3 };
+ static int writeSignalDev[] = { 0x90, 0x91, 0x92, 0x93 };
static int addr[] = { STEP_ID_PORT1_TYPE_CHANGE, STEP_ID_PORT2_TYPE_CHANGE, STEP_ID_PORT3_TYPE_CHANGE, STEP_ID_PORT4_TYPE_CHANGE };
CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
if (code == ROK && pszData != nullptr && size > 0) {
- m_nType = (unsigned int)CToolUnits::toInt16(pszData);
+ m_portType = (PortType)CToolUnits::toInt16(pszData);
}
return 0;
});
@@ -103,13 +114,13 @@
// Mode
static char* pszName[] = { STEP_EQ_PORT1_MODE, STEP_EQ_PORT2_MODE, STEP_EQ_PORT3_MODE, STEP_EQ_PORT4_MODE };
static int dev[] = { 0x6011, 0x6021, 0x6031, 0x6041 };
- static int writeSignalDev[] = { 0xa8, 0xa9, 0xaa, 0xab };
+ static int writeSignalDev[] = { 0x98, 0x99, 0x9a, 0x9b };
static int addr[] = { STEP_ID_PORT1_MODE_CHANGE, STEP_ID_PORT2_MODE_CHANGE, STEP_ID_PORT3_MODE_CHANGE, STEP_ID_PORT4_MODE_CHANGE };
CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
if (code == ROK && pszData != nullptr && size > 0) {
- m_nMode = (unsigned int)CToolUnits::toInt16(pszData);
+ m_portMode = (PortMode)CToolUnits::toInt16(pszData);
}
return 0;
});
@@ -124,13 +135,13 @@
// Cassette type
static char* pszName[] = { STEP_EQ_PORT1_CASSETTE_TYPE, STEP_EQ_PORT2_CASSETTE_TYPE, STEP_EQ_PORT3_CASSETTE_TYPE, STEP_EQ_PORT4_CASSETTE_TYPE };
static int dev[] = { 0x6012, 0x6022, 0x6032, 0x6042 };
- static int writeSignalDev[] = { 0xb0, 0xb1, 0xb2, 0xb3 };
+ static int writeSignalDev[] = { 0xa0, 0xa1, 0xa2, 0xa3 };
static int addr[] = { STEP_ID_PORT1_CASSETTE_TYPE_CHANGE, STEP_ID_PORT2_CASSETTE_TYPE_CHANGE, STEP_ID_PORT3_CASSETTE_TYPE_CHANGE, STEP_ID_PORT4_CASSETTE_TYPE_CHANGE };
CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
if (code == ROK && pszData != nullptr && size > 0) {
- m_nCassetteType = (unsigned int)CToolUnits::toInt16(pszData);
+ m_cassetteType = (CassetteType)CToolUnits::toInt16(pszData);
}
return 0;
});
@@ -145,13 +156,13 @@
// Transfer type
static char* pszName[] = { STEP_EQ_PORT1_TRANSFER_MODE, STEP_EQ_PORT2_TRANSFER_MODE, STEP_EQ_PORT3_TRANSFER_MODE, STEP_EQ_PORT4_TRANSFER_MODE };
static int dev[] = { 0x6014, 0x6024, 0x6034, 0x6044 };
- static int writeSignalDev[] = { 0xb8, 0xb9, 0xba, 0xbb };
+ static int writeSignalDev[] = { 0xa8, 0xa9, 0xaa, 0xab };
static int addr[] = { STEP_ID_PORT1_TRANSFER_MODE_CHANGE, STEP_ID_PORT2_TRANSFER_MODE_CHANGE, STEP_ID_PORT3_TRANSFER_MODE_CHANGE, STEP_ID_PORT4_TRANSFER_MODE_CHANGE };
CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
if (code == ROK && pszData != nullptr && size > 0) {
- m_nTransferMode = (unsigned int)CToolUnits::toInt16(pszData);
+ m_transferMode = (TransferMode)CToolUnits::toInt16(pszData);
}
return 0;
});
@@ -166,7 +177,7 @@
// Port enable
static char* pszName[] = { STEP_EQ_PORT1_ENABLE, STEP_EQ_PORT2_ENABLE, STEP_EQ_PORT3_ENABLE, STEP_EQ_PORT4_ENABLE };
static int dev[] = { 0x6015, 0x6025, 0x6035, 0x6045 };
- static int writeSignalDev[] = { 0xc0, 0xc1, 0xc2, 0xc3 };
+ static int writeSignalDev[] = { 0xb0, 0xb1, 0xb2, 0xb3 };
static int addr[] = { STEP_ID_PORT1_ENABLE_MODE_CHANGE, STEP_ID_PORT2_ENABLE_MODE_CHANGE, STEP_ID_PORT3_ENABLE_MODE_CHANGE, STEP_ID_PORT4_ENABLE_MODE_CHANGE };
CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
@@ -337,6 +348,50 @@
}
}
}
+
+ {
+ // Fetched Out Job Report #1~15
+ char szBuffer[256];
+ CEqReadStep* pStep = new CEqReadStep(0x5c31 + 18 * m_nIndex, 18 * 2,
+ [&](void* pFrom, int code, const char* pszData, size_t size) -> int {
+ if (code == ROK && pszData != nullptr && size > 0) {
+ int port = (int)(__int64)((CEqReadStep*)pFrom)->getProp("Port");
+ if (port > 0) {
+ decodeFetchedOutJobReport((CStep*)pFrom, port, pszData, size);
+ }
+ }
+ return -1;
+ });
+ sprintf_s(szBuffer, "%s%d", STEP_EQ_FETCHED_OUT_JOBn, m_nIndex + 1);
+ pStep->setName(szBuffer);
+ pStep->setProp("Port", (void*)(__int64)(m_nIndex + 1));
+ pStep->setWriteSignalDev(0x023 + m_nIndex);
+ if (addStep(STEP_ID_FETCHED_OUT_JOB_REPORT1 + m_nIndex, pStep) != 0) {
+ delete pStep;
+ }
+ }
+
+ {
+ // Store Job Report #1~15
+ char szBuffer[256];
+ CEqReadStep* pStep = new CEqReadStep(0x5b23 + 18 * m_nIndex, 18 * 2,
+ [&](void* pFrom, int code, const char* pszData, size_t size) -> int {
+ if (code == ROK && pszData != nullptr && size > 0) {
+ int port = (int)(__int64)((CEqReadStep*)pFrom)->getProp("Port");
+ if (port > 0) {
+ decodeStoredJobReport((CStep*)pFrom, port, pszData, size);
+ }
+ }
+ return -1;
+ });
+ sprintf_s(szBuffer, "%s%d", STEP_EQ_STORED_JOBn, m_nIndex + 1);
+ pStep->setName(szBuffer);
+ pStep->setProp("Port", (void*)(__int64)(m_nIndex + 1));
+ pStep->setWriteSignalDev(0x014 + m_nIndex);
+ if (addStep(STEP_ID_STORE_JOB_REPORT1 + m_nIndex, pStep) != 0) {
+ delete pStep;
+ }
+ }
}
void CLoadPort::onTimer(UINT nTimerid)
@@ -347,6 +402,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)
@@ -358,13 +435,13 @@
attrubutes.addAttribute(new CAttribute("Index",
std::to_string(m_nIndex).c_str(), "", weight++));
attrubutes.addAttribute(new CAttribute("Type",
- getPortTypeDescription(m_nType, strTemp).c_str(), "", weight++));
+ getPortTypeDescription(m_portType, strTemp).c_str(), "", weight++));
attrubutes.addAttribute(new CAttribute("Mode",
- getPortModeDescription(m_nMode, strTemp).c_str(), "", weight++));
+ getPortModeDescription(m_portMode, strTemp).c_str(), "", weight++));
attrubutes.addAttribute(new CAttribute("CassetteType",
- getPortCassetteTypeDescription(m_nCassetteType, strTemp).c_str(), "", weight++));
+ getPortCassetteTypeDescription(m_cassetteType, strTemp).c_str(), "", weight++));
attrubutes.addAttribute(new CAttribute("TransferMode",
- getPortTransferModeDescription(m_nTransferMode, strTemp).c_str(), "", weight++));
+ getPortTransferModeDescription(m_transferMode, strTemp).c_str(), "", weight++));
attrubutes.addAttribute(new CAttribute("Enable",
m_bEnable ? "Eanble" : "Disable", "", weight++));
attrubutes.addAttribute(new CAttribute("Auto Change",
@@ -374,21 +451,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,
@@ -426,6 +488,16 @@
return pStep;
}
+ short CLoadPort::getNextCassetteSequenceNo()
+ {
+ m_nNextCassetteSequenceNo++;
+ if (m_nNextCassetteSequenceNo >= 1000) {
+ m_nNextCassetteSequenceNo = 0;
+ }
+
+ return (m_nIndex + 1) * 1000 + m_nNextCassetteSequenceNo;
+ }
+
void CLoadPort::setIndex(unsigned int index)
{
m_nIndex = index;
@@ -441,29 +513,64 @@
return m_bEnable;
}
- int CLoadPort::getPortType()
+ PortType CLoadPort::getPortType()
{
- return m_nType;
+ return m_portType;
}
- int CLoadPort::getPortMode()
+ PortMode CLoadPort::getPortMode()
{
- return m_nMode;
+ return m_portMode;
}
- int CLoadPort::getCessetteType()
+ CassetteType CLoadPort::getCessetteType()
{
- return m_nCassetteType;
+ return m_cassetteType;
}
- int CLoadPort::getTransferMode()
+ TransferMode CLoadPort::getTransferMode()
{
- return m_nTransferMode;
+ return m_transferMode;
}
BOOL CLoadPort::isAutoChange()
{
return m_bAutoChangeEnable;
+ }
+
+ int CLoadPort::getPortStatus()
+ {
+ return m_portStatusReport.getPortStatus();
+ }
+
+ int CLoadPort::getCassetteSequenceNo()
+ {
+ return m_portStatusReport.getCassetteSequenceNo();
+ }
+
+ std::string& CLoadPort::getCassetteId()
+ {
+ return m_portStatusReport.getCassetteId();
+ }
+
+ int CLoadPort::getLoadingCassetteType()
+ {
+ return m_portStatusReport.getLoadingCassetteType();
+ }
+
+ int CLoadPort::getQTimeFlag()
+ {
+ return m_portStatusReport.getQTimeFlag();
+ }
+
+ int CLoadPort::getCassetteMappingState()
+ {
+ return m_portStatusReport.getCassetteMappingState();
+ }
+
+ int CLoadPort::getCassetteStatus()
+ {
+ return m_portStatusReport.getCassetteStatus();
}
/*
@@ -475,9 +582,9 @@
6: Buffer Port-Un-loader in Buffer Type
7: Unloading Partial Port
*/
- std::string& CLoadPort::getPortTypeDescription(int portType, std::string& strDescription)
+ std::string& CLoadPort::getPortTypeDescription(PortType portType, std::string& strDescription)
{
- switch (portType) {
+ switch ((int)portType) {
case 1:
strDescription = _T("Loading Port");
break;
@@ -515,9 +622,9 @@
4: InService
5: TransferReady
*/
- std::string& CLoadPort::getPortModeDescription(int portMode, std::string& strDescription)
+ std::string& CLoadPort::getPortModeDescription(PortMode portMode, std::string& strDescription)
{
- switch (portMode) {
+ switch ((int)portMode) {
case 0:
strDescription = _T("OutOfService");
break;
@@ -549,9 +656,9 @@
2: G2
3: G1&G2
*/
- std::string& CLoadPort::getPortCassetteTypeDescription(int casseteType, std::string& strDescription)
+ std::string& CLoadPort::getPortCassetteTypeDescription(CassetteType casseteType, std::string& strDescription)
{
- switch (casseteType) {
+ switch ((int)casseteType) {
case 1:
strDescription = _T("G1");
break;
@@ -574,9 +681,9 @@
2: AGV Mode
3: Stocker Inline Mode
*/
- std::string& CLoadPort::getPortTransferModeDescription(int mode, std::string& strDescription)
+ std::string& CLoadPort::getPortTransferModeDescription(TransferMode mode, std::string& strDescription)
{
- switch (mode) {
+ switch ((int)mode) {
case 1:
strDescription = _T("MGV Mode");
break;
@@ -616,8 +723,160 @@
return strDescription;
}
+ /*
+ 1: Load Ready(Load Request)
+ 2: Loaded
+ 3: In Use (Load Complete)
+ 4: Unload Ready (Unload Request)
+ 5: Empty (Unload Complete)
+ 6: Blocked
+ */
+ std::string& CLoadPort::getPortStatusDescription(int portStatus, std::string& strDescription)
+ {
+ switch (portStatus) {
+ case 1:
+ strDescription = _T("Load Ready(Load Request)");
+ break;
+ case 2:
+ strDescription = _T("Loaded");
+ break;
+ case 3:
+ strDescription = _T("In Use(Load Complete)");
+ break;
+ case 4:
+ strDescription = _T("Unload Ready(Unload Request)");
+ break;
+ case 5:
+ strDescription = _T("Empty(Unload Complete)");
+ break;
+ case 6:
+ strDescription = _T("Blocked");
+ break;
+ default:
+ strDescription = _T("");
+ break;
+ }
+
+ return strDescription;
+ }
+
+ /*
+ 1: G1 Cassette
+ 2: G2 Cassette
+ 3: G1 + G2 Cassette
+ 4: Empty Cassette
+ * Include this item only when cassette exists"
+ */
+ std::string& CLoadPort::getLoadingCassetteTypeDescription(int type, std::string& strDescription)
+ {
+ switch (type) {
+ case 1:
+ strDescription = _T("G1 Cassette)");
+ break;
+ case 2:
+ strDescription = _T("G2 Cassette");
+ break;
+ case 3:
+ strDescription = _T("G1+G2 Cassette)");
+ break;
+ case 4:
+ strDescription = _T("Empty Cassette)");
+ break;
+ default:
+ strDescription = _T("");
+ break;
+ }
+
+ return strDescription;
+ }
+
+ /*
+ 1: Normal Un-loading
+ 2: Q-Time Over & Un-loading
+ */
+ std::string& CLoadPort::getQTimeFlagDescription(int flag, std::string& strDescription)
+ {
+ switch (flag) {
+ case 1:
+ strDescription = _T("Normal Un-loading");
+ break;
+ case 2:
+ strDescription = _T("Q-Time Over & Un-loading");
+ break;
+ default:
+ strDescription = _T("");
+ break;
+ }
+
+ return strDescription;
+ }
+
+ /*
+ 1: mapping use
+ 2: mapping not use
+ */
+ std::string& CLoadPort::getCassetteMappingStateDescription(int state, std::string& strDescription)
+ {
+ switch (state) {
+ case 1:
+ strDescription = _T("Mapping use");
+ break;
+ case 2:
+ strDescription = _T("Mapping not use");
+ break;
+ default:
+ strDescription = _T("");
+ break;
+ }
+
+ return strDescription;
+ }
+
+ /*
+ 1: No Cassette Exist
+ 2: Waiting for Cassette Data
+ 3: Waiting for Start Command
+ 4: Waiting for Processing
+ 5: In Processing
+ 6: Process Paused
+ 7: Process Completed
+ */
+ std::string& CLoadPort::getCassetteStatusDescription(int state, std::string& strDescription)
+ {
+ switch (state) {
+ case 1:
+ strDescription = _T("No Cassette Exist");
+ break;
+ case 2:
+ strDescription = _T("Waiting for Cassette Data");
+ break;
+ case 3:
+ strDescription = _T("Waiting for Start Command");
+ break;
+ case 4:
+ strDescription = _T("Waiting for Processing");
+ break;
+ case 5:
+ strDescription = _T("In Processing");
+ break;
+ case 6:
+ strDescription = _T("Process Paused");
+ break;
+ case 7:
+ strDescription = _T("Process Completed");
+ break;
+ default:
+ strDescription = _T("");
+ break;
+ }
+
+ return strDescription;
+ }
+
void CLoadPort::onReceiveLBData(const char* pszData, size_t size)
{
+ __super::onReceiveLBData(pszData, size);
+
static int type[] = { STEP_ID_PORT1_TYPE_CHANGE, STEP_ID_PORT2_TYPE_CHANGE,
STEP_ID_PORT3_TYPE_CHANGE, STEP_ID_PORT4_TYPE_CHANGE };
static int mode[] = { STEP_ID_PORT1_MODE_CHANGE, STEP_ID_PORT2_MODE_CHANGE,
@@ -682,14 +941,219 @@
return nRet;
}
+ int CLoadPort::setPortType(PortType type, ONWRITED onWritedBlock/* = nullptr*/)
+ {
+ static char* pszName[] = { STEP_PORT1_TYPE_CHANGE, STEP_PORT2_TYPE_CHANGE, STEP_PORT3_TYPE_CHANGE, STEP_PORT4_TYPE_CHANGE };
+ SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(pszName[m_nIndex]);
+ if (pStep == nullptr) {
+ return -1;
+ }
+
+ LOGI("<CLoadPort-%d>准备设置Port type<%d>", m_nIndex, (int)type);
+ short value = (short)type;
+ 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;
+ }
+
+ int CLoadPort::eablePort(BOOL bEnable, ONWRITED onWritedBlock/* = nullptr*/)
+ {
+ static char* pszName[] = { STEP_PORT1_ENABLE_MODE_CHANGE, STEP_PORT2_ENABLE_MODE_CHANGE, STEP_PORT3_ENABLE_MODE_CHANGE, STEP_PORT4_ENABLE_MODE_CHANGE };
+ SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(pszName[m_nIndex]);
+ if (pStep == nullptr) {
+ return -1;
+ }
+
+ LOGI("<CLoadPort-%d>准备%s Port", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
+ short value = bEnable ? 1 : 2;
+ 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;
+ }
+
+ int CLoadPort::setPortMode(PortMode mode, ONWRITED onWritedBlock/* = nullptr*/)
+ {
+ static char* pszName[] = { STEP_PORT1_MODE_CHANGE, STEP_PORT2_MODE_CHANGE, STEP_PORT3_MODE_CHANGE, STEP_PORT4_MODE_CHANGE };
+ SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(pszName[m_nIndex]);
+ if (pStep == nullptr) {
+ return -1;
+ }
+
+ LOGI("<CLoadPort-%d>准备设置Port mode<%d>", m_nIndex, (int)mode);
+ short value = (short)mode;
+ 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;
+ }
+
+ int CLoadPort::setCassetteType(CassetteType type, ONWRITED onWritedBlock/* = nullptr*/)
+ {
+ static char* pszName[] = { STEP_PORT1_CASSETTE_TYPE_CHANGE, STEP_PORT2_CASSETTE_TYPE_CHANGE, STEP_PORT3_CASSETTE_TYPE_CHANGE, STEP_PORT4_CASSETTE_TYPE_CHANGE };
+ SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(pszName[m_nIndex]);
+ if (pStep == nullptr) {
+ return -1;
+ }
+
+ LOGI("<CLoadPort-%d>准备设置Cassette Type<%d>", m_nIndex, (int)type);
+ short value = (short)type;
+ 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;
+ }
+
+ int CLoadPort::setTransferMode(TransferMode mode, ONWRITED onWritedBlock/* = nullptr*/)
+ {
+ static char* pszName[] = { STEP_PORT1_TRANSFER_MODE_CHANGE, STEP_PORT2_TRANSFER_MODE_CHANGE, STEP_PORT3_TRANSFER_MODE_CHANGE, STEP_PORT4_TRANSFER_MODE_CHANGE };
+ SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(pszName[m_nIndex]);
+ if (pStep == nullptr) {
+ return -1;
+ }
+
+ LOGI("<CLoadPort-%d>准备设置Transfer mode<%d>", m_nIndex, (int)mode);
+ short value = (short)mode;
+ 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;
+ }
+
+ int CLoadPort::eableAutoChange(BOOL bEnable, ONWRITED onWritedBlock/* = nullptr*/)
+ {
+ static char* pszName[] = { STEP_PORT1_TYPE_AUTO_CHANGE, STEP_PORT2_TYPE_AUTO_CHANGE, STEP_PORT3_TYPE_AUTO_CHANGE, STEP_PORT4_TYPE_AUTO_CHANGE };
+ SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(pszName[m_nIndex]);
+ if (pStep == nullptr) {
+ return -1;
+ }
+
+ LOGI("<CLoadPort-%d>准备%s Auto Change", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
+ short value = bEnable ? 1 : 2;
+ 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)
{
// 如果非空就不生成了
Lock();
- if (!m_glassList.empty()) {
+ if (hasGlass()) {
Unlock();
return -1;
}
@@ -697,27 +1161,24 @@
char szBuffer[64];
- int suffix = startSuffix;
- for (int i = 0; i < count; i++) {
- CJobDataB jb;
- CJobDataS js;
+ for (int i = 0; i < 1; i++) {
+ if (!m_slot[i].isEnable()) continue;
- sprintf_s(szBuffer, "%s%d", pszPrefix, suffix++);
- jb.setGlassId(szBuffer);
+ CJobDataS js;
+ js.setCassetteSequenceNo(getNextCassetteSequenceNo());
+ js.setJobSequenceNo(i);
+ sprintf_s(szBuffer, 64, "%05d%05d", js.getCassetteSequenceNo(), js.getJobSequenceNo());
+ js.setGlass1Id(szBuffer);
+ js.setJobType(1);
js.setMaterialsType((int)type);
- if (type == MaterialsType::G1) {
- js.setGlass1Id(szBuffer);
- }
- else if (type == MaterialsType::G2) {
- js.setGlass2Id(szBuffer);
- }
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