浏览代码

Z991239-6270 #comment 高拍仪取消预览兼容

80374374 4 月之前
父节点
当前提交
d58414c39f

+ 1 - 1
Module/mod_HSPScanner/HSPSCanner_UserErrorCode.h

@@ -17,7 +17,7 @@
 #define HSPScanner_UserErrorCode_READ_IMAGE_FILE_FAILED			0x21700201
 #define HSPScanner_UserErrorCode_LOAD_DLLFILE_NOTEIXT			0x21700202
 #define HSPScanner_UserErrorCode_LOAD_DLLFILE_FAILED			0x21700203
-#define HSPScanner_UserErrorCode_GET_CDC_ADDR_FAILED			0x21700204
+#define HSPScanner_UserErrorCode_DuplicateCancelPreview			0x21700204
 #define HSPScanner_UserErrorCode_GET_RDC_ADDR_FAILED			0x21700205
 #define HSPScanner_UserErrorCode_CLEAR_RESOURCE_FAILED			0x21700206
 #define HSPScanner_UserErrorCode_UPLOAD_VENDORINFO				0x21700207

+ 55 - 6
Module/mod_HSPScanner/HSPScannerFSM.cpp

@@ -153,7 +153,7 @@ CHSPScannerFSM::CHSPScannerFSM(void)
 	m_nSrcState(sIdle),
 	m_desiredAction(USER_EVT_QUIT),
 	dwLastUserCode(0),
-	m_dwMaxImageSize(500), m_lightOn(false)
+	m_dwMaxImageSize(500), m_lightOn(false), m_dupFlag4ExitCancel(false)
 {
 	HARDWARE_ENTITY_RESET_ENTITYID(m_entCode, 0x217);
 }
@@ -371,12 +371,12 @@ unsigned int CHSPScannerFSM::s0_Idle_on_event(FSMEvent* e)
 
 void CHSPScannerFSM::s1_Preview_on_entry()
 {
-
+	m_dupFlag4ExitCancel = false;
 }
 
 void CHSPScannerFSM::s1_Preview_on_exit()
 {
-
+	m_dupFlag4ExitCancel = false;
 }
 
 unsigned int CHSPScannerFSM::s1_Preview_on_event(FSMEvent* e)
@@ -410,20 +410,29 @@ unsigned int CHSPScannerFSM::s1_Preview_on_event(FSMEvent* e)
 		JS::CancelPreviewTask* pTask = new JS::CancelPreviewTask(this);
 		JS::CancelPreviewEvent* pEvt = dynamic_cast<JS::CancelPreviewEvent*>(e);
 		pTask->SetContext(pEvt->m_ctx);
+		if (!pEvt->m_ctx->Req.hide) {
+			m_dupFlag4ExitCancel = true;
+		}
 		GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
 		e->SetHandled();
 	}
 	break;
 	case USER_EVT_CANCELPREVIEW_JS_DONE:
 	{
+		m_dupFlag4ExitCancel = false;
 		if (e->param1 == 0) {//取消预览成功
 			if (e->param2 == 1) uRet = 2; //仅仅是隐藏
-			else uRet = 1;
+			else {
+				uRet = 1; 
+			}
 			m_nFatalTimes = 0;
 		}
 		else {
 			uRet = 3;
-			if (e->param2 == 1) m_desiredAction = USER_EVT_HIDEPREVIEW; else m_desiredAction = USER_EVT_STOPPREVIEW;
+			if (e->param2 == 1) { m_desiredAction = USER_EVT_HIDEPREVIEW; }
+			else {
+				m_desiredAction = USER_EVT_STOPPREVIEW;
+			}
 			if (IsDevConnected() == 0) {
 				PostEventFIFO(new FSMEvent(USER_EVT_DISCONNECT));
 			}
@@ -485,12 +494,16 @@ unsigned int CHSPScannerFSM::s1_Preview_on_event(FSMEvent* e)
 			StopPreviewTask* pTask = new StopPreviewTask(this);
 			StopPreviewEvent* pEvt = dynamic_cast<StopPreviewEvent*>(e);
 			pTask->SetContext(pEvt->m_ctx);
+			if (!pEvt->m_ctx->Req.bOnlyHide) {
+				m_dupFlag4ExitCancel = true;
+			}
 			GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
 		}
 		e->SetHandled();
 		break;
 	case USER_EVT_STOPPREVIEW_FINISHED:
 		{
+			m_dupFlag4ExitCancel = false;
 			uRet = e->param1;
 			if((uRet == 0 || uRet == 4) && ++m_nFatalTimes <= MAX_ERROR_TIMES)
 			{
@@ -506,6 +519,7 @@ unsigned int CHSPScannerFSM::s1_Preview_on_event(FSMEvent* e)
 			{
 				PostEventFIFO(new FSMEvent(USER_EVT_DISCONNECT));
 			}
+			//fault
 			else if(uRet == 0) {
 				m_desiredAction = USER_EVT_STOPPREVIEW;
 			}
@@ -583,7 +597,19 @@ unsigned int CHSPScannerFSM::s1_Preview_on_event(FSMEvent* e)
 		}
 		e->SetHandled();
 		break;
+	case EVT_MAINPAGE_DISPLAY:
+	case USER_EVT_EXIT:
+		{
+			e->SetHandled();
+			if (m_dupFlag4ExitCancel) {
+				LogWarn(Severity_Low, Error_Debug, HSPScanner_UserErrorCode_DuplicateCancelPreview, CSimpleStringA::Format("%s::recv %s while CancelPreviewing", __FUNCTION__, EvtTypeToString(e->iEvt)));
+				uRet = 1;
+				//TODO: need to settimer ??  [Gifur@202565]
+			}
+		}
+		break;
 	}
+
 	return uRet;
 }
 
