Przeglądaj źródła

Merge branch 'ST2' into gifur_fixed_everything

80374374 1 rok temu
rodzic
commit
3ff06bc1eb
36 zmienionych plików z 181 dodań i 287 usunięć
  1. 3 0
      Framework/Common/SpHelper.h
  2. 2 2
      Framework/RvcLogSdk/log_builder.c
  3. 1 1
      Framework/RvcLogSdk/log_builder.h
  4. 2 2
      Framework/RvcLogSdk/log_producer_client.c
  5. 1 3
      Framework/RvcLogSdk/log_producer_client.h
  6. 2 2
      Framework/RvcLogSdk/log_producer_manager.c
  7. 1 3
      Framework/RvcLogSdk/log_producer_manager.h
  8. 1 2
      Framework/spbase/SpBase.cpp
  9. 24 0
      Framework/spbase/sp_cfg.cpp
  10. 1 2
      Framework/spbase/sp_cfg.h
  11. 2 1
      Framework/spbase/sp_httpDefine.cpp
  12. 24 9
      Framework/spbase/sp_logwithlink.cpp
  13. 8 8
      Framework/spbase/sp_mod.c
  14. 1 1
      Framework/spbase/sp_mod.h
  15. 6 0
      Framework/spbase/sp_runTask.cpp
  16. 1 0
      Framework/spbase/sp_runTask.h
  17. 3 3
      Framework/sphost/sphost.c
  18. 2 1
      Framework/spshell/spshell.cpp
  19. 0 3
      Framework/spshell/svc.cpp
  20. 2 1
      Module/include/DevFSMCommBase.hpp
  21. 1 0
      Module/include/EventCode.h
  22. 2 2
      Module/mod_chromium/CModTools.cpp
  23. 4 1
      Module/mod_chromium/mod_chromium.cpp
  24. 1 0
      Module/mod_guiconsole/mod_GuiConsole.h
  25. 10 0
      Module/mod_guiconsole/mod_guiconsole.cpp
  26. 4 12
      Module/mod_healthmanager/HealthManagerFSM.cpp
  27. 45 205
      Module/mod_healthmanager/mod_healthmanager.cpp
  28. 10 13
      Module/mod_healthmanager/mod_healthmanager.h
  29. 2 0
      Module/mod_pinpad/PinPadFSM.cpp
  30. 1 1
      Module/mod_pinpad/PinPad_UserErrorCode.h
  31. 3 2
      Other/liblog4rvcother/log4cplus_helper.cpp
  32. 2 2
      Other/liblog4rvcother/log4upload.h
  33. 2 1
      Other/liblog4vendor/log4cplus_helper.cpp
  34. 2 2
      Other/liblog4vendor/log4upload.h
  35. 1 1
      addin/cmake/DependencyConanFiles.cmake
  36. 4 1
      addin/packaging/WIN/Readme.txt

+ 3 - 0
Framework/Common/SpHelper.h

