Explorar o código

1、SATEXE命令空间。
2、PyCmd

Jeff %!s(int64=5) %!d(string=hai) anos
pai
achega
bcf35e4f01
Modificáronse 2 ficheiros con 53 adicións e 7 borrados
  1. 42 7
      SATService/SATService/SATExecutor.cpp
  2. 11 0
      SATService/SATService/SATExecutor.h

+ 42 - 7
SATService/SATService/SATExecutor.cpp

@@ -5,6 +5,37 @@
 #include "SynSerial.h"
 #include "IRControl.h"
 
+namespace SATEXE{
+	std::string GetPythonCommandLine(STPyCmd &pycmd)
+	{
+		std::string strPyCmd;
+		cJSON *pRoot = cJSON_CreateObject();
+		if ( pRoot == NULL ) {
+			return strPyCmd;
+		}
+
+		//cJSON_AddNumberToObject(pRoot, "Round", pycmd.nRound);
+		cJSON_AddStringToObject(pRoot, "Round", pycmd.strRound.c_str());
+		//cJSON_AddStringToObject(pRoot, "TaskId", pycmd.strTaskId.c_str());
+		cJSON_AddNumberToObject(pRoot, "TaskId", pycmd.nTaskId);
+
+		char *pText = cJSON_Print(pRoot);
+		if ( pText)
+			strPyCmd = pText;
+
+		// 释放堆内存;
+		if (pText)
+			delete pText;
+		pText = NULL;
+
+		if ( pRoot )
+			cJSON_Delete(pRoot);
+		pRoot = NULL;		
+
+		return GLOBAL::Replace(strPyCmd, "'", "\"");
+	}
+};
+
 CSATExecutor::CSATExecutor(void)
 {
 	m_bLogin = FALSE;
@@ -23,8 +54,8 @@ CSATExecutor::~CSATExecutor(void)
 
 bool CSATExecutor::IsTaskExist(SATHTTP::STTask &task)
 {
-#ifdef _DEBUG
-	if ( task.taskInfo.strTaskType == "FUNCTIONALITY" ) {
+	// 若是冒烟任务;
+	if ( task.taskInfo.strTaskType == "STANDARDAPKCOMPAT" ) {
 		AutoThreadSection ats(&m_csSomkingTask);
 		// 如果任务存在,删除原来的;
 		std::list<SATHTTP::STTask>::iterator it = m_vtSmokingTask.begin();
@@ -44,8 +75,8 @@ bool CSATExecutor::IsTaskExist(SATHTTP::STTask &task)
 		
 		return true;
 	}
-#endif
 
+	// 实时任务;
 	bool found = false;
 	std::list<SATHTTP::STTask>::iterator it = m_vtTask.begin();
 	for ( ; it != m_vtTask.end(); it++ ) {
@@ -243,15 +274,19 @@ SATHTTP::STCase* CSATExecutor::ExecuteFreeCaseScript(SATHTTP::STTask* pTask)
 		DeleteFile(xmlpath.c_str());
 
 		// 命令行:{"Round": %d}
-		TCHAR szCommandLine[MAX_PATH] = { 0 };
-		_stprintf_s(szCommandLine, _T("{'Round': %s}"), pCase->_strRoundNum.c_str());
+		SATEXE::STPyCmd pycmd;
+		pycmd.strRound = pCase->_strRoundNum;
+		pycmd.nTaskId = pTask->taskInfo.nInstanceId;
+		std::string strPyCmd = SATEXE::GetPythonCommandLine(pycmd);
+		//TCHAR szCommandLine[MAX_PATH] = { 0 };
+		//_stprintf_s(szCommandLine, _T("{'Round': %s}"), pCase->_strRoundNum.c_str());
 		if ( !pCase->_pExcutor ) {
 			CPythonExecutor *pExcutor = new CPythonExecutor(); 
 			if ( pExcutor ) {
 				pCase->_pExcutor = pExcutor;
 				// 用例的日志文件路径;
 				pCase->_strCaseLog = pCase->_strFileDir + pCase->_strFileName + _T("_") + pCase->_strRoundNum + ".txt";
-				if ( pExcutor->InitScript(pCase->_strScriptPath, pCase->_strCaseLog, szCommandLine) ) {
+				if ( pExcutor->InitScript(pCase->_strScriptPath, pCase->_strCaseLog, strPyCmd.c_str()) ) {
 					// 设置用例对象;
 					pExcutor->SetCaseObje(pCase);
 					pExcutor->StartScript();
@@ -271,7 +306,7 @@ SATHTTP::STCase* CSATExecutor::ExecuteFreeCaseScript(SATHTTP::STTask* pTask)
 			GLOBAL::WriteTextLog(GLOBAL::SAT_EXE, "重新初始化脚本(%s)", pCase->strCaseName.c_str());
 			// 重新初始化脚本;
 			CPythonExecutor *pExcutor = (CPythonExecutor *)pCase->_pExcutor;
-			if ( pExcutor->InitScript(pCase->_strScriptPath, pCase->_strCaseLog, szCommandLine) ) {
+			if ( pExcutor->InitScript(pCase->_strScriptPath, pCase->_strCaseLog, strPyCmd.c_str()) ) {
 				// 设置用例对象;
 				pExcutor->SetCaseObje(pCase);
 				pExcutor->StartScript();

+ 11 - 0
SATService/SATService/SATExecutor.h

@@ -6,6 +6,17 @@
 #include "CritSection.h"
 #include "SATDevices.h"
 
+namespace SATEXE{
+	// ÃüÁîÐÐ;
+	typedef struct __ST_PY_CDM__{
+		std::string		strRound;			// µ±Ç°ÂÖÊý; 
+		int				nTaskId;			// ÈÎÎñId;
+	}STPyCmd, *pSTPyCmd;
+
+	std::string GetPythonCommandLine(STPyCmd &pycmd);
+};
+
+
 class CSATExecutor
 {
 	CSATExecutor(void);