chenluhua1980
2026-01-10 6d140a6e6f2c24c9c7de46bb7c375ae4cbf931e7
1.实现远程删除配方功能;
已修改10个文件
118 ■■■■■ 文件已修改
SourceCode/Bond/EAPSimulator/CHsmsActive.cpp 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CHsmsActive.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulator.rc 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/Resource.h 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.cpp 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.h 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Model.cpp 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/PageRecipe.cpp 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
@@ -394,6 +394,20 @@
    return 0;
}
int CHsmsActive::hsmsDeletePPID(const std::vector<std::string>& ppids)
{
    IMessage* pMessage = nullptr;
    int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 7 | REPLY, 17, ++m_nSystemByte);
    if (nRet != 0 || pMessage == nullptr) return -1;
    ISECS2Item* pBody = pMessage->getBody();
    for (const auto& ppid : ppids) {
        pBody->addItem(ppid.c_str(), "PPID");
    }
    m_pActive->sendMessage(pMessage);
    HSMS_Destroy1Message(pMessage);
    return 0;
}
int CHsmsActive::hsmsCarrierActionRequest(unsigned int DATAID, 
    const char* pszCarrierAction, 
    const char* pszCarrierId,
SourceCode/Bond/EAPSimulator/CHsmsActive.h
@@ -84,6 +84,7 @@
    // 查询PPID List
    int hsmsQueryPPIDList();
    int hsmsDeletePPID(const std::vector<std::string>& ppids); // S7F17
    // S3F17
    // 卡匣动作请求
SourceCode/Bond/EAPSimulator/EAPSimulator.rc
Binary files differ
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
@@ -91,6 +91,7 @@
    ON_BN_CLICKED(IDC_BUTTON_TRANSMIT_SPOOLED_DATA, &CEAPSimulatorDlg::OnBnClickedButtonTransmitSpooledData)
    ON_BN_CLICKED(IDC_BUTTON_PURGE_SPOOLED_DATA, &CEAPSimulatorDlg::OnBnClickedButtonPurgeSpooledData)
    ON_BN_CLICKED(IDC_BUTTON_QUERY_PPID_LIST, &CEAPSimulatorDlg::OnBnClickedButtonQueryPpidList)
    ON_BN_CLICKED(IDC_BUTTON_DELETE_PPID, &CEAPSimulatorDlg::OnBnClickedButtonDeletePpid)
    ON_BN_CLICKED(IDC_BUTTON_PROCEED_WITH_CARRIER, &CEAPSimulatorDlg::OnBnClickedButtonProceedWithCarrier)
    ON_BN_CLICKED(IDC_BUTTON_PROCEED_WITH_SLOTMAP, &CEAPSimulatorDlg::OnBnClickedButtonProceedWithSlotMap)
    ON_BN_CLICKED(IDC_BUTTON_CARRIER_RELEASE, &CEAPSimulatorDlg::OnBnClickedButtonCarrierRelease)
@@ -380,6 +381,12 @@
    GetDlgItem(IDC_BUTTON_TRANSMIT_SPOOLED_DATA)->EnableWindow(enabled);
    GetDlgItem(IDC_BUTTON_PURGE_SPOOLED_DATA)->EnableWindow(enabled);
    GetDlgItem(IDC_BUTTON_QUERY_PPID_LIST)->EnableWindow(enabled);    
    if (GetDlgItem(IDC_BUTTON_DELETE_PPID) != nullptr) {
        GetDlgItem(IDC_BUTTON_DELETE_PPID)->EnableWindow(enabled);
    }
    if (GetDlgItem(IDC_EDIT_DELETE_PPID) != nullptr) {
        GetDlgItem(IDC_EDIT_DELETE_PPID)->EnableWindow(enabled);
    }
    GetDlgItem(IDC_BUTTON_PROCEED_WITH_CARRIER)->EnableWindow(enabled);    
    if (GetDlgItem(IDC_BUTTON_PROCEED_WITH_SLOTMAP) != nullptr) {
        GetDlgItem(IDC_BUTTON_PROCEED_WITH_SLOTMAP)->EnableWindow(enabled);
@@ -522,6 +529,31 @@
    theApp.m_model.m_pHsmsActive->hsmsQueryPPIDList();
}
void CEAPSimulatorDlg::OnBnClickedButtonDeletePpid()
{
    CString strPPID;
    GetDlgItemText(IDC_EDIT_DELETE_PPID, strPPID);
    strPPID.Trim();
    std::vector<std::string> ppids;
    if (!strPPID.IsEmpty()) {
        CString upper = strPPID;
        upper.MakeUpper();
        if (upper != _T("ALL")) {
            int start = 0;
            CString token = strPPID.Tokenize(_T(","), start);
            while (!token.IsEmpty()) {
                token.Trim();
                if (!token.IsEmpty()) {
                    ppids.push_back(std::string((LPTSTR)(LPCTSTR)token));
                }
                token = strPPID.Tokenize(_T(","), start);
            }
        }
    }
    // L:0 if ppids empty -> delete all
    theApp.m_model.m_pHsmsActive->hsmsDeletePPID(ppids);
}
static int DATAID = 1;
void CEAPSimulatorDlg::OnBnClickedButtonProceedWithCarrier()
{
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
@@ -57,6 +57,7 @@
    afx_msg void OnBnClickedButtonTransmitSpooledData();
    afx_msg void OnBnClickedButtonPurgeSpooledData();
    afx_msg void OnBnClickedButtonQueryPpidList();
    afx_msg void OnBnClickedButtonDeletePpid();
    afx_msg void OnBnClickedButtonProceedWithCarrier();
    afx_msg void OnBnClickedButtonProceedWithSlotMap();
    afx_msg void OnBnClickedButtonCarrierRelease();
SourceCode/Bond/EAPSimulator/Resource.h
@@ -65,14 +65,16 @@
#define IDC_BUTTON_QUERY_PROCESS_STATE  1047
#define IDC_BUTTON_QUERY_ALL_SVID       1048
#define IDC_BUTTON_QUERY_ALL_CEID       1049
#define IDC_EDIT_DELETE_PPID            1050
#define IDC_BUTTON_DELETE_PPID          1051
// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        143
#define _APS_NEXT_RESOURCE_VALUE        144
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1050
#define _APS_NEXT_CONTROL_VALUE         1052
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -1370,6 +1370,9 @@
        else if (nStream == 7 && pHeader->function == 19) {
            replyQueryPPIDList(pMessage);
        }
        else if (nStream == 7 && pHeader->function == 17) {
            replyDeletePPID(pMessage);
        }
        else if (nStream == 10 && pHeader->function == 3) {
            replyTerminalDisplay(pMessage);
        }
@@ -2544,6 +2547,44 @@
    return 0;
}
// S7F17 Delete Process Program (PPID list) / S7F18
int CHsmsPassive::replyDeletePPID(IMessage* pRecv)
{
    if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
        return ER_NOTSELECT;
    }
    bool allOk = true;
    const bool deleteAll = (pRecv->getBody() == nullptr || pRecv->getBody()->getSubItemSize() == 0);
    std::vector<std::string> ppids;
    ISECS2Item* pBody = pRecv->getBody();
    const int nCount = pBody ? pBody->getSubItemSize() : 0;
    for (int i = 0; i < nCount; ++i) {
        const char* pszPPID = nullptr;
        if (pBody->getSubItemString(i, pszPPID) && pszPPID != nullptr) {
            ppids.emplace_back(pszPPID);
        }
        else {
            allOk = false;
        }
    }
    if (deleteAll || !ppids.empty()) {
        if (m_listener.onDeletePPID != nullptr) {
            allOk = m_listener.onDeletePPID(this, ppids);
        }
        else {
            // no handler provided; treat as failure
            allOk = false;
            LOGW("<HSMS>DeletePPID request ignored: no onDeletePPID listener");
        }
    }
    replyAck(7, 18, pRecv->getHeader()->systemBytes, allOk ? BYTE(0) : BYTE(1), "ACKC7");
    return 0;
}
// S7F19
int CHsmsPassive::replyQueryPPIDList(IMessage* pRecv)
{
SourceCode/Bond/Servo/HsmsPassive.h
@@ -26,6 +26,8 @@
#define ER_UNLINK_EVENT_REPORT    -5
#define ER_NO_PPID_LIST            -6
#define ER_NOT_SUPPORTED        -7
#define ER_CREATED_MESSAGE        -8
/* CAACK */
@@ -90,6 +92,7 @@
    std::string& strErrorTxt)> CARRIERACTION;
