소스 검색

#IQRV #comment [Healthmanager] 先从集中配置中读取首次启动等待时间

gifur 3 년 전
부모
커밋
070cefe504
3개의 변경된 파일54개의 추가작업 그리고 17개의 파일을 삭제
  1. 38 0
      Module/include/CommEntitySettings.hpp
  2. 12 13
      Module/mod_healthmanager/HealthManagerFSM.cpp
  3. 4 4
      addin/cfg/HealthManager.ini

+ 38 - 0
Module/include/CommEntitySettings.hpp

@@ -2,6 +2,7 @@
 #define RVC_MOD_COMM_ENTITY_SETTINGS_HPP_
 
 #include "SpBase.h"
+#include "fileutil.h"
 
 namespace SP
 {
@@ -73,7 +74,44 @@ static inline bool IsUsingSubBranchServerConfig(CEntityBase* pEntity)
     return (enable == 1);
 }
 
+/*!
+ * @brief 先从集中配置中读取信息,如果没有,再从本地cfg实体配置文件读取信息
+ * section 使用实体名称,从 GetFunction()->GetEntityName中获取
+ * @param[in]  retStrValue 不为空,则说明读的时字符串,retDwValue 不为空说明读取的是数字,不能都为空,也不能都不为空
+ * @param[out] 
+ * @return : 
+ */
+static inline ErrorCodeEnum ReadConfigFromCenterAfterCfg(
+    CEntityBase* pEntity, LPCTSTR lpcszKey, CSimpleStringA* retStrValue, int* retValue)
+{
+    ErrorCodeEnum result(Error_Succeed);
+    if ((lpcszKey == NULL || strlen(lpcszKey) == 0)
+        || (retStrValue == NULL && retValue == NULL)
+        || (retStrValue != NULL && retValue != NULL)
+        || pEntity == NULL) {
 
+        return Error_Param;
+    }
+
+    CSmartPointer<IConfigInfo> pCenConfig;
+    result = pEntity->GetFunction()->OpenConfig(Config_CenterSetting, pCenConfig);
+    if (retStrValue != NULL) {
+        result = pCenConfig->ReadConfigValue(pEntity->GetEntityName(), lpcszKey, *retStrValue);
+        if (retStrValue->IsNullOrEmpty()) {
+            CSmartPointer<IConfigInfo> pCfgConfig;
+            result = pEntity->GetFunction()->OpenConfig(Config_Software, pCfgConfig);
+            result = pCfgConfig->ReadConfigValue(pEntity->GetEntityName(), lpcszKey, *retStrValue);
+        }
+    } else if(retValue != NULL) {
+        result = pCenConfig->ReadConfigValueInt(pEntity->GetEntityName(), lpcszKey, *retValue);
+        if (*retValue == 0) {
+            CSmartPointer<IConfigInfo> pCfgConfig;
+            result = pEntity->GetFunction()->OpenConfig(Config_Software, pCfgConfig);
+            result = pCfgConfig->ReadConfigValueInt(pEntity->GetEntityName(), lpcszKey, *retValue);
+        }
+    }
+    return result;
+}
 
 
 } //namespace Settings

+ 12 - 13
Module/mod_healthmanager/HealthManagerFSM.cpp

@@ -11,6 +11,7 @@
 #endif
 
 #include "CommEntityUtil.hpp"
+#include "CommEntitySettings.hpp"
 #include "mod_healthmanager.h"
 #include "publicFunExport.h"
 #include "iniutil.h"
@@ -260,13 +261,12 @@ bool CHealthManagerFSM::IsCoolBootThisTime()
 //系统启动小于1.5分钟,认为是冷启动
     const ULONGLONG dwElapse = GetTickCountRVC();
 
-    CSmartPointer<IConfigInfo> pConfig;
-    m_pEntity->GetFunction()->OpenConfig(Config_Software, pConfig);
-    int millsec = 0;
-    pConfig->ReadConfigValueInt("BootMaxMillsecsSeeAsAutoRun", "Value", millsec);
-    if (millsec <= 0) {
-        millsec = 90000;
-    }
+	int millsec = 0;
+	SP::Module::Comm::Settings::ReadConfigFromCenterAfterCfg(m_pEntity, "BootMaxMillsecsSeeAsAutoRun", NULL, &millsec);
+	if (millsec <= 0) {
+		millsec = 90000;
+	}
+
     Dbg("have elapsed %d seconds from system start vs %d", dwElapse / 1000, millsec / 1000);
     if (dwElapse < millsec) {
         return true;
@@ -295,13 +295,12 @@ void CHealthManagerFSM::s1_on_entry()
 
 	if (IsCoolBootThisTime()) {
 		GetEntityBase()->GetFunction()->ShowStartupInfo("正在初始化,请稍等片刻......");
-        CSmartPointer<IConfigInfo> pConfig;
-        m_pEntity->GetFunction()->OpenConfig(Config_Software, pConfig);
         int millsec = 0;
-        pConfig->ReadConfigValueInt("CoolBootDefaultWaitMillsecs", "Value", millsec);
-		if (millsec <= 0) {
-			millsec = 10000;
-		}
+        SP::Module::Comm::Settings::ReadConfigFromCenterAfterCfg(m_pEntity, "CoolBootDefaultWaitMillsecs", NULL, &millsec);
+        if (millsec <= 0) {
+            millsec = 30000;
+        }
+
         Dbg("Sleep a little time %d", millsec);
 		Sleep(millsec);
 	}

+ 4 - 4
addin/cfg/HealthManager.ini

@@ -97,8 +97,8 @@ LowTimesMax=5
 LowInternal=600000
 LowModule=
 
-[CoolBootDefaultWaitMillsecs]
-Value=30000
-[BootMaxMillsecsSeeAsAutoRun]
-Value=90000
+[HealthManager]
+CoolBootDefaultWaitMillsecs=30000
+BootMaxMillsecsSeeAsAutoRun=90000
+