LAPTOP-T815PCOQ\25526
2025-01-10 65ac403060f715a532e5a31927fecbfac208c905
1.添加.dmp文件保存
2.添加删除最后一个PLC时销毁PLC View窗口
已修改5个文件
95 ■■■■ 文件已修改
SourceCode/Bond/BoounionPLC/BoounionPLC.cpp 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BoounionPLC/Common.h 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BoounionPLC/Model.cpp 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BoounionPLC/PagePlcList.cpp 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BoounionPLC/BoounionPLC.cpp
@@ -8,11 +8,60 @@
#include "HorizontalLine.h"
#include "VerticalLine.h"
#include <DbgHelp.h>
#pragma comment(lib, "DbgHelp.lib")
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
LONG WINAPI MyUnhandledExceptionFilter(EXCEPTION_POINTERS* pExceptionInfo) {
    SYSTEMTIME st;
    GetLocalTime(&st);
    // 获取当前程序运行目录
    char szAppPath[MAX_PATH];
    GetModuleFileName(NULL, szAppPath, MAX_PATH);
    std::string strCurrentDir = szAppPath;
    size_t lastSlash = strCurrentDir.find_last_of("\\/");
    strCurrentDir = strCurrentDir.substr(0, lastSlash);
    // 检查Temp文件夹
    struct stat buffer;
    std::string strFullTempPath = strCurrentDir + "\\Temp";
    if (stat(strFullTempPath.c_str(), &buffer) != 0) {
        if (!CreateDirectory(strFullTempPath.c_str(), NULL)) {
            return EXCEPTION_EXECUTE_HANDLER;
        }
    }
    // 构建文件名
    char szFileName[MAX_PATH];
    snprintf(szFileName, MAX_PATH, "\\BoounionPLC_%04d%02d%02d_%02d%02d%02d.dmp",
        st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
    // 写入DMP文件
    std::string strFullPath = strFullTempPath + szFileName;
    HANDLE hFile = CreateFile(strFullPath.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if (hFile != INVALID_HANDLE_VALUE) {
        MINIDUMP_EXCEPTION_INFORMATION dumpInfo;
        dumpInfo.ExceptionPointers = pExceptionInfo;
        dumpInfo.ThreadId = GetCurrentThreadId();
        dumpInfo.ClientPointers = TRUE;
        // 写入dump文件
        BOOL success = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpWithFullMemory, &dumpInfo, NULL, NULL);
        CloseHandle(hFile);
        if (success) {
            CString strMsg;
            strMsg.Format(_T("Software crashes. Dump file: %s"), strFullPath.c_str());
            AfxMessageBox(strMsg);
        }
    }
    return EXCEPTION_EXECUTE_HANDLER;
}
// CBoounionPLCApp
@@ -30,6 +79,7 @@
    // TODO: 在此处添加构造代码,
    // 将所有重要的初始化放置在 InitInstance 中
    SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
}
SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp
@@ -113,15 +113,19 @@
            if (RX_CODE_SELECT_PLC == code) {
                CPLC* pPlc;
                if (pAny->getPtrValue("ptr", (void*&)pPlc)) {
                    ASSERT(m_pMainContainer != nullptr);
                    if (m_pActiveView == nullptr) {
                        m_pActiveView = (CPlcView*)CreatePlcView(pPlc);
                    }
                    ASSERT(m_pActiveView);
                    if (m_pActiveView->GetContext() != (void*)pPlc) {
                        m_pActiveView->SetWindowText(pPlc->getName().c_str());
                        m_pActiveView->SetContext(pPlc);
                        m_pActiveView->SendMessage(WM_NCPAINT, 0, 0);
                    if (pPlc != nullptr) {
                        ASSERT(m_pMainContainer != nullptr);
                        if (m_pActiveView == nullptr) {
                            m_pActiveView = (CPlcView*)CreatePlcView(pPlc);
                        }
                        ASSERT(m_pActiveView);
                        if (m_pActiveView->GetContext() != (void*)pPlc) {
                            m_pActiveView->SetWindowText(pPlc->getName().c_str());
                            m_pActiveView->SetContext(pPlc);
                            m_pActiveView->SendMessage(WM_NCPAINT, 0, 0);
                        }
                    } else {
                        CloseView(m_pActiveView);
                    }
                    theApp.m_model.setCurrentPlc(pPlc);
SourceCode/Bond/BoounionPLC/Common.h
@@ -1,5 +1,5 @@
#pragma once
#ifndef COMMON_H
#define COMMON_H
/* Rx Code */
#define RX_CODE_TEST                    0
@@ -72,4 +72,6 @@
/* 监控数据id */
#define MONITOR_ID_ALARM        1001
#define MONITOR_ID_ALARM        1001
#endif // COMMON_H
SourceCode/Bond/BoounionPLC/Model.cpp
@@ -348,8 +348,8 @@
    m_configuration.removePLC(pszName);
    notifyPtr(RX_CODE_REMOVE_PLC, iter->second);
    //delete iter->second;
    //m_mapPlc.erase(iter);        这个地方需要研究一下
    delete iter->second;
    m_mapPlc.erase(iter);
    return 0;
}
@@ -358,6 +358,8 @@
{
    if (pPlc != nullptr) {
        m_strCurrPlc = pPlc->getName();
    } else {
        m_strCurrPlc = "";
    }
}
SourceCode/Bond/BoounionPLC/PagePlcList.cpp
@@ -74,13 +74,12 @@
                    GetDlgItem(IDC_LABEL_NO_PLC)->ShowWindow(bNoPLC ? SW_SHOW : SW_HIDE);
                    // 更新节点
                    HTREEITEM hSelectedItem = m_treeCtrl.GetSelectedItem();
                    HTREEITEM hSelectedItem = m_treeCtrl.GetSelectedItem();
                    CPLC* pSelectedPlc = nullptr;
                    if (hSelectedItem != NULL) {
                        CPLC* pSelectedPlc = (CPLC*)m_treeCtrl.GetItemData(hSelectedItem);
                        if (pSelectedPlc != nullptr) {
                            theApp.m_model.notifyPtr(RX_CODE_SELECT_PLC, pSelectedPlc);
                        }
                        pSelectedPlc = (CPLC*)m_treeCtrl.GetItemData(hSelectedItem);
                    }
                    theApp.m_model.notifyPtr(RX_CODE_SELECT_PLC, pSelectedPlc);
                }
            }