| | |
| | | #include "stdafx.h" |
| | | #include "stdafx.h" |
| | | #include "CLoadPort.h" |
| | | #include "CGlassPool.h" |
| | | #include "Servo.h" |
| | |
| | | m_bAutoChangeEnable = FALSE; |
| | | m_nNextCassetteSequenceNo = 0; |
| | | m_isCompareMapsBeforeProceeding = FALSE; |
| | | m_downloadCassetteMap = 0; |
| | | } |
| | | |
| | | CLoadPort::~CLoadPort() |
| | |
| | | CEquipment::term(); |
| | | } |
| | | |
| | | // 必须要实现的虚函数,在此初始化Pin列表 |
| | | // 必须要实现的虚函数,在此初始化Pin列表 |
| | | void CLoadPort::initPins() |
| | | { |
| | | // 加入Pin初始化代码 |
| | | // 加入Pin初始化代码 |
| | | LOGD("<CLoadPort>initPins"); |
| | | addPin(SERVO::PinType::INPUT, _T("In")); |
| | | addPin(SERVO::PinType::OUTPUT, _T("Out")); |
| | | } |
| | | |
| | | // 必须要实现的虚函数,在此初始化Slot信息 |
| | | // 必须要实现的虚函数,在此初始化Slot信息 |
| | | void CLoadPort::initSlots() |
| | | { |
| | | for (int i = 0; i < SLOT_MAX; i++) { |
| | |
| | | CEquipment::onTimer(nTimerid); |
| | | |
| | | |
| | | // 从配置读出的enable,初始化时写给efem |
| | | // 从配置读出的enable,初始化时写给efem |
| | | static int i_enable[4] = { 0 }; |
| | | if ((++i_enable[m_nIndex]) == 20 + m_nIndex) { |
| | | eablePort(m_bEnable, [&](int code) -> int { |
| | |
| | | |
| | | |
| | | |
| | | // 模拟测试 |
| | | // 模拟测试 |
| | | /* |
| | | if (m_nIndex == 0) { |
| | | static int ii = 0; |
| | |
| | | m_portStatusReport.copyEx(portStatusReport); |
| | | |
| | | |
| | | // 当port状态为InUse, 比较map |
| | | // 当port状态为InUse, 比较map |
| | | if (m_portStatusReport.getPortStatus() == PORT_INUSE) { |
| | | if (m_isCompareMapsBeforeProceeding) { |
| | | short scanMap = getScanCassetteMap(); |
| | |
| | | else { |
| | | this->sendCassetteCtrlCmd(CCC_PROCESS_CANCEL, nullptr, 0, 0, 0, nullptr, nullptr); |
| | | |
| | | // 抛出到应用层做提示 |
| | | // 抛出到应用层做提示 |
| | | if (m_listener.onMapMismatch != nullptr) { |
| | | m_listener.onMapMismatch(this, scanMap, downloadMap); |
| | | } |
| | | } |
| | | } |
| | | else { |
| | | // 抛出到应用层做选择要加工的片子 |
| | | // 抛出到应用层做选择要加工的片子 |
| | | generateGlassList(getScanCassetteMap()); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | // 缓存Attribute,用于调试时显示信息 |
| | | // 缓存Attribute,用于调试时显示信息 |
| | | unsigned int weight = 201; |
| | | CAttributeVector& attrubutes = pStep->attributeVector(); |
| | | m_portStatusReport.getAttributeVector(attrubutes, weight); |
| | |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CLoadPort-%d>准备设置Port type<%d>", m_nIndex, (int)type); |
| | | LOGI("<CLoadPort-%d>准备设置Port type<%d>", m_nIndex, (int)type); |
| | | short value = (short)type; |
| | | pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int { |
| | | // test |
| | | code = WOK; |
| | | if (code == WOK) { |
| | | m_portType = type; |
| | | LOGI("<CLoadPort-%d>设置Port type成功.", m_nIndex); |
| | | LOGI("<CLoadPort-%d>设置Port type成功.", m_nIndex); |
| | | } |
| | | else { |
| | | LOGE("<CLoadPort-%d>设置Port type失败,code:%d", m_nIndex, code); |
| | | LOGE("<CLoadPort-%d>设置Port type失败,code:%d", m_nIndex, code); |
| | | } |
| | | if (onWritedBlock != nullptr) { |
| | | return onWritedBlock(code); |
| | |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CLoadPort-%d>准备%s Port", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | LOGI("<CLoadPort-%d>准备%s Port", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | short value = bEnable ? 1 : 2; |
| | | pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int { |
| | | // test |
| | | code = WOK; |
| | | if (code == WOK) { |
| | | m_bEnable = bEnable; |
| | | LOGI("<CLoadPort-%d>%s Port成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | LOGI("<CLoadPort-%d>%s Port成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | } |
| | | else { |
| | | LOGE("<CLoadPort-%d>%s Port失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code); |
| | | LOGE("<CLoadPort-%d>%s Port失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code); |
| | | } |
| | | if (onWritedBlock != nullptr) { |
| | | return onWritedBlock(code); |
| | |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CLoadPort-%d>准备设置Port mode<%d>", m_nIndex, (int)mode); |
| | | LOGI("<CLoadPort-%d>准备设置Port mode<%d>", m_nIndex, (int)mode); |
| | | short value = (short)mode; |
| | | pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int { |
| | | // test |
| | | code = WOK; |
| | | if (code == WOK) { |
| | | m_portMode = mode; |
| | | LOGI("<CLoadPort-%d>设置Port mode成功.", m_nIndex); |
| | | LOGI("<CLoadPort-%d>设置Port mode成功.", m_nIndex); |
| | | } |
| | | else { |
| | | LOGE("<CLoadPort-%d>设置Port mode失败,code:%d", m_nIndex, code); |
| | | LOGE("<CLoadPort-%d>设置Port mode失败,code:%d", m_nIndex, code); |
| | | } |
| | | if (onWritedBlock != nullptr) { |
| | | return onWritedBlock(code); |
| | |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CLoadPort-%d>准备设置Cassette Type<%d>", m_nIndex, (int)type); |
| | | LOGI("<CLoadPort-%d>准备设置Cassette Type<%d>", m_nIndex, (int)type); |
| | | short value = (short)type; |
| | | pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int { |
| | | // test |
| | | code = WOK; |
| | | if (code == WOK) { |
| | | LOGI("<CLoadPort-%d>设置Cassette Type成功.", m_nIndex); |
| | | LOGI("<CLoadPort-%d>设置Cassette Type成功.", m_nIndex); |
| | | } |
| | | else { |
| | | LOGE("<CLoadPort-%d>设置Cassette Type失败,code:%d", m_nIndex, code); |
| | | LOGE("<CLoadPort-%d>设置Cassette Type失败,code:%d", m_nIndex, code); |
| | | } |
| | | if (onWritedBlock != nullptr) { |
| | | return onWritedBlock(code); |
| | |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CLoadPort-%d>准备设置Transfer mode<%d>", m_nIndex, (int)mode); |
| | | LOGI("<CLoadPort-%d>准备设置Transfer mode<%d>", m_nIndex, (int)mode); |
| | | short value = (short)mode; |
| | | pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int { |
| | | // test |
| | | code = WOK; |
| | | if (code == WOK) { |
| | | m_transferMode = mode; |
| | | LOGI("<CLoadPort-%d>设置Transfer mode成功.", m_nIndex + 1); |
| | | LOGI("<CLoadPort-%d>设置Transfer mode成功.", m_nIndex + 1); |
| | | } |
| | | else { |
| | | LOGE("<CLoadPort-%d>设置Transfer mode失败,code:%d", m_nIndex + 1, code); |
| | | LOGE("<CLoadPort-%d>设置Transfer mode失败,code:%d", m_nIndex + 1, code); |
| | | } |
| | | if (onWritedBlock != nullptr) { |
| | | return onWritedBlock(code); |
| | |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CLoadPort-%d>准备%s Auto Change", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | LOGI("<CLoadPort-%d>准备%s Auto Change", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | short value = bEnable ? 1 : 2; |
| | | pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int { |
| | | // test |
| | | code = WOK; |
| | | if (code == WOK) { |
| | | m_bAutoChangeEnable = bEnable; |
| | | LOGI("<CLoadPort-%d>%s Auto Change成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | LOGI("<CLoadPort-%d>%s Auto Change成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | } |
| | | else { |
| | | LOGE("<CLoadPort-%d>%s Auto Change失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code); |
| | | LOGE("<CLoadPort-%d>%s Auto Change失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code); |
| | | } |
| | | if (onWritedBlock != nullptr) { |
| | | return onWritedBlock(code); |
| | |
| | | |
| | | short CLoadPort::getDownloadCassetteMap() |
| | | { |
| | | // 暂时未实现此功能 |
| | | short map = 0; |
| | | return map; |
| | | return m_downloadCassetteMap; |
| | | } |
| | | |
| | | void CLoadPort::setDownloadCassetteMap(short map) |
| | | { |
| | | m_downloadCassetteMap = map; |
| | | } |
| | | |
| | | /* |
| | | * 生成测试用的玻璃列表 |
| | | * 生成测试用的玻璃列表 |
| | | */ |
| | | int CLoadPort::testGenerateGlassList(MaterialsType type) |
| | | { |
| | | // 如果非空就不生成了 |
| | | // 如果非空就不生成了 |
| | | Lock(); |
| | | if (hasGlass()) { |
| | | Unlock(); |
| | |
| | | } |
| | | |
| | | /* |
| | | * 根据efem扫描到的map,生成玻璃列表 |
| | | * 根据efem扫描到的map,生成玻璃列表 |
| | | */ |
| | | int CLoadPort::generateGlassList(short map) |
| | | { |
| | | // 先释放较早前的数据 |
| | | // 先释放较早前的数据 |
| | | Lock(); |
| | | for (int i = 0; i < SLOT_MAX; i++) { |
| | | m_slot[i].setContext(nullptr); |
| | |
| | | Unlock(); |
| | | |
| | | |
| | | // 根据map生成新的 |
| | | // 根据map生成新的 |
| | | char szBuffer[64]; |
| | | for (int i = 0; i < SLOT_MAX; i++) { |
| | | if (!m_slot[i].isEnable()) continue; |