mirror of http://192.168.1.51:8099/lmh188/twain3.0
增加3399 折角检测 修复异常抛图问题
This commit is contained in:
parent
df8bb0c795
commit
957c1925e6
|
@ -87,6 +87,8 @@ typedef enum tagUsbSupported {
|
|||
V4L2_IMAGE_EMPTY = 80,
|
||||
//处于休眠中
|
||||
SLEEPING = 81,
|
||||
//检测到有折角
|
||||
HAVE_DOGEAR = 82,
|
||||
//USB 未连接
|
||||
USB_DISCONNECTED = 200,
|
||||
//用户点击停止
|
||||
|
@ -119,6 +121,7 @@ static map<UsbSupported, string> msgs = {
|
|||
{UsbSupported::V4L2_AQULRE_ERROR,"扫描仪取图失败!"},
|
||||
{UsbSupported::V4L2_IMAGE_EMPTY,"扫描仪图像处理异常!"},
|
||||
{UsbSupported::SLEEPING,"设备处于休眠模式,请唤醒休眠后再扫描!"},
|
||||
{UsbSupported::HAVE_DOGEAR,"检测到有折角,停止扫描!"},
|
||||
};
|
||||
|
||||
enum tagEventIndex
|
||||
|
|
|
@ -315,13 +315,13 @@ void GScanO1003399::Scanner_StartScan(UINT16 count)
|
|||
keeplastimg = true;
|
||||
reset();
|
||||
devState = DEV_ISRUNNING;
|
||||
if (scanner_read_reg(m_usb, SR_GET_SLEEP_STAUTUS) != 1)
|
||||
{
|
||||
devState = DEV_WRONG;
|
||||
Set_ErrorCode(SLEEPING);
|
||||
scanflag = false;
|
||||
return;
|
||||
}
|
||||
//if (scanner_read_reg(m_usb, SR_GET_SLEEP_STAUTUS) != 1)
|
||||
//{
|
||||
// devState = DEV_WRONG;
|
||||
// Set_ErrorCode(SLEEPING);
|
||||
// scanflag = false;
|
||||
// return;
|
||||
//}
|
||||
if (scan_mode())
|
||||
{
|
||||
devState = DEV_WRONG;
|
||||
|
@ -434,6 +434,7 @@ void GScanO1003399::usb_run()
|
|||
break;
|
||||
case V4L2:
|
||||
FileTools::writelog(log_ERROR, "Got V4L2 Error code = " + to_string(info.Code));
|
||||
stop();
|
||||
break;
|
||||
case STOPSCAN:
|
||||
FileTools::writelog(log_INFO, "StopScan");
|
||||
|
@ -442,31 +443,33 @@ void GScanO1003399::usb_run()
|
|||
FileTools::writelog(log_ERROR, "Got Unkown error code ! From =" + to_string(info.From) + " Code = " + to_string(info.Code));
|
||||
break;
|
||||
}
|
||||
if ((codeconvter(info) != 0))
|
||||
if (codeconvter(info) > 0)
|
||||
{
|
||||
if (info.Code == 0x10 || info.Code == 0x20 || info.Code == 0x40)
|
||||
{
|
||||
while (scanner_read_reg(m_usb, SR_STATUS) & 0x1)
|
||||
this_thread::sleep_for(chrono::microseconds(10));
|
||||
if (m_param.is_duplex)
|
||||
pop_dev_im();
|
||||
pop_dev_im();
|
||||
}
|
||||
Set_ErrorCode(codeconvter(info));
|
||||
}
|
||||
if ((codeconvter(info) == -1))
|
||||
{
|
||||
|
||||
if ((get_ErrorCode() != PAPER_JAM) && (get_ErrorCode() != DETECT_DOUBLE_FEED) && (get_ErrorCode() != DETECT_STAPLE))
|
||||
{
|
||||
keeplastimg = false;
|
||||
im_rx();
|
||||
}
|
||||
else {
|
||||
while (!scanner_read_reg(m_usb, SR_GET_IMAGEPROCESSDONE))
|
||||
this_thread::sleep_for(chrono::microseconds(30));
|
||||
if (m_param.is_duplex)
|
||||
pop_dev_im();
|
||||
pop_dev_im();
|
||||
}
|
||||
scanflag = false;
|
||||
if ((devState != DEV_WRONG) && (codeconvter(info) < 0))
|
||||
if ((devState != DEV_WRONG) && (get_ErrorCode()<=0))
|
||||
devState = DEV_STOP;
|
||||
else if ((devState != DEV_WRONG) && (codeconvter(info) > 0))
|
||||
else if ((devState != DEV_WRONG) && (get_ErrorCode() > 0))
|
||||
devState = DEV_WRONG;
|
||||
}
|
||||
if (codeconvter(info) > 0)
|
||||
{
|
||||
Set_ErrorCode(codeconvter(info));
|
||||
}
|
||||
|
||||
|
||||
this_thread::sleep_for(chrono::microseconds(10));
|
||||
}
|
||||
|
||||
|
@ -589,7 +592,7 @@ int GScanO1003399::read_data(void* data, int length, int timeout)
|
|||
|
||||
int readed = 0;
|
||||
int reading = 0;
|
||||
const int buffer_size = 2 * 1024 * 1024;
|
||||
const int buffer_size = 512 * 1024;
|
||||
StopWatch sw;
|
||||
FileTools::writelog(log_INFO, "read_data timeout =" + to_string(timeout));
|
||||
while (readed < length) {
|
||||
|
@ -604,7 +607,8 @@ int GScanO1003399::read_data(void* data, int length, int timeout)
|
|||
}
|
||||
else
|
||||
{
|
||||
FileTools::writelog(log_INFO, "read usb image data time out ,time = "+std::to_string(sw.elapsed_ms()));
|
||||
FileTools::writelog(log_INFO, "read usb image data time out ,time = " + std::to_string(sw.elapsed_ms()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return readed;
|
||||
|
@ -771,6 +775,16 @@ int GScanO1003399::codeconvter(HGEIntInfo code)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (code.From == HGType::IMG)
|
||||
{
|
||||
switch (code.Code)
|
||||
{
|
||||
case 0:
|
||||
return HAVE_DOGEAR;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (code.From == HGType::STOPSCAN)
|
||||
return -1;
|
||||
return 0;
|
||||
|
|
|
@ -178,6 +178,7 @@ enum Scanner_Reg_Defs
|
|||
SR_SET_SLEEPTIME,
|
||||
SR_GET_SLEEPTIME,
|
||||
SR_GET_SLEEP_STAUTUS,
|
||||
SR_GET_IMAGEPROCESSDONE,
|
||||
SR_GET_CUO_ERROR = 0x50,
|
||||
SR_GET_DOU_ERROR,
|
||||
SR_GET_JAM_ERROR,
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue