扫描结束时判定为保留双张,则继续扫描,否则停止扫描

This commit is contained in:
yangjiaxuan 2023-10-28 16:32:35 +08:00
parent 235d760ac0
commit da0da5b401
2 changed files with 44 additions and 13 deletions

View File

@ -553,6 +553,10 @@ scanner::~scanner()
thread_starting_->join(); thread_starting_->join();
thread_starting_.reset(); thread_starting_.reset();
if (start_after_keep_.get() && start_after_keep_->joinable())
start_after_keep_->join();
start_after_keep_.reset();
if (cfg_) if (cfg_)
{ {
cfg_->remove_all_schemes(); // schemes would add_ref on cfg_, so we clear them first. NOTE: do not call save after this !!! cfg_->remove_all_schemes(); // schemes would add_ref on cfg_, so we clear them first. NOTE: do not call save after this !!!
@ -1663,6 +1667,12 @@ int scanner::thread_start(void)
return ret; return ret;
} }
int scanner::thread_start_after_keep()
{
int ret = hg_sane_middleware::instance()->start(handle_, NULL);
return ret;
}
scanner::EXAPIPOS scanner::find_ex_api(int op_id) scanner::EXAPIPOS scanner::find_ex_api(int op_id)
{ {
return std::find(ex_opts_.begin(), ex_opts_.end(), op_id); return std::find(ex_opts_.begin(), ex_opts_.end(), op_id);
@ -3621,6 +3631,10 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len)
if (double_handle_ == DOUBLE_FEED_DISCARD) if (double_handle_ == DOUBLE_FEED_DISCARD)
return 0; return 0;
} }
else
{
double_handle_ = DOUBLE_FEED_NEED_UI;
}
swprintf_s(name, _countof(name) - 1, L"img_%05u.bmp", ++img_ind_); swprintf_s(name, _countof(name) - 1, L"img_%05u.bmp", ++img_ind_);
img = new scanned_img(handle_, simg->header, simg->data, simg->bytes, simg->flag.dpi, (tmp_path_ + name).c_str(), xfer_, &img_fmt_); img = new scanned_img(handle_, simg->header, simg->data, simg->bytes, simg->flag.dpi, (tmp_path_ + name).c_str(), xfer_, &img_fmt_);
@ -3673,11 +3687,25 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len)
// ui_notify(ev_code, data, 0); // ui_notify(ev_code, data, 0);
} }
else if (ev_code == SANE_EVENT_SCAN_FINISHED) else if (ev_code == SANE_EVENT_SCAN_FINISHED)
{
if (double_handle_ == DOUBLE_FEED_KEEP)
{
if (start_after_keep_.get() && start_after_keep_->joinable())
start_after_keep_->join();
start_after_keep_.reset(new std::thread(&scanner::thread_start_after_keep, this));
}
else
{ {
err_ = *len; err_ = *len;
scan_over_ = true; scan_over_ = true;
scan_msg_ = data ? (char*)data : "OK"; scan_msg_ = data ? (char*)data : "OK";
if (double_handle_ == DOUBLE_FEED_DISCARD)
{
scan_msg_ = "OK";
err_ = 0;
}
if (done_.get() && done_->joinable()) if (done_.get() && done_->joinable())
done_->join(); done_->join();
done_.reset(new std::thread(&scanner::scan_done, this)); done_.reset(new std::thread(&scanner::scan_done, this));
@ -3689,6 +3717,7 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len)
log_info(msg, 1); log_info(msg, 1);
} }
} }
}
//else if (ev_code == SANE_EVENT_ERROR) // 閻忕偛绻楅弬鈧柨娑樿嫰濠€顏堝磻濠婂嫷鍓鹃柟娈垮亝瀵潡寮捄铏规綌缂佲偓鏉為绻嗛柟?- 2023-05-30 //else if (ev_code == SANE_EVENT_ERROR) // 閻忕偛绻楅弬鈧柨娑樿嫰濠€顏堝磻濠婂嫷鍓鹃柟娈垮亝瀵潡寮捄铏规綌缂佲偓鏉為绻嗛柟?- 2023-05-30
//{ //{
// if (callback::show_messagebox_ui && *len) // if (callback::show_messagebox_ui && *len)

View File

@ -1,4 +1,4 @@
#pragma once #pragma once
#include "scanned_img.h" #include "scanned_img.h"
#include <vector> #include <vector>
@ -116,7 +116,9 @@ class scanner : public ISaneInvoker, virtual public refer
int set_is_multiout(bool enable); int set_is_multiout(bool enable);
int thread_start(void); int thread_start(void);
int thread_start_after_keep();
std::unique_ptr<std::thread> thread_starting_; std::unique_ptr<std::thread> thread_starting_;
std::unique_ptr<std::thread> start_after_keep_;
typedef struct _ex_api typedef struct _ex_api
{ {