Prechádzať zdrojové kódy

#IQRV #comment 优化context为空的表述

80374374 1 rok pred
rodič
commit
a552605b25

+ 9 - 2
Module/include/DevFSMCommBase.hpp

@@ -824,15 +824,22 @@ public:
 		else if (m_errPkgEx.apiUserCode != 0) {
 			UpdateDEC(m_errPkgEx.apiUserCode);
 		}
-		//oilyang@20200525 if have been set ErrorCode of entity defined (not device),use it directly
-		DWORD dwCode = GetAlarmDEC();
 
+		//oilyang@20200525 if have been set ErrorCode of entity defined (not device),use it directly
+		const DWORD dwCode = GetAlarmDEC();
+		if (context.IsNullOrEmpty() && !devApi.IsNullOrEmpty()) { context = devApi.GetData(); }
+		
 		const CSimpleStringA alarmMsg = CSimpleStringA::Format("{\"Function\":\"%s\", \"DevApi\":\"%s\", \"ReturnCode\":\"%s\", \"Msg\":\"%s\", \"Context\":\"%s\"}"
 			, funPath.GetData(), devApi.GetData(), SpStrError(m_errPkgEx.errCode), csErrMsg.GetData(), context.GetData());
+		
 		CSimpleStringA csErrMsgWithReturnCode = CSimpleStringA::Format("{\"ReturnCode\":\"%s\", \"ErrMsg\":\"%s\", \"Context\":\"%s\"}", SpStrError(errCode), csErrMsg.GetData(), context.GetData());
+		
+		
 		CSimpleStringA tmpRTA(true), tmpDesc(true);
 		if (this->GetEntityBase()->GetFunction()->GetVTMErrMsg(dwCode, tmpDesc, tmpRTA) != Error_Succeed)
 			tmpRTA = CSimpleStringA::Format("%d", dwCode);//if map failed, use dwCode instead
+
+
 		if (bInBusiness) {
 			LogError(Severity_High, m_errPkgEx.errCode, dwCode, alarmMsg.GetData());
 			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_USER).setLogCode(logCode).setAPI(devApi).setResultCode(tmpRTA.GetData()).setCostTime(costTime)(csErrMsgWithReturnCode.GetData());

+ 4 - 5
Module/mod_gpio/mod_gpio.cpp

@@ -665,7 +665,7 @@ void CGpioEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nLogID, con
         DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("hspscanner light off");
         break;
     default:
-        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("unkown event: 0x%X", dwUserCode);
+        //DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("unkown event: 0x%X", dwUserCode);
         return;
     }
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("devseq[%d],mode[%d]close[%d]", Req.devseq, Req.mode, Req.close);
@@ -1095,17 +1095,16 @@ void CGpioEntity::OnEventDetect(void* pData)
 
 	/*物体靠近感知检测*/
 	if (DetectBit(btInput, MOVESENSOR)) {
-		bool toCheck = false;
 		if (!m_bMoveFlag) {
 			m_bMoveFlag = true;
 			m_moveDisappearTimes = 0;
-			LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(20), __LINE__));
+			LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d, times: %lu", GetDriverPortString(20), __LINE__, m_moveHoldTimes));
 		}
 		/** 只是发一次时间时,发现感知实体没有收到或者不处理第一次发出的时间,所以需要沿用原有的发送频率,再继续发送消失的事件,下同  [Gifur@202496]*/
 		else if(m_moveHoldTimes != 0 && (m_moveHoldTimes % (REPEAT_FIRE_TIMEOUT_VALUE / ON_EVENT_DETECT_TIMOUE_MILLSECS))== 0){
-			LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(20), __LINE__));
+			LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d, times: %lu", GetDriverPortString(20), __LINE__, m_moveHoldTimes));
 		}
-		toCheck = !!(m_moveHoldTimes != 0 && (m_moveHoldTimes % (8/*mins*/ * 60 * 1000 / ON_EVENT_DETECT_TIMOUE_MILLSECS) == 0));
+		const bool toCheck = !!(m_moveHoldTimes != 0 && (m_moveHoldTimes % (8/*mins*/ * 60 * 1000 / ON_EVENT_DETECT_TIMOUE_MILLSECS) == 0));
 		if (toCheck) {
 			SYSTEMTIME localTime;
 			GetLocalTime(&localTime);