| | |
| | | #include "CDataMonitor1.h" |
| | | #include "AlarmMonitor.h" |
| | | #include "LoadMonitor.h" |
| | | #include "ToolUnits.h" |
| | | #include "Model.h" |
| | | |
| | | |
| | | CBonder* g_pBonder = NULL; |
| | |
| | | m_strEquipmentModelType = "2860"; |
| | | m_strSoftRev = "1.01"; |
| | | m_pPlcData = nullptr; |
| | | m_pModel = nullptr; |
| | | m_bMute = false; |
| | | m_nVelocityRatio = 0; |
| | | m_dTactTime = 0.0; |
| | | m_nDayShiftCapacity = 0; |
| | | m_nNightShiftCapacity = 0; |
| | | InitializeCriticalSection(&m_criticalSection); |
| | | } |
| | | |
| | |
| | | m_listener.onPlcStateChanged = listener.onPlcStateChanged; |
| | | m_listener.onEfemStateChanged = listener.onEfemStateChanged; |
| | | m_listener.onRecvBroadcast = listener.onRecvBroadcast; |
| | | } |
| | | |
| | | void CBonder::setModel(CModel* pModel) |
| | | { |
| | | m_pModel = pModel; |
| | | } |
| | | |
| | | const std::vector<CComponent*>& CBonder::getComponents() |
| | |
| | | { |
| | | // 机器状态 |
| | | CEQStateMonitor* pEQStateMonitor1 = new CEQStateMonitor(); |
| | | pEQStateMonitor1->setName("机器状态(A单元)"); |
| | | pEQStateMonitor1->setDescription("A单机器状态"); |
| | | pEQStateMonitor1->setName("机器状态"); |
| | | pEQStateMonitor1->setDescription("机器状态"); |
| | | pEQStateMonitor1->setIndex(0); |
| | | pEQStateMonitor1->setBeginAddr(4463 - 4400); |
| | | AddComponent(pEQStateMonitor1); |
| | | pEQStateMonitor1->init(); |
| | | |
| | | CEQStateMonitor* pEQStateMonitor2 = new CEQStateMonitor(); |
| | | pEQStateMonitor2->setName("机器状态(B单元)"); |
| | | pEQStateMonitor2->setDescription("B单机器状态"); |
| | | pEQStateMonitor2->setIndex(1); |
| | | pEQStateMonitor2->setBeginAddr(4563 - 4500); |
| | | AddComponent(pEQStateMonitor2); |
| | | pEQStateMonitor2->init(); |
| | | |
| | | m_bMute = false; |
| | | |
| | | // 初始化各种组件 |
| | | // 读PLC1配置 |
| | |
| | | c->onData(id, &m_pPlcData[400], 184); |
| | | } |
| | | } |
| | | else if (id == MONITOR_ID_ALARM) { |
| | | for (auto c : m_components) { |
| | | c->onData(id, &m_pPlcData[600], 260); |
| | | } |
| | | } |
| | | }; |
| | | pPlc->setListener(listener); |
| | | pPlc->addMonitor(1, 4400, 4499, MC::SOFT_COMPONENT::D, m_pPlcData); |
| | | pPlc->addMonitor(2, 4500, 4599, MC::SOFT_COMPONENT::D, &m_pPlcData[200]); |
| | | pPlc->addMonitor(3, 4700, 4791, MC::SOFT_COMPONENT::D, &m_pPlcData[400]); |
| | | pPlc->addMonitor(MONITOR_ID_ALARM, 10001, 10064, MC::SOFT_COMPONENT::M, &m_pPlcData[600]); |
| | | |
| | | pPlc->setName("PLC(1)"); |
| | | pPlc->setDescription("PLC"); |
| | | pPlc->setIndex(0); |
| | |
| | | |
| | | |
| | | CDataMonitor1* pDataMonitor1 = new CDataMonitor1(); |
| | | pDataMonitor1->setName("数据监控(A单元)"); |
| | | pDataMonitor1->setDescription("A单元真空、压力和温度数据"); |
| | | pDataMonitor1->setName("数据监控"); |
| | | pDataMonitor1->setDescription("真空、压力和温度数据"); |
| | | pDataMonitor1->setIndex(0); |
| | | pDataMonitor1->setResponseAddr(4425); |
| | | pDataMonitor1->enableAutoSendData(bAutoSendData); |
| | | AddComponent(pDataMonitor1); |
| | | pDataMonitor1->init(); |
| | | |
| | | CDataMonitor1* pDataMonitor2 = new CDataMonitor1(); |
| | | pDataMonitor2->setName("数据监控(B单元)"); |
| | | pDataMonitor2->setDescription("B单元真空、压力和温度数据"); |
| | | pDataMonitor2->setIndex(1); |
| | | pDataMonitor2->setResponseAddr(4525); |
| | | pDataMonitor2->enableAutoSendData(bAutoSendData); |
| | | AddComponent(pDataMonitor2); |
| | | pDataMonitor2->init(); |
| | | |
| | | |
| | | |
| | | CString strAlarmFile; |
| | | strAlarmFile.Format(_T("%s\\AlarmList.txt"), m_strWorkDir.c_str()); |
| | | CAlarmMonitor* pAlarmMonitor1 = new CAlarmMonitor(); |
| | | pAlarmMonitor1->setName("警告信息(A单元)"); |
| | | pAlarmMonitor1->setDescription("警告信息监控(A单元)"); |
| | | pAlarmMonitor1->setBeginAddr(4461 - 4400); |
| | | pAlarmMonitor1->setName("警告信息"); |
| | | pAlarmMonitor1->setDescription("警告信息监控"); |
| | | pAlarmMonitor1->setIndex(0); |
| | | pAlarmMonitor1->readAlarmListFromFile((LPTSTR)(LPCTSTR)strAlarmFile); |
| | | AddComponent(pAlarmMonitor1); |
| | | pAlarmMonitor1->init(); |
| | | |
| | | CAlarmMonitor* pAlarmMonitor2 = new CAlarmMonitor(); |
| | | pAlarmMonitor2->setName("警告信息(B单元)"); |
| | | pAlarmMonitor2->setDescription("警告信息监控(B单元)"); |
| | | pAlarmMonitor2->setBeginAddr(4561 - 4500); |
| | | pAlarmMonitor2->setIndex(1); |
| | | pAlarmMonitor2->readAlarmListFromFile((LPTSTR)(LPCTSTR)strAlarmFile); |
| | | AddComponent(pAlarmMonitor2); |
| | | pAlarmMonitor2->init(); |
| | | |
| | | // LoadMonitor |
| | | CLoadMonitor* pLoadMonitor1 = new CLoadMonitor(); |
| | | pLoadMonitor1->setName("上下料(A单元)"); |
| | | pLoadMonitor1->setDescription("上下料信号监控(A单元)"); |
| | | pLoadMonitor1->setName("上下料"); |
| | | pLoadMonitor1->setDescription("上下料信号监控"); |
| | | pLoadMonitor1->setBeginAddr(4700); |
| | | pLoadMonitor1->setIndex(0); |
| | | AddComponent(pLoadMonitor1); |
| | | pLoadMonitor1->init(); |
| | | |
| | | CLoadMonitor* pLoadMonitor2 = new CLoadMonitor(); |
| | | pLoadMonitor2->setName("上下料(B单元)"); |
| | | pLoadMonitor2->setDescription("上下料信号监控(B单元)"); |
| | | pLoadMonitor2->setBeginAddr(4700); |
| | | pLoadMonitor2->setIndex(1); |
| | | AddComponent(pLoadMonitor2); |
| | | pLoadMonitor2->init(); |
| | | |
| | | CLoadMonitor* pLoadMonitor3 = new CLoadMonitor(); |
| | | pLoadMonitor3->setName("上下料(冷却箱)"); |
| | | pLoadMonitor3->setDescription("上下料信号监控(冷却箱)"); |
| | | pLoadMonitor3->setBeginAddr(4700); |
| | | pLoadMonitor3->setIndex(2); |
| | | AddComponent(pLoadMonitor3); |
| | | pLoadMonitor3->init(); |
| | | |
| | | |
| | | // BEQ与EFEM通讯 |
| | |
| | | }; |
| | | m_pEquipment->setEquipmentListener(equListener); |
| | | m_pEquipment->setVersion(m_strSoftRev.c_str()); |
| | | m_pEquipment->addUnit(UNITA, 5); |
| | | m_pEquipment->addUnit(UNITB, 5); |
| | | BEQ::IUnit* pUnitC = m_pEquipment->addUnit(UNITC, 1); |
| | | pUnitC->setLayerCount(4); |
| | | m_pEquipment->addUnit(UNIT1, 5); |
| | | m_pEquipment->runOnServerMode(8192); |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | if (BC_CODE_RUN_RECIPE_RESULT == code) { |
| | | int errorCode = (int)pIntent->getContext(); |
| | | int errorCode = (int)(__int64)pIntent->getContext(); |
| | | m_pEquipment->repLoadReadyComplete(errorCode); |
| | | } |
| | | } |
| | |
| | | if (iii % 5 == 0) { |
| | | save(); |
| | | } |
| | | |
| | | // 需要定时读取的数据 |
| | | readTaktTime(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // 测试 |
| | | BOOL bTest = FALSE; |
| | | if (bTest) { |
| | | static int xx = 0; |
| | | xx++; |
| | | memset(&m_pPlcData[600], 0, 260); |
| | | if (xx == 12) { |
| | | m_pPlcData[600] = 0x01; |
| | | for (auto c : m_components) { |
| | | c->onData(MONITOR_ID_ALARM, &m_pPlcData[600], 260); |
| | | } |
| | | } |
| | | else if (xx == 20) { |
| | | m_pPlcData[600] = 0x00; |
| | | for (auto c : m_components) { |
| | | c->onData(MONITOR_ID_ALARM, &m_pPlcData[600], 260); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | void CBonder::AddComponent(CComponent* pComponent) |
| | |
| | | BEQ::IUnit* CBonder::getUnit(int index) |
| | | { |
| | | if (index == 0) |
| | | return m_pEquipment->getUnit(UNITA); |
| | | if (index == 1) |
| | | return m_pEquipment->getUnit(UNITB); |
| | | if (index == 2) |
| | | return m_pEquipment->getUnit(UNITC); |
| | | return m_pEquipment->getUnit(UNIT1); |
| | | |
| | | return nullptr; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | // 单元C为水冷塔,不需要写 |
| | | if (strcmp(szUnitName, UNITC) == 0) { |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | // 如果是单元A或单元B, 写物料ID和配方ID到PLC |
| | | CLoadMonitor* pLoadMonitor = nullptr; |
| | | if (strcmp(szUnitName, UNITA) == 0) { |
| | | if (strcmp(szUnitName, UNIT1) == 0) { |
| | | |
| | | pLoadMonitor = (CLoadMonitor*)GetComponent("上下料(A单元)"); |
| | | pLoadMonitor = (CLoadMonitor*)GetComponent("上下料"); |
| | | return pLoadMonitor->loadReady(pszMaterielId, pszRecipeId); |
| | | } |
| | | else if (strcmp(szUnitName, UNITB) == 0) { |
| | | |
| | | pLoadMonitor = (CLoadMonitor*)GetComponent("上下料(B单元)"); |
| | | return pLoadMonitor->loadReady(pszMaterielId, pszRecipeId); |
| | | } |
| | | |
| | | return -2; |
| | | } |
| | |
| | | if (!pPLC->isConnected()) { |
| | | return -1; |
| | | } |
| | | if (layer <= 0 || layer > 4) { |
| | | if (layer <= 0 || layer > 1) { |
| | | return -2; |
| | | } |
| | | |
| | |
| | | |
| | | // д |
| | | int index, nFlagAddr; |
| | | if (strcmp(szUnitName, UNITA) == 0) { |
| | | if (strcmp(szUnitName, UNIT1) == 0) { |
| | | index = 0; |
| | | nFlagAddr = 4710; |
| | | szBuffer[index * 2] |= 0x02; |
| | | } |
| | | else if (strcmp(szUnitName, UNITB) == 0) { |
| | | index = 1; |
| | | nFlagAddr = 4711; |
| | | szBuffer[index * 2] |= 0x02; |
| | | } |
| | | else if (strcmp(szUnitName, UNITC) == 0) { |
| | | index = 2; |
| | | nFlagAddr = 4712; |
| | | switch (layer) |
| | | { |
| | | case 1: |
| | | szBuffer[index * 2] |= 0x01; |
| | | break; |
| | | case 2: |
| | | szBuffer[index * 2] |= 0x02; |
| | | break; |
| | | case 3: |
| | | szBuffer[index * 2] |= 0x04; |
| | | break; |
| | | case 4: |
| | | szBuffer[index * 2] |= 0x08; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // д |
| | | int index, nFlagAddr; |
| | | if (strcmp(szUnitName, UNITA) == 0) { |
| | | if (strcmp(szUnitName, UNIT1) == 0) { |
| | | index = 0; |
| | | nFlagAddr = 4710; |
| | | szBuffer[index * 2 + 1] |= 0x02; |
| | | } |
| | | else if (strcmp(szUnitName, UNITB) == 0) { |
| | | index = 1; |
| | | nFlagAddr = 4711; |
| | | szBuffer[index * 2 + 1] |= 0x02; |
| | | } |
| | | else if (strcmp(szUnitName, UNITC) == 0) { |
| | | index = 2; |
| | | nFlagAddr = 4712; |
| | | switch (layer) |
| | | { |
| | | case 1: |
| | | szBuffer[index * 2] |= 0x20; |
| | | break; |
| | | case 2: |
| | | szBuffer[index * 2] |= 0x40; |
| | | break; |
| | | case 3: |
| | | szBuffer[index * 2] |= 0x80; |
| | | break; |
| | | case 4: |
| | | szBuffer[index * 2 + 1] |= 0x01; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | return iter->second; |
| | | } |
| | | |
| | | bool CBonder::isMute() |
| | | { |
| | | return m_bMute; |
| | | } |
| | | |
| | | void CBonder::setMute(bool bMute) |
| | | { |
| | | m_bMute = bMute; |
| | | } |
| | | |
| | | double CBonder::getTackTime() |
| | | { |
| | | return m_dTactTime; |
| | | } |
| | | |
| | | #define ADDR_NIGHT_SHIFT_CAPACTITY 2027 |
| | | void CBonder::readTaktTime() |
| | | { |
| | | CPLC* pPlc = getPLC("PLC(1)"); |
| | | if (pPlc == nullptr || !pPlc->isConnected()) return; |
| | | |
| | | { |
| | | auto funOnReadData = [this](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) -> void { |
| | | if (nDataSize == 2 && flag == 0) { |
| | | bool bMute = CToolUnits::toInt16(&pData[0]) != 0; |
| | | if (m_bMute != bMute) { |
| | | m_bMute = bMute; |
| | | m_pModel->notify(RX_CODE_BONDER_BEEP); |
| | | } |
| | | } |
| | | }; |
| | | pPlc->readData(MC::M, 1003, 2, funOnReadData); |
| | | } |
| | | |
| | | { |
| | | auto funOnReadData = [this](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) -> void { |
| | | if (nDataSize == 2 && flag == 0) { |
| | | int nVelocityRatio = CToolUnits::toInt16(&pData[0]); |
| | | if (nVelocityRatio != m_nVelocityRatio) { |
| | | m_nVelocityRatio = nVelocityRatio; |
| | | m_pModel->notifyInt(RX_CODE_BONDER_VELOCITY_RATIO, m_nVelocityRatio); |
| | | } |
| | | } |
| | | }; |
| | | pPlc->readData(MC::D, 530, 2, funOnReadData); |
| | | } |
| | | |
| | | { |
| | | auto funOnReadData = [this](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) -> void { |
| | | if (nDataSize == 2 && flag == 0) { |
| | | double dTactTime = (double)CToolUnits::toInt16(&pData[0]); |
| | | if (dTactTime != m_dTactTime) { |
| | | m_dTactTime = dTactTime; |
| | | m_pModel->notifyDouble(RX_CODE_BONDER_TACT_TIME, m_dTactTime); |
| | | } |
| | | } |
| | | }; |
| | | pPlc->readData(MC::ZR, 1500, 2, funOnReadData); |
| | | } |
| | | |
| | | { |
| | | auto funOnReadData = [this](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) -> void { |
| | | if (nDataSize == (ADDR_NIGHT_SHIFT_CAPACTITY - 2012 + 1) * 2 && flag == 0) { |
| | | int nDayShiftCapacity = CToolUnits::toInt16(&pData[0]); |
| | | int nNightShiftCapacity = CToolUnits::toInt16(&pData[(ADDR_NIGHT_SHIFT_CAPACTITY - 2012) * 2]); |
| | | if (nDayShiftCapacity != m_nDayShiftCapacity) { |
| | | m_nDayShiftCapacity = nDayShiftCapacity; |
| | | m_pModel->notifyInt(RX_CODE_BONDER_DAY_SHIFT_CAPACTITY, nDayShiftCapacity); |
| | | } |
| | | if (nNightShiftCapacity != m_nNightShiftCapacity) { |
| | | m_nNightShiftCapacity = nNightShiftCapacity; |
| | | m_pModel->notifyInt(RX_CODE_BONDER_NIGHT_SHIFT_CAPACTITY, nNightShiftCapacity); |
| | | } |
| | | |
| | | } |
| | | }; |
| | | pPlc->readData(MC::ZR, 2012, (ADDR_NIGHT_SHIFT_CAPACTITY - 2012 + 1)*2, funOnReadData); |
| | | } |
| | | |
| | | { |
| | | int nStartAddress = 1000; |
| | | int nEndAddress = 1200; |
| | | int nReadSize = (nEndAddress - nStartAddress + 1) * 2; |
| | | auto funOnReadData = [this, nStartAddress, nReadSize](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) -> void { |
| | | if (nDataSize == nReadSize && flag == 0) { |
| | | bool bValue0 = CToolUnits::toInt16(&pData[(1103 - nStartAddress) * 2]) != 0; // 启动 |
| | | bool bValue1 = CToolUnits::toInt16(&pData[(1100 - nStartAddress) * 2]) != 0; // 自动 |
| | | bool bValue2 = CToolUnits::toInt16(&pData[(1104 - nStartAddress) * 2]) != 0; // 暂停 |
| | | bool bValue3 = CToolUnits::toInt16(&pData[(1100 - nStartAddress) * 2]) != 0; // 手动 |
| | | bool bValue4 = CToolUnits::toInt16(&pData[(1003 - nStartAddress) * 2]) != 0; // 静音 |
| | | bool bValue5 = CToolUnits::toInt16(&pData[(1150 - nStartAddress) * 2]) != 0; // 复位 |
| | | bool bValue6 = CToolUnits::toInt16(&pData[(1114 - nStartAddress) * 2]) != 0; // ֹͣ |
| | | |
| | | bValue4 = pData[0] & 0x8; |
| | | bValue3 = pData[100*2/8] & 0x1; |
| | | if (m_bBlBtnsStates[0] != bValue0) { |
| | | m_bBlBtnsStates[0] = bValue0; |
| | | m_pModel->notifyInt(RX_CODE_BONDER_STATES_BTN0, bValue0); |
| | | } |
| | | |
| | | if (m_bBlBtnsStates[1] != bValue1) { |
| | | m_bBlBtnsStates[1] = bValue1; |
| | | m_pModel->notifyInt(RX_CODE_BONDER_STATES_BTN1, bValue1); |
| | | } |
| | | |
| | | if (m_bBlBtnsStates[2] != bValue2) { |
| | | m_bBlBtnsStates[2] = bValue2; |
| | | m_pModel->notifyInt(RX_CODE_BONDER_STATES_BTN2, bValue2); |
| | | } |
| | | |
| | | if (m_bBlBtnsStates[3] != bValue3) { |
| | | m_bBlBtnsStates[3] = bValue3; |
| | | m_pModel->notifyInt(RX_CODE_BONDER_STATES_BTN3, bValue3); |
| | | } |
| | | |
| | | if (m_bBlBtnsStates[4] != bValue4) { |
| | | m_bBlBtnsStates[4] = bValue4; |
| | | m_pModel->notifyInt(RX_CODE_BONDER_STATES_BTN4, bValue4); |
| | | } |
| | | |
| | | if (m_bBlBtnsStates[5] != bValue5) { |
| | | m_bBlBtnsStates[5] = bValue5; |
| | | m_pModel->notifyInt(RX_CODE_BONDER_STATES_BTN5, bValue5); |
| | | } |
| | | |
| | | if (m_bBlBtnsStates[6] != bValue6) { |
| | | m_bBlBtnsStates[6] = bValue6; |
| | | m_pModel->notifyInt(RX_CODE_BONDER_STATES_BTN6, bValue6); |
| | | } |
| | | } |
| | | }; |
| | | pPlc->readData(MC::M, nStartAddress, nReadSize, funOnReadData); |
| | | } |
| | | } |