code_device/hgdriver/hgdev/hg_scanner_300.cpp

1023 lines
50 KiB
C++
Raw Normal View History

2022-05-03 03:56:07 +00:00
#include "hg_scanner_300.h"
#include "../wrapper/hg_log.h"
2022-05-03 03:56:07 +00:00
#if defined(WIN32) || defined(_WIN64)
2022-05-03 03:56:07 +00:00
#include "scanner_manager.h"
#endif
static std::string jsontext1("{\"global\":{\"device_type\":\"G300\",\"option_count\":63},\"restore\":{\"category\":\"base\",\"title\":\"\\u6062\\u590d\\u9ed8\\u8ba4\\u8bbe\\u7f6e\",\"desc\":\"\\u6062\\u590d\\u9ed8\\u8ba4\\u8bbe\\u7f6e\",\"type\":\"button\",\"cur\":\"button\",\"default\":\"button\",\"size\":0},\"help\":{\"category\":\"advanced\",\"title\":\"\\u5e2e\\u52a9\",\"desc\":\"\\u663e\\u793a\\u8f6f\\u4ef6\\u5e2e\\u52a9\\u6587\\u6863\",\"type\":\"button\",\"cur\":\"true\",\"default\":\"true\",\"size\":4},\"grp-1\":{\"category\":\"base\",\"title\":\"\\u57fa\\u672c\\u8bbe\\u7f6e\",\"type\":\"group\"},\"is-multiout\":{\"category\":\"base\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\",\"desc\":\"\\u540c\\u65f6\\u8f93\\u51fa\\u591a\\u79cd\\u989c\\u8272\\u6a21\\u5f0f\\u7684\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"multiout-type\":{\"category\":\"base\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\\u7c7b\\u578b\",\"desc\":\"\\u9009\\u62e9\\u591a\\u6d41\\u8f93\\u51fa\\u7684\\u7c7b\\u578b\",\"type\":\"string\",\"cur\":\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"default\":\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"size\":32,\"range\":[\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"\\u5f69\\u8272+\\u7070\\u5ea6\",\"\\u5f69\\u8272+\\u9ed1\\u767d\",\"\\u7070\\u5ea6+\\u9ed1\\u767d\"],\"depend_or\":[\"is-multiout==true\"]},\"mode\":{\"category\":\"base\",\"title\":\"\\u989c\\u8272\\u6a21\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u8272\\u5f69\\u6a21\\u5f0f\",\"type\":\"string\",\"cur\":\"24\\u4f4d\\u5f69\\u8272\",\"default\":\"24\\u4f4d\\u5f69\\u8272\",\"size\":32,\"range\":[\"24\\u4f4d\\u5f69\\u8272\",\"256\\u7ea7\\u7070\\u5ea6\",\"\\u9ed1\\u767d\",\"\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"],\"depend_or\":[\"is-multiout==false\"]},\"binary-threshold\":{\"category\":\"base\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u9608\\u503c\",\"desc\":\"\\u9ad8\\u4e8e\\u8be5\\u9608\\u503c\\u4e3a1\\uff08\\u767d\\uff09\\uff0c\\u4f4e\\u4e8e\\u8be5\\u9608\\u503c\\u4e3a0\\uff08\\u9ed1\\uff09\",\"type\":\"int\",\"cur\":127,\"default\":127,\"size\":4,\"range\":{\"min\":0,\"max\":255},\"depend_or\":[\"is-multiout==true\",\"mode==\\u9ed1\\u767d\"]},\"reverse-bw\":{\"category\":\"base\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u53cd\\u8272\\u8f93\\u51fa\",\"desc\":\"\\u8f93\\u51fa\\u7684\\u9ed1\\u767d\\u56fe\\u50cf\\u4ee5\\u201c1\\u201d\\u4ee3\\u8868\\u9ed1\\u8272\\uff0c\\u201c0\\u201d\\u4ee3\\u8868\\u767d\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"is-multiout==true\",\"mode==\\u9ed1\\u767d\"]},\"filter\":{\"category\":\"base\",\"title\":\"\\u7070\\u5ea6\\u6216\\u9ed1\\u767d\\u56fe\\u50cf - \\u9664\\u8272\\u4e0e\\u589e\\u5f3a\",\"desc\":\"\\u6d88\\u9664\\u6216\\u589e\\u5f3a\\u6307\\u5b9a\\u8272\\u5f69\",\"type\":\"string\",\"cur\":\"\\u4e0d\\u9664\\u8272\",\"default\":\"\\u4e0d\\u9664\\u8272\",\"size\":24,\"range\":[\"\\u4e0d\\u9664\\u8272\",\"\\u9664\\u7ea2\\u8272\",\"\\u9664\\u7eff\\u8272\",\"\\u9664\\u84dd\\u8272\",\"\\u7ea2\\u8272\\u589e\\u5f3a\",\"\\u7eff\\u8272\\u589e\\u5f3a\",\"\\u84dd\\u8272\\u589e\\u5f3a\"],\"depend_and\":[\"is-multiout!=true\",\"mode!=24\\u4f4d\\u5f69\\u8272\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-multiout-red\":{\"category\":\"base\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u591a\\u6d41\\u8f93\\u51fa\\u9664\\u7ea2\",\"desc\":\"\\u540c\\u65f6\\u8f93\\u51fa\\u5f69\\u8272\\u56fe\\u50cf\\u548c\\u7070\\u5ea6\\u9664\\u7ea2\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-answer-sheet-red\":{\"category\":\"base\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u7b54\\u9898\\u5361\\u9664\\u7ea2\",\"desc\":\"\\u8f93\\u51fa\\u9664\\u7ea2\\u5f69\\u8272\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\",\"
static std::string jsontext2("7df\\u53f3\\u4e0b\\u89d2y\\u5750\\u6807\",\"type\":\"float\",\"cur\":297.000000,\"default\":297.000000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":297.000000},\"depend_and\":[\"is-custom-area==true\"]},\"page\":{\"category\":\"base\",\"title\":\"\\u626b\\u63cf\\u9875\\u9762\",\"desc\":\"\\u8bbe\\u7f6e\\u9875\\u9762\\u626b\\u63cf\\u65b9\\u5f0f\",\"type\":\"string\",\"cur\":\"\\u53cc\\u9762\",\"default\":\"\\u53cc\\u9762\",\"size\":50,\"range\":[\"\\u5355\\u9762\",\"\\u53cc\\u9762\",\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u901a\\u7528\\uff09\",\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u53d1\\u7968\\u7eb8\\uff09\",\"\\u5bf9\\u6298\"]},\"blank-sensitivity\":{\"category\":\"base\",\"title\":\" \\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u7075\\u654f\\u5ea6\",\"desc\":\"\\u6570\\u503c\\u8d8a\\u5927\\uff0c\\u5219\\u8d8a\\u5bb9\\u6613\\u8df3\\u8fc7\",\"type\":\"int\",\"cur\":50,\"default\":50,\"size\":4,\"range\":{\"min\":1,\"max\":100},\"depend_or\":[\"page==\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u901a\\u7528\\uff09\",\"==\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u53d1\\u7968\\u7eb8\\uff09\"]},\"fold-type\":{\"category\":\"base\",\"title\":\"\\u5bf9\\u6298\\u6a21\\u5f0f\",\"desc\":\"\",\"type\":\"string\",\"cur\":\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"default\":\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"size\":50,\"range\":[\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"\\u4e0a\\u4e0b\\u5bf9\\u6298\",\"\\u81ea\\u52a8\\u5bf9\\u6298\"],\"depend_or\":[\"page==\\u5bf9\\u6298\"]},\"resolution\":{\"category\":\"base\",\"title\":\"\\u5206\\u8fa8\\u7387\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u56fe\\u50cf\\u7684\\u5206\\u8fa8\\u7387\",\"type\":\"int\",\"cur\":200,\"default\":200,\"size\":4,\"range\":{\"min\":1,\"max\":600}},\"is-exchange\":{\"category\":\"base\",\"title\":\"\\u4ea4\\u6362\\u6b63\\u53cd\\u9762\",\"desc\":\"\\u4ea4\\u6362\\u6bcf\\u5f20\\u6587\\u7a3f\\u7684\\u6b63\\u53cd\\u9762\\u51fa\\u56fe\\u987a\\u5e8f\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5355\\u9762\"]},\"grp-2\":{\"category\":\"base\",\"title\":\"\\u4eae\\u5ea6\",\"type\":\"group\"},\"is-custom-gamma\":{\"category\":\"base\",\"title\":\"\\u542f\\u7528\\u8272\\u8c03\\u66f2\\u7ebf\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u56fe\\u50cf\\u8272\\u8c03\\u6548\\u679c\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"brightness\":{\"category\":\"base\",\"title\":\"\\u4eae\\u5ea6\\u503c\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u4eae\\u5ea6\",\"type\":\"int\",\"cur\":128,\"default\":128,\"size\":4,\"range\":{\"min\":1,\"max\":255},\"depend_and\":[\"is-custom-gamma==false\"]},\"contrast\":{\"category\":\"base\",\"title\":\"\\u5bf9\\u6bd4\\u5ea6\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u5bf9\\u6bd4\\u5ea6\",\"type\":\"int\",\"cur\":4,\"default\":4,\"size\":4,\"range\":{\"min\":1,\"max\":7},\"depend_and\":[\"is-custom-gamma==false\"]},\"gamma\":{\"category\":\"base\",\"title\":\"\\u4f3d\\u9a6c\\u503c\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u4f3d\\u739b\\u503c\",\"type\":\"float\",\"cur\":1.000000,\"default\":1.000000,\"size\":4,\"range\":{\"min\":0.010000,\"max\":5.000000},\"depend_and\":[\"is-custom-gamma==false\"]},\"grp-3\":{\"category\":\"base\",\"title\":\"\\u56fe\\u50cf\\u5904\\u7406\",\"type\":\"group\"},\"is-anti-skew\":{\"category\":\"base\",\"title\":\"\\u81ea\\u52a8\\u7ea0\\u504f\",\"desc\":\"\\u81ea\\u52a8\\u7ea0\\u6b63\\u6b6a\\u659c\\u9001\\u5165\\u7684\\u6587\\u7a3f\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4,\"depend_or\":[\"page!=\\u5bf9\\u6298\"]},\"is-split\":{\"category\":\"base\",\"title\":\"\\u56fe\\u50cf\\u62c6\\u5206\",\"desc\":\"\\u81ea\\u52a8\\u62c6\\u5206\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"page!=\\u5bf9\\u6298\"]},\"is-photo-mode\":{\"category\":\"base\",\"title\":\"\\u7167\\u7247\\u6a21\\u5f0f\",\"desc\":\"\\u542f\\u7528\\u8be5\\u6a21\\u5f0f\\u53ef\\u4fdd\\u7559\\u56fe\\u50cf\\u539f\\u59cb\\u7ec6\\u8282\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"is-er
2022-10-28 10:42:22 +00:00
2022-11-15 02:46:41 +00:00
2022-05-03 03:56:07 +00:00
namespace settingsdsp_300
{
scanner_err device_status_to_hg_err(int usbdata)
2022-05-03 03:56:07 +00:00
{
scanner_err code = SCANNER_ERR_NO_DATA;
2022-05-03 03:56:07 +00:00
switch (usbdata)
{
case setting3288dsp::HAVE_IMAGE:
code = SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
break;
case setting3288dsp::STOP_SCAN:
code = SCANNER_ERR_DEVICE_STOPPED;
2022-05-03 03:56:07 +00:00
break;
case setting3288dsp::COUNT_MODE:
code = SCANNER_ERR_DEVICE_COUNT_MODE;
2022-05-03 03:56:07 +00:00
break;
case setting3288dsp::NO_FEED:
code = SCANNER_ERR_DEVICE_NO_PAPER;
2022-05-03 03:56:07 +00:00
break;
case setting3288dsp::OPEN_COVER:
code = SCANNER_ERR_DEVICE_COVER_OPENNED;
2022-05-03 03:56:07 +00:00
break;
case setting3288dsp::FEED_IN_ERROR:
code = SCANNER_ERR_DEVICE_FEEDING_PAPER;
2022-05-03 03:56:07 +00:00
break;
case setting3288dsp::PAPER_JAM:
code = SCANNER_ERR_DEVICE_PAPER_JAMMED;
2022-05-03 03:56:07 +00:00
break;
case setting3288dsp::DETECT_DOUBLE_FEED:
code = SCANNER_ERR_DEVICE_DOUBLE_FEEDING;
2022-05-03 03:56:07 +00:00
break;
case setting3288dsp::DETECT_STAPLE:
code = SCANNER_ERR_DEVICE_STAPLE_ON;
2022-05-03 03:56:07 +00:00
break;
case setting3288dsp::PAPER_SKEW:
code = SCANNER_ERR_DEVICE_PAPER_SKEW;
2022-05-03 03:56:07 +00:00
break;
case setting3288dsp::HARDWARE_ERROR:
code = SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
break;
case setting3288dsp::PC_SCAN_BUSY_or_ERROR:
code = SCANNER_ERR_DEVICE_PC_BUSY;
2022-05-03 03:56:07 +00:00
break;
case setting3288dsp::SIZE_ERROR:
code = SCANNER_ERR_DEVICE_SIZE_CHECK;
2022-05-03 03:56:07 +00:00
break;
default:
code = SCANNER_ERR_NO_DATA;
2022-05-03 03:56:07 +00:00
break;
}
return code;
}
}
hg_scanner_300::hg_scanner_300(const char* dev_name,int pid, usb_io* io) : hg_scanner(G100Serial, dev_name, io),papersize(pid)
2022-05-03 03:56:07 +00:00
{
pid_ = pid;
2022-05-03 03:56:07 +00:00
string fw = get_firmware_version();
2022-11-19 10:16:43 +00:00
if (atoi(fw.substr(4, 9).c_str()) >= 221106)
is_kernelsnap3288_221106_ = true;
else
is_kernelsnap3288_221106_ = false;
2022-05-03 03:56:07 +00:00
initdevice();
#ifndef MAPPING_FUNCTION_IN_BASE
2022-05-03 03:56:07 +00:00
init_setting_map(setting_map_, ARRAY_SIZE(setting_map_));//优先初始化
#endif
if (init_settings(0x300))
init_settings((jsontext1 + jsontext2).c_str());
2022-05-03 03:56:07 +00:00
printf_devconfig();
}
hg_scanner_300::~hg_scanner_300()
{}
int hg_scanner_300::on_scanner_closing(bool force)
{
return SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
}
void hg_scanner_300::thread_handle_usb_read(void)
{
int ret = SCANNER_ERR_OK,
status = SCANNER_ERR_OK;
StopWatch sw;
SANE_Image_Statu statu = SANE_Image_Statu_OK;
savestatus_.clear();
2022-05-03 03:56:07 +00:00
while (run_)
{
USBCB usb={0};
ret = get_scanner_status(usb);
//printf("usb.u32_Data = %d ret = %d\r\n",usb.u32_Data,ret);
////如果设备出现卡纸 或者双张等设备信息问题需要等到设备进行发送stop才能停止。 所以始终以 "停止" 消息为结束信号
////如果有图的情况下,并且卡纸或双张等,设备会先发送卡纸双张信息。所以接受到错误信息之后,仍需要把图像取出来。
if (ret == SCANNER_ERR_DEVICE_STOPPED)
2022-05-03 03:56:07 +00:00
{
if (!savestatus_.empty())
{
status_ = savestatus_[0]; //以第一个消息为准
}
else
{
status_ = SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
}
savestatus_.clear();
break;
}
if (ret != SCANNER_ERR_OK && ret != SCANNER_ERR_DEVICE_STOPPED && ret != SCANNER_ERR_NO_DATA)
2022-05-03 03:56:07 +00:00
{
statu = last_usb_image_statu(ret);
2022-05-03 03:56:07 +00:00
savestatus_.push_back(ret);
}
else
statu = SANE_Image_Statu_OK;
2022-05-03 03:56:07 +00:00
if (sw.elapsed_ms() > 30000)//防止状态信息一直取不上来导致卡死
{
if (!savestatus_.empty())
{
status_ = savestatus_[0];
}
else
{
status_ = SCANNER_ERR_TIMEOUT;
2022-05-03 03:56:07 +00:00
}
savestatus_.clear();
hg_log::log(LOG_LEVEL_WARNING, "get status timeout,get image out\n");
2022-05-03 03:56:07 +00:00
break;
}
if (ret == SCANNER_ERR_OK && usb.u32_Count > 0)
2022-05-03 03:56:07 +00:00
{
2022-08-04 03:36:37 +00:00
int totalNum = usb.u32_Count & 0x3fffffff; // 2022-08-04: 兼容Android默认图片大小均在1GB以内
if (totalNum)
{
2022-08-04 03:36:37 +00:00
std::shared_ptr<tiny_buffer> imagedata(aquire_memory(totalNum));
2022-05-03 03:56:07 +00:00
2022-08-04 03:36:37 +00:00
if (!imagedata.get())
{
status_ = SCANNER_ERR_INSUFFICIENT_MEMORY;
break;
}
2022-05-03 03:56:07 +00:00
2022-08-04 03:36:37 +00:00
imagedata->set_image_statu(statu);
ret = get_img_data(imagedata);
//io_->set_timeout(200);
if (ret == SCANNER_ERR_OK)
{
ret = pop_image();
sw.reset();
if (ret != SCANNER_ERR_OK)
{
status_ = ret;
break;
}
}
else
2022-05-03 03:56:07 +00:00
{
status_ = ret;
break;
}
}
}
this_thread::sleep_for(chrono::milliseconds(10));
}
}
int hg_scanner_300::start(void)
{
bool handled = false;
int ret = try_third_app_handle_start(handled),
2022-05-03 03:56:07 +00:00
count = -1;
user_cancel_ = false;
2022-05-03 03:56:07 +00:00
// for third-sane-app invoking, added on 2022-05-19
if (handled)
return ret;
2022-05-03 03:56:07 +00:00
ret = writedown_device_configuration(true);
if (ret == SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
writedown_image_configuration();
else
{
status_ = ret;
return ret;
}
printf_devconfig();
ret = get_scan_is_sleep();
if (ret == SCANNER_ERR_DEVICE_SLEEPING)
2022-05-03 03:56:07 +00:00
{
status_ = ret;
notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING, SANE_EVENT_ERROR, status_);
2022-08-22 06:46:35 +00:00
notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_NOTIFY_SLEEP, SANE_EVENT_ERROR, status_);
VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING);
2022-05-03 03:56:07 +00:00
return ret;
}
ret = get_scanner_paperon();
if (ret == SCANNER_ERR_DEVICE_NO_PAPER)
2022-05-03 03:56:07 +00:00
{
status_ = ret;
notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER, SANE_EVENT_ERROR, status_);
VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER);
2022-05-04 03:07:55 +00:00
return ret;
2022-05-03 03:56:07 +00:00
}
USBCB usb = { setting3288dsp::START_COMMAND, img_conf_.scannum, 0};
2022-05-03 03:56:07 +00:00
ret = writeusb(usb);
2022-08-04 03:36:37 +00:00
//io_->set_timeout(500);
if(ret == SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
//status_ = SCANNER_ERR_DEVICE_BUSY;
2022-05-03 03:56:07 +00:00
wait_usb_.notify();
std::this_thread::sleep_for(std::chrono::milliseconds(300));
ret = try_third_app_after_start(ret);
2022-05-03 03:56:07 +00:00
}
else
status_ = ret;
VLOG_MINI_1(LOG_LEVEL_WARNING, "start result: %s\n", hg_scanner_err_name(ret));
2022-05-03 03:56:07 +00:00
return ret;
}
int hg_scanner_300::stop(void)
{
int ret = SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
USBCB usbcb = { setting3288dsp::STOP, 0, 0};
2022-05-03 03:56:07 +00:00
ret = writeusb(usbcb);
if (status_ == SCANNER_ERR_DEVICE_BUSY)
2022-05-03 03:56:07 +00:00
{
LOG_INFO(LOG_LEVEL_DEBUG_INFO,"stop status is busy\r\n");
2022-05-03 03:56:07 +00:00
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
}
2022-06-07 10:06:28 +00:00
user_cancel_ = true;
if (ret == SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
status_ = SCANNER_ERR_DEVICE_STOPPED;
2022-05-03 03:56:07 +00:00
}
//final_imgs_.clear();
2022-05-03 03:56:07 +00:00
return status_;
}
int hg_scanner_300::writeusb(USBCB &usb)
{
std::lock_guard<std::mutex> lock(io_lock_);
int ret = SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
int len = sizeof(usb);
ret = io_->write_bulk(&usb,&len);
if (ret)
{
status_ = ret;
}
return ret;
}
int hg_scanner_300::readusb(USBCB &usb)
{
std::lock_guard<std::mutex> lock(io_lock_);
int ret = SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
int len = sizeof(USBCB);
ret = io_->read_bulk(&usb,&len);
if (ret)
{
status_ = ret;
}
return ret;
}
int hg_scanner_300::pop_image()
{
int ret = SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
USBCB usbcb = { setting3288dsp::POP_IMAGE, 0, 0};
2022-05-03 03:56:07 +00:00
ret = writeusb(usbcb);
return ret;
}
int hg_scanner_300::get_scanner_status(USBCB &usb)
{
int ret = SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
usb = { setting3288dsp::GET_DSP_STATUS, 0, 0};
2022-05-03 03:56:07 +00:00
ret = writeusb(usb);
if (ret != SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
return ret;
2022-08-04 03:36:37 +00:00
//io_->set_timeout(200); //必要延时,且不能小于这个数值
2022-05-03 03:56:07 +00:00
ret = readusb(usb);
if (ret != SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
status_ = ret;
return ret;
}
scanner_err code = settingsdsp_300::device_status_to_hg_err(usb.u32_Data);
2022-05-03 03:56:07 +00:00
return code ;
}
int hg_scanner_300::get_img_data(std::shared_ptr<tiny_buffer> &imagedata)
2022-05-03 03:56:07 +00:00
{
int total = imagedata->size(),
ret = SCANNER_ERR_OK,
2022-05-03 03:56:07 +00:00
index = 0,
block = total;
USBCB usb{ setting3288dsp::GET_IMAGE, 0, total};
2022-05-03 03:56:07 +00:00
ret = writeusb(usb);
if (ret != SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
status_ = ret;
return ret;
}
2022-08-04 03:36:37 +00:00
//io_->set_timeout(500);
2022-05-03 03:56:07 +00:00
printf_devconfig();
while (total > 0)
{
block = 512 * 1024;
if (total < block)
block = total;
unsigned int size = block;
void* buf = imagedata->data(index, &size);
if (!buf)
{
VLOG_MINI_3(LOG_LEVEL_FATAL, "memory(0x%08x + %u) fatal when read USB image %d !!!\n", index, block, usb_img_index_);
ret = SCANNER_ERR_INSUFFICIENT_MEMORY;
break;
}
block = size;
ret = io_->read_bulk(buf, &block);
2022-05-03 03:56:07 +00:00
if (ret != SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
status_ = ret;
return ret;
}
index += block;
total -= block;
}
if (ret == SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
ret = save_usb_data(imagedata);
}
status_ = ret;
return ret;
}
int hg_scanner_300::writedown_device_configuration(bool type,setting_hardware::HGSCANCONF_3288 *d)
2022-05-03 03:56:07 +00:00
{
if (!type)
return SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
int ret = SCANNER_ERR_OK,
2022-05-03 03:56:07 +00:00
len = 0;
2022-11-19 10:16:43 +00:00
SIZE size;
2022-05-03 03:56:07 +00:00
if (!d)
{
dsp_config.params_3288.lutmode = keep_watermark_;
2022-05-03 03:56:07 +00:00
d = &dsp_config;
}
2022-11-19 10:16:43 +00:00
if (is_multiout)
{
d->params_3288.isColor = image_prc_param_.bits.multi_out == MULTI_COLOR_AND_BW ? 0 : 1;
}
else if ((image_prc_param_.bits.color_mode == COLOR_MODE_256_GRAY
|| image_prc_param_.bits.color_mode == COLOR_MODE_BLACK_WHITE)
&& image_prc_param_.bits.rid_color != RID_COLOR_NONE)
{
d->params_3288.isColor = 1;
}
2022-11-23 14:58:22 +00:00
if (paper_size_ == TwSS::USStatement || paper_size_ == TwSS::MaxSize)
2022-11-19 10:16:43 +00:00
{
2022-11-23 14:58:22 +00:00
d->params_3288.pageSize = setting3288dsp::G400_MAXSIZE;
2022-11-19 10:16:43 +00:00
}
size = papersize.GetPaperSize(TwSS::A4, 200, img_conf_.paperAlign);
dsp_config.params_3288.dstHeight = (int)((size.cy + 200) / 100);
2022-05-03 03:56:07 +00:00
USBCB usbcb = { setting3288dsp::CONFIGURED_DATA, d->value, 0};
2022-05-03 03:56:07 +00:00
len = sizeof(USBCB);
ret = io_->write_bulk(&usbcb,&len);
VLOG_MINI_1(LOG_LEVEL_WARNING, "writedown_device_configuration is .(%s)\n", hg_scanner_err_name(ret));
2022-05-03 03:56:07 +00:00
return ret;
}
int hg_scanner_300::on_color_mode_changed(int& color_mode)
{
2022-11-19 10:16:43 +00:00
dsp_config.params_3288.isColor = (color_mode == COLOR_MODE_BLACK_WHITE || color_mode == COLOR_MODE_256_GRAY) ? 0 : 1;
return SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
}
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_),
ret = exact ? SCANNER_ERR_OK : SCANNER_ERR_NOT_EXACT;
2022-05-03 03:56:07 +00:00
if (dsp_config.params_3288.pageSize != paper_map_3288[ind].dev_value)
2022-05-03 03:56:07 +00:00
{
int old = dsp_config.params_3288.pageSize;
2022-05-03 03:56:07 +00:00
dsp_config.params_3288.pageSize = paper_map_3288[ind].dev_value;
2022-05-03 03:56:07 +00:00
ret = writedown_device_configuration();
if (ret)
{
dsp_config.params_3288.pageSize = old;
for (int i = 0; i < ARRAY_SIZE(paper_map_3288); ++i)
2022-05-03 03:56:07 +00:00
{
if (paper_map_3288[i].dev_value == old)
2022-05-03 03:56:07 +00:00
{
paper = paper_map_3288[i].paper;
2022-05-03 03:56:07 +00:00
break;
}
}
}
else if (!exact)
ret = SCANNER_ERR_NOT_EXACT;
2022-05-03 03:56:07 +00:00
}
return ret;
}
int hg_scanner_300::on_paper_check_changed(bool& check)
{
int ret = SCANNER_ERR_OK;
if(dsp_config.params_3288.enableSizeDetect ^ check)
2022-05-03 03:56:07 +00:00
{
dsp_config.params_3288.enableSizeDetect = check;
2022-05-03 03:56:07 +00:00
ret = writedown_device_configuration();
if (ret)
{
dsp_config.params_3288.enableSizeDetect = !check;
check = dsp_config.params_3288.enableSizeDetect;
2022-05-03 03:56:07 +00:00
}
}
return ret;
}
int hg_scanner_300::on_resolution_changed(int& dpi)
{
int ret = SCANNER_ERR_OK;
dsp_config.params_3288.dpi = is_kernelsnap3288_221106_ ? (dsp_config.params_3288.dpi = (dpi > 200) ? 2 : 1) : 1;//暂时还未有固件支持
2022-11-19 10:16:43 +00:00
2022-05-03 03:56:07 +00:00
ret = writedown_device_configuration();
return ret;
}
int hg_scanner_300::on_ultrasonic_check_changed(bool& check)
{
int ret = SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
if (dsp_config.params_3288.doubleFeeded ^ check)
2022-05-03 03:56:07 +00:00
{
dsp_config.params_3288.doubleFeeded = check;
2022-05-03 03:56:07 +00:00
ret = writedown_device_configuration();
if (ret)
{
dsp_config.params_3288.doubleFeeded = !check;
check = dsp_config.params_3288.doubleFeeded;
2022-05-03 03:56:07 +00:00
}
}
return ret;
}
int hg_scanner_300::agreement(TwSS tw,int align)
{
int ret = SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
SIZE size;
setting_hardware::HGSCANCONF_3288 d = dsp_config;
2022-05-03 03:56:07 +00:00
size = papersize.GetPaperSize(TwSS::A4,200,align);
dsp_config.params_3288.dstHeight = (int)((size.cy + 200)/100);
2022-05-03 03:56:07 +00:00
ret = writedown_device_configuration(true,&d);
return ret;
}
int hg_scanner_300::initdevice()
{
dsp_config.value = 0;
dsp_config.params_3288.enableLed = 1;
dsp_config.params_3288.isCorrect = 1;
dsp_config.params_3288.reversed1 = 0;
dsp_config.params_3288.reversed2 = 0;
dsp_config.params_3288.enableSizeDetect =0;
2022-05-03 03:56:07 +00:00
writedown_device_configuration(true);
printf_devconfig();
return SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
}
void hg_scanner_300::writedown_image_configuration(void)
{
SCANCONF ic;
2022-11-19 10:16:43 +00:00
int len = sizeof(ic);
bzero(&ic, len);
ic.contrast = contrast_;
ic.brightness = bright_;
2022-11-23 11:00:17 +00:00
if (image_prc_param_.bits.text_direction != TEXT_DIRECTION_AUTO)
ic.imageRotateDegree = image_prc_param_.bits.text_direction;
else
ic.imageRotateDegree = 0;
2022-11-19 10:16:43 +00:00
if (test_1_paper_)
{
LOG_INFO(LOG_LEVEL_DEBUG_INFO, "scanning mode: testing ONE paper ...\n");
ic.scannum = 1;
}
else
ic.scannum = scan_count_;
ic.en_sizecheck = dsp_config.params_3288.enableSizeDetect;
ic.hardwarecaps.en_skrewdetect = 0;
ic.hardwarecaps.en_doublefeed = dsp_config.params_3288.doubleFeeded;
ic.hardwarecaps.en_stapledetect = 0;
ic.hardwarecaps.skrewdetectlevel = 0;
// ic.hardwarecaps.is_autopaper = dsp_config_.params_dsp.is_autopaper;
ic.hardwarecaps.capturepixtype = 0; //暂无参数 获取图像类型
ic.hardwarecaps.lowpowermode = LowPowerMode::Min_None; //暂无参数 设置休眠时间 两个参数3399未使用
image_configuration(ic);
//int ret = agreement((TwSS)img_conf_.papertype, img_conf_.paperAlign);
/*SCANCONF ic;
2022-05-03 03:56:07 +00:00
ic.papertype = paper_size_;
if (is_lateral(image_prc_param_.bits.paper))
ic.paperAlign = Rot270;
// else if (image_prc_param_.bits.text_direction == TEXT_DIRECTION_AUTO)
// ic.paperAlign = AutoTextOrientation;
2022-05-03 03:56:07 +00:00
else
ic.paperAlign = Rot0;
ic.en_sizecheck = dsp_config.params_3288.enableSizeDetect;
2022-05-11 03:27:11 +00:00
if (image_prc_param_.bits.text_direction != TEXT_DIRECTION_AUTO)
ic.imageRotateDegree = image_prc_param_.bits.text_direction;
else
ic.imageRotateDegree = 0;
2022-05-11 03:27:11 +00:00
2022-05-03 03:56:07 +00:00
ic.is_duplex = (image_prc_param_.bits.page == PAGE_DOUBLE || image_prc_param_.bits.page == PAGE_OMIT_EMPTY ||
image_prc_param_.bits.page == PAGE_OMIT_EMPTY_RECEIPT || image_prc_param_.bits.page ==PAGE_FOLIO);
ic.en_fold = (image_prc_param_.bits.page == PAGE_FOLIO);
ic.pixtype = image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH ? 2 : image_prc_param_.bits.color_mode;
ic.automaticcolor = is_auto_matic_color;
ic.automaticcolortype = 1;// ic.pixtype; //存疑
ic.resolution_dst = resolution_;
ic.resolution_native = 200;
ic.gamma = (float)gamma_;
ic.contrast = (float)contrast_ ;
ic.brightness = (float)bright_ ;
ic.threshold = threshold_;
ic.is_autocontrast = 0; //无参数
ic.is_autocrop = (ic.papertype == TwSS::None || ic.papertype ==TwSS::USStatement);
ic.is_autodiscradblank_normal = image_prc_param_.bits.page == PAGE_OMIT_EMPTY;
ic.discardblank_percent = omit_empty_level_ > 70 ? 70 : omit_empty_level_; //默认20
ic.is_autodiscradblank_vince = image_prc_param_.bits.page == PAGE_OMIT_EMPTY_RECEIPT;
ic.is_switchfrontback = image_prc_param_.bits.exchange;
ic.autodescrew = image_prc_param_.bits.automatic_skew;
ic.multi_output_red = image_prc_param_.bits.rid_red;
ic.hsvcorrect = image_prc_param_.bits.rid_answer_red;
ic.sharpen = image_prc_param_.bits.sharpen;
//ic.enhance_color = image_prc_param_.bits.rid_color;
ic.fillbackground = image_prc_param_.bits.erase_black_frame;
ic.is_convex = (image_prc_param_.bits.fill_background == FILL_BKG_CONVEX_POLYGON);
ic.noise = image_prc_param_.bits.noise_optimize;
ic.indent = margin_;
ic.AutoCrop_threshold = threshold_;
if (test_1_paper_)
{
LOG_INFO(LOG_LEVEL_DEBUG_INFO, "scanning mode: testing ONE paper ...\n");
2022-05-03 03:56:07 +00:00
ic.scannum = 1;
}
else
{
ic.scannum = scan_count_;
}
ic.is_backrotate180 = image_prc_param_.bits.rotate_back_180;
ic.is_dogeardetection = image_prc_param_.bits.fractate_check;
ic.hardwarecaps.en_skrewdetect = 0;
ic.hardwarecaps.en_doublefeed = dsp_config.params_3288.doubleFeeded;
2022-05-03 03:56:07 +00:00
ic.hardwarecaps.en_stapledetect = 0;
ic.hardwarecaps.skrewdetectlevel = 0;
// ic.hardwarecaps.is_autopaper = dsp_config.params_3288.is_autopaper;
2022-05-03 03:56:07 +00:00
ic.hardwarecaps.capturepixtype = 0; //暂无参数 获取图像类型
ic.hardwarecaps.lowpowermode = LowPowerMode::Min_None; //暂无参数 设置休眠时间 两个参数3399未使用
ic.fillhole.is_fillhole = image_prc_param_.bits.rid_hole;
ic.fillhole.fillholeratio = rid_hole_range_;
adjust_filling_hole(&ic);
2022-05-03 03:56:07 +00:00
ic.detachnoise.is_detachnoise = image_prc_param_.bits.noise_optimize;
ic.detachnoise.detachnoise = noise_range_;
2022-05-11 03:27:11 +00:00
ic.is_autotext = image_prc_param_.bits.text_direction == TEXT_DIRECTION_AUTO ? 1 :0;
2022-05-20 07:53:40 +00:00
ic.isfillcolor = is_color_fill;
2022-05-03 03:56:07 +00:00
ic.refuseInflow = image_prc_param_.bits.is_permeate;
ic.colorCorrection = 0;
ic.removeMorr = image_prc_param_.bits.remove_morr;
ic.errorExtention = image_prc_param_.bits.error_extention ;//暂无参数
ic.textureRemove = image_prc_param_.bits.remove_txtture;//暂无参数
ic.splitImage = image_prc_param_.bits.split;
2022-05-07 07:39:48 +00:00
ic.cropRect.enable = custom_area_;
int height = (custom_area_br_y_ *ic.resolution_dst) /25.4 - (custom_area_lt_y_ *ic.resolution_dst /25.4);
int width = (custom_area_br_x_ *ic.resolution_dst) /25.4 - (custom_area_lt_x_ *ic.resolution_dst /25.4);
ic.cropRect.height = height;
ic.cropRect.width = width;
2022-05-07 07:39:48 +00:00
ic.cropRect.x = custom_area_lt_x_ *ic.resolution_dst /25.4;
ic.cropRect.y = custom_area_lt_y_ *ic.resolution_dst /25.4;
2022-08-20 03:18:34 +00:00
ic.multiOutput = (MultiOutput)image_prc_param_.bits.multi_out;
if (!is_multiout)
{
ic.multiOutput = MultiOutput::Unused;
}
2022-05-03 03:56:07 +00:00
ic.normalCrop = image_prc_param_.bits.dark_sample;
ic.dogeardistabce = fractate_level_;
ic.fadeback = image_prc_param_.bits.erase_bakground;
ic.fadebackrange = erase_bkg_range_;
2022-07-28 06:03:20 +00:00
ic.isuoloadexceptionimage = (double_paper_handle_ & DOUBLE_PAPER_SAVE_IMG) == DOUBLE_PAPER_SAVE_IMG;
2022-10-28 10:42:22 +00:00
ic.fold_concatmode = fold_type_;
2022-05-03 03:56:07 +00:00
int filter_clr[] = { 3, 0, 1, 2, 5, 6, 7 };
if(image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS || image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH)
ic.filter = 3;
else
{
ic.filter = filter_clr[image_prc_param_.bits.rid_color];
// if(ic.filter != 3)
// ic.pixtype = 2;
ic.hsvcorrect = 0;
ic.multi_output_red = 0;
ic.multiOutput = MultiOutput::Unused;
ic.fadeback = false;
}
2022-06-15 02:35:09 +00:00
//多留输出的处理
if (image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW && is_multiout)
{
ic.pixtype = 1;
}
else if ((image_prc_param_.bits.multi_out == MULTI_OUT_ALL ||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_GRAY||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_BW) && is_multiout)
{
ic.pixtype = 2;
2022-06-15 02:35:09 +00:00
}
if (is_multiout)
{
ic.hsvcorrect = 0;
ic.multi_output_red = 0;
ic.fadeback = false;
ic.sharpen = 0;
ic.removeMorr = 0;
ic.textureRemove = 0;
ic.errorExtention = 0;
ic.detachnoise.is_detachnoise = 0;
}
2022-06-15 02:35:09 +00:00
if (ic.pixtype == 0)
{
ic.hsvcorrect = 0;
ic.multi_output_red = 0;
ic.fadeback = false;
ic.sharpen = 0;
ic.removeMorr = 0;
ic.textureRemove = 0;
}
//自定义裁切
if (image_prc_param_.bits.paper == PAPER_AUTO_MATCH
||image_prc_param_.bits.paper == PAPER_MAX_SIZE
||image_prc_param_.bits.paper == PAPER_MAX_SIZE_CLIP
||image_prc_param_.bits.paper == PAPER_TRIGEMINY
)
{
ic.cropRect.enable = false;
}
2022-05-03 03:56:07 +00:00
2022-06-15 02:35:09 +00:00
img_conf_ = ic;
2022-05-03 03:56:07 +00:00
int ret = agreement((TwSS)img_conf_.papertype,img_conf_.paperAlign);
if (ret != SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
status_ = ret;
return ;
}
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.pixtype=%d", ic.pixtype);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.papertype=%d", ic.papertype);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.AutoCrop_threshold=%d", ic.AutoCrop_threshold);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.autodescrew=%d", ic.autodescrew);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.automaticcolor=%d", ic.automaticcolor);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.brightness=%f", ic.brightness);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.contrast=%f", ic.contrast);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_fold=%d", ic.en_fold);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_sizecheck=%d", ic.en_sizecheck);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.enhance_color=%d", ic.enhance_color);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillbackground=%d", ic.fillbackground);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.filter=%d", ic.filter);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.gamma=%f", ic.gamma);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.capturepixtype=%d", ic.hardwarecaps.capturepixtype);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.en_doublefeed=%d", ic.hardwarecaps.en_doublefeed);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hsvcorrect=%d", ic.hsvcorrect);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.imageRotateDegree=%f", ic.imageRotateDegree);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.indent=%d", 5);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocontrast=%d", ic.is_autocontrast);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocrop=%d", ic.is_autocrop);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_normal=%d", ic.is_autodiscradblank_normal);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_vince=%d", ic.is_autodiscradblank_vince);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autotext=%d", ic.is_autotext);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_backrotate180=%d", ic.is_backrotate180);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_convex=%d", ic.is_convex);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_duplex=%d", ic.is_duplex);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_switchfrontback=%d", ic.is_switchfrontback);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_dogeardetection=%d", ic.is_dogeardetection);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.multi_output_red=%d", ic.multi_output_red);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.noise=%d", 8);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_dst=%f", ic.resolution_dst);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_native=%f", ic.resolution_native);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.scannum=%d", ic.scannum);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.sharpen=%d", ic.sharpen);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.discardblank_percent=%d", ic.discardblank_percent);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.is_detachnoise=%d", ic.detachnoise.is_detachnoise);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.detachnoise=%d\r ", ic.detachnoise.detachnoise);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.refuseInflow=%d\r ", ic.refuseInflow);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.refuseInflow=%d\r ", ic.refuseInflow);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.removeMorr=%d\r ", ic.removeMorr);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.errorExtention=%d\r ", ic.errorExtention);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.textureRemove=%d\r\n ", ic.textureRemove);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.is_fillhole=%d\r\n ", ic.fillhole.is_fillhole);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.ic.fillhole.fillholeratio=%f\r\n ", ic.fillhole.fillholeratio);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fadeback=%d\r\n ",ic.fadeback);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.enable=%d\r\n ",ic.cropRect.enable);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.height=%d\r\n ",ic.cropRect.height);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.width=%d\r\n ",ic.cropRect.width);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.x=%d\r\n ",ic.cropRect.x);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.y=%d\r\n ",ic.cropRect.y);
2022-11-19 10:16:43 +00:00
*/
2022-05-03 03:56:07 +00:00
}
void hg_scanner_300::printf_devconfig(setting_hardware::HGSCANCONF_3288 *d)
2022-05-03 03:56:07 +00:00
{
if (!d)
d = &dsp_config;
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\r\ndsp_config.params_3288.doubleFeeded:%d\r\n",d->params_3288.doubleFeeded);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params_3288.dpi:%d\r\n",d->params_3288.dpi);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params_3288.dstHeight:%d\r\n",d->params_3288.dstHeight);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params_3288.enableLed:%d\r\n",d->params_3288.enableLed);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params_3288.enableStable:%d\r\n",d->params_3288.enableStable);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params_3288.isColor:%d\r\n",d->params_3288.isColor);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params_3288.isCorrect:%d\r\n",d->params_3288.isCorrect);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params_3288.pageSize:%d\r\n",d->params_3288.pageSize);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params_3288.reversed1:%d\r\n",d->params_3288.reversed1);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params_3288.reversed2:%d\r\n",d->params_3288.reversed2);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params_3288.enableSizeDetect:%d\r\n",d->params_3288.enableSizeDetect);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params_3288.value:%d\r\n",d->value);
2022-05-03 03:56:07 +00:00
}
std::string hg_scanner_300::get_firmware_version()
{
char buf[20] = { 0 };
int ret = SCANNER_ERR_OK,
2022-05-03 03:56:07 +00:00
len = 10; //协议定义长度为10 100 200 =8
USBCB cmd = { setting3288dsp::GET_FW_VERSION,len,0,};
2022-05-03 03:56:07 +00:00
ret = writeusb(cmd);
ret = io_->read_bulk(buf, &len);
return buf;
}
std::string hg_scanner_300::get_serial_num()
{
string SerialNum = "";
int ret = SCANNER_ERR_OK,
2022-05-03 03:56:07 +00:00
len = 14;
SerialNum.resize(len);
USBCB cmd = { setting3288dsp::GET_SERIAL,len,0,};
2022-05-03 03:56:07 +00:00
ret = writeusb(cmd);
std::lock_guard<std::mutex> lock(io_lock_);
ret = io_->read_bulk(&SerialNum[0],&len);
if (ret != SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
return "0000000000000000000";
}
return SerialNum;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int hg_scanner_300::set_leaflet_scan(void)
{
int ret = SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
test_1_paper_ = true;
ret = start();
return ret;
}
int hg_scanner_300::get_abuot_info(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::restore_default_setting(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::set_final_image_format(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::get_compression_format(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::set_compression_format(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::set_auto_color_type(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::get_device_code(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::get_sleep_time(SANE_Power* getime)
{
int ret = SCANNER_ERR_OK,
2022-05-03 03:56:07 +00:00
len = 0;
USBCB usbcb = { setting3288dsp::GET_SLEEP_TIME, 0, 0};
2022-05-03 03:56:07 +00:00
ret = writeusb(usbcb);
if (ret != SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
return ret;
}
len = sizeof(usbcb);
ret = io_->read_bulk(&usbcb,&len);
if (ret == SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
if (getime)
{
*getime = (SANE_Power)usbcb.u32_Data;
}
if (usbcb.u32_Data)
{
return SCANNER_ERR_DEVICE_SLEEPING;
2022-05-03 03:56:07 +00:00
}
}
return ret;
}
int hg_scanner_300::set_sleep_time(SANE_Power* setime)
{
if (!setime)
{
return SCANNER_ERR_NO_DATA;
2022-05-03 03:56:07 +00:00
}
int ret = SCANNER_ERR_OK,
2022-05-03 03:56:07 +00:00
time = *setime;
USBCB usbcb = { setting3288dsp::SET_SLEEP_TIME,time, 0};
2022-05-03 03:56:07 +00:00
ret = writeusb(usbcb);
return ret;
}
int hg_scanner_300::get_dogear_distance(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::set_dogear_distance(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::get_scanner_paperon(SANE_Bool* paperon)
{
int ret = SCANNER_ERR_OK,
2022-05-03 03:56:07 +00:00
len = 0;
USBCB usbcb = { setting3288dsp::GET_PAPER_STATUS, 0, 0};
2022-05-03 03:56:07 +00:00
len = sizeof(USBCB);
ret = writeusb(usbcb);
2022-08-04 03:36:37 +00:00
//io_->set_timeout(500);
2022-05-03 03:56:07 +00:00
if (ret == SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
ret = io_->read_bulk(&usbcb,&len);
}
if (ret != SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
return ret;
}
if (usbcb.u32_Data == 0)
ret = SCANNER_ERR_DEVICE_NO_PAPER;
2022-05-03 03:56:07 +00:00
else
ret = SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
if (paperon)
{
*paperon = usbcb.u32_Data;
}
return ret;
}
int hg_scanner_300::set_scan_when_paper_on(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::get_scan_when_paper_on(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::get_scan_with_hole(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::set_scan_with_hole(void)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::get_scan_is_sleep()
{
int ret = SCANNER_ERR_OK,
2022-05-03 03:56:07 +00:00
len = 0;
USBCB usbcb = {0x100, 0, 0};
len = sizeof(USBCB);
ret = writeusb(usbcb);
2022-08-04 03:36:37 +00:00
//io_->set_timeout(200);
2022-05-03 03:56:07 +00:00
if (ret == SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
ret = io_->read_bulk(&usbcb,&len);
}
if (ret != SCANNER_ERR_OK)
2022-05-03 03:56:07 +00:00
{
return ret;
}
if (usbcb.u32_Data == 0x10)
{
return SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
}
else if (usbcb.u32_Data == 0x100)
{
return SCANNER_ERR_DEVICE_SLEEPING;
2022-05-03 03:56:07 +00:00
}
}
///此款设备无此功能
int hg_scanner_300::on_staple_check_changed(bool& check)
{
return SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::on_skew_check_changed(bool& check)
{
return SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::on_skew_check_level_changed(int& check)
{
return SCANNER_ERR_OK;
2022-05-03 03:56:07 +00:00
}
int hg_scanner_300::on_set_feedmode(int feedmode)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
int hg_scanner_300::on_get_feedmode(int &feedmode)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
int hg_scanner_300::get_device_log(string &log)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
int hg_scanner_300::notify_sleep()
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-05-03 03:56:07 +00:00
}