|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "LogMgr.h"
|
|
|
|
|
#include "MainFrm.h"
|
|
|
|
|
#include "FileMgr.h"
|
|
|
|
|
#include "Propertie.h"
|
|
|
|
|
#include "PropertieMgr.h"
|
|
|
|
|
#include "BitOperation.h"
|
|
|
|
|
#include "AuthorityMgr.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CLogMgr* gLogMgr = NULL;//<2F><>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
CLogMgr::CLogMgr(void)
|
|
|
|
|
{
|
|
|
|
|
m_bWriteDebugLog = true;
|
|
|
|
|
m_bDebug = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>
|
|
|
|
|
m_DebugCmdDelay = 100;//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ʱʱ<CAB1><CAB1>
|
|
|
|
|
m_LogListMaxLine = 1000;//<2F><>־<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|
|
|
|
m_bWriteToLogList = true;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>б<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
CLogMgr::~CLogMgr(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
void CLogMgr::Ini()
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>pFrame
|
|
|
|
|
CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd();
|
|
|
|
|
#ifdef __DLG_PANE_CMD__
|
|
|
|
|
m_pOutputCmd = &pFrame->m_OutputCmd;
|
|
|
|
|
#endif
|
|
|
|
|
m_pOutputLog = &pFrame->m_OutputLog;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
CString FileName = "\\Debug.txt";
|
|
|
|
|
CFileMgr FileMgr;
|
|
|
|
|
char filepath[1024];
|
|
|
|
|
FileMgr.GetFullFilePath(filepath,FileName);
|
|
|
|
|
m_DebugLogFile.open(filepath);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
CString FileName = "\\Result.txt";
|
|
|
|
|
CFileMgr FileMgr;
|
|
|
|
|
char filepath[1024];
|
|
|
|
|
FileMgr.GetFullFilePath(filepath,FileName);
|
|
|
|
|
m_ResultFile.open(filepath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CMFCPropertyGridProperty *CLogMgr::CreatGridProperty()
|
|
|
|
|
{
|
|
|
|
|
CString PropertyName;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CString Description;//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
CString Path = _T("LogMgr");;//<2F>洢·<E6B4A2><C2B7>
|
|
|
|
|
CString Name;
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
PropertyName = _T("<EFBFBD><EFBFBD>־");
|
|
|
|
|
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY))
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
|
|
|
|
|
Name = _T("bWriteDebugLog");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
|
|
pPropertie->SetpVal((void*)&m_bWriteDebugLog);
|
|
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
|
|
pPropertie->SetpModule(this);
|
|
|
|
|
pPropertie->SetPath(Path);
|
|
|
|
|
pPropertie->SetName(Name);
|
|
|
|
|
pPropertie->WriteRead(true);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
PropertyName = _T("<EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD>");
|
|
|
|
|
Description = _T("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD>");
|
|
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bWriteDebugLog, Description);
|
|
|
|
|
pGroup->AddSubItem(p1);
|
|
|
|
|
|
|
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
|
|
}
|
|
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY))
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
|
|
|
|
|
Name = _T("m_bWriteToLogList");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
|
|
pPropertie->SetpVal((void*)&m_bWriteToLogList);
|
|
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
|
|
pPropertie->SetpModule(this);
|
|
|
|
|
pPropertie->SetPath(Path);
|
|
|
|
|
pPropertie->SetName(Name);
|
|
|
|
|
pPropertie->WriteRead(true);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
PropertyName = _T("<EFBFBD><EFBFBD>־<EFBFBD>б<EFBFBD>");
|
|
|
|
|
Description = _T("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>б<EFBFBD>");
|
|
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bWriteToLogList, Description);
|
|
|
|
|
pGroup->AddSubItem(p1);
|
|
|
|
|
|
|
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
|
|
}
|
|
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY))
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
|
|
|
|
|
Name = _T("m_LogListMaxLine");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
|
|
pPropertie->SetpVal((void*)&m_LogListMaxLine);
|
|
|
|
|
pPropertie->SetType(_PROP_TYPE_INT);
|
|
|
|
|
pPropertie->SetpModule(this);
|
|
|
|
|
pPropertie->SetPath(Path);
|
|
|
|
|
pPropertie->SetName(Name);
|
|
|
|
|
pPropertie->WriteRead(true);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
PropertyName = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
Description = _T("<EFBFBD><EFBFBD>־<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>б<EFBFBD>");
|
|
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_LogListMaxLine, Description);
|
|
|
|
|
pGroup->AddSubItem(p1);
|
|
|
|
|
|
|
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
|
|
}
|
|
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY))
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
|
|
|
|
|
Name = _T("m_bDebug");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
|
|
pPropertie->SetpVal((void*)&m_bDebug);
|
|
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
|
|
pPropertie->SetpModule(this);
|
|
|
|
|
pPropertie->SetPath(Path);
|
|
|
|
|
pPropertie->SetName(Name);
|
|
|
|
|
pPropertie->WriteRead(true);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
PropertyName = _T("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
Description = _T("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>״̬");
|
|
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bDebug, Description);
|
|
|
|
|
pGroup->AddSubItem(p1);
|
|
|
|
|
|
|
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
|
|
}
|
|
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY))
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
|
|
|
|
|
Name = _T("m_DebugCmdDelay");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
|
|
pPropertie->SetpVal((void*)&m_DebugCmdDelay);
|
|
|
|
|
pPropertie->SetType(_PROP_TYPE_INT);
|
|
|
|
|
pPropertie->SetpModule(this);
|
|
|
|
|
pPropertie->SetPath(Path);
|
|
|
|
|
pPropertie->SetName(Name);
|
|
|
|
|
pPropertie->WriteRead(true);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
PropertyName = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ");
|
|
|
|
|
Description = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(ms)");
|
|
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_DebugCmdDelay, Description);
|
|
|
|
|
pGroup->AddSubItem(p1);
|
|
|
|
|
|
|
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
return pGroup;
|
|
|
|
|
}
|
|
|
|
|
void CLogMgr::ExportPar(ofstream *pFile)
|
|
|
|
|
{
|
|
|
|
|
(*pFile)<<"[ģ<><C4A3>] [CLogMgr]------------------------------------------------"<<endl;
|
|
|
|
|
(*pFile)<<"[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־][m_bWriteDebugLog] = "<<m_bWriteDebugLog<<endl;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
//д<><D0B4><EFBFBD><EFBFBD>־
|
|
|
|
|
void CLogMgr::WriteLog(CLog &Log)
|
|
|
|
|
{
|
|
|
|
|
if(gExitApp)
|
|
|
|
|
return;
|
|
|
|
|
CString strTime; //<2F><>ȡϵͳʱ<CDB3><CAB1>
|
|
|
|
|
CTime tm=CTime::GetCurrentTime();
|
|
|
|
|
strTime=tm.Format("[%m<><6D>%d<><64> %X] ");
|
|
|
|
|
//<2F><>־<EFBFBD>б<EFBFBD>
|
|
|
|
|
if(m_bWriteToLogList)
|
|
|
|
|
{
|
|
|
|
|
if(Log.bCmdLog)
|
|
|
|
|
{
|
|
|
|
|
#ifdef __DLG_PANE_CMD__
|
|
|
|
|
CString strCmd = " <20><><EFBFBD><EFBFBD> : ";
|
|
|
|
|
m_pOutputCmd->AddToList(strTime+strCmd+Log.str,m_LogListMaxLine);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_pOutputLog->AddToList(strTime+Log.str,m_LogListMaxLine);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//д<><D0B4><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
if(m_bWriteDebugLog)
|
|
|
|
|
{
|
|
|
|
|
m_DebugLogFile<<Log.str<<endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CLogMgr::WriteCmd(CString Cmd,CString val1,CString val2)
|
|
|
|
|
{
|
|
|
|
|
if(gExitApp)
|
|
|
|
|
return;
|
|
|
|
|
if(val1 != STR_NULL || val2 != STR_NULL)
|
|
|
|
|
{
|
|
|
|
|
Cmd += " : ";
|
|
|
|
|
}
|
|
|
|
|
if(val1 != STR_NULL)
|
|
|
|
|
{
|
|
|
|
|
val1 = "<"+val1+">";
|
|
|
|
|
}
|
|
|
|
|
if(val2 != STR_NULL)
|
|
|
|
|
{
|
|
|
|
|
val2 = "<"+val2+">";
|
|
|
|
|
}
|
|
|
|
|
CLog log;
|
|
|
|
|
log.AddCmdLog();
|
|
|
|
|
log.str = Cmd+val1+val2;
|
|
|
|
|
WriteLog(log);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1//һЩ<D2BB><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>дlog <20><>ʽ
|
|
|
|
|
void CLogMgr::WriteDebugLog(CString Str,LOG_TYPE type)
|
|
|
|
|
{
|
|
|
|
|
if(gExitApp)
|
|
|
|
|
return;
|
|
|
|
|
if(m_bWriteDebugLog || m_bWriteToLogList)
|
|
|
|
|
{
|
|
|
|
|
CLog log;
|
|
|
|
|
log.AddDebugLog();
|
|
|
|
|
switch(type)
|
|
|
|
|
{
|
|
|
|
|
case _LOG_ERROR:
|
|
|
|
|
Str = "[Error]"+Str;
|
|
|
|
|
break;
|
|
|
|
|
case _LOG_FUNC:
|
|
|
|
|
Str = "[Function]"+Str;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
CString str1 = Str;
|
|
|
|
|
log.str = str1;
|
|
|
|
|
WriteLog(log);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CLogMgr::WriteDebugLog(CString Str,CString ValName1,CString ValName2,double val1,double val2)
|
|
|
|
|
{
|
|
|
|
|
if(gExitApp)
|
|
|
|
|
return;
|
|
|
|
|
CString sVal1;
|
|
|
|
|
sVal1.Format("%lf",val1);
|
|
|
|
|
CString sVal2;
|
|
|
|
|
sVal2.Format("%lf",val2);
|
|
|
|
|
CString str = Str+"["+ValName1+"] = "+sVal1+" ["+ValName2+"] = "+sVal2;
|
|
|
|
|
WriteDebugLog(str);
|
|
|
|
|
}
|
|
|
|
|
//һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CLogMgr::WriteDebugLog(CString Str,CString ValName,double val)
|
|
|
|
|
{
|
|
|
|
|
if(gExitApp)
|
|
|
|
|
return;
|
|
|
|
|
CString sVal1;
|
|
|
|
|
sVal1.Format("%lf",val);
|
|
|
|
|
CString str = Str+"["+ValName+"] = "+sVal1;
|
|
|
|
|
WriteDebugLog(str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLogMgr::WriteByte(BYTE bit)
|
|
|
|
|
{
|
|
|
|
|
if(gExitApp)
|
|
|
|
|
return;
|
|
|
|
|
CString str;
|
|
|
|
|
for(int i=0;i<8;i++)
|
|
|
|
|
{
|
|
|
|
|
if(IsBitOn(bit,i))
|
|
|
|
|
str += "1";
|
|
|
|
|
else
|
|
|
|
|
str += "0";
|
|
|
|
|
}
|
|
|
|
|
WriteDebugLog(str);
|
|
|
|
|
}
|
|
|
|
|
void CLogMgr::WriteDebugLogFile(CString str)
|
|
|
|
|
{
|
|
|
|
|
if(gExitApp)
|
|
|
|
|
return;
|
|
|
|
|
if(m_bWriteDebugLog)
|
|
|
|
|
{
|
|
|
|
|
m_DebugLogFile<<str<<endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|