LAPTOP-SNT8I5JK\Boounion
2025-06-26 838262ab61d580d7dd5eb3b181c61d8b4d3f54fe
SourceCode/Bond/Servo/CEquipment.cpp
@@ -41,6 +41,7 @@
      m_nBaseAlarmId = 0;
      m_pArm = nullptr;
      m_processState = PROCESS_STATE::Ready;
      m_blockReadBit = { 0 };
      InitializeCriticalSection(&m_criticalSection);
   }
@@ -410,6 +411,7 @@
         onSendAble();
      }
      index += 0x40 * 2;
      for (int i = 0; i < 8; i++) {
         m_bLinkSignalToDownstream[i][SIGNAL_UPSTREAM_INLINE] = isBitOn(pszData, size, index + 0);
         m_bLinkSignalToDownstream[i][SIGNAL_UPSTREAM_TROUBLE] = isBitOn(pszData, size, index + 1);
@@ -418,7 +420,7 @@
         index += 0x40;
      }
      if (m_bLinkSignalToDownstream[0][SIGNAL_RECEIVE_ABLE]) {
         onSendAble();
         onReceiveAble();
      }
      // 其它信号及响应
@@ -602,6 +604,10 @@
      // Job Data Request
      CHECK_READ_STEP_SIGNAL(STEP_ID_JOB_DATA_REQUEST, pszData, size);
      // job process start/end report
      CHECK_READ_STEP_SIGNAL(STEP_ID_JOB_PROCESS_START_REPORT, pszData, size);
      CHECK_READ_STEP_SIGNAL(STEP_ID_JOB_PROCESS_END_REPORT, pszData, size);
   }
   BOOL CEquipment::isBitOn(const char* pszData, size_t size, int index)
