Browse Source

Z991239-2089 #comment 自检通过健康获取配置实体列表

杨诗友80174847 4 years ago
parent
commit
4723a78c24

+ 18 - 6
Module/mod_healthmanager/HealthManagerFSM.cpp

@@ -1143,6 +1143,7 @@ ErrorCodeEnum CHealthManagerFSM::Initial()
 				case LOADSTAGE_COREBOOT:
 					spConfig->ReadConfigValueInt(strCoreBoot,keyName.c_str(),m_coreBootOpt[keyName.c_str()].loadOpt);
 					m_vCoreBoot.push_back(keyName.c_str());
+					m_vAllCfgEntity.push_back(keyName.c_str());
 					m_coreBootOpt[keyName.c_str()].eResult = LOADING_INIT;
 					m_coreBootOpt[keyName.c_str()].initSn = cbNum;
 					cbNum++;
@@ -1150,6 +1151,7 @@ ErrorCodeEnum CHealthManagerFSM::Initial()
 				case LOADSTAGE_SAFELOAD:
 					spConfig->ReadConfigValueInt(strSafeLoad,keyName.c_str(),m_safeLoadOpt[keyName.c_str()].loadOpt);
 					m_vSafeLoad.push_back(keyName.c_str());
+					m_vAllCfgEntity.push_back(keyName.c_str());
 					m_safeLoadOpt[keyName.c_str()].eResult = LOADING_INIT;
 					m_safeLoadOpt[keyName.c_str()].initSn = slNum;
 					slNum++;
@@ -1161,6 +1163,7 @@ ErrorCodeEnum CHealthManagerFSM::Initial()
 					else
 					{
 						m_vOperating.push_back(keyName.c_str());
+						m_vAllCfgEntity.push_back(keyName.c_str());
 						m_operatingOpt[keyName.c_str()].eResult = LOADING_INIT;
 						m_operatingOpt[keyName.c_str()].initSn = opNum;
 						opNum++;
@@ -1865,15 +1868,24 @@ int CHealthManagerFSM::USBControl()
 	}
 	return 0;
 }
-int CHealthManagerFSM::GetEntityCfgInfo(CSimpleStringA name,int &loadOpt)
+CSimpleStringA CHealthManagerFSM::GetEntityCfgInfo(CSimpleStringA name,int &loadOpt)
 {
+	CSimpleStringA entityList("");
 	Dbg("GetEntityCfgInfo %s",(LPCTSTR)name);
+	if (!name.IsNullOrEmpty() && name.Compare("AllConfiguredEntity") == 0)
+	{
+		for (auto itor = m_vAllCfgEntity.cbegin(); itor != m_vAllCfgEntity.cend(); itor++)
+		{
+			entityList += (*itor) + ",";
+		}
+		return entityList;
+	}
 #ifdef RVC_OS_WIN
 	if (!name.IsNullOrEmpty() && name.Compare("IEBrowser") == 0)
 	{
 		Dbg("IEBrowser just return 2");
 		loadOpt = 2;
-		return 0;
+		return "";
 	}
 #endif //RVC_OS_WIN
 	map<CSimpleStringA,EntityLoadInfo>::iterator it;
@@ -1883,7 +1895,7 @@ int CHealthManagerFSM::GetEntityCfgInfo(CSimpleStringA name,int &loadOpt)
 		{
 			loadOpt = it->second.loadOpt;
 			Dbg("GetEntityCfgInfo %d",loadOpt);
-			return 0;
+			return "";
 		}
 	}
 	for (it = m_safeLoadOpt.begin(); it != m_safeLoadOpt.end(); ++it)
@@ -1892,7 +1904,7 @@ int CHealthManagerFSM::GetEntityCfgInfo(CSimpleStringA name,int &loadOpt)
 		{
 			loadOpt = it->second.loadOpt;
 			Dbg("GetEntityCfgInfo %d",loadOpt);
-			return 0;
+			return "";
 		}
 	}
 	for (it = m_operatingOpt.begin(); it != m_operatingOpt.end(); ++it)
