扫描结束时判定为保留双张,则继续扫描,否则停止扫描
This commit is contained in:
parent
235d760ac0
commit
da0da5b401
|
@ -553,6 +553,10 @@ scanner::~scanner()
|
|||
thread_starting_->join();
|
||||
thread_starting_.reset();
|
||||
|
||||
if (start_after_keep_.get() && start_after_keep_->joinable())
|
||||
start_after_keep_->join();
|
||||
start_after_keep_.reset();
|
||||
|
||||
if (cfg_)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
double_handle_ = DOUBLE_FEED_NEED_UI;
|
||||
}
|
||||
|
||||
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_);
|
||||
|
@ -3674,19 +3688,34 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len)
|
|||
}
|
||||
else if (ev_code == SANE_EVENT_SCAN_FINISHED)
|
||||
{
|
||||
err_ = *len;
|
||||
scan_over_ = true;
|
||||
scan_msg_ = data ? (char*)data : "OK";
|
||||
|
||||
if (done_.get() && done_->joinable())
|
||||
done_->join();
|
||||
done_.reset(new std::thread(&scanner::scan_done, this));
|
||||
// scan_done(); // invoking move to the last image fetched
|
||||
|
||||
if (double_handle_ == DOUBLE_FEED_KEEP)
|
||||
{
|
||||
wchar_t msg[128] = { 0 };
|
||||
swprintf_s(msg, _countof(msg) - 1, L"Scan finished with error: %u\r\n", *len);
|
||||
log_info(msg, 1);
|
||||
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;
|
||||
scan_over_ = true;
|
||||
scan_msg_ = data ? (char*)data : "OK";
|
||||
|
||||
if (double_handle_ == DOUBLE_FEED_DISCARD)
|
||||
{
|
||||
scan_msg_ = "OK";
|
||||
err_ = 0;
|
||||
}
|
||||
|
||||
if (done_.get() && done_->joinable())
|
||||
done_->join();
|
||||
done_.reset(new std::thread(&scanner::scan_done, this));
|
||||
// scan_done(); // invoking move to the last image fetched
|
||||
|
||||
{
|
||||
wchar_t msg[128] = { 0 };
|
||||
swprintf_s(msg, _countof(msg) - 1, L"Scan finished with error: %u\r\n", *len);
|
||||
log_info(msg, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
//else if (ev_code == SANE_EVENT_ERROR) // 閻忕偛绻楅弬鈧柨娑樿嫰濠€顏堝磻濠婂嫷鍓鹃柟娈垮亝瀵潡寮捄铏规綌缂佲偓鏉為绻嗛柟?- 2023-05-30
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include "scanned_img.h"
|
||||
#include <vector>
|
||||
|
@ -116,7 +116,9 @@ class scanner : public ISaneInvoker, virtual public refer
|
|||
int set_is_multiout(bool enable);
|
||||
|
||||
int thread_start(void);
|
||||
int thread_start_after_keep();
|
||||
std::unique_ptr<std::thread> thread_starting_;
|
||||
std::unique_ptr<std::thread> start_after_keep_;
|
||||
|
||||
typedef struct _ex_api
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue