#pragma once #include "TimerThreadPools.h" #include #include using namespace std; struct SFDCData { SFDCData() { Reset(); } void Reset() { strName = _T(""); nDataIndex = -1; nDataType = 0; nRepeatType = 0; dwInterval = 10000; dwLastTime = 0; nAddress = -1; nDataSize = 0; nDataValue = 0; fDataValue = 0.0f; } // save / load CString strName; // name int nDataIndex; // index int nRepeatType; // type : 0 once, 1 repeat DWORD dwInterval; // time interval msec int nAddress; // word int nDataSize; // word // DWORD dwLastTime; // last report time msec int nDataType; // data type : 0 int, 1 float int nDataValue; // int float fDataValue; // float }; typedef std::vector VectorSFDCData; typedef std::vector::iterator VectorSFDCDataIt; typedef std::deque DequeSFDCData; typedef std::deque::iterator DequeSFDCDataIt; interface IFDCReporter2Parent { virtual void FDCR2P_ReportFDCData(const SFDCData& fdcData) = 0; virtual BOOL FDCR2P_GetFDCDataValue(SFDCData& fdcData) = 0; }; class AFX_EXT_CLASS CFDCReporter : public CTimerThreadPools { public: CFDCReporter(const CString& strFileName, DWORD dwTime=500); // µ¿Àû ¸¸µé±â¿¡ »ç¿ëµÇ´Â protected »ý¼ºÀÚÀÔ´Ï´Ù. virtual ~CFDCReporter(); void SetFDCR2P(IFDCReporter2Parent* pFDCR2P) { m_pFDCR2P = pFDCR2P; } // CTimerThreadPools virtual BOOL StartThread(); virtual void StopThread(); virtual void ClearOnceData(); virtual void AddDefaultData(); virtual BOOL LoadFDCData(); virtual BOOL SaveFDCData(); virtual void AddFDCData(const SFDCData& data); protected: // CTimerThreadPools virtual void TimerThreadProcess(PVOID pParameter); protected: void Reporting(); CString m_strFileName; BOOL m_bIsRunThread; // thread status BOOL m_bThreadRun; // thread status CRITICAL_SECTION m_csExit; // exit cs DWORD m_dwTime; IFDCReporter2Parent* m_pFDCR2P; VectorSFDCData m_vecFDCData; // repeat };