LAPTOP-SNT8I5JK\Boounion
2025-07-11 2de4eb139c0cc595db761fedd822549384822fc9
1.EAP模拟器,Eanble/Disable Event对话框,可以模拟EAP下发 Enable/Disable Event Report;
2.Master, 增加接口设置 Enable/Disable Event Report,目前仅处理enable/disable所有 event上报;
已添加2个文件
已修改13个文件
181 ■■■■■ 文件已修改
SourceCode/Bond/EAPSimulator/CEDEventReportDlg.cpp 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CEDEventReportDlg.h 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CHsmsActive.cpp 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CHsmsActive.h 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulator.rc 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj.filters 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/Resource.h 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMaster.cpp 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMaster.h 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.cpp 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Model.cpp 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CEDEventReportDlg.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,71 @@
// CEDEventReportDlg.cpp: å®žçŽ°æ–‡ä»¶
//
#include "pch.h"
#include "EAPSimulator.h"
#include "CEDEventReportDlg.h"
#include "afxdialogex.h"
#include <vector>
// CEDEventReportDlg å¯¹è¯æ¡†
IMPLEMENT_DYNAMIC(CEDEventReportDlg, CDialogEx)
CEDEventReportDlg::CEDEventReportDlg(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_DIALOG_ED_EVENT_REPORT, pParent)
{
}
CEDEventReportDlg::~CEDEventReportDlg()
{
}
void CEDEventReportDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CEDEventReportDlg, CDialogEx)
    ON_BN_CLICKED(IDC_BUTTON_SEND, &CEDEventReportDlg::OnBnClickedButtonSend)
END_MESSAGE_MAP()
// CEDEventReportDlg æ¶ˆæ¯å¤„理程序
BOOL CEDEventReportDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();
    CButton* pButton = (CButton*)GetDlgItem(IDC_RADIO_ENABLE);
    pButton->SetCheck(BST_CHECKED);
    return TRUE;  // return TRUE unless you set the focus to a control
                  // å¼‚常: OCX å±žæ€§é¡µåº”返回 FALSE
}
void CEDEventReportDlg::OnBnClickedButtonSend()
{
    CButton* pButton = (CButton*)GetDlgItem(IDC_RADIO_ENABLE);
    bool bEnable = pButton->GetCheck() == BST_CHECKED;
    CString strText, strId;
    GetDlgItemText(IDC_EDIT_CEID, strText);
    std::vector<int> ids;
    if (!strText.IsEmpty()) {
        int i = 0;
        while (1) {
            if (!AfxExtractSubString(strId, (LPCTSTR)strText, i++, ',')) {
                break;
            }
            ids.push_back(atoi(strId));
        }
    }
    theApp.m_model.m_pHsmsActive->hsmsEDEventReport(bEnable, ids);
}
SourceCode/Bond/EAPSimulator/CEDEventReportDlg.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
#pragma once
// CEDEventReportDlg å¯¹è¯æ¡†
class CEDEventReportDlg : public CDialogEx
{
    DECLARE_DYNAMIC(CEDEventReportDlg)
public:
    CEDEventReportDlg(CWnd* pParent = nullptr);   // æ ‡å‡†æž„造函数
    virtual ~CEDEventReportDlg();
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_DIALOG_ED_EVENT_REPORT };
#endif
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL OnInitDialog();
    afx_msg void OnBnClickedButtonSend();
};
SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
@@ -170,6 +170,22 @@
    return 0;
}
int CHsmsActive::hsmsEDEventReport(bool bEnable, std::vector<int>& ids)
{
    IMessage* pMessage = nullptr;
    int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 2 | REPLY, 37, ++m_nSystemByte);
    ISECS2Item* pItem = pMessage->getBody();
    pItem->addBoolItem(bEnable, "CEED");
    ISECS2Item* pItem2 = pItem->addItem();
    for (auto item : ids) {
        pItem2->addU4Item(item, "CEID");
    }
    m_pActive->sendMessage(pMessage);
    HSMS_Destroy1Message(pMessage);
    return 0;
}
int CHsmsActive::replyAck0(IMessage* pMessage)
{
    return 0;
SourceCode/Bond/EAPSimulator/CHsmsActive.h
@@ -1,5 +1,7 @@
#pragma once
#include <string>
#include <vector>
typedef std::function<void(void* pFrom, ACTIVESTATE state)> STATECHANGED;
typedef struct _ACTIVEListener
@@ -37,6 +39,9 @@
    // terminal display
    int hsmsTerminalDisplay(BYTE tid, const char* pszText);
    // Enable/Disable Event Report
    int hsmsEDEventReport(bool bEnable, std::vector<int>& ids);
    // é€šè¿‡çš„reply函数
    void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName);
