| | |
| | | connectEquipments(); |
| | | |
| | | |
| | | // 读缓存数据 |
| | | readCache(); |
| | | |
| | | |
| | | // 定时器 |
| | | g_pMaster = this; |
| | | SetTimer(NULL, 1, 250, (TIMERPROC)MasterTimerProc); |
| | |
| | | for (auto item : m_listEquipment) { |
| | | item->term(); |
| | | } |
| | | saveCache(); |
| | | |
| | | |
| | | return 0; |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // 自动保存缓存 |
| | | saveCache(); |
| | | } |
| | | |
| | | void CMaster::connectEquipments() |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |