| | |
| | | #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() |
| | |
| | | if (iii % 5 == 0) { |
| | | save(); |
| | | } |
| | | |
| | | // 需要定时读取的数据 |
| | | readTaktTime(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // 测试 |
| | |
| | | { |
| | | 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); |
| | | } |
| | | } |