From a513c71ec67aad2a696dc02406d582283caab785 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Sat, 28 Oct 2023 16:46:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E5=90=AF=E5=8A=A8=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=87=E4=BB=B6=E6=A0=BC=E5=BC=8F=EF=BC=9B?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=90=AF=E5=8A=A8=E5=A4=B1=E8=B4=A5=E5=90=8E?= =?UTF-8?q?=E7=9A=84=E4=BA=8C=E6=AC=A1=E5=90=AF=E5=8A=A8=EF=BC=9B=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E6=89=AB=E6=8F=8F=E4=BA=8B=E4=BB=B6=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E4=B8=AD=E5=88=A4=E6=96=AD=E7=95=8C=E9=9D=A2=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=87=BD=E6=95=B0=EF=BC=9B=E6=97=A5=E5=BF=97=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=88=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sane/scanner.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/sane/scanner.cpp b/sane/scanner.cpp index 7b4ddda..e16fe95 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -1605,22 +1605,22 @@ int scanner::thread_start(void) scan_over_ = false; double_handle_ = DOUBLE_FEED_NEED_UI; + unsigned int l = sizeof(img_fmt_); + SANE_CompressionType cmprsn = img_fmt_.compress.compression; + if (hg_sane_middleware::instance()->io_control(handle_, IO_CTRL_CODE_GET_FINAL_IMAGE_FORMAT, &img_fmt_, &l)) + img_fmt_.img_format = SANE_IMAGE_TYPE_BMP; + img_fmt_.compress.compression = cmprsn; + int ret = hg_sane_middleware::instance()->start(handle_, NULL); // the third-APPs in linux will call 'stop' after every start, but it not happens in windows-apps, so we handle this as following ... - if (ret == SANE_STATUS_NO_DOCS && prev_start_result_ == SANE_STATUS_GOOD) - ret = hg_sane_middleware::instance()->start(handle_, NULL); + //if (ret == SANE_STATUS_NO_DOCS && prev_start_result_ == SANE_STATUS_GOOD) + // ret = hg_sane_middleware::instance()->start(handle_, NULL); - if (ret == SANE_STATUS_GOOD) + if (ret == SANE_STATUS_GOOD || ret == SCANNER_ERR_DEVICE_DOUBLE_FEEDING) { /*if (indicator_.get() && !IsWindowVisible(indicator_->hwnd())) indicator_->show(true);*/ - - unsigned int l = sizeof(img_fmt_); - SANE_CompressionType cmprsn = img_fmt_.compress.compression; - if (hg_sane_middleware::instance()->io_control(handle_, IO_CTRL_CODE_GET_FINAL_IMAGE_FORMAT, &img_fmt_, &l)) - img_fmt_.img_format = SANE_IMAGE_TYPE_BMP; - img_fmt_.compress.compression = cmprsn; } //else if (indicator_.get()) //{ @@ -3600,7 +3600,7 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len) img_ind_ = 0; if (prog) prog->notify_working(); - else if (callback::show_progress_ui && is_bIndicator) + else if (callback::show_progress_ui && is_bIndicator && ui_notify) ui_notify(ev_code, data, *len); on_ui_event(ev_code, (void*)ev_code); log_info(L"Scanning ...\r\n", 1); @@ -3675,7 +3675,7 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len) { wchar_t msg[128] = { 0 }; - swprintf_s(msg, _countof(msg) - 1, L"New image(%u) received with %u bytes\r\n", img_ind_, simg->bytes); + swprintf_s(msg, _countof(msg) - 1, L"New image(%u) received with %u bytes (status: %d)\r\n", img_ind_, simg->bytes, simg->flag.statu); log_info(msg, 1); } } @@ -3839,11 +3839,16 @@ void close_log(void) } void log(const wchar_t* info) { + wchar_t clock[40] = { 0 }; + + hg_get_current_time_w(clock); if (g_file_) { std::lock_guard lock(g_lock_); + std::wstring text(clock); - fwrite(info, 2, lstrlenW(info), g_file_); + text += info; + fwrite(text.c_str(), 2, text.length(), g_file_); fflush(g_file_); if (ftell(g_file_) > 10 * 1024 * 1024) {