From 8942dacbc2bfaf8aec6a360671de20b0fbf32273 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期三, 26 三月 2025 13:43:32 +0800
Subject: [PATCH] 1.Equipment属性页对话框,准备用于展示Equipment数据,里面的Glass等。
---
SourceCode/Bond/Servo/CMaster.cpp | 37 ++++++++++++++++++++++++++++++++++++-
1 files changed, 36 insertions(+), 1 deletions(-)
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 0975cde..145531f 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/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;
--
Gitblit v1.9.3