Merge branch 'clh' into liuyang
| | |
| | | return 0; // 校验通过 |
| | | } |
| | | |
| | | int CCCLinkIEControl::ReadData2(const StationIdentifier& station, short devType, short devNo, short size, void* pData) |
| | | int CCCLinkIEControl::ReadData2(const StationIdentifier& station, DeviceType enDevType, short devNo, short size, void* pData) |
| | | { |
| | | // 验证站点参数和数据有效性 |
| | | int nRet = ValidateStationAndSize(station, size); |
| | |
| | | // 确保线程安全的最小锁定范围 |
| | | { |
| | | std::lock_guard<std::mutex> lock(m_mtx); |
| | | nRet = mdReceive(m_nPath, CombineStation(station), devType, devNo, &size, pData); |
| | | const short nDevType = CalculateDeviceType(station, enDevType); |
| | | nRet = mdReceive(m_nPath, CombineStation(station), nDevType, devNo, &size, pData); |
| | | } |
| | | |
| | | if (nRet != 0) { |
| | |
| | | // 读取LED状态 |
| | | int ReadLedStatus(LedStatus& outLedStatus); |
| | | |
| | | int ReadData2(const StationIdentifier& station, short devType, short devNo, short size, void* pData); |
| | | int ReadData2(const StationIdentifier& station, DeviceType enDevType, short devNo, short size, void* pData); |
| | | |
| | | private: |
| | | static CCLinkIEControlMode ConvertToCCLinkIEControlMode(short nMode); |
| | |
| | | SPB = 0x0032, // 缓冲存储器 (字) |
| | | MAIL = 0x0065, // 特殊软元件类型:邮件类型 (10进制 101) |
| | | MAILMC = 0x0066, // 特殊软元件类型:无确认邮件 (10进制 102) |
| | | LX = 0x03E9, // 链接直接软元件 (链接输入) (0x03E9~0x04E7) (位) |
| | | LY = 0x07D1, // 链接直接软元件 (链接输出) (0x07D1~0x08CF) (位) |
| | | LB = 0x59D9, // 链接直接软元件 (链接继电器) (0x59D9~0x5AD7) (位) |
| | | LW = 0x5DC1, // 链接直接软元件 (链接寄存器) (0x5DC1~0x5EBF) (字) |
| | | LSB = 0x61A9, // 链接直接软元件 (链接特殊继电器) (0x61A9~0x62A7) (位) |
| | | LSW = 0x6D61, // 链接直接软元件 (链接特殊寄存器) (0x6D61~0x6E5F) (字) |
| | | SPG = 0x7148, // 智能功能模块软元件 (0x7148~0x7247) (字) |
| | | LX = 0x03E8, // 链接直接软元件 (链接输入) (0x03E9~0x04E7) (位) |
| | | LY = 0x07D0, // 链接直接软元件 (链接输出) (0x07D1~0x08CF) (位) |
| | | LB = 0x59D8, // 链接直接软元件 (链接继电器) (0x59D9~0x5AD7) (位) |
| | | LW = 0x5DC0, // 链接直接软元件 (链接寄存器) (0x5DC1~0x5EBF) (字) |
| | | LSB = 0x61A8, // 链接直接软元件 (链接特殊继电器) (0x61A9~0x62A7) (位) |
| | | LSW = 0x6D60, // 链接直接软元件 (链接特殊寄存器) (0x6D61~0x6E5F) (字) |
| | | SPG = 0x7147, // 智能功能模块软元件 (0x7148~0x7247) (字) |
| | | }; |
| | | |
| | | // 数据类型 |
| | |
| | | m_bLocalAlarm = FALSE; |
| | | m_bAutoRecipeChange = FALSE; |
| | | m_bVCREnable[0] = FALSE; |
| | | m_pCclink = nullptr; |
| | | InitializeCriticalSection(&m_criticalSection); |
| | | } |
| | | |
| | |
| | | { |
| | | m_listener.onAlive = listener.onAlive; |
| | | m_listener.onCimStateChanged = listener.onCimStateChanged; |
| | | } |
| | | |
| | | void CEquipment::setCcLink(CCCLinkIEControl* pCcLink) |
| | | { |
| | | m_pCclink = pCcLink; |
| | | } |
| | | |
| | | void CEquipment::getProperties(std::vector<std::pair<std::string, std::string>>& container) |
| | |
| | | { |
| | | auto iter = m_mapStep.find(addr); |
| | | if (iter != m_mapStep.end()) return -1; |
| | | pStep->setCcLink(m_pCclink); |
| | | m_mapStep[addr] = pStep; |
| | | return 0; |
| | | } |
| | |
| | | |
| | | void CEquipment::setReadBitBlock(unsigned int start, unsigned int end) |
| | | { |
| | | m_blockReadBit.type = (unsigned int)DeviceType::LB;; |
| | | m_blockReadBit.type = (unsigned int)DeviceType::B; |
| | | m_blockReadBit.start = start; |
| | | m_blockReadBit.end = end; |
| | | m_blockReadBit.size = (m_blockReadBit.end - m_blockReadBit.start + 1) / 8; |
| | |
| | | |
| | | void CEquipment::onReceiveLBData(const char* pszData, size_t size) |
| | | { |
| | | /* |
| | | TRACE("%s onReceiveLBData: %d bytes\n", m_strName.c_str(), size); |
| | | for (unsigned int i = 0; i < size; i++) { |
| | | if (pszData[i] != 0) |
| | | TRACE("%d[%x]\n", i, pszData[i]); |
| | | } |
| | | |
| | | */ |
| | | |
| | | // 以下解释和处理数据 |
| | | BOOL bFlag; |
| | |
| | | |
| | | // Equipment Mode Change Report |
| | | index = 0x360; |
| | | bFlag = isBitOn(pszData, size, ++index); |
| | | static int i; |
| | | i++; |
| | | if (i > 10) bFlag = TRUE; |
| | | if (i > 15) bFlag = FALSE; |
| | | if (i > 110) bFlag = TRUE; |
| | | if (i > 115) bFlag = FALSE; |
| | | //if (i == 12) bFlag = FALSE; |
| | | bFlag = isBitOn(pszData, size, index); |
| | | CStep* pStep = getStep(0x360); |
| | | if (pStep != nullptr) { |
| | | pStep->onSignal(bFlag); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | BOOL CEquipment::isBitOn(const char* pszData, size_t size, int index) |
| | |
| | | public: |
| | | virtual const char* getClassName() = 0; |
| | | virtual void setListener(EquipmentListener listener); |
| | | void setCcLink(CCCLinkIEControl* pCcLink); |
| | | void setID(int nID); |
| | | int getID(); |
| | | void setName(const char* pszName); |
| | |
| | | BOOL m_bVCREnable[VCR_MAX]; |
| | | |
| | | private: |
| | | CCCLinkIEControl* m_pCclink; |
| | | std::map<unsigned int, CStep*> m_mapStep; |
| | | }; |
| | | } |
| | |
| | | pEquipment->setName("EFEM(ROBOT)"); |
| | | pEquipment->setDescription("EFEM(ROBOT)."); |
| | | pEquipment->setReadBitBlock(0x4000, 0x45ff); |
| | | pEquipment->setStation(1, 2); |
| | | pEquipment->setStation(0, 255); |
| | | addEquipment(pEquipment); |
| | | |
| | | pEquipment->init(); |
| | |
| | | } |
| | | }; |
| | | pEquipment->setListener(listener); |
| | | pEquipment->setCcLink(&m_cclink); |
| | | m_listEquipment.push_back(pEquipment); |
| | | |
| | | return 0; |
| | |
| | | const StationIdentifier& station = item->getStation(); |
| | | MemoryBlock& block = item->getReadBitBlock(); |
| | | |
| | | int nRet = m_cclink.ReadData2(station, (short)block.type, |
| | | int nRet = m_cclink.ReadData2(station, (DeviceType)block.type, |
| | | block.start, block.size, block.buffer); |
| | | if (0 == nRet) { |
| | | item->onReceiveLBData(block.buffer, block.size); |
| | |
| | | m_hSignalOn = ::CreateEvent(NULL, TRUE, FALSE, NULL); |
| | | m_hSignalOff = ::CreateEvent(NULL, TRUE, FALSE, NULL); |
| | | m_nCurStep = 0; |
| | | m_pCclink = nullptr; |
| | | InitializeCriticalSection(&m_criticalSection); |
| | | } |
| | | |
| | |
| | | m_hSignalOff = nullptr; |
| | | |
| | | DeleteCriticalSection(&m_criticalSection); |
| | | } |
| | | |
| | | void CStep::setCcLink(CCCLinkIEControl* pCcLink) |
| | | { |
| | | m_pCclink = pCcLink; |
| | | } |
| | | |
| | | void CStep::init() |
| | |
| | | |
| | | // 1.读取数据 |
| | | nextStep(); |
| | | TRACE("m_nCurStep:%d\n", m_nCurStep); |
| | | |
| | | ASSERT(m_pCclink); |
| | | StationIdentifier station(0, 255); |
| | | DWordContainer dc; |
| | | m_pCclink->ReadDWordData(station, DeviceType::W, 0x4a8c, 1, dc); |
| | | int nState = dc.at(0); |
| | | TRACE(">> nState:%d\n", nState); |
| | | |
| | | // 2.给对方写ON |
| | | nextStep(); |
| | | TRACE("m_nCurStep:%d\n", m_nCurStep); |
| | | m_pCclink->SetBitDevice(station, DeviceType::B, 0x30); |
| | | |
| | | |
| | | // 3.等待对方OFF |
| | | nextStep(); |
| | | TRACE("m_nCurStep:%d\n", m_nCurStep); |
| | | int nStep3Ret = ::WaitForSingleObject(m_hSignalOff, TIMEOUT * 1000); |
| | | if (nStep3Ret == WAIT_TIMEOUT) { |
| | | timeout(); |
| | | m_pCclink->ResetBitDevice(station, DeviceType::B, 0x30); |
| | | goto RESET; |
| | | } |
| | | ResetEvent(m_hSignalOff); |
| | |
| | | |
| | | // 4.给对方写OFF |
| | | nextStep(); |
| | | m_pCclink->ResetBitDevice(station, DeviceType::B, 0x30); |
| | | TRACE("m_nCurStep:%d\n", m_nCurStep); |
| | | |
| | | |
| | |
| | | |
| | | void CStep::onSignal(BOOL bSignal) |
| | | { |
| | | TRACE(">>>>>>>>>>>>>>>>>>>> setSignal:%s\n", bSignal ? "ON" : "OFF"); |
| | | Lock(); |
| | | if (m_nCurStep == 0 && bSignal) { |
| | | SetEvent(m_hSignalOn); |
| | |
| | | #pragma once |
| | | #include "CCLinkIEControl.h" |
| | | |
| | | |
| | | namespace SERVO { |
| | |
| | | |
| | | public: |
| | | unsigned WorkingProc(); |
| | | void setCcLink(CCCLinkIEControl* pCcLink); |
| | | virtual void init(); |
| | | virtual void CStep::term(); |
| | | virtual void onSignal(BOOL bSignal); |
| | |
| | | void timeout(); |
| | | |
| | | private: |
| | | CCCLinkIEControl* m_pCclink; |
| | | CRITICAL_SECTION m_criticalSection; |
| | | std::string strName; |
| | | HANDLE m_hWorkThreadHandle; |