@@ -1901,11 +1913,11 @@ int CHealthManagerFSM::GetEntityCfgInfo(CSimpleStringA name,int &loadOpt)
 		{
 			loadOpt = it->second.loadOpt;
 			Dbg("GetEntityCfgInfo %d",loadOpt);
-			return 0;
+			return "";
 		}
 	}
 	loadOpt = 99;
-	return -1;
+	return "";
 }
 CSimpleStringA CHealthManagerFSM::QueryCheckCode()
 {

+ 2 - 2
Module/mod_healthmanager/HealthManagerFSM.h

@@ -247,7 +247,7 @@ public:
 	void SetCustomerMngerState(int iValue){m_custMngerState = iValue;}
 	int GetCustomerMngerState(){return m_custMngerState;}
 	int USBControl();
-	int GetEntityCfgInfo(CSimpleStringA name,int &loadOpt);
+	CSimpleStringA GetEntityCfgInfo(CSimpleStringA name,int &loadOpt);
 	CSimpleStringA GetUrlValue(){ return m_strURLValue; }
 	void SetMD5OK(const int value){ m_havReceiveMD5OK = value; SetEvent(m_hMD5OKEvt); }
 	int QueryAccessAuthStatus()
@@ -283,7 +283,7 @@ private:
 	LoadStage m_eStage;
 	CSimpleStringA m_SysState,m_strURL,m_strURLValue,m_checkCode,m_csErrEntity;
 	map<int,int> m_enOpt;//entity option
-	vector<CSimpleStringA> m_vCoreBoot,m_vSafeLoad,m_vOperating;
+	vector<CSimpleStringA> m_vCoreBoot,m_vSafeLoad,m_vOperating,m_vAllCfgEntity;
 	map<CSimpleStringA,EntityLoadInfo> m_coreBootOpt;
 	map<CSimpleStringA,EntityLoadInfo> m_safeLoadOpt;
 	map<CSimpleStringA,EntityLoadInfo> m_operatingOpt;

+ 14 - 1
Module/mod_healthmanager/HealthManager_client_g.h

@@ -14,7 +14,20 @@ public:
 	HealthManagerService_ClientBase(CEntityBase *pEntity) : m_pEntityBase(pEntity), m_bSysManaged(false) {}
 
 protected:
-	virtual ~HealthManagerService_ClientBase() {}
+	virtual ~HealthManagerService_ClientBase()
+	{
+		/// override by user
+	}
+private:
+	bool bSessionClosed;
+public:
+	void OnConnectSucceed() { bSessionClosed = false; }
+	void OnClose(ErrorCodeEnum /*eErrorCode*/)
+	{
+		Dbg("session closed.");
+		bSessionClosed = true;
+	}
+	bool QuerySessionClosed(){ return bSessionClosed; }
 public:
 
 	ErrorCodeEnum Connect(CSmartPointer<IAsynWaitSp> &spAsyncWait)

+ 1 - 1
Module/mod_healthmanager/mod_healthmanager.h

@@ -150,7 +150,7 @@ public:
 	}
 	void GetEntityCfgInfo(SpReqAnsContext<HealthManagerService_GetEntityCfgInfo_Req, HealthManagerService_GetEntityCfgInfo_Ans>::Pointer ctx)
 	{
-		m_fsm.GetEntityCfgInfo(ctx->Req.name,ctx->Ans.loadOpt);
+		ctx->Ans.reserved2 = m_fsm.GetEntityCfgInfo(ctx->Req.name,ctx->Ans.loadOpt);
 		ctx->Answer(Error_Succeed);
 	}
 	void GetNetworkState(SpReqAnsContext<HealthManagerService_GetNetworkState_Req, HealthManagerService_GetNetworkState_Ans>::Pointer ctx)

+ 30 - 6
Module/mod_selfchecker/SelfCheckerFSM.cpp

