|
@@ -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;
|
|
|
}
|
|
|
|