SourceCode/Bond/EAPSimulator/EAPSimulator.rc
Binary files differ
SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj
@@ -183,6 +183,7 @@
    </ResourceCompile>
  </ItemDefinitionGroup>
  <ItemGroup>
    <ClInclude Include="CEDEventReportDlg.h" />
    <ClInclude Include="CHsmsActive.h" />
    <ClInclude Include="CModel.h" />
    <ClInclude Include="Common.h" />
@@ -198,6 +199,7 @@
    <ClInclude Include="targetver.h" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="CEDEventReportDlg.cpp" />
    <ClCompile Include="CHsmsActive.cpp" />
    <ClCompile Include="CModel.cpp" />
    <ClCompile Include="Context.cpp" />
SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj.filters
@@ -54,6 +54,9 @@
    <ClInclude Include="CTerminalDisplayDlg.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="CEDEventReportDlg.h">
      <Filter>头文件</Filter>
    </ClInclude>
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="EAPSimulator.cpp">
@@ -83,6 +86,9 @@
    <ClCompile Include="CTerminalDisplayDlg.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="CEDEventReportDlg.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ResourceCompile Include="EAPSimulator.rc">
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
@@ -10,6 +10,7 @@
#include "Common.h"
#include <regex>
#include "CTerminalDisplayDlg.h"
#include "CEDEventReportDlg.h"
#ifdef _DEBUG
@@ -77,6 +78,7 @@
    ON_BN_CLICKED(IDC_BUTTON_ARE_YOU_THERE, &CEAPSimulatorDlg::OnBnClickedButtonAreYouThere)
    ON_BN_CLICKED(IDC_BUTTON_DATETIME_SYNC, &CEAPSimulatorDlg::OnBnClickedButtonDatetimeSync)
    ON_BN_CLICKED(IDC_BUTTON_TERMINAL_DISPLAY, &CEAPSimulatorDlg::OnBnClickedButtonTerminalDisplay)
    ON_BN_CLICKED(IDC_BUTTON_ED_EVENT_REPORT, &CEAPSimulatorDlg::OnBnClickedButtonEdEventReport)
END_MESSAGE_MAP()
@@ -255,6 +257,7 @@
    GetDlgItem(IDC_BUTTON_ARE_YOU_THERE)->EnableWindow(enabled);
    GetDlgItem(IDC_BUTTON_DATETIME_SYNC)->EnableWindow(enabled);
    GetDlgItem(IDC_BUTTON_TERMINAL_DISPLAY)->EnableWindow(enabled);    
    GetDlgItem(IDC_BUTTON_ED_EVENT_REPORT)->EnableWindow(enabled);
}
void CEAPSimulatorDlg::OnBnClickedButtonConnect()
@@ -287,3 +290,9 @@
    CTerminalDisplayDlg dlg;
    dlg.DoModal();
}
void CEAPSimulatorDlg::OnBnClickedButtonEdEventReport()
{
    CEDEventReportDlg dlg;
    dlg.DoModal();
}
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
@@ -49,4 +49,5 @@
    afx_msg void OnBnClickedButtonAreYouThere();
    afx_msg void OnBnClickedButtonDatetimeSync();
    afx_msg void OnBnClickedButtonTerminalDisplay();
    afx_msg void OnBnClickedButtonEdEventReport();
};
SourceCode/Bond/EAPSimulator/Resource.h
@@ -8,6 +8,7 @@
#define IDD_EAPSIMULATOR_DIALOG         102
#define IDR_MAINFRAME                   128
#define IDD_DIALOG_TERMINAL_DISPLAY     129
#define IDD_DIALOG_ED_EVENT_REPORT      131
#define IDC_EDIT_LOG                    1000
#define IDC_EDIT_IP                     1001
#define IDC_EDIT_PORT                   1002
@@ -17,16 +18,21 @@
#define IDC_BUTTON_DATETIME_SYNC        1006
#define IDC_BUTTON_TERMINAL_DISPLAY     1007
#define IDC_COMBO_TID                   1008
#define IDC_BUTTON_ED_EVENT_REPORT      1008
#define IDC_EDIT_TEXT                   1009
#define IDC_BUTTON_SEND                 1010
#define IDC_RADIO_ENABLE                1012
#define IDC_RADIO_DISABLE               1013
#define IDC_EDIT1                       1014
#define IDC_EDIT_CEID                   1014
// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        131
#define _APS_NEXT_RESOURCE_VALUE        133
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1011
#define _APS_NEXT_CONTROL_VALUE         1015
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
SourceCode/Bond/Servo/CMaster.cpp
@@ -51,6 +51,8 @@
        m_state = MASTERSTATE::READY;
        m_pActiveRobotTask = nullptr;
        m_nLastError = 0;
        m_bEnableEventReport = true;
        m_bEnableAlarmReport = true;
        InitializeCriticalSection(&m_criticalSection);
    }
