|
@@ -1,26 +1,21 @@
|
|
|
#include "stdafx.h"
|
|
|
#include "mod_alarm.h"
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
-
|
|
|
-#else
|
|
|
+#ifdef RVC_OS_LINUX
|
|
|
#include <sys/timeb.h>
|
|
|
#include "SpUtility.h"
|
|
|
#endif
|
|
|
-
|
|
|
+#include <winpr/sysinfo.h>
|
|
|
|
|
|
void CAlarmEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
|
|
|
const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
|
|
|
const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage, const linkContext &pLinkInfo)
|
|
|
{
|
|
|
- //Dbg("receive log,pszEntityName=%s,eLogType=%d,pszMessage=%s",pszEntityName,(int)eLogType,pszMessage);
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
-
|
|
|
-#else
|
|
|
- CSimpleStringA strMessage(true);
|
|
|
- if (!(pszMessage == NULL || strlen(pszMessage) == 0))
|
|
|
- strMessage = pszMessage;
|
|
|
+ CSimpleStringA strMessage(true);
|
|
|
+ if (!(pszMessage == NULL || strlen(pszMessage) == 0))
|
|
|
+ strMessage = pszMessage;
|
|
|
|
|
|
- //如果是旧模式则转GBK码
|
|
|
+#ifdef RVC_OS_LINUX
|
|
|
+ //TODO: CrossPlaform UOS现在是否还有区分新旧模式 如果是旧模式则转GBK码 [Gifur@2025820]
|
|
|
if (m_fsm.m_CenterModel == 0) {
|
|
|
if (!strMessage.IsNullOrEmpty()) {
|
|
|
std::string tmpStr = SP::Utility::UTF8ToGBK(pszMessage);
|
|
@@ -56,36 +51,13 @@ void CAlarmEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,con
|
|
|
}
|
|
|
|
|
|
char cDescription[512]={0};
|
|
|
- //char clogTime[32]={0};//2020-20-20 12:12:12.100 日志时间,记得释放
|
|
|
char warnTime[20]={0};//2020-20-20 12:12:12 告警时间,记得释放
|
|
|
-
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
SYSTEMTIME st;
|
|
|
GetLocalTime(&st);
|
|
|
- //sprintf(clogTime, "%04d-%02d-%02d %02d:%02d:%02d.%03d ", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
|
|
|
sprintf(warnTime, "%04d-%02d-%02d %02d:%02d:%02d", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
|
|
|
-#else
|
|
|
- struct timeb stime = { 0, 0 };
|
|
|
- tm nowTm = { 0 };
|
|
|
- ftime(&stime);
|
|
|
- localtime_r(&stime.time, &nowTm);
|
|
|
- //sprintf(clogTime, "%04d-%02d-%02d %02d:%02d:%02d.%03d ", nowTm.tm_year + 1900, nowTm.tm_mon + 1, nowTm.tm_mday, nowTm.tm_hour, nowTm.tm_min, nowTm.tm_sec, stime.millitm);
|
|
|
- sprintf(warnTime, "%04d-%02d-%02d %02d:%02d:%02d", nowTm.tm_year + 1900, nowTm.tm_mon + 1, nowTm.tm_mday, nowTm.tm_hour, nowTm.tm_min, nowTm.tm_sec);
|
|
|
-#endif
|
|
|
-
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- strncat(cDescription, pszMessage, 512 - 1);
|
|
|
-#else
|
|
|
strncat(cDescription, strMessage.GetData(), 512 - 1);
|
|
|
-#endif
|
|
|
-
|
|
|
Alarm->Description = _strdup(cDescription);
|
|
|
Alarm->warnTime = _strdup(warnTime);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
m_fsm.add_NewAlarm(Alarm);
|
|
|
m_fsm.m_iRec++;
|
|
|
if(m_fsm.m_iRec%500==0){
|