LAPTOP-SNT8I5JK\Boounion
2025-03-24 cfa0f3595c53e3567bb12cb194a37617a7b8a662
1.缓存文件的备份。
已修改6个文件
66 ■■■■ 文件已修改
.gitignore 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CEquipment.cpp 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CEquipment.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMaster.cpp 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMaster.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/EqsGraphWnd.cpp 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -49,3 +49,4 @@
SourceCode/Bond/BoounionPLC/BoounionPLC.vcxproj.user
SourceCode/Bond/x64/Debug/ServoConfiguration.ini
*.iobj
SourceCode/Bond/x64/Debug/Backups/
SourceCode/Bond/Servo/CEquipment.cpp
@@ -7,7 +7,7 @@
    CEquipment::CEquipment() : m_nID(0), m_strName(""), m_strDescription(""), m_station(0, 255)
    {
        m_listener = { nullptr, nullptr };
        m_listener = { nullptr, nullptr, nullptr };
        m_alive = {FALSE, 0, FALSE};
        m_bCimState = FALSE;
        m_bUpstreamInline = FALSE;
@@ -49,6 +49,7 @@
    {
        m_listener.onAlive = listener.onAlive;
        m_listener.onCimStateChanged = listener.onCimStateChanged;
        m_listener.onDataChanged = listener.onDataChanged;
    }
    void CEquipment::setCcLink(CCCLinkIEControl* pCcLink)
@@ -563,6 +564,9 @@
        else if (nRet == FLOW_ACCEPT) {
            m_glassList.pop_front();
            pContext->release();        // 添加到列队时addRef, 取出时release
            if (m_listener.onDataChanged != nullptr) {
                m_listener.onDataChanged(this, 0);
            }
        }
        pContext->release();
@@ -582,6 +586,11 @@
        pGlass->addRef();
        m_glassList.push_back(pGlass);
        Unlock();
        if (m_listener.onDataChanged != nullptr) {
            m_listener.onDataChanged(this, 0);
        }
        return FLOW_ACCEPT;
    }
@@ -593,5 +602,9 @@
        pGlass->addRef();
        m_glassList.push_back(pGlass);
        Unlock();
        if (m_listener.onDataChanged != nullptr) {
            m_listener.onDataChanged(this, 0);
        }
    }
}
SourceCode/Bond/Servo/CEquipment.h
@@ -25,10 +25,12 @@
#define VCR_MAX                        1
    typedef std::function<void(void* pEiuipment, BOOL bAlive)> ONALIVE;
    typedef std::function<void(void* pEiuipment, int code)> ONDATACHANGED;
    typedef struct _EquipmentListener
    {
        ONALIVE                onAlive;
        ONALIVE                onCimStateChanged;
        ONDATACHANGED        onDataChanged;
    } EquipmentListener;
    // Memory Block 结构体定义
SourceCode/Bond/Servo/CMaster.cpp
@@ -14,6 +14,7 @@
    CMaster::CMaster()
    {
        m_listener = {nullptr, nullptr, nullptr};
        m_bDataModify = FALSE;
    }
    CMaster::~CMaster()
@@ -126,6 +127,10 @@
                m_listener.onEqCimStateChanged(this, p, bOn);
            }
        };
        listener.onDataChanged = [&](void* pEquipment, int code) -> void {
            m_bDataModify = TRUE;
        };
        pEquipment->setListener(listener);
        pEquipment->setCcLink(&m_cclink);
        m_listEquipment.push_back(pEquipment);
@@ -578,7 +583,13 @@
        // 自动保存缓存
        saveCache();
        if (i % (4 * 2) == 0) {
            if (m_bDataModify) {
                saveCacheAndBackups();
                m_bDataModify = FALSE;
            }
        }
    }
    void CMaster::connectEquipments()
@@ -669,6 +680,30 @@
        return 0;
    }
    int CMaster::saveCacheAndBackups()
    {
        saveCache();
        // 创建备份目录
        CString strNewFile;
        CString strFileDir = m_strFilepath.c_str();
        int index = strFileDir.ReverseFind('\\');
        ASSERT(index > 0);
        strFileDir = strFileDir.Left(index);
        strFileDir = strFileDir + _T("Backups");
        ::CreateDirectory(strFileDir, nullptr);
        CTime time = CTime::GetCurrentTime();
        strNewFile.Format(_T("%s//Master_%d_%02d_%02d_%02d_%02d_%02d.dat"),
            (LPTSTR)(LPCTSTR)strFileDir,
            time.GetYear(), time.GetMonth(), time.GetDay(),
            time.GetHour(), time.GetMinute(), time.GetSecond());
        ::CopyFile(m_strFilepath.c_str(), strNewFile, FALSE);
        return 0;
    }
    void CMaster::setCacheFilepath(const char* pszFilepath)
    {
        m_strFilepath = pszFilepath;
SourceCode/Bond/Servo/CMaster.h
@@ -48,6 +48,7 @@
        int addBakeCooling(StepListener& listener);
        void connectEquipments();
        int saveCache();
        int saveCacheAndBackups();
        int readCache();
        void serialize(CArchive& ar);
@@ -56,6 +57,7 @@
        CCCLinkIEControl m_cclink;
        std::list<CEquipment*> m_listEquipment;
        std::string m_strFilepath;
        BOOL m_bDataModify;
    };
}
SourceCode/Bond/Servo/EqsGraphWnd.cpp
@@ -35,14 +35,7 @@
    m_hWnd = NULL;
    m_crFrame = GetSysColor(COLOR_WINDOWFRAME);
    m_crBkgnd = RGB(255, 255, 255);
    m_listener.onConnectPin = nullptr;
    m_listener.onCheckConnectPin = nullptr;
    m_listener.onDisconnectPin = nullptr;
    m_listener.onDeleteEqItem = nullptr;
    m_listener.onEqItemPosChanged = nullptr;
    m_listener.onDblckEqItem = nullptr;
    m_listener.onRclickEqItem = nullptr;
    m_listener.onSelectEqItem = nullptr;
    m_listener = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
    m_crItemBackground[0] = RGB(218, 218, 218);
    m_crItemBackground[1] = RGB(193, 208, 227);
    m_crItemFrame[0] = RGB(128, 128, 128);