|
@@ -34,50 +34,55 @@ const char* EvtTypeToString(int nEvtType)
|
|
|
switch (nEvtType)
|
|
|
{
|
|
|
T_STRINGY(USER_EVT_STARTPREVIEW)
|
|
|
- T_STRINGY(USER_EVT_STARTPREVIEW_FINISHED)
|
|
|
- T_STRINGY(USER_EVT_SETPROPERTYINVIEW_FINISHED)
|
|
|
+ T_STRINGY(USER_EVT_STARTPREVIEW_FINISHED)
|
|
|
+ T_STRINGY(USER_EVT_SETPROPERTYINVIEW_FINISHED)
|
|
|
|
|
|
- T_STRINGY(USER_EVT_STARTPREVIEW_JS)
|
|
|
- T_STRINGY(USER_EVT_STARTPREVIEW_JS_DONE)
|
|
|
+ T_STRINGY(USER_EVT_STARTPREVIEW_JS)
|
|
|
+ T_STRINGY(USER_EVT_STARTPREVIEW_JS_DONE)
|
|
|
|
|
|
- T_STRINGY(USER_EVT_CANCELPREVIEW_JS)
|
|
|
- T_STRINGY(USER_EVT_CANCELPREVIEW_JS_DONE)
|
|
|
+ T_STRINGY(USER_EVT_CANCELPREVIEW_JS)
|
|
|
+ T_STRINGY(USER_EVT_CANCELPREVIEW_JS_DONE)
|
|
|
|
|
|
- T_STRINGY(USER_EVT_SCANIMAGE_JS)
|
|
|
- T_STRINGY(USER_EVT_SCANIMAGE_JS_DONE)
|
|
|
+ T_STRINGY(USER_EVT_SCANIMAGE_JS)
|
|
|
+ T_STRINGY(USER_EVT_SCANIMAGE_JS_DONE)
|
|
|
|
|
|
- T_STRINGY(USER_EVT_SETPARAM_JS)
|
|
|
+ T_STRINGY(USER_EVT_SETPARAM_JS)
|
|
|
|
|
|
- T_STRINGY(USER_EVT_STOPPREVIEW)
|
|
|
- T_STRINGY(USER_EVT_HIDEPREVIEW)
|
|
|
- T_STRINGY(USER_EVT_STOPPREVIEW_FINISHED)
|
|
|
+ T_STRINGY(USER_EVT_STOPPREVIEW)
|
|
|
+ T_STRINGY(USER_EVT_HIDEPREVIEW)
|
|
|
+ T_STRINGY(USER_EVT_STOPPREVIEW_FINISHED)
|
|
|
|
|
|
- T_STRINGY(USER_EVT_SETWINPOS)
|
|
|
- T_STRINGY(USER_EVT_SETWINPOSFINISHED)
|
|
|
+ T_STRINGY(USER_EVT_SETWINPOS)
|
|
|
+ T_STRINGY(USER_EVT_SETWINPOSFINISHED)
|
|
|
|
|
|
- T_STRINGY(USER_EVT_SHOWPROPERTY)
|
|
|
- T_STRINGY(USER_EVT_SHOWPROPERTY_FINISHED)
|
|
|
+ T_STRINGY(USER_EVT_SCANIMAGE)
|
|
|
+ T_STRINGY(USER_EVT_SCANIMAGE_EX)
|
|
|
+ T_STRINGY(USER_EVT_SCANIMAGEFINISHED)
|
|
|
|
|
|
- T_STRINGY(USER_EVT_SETPROPERTY)
|
|
|
- T_STRINGY(USER_EVT_SETPROPERTY_FINISHED)
|
|
|
+ T_STRINGY(USER_EVT_SHOWPROPERTY)
|
|
|
+ T_STRINGY(USER_EVT_SHOWPROPERTY_FINISHED)
|
|
|
|
|
|
- T_STRINGY(USER_EVT_GETSTATUS)
|
|
|
- T_STRINGY(USER_EVT_GETINFO)
|
|
|
+ T_STRINGY(USER_EVT_SETPROPERTY)
|
|
|
+ T_STRINGY(USER_EVT_SETPROPERTY_FINISHED)
|
|
|
|
|
|
- T_STRINGY(USER_EVT_DISCONNECT)
|
|
|
- T_STRINGY(USER_EVT_RESET)
|
|
|
- T_STRINGY(USER_EVT_EXIT)
|
|
|
- T_STRINGY(USER_EVT_EXIT_FINISHED)
|
|
|
+ T_STRINGY(USER_EVT_GETSTATUS)
|
|
|
+ T_STRINGY(USER_EVT_GETINFO)
|
|
|
|
|
|
- T_STRINGY(USER_EVT_GOTOHELL)
|
|
|
- T_STRINGY(USER_EVT_QUIT)
|
|
|
- T_STRINGY(USER_EVT_INIT)
|
|
|
- T_STRINGY(USER_EVT_INIT_FINISHED)
|
|
|
+ T_STRINGY(USER_EVT_DISCONNECT)
|
|
|
|
|
|
- T_STRINGY(EVT_INTERNAL)
|
|
|
- T_STRINGY(EVT_TIMER)
|
|
|
- T_STRINGY(EVT_MAINPAGE_DISPLAY)
|
|
|
- T_STRINGY(EVT_USER)
|
|
|
+ T_STRINGY(USER_EVT_RESET)
|
|
|
+ T_STRINGY(USER_EVT_EXIT)
|
|
|
+ T_STRINGY(USER_EVT_EXIT_FINISHED)
|
|
|
+
|
|
|
+ T_STRINGY(USER_EVT_GOTOHELL)
|
|
|
+ T_STRINGY(USER_EVT_QUIT)
|
|
|
+ T_STRINGY(USER_EVT_INIT)
|
|
|
+ T_STRINGY(USER_EVT_INIT_FINISHED)
|
|
|
+
|
|
|
+ T_STRINGY(EVT_INTERNAL)
|
|
|
+ T_STRINGY(EVT_TIMER)
|
|
|
+ T_STRINGY(EVT_MAINPAGE_DISPLAY)
|
|
|
+ T_STRINGY(EVT_USER)
|
|
|
default:
|
|
|
return "Unknown EventType";
|
|
|
break;
|
|
@@ -128,18 +133,18 @@ CSimpleStringA CombineJsonContext4SetPreview(bool bOpen, const char* szMessage =
|
|
|
CSimpleStringA result(true);
|
|
|
if (szMessage == NULL || strlen(szMessage) == 0) {
|
|
|
if (bOpen) {
|
|
|
- result = CSimpleStringA::Format("{\"PreviewSwitch\": ON}");
|
|
|
+ result = CSimpleStringA::Format("{\"PreviewSwitch\": \"ON\"}");
|
|
|
}
|
|
|
else {
|
|
|
- result = CSimpleStringA::Format("{\"PreviewSwitch\": OFF}");
|
|
|
+ result = CSimpleStringA::Format("{\"PreviewSwitch\": \"OFF\"}");
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
if (bOpen) {
|
|
|
- result = CSimpleStringA::Format("{\"addition\": \"%s\", \"PreviewSwitch\": ON}", szMessage);
|
|
|
+ result = CSimpleStringA::Format("{\"addition\": \"%s\", \"PreviewSwitch\": \"ON\"}", szMessage);
|
|
|
}
|
|
|
else {
|
|
|
- result = CSimpleStringA::Format("{\"addition\": \"%s\", \"PreviewSwitch\": OFF}", szMessage);
|
|
|
+ result = CSimpleStringA::Format("{\"addition\": \"%s\", \"PreviewSwitch\": \"OFF\"}", szMessage);
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
@@ -184,7 +189,6 @@ ErrorCodeEnum CHSPScannerFSM::OnInit()
|
|
|
}
|
|
|
else {
|
|
|
FulfillAdapterInfoFrom(pEntity->vendorLibInfo);
|
|
|
- LogWarn(Severity_Low, Error_Unexpect, HSPScanner_UserErrorCode_ROOT_INFO, (LPCTSTR)m_adapterInfo.adapterFilePath);
|
|
|
PostEventLIFO(new FSMEvent(USER_EVT_INIT));
|
|
|
}
|
|
|
return Error_Succeed;
|
|
@@ -212,7 +216,7 @@ void CHSPScannerFSM::s0_Idle_on_exit()
|
|
|
|
|
|
unsigned int CHSPScannerFSM::s0_Idle_on_event(FSMEvent* e)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("s0_Idle_on_event: %s(%d), %d.", EvtTypeToString(e->iEvt), e->iEvt, e->param1);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("s0_Idle_on_event: %s, %d.", EvtTypeToString(e->iEvt), e->param1);
|
|
|
unsigned int uRet = 0;
|
|
|
switch (e->iEvt)
|
|
|
{
|
|
@@ -301,6 +305,15 @@ unsigned int CHSPScannerFSM::s0_Idle_on_event(FSMEvent* e)
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
+ /** 根据日志查看在空闲状态偶尔会收到取消预览的请求,兼容处理之(参照JS改造) [Gifur@2025613]*/
|
|
|
+ case USER_EVT_STOPPREVIEW:
|
|
|
+ {
|
|
|
+ StopPreviewTask* pTask = new StopPreviewTask(this);
|
|
|
+ StopPreviewEvent* pEvt = dynamic_cast<StopPreviewEvent*>(e);
|
|
|
+ pEvt->m_ctx->Answer(Error_Succeed);
|
|
|
+ }
|
|
|
+ e->SetHandled();
|
|
|
+ break;
|
|
|
// Add after ST !!! --Josephus at 12:37:15 2016129
|
|
|
case USER_EVT_SETWINPOS:
|
|
|
{
|
|
@@ -347,7 +360,6 @@ unsigned int CHSPScannerFSM::s0_Idle_on_event(FSMEvent* e)
|
|
|
break;
|
|
|
case USER_EVT_INIT:
|
|
|
e->SetHandled();
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("To open device.");
|
|
|
break;
|
|
|
case EVT_MAINPAGE_DISPLAY:
|
|
|
case USER_EVT_EXIT:
|
|
@@ -358,12 +370,8 @@ unsigned int CHSPScannerFSM::s0_Idle_on_event(FSMEvent* e)
|
|
|
break;
|
|
|
case USER_EVT_GOTOHELL:
|
|
|
e->SetHandled();
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("HSPScaner init failed!");
|
|
|
break;
|
|
|
default:
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("%s::UnHandle event ! %s", __FUNCTION__, EvtTypeToString(e->iEvt));
|
|
|
- }
|
|
|
break;
|
|
|
}
|
|
|
return uRet;
|
|
@@ -602,9 +610,8 @@ unsigned int CHSPScannerFSM::s1_Preview_on_event(FSMEvent* e)
|
|
|
{
|
|
|
e->SetHandled();
|
|
|
if (m_dupFlag4ExitCancel) {
|
|
|
- LogWarn(Severity_Low, Error_Debug, HSPScanner_UserErrorCode_DuplicateCancelPreview, CSimpleStringA::Format("%s::recv %s while CancelPreviewing", __FUNCTION__, EvtTypeToString(e->iEvt)));
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s::recv %s while CancelPreviewing", __FUNCTION__, EvtTypeToString(e->iEvt));
|
|
|
uRet = 1;
|
|
|
- //TODO: need to settimer ?? [Gifur@202565]
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -659,18 +666,20 @@ unsigned int CHSPScannerFSM::s2_on_event(FSMEvent* e)
|
|
|
|
|
|
void CHSPScannerFSM::s3_Failed_on_entry()
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Enter s3_Failed");
|
|
|
if (GetDevInitFlag()) {
|
|
|
SetLastUserCode(HSPScanner_UserErrorCode_FSM_INVALID);
|
|
|
const int nStatus = IsDevConnected();
|
|
|
if (nStatus == 0) {
|
|
|
PostEventFIFO(new FSMEvent(USER_EVT_DISCONNECT));
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Enter s3_Failed by Disconnected");
|
|
|
}
|
|
|
else if (nStatus == 1) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Enter s3_Failed by Others' reason");
|
|
|
ScheduleTimer(RESET_TIMER_ID, MILLISECOND_TO_RESET / 6);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Enter s3_Failed by Device open failed");
|
|
|
SetDevState(DEVICE_STATUS_FAULT);
|
|
|
}
|
|
|
}
|
|
@@ -695,7 +704,9 @@ unsigned int CHSPScannerFSM::s3_Failed_on_event(FSMEvent* e)
|
|
|
case USER_EVT_STARTPREVIEW_JS:
|
|
|
{
|
|
|
JS::StartPreviewEvent* pEvt = dynamic_cast<JS::StartPreviewEvent*>(e);
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_StartPreviewJS).setResultCode(MapCode2RTAString(GetLastUserCode()))(GetDevInitFlag()? "高拍仪模块出现异常" : "高拍仪模块未打开");
|
|
|
+ if (GetDevInitFlag()) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_StartPreviewJS).setResultCode(MapCode2RTAString(GetLastUserCode()))("高拍仪模块出现异常");
|
|
|
+ }
|
|
|
pEvt->m_ctx->Answer(Error_DevNotAvailable, GetLastUserCode());
|
|
|
e->SetHandled();
|
|
|
}
|
|
@@ -703,7 +714,9 @@ unsigned int CHSPScannerFSM::s3_Failed_on_event(FSMEvent* e)
|
|
|
case USER_EVT_CANCELPREVIEW_JS:
|
|
|
{
|
|
|
JS::CancelPreviewEvent* pEvt = dynamic_cast<JS::CancelPreviewEvent*>(e);
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_CancelPreviewJS).setResultCode(MapCode2RTAString(GetLastUserCode()))(GetDevInitFlag() ? "高拍仪模块出现异常" : "高拍仪模块未打开");
|
|
|
+ if (GetDevInitFlag()) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_CancelPreviewJS).setResultCode(MapCode2RTAString(GetLastUserCode()))("高拍仪模块出现异常");
|
|
|
+ }
|
|
|
pEvt->m_ctx->Answer(Error_DevNotAvailable, GetLastUserCode());
|
|
|
e->SetHandled();
|
|
|
}
|
|
@@ -711,7 +724,9 @@ unsigned int CHSPScannerFSM::s3_Failed_on_event(FSMEvent* e)
|
|
|
case USER_EVT_SCANIMAGE_JS:
|
|
|
{
|
|
|
JS::ScanImageEvent* pEvt = dynamic_cast<JS::ScanImageEvent*>(e);
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_ScanImageJS).setResultCode(MapCode2RTAString(GetLastUserCode()))(GetDevInitFlag() ? "高拍仪模块出现异常" : "高拍仪模块未打开");
|
|
|
+ if (GetDevInitFlag()) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_ScanImageJS).setResultCode(MapCode2RTAString(GetLastUserCode()))("高拍仪模块出现异常");
|
|
|
+ }
|
|
|
pEvt->m_ctx->Answer(Error_DevNotAvailable, GetLastUserCode());
|
|
|
e->SetHandled();
|
|
|
}
|
|
@@ -726,7 +741,6 @@ unsigned int CHSPScannerFSM::s3_Failed_on_event(FSMEvent* e)
|
|
|
e->SetHandled();
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_SetParamJS).setResultCode(MapCode2RTAString(GetLastUserCode()))("高拍仪模块未打开");
|
|
|
pEvt->m_ctx->Answer(Error_DevNotAvailable, GetLastUserCode());
|
|
|
e->SetHandled();
|
|
|
}
|
|
@@ -737,7 +751,6 @@ unsigned int CHSPScannerFSM::s3_Failed_on_event(FSMEvent* e)
|
|
|
{
|
|
|
StartPreviewEvent* pEvt = dynamic_cast<StartPreviewEvent*>(e);
|
|
|
if (!GetDevInitFlag()) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_StartPreview).setResultCode(MapCode2RTAString(GetLastUserCode()))("高拍仪模块未打开");
|
|
|
pEvt->m_ctx->Answer(Error_DevNotAvailable, GetLastUserCode());
|
|
|
} else {
|
|
|
StartPreviewTask* pTask = new StartPreviewTask(this);
|
|
@@ -773,17 +786,16 @@ unsigned int CHSPScannerFSM::s3_Failed_on_event(FSMEvent* e)
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_CancelPreview).setAPI("DevAdapter::SetParam").setCostTime(ullEnd - ullStart)("HSPS_VIEW_HIDE");
|
|
|
} else {
|
|
|
//RTA2N0Q
|
|
|
- SetErrorAndLog(erroCode, MEC_DEVAPI_HSPSCANNER_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), ullEnd - ullStart, HSPScannerService_LogCode_CancelPreview, CombineJsonContext("HSPS_VIEW_HIDE failed"));
|
|
|
+ SetErrorAndLog(erroCode, MEC_DEVAPI_HSPSCANNER_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), ullEnd - ullStart, HSPScannerService_LogCode_CancelPreview, CombineJsonContext("HSPS_VIEW_HIDE"));
|
|
|
SetLastUserCode(GetAlarmDEC());
|
|
|
}
|
|
|
- pEvt->m_ctx->Answer(TransECWithRepeat(erroCode));
|
|
|
+ pEvt->m_ctx->Answer(erroCode);
|
|
|
FSMEvent* timerEvent = new FSMEvent(EVT_TIMER);
|
|
|
timerEvent->param1 = RESET_TIMER_ID;
|
|
|
PostEventFIFO(timerEvent);
|
|
|
}
|
|
|
} else {
|
|
|
StopPreviewEvent* pEvt = dynamic_cast<StopPreviewEvent*>(e);
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_CancelPreview).setResultCode(MapCode2RTAString(GetLastUserCode()))("高拍仪设备未打开");
|
|
|
pEvt->m_ctx->Answer(Error_DevNotAvailable, GetLastUserCode());
|
|
|
}
|
|
|
}
|
|
@@ -914,7 +926,6 @@ unsigned int CHSPScannerFSM::s3_Failed_on_event(FSMEvent* e)
|
|
|
{
|
|
|
GetDevStatusEvent* pEvt = dynamic_cast<GetDevStatusEvent*>(e);
|
|
|
if (!GetDevInitFlag()) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_GetDevStatus).setResultCode(MapCode2RTAString(GetLastUserCode()))("高拍仪设备未打开");
|
|
|
pEvt->m_ctx->Answer(Error_DevNotAvailable, GetLastUserCode());
|
|
|
} else {
|
|
|
GetDevStatusTask* pTask = new GetDevStatusTask(this);
|
|
@@ -928,7 +939,6 @@ unsigned int CHSPScannerFSM::s3_Failed_on_event(FSMEvent* e)
|
|
|
{
|
|
|
GetDevInfoEvent* pEvt = dynamic_cast<GetDevInfoEvent*>(e);
|
|
|
if (!GetDevInitFlag()) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_GetDevInfo).setResultCode(MapCode2RTAString(GetLastUserCode()))("高拍仪设备未打开");
|
|
|
pEvt->m_ctx->Answer(Error_DevNotAvailable, GetLastUserCode());
|
|
|
e->SetHandled();
|
|
|
}
|
|
@@ -944,7 +954,6 @@ unsigned int CHSPScannerFSM::s3_Failed_on_event(FSMEvent* e)
|
|
|
{
|
|
|
SetWinPosEvent* pEvt = dynamic_cast<SetWinPosEvent*>(e);
|
|
|
if (!GetDevInitFlag()) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_SetWinPos).setResultCode(MapCode2RTAString(GetLastUserCode()))("高拍仪设备未打开");
|
|
|
pEvt->m_ctx->Answer(Error_DevNotAvailable, GetLastUserCode());
|
|
|
e->SetHandled();
|
|
|
}
|
|
@@ -1033,8 +1042,9 @@ unsigned int CHSPScannerFSM::s4_ScanImage_on_event(FSMEvent* e)
|
|
|
void CHSPScannerFSM::s5_DeviceOff_on_entry()
|
|
|
{
|
|
|
SetDevState(DEVICE_STATUS_CONNECTING);
|
|
|
- LogWarn(Severity_Low, Error_DevNotAvailable, HSPScanner_UserErrorCode_DEVICE_OFFLINE, "高拍仪断开连接!");
|
|
|
SetLastUserCode(HSPScanner_UserErrorCode_DEVICE_OFFLINE);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode(MapCode2RTAString(GetLastUserCode()))("高拍仪断开连接!");
|
|
|
+ m_ullTS4Disconnect = SP::Module::Comm::RVCGetTickCount();
|
|
|
ScheduleTimer(CHECK_CONNECT_TIMER_ID, MILLISECOND_TO_CHECK_CONNECT);
|
|
|
}
|
|
|
|
|
@@ -1097,13 +1107,18 @@ unsigned int CHSPScannerFSM::s5_DeviceOff_on_event(FSMEvent* e)
|
|
|
if (status.isConnected == 0) {
|
|
|
ScheduleTimer(CHECK_CONNECT_TIMER_ID, MILLISECOND_TO_CHECK_CONNECT);
|
|
|
}
|
|
|
- else if (status.inShow == 1 && status.inPreview == 1) {
|
|
|
- //回到预览状态
|
|
|
- uRet = 2;
|
|
|
- } else if(status.inShow == 0 && status.inPreview == 1) {
|
|
|
- uRet = 3;
|
|
|
- } else {
|
|
|
- uRet = 1;
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setCostTime(SP::Module::Comm::RVCGetTickCount() - m_ullTS4Disconnect)("高拍仪恢复连接");
|
|
|
+ if (status.inShow == 1 && status.inPreview == 1) {
|
|
|
+ //回到预览状态
|
|
|
+ uRet = 2;
|
|
|
+ }
|
|
|
+ else if (status.inShow == 0 && status.inPreview == 1) {
|
|
|
+ uRet = 3;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ uRet = 1;
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
//RTA2N09
|
|
@@ -1154,7 +1169,7 @@ void CHSPScannerFSM::s6_HidePreview_on_exit()
|
|
|
|
|
|
unsigned int CHSPScannerFSM::s6_HidePreview_on_event(FSMEvent* e)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("s6_HidePreview_on_event: %s(%d), %d.", EvtTypeToString(e->iEvt), e->iEvt, e->param1);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("s6_HidePreview_on_event: %s, %d.", EvtTypeToString(e->iEvt), e->param1);
|
|
|
unsigned int uRet = 0;
|
|
|
switch(e->iEvt)
|
|
|
{
|
|
@@ -1183,7 +1198,7 @@ unsigned int CHSPScannerFSM::s6_HidePreview_on_event(FSMEvent* e)
|
|
|
{
|
|
|
JS::CancelPreviewEvent* pEvt = dynamic_cast<JS::CancelPreviewEvent*>(e);
|
|
|
if (pEvt->m_ctx->Req.hide) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_CancelPreviewJS)("current state is already hide preview");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_CancelPreviewJS)("current state is already hide preview");
|
|
|
pEvt->m_ctx->Answer(Error_Succeed);
|
|
|
}
|
|
|
else {
|
|
@@ -1331,9 +1346,8 @@ unsigned int CHSPScannerFSM::s6_HidePreview_on_event(FSMEvent* e)
|
|
|
{
|
|
|
e->SetHandled();
|
|
|
if (m_dupFlag4ExitCancel) {
|
|
|
- LogWarn(Severity_Low, Error_Debug, HSPScanner_UserErrorCode_DuplicateCancelPreview, CSimpleStringA::Format("%s::recv %s while CancelPreviewing", __FUNCTION__, EvtTypeToString(e->iEvt)));
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s::recv %s while CancelPreviewing", __FUNCTION__, EvtTypeToString(e->iEvt));
|
|
|
uRet = 1;
|
|
|
- //TODO: need to settimer ?? [Gifur@202565]
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -1580,7 +1594,7 @@ int CHSPScannerFSM::StartPreview(SpReqAnsContext<HSPScannerService_StartPreview_
|
|
|
/** 无论如何都打开一次灯,所以这里应该是有所冗余的 [Gifur@2025325]*/
|
|
|
ToSwithLight();
|
|
|
}
|
|
|
- ctx->Answer(TransECWithRepeat(erroCode), GetLastUserCode());
|
|
|
+ ctx->Answer(erroCode, GetLastUserCode());
|
|
|
return nRes;
|
|
|
}
|
|
|
|
|
@@ -1625,28 +1639,30 @@ int CHSPScannerFSM::StopPreview(SpReqAnsContext<HSPScannerService_CancelPreview_
|
|
|
/** 取消预览时如果仅仅是隐藏也会关闭灯 [Gifur@2025325]*/
|
|
|
ToSwithLight(false);
|
|
|
}
|
|
|
- ctx->Answer(TransECWithRepeat(erroCode), GetLastUserCode());
|
|
|
+ ctx->Answer(erroCode, GetLastUserCode());
|
|
|
return nRes;
|
|
|
}
|
|
|
|
|
|
-bool CHSPScannerFSM::ResizeImage(const CSimpleStringA& fileName, int kbSize)
|
|
|
+bool CHSPScannerFSM::ResizeImage(const CSimpleStringA& fileName, int kbSize, long& originSize, CSimpleStringA& retMsg)
|
|
|
{
|
|
|
double rate; //limit rate
|
|
|
int width;
|
|
|
int height;
|
|
|
- bool success = TRUE;
|
|
|
|
|
|
+ originSize = 0;
|
|
|
const int imageSize = kbSize * 1024;
|
|
|
+ if (imageSize == 0) return TRUE;
|
|
|
|
|
|
FILE* fHandle = fopen(fileName.GetData(), "rb");
|
|
|
if (!fHandle) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setAPI(__FUNCTION__)("fopen image %s for resize failed: %d", fileName.GetData(), errno);
|
|
|
+ retMsg = CSimpleStringA::Format("fopen image %s failed: %d", fileName.GetData(), errno);
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
|
fseek(fHandle, 0, SEEK_END);
|
|
|
long fileSize = ftell(fHandle);
|
|
|
fclose(fHandle);
|
|
|
+ originSize = fileSize;
|
|
|
if (fileSize <= (imageSize)) {
|
|
|
return TRUE;
|
|
|
}
|
|
@@ -1654,19 +1670,16 @@ bool CHSPScannerFSM::ResizeImage(const CSimpleStringA& fileName, int kbSize)
|
|
|
m_pEntity->GetFunction()->GetPath("Temp", backUpPath);
|
|
|
backUpFile = backUpPath + SPLIT_SLASH_STR + "backupHSPSCannerImage";
|
|
|
DeleteFileIfExisted(backUpFile);
|
|
|
-#ifndef _WIN32
|
|
|
fileutil_copy_file((LPCTSTR)backUpFile, (LPCTSTR)fileName);
|
|
|
-#else
|
|
|
- CopyFileA(fileName, backUpFile, FALSE);
|
|
|
-#endif //NOT _WIN32
|
|
|
|
|
|
+ bool success = TRUE;
|
|
|
while (fileSize > imageSize)
|
|
|
{
|
|
|
rate = (double)fileSize / imageSize;
|
|
|
rate = 1.0 / sqrt(rate); //width and height limit rate
|
|
|
cv::Mat img = cv::imread(fileName.GetData());
|
|
|
if (!img.data) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setAPI(__FUNCTION__)("Opencv READ failed!");
|
|
|
+ retMsg = CSimpleStringA::Format("Opencv READ failed!");
|
|
|
success = FALSE;
|
|
|
break;
|
|
|
}
|
|
@@ -1675,7 +1688,7 @@ bool CHSPScannerFSM::ResizeImage(const CSimpleStringA& fileName, int kbSize)
|
|
|
cv::resize(img, img, cv::Size(width * rate, height * rate));
|
|
|
const bool openwrite = cv::imwrite(fileName.GetData(), img);
|
|
|
if (!openwrite) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Opencv WRITE failed!");
|
|
|
+ retMsg = CSimpleStringA::Format("Opencv WRITE failed!");
|
|
|
success = FALSE;
|
|
|
break;
|
|
|
}
|
|
@@ -1688,11 +1701,7 @@ bool CHSPScannerFSM::ResizeImage(const CSimpleStringA& fileName, int kbSize)
|
|
|
}
|
|
|
|
|
|
if (!success) {
|
|
|
-#ifndef _WIN32
|
|
|
- ///*TODO(80374374@3/3/2023): */
|
|
|
fileutil_copy_file((LPCTSTR)fileName, (LPCTSTR)backUpFile); //recover original img
|
|
|
-#endif //NOT _WIN32
|
|
|
- CopyFileA(backUpFile, fileName, FALSE);
|
|
|
DeleteFileIfExisted(backUpFile);
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -1711,18 +1720,18 @@ int CHSPScannerFSM::ScanImage(SpReqAnsContext<HSPScannerService_ScanImage_Req,
|
|
|
BOOL bRet = DelAndGetNewFileName(csImageFile);
|
|
|
if (!bRet) {
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_ScanImage).setResultCode(MapCode2RTAString(HSPScanner_UserErrorCode_CLEAR_RESOURCE_FAILED))("Cleare previous image failed before ScanImage");
|
|
|
- ctx->Answer(TransECWithRepeat(Error_Resource), HSPScanner_UserErrorCode_CLEAR_RESOURCE_FAILED);
|
|
|
+ ctx->Answer(Error_Resource, HSPScanner_UserErrorCode_CLEAR_RESOURCE_FAILED);
|
|
|
return 1;
|
|
|
}
|
|
|
- ///*TODO: (80374374@2/20/2024)*/
|
|
|
+ long pictureSize(0), resizeSize(0);
|
|
|
ULONGLONG ullStart = SP::Module::Comm::RVCGetTickCount();
|
|
|
erroCode = m_hDevHelper->ScanImage((LPCTSTR)csImageFile);
|
|
|
ULONGLONG ullEnd = SP::Module::Comm::RVCGetTickCount();
|
|
|
if (ISSUCCEEDED(erroCode)) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::ScanImage").setCostTime(ullEnd - ullStart)("ScanImage succ");
|
|
|
- ///*TODO: (80374374@2/20/2024)*/
|
|
|
- if (!ResizeImage(csImageFile, m_dwMaxImageSize)) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode(MapCode2RTAString(LOG_WARN_HSPS_RESIZE_IMAGE_FILE_FAILED)).setAPI(__FUNCTION__)("HSPScanner resize image failed");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::ScanImage").setCostTime(ullEnd - ullStart)();
|
|
|
+ CSimpleStringA resizeMsg(true);
|
|
|
+ if (ExistsFileA(csImageFile) && !ResizeImage(csImageFile, m_dwMaxImageSize, pictureSize, resizeMsg)) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode(MapCode2RTAString(LOG_WARN_HSPS_RESIZE_IMAGE_FILE_FAILED)).setAPI(__FUNCTION__)("Resize image failed:%s", resizeMsg.GetData());
|
|
|
}
|
|
|
ctx->Ans.filePath = csImageFile;
|
|
|
CBlob& cbData = ctx->Ans.imageData;
|
|
@@ -1732,12 +1741,14 @@ int CHSPScannerFSM::ScanImage(SpReqAnsContext<HSPScannerService_ScanImage_Req,
|
|
|
fseek(fHandle, 0, SEEK_END);
|
|
|
long fileSize = ftell(fHandle);
|
|
|
if (fileSize <= 0) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_ScanImage).setResultCode(MapCode2RTAString(tmpCode))("ftell(%s) error after invoking scanimage: %ld.", (LPCTSTR)csImageFile, fileSize);
|
|
|
+ LogWarn(Severity_Middle, Error_NotExist, HSPScanner_UserErrorCode_READ_IMAGE_FILE_ZERO, CSimpleStringA::Format("ftell(%s) error after invoking scanimage: %ld.", (LPCTSTR)csImageFile, fileSize));
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_ScanImage).setResultCode(MapCode2RTAString(HSPScanner_UserErrorCode_READ_IMAGE_FILE_ZERO))("ftell(%s) error after invoking scanimage: %ld.", (LPCTSTR)csImageFile, fileSize);
|
|
|
erroCode = Error_NotExist;
|
|
|
fclose(fHandle);
|
|
|
nRes = 4;
|
|
|
} else {
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("picture size:%ld", fileSize);
|
|
|
+ resizeSize = fileSize;
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("picture size:%ld", resizeSize);
|
|
|
cbData.Alloc(fileSize);
|
|
|
fseek(fHandle, 0, SEEK_SET);
|
|
|
fread(cbData.m_pData, 1, fileSize, fHandle);
|
|
@@ -1752,28 +1763,28 @@ int CHSPScannerFSM::ScanImage(SpReqAnsContext<HSPScannerService_ScanImage_Req,
|
|
|
nRes = 4;
|
|
|
}
|
|
|
if (ISSUCCEEDED(erroCode)) {
|
|
|
+
|
|
|
// Additional ChangeTo Hide --Josephus at 11:32:29 2016/11/22
|
|
|
if (true/*TODO: */) {
|
|
|
ullStart = SP::Module::Comm::RVCGetTickCount();
|
|
|
ErrorCodeEnum eHide = m_hDevHelper->SetParam(HSPS_MODEL_VIEW, HSPS_VIEW_HIDE);
|
|
|
ullEnd = SP::Module::Comm::RVCGetTickCount();
|
|
|
if (ISSUCCEEDED(eHide)) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::SetParam").setCostTime(ullEnd - ullStart)("HSPS_MODEL_VIEW::HSPS_VIEW_HIDE");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::SetParam").setCostTime(ullEnd - ullStart)("HSPS_VIEW_HIDE");
|
|
|
nRes = 6;
|
|
|
} else {
|
|
|
//RTA2N0Q
|
|
|
- SetErrorAndLog(eHide, MEC_DEVAPI_HSPSCANNER_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), ullEnd - ullStart, HSPScannerService_LogCode_ScanImage, CombineJsonContext("HSPS_MODEL_VIEW::HSPS_VIEW_HIDE"));
|
|
|
+ SetErrorAndLog(eHide, MEC_DEVAPI_HSPSCANNER_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), ullEnd - ullStart, "", CombineJsonContext("HSPS_VIEW_HIDE"));
|
|
|
}
|
|
|
/** 拍照成功虽然隐藏了但没有关闭灯 [Gifur@2025325]*/
|
|
|
}
|
|
|
-
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_ScanImage).setAPI(__FUNCTION__)("ScanImage succ");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_ScanImage).setAPI(__FUNCTION__)("ScanImage succ, originalPicSize:%ld, resizePicSize:%ld", pictureSize, resizeSize);
|
|
|
}
|
|
|
- ctx->Answer(TransECWithRepeat(erroCode), GetLastUserCode());
|
|
|
+ ctx->Answer(erroCode, GetLastUserCode());
|
|
|
} else {
|
|
|
SetErrorAndLog(erroCode, MEC_DEVAPI_HSPSCANNER_ScanImage, "DevAdapter::ScanImage", __FUNCTION__, IsInBusiness(), ullEnd - ullStart, HSPScannerService_LogCode_ScanImage);
|
|
|
SetLastUserCode(GetAlarmDEC());
|
|
|
- ctx->Answer(TransECWithRepeat(erroCode), GetLastUserCode());
|
|
|
+ ctx->Answer(erroCode, GetLastUserCode());
|
|
|
nRes = 2;
|
|
|
}
|
|
|
ClearPictureFileSure(1);
|
|
@@ -1790,7 +1801,7 @@ int CHSPScannerFSM::ScanImageEx(SpReqAnsContext<HSPScannerService_ScanImageEx_Re
|
|
|
BOOL bRet = DelAndGetNewFileName(csImageFile);
|
|
|
if (!bRet) {
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode(MapCode2RTAString(HSPScanner_UserErrorCode_CLEAR_RESOURCE_FAILED))("Cleare previous image failed before ScanImageEx");
|
|
|
- ctx->Answer(TransECWithRepeat(Error_Resource), HSPScanner_UserErrorCode_CLEAR_RESOURCE_FAILED);
|
|
|
+ ctx->Answer(Error_Resource, HSPScanner_UserErrorCode_CLEAR_RESOURCE_FAILED);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -1818,11 +1829,13 @@ int CHSPScannerFSM::ScanImageEx(SpReqAnsContext<HSPScannerService_ScanImageEx_Re
|
|
|
erroCode = m_hDevHelper->ScanImageEx(pBtImage, len, (LPCTSTR)csImageFile);
|
|
|
ullEnd = SP::Module::Comm::RVCGetTickCount();
|
|
|
if (erroCode == Error_Succeed) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::ScanImageEx").setCostTime(ullEnd - ullStart)("ScanImageEx suc %d, %d.", len, strlen((const char*)pBtImage));
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::ScanImageEx").setCostTime(ullEnd - ullStart)("len: %d, btLen:%d.", len, strlen((const char*)pBtImage));
|
|
|
}
|
|
|
}
|
|
|
if (ISSUCCEEDED(erroCode)) {
|
|
|
- if (ResizeImage(csImageFile, m_dwMaxImageSize)) {
|
|
|
+ long pictureSize(0);
|
|
|
+ CSimpleStringA resizeMsg(true);
|
|
|
+ if (ResizeImage(csImageFile, m_dwMaxImageSize, pictureSize, resizeMsg)) {
|
|
|
FILE* fHandle = fopen(csImageFile.GetData(), "rb");
|
|
|
fseek(fHandle, 0, SEEK_END);
|
|
|
len = ftell(fHandle);
|
|
@@ -1834,7 +1847,7 @@ int CHSPScannerFSM::ScanImageEx(SpReqAnsContext<HSPScannerService_ScanImageEx_Re
|
|
|
fclose(fHandle);
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode(MapCode2RTAString(LOG_WARN_HSPS_RESIZE_IMAGE_FILE_FAILED)).setAPI(__FUNCTION__)("HSPScanner resize image failed");
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode(MapCode2RTAString(LOG_WARN_HSPS_RESIZE_IMAGE_FILE_FAILED)).setAPI(__FUNCTION__)("Resize image failed:%s", resizeMsg.GetData());
|
|
|
}
|
|
|
ctx->Ans.filePath = csImageFile;
|
|
|
CBlob& cbData = ctx->Ans.imageData;
|
|
@@ -1850,19 +1863,19 @@ int CHSPScannerFSM::ScanImageEx(SpReqAnsContext<HSPScannerService_ScanImageEx_Re
|
|
|
ErrorCodeEnum eHide = m_hDevHelper->SetParam(HSPS_MODEL_VIEW, HSPS_VIEW_HIDE);
|
|
|
ullEnd = SP::Module::Comm::RVCGetTickCount();
|
|
|
if (ISSUCCEEDED(eHide)) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::SetParam").setCostTime(ullEnd - ullStart)("HSPS_MODEL_VIEW::HSPS_VIEW_HIDE");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::SetParam").setCostTime(ullEnd - ullStart)("HSPS_VIEW_HIDE");
|
|
|
nRes = 6;
|
|
|
} else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setAPI("DevAdapter::SetParam").setCostTime(ullEnd - ullStart).setResultCode(MapCode2RTAString(HSPScanner_UserErrorCode_SetParam_Hide))("HSPS_MODEL_VIEW::HSPS_VIEW_HIDE failed: %s", SpStrError(eHide));
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setAPI("DevAdapter::SetParam").setCostTime(ullEnd - ullStart).setResultCode(MapCode2RTAString(HSPScanner_UserErrorCode_SetParam_Hide))("HSPS_VIEW_HIDE failed: %s", SpStrError(eHide));
|
|
|
}
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI(__FUNCTION__).setLogCode(HSPScannerService_LogCode_ScanImageEx)("ScanImageEx ctx: %s, %d.", (LPCTSTR)ctx->Ans.filePath, ctx->Ans.imageData.m_iLength);
|
|
|
}
|
|
|
- ctx->Answer(TransECWithRepeat(erroCode));
|
|
|
+ ctx->Answer(erroCode);
|
|
|
} else {
|
|
|
//RTA2N06
|
|
|
SetErrorAndLog(erroCode, MEC_DEVAPI_HSPSCANNER_ScanImageEx, "DevAdapter::ScanImageEx", __FUNCTION__, IsInBusiness(), ullEnd - ullStart, HSPScannerService_LogCode_ScanImageEx);
|
|
|
SetLastUserCode(GetAlarmDEC());
|
|
|
- ctx->Answer(TransECWithRepeat(erroCode), GetLastUserCode());
|
|
|
+ ctx->Answer(erroCode, GetLastUserCode());
|
|
|
nRes = 2;
|
|
|
}
|
|
|
|
|
@@ -1888,7 +1901,7 @@ int CHSPScannerFSM::ShowProperty(SpReqAnsContext<HSPScannerService_ShowProperty_
|
|
|
} else {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_ShowProperty).setAPI("DevAdapter::SetViewPos").setCostTime(ullEnd - ullStart)();
|
|
|
}
|
|
|
- ctx->Answer(TransECWithRepeat(erroCode));
|
|
|
+ ctx->Answer(erroCode);
|
|
|
|
|
|
DWORD dwStart = GetTickCount();
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Start to show Property dialog...");
|
|
@@ -1945,7 +1958,7 @@ int CHSPScannerFSM::SetWinPos(SpReqAnsContext<HSPScannerService_SetWinPos_Req,
|
|
|
erroCode = m_hDevHelper->SetViewPos(ctx->Req.pointX, ctx->Req.pointY, ctx->Req.nWidth);
|
|
|
const ULONGLONG ullEnd = SP::Module::Comm::RVCGetTickCount();
|
|
|
if (ISSUCCEEDED(erroCode)) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::SetViewPos").setCostTime(ullEnd - ullStart)("x: %d, y: %d, w: %d", ctx->Req.pointX, ctx->Req.pointY, ctx->Req.nWidth);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::SetViewPos").setLogCode(HSPScannerService_LogCode_SetWinPos).setCostTime(ullEnd - ullStart)("x:%d, y:%d, w:%d", ctx->Req.pointX, ctx->Req.pointY, ctx->Req.nWidth);
|
|
|
m_nRecX = ctx->Req.pointX;
|
|
|
m_nRecY = ctx->Req.pointY;
|
|
|
m_nRecW = ctx->Req.nWidth;
|
|
@@ -1960,7 +1973,7 @@ int CHSPScannerFSM::SetWinPos(SpReqAnsContext<HSPScannerService_SetWinPos_Req,
|
|
|
erroCode = m_hDevHelper->SetParam(HSPS_MODEL_VIEW, value);
|
|
|
const ULONGLONG ullEnd = SP::Module::Comm::RVCGetTickCount();
|
|
|
if (ISSUCCEEDED(erroCode)) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::SetParam").setCostTime(ullEnd - ullStart)("%d", value);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::SetParam").setLogCode(HSPScannerService_LogCode_SetWinPos).setCostTime(ullEnd - ullStart)("%d", value);
|
|
|
} else {
|
|
|
//RTA2N02
|
|
|
SetErrorAndLog(erroCode, MEC_DEVAPI_HSPSCANNER_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), ullEnd - ullStart, HSPScannerService_LogCode_SetWinPos);
|
|
@@ -1968,15 +1981,12 @@ int CHSPScannerFSM::SetWinPos(SpReqAnsContext<HSPScannerService_SetWinPos_Req,
|
|
|
nRes = 1;
|
|
|
}
|
|
|
}
|
|
|
- if (ISSUCCEEDED(erroCode)) {
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_SetWinPos)("SetWinPos succ.");
|
|
|
- }
|
|
|
- else {
|
|
|
+ if (!ISSUCCEEDED(erroCode)) {
|
|
|
CSimpleStringA tmpRTA(true), tmpDesc(true);
|
|
|
if (GetEntityBase()->GetFunction()->GetVTMErrMsg(GetLastUserCode(), tmpDesc, tmpRTA) == Error_Succeed)
|
|
|
DbgToBeidou(ctx->link, "SetWinPos").setReturnCode(tmpRTA)();
|
|
|
}
|
|
|
- ctx->Answer(TransECWithRepeat(erroCode), GetLastUserCode());
|
|
|
+ ctx->Answer(erroCode, GetLastUserCode());
|
|
|
return nRes;
|
|
|
}
|
|
|
|
|
@@ -1995,7 +2005,7 @@ int CHSPScannerFSM::GetDevStatus(SpReqAnsContext<HSPScannerService_GetDevStatus_
|
|
|
else {
|
|
|
nRes = 1;
|
|
|
}
|
|
|
- ctx->Answer(TransECWithRepeat(erroCode), GetLastUserCode());
|
|
|
+ ctx->Answer(erroCode, GetLastUserCode());
|
|
|
return nRes;
|
|
|
}
|
|
|
|
|
@@ -2175,7 +2185,7 @@ void CHSPScannerFSM::SelfTest(EntityTestEnum eTestType,
|
|
|
|
|
|
void CHSPScannerFSM::OnStateTrans(int iSrcState, int iDstState)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("trans from %s to %s", GetStateName(iSrcState), GetStateName(iDstState));
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("trans from %s to %s", GetStateName(iSrcState), GetStateName(iDstState));
|
|
|
m_nSrcState = iSrcState;
|
|
|
}
|
|
|
|
|
@@ -2225,6 +2235,7 @@ int CHSPScannerFSM::CancelPreview(SpReqAnsContext<HSPScannerService_CancelPrevie
|
|
|
ret = 1;
|
|
|
}
|
|
|
else {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_CancelPreviewJS)("HSPS_VIEW_HIDE");
|
|
|
ctx->Answer(Error_Succeed);
|
|
|
}
|
|
|
}
|
|
@@ -2265,22 +2276,27 @@ int CHSPScannerFSM::ScanImageJS(SpReqAnsContext<HSPScannerService_ScanImageJS_Re
|
|
|
erroCode = m_hDevHelper->ScanImage((LPCTSTR)csImageFile);
|
|
|
ULONGLONG ullEnd = SP::Module::Comm::RVCGetTickCount();
|
|
|
if (ISSUCCEEDED(erroCode)) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::ScanImage").setCostTime(ullEnd - ullStart)("ScanImage succ");
|
|
|
- if (ctx->Req.compress > 0 && !ResizeImage(csImageFile, ctx->Req.compress/*KB*/)) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode(MapCode2RTAString(LOG_WARN_HSPS_RESIZE_IMAGE_FILE_FAILED)).setAPI(__FUNCTION__).setLogCode(HSPScannerService_LogCode_ScanImageJS).setCostTime(ullEnd - ullStart)("HSPScanner resize image failed");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::ScanImage").setCostTime(ullEnd - ullStart)();
|
|
|
+ long pictureSize(0), resizeSize(0);
|
|
|
+ CSimpleStringA resizeMsg(true);
|
|
|
+ if (ctx->Req.compress > 0 && ExistsFileA(csImageFile) && !ResizeImage(csImageFile, ctx->Req.compress/*KB*/, pictureSize, resizeMsg)) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode(MapCode2RTAString(LOG_WARN_HSPS_RESIZE_IMAGE_FILE_FAILED)).setAPI(__FUNCTION__).setLogCode(HSPScannerService_LogCode_ScanImageJS).setCostTime(ullEnd - ullStart)("Resize image failed:%s", resizeMsg.GetData());
|
|
|
SetLastUserCode(LOG_WARN_HSPS_RESIZE_IMAGE_FILE_FAILED);
|
|
|
erroCode = Error_Unexpect;
|
|
|
ret = 1;
|
|
|
}
|
|
|
else {
|
|
|
CSimpleStringA tmpMsg(true);
|
|
|
+ DWORD tmpCode(0);
|
|
|
CBlob& cbData = ctx->Ans.imageData;
|
|
|
FILE* fHandle = fopen(csImageFile, "rb");
|
|
|
if (fHandle) {
|
|
|
fseek(fHandle, 0, SEEK_END);
|
|
|
long fileSize = ftell(fHandle);
|
|
|
+ resizeSize = fileSize;
|
|
|
if (fileSize <= 0) {
|
|
|
tmpMsg = CSimpleStringA::Format("ftell(%s) error after invoking scanimage: %ld.", (LPCTSTR)csImageFile, fileSize);
|
|
|
+ tmpCode = HSPScanner_UserErrorCode_READ_IMAGE_FILE_ZERO;
|
|
|
}
|
|
|
else {
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("picture size:%ld", fileSize);
|
|
@@ -2292,20 +2308,19 @@ int CHSPScannerFSM::ScanImageJS(SpReqAnsContext<HSPScannerService_ScanImageJS_Re
|
|
|
}
|
|
|
else {
|
|
|
tmpMsg = CSimpleStringA::Format("fopen(%s) error after invoking scanimage: %d.", (LPCTSTR)csImageFile, errno);
|
|
|
+ tmpCode = HSPScanner_UserErrorCode_READ_IMAGE_FILE_FAILED;
|
|
|
}
|
|
|
|
|
|
- if (tmpMsg.IsNullOrEmpty()) {
|
|
|
- //Succ
|
|
|
+ if (!tmpCode) {//Succ
|
|
|
if (ctx->Req.hide && FAILURED(SetPreviewProperty(JS::PreviewSettings(false), HSPScannerService_LogCode_ScanImageJS))) {
|
|
|
erroCode = Error_Unexpect;
|
|
|
ret = 1;
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_ScanImageJS).setAPI(__FUNCTION__)("ScanImage succ");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_ScanImageJS).setAPI(__FUNCTION__)("ScanImage succ, originalPicSize:%ld, resizePicSize:%ld", pictureSize, resizeSize);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- const DWORD tmpCode(HSPScanner_UserErrorCode_READ_IMAGE_FILE_FAILED);
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(HSPScannerService_LogCode_ScanImageJS).setResultCode(MapCode2RTAString(tmpCode))(tmpMsg.GetData());
|
|
|
SetLastUserCode(tmpCode);
|
|
|
erroCode = Error_Unexpect;
|
|
@@ -2387,7 +2402,7 @@ ErrorCodeEnum CHSPScannerFSM::SetPreviewProperty(const JS::PreviewSettings& val,
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
if (val.pos != 0) {
|
|
|
- CSimpleStringA tmpParm = CSimpleStringA::Format("x(%d), y(%d), w(%d)", val.pos_x, val.pos_y, val.pos_w);
|
|
|
+ CSimpleStringA tmpParm = CSimpleStringA::Format("x:%d, y:%d, w:%d", val.pos_x, val.pos_y, val.pos_w);
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_USER)("Start to SetViewPos %s...", tmpParm.GetData());
|
|
|
const ULONGLONG ullStart = SP::Module::Comm::RVCGetTickCount();
|
|
|
erroCode = m_hDevHelper->SetViewPos(val.pos_x, val.pos_y, val.pos_w);
|
|
@@ -2489,7 +2504,7 @@ ErrorCodeEnum CHSPScannerFSM::DeleteFileIfExisted(LPCTSTR fileName)
|
|
|
}
|
|
|
else {
|
|
|
LogWarn(Severity_High, Error_Unexpect, HSPScanner_UserErrorCode_CLEAR_RESOURCE_FAILED, CSimpleStringA::Format(
|
|
|
- "DeleteFile(%s) failed LastError(%d) at ResizeImage proc", fileName, GetLastError()));
|
|
|
+ "DeleteFile(%s) failed LastError(%d)", fileName, GetLastError()));
|
|
|
return Error_Unexpect;
|
|
|
}
|
|
|
}
|
|
@@ -2515,7 +2530,7 @@ void CHSPScannerFSM::InitialMaxResizeValue()
|
|
|
ErrorCodeEnum CHSPScannerFSM::TryToOpenDevice()
|
|
|
{
|
|
|
ErrorCodeEnum result(Error_Succeed);
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("to open device...");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to open device...");
|
|
|
ULONGLONG ullStart = SP::Module::Comm::RVCGetTickCount();
|
|
|
result = m_hDevHelper->DevOpen();
|
|
|
ULONGLONG ullEnd = SP::Module::Comm::RVCGetTickCount();
|
|
@@ -2526,7 +2541,7 @@ ErrorCodeEnum CHSPScannerFSM::TryToOpenDevice()
|
|
|
}
|
|
|
else {
|
|
|
SetLastUserCode();
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::DevOpen").setCostTime(ullEnd - ullStart)("Open HSPS succ");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::DevOpen").setCostTime(ullEnd - ullStart)();
|
|
|
ullStart = SP::Module::Comm::RVCGetTickCount();
|
|
|
result = FulfillAdapterDevCategory();
|
|
|
ullEnd = SP::Module::Comm::RVCGetTickCount();
|
|
@@ -2537,12 +2552,17 @@ ErrorCodeEnum CHSPScannerFSM::TryToOpenDevice()
|
|
|
m_nRecY = 224;
|
|
|
m_nRecW = 1024;
|
|
|
ErrorCodeEnum ecInit = m_hDevHelper->SetViewPos(m_nRecX, m_nRecY, m_nRecW);
|
|
|
+ if (FAILURED(ecInit))
|
|
|
+ SetErrorAndLog(ecInit, MEC_DEVAPI_HSPSCANNER_SetViewPos, "DevAdapter::SetViewPos", __FUNCTION__, false);
|
|
|
ErrorCodeEnum ecInitScan = m_hDevHelper->SetParam(HSPS_MODEL_SCANSIZE, HSPS_SCAN_FULL);
|
|
|
+ if (FAILURED(ecInitScan))
|
|
|
+ SetErrorAndLog(ecInitScan, MEC_DEVAPI_HSPSCANNER_SetParam, "DevAdapter::SetParam", __FUNCTION__, false, 0, "", CombineJsonContext("HSPS_SCAN_FULL"));
|
|
|
ErrorCodeEnum ecInitRotate = m_hDevHelper->SetParam(HSPS_MODEL_ROTATE, HSPS_ROTATE_NOANGLE);
|
|
|
+ if (FAILURED(ecInitRotate))
|
|
|
+ SetErrorAndLog(ecInitRotate, MEC_DEVAPI_HSPSCANNER_SetParam, "DevAdapter::SetParam", __FUNCTION__, false, 0, "", CombineJsonContext("HSPS_ROTATE_NOANGLE"));
|
|
|
ErrorCodeEnum ecInitColor = m_hDevHelper->SetParam(HSPS_MODEL_COLOR, HSPS_COLOR_FULL);
|
|
|
- if (FAILURED(ecInit) || FAILURED(ecInitScan) || FAILURED(ecInitRotate) || FAILURED(ecInitColor)) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("ViewPos: %s, Scan: %s, rotate: %s, color: %s.", SpStrError(ecInit), SpStrError(ecInitScan), SpStrError(ecInitRotate), SpStrError(ecInitColor));
|
|
|
- }
|
|
|
+ if (FAILURED(ecInitColor))
|
|
|
+ SetErrorAndLog(ecInitColor, MEC_DEVAPI_HSPSCANNER_SetParam, "DevAdapter::SetParam", __FUNCTION__, false, 0, "", CombineJsonContext("HSPS_COLOR_FULL"));
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -2564,6 +2584,9 @@ LPCTSTR CHSPScannerFSM::MapCode2RTAString(DWORD dwValue)
|
|
|
case 0x2170000C: /*未登记到资源管理平台*/
|
|
|
return "RTA2N0C";
|
|
|
break;
|
|
|
+ case 0x21700204: /*未登记到资源管理平台*/
|
|
|
+ return "RTA2N0S";
|
|
|
+ break;
|
|
|
case 0:
|
|
|
default:
|
|
|
return "SUC0000";
|