瀏覽代碼

Z991239-385 #comment 单个实体启动时也支持测试模式

gifur 5 年之前
父節點
當前提交
4beb634784
共有 5 個文件被更改,包括 44 次插入18 次删除
  1. 10 0
      Common/SpBase.h
  2. 3 0
      module/mod_sample/mod_SampleEntity.h
  3. 11 6
      module/mod_validityVertifier/mod_validityVertifier.cpp
  4. 9 0
      spbase/SpEntity.cpp
  5. 11 12
      spbase/sp_cfg.cpp

+ 10 - 0
Common/SpBase.h

@@ -366,12 +366,22 @@ struct CSystemStaticInfo : public CInstallInfo
 	//CSimpleStringA strMachineModel;
 };
 
+/** map to spshell launch options.*/
+enum SystemBootOptionEnum
+{
+	BootOption_Default = 0,
+	BootOption_Test = 1,
+	BootOption_Entity = 2,
+	BootOption_Debug = 4
+};
+
 /** acm system startup info */
 struct CSystemRunInfo
 {
 	CSmallDateTime tmStart;
 	DebugLevelEnum eDebugLevel;
 	FrameworkStateEnum eState;
+	DWORD dwBootOption;
 	CAutoArray<CSimpleStringA> strRunningEntityNames;
 };
 

+ 3 - 0
module/mod_sample/mod_SampleEntity.h

@@ -105,6 +105,9 @@ public:
 
 	virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
 	{
+
+		LOG_FUNCTION();
+
 		ErrorCodeEnum ec = Error_Succeed;
 		if(m_sampleFsm.Init(this) != 0) {
 			ec = Error_InvalidState;

+ 11 - 6
module/mod_validityVertifier/mod_validityVertifier.cpp

@@ -45,6 +45,8 @@ public:
 			}
 		}
 
+		IFFAILBREAK(GetFunction()->GetSystemRunInfo(_runInfo));
+
 		auto privilegeFunc = GetFunction()->GetPrivilegeFunction();
 		privilegeFunc->RegistEntityLifeEvent(this);
 		/*register all entity state*/
@@ -155,11 +157,13 @@ public:
 		else if (eLastState == EntityState_Starting && eState == EntityState_Idle) {
 			/** if meet multi-entities at one mod, do test maybe failed beacause mod is busy at starting other brother entity.*/
 			//TestEntity(pszEntityName);
-			if (strcmp(pszEntityName, "SampleEntity") == 0) {
-				if (_testInfo.isTestMode) {
-					if (IS_SUCCEED(StartTestEntity())) {
-						//TestAllRegistedEntity();
-					}
+
+			if ((_runInfo.dwBootOption & BootOption_Entity) == 0  /** if specified entity fired, do not wake up highvoltage*** entities. */
+				&&
+				/** only after SampleEntity idle, we are permitted to wake up hightVoltage** entities.*/
+				strcmp(pszEntityName, "SampleEntity") == 0) {
+				if (IS_SUCCEED(StartTestEntity())) {
+					//TestAllRegistedEntity();
 				}
 			}
 		}
@@ -216,7 +220,7 @@ public:
 
 	void OnTimeout(DWORD dwTimerID)
 	{
-		Dbg("timer out: %d", dwTimerID);
+		Dbg("timer out: %d, to shake hand", dwTimerID);
 		CAutoArray<CSimpleStringA> arrStartEntities;
 		CAutoArray< DWORD> arrEntitityID;
 		IFFAILBREAK(GetFunction()->GetAllStartedEntity(arrStartEntities, arrEntitityID));
@@ -307,6 +311,7 @@ private:
 	CUUID m_subUUID;
 	CAutoArray<CSimpleStringA> _arrTestEntities;
 	DWORD _dwStartedTestEntities;
+	CSystemRunInfo _runInfo;
 };
 
 SP_BEGIN_ENTITY_MAP()

+ 9 - 0
spbase/SpEntity.cpp

@@ -1335,6 +1335,15 @@ ErrorCodeEnum SpEntity::GetSystemRunInfo(CSystemRunInfo &Info)
 	Info.eDebugLevel = (DebugLevelEnum)cfg->shell_ini->shell_debug_level;
 	Info.tmStart = cfg->run_info->startup_time;
 
+	Info.dwBootOption = 0;
+	if (cfg->args->debug_mode)
+		Info.dwBootOption |= SystemBootOptionEnum::BootOption_Debug;
+	if (cfg->args->test_mode)
+		Info.dwBootOption |= SystemBootOptionEnum::BootOption_Test;
+	if (cfg->args->start_entities != NULL && strlen(cfg->args->start_entities) != 0) {
+		Info.dwBootOption |= SystemBootOptionEnum::BootOption_Entity;
+	}
+
 	sp_mod_mgr_t *mod_mgr = env->mod_mgr;
 	sp_mod_t *pos;
 	array_header_t *arr = array_make(16, sizeof(char*));

+ 11 - 12
spbase/sp_cfg.cpp

@@ -1031,20 +1031,19 @@ static int load_shell_ini(sp_dir_t *dir, sp_cfg_shell_ini_t *shell, const sp_cfg
 		if (rc != 0)
 			return rc;
 	}
-	else {
-		if ((rc = shell_init__load_startup_list(shell, shell_ini_path)) != 0) {
+	else if ((rc = shell_init__load_startup_list(shell, shell_ini_path)) != 0) {
+		return rc;
+	}
+
+	if (args->test_mode) {
+		array_header_t* arr = NULL;
+		if ((rc = shell_ini__load_entity_list(shell, &arr, shell_ini_path, 1)) != 0)
 			return rc;
+		if (arr && arr->nelts > 0) {
+			sp_dbg_info("append additional test entity: %d", arr->nelts);
+			shm_array_cat(shell->arr_startlist, arr);
 		}
-		if (args->test_mode) {
-			array_header_t* arr = NULL;
-			if ((rc = shell_ini__load_entity_list(shell, &arr, shell_ini_path, 1)) != 0)
-				return rc;
-			if (arr && arr->nelts > 0) {
-				sp_dbg_info("append additional test entity: %d", arr->nelts);
-				shm_array_cat(shell->arr_startlist, arr);
-			}
-			shm_array_free(arr);
-		}
+		shm_array_free(arr);
 	}
 
 	shell->shell_debug_level = args->debug_mode ? 2 : shell_ini__load_debug_level(shell_ini_path, "SpShell");