typedef std::function<int(void* pFrom, std::vector<SERVO::CProcessJob*>& pjs)> PRJOBMULTICREATE;
typedef std::function<int(void* pFrom, SERVO::CControlJob& controlJob)> CONTROLJOBCREATE;
typedef std::function<bool(void* pFrom, const std::vector<std::string>& ppids)> DELETEPPID;
typedef struct _SECSListener
{
    SECSEQOFFLINE                onEQOffLine;
@@ -101,6 +104,7 @@
    EDEVENTREPORT                onEnableDisableEventReport;
    EDALARMREPORT                onEnableDisableAlarmReport;
    QUERYPPIDLIST                onQueryPPIDList;
    DELETEPPID                    onDeletePPID;
    CARRIERACTION                onCarrierAction;
    PRJOBMULTICREATE            onPRJobMultiCreate;
    CONTROLJOBCREATE            onControlJobCreate;
@@ -250,6 +254,7 @@
    int replyEanbleDisableAlarmReport(IMessage* pRecv);
    int replyPurgeSpooledData(IMessage* pRecv);
    int replyQueryPPIDList(IMessage* pRecv);
    int replyDeletePPID(IMessage* pRecv); // S7F17/S7F18
    int replyTerminalDisplay(IMessage* pRecv);
    int replyCreateObj(IMessage* pRecv);
    int replyPRJobMultiCreate(IMessage* pRecv);
SourceCode/Bond/Servo/Model.cpp
@@ -190,6 +190,21 @@
            m_master.enableEventReport(bEnable);
        }
    };
    listener.onDeletePPID = [&](void* pFrom, const std::vector<std::string>& ppids) -> bool {
        (void)pFrom;
        bool allOk = true;
        std::vector<std::string> targets = ppids;
        if (targets.empty()) {
            // L:0 => delete all PPIDs
            targets = RecipeManager::getInstance().getAllPPID();
        }
        for (auto& ppid : targets) {
            bool ok = RecipeManager::getInstance().deleteRecipeByPPID(ppid);
            allOk = allOk && ok;
            LOGI("<CModel>DeletePPID: %s, result=%s", ppid.c_str(), ok ? "OK" : "FAIL");
        }
        return allOk;
    };
    listener.onEnableDisableAlarmReport = [&](void* pFrom, bool bEnable, unsigned int id) -> void {
        LOGI("onEnableDisableAlarmReport bEnable:%s, id:%d", bEnable ? _T("YES") : _T("NO"), id);
        if (id == 0) {
SourceCode/Bond/Servo/PageRecipe.cpp
@@ -138,9 +138,12 @@
    // 遍历数据并插入到CListCtrl中
    for (int i = 0; i < static_cast<int>(vecRecipe.size()); ++i) {
        const RecipeInfo& recipe = vecRecipe[i];
        // 原程序要求PPID有子配方,先注释
        /*
        if (recipe.vecDeviceList.empty() || recipe.vecDeviceList.size() > 6){
            continue;
        }
        */
        m_listPPID.InsertItem(i, _T("")); // 第0列空白