#pragma once #include "Module.h" #include "GlobalDefine.h" #include "EnumPropertieType.h" //输出日志的类型 enum LOG_TYPE { _LOG_NORMAL=0,//正常 _LOG_ERROR,//错误 _LOG_FUNC,//函数 }; class COutputWnd; class CLog { friend class CLogMgr; public: CLog(void) { bCmdLog = false; bDebugLog = false; } void AddCmdLog(){bCmdLog = true;}; void AddDebugLog(){bDebugLog = true;}; public: CString str; private: bool bCmdLog; bool bDebugLog; }; //负责管理程序日志log 的输出 class CLogMgr:public CModule { public: CLogMgr(void); ~CLogMgr(void); virtual void Ini(); virtual CMFCPropertyGridProperty *CreatGridProperty(); virtual void ExportPar(ofstream *pFile); virtual MODULE GetModuleType(){return _LOG_PROP;}; public: void WriteLog(CLog &Log); ofstream *GetDebugOfstream(){return &m_DebugLogFile;};//调试用 ofstream *GetResultOfstream(){return &m_ResultFile;};//调试用 void WriteCmd(CString Cmd,CString val1,CString val2); void WriteDebugLog(CString Str,LOG_TYPE type = _LOG_NORMAL); void WriteDebugLog(CString Str,CString ValName1,CString ValName2,double val1,double val2); void WriteDebugLog(CString Str,CString ValName,double val); bool IsDebuging(){return m_bDebug;}; int GetDebugCmdDelay(){return m_DebugCmdDelay;}; void WriteByte(BYTE bit); void WriteDebugLogFile(CString str); void SetbWriteDebugLog(bool b){m_bWriteDebugLog = b;}; void WritePlcTimeLog(CString str);//自动记录时间,输出到文本,日期命名 private: #ifdef __DLG_PANE_CMD__ COutputWnd * m_pOutputCmd;//命令输出 #endif COutputWnd * m_pOutputLog;//日志输出 bool m_bWriteDebugLog;//是否输出日志文件 bool m_bWriteToLogList;//输出到日志列表 int m_LogListMaxLine;//日志列表最大的行数,超过时清空 ofstream m_DebugLogFile;//用于debug 的日志文件 ofstream m_ResultFile;//用于记录特殊输出的文件 bool m_bDebug;//是否正在调试 int m_DebugCmdDelay;//调试指令延时时间 CString PlcLogDir;//记录与PLC通信的文本文件 所在的文件夹 public: Dbxy LastTargetCoord; }; extern CLogMgr* gLogMgr;