Explorar o código

#IQRV #comment 增加拍照的案例支持

80374374 hai 6 meses
pai
achega
9afa472108

BIN=BIN
DevAdapter/simulator/assets/simulator_hsps_01.jpg


BIN=BIN
DevAdapter/simulator/assets/simulator_hsps_02.jpg


BIN=BIN
DevAdapter/simulator/assets/simulator_hsps_03.jpg


+ 5 - 0
DevAdapter/simulator/hspscanner.1.1/hspscanner_httpans.h

@@ -16,3 +16,8 @@ typedef struct HspsDevStatusAns {
 
 	JSONCONVERT2OBJECT_MEMEBER_REGISTER(isConnected, inPreview, inShow)
 }HspsDevStatusAns;
+
+typedef struct ScanImageAns {
+	int ImageType;
+	JSONCONVERT2OBJECT_MEMEBER_REGISTER(ImageType)
+}ScanImageAns;

+ 29 - 11
DevAdapter/simulator/hspscanner.1.1/hspscanner_impl.cpp

@@ -151,24 +151,42 @@ ErrorCodeEnum HSPSClassImpl::SetPreview(short nValue)
 ErrorCodeEnum HSPSClassImpl::ScanImage(const char* pszFileName)
 {
     ErrorCodeEnum err = Error_NotImpl;
+    static unsigned long times = 0;
+	ScanImageAns ans;
 
-    err = SimulatorHttpFunction(EntityName, "ScanImage");
+    err = SimulatorHttpFunction(EntityName, "ScanImage", ans);
     LOG4VTM(INFO, "ScanImage err = " << err);
-
     if (err == Error_Succeed)
     {
-        string srcPath = GetCurrentDirectory() + SPLIT_SLASH_STR + "HspTest.jpg";
-
+		string srcPath("");
+        if (ans.ImageType == 2) {
+			srcPath = GetCurrentDirectory() + SPLIT_SLASH_STR + "simulator_hsps_01.jpg";
+        }
+        else if (ans.ImageType == 1) {
+            srcPath = GetCurrentDirectory() + SPLIT_SLASH_STR + "simulator_hsps_02.jpg";
+        }
+        else {
+            if (times % 3 == 0) {
+				srcPath = GetCurrentDirectory() + SPLIT_SLASH_STR + "simulator_hsps_01.jpg";
+            }
+            else if (times % 3 == 1) {
+				srcPath = GetCurrentDirectory() + SPLIT_SLASH_STR + "simulator_hsps_02.jpg";
+			}
+			else if (times % 3 == 2) {
+				srcPath = GetCurrentDirectory() + SPLIT_SLASH_STR + "simulator_hsps_03.jpg";
+			}
+            times++;
+        }
+        LOG4VTM(INFO, "ScanImage file = " << srcPath);
 #ifdef _WIN32
-        CopyFileA(srcPath.c_str(), pszFileName, TRUE);
+		CopyFileA(srcPath.c_str(), pszFileName, TRUE);
 #else
-        string cmdStr = "cp " + srcPath + " " + pszFileName;
-        char buff[256] = { 0 };
-        sprintf(buff, cmdStr.c_str());
-        system(buff);
+		string cmdStr = "cp " + srcPath + " " + pszFileName;
+		char buff[256] = { 0 };
+		sprintf(buff, cmdStr.c_str());
+		system(buff);
 #endif 
     }
-
     return err;
 }
 
@@ -182,7 +200,7 @@ ErrorCodeEnum HSPSClassImpl::ScanImageEx(BYTE* pBtImg, int& nBtLen, const char*
 
     if (err == Error_Succeed)
     {
-        string srcPath = GetCurrentDirectory() + SPLIT_SLASH_STR + "HspTest.jpg";
+        string srcPath = GetCurrentDirectory() + SPLIT_SLASH_STR + "agent.jpg";
 
 #ifdef _WIN32
         CopyFileA(srcPath.c_str(), pszFileName, TRUE);