@@ -216,6 +216,7 @@ struct SpReqAnsContext
 
 	virtual ErrorCodeEnum Answer(ErrorCodeEnum Error = Error_Succeed)
 	{
+		EntityResource::clearLink();
 		//static_assert(Error == Error_Succeed, "Input parameter must be Error_Succeed!");
 		if (Error == Error_Succeed) {
 			CAutoBuffer Buf = SpObject2Buffer<TAns>(Ans);
@@ -227,6 +228,7 @@ struct SpReqAnsContext
 
 	virtual ErrorCodeEnum Answer(ErrorCodeEnum eSysError, DWORD dwUserError)
 	{
+		EntityResource::clearLink();
 		if (eSysError == Error_Succeed) {
 			CAutoBuffer Buf = SpObject2Buffer<TAns>(Ans);
 			return m_spTransactionContext->SendAnswer(Buf, true);
@@ -237,6 +239,7 @@ struct SpReqAnsContext
 
 	virtual ErrorCodeEnum Answer(ErrorCodeEnum eSysError, DWORD dwUserError, CSimpleString str)
 	{
+		EntityResource::clearLink();
 		if (eSysError == Error_Succeed) {
 			CAutoBuffer Buf = SpObject2Buffer<TAns>(Ans);
 			return m_spTransactionContext->SendAnswer(Buf, true);

+ 2 - 2
Framework/RvcLogSdk/log_builder.c

@@ -199,7 +199,7 @@ int add_beidou_log(log_group_builder* bder, beidou_log_item* log) {
 }
 
 
-int add_log(log_group_builder* bder, long start_time, uint32_t pack_index, log_item* log)
+int add_log(log_group_builder* bder, long start_time, uint32_t pack_index, log_item* log, long record_time)
 {
     cJSON* skyeye_content;
     cJSON* united_content;
@@ -222,7 +222,7 @@ int add_log(log_group_builder* bder, long start_time, uint32_t pack_index, log_i
     aos_debug_log((LB, "add_log 1"));
     GetLocalIP(local_ip_str);
     aos_debug_log((LB, "add_log 2"));
-    now = time(NULL);
+    now = record_time;
     aos_debug_log((LB, "add_log 3"));
     GetTimeStr(now, nowTime);
     aos_debug_log((LB, "add_log 4"));

+ 1 - 1
Framework/RvcLogSdk/log_builder.h

@@ -79,7 +79,7 @@ typedef struct _serialize_buf {
 extern log_group_builder* log_group_create(log_producer_config* config);
 extern log_group_builder* log_group_clone(log_group_builder* bder);
 extern void log_group_destroy(log_group_builder* bder);
-extern int add_log(log_group_builder* bder, long start_time, uint32_t pack_index, log_item* log);
+extern int add_log(log_group_builder* bder, long start_time, uint32_t pack_index, log_item* log, long record_time);
 extern int add_beidou_log(log_group_builder* bder, beidou_log_item* log);
 extern int add_log_raw(log_group_builder* bder, build_item* log);
 extern int add_log_serialize_buf(log_group_builder* bder, serialize_buf* buffer);

+ 2 - 2
Framework/RvcLogSdk/log_producer_client.c

@@ -126,7 +126,7 @@ void destroy_log_producer_client(log_producer_client* client)
 }
 
 log_producer_result log_producer_client_add_log(log_producer_client* client,
-    log_item* log, int flush)
+    log_item* log, int flush, long record_time)
 {
     int rst;
     int i = 0, j = 0;
@@ -145,7 +145,7 @@ log_producer_result log_producer_client_add_log(log_producer_client* client,
     CS_LEAVE(manager->lock);
 
     //日志放入内存缓存,再发送
-    rst = log_producer_manager_add_log(manager, log, flush);
+    rst = log_producer_manager_add_log(manager, log, flush, record_time);
     //aos_debug_log((LB, "log producer client add log rst %d", rst));
     
     return rst;

+ 1 - 3
Framework/RvcLogSdk/log_producer_client.h

@@ -60,9 +60,7 @@ LOG_EXPORT void destroy_log_producer_client(log_producer_client* client);
  * @param flush
  * @return ok if success, LOG_PRODUCER_DROP_ERROR if buffer is full, LOG_PRODUCER_INVALID if client is destroyed, LOG_PRODUCER_PERSISTENT_ERROR is save binlog failed.
  */
-LOG_EXPORT log_producer_result log_producer_client_add_log(log_producer_client* client,
-    log_item* log,
-    int flush);
+LOG_EXPORT log_producer_result log_producer_client_add_log(log_producer_client* client, log_item* log, int flush, long record_time);
 
 /**
  * add log天眼

+ 2 - 2
Framework/RvcLogSdk/log_producer_manager.c

@@ -673,11 +673,11 @@ CS_LEAVE(producer_manager->lock); \
 return ret; }
 
 
-log_producer_result log_producer_manager_add_log(log_producer_manager* producer_manager, log_item* log, int flush)
+log_producer_result log_producer_manager_add_log(log_producer_manager* producer_manager, log_item* log, int flush, long record_time)
 {
     LOG_PRODUCER_MANAGER_ADD_LOG_BEGIN;
 
-    if (0 != add_log(producer_manager->builder, producer_manager->start_time, producer_manager->pack_index, log)) {
+    if (0 != add_log(producer_manager->builder, producer_manager->start_time, producer_manager->pack_index, log, record_time)) {
         aos_error_log((LB, "add log failed !"));
     }
 

+ 1 - 3
Framework/RvcLogSdk/log_producer_manager.h

@@ -48,9 +48,7 @@ typedef struct _log_producer_manager
 extern log_producer_manager* create_log_producer_manager(log_producer_config* producer_config);
 extern void destroy_log_producer_manager(log_producer_manager* manager);
 
-extern log_producer_result log_producer_manager_add_log(log_producer_manager* producer_manager,
-    log_item* log,
-    int flush);
+extern log_producer_result log_producer_manager_add_log(log_producer_manager* producer_manager, log_item* log, int flush, long record_time);
 
 extern log_producer_result log_producer_manager_add_beidou_log(log_producer_manager* producer_manager,
     beidou_log_item* log,

+ 1 - 2
Framework/spbase/SpBase.cpp

@@ -118,7 +118,6 @@ static LONG WINAPI SuppressError(struct _EXCEPTION_POINTERS* ExceptionInfo)
 
 		BOOL rv = MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), 
 			hDumpFile, mdt, (ExceptionInfo != 0) ? &mdei : 0, 0, 0 ); 
-
 		CloseHandle( hDumpFile );
 	}
 	DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__).setLogCode(ERR_ENTITY_EXCEPTION).setVtmCode(RTAERR_ENTITY_EXCEPTION)("exit entity exception, saveDmp, %s, detail:%d:%s"
@@ -236,7 +235,7 @@ SPBASE_API void LogEvent(const SeverityLevelEnum eLevel,DWORD dwUserEventCode,co
 	}
 
 	// write a copy in dbg log
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__).setVtmCode(DWORD2Hex(dwUserEventCode).GetData())
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__).setVtmCode(DWORD2Hex(dwUserEventCode).GetData())
 		("Event: {%s}(uc=0x%X)", pszMessage, dwUserEventCode);
 }
 

+ 24 - 0
Framework/spbase/sp_cfg.cpp

@@ -115,6 +115,9 @@ auto fileExist = [](const char* path) ->bool {
 ErrorCodeEnum init_shell_byHttp(sp_dir_t* dir, sp_cfg_shell_ini_t* shell, sp_cfg_root_ini_t* root, const sp_cfg_start_args_t* args,
 	const char* shellVarIni, std::map<std::string, std::map<std::string, std::string>> shellConfig);
 
+int sp_tryReadFromCacheConfig(int cfgType, const char* section, const char* key, char* dst, int max_len);
+int sp_tryRefreshLogLevelFromCacheConfig();
+
 
 void shell_getHttpToken(std::string& channelId, std::string& token)
 {
@@ -686,6 +689,25 @@ int sp_tryReadFromCacheConfig(int cfgType, const char* section, const char* key,
 	}
 }
 
+int sp_tryRefreshLogLevelFromCacheConfig()
+{
+	char tmp[MAX_PATH];
+	GetModuleFileNameA(NULL, tmp, MAX_PATH);
+	*strrchr(tmp, SPLIT_SLASH) = 0;
+	*strrchr(tmp, SPLIT_SLASH) = 0;
+	*strrchr(tmp, SPLIT_SLASH) = 0;
+	*strrchr(tmp, SPLIT_SLASH) = 0;
+	sprintf(tmp, "%s" SPLIT_SLASH_STR "runinfo" SPLIT_SLASH_STR "runcfg" SPLIT_SLASH_STR "CenterCfg", tmp);
+	if (!ExistsFile(tmp))
+		return ErrorCodeEnum::Error_NotConfig;
+	std::string cfgInfo = TerminalCfgRet::readStrFromFile(tmp);
+	std::map<std::string, std::map<std::string, std::string>> tmp_Config;
+	ConvertStrToDeviceConfigMap(cfgInfo, tmp_Config);
+
+	load_debugLevelInMem(tmp_Config);
+	return 0;
+}
+
 int sp_tryReadFromCenterSetting(const char* section, const char* key, char *dst, int max_len)
 {
 	char tmp[MAX_PATH];
@@ -1584,6 +1606,7 @@ static int shell_ini__load_entities_list(sp_dir_t* dir, sp_cfg_shell_ini_t* shel
 #endif //_MSC_VER
 						mod->mem_trace = memTraceArr.find(entity->name) == memTraceArr.end() ? 0 : memTraceArr[cur_it->first];
 						mod->idx = shell->arr_module->nelts;
+						//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("mod idx, %s : %d", entity->name, mod->idx);
 						SHM_ARRAY_PUSH(shell->arr_module, sp_cfg_shell_module_t*) = mod;
 					}
 					else {
@@ -1595,6 +1618,7 @@ static int shell_ini__load_entities_list(sp_dir_t* dir, sp_cfg_shell_ini_t* shel
 				}
 				entity->mod = mod;
 				entity->idx = shell->arr_entity->nelts;
+				//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("entity idx, %s : %d", entity->name, entity->idx);
 				SHM_ARRAY_PUSH(shell->arr_entity, sp_cfg_shell_entity_t*) = entity;
 				//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("entity: %s, id: %d", entity->name, entity->idx);
 			}

+ 1 - 2
Framework/spbase/sp_cfg.h

@@ -252,9 +252,8 @@ SPBASE_API int sp_TryUpdateCfg();
 SPBASE_API int sp_ModifyMemCfg(const char* configType, const char* module, const char* name, const char* value);
 int sp_TryUpdateCenterCfg(int *isUpdate, int *isReset, char *version);
 SPBASE_API int sp_tryReadFromCenterSetting(const char *section, const char *key, char *dst, int max_len);
-SPBASE_API int sp_tryReadFromCacheConfig(int cfgType, const char* section, const char* key, char* dst, int max_len);
 SPBASE_API int sp_TryUpdate_vtm_err_msg();
-
+SPBASE_API int sp_tryRefreshLogLevelFromCacheConfig();
 SPBASE_API void sp_cfg_setShellFirstStartTime(LARGE_TIME t_shellFirstStart);
 SPBASE_API void load_specialRunInfoInCentersetting(const char* fileName);
 SPBASE_API LARGE_TIME sp_cfg_getShellFirstStartTime();

+ 2 - 1
Framework/spbase/sp_httpDefine.cpp

@@ -9,6 +9,7 @@
 #include <fstream>
 #include <ostream>
 #include <iostream>
+#include "SpUtility.h"
 //#include "cpp-httplib/httplib.h"
 
 #define QUERY_TERMINAL_MAX_WAIT_TIME 10000
@@ -852,7 +853,7 @@ int ConvertStrToVTMErrMsg(std::string input, CAutoArray<CSimpleStringA>& strErro
 	{
 		CSimpleString errorCode = (*it)[VTMERRMSG_CONFIG_ERRORCODE].asString().c_str();
 		CSimpleString description = (*it)[VTMERRMSG_CONFIG_DESCRIPETION].asString().c_str();
-		CSimpleString remark = (*it)[VTMERRMSG_CONFIG_REMARK].asString().c_str();
+		CSimpleString remark = SP::Utility::ToLower((*it)[VTMERRMSG_CONFIG_REMARK].asString()).c_str();
 		errorCodeArr.push_back(errorCode);
 		descriptionArr.push_back(description);
 		remarkArr.push_back(remark);

+ 24 - 9
Framework/spbase/sp_logwithlink.cpp

@@ -28,7 +28,7 @@
 
 void* g_logProducer = NULL;//为spshell、spbase共用,所以不放入getEntityResource中
 //#define MAX_LOG_LEN 9700 //大致为10 * 1024 - 400(固定头)
-#define MAX_LOG_LEN 2000
+#define MAX_LOG_LEN 1900
 
 #define MAX_ENTITY_SAVE_LEN 100
 
@@ -111,9 +111,11 @@ public:
     CSimpleString VtmCode;
     void* logProducer;
     bool m_doLog;
+    long m_time;
     Link_private(LOG_LEVEL_E t_level, LOG_TYPE_E t_type)
         : Level(t_level), Type(t_type), BeginTime(0), EndTime(0), CostTime(0), ResultCode("SUC0000"), m_doLog(true)
     {
+        m_time = time(NULL);
         TraceID = ResultMsg = LogCode = API = BussID = TipMsg = SourceType = VtmCode = "";
         logProducer = NULL;
     }
@@ -283,6 +285,12 @@ DbgToBeidou& DbgToBeidou::withLogProducer(void* t_logProducer) {
 
 DbgWithLink::DbgWithLink(LOG_LEVEL_E t_level, LOG_TYPE_E t_type) : m_priPtr(new Link_private(t_level, t_type))
 {
+    auto curLink = EntityResource::getLink();
+    if (curLink.traceId.GetLength() > 0 && curLink.bussinessId.GetLength() > 0)
+    {
+        m_priPtr->TraceID = curLink.traceId;
+        m_priPtr->BussID = curLink.bussinessId;
+    }
 }
 
 DbgWithLink::~DbgWithLink() {
@@ -423,9 +431,9 @@ void DbgWithLink::operator () (const char* str, ...)  const  {
         }
         if (cur != NULL) {
             if (log.Type == LOG_TYPE_SYSTEM && curEntityLogLevel <= log.Level)
-                rst = log_producer_client_add_log(cur, &log, 1);
+                rst = log_producer_client_add_log(cur, &log, 1, m_priPtr->m_time);
             else if (log.Type != LOG_TYPE_SYSTEM)
-                rst = log_producer_client_add_log(cur, &log, 1);
+                rst = log_producer_client_add_log(cur, &log, 1, m_priPtr->m_time);
         }
     }
 
@@ -486,9 +494,9 @@ void DbgWithLink::operator () ()  const  {
     }
     if (cur != NULL) {
         if (log.Type == LOG_TYPE_SYSTEM && curEntityLogLevel <= log.Level)
-            log_producer_client_add_log(cur, &log, 1);
+            log_producer_client_add_log(cur, &log, 1, m_priPtr->m_time);
         else if (log.Type != LOG_TYPE_SYSTEM)
-            log_producer_client_add_log(cur, &log, 1);
+            log_producer_client_add_log(cur, &log, 1, m_priPtr->m_time);
     }
 
     if (!m_priPtr->m_doLog)
@@ -741,16 +749,23 @@ SPBASE_API bool refreshLogLevel()
         sp_cfg_t* cfg = env->cfg;
         sp_cfg_shell_entity_t* ent = sp_cfg_get_entity_by_idx(cfg, g_curEntityIdx);
         if (ent) {
-        curEntityLogLevel = ent->log_record_level;
+            curEntityLogLevel = ent->log_record_level;
+            DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("refreshLogLevel change to EntityLevel:%d", curEntityLogLevel);
         }
     }
-    else {
-            if (g_entityDebugLevelArr.find("Common") != g_entityDebugLevelArr.end()) {
+    else
+    {
+        if (g_entityDebugLevelArr.find("Common") != g_entityDebugLevelArr.end()) 
+        {
             curEntityLogLevel = g_entityDebugLevelArr["Common"];
-            }
+            DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("refreshLogLevel change to Common:%d", curEntityLogLevel);
+        }
         else
+        {
+            DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("refreshLogLevel change to Default:%d", curEntityLogLevel);
             curEntityLogLevel = 1;
         }
+    }
     return true;
 }
 

+ 8 - 8
Framework/spbase/sp_mod.c

@@ -839,7 +839,7 @@ int assigntoJob(HANDLE process, int pid)
 }
 #endif //RVC_OS_WIN
 
-static int create_module_process(const char *mod_name, int epid, int range, int debugFileExist, tk_process_t* new_process, int runType)
+static int create_module_process(const char *mod_name, int epid, int range, int debugFileExist, tk_process_t* new_process, int runType, int entity_id)
 {
 	char app[MAX_PATH] = {'\0'};
 	int group = 0;
@@ -876,7 +876,7 @@ static int create_module_process(const char *mod_name, int epid, int range, int
 	else
 		sprintf(app, ".\\bin\\sphost_re.exe {%s} %d", mutexName, shellId);
 
-	sprintf_s(writeParam, sizeof(writeParam), "%s %d %d %s %d", mod_name, epid, range, mutexName, debugFileExist);
+	sprintf_s(writeParam, sizeof(writeParam), "%s %d %d %s %d %d", mod_name, epid, range, mutexName, debugFileExist, entity_id);
 
 	do {
 		sp_process_t* curProcess = ZALLOC_T(sp_process_t);
@@ -963,7 +963,7 @@ static int create_module_process(const char *mod_name, int epid, int range, int
 
 	tk_process_t* process = NULL;
 	tk_process_option_t option;
-	sprintf(app, "./bin/sphost %d %s %d %d", range, mod_name, epid, debugFileExist);
+	sprintf(app, "./bin/sphost %d %s %d %d %d", range, mod_name, epid, debugFileExist, entity_id);
 	option.exit_cb = NULL;
 	option.file = NULL;
 	option.flags = 0;
@@ -1771,7 +1771,7 @@ static void unlock_doing(sp_mod_mgr_t *mgr, sp_mod_t *mod)
 #endif //_WIN32
 }
 
-static int load_module(sp_mod_mgr_t *mgr, sp_mod_t *mod, int trigger_entity_id)
+static int load_module(sp_mod_mgr_t *mgr, sp_mod_t *mod, int trigger_entity_id, int entity_id)
 {
 	int rc = 0;
 	sp_env_t *env = sp_get_env();
@@ -1785,7 +1785,7 @@ static int load_module(sp_mod_mgr_t *mgr, sp_mod_t *mod, int trigger_entity_id)
 #endif //_WIN32
 	if (!mod->loaded) {
 		ResetEvent(mod->evt_app_exit);
-		if (0 != create_module_process(mod->cfg->name, mod->cfg->idx, env->shm_range, mod->cfg->debugFileExist, &mod->process, mod->cfg->runType)) {
+		if (0 != create_module_process(mod->cfg->name, mod->cfg->idx, env->shm_range, mod->cfg->debugFileExist, &mod->process, mod->cfg->runType, entity_id)) {
 			DbgWithLinkForC(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM, "sp_mod_mgr_load_module %s failed! create module process failed", mod->cfg->name);
 			rc = Error_Unexpect;
 		} else {
@@ -2462,7 +2462,7 @@ int sp_mod_mgr_start_entity(sp_mod_mgr_t *mgr, int entity_id, const char *cmdlin
 	ent = sp_mod_mgr_find_entity_by_idx(mgr, entity_id);
 	if (!ent)
 		return Error_NotExist;
-	return sp_mod_mgr_start_entity2(mgr, ent, cmdline, trigger_entity_id);
+	return sp_mod_mgr_start_entity2(mgr, ent, cmdline, trigger_entity_id, entity_id);
 }
 
 int sp_mod_mgr_stop_entity(sp_mod_mgr_t *mgr, int entity_id, int trigger_entity_id, int cause_code)
@@ -2555,7 +2555,7 @@ int sp_mod_mgr_terminate_all_entity(sp_mod_mgr_t* mgr, int trigger_entity_id)
 	return rc;
 }
 
-int sp_mod_mgr_start_entity2(sp_mod_mgr_t *mgr, sp_entity_t *ent, const char *cmdline, int trigger_entity_id)
+int sp_mod_mgr_start_entity2(sp_mod_mgr_t *mgr, sp_entity_t *ent, const char *cmdline, int trigger_entity_id, int entity_id)
 {
 	int rc = 0;
 	ULONGLONG curTickCount;
@@ -2576,7 +2576,7 @@ int sp_mod_mgr_start_entity2(sp_mod_mgr_t *mgr, sp_entity_t *ent, const char *cm
 			GetLocalTime(&ent->cfg->m_EntityStartTime);
 #endif //_MSC_VER
         if (!ent->mod->loaded)
-            rc = load_module(mgr, ent->mod, trigger_entity_id);	//start Entity process return init ok
+            rc = load_module(mgr, ent->mod, trigger_entity_id, entity_id);	//start Entity process return init ok
         if (isFirstStart)
 #if defined(_MSC_VER)
 			ent->cfg->m_EntityInitEndTime.longPart = sp_cfg_getShellFirstStartTime().longPart + clock() * 10000;

+ 1 - 1
Framework/spbase/sp_mod.h

@@ -202,7 +202,7 @@ SPBASE_API int sp_mod_mgr_terminate_all_entity(sp_mod_mgr_t* mgr, int trigger_en
 
 
 int sp_mod_mgr_terminate_entity2(sp_mod_mgr_t *mgr, sp_entity_t *entity, int trigger_entity_id);
-int sp_mod_mgr_start_entity2(sp_mod_mgr_t *mgr, sp_entity_t *entity, const char *cmdline, int trigger_entity_id);
+int sp_mod_mgr_start_entity2(sp_mod_mgr_t *mgr, sp_entity_t *entity, const char *cmdline, int trigger_entity_id, int entity_id);
 int sp_mod_mgr_stop_entity2(sp_mod_mgr_t *mgr, sp_entity_t *entity, int trigger_entity_id, int cause_code);
 int sp_mod_mgr_pause_entity2(sp_mod_mgr_t *mgr, sp_entity_t *entity, int trigger_entity_id);
 int sp_mod_mgr_continue_entity2(sp_mod_mgr_t *mgr, sp_entity_t *entity, int trigger_entity_id);

+ 6 - 0
Framework/spbase/sp_runTask.cpp

@@ -11,6 +11,7 @@
 #endif //_MSC_VER
 #include <SpBase.h>
 #include "fileutil.h"
+#include "sp_cfg.h"
 
 extern std::vector<std::string> getKillArr();
 
@@ -120,3 +121,8 @@ int sp_runtask_killprocess()
 	return 0;
 }
 
+int sp_runtask_loadLogLevel()
+{
+	sp_tryRefreshLogLevelFromCacheConfig();
+	return 0;
+}

+ 1 - 0
Framework/spbase/sp_runTask.h

@@ -9,6 +9,7 @@ extern "C" {
 
 	SPBASE_API int sp_runtask_killprocess();
 	SPBASE_API int sp_runtask_startprocess();
+	SPBASE_API int sp_runtask_loadLogLevel();
 
 #ifdef __cplusplus
 } // extern "C" {

+ 3 - 3
Framework/sphost/sphost.c

@@ -337,7 +337,7 @@ int main(int argc, char *argv[])
 		if (-1 == (paramNum = paramSplit(readBuf, dstParam)))
 			continue;
 
-		if (!strcmp(dstParam[0], "start") && paramNum == 6)
+		if (!strcmp(dstParam[0], "start") && paramNum == 7)
 		{//start
 			
 			mod_runInfo *curModInfo = (mod_runInfo*)malloc(sizeof(mod_runInfo));
@@ -348,7 +348,7 @@ int main(int argc, char *argv[])
 			strcpy(curModInfo->modMutexName, dstParam[4]);
 			curModInfo->group = 0;
 			g_saveFile = atoi((dstParam[5]));
-			setCurEntityIdx(curModInfo->epid);
+			setCurEntityIdx(atoi(dstParam[6]));
 			createLogProducer(dstParam[1], dstParam[2]);
 			if (testDua1 > 100 || testDual2 > 100 || testDual3 > 100 || testDual4 > 100)
 				DbgWithLink_sphost("sphost initTest in %d-%d-%d-%d", testDua1, testDual2, testDual3, testDual4);
@@ -434,7 +434,7 @@ int main(int argc, char *argv[])
 	epid = atoi(argv[3]);
 	g_saveFile = atoi((argv[4]));
 	sprintf(epid_str, "%d", epid);
-	setCurEntityIdx(epid);
+	setCurEntityIdx(atoi(argv[5]));
 
 	if (!mod_name || !strlen(mod_name)) {
 		return -300;

+ 2 - 1
Framework/spshell/spshell.cpp

@@ -59,6 +59,7 @@ using namespace std;
 #include <QMessageBox>
 //#pragma execution_character_set("utf-8")
 #endif
+#include <spbase/sp_runTask.h>
 
 #ifndef RVC_OS_WIN
 static int GetParentProcessID()
@@ -1120,7 +1121,7 @@ int main(int argc, char** argv)
 	} while (false);
 	}
 #endif //_MSC_VER
-
+	sp_runtask_loadLogLevel();
     create_log_producer_default("SpShell", 0);
     DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("===================SpShell start=====================");
     DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("process id: %d, saveFile:%d", GetCurrentProcessId(), saveFile);

+ 0 - 3
Framework/spshell/svc.cpp

@@ -498,9 +498,6 @@ void on_machine_reboot(sp_rpc_server_t *server, int epid, int svc_id, int call_t
 		if (eRebootTrigger == RebootTrigger_DeadForever) {
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("shutdown framework now");
 			result = KickoffSpRestart(false);
-		} else if (eRebootTrigger == RebootTrigger_Unknown) {
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("quit  framework now, let quit flag do it, maybe would booted by guardian in ten minutes");
-			result = 0;
 		} else {
             DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("reboot framework now");
             result = KickoffSpRestart(true);

+ 2 - 1
Module/include/DevFSMCommBase.hpp

@@ -618,7 +618,8 @@ struct AdapterInfo : public AdaptorInfo
 						else if (strnicmp((LPCTSTR)arr2[0], "FUNCTION", strlen("FUNCTION")) == 0)
 						{
 							string strData = arr2[1].GetData();
-							regex pattern("^(I|T|F|IT|TI|IF|FI|TF|FT|ITF|IFT|FIT|FTI|FIT|FTI)$");//stupid,how to write the right... composite of 'I'/'T'/'F'
+							//regex pattern("^(I|T|F|Y|IT|TI|IF|FI|TF|FT|IY|TY|FY|ITF|IFT|FIT|FTI|FIT|FTI)$");//stupid,how to write the right... composite of 'I'/'T'/'F'/'Y'
+							regex pattern("^[ITFY]{1,4}$");
 							smatch sm;
 							if (!regex_match(strData, sm, pattern))
 								DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CheckDevInfoFormat, Wrong format of %s:%s", arr2[0].GetData(), arr2[1].GetData());

+ 1 - 0
Module/include/EventCode.h

@@ -576,6 +576,7 @@ ERROR_ACCESSAUTH_CONNECT_ACS_x}
 #define LOG_WARN_CHROMIUM_INSTALL_URLS_CHECK	0x40200021
 #define LOG_WARN_CHROMIUM_INSTALL_NOTSURPORT	0x40200022
 #define LOG_WARN_CHROMIUM_VTMUSERMSG_ERR		0x40200023
+#define LOG_EVT_CHROMIUM_OPEN_INSTALLPAGE		0x40200024
 
 #define EVENT_RESTART_SHELL      0x50300001  // 重启Shell
 #define EVENT_RESTART_MACHINE     0x50300002  // 重启终端

+ 2 - 2
Module/mod_chromium/CModTools.cpp

@@ -688,7 +688,7 @@ namespace Chromium {
 		if (AdUrlRet.first)
 		{
 			auto strAdCmd = generateAdCmd(AdUrlRet.second);
-			auto openAdRet = openCef(strAdCmd);
+			auto openAdRet = openCef(strAdCmd, (m_UseUOSBrowser == 0));
 			if (Error_Succeed != openAdRet.first)
 				return std::make_pair(false, "open Ad err!");
 			else
@@ -877,7 +877,7 @@ namespace Chromium {
 			{
 				return;
 			}
-			boost::this_thread::sleep_for(boost::chrono::seconds(1));
+			boost::this_thread::sleep_for(boost::chrono::seconds(3));
 		}
 		return;
 	}

+ 4 - 1
Module/mod_chromium/mod_chromium.cpp

@@ -598,6 +598,7 @@ namespace Chromium {
 #endif 
 			boost::this_thread::sleep_for(boost::chrono::seconds(2));
 			openInstallPage();
+			LogEvent(Severity_High, LOG_EVT_CHROMIUM_OPEN_INSTALLPAGE, CSimpleStringA::Format("open install page"));
 		}
 			
 	}
@@ -807,9 +808,9 @@ namespace Chromium {
 		case Event_VtmLoader_GetConfig_Suc:
 			g_hasInitCfg = true;
 		case Event_VtmLoader_GetConfig_Fail:
+			refreshLogLevel();//后置后需要刷新log level,因为chromium是先启动的实体
 			if (m_installMode)//Do not init Entity again in install mode
 				break;
-			refreshLogLevel();//后置后需要刷新log level,因为chromium是先启动的实体
 			startWithCfg();
 			break;
 		case Event_VtmLoader_GetVTMERRMSG_Suc:
@@ -876,12 +877,14 @@ namespace Chromium {
 		CacheCleanThread.timed_join(boost::posix_time::microseconds(10000));
 
 		CModTools::get_mutable_instance().unlockGuard();
+		/*
 		if (m_runAd)
 		{
 			CModTools::get_mutable_instance().m_isAdOpen = false;
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnBrowserCacheClean open add page");
 			openAdPage();
 		}
+		*/
 			
 #else
 		//uos 由于无guard,需要重启整个chromium实体

+ 1 - 0
Module/mod_guiconsole/mod_GuiConsole.h

@@ -85,6 +85,7 @@ protected:
 	CUUID m_SubLogID3;
 	CUUID m_SubLogID4;
 	CUUID m_uuidVTMLoader;
+	CUUID m_uuidChromium;
 
 	// 当前维护用户信息
 	CSimpleStringA m_strUserID;

+ 10 - 0
Module/mod_guiconsole/mod_guiconsole.cpp

@@ -170,6 +170,9 @@ void CGUIConsoleEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPoi
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("subscribe VtmLoader %s",
 		(Error_Succeed == GetFunction()->SubscribeLog(m_uuidVTMLoader, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "VtmLoader")) ? "success" : "failed");
 
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("subscribe Chromium %s",
+		(Error_Succeed == GetFunction()->SubscribeLog(m_uuidChromium, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "Chromium")) ? "success" : "failed");
+
 	pTransactionContext->SendAnswer(Error_Succeed);
 }
 
@@ -194,6 +197,13 @@ void CGUIConsoleEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nLogI
 		m_FSM.m_pGuiTask->InitBack(this);
 	}
 
+	if (LOG_EVT_CHROMIUM_OPEN_INSTALLPAGE == dwUserCode)
+	{
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("recv LOG_EVT_CHROMIUM_OPEN_INSTALLPAGE");
+		m_FSM.m_pGuiTask->HideGuiConsole();
+		m_FSM.m_pGuiTask->Close();
+	}
+
 	if (dwUserCode == EVENT_MACHINE_COVER_OPEN)		// 机盖打开
 	{
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("the machine cover open!!");

+ 4 - 12
Module/mod_healthmanager/HealthManagerFSM.cpp

@@ -28,15 +28,7 @@ using namespace std;
 const int MAX_AYSNC_TIMEOUT = 60000;
 const int MAX_IGNORE_TIMEOUT = 100;
 
-unsigned long long GetTickCountRVC() {
-#if defined(RVC_OS_WIN)
-	return GetTickCount64();
-#else
-	struct timespec ts;
-	clock_gettime(CLOCK_MONOTONIC, &ts);
-	return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
-#endif //RVC_OS_WIN
-}
+
 unsigned long long GetLastErrorRVC() {
 #if defined(RVC_OS_WIN)
 	return GetLastError();
@@ -108,7 +100,7 @@ ErrorCodeEnum CHealthManagerFSM::Initial()
 }
 ErrorCodeEnum CHealthManagerFSM::OnInit(void)
 {
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Complied at: %s %s", __DATE__, __TIME__);
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Complied at: %s %s", __DATE__, __TIME__);
 	return Initial();
 }
 ErrorCodeEnum CHealthManagerFSM::OnExit(void)
@@ -893,7 +885,7 @@ void CHealthManagerFSM::ToLogWarnTermAboutInfo()
 			if (strEntityIdx[i] == 0)
 			{
 				shellStartTime = Infos[i].startTime;
-				ULONGLONG dwElapseNow = GetTickCount64();
+				ULONGLONG dwElapseNow = SP::Module::Comm::RVCGetTickCount();
 				totalCost = dwElapseNow - m_ullElapseFromOSStart;
 				LogWarn(Severity_Low, Error_Debug, LOG_TRACE_ENTITY_START_TIME,
 					SP::Module::Util::generateConsumeTimeJson("total", SP::Module::Util::formatTime(shellStartTime).c_str(), totalCost).GetData());
@@ -983,7 +975,7 @@ void CHealthManagerFSM::ToLogWarnTermAboutInfo()
 	char xOSTime[64] = {0};
 
 	char elapseTime[64] = {0};//使用机器启动时间秒数
-	ULONGLONG dwElapse = GetTickCountRVC();
+	ULONGLONG dwElapse = SP::Module::Comm::RVCGetTickCount();
 	DWORD elapseTimeTemp = dwElapse / 1000;
 #if defined(RVC_OS_WIN)
 	termInfo["OSTime"] = itoa(m_elapseTimeFromOSStart, xOSTime, 10);

+ 45 - 205
Module/mod_healthmanager/mod_healthmanager.cpp

@@ -62,7 +62,7 @@ const DWORD HEALTHMANAGER_WAIT_MAINPAGE_OPEN_TIMER_ID = 2;
 const DWORD HEALTHMANAGER_SELFCHECK_TIMER_ID = 3;
 const DWORD HEALTHMANAGER_TIMER_INTERVAL = 60000;
 const DWORD HEALTHMANAGER_WAIT_MAINPAGE_OPEN_TIMER_INTERVAL = 60000;
-const DWORD HEALTHMANAGER_TIMER_INTERVAL_MINUTE = (HEALTHMANAGER_TIMER_INTERVAL/60000)*3;
+const DWORD HEALTHMANAGER_REBOOT_OS_IN_MINUTES_AFTER_TIME = 5;
 const DWORD HEALTHMANAGER_SELFCHECK_TIMER_INTERVAL = 60000;
 const int MAX_STOP_AYSNC_TIMEOUT = 20000;
 const int MAX_TERM_AYSNC_TIMEOUT = 30000;
@@ -200,140 +200,6 @@ N:
 U:
 */
 
-
-int CHealthManagerEntity::SystemRestart(bool bPeriod, bool bNow)
-{
-	if (bPeriod)
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("restart periodly.");
-	if (bNow)
-	{
-		m_fsm.QuitFrameworkAndSaveInfo(m_eRebootTrigger, m_eRebootWay);
-		int x = SystemShutdown(TRUE);
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("From browser to shutdown %d", x);
-		return 0;
-	}
-
-	m_fsm.QuitFrameworkAndSaveInfo(m_eRebootTrigger, RebootWay_OS);
-	return 0;
-}
-/** 这里建议改用调用框架提供的接口,关机、重启均支持 [Gifur@202135]*/
-//system api shutdown
-int CHealthManagerEntity::SystemShutdown(BOOL bReboot)
-{
-#ifdef RVC_OS_WIN
-	HANDLE hToken;              // handle to process token 
-	TOKEN_PRIVILEGES tkp;       // pointer to token structure 
-
-	BOOL fResult;               // system shutdown flag 
-
-	// Get the current process token handle so we can get shutdown 
-	// privilege. 
-
-	if (!OpenProcessToken(GetCurrentProcess(), 
-		TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) 
-		return FALSE; 
-
-	// Get the LUID for shutdown privilege. 
-
-	LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, 
-		&tkp.Privileges[0].Luid); 
-
-	tkp.PrivilegeCount = 1;  // one privilege to set    
-	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 
-
-	// Get shutdown privilege for this process. 
-
-	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, 
-		(PTOKEN_PRIVILEGES) NULL, 0); 
-
-	// Cannot test the return value of AdjustTokenPrivileges. 
-
-	if (GetLastError() != ERROR_SUCCESS) 
-		return FALSE; 
-
-	// Display the shutdown dialog box and start the countdown. 
-
-	fResult = InitiateSystemShutdown( 
-		NULL,    // shut down local computer 
-		NULL,   // message for user
-		0,      // time-out period, in seconds 
-		FALSE,   // ask user to close apps 
-		bReboot);   // reboot after shutdown 
-
-	if (!fResult) 
-		return FALSE; 
-
-	// Disable shutdown privilege. 
-
-	tkp.Privileges[0].Attributes = 0; 
-	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, 
-		(PTOKEN_PRIVILEGES) NULL, 0); 
-	return 0;
-#else
-	sync();
-	if (bReboot)
-		system("init 6");
-	else
-		system("init 0");
-	return 0;//oiltestlinux
-#endif //RVC_OS_WIN
-}
-
-int CHealthManagerEntity::FrameworkShutdown(bool bRestart)
-{
-#if defined(RVC_OS_WIN)
-	//oilyang@20211213 if reboot Framework,just call "pFuncPrivilege->Reboot";if shutdown only,call sprestart
-	if (bRestart)
-	{
-		m_fsm.QuitFrameworkAndSaveInfo(m_eRebootTrigger, m_eRebootWay);
-		return 0;
-	}
-    STARTUPINFO si;
-    PROCESS_INFORMATION pi;
-
-    ZeroMemory( &si, sizeof(si) );
-    si.cb = sizeof(si);
-    ZeroMemory( &pi, sizeof(pi) );
-	GetFunction()->FlushLogFile();
-
-	//	LPTSTR szCmdline[] = _tcsdup(TEXT("\"C:\\Program Files\\MyApp\" -L -S"));
-	//CreateProcess(NULL, szCmdline, /*...*/);
-
-    // Start the child process.
-	CSimpleStringA csRestart,csVerPath,csAll,csSep("\""),csBlank(" "),csScript("wscript.exe"),csReFlag("r");
-	csRestart = "sprestart.exe ";
-	ErrorCodeEnum Error = GetFunction()->GetPath("RootVer", csVerPath);
-	//csVerPath +="\\spexplorerfast.vbs";
-	csVerPath +="\\VTM.exe";
-	if (!bRestart)
-		csReFlag = "n";
-	//csAll = csSep + csRestart + csSep + csBlank + csSep + csScript+csBlank + csVerPath + csSep 
-	//	+ csBlank + csSep + csReFlag + csSep;
-	csAll = csSep + csRestart + csSep + csBlank + csSep + csVerPath + csSep 
-		+ csBlank + csSep + csReFlag + csSep;
-	DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("allpath[%s]",(LPCTSTR)csAll);
-	LPTSTR szCmdline = _strdup(csAll);
-    if( !CreateProcess( NULL,szCmdline,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi)) 
-    {
-		DbgWithLink(LOG_LEVEL_ERROR,LOG_TYPE_SYSTEM)("CreateProcess failed (%d).\n", GetLastError());
-        return -1;
-    }
-	//MessageBoxA(0,0,0,0);
-	DWORD dwErr = GetLastError();
-	// Wait until child process exits.
-    WaitForSingleObject( pi.hProcess, INFINITE );
-	
-	
-    // Close process and thread handles. 
-    CloseHandle( pi.hProcess );
-    CloseHandle( pi.hThread );
-	return 0;
-#else
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("FrameworkShutdown to call QuitFrameworkAndSaveInfo:%d,%d", m_eRebootTrigger, m_eRebootWay);
-	m_fsm.QuitFrameworkAndSaveInfo(m_eRebootTrigger, m_eRebootWay);
-	return 0;//oiltestlinux
-#endif
-}
 //almost disused.
 
 ErrorCodeEnum CHealthManagerEntity::RestartModule(const char* pEntityName)
@@ -350,7 +216,7 @@ ErrorCodeEnum CHealthManagerEntity::RestartModule(const char* pEntityName)
 	if (it == m_modRunInfo.end())
 	{
 		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("add %s to modfuninfo(%d).",pEntityName,m_modRunInfo.size());
-		m_modRunInfo[pEntityName].dwStart = GetTickCountRVC();
+		m_modRunInfo[pEntityName].dwStart = SP::Module::Comm::RVCGetTickCount();
 	}
 	else
 	{
@@ -402,9 +268,7 @@ void CHealthManagerEntity::AfterWaitRestartPC()
 		m_bWaitRestartPC = false;
 		pFuncPrivilege->DisplayBlueScreen("PAUSE SERVICE");
 		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("time comes,restart machine");
-		m_eRebootTrigger = RebootTrigger_RunExcepition;
-		m_eRebootWay = RebootWay_Power;
-		SystemRestart(false);
+		m_fsm.QuitFrameworkAndSaveInfo(RebootTrigger_RunExcepition, RebootWay_OS);
 	}
 }
 void CHealthManagerEntity::OnCheckTimeTimeout()
@@ -421,36 +285,36 @@ void CHealthManagerEntity::OnCheckTimeTimeout()
 		if (m_bInMainPage || csTermStage.Compare("A"))
 		{
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("THE key CenterSetting updated,we must restart framework right now.");
-			m_eRebootTrigger = RebootTrigger_Resource;
-			m_eRebootWay = RebootWay_Framework;
-			FrameworkShutdown();
+			m_fsm.QuitFrameworkAndSaveInfo(RebootTrigger_Resource, RebootWay_Framework);
 		}
 	}
 	SYSTEMTIME localTime;
 	GetLocalTimeRVC(localTime);
+	//for example:[1----6]
+	//               ^ here we go
+	//in reboot period
+	if (localTime.wHour >= m_rebootHourBegin && localTime.wHour <= m_rebootHourEnd)
+	{
+		//reach setting reboot time
+		if (localTime.wHour == m_restartHour && (localTime.wMinute >= m_restartMinute && localTime.wMinute <= m_restartMinute + HEALTHMANAGER_REBOOT_OS_IN_MINUTES_AFTER_TIME))
+		{
+			m_OSRunTicks = SP::Module::Comm::RVCGetTickCount();
+			//the os haven't reboot today
+			if (m_OSRunTicks > m_restartHour * 60 * 60 * 1000 + m_restartMinute * 60 * 1000)
+			{
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to restart machine daily");
+				m_fsm.QuitFrameworkAndSaveInfo(RebootTrigger_Period, RebootWay_OS);
+			}
+		}
+	}
+
 	ErrorCodeEnum eErr = Error_Unexpect;
 
-	//99 is initial value of m_preDay
-	m_preDay = localTime.wDayOfWeek;
 	CSmartPointer<IConfigInfo> spConfigRun;
 	eErr = GetFunction()->OpenConfig(Config_Run, spConfigRun);
 	if (eErr != Error_Succeed)
 		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("timer open cfg file failed!");
 
-
-	if (m_wDayOfWeek != localTime.wDayOfWeek)
-	{
-		if (localTime.wHour == m_restartHour && localTime.wMinute >= m_restartMinute
-			&& localTime.wMinute <= (m_restartMinute + HEALTHMANAGER_TIMER_INTERVAL_MINUTE))
-		{
-			m_wDayOfWeek = localTime.wDayOfWeek;
-			m_eRebootTrigger = RebootTrigger_Period;
-			m_eRebootWay = RebootWay_Power;
-			BOOL bRet = SystemRestart(true);
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("OnCheckTimeTimeout")("restart machine[%d][%d] bRet=%d, LastError=%d", localTime.wHour, localTime.wMinute, bRet, GetLastError());
-		}
-	}
-
 	if (!m_bSayIdle)
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_fsm.GetFSMState():%d", m_fsm.GetFSMState());
 	int iCheckGuardian = 0;
@@ -854,27 +718,26 @@ bool CHealthManagerEntity::DoRestart()
 	}
 
 	m_restartHour = m_restartMinute = 1;
-	int tmpHourBegin, tmpHourEnd;
 	//the region (RestartHourBegin,RestartHourEnd) that we should reboot VTM 
-	tmpHourBegin = 1;
-	tmpHourEnd = 6;
+	m_rebootHourBegin = 1;
+	m_rebootHourEnd = 6;
 	do 
 	{
 		int value(0);
 		spCerConfig->ReadConfigValueInt(GetEntityName(), "RestartHourBegin", value);
-		if (value > 0) {
-			tmpHourBegin = value;
+		if (value > 0 && value < 8) {
+			m_rebootHourBegin = value;
 		}
 	} while (false);
 	do {
 		int value(0);
 		spCerConfig->ReadConfigValueInt(GetEntityName(), "RestartHourEnd", value);
-		if (value > 0) {
-			tmpHourEnd = value;
+		if (value > 0 && value < 8) {
+			m_rebootHourEnd = value;
 		}
 	} while (false);
 	//to calculate the restartHour & restartMinute of the Terminal
-	ToCalcRebootHourAndMinute(tmpHourBegin, tmpHourEnd);
+	ToCalcRebootHourAndMinute(m_rebootHourBegin, m_rebootHourEnd);
 
 	do {
 		m_maxAbnormalTimes = 30;
@@ -930,17 +793,11 @@ bool CHealthManagerEntity::DoRestart()
 			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("set NeedGuardian N failed (%s).", SpStrError(eErr));
 		}
 
-	}else{
-		LogWarn(Severity_Low, Error_Unexpect, HealthManager_UserErrorCode_Need_Guardian, "terminal is need start up guardian");
 	}
 	DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("[NonExclusive],NonGuardian=%s", csimpleStrMachineTypeCfg.GetData());
 	SYSTEMTIME localTime;
 	GetLocalTimeRVC(localTime);
-	if (m_bInit)
-	{
-		m_bInit = false;
-		m_wDayOfWeek = localTime.wDayOfWeek;
-	}
+
 
 	ITimerListener *pListener = new TimerOutHelper<CHealthManagerEntity>(this, &CHealthManagerEntity::OnCheckTimeTimeout);
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set check timer %d(ms)", HEALTHMANAGER_TIMER_INTERVAL);
@@ -1266,7 +1123,8 @@ void CHealthManagerEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nL
 		{
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("version rollback succeed.to restart framework");
 			m_bVerRollback = false;
-			m_eRebootTrigger = RebootTrigger_RollBack;
+			m_fsm.QuitFrameworkAndSaveInfo(RebootTrigger_RollBack, RebootWay_Framework);
+			break;
 		}
 		else if (dwUserCode == Event_Req_Framework_No_Upgrade_Restart)
 		{
@@ -1275,16 +1133,7 @@ void CHealthManagerEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nL
 			GetFunction()->PostThreadPoolTask(task);
 			break;
 		}
-		m_eRebootWay = RebootWay_Framework;
-		BOOL bRet = FrameworkShutdown();
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("framework shutdown [%d]", bRet);
-	}
-	break;
-	case EVENT_CONSOLE_REQ_SHUTDOWN_SHELL:
-	{
-		LogWarn(Severity_Low, Error_Unexpect, HealthManager_UserErrorCode_PrivilegeCMD, CSimpleStringA::Format("%x", dwUserCode));
-		BOOL bRet = FrameworkShutdown(false);
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("framework shutdown from console [%d]", bRet);
+		m_fsm.QuitFrameworkAndSaveInfo(RebootTrigger_Unknown, RebootWay_Framework);
 	}
 	break;
 	case EVENT_RESTART_MACHINE:
@@ -1292,34 +1141,29 @@ void CHealthManagerEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nL
 	case EVENT_CONSOLE_REQ_RESTART_POWER:
 	{
 		LogWarn(Severity_Low, Error_Unexpect, HealthManager_UserErrorCode_PrivilegeCMD, CSimpleStringA::Format("%x", dwUserCode));
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("restart [%x]", dwUserCode);
 		if (dwUserCode == Event_Req_OS_Restart)
-			m_eRebootTrigger = RebootTrigger_OSUpgrade;
+			m_fsm.QuitFrameworkAndSaveInfo(RebootTrigger_OSUpgrade, RebootWay_OS);
 		else
-			m_eRebootTrigger = RebootTrigger_Unknown;
-		m_eRebootWay = RebootWay_Power;
-		BOOL bRet = SystemRestart(false);
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("os restart [%d]", bRet);
+			m_fsm.QuitFrameworkAndSaveInfo(RebootTrigger_Unknown, RebootWay_OS);	
 	}
 	break;
 	case LOG_EVT_IEBROWSER_RESTART_MACHINE:
 	{
-		m_eRebootTrigger = RebootTrigger_Unknown;
-		m_eRebootWay = RebootWay_Power;
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("machine restart now [%x]", dwUserCode);
 		LogWarn(Severity_Low, Error_Unexpect, LOG_EVT_IEBROWSER_RESTART_MACHINE, "ClosePage/UserDeskTop to call restart machine.");
-		BOOL bRet = SystemRestart(false, true);
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("machine restart now [%d]", bRet);
+		m_fsm.QuitFrameworkAndSaveInfo(RebootTrigger_Unknown, RebootWay_OS);
 		break;
 	}
 	case LOG_EVT_IEBROWSER_SHUTDOWN_MACHINE:
 	{
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("ClosePage/UserDeskTop to call shutdown machine. [%x]", dwUserCode);
 		LogWarn(Severity_Low, Error_Unexpect, LOG_EVT_IEBROWSER_SHUTDOWN_MACHINE, "ClosePage/UserDeskTop to call shutdown machine.");
-		SystemShutdown();
+		m_fsm.QuitFrameworkAndSaveInfo(RebootTrigger_DeadForever, RebootWay_OS);
 		break;
 	}
 	case EVENT_MOD_SIP_RESART:
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SIPPhone said to wait chance to restart(power) pc.");
-		m_eRebootTrigger = RebootTrigger_RunExcepition;
-		m_eRebootWay = RebootWay_Power;
 		m_bWaitRestartPC = true;
 		break;
 	case EVENT_ACCESSAUTH_SUCCEED:
@@ -1328,7 +1172,7 @@ void CHealthManagerEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nL
 		m_fsm.SetAccessAuth(AccessAuth_Suc);
 		m_bNeedAuthRetry = false;
 		m_bNeedGuardianRestart = true;
-		m_dwTimeOfAuthSuc = GetTickCount64() / 1000;
+		m_dwTimeOfAuthSuc = SP::Module::Comm::RVCGetTickCount() / 1000;
 		GetFunction()->SetTimer(HEALTHMANAGER_WAIT_MAINPAGE_OPEN_TIMER_ID, this, m_maxWaitMainpageTime);
 
 		CSimpleStringA msg(true);
@@ -1443,7 +1287,7 @@ void CHealthManagerEntity::OnSysVarEvent(const char *pszKey, const char *pszValu
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402501Z10401")(m_sysStaticInfo.InstallVersion.ToString().GetData());
 				m_bHaveThrowMainPage = true;
 				
-				ULONGLONG dwElapse = GetTickCount64();//使用机器启动时间秒数
+				ULONGLONG dwElapse = SP::Module::Comm::RVCGetTickCount();//使用机器启动时间秒数
 				DWORD elapseTimeTemp = dwElapse / 1000;
 				DWORD dwToMainPageCostTime = elapseTimeTemp - m_dwTimeOfAuthSuc;//从准入通过到首次收到进入首页事件
 				CSimpleStringA xMsg = CSimpleStringA::Format("{\"Decripstion\":\"the first enter main page from HealthManger started.\",\"version\":\"%s\",\"elapseTime\":\"%d\",\"enterMainPageTime\":\"%d\"}"
@@ -1466,7 +1310,7 @@ void CHealthManagerEntity::OnSysVarEvent(const char *pszKey, const char *pszValu
 				m_bBrowserIdleFirst = false;
 				m_bEnterMainPageEver = true;
 				LogEvent(Severity_Middle, LOG_EVT_HEALTH_FIRST_ENTER_MAINPADE, "enter main page");
-				ULONGLONG dwElapse = GetTickCount64();//使用机器启动时间秒数
+				ULONGLONG dwElapse = SP::Module::Comm::RVCGetTickCount();//使用机器启动时间秒数
 				DWORD elapseTimeTemp = dwElapse / 1000;
 				CSimpleStringA xMsg = CSimpleStringA::Format("{\"Decripstion\":\"the first enter main page from browser started.\",\"version\":\"%s\",\"elapseTime\":\"%d\"}"
 					, m_sysStaticInfo.InstallVersion.ToString().GetData(), elapseTimeTemp);
@@ -1573,12 +1417,8 @@ void CHealthManagerEntity::WarnAndRestartFramwork()
 		//Dbg("to tell guardian framework is restarting.%d",eErr);
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to tell guardian framework is restarting.%d", eErr);
 	}
-	m_eRebootTrigger = RebootTrigger_FrameUpgrade;
-
-	m_eRebootWay = RebootWay_Framework;
-	BOOL bRet = FrameworkShutdown();
-	//Dbg("framework shutdown [%d]", bRet);
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("framework shutdown in restart task [%d]", bRet);
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("framework shutdown in restart task");
+	m_fsm.QuitFrameworkAndSaveInfo(RebootTrigger_FrameUpgrade, RebootWay_Framework);	
 }
 
 void CHealthManagerEntity::ControlEntityLife(SpReqAnsContext<HealthManagerService_ControlEntityLife_Req, HealthManagerService_ControlEntityLife_Ans>::Pointer ctx)

+ 10 - 13
Module/mod_healthmanager/mod_healthmanager.h

@@ -85,13 +85,13 @@ class CHealthManagerEntity : public CEntityBase, public ILogListener, public IEn
 	,public ITimerListener, public ICallbackListener
 {
 public:
-	CHealthManagerEntity() :m_bInit(true)
-		, m_bWaitRestartPC(false)
+	CHealthManagerEntity() :
+		m_bWaitRestartPC(false)
 		, m_bScreenLock(false)
 		, m_bSayIdle(false), m_bGuardianRun(false), m_guardianCount(1), m_pUpgMgr(NULL)
-		, m_bVerRollback(false), m_eRebootTrigger(RebootTrigger_Resource), m_eRebootWay(RebootWay_Unknown)
+		, m_bVerRollback(false)
 		, m_menuChoice(""), m_menuPre(""), m_netState("N"), m_bBrowserIdleFirst(true)
-		, m_preDay(99), m_bInMainPage(false), m_stopSelfCheck(0)
+		, m_bInMainPage(false), m_stopSelfCheck(0)
 		, m_bEnterMainPageEver(false),m_bHaveThrowMainPage(false)
 		,m_bNeedAuthRetry(false), m_bNeedGuardianRestart(true), m_bNeedGuardian(true)
 		, m_bToRestartByCenterSetting(false){}
@@ -183,7 +183,7 @@ public:
 	{
 		if (ctx->Req.code == Event_VtmLoader_EntityLoad_Finished || ctx->Req.code == Event_VtmLoader_EntityLoad_Failed)
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("receive %x,entityList:%s", ctx->Req.code,ctx->Req.entityList.GetData());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("receive %x,entityList:%s", ctx->Req.code,ctx->Req.entityList.GetData());
 			if (!ctx->Req.entityList.IsNullOrEmpty())
 				m_fsm.SetLoadEntityList(ctx->Req.entityList);
 			FSMEvent* pEvt = new FSMEvent(USER_EVT_VTMLOADER_FINISHED);
@@ -226,9 +226,6 @@ public:
 	virtual bool IsService()const{return true;}
 	virtual bool IsMultiThread()const{return true;}
 
-	int SystemRestart(bool bPeriod, bool bNow = false);
-	int SystemShutdown(BOOL bReboot=FALSE);
-	int FrameworkShutdown(bool bRestart=true);
 	void QueryHardwareInfo(SpReqAnsContext<HealthManagerService_QueryHardwareInfo_Req, HealthManagerService_QueryHardwareInfo_Ans>::Pointer ctx)
 	{
 		QueryHardwareInfoTask* pTask = new QueryHardwareInfoTask(&m_fsm);
@@ -267,15 +264,15 @@ private:
 		, m_uuidRemoteController, m_uuidGUIConsole, m_uuidHeartBeat, m_uuidIE, m_uuidCenterS, m_uuidVtmLoader;
 	CUUID m_uuidPublic, m_uuid4SIPPhone;
 	int m_stopSelfCheck;
-	int m_restartHour, m_restartMinute, m_lastHour, m_preDay,m_guardianCount, m_maxAbnormalTimes;
-	bool m_bInit, m_bWaitRestartPC, m_bScreenLock, m_bSayIdle
+	int m_restartHour, m_restartMinute, m_lastHour, m_guardianCount, m_maxAbnormalTimes, m_rebootHourBegin, m_rebootHourEnd;;
+	bool m_bWaitRestartPC, m_bScreenLock, m_bSayIdle
 		, m_bGuardianRun, m_bVerRollback, m_bBrowserIdleFirst
 		, m_bInMainPage, m_bEnterMainPageEver, m_bHaveThrowMainPage, m_bToRestartByCenterSetting;
 	bool m_bNeedAuthRetry/*需要重试准入*/, m_bNeedGuardianRestart/*需要重启*/, m_bNeedGuardian;
-	DWORD m_wDayOfWeek,m_dwTimeOfAuthSuc;
+	DWORD m_dwTimeOfAuthSuc;
 	int m_maxWaitMainpageTime;
-	RebootTriggerEnum m_eRebootTrigger;
-	RebootWayEnum m_eRebootWay;
+	ULONGLONG m_OSRunTicks;
+
 	CSimpleStringA m_menuChoice,m_currentVer,m_menuPre,m_netState, m_versionEx;
 	map<CSimpleStringA,ModuleRunInfo> m_modRunInfo;
 	UpgradeMgrService_ClientBase *m_pUpgMgr;

+ 2 - 0
Module/mod_pinpad/PinPadFSM.cpp

@@ -472,6 +472,8 @@ int CPinPadFSM::Initial()
 		if (infile.is_open())
 			infile.read(buffer, 16);
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("bak.sn:%s", buffer);
+		if (strlen(buffer) > 0 && m_keySNSM.Compare(buffer) != 0)
+			LogWarn(Severity_High, Error_Unexpect, PinPad_UserErrorCode_PinPad_SN_NOTMATCH, CSimpleStringA::Format("m_keySN:%s,snbak:%s", m_keySNSM.GetData(), buffer));
 		delete[] buffer;
 		infile.close();
 	}

+ 1 - 1
Module/mod_pinpad/PinPad_UserErrorCode.h

@@ -32,7 +32,7 @@ enum PinPad_UserErrorCode {
 	PinPad_UserErrorCode_PinPad_GetEncryptText_Get12Account_Error = 0x2060021B,
 	PinPad_UserErrorCode_PinPad_DevOpenFailed = 0x2060021C,
 	PinPad_UserErrorCode_PinPad_CkCode_While_Load_SM = 0x2060021D,
-		
+	PinPad_UserErrorCode_PinPad_SN_NOTMATCH = 0x2060021E,
 	PinPad_UserErrorCode_PinPad_Real_Root_Config = 0x2060021F,
 	PinPad_UserErrorCode_PinPad_GetPinBlock_Call = 0x20600220,
 	PinPad_UserErrorCode_Unexpected_Exit = 0x20600221,

+ 3 - 2
Other/liblog4rvcother/log4cplus_helper.cpp

@@ -524,8 +524,9 @@ namespace cmb {
 			if (_log_level <= converted_ll) {
                 log_link link_item((VENDORLOG_LEVEL_E)(int)(level), VENDORLOG_TYPE_SYSTEM);
                 log_item logitem;
-                link_item.result_msg(text).with_extend_log_or_not(false).fetch_log_item(logitem);
-                _upload_helper.pinst_log_producer_client_add_log(_upload_helper._client, &logitem, 1);
+				long cur_time = time(NULL);
+				link_item.result_msg(text).with_extend_log_or_not(false).fetch_log_item(logitem);
+				_upload_helper.pinst_log_producer_client_add_log(_upload_helper._client, &logitem, 1, cur_time);
 			}
         }
     }

+ 2 - 2
Other/liblog4rvcother/log4upload.h

@@ -112,7 +112,7 @@ typedef void(*pfn_log_producer_config_set_united_deployUnitId)(log_producer_conf
 typedef void(*pfn_log_producer_config_set_united_serviceUnitId)(log_producer_config*, char*);
 
 typedef log_producer_client*(*pfn_create_log_producer_client)(log_producer_config*, pfn_on_log_producer_send_done, void*);
-typedef log_producer_result(*pfn_log_producer_client_add_log)(log_producer_client*, log_item*, int);
+typedef log_producer_result(*pfn_log_producer_client_add_log)(log_producer_client*, log_item*, int, long);
 
 typedef void(*pfn_log_producer_config_switch_debug_mode)(log_producer_config*, int32_t);
 
@@ -142,7 +142,7 @@ using pfn_log_producer_config_set_united_deployUnitId = void(*)(log_producer_con
 using pfn_log_producer_config_set_united_serviceUnitId = void(*)(log_producer_config*, char*);
 
 using pfn_create_log_producer_client = log_producer_client*(*)(log_producer_config*, pfn_on_log_producer_send_done, void*);
-using pfn_log_producer_client_add_log = log_producer_result(*)(log_producer_client*, log_item*, int);
+using pfn_log_producer_client_add_log = log_producer_result(*)(log_producer_client*, log_item*, int, long);
 
 using pfn_log_producer_config_switch_debug_mode = void(*)(log_producer_config*, int32_t);
 

+ 2 - 1
Other/liblog4vendor/log4cplus_helper.cpp

@@ -524,8 +524,9 @@ namespace cmb {
 			if (_log_level <= converted_ll) {
                 log_link link_item((VENDORLOG_LEVEL_E)(int)(level), VENDORLOG_TYPE_SYSTEM);
                 log_item logitem;
+				long cur_time = time(NULL);
                 link_item.result_msg(text).with_extend_log_or_not(false).fetch_log_item(logitem);
-                _upload_helper.pinst_log_producer_client_add_log(_upload_helper._client, &logitem, 1);
+                _upload_helper.pinst_log_producer_client_add_log(_upload_helper._client, &logitem, 1, cur_time);
 			}
         }
     }

+ 2 - 2
Other/liblog4vendor/log4upload.h

@@ -112,7 +112,7 @@ typedef void(*pfn_log_producer_config_set_united_deployUnitId)(log_producer_conf
 typedef void(*pfn_log_producer_config_set_united_serviceUnitId)(log_producer_config*, char*);
 
 typedef log_producer_client*(*pfn_create_log_producer_client)(log_producer_config*, pfn_on_log_producer_send_done, void*);
-typedef log_producer_result(*pfn_log_producer_client_add_log)(log_producer_client*, log_item*, int);
+typedef log_producer_result(*pfn_log_producer_client_add_log)(log_producer_client*, log_item*, int, long);
 
 typedef void(*pfn_log_producer_config_switch_debug_mode)(log_producer_config*, int32_t);
 
@@ -142,7 +142,7 @@ using pfn_log_producer_config_set_united_deployUnitId = void(*)(log_producer_con
 using pfn_log_producer_config_set_united_serviceUnitId = void(*)(log_producer_config*, char*);
 
 using pfn_create_log_producer_client = log_producer_client*(*)(log_producer_config*, pfn_on_log_producer_send_done, void*);
-using pfn_log_producer_client_add_log = log_producer_result(*)(log_producer_client*, log_item*, int);
+using pfn_log_producer_client_add_log = log_producer_result(*)(log_producer_client*, log_item*, int, long);
 
 using pfn_log_producer_config_switch_debug_mode = void(*)(log_producer_config*, int32_t);
 

+ 1 - 1
addin/cmake/DependencyConanFiles.cmake

@@ -69,7 +69,7 @@ if(MSVC)
 			#mod_chromium
 			CEFControl/1.0@LR04.02_ThirdParty/testing
 			#mod_chromium
-			cefclient_mutable/2.0.34@LR04.02_ThirdParty/testing
+			cefclient_mutable/2.0.35@LR04.02_ThirdParty/testing
 			#libaudiorender
 			speex/1.2.1@LR04.02_ThirdParty/testing
 			#libvideoframework

+ 4 - 1
addin/packaging/WIN/Readme.txt

@@ -1 +1,4 @@
-请执行 install.bat 进行应用版本安装和拷贝
+不要在桌面保留任何文件!安装过程中会进行清理
+不要在桌面保留任何文件!安装过程中会进行清理
+不要在桌面保留任何文件!安装过程中会进行清理
+请直接双击执行 install.bat 进行应用版本安装和拷贝