|
@@ -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_
|