1.Master数据的缓存,主动关闭程序,或程序闪退,可重启还原。
| | |
| | | |
| | | CEquipment::~CEquipment() |
| | | { |
| | | for (auto item : m_glassList) { |
| | | item->release(); |
| | | } |
| | | m_glassList.clear(); |
| | | |
| | | for (auto item : m_mapStep) { |
| | | delete item.second; |
| | | } |
| | |
| | | |
| | | 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) |
| | |
| | | { |
| | | return m_strID; |
| | | } |
| | | |
| | | void CGlass::serialize(CArchive& ar) |
| | | { |
| | | if (ar.IsStoring()) |
| | | { |
| | | Lock(); |
| | | WriteString(ar, m_strID); |
| | | Unlock(); |
| | | } |
| | | else |
| | | { |
| | | Lock(); |
| | | ReadString(ar, m_strID); |
| | | Unlock(); |
| | | } |
| | | } |
| | | } |
| | |
| | | virtual std::string toString(); |
| | | void setID(const char* pszID); |
| | | std::string& getID(); |
| | | void serialize(CArchive& ar); |
| | | |
| | | private: |
| | | std::string m_strID; |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | |
| | | void onTimer(UINT nTimerid); |
| | | std::list<CEquipment*>& getEquipmentList(); |
| | | CEquipment* getEquipment(int id); |
| | | void setCacheFilepath(const char* pszFilepath); |
| | | |
| | | private: |
| | | int addToEquipmentList(CEquipment* pEquipment); |
| | |
| | | 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; |
| | | }; |
| | | } |
| | | |
| | |
| | | m_configuration.getUnitId(strUnitId); |
| | | |
| | | // 机器型号和软件版本号应从配置中读取,当前先固定值 |
| | | CString strModeType = _T("Bond2860"); |
| | | CString strModeType = _T("Master"); |
| | | CString strSoftRev = _T("1.0.2"); |
| | | |
| | | |
| | |
| | | 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]; |