| | |
| | | #include "stdafx.h" |
| | | #include "CEFEM.h" |
| | | #include "Log.h" |
| | | |
| | | |
| | | #define ADD_EQ_CASSETTE_TRANSFER_STATE_STEP(name,ws,index,psd) { \ |
| | |
| | | m_pPort[1] = nullptr; |
| | | m_pPort[2] = nullptr; |
| | | m_pPort[3] = nullptr; |
| | | m_pAligner = nullptr; |
| | | m_pFliper = nullptr; |
| | | } |
| | | |
| | | CEFEM::~CEFEM() |
| | |
| | | if (index < 4) { |
| | | m_pPort[index] = pPort; |
| | | } |
| | | } |
| | | |
| | | void CEFEM::setAligner(CAligner* pAligner) |
| | | { |
| | | m_pAligner = pAligner; |
| | | } |
| | | |
| | | void CEFEM::setFliper(CFliper* pFliper) |
| | | { |
| | | m_pFliper = pFliper; |
| | | } |
| | | |
| | | void CEFEM::setArmTray(unsigned int index, CArmTray* pArmTray) |
| | | { |
| | | if (index < 2) { |
| | | m_pArmTray[index] = pArmTray; |
| | | } |
| | | } |
| | | |
| | | int CEFEM::robotCmd(ROBOT_CMD_PARAM& robotCmdParam, ONWRITED onWritedBlock/* = nullptr*/) |
| | | { |
| | | SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(STEP_EFEM_ROBOT_CMD); |
| | | if (pStep == nullptr) { |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CEFEM-%s>准备发送RobotCmd<%d>", m_strName.c_str(), (int)robotCmdParam.rcmd); |
| | | if (onWritedBlock != nullptr) { |
| | | pStep->writeDataEx((const char*)&robotCmdParam, ROBOT_CMD_PARAM_SIZE, onWritedBlock); |
| | | } |
| | | else { |
| | | pStep->writeDataEx((const char*)&robotCmdParam, ROBOT_CMD_PARAM_SIZE, [&](int code) -> int { |
| | | if (code == WOK) { |
| | | LOGI("<CEFEM-%s>发送RobotCmd成功.", m_strName.c_str()); |
| | | } |
| | | else { |
| | | LOGI("<CEFEM-%s>发送RobotCmd失败,code:%d", m_strName.c_str(), code); |
| | | } |
| | | |
| | | return 0; |
| | | }); |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | int CEFEM::robotCmds(ROBOT_CMD_PARAM* robotCmdParam, unsigned int count, ONWRITED onWritedBlock/* = nullptr*/) |
| | | { |
| | | SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(STEP_EFEM_ROBOT_CMD); |
| | | if (pStep == nullptr) { |
| | | return -1; |
| | | } |
| | | |
| | | |
| | | // 平铺到内存中,如果ROBOT_CMD_PARAM不是4的整数倍,只能一个一个复制 |
| | | std::string strLog = "准备发送RobotCmds<"; |
| | | char szBuffer[ROBOT_CMD_PARAM_SIZE * 4]; |
| | | for (int i = 0; i < min(4, count); i++) { |
| | | memcpy(&szBuffer[i * ROBOT_CMD_PARAM_SIZE], (robotCmdParam + i), ROBOT_CMD_PARAM_SIZE); |
| | | strLog += std::to_string((robotCmdParam + i)->rcmd); |
| | | strLog += ","; |
| | | LOGI("%d", (robotCmdParam + 1)->rcmd); |
| | | } |
| | | strLog += ">."; |
| | | LOGI("<CEFEM-%s>%s", m_strName.c_str(), strLog.c_str()); |
| | | |
| | | |
| | | if (onWritedBlock != nullptr) { |
| | | pStep->writeDataEx(szBuffer, ROBOT_CMD_PARAM_SIZE * min(4, count), onWritedBlock); |
| | | } |
| | | else { |
| | | pStep->writeDataEx(szBuffer, ROBOT_CMD_PARAM_SIZE * min(4, count), [&](int code) -> int { |
| | | if (code == WOK) { |
| | | LOGI("<CEquipment-%s>发送RobotCmdS成功.", m_strName.c_str()); |
| | | } |
| | | else { |
| | | LOGI("<CEquipment-%s>发送RobotCmds失败,code:%d", m_strName.c_str(), code); |
| | | } |
| | | |
| | | return 0; |
| | | }); |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | void CEFEM::init() |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | { |
| | | // 请求主配方列表的step |
| | | CEqWriteStep* pStep = new CEqWriteStep(); |
| | |
| | | STEP_ID_PORT4_CASSETTIE_UNLOAD_READY, 0x60b0); |
| | | ADD_EQ_CASSETTE_TRANSFER_STATE_STEP(STEP_EQ_P4_CASSETTE_BLOCKED, 0x103, |
| | | STEP_ID_PORT4_CASSETTIE_BLOCKED, 0x60b0); |
| | | |
| | | { |
| | | // Received Job Report Upstream#1~9 |
| | | char szBuffer[256]; |
| | | for (int i = 0; i < 9; i++) { |
| | | CEqReadStep* pStep = new CEqReadStep(0x4c90 + 320 * i, 320 * 2, |
| | | [&](void* pFrom, int code, const char* pszData, size_t size) -> int { |
| | | if (code == ROK && pszData != nullptr && size > 0) { |
| | | int port = (int)(__int64)((CEqReadStep*)pFrom)->getProp("Port"); |
| | | if (port > 0) { |
| | | decodeFetchedOutJobReport((CStep*)pFrom, port, pszData, size); |
| | | } |
| | | } |
| | | return -1; |
| | | }); |
| | | sprintf_s(szBuffer, "%s%d", STEP_EQ_RECEIVED_JOBn, i + 1); |
| | | pStep->setName(szBuffer); |
| | | pStep->setProp("Upstream", (void*)(__int64)(i + 1)); |
| | | pStep->setWriteSignalDev(0x0 + i); |
| | | if (addStep(STEP_ID_FETCHED_OUT_JOB_REPORT1 + i, pStep) != 0) { |
| | | delete pStep; |
| | | } |
| | | } |
| | | } |
| | | |
| | | { |
| | | // Fetched Out Job Report #1~15 |
| | | char szBuffer[256]; |
| | | for (int i = 0; i < 15; i++) { |
| | | CEqReadStep* pStep = new CEqReadStep(0x5c31 + 18 * i, 18 * 2, |
| | | [&](void* pFrom, int code, const char* pszData, size_t size) -> int { |
| | | if (code == ROK && pszData != nullptr && size > 0) { |
| | | int port = (int)(__int64)((CEqReadStep*)pFrom)->getProp("Port"); |
| | | if (port > 0) { |
| | | decodeFetchedOutJobReport((CStep*)pFrom, port, pszData, size); |
| | | } |
| | | } |
| | | return -1; |
| | | }); |
| | | sprintf_s(szBuffer, "%s%d", STEP_EQ_FETCHED_OUT_JOBn, i+1); |
| | | pStep->setName(szBuffer); |
| | | pStep->setProp("Port", (void*)(__int64)(i + 1)); |
| | | pStep->setWriteSignalDev(0x023 + i); |
| | | if (addStep(STEP_ID_FETCHED_OUT_JOB_REPORT1 + i, pStep) != 0) { |
| | | delete pStep; |
| | | } |
| | | } |
| | | } |
| | | |
| | | { |
| | | // Store Job Report #1~15 |
| | | char szBuffer[256]; |
| | | for (int i = 0; i < 15; i++) { |
| | | CEqReadStep* pStep = new CEqReadStep(0x5b23 + 18 * i, 18 * 2, |
| | | [&](void* pFrom, int code, const char* pszData, size_t size) -> int { |
| | | if (code == ROK && pszData != nullptr && size > 0) { |
| | | int port = (int)(__int64)((CEqReadStep*)pFrom)->getProp("Port"); |
| | | if (port > 0) { |
| | | decodeStoredJobReport((CStep*)pFrom, port, pszData, size); |
| | | } |
| | | } |
| | | return -1; |
| | | }); |
| | | sprintf_s(szBuffer, "%s%d", STEP_EQ_STORED_JOBn, i + 1); |
| | | pStep->setName(szBuffer); |
| | | pStep->setProp("Port", (void*)(__int64)(i + 1)); |
| | | pStep->setWriteSignalDev(0x014 + i); |
| | | if (addStep(STEP_ID_STORE_JOB_REPORT1 + i, pStep) != 0) { |
| | | delete pStep; |
| | | } |
| | | } |
| | | } |
| | | |
| | | { |
| | | // Dispatching Mode Change Command |
| | | CEqWriteStep* pStep = new CEqWriteStep(); |
| | | pStep->setName(STEP_EQ_DISPATCHINT_MODE_CHANGE); |
| | | pStep->setWriteSignalDev(0x071); |
| | | pStep->setDataDev(0x5c6); |
| | | if (addStep(STEP_ID_DISPATCHING_MODE_CHANGE_REPLY, pStep) != 0) { |
| | | delete pStep; |
| | | } |
| | | } |
| | | |
| | | { |
| | | // Robot CMD |
| | | CEqWriteStep* pStep = new CEqWriteStep(); |
| | | pStep->setName(STEP_EFEM_ROBOT_CMD); |
| | | pStep->setWriteSignalDev(0x14D); |
| | | pStep->setDataDev(0x90a); |
| | | if (addStep(STEP_ID_ROBOT_CMD_REPLY, pStep) != 0) { |
| | | delete pStep; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int CEFEM::onStepEvent(CStep* pStep, int code) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | int CEFEM::onReceivedJob(int port, CJobDataS* pJobDataS) |
| | | { |
| | | m_pPort[0]->onReceivedJob(port, pJobDataS); |
| | | m_pPort[1]->onReceivedJob(port, pJobDataS); |
| | | m_pPort[2]->onReceivedJob(port, pJobDataS); |
| | | m_pPort[3]->onReceivedJob(port, pJobDataS); |
| | | m_pArmTray[0]->onReceivedJob(port, pJobDataS); |
| | | m_pArmTray[1]->onReceivedJob(port, pJobDataS); |
| | | m_pAligner->onReceivedJob(port, pJobDataS); |
| | | m_pFliper->onReceivedJob(port, pJobDataS); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | int CEFEM::onSentOutJob(int port, CJobDataS* pJobDataS) |
| | | { |
| | | m_pPort[0]->onSentOutJob(port, pJobDataS); |
| | | m_pPort[1]->onSentOutJob(port, pJobDataS); |
| | | m_pPort[2]->onSentOutJob(port, pJobDataS); |
| | | m_pPort[3]->onSentOutJob(port, pJobDataS); |
| | | m_pArmTray[0]->onSentOutJob(port, pJobDataS); |
| | | m_pArmTray[1]->onSentOutJob(port, pJobDataS); |
| | | m_pAligner->onSentOutJob(port, pJobDataS); |
| | | m_pFliper->onSentOutJob(port, pJobDataS); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | int CEFEM::onFetchedOutJob(int port, CJobDataB* pJobDataB) |
| | | { |
| | | if (port == 1) { |
| | | return m_pPort[0]->onFetchedOutJob(port, pJobDataB); |
| | | } |
| | | if (port == 2) { |
| | | return m_pPort[1]->onFetchedOutJob(port, pJobDataB); |
| | | } |
| | | if (port == 3) { |
| | | return m_pPort[2]->onFetchedOutJob(port, pJobDataB); |
| | | } |
| | | if (port == 4) { |
| | | return m_pPort[3]->onFetchedOutJob(port, pJobDataB); |
| | | } |
| | | if (port == 5) { |
| | | return m_pArmTray[0]->onFetchedOutJob(port, pJobDataB); |
| | | } |
| | | if (port == 6) { |
| | | return m_pArmTray[1]->onFetchedOutJob(port, pJobDataB); |
| | | } |
| | | if (port == 7) { |
| | | return m_pAligner->onFetchedOutJob(port, pJobDataB); |
| | | } |
| | | if (port == 8) { |
| | | return m_pFliper->onFetchedOutJob(port, pJobDataB); |
| | | } |
| | | |
| | | return -1; |
| | | } |
| | | |
| | | int CEFEM::onStoredJob(int port, CJobDataB* pJobDataB) |
| | | { |
| | | if (port == 1) { |
| | | return m_pPort[0]->onStoredJob(port, pJobDataB); |
| | | } |
| | | if (port == 2) { |
| | | return m_pPort[1]->onStoredJob(port, pJobDataB); |
| | | } |
| | | if (port == 3) { |
| | | return m_pPort[2]->onStoredJob(port, pJobDataB); |
| | | } |
| | | if (port == 4) { |
| | | return m_pPort[3]->onStoredJob(port, pJobDataB); |
| | | } |
| | | if (port == 5) { |
| | | return m_pArmTray[0]->onStoredJob(port, pJobDataB); |
| | | } |
| | | if (port == 6) { |
| | | return m_pArmTray[1]->onStoredJob(port, pJobDataB); |
| | | } |
| | | if (port == 7) { |
| | | return m_pAligner->onStoredJob(port, pJobDataB); |
| | | } |
| | | if (port == 8) { |
| | | return m_pFliper->onStoredJob(port, pJobDataB); |
| | | } |
| | | |
| | | return -1; |
| | | } |
| | | } |