LAPTOP-SNT8I5JK\Boounion
2025-07-25 247a2a9a9f3d699df42a009bf124d3b536ad6b37
1.Master端,Line Event Report功能修改完善,并通过EAP模拟测试OK;
已修改4个文件
117 ■■■■ 文件已修改
SourceCode/Bond/Servo/CCollectionEvent.cpp 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CCollectionEvent.h 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.cpp 73 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.h 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CCollectionEvent.cpp
@@ -49,6 +49,22 @@
        return TRUE;
    }
    void CCollectionEvent::setReport(CReport* pReport)
    {
        m_rptids.clear();
        m_reports.clear();
        if (pReport != nullptr) {
            m_rptids.push_back(pReport->getReportId());
            m_reports.push_back(pReport);
        }
    }
    unsigned int CCollectionEvent::getPortID()
    {
        if (m_reports.empty()) return -1;
        return m_reports.front()->getReportId();
    }
    BOOL CCollectionEvent::deleteReport(unsigned int nReportId)
    {
        BOOL bDelete = FALSE;
SourceCode/Bond/Servo/CCollectionEvent.h
@@ -21,6 +21,9 @@
        BOOL deleteReport(unsigned int nReportId);
        CReport* getReport(unsigned int nReportId);
        /* 如果一个CEID只有一个Report的场景,调用此函数设置或取消 */
        void setReport(CReport* pReport);
        unsigned int getPortID();
    private:
        unsigned int m_nCEID;
        std::string m_strName;
SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -98,39 +98,21 @@
}
void CHsmsPassive::addReport(unsigned int id, const char* pszName)
void CHsmsPassive::linkEventReport(unsigned int CEID, unsigned int RPTID)
{
    Lock();
    REPORT report;
    report.id = id;
    strcpy_s(report.szName, REPORT_NAME_MAX, pszName);
    m_mapReport[id] = report;
    Unlock();
    SERVO::CCollectionEvent* pEvent = getEvent(CEID);
    SERVO::CReport* pReport = getReport(RPTID);
    if (pEvent != nullptr) {
        pEvent->setReport(pReport);
}
void CHsmsPassive::linkEventReport(unsigned int RPTID, unsigned int CEID)
{
    m_mapReportIdToCEID[RPTID] = CEID;
}
void CHsmsPassive::unlinkEventReport(unsigned int CEID)
{
    for (auto it = m_mapReportIdToCEID.begin(); it != m_mapReportIdToCEID.end(); ) {
        if (it->second == CEID) {
            m_mapReportIdToCEID.erase(it++);  // 更新迭代器
    SERVO::CCollectionEvent* pEvent = getEvent(CEID);
    if (pEvent != nullptr) {
        pEvent->setReport(nullptr);
        }
        else {
            ++it;
        }
    }
}
unsigned int CHsmsPassive::getCEID(int RPTID)
{
    auto iter = m_mapReportIdToCEID.find(RPTID);
    if (iter != m_mapReportIdToCEID.end()) return iter->second;
    return 0;
}
SERVO::CReport* CHsmsPassive::defineReport(unsigned int RPTID, std::vector<unsigned int>& vids)
@@ -399,7 +381,7 @@
    if (!events.empty()) {
        clearAllCollectionEvent();
        for (auto item : events) {
            m_collectionEvent.push_back(item);
            m_collectionEvents.push_back(item);
        }
    }
@@ -410,15 +392,26 @@
std::vector<SERVO::CCollectionEvent*>& CHsmsPassive::getCollectionEvents()
{
    return m_collectionEvent;
    return m_collectionEvents;
}
void CHsmsPassive::clearAllCollectionEvent()
{
    for (auto item : m_collectionEvent) {
    for (auto item : m_collectionEvents) {
        delete item;
    }
    m_collectionEvent.clear();
    m_collectionEvents.clear();
}
SERVO::CCollectionEvent* CHsmsPassive::getEvent(unsigned short CEID)
{
    for (auto item : m_collectionEvents) {
        if (item->getEventId() == CEID) {
            return item;
        }
    }
    return nullptr;
}
std::vector<unsigned int> CHsmsPassive::parseVidList(CString& strNums)
@@ -967,7 +960,7 @@
            else {
                for (int k = 0; k < prtCount; k++) {
                    if (rptListItem->getSubItemU4(k, rptid)) {
                        linkEventReport(rptid, ceid);
                        linkEventReport(ceid, rptid);
                    }
                }
            }
@@ -976,8 +969,8 @@
    // 检验结果是否正确
    for (auto item : m_mapReportIdToCEID) {
        LOGE("=== prtid:%d, ceid:%d", item.first, item.second);
    for (auto item : m_collectionEvents) {
        LOGE("=== ceid:%d, prtid:%d", item->getEventId(), item->getPortID());
    }
MYREPLY:
@@ -1193,10 +1186,18 @@
}
// S6F11
int CHsmsPassive::requestEventReportSend(unsigned int DATAID, unsigned int RPTID, const std::vector<std::string>& values)
int CHsmsPassive::requestEventReportSend(unsigned int DATAID, unsigned int CEID, const std::vector<std::string>& values)
{
    if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
        return ER_NOTSELECT;
    }
    SERVO::CCollectionEvent* pEvent = getEvent(CEID);
    if (pEvent == nullptr) {
        return ER_NO_EVENT;
    }
    if (pEvent == nullptr) {
        return ER_UNLINK_EVENT_REPORT;
    }
    Lock();
@@ -1207,10 +1208,10 @@
    ASSERT(pMessage);
    ISECS2Item* pItem = pMessage->getBody();
    pItem->addU4Item(DATAID, "DATAID");
    pItem->addU4Item(getCEID(RPTID), "CEID");
    pItem->addU4Item(CEID, "CEID");
    ISECS2Item* pItemList1 = pItem->addItem();
    ISECS2Item* pItemList2 = pItemList1->addItem();
    pItemList2->addU4Item(RPTID, "RPTID");
    pItemList2->addU4Item(pEvent->getPortID(), "RPTID");
    ISECS2Item* pItemList3 = pItemList2->addItem();
    for (auto item : values) {
        pItemList3->addItem(item.c_str(), "V");
SourceCode/Bond/Servo/HsmsPassive.h
@@ -19,6 +19,8 @@
#define ER_NOTSELECT        -1
#define ER_BUSY                -2
#define ER_PARAM_ERROR        -3
#define ER_NO_EVENT                -4
#define ER_UNLINK_EVENT_REPORT    -5
/*
@@ -91,16 +93,11 @@
    /* 设置软件版本号 最大长度 20 bytes */
    void setSoftRev(const char* pszRev);
    /* 添加Report */
    void addReport(unsigned int id, const char* pszName);
    // 连接Report
    void linkEventReport(unsigned int RPTID, unsigned int CEID);
    void linkEventReport(unsigned int CEID, unsigned int RPTID);
    // 取消连接report
    void unlinkEventReport(unsigned int CEID);
    unsigned int getCEID(int RPTID);
    // define Report
    SERVO::CReport* defineReport(unsigned int RPTID, std::vector<unsigned int>& vids);
@@ -133,7 +130,10 @@
    // 取消/删除所有CollectionEvent
    void clearAllCollectionEvent();
    // 取得CCollectionEvent
    SERVO::CCollectionEvent* getEvent(unsigned short CEID);
    // 取得Report
    SERVO::CReport* getReport(int rptid);
    void setListener(SECSListener listener);
@@ -147,7 +147,7 @@
    /* request开头的函数为主动发送数据的函数 */
    int requestAreYouThere();
    int requestAlarmReport(int ALCD, int ALID, const char* ALTX);
    int requestEventReportSend(unsigned int DATAID, unsigned int RPTID, const std::vector<std::string>& values);
    int requestEventReportSend(unsigned int DATAID, unsigned int CEID, const std::vector<std::string>& values);
private:
    void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName);
@@ -196,15 +196,6 @@
    unsigned m_nCimWorkThrdaddr;
private:
    // RPTID to CEID
    std::map<unsigned int, unsigned int> m_mapReportIdToCEID;
    // RPTID to Report
    std::map<unsigned int, REPORT> m_mapReport;
    // VID to Report
    std::map<unsigned int, VALUE> m_mapValue;
    // CVariable vector
    std::vector<SERVO::CVariable*> m_variabels;
@@ -212,6 +203,6 @@
    std::vector<SERVO::CReport*> m_reports;
    // CollectionEvent vector
    std::vector<SERVO::CCollectionEvent*> m_collectionEvent;
    std::vector<SERVO::CCollectionEvent*> m_collectionEvents;
};