Selaa lähdekoodia

#IQRV #comment Gpio处理WritePort3的问题

80374374 10 kuukautta sitten
vanhempi
sitoutus
fce48abbe4

+ 77 - 67
Module/mod_ResourceWatcher/ResourceWatcherFSM.cpp

@@ -427,20 +427,7 @@ ErrorCodeEnum ResourceWatcherFSM::OnInit()
     }
 #if defined(RVC_OS_WIN)
     if (m_bFirstRunAfterBoot) {
-		//GetSystemMetrics (SM_CMONITORS) 计数仅显示可见的显示器
-		const int screenNums = GetSystemMetrics(SM_CMONITORS);
-		const int aimScreenNums4Stand2S = 2;
-		const int aimScreenNums4Other = 1;
-		if (0 == m_RvcSysinfo.strMachineType.Compare("RVC.Stand2S", true) && screenNums != aimScreenNums4Stand2S) {
-			LogWarn(Severity_Low, Error_Unexpect, LOG_RESOURCEWATCHER_LACK_OF_MONITOR
-				, CSimpleStringA::Format("{\"subject\":\"screen_count\",\"machine_type\":\"%s\",\"expect\":%d,\"actual\":%d}"
-                    , m_RvcSysinfo.strMachineType.GetData(), aimScreenNums4Stand2S, screenNums));
-        }
-        else if (0 != m_RvcSysinfo.strMachineType.Compare("RVC.Stand2S", true) && screenNums != aimScreenNums4Other) {
-			LogWarn(Severity_Low, Error_Unexpect, LOG_RESOURCEWATCHER_LACK_OF_MONITOR
-				, CSimpleStringA::Format("{\"subject\":\"screen_count\",\"machine_type\":\"%s\",\"expect\":%d,\"actual\":%d}"
-					, m_RvcSysinfo.strMachineType.GetData(), aimScreenNums4Other, screenNums));
-        }
+
     }
     
 #endif //RVC_OS_WIN
@@ -486,60 +473,11 @@ void ResourceWatcherFSM::AfterInit()
 		GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
     }
 	DetectVersionHasChangedAndWarnCover();
-
 #else
-    if (m_bFirstRunAfterBoot) {
-        //获取系统激活状态
-        CSimpleStringA value(true);
-        CSimpleStringA warnMsg(true);
-        bool res = GetSysActiveStatus(value);
-        if (!value.IsNullOrEmpty()) {
-            auto elems = value.Split('|');
-            std::map<std::string, std::string> info;
-            info["subject"] = "system_activation";
-            if (elems.GetCount() > 0) {
-                for (int i = 0; i < elems.GetCount(); ++i) {
-                    auto sub_elems = elems[i].Split(':');
-                    if (sub_elems.GetCount() == 2) {
-                        CSimpleStringA val = sub_elems[1].GetData();
-                        CSimpleStringA key(true);
-                        //因为UOS内容用了中文的冒号,而Split函数无法拆分中文冒号(拆出来前面的内容有乱码),只能这样去操作
-                        if (sub_elems[0].IndexOf("服务器") != -1) {
-                            key = "server_addr";
-                        } else if (sub_elems[0].IndexOf("激活状") != -1) {
-                            key = "activation_status";
-                        }
-                        else if(sub_elems[0].IndexOf("授权状") != -1) {
-                            key = "authorization_status";
-                        }
-                        else if(sub_elems[0].IndexOf("到期时") != -1) {
-                            key = "deadline_status";
-                        }
-                        else if (sub_elems[0].IndexOf("序列") != -1) {
-                            key = "serial_number";
-                            if (val.GetLength() >= 23) {
-                                //NNAAA-7AAAY-*****-*****-MT6SK
-                                val[12] = val[13] = val[14] = val[15] = val[16] = '*';
-                                val[18] = val[19] = val[20] = val[21] = val[22] = '*';
-                            }
-                        }
-                        else {
-                            key = CSimpleStringA::Format("other%02d", i);
-                        }
-                        info[key.GetData()] = val.GetData();
-                    }
-                }
-            }
-            info["fetch_status"] = "succ";
-            std::pair<bool, std::string> strResult;
-            strResult = generateJsonStr(info);
-            value = strResult.second.c_str();
-        }
-        else {
-            warnMsg = CSimpleStringA::Format("{\"subject\":\"system_activation\", \"fetch_status\":\"failed\"}");
-        }
-        LogWarn(Severity_Low, Error_Debug, LOG_INFO_SYSTEM_ACTIVATION_INFO, value);
-    }
+	if (m_bFirstRunAfterBoot) {
+		AggerateAutoStatTask* task = new AggerateAutoStatTask(this);
+		GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
+	}
 #endif //RVC_OS_WIN
 }
 
