chenluhua1980
2025-12-15 cacf29e9e6a5c080688e25e87850ddfb5148f0f2
1.通过从mes下发的job,提取map,设置到loadport里;
已修改3个文件
103 ■■■■■ 文件已修改
SourceCode/Bond/Servo/CLoadPort.cpp 76 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CLoadPort.h 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMaster.cpp 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CLoadPort.cpp
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "CLoadPort.h"
#include "CGlassPool.h"
#include "Servo.h"
@@ -17,6 +17,7 @@
        m_bAutoChangeEnable = FALSE;
        m_nNextCassetteSequenceNo = 0;
        m_isCompareMapsBeforeProceeding = FALSE;
        m_downloadCassetteMap = 0;
    }
    CLoadPort::~CLoadPort()
@@ -40,16 +41,16 @@
        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++) {
@@ -351,7 +352,7 @@
        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 {
@@ -362,7 +363,7 @@
        // 模拟测试
        // 模拟测试
        /*
        if (m_nIndex == 0) {
            static int ii = 0;
@@ -934,7 +935,7 @@
        m_portStatusReport.copyEx(portStatusReport);
        // 当port状态为InUse, 比较map
        // 当port状态为InUse, 比较map
        if (m_portStatusReport.getPortStatus() == PORT_INUSE) {
            if (m_isCompareMapsBeforeProceeding) {
                short scanMap = getScanCassetteMap();
@@ -946,14 +947,14 @@
                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());
            }
        }
@@ -963,7 +964,7 @@
        }
        // 缓存Attribute,用于调试时显示信息
        // 缓存Attribute,用于调试时显示信息
        unsigned int weight = 201;
        CAttributeVector& attrubutes = pStep->attributeVector();
        m_portStatusReport.getAttributeVector(attrubutes, weight);
@@ -988,17 +989,17 @@
            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);
@@ -1018,17 +1019,17 @@
            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);
@@ -1047,17 +1048,17 @@
            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);
@@ -1077,16 +1078,16 @@
            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);
@@ -1105,17 +1106,17 @@
            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);
@@ -1134,17 +1135,17 @@
            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);
@@ -1192,17 +1193,20 @@
    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();
@@ -1236,11 +1240,11 @@
    }
    /*
     * 根据efem扫描到的map,生成玻璃列表
     * 根据efem扫描到的map,生成玻璃列表
     */
    int CLoadPort::generateGlassList(short map)
    {
        // 先释放较早前的数据
        // 先释放较早前的数据
        Lock();
        for (int i = 0; i < SLOT_MAX; i++) {
            m_slot[i].setContext(nullptr);
@@ -1248,7 +1252,7 @@
        Unlock();
        // 根据map生成新的
        // 根据map生成新的
        char szBuffer[64];
        for (int i = 0; i < SLOT_MAX; i++) {
            if (!m_slot[i].isEnable()) continue;
SourceCode/Bond/Servo/CLoadPort.h
@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "CEquipment.h"
#include "ServoCommo.h"
@@ -39,6 +39,7 @@
        void localAutoChangeEnable(BOOL bEnable);
        short getScanCassetteMap();
        short getDownloadCassetteMap();
        void setDownloadCassetteMap(short map);
    public:
        short getNextCassetteSequenceNo();
@@ -100,8 +101,8 @@
        CPortStatusReport m_portStatusReport;
        int m_nNextCassetteSequenceNo;
        // 在开始工艺前是否先需要先比较map
        // 在开始工艺前是否先需要先比较map
        BOOL m_isCompareMapsBeforeProceeding;
        short m_downloadCassetteMap;
    };
}
SourceCode/Bond/Servo/CMaster.cpp
@@ -2601,15 +2601,31 @@
        }
        m_processJobs = temp;
        // 重置各端口 DownloadMap(Host/本地勾选的期望加工槽位)
        for (int i = 0; i < 4; i++) {
            auto* pPort = (CLoadPort*)getEquipment(EQ_ID_LOADPORT1 + i);
            if (pPort != nullptr) {
                pPort->setDownloadCassetteMap(0);
            }
        }
        // 更新context
        std::vector<uint8_t> newSlots;
        std::vector<void*> newContexts;
        for (auto pj : m_processJobs) {
            for (auto& c : pj->carriers()) {
                auto pPort = getPortWithCarrierId(c.carrierId);
                if (pPort == nullptr) continue;
                short downloadMap = 0;
                for (auto s : c.slots) {
                    if (s >= 1 && s <= 8) {
                        downloadMap |= (short)(1 << (s - 1));
                    }
                }
                pPort->setDownloadCassetteMap((short)(pPort->getDownloadCassetteMap() | downloadMap));
                std::vector<uint8_t> newSlots;
                std::vector<void*> newContexts;
                for (auto s : c.slots) {
                    auto pGlass = pPort->getGlassFromSlot(s);
                    if (pGlass == nullptr) continue;