@@ -654,7 +654,7 @@ ErrorCodeEnum CSelfCheckerFSM::GetAllLiveEntity(CAutoArray<CSimpleString> &allEn
 		testStr += tmpName;
 		testStr += ";";
 	}
-	Dbg("allentity[%d][%s]",allEntitys.GetCount(),(const char*)testStr);
+	//Dbg("allentity[%d][%s]",allEntitys.GetCount(),(const char*)testStr);
 	return Error_Succeed;
 }
 //ErrorCodeEnum CSelfCheckerFSM::AddEntity(const char *pszEntityName)
@@ -1567,9 +1567,9 @@ void CSelfCheckerFSM::UpgradeActionProcess(const char *pszEntityName, const char
 ErrorCodeEnum CSelfCheckerFSM::ConnectToHealthManager()
 {
 	LOG_FUNCTION();
-	if (m_pHealthClient == NULL)
+	if (m_pHealthClient == NULL || m_pHealthClient->QuerySessionClosed())
 	{
-		m_pHealthClient = new HealthManagerClient(GetEntityBase());
+		m_pHealthClient = new HealthManagerService_ClientBase(GetEntityBase());
 		ErrorCodeEnum ErrorConn = m_pHealthClient->Connect();
 		if (ErrorConn != Error_Succeed) {
 			m_pHealthClient->SafeDelete();
@@ -1584,7 +1584,31 @@ ErrorCodeEnum CSelfCheckerFSM::ConnectToHealthManager()
 	}
 	return Error_Succeed;
 }
-HealthManagerClient::HealthManagerClient(CEntityBase *pEntity) :HealthManagerService_ClientBase(pEntity)
-{
-
+void CSelfCheckerFSM::SetEverEnterMainPageFlag(bool bValue)
+{ 
+	Dbg("set m_bEverInMainPage:%d,m_bHaveGetEntityList:%d",bValue, m_bHaveGetEntityList);
+	m_bEverInMainPage = bValue; 
+	if (!m_bHaveGetEntityList)
+	{
+		ConnectToHealthManager();
+		if (m_pHealthClient != NULL)
+		{
+			HealthManagerService_GetEntityCfgInfo_Req req;
+			HealthManagerService_GetEntityCfgInfo_Ans ans;
+			req.name = "AllConfiguredEntity";
+			ErrorCodeEnum errCode = m_pHealthClient->GetEntityCfgInfo(req, ans, 5000);
+			if (errCode == Error_Succeed)
+			{
+				m_bHaveGetEntityList = true;
+				CAutoArray<CSimpleStringA> allCfgEntity = ans.reserved2.Split(',');
+				m_activeEntity.clear();
+				for (int i = 0; i < allCfgEntity.GetCount(); i++)
+				{
+					if (allCfgEntity[i].Trim().GetLength() > 1)//except for empty entity name
+						m_activeEntity.push_back(allCfgEntity[i]);
+				}
+				Dbg("to get all entity list:%s", ans.reserved2);
+			}
+		}
+	}
 }

+ 4 - 10
Module/mod_selfchecker/SelfCheckerFSM.h

@@ -129,12 +129,6 @@ enum ProcType
 	ProcType_Shake,
 	ProcType_Warn,
 };
-class HealthManagerClient : public HealthManagerService_ClientBase
-{
-public:
-	HealthManagerClient(CEntityBase *pEntity);
-	~HealthManagerClient() {}
-};
 class CSelfCheckerFSM : public FSMImpl<CSelfCheckerFSM>,public ICallbackListener
 {
 public:
@@ -151,7 +145,7 @@ public:
 		END_FSM_RULE()
 
 		CSelfCheckerFSM() :m_warmLevel(0), m_bFirstCalcCpu(true), m_pHealthClient(NULL) , m_diskLastWarnHour(1)
-	, m_bEverInMainPage(false){}
+	, m_bEverInMainPage(false), m_bHaveGetEntityList(false){}
 	~CSelfCheckerFSM(){}
 	virtual ErrorCodeEnum OnInit();
 	virtual ErrorCodeEnum OnExit();
@@ -183,7 +177,7 @@ public:
 	void SetEntityCfgInfo(const char *pszEntityName,int loadOpt){m_entRunInfo[pszEntityName].loadOpt = loadOpt;Dbg("%s,%d,%d",(LPCTSTR)pszEntityName,loadOpt,m_entRunInfo[pszEntityName].loadOpt);};
 	void SetEntityRestarting(const char* pszEntityName,bool flag) { m_entRunInfo[pszEntityName].bRestarting = flag;}
 	int Proc(string entity, ProcType eType, DWORD dwCode,const char *pszMessage="");
-	void SetEverEnterMainPageFlag(bool bValue = true) { m_bEverInMainPage = bValue; }
+	void SetEverEnterMainPageFlag(bool bValue = true);
 private:
 	ErrorCodeEnum Initial();
 	void OnNormalWorkTimerout(void *pData);
@@ -210,11 +204,11 @@ private:
 	int m_restartNormal,m_restartSpecial,m_maxOsRestart,m_maxPowerRestart
 		,m_cpuHighPercent,m_memHighPercent,m_diskHighPercent,m_warmLevel,m_diskLastWarnHour;
 	DWORD m_dwIssueCount,m_dwCaptureCount;
-	bool m_bInIssue,m_bFirstCalcCpu, m_bEverInMainPage;
+	bool m_bInIssue,m_bFirstCalcCpu, m_bEverInMainPage,m_bHaveGetEntityList;
 	int m_simulateTest;
 	CSimpleStringA m_csKeyEntity,m_csMachineType,m_csSite;
 	__int64  m_xIdlePre,m_xKernelPre,m_xUserPre;
-	HealthManagerClient *m_pHealthClient;
+	HealthManagerService_ClientBase *m_pHealthClient;
 };
 
 template<class T>

+ 2 - 2
Module/mod_selfchecker/mod_selfchecker.cpp

@@ -153,7 +153,7 @@ void CSelfCheckerEntity::OnEntityStateHook(const char *pszEntityName,const char
 			}
 			if (!_strnicmp("IEBrowser",pszEntityName,strlen("IEBrowser")))
 			{
-				Dbg("selfchecker to connect healthmanager...");
+				//Dbg("selfchecker to connect healthmanager...");
 				//ConnectToHealthManager();
 				Dbg("IEBrowser change to idle.");
 				LogEvent(Severity_Middle,LOG_EVT_SELFCHECK_IEBROWSER_IDLE,"IEBrowser to idle.");
@@ -161,7 +161,7 @@ void CSelfCheckerEntity::OnEntityStateHook(const char *pszEntityName,const char
 			}
 			if (!_strnicmp("HealthManager", pszEntityName, strlen("HealthManager")))
 			{
-				Dbg("selfchecker to connect healthmanager...after healthmanager have been restarted.");
+				//Dbg("selfchecker to connect healthmanager...after healthmanager have been restarted.");
 				//ConnectToHealthManager();
 			}
 			if (!_strnicmp("LocalMediaPlay",pszEntityName,strlen("LocalMediaPlay")))

+ 1 - 0
Module/mod_selfchecker/mod_selfchecker.h

@@ -79,6 +79,7 @@ public:
 		//GetFunction()->SubscribeLog(m_uuidPinPad,this,Log_Error,Severity_High,Error_IgnoreAll,-1,"PinPad",false);
 		//GetFunction()->SubscribeLog(m_uuidIDCertificate,this,Log_Error,Severity_High,Error_IgnoreAll,-1,"IDCertificate",false);
 		//GetFunction()->SubscribeLog(m_uuidMedia,this,Log_Error,Severity_High,Error_IgnoreAll,-1,"MediaController",false);
+		GetFunction()->RegistSysVarEvent("UIState", this);
 		CSmartPointer<IConfigInfo> spConfig;
 		ErrorCodeEnum eCfg = pFunc->OpenConfig(Config_Software, spConfig);
 		if (eCfg != Error_Succeed) {