@@ -1236,6 +1242,23 @@
      return nullptr;
   }
   CSlot* CEquipment::getAvailableSlotForGlassExcludeSignal(MaterialsType type)
   {
      for (int i = 0; i < SLOT_MAX; i++) {
         if (!m_slot[i].isEnable()) continue;
         if (m_slot[i].isLock()) continue;
         if (!m_slot[i].isEmpty()) continue;
         MaterialsType slotType = m_slot[i].getType();
         if (type == MaterialsType::G1 && slotType == MaterialsType::G2) continue;
         if (type == MaterialsType::G2 && slotType == MaterialsType::G1) continue;
         return &m_slot[i];
      }
      return nullptr;
   }
   CSlot* CEquipment::getAvailableSlotForGlass2(MaterialsType type, const std::vector<int>& candidates)
   {
      for (auto item : candidates) {
@@ -1663,6 +1686,131 @@
      return 0;
   }
   int CEquipment::decodeJobProcessStartReport(CStep* pStep, const char* pszData, size_t size)
   {
      LOGI("<CEquipment-%s>decodeJobProcessStartReport", getName().c_str());
      short cassetteNo, jobSequenceNo, unitNo, subUnitNo, slotNo;
      int year, month, day, hour, minute, second;
      int index = 0;
      memcpy(&cassetteNo, &pszData[index], sizeof(short));
      index += sizeof(short);
      memcpy(&jobSequenceNo, &pszData[index], sizeof(short));
      index += sizeof(short);
      memcpy(&unitNo, &pszData[index], sizeof(short));
      index += sizeof(short);
      memcpy(&subUnitNo, &pszData[index], sizeof(short));
      index += sizeof(short);
      memcpy(&slotNo, &pszData[index], sizeof(short));
      index += sizeof(short);
      memcpy(&year, &pszData[index], sizeof(short));
      index += sizeof(short);
      month = (int)pszData[index];
      index += 1;
      day = (int)pszData[index];
      index += 1;
      hour = (int)pszData[index];
      index += 1;
      minute = (int)pszData[index];
      index += 1;
      second = (int)pszData[index];
      index += 1;
      LOGI("<CEquipment-%s>cassetteNo:%d, jobSequenceNo:%d,unitNo:%d, subUnitNo:%d, slotNo:%d %d-%d-%d %d:%d:%d",
         getName().c_str(),
         cassetteNo,
         jobSequenceNo,
         unitNo,
         subUnitNo,
         slotNo,
         year, month, day, hour, minute, second
         );
      // 缓存Attribute,用于调试时显示信息
      unsigned int weight = 201;
      pStep->addAttribute(new CAttribute("CassetteNo",
         std::to_string(cassetteNo).c_str(), "", weight++));
      pStep->addAttribute(new CAttribute("JobSequenceNo",
         std::to_string(jobSequenceNo).c_str(), "", weight++));
      pStep->addAttribute(new CAttribute("UnitNo",
         std::to_string(unitNo).c_str(), "", weight++));
      pStep->addAttribute(new CAttribute("SubUnitNo",
         std::to_string(subUnitNo).c_str(), "", weight++));
      pStep->addAttribute(new CAttribute("SlotNo",
         std::to_string(slotNo).c_str(), "", weight++));
      pStep->addAttribute(new CAttribute("ProcessStartTime",
         (std::to_string(year) + std::to_string(day) + std::to_string(day) + std::to_string(hour) + std::to_string(minute) + std::to_string(second)).c_str()
         , "", weight++));
      return 0;
   }
   int CEquipment::decodeJobProcessEndReport(CStep* pStep, const char* pszData, size_t size)
   {
      LOGI("<CEquipment-%s>decodeJobProcessEndReport", getName().c_str());
      short cassetteNo, jobSequenceNo, unitNo, subUnitNo, slotNo;
      int year, month, day, hour, minute, second;
      int index = 0;
      std::string strPanelJudgeData, strPanelGradeData;
      memcpy(&cassetteNo, &pszData[index], sizeof(short));
      index += sizeof(short);
      memcpy(&jobSequenceNo, &pszData[index], sizeof(short));
      index += sizeof(short);
      memcpy(&unitNo, &pszData[index], sizeof(short));
      index += sizeof(short);
      memcpy(&subUnitNo, &pszData[index], sizeof(short));
      index += sizeof(short);
      memcpy(&slotNo, &pszData[index], sizeof(short));
      index += sizeof(short);
      memcpy(&year, &pszData[index], sizeof(short));
      index += sizeof(short);
      month = (int)pszData[index];
      index += 1;
      day = (int)pszData[index];
      index += 1;
      hour = (int)pszData[index];
      index += 1;
      minute = (int)pszData[index];
      index += 1;
      second = (int)pszData[index];
      index += 1;
      LOGI("<CEquipment-%s>cassetteNo:%d, jobSequenceNo:%d,unitNo:%d, subUnitNo:%d, slotNo:%d %d-%d-%d %d:%d:%d",
         getName().c_str(),
         cassetteNo,
         jobSequenceNo,
         unitNo,
         subUnitNo,
         slotNo,
         year, month, day, hour, minute, second
      );
      // 缓存Attribute,用于调试时显示信息
      unsigned int weight = 201;
      pStep->addAttribute(new CAttribute("CassetteNo",
         std::to_string(cassetteNo).c_str(), "", weight++));
      pStep->addAttribute(new CAttribute("JobSequenceNo",
         std::to_string(jobSequenceNo).c_str(), "", weight++));
      pStep->addAttribute(new CAttribute("UnitNo",
         std::to_string(unitNo).c_str(), "", weight++));
      pStep->addAttribute(new CAttribute("SubUnitNo",
         std::to_string(subUnitNo).c_str(), "", weight++));
      pStep->addAttribute(new CAttribute("SlotNo",
         std::to_string(slotNo).c_str(), "", weight++));
      pStep->addAttribute(new CAttribute("ProcessStartTime",
         (std::to_string(year) + std::to_string(day) + std::to_string(day) + std::to_string(hour) + std::to_string(minute) + std::to_string(second)).c_str()
         , "", weight++));
      return 0;
   }
   int CEquipment::onPreStoredJob(int port, CJobDataB* pJobDataB, short& putSlot)
   {
      LOGI("<CEquipment-%s>onPreStoredJob:port:%d|GlassId:%s",
@@ -1679,7 +1827,7 @@
      CJobDataS* pJobDataS = pGlass->getJobDataS();
      ASSERT(pJobDataS);
      if (!compareJobData(pJobDataB, pJobDataS)) {
         LOGE("<CFliper-%s>onPreFetchedOutJob,JobData数据不匹配(JobDataB(%d, %d),JobDataS(%d, %d)), 注意排查风险!", m_strName.c_str(),
         LOGE("<CEquipemnt-%s>onPreFetchedOutJob,JobData数据不匹配(JobDataB(%d, %d),JobDataS(%d, %d)), 注意排查风险!", m_strName.c_str(),
            pJobDataB->getCassetteSequenceNo(), pJobDataB->getJobSequenceNo(),
            pJobDataS->getCassetteSequenceNo(), pJobDataS->getJobSequenceNo());
         return FALSE;
@@ -1687,10 +1835,10 @@
      // 如果没有可用位置,报错
      Lock();
      CSlot* pSlot = getAvailableSlotForGlass((MaterialsType)pJobDataS->getMaterialsType());
      CSlot* pSlot = getAvailableSlotForGlassExcludeSignal((MaterialsType)pJobDataS->getMaterialsType());
      if (pSlot == nullptr) {
         Unlock();
         LOGE("<CFliper-%s>onPreFetchedOutJob,找不到匹配的Slot,不能进料,请注意风险!", m_strName.c_str());
         LOGE("<CEquipemnt-%s>onPreFetchedOutJob,找不到匹配的Slot,不能进料,请注意风险!", m_strName.c_str());
         return FALSE;
      }
      Unlock();
@@ -1748,10 +1896,9 @@
      return 0;
   }
   int CEquipment::onRecieveAble()
   int CEquipment::onReceiveAble()
   {
      LOGI("<CEquipment-%s>onRecieveAble.", m_strName.c_str());
      LOGI("<CEquipment-%s>onReceiveAble.", m_strName.c_str());
      return 0;
   }