@@ -1585,4 +1587,14 @@
                time.wHour, time.wMinute, time.wSecond);
        }
    }
    void CMaster::enableEventReport(bool bEnable)
    {
        m_bEnableEventReport = bEnable;
    }
    void CMaster::enableAlarmReport(bool bEnable)
    {
        m_bEnableAlarmReport = bEnable;
    }
}
SourceCode/Bond/Servo/CMaster.h
@@ -70,6 +70,8 @@
        void setPortType(unsigned int index, BOOL enable, int type, int mode,
            int cassetteType, int transferMode, BOOL autoChangeEnable);
        void datetimeSync(SYSTEMTIME& time);
        void enableEventReport(bool bEnable);
        void enableAlarmReport(bool bEnable);
    private:
        inline void lock() { EnterCriticalSection(&m_criticalSection); }
@@ -131,6 +133,10 @@
        // é”™è¯¯ä»£ç 
        int m_nLastError;
        std::string m_strLastError;
    private:
        bool m_bEnableEventReport;
        bool m_bEnableAlarmReport;
    };
}
SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -754,15 +754,15 @@
            }
        }
        bCheckData = TRUE;
        LOGI("EanbleDisableAlarm bEnable:%s", bEnable ? _T("YES") : _T("NO"));
        for (auto item : ids) {
            LOGI("ID:%u", item);
        if (m_listener.onEnableDisableEventReport != nullptr) {
            m_listener.onEnableDisableEventReport(this, bEnable, ids);
        }
    }
MYREPLY:
    replyAck(2, 38, pRecv->getHeader()->systemBytes, BYTE(0), "ERACK");
    replyAck(2, 38, pRecv->getHeader()->systemBytes,
        bCheckData ? BYTE(0) : BYTE(1), "ERACK");
    return 0;
}
SourceCode/Bond/Servo/HsmsPassive.h
@@ -61,6 +61,7 @@
typedef std::function<void(void* pFrom, std::vector<EQConstant>&)> SECSEQCONSTANTREQUEST;
typedef std::function<void(void* pFrom, const char*, std::vector<CommandParameter>&)> SECSCommand;
typedef std::function<void(void* pFrom, SYSTEMTIME& time)> DATETIMESYNC;
typedef std::function<void(void* pFrom, bool bEnable, std::vector<unsigned int>& ids)> EDEVENTREPORT;
typedef struct _SECSListener
{
    SECSEQOFFLINE                onEQOffLine;
@@ -69,6 +70,7 @@
    SECSEQCONSTANTREQUEST        onEQConstantSend;
    SECSCommand                    onCommand;
    DATETIMESYNC                onDatetimeSync;
    EDEVENTREPORT                onEnableDisableEventReport;
} SECSListener;
SourceCode/Bond/Servo/Model.cpp
@@ -113,7 +113,12 @@
            time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond);
        m_master.datetimeSync(time);
    };
    listener.onEnableDisableEventReport = [&](void* pFrom, bool bEnable, std::vector<unsigned int> ids) -> void {
        LOGI("EanbleDisableEventReport bEnable:%s", bEnable ? _T("YES") : _T("NO"));
        if (ids.empty()) {
            m_master.enableEventReport(bEnable);
        }
    };
    m_hsmsPassive.setListener(listener);
    m_hsmsPassive.setEquipmentModelType((LPTSTR)(LPCTSTR)strModeType);
    m_hsmsPassive.setSoftRev((LPTSTR)(LPCTSTR)strSoftRev);