LAPTOP-SNT8I5JK\Boounion
2025-03-24 f0928d2abc4f3b5875d27b1beeb393cf5edf8c4a
1.Master数据的缓存,主动关闭程序,或程序闪退,可重启还原。
已修改6个文件
109 ■■■■■ 文件已修改
SourceCode/Bond/Servo/CEquipment.cpp 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CGlass.cpp 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CGlass.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMaster.cpp 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMaster.h 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Model.cpp 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CEquipment.cpp
@@ -22,6 +22,11 @@
    CEquipment::~CEquipment()
    {
        for (auto item : m_glassList) {
            item->release();
        }
        m_glassList.clear();
        for (auto item : m_mapStep) {
            delete item.second;
        }
@@ -253,7 +258,26 @@
    void CEquipment::serialize(CArchive& ar)
    {
        if (ar.IsStoring()) {
            Lock();
            int count = (int)m_glassList.size();
            ar << count;
            for (auto item : m_glassList) {
                item->serialize(ar);
            }
            Unlock();
        }
        else {
            Lock();
            int count;
            ar >> count;
            for (int i = 0; i < count; i++) {
                CGlass* pGlass = new CGlass();
                pGlass->serialize(ar);
                addGlassToList(pGlass);
            }
            Unlock();
        }
    }
    void CEquipment::onReceiveLBData(const char* pszData, size_t size)
SourceCode/Bond/Servo/CGlass.cpp
@@ -38,4 +38,20 @@
    {
        return m_strID;
    }
    void CGlass::serialize(CArchive& ar)
    {
        if (ar.IsStoring())
        {
            Lock();
            WriteString(ar, m_strID);
            Unlock();
        }
        else
        {
            Lock();
            ReadString(ar, m_strID);
            Unlock();
        }
    }
}
SourceCode/Bond/Servo/CGlass.h
@@ -15,6 +15,7 @@
        virtual std::string toString();
        void setID(const char* pszID);
        std::string& getID();
        void serialize(CArchive& ar);
    private:
        std::string m_strID;
SourceCode/Bond/Servo/CMaster.cpp
@@ -86,6 +86,10 @@
        connectEquipments();
        // 读缓存数据
        readCache();
        // 定时器
        g_pMaster = this;
        SetTimer(NULL, 1, 250, (TIMERPROC)MasterTimerProc);
@@ -101,6 +105,8 @@
        for (auto item : m_listEquipment) {
            item->term();
        }
        saveCache();
        return 0;
    }
@@ -569,6 +575,10 @@
                }
            }
        }
        // 自动保存缓存
        saveCache();
    }
    void CMaster::connectEquipments()
@@ -643,4 +653,46 @@
            LOGE("连接BakeCooling-LoadPort4失败");
        }
    }
    int CMaster::saveCache()
    {
        CFile file;
        if (!file.Open(m_strFilepath.c_str(), CFile::modeCreate | CFile::modeWrite)) {
            return -1;
        }
        CArchive ar(&file, CArchive::store);
        serialize(ar);
        ar.Close();
        file.Close();
        return 0;
    }
    void CMaster::setCacheFilepath(const char* pszFilepath)
    {
        m_strFilepath = pszFilepath;
    }
    int CMaster::readCache()
    {
        CFile file;
        if (!file.Open(m_strFilepath.c_str(), CFile::modeRead)) {
            return -1;
        }
        CArchive ar(&file, CArchive::load);
        serialize(ar);
        ar.Close();
        file.Close();
        return 0;
    }
    void CMaster::serialize(CArchive& ar)
    {
        for (auto item : m_listEquipment) {
            item->serialize(ar);
        }
    }
}
SourceCode/Bond/Servo/CMaster.h
@@ -35,6 +35,7 @@
        void onTimer(UINT nTimerid);
        std::list<CEquipment*>& getEquipmentList();
        CEquipment* getEquipment(int id);
        void setCacheFilepath(const char* pszFilepath);
    private:
        int addToEquipmentList(CEquipment* pEquipment);
@@ -46,12 +47,15 @@
        int addBonder(int index, StepListener& listener);
        int addBakeCooling(StepListener& listener);
        void connectEquipments();
        int saveCache();
        int readCache();
        void serialize(CArchive& ar);
    private:
        MasterListener m_listener;
        CCCLinkIEControl m_cclink;
        std::list<CEquipment*> m_listEquipment;
        std::string m_strFilepath;
    };
}
SourceCode/Bond/Servo/Model.cpp
@@ -36,7 +36,7 @@
    m_configuration.getUnitId(strUnitId);
    // 机器型号和软件版本号应从配置中读取,当前先固定值
    CString strModeType = _T("Bond2860");
    CString strModeType = _T("Master");
    CString strSoftRev = _T("1.0.2");
@@ -166,6 +166,12 @@
    m_master.setListener(masterListener);
    // master 设置缓存文件
    CString strMasterDataFile;
    strMasterDataFile.Format(_T("%s\\Master.dat"), (LPTSTR)(LPCTSTR)m_strWorkDir);
    m_master.setCacheFilepath((LPTSTR)(LPCTSTR)strMasterDataFile);
    // 加载警告信息
    AlarmManager& alarmManager = AlarmManager::getInstance();
    char szBuffer[MAX_PATH];