Browse Source

#IQRV #comment 旧改JS合并到最新版本

80374374 6 months ago
parent
commit
d90c0226c7

+ 14 - 6
Module/mod_HSPScanner/HSPSCanner_UserErrorCode.h

@@ -7,11 +7,11 @@
 
 
 #define LOG_ERR_HSPS_DEVOPEN_FAILED 0x21700001
-#define LOG_EVT_HSPS_LIGHT_ON 0x21700002
-#define LOG_EVT_HSPS_LIGHT_OFF 0x21700003
-#define LOG_EVT_HSPS_LOST_CONNECT 0x21700004
-#define LOG_EVT_HSPS_READ_IMAGE_FILE_FAILED 0x21700005
+#define LOG_ERR_HSPS_PREVIEW_FAILED 0x21700003
+#define LOG_EVT_HSPS_CANCEL_PREVIEW_FAILED 0x21700004
+#define LOG_EVT_HSPS_SCANIMAGE_FAILED 0x21700005
 #define LOG_EVT_HSPS_READ_IMAGEEX_FILE_FAILED 0x21700006
+#define HSPScanner_UserErrorCode_SetParam_Position 0x21700007
 #define LOG_EVT_SCANNERSET_HSPSCNT_UPLOAD_VENDORINFO 0x21700102
 #define LOG_EVT_SCANNERSET_HSPSCNT_ROOTINFO 0x21700103
 #define LOG_EVT_HSPSCANNER_SetPreview_Close 0x21700104
@@ -34,7 +34,7 @@
 #define HSPScanner_UserErrorCode_NOT_SUPPORT					0x2170020E
 #define HSPScanner_UserErrorCode_REAL_ROOT_CONFIG	0x2170020F
 
-#define LOG_DEBUG_HSPS_CRITICAL_OPERATION_START						 0x21700210
+#define LOG_DEBUG_HSPS_CRITICAL_OPERATION_START			0x21700210
 #define LOG_DEBUG_HSPS_CRITICAL_OPERATION_SCANIMAGE_START  0x21700211
 #define LOG_DEBUG_HSPS_CRITICAL_OPERATION_SCANIMAGEEX_START  0x21700212
 
@@ -45,8 +45,9 @@
 #define LOG_WARN_HSPS_RESIZE_IMAGEEX_FILE_FAILED				0x21700217 //ex图片缩小失败
 #define LOG_WARN_HSPS_RESIZE_FUNCTION_SUCCEED					0x21700218 //resize函数执行成功
 
-#define LOG_WARN_HSPS_VENDORDLL_CHANGE					0x21700219 //修改加载DLL的名称
 #define LOG_WARN_HSPS_VENDORDLL_KEBA_MATCHED	    0x2170021A //符合切换科堡适配器的告警
+#define LOG_WARN_HSPS_INVALID_OPERATION	    0x2170021B
+#define LOG_WARN_HSPS_OPENING_NOW 0x2170021C
 
 #define LOG_DEBUG_HSPS_CRITICAL_OPERATION_SCANIMAGE_SUCC   0x21700220
 #define LOG_DEBUG_HSPS_CRITICAL_OPERATION_SCANIMAGE_FAILED 0x21700221
@@ -55,4 +56,11 @@
 
 #define HSPScanner_UserErrorCode_FindFile_in_DepBak 0x21700225
 
+#define HSPScanner_UserErrorCode_SetParam_Color 0x21700226
+#define HSPScanner_UserErrorCode_SetParam_Rotate 0x21700227
+#define HSPScanner_UserErrorCode_SetParam_Scan 0x21700228
+#define HSPScanner_UserErrorCode_SetParam_View 0x21700229
+#define HSPScanner_UserErrorCode_SetParam_Hide 0x2170022A
+
+
 #endif

+ 125 - 6
Module/mod_HSPScanner/HSPScanner.xml

@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="gb2312" ?>
+<?xml version="1.0" encoding="utf-8" ?>
 <entity name="HSPScanner">
 	<class name="HSPScannerService" overlap="true" exclusive="false">
 		<twoway name="StartPreview" overlap="true">
@@ -105,18 +105,137 @@
 				<param name="reserved2" type="array_string"/>	
 			</res>
 		</twoway>
-		<twoway name="GetDevInfo" overlap="true" method_id="65535">
+    <!-- 获取设备模块信息,成功时errorCode为Error_Succeed(0),及相关数据 -->
+    <!-- 1、设备未打开,errorCode为Error_DevNotAvailable,rtaCode为RTA2N01 -->
+    <!-- 2、硬件未配置,errorCode为Error_NotConfig,rtaCode为RTA2N0J -->
+    <!-- 3、硬件掉线,errorCode为Error_DevNotAvailable,rtaCode为RTA2N0K -->
+    <twoway name="GetDevInfo" overlap="true" jsflag="true" method_id="65535">
 			<req>
 			</req>
 			<res>
-				<param name="type" type="string" />
+        <!--设备适配器DevCategoryInfo的szType-->
+        <param name="type" type="string" />
+        <!--设备适配器DevCategoryInfo的szModel-->
 				<param name="model" type="string" />
-				<param name="version" type="string" />
-				<param name="state" type="int" />
+        <!--设备适配器DevCategoryInfo的version-->
+        <param name="version" type="string" />
+        <!--硬件实体内置的状态,目前暂无使用场景,有需要在讨论如何定义-->
+        <param name="state" type="int" />
 			</res>
 		</twoway>
 		<oneway name="Exit" overlap="true">			
-		</oneway>							
+		</oneway>
+    <!-- 预览,成功时返回Error_Succeed,及相关数据 -->
+    <!-- 1、设备未打开,errorCode为Error_DevNotAvailable,rtaCode为RTA2N01 -->
+    <!-- 2、硬件未配置,errorCode为Error_NotConfig,rtaCode为RTA2N0J -->
+    <!-- 3、硬件掉线,errorCode为Error_DevNotAvailable,rtaCode为RTA2N0K -->
+    <!-- 4、调用硬件-预览失败,errorCode为Error_Unexpect,rtaCode为RTA2N03 -->
+    <!-- 5、调用硬件-设置角度失败,errorCode为Error_Unexpect,rtaCode为RTA2N0Y -->
+    <!-- 6、调用硬件-设置画幅失败,errorCode为Error_Unexpect,rtaCode为RTA2N0Z -->
+    <!-- 7、调用硬件-设置色彩失败,errorCode为Error_Unexpect,rtaCode为RTA2N0W -->
+    <!-- 8、调用硬件-设置坐标大小失败,errorCode为Error_Unexpect,rtaCode为RTA2N07 -->
+    <!-- 9、调用硬件-显示预览窗口失败(预览&隐藏的状态),errorCode为Error_Unexpect,rtaCode为RTA2N0R -->
+    <!-- 说明补充:
+     * 如需设置参数,将在预览前设置,设置参数失败则提前返回,无论当时是否已经处于预览状态
+     * 处于预览但隐藏(关于隐藏,见下方对取消预览的说明)状态,则会直接显示窗口,如果其他参数有值,仍然优先设置参数(失败则提前返回),再显示窗口
+    -->
+    <twoway name="StartPreviewJS" jsflag="true" overlap="true">
+      <req>
+        <!--0:跳过角度设置,不生效;1:不旋转角度;2:顺时针旋转90;3:顺时针旋转180;4:顺时针旋转270-->
+        <param name="rotate" type="short" />
+        <!--0:跳过画幅设置,不生效;1:全画幅;2:A4画幅;3:身份证大小画幅-->
+        <param name="scan" type="short"/>
+        <!--0:跳过色彩设置,不生效;1:彩色;2:黑白-->
+        <param name="color" type="short" />
+        <!--0:跳过坐标&大小设置,不生效;1:设置预览窗口坐标,只有此值为1时才会读取pos_x|y|w-->
+        <param name="pos" type="short"/>
+        <!--设置预览窗口坐标的X轴坐标,当pos不为0时该值才有效-->
+        <param name="pos_x" type="short"/>
+        <!--设置预览窗口坐标的Y轴坐标,当pos不为0时该值才有效-->
+        <param name="pos_y" type="short"/>
+        <!--设置预览窗口的窗口宽度,当pos不为0时该值才有效-->
+        <param name="pos_w" type="short"/>
+        <param name="reserved1" type="int"/>
+      </req>
+      <res>
+      </res>
+    </twoway>
+    <!-- 取消预览,成功时返回Error_Succeed(0),及相关数据 -->
+    <!-- 1、设备未打开,errorCode为Error_DevNotAvailable,rtaCode为RTA2N01 -->
+    <!-- 2、硬件未配置,errorCode为Error_NotConfig,rtaCode为RTA2N0J -->
+    <!-- 3、硬件掉线,errorCode为Error_DevNotAvailable,rtaCode为RTA2N0K -->
+    <!-- 4、调用硬件-取消预览失败,errorCode为Error_Unexpect,rtaCode为RTA2N04 -->
+    <!-- 5、调用硬件-隐藏预览窗口失败,errorCode为Error_Unexpect,rtaCode为RTA2N0Q -->
+    <!-- 说明补充:
+     * 当要求仅为隐藏预览窗口时:1)预览&隐藏状态时直接返回成功;2)预览&非隐藏时调用隐藏;3)非预览时返回无效操作,errorCode为Error_InvalidState,rtaCode为RTA2N0V
+     * 当直接关闭预览时:1)非预览时直接返回成功;2)预览&隐藏状态时调用硬件取消预览
+    -->
+    <twoway name="CancelPreviewJS" jsflag="true" overlap="true">
+      <req>
+        <!--是否仅为隐藏预览窗口,如果为false,表示调用硬件关闭摄像头,true表示仅为隐藏预览窗口不关闭摄像头,默认是关闭摄像头-->
+        <param name="hide" type="bool"/>
+      </req>
+      <res>
+      </res>
+    </twoway>
+    <!--拍照,成功时返回Error_Succeed(0),及相关数据-->
+    <!-- 1、设备未打开,errorCode为Error_DevNotAvailable,rtaCode为RTA2N01 -->
+    <!-- 2、硬件未配置,errorCode为Error_NotConfig,rtaCode为RTA2N0J -->
+    <!-- 3、硬件掉线,errorCode为Error_DevNotAvailable,rtaCode为RTA2N0K -->
+    <!-- 4、非预览状态无法拍照,errorCode为Error_InvalidState,rtaCode为RTA2N0V -->
+    <!-- 5、调用硬件-拍照失败,errorCode为Error_Unexpect,rtaCode为RTA2N05 -->
+    <!-- 6、调用硬件-隐藏预览窗口失败,errorCode为Error_Unexpect,rtaCode为RTA2N0Q -->
+    <!-- 7、拍照成功后,压缩照片失败,errorCode为Error_Unexpect,rtaCode为RTA2N0N -->
+    <!-- 说明补充:
+     * 当需要隐藏时,前提是【拍照成功】才会调用隐藏预览窗口,如果隐藏窗口失败,一样扔定为拍照不成功
+     * 只要处于预览状态中,就认为可进行拍照,不区分是否隐藏预览窗口
+     * 调用拍照成功,但是硬件没有返回图片数据,仍认为成功。只有需要压缩时(应用介入),会因为压缩图片失败而报错返回
+    -->
+    <twoway name="ScanImageJS" jsflag="true" overlap="true">
+      <req>
+        <!--拍照后是否自动隐藏预览窗口,如果为false,表示仅为拍照不做其他操作,true表示拍照后自动隐藏预览窗口,底层默认是拍照后自动隐藏预览窗口-->
+        <param name="hide" type="bool"/>
+        <!-- 是否压缩图片和压缩的阈值,单位KB,为0表示不压缩,业务目前定的是500KB -->
+        <param name="compress" type="int" />
+        <param name="reserved1" type="int" />
+      </req>
+      <res>
+        <!--返回照片的数据流-->
+        <param name="imageData" type="blob"/>
+      </res>
+    </twoway>
+    <!-- 设置参数,成功时返回Error_Succeed(0),及相关数据 -->
+    <!-- 1、设备未打开,errorCode为Error_DevNotAvailable,rtaCode为RTA2N01 -->
+    <!-- 2、硬件未配置,errorCode为Error_NotConfig,rtaCode为RTA2N0J -->
+    <!-- 3、硬件掉线,errorCode为Error_DevNotAvailable,rtaCode为RTA2N0K -->
+    <!-- 4、调用硬件-设置角度失败,errorCode为Error_Unexpect,rtaCode为RTA2N0Y -->
+    <!-- 5、调用硬件-设置画幅失败,errorCode为Error_Unexpect,rtaCode为RTA2N0Z -->
+    <!-- 6、调用硬件-设置色彩失败,errorCode为Error_Unexpect,rtaCode为RTA2N0W -->
+    <!-- 7、调用硬件-设置坐标大小失败,errorCode为Error_Unexpect,rtaCode为RTA2N07 -->
+    <!-- 说明补充:
+     * 除以上第1-3种情况,在其他任何状态中都支持设置参数,成功与否由调用硬件结果决定
+    -->
+    <twoway name="SetParamJS" jsflag="true" overlap="true">
+      <req>
+        <!--0:跳过设置,不生效;1:不旋转角度;2:顺时针旋转90;3:顺时针旋转180;4:顺时针旋转270-->
+        <param name="rotate" type="short" />
+        <!--0:跳过设置,不生效;1:全画幅;2:A4画幅;3:身份证大小画幅-->
+        <param name="scan" type="short"/>
+        <!--0:跳过设置,不生效;1:彩色;2:黑白-->
+        <param name="color" type="short" />
+        <!--0:跳过设置,不生效;1:设置预览窗口坐标,只有此值为1时才会读取pos_x|y|w-->
+        <param name="pos" type="short"/>
+        <!--设置预览窗口坐标的X轴坐标,当pos不为0时该值才有效-->
+        <param name="pos_x" type="short"/>
+        <!--设置预览窗口坐标的Y轴坐标,当pos不为0时该值才有效-->
+        <param name="pos_y" type="short"/>
+        <!--设置预览窗口的窗口宽度,当pos不为0时该值才有效-->
+        <param name="pos_w" type="short"/>
+        <param name="reserved1" type="int"/>
+      </req>
+      <res>
+      </res>
+    </twoway>
 	</class>
 		<message name="StatusMsg">
 			<param name="status" type="int"/>

File diff suppressed because it is too large
+ 515 - 178
Module/mod_HSPScanner/HSPScannerFSM.cpp


+ 294 - 75
Module/mod_HSPScanner/HSPScannerFSM.h

@@ -21,23 +21,24 @@ using namespace HSPScanner;
 #define ISSUCCEEDED(hr) ((hr) == Error_Succeed)
 #define FAILURED(hr) (!(ISSUCCEEDED(hr)))
 
-#define SAFE_FREE_LIBRARY(hModule)	\
-	do {							\
-	if(hModule){					\
-	FreeLibrary(hModule);		\
-	hModule = NULL;				\
-	}							\
-	}while(0)
-
-
-
-
 enum EvtType
 {
 	USER_EVT_STARTPREVIEW = (EVT_USER + 1),
 	USER_EVT_STARTPREVIEW_FINISHED,
 	USER_EVT_SETPROPERTYINVIEW_FINISHED,
 
+	USER_EVT_STARTPREVIEW_JS,
+	USER_EVT_STARTPREVIEW_JS_DONE,
+
+	USER_EVT_CANCELPREVIEW_JS,
+	USER_EVT_CANCELPREVIEW_JS_DONE,
+
+	USER_EVT_SCANIMAGE_JS,
+	USER_EVT_SCANIMAGE_JS_DONE,
+
+	USER_EVT_SETPARAM_JS,
+	USER_EVT_SETPARAM_JS_DONE,
+
 	USER_EVT_STOPPREVIEW,
 	USER_EVT_HIDEPREVIEW,
 	USER_EVT_STOPPREVIEW_FINISHED,
@@ -71,6 +72,37 @@ enum EvtType
 	USER_EVT_QUIT
 };
 
+
+namespace JS
+{
+	struct PreviewSettings
+	{
+		short rotate;
+		short scan;
+		short color;
+		short pos;
+		short pos_x;
+		short pos_y;
+		short pos_w;
+
+		//0:do nothing,1:show, 2:hide
+		short view;
+
+		PreviewSettings(const HSPScannerService_SetParamJS_Req& rhs) :rotate(rhs.rotate), scan(rhs.scan), color(rhs.color), pos(rhs.pos)
+			, pos_x(rhs.pos_x), pos_y(rhs.pos_y), pos_w(rhs.pos_w),view(0) {}
+
+		PreviewSettings(const HSPScannerService_StartPreviewJS_Req& rhs) :rotate(rhs.rotate), scan(rhs.scan), color(rhs.color), pos(rhs.pos)
+			, pos_x(rhs.pos_x), pos_y(rhs.pos_y), pos_w(rhs.pos_w),view(0) {}
+
+		PreviewSettings(bool show) :rotate(0), scan(0), color(0), pos(0), pos_x(0), pos_y(0), pos_w(0), view(show ? 1 : 2) {}
+
+		bool IsWorth() const {
+			return (rotate != 0 || scan != 0 || color != 0 || pos != 0);
+		}
+		void SetDisplay(bool display) { if (display) view = 1; else view = 2; }
+	};
+}
+
 class StartPreviewEvent : public FSMEvent
 {
 public:
@@ -82,7 +114,7 @@ public:
 		if(m_ctx != NULL)
 		{
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_StartPreview).setResultCode("RTA2N0V")("Error_InvalidState");
-			m_ctx->Answer(Error_InvalidState, HSPScanner_UserErrorCode_FSM_INVALID);
+			m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
 		}
 	}
 };
@@ -99,7 +131,7 @@ public:
 		if(m_ctx != NULL)
 		{
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_CancelPreview).setResultCode("RTA2N0V")("Error_InvalidState");
-			m_ctx->Answer(Error_InvalidState, HSPScanner_UserErrorCode_FSM_INVALID);
+			m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
 		}
 	}
 };
@@ -116,7 +148,7 @@ public:
 		if(m_ctx != NULL)
 		{
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_ScanImage).setResultCode("RTA2N0V")("Error_InvalidState");
-			m_ctx->Answer(Error_InvalidState, HSPScanner_UserErrorCode_FSM_INVALID);
+			m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
 		}
 	}
 };
@@ -133,7 +165,7 @@ public:
 		if(m_ctx != NULL)
 		{
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_ScanImageEx).setResultCode("RTA2N0V")("Error_InvalidState");
-			m_ctx->Answer(Error_InvalidState, HSPScanner_UserErrorCode_FSM_INVALID);
+			m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
 		}
 	}
 };
@@ -150,7 +182,7 @@ public:
 		if(m_ctx != NULL)
 		{
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_ShowProperty).setResultCode("RTA2N0V")("Error_InvalidState");
-			m_ctx->Answer(Error_InvalidState, HSPScanner_UserErrorCode_FSM_INVALID);
+			m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
 		}
 	}
 };
@@ -167,7 +199,7 @@ public:
 		if(m_ctx != NULL)
 		{
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_SetProperty).setResultCode("RTA2N0V")("Error_InvalidState");
-			m_ctx->Answer(Error_InvalidState, HSPScanner_UserErrorCode_FSM_INVALID);
+			m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
 		}
 	}
 };
@@ -184,7 +216,7 @@ public:
 		if(m_ctx != NULL)
 		{
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_SetWinPos).setResultCode("RTA2N0V")("Error_InvalidState");
-			m_ctx->Answer(Error_InvalidState, HSPScanner_UserErrorCode_FSM_INVALID);
+			m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
 		}
 	}
 };
@@ -201,7 +233,7 @@ public:
 		if(m_ctx != NULL)
 		{
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_GetDevStatus).setResultCode("RTA2N0V")("Error_InvalidState");
-			m_ctx->Answer(Error_InvalidState, HSPScanner_UserErrorCode_FSM_INVALID);
+			m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
 		}
 	}
 };
@@ -218,11 +250,79 @@ public:
 		if(m_ctx != NULL)
 		{
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_GetDevInfo).setResultCode("RTA2N0V")("Error_InvalidState");
-			m_ctx->Answer(Error_InvalidState, HSPScanner_UserErrorCode_FSM_INVALID);
+			m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
 		}
 	}
 };
 
+/** JS Component  [Gifur@20241112]*/
+namespace JS {
+
+	class StartPreviewEvent : public FSMEvent
+	{
+	public:
+		StartPreviewEvent() : FSMEvent(USER_EVT_STARTPREVIEW_JS) {}
+		~StartPreviewEvent() {}
+		SpReqAnsContext<HSPScannerService_StartPreviewJS_Req, HSPScannerService_StartPreviewJS_Ans>::Pointer m_ctx;
+		virtual void OnUnhandled()
+		{
+			if (m_ctx != NULL)
+			{
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_StartPreviewJS).setResultCode("RTA2N0V")("StartPreviewEvent::Error_InvalidState");
+				m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
+			}
+		}
+	};
+
+	class CancelPreviewEvent : public FSMEvent
+	{
+	public:
+		CancelPreviewEvent() : FSMEvent(USER_EVT_CANCELPREVIEW_JS) {}
+		~CancelPreviewEvent() {}
+		SpReqAnsContext<HSPScannerService_CancelPreviewJS_Req, HSPScannerService_CancelPreviewJS_Ans>::Pointer m_ctx;
+		virtual void OnUnhandled()
+		{
+			if (m_ctx != NULL)
+			{
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_CancelPreviewJS).setResultCode("RTA2N0V")("CancelPreviewEvent::Error_InvalidState");
+				m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
+			}
+		}
+	};
+
+	class ScanImageEvent : public FSMEvent
+	{
+	public:
+		ScanImageEvent() : FSMEvent(USER_EVT_SCANIMAGE_JS) {}
+		~ScanImageEvent() {}
+		SpReqAnsContext<HSPScannerService_ScanImageJS_Req, HSPScannerService_ScanImageJS_Ans>::Pointer m_ctx;
+		virtual void OnUnhandled()
+		{
+			if (m_ctx != NULL)
+			{
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_ScanImageJS).setResultCode("RTA2N0V")("ScanImageEvent::Error_InvalidState");
+				m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
+			}
+		}
+	};
+
+	class SetParamEvent : public FSMEvent
+	{
+	public:
+		SetParamEvent() : FSMEvent(USER_EVT_SCANIMAGE_JS) {}
+		~SetParamEvent() {}
+		SpReqAnsContext<HSPScannerService_SetParamJS_Req, HSPScannerService_SetParamJS_Ans>::Pointer m_ctx;
+		virtual void OnUnhandled()
+		{
+			if (m_ctx != NULL)
+			{
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode(HSPScannerService_LogCode_SetParamJS).setResultCode("RTA2N0V")("SetParamEvent::Error_InvalidState");
+				m_ctx->Answer(Error_InvalidState, LOG_WARN_HSPS_INVALID_OPERATION);
+			}
+		}
+	};
+}
+/** JS Component Done  [Gifur@20241112]*/
 
 class CHSPScannerFSM : public CCommDevFSM<CHSPScannerFSM, CHSPSClass>, public IFSMStateHooker
 {
@@ -238,15 +338,15 @@ public:
 	enum {s0, s1, s2, s3, s4, s5, s6, s7, s8};
 
 	BEGIN_FSM_STATE(CHSPScannerFSM)
-		FSM_STATE_ENTRY(s0, "Idle", s0_on_entry, s0_on_exit, s0_on_event)
-		FSM_STATE_ENTRY(s1, "Previewing", s1_on_entry, s1_on_exit, s1_on_event)
+		FSM_STATE_ENTRY(s0, "Idle", s0_Idle_on_entry, s0_Idle_on_exit, s0_Idle_on_event)
+		FSM_STATE_ENTRY(s1, "Previewing", s1_Preview_on_entry, s1_Preview_on_exit, s1_Preview_on_event)
 		FSM_STATE_ENTRY(s2, "Property", s2_on_entry, s2_on_exit, s2_on_event)
-		FSM_STATE_ENTRY(s3, "Failed", s3_on_entry, s3_on_exit, s3_on_event)
-		FSM_STATE_ENTRY(s4, "Picturing", s4_on_entry, s4_on_exit, s4_on_event)
-		FSM_STATE_ENTRY(s5, "DeviceOff", s5_on_entry, s5_on_exit, s5_on_event)
-		FSM_STATE_ENTRY(s6, "HidPreviewing", s6_on_entry, s6_on_exit, s6_on_event)
-		FSM_STATE_ENTRY(s7, "Exit", s7_on_entry, s7_on_exit, s7_on_event)
-		FSM_STATE_ENTRY(s8, "Idiot", s8_on_entry, s8_on_exit, s8_on_event)
+		FSM_STATE_ENTRY(s3, "Failed", s3_Failed_on_entry, s3_Failed_on_exit, s3_Failed_on_event)
+		FSM_STATE_ENTRY(s4, "Picturing", s4_ScanImage_on_entry, s4_ScanImage_on_exit, s4_ScanImage_on_event)
+		FSM_STATE_ENTRY(s5, "DeviceOff", s5_DeviceOff_on_entry, s5_DeviceOff_on_exit, s5_DeviceOff_on_event)
+		FSM_STATE_ENTRY(s6, "HidPreviewing", s6_HidPreviewing_on_entry, s6_HidPreviewing_on_exit, s6_HidPreviewing_on_event)
+		FSM_STATE_ENTRY(s7, "Exit", s7_Exit_on_entry, s7_Exit_on_exit, s7_Exit_on_event)
+		FSM_STATE_ENTRY(s8, "NotConfig", s8_NotConfig_on_entry, s8_NotConfig_on_exit, s8_NotConfig_on_event)
 	END_FSM_STATE()
 
 	
@@ -317,59 +417,93 @@ public:
 
 		FSM_RULE_ENTRY_ANY(s0, s8, USER_EVT_NOCFG)
 		FSM_RULE_ENTRY_ANY(s0, s3, USER_EVT_GOTOHELL)
+
+		/*
+			USER_EVT_STARTPREVIEW_JS,
+	USER_EVT_STARTPREVIEW_JS_DONE,
+
+	USER_EVT_CANCELPREVIEW_JS,
+	USER_EVT_CANCELPREVIEW_JS_DONE,
+
+	USER_EVT_SCANIMAGE_JS,
+	USER_EVT_SCANIMAGE_JS_DONE,
+
+	USER_EVT_SETPARAM_JS,
+	USER_EVT_SETPARAM_JS_DONE,
+		
+		*/
+
+		/** JS Compoent  [Gifur@20241114]*/
+		FSM_RULE_ENTRY(s0, s1, USER_EVT_STARTPREVIEW_JS_DONE, 0)
+		FSM_RULE_ENTRY(s6, s1, USER_EVT_STARTPREVIEW_JS, 1)
+
+		FSM_RULE_ENTRY(s1, s0, USER_EVT_CANCELPREVIEW_JS_DONE, 1)
+		FSM_RULE_ENTRY(s1, s6, USER_EVT_CANCELPREVIEW_JS_DONE, 2)
+		FSM_RULE_ENTRY(s6, s0, USER_EVT_CANCELPREVIEW_JS_DONE, 0)
+
+		FSM_RULE_ENTRY(s1, s6, USER_EVT_SCANIMAGE_JS_DONE, 2)
+		/** JS Compoent Done [Gifur@20241114]*/
+
 		
 	END_FSM_RULE()
 
-	virtual void s0_on_entry();
-	virtual void s0_on_exit();
-	virtual unsigned int s0_on_event(FSMEvent* e);
+	virtual void s0_Idle_on_entry();
+	virtual void s0_Idle_on_exit();
+	virtual unsigned int s0_Idle_on_event(FSMEvent* e);
 
-	virtual void s1_on_entry();
-	virtual void s1_on_exit();
-	virtual unsigned int s1_on_event(FSMEvent* e);
+	virtual void s1_Preview_on_entry();
+	virtual void s1_Preview_on_exit();
+	virtual unsigned int s1_Preview_on_event(FSMEvent* e);
 
 	virtual void s2_on_entry();
 	virtual void s2_on_exit();
 	virtual unsigned int s2_on_event(FSMEvent* e);
 
-	virtual void s3_on_entry();
-	virtual void s3_on_exit();
-	virtual unsigned int s3_on_event(FSMEvent* e);
+	virtual void s3_Failed_on_entry();
+	virtual void s3_Failed_on_exit();
+	virtual unsigned int s3_Failed_on_event(FSMEvent* e);
 
-	virtual void s4_on_entry();
-	virtual void s4_on_exit();
-	virtual unsigned int s4_on_event(FSMEvent* e);
+	virtual void s4_ScanImage_on_entry();
+	virtual void s4_ScanImage_on_exit();
+	virtual unsigned int s4_ScanImage_on_event(FSMEvent* e);
 
-	virtual void s5_on_entry();
-	virtual void s5_on_exit();
-	virtual unsigned int s5_on_event(FSMEvent* e);
+	virtual void s5_DeviceOff_on_entry();
+	virtual void s5_DeviceOff_on_exit();
+	virtual unsigned int s5_DeviceOff_on_event(FSMEvent* e);
 
-	virtual void s6_on_entry();
-	virtual void s6_on_exit();
-	virtual unsigned int s6_on_event(FSMEvent* e);
+	virtual void s6_HidPreviewing_on_entry();
+	virtual void s6_HidPreviewing_on_exit();
+	virtual unsigned int s6_HidPreviewing_on_event(FSMEvent* e);
 
-	virtual void s7_on_entry();
-	virtual void s7_on_exit();
-	virtual unsigned int s7_on_event(FSMEvent* e);
+	virtual void s7_Exit_on_entry();
+	virtual void s7_Exit_on_exit();
+	virtual unsigned int s7_Exit_on_event(FSMEvent* e);
 
-	virtual void s8_on_entry() {
-		SetDevState(DEVICE_STATUS_NOCFG);
-		SetLastUserCode(HSPScanner_UserErrorCode_DLLNAME_NOCFG);
-	}
-	virtual void s8_on_exit() {
-		SetDevState(DEVICE_STATUS_NORMAL);
-	}
-	virtual unsigned int s8_on_event(FSMEvent* e);
+	//NotConfig
+	virtual void s8_NotConfig_on_entry();
+	virtual void s8_NotConfig_on_exit();
+	virtual unsigned int s8_NotConfig_on_event(FSMEvent* e);
 
 	virtual void OnStateTrans(int iSrcState, int iDstState);
 
+	/** JS Component  [Gifur@20241112]*/
+	int StartPreviewJS(SpReqAnsContext<HSPScannerService_StartPreviewJS_Req,
+		HSPScannerService_StartPreviewJS_Ans>::Pointer ctx);
+	int CancelPreview(SpReqAnsContext<HSPScannerService_CancelPreviewJS_Req,
+		HSPScannerService_CancelPreviewJS_Ans>::Pointer ctx);
+	int ScanImageJS(SpReqAnsContext<HSPScannerService_ScanImageJS_Req,
+		HSPScannerService_ScanImageJS_Ans>::Pointer ctx);
+	int SetParam(SpReqAnsContext<HSPScannerService_SetParamJS_Req,
+		HSPScannerService_SetParamJS_Ans>::Pointer ctx);
+	/** JS Component Done  [Gifur@20241112]*/
+
 	int StartPreview(SpReqAnsContext<HSPScannerService_StartPreview_Req,
 		HSPScannerService_StartPreview_Ans>::Pointer ctx);
 
 	int StopPreview(SpReqAnsContext<HSPScannerService_CancelPreview_Req,
 		HSPScannerService_CancelPreview_Ans>::Pointer ctx);
 	
-	bool ResizeImage(const CSimpleStringA& fileName);
+	bool ResizeImage(const CSimpleStringA& fileName, int kbSize);
 	
 	int ScanImage(SpReqAnsContext<HSPScannerService_ScanImage_Req,
 		HSPScannerService_ScanImage_Ans>::Pointer ctx);
@@ -406,37 +540,31 @@ public:
 
 	int SetPreviewParam(int colorType, int rotateType, int scanType, bool abortIfFault = false);
 
-private:
-	int m_version, m_batch;
+	ErrorCodeEnum TryToOpenDevice();
 
+protected:
+	
+	ErrorCodeEnum SetPreviewProperty(const JS::PreviewSettings& val, const char* logCode = "");
+
+private:
 	ErrorCodeEnum m_ecSelfTest;
-	DWORD m_dwErroCode;
-	BOOL m_bOperating;
-	int m_nTickTimes;
 	int m_nFatalTimes;
 	int m_nSrcState;
-
 	int m_nRecX, m_nRecY, m_nRecW;
 
 	EvtType m_desiredAction;
-	CSimpleStringA m_csMachineType;
-	DevCategoryInfo m_devCat;
-	CSimpleStringA m_csDevNo;
-
 	DWORD dwLastUserCode;
 	DWORD m_dwMaxImageSize;
 
-public:
-
-	DWORD GetCustLastErrorCode() { return m_dwErroCode; }
-	void SetCustLastErrorCode(DWORD dwVal = 0) { m_dwErroCode = dwVal; }
-	ErrorCodeEnum TryToOpenDevice();
-
 private:
 	BOOL GetCurImageName(CSimpleStringA& csImagName, bool bExt = false);
 	BOOL DelAndGetNewFileName(CSimpleStringA& csfileName, bool bInBusiness = false);
 	ErrorCodeEnum DeleteFileIfExisted(LPCTSTR fileName);
+
+	ErrorCodeEnum GetDevStatusFromAdapter(HspsDevStatus& status, bool fromBusiness = false);
+
 	//  --Josephus at 16:33:57 20161214
+	// to replace when JS
 	// 0: disconnected;
 	// 1: connected;
 	// -1: invalid;
@@ -444,7 +572,7 @@ private:
 	{
 		if(!m_hDevHelper || !m_bOpened) return -1;
 		HspsDevStatus status = {0};
-		if(m_hDevHelper->GetDevStatus(status) == Error_Succeed)
+		if(GetDevStatusFromAdapter(status) == Error_Succeed)
 		{
 			if(status.isConnected == 0)
 				return 0;
@@ -700,4 +828,95 @@ struct OpenDeviceTask : public ITaskSp
 	}
 };
 
+/** JS Compoent  [Gifur@20241112]*/
+namespace JS {
+
+	struct StartPreviewTask : public ITaskSp
+	{
+		CHSPScannerFSM* m_fsm;
+		SpReqAnsContext<HSPScannerService_StartPreviewJS_Req, HSPScannerService_StartPreviewJS_Ans>::Pointer m_ctx;
+		StartPreviewTask(CHSPScannerFSM* fsm) : m_fsm(fsm) {}
+		void Process()
+		{
+			FSMEvent* pEvt = new FSMEvent(USER_EVT_STARTPREVIEW_JS_DONE);
+			//0,succ;1 failed;
+			pEvt->param1 = m_fsm->StartPreviewJS(m_ctx);
+			m_fsm->PostEventFIFO(pEvt);
+			return;
+		}
+		void SetContext(
+			SpReqAnsContext<HSPScannerService_StartPreviewJS_Req,
+			HSPScannerService_StartPreviewJS_Ans>::Pointer ctx)
+		{
+			m_ctx = ctx;
+			return;
+		}
+	};
+
+	struct CancelPreviewTask : public ITaskSp
+	{
+		CHSPScannerFSM* m_fsm;
+		SpReqAnsContext<HSPScannerService_CancelPreviewJS_Req, HSPScannerService_CancelPreviewJS_Ans>::Pointer m_ctx;
+		CancelPreviewTask(CHSPScannerFSM* fsm) : m_fsm(fsm) {}
+		void Process()
+		{
+			FSMEvent* pEvt = new FSMEvent(USER_EVT_CANCELPREVIEW_JS_DONE);
+			////0,succ;1 failed;
+			pEvt->param1 = m_fsm->CancelPreview(m_ctx);
+			pEvt->param2 = m_ctx->Req.hide ? 1 : 0;
+			m_fsm->PostEventFIFO(pEvt);
+			return;
+		}
+		void SetContext(
+			SpReqAnsContext<HSPScannerService_CancelPreviewJS_Req,
+			HSPScannerService_CancelPreviewJS_Ans>::Pointer ctx)
+		{
+			m_ctx = ctx;
+			return;
+		}
+	};
+
+	struct ScanImageTask : public ITaskSp
+	{
+		CHSPScannerFSM* m_fsm;
+		SpReqAnsContext<HSPScannerService_ScanImageJS_Req, HSPScannerService_ScanImageJS_Ans>::Pointer m_ctx;
+		ScanImageTask(CHSPScannerFSM* fsm) : m_fsm(fsm) {}
+		void Process()
+		{
+			FSMEvent* pEvt = new FSMEvent(USER_EVT_SCANIMAGE_JS_DONE);
+			////0,succ;1 failed;
+			pEvt->param1 = m_fsm->ScanImageJS(m_ctx);
+			pEvt->param2 = m_ctx->Req.hide ? 1 : 0;
+			m_fsm->PostEventFIFO(pEvt);
+			return;
+		}
+		void SetContext(
+			SpReqAnsContext<HSPScannerService_ScanImageJS_Req,
+			HSPScannerService_ScanImageJS_Ans>::Pointer ctx)
+		{
+			m_ctx = ctx;
+			return;
+		}
+	};
+
+	struct SetParamTask : public ITaskSp
+	{
+		CHSPScannerFSM* m_fsm;
+		SpReqAnsContext<HSPScannerService_SetParamJS_Req, HSPScannerService_SetParamJS_Ans>::Pointer m_ctx;
+		SetParamTask(CHSPScannerFSM* fsm) : m_fsm(fsm) {}
+		void Process()
+		{
+			m_fsm->SetParam(m_ctx);
+			return;
+		}
+		void SetContext(
+			SpReqAnsContext<HSPScannerService_SetParamJS_Req,
+			HSPScannerService_SetParamJS_Ans>::Pointer ctx)
+		{
+			m_ctx = ctx;
+			return;
+		}
+	};
+}
+
 #endif //_HSPSCANNER_FSM_H_

+ 196 - 0
Module/mod_HSPScanner/HSPScanner_client_g.h

@@ -513,6 +513,202 @@ public:
 		return ret;
 	}
 