@@ -2033,6 +1971,24 @@ int ResourceWatcherFSM::InitialAutoStartupSetType()
     return ret;
 }
 
+void ResourceWatcherFSM::UploadScreenInfo()
+{
+	//GetSystemMetrics (SM_CMONITORS) 计数仅显示可见的显示器
+	const int screenNums = GetSystemMetrics(SM_CMONITORS);
+	const int aimScreenNums4Stand2S = 2;
+	const int aimScreenNums4Other = 1;
+	if (0 == m_RvcSysinfo.strMachineType.Compare("RVC.Stand2S", true) && screenNums != aimScreenNums4Stand2S) {
+		LogWarn(Severity_Low, Error_Unexpect, LOG_RESOURCEWATCHER_LACK_OF_MONITOR
+			, CSimpleStringA::Format("{\"subject\":\"screen_count\",\"machine_type\":\"%s\",\"expect\":%d,\"actual\":%d}"
+				, m_RvcSysinfo.strMachineType.GetData(), aimScreenNums4Stand2S, screenNums));
+	}
+	else if (0 != m_RvcSysinfo.strMachineType.Compare("RVC.Stand2S", true) && screenNums != aimScreenNums4Other) {
+		LogWarn(Severity_Low, Error_Unexpect, LOG_RESOURCEWATCHER_LACK_OF_MONITOR
+			, CSimpleStringA::Format("{\"subject\":\"screen_count\",\"machine_type\":\"%s\",\"expect\":%d,\"actual\":%d}"
+				, m_RvcSysinfo.strMachineType.GetData(), aimScreenNums4Other, screenNums));
+	}
+}
+
 void ResourceWatcherFSM::DeleteDuplicateAutoStartFile(bool toDeleteLastLegity)
 {
 	std::vector<std::string> userlist;
@@ -4794,6 +4750,60 @@ void ResourceWatcherFSM::UploadSysVersionInfo(UINT& ver)
     LogWarn(Severity_Low, Error_Hardware, LOG_RESOURCEWATCHER_SYSTEMINFO, ret.second.c_str());
 }
 
