| | |
| | | CMaster::CMaster() |
| | | { |
| | | m_listener = {nullptr, nullptr, nullptr}; |
| | | m_bDataModify = FALSE; |
| | | } |
| | | |
| | | CMaster::~CMaster() |
| | |
| | | addLoadPort(1, listener); |
| | | addLoadPort(2, listener); |
| | | addLoadPort(3, listener); |
| | | addFliper(listener); |
| | | addVacuumBake(listener); |
| | | addAligner(listener); |
| | | addEFEM(listener); |
| | | addBonder(0, listener); |
| | | addBonder(1, listener); |
| | | addBakeCooling(listener); |
| | | connectEquipments(); |
| | | |
| | | |
| | | // 读缓存数据 |
| | | readCache(); |
| | | |
| | | |
| | | // 定时器 |
| | |
| | | for (auto item : m_listEquipment) { |
| | | item->term(); |
| | | } |
| | | saveCache(); |
| | | |
| | | |
| | | return 0; |
| | | } |
| | |
| | | m_listener.onEqCimStateChanged(this, p, bOn); |
| | | } |
| | | }; |
| | | listener.onDataChanged = [&](void* pEquipment, int code) -> void { |
| | | m_bDataModify = TRUE; |
| | | }; |
| | | |
| | | pEquipment->setListener(listener); |
| | | pEquipment->setCcLink(&m_cclink); |
| | | m_listEquipment.push_back(pEquipment); |
| | |
| | | LOGE("已添加“%s”.", pEquipment->getName().c_str()); |
| | | |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | int CMaster::addFliper(StepListener& listener) |
| | | { |
| | | CFliper* pEquipment = new CFliper(); |
| | | pEquipment->setID(EQ_ID_FLIPER); |
| | | pEquipment->setBaseAlarmId(BASE_ALARM_EFEM); |
| | | pEquipment->setName("Fliper"); |
| | | pEquipment->setDescription("Fliper."); |
| | | pEquipment->setReadBitBlock(0x4000, 0x45ff); |
| | | pEquipment->setStation(0, 255); |
| | | addToEquipmentList(pEquipment); |
| | | |
| | | |
| | | pEquipment->init(); |
| | | LOGE("已添加“Fliper”."); |
| | | return 0; |
| | | } |
| | | |
| | | int CMaster::addVacuumBake(StepListener& listener) |
| | | { |
| | | CVacuumBake* pEquipment = new CVacuumBake(); |
| | | pEquipment->setID(EQ_ID_VACUUMBAKE); |
| | | pEquipment->setBaseAlarmId(BASE_ALARM_EFEM); |
| | | pEquipment->setName("VacuumBake"); |
| | | pEquipment->setDescription("VacuumBake."); |
| | | pEquipment->setReadBitBlock(0x4000, 0x45ff); |
| | | pEquipment->setStation(0, 255); |
| | | addToEquipmentList(pEquipment); |
| | | |
| | | |
| | | pEquipment->init(); |
| | | LOGE("已添加“VacuumBake”."); |
| | | return 0; |
| | | } |
| | | |
| | | int CMaster::addAligner(StepListener& listener) |
| | | { |
| | | CAligner* pEquipment = new CAligner(); |
| | | pEquipment->setID(EQ_ID_ALIGNER); |
| | | pEquipment->setBaseAlarmId(BASE_ALARM_EFEM); |
| | | pEquipment->setName("Aligner"); |
| | | pEquipment->setDescription("Aligner."); |
| | | pEquipment->setReadBitBlock(0x4000, 0x45ff); |
| | | pEquipment->setStation(0, 255); |
| | | addToEquipmentList(pEquipment); |
| | | |
| | | |
| | | pEquipment->init(); |
| | | LOGE("已添加“Aligner”."); |
| | | return 0; |
| | | } |
| | | |
| | |
| | | return 0; |
| | | } |
| | | |
| | | int CMaster::addBakeCooling(StepListener& listener) |
| | | { |
| | | CBakeCooling* pEquipment = new CBakeCooling(); |
| | | pEquipment->setID(EQ_ID_BAKE_COOLING); |
| | | pEquipment->setBaseAlarmId(BASE_ALARM_EFEM); |
| | | pEquipment->setName("BakeCooling"); |
| | | pEquipment->setDescription("BakeCooling."); |
| | | pEquipment->setReadBitBlock(0x4000, 0x45ff); |
| | | pEquipment->setStation(0, 255); |
| | | addToEquipmentList(pEquipment); |
| | | |
| | | |
| | | pEquipment->init(); |
| | | LOGE("已添加“Aligner”."); |
| | | return 0; |
| | | } |
| | | |
| | | void CMaster::onTimer(UINT nTimerid) |
| | | { |
| | | for (auto item : m_listEquipment) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // 自动保存缓存 |
| | | if (i % (4 * 2) == 0) { |
| | | if (m_bDataModify) { |
| | | saveCacheAndBackups(); |
| | | m_bDataModify = FALSE; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | void CMaster::connectEquipments() |
| | | { |
| | | int nRet; |
| | | CLoadPort* pLoadPort1 = (CLoadPort*)getEquipment(EQ_ID_LOADPORT1); |
| | | CLoadPort* pLoadPort2 = (CLoadPort*)getEquipment(EQ_ID_LOADPORT2); |
| | | CLoadPort* pLoadPort3 = (CLoadPort*)getEquipment(EQ_ID_LOADPORT3); |
| | | CLoadPort* pLoadPort4 = (CLoadPort*)getEquipment(EQ_ID_LOADPORT4); |
| | | CFliper* pFliper = (CFliper*)getEquipment(EQ_ID_FLIPER); |
| | | CVacuumBake* pVacuumBake = (CVacuumBake*)getEquipment(EQ_ID_VACUUMBAKE); |
| | | CAligner* pAligner = (CAligner*)getEquipment(EQ_ID_ALIGNER); |
| | | CBonder* pBonder1 = (CBonder*)getEquipment(EQ_ID_Bonder1); |
| | | CBonder* pBonder2 = (CBonder*)getEquipment(EQ_ID_Bonder2); |
| | | CBakeCooling* pBakeCooling = (CBakeCooling*)getEquipment(EQ_ID_BAKE_COOLING); |
| | | |
| | | int nRet = pLoadPort1->getPin("Out")->connectPin(pBonder1->getPin("In")); |
| | | nRet = pLoadPort1->getPin("Out1")->connectPin(pFliper->getPin("In1")); |
| | | if (nRet < 0) { |
| | | AfxMessageBox("连接失败"); |
| | | LOGE("连接LoadPort1-Fliper失败"); |
| | | } |
| | | else { |
| | | // AfxMessageBox("连接成功"); |
| | | nRet = pLoadPort2->getPin("Out1")->connectPin(pFliper->getPin("In2")); |
| | | if (nRet < 0) { |
| | | LOGE("连接LoadPort1-Fliper失败"); |
| | | } |
| | | |
| | | nRet = pLoadPort1->getPin("Out2")->connectPin(pVacuumBake->getPin("In1")); |
| | | if (nRet < 0) { |
| | | LOGE("连接LoadPort1-VacuumBake失败"); |
| | | } |
| | | nRet = pLoadPort2->getPin("Out2")->connectPin(pVacuumBake->getPin("In2")); |
| | | if (nRet < 0) { |
| | | LOGE("连接LoadPort1-VacuumBake失败"); |
| | | } |
| | | |
| | | nRet = pFliper->getPin("Out")->connectPin(pAligner->getPin("In1")); |
| | | if (nRet < 0) { |
| | | LOGE("连接Fliper-Aligner失败"); |
| | | } |
| | | |
| | | nRet = pVacuumBake->getPin("Out")->connectPin(pAligner->getPin("In2")); |
| | | if (nRet < 0) { |
| | | LOGE("连接VacuumBake-Aligner失败"); |
| | | } |
| | | |
| | | nRet = pAligner->getPin("Out1")->connectPin(pBonder1->getPin("In")); |
| | | if (nRet < 0) { |
| | | LOGE("连接Aligner-Bondere1失败"); |
| | | } |
| | | |
| | | nRet = pAligner->getPin("Out2")->connectPin(pBonder2->getPin("In")); |
| | | if (nRet < 0) { |
| | | LOGE("连接Aligner-Bondere2失败"); |
| | | } |
| | | |
| | | nRet = pBonder1->getPin("Out")->connectPin(pBakeCooling->getPin("In1")); |
| | | if (nRet < 0) { |
| | | LOGE("连接Bonder1-BakeCooling失败"); |
| | | } |
| | | |
| | | nRet = pBonder2->getPin("Out")->connectPin(pBakeCooling->getPin("In2")); |
| | | if (nRet < 0) { |
| | | LOGE("连接Bonder2-BakeCooling失败"); |
| | | } |
| | | |
| | | nRet = pBakeCooling->getPin("Out1")->connectPin(pLoadPort3->getPin("In")); |
| | | if (nRet < 0) { |
| | | LOGE("连接BakeCooling-LoadPort3失败"); |
| | | } |
| | | |
| | | nRet = pBakeCooling->getPin("Out2")->connectPin(pLoadPort4->getPin("In")); |
| | | if (nRet < 0) { |
| | | LOGE("连接BakeCooling-LoadPort4失败"); |
| | | } |
| | | } |
| | | |
| | | int CMaster::saveCache() |
| | | { |
| | | CFile file; |
| | | if (!file.Open(m_strFilepath.c_str(), CFile::modeCreate | CFile::modeWrite)) { |
| | | return -1; |
| | | } |
| | | |
| | | CArchive ar(&file, CArchive::store); |
| | | serialize(ar); |
| | | ar.Close(); |
| | | file.Close(); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | int CMaster::saveCacheAndBackups() |
| | | { |
| | | saveCache(); |
| | | |
| | | |
| | | // 创建备份目录 |
| | | CString strNewFile; |
| | | CString strFileDir = m_strFilepath.c_str(); |
| | | int index = strFileDir.ReverseFind('\\'); |
| | | ASSERT(index > 0); |
| | | strFileDir = strFileDir.Left(index); |
| | | strFileDir = strFileDir + _T("Backups"); |
| | | ::CreateDirectory(strFileDir, nullptr); |
| | | |
| | | CTime time = CTime::GetCurrentTime(); |
| | | strNewFile.Format(_T("%s//Master_%d_%02d_%02d_%02d_%02d_%02d.dat"), |
| | | (LPTSTR)(LPCTSTR)strFileDir, |
| | | time.GetYear(), time.GetMonth(), time.GetDay(), |
| | | time.GetHour(), time.GetMinute(), time.GetSecond()); |
| | | ::CopyFile(m_strFilepath.c_str(), strNewFile, FALSE); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | void CMaster::setCacheFilepath(const char* pszFilepath) |
| | | { |
| | | m_strFilepath = pszFilepath; |
| | | } |
| | | |
| | | int CMaster::readCache() |
| | | { |
| | | CFile file; |
| | | if (!file.Open(m_strFilepath.c_str(), CFile::modeRead)) { |
| | | return -1; |
| | | } |
| | | |
| | | CArchive ar(&file, CArchive::load); |
| | | serialize(ar); |
| | | ar.Close(); |
| | | file.Close(); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | void CMaster::serialize(CArchive& ar) |
| | | { |
| | | for (auto item : m_listEquipment) { |
| | | item->serialize(ar); |
| | | } |
| | | } |
| | | } |