fix optimize-402: change DoubleFeedDetection protocol for 爱云校
This commit is contained in:
parent
16af0bbee1
commit
935374f2cb
|
@ -1005,6 +1005,20 @@ Result huagao_ds::identityOpenDs(const Identity& id)
|
|||
}
|
||||
log_all_triple_ = get_config_number(L"twain-app", L"log-all-triple") == 1;
|
||||
notify_close_ = get_config_number(L"twain-app", L"notify-close");
|
||||
double_check_mode_ = get_config_number(L"twain-app", L"double-check");
|
||||
if (double_check_mode_ == 0)
|
||||
{
|
||||
wchar_t pe[MAX_PATH] = { 0 }, * name = NULL;
|
||||
GetModuleFileNameW(NULL, pe, _countof(pe) - 1);
|
||||
name = wcsrchr(pe, L'\\');
|
||||
if (name++ == NULL)
|
||||
name = pe;
|
||||
if (wcsicmp(name, L"\u597D\u5206\u6570\u9605\u5377\u626B\u63CF\u7AEF.exe") == 0) // 爱云校PE:好分数阅卷扫描端.exe
|
||||
double_check_mode_ = DOUBLE_CHECK_ULTRASONIC;
|
||||
else
|
||||
double_check_mode_ = DOUBLE_CHECK_TWAIN;
|
||||
}
|
||||
load_sane_util::to_log(1, L"Double check mode = %d\r\n", double_check_mode_);
|
||||
|
||||
m_compression = Compression::None;
|
||||
init_support_caps();
|
||||
|
@ -2704,18 +2718,33 @@ void huagao_ds::init_support_caps(void)
|
|||
m_caps[CapType::DoubleFeedDetection] = [this](Msg msg, Capability& data)->Result {
|
||||
log_attr_access((int)CapType::DoubleFeedDetection, (int)msg);
|
||||
if (Msg::Set == msg) {
|
||||
auto atuodsw = data.currentItem<CapType::DoubleFeedDetection>();
|
||||
auto val = data.currentItem<CapType::DoubleFeedDetection>();
|
||||
int ret = SCANNER_ERR_OK;
|
||||
bool enable = atuodsw == DoubleFeedDetection::Ultrasonic;
|
||||
bool enable = val == DoubleFeedDetection::Ultrasonic;
|
||||
if (double_check_mode_ == DOUBLE_CHECK_ULTRASONIC)
|
||||
{
|
||||
enable = (bool)val;
|
||||
load_sane_util::to_log(1, L"DoubleFeedDetection parameter is for boolean of Ultrasonic. set to %s\r\n", enable ? L"TRUE" : L"FALSE");
|
||||
}
|
||||
SET_SANE_OPT_EX(ret, scanner_, is_ultrasonic_check, &enable);
|
||||
return ret == SCANNER_ERR_OK ? success() : seqError();
|
||||
}
|
||||
DoubleFeedDetection init = DoubleFeedDetection::Ultrasonic;
|
||||
std::vector<bool> all;
|
||||
GET_SANE_OPT_EX(bool, scanner_, is_ultrasonic_check, NULL, &all);
|
||||
BYTE ato = !all[sane_opts::RANGE_POS_CURRENT];
|
||||
init = all[sane_opts::RANGE_POS_DEFAULT] ? DoubleFeedDetection::Ultrasonic : DoubleFeedDetection::ByLength;
|
||||
return CapSupGetAllReset<BYTE, DoubleFeedDetection, CapType::DoubleFeedDetection>(msg, data, ato, init);
|
||||
if (double_check_mode_ == DOUBLE_CHECK_ULTRASONIC)
|
||||
{
|
||||
Bool ni = all[sane_opts::RANGE_POS_CURRENT],
|
||||
ii = all[sane_opts::RANGE_POS_DEFAULT];
|
||||
data = Capability::createEnumeration<Bool>(CapType::DoubleFeedDetection, { FALSE, TRUE }, ni, ii);
|
||||
return success();
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE ato = !all[sane_opts::RANGE_POS_CURRENT];
|
||||
init = all[sane_opts::RANGE_POS_DEFAULT] ? DoubleFeedDetection::Ultrasonic : DoubleFeedDetection::ByLength;
|
||||
return CapSupGetAllReset<BYTE, DoubleFeedDetection, CapType::DoubleFeedDetection>(msg, data, ato, init);
|
||||
}
|
||||
};
|
||||
|
||||
m_query[CapType::IAutomaticCropUsesFrame] = msgSupportGetAll;
|
||||
|
|
|
@ -61,6 +61,8 @@ class huagao_ds : public Twpp::SourceFromThis<huagao_ds> {
|
|||
volatile bool notfify_close_ = false;
|
||||
enum {NOTIFY_AUTO = 0, NOTIFY_ALWAYS, NOTIFY_NONE};
|
||||
volatile unsigned notify_close_ = 0; // 0 - auto; 1 - notify always; 2 - no notify
|
||||
enum {DOUBLE_CHECK_TWAIN = 1, DOUBLE_CHECK_ULTRASONIC, DOUBLE_CHECK_INFRARED}; // for BUG-402
|
||||
volatile unsigned double_check_mode_ = 0; // 1 - standard twain protocol; 2 - bool for ultrasonic; 3 - bool for infrared
|
||||
std::mutex notify_close_lock_;
|
||||
std::unique_ptr<std::thread> notify_close_thread_;
|
||||
bool take_and_reset_notify_close_flag(void);
|
||||
|
|
Loading…
Reference in New Issue