LAPTOP-SNT8I5JK\Boounion
2025-01-13 526a56428d2111aef216cfca5bc63c806048a0e6
1.PLC连接状态在最左侧树控件中的小圆点展示;
2.当前PLC名称修改为CPLC指针;
已修改7个文件
53 ■■■■ 文件已修改
SourceCode/Bond/BoounionPLC/BoounionPLC.cpp 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BoounionPLC/BoounionPLC.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BoounionPLC/Common.h 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BoounionPLC/Model.cpp 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BoounionPLC/Model.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BoounionPLC/PagePlcList.cpp 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BoounionPLC/BoounionPLC.cpp
@@ -136,6 +136,11 @@
    m_model.setWorkDir((LPTSTR)(LPCTSTR)m_strAppDir);
    // gdi+
    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
    CString strIniFile;
    strIniFile.Format(_T("%s\\BoounionPLCconfiguration.ini"), (LPTSTR)(LPCTSTR)m_strAppDir);
    int plcTimeout = GetPrivateProfileInt("PLC", "Timeout", 700, strIniFile);
@@ -192,6 +197,9 @@
int CBoounionPLCApp::ExitInstance()
{
    // gdi+
    Gdiplus::GdiplusShutdown(m_gdiplusToken);
    m_model.term();
    RX_Term();
    MCL_Term();
SourceCode/Bond/BoounionPLC/BoounionPLC.h
@@ -28,6 +28,7 @@
    CString m_strAppFile;
    int m_nVersionNumber;
    CString m_strVersionName;
    ULONG_PTR m_gdiplusToken;
// 重写
public:
SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp
@@ -140,6 +140,9 @@
                    theApp.m_model.setCurrentPlc(pPlc);
                }
            }
            else if (RX_PLC_STATE_CHANGED == code) {
            }
            else if (code == RX_CODE_ALARM_ON) {
                CPLC* pPlc;
                if (pAny->getPtrValue("ptr", (void*&)pPlc) && pPlc == theApp.m_model.getCurrentPlc()) {
SourceCode/Bond/BoounionPLC/Common.h
@@ -20,6 +20,7 @@
#define RX_CODE_TACT_TIME                1014 // 节拍时间
#define RX_CODE_DAY_SHIFT_CAPACTITY        1015 // 白班产量
#define RX_CODE_NIGHT_SHIFT_CAPACTITY    1016 // 夜班产量
#define RX_PLC_STATE_CHANGED            1017    /* PLC状态改变 */
/* 定制颜色 */
@@ -115,6 +116,12 @@
#define BTN_SOUND_ON_BKGND_HOVER        RGB(150, 250, 150)
#define BTN_SOUND_ON_BKGND_PRESS        RGB(50, 150, 50)
/* 树控件小圆点 */
#define TREE_BADGE_BACKGROUND            RGB(34, 177, 76)
#define TREE_BADGE_FOREGROUND            RGB(222, 222, 222)
#define TREE_BADGE2_BACKGROUND            RGB(255, 127, 39)
#define TREE_BADGE2_FOREGROUND            RGB(222, 222, 222)
/* 按钮id */
#define VIEW_TOOL_BTN_CLOSE                0x1016
SourceCode/Bond/BoounionPLC/Model.cpp
@@ -21,6 +21,7 @@
    m_pObservableEmitter = nullptr;
    m_pObservable = nullptr;
    m_nTimerID = 0;
    m_pActivePlc = nullptr;
}
@@ -337,7 +338,7 @@
    pPLC->setWorkDir((LPTSTR)(LPCTSTR)strPlcDir);
    PLCListener listener;
    listener.onStateChanged = [&](void* pFrom, int state) -> void {
        LOGD("PLC状态改变,%d", state);
        notifyPtr(RX_PLC_STATE_CHANGED, pFrom);
    };
    listener.onMonitorData = [&](void* pFrom, int id) -> void {
        LOGD("PLConMonitorData,%d", id);
@@ -388,19 +389,10 @@
void CModel::setCurrentPlc(CPLC* pPlc)
{
    if (pPlc != nullptr) {
        m_strCurrPlc = pPlc->getName();
    } else {
        m_strCurrPlc = "";
    }
    m_pActivePlc = pPlc;
}
CPLC* CModel::getCurrentPlc()
{
    auto item = m_mapPlc.find(m_strCurrPlc);
    if (item != m_mapPlc.end()) {
        return item->second;
    }
    return nullptr;
    return m_pActivePlc;
}
SourceCode/Bond/BoounionPLC/Model.h
@@ -46,7 +46,7 @@
    IObservableEmitter* m_pObservableEmitter;
    CString m_strWorkDir;
    std::map<std::string, CPLC*> m_mapPlc;
    std::string m_strCurrPlc;
    CPLC* m_pActivePlc;
private:
    int m_nTimerID;
SourceCode/Bond/BoounionPLC/PagePlcList.cpp
@@ -85,6 +85,18 @@
                    theApp.m_model.notifyPtr(RX_CODE_SELECT_PLC, pSelectedPlc);
                }
            }
            else if (RX_PLC_STATE_CHANGED == code) {
                CPLC* pPlc;
                if (pAny->getPtrValue("ptr", (void*&)pPlc)) {
                    HTREEITEM hItem = FindItem(pPlc);
                    if (hItem != nullptr && pPlc->isConnected()) {
                        m_treeCtrl.ShowItemBadgeDotMode(hItem);
                    }
                    else {
                        m_treeCtrl.HideItemBadge(hItem);
                    }
                }
            }
            pAny->release();
        }, [&]() -> void {
@@ -191,6 +203,10 @@
    for (auto item : plcs) {
        HTREEITEM hItem = m_treeCtrl.InsertItem(item.second->getName().c_str(), nullptr, nullptr);
        m_treeCtrl.SetItemData(hItem, (DWORD_PTR)item.second);
        m_treeCtrl.SetItemBadge(hItem, TREE_BADGE_BACKGROUND, TREE_BADGE_FOREGROUND);
        if (item.second->isConnected()) {
            m_treeCtrl.ShowItemBadgeDotMode(hItem);
        }
        if (hItemFirst == nullptr) {
            hItemFirst = hItem;
        }