| | |
| | | |
| | | |
| | | namespace SERVO { |
| | | #define JOBDATAS_SIZE (256 * 2) |
| | | #define ENABLE_JOBDATAS_RAWDATA TRUE |
| | | |
| | | CJobDataS::CJobDataS() |
| | | { |
| | | m_nCassetteSequenceNo = 0; |
| | |
| | | m_nSourceSlotNo = 0; |
| | | m_nTargetPortNo = 0; |
| | | m_nTargetSlotNo = 0; |
| | | m_pRawData = nullptr; |
| | | if (ENABLE_JOBDATAS_RAWDATA) { |
| | | m_pRawData = new char[JOBDATAS_SIZE]; |
| | | serialize(m_pRawData, JOBDATAS_SIZE); |
| | | } |
| | | } |
| | | |
| | | CJobDataS::CJobDataS(CJobDataS&& other) noexcept |
| | | { |
| | | copy(&other); |
| | | m_pRawData = other.m_pRawData; // 偷资源 |
| | | other.m_pRawData = nullptr; // 防止释放两次 |
| | | } |
| | | |
| | | CJobDataS::~CJobDataS() |
| | | { |
| | | if (m_pRawData != nullptr) { |
| | | delete[] m_pRawData; |
| | | m_pRawData = nullptr; |
| | | } |
| | | } |
| | | |
| | | void CJobDataS::copy(CJobDataS* pScr) |
| | | { |
| | | m_nCassetteSequenceNo = pScr->m_nCassetteSequenceNo; |
| | | m_nJobSequenceNo = pScr->m_nJobSequenceNo; |
| | | m_strLotId = pScr->m_strLotId; |
| | | m_strProductId = pScr->m_strProductId; |
| | | m_strOperationId = pScr->m_strOperationId; |
| | | m_strGlass1Id = pScr->m_strGlass1Id; |
| | | m_strGlass2Id = pScr->m_strGlass2Id; |
| | | m_nJobType = pScr->m_nJobType; |
| | | m_nMaterialsType = pScr->m_nMaterialsType; |
| | | m_nProductType = pScr->m_nProductType; |
| | | m_nDummyType = pScr->m_nDummyType; |
| | | m_nSkipFlag = pScr->m_nSkipFlag; |
| | | m_nProcessFlag = pScr->m_nProcessFlag; |
| | | m_nProcessResonCode = pScr->m_nProcessResonCode; |
| | | m_nLastGlassFlag = pScr->m_nLastGlassFlag; |
| | | m_nFirstGlassFlag = pScr->m_nFirstGlassFlag; |
| | | m_nQTime[0] = pScr->m_nQTime[0]; |
| | | m_nQTime[1] = pScr->m_nQTime[1]; |
| | | m_nQTime[2] = pScr->m_nQTime[2]; |
| | | m_nQTimeOverFlag = pScr->m_nQTimeOverFlag; |
| | | m_nMasterRecipe = pScr->m_nMasterRecipe; |
| | | m_strProductRecipeId = pScr->m_strProductRecipeId; |
| | | m_strPCode = pScr->m_strPCode; |
| | | m_strUseType = pScr->m_strUseType; |
| | | m_strPanelMeasure = pScr->m_strPanelMeasure; |
| | | m_nMode = pScr->m_nMode; |
| | | m_nSlotUnitSelectFlag = pScr->m_nSlotUnitSelectFlag; |
| | | m_nSourcePortNo = pScr->m_nSourcePortNo; |
| | | m_nSourceSlotNo = pScr->m_nSourceSlotNo; |
| | | m_nTargetPortNo = pScr->m_nTargetPortNo; |
| | | m_nTargetSlotNo = pScr->m_nTargetSlotNo; |
| | | } |
| | | |
| | | int CJobDataS::getCassetteSequenceNo() |
| | |
| | | memcpy(&pszBuffer[index], &m_nJobSequenceNo, sizeof(short)); |
| | | index += sizeof(short); |
| | | |
| | | int strLen = min(40, m_strLotId.size()); |
| | | int strLen = min(40, (int)m_strLotId.size()); |
| | | memcpy(&pszBuffer[index], m_strLotId.c_str(), strLen); |
| | | index += 40; |
| | | |
| | | strLen = min(20, m_strProductId.size()); |
| | | strLen = min(20, (int)m_strProductId.size()); |
| | | memcpy(&pszBuffer[index], m_strProductId.c_str(), strLen); |
| | | index += 20; |
| | | |
| | | strLen = min(20, m_strOperationId.size()); |
| | | strLen = min(20, (int)m_strOperationId.size()); |
| | | memcpy(&pszBuffer[index], m_strOperationId.c_str(), strLen); |
| | | index += 20; |
| | | |
| | | strLen = min(20, m_strGlass1Id.size()); |
| | | strLen = min(20, (int)m_strGlass1Id.size()); |
| | | memcpy(&pszBuffer[index], m_strGlass1Id.c_str(), strLen); |
| | | index += 20; |
| | | |
| | | strLen = min(20, m_strGlass2Id.size()); |
| | | strLen = min(20, (int)m_strGlass2Id.size()); |
| | | memcpy(&pszBuffer[index], m_strGlass2Id.c_str(), strLen); |
| | | index += 20; |
| | | |
| | |
| | | memcpy(&pszBuffer[index], &m_nMasterRecipe, sizeof(short)); |
| | | index += sizeof(short); |
| | | |
| | | strLen = min(10, m_strProductRecipeId.size()); |
| | | strLen = min(10, (int)m_strProductRecipeId.size()); |
| | | memcpy(&pszBuffer[index], m_strProductRecipeId.c_str(), strLen); |
| | | index += 10; |
| | | |
| | | strLen = min(10, m_strPCode.size()); |
| | | strLen = min(10, (int)m_strPCode.size()); |
| | | memcpy(&pszBuffer[index], m_strPCode.c_str(), strLen); |
| | | index += 10; |
| | | |
| | | strLen = min(10, m_strUseType.size()); |
| | | strLen = min(10, (int)m_strUseType.size()); |
| | | memcpy(&pszBuffer[index], m_strUseType.c_str(), strLen); |
| | | index += 10; |
| | | |
| | | strLen = min(80, m_strPanelMeasure.size()); |
| | | strLen = min(80, (int)m_strPanelMeasure.size()); |
| | | memcpy(&pszBuffer[index], m_strPanelMeasure.c_str(), strLen); |
| | | index += 80; |
| | | |
| | |
| | | |
| | | int CJobDataS::unserialize(const char* pszBuffer, int nBufferSize) |
| | | { |
| | | if (nBufferSize < 256 * 2) return -1; |
| | | if (nBufferSize < JOBDATAS_SIZE) return -1; |
| | | |
| | | int index = 0; |
| | | memcpy(&m_nCassetteSequenceNo, &pszBuffer[index], sizeof(short)); |
| | |
| | | index += sizeof(short); |
| | | |
| | | |
| | | return 256 * 2; |
| | | // 缓存原始数据 |
| | | if (m_pRawData != nullptr) { |
| | | memcpy(m_pRawData, pszBuffer, JOBDATAS_SIZE); |
| | | } |
| | | |
| | | |
| | | return JOBDATAS_SIZE; |
| | | } |
| | | |
| | | void CJobDataS::getAttributeVector(CAttributeVector& attrubutes, int beginWeight) |
| | | { |
| | | unsigned int weight = beginWeight; |
| | | std::string strTemp; |
| | | |
| | | attrubutes.addAttribute(new CAttribute("CassetteSequenceNo", |
| | | std::to_string(getCassetteSequenceNo()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("JobSequenceNo", |
| | | std::to_string(getJobSequenceNo()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("LotId", |
| | | getLotId().c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("ProductId", |
| | | getProductId().c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("OperationId", |
| | | getOperationId().c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("Glass1Id", |
| | | getGlass1Id().c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("Glass2Id", |
| | | getGlass2Id().c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("JobType", |
| | | std::to_string(getJobType()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("MaterialsType", |
| | | std::to_string(getMaterialsType()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("ProductType", |
| | | std::to_string(getProductType()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("DummyType", |
| | | std::to_string(getDummyType()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("SkipFlag", |
| | | std::to_string(getSkipFlag()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("ProcessFlag", |
| | | std::to_string(getProcessFlag()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("ProcessResonCode", |
| | | std::to_string(getProcessResonCode()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("LastGlassFlag", |
| | | std::to_string(getLastGlassFlag()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("FirstGlassFlag", |
| | | std::to_string(getFirstGlassFlag()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("QTime1", |
| | | std::to_string(getQTime(0)).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("QTime2", |
| | | std::to_string(getQTime(1)).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("QTime3", |
| | | std::to_string(getQTime(2)).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("QTimeOverFlag", |
| | | std::to_string(getQTimeOverFlag()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("MasterRecipe", |
| | | std::to_string(getMasterRecipe()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("ProductRecipeId", |
| | | getProductRecipeId().c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("PCode", |
| | | getPCode().c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("UseType", |
| | | getUseType().c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("PanelMeasure", |
| | | getPanelMeasure().c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("SlotUnitSelectFlag", |
| | | std::to_string(getSlotUnitSelectFlag()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("SourcePortNo", |
| | | std::to_string(getSourcePortNo()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("SourceSlotNo", |
| | | std::to_string(getSourceSlotNo()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("TargetPortNo", |
| | | std::to_string(getTargetPortNo()).c_str(), "", weight++)); |
| | | |
| | | attrubutes.addAttribute(new CAttribute("TargetSlotNo", |
| | | std::to_string(getTargetSlotNo()).c_str(), "", weight++)); |
| | | } |
| | | } |