diff --git a/hgdriver/hgdev/hg_scanner.cpp b/hgdriver/hgdev/hg_scanner.cpp index d03aa03..d4c4706 100644 --- a/hgdriver/hgdev/hg_scanner.cpp +++ b/hgdriver/hgdev/hg_scanner.cpp @@ -163,7 +163,6 @@ hg_scanner::hg_scanner(ScannerSerial serial, const char* dev_name, usb_io* io, i , 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), have_max_size(false), is_discardblank(false),firmware_sup_device_7010(false), firmware_sup_double_check(false) , firmware_sup_dirty_check(false) - , auto_scan_restore_(false), auto_scan_prev_(is_auto_paper_scan) { #if !defined(_WIN32) && !defined(_WIN64) &&defined(x86_64) isx86_Advan_ = false; @@ -269,7 +268,7 @@ hg_scanner::~hg_scanner() name_.insert(0, hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_DEVS)); name_ += hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_IS_CLOSE); - notify_ui_working_status(name_.c_str(), SANE_EVENT_SCANNER_CLOSED); + //notify_ui_working_status(name_.c_str(), SANE_EVENT_SCANNER_CLOSED); VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s(%s) destroyed.\n", name_.c_str(), hg_log::format_ptr(this).c_str()); } @@ -2420,34 +2419,10 @@ int hg_scanner::setting_scan_mode(void* data, long* len) if (strcmp(str.c_str(), hg_log::lang_load(ID_OPTION_VALUE_SMZS_LXSM)) == 0) { scan_count_ = -1; - - // restore AutoScan ? - if (auto_scan_restore_) - { - long len = sizeof(auto_scan_prev_); - - setting_auto_paper_scan(&auto_scan_prev_, &len); - VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Restore 'AutoScan' to '%s' for user changes scan mode to '%s'\n" - , auto_scan_prev_ ? "true" : "false", str.c_str()); - } } else { setting_jsn_.at(SANE_STD_OPT_NAME_SCAN_COUNT).at("cur").get_to(scan_count_); - - // 智学网设置该参数时,程序取消待纸扫描 - if (!auto_scan_restore_) // 连续调用时,保留最初状态 - { - auto_scan_restore_ = auto_scan_prev_ = is_auto_paper_scan; - if (auto_scan_restore_) - { - bool v = false; - long len = sizeof(v); - setting_auto_paper_scan(&v, &len); - auto_scan_restore_ = true; - VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Disable 'AutoScan' for user changes scan mode to '%s'\n", str.c_str()); - } - } } VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "set scanning pages to %d\n", scan_count_); @@ -2728,7 +2703,6 @@ int hg_scanner::setting_auto_paper_scan(void* data, long* len) { hg_log::log(LOG_LEVEL_DEBUG_INFO, "No 'AutoScan' restroing for setting_auto_paper_scan invoked.\n"); - auto_scan_restore_ = false; is_auto_paper_scan = *((bool *)data); if (!firmware_sup_wait_paper_ && is_auto_paper_scan) { @@ -3225,6 +3199,10 @@ SANE_Image_Statu hg_scanner::last_usb_image_statu(int err) return statu; } +bool hg_scanner::is_auto_scan(void) +{ + return is_auto_paper_scan && scan_count_ == -1 && !test_1_paper_; +} void hg_scanner::change_setting_language(bool init) { for (size_t i = 1; i < jsn_children_.size(); ++i) @@ -4247,6 +4225,11 @@ int hg_scanner::start(void) usb_img_index_ = final_img_index_ = 0; status_ = SCANNER_ERR_OK; + if (is_auto_paper_scan && !is_auto_scan()) + { + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "AutoScan is disabled for scan-count(%d) was not -1 or test-one-paper(%s) was true.\n", scan_count_, test_1_paper_ ? "true" : "false"); + } + // start ... ret = do_start(); diff --git a/hgdriver/hgdev/hg_scanner.h b/hgdriver/hgdev/hg_scanner.h index 6a66f0c..ce87777 100644 --- a/hgdriver/hgdev/hg_scanner.h +++ b/hgdriver/hgdev/hg_scanner.h @@ -279,6 +279,7 @@ protected: void adjust_color(hg_imgproc::HIMGPRC handle); hg_imgproc::IMGPRCPARAM get_image_process_object(int model); SANE_Image_Statu last_usb_image_statu(int err); + bool is_auto_scan(void); // BUG-732 hg_imgproc::HIMGPRC ImagePrc_pHandle_; protected: ScannerSerial serial_; @@ -327,8 +328,6 @@ protected: int feedmode_; // 分纸强度 int sleeptime_; // 睡眠时间 bool is_auto_paper_scan; // 待纸扫描 - bool auto_scan_prev_; // 保留待纸扫描程序改变状态之前的值 - 2023-10-16: 智学网根据扫描张数来打开或关闭待纸扫描 - bool auto_scan_restore_; // 是否需要恢复待纸扫描状态 - 2023-10-16: 智学网根据扫描张数来打开或关闭待纸扫描 bool size_check; // 尺寸检测 bool save_feedmode_type_; //保存分支强度狀態 diff --git a/hgdriver/hgdev/hg_scanner_239.cpp b/hgdriver/hgdev/hg_scanner_239.cpp index 1904a82..31a457f 100644 --- a/hgdriver/hgdev/hg_scanner_239.cpp +++ b/hgdriver/hgdev/hg_scanner_239.cpp @@ -109,7 +109,7 @@ namespace settings {200.0f, 1}, {240.0f, 1}, {300.0f, 0}, - {600.0f, 1} //临时版本发1 原来发2 + {600.0f, 1} //临时版本? 原来? }; bool is_equal(float l, float r) { @@ -333,7 +333,7 @@ int hg_scanner_239::set_auto_flat(int data) } if ((fw[5] == 'A' && atoi(fw.substr(6, 4).c_str()) <= 9999)) { - data = data == 1 ? 1 : 0; //暂时没有用。 + data = data == 1 ? 1 : 0; //暂时没有用? } if (!wait_usb_.is_waiting()) { @@ -571,7 +571,7 @@ void hg_scanner_239::init_version(void) { firmware_sup_wait_paper_ = year_date.compare("3B0629") >= 0 ? true : false; firmware_sup_log_export_ = true; - firmware_sup_pick_strength_ = false; //不支持 + firmware_sup_pick_strength_ = false; //不支? firmware_sup_wake_device_ = year_date.compare("3C0518") >= 0 ? true : false; firmware_sup_color_corr_ = year.compare("3C") >= 0 ? true : false; firmware_sup_double_img = year_date.compare("3C1021") >= 0 ? true : false; @@ -603,7 +603,8 @@ int hg_scanner_239::writedown_device_configuration(bool type, setting_hardware: int ret = SCANNER_ERR_OK; if (!type) return ret; - setting_hardware::HGSCANCONF_3399 p = dev_conf_; //不得改变外部的值 + setting_hardware::HGSCANCONF_3399 p = dev_conf_; //不得改变外部的? + p.params_3399.is_autopaper = is_auto_scan(); // 多因素决定待纸扫 if (!dev_conf) dev_conf = &p; @@ -623,7 +624,7 @@ int hg_scanner_239::writedown_device_configuration(bool type, setting_hardware: dev_conf->params_3399.is_fixedpaper = false; dev_conf->params_3399.en_autosize = true; } - if (!firmware_sup_auto_speed_ && image_prc_param_.bits.paper == PAPER_AUTO_MATCH)//3399 ,在3C之前的版本 匹配原始尺寸设置 12 + if (!firmware_sup_auto_speed_ && image_prc_param_.bits.paper == PAPER_AUTO_MATCH)//3399 ,?C之前的版?匹配原始尺寸设置 12 { dev_conf->params_3399.paper = 12; } @@ -662,7 +663,7 @@ int hg_scanner_239::writedown_image_configuration(void) } else { - if (scan_count_ == -1 || is_auto_paper_scan) + if (scan_count_ == -1 /*|| is_auto_paper_scan*/) ic.scannum = -1; else ic.scannum = ((image_prc_param_.bits.page != PAGE_SINGLE) ? scan_count_ * 2 : scan_count_); @@ -918,7 +919,7 @@ int hg_scanner_239::on_resolution_changed(int& dpi) else dev_conf_.params_3399.dpi = dpi >= 500 ? 3 : (dpi < 500 && dpi> 299) ? 2 : 1; - //dev_conf_.params_3399.dpi = 1; //dpi 华凌cis和敦南cis 默认发1无需改变 + //dev_conf_.params_3399.dpi = 1; //dpi 华凌cis和敦南cis 默认?无需改变 int ret = writedown_device_configuration(); return ret; } @@ -976,7 +977,7 @@ int hg_scanner_239::on_skew_check_changed(bool& check) int hg_scanner_239::on_skew_check_level_changed(int& check) { int ret = SCANNER_ERR_OK, - val = check - 1,//上面设置的是1 - 5 ,接受范围值为0 - 4,默认2 + val = check - 1,//上面设置的是1 - 5 ,接受范围值为0 - 4,默? old = dev_conf_.params_3399.screw_detect_level; setting_hardware::HGSCANCONF_3399 cf; @@ -1354,7 +1355,7 @@ void hg_scanner_239::thread_get_dves_image(void) if (ret == SCANNER_ERR_TIMEOUT) { std::this_thread::sleep_for(std::chrono::milliseconds(400)); - if (sw.elapsed_s() > 60 && !is_auto_paper_scan) + if (sw.elapsed_s() > 60 && !is_auto_scan()) { status_ = ret; notify_ui_working_status(from_default_language(STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME), SANE_EVENT_ERROR, ret); // 取图通信超时 @@ -1362,7 +1363,7 @@ void hg_scanner_239::thread_get_dves_image(void) break; } - if (is_auto_paper_scan && sw.elapsed_s() >= is_auto_paper_scan_exit_time && is_auto_paper_scan_exit_time != 0) + if (is_auto_scan() && sw.elapsed_s() >= is_auto_paper_scan_exit_time && is_auto_paper_scan_exit_time != 0) { is_quit_wait_paper_scan = true;//标记待纸扫描时间到了自动结束 do_stop(); @@ -1376,7 +1377,7 @@ void hg_scanner_239::thread_get_dves_image(void) //break; } - if (user_cancel_ && is_auto_paper_scan || is_quit_wait_paper_scan) //其他直接跳过当此循坏 + if (user_cancel_ && is_auto_scan() || is_quit_wait_paper_scan) //其他直接跳过当此循坏 { size = sizeof(buf); memset(buf, 0, size); @@ -1413,7 +1414,7 @@ void hg_scanner_239::thread_get_dves_image(void) } //break; - //杩欎釜鏃跺€欓€€鍑虹殑璇濇秷鎭氨杩樻病璇诲畬锛岄敊璇俊鎭厛淇濆瓨涓嬫潵锛屽彧鏈夎幏鍙栧埌stop鏃舵墠閫€鍑猴紝濡傛灉娌¤幏鍙栧畬閫€鍑猴紝鍙兘浼氬鑷寸浜屾鎵弿鐩存帴杩斿洖鎵弿瀹屾垚 + //杩欎釜鏃跺€欓€€鍑虹殑璇濇秷鎭氨杩樻病璇诲畬锛岄敊璇俊鎭厛淇濆瓨涓嬫潵锛屽彧鏈夎幏鍙栧埌stop鏃舵墠閫€鍑猴紝濡傛灉娌¤幏鍙栧畬閫€鍑猴紝鍙兘浼氬鑷寸浜屾鎵弿鐩存帴杩斿洖鎵弿瀹屾? } if (info->From == setting3399::IMG) { @@ -1436,8 +1437,8 @@ void hg_scanner_239::thread_get_dves_image(void) //else // VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "status(0x%x) is not accept in usb thread\n", status); } - else if (info->From == setting3399::STOPSCAN)//鍥轰欢鐗堟湰:3B0326鑾峰彇鏃犵焊鏃讹紝涓嬮潰涓柇淇℃伅浼氬厛鍙戞棤绾稿湪鍋滄鎵弿,鐒跺悗鍦ㄥ彂鏃犵焊 - { //姝ゆ椂int绔偣杩樿淇℃伅娌℃湁璇诲彇瀹岋紝鑰屼笖閫€鍑虹偣鍑荤户缁壂鎻忥紝涓嬮潰璁惧杩樻湭缁撴潫鎵弿 + else if (info->From == setting3399::STOPSCAN)//鍥轰欢鐗堟湰:3B0326鑾峰彇鏃犵焊鏃讹紝涓嬮潰涓柇淇℃伅浼氬厛鍙戞棤绾稿湪鍋滄鎵?鐒跺悗鍦ㄥ彂鏃犵? + { //姝ゆ椂int绔偣杩樿淇℃伅娌℃湁璇诲彇瀹岋紝鑰屼笖閫€鍑虹偣鍑荤户缁壂鎻忥紝涓嬮潰璁惧杩樻湭缁撴潫鎵? if (!svdevs_err_.empty()) { status_ = svdevs_err_.front(); @@ -1467,7 +1468,7 @@ void hg_scanner_239::thread_get_dves_image(void) VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "STOPSCAN message is ahead of %d image(s)!\n", rest); } - if (user_cancel_ && !is_auto_paper_scan) + if (user_cancel_ && !is_auto_scan()) { if (status_ && status_ != SCANNER_ERR_DEVICE_STOPPED) // thread_handle_image_process maybe call stop() when insufficient memory occurs . ret = status_; @@ -1503,7 +1504,7 @@ void hg_scanner_239::thread_get_dves_image(void) string str = hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_ROUND_SACN_OVER); str += ":" + to_string(++auoto_paper_indx); - if (!user_cancel_ && is_auto_paper_scan && svdevs_err_.empty() && !is_quit_wait_paper_scan) + if (!user_cancel_ && is_auto_scan() && svdevs_err_.empty() && !is_quit_wait_paper_scan) notify_ui_working_status(str.c_str(), SANE_EVENT_ERROR, status_); else break; @@ -1563,7 +1564,7 @@ int hg_scanner_239::do_start(void) reset(); - //211220固件版本不支持返回 + //211220固件版本不支持返? ret = get_scan_is_sleep(val); if (!val && ret == SCANNER_ERR_OK) { @@ -1853,7 +1854,7 @@ int hg_scanner_239::get_scan_is_sleep(SANE_Bool& type) std::lock_guard lock(io_lock_); int ret = 0,val; - ret = read_register(setting3399::SR_GET_SLEEP_STAUTUS, &val); //0休眠 1唤醒状态 + ret = read_register(setting3399::SR_GET_SLEEP_STAUTUS, &val); //0休眠 1唤醒状? if (ret == SCANNER_ERR_OK) { type = val == 1 ? true : false; @@ -2025,7 +2026,7 @@ int hg_scanner_239::set_scan_lock_check_val(string check_str) { return SCANNER_ERR_INVALID_PARAMETER; } - int num = 32 - keys.size(); //保持32位下发 + int num = 32 - keys.size(); //保持32位下? if (num > 0) { std::string str(num, '0'); @@ -2085,7 +2086,7 @@ int hg_scanner_239::set_firmware_upgrade(std::string filename) return SCANNER_ERR_OPEN_FILE_FAILED; } fwname.seekg(0, std::ios::end); - int total = fwname.tellg();//记录总长度 + int total = fwname.tellg();//记录总长? fwname.seekg(0, std::ios::beg); int pos = fwname.tellg();//记录pos位置 @@ -2124,7 +2125,7 @@ int hg_scanner_239::set_firmware_upgrade(std::string filename) return SCANNER_ERR_DEVICE_UPGRADE_FAIL; int to_cnt = 0; - // 到这个位置已经能够升级成功了 后面对升级结果做下判断 + // 到这个位置已经能够升级成功了 后面对升级结果做下判? auto now = std::chrono::steady_clock::now(); while (std::chrono::duration(std::chrono::steady_clock::now() - now).count() < 70) { @@ -2195,7 +2196,7 @@ int hg_scanner_239::set_dev_islock_file(int islockfile) } if (islockfile != 0 && islockfile != 1) { - return SCANNER_ERR_INVALID_PARAMETER; //这个地方设置的参数必须保证正确 + return SCANNER_ERR_INVALID_PARAMETER; //这个地方设置的参数必须保证正? } string device_log_path = "/var/log/black_list_file.txt"; string str = std::to_string(islockfile); diff --git a/hgdriver/hgdev/scanner_manager.cpp b/hgdriver/hgdev/scanner_manager.cpp index 2244ad5..9694dd4 100644 --- a/hgdriver/hgdev/scanner_manager.cpp +++ b/hgdriver/hgdev/scanner_manager.cpp @@ -811,8 +811,8 @@ scanner_err hg_scanner_mgr::hg_scanner_open(scanner_handle* h, const char* name, if (ptr != online_devices_.end()) ptr->scanner = (hg_scanner*)*h; } - else if(hg_scanner_mgr::last_open_msg_.length()) - hg_scanner_mgr::ui_default_callback(nullptr, SANE_EVENT_ERROR, (void*)hg_scanner_mgr::last_open_msg_.c_str(), (unsigned int*)&ret, nullptr); + //else if(hg_scanner_mgr::last_open_msg_.length()) + // hg_scanner_mgr::ui_default_callback(nullptr, SANE_EVENT_ERROR, (void*)hg_scanner_mgr::last_open_msg_.c_str(), (unsigned int*)&ret, nullptr); if(io) io->release();