Преглед изворни кода

#IQRV #comment FrameworkStateEnum 支持

80374374 пре 6 месеци
родитељ
комит
057a30992b

+ 1 - 5
Framework/spbase/SpMisc.cpp

@@ -369,18 +369,14 @@ ErrorCodeEnum SpIniConfig::ReadConfigValueInt(const char *pszSection, const char
 //TODO: forbid from write cfg/entity.ini
 ErrorCodeEnum SpIniConfig::WriteConfigValue(const char *pszSection, const char *pszKey, const char *pszValue)
 {
-	if (m_type == Config_Root && (((FrameworkStateEnum)sp_get_env()->cfg->shell_ini->shell_state) == FrameworkState_NotConfig)) {
-		/** Skip and allow to modify root.ini  [Gifur@20211014]*/
-	} else if (m_type == Config_Hardware || m_type == Config_Shell || m_type == Config_Root || m_type == Config_CenterSetting) {
+	if (m_type == Config_Hardware || m_type == Config_Shell || m_type == Config_Root || m_type == Config_CenterSetting) {
 		return Error_Readonly;
 	}
-
     CSimpleStringA path;
     ErrorCodeEnum Error = _GetMappFilePath(path);
 	if (Error == Error_Succeed) {
 		Error = SpIniFileWriteString(path, pszSection, pszKey, pszValue);
 	}
-
 	return Error;
 }
 

+ 17 - 7
Framework/spbase/sp_cfg.cpp

@@ -1692,21 +1692,25 @@ static int shell_ini__load_entities_list(sp_dir_t* dir, sp_cfg_shell_ini_t* shel
 	return rc;
 }
 
-static int shell_ini__load_sysevent(sp_cfg_shell_ini_t* shell, const char* shell_var_path, std::map<std::string, std::string> &sysEventArr)
+static int shell_ini__init_sysevent(sp_cfg_shell_ini_t* shell)
 {
 	int rc = 0;
-
 	if (NULL == shell->arr_sysevent)
 	{
 		shell->arr_sysevent = shm_array_make(0, sizeof(sp_cfg_shell_sysevent_t*));
+		rc = 1;
+	}
+	else if (shell->arr_sysevent->nelts == 0) {
+		rc = 1;
+	}
+	if (rc == 1) {
 		//单独添加一个框架级别的系统变量
 		sp_cfg_shell_sysevent_t* sysevent = T_MALLOC_T(sp_cfg_shell_sysevent_t, 1);
 		memset(sysevent, 0, sizeof(sp_cfg_shell_sysevent_t));
 		sysevent->name = T_STRDUP(VAR_RSERVERD_KEY_TERM_STATE, 1);
 		sysevent->init_value[0] = '0', sysevent->init_value[1] = '\0';
-
 		sysevent->arr_owner_entity = shm_array_make(0, sizeof(sp_cfg_shell_entity_t*));
-		sp_cfg_shell_entity_t* owner_entity = find_entity(shell, "SpShell");
+		sp_cfg_shell_entity_t* owner_entity = find_entity(shell, SPSHELL_NAME);
 		if (owner_entity) {
 			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("add framework level sys val: %s", VAR_RSERVERD_KEY_TERM_STATE);
 			SHM_ARRAY_PUSH(sysevent->arr_owner_entity, sp_cfg_shell_entity_t*) = owner_entity;
@@ -1718,6 +1722,14 @@ static int shell_ini__load_sysevent(sp_cfg_shell_ini_t* shell, const char* shell
 			destroy_sysevent(sysevent);
 		}
 	}
+	return rc;
+}
+
+static int shell_ini__load_sysevent(sp_cfg_shell_ini_t* shell, const char* shell_var_path, std::map<std::string, std::string> &sysEventArr)
+{
+	int rc = 0;
+
+	shell_ini__init_sysevent(shell);
 
 	for (auto it = sysEventArr.begin(); it != sysEventArr.end(); it++)
 	{
@@ -2109,8 +2121,6 @@ ErrorCodeEnum init_shell_byHttp(sp_dir_t* dir, sp_cfg_shell_ini_t* shell, sp_cfg
 		}
 	}
 
-	
-
 	//init entity debug mode
 	if (args->debug_mode && shell->arr_entity) {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("override entities' debug level!");
@@ -2172,7 +2182,7 @@ ErrorCodeEnum init_shell_byHttp(sp_dir_t* dir, sp_cfg_shell_ini_t* shell, sp_cfg
 	}	
 
 	shell->shell_debug_level = args->debug_mode ? 2 : debug_level;
-	shell->log_record_level = getEntityLogLevel("SpShell");
+	shell->log_record_level = getEntityLogLevel(SPSHELL_NAME);
 
 	if (args->telnet_port == 0)
 		shell->nConsolePort = shellConfig[SHELL_MAIN_HEAD].find(SHELL_MAIN_CONSOLEPORT) != shellConfig[SHELL_MAIN_HEAD].end() ?

+ 21 - 0
Module/mod_healthmanager/HealthManagerFSM.cpp

@@ -85,6 +85,27 @@ ErrorCodeEnum CHealthManagerFSM::Initial()
 ErrorCodeEnum CHealthManagerFSM::OnInit(void)
 {
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Complied at: %s %s", __DATE__, __TIME__);
+
+	/*GifutTest20250314 begin*/
+	do 
+	{
+		CSystemRunInfo sysRunInfo;
+		GetEntityBase()->GetFunction()->GetSystemRunInfo(sysRunInfo);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("gifur test: FrameworkState: %s", SpStrFrameworkState(sysRunInfo.eState));
+	} while (false);
+
+	Sleep(200);
+	/** 更新框架变量  [Gifur@2025314]*/
+	GetEntityBase()->GetFunction()->GetPrivilegeFunction()->RefreshFrameworkState(FrameworkState_Upgrading);
+
+	do
+	{
+		CSystemRunInfo sysRunInfo;
+		GetEntityBase()->GetFunction()->GetSystemRunInfo(sysRunInfo);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("gifur test2: FrameworkState: %s", SpStrFrameworkState(sysRunInfo.eState));
+	} while (false);
+	/*GifutTest20250314 end*/
+
 	return Initial();
 }
 ErrorCodeEnum CHealthManagerFSM::OnExit(void)

+ 0 - 12
Module/mod_healthmanager/mod_healthmanager.cpp

@@ -1455,18 +1455,6 @@ namespace
 	}
 }
 
-bool CHealthManagerEntity::IsTestMode()
-{
-	static int flag = -1;
-	if (flag == -1) {
-		CSystemRunInfo runInfo;
-		bool result = (GetFunction()->GetSystemRunInfo(runInfo) == Error_Succeed
-			&& !!(runInfo.dwBootOption & SystemBootOptionEnum::BootOption_Test));
-		flag = result ? 1 : 0;
-	}
-	return !!flag;
-}
-
 void CHealthManagerEntity::OnEntityStateHook(const char* pszEntityName, const char* pszTriggerEntity, EntityStateEnum eState, EntityStateEnum eLastState)
 {
 	CSmartPointer<IEntityFunction> pFunc = GetFunction();

+ 0 - 2
Module/mod_healthmanager/mod_healthmanager.h

@@ -296,8 +296,6 @@ private:
 	
 	CSimpleStringA __ReadCenterConfigStr(CSimpleStringA key, CSimpleStringA entityName);
 
-	bool IsTestMode();
-
 	void ToCalcRebootHourAndMinute(int restartBegin, int restartEnd);
 	bool CheckUIStateIsM();
 };

+ 8 - 1
Module/mod_vtmloader/VtmLoaderFSM.cpp

@@ -1829,8 +1829,15 @@ bool CVtmLoaderFSM::GetConfig()
 ErrorCodeEnum CVtmLoaderFSM::SubscribeEntitysEvents()
 {
 	//want to do what?
-
 	auto rc = Error_Succeed;
+	/*GifutTest20250314 begin*/
+	CSmartPointer<IEntityFunction> pFunc = GetEntityBase()->GetFunction();
+	rc = pFunc->RegistTerminalStateChangeEvent(dynamic_cast<ITerminalStateChangedListener*>(this->GetEntityBase()));
+	if (rc != Error_Succeed)
+	{
+		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("RegistTerminalStateChangeEvent failed: %s", SpStrError(rc));
+	}
+	/*GifutTest20250314 end*/
 	return rc;
 }
 int CVtmLoaderFSM::HttpConnCheck(CSimpleStringA csHttAddr, HttpAddrType eType)

+ 10 - 1
Module/mod_vtmloader/mod_vtmloader.h

@@ -34,7 +34,7 @@ DWORD thread_testEvent(LPVOID param)
 	return 0;
 }
 
-class CVtmLoaderEntity : public CEntityBase, public ILogListener, public IEntityStateListener
+class CVtmLoaderEntity : public CEntityBase, public ILogListener, public IEntityStateListener/*GifutTest20250314 begin*/, public ITerminalStateChangedListener/*GifutTest20250314 end*/
 {
 public:
 	CVtmLoaderEntity() :m_SubLogID1(0), m_SubLogID2(0), m_dwBeginTime(0),
@@ -87,6 +87,15 @@ public:
 	virtual void OnCloseConnection(const char* pszCallerEntity, const char* pszServiceEntity) { return; }
 	void EntityLostProc(CSimpleStringA entityName);
 	void SetVideoEntityOK() { m_FSM.SetVideoEntityOK(); }
+
+	/*GifutTest20250314 begin*/
+	void OnStateChanged(FrameworkStateEnum oldState, FrameworkStateEnum curState, const char* triggerEntity)
+	{
+		LOG_FUNCTION();
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("state changed from %s to %s by %s", SpStrFrameworkState(oldState), SpStrFrameworkState(curState), triggerEntity);
+	}
+	/*GifutTest20250314 end*/
+
 protected:
 	//GUITask m_task;
 	CVtmLoaderFSM m_FSM;