123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #ifndef WATCHDOG_H
- #define WATCHDOG_H
- #include "wintypes.h"
- #include <map>
- #include <list>
- #include <vector>
- #include <deque>
- #include "TraceManager.h"
- #include "CommDef.h"
- #include "WatchDogClass.h"
- #include <iostream>
- #include <string.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <sys/ioctl.h>
- #include <linux/watchdog.h>
- #include <unistd.h>
- #include "TimerCtrl.h"
- //#include "IOPort.h"
- #include "CkLog.h"
- #include "Algorithm.h"
- typedef unsigned int UINT;
- typedef unsigned int MMRESULT;
- #define _TIMER_DELAY (178 * 1000)
- #define WATCHDOG "/dev/watchdog"
- #define WATCHDOG0 "/dev/watchdog0"
- #define WATCHDOG1 "/dev/watchdog1"
- //编译版本
- #define FILE_VERSION 1
- #pragma pack(push,1)
- class WatchDogClassImpl:public WatchDogClass
- {
- public:
- WatchDogClassImpl();
- ~WatchDogClassImpl();
- //DeviceBaseClass
- virtual ErrorCodeEnum GetDevCategory(DevCategoryInfo &devCategory);
- virtual ErrorCodeEnum Reset();
- virtual ErrorCodeEnum DevClose();
- virtual ErrorCodeEnum GetLastErr(DevErrorInfo &devErrInfo);
- //WatchDogClass
- // Initialization,make preparation for working.
- //
- virtual ErrorCodeEnum DevOpen();
- //
- // Conifgure watchdog.
- // Watchdog start to work in [dwDelay] second.It must be feed in every [dwTimeout]
- // period or it will restart the computer.
- // Arguments:
- // - dwDelay:time to start watching(in second)
- // - dwTimeout:max time period to feed dog(in second)
- //
- virtual ErrorCodeEnum StartWatch(DWORD dwDelay, DWORD dwTimeout);
- //
- // Stop watchdog.
- //
- virtual ErrorCodeEnum StopWatch();
- //
- // Feed watchdog.
- //
- virtual ErrorCodeEnum RefreshDog();
- private:
- bool m_bDevOpen;
- bool m_bDelayTimer;
- bool m_bWDTTimer;
- //WDTTimer
- DWORD m_dwTimeOut;
- DWORD m_dwRealTimeOut;
- DWORD m_dwWDTDelayTime;
- //DelayTimer
- DWORD m_dwDelay;
- DWORD m_dwDelayRemain;
- DWORD m_dwDelayTime;
- //DelayTimerID
- timer_t m_mmDelayTimerID;
- //WDTTimerOutID
- timer_t m_mmWDTTimerID;
- //CHAR m_szErrMsg[MAX_DEV_ERR_MSG];
- CHAR m_szErrMsg[MAX_DEV_ERROR_MSG_LEN];
- //void SaveErrorInfo(CHAR* errMsg, int errCode=95555);
- void SaveErrorInfo(CHAR* errMsg, int errCode, const CHAR* strFunc = NULL, int nLine = 0);
- std::string m_LogFileNamePath;
- int m_wfd;
- CTimerCtrl *m_TimerCtrl;
- //int m_nLogLevel;
- // IOPort* m_pMB330CRM;
- //ILog* m_pLog;
- // IIniFile* m_pIniFile;
- //ILevelLog* m_pLevelLog;
- private:
- int string_format(std::string &str, const std::string fmt, ...);
- //TimerProc
- static void DelayTimer(sigval_t ptr);
- //WDTProc
- static void WDTTimer(sigval_t ptr);
- };
- #endif // WATCHDOG_H
- #pragma pack(pop)
|