diff --git a/hgdriver/hgdev/hg_scanner.cpp b/hgdriver/hgdev/hg_scanner.cpp index 1beb463..b70fb75 100644 --- a/hgdriver/hgdev/hg_scanner.cpp +++ b/hgdriver/hgdev/hg_scanner.cpp @@ -161,7 +161,7 @@ hg_scanner::hg_scanner(ScannerSerial serial, const char* dev_name, usb_io* io, i , is_auto_paper_scan_exit_time(60), is_read_int(true), is_auto_feedmode_(false) , firmware_sup_wait_paper_(false),firmware_sup_pick_strength_(false),firmware_sup_log_export_(false),firmware_sup_color_corr_(false),firmware_sup_wake_device_(false) , firmware_sup_double_img(false),firmware_sup_devs_lock_(false),firmware_sup_dpi_300(false),firmware_sup_dpi_600(false),firmware_sup_auto_speed_(false),firmware_sup_morr_(false) - , firmware_sup_color_fill_(false),firmware_sup_history_cnt(false) + , firmware_sup_color_fill_(false),firmware_sup_history_cnt(false), have_max_size(false) { #if !defined(_WIN32) && !defined(_WIN64) &&defined(x86_64) isx86_Advan_ = false; @@ -1366,6 +1366,23 @@ int hg_scanner::set_color_change(void) } bool hg_scanner::jsn_reorganize() { + string str; + int len = setting_jsn_.at(SANE_STD_OPT_NAME_PAPER).at("range").size(); + int max_papers[] = { PAPER_MAX_SIZE, PAPER_MAX_SIZE_CLIP, PAPER_TRIGEMINY }; + for (auto& v : max_papers) + { + std::string paper(paper_string(v)); + for (int i = 0; i < len; i++) + { + setting_jsn_.at(SANE_STD_OPT_NAME_PAPER).at("range").at(i).get_to(str); + if (str.compare(paper) == 0) + { + have_max_size = true; + break; + } + } + } + if (!firmware_sup_wait_paper_ && pid_ == 0x239) { erase_option(SANE_STD_OPT_NAME_WAIT_TO_SCAN); @@ -1794,6 +1811,10 @@ int hg_scanner::setting_resolution(void* data, long* len) VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change resolution from %d to %d = %s\n", old, *((int*)data), hg_scanner_err_name(ret)); //*((int*)data) = resolution_; + if (!have_max_size) + { + return ret; + } #ifdef DYN_JSON_BETWEEN_PAPER_AND_DPI int max_papers[] = { PAPER_MAX_SIZE, PAPER_MAX_SIZE_CLIP, PAPER_TRIGEMINY }; @@ -2945,6 +2966,7 @@ void hg_scanner::init_settings(const char* json_setting_text) jsn_children_.clear(); setting_jsn_ = jsonconfig::load_json_from_text(json_setting_text, &jsn_children_); } + jsn_reorganize(); VLOG_MINI_1(LOG_LEVEL_ALL, "Initialize %d settings ...\n", jsn_children_.size() - 1); @@ -2954,6 +2976,11 @@ void hg_scanner::init_settings(const char* json_setting_text) if (lang_get_cur_code_page() != DEFAULT_CODE_PAGE) on_language_changed(); notify_setting_result_ = true; + + + + //setting_jsn_ + } int hg_scanner::init_settings(int pid) { diff --git a/hgdriver/hgdev/hg_scanner.h b/hgdriver/hgdev/hg_scanner.h index 47e1e3d..5468705 100644 --- a/hgdriver/hgdev/hg_scanner.h +++ b/hgdriver/hgdev/hg_scanner.h @@ -90,6 +90,9 @@ class hg_scanner bool save_sizecheck; bool read_over_with_no_data_; // 针对第三方调用,在最后一段数据时是否返回“SCANNER_ERR_NO_DATA” int is_color_type_;//保存最后下发到设备的颜色类型 + bool have_max_size; //条目是否存在最大尺寸 + + sane_callback ui_ev_cb_; do_when_born_and_dead* scan_life_;