chenluhua1980
7 天以前 ceb64b6612309fe384e096dcdc8b5a5e0dfe6cce
SourceCode/Bond/Servo/CJobDataB.cpp
@@ -6,7 +6,14 @@
namespace SERVO {
   CJobDataB::CJobDataB()
   {
      m_nCassetteSequenceNo = 0;
      m_nJobSequenceNo = 0;
      m_pOwner = nullptr;
   }
   CJobDataB::CJobDataB(CJobDataB&& other) noexcept
   {
      copy(&other);
   }
   CJobDataB::~CJobDataB()
@@ -14,144 +21,86 @@
   }
   short CJobDataB::getPortNo()
   void CJobDataB::copy(CJobDataB* pScr)
   {
      return m_nPortNo;
      m_nCassetteSequenceNo = pScr->m_nCassetteSequenceNo;
      m_nJobSequenceNo = pScr->m_nJobSequenceNo;
      m_strGlassId = pScr->m_strGlassId;
      m_pOwner = pScr->m_pOwner;
   }
   std::string& CJobDataB::getCarrierId()
   void* CJobDataB::getOwner()
   {
      return m_strCarrierId;
      return m_pOwner;
   }
   std::string& CJobDataB::getPruductId()
   void CJobDataB::setOwner(void* pOwner)
   {
      return m_pruductId;
      m_pOwner = pOwner;
   }
   int CJobDataB::getCassetteSequenceNo()
   {
      return m_nCassetteSequenceNo;
   }
   void CJobDataB::setCassetteSequenceNo(int no)
   {
      m_nCassetteSequenceNo = no;
   }
   int CJobDataB::getJobSequenceNo()
   {
      return m_nJobSequenceNo;
   }
   void CJobDataB::setJobSequenceNo(int no)
   {
      m_nJobSequenceNo = no;
   }
   std::string& CJobDataB::getGlassId()
   {
      return m_strGlassId;
   }
   void CJobDataB::setGlassId(const char* pszGlassId)
   {
      m_strGlassId = pszGlassId;
   }
   int CJobDataB::serialize(char* pszBuffer, int nBufferSize)
   {
      if (nBufferSize < 640) return -1;
      if (nBufferSize < JOBDATAB_SIZE) return -1;
      int index = 0;
      memcpy(&pszBuffer[index], &m_nPortNo, sizeof(short));
      memcpy(&pszBuffer[index], &m_nCassetteSequenceNo, sizeof(short));
      index += sizeof(short);
      int strLen = min(20, m_strCarrierId.size());
      memcpy(&pszBuffer[index], m_strCarrierId.c_str(), strLen);
      index += 20;
      strLen = min(20, m_pruductId.size());
      memcpy(&pszBuffer[index], m_pruductId.c_str(), strLen);
      index += 20;
      memcpy(&pszBuffer[index], &m_nCarrierState, sizeof(short));
      memcpy(&pszBuffer[index], &m_nJobSequenceNo, sizeof(short));
      index += sizeof(short);
      memcpy(&pszBuffer[index], &m_nSlotMapping, sizeof(int));
      index += sizeof(int);
      int strLen = min(20, m_strGlassId.size());
      memcpy(&pszBuffer[index], m_strGlassId.c_str(), strLen);
      index += 20;
      memcpy(&pszBuffer[index], &m_nSlotSelectedFlag, sizeof(int));
      index += sizeof(int);
      for (int i = 0; i < min(25, m_glassIds.size()); i++) {
         std::string& strGlassId = m_glassIds.at(i);
         strLen = min(20, strGlassId.size());
         memcpy(&pszBuffer[index], strGlassId.c_str(), strLen);
         index += 20;
      }
      return 320 * 2;
      return JOBDATAB_SIZE;
   }
   int CJobDataB::unserialize(char* pszBuffer, int nBufferSize)
   int CJobDataB::unserialize(const char* pszBuffer, int nBufferSize)
   {
      if (nBufferSize < 640) return -1;
      if (nBufferSize < 14 * 2) return -1;
      int index = 0;
      memcpy(&m_nPortNo, &pszBuffer[index], sizeof(short));
      memcpy(&m_nCassetteSequenceNo, &pszBuffer[index], sizeof(short));
      index += sizeof(short);
      CToolUnits::convertString(&pszBuffer[index], 20, m_strCarrierId);
      index += 20;
      CToolUnits::convertString(&pszBuffer[index], 20, m_pruductId);
      index += 20;
      memcpy(&m_nCarrierState, &pszBuffer[index], sizeof(short));
      memcpy(&m_nJobSequenceNo, &pszBuffer[index], sizeof(short));
      index += sizeof(short);
      memcpy(&m_nSlotMapping, &pszBuffer[index], sizeof(int));
      index += sizeof(int);
      CToolUnits::convertString(&pszBuffer[index], 20, m_strGlassId);
      index += 20;
      memcpy(&m_nSlotSelectedFlag, &pszBuffer[index], sizeof(int));
      index += sizeof(int);
      std::string strGlassId;
      m_glassIds.clear();
      for (int i = 0; i < 25; i++) {
         CToolUnits::convertString(&pszBuffer[index], 20, strGlassId);
         index += 20;
         if (!strGlassId.empty()) {
            m_glassIds.push_back(strGlassId);
         }
      }
      return 320 * 2;
   }
   short CJobDataB::getCarrierState()
   {
      return m_nCarrierState;
   }
   std::string& CJobDataB::getCarrierStateDescription(std::string& strDescription)
   {
      static char* pszDescription[20] = {
         "Bind",
         "CancelPod",
         "CancelPodNotification",
         "CancelPodOut",
         "CancelPodAtPort",
         "CancelBind",
         "Clamp",
         "ClosePod",
         "IndexDown",
         "IndexUp",
         "OpenPod",
         "PodComplete",
         "PodIn",
         "PodNotification",
         "PodOut",
         "PodRelease",
         "PodTagReadData",
         "PodTagWriteData",
         "Proceed WithPod",
         "Unclamp"
      };
      if (0 <= m_nCarrierState && m_nCarrierState < 20) {
         strDescription = pszDescription[m_nCarrierState];
      }
      else {
         strDescription = "";
      }
      return strDescription;
   }
   int CJobDataB::getSlotMapping()
   {
      return m_nSlotMapping;
   }
   int CJobDataB::getSlotSelectedFlag()
   {
      return m_nSlotSelectedFlag;
   }
   std::vector<std::string>& CJobDataB::getGlassIds()
   {
      return m_glassIds;
      return 14 * 2;
   }
}