LAPTOP-SNT8I5JK\Boounion
2025-09-22 9e9e63ef44ff672989d7b78bf37afb2054267671
SourceCode/Bond/Servo/CLoadPort.cpp
@@ -44,7 +44,7 @@
   void CLoadPort::initPins()
   {
      // 加入Pin初始化代码
      LOGI("<CLoadPort>initPins");
      LOGD("<CLoadPort>initPins");
      addPin(SERVO::PinType::INPUT, _T("In"));
      addPin(SERVO::PinType::OUTPUT, _T("Out"));
   }
@@ -350,6 +350,18 @@
   {
      CEquipment::onTimer(nTimerid);
      // 从配置读出的enable,初始化时写给efem
      static int i_enable[4] = { 0 };
      if ((++i_enable[m_nIndex]) == 20 + m_nIndex) {
         eablePort(m_bEnable, [&](int code) -> int {
            LOGI("<LoadPort-%d>eablePort:code=%d", m_nIndex, code);
            return 0;
            });
      }
      // 模拟测试
      /*
      if (m_nIndex == 0) {
@@ -357,11 +369,25 @@
         ii++;
         if (ii == 50) {
            char szBuffer[64] = {0};
            CStep* pStep = getStepWithName(STEP_EQ_PORT1_INUSE);
            CStep* pStep = getStepWithName(STEP_EQ_PORT1_BLOCKED);
            CPortStatusReport portStatusReport;
            portStatusReport.setPortStatus(PORT_INUSE);
            portStatusReport.setPortStatus(PORT_BLOCKED);
            portStatusReport.setJobExistenceSlot(0xf);
            portStatusReport.setCassetteId("CID1984113");
            portStatusReport.setCassetteId("CID1001");
            int nRet = portStatusReport.serialize(szBuffer, 64);
            decodePortStatusReport(pStep, szBuffer, 64);
         }
      }
      if (m_nIndex == 1) {
         static int ii = 0;
         ii++;
         if (ii == 55) {
            char szBuffer[64] = { 0 };
            CStep* pStep = getStepWithName(STEP_EQ_PORT2_BLOCKED);
            CPortStatusReport portStatusReport;
            portStatusReport.setPortStatus(PORT_BLOCKED);
            portStatusReport.setJobExistenceSlot(0xff );
            portStatusReport.setCassetteId("CID1004");
            int nRet = portStatusReport.serialize(szBuffer, 64);
            decodePortStatusReport(pStep, szBuffer, 64);
         }
@@ -378,7 +404,6 @@
         m_portStatusReport.serialize(ar);
      }
      else {
         int temp;
         ar >> m_nIndex;
         m_portStatusReport.serialize(ar);
      }
@@ -464,9 +489,25 @@
      return (m_nIndex + 1) * 1000 + m_nNextCassetteSequenceNo;
   }
   int CLoadPort::getPortCassetteSnSeed()
   {
      return m_nNextCassetteSequenceNo;
   }
   void CLoadPort::setPortCassetteSnSeed(int seed)
   {
      m_nNextCassetteSequenceNo = seed;
      if (m_nNextCassetteSequenceNo >= 1000) {
         m_nNextCassetteSequenceNo = 0;
      }
   }
   void CLoadPort::setIndex(unsigned int index)
   {
      m_nIndex = index;
      std::string id = "Port" + std::to_string(index + 1);
      m_portStatusReport.setCassetteId(id.c_str());
   }
   unsigned int CLoadPort::getIndex()
@@ -957,7 +998,7 @@
            LOGI("<CLoadPort-%d>设置Port type成功.", m_nIndex);
         }
         else {
            LOGI("<CLoadPort-%d>设置Port type失败,code:%d", m_nIndex, code);
            LOGE("<CLoadPort-%d>设置Port type失败,code:%d", m_nIndex, code);
         }
         if (onWritedBlock != nullptr) {
            return onWritedBlock(code);
@@ -987,7 +1028,7 @@
            LOGI("<CLoadPort-%d>%s Port成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
         }
         else {
            LOGI("<CLoadPort-%d>%s  Port失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
            LOGE("<CLoadPort-%d>%s  Port失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
         }
         if (onWritedBlock != nullptr) {
            return onWritedBlock(code);
@@ -1016,7 +1057,7 @@
            LOGI("<CLoadPort-%d>设置Port mode成功.", m_nIndex);
         }
         else {
            LOGI("<CLoadPort-%d>设置Port mode失败,code:%d", m_nIndex, code);
            LOGE("<CLoadPort-%d>设置Port mode失败,code:%d", m_nIndex, code);
         }
         if (onWritedBlock != nullptr) {
            return onWritedBlock(code);
@@ -1045,7 +1086,7 @@
            LOGI("<CLoadPort-%d>设置Cassette Type成功.", m_nIndex);
         }
         else {
            LOGI("<CLoadPort-%d>设置Cassette Type失败,code:%d", m_nIndex, code);
            LOGE("<CLoadPort-%d>设置Cassette Type失败,code:%d", m_nIndex, code);
         }
         if (onWritedBlock != nullptr) {
            return onWritedBlock(code);
@@ -1074,7 +1115,7 @@
            LOGI("<CLoadPort-%d>设置Transfer mode成功.", m_nIndex + 1);
         }
         else {
            LOGI("<CLoadPort-%d>设置Transfer mode失败,code:%d", m_nIndex + 1, code);
            LOGE("<CLoadPort-%d>设置Transfer mode失败,code:%d", m_nIndex + 1, code);
         }
         if (onWritedBlock != nullptr) {
            return onWritedBlock(code);
@@ -1103,7 +1144,7 @@
            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);
            LOGE("<CLoadPort-%d>%s  Auto Change失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
         }
         if (onWritedBlock != nullptr) {
            return onWritedBlock(code);
@@ -1183,7 +1224,7 @@
         CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
         pGlass->setOriginPort(m_nIndex, i);
         pGlass->addPath(m_nID, 0);
         pGlass->addPath(m_nID, 0, i + 1);
         pGlass->processEnd(m_nID, 0);
         pGlass->setID(szBuffer);
         pGlass->setType(type);
@@ -1211,7 +1252,7 @@
      char szBuffer[64];
      for (int i = 0; i < SLOT_MAX; i++) {
         if (!m_slot[i].isEnable()) continue;
         if (!(map >> i) & 1) continue;
         if (((map >> i) & 1) == 0) continue;
         CJobDataS js;
         js.setCassetteSequenceNo(getNextCassetteSequenceNo());
@@ -1223,7 +1264,7 @@
         CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
         pGlass->setOriginPort(m_nIndex, i);
         pGlass->setScheduledForProcessing(i % 2 == 1);
         pGlass->addPath(m_nID, 0);
         pGlass->addPath(m_nID, 0, i + 1);
         pGlass->processEnd(m_nID, 0);
         pGlass->setID(szBuffer);
         pGlass->setType(m_cassetteType);
@@ -1263,7 +1304,7 @@
         CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
         pGlass->setOriginPort(m_nIndex, nSlotIndex);
         pGlass->addPath(m_nID, 0);
         pGlass->addPath(m_nID, 0, slot.nSlotID);
         pGlass->processEnd(m_nID, 0);
         pGlass->setID(szBuffer);
         pGlass->setType(static_cast<SERVO::MaterialsType>(config.nMaterialType));