+void ResourceWatcherFSM::UploadSysActivationStatus()
+{
+	//获取系统激活状态
+	CSimpleStringA value(true);
+	CSimpleStringA warnMsg(true);
+	bool res = GetSysActiveStatus(value);
+	if (!value.IsNullOrEmpty()) {
+		auto elems = value.Split('|');
+		std::map<std::string, std::string> info;
+		info["subject"] = "system_activation";
+		if (elems.GetCount() > 0) {
+			for (int i = 0; i < elems.GetCount(); ++i) {
+				auto sub_elems = elems[i].Split(':');
+				if (sub_elems.GetCount() == 2) {
+					CSimpleStringA val = sub_elems[1].GetData();
+					CSimpleStringA key(true);
+					//因为UOS内容用了中文的冒号,而Split函数无法拆分中文冒号(拆出来前面的内容有乱码),只能这样去操作
+					if (sub_elems[0].IndexOf("服务器") != -1) {
+						key = "server_addr";
+					}
+					else if (sub_elems[0].IndexOf("激活状") != -1) {
+						key = "activation_status";
+					}
+					else if (sub_elems[0].IndexOf("授权状") != -1) {
+						key = "authorization_status";
+					}
+					else if (sub_elems[0].IndexOf("到期时") != -1) {
+						key = "deadline_status";
+					}
+					else if (sub_elems[0].IndexOf("序列") != -1) {
+						key = "serial_number";
+						if (val.GetLength() >= 23) {
+							//NNAAA-7AAAY-*****-*****-MT6SK
+							val[12] = val[13] = val[14] = val[15] = val[16] = '*';
+							val[18] = val[19] = val[20] = val[21] = val[22] = '*';
+						}
+					}
+					else {
+						key = CSimpleStringA::Format("other%02d", i);
+					}
+					info[key.GetData()] = val.GetData();
+				}
+			}
+		}
+		info["fetch_status"] = "succ";
+		std::pair<bool, std::string> strResult;
+		strResult = generateJsonStr(info);
+		value = strResult.second.c_str();
+	}
+	else {
+		warnMsg = CSimpleStringA::Format("{\"subject\":\"system_activation\", \"fetch_status\":\"failed\"}");
+	}
+	LogWarn(Severity_Low, Error_Debug, LOG_INFO_SYSTEM_ACTIVATION_INFO, value);
+}
 
 string ResourceWatcherFSM::MemoryProcessStatus()
 {

+ 13 - 1
Module/mod_ResourceWatcher/ResourceWatcherFSM.h

@@ -287,7 +287,7 @@ public:
 	/** 返回操作系统当前的版本,比如1032,1010,1031*/
 	UINT GetSystemDisplayVersion(CSimpleStringA& strVersion);
 	void UploadSysVersionInfo(UINT& ver);
-
+	void UploadSysActivationStatus();
 	string MemoryProcessStatus();
 	long GetCPURunTime(CPUInfo* cpu);
 	long ReadProcCPURunTime(DWORD pid, ProcCPUInfo* pInfo);
@@ -321,6 +321,7 @@ public:
 	bool GetRegValue(HKEY hKey, LPCTSTR lpcszParam, CSimpleStringA& strValue);
 
 	void DetectAutoStartupCover();
+	void UploadScreenInfo();
 	//0:explorer.exe
 	//1:vbs
 	//2:vtm.exe
@@ -396,6 +397,16 @@ struct DetectSoftwareInstallStatusTask : public ITaskSp
     }
 };
 
+struct AggerateAutoStatTask : public ITaskSp
+{
+	ResourceWatcherFSM* m_pFSM;
+	AggerateAutoStatTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
+	void Process()
+	{
+		m_pFSM->UploadSysActivationStatus();
+	}
+};
+
 #else
 struct CreateLinkTask :public ITaskSp
 {
@@ -423,6 +434,7 @@ struct AggerateAutoStatTask : public ITaskSp
 	AggerateAutoStatTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
 	void Process()
 	{
+		m_pFSM->UploadScreenInfo();
 		m_pFSM->DetectWallpaperAndWarn();
 		m_pFSM->DetectAutoStartupCover();
 		m_pFSM->RegOperation4LnkFile();

+ 3 - 4
Module/mod_gpio/mod_gpio.cpp

@@ -687,10 +687,9 @@ void CGpioEntity::WritePin(DWORD dwPinSeq, bool bHighLevel)
     int idx = -1;
     DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Write Pin %s with %s", GetDriverPortString(dwPinSeq + 1), bHighLevel ? "[Active]" : "[InActive]");
     if (dwPinSeq > 16) {/** 目前只有一个高拍仪的提示灯会超过该值  [Gifur@202495]*/
-        if (!m_bNewVersion && dwPinSeq < 24) {
-            DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("not support pin number:%d", dwPinSeq);
-            return;
-        }
+		if (!m_bNewVersion || dwPinSeq < 24) {
+			return;
+		}
         idx = 3;
     } else if (dwPinSeq < 8) {
         idx = 0;