From 1f65d4d014e760900bfdeb92c2797d3778a90110 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Tue, 14 Nov 2023 14:38:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=84=B1=E6=9C=BA=E5=B1=9E=E6=80=A7=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E5=9C=A8=E9=A9=B1=E5=8A=A8=E4=B8=AD=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E5=9C=A8=E6=89=93=E5=BC=80=E7=9A=84=E8=AE=BE=E5=A4=87=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E6=9C=89=E8=AE=BE=E5=A4=87=E5=8F=A5=E6=9F=84=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=86=8D=E5=9C=A8SANE=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E5=B1=82=E5=8D=95=E7=8B=AC=E6=B7=BB=E5=8A=A0=EF=BC=9B=E7=BC=A9?= =?UTF-8?q?=E7=9F=AD=E6=B8=85=E7=A9=BA=E4=B8=8A=E6=AC=A1=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hgdriver/hgdev/hg_scanner_239.cpp | 5 +++-- hgsane/sane_hg_mdw.cpp | 28 ++++++++++++++------------ twain/ds/scanner.cpp | 33 +++++++------------------------ 3 files changed, 25 insertions(+), 41 deletions(-) diff --git a/hgdriver/hgdev/hg_scanner_239.cpp b/hgdriver/hgdev/hg_scanner_239.cpp index 062c6f2..b8ec5d0 100644 --- a/hgdriver/hgdev/hg_scanner_239.cpp +++ b/hgdriver/hgdev/hg_scanner_239.cpp @@ -801,7 +801,7 @@ int hg_scanner_239::discard_all_images(void) str.resize(block); { char buf[64]; - int size = sizeof(buf); + int size = sizeof(buf), to = io_->set_timeout(50); ret = SCANNER_ERR_OK; setting3399::HGEIntInfo* info = (setting3399::HGEIntInfo*)buf; { @@ -826,8 +826,9 @@ int hg_scanner_239::discard_all_images(void) ret = io_->read_interrupt(buf, &size); } } + io_->set_timeout(to); } - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); if (pre_int) utils::to_log(LOG_LEVEL_DEBUG, "prev-connection has left %d interrupt packet(s) && %d image(s).\n", pre_int, pre_img); diff --git a/hgsane/sane_hg_mdw.cpp b/hgsane/sane_hg_mdw.cpp index b8477a5..9ae166a 100644 --- a/hgsane/sane_hg_mdw.cpp +++ b/hgsane/sane_hg_mdw.cpp @@ -504,7 +504,7 @@ SANE_Status hg_sane_middleware::get_current_value(LPDEVINST inst, const void* op std::string val(""); SANE_Option_Descriptor* desc = inst->opts->get_opt_descriptor(opt); - if (!desc && inst != offline_) + /*if (!desc && inst != offline_) { desc = offline_->opts->get_opt_descriptor(opt, nullptr, inst->opts->get_option_count()); if (desc) @@ -512,7 +512,7 @@ SANE_Status hg_sane_middleware::get_current_value(LPDEVINST inst, const void* op else return SANE_STATUS_INVAL; } - else if (!desc) + else*/ if (!desc) { return SANE_STATUS_INVAL; } @@ -533,7 +533,7 @@ SANE_Status hg_sane_middleware::set_value(LPDEVINST inst, const void* opt, void* bool empty_value = false; SANE_Option_Descriptor* desc = inst->opts->get_opt_descriptor(opt); - if (!desc && inst != offline_) + /*if (!desc && inst != offline_) { desc = offline_->opts->get_opt_descriptor(opt, nullptr, inst->opts->get_option_count()); if (desc) @@ -541,7 +541,7 @@ SANE_Status hg_sane_middleware::set_value(LPDEVINST inst, const void* opt, void* else return SANE_STATUS_INVAL; } - else if (!desc) + else*/ if (!desc) { return SANE_STATUS_INVAL; } @@ -568,10 +568,11 @@ SANE_Status hg_sane_middleware::get_option_fixed_id(LPDEVINST inst, const void* { int fix_id = 0; - if (!inst->opts->get_opt_descriptor(opt, &fix_id) && inst != offline_) - { - offline_->opts->get_opt_descriptor(opt, &fix_id, inst->opts->get_option_count()); - } + inst->opts->get_opt_descriptor(opt, &fix_id); + //if (!inst->opts->get_opt_descriptor(opt, &fix_id) && inst != offline_) + //{ + // offline_->opts->get_opt_descriptor(opt, &fix_id, inst->opts->get_option_count()); + //} *(SANE_Int*)value = fix_id; return fix_id <= 0 ? SANE_STATUS_INVAL : SANE_STATUS_GOOD; @@ -761,8 +762,8 @@ SANE_Option_Descriptor* hg_sane_middleware::get_option_descriptor(SANE_Handle h, base_ind = dev->opts->get_option_count(); ret = dev->opts->get_opt_descriptor(option); } - - if (!ret) + else + //if (!ret) ret = offline_->opts->get_opt_descriptor(option, nullptr, base_ind); return ret; @@ -784,7 +785,7 @@ SANE_Status hg_sane_middleware::control_option(SANE_Handle h, const void* option { if (!option) { - *(SANE_Int*)value = inst->opts->get_option_count() + offline_->opts->get_option_count(); + *(SANE_Int*)value = inst->opts->get_option_count(); // +offline_->opts->get_option_count(); err = SANE_STATUS_GOOD; } else @@ -827,8 +828,9 @@ SANE_Status hg_sane_middleware::control_option(SANE_Handle h, const void* option else if (action == SANE_ACTION_ENUM_INVISIBLE_FIX_ID) { struct _fix_id_cb* fcb = (struct _fix_id_cb*)value; - if (!inst->opts->enum_invisible_fix_ids(fcb) && inst != offline_) - offline_->opts->enum_invisible_fix_ids(fcb); + inst->opts->enum_invisible_fix_ids(fcb); + //if (!inst->opts->enum_invisible_fix_ids(fcb) && inst != offline_) + // offline_->opts->enum_invisible_fix_ids(fcb); err = SANE_STATUS_GOOD; } diff --git a/twain/ds/scanner.cpp b/twain/ds/scanner.cpp index 97b226a..e7cb8f6 100644 --- a/twain/ds/scanner.cpp +++ b/twain/ds/scanner.cpp @@ -939,36 +939,17 @@ COM_API_IMPLEMENT(scanner, int, get_scanned_images(DWORD milliseconds)) is_ui_wait_img_ = true; while (is_scanning_ && count == 0 && milliseconds) { - // MSG msg = { 0 }; - // if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) - // { - // TranslateMessage(&msg); - // DispatchMessageW(&msg); - // } - // else + MSG msg = { 0 }; + if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessageW(&msg); + } + else Sleep(elapse); count = images_.count(); - //int ev = get_event(); - // - - //if (ev == SANE_EVENT_SCAN_FINISHED) - //{ - // ui_hide(); - // break; - //} - //else if (ev == SANE_EVENT_UI_CLOSE_CANCEL) - //{ - // stop(); - // ui_hide(); - // break; - //} - //else if (ev == SANE_EVENT_UI_CLOSE_NORMAL) - //{ - // ui_hide(); - // break; - //} if (milliseconds != -1) { if (milliseconds <= elapse)