+	ErrorCodeEnum StartPreviewJS(HSPScannerService_StartPreviewJS_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		if (m_context.checkEmpty())
+		{
+			m_context.AutoGenerate();
+			DbgToBeidou(m_context, m_pEntityBase != NULL ? m_pEntityBase->GetEntityName() : "")();
+			m_context = m_context.upgradeLink();
+		}
+		auto ret = pFunc->AsyncRequest(HSPScannerService_Method_StartPreviewJS, HSPScannerService_MethodSignature_StartPreviewJS, Buf, spAsyncWait, m_context, dwTimeout);
+		m_context.clear();
+		return ret;
+	}
+	ErrorCodeEnum StartPreviewJS(HSPScannerService_StartPreviewJS_Req &Req, HSPScannerService_StartPreviewJS_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = StartPreviewJS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum StartPreviewJS(HSPScannerService_StartPreviewJS_Req &Req, HSPScannerService_StartPreviewJS_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError, CSimpleString &str)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = StartPreviewJS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum StartPreviewJS(HSPScannerService_StartPreviewJS_Req &Req, HSPScannerService_StartPreviewJS_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = StartPreviewJS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			CSimpleString str;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
+	ErrorCodeEnum CancelPreviewJS(HSPScannerService_CancelPreviewJS_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		if (m_context.checkEmpty())
+		{
+			m_context.AutoGenerate();
+			DbgToBeidou(m_context, m_pEntityBase != NULL ? m_pEntityBase->GetEntityName() : "")();
+			m_context = m_context.upgradeLink();
+		}
+		auto ret = pFunc->AsyncRequest(HSPScannerService_Method_CancelPreviewJS, HSPScannerService_MethodSignature_CancelPreviewJS, Buf, spAsyncWait, m_context, dwTimeout);
+		m_context.clear();
+		return ret;
+	}
+	ErrorCodeEnum CancelPreviewJS(HSPScannerService_CancelPreviewJS_Req &Req, HSPScannerService_CancelPreviewJS_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = CancelPreviewJS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum CancelPreviewJS(HSPScannerService_CancelPreviewJS_Req &Req, HSPScannerService_CancelPreviewJS_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError, CSimpleString &str)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = CancelPreviewJS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum CancelPreviewJS(HSPScannerService_CancelPreviewJS_Req &Req, HSPScannerService_CancelPreviewJS_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = CancelPreviewJS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			CSimpleString str;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
+	ErrorCodeEnum ScanImageJS(HSPScannerService_ScanImageJS_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		if (m_context.checkEmpty())
+		{
+			m_context.AutoGenerate();
+			DbgToBeidou(m_context, m_pEntityBase != NULL ? m_pEntityBase->GetEntityName() : "")();
+			m_context = m_context.upgradeLink();
+		}
+		auto ret = pFunc->AsyncRequest(HSPScannerService_Method_ScanImageJS, HSPScannerService_MethodSignature_ScanImageJS, Buf, spAsyncWait, m_context, dwTimeout);
+		m_context.clear();
+		return ret;
+	}
+	ErrorCodeEnum ScanImageJS(HSPScannerService_ScanImageJS_Req &Req, HSPScannerService_ScanImageJS_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = ScanImageJS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum ScanImageJS(HSPScannerService_ScanImageJS_Req &Req, HSPScannerService_ScanImageJS_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError, CSimpleString &str)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = ScanImageJS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum ScanImageJS(HSPScannerService_ScanImageJS_Req &Req, HSPScannerService_ScanImageJS_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = ScanImageJS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			CSimpleString str;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
+	ErrorCodeEnum SetParamJS(HSPScannerService_SetParamJS_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		if (m_context.checkEmpty())
+		{
+			m_context.AutoGenerate();
+			DbgToBeidou(m_context, m_pEntityBase != NULL ? m_pEntityBase->GetEntityName() : "")();
+			m_context = m_context.upgradeLink();
+		}
+		auto ret = pFunc->AsyncRequest(HSPScannerService_Method_SetParamJS, HSPScannerService_MethodSignature_SetParamJS, Buf, spAsyncWait, m_context, dwTimeout);
+		m_context.clear();
+		return ret;
+	}
+	ErrorCodeEnum SetParamJS(HSPScannerService_SetParamJS_Req &Req, HSPScannerService_SetParamJS_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = SetParamJS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum SetParamJS(HSPScannerService_SetParamJS_Req &Req, HSPScannerService_SetParamJS_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError, CSimpleString &str)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = SetParamJS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum SetParamJS(HSPScannerService_SetParamJS_Req &Req, HSPScannerService_SetParamJS_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = SetParamJS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			CSimpleString str;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
 
 	bool SafeDelete()
 	{

+ 110 - 0
Module/mod_HSPScanner/HSPScanner_def_g.h

@@ -22,6 +22,10 @@ namespace HSPScanner {
 #define HSPScannerService_Method_GetDevStatus 7
 #define HSPScannerService_Method_GetDevInfo 65535
 #define HSPScannerService_Method_Exit 8
+#define HSPScannerService_Method_StartPreviewJS 9
+#define HSPScannerService_Method_CancelPreviewJS 10
+#define HSPScannerService_Method_ScanImageJS 11
+#define HSPScannerService_Method_SetParamJS 12
 
 #define HSPScannerService_MethodSignature_StartPreview 220854261
 #define HSPScannerService_MethodSignature_CancelPreview 961536349
@@ -33,6 +37,10 @@ namespace HSPScanner {
 #define HSPScannerService_MethodSignature_GetDevStatus -321104988
 #define HSPScannerService_MethodSignature_GetDevInfo 296205965
 #define HSPScannerService_MethodSignature_Exit -1158854104
+#define HSPScannerService_MethodSignature_StartPreviewJS -364206811
+#define HSPScannerService_MethodSignature_CancelPreviewJS -771733850
+#define HSPScannerService_MethodSignature_ScanImageJS -719300712
+#define HSPScannerService_MethodSignature_SetParamJS 1301088866
 
 #define HSPScannerService_LogCode_StartPreview "QLR040221700"
 #define HSPScannerService_LogCode_CancelPreview "QLR040221701"
@@ -44,6 +52,10 @@ namespace HSPScanner {
 #define HSPScannerService_LogCode_GetDevStatus "QLR040221707"
 #define HSPScannerService_LogCode_GetDevInfo "QLR040221799"
 #define HSPScannerService_LogCode_Exit "QLR040221708"
+#define HSPScannerService_LogCode_StartPreviewJS "QLR040221709"
+#define HSPScannerService_LogCode_CancelPreviewJS "QLR040221710"
+#define HSPScannerService_LogCode_ScanImageJS "QLR040221711"
+#define HSPScannerService_LogCode_SetParamJS "QLR040221712"
 
 struct HSPScannerService_StartPreview_Req
 {
@@ -276,6 +288,104 @@ struct HSPScannerService_Exit_Info
 
 };
 
+struct HSPScannerService_StartPreviewJS_Req
+{
+	short rotate;
+	short scan;
+	short color;
+	short pos;
+	short pos_x;
+	short pos_y;
+	short pos_w;
+	int reserved1;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & rotate & scan & color & pos & pos_x & pos_y & pos_w & reserved1;
+	}
+
+};
+
+struct HSPScannerService_StartPreviewJS_Ans
+{
+
+	void Serialize(SpBuffer &Buf)
+	{
+	}
+
+};
+
+struct HSPScannerService_CancelPreviewJS_Req
+{
+	bool hide;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & hide;
+	}
+
+};
+
+struct HSPScannerService_CancelPreviewJS_Ans
+{
+
+	void Serialize(SpBuffer &Buf)
+	{
+	}
+
+};
+
+struct HSPScannerService_ScanImageJS_Req
+{
+	bool hide;
+	int compress;
+	int reserved1;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & hide & compress & reserved1;
+	}
+
+};
+
+struct HSPScannerService_ScanImageJS_Ans
+{
+	CBlob imageData;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & imageData;
+	}
+
+};
+
+struct HSPScannerService_SetParamJS_Req
+{
+	short rotate;
+	short scan;
+	short color;
+	short pos;
+	short pos_x;
+	short pos_y;
+	short pos_w;
+	int reserved1;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & rotate & scan & color & pos & pos_x & pos_y & pos_w & reserved1;
+	}
+
+};
+
+struct HSPScannerService_SetParamJS_Ans
+{
+
+	void Serialize(SpBuffer &Buf)
+	{
+	}
+
+};
+
 
 ///////////////////////////
 

+ 108 - 0
Module/mod_HSPScanner/HSPScanner_server_g.h

@@ -100,6 +100,34 @@ public:
 				Error = Error_MethodSignatureFailed;
 			}
 			break;
+		case HSPScannerService_Method_StartPreviewJS:
+			if (dwSignature == HSPScannerService_MethodSignature_StartPreviewJS) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case HSPScannerService_Method_CancelPreviewJS:
+			if (dwSignature == HSPScannerService_MethodSignature_CancelPreviewJS) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case HSPScannerService_Method_ScanImageJS:
+			if (dwSignature == HSPScannerService_MethodSignature_ScanImageJS) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case HSPScannerService_Method_SetParamJS:
+			if (dwSignature == HSPScannerService_MethodSignature_SetParamJS) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
 		default:
 			Error = Error_MethodNotFound;
 			break;
@@ -161,6 +189,26 @@ public:
 				Error = Error_MethodSignatureFailed;
 			}
 			break;
+		case HSPScannerService_Method_StartPreviewJS:
+			if (dwSignature != HSPScannerService_MethodSignature_StartPreviewJS) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case HSPScannerService_Method_CancelPreviewJS:
+			if (dwSignature != HSPScannerService_MethodSignature_CancelPreviewJS) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case HSPScannerService_Method_ScanImageJS:
+			if (dwSignature != HSPScannerService_MethodSignature_ScanImageJS) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case HSPScannerService_Method_SetParamJS:
+			if (dwSignature != HSPScannerService_MethodSignature_SetParamJS) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
 		default:
 			Error = Error_MethodNotFound;
 			break;
@@ -218,6 +266,26 @@ public:
 	/// override by user
 	}
 
+	virtual void Handle_StartPreviewJS(SpReqAnsContext<HSPScannerService_StartPreviewJS_Req, HSPScannerService_StartPreviewJS_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
+	virtual void Handle_CancelPreviewJS(SpReqAnsContext<HSPScannerService_CancelPreviewJS_Req, HSPScannerService_CancelPreviewJS_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
+	virtual void Handle_ScanImageJS(SpReqAnsContext<HSPScannerService_ScanImageJS_Req, HSPScannerService_ScanImageJS_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
+	virtual void Handle_SetParamJS(SpReqAnsContext<HSPScannerService_SetParamJS_Req, HSPScannerService_SetParamJS_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
 	virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
 	{
 		CAutoBuffer Buf;
@@ -334,6 +402,46 @@ public:
 						Handle_Exit(ctx);
 					}
 					break;
+				case HSPScannerService_Method_StartPreviewJS:
+					{
+						SpReqAnsContext<HSPScannerService_StartPreviewJS_Req,HSPScannerService_StartPreviewJS_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<HSPScannerService_StartPreviewJS_Req,HSPScannerService_StartPreviewJS_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						pTransactionContext->GetLinkContext(ctx->link);
+						EntityResource::setLink(ctx->link);
+						Handle_StartPreviewJS(ctx);
+					}
+					break;
+				case HSPScannerService_Method_CancelPreviewJS:
+					{
+						SpReqAnsContext<HSPScannerService_CancelPreviewJS_Req,HSPScannerService_CancelPreviewJS_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<HSPScannerService_CancelPreviewJS_Req,HSPScannerService_CancelPreviewJS_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						pTransactionContext->GetLinkContext(ctx->link);
+						EntityResource::setLink(ctx->link);
+						Handle_CancelPreviewJS(ctx);
+					}
+					break;
+				case HSPScannerService_Method_ScanImageJS:
+					{
+						SpReqAnsContext<HSPScannerService_ScanImageJS_Req,HSPScannerService_ScanImageJS_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<HSPScannerService_ScanImageJS_Req,HSPScannerService_ScanImageJS_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						pTransactionContext->GetLinkContext(ctx->link);
+						EntityResource::setLink(ctx->link);
+						Handle_ScanImageJS(ctx);
+					}
+					break;
+				case HSPScannerService_Method_SetParamJS:
+					{
+						SpReqAnsContext<HSPScannerService_SetParamJS_Req,HSPScannerService_SetParamJS_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<HSPScannerService_SetParamJS_Req,HSPScannerService_SetParamJS_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						pTransactionContext->GetLinkContext(ctx->link);
+						EntityResource::setLink(ctx->link);
+						Handle_SetParamJS(ctx);
+					}
+					break;
 				default:
 					assert(0);
 					break;

+ 24 - 0
Module/mod_HSPScanner/mod_HSPScanner.cpp

@@ -73,6 +73,30 @@ void CHSPScannerServerSession::Handle_Exit(SpOnewayCallContext<HSPScannerService
 	m_pEntity->Exit(ctx);
 }
 
+void CHSPScannerServerSession::Handle_StartPreviewJS(SpReqAnsContext<HSPScannerService_StartPreviewJS_Req, HSPScannerService_StartPreviewJS_Ans>::Pointer ctx)
+{
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_StartPreviewJS).setAPI(__FUNCTION__)(__FUNCTION__);
+	m_pEntity->StartPreviewJS(ctx);
+}
+
+void CHSPScannerServerSession::Handle_CancelPreviewJS(SpReqAnsContext<HSPScannerService_CancelPreviewJS_Req, HSPScannerService_CancelPreviewJS_Ans>::Pointer ctx)
+{
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_CancelPreviewJS).setAPI(__FUNCTION__)(__FUNCTION__);
+	m_pEntity->CancelPreviewJS(ctx);
+}
+
+void CHSPScannerServerSession::Handle_ScanImageJS(SpReqAnsContext<HSPScannerService_ScanImageJS_Req, HSPScannerService_ScanImageJS_Ans>::Pointer ctx)
+{
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_ScanImageJS).setAPI(__FUNCTION__)(__FUNCTION__);
+	m_pEntity->ScanImageJS(ctx);
+}
+
+void CHSPScannerServerSession::Handle_SetParamJS(SpReqAnsContext<HSPScannerService_SetParamJS_Req, HSPScannerService_SetParamJS_Ans>::Pointer ctx)
+{
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_SetParamJS).setAPI(__FUNCTION__)(__FUNCTION__);
+	m_pEntity->SetParamJS(ctx);
+}
+
 void CHSPScannerEntity::OnSysVarEvent(const char* pszKey, const char* pszValue, const char* pszOldValue, const char* pszEntityName)
 {
 	if ((_strnicmp(pszKey, "UIState", strlen("UIState")) == 0))

+ 25 - 0
Module/mod_HSPScanner/mod_HSPScanner.h

@@ -51,6 +51,11 @@ public:
 
 	virtual void Handle_Exit(SpOnewayCallContext<HSPScannerService_Exit_Info>::Pointer ctx);
 
+	virtual void Handle_StartPreviewJS(SpReqAnsContext<HSPScannerService_StartPreviewJS_Req, HSPScannerService_StartPreviewJS_Ans>::Pointer ctx);
+	virtual void Handle_CancelPreviewJS(SpReqAnsContext<HSPScannerService_CancelPreviewJS_Req, HSPScannerService_CancelPreviewJS_Ans>::Pointer ctx);
+	virtual void Handle_ScanImageJS(SpReqAnsContext<HSPScannerService_ScanImageJS_Req, HSPScannerService_ScanImageJS_Ans>::Pointer ctx);
+	virtual void Handle_SetParamJS(SpReqAnsContext<HSPScannerService_SetParamJS_Req, HSPScannerService_SetParamJS_Ans>::Pointer ctx);
+
 private:
 	CHSPScannerEntity *m_pEntity;
 };
@@ -184,6 +189,26 @@ public:
 		m_fsm.PostEventFIFO(pEvent);
 	}
 
+	void StartPreviewJS(SpReqAnsContext<HSPScannerService_StartPreviewJS_Req, HSPScannerService_StartPreviewJS_Ans>::Pointer ctx)
+	{
+		ctx->Answer(Error_NotImpl);
+	}
+
+	void CancelPreviewJS(SpReqAnsContext<HSPScannerService_CancelPreviewJS_Req, HSPScannerService_CancelPreviewJS_Ans>::Pointer ctx)
+	{
+		ctx->Answer(Error_NotImpl);
+	}
+
+	void ScanImageJS(SpReqAnsContext<HSPScannerService_ScanImageJS_Req, HSPScannerService_ScanImageJS_Ans>::Pointer ctx)
+	{
+		ctx->Answer(Error_NotImpl);
+	}
+
+	void SetParamJS(SpReqAnsContext<HSPScannerService_SetParamJS_Req, HSPScannerService_SetParamJS_Ans>::Pointer ctx)
+	{
+		ctx->Answer(Error_NotImpl);
+	}
+
 	void OnSelfTest(EntityTestEnum eTestType, CSmartPointer<ITransactionContext> pTransactionContext)
 	{
 		m_fsm.SelfTest(eTestType, pTransactionContext);

Some files were not shown because too many files changed in this diff