1.Bonder 处理ProcessDataReport, 并将G1与G2绑定一起。
| | |
| | | |
| | | return bCheck; |
| | | } |
| | | |
| | | int CBonder::onProcessData(CProcessData* pProcessData) |
| | | { |
| | | CEquipment::onProcessData(pProcessData); |
| | | |
| | | |
| | | // 检查数据,当前两片玻璃,一片为G1, 一片为G2, 且pProcessData中的id能匹配G1或G2 |
| | | Lock(); |
| | | if (m_glassList.size() != 2) { |
| | | Unlock(); |
| | | LOGE("<CBonder-%s>onProcessData,绑定失败,腔体内必须有且仅有两片玻璃!", m_strName.c_str()); |
| | | return -1; |
| | | } |
| | | |
| | | CGlass* pGlass1 = m_glassList.front(); |
| | | CGlass* pGlass2 = m_glassList.back(); |
| | | Unlock(); |
| | | |
| | | if (pGlass1->getBuddy() != nullptr || pGlass2->getBuddy() != nullptr) { |
| | | LOGE("<CBonder-%s>onProcessData,错误!玻璃较早前已被绑定,请检查数据是否正确!", m_strName.c_str()); |
| | | return -1; |
| | | } |
| | | |
| | | if (pGlass1->getBuddy() != nullptr || pGlass2->getBuddy() != nullptr) { |
| | | LOGE("<CBonder-%s>onProcessData,错误!玻璃较早前已被贴合,请检查数据是否正确!", m_strName.c_str()); |
| | | return -1; |
| | | } |
| | | |
| | | if (pGlass1->getType() == pGlass2->getType()) { |
| | | LOGE("<CBonder-%s>onProcessData,错误!两片玻璃未匹配,必须分别为G1和G2类型,请检查数据是否正确!", m_strName.c_str()); |
| | | return -1; |
| | | } |
| | | |
| | | pGlass1->setBuddy(pGlass2); |
| | | pGlass2->setBuddy(pGlass1); |
| | | LOGE("<CBonder-%s>onProcessData,%s和%s已贴合!", m_strName.c_str(), |
| | | pGlass1->getID().c_str(), pGlass2->getID().c_str()); |
| | | |
| | | return 0; |
| | | } |
| | | } |
| | |
| | | virtual int recvIntent(CPin* pPin, CIntent* pIntent); |
| | | virtual BOOL glassWillArrive(CGlass* pGlass); |
| | | virtual BOOL onPreStoredJob(int port, CJobDataB* pJobDataB); |
| | | virtual int onProcessData(CProcessData* pProcessData); |
| | | |
| | | public: |
| | | void setIndex(unsigned int index); |
| | |
| | | Unlock(); |
| | | } |
| | | else { |
| | | Lock(); |
| | | // addGlassToList前不需要上锁,因其内部有锁 |
| | | int count; |
| | | ar >> count; |
| | | for (int i = 0; i < count; i++) { |
| | | CGlass* pGlass = new CGlass(); |
| | | pGlass->serialize(ar); |
| | | addGlassToList(pGlass); |
| | | } |
| | | |
| | | // 梳理各玻璃之间的绑定关系 |
| | | Lock(); |
| | | std::list<CGlass*> list = m_glassList; |
| | | for (auto item : list) { |
| | | std::string& strBuddyId = item->getBuddyId(); |
| | | if (!strBuddyId.empty()) { |
| | | for (auto item2 : m_glassList) { |
| | | if (strBuddyId.compare(item2->getID()) == 0) { |
| | | item->setBuddy(item2); |
| | | TRACE("绑定关系: %s <- %s\n", item->getID().c_str(), item2->getID().c_str()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | Unlock(); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | CGlass* CEquipment::getGlassFromList(const char* pszId) |
| | | { |
| | | CGlass* pGlass = nullptr; |
| | | Lock(); |
| | | for (auto item : m_glassList) { |
| | | if (item->getID().compare(pszId) == 0) { |
| | | pGlass = item; |
| | | break; |
| | | } |
| | | } |
| | | Unlock(); |
| | | |
| | | return pGlass; |
| | | } |
| | | |
| | | BOOL CEquipment::removeClass(CGlass* pGlass) |
| | | { |
| | | Lock(); |
| | |
| | | virtual int onStoredJob(int port, CJobDataB* pJobDataB); |
| | | virtual int onProcessData(CProcessData* pProcessData); |
| | | void getGlassList(std::list<CGlass*>& list); |
| | | CGlass* getGlassFromList(const char* pszId); |
| | | CGlass* getFrontGlass(); |
| | | BOOL removeClass(CGlass* pGlass); |
| | | bool isAlarmStep(SERVO::CStep* pStep); |
| | |
| | | { |
| | | m_pPath = nullptr; |
| | | m_type = MaterialsType::G1; |
| | | m_pBuddy = nullptr; |
| | | } |
| | | |
| | | CGlass::~CGlass() |
| | |
| | | pPath = pTemp; |
| | | } |
| | | m_pPath = nullptr; |
| | | |
| | | if (m_pBuddy != nullptr && m_type == MaterialsType::G1) { |
| | | m_pBuddy->release(); |
| | | } |
| | | } |
| | | |
| | | std::string& CGlass::getClassName() |
| | |
| | | if (ar.IsStoring()) |
| | | { |
| | | Lock(); |
| | | ar << (int)m_type; |
| | | WriteString(ar, m_strID); |
| | | ar << (ULONGLONG)m_pPath; |
| | | if (m_pPath != nullptr) { |
| | |
| | | ar.Write(temp, JOBDATAB_SIZE); |
| | | m_jobDataS.serialize(temp, JOBDATAS_SIZE); |
| | | ar.Write(temp, JOBDATAS_SIZE); |
| | | ar << (ULONGLONG)m_pBuddy; |
| | | WriteString(ar, m_strBuddyId); |
| | | Unlock(); |
| | | } |
| | | else |
| | | { |
| | | Lock(); |
| | | ReadString(ar, m_strID); |
| | | ULONGLONG ullPath; |
| | | int type; |
| | | |
| | | Lock(); |
| | | ar >> type; |
| | | m_type = (MaterialsType)type; |
| | | ReadString(ar, m_strID); |
| | | ar >> ullPath; |
| | | if (ullPath != 0) { |
| | | m_pPath = new CPath(); |
| | |
| | | m_jobDataB.unserialize(temp, JOBDATAB_SIZE); |
| | | ar.Read(temp, JOBDATAS_SIZE); |
| | | m_jobDataS.unserialize(temp, JOBDATAS_SIZE); |
| | | ar >> ullPath; // 这是m_pBuddy, 用不上 |
| | | ReadString(ar, m_strBuddyId); |
| | | Unlock(); |
| | | } |
| | | } |
| | |
| | | { |
| | | return &m_jobDataS; |
| | | } |
| | | |
| | | BOOL CGlass::setBuddy(CGlass* pGlass) |
| | | { |
| | | if (m_pBuddy != nullptr) return FALSE; |
| | | if (pGlass->getType() == this->getType()) return FALSE; |
| | | m_pBuddy = pGlass; |
| | | if (m_type == MaterialsType::G1) { |
| | | m_pBuddy->addRef(); |
| | | } |
| | | m_strBuddyId = m_pBuddy->getID(); |
| | | |
| | | return TRUE; |
| | | } |
| | | |
| | | CGlass* CGlass::getBuddy() |
| | | { |
| | | return m_pBuddy; |
| | | } |
| | | |
| | | std::string& CGlass::getBuddyId() |
| | | { |
| | | return m_strBuddyId; |
| | | } |
| | | } |
| | |
| | | CJobDataB* getJobDataB(); |
| | | void setJobDataS(CJobDataS* pJobDataS); |
| | | CJobDataS* getJobDataS(); |
| | | BOOL setBuddy(CGlass* pGlass); |
| | | CGlass* getBuddy(); |
| | | std::string& getBuddyId(); |
| | | |
| | | private: |
| | | MaterialsType m_type; |
| | |
| | | CPath* m_pPath; |
| | | CJobDataB m_jobDataB; |
| | | CJobDataS m_jobDataS; |
| | | CGlass* m_pBuddy; |
| | | std::string m_strBuddyId; |
| | | }; |
| | | } |
| | | |
| | |
| | | } |
| | | else if (nCmd == ID_EQSGRAPHITEM_TEST3) { |
| | | SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData; |
| | | if (pEquipment != nullptr) { |
| | | SERVO::CGlass* pGlass = pEquipment->getFrontGlass(); |
| | | if (pGlass != nullptr) { |
| | | SERVO::CProcessData pd; |
| | | pd.setGlassId(pGlass->getID().c_str()); |
| | | pEquipment->onProcessData(&pd); |
| | | } |
| | | } |
| | | } |
| | | else if (nCmd == ID_EQSGRAPHITEM_TEST4) { |
| | | SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData; |
| | | |
| | | // 测试下发Cim Message |
| | | /* |
| | |
| | | return m_strGlassId; |
| | | } |
| | | |
| | | void CProcessData::setGlassId(const char* pszId) |
| | | { |
| | | m_strGlassId = pszId; |
| | | } |
| | | |
| | | std::string& CProcessData::getStartTime() |
| | | { |
| | | return m_strStartTime; |
| | |
| | | |
| | | public: |
| | | std::string& getGlassId(); |
| | | void setGlassId(const char* pszId); |
| | | std::string& getStartTime(); |
| | | std::string& getEndTime(); |
| | | unsigned int getTotalParameter(); |