@@ -1118,11 +1144,12 @@ unsigned int CHSPScannerFSM::s5_DeviceOff_on_event(FSMEvent* e)
 
 void CHSPScannerFSM::s6_HidePreview_on_entry()
 {
+	m_dupFlag4ExitCancel = false;
 }
 
 void CHSPScannerFSM::s6_HidePreview_on_exit()
 {
-
+	m_dupFlag4ExitCancel = false;
 }
 
 unsigned int CHSPScannerFSM::s6_HidePreview_on_event(FSMEvent* e)
@@ -1160,6 +1187,7 @@ unsigned int CHSPScannerFSM::s6_HidePreview_on_event(FSMEvent* e)
 			pEvt->m_ctx->Answer(Error_Succeed);
 		}
 		else {
+			m_dupFlag4ExitCancel = true;
 			JS::CancelPreviewTask* pTask = new JS::CancelPreviewTask(this);
 			pTask->SetContext(pEvt->m_ctx);
 			GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
@@ -1173,6 +1201,13 @@ unsigned int CHSPScannerFSM::s6_HidePreview_on_event(FSMEvent* e)
 		e->SetHandled();
 	}
 	break;
+	case USER_EVT_CANCELPREVIEW_JS_DONE:
+	{
+		m_dupFlag4ExitCancel = false;
+		uRet = e->param1;
+		e->SetHandled();
+	}
+	break;
 	case USER_EVT_SCANIMAGE_JS:
 	{
 		JS::ScanImageTask* pTask = new JS::ScanImageTask(this);
@@ -1231,6 +1266,7 @@ unsigned int CHSPScannerFSM::s6_HidePreview_on_event(FSMEvent* e)
 			StopPreviewEvent* pEvt = dynamic_cast<StopPreviewEvent*>(e);
 			if(!pEvt->m_ctx->Req.bOnlyHide)
 			{//业务在s6状态仅能进行彻底取消预览的操作
+				m_dupFlag4ExitCancel = true;
 				StopPreviewTask* pTask = new StopPreviewTask(this);
 				pTask->SetContext(pEvt->m_ctx);
 				GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
@@ -1240,6 +1276,7 @@ unsigned int CHSPScannerFSM::s6_HidePreview_on_event(FSMEvent* e)
 		break;
 	case USER_EVT_STOPPREVIEW_FINISHED:
 		{
+			m_dupFlag4ExitCancel = false;
 			uRet = e->param1;
 			if (uRet == 0 && ++m_nFatalTimes < MAX_ERROR_TIMES) {
 				uRet = 3;
@@ -1289,7 +1326,19 @@ unsigned int CHSPScannerFSM::s6_HidePreview_on_event(FSMEvent* e)
 		}
 		e->SetHandled();
 		break;
+	case EVT_MAINPAGE_DISPLAY:
+	case USER_EVT_EXIT:
+		{
+			e->SetHandled();
+			if (m_dupFlag4ExitCancel) {
+				LogWarn(Severity_Low, Error_Debug, HSPScanner_UserErrorCode_DuplicateCancelPreview, CSimpleStringA::Format("%s::recv %s while CancelPreviewing", __FUNCTION__, EvtTypeToString(e->iEvt)));
+				uRet = 1;
+				//TODO: need to settimer ??  [Gifur@202565]
+			}
+		}
+		break;
 	}
+
 	return uRet;
 }
 

+ 9 - 11
Module/mod_HSPScanner/HSPScannerFSM.h

@@ -146,8 +146,6 @@ public:
 		FSM_RULE_ENTRY(sPreview, sFault, USER_EVT_STOPPREVIEW_FINISHED, 0)
 		FSM_RULE_ENTRY(sPreview, sFault, USER_EVT_STOPPREVIEW_FINISHED, 4)
 
-		// Try sHidePreview state --Josephus at 10:10:05 2016/11/22
-		//FSM_RULE_ENTRY(sPreview, sIdle, USER_EVT_STOPPREVIEW_FINISHED, 1) //隐藏
 		FSM_RULE_ENTRY(sPreview, sHidePreview, USER_EVT_STOPPREVIEW_FINISHED, 1)
 
 		FSM_RULE_ENTRY(sPreview, sIdle, USER_EVT_STOPPREVIEW_FINISHED, 2) //关闭预览
@@ -187,15 +185,14 @@ public:
 		FSM_RULE_ENTRY(sHidePreview, sHidePreview, USER_EVT_STOPPREVIEW_FINISHED, 3) //错误还不足够严重,停留在当前状态
 
 
-		FSM_RULE_ENTRY_ANY(sPreview, sExit, USER_EVT_EXIT)
+		FSM_RULE_ENTRY(sPreview, sExit, USER_EVT_EXIT, 0)
 		FSM_RULE_ENTRY_ANY(sProperty, sExit, USER_EVT_EXIT)
-		FSM_RULE_ENTRY_ANY(sHidePreview, sExit, USER_EVT_EXIT)
+		FSM_RULE_ENTRY(sHidePreview, sExit, USER_EVT_EXIT, 0)
 		FSM_RULE_ENTRY(sExit, sIdle, USER_EVT_EXIT_FINISHED, 0)
-		FSM_RULE_ENTRY(sExit, sPreview, USER_EVT_EXIT_FINISHED, 2)
-		FSM_RULE_ENTRY(sExit, sHidePreview, USER_EVT_EXIT_FINISHED, 3)
-		FSM_RULE_ENTRY(sExit, sFault_Offline, USER_EVT_EXIT_FINISHED, 4)
-
 		FSM_RULE_ENTRY(sExit, sFault, USER_EVT_EXIT_FINISHED, 1)
+		FSM_RULE_ENTRY(sExit, sPreview, USER_EVT_EXIT_FINISHED, 2) //TODO: remove it  [Gifur@202565]
+		FSM_RULE_ENTRY(sExit, sHidePreview, USER_EVT_EXIT_FINISHED, 3) //TODO: remove it  [Gifur@202565]
+		FSM_RULE_ENTRY(sExit, sFault_Offline, USER_EVT_EXIT_FINISHED, 4) //TODO: remove it  [Gifur@202565]
 
 		FSM_RULE_ENTRY_ANY(sIdle, sInit, USER_EVT_INIT)
 		FSM_RULE_ENTRY_ANY(sIdle, sFault, USER_EVT_GOTOHELL)
@@ -209,15 +206,15 @@ public:
 
 		FSM_RULE_ENTRY(sPreview, sIdle, USER_EVT_CANCELPREVIEW_JS_DONE, 1) //取消预览成功
 		FSM_RULE_ENTRY(sPreview, sHidePreview, USER_EVT_CANCELPREVIEW_JS_DONE, 2) //隐藏成功
-		FSM_RULE_ENTRY(sPreview, sFault, USER_EVT_CANCELPREVIEW_JS_DONE, 4)
+		FSM_RULE_ENTRY(sPreview, sFault, USER_EVT_CANCELPREVIEW_JS_DONE, 4)//TODO: remove it  [Gifur@202565]
 
 		FSM_RULE_ENTRY(sHidePreview, sIdle, USER_EVT_CANCELPREVIEW_JS_DONE, 0)
 
 		FSM_RULE_ENTRY(sPreview, sHidePreview, USER_EVT_SCANIMAGE_JS_DONE, 2)
 		FSM_RULE_ENTRY(sPreview, sFault, USER_EVT_SCANIMAGE_JS_DONE, 4)
 
-		FSM_RULE_ENTRY_ANY(sPreview, sExit, EVT_MAINPAGE_DISPLAY)
-		FSM_RULE_ENTRY_ANY(sHidePreview, sExit, EVT_MAINPAGE_DISPLAY)
+		FSM_RULE_ENTRY(sPreview, sExit, EVT_MAINPAGE_DISPLAY, 0)
+		FSM_RULE_ENTRY(sHidePreview, sExit, EVT_MAINPAGE_DISPLAY, 0)
 		/** JS Compoent Done [Gifur@20241114]*/
 
 		FSM_RULE_ENTRY_ANY(sInit, sIdle, USER_EVT_INIT_FINISHED)
@@ -341,6 +338,7 @@ private:
 	DWORD dwLastUserCode;
 	DWORD m_dwMaxImageSize;
 	bool m_lightOn;
+	bool m_dupFlag4ExitCancel;
 
 private: