| | |
| | | CMaster::CMaster() |
| | | { |
| | | m_listener = {nullptr, nullptr, nullptr}; |
| | | m_bDataModify = FALSE; |
| | | } |
| | | |
| | | CMaster::~CMaster() |
| | |
| | | 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); |
| | |
| | | |
| | | |
| | | // 自动保存缓存 |
| | | saveCache(); |
| | | if (i % (4 * 2) == 0) { |
| | | if (m_bDataModify) { |
| | | saveCacheAndBackups(); |
| | | m_bDataModify = FALSE; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | void CMaster::connectEquipments() |
| | |
| | | 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; |