调整 长幅面超时退出

This commit is contained in:
13038267101 2023-02-15 15:06:36 +08:00
parent 78ce295c6d
commit fd978173ab
4 changed files with 99 additions and 20 deletions

View File

@ -928,6 +928,31 @@ namespace setting3288dsp
};
//G300 G400 纸张类型协议 - OVER
}
namespace setting3288dsp_600dpi
{
enum G400_PaperSize {
G400_A3 = 0,
G400_A4,
G400_A4R,
G400_A5,
G400_A5R,
G400_A6,
G400_A6R,
G400_B4,
G400_B5,
G400_B5R,
G400_B6,
G400_B6R,
G400_DOUBLELETTER,
G400_LEGAL,
G400_LETTER,
G400_LETTERR,
G400_LONGLETTER,
G400_MAXSIZE,
G400_AUTO,
G400_MAXAUTO
};
}
namespace setting3399
{
enum Scanner_Reg_Defs
@ -1119,7 +1144,7 @@ namespace setting3399
{PAPER_MAX_SIZE, TwSS::MaxSize, setting3399::G400_MAXSIZE},
{PAPER_TRIGEMINY, TwSS::Trigeminy, setting3399::G400_LONGLETTER}
},
paper_map_dsp[] =
paper_map_dsp[] =
{
{PAPER_A3, TwSS::A3, 0},
{PAPER_8K, TwSS::K8, 0},
@ -1145,7 +1170,7 @@ namespace setting3399
{PAPER_MAX_SIZE, TwSS::MaxSize, 16},
{PAPER_TRIGEMINY, TwSS::Trigeminy, 16}
},
paper_map_3288[] =
paper_map_3288[] =
{
{PAPER_A3, TwSS::A3, setting3288dsp::G400_A3},
{PAPER_A4, TwSS::A4, setting3288dsp::G400_A4},
@ -1167,5 +1192,29 @@ namespace setting3399
{PAPER_MAX_SIZE_CLIP, TwSS::USStatement, setting3288dsp::G400_MAXSIZE},
{PAPER_MAX_SIZE, TwSS::MaxSize, setting3288dsp::G400_MAXSIZE},
{PAPER_TRIGEMINY, TwSS::MaxSize, setting3288dsp::G400_LONGLETTER},
},
paper_map_3288_600dpi[] =
{
{PAPER_A3, TwSS::A3, setting3288dsp_600dpi::G400_A3},
{PAPER_A4, TwSS::A4, setting3288dsp_600dpi::G400_A4},
{PAPER_A4_LATERAL, TwSS::A4, setting3288dsp_600dpi::G400_A4R},
{PAPER_A5, TwSS::A5, setting3288dsp_600dpi::G400_A5},
{PAPER_A5_LATERAL, TwSS::A5, setting3288dsp_600dpi::G400_A5R},
{PAPER_A6, TwSS::A6, setting3288dsp_600dpi::G400_A6},
{PAPER_A6_LATERAL, TwSS::A6, setting3288dsp_600dpi::G400_A6R},
{PAPER_B4, TwSS::B4, setting3288dsp_600dpi::G400_B4},
{PAPER_B5, TwSS::B5, setting3288dsp_600dpi::G400_B5},
{PAPER_B5_LATERAL, TwSS::B5, setting3288dsp_600dpi::G400_B5R},
{PAPER_B6, TwSS::B6, setting3288dsp_600dpi::G400_B6},
{PAPER_B6_LATERAL, TwSS::B6, setting3288dsp_600dpi::G400_B6R},
{PAPER_LETTER, TwSS::USLetter, setting3288dsp_600dpi::G400_LETTER},
{PAPER_LETTER_LATERAL, TwSS::USLetter, setting3288dsp_600dpi::G400_LETTERR},
{PAPER_DOUBLE_LETTER, TwSS::USLedger, setting3288dsp_600dpi::G400_DOUBLELETTER},
{PAPER_LEGAL, TwSS::USLegal, setting3288dsp_600dpi::G400_LEGAL},
{PAPER_AUTO_MATCH, TwSS::None, setting3288dsp_600dpi::G400_AUTO},
{PAPER_MAX_SIZE_CLIP, TwSS::USStatement, setting3288dsp_600dpi::G400_MAXAUTO},
{PAPER_MAX_SIZE, TwSS::MaxSize, setting3288dsp_600dpi::G400_MAXSIZE},
{PAPER_TRIGEMINY, TwSS::MaxSize, setting3288dsp_600dpi::G400_LONGLETTER},
};

View File

@ -2352,7 +2352,7 @@ hg_imgproc::IMGPRCPARAM hg_scanner::get_image_process_object(int model)
param.color_mode = image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH ? 2 : image_prc_param_.bits.color_mode;
param.double_side = img_conf_.is_duplex;
param.dpi = img_conf_.resolution_dst;
param.cis_image = is_cis_image || (img_conf_.papertype == TwSS::MaxSize && pid_ == 0x0300 && is_kernelsnap3288_230210_);
param.cis_image = is_cis_image;
//img_conf_.brightness = (float)bright_;
//img_conf_.contrast = (float)contrast_;
@ -3867,7 +3867,7 @@ void hg_scanner::image_process(std::shared_ptr<tiny_buffer>& buffer, uint32_t id
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Set distortion val is:h:%f w:%f distortion val is:%f\n", distortion_val.h, distortion_val.w, distortion_val.scaleXY);
}
else if (param.cis_image)
else if (param.cis_image || (img_conf_.papertype == TwSS::MaxSize && pid_ == 0x0300 && is_kernelsnap3288_230210_))
{
printf("cis 原图测试无需任何算法\r\n");
}
@ -3877,6 +3877,7 @@ void hg_scanner::image_process(std::shared_ptr<tiny_buffer>& buffer, uint32_t id
{
ret = hg_imgproc::fillhole(ImagePrc_pHandle_, isremove_top_hole_threshold, isremove_low_hole_threshold, isremove_left_hole_threshold, isremove_right_hole_threshold);
(this->*dump_img_)(ImagePrc_pHandle_, "fillhole");
VLOG_MINI_1(LOG_LEVEL_WARNING, "Image proc fillhole is:%d\n", ret);
}
if (pid_ != 0x239 && pid_ != 0x439)

View File

@ -1147,7 +1147,7 @@ void hg_scanner_239::thread_get_dves_image(void)
}
if (user_cancel_)
{
if (status_) // thread_handle_image_process maybe call stop() when insufficient memory occurs .
if (status_ && status_ != SCANNER_ERR_DEVICE_STOPPED) // thread_handle_image_process maybe call stop() when insufficient memory occurs .
ret = status_;
else
status_ = ret = SCANNER_ERR_USER_CANCELED;

View File

@ -118,7 +118,8 @@ void hg_scanner_300::thread_handle_usb_read(void)
SANE_Image_Statu statu = SANE_Image_Statu_OK;
savestatus_.clear();
VLOG_MINI_1(LOG_LEVEL_WARNING, "thread_handle_usb_read run is:%d\n", run_);
int errlist = 1;
while (run_)
{
USBCB usb={0};
@ -126,11 +127,20 @@ void hg_scanner_300::thread_handle_usb_read(void)
//printf("usb.u32_Data = %d ret = %d\r\n",usb.u32_Data,ret);
////如果设备出现卡纸 或者双张等设备信息问题需要等到设备进行发送stop才能停止。 所以始终以 "停止" 消息为结束信号
////如果有图的情况下,并且卡纸或双张等,设备会先发送卡纸双张信息。所以接受到错误信息之后,仍需要把图像取出来。
if (ret == SCANNER_ERR_DEVICE_STOPPED)
{
status_ = !savestatus_.empty() ? savestatus_[0] : SCANNER_ERR_OK;//以第一个消息为准
savestatus_.clear();
if (user_cancel_)
{
if (status_ && status_ != SCANNER_ERR_DEVICE_STOPPED) // thread_handle_image_process maybe call stop() when insufficient memory occurs .
ret = status_;
else
status_ = ret = SCANNER_ERR_USER_CANCELED;
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s:%s\n", hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_GET_USER_CANCEL_SCAN), hg_scanner_err_name(status_));
}
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s:%s\n", "'STOPSCAN' message in usb thread\n" , hg_scanner_err_name(status_));
break;
}
if (ret != SCANNER_ERR_OK &&
@ -141,6 +151,8 @@ void hg_scanner_300::thread_handle_usb_read(void)
{
//statu = last_usb_image_statu(ret);
savestatus_.push_back(ret);
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s'ERR LIST[%d]!!! Look at the first error...' message in usb thread\n", hg_scanner_err_name(ret),errlist);
errlist++;
}
else if (ret != SCANNER_ERR_NO_DATA &&
ret != SCANNER_ERR_DEVICE_AUTO_FAIL_OVER &&
@ -187,16 +199,30 @@ void hg_scanner_300::thread_handle_usb_read(void)
break;
}
}
if (sw.elapsed_ms() > 30000 && (img_conf_.papertype != TwSS::MaxSize && (pid_ != 0x0300 && !is_kernelsnap3288_230210_)))//防止状态信息一直取不上来导致卡死
else if (ret == SCANNER_ERR_IO)
{
//3288固件 获取有纸无纸问题的bug如果是打开盖子在start之前【主动】获取的话会先报无纸而不是开盖。
//但是在【端点】又获取不到有纸还是无纸的状态,所以只能通过等待超时,再来【主动】获取有无纸张。
status_ = !savestatus_.empty() ? savestatus_[0] : SCANNER_ERR_TIMEOUT;//以第一个消息为准
savestatus_.clear();
hg_log::log(LOG_LEVEL_WARNING, "get status timeout,get image out\n");
status_ = ret;
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s\n", hg_scanner_err_name(status_));
break;
}
if (sw.elapsed_ms() > 30000)//防止状态信息一直取不上来导致卡死
{
if (img_conf_.papertype == TwSS::MaxSize && pid_ == 0x0300 && is_kernelsnap3288_230210_)
{
sw.reset();
VLOG_MINI_1(LOG_LEVEL_WARNING, "thread_handle_usb_read run is:%d\n", run_);
}
else
{
//3288固件 获取有纸无纸问题的bug如果是打开盖子在start之前【主动】获取的话会先报无纸而不是开盖。
//但是在【端点】又获取不到有纸还是无纸的状态,所以只能通过等待超时,再来【主动】获取有无纸张。
status_ = !savestatus_.empty() ? savestatus_[0] : SCANNER_ERR_TIMEOUT;//以第一个消息为准
savestatus_.clear();
hg_log::log(LOG_LEVEL_WARNING, "get status timeout,get image out\n");
break;
}
}
if (ret == SCANNER_ERR_OK && usb.u32_Count > 0)
{
@ -479,23 +505,26 @@ int hg_scanner_300::on_color_mode_changed(int& color_mode)
int hg_scanner_300::on_paper_changed(int& paper)
{
bool exact = true;
int ind = hgpaper_to_devspaper(paper_map_3288, ARRAY_SIZE(paper_map_3288), paper, &exact, &paper_size_),
Paper_Map* papermap = pid_ == 0x0300 && is_kernelsnap3288_230210_ ? paper_map_3288_600dpi : paper_map_3288;
int paperlen = pid_ == 0x0300 && is_kernelsnap3288_230210_ ? ARRAY_SIZE(paper_map_3288_600dpi) : ARRAY_SIZE(paper_map_3288);
int ind = hgpaper_to_devspaper(papermap, paperlen, paper, &exact, &paper_size_),
ret = exact ? SCANNER_ERR_OK : SCANNER_ERR_NOT_EXACT;
if (dsp_config.params_3288.pageSize != paper_map_3288[ind].dev_value)
if (dsp_config.params_3288.pageSize != papermap[ind].dev_value)
{
int old = dsp_config.params_3288.pageSize;
dsp_config.params_3288.pageSize = paper_map_3288[ind].dev_value;
dsp_config.params_3288.pageSize = papermap[ind].dev_value;
ret = writedown_device_configuration();
if (ret)
{
dsp_config.params_3288.pageSize = old;
for (int i = 0; i < ARRAY_SIZE(paper_map_3288); ++i)
for (int i = 0; i < paperlen; ++i)
{
if (paper_map_3288[i].dev_value == old)
if (papermap[i].dev_value == old)
{
paper = paper_map_3288[i].paper;
paper = papermap[i].paper;
break;
}
}