From fcf3a6bcfff7b2231a3fb3460d92385ad7ac4992 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Mon, 30 May 2022 11:04:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=97=A5=E5=BF=97=EF=BC=8C?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=88=B0=E8=AE=BE=E5=A4=87=E5=B1=82=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=EF=BC=8C=E5=B9=B6=E5=B0=86=E8=B7=AF=E5=BE=84=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E4=B8=BA=E8=AE=BE=E5=A4=87=E5=B1=82=E7=BB=84=E4=BC=AF?= =?UTF-8?q?=E6=89=80=E5=9C=A8=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hgdriver/hgdev/hg_ipc.cpp | 26 +- hgdriver/hgdev/hg_scanner.cpp | 84 +-- hgdriver/hgdev/hg_scanner_200.cpp | 162 ++-- hgdriver/hgdev/hg_scanner_200.h | 2 +- hgdriver/hgdev/hg_scanner_239.cpp | 216 +++--- hgdriver/hgdev/hg_scanner_300.cpp | 158 ++-- hgdriver/hgdev/hg_scanner_300.h | 2 +- hgdriver/hgdev/hg_scanner_400.cpp | 192 ++--- hgdriver/hgdev/hg_scanner_400.h | 2 +- hgdriver/hgdev/image_process.cpp | 8 +- hgdriver/hgdev/scanner_manager.cpp | 10 +- hgdriver/hgdev/usb_manager.cpp | 84 +-- hgdriver/wrapper/CMakeLists.txt | 1 + hgdriver/wrapper/hg_log.cpp | 244 ++++-- hgdriver/wrapper/hg_log.h | 59 ++ hgdriver/wrapper/huagaoxxx_warraper_ex.cpp | 138 +++- {hgsane => hgdriver/wrapper}/ini_file.cpp | 0 {hgsane => hgdriver/wrapper}/ini_file.h | 0 hgsane/sane_hg_mdw.cpp | 822 +-------------------- hgsane/sane_option.cpp | 6 +- sdk/hginclude/huagaoxxx_warraper_ex.h | 108 +++ 21 files changed, 1021 insertions(+), 1303 deletions(-) create mode 100644 hgdriver/wrapper/hg_log.h rename {hgsane => hgdriver/wrapper}/ini_file.cpp (100%) rename {hgsane => hgdriver/wrapper}/ini_file.h (100%) diff --git a/hgdriver/hgdev/hg_ipc.cpp b/hgdriver/hgdev/hg_ipc.cpp index c13d057..c91d965 100644 --- a/hgdriver/hgdev/hg_ipc.cpp +++ b/hgdriver/hgdev/hg_ipc.cpp @@ -1,5 +1,5 @@ #include "hg_ipc.h" -#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #include "huagao/hgscanner_error.h" #ifdef WIN32 @@ -78,7 +78,7 @@ platform_event::platform_event() : waiting_(false), dbg_info_("") if (err == -1) { err = errno; - HG_VLOG_MINI_2(LOG_LEVEL_FATAL, "(%s)sem_init failed: %d\n", hg_log::format_ptr(this).c_str(), err); + VLOG_MINI_2(LOG_LEVEL_FATAL, "(%s)sem_init failed: %d\n", hg_log::format_ptr(this).c_str(), err); } } platform_event::~platform_event() @@ -94,7 +94,7 @@ bool platform_event::wait(unsigned timeout) { bool waited = true; - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "platform_event(%s - %s) --> waiting...\n", hg_log::format_ptr(this).c_str(), dbg_info_.c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "platform_event(%s - %s) --> waiting...\n", hg_log::format_ptr(this).c_str(), dbg_info_.c_str()); waiting_ = true; if (timeout == USB_TIMEOUT_INFINITE) sem_wait(&sem_); @@ -105,7 +105,7 @@ bool platform_event::wait(unsigned timeout) to.tv_nsec = (long)((timeout % 1000) * 1000 * 1000); waited = sem_timedwait(&sem_, &to) == 0; } - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "platform_event(%s - %s) --> %s.\n", hg_log::format_ptr(this).c_str(), dbg_info_.c_str(), waited ? "waited" : "wait timeout"); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "platform_event(%s - %s) --> %s.\n", hg_log::format_ptr(this).c_str(), dbg_info_.c_str(), waited ? "waited" : "wait timeout"); waiting_ = false; return waited; @@ -129,7 +129,7 @@ void platform_event::set_debug_info(const char* info) shared_memory::shared_memory(unsigned long long key, size_t size) : key_(key), obj_((void*)-1), first_(true), bytes_(size), len_(0) { unsigned int* ptr = (unsigned int*)&key_; - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "shared memory key = 0x%x%08x\n", ptr[1], ptr[0]); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "shared memory key = 0x%x%08x\n", ptr[1], ptr[0]); init(); } @@ -163,11 +163,11 @@ void shared_memory::init(void) obj = shmget(key_, bytes_, 0600); if(obj == -1) obj = shmget(key_, bytes_, 0); - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "open existing: shmget(0x%x%08x) = %d\n", v[1], v[0], obj); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "open existing: shmget(0x%x%08x) = %d\n", v[1], v[0], obj); obj_ = (void*)obj; std::string prev(read()), proc(""); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "shared memory content: %s\n", prev.c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "shared memory content: %s\n", prev.c_str()); if(prev.length()) { proc = prev; @@ -192,17 +192,17 @@ void shared_memory::init(void) first_ = true; clear(); obj = shmget(key_, bytes_, IPC_EXCL | IPC_CREAT | 0600); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s is not existing and reopen it\n", prev.c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s is not existing and reopen it\n", prev.c_str()); } } else { - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "shmget(0x%x%08x) = %d\n", v[1], v[0], errno); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "shmget(0x%x%08x) = %d\n", v[1], v[0], errno); return; } } obj_ = (void*)obj; - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "shared memory id = %d[%s], \n", obj, first_ ? "created" : "opened"); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "shared memory id = %d[%s], \n", obj, first_ ? "created" : "opened"); #endif if(first_) @@ -248,7 +248,7 @@ char* shared_memory::get_buf(void) #else int* h = (int*)&obj_; char* buf = (char*)shmat(*h, 0, 0); - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "shared memory %d buffer = %s, error = %d\n", *h, hg_log::format_ptr(buf).c_str(), errno); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "shared memory %d buffer = %s, error = %d\n", *h, hg_log::format_ptr(buf).c_str(), errno); #endif return buf; @@ -287,11 +287,11 @@ std::string shared_memory::get_proc_name_by_pid(pid_t pid) } if (sizeof(pid) > 4 && v[1]) { - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "PID(%lld) name is: %s\n", pid, ret.c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "PID(%lld) name is: %s\n", pid, ret.c_str()); } else { - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "PID(%u) name is: %s\n", pid, ret.c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "PID(%u) name is: %s\n", pid, ret.c_str()); } return ret; diff --git a/hgdriver/hgdev/hg_scanner.cpp b/hgdriver/hgdev/hg_scanner.cpp index ab2c54f..277ced4 100644 --- a/hgdriver/hgdev/hg_scanner.cpp +++ b/hgdriver/hgdev/hg_scanner.cpp @@ -1,5 +1,5 @@ #include "hg_scanner.h" -#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #include "sane/sane_option_definitions.h" #ifdef WIN32 @@ -38,7 +38,7 @@ hg_scanner::hg_scanner(ScannerSerial serial for (int i = 0; i < ARRAY_SIZE(custom_gamma_val_->table); ++i) custom_gamma_val_->table[i] = i & 0x0ff; - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s(%s) constructed\n", name_.c_str(), hg_log::format_ptr(this).c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s(%s) constructed\n", name_.c_str(), hg_log::format_ptr(this).c_str()); image_prc_param_.value = 0; if (io_) @@ -67,7 +67,7 @@ hg_scanner::~hg_scanner() name_.insert(0, "\350\256\276\345\244\207 “"); name_ += "”\345\267\262\347\273\217\345\205\263\351\227\255\343\200\202"; notify_ui_working_status(name_.c_str(), SANE_EVENT_SCANNER_CLOSED); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s(%s) destroyed.\n", name_.c_str(), hg_log::format_ptr(this).c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s(%s) destroyed.\n", name_.c_str(), hg_log::format_ptr(this).c_str()); } std::string hg_scanner::strerr(scanner_err err) @@ -217,19 +217,19 @@ int hg_scanner::save_2_tempory_file(std::shared_ptr> data, std { if (path_file) *path_file = file; - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "--->Wrote %u bytes to file '%s'\n", wrote, file.c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "--->Wrote %u bytes to file '%s'\n", wrote, file.c_str()); } else { ret = SCANNER_ERR_WRITE_FILE_FAILED; - HG_VLOG_MINI_3(LOG_LEVEL_FATAL, "Failed in writting file(%u/%u) '%s'\n", wrote, data->size(), file.c_str()); + VLOG_MINI_3(LOG_LEVEL_FATAL, "Failed in writting file(%u/%u) '%s'\n", wrote, data->size(), file.c_str()); } fclose(dst); } else { ret = SCANNER_ERR_CREATE_FILE_FAILED; - HG_VLOG_MINI_1(LOG_LEVEL_FATAL, "Failed in creating file '%s'\n", file.c_str()); + VLOG_MINI_1(LOG_LEVEL_FATAL, "Failed in creating file '%s'\n", file.c_str()); } return ret; @@ -249,7 +249,7 @@ void hg_scanner::set_setting_map(int sn, const char* title) empty++; val.erase(0, empty); - //HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "title: '%s', val: '%s'\n", title, val.c_str()); + //VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "title: '%s', val: '%s'\n", title, val.c_str()); if (val == OPTION_TITLE_HFMRSZ) setting_map_[HG_BASE_SETTING_INDEX_RESTORE_DEFAULT_SETTINGS] = sn; @@ -376,7 +376,7 @@ void hg_scanner::thread_handle_usb(void) std::this_thread::sleep_for(std::chrono::milliseconds(3000)); if (scan_life_) { - HG_LOG(LOG_LEVEL_FATAL, "image process is still running!\n"); + LOG_INFO(LOG_LEVEL_FATAL, "image process is still running!\n"); continue; } } @@ -486,7 +486,7 @@ void hg_scanner::get_range(int setting_no, std::vector& range, std: else if(type == "string") setting_jsn_.at(sn).at("default").get_to(def_val); - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "setting %d has %d range(s) and default value is '%s'\n", setting_no, range.size(), def_val.c_str()); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "setting %d has %d range(s) and default value is '%s'\n", setting_no, range.size(), def_val.c_str()); } bool hg_scanner::check_range(int setting_no, bool& val) { @@ -723,7 +723,7 @@ void hg_scanner::thread_handle_image_process(void) } else { - HG_VLOG_MINI_1(LOG_LEVEL_FATAL, "FATAL: open tempory image file '%s' failed.\n", file.c_str()); + VLOG_MINI_1(LOG_LEVEL_FATAL, "FATAL: open tempory image file '%s' failed.\n", file.c_str()); } } else @@ -821,11 +821,11 @@ void hg_scanner::working_done(void*) if (test_1_paper_) { - HG_LOG(LOG_LEVEL_DEBUG_INFO, "scanning mode: finished testing ONE paper, restore to normal scanning.\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, "scanning mode: finished testing ONE paper, restore to normal scanning.\n"); } else { - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "scanned %d picture(s) and finished with error %s.\n", final_img_index_, hg_scanner::strerr((scanner_err)status_).c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "scanned %d picture(s) and finished with error %s.\n", final_img_index_, hg_scanner::strerr((scanner_err)status_).c_str()); } test_1_paper_ = false; @@ -932,14 +932,14 @@ int hg_scanner::setting_help(void* data) if (access(helpfile.c_str(),F_OK) == -1) #endif { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"App_Help_pdf path is:%s system is:%d\r\n",helpfile.c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"App_Help_pdf path is:%s system is:%d\r\n",helpfile.c_str()); ret = SCANNER_ERR_OPEN_FILE_FAILED; return ret ; } com += helpfile; system(com.c_str()); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"App_Help_pdf path is:%s system is:%d\r\n",helpfile.c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"App_Help_pdf path is:%s system is:%d\r\n",helpfile.c_str()); return ret; } int hg_scanner::setting_color_mode(void* data) @@ -975,7 +975,7 @@ int hg_scanner::setting_color_mode(void* data) is_auto_matic_color = image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH ? true :false; // 等于COLOR_MODE_AUTO_MATCH 的时候颜色模式需要变为2 彩色模式图像参数和硬件参数都如此 - HG_VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "Change color mode from %s to %s = %s color is =%s\n", color_mode_string(old).c_str(), (char*)data, hg_scanner::strerr((scanner_err)ret).c_str(),str.c_str()); + VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "Change color mode from %s to %s = %s color is =%s\n", color_mode_string(old).c_str(), (char*)data, hg_scanner::strerr((scanner_err)ret).c_str(),str.c_str()); if(ret == SCANNER_ERR_NOT_EXACT) strcpy((char*)data, str.c_str()); @@ -999,7 +999,7 @@ int hg_scanner::setting_multi_out_type(void *data) bool exact = check_range(setting_map_[HG_BASE_SETTING_INDEX_MULTI_OUT], str); int color; image_prc_param_.bits.multi_out = match_best_multi_out(str,NULL); - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "set multi_out type from %s to %s = %s\n", multi_out_string(image_prc_param_.bits.multi_out).c_str(), (char*)data, hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "set multi_out type from %s to %s = %s\n", multi_out_string(image_prc_param_.bits.multi_out).c_str(), (char*)data, hg_scanner::strerr((scanner_err)ret).c_str()); if (image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW) color = COLOR_MODE_256_GRAY; @@ -1105,7 +1105,7 @@ int hg_scanner::setting_paper(void* data) else if (!exact) ret = SCANNER_ERR_NOT_EXACT; - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change paper from %s to %s = %s\n", paper_string(old).c_str(), (char*)data, hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change paper from %s to %s = %s\n", paper_string(old).c_str(), (char*)data, hg_scanner::strerr((scanner_err)ret).c_str()); if(ret == SCANNER_ERR_NOT_EXACT) strcpy((char*)data, paper.c_str()); @@ -1119,7 +1119,7 @@ int hg_scanner::setting_paper_check(void* data) bool use = *((bool*)data); int ret = on_paper_check_changed(use); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Change paper size-checking %s = %s\n", *((bool*)data) ? "enabled" : "disabled", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Change paper size-checking %s = %s\n", *((bool*)data) ? "enabled" : "disabled", hg_scanner::strerr((scanner_err)ret).c_str()); *((bool*)data) = use; return ret; @@ -1130,7 +1130,7 @@ int hg_scanner::setting_page(void* data) bool exact = check_range(setting_map_[HG_BASE_SETTING_INDEX_PAGE], val); int ret = exact ? SCANNER_ERR_OK : SCANNER_ERR_NOT_EXACT; - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change page from %s to %s = %s\n", page_string(image_prc_param_.bits.page).c_str(), (char*)data, hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change page from %s to %s = %s\n", page_string(image_prc_param_.bits.page).c_str(), (char*)data, hg_scanner::strerr((scanner_err)ret).c_str()); image_prc_param_.bits.page = match_best_page(val, NULL); if (!exact) strcpy((char*)data, val.c_str()); @@ -1165,7 +1165,7 @@ int hg_scanner::setting_resolution(void* data) else if (sub) ret = sub; - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change resolution from %d to %d = %s\n", old, *((int*)data), hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change resolution from %d to %d = %s\n", old, *((int*)data), hg_scanner::strerr((scanner_err)ret).c_str()); *((int*)data) = resolution_; return ret; @@ -1206,7 +1206,7 @@ int hg_scanner::setting_rid_hoe_range(void* data) *((int*)data) = rid_hole_range_; } rid_hole_range_*=100; - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "rid_hole_range_ = %f\r\n", rid_hole_range_); + VLOG_MINI_1(LOG_LEVEL_WARNING, "rid_hole_range_ = %f\r\n", rid_hole_range_); return ret; } @@ -1255,7 +1255,7 @@ int hg_scanner::setting_sharpen(void* data) int ret = SCANNER_ERR_OK; bool exact = check_range(setting_map_[HG_BASE_SETTING_INDEX_SHARPEN], str); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Change sharpen from %s to %s = ", sharpen_string(image_prc_param_.bits.sharpen).c_str(), (char*)data); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Change sharpen from %s to %s = ", sharpen_string(image_prc_param_.bits.sharpen).c_str(), (char*)data); image_prc_param_.bits.sharpen = match_best_sharpen(str, NULL); if (!exact) @@ -1263,7 +1263,7 @@ int hg_scanner::setting_sharpen(void* data) strcpy((char*)data, str.c_str()); ret = SCANNER_ERR_NOT_EXACT; } - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%d\n", ret); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%d\n", ret); return ret; } @@ -1344,7 +1344,7 @@ int hg_scanner::setting_is_permeate_lv(void* data) std::string str((char*)data); bool exact = check_range(setting_map_[HG_BASE_SETTING_INDEX_PERMEATE_LV], str); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Change is_permeate_lv from %s to %s = ", is_permaeate_string(image_prc_param_.bits.is_permeate_lv_).c_str(), (char*)data); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Change is_permeate_lv from %s to %s = ", is_permaeate_string(image_prc_param_.bits.is_permeate_lv_).c_str(), (char*)data); image_prc_param_.bits.is_permeate_lv_ = match_best_permaeate_lv(str, NULL); if (!exact) @@ -1352,7 +1352,7 @@ int hg_scanner::setting_is_permeate_lv(void* data) strcpy((char*)data, str.c_str()); ret = SCANNER_ERR_NOT_EXACT; } - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%d\n", ret); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%d\n", ret); return ret; @@ -1412,7 +1412,7 @@ int hg_scanner::setting_scan_mode(void* data) setting_jsn_.at(key).at("cur").get_to(scan_count_); } - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "set scanning pages to %d\n", scan_count_); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "set scanning pages to %d\n", scan_count_); return ret; } @@ -1433,7 +1433,7 @@ int hg_scanner::setting_scan_count(void* data) scan_count_ = *((int*)data); } - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "set scanning pages to %d\n", scan_count_); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "set scanning pages to %d\n", scan_count_); return ret; } @@ -1443,7 +1443,7 @@ int hg_scanner::setting_text_direction(void* data) bool exact = check_range(setting_map_[HG_BASE_SETTING_INDEX_TEXT_DIRECTION], str); int ret = exact ? SCANNER_ERR_OK : SCANNER_ERR_NOT_EXACT; - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change text direction from '%s' to '%s' = %s\n", text_direction_string(image_prc_param_.bits.text_direction).c_str() + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change text direction from '%s' to '%s' = %s\n", text_direction_string(image_prc_param_.bits.text_direction).c_str() , (char*)data, hg_scanner::strerr((scanner_err)ret).c_str()); image_prc_param_.bits.text_direction = match_best_text_direction(str, NULL); if (!exact) @@ -1565,7 +1565,7 @@ int hg_scanner::setting_img_quality(void *data) std::string str((char*)data); bool exact = check_range(setting_map_[HG_BASE_SETTING_INDEX_IMG_QUALITY], str); int ret = exact ? SCANNER_ERR_OK : SCANNER_ERR_NOT_EXACT; - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change quality from '%s' to '%s' = %s\n", is_img_quality(is_quality_).c_str() + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Change quality from '%s' to '%s' = %s\n", is_img_quality(is_quality_).c_str() , (char*)data, hg_scanner::strerr((scanner_err)ret).c_str()); is_quality_ = match_best_img_quality(str,NULL); @@ -1613,7 +1613,7 @@ void hg_scanner::on_device_reconnected(void) { std::lock_guard lock(io_lock_); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%04x:%04x reconnected.\n", io_->get_vid(), io_->get_pid()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%04x:%04x reconnected.\n", io_->get_vid(), io_->get_pid()); } int hg_scanner::set_setting_value(int setting_no, void* data, int len) { @@ -1689,7 +1689,7 @@ int hg_scanner::on_scann_error(int err) { status_ = err; - HG_VLOG_MINI_1(LOG_LEVEL_FATAL, "[xxx]Device status: 0x%x\n", err); + VLOG_MINI_1(LOG_LEVEL_FATAL, "[xxx]Device status: 0x%x\n", err); unsigned int e = err; @@ -1743,7 +1743,7 @@ std::shared_ptr> hg_scanner::aquire_memory(int size, bool from catch (...) { mem.reset(); - HG_VLOG_MINI_1(LOG_LEVEL_FATAL, "Allocate memory of bytes %u failed!\n", size); + VLOG_MINI_1(LOG_LEVEL_FATAL, "Allocate memory of bytes %u failed!\n", size); } if (!mem.get()) @@ -1758,12 +1758,12 @@ std::shared_ptr> hg_scanner::aquire_memory(int size, bool from catch (...) { mem.reset(); - HG_VLOG_MINI_1(LOG_LEVEL_FATAL, "Allocate memory of bytes %u failed secondary after 10 milliseconds!\n", size); + VLOG_MINI_1(LOG_LEVEL_FATAL, "Allocate memory of bytes %u failed secondary after 10 milliseconds!\n", size); } } if (!mem.get()) { - HG_LOG(LOG_LEVEL_FATAL, "Can't aquire enough memory, working must be stopped!\n"); + LOG_INFO(LOG_LEVEL_FATAL, "Can't aquire enough memory, working must be stopped!\n"); stop(); } } @@ -1805,7 +1805,7 @@ bool hg_scanner::waiting_for_memory_enough(unsigned need_bytes) { if (first) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Memory is too small for aquiring image(%u bytes), wait for ENOUGH ...\n", need_bytes); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Memory is too small for aquiring image(%u bytes), wait for ENOUGH ...\n", need_bytes); notify_ui_working_status(STATU_DESC_WAIT_FOR_MEM); first = false; } @@ -1816,11 +1816,11 @@ bool hg_scanner::waiting_for_memory_enough(unsigned need_bytes) { if (buf) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "waited for memory need(%u)\n", need_bytes); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "waited for memory need(%u)\n", need_bytes); } else { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "canceled by user while waiting for memory need(%u)\n", need_bytes); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "canceled by user while waiting for memory need(%u)\n", need_bytes); } } ret = (!user_cancel_) && (buf != NULL); @@ -1848,7 +1848,7 @@ int hg_scanner::save_usb_data(std::shared_ptr> data) int ret = SCANNER_ERR_OK; usb_img_index_++; - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "USB read one picture with %u bytes\n", data->size()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "USB read one picture with %u bytes\n", data->size()); if (is_to_file()) { std::string file(""); @@ -1972,7 +1972,7 @@ int hg_scanner::close(bool force) } else if (io_) { - HG_LOG(LOG_LEVEL_WARNING, "close scanner: USB thread or Image thread is still running.\n"); + LOG_INFO(LOG_LEVEL_WARNING, "close scanner: USB thread or Image thread is still running.\n"); io_->close(); io_->release(); io_ = NULL; @@ -2060,7 +2060,7 @@ int hg_scanner::set_setting(int setting_no, void* data, int len) } if (!hit) { - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "Setting %d is not found in base setting functions.\n", setting_no); + VLOG_MINI_1(LOG_LEVEL_WARNING, "Setting %d is not found in base setting functions.\n", setting_no); ret = set_setting_value(setting_no, data, len); } @@ -2140,7 +2140,7 @@ int hg_scanner::get_setting(int setting_no, char* json_txt_buf, int* len) sprintf(sn, "%d", setting_no); if (!setting_jsn_.contains(sn)) - HG_VLOG_MINI_2(LOG_LEVEL_FATAL, "!!!option(%d - %s) is not found.\n", setting_no, sn); + VLOG_MINI_2(LOG_LEVEL_FATAL, "!!!option(%d - %s) is not found.\n", setting_no, sn); text = setting_jsn_.at(sn).dump(); setting_jsn_.at(sn).at("name").get_to(name); if (name == SANE_STD_OPT_NAME_CUSTOM_AREA_LEFT || name == SANE_STD_OPT_NAME_CUSTOM_AREA_RIGHT) @@ -2273,7 +2273,7 @@ int hg_scanner::get_image_info(SANE_Parameters* ii) ret = SCANNER_ERR_OK; } } - HG_VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "Get image info(%d * %d * %d) = %s\n", ii->pixels_per_line, ii->lines, imh.bits, hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "Get image info(%d * %d * %d) = %s\n", ii->pixels_per_line, ii->lines, imh.bits, hg_scanner::strerr((scanner_err)ret).c_str()); return ret; } diff --git a/hgdriver/hgdev/hg_scanner_200.cpp b/hgdriver/hgdev/hg_scanner_200.cpp index fe06c7b..fa9bf9b 100644 --- a/hgdriver/hgdev/hg_scanner_200.cpp +++ b/hgdriver/hgdev/hg_scanner_200.cpp @@ -1,5 +1,5 @@ #include "hg_scanner_200.h" -#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #ifdef WIN32 #include "scanner_manager.h" @@ -120,7 +120,7 @@ namespace settingsdsp_200 *r = true; else *r = false; - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Paper '%s' index = %d, device value = %d\n", paper_string(paper).c_str(), ind, paper_map[ind].dev_value); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Paper '%s' index = %d, device value = %d\n", paper_string(paper).c_str(), ind, paper_map[ind].dev_value); paper = paper_map[ind].paper; if (type) *type = paper_map[ind].type; @@ -209,7 +209,7 @@ enum hg_239_setting_item hg_scanner_200::hg_scanner_200(const char* dev_name,int pid, usb_io* io) : hg_scanner(G100Serial, dev_name, io), pid_(pid) { string fw = get_firmware_version(); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_firmware_version is: %s\n",fw.c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_firmware_version is: %s\n",fw.c_str()); initdevice(); dsp_config_.value = 0; @@ -250,7 +250,7 @@ void hg_scanner_200::discard_prev(void) ret = get_scanner_status(usb); } if (imgs || packets) - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "discard prev-scanning %d packets and %d images.\n", packets, imgs); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "discard prev-scanning %d packets and %d images.\n", packets, imgs); } void hg_scanner_200::init_setting_map(int* setting_map, int count) @@ -397,7 +397,7 @@ void hg_scanner_200::thread_handle_usb_read(void) else { // notify_ui_working_status(hg_scanner::error_description((scanner_err)prev_err).c_str(), SANE_EVENT_ERROR, prev_err); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "-x-x-x-: USB thread error: %s\n", hg_scanner::strerr((scanner_err)prev_err).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "-x-x-x-: USB thread error: %s\n", hg_scanner::strerr((scanner_err)prev_err).c_str()); } prev_err = ret; } @@ -433,7 +433,7 @@ int hg_scanner_200::start(void) // { // status_ = ret; // notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING, SANE_EVENT_SCAN_FINISHED, status_); - // HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING); + // VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING); // return ret; // } ret = get_scanner_paperon(); @@ -441,7 +441,7 @@ int hg_scanner_200::start(void) { status_ = ret; notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER, SANE_EVENT_ERROR, status_); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER); + VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER); return ret; } @@ -450,7 +450,7 @@ int hg_scanner_200::start(void) ret = writeusb(usb); io_->set_timeout(500); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "device start is.(%s)\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "device start is.(%s)\n", hg_scanner::strerr((scanner_err)ret).c_str()); if(ret == SCANNER_ERR_OK) { @@ -473,7 +473,7 @@ int hg_scanner_200::stop(void) user_cancel_ = true; if (ret == SCANNER_ERR_DEVICE_BUSY) { - HG_LOG(LOG_LEVEL_DEBUG_INFO,"stop status is busy\r\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO,"stop status is busy\r\n"); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); } else if (ret == SCANNER_ERR_OK) @@ -604,11 +604,11 @@ void hg_scanner_200::image_process(std::shared_ptr>& buffer) param.double_side = img_conf_.is_duplex; param.dpi = img_conf_.resolution_dst; - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.black_white :%d\r\n",param.black_white); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.channels :%d\r\n",param.channels); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.color_mode :%d\r\n",param.color_mode); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.double_side :%d\r\n",param.double_side); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.dpi :%d\r\n",param.dpi); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.black_white :%d\r\n",param.black_white); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.channels :%d\r\n",param.channels); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.color_mode :%d\r\n",param.color_mode); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.double_side :%d\r\n",param.double_side); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.dpi :%d\r\n",param.dpi); handle = hg_imgproc::init(&img_conf_,¶m,pid_); @@ -759,7 +759,7 @@ void hg_scanner_200::image_process(std::shared_ptr>& buffer) colormode=img_conf_.pixtype; err = hg_imgproc::split(handle,img_conf_.multiOutput,img_conf_.splitImage,img_conf_.multi_output_red,colormode,img_conf_.is_duplex); - HG_VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "img split-> multiOutput is:%d splitImage is:%d multi_output_red is:%d pixtype is:%d is_duplex:%d\r\n" + VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "img split-> multiOutput is:%d splitImage is:%d multi_output_red is:%d pixtype is:%d is_duplex:%d\r\n" ,img_conf_.multiOutput ,img_conf_.splitImage ,img_conf_.multi_output_red @@ -792,7 +792,7 @@ void hg_scanner_200::image_process(std::shared_ptr>& buffer) while (hg_imgproc::get_final_data(handle, &ih, &buf, index++) == SCANNER_ERR_OK && !user_cancel_) { - HG_VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "Final picture %d (%d * %d * %d) with %u bytes!\n", index + VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "Final picture %d (%d * %d * %d) with %u bytes!\n", index , ih.width, ih.height, ih.bits * ih.channels, ih.total_bytes); std::vectorbmpdata; @@ -808,7 +808,7 @@ void hg_scanner_200::image_process(std::shared_ptr>& buffer) buf = bmpdata.data(); ih.total_bytes = bmpdata.size(); - HG_VLOG_MINI_6(LOG_LEVEL_DEBUG_INFO, "Set img type is:%s Final picture %d (%d * %d * %d) with %u bytes!\n",img_type_.c_str() ,index + VLOG_MINI_6(LOG_LEVEL_DEBUG_INFO, "Set img type is:%s Final picture %d (%d * %d * %d) with %u bytes!\n",img_type_.c_str() ,index , ih.width, ih.height, ih.bits * ih.channels, ih.total_bytes); } @@ -833,7 +833,7 @@ int hg_scanner_200::writedown_device_configuration(bool type,HGSCANCONF_DSP *d) len = sizeof(USBCB); ret = io_->write_bulk(&usbcb,&len); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "writedown_device_configuration is .(%s)\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "writedown_device_configuration is .(%s)\n", hg_scanner::strerr((scanner_err)ret).c_str()); return ret; } @@ -1067,7 +1067,7 @@ else if (test_1_paper_) { - HG_LOG(LOG_LEVEL_DEBUG_INFO, "scanning mode: testing ONE paper ...\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, "scanning mode: testing ONE paper ...\n"); ic.scannum = 1; } else @@ -1142,56 +1142,56 @@ else img_conf_ = ic; agreement(); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.pixtype=%d", ic.pixtype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.papertype=%d", ic.papertype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.AutoCrop_threshold=%d", ic.AutoCrop_threshold); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.autodescrew=%d", ic.autodescrew); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.automaticcolor=%d", ic.automaticcolor); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.brightness=%f", ic.brightness); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.contrast=%f", ic.contrast); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_fold=%d", ic.en_fold); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_sizecheck=%d", ic.en_sizecheck); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.enhance_color=%d", ic.enhance_color); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillbackground=%d", ic.fillbackground); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.filter=%d", ic.filter); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.gamma=%f", ic.gamma); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.capturepixtype=%d", ic.hardwarecaps.capturepixtype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.en_doublefeed=%d", ic.hardwarecaps.en_doublefeed); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hsvcorrect=%d", ic.hsvcorrect); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.imageRotateDegree=%f", ic.imageRotateDegree); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.indent=%d", 5); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocontrast=%d", ic.is_autocontrast); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocrop=%d", ic.is_autocrop); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_normal=%d", ic.is_autodiscradblank_normal); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_vince=%d", ic.is_autodiscradblank_vince); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autotext=%d", ic.is_autotext); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_backrotate180=%d", ic.is_backrotate180); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_convex=%d", ic.is_convex); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_duplex=%d", ic.is_duplex); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_switchfrontback=%d", ic.is_switchfrontback); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_dogeardetection=%d", ic.is_dogeardetection); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.multi_output_red=%d", ic.multi_output_red); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.noise=%d", 8); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_dst=%f", ic.resolution_dst); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_native=%f", ic.resolution_native); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.scannum=%d", ic.scannum); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.sharpen=%d", ic.sharpen); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.discardblank_percent=%d", ic.discardblank_percent); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.is_detachnoise=%d", ic.detachnoise.is_detachnoise); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.detachnoise=%d\r ", ic.detachnoise.detachnoise); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.refuseInflow=%d\r ", ic.refuseInflow); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.refuseInflow=%d\r ", ic.refuseInflow); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.removeMorr=%d\r ", ic.removeMorr); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.errorExtention=%d\r ", ic.errorExtention); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.textureRemove=%d\r\n ", ic.textureRemove); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.is_fillhole=%d\r\n ", ic.fillhole.is_fillhole); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.ic.fillhole.fillholeratio=%f\r\n ", ic.fillhole.fillholeratio); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fadeback=%d\r\n ",ic.fadeback); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.enable=%d\r\n ",ic.cropRect.enable); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.height=%d\r\n ",ic.cropRect.height); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.width=%d\r\n ",ic.cropRect.width); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.x=%d\r\n ",ic.cropRect.x); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.y=%d\r\n ",ic.cropRect.y); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.pixtype=%d", ic.pixtype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.papertype=%d", ic.papertype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.AutoCrop_threshold=%d", ic.AutoCrop_threshold); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.autodescrew=%d", ic.autodescrew); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.automaticcolor=%d", ic.automaticcolor); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.brightness=%f", ic.brightness); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.contrast=%f", ic.contrast); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_fold=%d", ic.en_fold); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_sizecheck=%d", ic.en_sizecheck); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.enhance_color=%d", ic.enhance_color); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillbackground=%d", ic.fillbackground); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.filter=%d", ic.filter); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.gamma=%f", ic.gamma); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.capturepixtype=%d", ic.hardwarecaps.capturepixtype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.en_doublefeed=%d", ic.hardwarecaps.en_doublefeed); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hsvcorrect=%d", ic.hsvcorrect); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.imageRotateDegree=%f", ic.imageRotateDegree); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.indent=%d", 5); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocontrast=%d", ic.is_autocontrast); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocrop=%d", ic.is_autocrop); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_normal=%d", ic.is_autodiscradblank_normal); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_vince=%d", ic.is_autodiscradblank_vince); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autotext=%d", ic.is_autotext); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_backrotate180=%d", ic.is_backrotate180); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_convex=%d", ic.is_convex); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_duplex=%d", ic.is_duplex); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_switchfrontback=%d", ic.is_switchfrontback); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_dogeardetection=%d", ic.is_dogeardetection); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.multi_output_red=%d", ic.multi_output_red); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.noise=%d", 8); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_dst=%f", ic.resolution_dst); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_native=%f", ic.resolution_native); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.scannum=%d", ic.scannum); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.sharpen=%d", ic.sharpen); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.discardblank_percent=%d", ic.discardblank_percent); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.is_detachnoise=%d", ic.detachnoise.is_detachnoise); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.detachnoise=%d\r ", ic.detachnoise.detachnoise); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.refuseInflow=%d\r ", ic.refuseInflow); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.refuseInflow=%d\r ", ic.refuseInflow); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.removeMorr=%d\r ", ic.removeMorr); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.errorExtention=%d\r ", ic.errorExtention); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.textureRemove=%d\r\n ", ic.textureRemove); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.is_fillhole=%d\r\n ", ic.fillhole.is_fillhole); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.ic.fillhole.fillholeratio=%f\r\n ", ic.fillhole.fillholeratio); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fadeback=%d\r\n ",ic.fadeback); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.enable=%d\r\n ",ic.cropRect.enable); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.height=%d\r\n ",ic.cropRect.height); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.width=%d\r\n ",ic.cropRect.width); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.x=%d\r\n ",ic.cropRect.x); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.y=%d\r\n ",ic.cropRect.y); } void hg_scanner_200::printf_devconfig(HGSCANCONF_DSP *d) @@ -1200,18 +1200,18 @@ void hg_scanner_200::printf_devconfig(HGSCANCONF_DSP *d) if (!d) d = &dsp_config_; - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\r\ndsp_config.params.color:%d\r\n",d->params.color); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.double_feed_enbale:%d\r\n",d->params.double_feed_enbale); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.dpi:%d\r\n",d->params.dpi); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.enable_sizecheck:%d\r\n",d->params.enable_sizecheck); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.paper:%d\r\n",d->params.paper); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.pc_correct:%d\r\n",d->params.pc_correct); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.screw_detect_enable:%d\r\n",d->params.screw_detect_enable); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.screw_detect_level:%d\r\n",d->params.screw_detect_level); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.stable_enbale:%d\r\n",d->params.stable_enbale); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.unused_one:%d\r\n",d->params.unused_one); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.unused_two:%d\r\n",d->params.unused_two); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.value:%d\r\n",d->value); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\r\ndsp_config.params.color:%d\r\n",d->params.color); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.double_feed_enbale:%d\r\n",d->params.double_feed_enbale); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.dpi:%d\r\n",d->params.dpi); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.enable_sizecheck:%d\r\n",d->params.enable_sizecheck); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.paper:%d\r\n",d->params.paper); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.pc_correct:%d\r\n",d->params.pc_correct); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.screw_detect_enable:%d\r\n",d->params.screw_detect_enable); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.screw_detect_level:%d\r\n",d->params.screw_detect_level); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.stable_enbale:%d\r\n",d->params.stable_enbale); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.unused_one:%d\r\n",d->params.unused_one); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.unused_two:%d\r\n",d->params.unused_two); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config_.params.value:%d\r\n",d->value); } std::string hg_scanner_200::get_firmware_version() { diff --git a/hgdriver/hgdev/hg_scanner_200.h b/hgdriver/hgdev/hg_scanner_200.h index d02e900..0072058 100644 --- a/hgdriver/hgdev/hg_scanner_200.h +++ b/hgdriver/hgdev/hg_scanner_200.h @@ -10,7 +10,7 @@ #include #include "hg_scanner.h" -#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #ifdef OEM_HANWANG #define hg_scanner_200 hw_scanner_200 diff --git a/hgdriver/hgdev/hg_scanner_239.cpp b/hgdriver/hgdev/hg_scanner_239.cpp index bc44217..60e1c2f 100644 --- a/hgdriver/hgdev/hg_scanner_239.cpp +++ b/hgdriver/hgdev/hg_scanner_239.cpp @@ -1,5 +1,5 @@ #include "hg_scanner_239.h" -#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #include "filetools.h" #ifdef WIN32 @@ -365,7 +365,7 @@ namespace settings *r = true; else *r = false; - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Paper '%s' index = %d, device value = %d\n", paper_string(paper).c_str(), ind, paper_map[ind].dev_value); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Paper '%s' index = %d, device value = %d\n", paper_string(paper).c_str(), ind, paper_map[ind].dev_value); paper = paper_map[ind].paper; if (type) *type = paper_map[ind].type; @@ -379,7 +379,7 @@ namespace settings hg_scanner_239::hg_scanner_239(const char* dev_name, int pid,usb_io* io) : hg_scanner(G20039Serial, dev_name, io) , rewrite_conf_(false), reset_(false),pid_(pid) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "hg_scanner_239(%s) constructing ...\n", hg_log::format_ptr(this).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "hg_scanner_239(%s) constructing ...\n", hg_log::format_ptr(this).c_str()); dev_conf_.value = 0; #ifndef MAPPING_FUNCTION_IN_BASE init_setting_map(setting_map_, ARRAY_SIZE(setting_map_)); @@ -390,7 +390,7 @@ hg_scanner_239::hg_scanner_239(const char* dev_name, int pid,usb_io* io) : hg_sc } hg_scanner_239::~hg_scanner_239() { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "hg_scanner_239(%s) destroyed.\n", hg_log::format_ptr(this).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "hg_scanner_239(%s) destroyed.\n", hg_log::format_ptr(this).c_str()); } int hg_scanner_239::read_register(int addr, int* val) @@ -438,12 +438,12 @@ std::string hg_scanner_239::control_fetch(int addr, int val, int size) ret = io_->read_bulk(&data[0], &l); if (ret) { - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "control_fetch(%d, %d) - read_bulk = %s\n", addr, val, hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "control_fetch(%d, %d) - read_bulk = %s\n", addr, val, hg_scanner::strerr((scanner_err)ret).c_str()); data.clear(); } } else - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "control_fetch(%d, %d) = %s\n", addr, val, hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "control_fetch(%d, %d) = %s\n", addr, val, hg_scanner::strerr((scanner_err)ret).c_str()); return data; } @@ -473,7 +473,7 @@ int hg_scanner_239::clr_roller_num(void) return val; else { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "clr_roller_num = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "clr_roller_num = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); return -1; } } @@ -486,7 +486,7 @@ int hg_scanner_239::get_sleep_time(void) return val; else { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_sleep_time = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_sleep_time = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); return -1; } } @@ -497,7 +497,7 @@ int hg_scanner_239::get_scan_mode(void) if (ret) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get scan mode error: %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get scan mode error: %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); status_ = ret; return -1; @@ -512,7 +512,7 @@ int hg_scanner_239::get_status(void) if (ret) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get status error: %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get status error: %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); status_ = ret; return -1; @@ -527,7 +527,7 @@ bool hg_scanner_239::is_dev_tx(void) if (ret) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "is_dev_tx() error: %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "is_dev_tx() error: %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); status_ = ret; return false; @@ -542,7 +542,7 @@ bool hg_scanner_239::is_dev_image_process_done(void) if (ret) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "is_dev_image_process_done() error: %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "is_dev_image_process_done() error: %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); status_ = ret; return true; @@ -558,7 +558,7 @@ bool hg_scanner_239::is_dev_image_keep_last_paper(void) if (ret) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "is_dev_image_keep_last_paper() error: %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "is_dev_image_keep_last_paper() error: %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); status_ = ret; return true; @@ -575,7 +575,7 @@ int hg_scanner_239::get_scanned_count(void) return val; else { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_scanned_count = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_scanned_count = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); return -1; } } @@ -584,7 +584,7 @@ int hg_scanner_239::get_image_count(void) int val = 0, ret = read_register(SR_IM_COUNT, &val); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "get_image_count() = %d, error: %s\n", val, hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "get_image_count() = %d, error: %s\n", val, hg_scanner::strerr((scanner_err)ret).c_str()); if (ret == SCANNER_ERR_OK) return val; @@ -600,7 +600,7 @@ int hg_scanner_239::get_front_data_size(void) return val; else { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_front_data_size = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_front_data_size = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); return -1; } } @@ -609,9 +609,9 @@ void hg_scanner_239::init_version(void) std::string fv(get_firmware_version()), sn(get_serial_num()); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " HG3399 firmware version: %s\n", fv.c_str()); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " HG3399 serial number: %s\n", sn.c_str()); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " HG3399 IP: %s\n", get_ip().c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " HG3399 firmware version: %s\n", fv.c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " HG3399 serial number: %s\n", sn.c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " HG3399 IP: %s\n", get_ip().c_str()); if (fv.length() >= 10 && (fv[5] > 'A' || atoi(fv.substr(6, 4).c_str()) >= 1209)) { @@ -622,7 +622,7 @@ void hg_scanner_239::init_version(void) } void hg_scanner_239::image_process(std::shared_ptr>& buff) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Process image with %u bytes content ...\n", buff->size()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Process image with %u bytes content ...\n", buff->size()); hg_imgproc::IMGPRCPARAM param; hg_imgproc::HIMGPRC handle = NULL; @@ -666,7 +666,7 @@ void hg_scanner_239::image_process(std::shared_ptr>& buff) colormode=img_conf_.pixtype; err = hg_imgproc::split(handle,img_conf_.multiOutput,img_conf_.splitImage,img_conf_.multi_output_red,colormode,img_conf_.is_duplex); - HG_VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "img split-> multiOutput is:%d splitImage is:%d multi_output_red is:%d pixtype is:%d is_duplex:%d\r\n" + VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "img split-> multiOutput is:%d splitImage is:%d multi_output_red is:%d pixtype is:%d is_duplex:%d\r\n" ,img_conf_.multiOutput ,img_conf_.splitImage ,img_conf_.multi_output_red @@ -700,7 +700,7 @@ void hg_scanner_239::image_process(std::shared_ptr>& buff) while (hg_imgproc::get_final_data(handle, &ih, &buf, index++) == SCANNER_ERR_OK && !user_cancel_) { - HG_VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "Final picture %d (%d * %d * %d) with %u bytes!\n", index + VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "Final picture %d (%d * %d * %d) with %u bytes!\n", index , ih.width, ih.height, ih.bits * ih.channels, ih.total_bytes); if(!img_type_.empty()) @@ -717,7 +717,7 @@ void hg_scanner_239::image_process(std::shared_ptr>& buff) buf = bmpdata.data(); ih.total_bytes = bmpdata.size(); - HG_VLOG_MINI_6(LOG_LEVEL_DEBUG_INFO, "Set img type is:%s Final picture %d (%d * %d * %d) with %u bytes!\n",img_type_.c_str() ,index + VLOG_MINI_6(LOG_LEVEL_DEBUG_INFO, "Set img type is:%s Final picture %d (%d * %d * %d) with %u bytes!\n",img_type_.c_str() ,index , ih.width, ih.height, ih.bits * ih.channels, ih.total_bytes); } save_final_image(&ih, buf); @@ -743,7 +743,7 @@ int hg_scanner_239::get_device_paperon_stautus(void) // ret = write_register(SR_CONFIG_SCAN_PARAM, dev_conf_.value); -// HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Writedown scanner configuration(0x%x) = %s\n", dev_conf_.value, hg_scanner::strerr((scanner_err)ret).c_str()); +// VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Writedown scanner configuration(0x%x) = %s\n", dev_conf_.value, hg_scanner::strerr((scanner_err)ret).c_str()); // return ret; // } @@ -757,7 +757,7 @@ int hg_scanner_239::writedown_device_configuration(HGSCANCONF *dev_conf) ret = write_register(SR_CONFIG_SCAN_PARAM, dev_conf->value); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Writedown scanner configuration(0x%x) = %s\n", dev_conf->value, hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Writedown scanner configuration(0x%x) = %s\n", dev_conf->value, hg_scanner::strerr((scanner_err)ret).c_str()); return ret; } @@ -834,7 +834,7 @@ else ic.AutoCrop_threshold = threshold_; if (test_1_paper_) { - HG_LOG(LOG_LEVEL_DEBUG_INFO, "scanning mode: testing ONE paper ...\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, "scanning mode: testing ONE paper ...\n"); ic.scannum = ic.is_duplex ? 2 : 1; } else @@ -903,58 +903,58 @@ else this_thread::sleep_for(chrono::milliseconds(500)); io_->set_timeout(2000);//必要延时 } - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Write-down 0x%x bytes image process parameters\n", len); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.pixtype=%d", ic.pixtype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.papertype=%d", ic.papertype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.AutoCrop_threshold=%d", ic.AutoCrop_threshold); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.autodescrew=%d", ic.autodescrew); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.automaticcolor=%d", ic.automaticcolor); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.brightness=%f", ic.brightness); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.contrast=%f", ic.contrast); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_fold=%d", ic.en_fold); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_sizecheck=%d", ic.en_sizecheck); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.enhance_color=%d", ic.enhance_color); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillbackground=%d", ic.fillbackground); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.filter=%d", ic.filter); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.gamma=%f", ic.gamma); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.capturepixtype=%d", ic.hardwarecaps.capturepixtype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.en_doublefeed=%d", ic.hardwarecaps.en_doublefeed); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hsvcorrect=%d", ic.hsvcorrect); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.imageRotateDegree=%f", ic.imageRotateDegree); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.indent=%d", 5); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocontrast=%d", ic.is_autocontrast); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocrop=%d", ic.is_autocrop); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_normal=%d", ic.is_autodiscradblank_normal); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_vince=%d", ic.is_autodiscradblank_vince); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autotext=%d", ic.is_autotext); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_backrotate180=%d", ic.is_backrotate180); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_convex=%d", ic.is_convex); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_duplex=%d", ic.is_duplex); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_switchfrontback=%d", ic.is_switchfrontback); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_dogeardetection=%d", ic.is_dogeardetection); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.multi_output_red=%d", ic.multi_output_red); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.noise=%d", 8); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.pixtype=%d", ic.pixtype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_dst=%f", ic.resolution_dst); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_native=%f", ic.resolution_native); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.scannum=%d", ic.scannum); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.sharpen=%d", ic.sharpen); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.discardblank_percent=%d", ic.discardblank_percent); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.is_detachnoise=%d", ic.detachnoise.is_detachnoise); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.detachnoise=%d\r ", ic.detachnoise.detachnoise); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.refuseInflow=%d\r ", ic.refuseInflow); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.refuseInflow=%d\r ", ic.refuseInflow); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.removeMorr=%d\r ", ic.removeMorr); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.errorExtention=%d\r ", ic.errorExtention); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.textureRemove=%d\r\n ", ic.refuseInflow); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.is_fillhole=%d\r\n ", ic.fillhole.is_fillhole); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.ic.fillhole.fillholeratio=%d\r\n ", ic.fillhole.fillholeratio); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fadeback=%d\r\n ",ic.fadeback); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.enable=%d\r ", ic.cropRect.enable); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.width=%d\r\n ", ic.cropRect.width); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.height=%d\r\n ", ic.cropRect.height); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.x=%f\r\n ", ic.cropRect.x); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.y=%d\r\n ",ic.cropRect.y); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Write-down 0x%x bytes image process parameters\n", len); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.pixtype=%d", ic.pixtype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.papertype=%d", ic.papertype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.AutoCrop_threshold=%d", ic.AutoCrop_threshold); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.autodescrew=%d", ic.autodescrew); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.automaticcolor=%d", ic.automaticcolor); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.brightness=%f", ic.brightness); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.contrast=%f", ic.contrast); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_fold=%d", ic.en_fold); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_sizecheck=%d", ic.en_sizecheck); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.enhance_color=%d", ic.enhance_color); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillbackground=%d", ic.fillbackground); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.filter=%d", ic.filter); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.gamma=%f", ic.gamma); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.capturepixtype=%d", ic.hardwarecaps.capturepixtype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.en_doublefeed=%d", ic.hardwarecaps.en_doublefeed); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hsvcorrect=%d", ic.hsvcorrect); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.imageRotateDegree=%f", ic.imageRotateDegree); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.indent=%d", 5); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocontrast=%d", ic.is_autocontrast); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocrop=%d", ic.is_autocrop); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_normal=%d", ic.is_autodiscradblank_normal); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_vince=%d", ic.is_autodiscradblank_vince); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autotext=%d", ic.is_autotext); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_backrotate180=%d", ic.is_backrotate180); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_convex=%d", ic.is_convex); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_duplex=%d", ic.is_duplex); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_switchfrontback=%d", ic.is_switchfrontback); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_dogeardetection=%d", ic.is_dogeardetection); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.multi_output_red=%d", ic.multi_output_red); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.noise=%d", 8); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.pixtype=%d", ic.pixtype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_dst=%f", ic.resolution_dst); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_native=%f", ic.resolution_native); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.scannum=%d", ic.scannum); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.sharpen=%d", ic.sharpen); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.discardblank_percent=%d", ic.discardblank_percent); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.is_detachnoise=%d", ic.detachnoise.is_detachnoise); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.detachnoise=%d\r ", ic.detachnoise.detachnoise); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.refuseInflow=%d\r ", ic.refuseInflow); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.refuseInflow=%d\r ", ic.refuseInflow); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.removeMorr=%d\r ", ic.removeMorr); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.errorExtention=%d\r ", ic.errorExtention); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.textureRemove=%d\r\n ", ic.refuseInflow); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.is_fillhole=%d\r\n ", ic.fillhole.is_fillhole); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.ic.fillhole.fillholeratio=%d\r\n ", ic.fillhole.fillholeratio); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fadeback=%d\r\n ",ic.fadeback); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.enable=%d\r ", ic.cropRect.enable); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.width=%d\r\n ", ic.cropRect.width); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.height=%d\r\n ", ic.cropRect.height); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.x=%f\r\n ", ic.cropRect.x); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.y=%d\r\n ",ic.cropRect.y); img_conf_ = ic; return ret; @@ -964,7 +964,7 @@ int hg_scanner_239::pop_first_image(void) { int ret = write_register(SR_IM_POP, 1); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "popup first image = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "popup first image = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); return ret; } @@ -1028,7 +1028,7 @@ int hg_scanner_239::read_one_image_from_usb(void) } if (ret == SCANNER_ERR_OK) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Read image from USB = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Read image from USB = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); ret = save_usb_data(buf); if (ret == SCANNER_ERR_OK) { @@ -1041,7 +1041,7 @@ int hg_scanner_239::read_one_image_from_usb(void) { char msg[128]; sprintf(msg, "Read image data from USB err: %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); - HG_LOG(LOG_LEVEL_DEBUG_INFO, msg); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, msg); notify_ui_working_status(msg); notify_ui_working_status(STATU_DESC_SCANNER_ERR_TIMEOUT, SANE_EVENT_ERROR); } @@ -1089,7 +1089,7 @@ void hg_scanner_239::discard_all_images(void) io_->set_timeout(oto); } if (pre_int) - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "prev-connection has left %d interrupt packet(s) && %d image(s).\n", pre_int, pre_img); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "prev-connection has left %d interrupt packet(s) && %d image(s).\n", pre_int, pre_img); } void hg_scanner_239::init_setting_map(int* setting_map, int count) @@ -1429,7 +1429,7 @@ void hg_scanner_239::thread_handle_usb_read(void) if (size == sizeof(buf)) { status_ = settings::device_status_to_hg_err(info); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "status from interrupt point is '%s'\n", hg_scanner::strerr((scanner_err)status_).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "status from interrupt point is '%s'\n", hg_scanner::strerr((scanner_err)status_).c_str()); if (status_ != SCANNER_ERR_OK && status_ != SCANNER_ERR_TIMEOUT && status_ != SCANNER_ERR_DEVICE_STOPPED) { @@ -1450,7 +1450,7 @@ void hg_scanner_239::thread_handle_usb_read(void) } status_ = st; } - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "扫描失败, read interrupt返回状态为:%s\n", hg_scanner::error_description((scanner_err)status_).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "扫描失败, read interrupt返回状态为:%s\n", hg_scanner::error_description((scanner_err)status_).c_str()); //notify_ui_working_status(("扫描失败 " + hg_scanner::error_description((scanner_err)status_)).c_str(), SANE_EVENT_ERROR, status_); break; } @@ -1474,16 +1474,16 @@ void hg_scanner_239::thread_handle_usb_read(void) if (ret == SCANNER_ERR_INSUFFICIENT_MEMORY) stop(); status_ = ret = SCANNER_ERR_USER_CANCELED; - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "用户取消操作 '%s'\n", hg_scanner::strerr((scanner_err)status_).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "用户取消操作 '%s'\n", hg_scanner::strerr((scanner_err)status_).c_str()); break; } } //else - // HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "status(0x%x) is not accept in usb thread\n", status); + // VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "status(0x%x) is not accept in usb thread\n", status); } else if (info->From == STOPSCAN) { - HG_LOG(LOG_LEVEL_DEBUG_INFO, "received 'STOPSCAN' message in usb thread, check remaining image and finish scanning ...\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, "received 'STOPSCAN' message in usb thread, check remaining image and finish scanning ...\n"); // fetch all buffered images and exit ... while(!is_dev_image_process_done()) @@ -1502,7 +1502,7 @@ void hg_scanner_239::thread_handle_usb_read(void) { std::lock_guard lock(io_lock_); - HG_LOG(LOG_LEVEL_DEBUG_INFO, "First message received from USB is 'STOPSCAN'\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, "First message received from USB is 'STOPSCAN'\n"); // notify_ui_working_status(STATU_DESC_DEVICE_RESET); // reset_ = true; // ret = io_->reset(); @@ -1512,31 +1512,31 @@ void hg_scanner_239::thread_handle_usb_read(void) status_ = SCANNER_ERR_OK; int s = get_status(); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "status after received 'STOPSCAN': 0x%x\n", s); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "status after received 'STOPSCAN': 0x%x\n", s); if (count || (s & 3) == 0) { - HG_LOG(LOG_LEVEL_DEBUG_INFO, "Really stopped ^_^\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, "Really stopped ^_^\n"); break; } } else if (info->From == V4L2) { - HG_VLOG_MINI_2(LOG_LEVEL_WARNING, "V4L2 message received, code = %d, index = %d\n", info->Code, info->Img_Index); + VLOG_MINI_2(LOG_LEVEL_WARNING, "V4L2 message received, code = %d, index = %d\n", info->Code, info->Img_Index); // stop(); break; } else { // error handling ... - HG_VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "Read HGEIntInfo: From = %d, Code = %d, Img_Index = %d, status = %s\n", info->From, info->Code, info->Img_Index, hg_scanner::strerr((scanner_err)status_).c_str()); + VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "Read HGEIntInfo: From = %d, Code = %d, Img_Index = %d, status = %s\n", info->From, info->Code, info->Img_Index, hg_scanner::strerr((scanner_err)status_).c_str()); } } else - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "read %d bytes, sizeof(buf) = %d\n", size, sizeof(buf)); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "read %d bytes, sizeof(buf) = %d\n", size, sizeof(buf)); this_thread::sleep_for(chrono::milliseconds(10)); } - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "USB thread exit with code: %s, status = %s\n", hg_scanner::strerr((scanner_err)ret).c_str(), hg_scanner::strerr((scanner_err)status_).c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "USB thread exit with code: %s, status = %s\n", hg_scanner::strerr((scanner_err)ret).c_str(), hg_scanner::strerr((scanner_err)status_).c_str()); } int hg_scanner_239::start(void) @@ -1553,7 +1553,7 @@ int hg_scanner_239::start(void) user_cancel_ = false; cb_mem_ = true; - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "scanner status: 0x%x\n", get_status()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "scanner status: 0x%x\n", get_status()); notify_ui_working_status(STATU_DESC_PREPARE_START); reset(); @@ -1562,7 +1562,7 @@ int hg_scanner_239::start(void) //if (val != 1) //{ // status_ = SCANNER_ERR_DEVICE_SLEEPING; - // HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "scanner's status(0x%x) is considerring as sleepping.\n", val); + // VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "scanner's status(0x%x) is considerring as sleepping.\n", val); // return status_; //} @@ -1593,7 +1593,7 @@ int hg_scanner_239::start(void) if (ret) { - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "Write down image process parameters fail is(%s), the result will be unpredictable.\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "Write down image process parameters fail is(%s), the result will be unpredictable.\n", hg_scanner::strerr((scanner_err)ret).c_str()); std::string info(STATU_DESC_REWRITE_CONFIGURATION); @@ -1603,7 +1603,7 @@ int hg_scanner_239::start(void) if (ret != SCANNER_ERR_OK) { - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "start status01 is(%s), the result will be unpredictable.\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "start status01 is(%s), the result will be unpredictable.\n", hg_scanner::strerr((scanner_err)ret).c_str()); return ret; } ret = get_scanner_paperon(); @@ -1611,17 +1611,17 @@ int hg_scanner_239::start(void) { status_ = ret; notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER, SANE_EVENT_ERROR, status_); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER); + VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER); return ret; } ret = write_command(SC_START); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "start status02 is(%s), the result will be unpredictable.\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "start status02 is(%s), the result will be unpredictable.\n", hg_scanner::strerr((scanner_err)ret).c_str()); io_->set_timeout(1000); if (ret == SCANNER_ERR_OK) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Write SC_START command success, and now scanner stauts is %x\n", get_status()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Write SC_START command success, and now scanner stauts is %x\n", get_status()); //status_ = SCANNER_ERR_DEVICE_BUSY; wait_usb_.notify(); @@ -1630,7 +1630,7 @@ int hg_scanner_239::start(void) else { status_ = ret; - HG_VLOG_MINI_3(LOG_LEVEL_WARNING, "(%s)[Thread %s]Send start command = %s\n", hg_log::current_time().c_str(), hg_log::format_current_thread_id().c_str(), hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_3(LOG_LEVEL_WARNING, "(%s)[Thread %s]Send start command = %s\n", hg_log::current_time().c_str(), hg_log::format_current_thread_id().c_str(), hg_scanner::strerr((scanner_err)ret).c_str()); } return ret; @@ -1663,7 +1663,7 @@ int hg_scanner_239::start(void) // ii->lines = imh.height; // } // } -// HG_VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "Get image info(%d * %d * %d) = %s\n", ii->pixels_per_line, ii->lines, imh.bits, hg_scanner::strerr((scanner_err)ret).c_str()); +// VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "Get image info(%d * %d * %d) = %s\n", ii->pixels_per_line, ii->lines, imh.bits, hg_scanner::strerr((scanner_err)ret).c_str()); // // return ret; //} @@ -1686,7 +1686,7 @@ int hg_scanner_239::start(void) // int fetch = *len; // // final_imgs_.fetch_front(buf, len); -// HG_VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "[%s]UI fetch image 0x%x/0x%x to buf %s...\n", hg_log::format_current_thread_id().c_str(), *len, fetch +// VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "[%s]UI fetch image 0x%x/0x%x to buf %s...\n", hg_log::format_current_thread_id().c_str(), *len, fetch // , hg_log::format_ptr(buf).c_str()); // // return SCANNER_ERR_OK; @@ -1762,7 +1762,7 @@ int hg_scanner_239::get_roller_num(void) return val; else { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_roller_num = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_roller_num = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); return -1; } } @@ -1826,7 +1826,7 @@ int hg_scanner_239::get_sleep_time(SANE_Power* getime) *getime = (SANE_Power)val; else { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_sleep_time = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_sleep_time = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); return -1; } } @@ -1835,7 +1835,7 @@ int hg_scanner_239::set_sleep_time(int setsleepime) { int ret = write_register(SR_SET_SLEEPTIME, setsleepime); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "set sleep time to %d = %s\n", setsleepime, hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "set sleep time to %d = %s\n", setsleepime, hg_scanner::strerr((scanner_err)ret).c_str()); return ret; } @@ -1873,7 +1873,7 @@ int hg_scanner_239::get_scanner_paperon(SANE_Bool* paperon) } else { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_scanner_paperon = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_scanner_paperon = %s\n", hg_scanner::strerr((scanner_err)ret).c_str()); return -1; } return ret; diff --git a/hgdriver/hgdev/hg_scanner_300.cpp b/hgdriver/hgdev/hg_scanner_300.cpp index 0ee2302..2c71c45 100644 --- a/hgdriver/hgdev/hg_scanner_300.cpp +++ b/hgdriver/hgdev/hg_scanner_300.cpp @@ -1,5 +1,5 @@ #include "hg_scanner_300.h" -#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #ifdef WIN32 #include "scanner_manager.h" @@ -105,7 +105,7 @@ namespace settingsdsp_300 *r = true; else *r = false; - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Paper '%s' index = %d, device value = %d\n", paper_string(paper).c_str(), ind, paper_map[ind].dev_value); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Paper '%s' index = %d, device value = %d\n", paper_string(paper).c_str(), ind, paper_map[ind].dev_value); paper = paper_map[ind].paper; if (type) *type = paper_map[ind].type; @@ -380,7 +380,7 @@ void hg_scanner_300::thread_handle_usb_read(void) { status_ = ret; notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING, SANE_EVENT_ERROR, status_); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING); + VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING); return ret; } ret = get_scanner_paperon(); @@ -388,14 +388,14 @@ void hg_scanner_300::thread_handle_usb_read(void) { status_ = ret; notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER, SANE_EVENT_ERROR, status_); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER); + VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER); return ret; } USBCB usb = {START_COMMAND, img_conf_.scannum, 0}; ret = writeusb(usb); io_->set_timeout(500); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "device start is.(%s)\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "device start is.(%s)\n", hg_scanner::strerr((scanner_err)ret).c_str()); if(ret == SCANNER_ERR_OK) { @@ -417,7 +417,7 @@ int hg_scanner_300::stop(void) if (status_ == SCANNER_ERR_DEVICE_BUSY) { - HG_LOG(LOG_LEVEL_DEBUG_INFO,"stop status is busy\r\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO,"stop status is busy\r\n"); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); } //user_cancel_ = true; @@ -552,10 +552,10 @@ void hg_scanner_300::image_process(std::shared_ptr>& buffer) param.double_side = img_conf_.is_duplex; param.dpi = img_conf_.resolution_dst; - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.black_white :%d\r\n",param.black_white); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.channels :%d\r\n",param.channels); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.color_mode :%d\r\n",param.color_mode); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.double_side :%d\r\n",param.double_side); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.black_white :%d\r\n",param.black_white); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.channels :%d\r\n",param.channels); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.color_mode :%d\r\n",param.color_mode); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.double_side :%d\r\n",param.double_side); @@ -570,10 +570,10 @@ void hg_scanner_300::image_process(std::shared_ptr>& buffer) // if (img_conf_.en_sizecheck) // { -// HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"img_conf_.en_sizecheck :%d\r\n",img_conf_.en_sizecheck); +// VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"img_conf_.en_sizecheck :%d\r\n",img_conf_.en_sizecheck); // printf("img_conf_.en_sizecheck = %d\r\n",img_conf_.en_sizecheck); // ret = hg_imgproc::size_detection(handle); -// HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"img_conf_.en_sizecheck ret:%d\r\n",ret); +// VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"img_conf_.en_sizecheck ret:%d\r\n",ret); // if (ret == SCANNER_ERR_DEVICE_SIZE_CHECK) // { @@ -726,7 +726,7 @@ void hg_scanner_300::image_process(std::shared_ptr>& buffer) colormode=img_conf_.pixtype; err = hg_imgproc::split(handle,img_conf_.multiOutput,img_conf_.splitImage,img_conf_.multi_output_red,colormode,img_conf_.is_duplex); - HG_VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "img split-> multiOutput is:%d splitImage is:%d multi_output_red is:%d pixtype is:%d is_duplex:%d\r\n" + VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "img split-> multiOutput is:%d splitImage is:%d multi_output_red is:%d pixtype is:%d is_duplex:%d\r\n" ,img_conf_.multiOutput ,img_conf_.splitImage ,img_conf_.multi_output_red @@ -758,7 +758,7 @@ void hg_scanner_300::image_process(std::shared_ptr>& buffer) hg_imgproc::final(handle); while (hg_imgproc::get_final_data(handle, &ih, &buf, index++) == SCANNER_ERR_OK && !user_cancel_) { - HG_VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "Final picture %d (%d * %d * %d) with %u bytes!\n", index + VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "Final picture %d (%d * %d * %d) with %u bytes!\n", index , ih.width, ih.height, ih.bits * ih.channels, ih.total_bytes); if(!img_type_.empty()) @@ -774,7 +774,7 @@ void hg_scanner_300::image_process(std::shared_ptr>& buffer) buf = bmpdata.data(); ih.total_bytes = bmpdata.size(); - HG_VLOG_MINI_6(LOG_LEVEL_DEBUG_INFO, "Set img type is:%s Final picture %d (%d * %d * %d) with %u bytes!\n",img_type_.c_str() ,index + VLOG_MINI_6(LOG_LEVEL_DEBUG_INFO, "Set img type is:%s Final picture %d (%d * %d * %d) with %u bytes!\n",img_type_.c_str() ,index , ih.width, ih.height, ih.bits * ih.channels, ih.total_bytes); } save_final_image(&ih, buf); @@ -798,7 +798,7 @@ int hg_scanner_300::writedown_device_configuration(bool type,HGSCANCONF_G400 *d) len = sizeof(USBCB); ret = io_->write_bulk(&usbcb,&len); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "writedown_device_configuration is .(%s)\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "writedown_device_configuration is .(%s)\n", hg_scanner::strerr((scanner_err)ret).c_str()); return ret; } @@ -998,7 +998,7 @@ else ic.AutoCrop_threshold = threshold_; if (test_1_paper_) { - HG_LOG(LOG_LEVEL_DEBUG_INFO, "scanning mode: testing ONE paper ...\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, "scanning mode: testing ONE paper ...\n"); ic.scannum = 1; } else @@ -1069,56 +1069,56 @@ else return ; } - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.pixtype=%d", ic.pixtype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.papertype=%d", ic.papertype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.AutoCrop_threshold=%d", ic.AutoCrop_threshold); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.autodescrew=%d", ic.autodescrew); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.automaticcolor=%d", ic.automaticcolor); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.brightness=%f", ic.brightness); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.contrast=%f", ic.contrast); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_fold=%d", ic.en_fold); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_sizecheck=%d", ic.en_sizecheck); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.enhance_color=%d", ic.enhance_color); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillbackground=%d", ic.fillbackground); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.filter=%d", ic.filter); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.gamma=%f", ic.gamma); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.capturepixtype=%d", ic.hardwarecaps.capturepixtype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.en_doublefeed=%d", ic.hardwarecaps.en_doublefeed); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hsvcorrect=%d", ic.hsvcorrect); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.imageRotateDegree=%f", ic.imageRotateDegree); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.indent=%d", 5); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocontrast=%d", ic.is_autocontrast); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocrop=%d", ic.is_autocrop); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_normal=%d", ic.is_autodiscradblank_normal); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_vince=%d", ic.is_autodiscradblank_vince); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autotext=%d", ic.is_autotext); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_backrotate180=%d", ic.is_backrotate180); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_convex=%d", ic.is_convex); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_duplex=%d", ic.is_duplex); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_switchfrontback=%d", ic.is_switchfrontback); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_dogeardetection=%d", ic.is_dogeardetection); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.multi_output_red=%d", ic.multi_output_red); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.noise=%d", 8); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_dst=%f", ic.resolution_dst); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_native=%f", ic.resolution_native); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.scannum=%d", ic.scannum); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.sharpen=%d", ic.sharpen); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.discardblank_percent=%d", ic.discardblank_percent); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.is_detachnoise=%d", ic.detachnoise.is_detachnoise); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.detachnoise=%d\r ", ic.detachnoise.detachnoise); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.refuseInflow=%d\r ", ic.refuseInflow); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.refuseInflow=%d\r ", ic.refuseInflow); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.removeMorr=%d\r ", ic.removeMorr); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.errorExtention=%d\r ", ic.errorExtention); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.textureRemove=%d\r\n ", ic.textureRemove); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.is_fillhole=%d\r\n ", ic.fillhole.is_fillhole); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.ic.fillhole.fillholeratio=%f\r\n ", ic.fillhole.fillholeratio); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fadeback=%d\r\n ",ic.fadeback); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.enable=%d\r\n ",ic.cropRect.enable); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.height=%d\r\n ",ic.cropRect.height); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.width=%d\r\n ",ic.cropRect.width); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.x=%d\r\n ",ic.cropRect.x); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.y=%d\r\n ",ic.cropRect.y); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.pixtype=%d", ic.pixtype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.papertype=%d", ic.papertype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.AutoCrop_threshold=%d", ic.AutoCrop_threshold); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.autodescrew=%d", ic.autodescrew); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.automaticcolor=%d", ic.automaticcolor); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.brightness=%f", ic.brightness); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.contrast=%f", ic.contrast); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_fold=%d", ic.en_fold); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_sizecheck=%d", ic.en_sizecheck); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.enhance_color=%d", ic.enhance_color); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillbackground=%d", ic.fillbackground); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.filter=%d", ic.filter); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.gamma=%f", ic.gamma); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.capturepixtype=%d", ic.hardwarecaps.capturepixtype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.en_doublefeed=%d", ic.hardwarecaps.en_doublefeed); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hsvcorrect=%d", ic.hsvcorrect); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.imageRotateDegree=%f", ic.imageRotateDegree); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.indent=%d", 5); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocontrast=%d", ic.is_autocontrast); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocrop=%d", ic.is_autocrop); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_normal=%d", ic.is_autodiscradblank_normal); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_vince=%d", ic.is_autodiscradblank_vince); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autotext=%d", ic.is_autotext); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_backrotate180=%d", ic.is_backrotate180); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_convex=%d", ic.is_convex); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_duplex=%d", ic.is_duplex); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_switchfrontback=%d", ic.is_switchfrontback); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_dogeardetection=%d", ic.is_dogeardetection); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.multi_output_red=%d", ic.multi_output_red); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.noise=%d", 8); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_dst=%f", ic.resolution_dst); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_native=%f", ic.resolution_native); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.scannum=%d", ic.scannum); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.sharpen=%d", ic.sharpen); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.discardblank_percent=%d", ic.discardblank_percent); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.is_detachnoise=%d", ic.detachnoise.is_detachnoise); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.detachnoise=%d\r ", ic.detachnoise.detachnoise); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.refuseInflow=%d\r ", ic.refuseInflow); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.refuseInflow=%d\r ", ic.refuseInflow); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.removeMorr=%d\r ", ic.removeMorr); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.errorExtention=%d\r ", ic.errorExtention); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.textureRemove=%d\r\n ", ic.textureRemove); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.is_fillhole=%d\r\n ", ic.fillhole.is_fillhole); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.ic.fillhole.fillholeratio=%f\r\n ", ic.fillhole.fillholeratio); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fadeback=%d\r\n ",ic.fadeback); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.enable=%d\r\n ",ic.cropRect.enable); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.height=%d\r\n ",ic.cropRect.height); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.width=%d\r\n ",ic.cropRect.width); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.x=%d\r\n ",ic.cropRect.x); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.y=%d\r\n ",ic.cropRect.y); } void hg_scanner_300::printf_devconfig(HGSCANCONF_G400 *d) @@ -1127,18 +1127,18 @@ void hg_scanner_300::printf_devconfig(HGSCANCONF_G400 *d) if (!d) d = &dsp_config; - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\r\ndsp_config.params.doubleFeeded:%d\r\n",d->params.doubleFeeded); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.dpi:%d\r\n",d->params.dpi); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.dstHeight:%d\r\n",d->params.dstHeight); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.enableLed:%d\r\n",d->params.enableLed); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.enableUV:%d\r\n",d->params.enableUV); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.isColor:%d\r\n",d->params.isColor); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.isCorrect:%d\r\n",d->params.isCorrect); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.pageSize:%d\r\n",d->params.pageSize); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.reversed1:%d\r\n",d->params.reversed1); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.reversed2:%d\r\n",d->params.reversed2); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.sizedetece:%d\r\n",d->params.sizedetece); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.value:%d\r\n",d->value); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\r\ndsp_config.params.doubleFeeded:%d\r\n",d->params.doubleFeeded); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.dpi:%d\r\n",d->params.dpi); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.dstHeight:%d\r\n",d->params.dstHeight); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.enableLed:%d\r\n",d->params.enableLed); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.enableUV:%d\r\n",d->params.enableUV); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.isColor:%d\r\n",d->params.isColor); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.isCorrect:%d\r\n",d->params.isCorrect); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.pageSize:%d\r\n",d->params.pageSize); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.reversed1:%d\r\n",d->params.reversed1); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.reversed2:%d\r\n",d->params.reversed2); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.sizedetece:%d\r\n",d->params.sizedetece); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.value:%d\r\n",d->value); } std::string hg_scanner_300::get_firmware_version() diff --git a/hgdriver/hgdev/hg_scanner_300.h b/hgdriver/hgdev/hg_scanner_300.h index 00f454c..5e3abd6 100644 --- a/hgdriver/hgdev/hg_scanner_300.h +++ b/hgdriver/hgdev/hg_scanner_300.h @@ -10,7 +10,7 @@ #include #include "hg_scanner.h" -#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #include "PaperSize.h" #ifdef OEM_HANWANG diff --git a/hgdriver/hgdev/hg_scanner_400.cpp b/hgdriver/hgdev/hg_scanner_400.cpp index 1b03515..a5684b4 100644 --- a/hgdriver/hgdev/hg_scanner_400.cpp +++ b/hgdriver/hgdev/hg_scanner_400.cpp @@ -1,5 +1,5 @@ #include "hg_scanner_400.h" -#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #ifdef WIN32 #include "scanner_manager.h" @@ -106,7 +106,7 @@ namespace settingsdsp_400 *r = true; else *r = false; - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Paper '%s' index = %d, device value = %d\n", paper_string(paper).c_str(), ind, paper_map[ind].dev_value); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Paper '%s' index = %d, device value = %d\n", paper_string(paper).c_str(), ind, paper_map[ind].dev_value); paper = paper_map[ind].paper; if (type) *type = paper_map[ind].type; @@ -377,7 +377,7 @@ int hg_scanner_400::start(void) { status_ = ret; notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING, SANE_EVENT_ERROR, status_); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING); + VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING); return ret; } ret = get_scanner_paperon(); @@ -385,14 +385,14 @@ int hg_scanner_400::start(void) { status_ = ret; notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER, SANE_EVENT_ERROR, status_); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER); + VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER); return ret; } USBCB usb = {START_COMMAND, img_conf_.scannum, 0}; ret = writeusb(usb); io_->set_timeout(1000); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "device start is.(%s)\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "device start is.(%s)\n", hg_scanner::strerr((scanner_err)ret).c_str()); if(ret == SCANNER_ERR_OK) { @@ -414,14 +414,14 @@ int hg_scanner_400::stop(void) if (status_ == SCANNER_ERR_DEVICE_BUSY) { - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "stop !but device is busy ,so sleep 2s(%s)\n", hg_scanner::strerr((scanner_err)status_).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "stop !but device is busy ,so sleep 2s(%s)\n", hg_scanner::strerr((scanner_err)status_).c_str()); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); } user_cancel_ = true; if (ret == SCANNER_ERR_OK) { status_ = SCANNER_ERR_DEVICE_STOPPED; - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "stop device:(%s)\n", hg_scanner::strerr((scanner_err)status_).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "stop device:(%s)\n", hg_scanner::strerr((scanner_err)status_).c_str()); } notify_ui_working_status("取消扫描", SANE_EVENT_STATUS, status_); final_imgs_.Clear(); @@ -550,11 +550,11 @@ void hg_scanner_400::image_process(std::shared_ptr>& buffer) param.double_side = img_conf_.is_duplex; param.dpi = img_conf_.resolution_dst; - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.black_white :%d\r\n",param.black_white); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.channels :%d\r\n",param.channels); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.color_mode :%d\r\n",param.color_mode); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.double_side :%d\r\n",param.double_side); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.dpi :%d\r\n",param.dpi); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.black_white :%d\r\n",param.black_white); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.channels :%d\r\n",param.channels); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.color_mode :%d\r\n",param.color_mode); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.double_side :%d\r\n",param.double_side); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.dpi :%d\r\n",param.dpi); handle = hg_imgproc::init(&img_conf_,¶m,pid_); @@ -565,7 +565,7 @@ void hg_scanner_400::image_process(std::shared_ptr>& buffer) { ret = hg_imgproc::fillhole(handle); //printf("填穿孔开启\r\n"); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "填穿孔开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "填穿孔开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } /////////////////////////////////////111111111111111111111111111////////////////////////////////// @@ -575,32 +575,32 @@ void hg_scanner_400::image_process(std::shared_ptr>& buffer) { ret = hg_imgproc::discardBlank(handle); printf("丢弃空白页开启\r\n"); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "丢弃空白页开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "丢弃空白页开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } if(img_conf_.fadeback) { hg_imgproc::fadeback(handle,img_conf_.fadebackrange,param.double_side); //printf("背景除色开启\r\n"); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "背景除色开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "背景除色开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } if (img_conf_.resolution_dst != img_conf_.resolution_native) { hg_imgproc::resolution_change(handle); //printf("dpi改变开启\r\n"); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "dpi改变开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "dpi改变开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } if (img_conf_.cropRect.enable && !img_conf_.is_autocrop) { hg_imgproc::croprect(handle); //printf("手动裁图开启\r\n"); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "手动裁图开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "手动裁图开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } if (img_conf_.filter != ColorFilter::FILTER_NONE && (img_conf_.pixtype == COLOR_MODE_BLACK_WHITE || img_conf_.pixtype == COLOR_MODE_256_GRAY)) { printf("除色开启\r\n"); hg_imgproc::channel(handle); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "除色开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "除色开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } /////////////////////////////////////2222222222222222222222222222222222222////////////////////////////////// int tableLength ;//= sizeof(custom_gamma_val_->table)/sizeof(custom_gamma_val_->table[0]); @@ -644,7 +644,7 @@ void hg_scanner_400::image_process(std::shared_ptr>& buffer) { hg_imgproc::answerSheetFilterRed(handle); //printf("答题卡出红开启\r\n"); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "答题卡出红开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "答题卡出红开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } if (img_conf_.refuseInflow) { @@ -667,7 +667,7 @@ void hg_scanner_400::image_process(std::shared_ptr>& buffer) { hg_imgproc::colorCorrection(handle); //printf("颜色校正开启\r\n"); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "颜色校正开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "颜色校正开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } if ((img_conf_.imageRotateDegree != TEXT_DIRECTION_0 || img_conf_.is_backrotate180) && (!img_conf_.is_autotext)) { @@ -678,25 +678,25 @@ void hg_scanner_400::image_process(std::shared_ptr>& buffer) { hg_imgproc::textureRemove(handle); //printf("除摩尔纹开启\r\n"); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "除摩尔纹开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "除摩尔纹开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } if (img_conf_.detachnoise.is_detachnoise) { hg_imgproc::nosieDetach(handle); //printf("噪点优化开启\r\n"); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "噪点优化开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "噪点优化开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } if (img_conf_.pixtype == COLOR_MODE_BLACK_WHITE) { hg_imgproc::errorextention(handle); //printf("黑白图处理开启\r\n"); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "黑白图处理开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "黑白图处理开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } if (img_conf_.en_fold) { hg_imgproc::fold(handle); //printf("对折开启\r\n"); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "对折开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "对折开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } /////////////////////////////////// @@ -705,7 +705,7 @@ void hg_scanner_400::image_process(std::shared_ptr>& buffer) { err = hg_imgproc::multi_out_red(handle); //printf("多流出红开启\r\n"); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "多流出红开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "多流出红开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } if (img_conf_.sharpen) @@ -720,7 +720,7 @@ void hg_scanner_400::image_process(std::shared_ptr>& buffer) colormode=img_conf_.pixtype; err = hg_imgproc::split(handle,img_conf_.multiOutput,img_conf_.splitImage,img_conf_.multi_output_red,colormode,img_conf_.is_duplex); - HG_VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "img split-> multiOutput is:%d splitImage is:%d multi_output_red is:%d pixtype is:%d is_duplex:%d\r\n" + VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "img split-> multiOutput is:%d splitImage is:%d multi_output_red is:%d pixtype is:%d is_duplex:%d\r\n" ,img_conf_.multiOutput ,img_conf_.splitImage ,img_conf_.multi_output_red @@ -728,7 +728,7 @@ void hg_scanner_400::image_process(std::shared_ptr>& buffer) ,img_conf_.is_duplex); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "图像拆分开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "图像拆分开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } if (!image_prc_param_.bits.split || !image_prc_param_.bits.rid_red || !image_prc_param_.bits.multi_out) @@ -736,7 +736,7 @@ void hg_scanner_400::image_process(std::shared_ptr>& buffer) if(img_conf_.automaticcolor) { ret = hg_imgproc::auto_matic_color(handle,img_conf_.automaticcolortype); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "颜色自动识别模式开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "颜色自动识别模式开启:%s\n",hg_scanner::strerr((scanner_err)ret).c_str()); } } if (img_conf_.is_autotext) @@ -754,7 +754,7 @@ void hg_scanner_400::image_process(std::shared_ptr>& buffer) hg_imgproc::final(handle); while (hg_imgproc::get_final_data(handle, &ih, &buf, index++) == SCANNER_ERR_OK) { - HG_VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "Final picture %d (%d * %d * %d) with %u bytes!\n", index + VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "Final picture %d (%d * %d * %d) with %u bytes!\n", index , ih.width, ih.height, ih.bits * ih.channels, ih.total_bytes); if(!img_type_.empty()) @@ -771,7 +771,7 @@ void hg_scanner_400::image_process(std::shared_ptr>& buffer) buf = bmpdata.data(); ih.total_bytes = bmpdata.size(); - HG_VLOG_MINI_6(LOG_LEVEL_DEBUG_INFO, "Set img type is:%s Final picture %d (%d * %d * %d) with %u bytes!\n",img_type_.c_str() ,index + VLOG_MINI_6(LOG_LEVEL_DEBUG_INFO, "Set img type is:%s Final picture %d (%d * %d * %d) with %u bytes!\n",img_type_.c_str() ,index , ih.width, ih.height, ih.bits * ih.channels, ih.total_bytes); } @@ -796,7 +796,7 @@ int hg_scanner_400::writedown_device_configuration(bool type,HGSCANCONF_G400 *d) len = sizeof(USBCB); ret = io_->write_bulk(&usbcb,&len); - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "writedown_device_configuration is .(%s)\n", hg_scanner::strerr((scanner_err)ret).c_str()); + VLOG_MINI_1(LOG_LEVEL_WARNING, "writedown_device_configuration is .(%s)\n", hg_scanner::strerr((scanner_err)ret).c_str()); return ret; } @@ -1005,7 +1005,7 @@ void hg_scanner_400::writedown_image_configuration(void) ic.AutoCrop_threshold = threshold_; if (test_1_paper_) { - HG_LOG(LOG_LEVEL_DEBUG_INFO, "scanning mode: testing ONE paper ...\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, "scanning mode: testing ONE paper ...\n"); ic.scannum = 1; } else @@ -1083,59 +1083,59 @@ void hg_scanner_400::writedown_image_configuration(void) } - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.pixtype=%d", ic.pixtype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.papertype=%d", ic.papertype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.AutoCrop_threshold=%d", ic.AutoCrop_threshold); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.autodescrew=%d", ic.autodescrew); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.automaticcolor=%d", ic.automaticcolor); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.brightness=%f", ic.brightness); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.contrast=%f", ic.contrast); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_fold=%d", ic.en_fold); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_sizecheck=%d", ic.en_sizecheck); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.enhance_color=%d", ic.enhance_color); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillbackground=%d", ic.fillbackground); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.filter=%d", ic.filter); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.gamma=%f", ic.gamma); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.capturepixtype=%d", ic.hardwarecaps.capturepixtype); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.en_doublefeed=%d", ic.hardwarecaps.en_doublefeed); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hsvcorrect=%d", ic.hsvcorrect); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.imageRotateDegree=%f", ic.imageRotateDegree); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.indent=%d", 5); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocontrast=%d", ic.is_autocontrast); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocrop=%d", ic.is_autocrop); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_normal=%d", ic.is_autodiscradblank_normal); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_vince=%d", ic.is_autodiscradblank_vince); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.isfillcolor=%d", ic.isfillcolor); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.pixtype=%d", ic.pixtype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.papertype=%d", ic.papertype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.AutoCrop_threshold=%d", ic.AutoCrop_threshold); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.autodescrew=%d", ic.autodescrew); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.automaticcolor=%d", ic.automaticcolor); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.brightness=%f", ic.brightness); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.contrast=%f", ic.contrast); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_fold=%d", ic.en_fold); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_sizecheck=%d", ic.en_sizecheck); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.enhance_color=%d", ic.enhance_color); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillbackground=%d", ic.fillbackground); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.filter=%d", ic.filter); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.gamma=%f", ic.gamma); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.capturepixtype=%d", ic.hardwarecaps.capturepixtype); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.en_doublefeed=%d", ic.hardwarecaps.en_doublefeed); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hsvcorrect=%d", ic.hsvcorrect); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.imageRotateDegree=%f", ic.imageRotateDegree); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.indent=%d", 5); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocontrast=%d", ic.is_autocontrast); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocrop=%d", ic.is_autocrop); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_normal=%d", ic.is_autodiscradblank_normal); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_vince=%d", ic.is_autodiscradblank_vince); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.isfillcolor=%d", ic.isfillcolor); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autotext=%d", ic.is_autotext); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_backrotate180=%d", ic.is_backrotate180); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_convex=%d", ic.is_convex); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_duplex=%d", ic.is_duplex); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_switchfrontback=%d", ic.is_switchfrontback); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_dogeardetection=%d", ic.is_dogeardetection); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.multi_output_red=%d", ic.multi_output_red); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.noise=%d", 8); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_dst=%f", ic.resolution_dst); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_native=%f", ic.resolution_native); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.scannum=%d", ic.scannum); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.sharpen=%d", ic.sharpen); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.discardblank_percent=%d", ic.discardblank_percent); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.is_detachnoise=%d", ic.detachnoise.is_detachnoise); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.detachnoise=%d\r ", ic.detachnoise.detachnoise); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.refuseInflow=%d\r ", ic.refuseInflow); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.refuseInflow=%d\r ", ic.refuseInflow); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.removeMorr=%d\r ", ic.removeMorr); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.errorExtention=%d\r ", ic.errorExtention); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.textureRemove=%d\r\n ", ic.textureRemove); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.is_fillhole=%d\r\n ", ic.fillhole.is_fillhole); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.ic.fillhole.fillholeratio=%f\r\n ", ic.fillhole.fillholeratio); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fadeback=%d\r\n ",ic.fadeback); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autotext=%d", ic.is_autotext); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_backrotate180=%d", ic.is_backrotate180); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_convex=%d", ic.is_convex); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_duplex=%d", ic.is_duplex); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_switchfrontback=%d", ic.is_switchfrontback); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_dogeardetection=%d", ic.is_dogeardetection); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.multi_output_red=%d", ic.multi_output_red); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.noise=%d", 8); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_dst=%f", ic.resolution_dst); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_native=%f", ic.resolution_native); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.scannum=%d", ic.scannum); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.sharpen=%d", ic.sharpen); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.discardblank_percent=%d", ic.discardblank_percent); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.is_detachnoise=%d", ic.detachnoise.is_detachnoise); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.detachnoise=%d\r ", ic.detachnoise.detachnoise); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.refuseInflow=%d\r ", ic.refuseInflow); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.refuseInflow=%d\r ", ic.refuseInflow); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.removeMorr=%d\r ", ic.removeMorr); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.errorExtention=%d\r ", ic.errorExtention); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.textureRemove=%d\r\n ", ic.textureRemove); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.is_fillhole=%d\r\n ", ic.fillhole.is_fillhole); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.ic.fillhole.fillholeratio=%f\r\n ", ic.fillhole.fillholeratio); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fadeback=%d\r\n ",ic.fadeback); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.enable=%d\r ", ic.cropRect.enable); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.width=%d\r\n ", ic.cropRect.width); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.height=%d\r\n ", ic.cropRect.height); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.x=%f\r\n ", ic.cropRect.x); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.y=%d\r\n ",ic.cropRect.y); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.enable=%d\r ", ic.cropRect.enable); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.width=%d\r\n ", ic.cropRect.width); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.height=%d\r\n ", ic.cropRect.height); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.x=%f\r\n ", ic.cropRect.x); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.y=%d\r\n ",ic.cropRect.y); } @@ -1144,18 +1144,18 @@ void hg_scanner_400::printf_devconfig(HGSCANCONF_G400 *d) if (!d) d = &dsp_config; - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\r\ndsp_config.params.doubleFeeded:%d\r\n",d->params.doubleFeeded); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.dpi:%d\r\n",d->params.dpi); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.dstHeight:%d\r\n",d->params.dstHeight); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.enableLed:%d\r\n",d->params.enableLed); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.enableUV:%d\r\n",d->params.enableUV); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.isColor:%d\r\n",d->params.isColor); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.isCorrect:%d\r\n",d->params.isCorrect); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.pageSize:%d\r\n",d->params.pageSize); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.reversed1:%d\r\n",d->params.reversed1); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.reversed2:%d\r\n",d->params.reversed2); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.sizedetece:%d\r\n",d->params.sizedetece); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.value:%d\r\n",d->value); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\r\ndsp_config.params.doubleFeeded:%d\r\n",d->params.doubleFeeded); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.dpi:%d\r\n",d->params.dpi); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.dstHeight:%d\r\n",d->params.dstHeight); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.enableLed:%d\r\n",d->params.enableLed); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.enableUV:%d\r\n",d->params.enableUV); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.isColor:%d\r\n",d->params.isColor); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.isCorrect:%d\r\n",d->params.isCorrect); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.pageSize:%d\r\n",d->params.pageSize); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.reversed1:%d\r\n",d->params.reversed1); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.reversed2:%d\r\n",d->params.reversed2); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.sizedetece:%d\r\n",d->params.sizedetece); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.value:%d\r\n",d->value); } std::string hg_scanner_400::get_firmware_version() @@ -1185,7 +1185,7 @@ std::string hg_scanner_400::get_firmware_version() std::lock_guard lock(io_lock_); ret = io_->read_bulk(buf, &len); } - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "get serial num = %s, serial num = %s\n", hg_scanner::strerr((scanner_err)ret).c_str(), buf); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "get serial num = %s, serial num = %s\n", hg_scanner::strerr((scanner_err)ret).c_str(), buf); return buf; } diff --git a/hgdriver/hgdev/hg_scanner_400.h b/hgdriver/hgdev/hg_scanner_400.h index a24b53c..92089c0 100644 --- a/hgdriver/hgdev/hg_scanner_400.h +++ b/hgdriver/hgdev/hg_scanner_400.h @@ -10,7 +10,7 @@ #include #include "hg_scanner.h" -#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #include "PaperSize.h" diff --git a/hgdriver/hgdev/image_process.cpp b/hgdriver/hgdev/image_process.cpp index f0be08c..84d9aca 100644 --- a/hgdriver/hgdev/image_process.cpp +++ b/hgdriver/hgdev/image_process.cpp @@ -1,5 +1,5 @@ #include "image_process.h" -#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #include #include @@ -164,7 +164,7 @@ namespace hg_imgproc //("/home/huagao/Desktop/1.jpg",mat); if (mat.empty()) { - HG_LOG(LOG_LEVEL_FATAL, "decode image data error\n"); + LOG_INFO(LOG_LEVEL_FATAL, "decode image data error\n"); continue; } if(pid == 0x100 || pid == 0x200 || pid == 0x139 || pid == 0x239) @@ -195,11 +195,11 @@ namespace hg_imgproc } catch (const std::exception& e) { - HG_LOG(LOG_LEVEL_FATAL, e.what()); + LOG_INFO(LOG_LEVEL_FATAL, e.what()); } } buffs.clear(); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Decode %u bytes to %u picture(s)\n", origin, mats_.size()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Decode %u bytes to %u picture(s)\n", origin, mats_.size()); if(mats_.size() == 0) { return SCANNER_ERR_NO_DATA; diff --git a/hgdriver/hgdev/scanner_manager.cpp b/hgdriver/hgdev/scanner_manager.cpp index c8c8130..1ca729f 100644 --- a/hgdriver/hgdev/scanner_manager.cpp +++ b/hgdriver/hgdev/scanner_manager.cpp @@ -1,5 +1,5 @@ #include "scanner_manager.h" -#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #include #include #include "raw_src.h" @@ -98,7 +98,7 @@ hg_scanner_mgr* hg_scanner_mgr::instance(sane_callback cb) if (cb) hg_scanner_mgr::async_io_enabled_ = cb(NULL, SANE_EVENT_SUPPORT_ASYNC_IO, NULL, NULL, NULL) == 0; hg_scanner_mgr::inst_ = new hg_scanner_mgr(); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "async image transferring is %s\n", hg_scanner_mgr::async_io_enabled_ ? "enabled" : "disabled"); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "async image transferring is %s\n", hg_scanner_mgr::async_io_enabled_ ? "enabled" : "disabled"); } return hg_scanner_mgr::inst_; @@ -156,7 +156,7 @@ void hg_scanner_mgr::on_hgscanner_pnp(usb_event ev, libusb_device* device, int v { if (g_supporting_devices[i].vid == vid && g_supporting_devices[i].pid == pid) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s connected.\n", g_supporting_devices[i].name.c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s connected.\n", g_supporting_devices[i].name.c_str()); index = i; ev_ui = SANE_EVENT_DEVICE_ARRIVED; de.name = g_supporting_devices[i].name.c_str(); @@ -190,7 +190,7 @@ void hg_scanner_mgr::on_hgscanner_pnp(usb_event ev, libusb_device* device, int v len = usb_manager::instance()->open(device, &io); if (len == SCANNER_ERR_OK) { - HG_VLOG_MINI_3(LOG_LEVEL_WARNING, "[%04x:%04x]%s re-connected.\n", pid, vid, online_devices_[i].display_name.c_str()); + VLOG_MINI_3(LOG_LEVEL_WARNING, "[%04x:%04x]%s re-connected.\n", pid, vid, online_devices_[i].display_name.c_str()); online_devices_[i].scanner->reset_io(io); de.openned = SANE_TRUE; } @@ -231,7 +231,7 @@ void hg_scanner_mgr::on_hgscanner_pnp(usb_event ev, libusb_device* device, int v name = it->display_name; type = g_supporting_devices[it->ind].type; h = it->scanner; - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s Dis-connected.\n", name.c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s Dis-connected.\n", name.c_str()); if (it->scanner) it->scanner->io_disconnected(); else diff --git a/hgdriver/hgdev/usb_manager.cpp b/hgdriver/hgdev/usb_manager.cpp index 28de5a7..55b8275 100644 --- a/hgdriver/hgdev/usb_manager.cpp +++ b/hgdriver/hgdev/usb_manager.cpp @@ -1,5 +1,5 @@ #include "usb_manager.h" -#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #include #include "hg_scanner.h" // for hg_scanner::strerr @@ -33,7 +33,7 @@ usb_manager::usb_manager() : run_(true) int ret = libusb_init(&context_); // libusb_set_log_cb(context_, &usb_manager::usb_log_callback, LIBUSB_LOG_CB_CONTEXT); // LIBUSB_API_VERSION >= 0x01000107 - HG_VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "usb_manager(%s) libusb_init(%s) = %s, context = %s\n", hg_log::format_ptr(this).c_str(), hg_log::format_ptr(&context_).c_str(), libusb_error_name(ret), hg_log::format_ptr(context_).c_str()); + VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "usb_manager(%s) libusb_init(%s) = %s, context = %s\n", hg_log::format_ptr(this).c_str(), hg_log::format_ptr(&context_).c_str(), libusb_error_name(ret), hg_log::format_ptr(context_).c_str()); if (ret) status_ = SCANNER_ERR_USB_INIT_FAILED; @@ -66,7 +66,7 @@ usb_manager::~usb_manager() usb_notify_thread_.reset(); } libusb_exit(context_); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "usb_manager(%s) destroying and free context(%s)\n", hg_log::format_ptr(this).c_str(), hg_log::format_ptr(context_).c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "usb_manager(%s) destroying and free context(%s)\n", hg_log::format_ptr(this).c_str(), hg_log::format_ptr(context_).c_str()); } int LIBUSB_CALL usb_manager::usb_pnp_callback(libusb_context* ctx, libusb_device* device, libusb_hotplug_event event, void* monitor) @@ -89,11 +89,11 @@ void usb_manager::usb_log_callback(libusb_context* ctx, libusb_log_level level, // used when LIBUSB_API_VERSION >= 0x01000107 if (level == LIBUSB_LOG_LEVEL_NONE || LIBUSB_LOG_LEVEL_INFO || LIBUSB_LOG_LEVEL_DEBUG) { - HG_LOG(LOG_LEVEL_DEBUG_INFO, str); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, str); } else { - HG_LOG(LOG_LEVEL_FATAL, str); + LOG_INFO(LOG_LEVEL_FATAL, str); } } @@ -114,7 +114,7 @@ int usb_manager::register_usb_pnp(void) if (ret != LIBUSB_SUCCESS) { - HG_LOG(LOG_LEVEL_FATAL, (std::string("regist usbhotplug callback error msg: ") + libusb_error_name(ret) + "\n").c_str()); + LOG_INFO(LOG_LEVEL_FATAL, (std::string("regist usbhotplug callback error msg: ") + libusb_error_name(ret) + "\n").c_str()); usb_cb_handle_ = NULL; status_ = SCANNER_ERR_USB_REGISTER_PNP_FAILED; } @@ -230,7 +230,7 @@ void usb_manager::notify_usb_event(PNPDEV& pd, bool* retry) sprintf(buf, "0x%x", pd.event); evstr = buf; } - HG_VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "USB%u.%x of pid:vid(%x:%x) event(%s) received.\n" + VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "USB%u.%x of pid:vid(%x:%x) event(%s) received.\n" , HIBYTE(ud.ver), LOBYTE(ud.ver) / 0x10, ud.pid, ud.vid, evstr.c_str()); if (ev != USB_EVENT_NULL) { @@ -265,7 +265,7 @@ void usb_manager::thread_trigger_usb_event() { // ^_^ devices.clear(); - HG_LOG(LOG_LEVEL_DEBUG_INFO, "register_usb_pnp success ^_^\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, "register_usb_pnp success ^_^\n"); break; } } @@ -277,7 +277,7 @@ void usb_manager::thread_trigger_usb_event() timeval tm={1,0}; int ret=libusb_handle_events_timeout(context_, &tm); if(ret < 0) - HG_LOG(LOG_LEVEL_FATAL, (std::string("libusb_handle_events_timeout error ") + libusb_error_name(ret) + "\n").c_str()); + LOG_INFO(LOG_LEVEL_FATAL, (std::string("libusb_handle_events_timeout error ") + libusb_error_name(ret) + "\n").c_str()); std::this_thread::sleep_for(std::chrono::milliseconds(10)); } @@ -422,7 +422,7 @@ void usb_manager::enum_endpoints(libusb_device* device, USBTRANSENDP* endp) if (ret != 0) { - HG_LOG(LOG_LEVEL_WARNING, (std::string("Get device descriptor of device(") + dev + ") failed.\n").c_str()); + LOG_INFO(LOG_LEVEL_WARNING, (std::string("Get device descriptor of device(") + dev + ") failed.\n").c_str()); return; } @@ -436,26 +436,26 @@ void usb_manager::enum_endpoints(libusb_device* device, USBTRANSENDP* endp) usb_manager::init_endpoint(&endp->isochronous); } else - hg_log::vlog(LOG_LEVEL_DEBUG_INFO, " +Device(%s) has %u configurations ...\n", dev.c_str(), desc.bNumConfigurations); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, " +Device(%s) has %u configurations ...\n", dev.c_str(), desc.bNumConfigurations); for (int i = 0; i < (int)desc.bNumConfigurations; ++i) { ret = libusb_get_config_descriptor(device, i, &conf); if (ret != 0) { if (!endp) - hg_log::vlog(LOG_LEVEL_DEBUG_INFO, " Get %d configuration failed.\n", i + 1); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " Get %d configuration failed.\n", i + 1); continue; } if (!endp) - hg_log::vlog(LOG_LEVEL_DEBUG_INFO, " Configuration %d has %d interfaces\n", i + 1, conf->bNumInterfaces); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, " Configuration %d has %d interfaces\n", i + 1, conf->bNumInterfaces); for (int j = 0; j < conf->bNumInterfaces; ++j) { if (!endp) - hg_log::vlog(LOG_LEVEL_DEBUG_INFO, " Interface %d has %d alt-settings\n", j + 1, conf->interface[j].num_altsetting); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, " Interface %d has %d alt-settings\n", j + 1, conf->interface[j].num_altsetting); for (int k = 0; k < conf->interface[j].num_altsetting; ++k) { if (!endp) - hg_log::vlog(LOG_LEVEL_DEBUG_INFO, " Setting %d: %d - %s has %d endpoints\n", k + 1, conf->interface[j].altsetting[k].bInterfaceNumber + VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, " Setting %d: %d - %s has %d endpoints\n", k + 1, conf->interface[j].altsetting[k].bInterfaceNumber , usb_manager::device_class((libusb_class_code)conf->interface[j].altsetting[k].bInterfaceClass).c_str() , conf->interface[j].altsetting[k].bNumEndpoints); for (int l = 0; l < conf->interface[j].altsetting[k].bNumEndpoints; ++l) @@ -466,27 +466,27 @@ void usb_manager::enum_endpoints(libusb_device* device, USBTRANSENDP* endp) if (conf->interface[j].altsetting[k].endpoint[l].bmAttributes == LIBUSB_TRANSFER_TYPE_CONTROL) { - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Found endpoint(%x) for device(VID: %x, PID: %x) of control\n", conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress, desc.idVendor, desc.idProduct); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Found endpoint(%x) for device(VID: %x, PID: %x) of control\n", conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress, desc.idVendor, desc.idProduct); ep = &endp->control; } else if (conf->interface[j].altsetting[k].endpoint[l].bmAttributes == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) { - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Found endpoint(%x) for device(VID: %x, PID: %x) of isochronous\n", conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress, desc.idVendor, desc.idProduct); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Found endpoint(%x) for device(VID: %x, PID: %x) of isochronous\n", conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress, desc.idVendor, desc.idProduct); ep = &endp->isochronous; } if (conf->interface[j].altsetting[k].endpoint[l].bmAttributes == LIBUSB_TRANSFER_TYPE_BULK) { - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Found endpoint(%x) for device(VID: %x, PID: %x) of bulk\n", conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress, desc.idVendor, desc.idProduct); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Found endpoint(%x) for device(VID: %x, PID: %x) of bulk\n", conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress, desc.idVendor, desc.idProduct); ep = &endp->bulk; } if (conf->interface[j].altsetting[k].endpoint[l].bmAttributes == LIBUSB_TRANSFER_TYPE_INTERRUPT) { - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Found endpoint(%x) for device(VID: %x, PID: %x) of interrupt\n", conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress, desc.idVendor, desc.idProduct); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Found endpoint(%x) for device(VID: %x, PID: %x) of interrupt\n", conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress, desc.idVendor, desc.idProduct); ep = &endp->interrupt; } if (conf->interface[j].altsetting[k].endpoint[l].bmAttributes == LIBUSB_TRANSFER_TYPE_BULK_STREAM) { - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Found endpoint(%x) for device(VID: %x, PID: %x) of bulk-stream\n", conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress, desc.idVendor, desc.idProduct); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Found endpoint(%x) for device(VID: %x, PID: %x) of bulk-stream\n", conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress, desc.idVendor, desc.idProduct); ep = &endp->bulk_stream; } if (ep) @@ -505,14 +505,14 @@ void usb_manager::enum_endpoints(libusb_device* device, USBTRANSENDP* endp) s->iface = j; s->claimed = 0; s->max_packet = conf->interface[j].altsetting[k].endpoint[l].wMaxPacketSize; - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, " Endpoint address = 0x%02x, origin = 0x%02x, max packet: 0x%x\n", s->port, conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, " Endpoint address = 0x%02x, origin = 0x%02x, max packet: 0x%x\n", s->port, conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress , s->max_packet); } found_ep = true; } } else - HG_VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, " Endpoint %d(%s) address: %x, Max packet: 0x%x bytes\n", l + 1 + VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, " Endpoint %d(%s) address: %x, Max packet: 0x%x bytes\n", l + 1 , usb_manager::endpoint_type((libusb_transfer_type)conf->interface[j].altsetting[k].endpoint[l].bmAttributes).c_str() , conf->interface[j].altsetting[k].endpoint[l].bEndpointAddress , conf->interface[j].altsetting[k].endpoint[l].wMaxPacketSize); @@ -523,7 +523,7 @@ void usb_manager::enum_endpoints(libusb_device* device, USBTRANSENDP* endp) } if (endp && !found_ep) - HG_VLOG_MINI_2(LOG_LEVEL_FATAL, "No endpoint has been found on device (VID: %x, PID: %x)\n", desc.idVendor, desc.idProduct); + VLOG_MINI_2(LOG_LEVEL_FATAL, "No endpoint has been found on device (VID: %x, PID: %x)\n", desc.idVendor, desc.idProduct); } int usb_manager::register_hotplug(usb_event_handler cb, void* user) @@ -562,7 +562,7 @@ int usb_manager::open(libusb_device* device, usb_io** usbio, std::string* msg) if (msg) *msg = usb->init_error_msg(); usb->release(); - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Open %04x:%04x failed: %s\n", dev.vid, dev.pid, hg_scanner::strerr((scanner_err)err).c_str()); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Open %04x:%04x failed: %s\n", dev.vid, dev.pid, hg_scanner::strerr((scanner_err)err).c_str()); return err; } @@ -654,34 +654,34 @@ bool usb_io::claim_interterface(usb_manager::USBSIMPLEX* spl) return true; } - HG_VLOG_MINI_2(LOG_LEVEL_FATAL, " first libusb_claim_interface(%d) = %s\n", spl->iface, libusb_error_name(ret)); + VLOG_MINI_2(LOG_LEVEL_FATAL, " first libusb_claim_interface(%d) = %s\n", spl->iface, libusb_error_name(ret)); ret = libusb_kernel_driver_active(handle_, spl->iface); if (ret == 1) { ret = libusb_detach_kernel_driver(handle_, spl->iface); - HG_VLOG_MINI_2(LOG_LEVEL_FATAL, " libusb_detach_kernel_driver(%d) = %s\n", spl->iface, libusb_error_name(ret)); + VLOG_MINI_2(LOG_LEVEL_FATAL, " libusb_detach_kernel_driver(%d) = %s\n", spl->iface, libusb_error_name(ret)); } else if (ret == LIBUSB_ERROR_NO_DEVICE) { last_err_ = SCANNER_ERR_DEVICE_NOT_FOUND; - HG_VLOG_MINI_1(LOG_LEVEL_FATAL, "device(%s) maybe left when libusb_kernel_driver_active.\n", hg_log::format_ptr(dev_info_.device).c_str()); + VLOG_MINI_1(LOG_LEVEL_FATAL, "device(%s) maybe left when libusb_kernel_driver_active.\n", hg_log::format_ptr(dev_info_.device).c_str()); return false; } - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " libusb_clear_halt(%x) ...\n", spl->port); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " libusb_clear_halt(%x) ...\n", spl->port); libusb_clear_halt(handle_, spl->port); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " libusb_release_interface(%u) ...\n", spl->iface); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " libusb_release_interface(%u) ...\n", spl->iface); libusb_release_interface(handle_, spl->iface); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " libusb_set_configuration(%u) ...\n", spl->iconf); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " libusb_set_configuration(%u) ...\n", spl->iconf); libusb_set_configuration(handle_, spl->iconf); //ret = libusb_reset_device(handle_); - //HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " libusb_reset_device = %s\n", libusb_error_name(ret)); + //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " libusb_reset_device = %s\n", libusb_error_name(ret)); //if (ret == LIBUSB_ERROR_NOT_FOUND) //{ // last_err_ = usb_manager::usb_error_2_hg_err(ret); - // HG_VLOG_MINI_1(LOG_LEVEL_FATAL, "device(%s) maybe left when libusb_reset_device.\n", hg_log::format_ptr(dev_info_.device).c_str()); + // VLOG_MINI_1(LOG_LEVEL_FATAL, "device(%s) maybe left when libusb_reset_device.\n", hg_log::format_ptr(dev_info_.device).c_str()); // // return false; //} @@ -694,7 +694,7 @@ bool usb_io::claim_interterface(usb_manager::USBSIMPLEX* spl) return true; } - HG_VLOG_MINI_2(LOG_LEVEL_FATAL, "second try libusb_claim_interface(%d) = %s\n", spl->iface, libusb_error_name(ret)); + VLOG_MINI_2(LOG_LEVEL_FATAL, "second try libusb_claim_interface(%d) = %s\n", spl->iface, libusb_error_name(ret)); last_err_ = SCANNER_ERR_USB_CLAIM_INTERFACE_FAILED; return false; @@ -715,7 +715,7 @@ int usb_io::claim_interfaces(bool claim) break; claimed.push_back(eps[i]->in.iface); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "claimed %s interface %d\n", usb_manager::endpoint_type((libusb_transfer_type)i).c_str(), eps[i]->in.iface); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "claimed %s interface %d\n", usb_manager::endpoint_type((libusb_transfer_type)i).c_str(), eps[i]->in.iface); } if (eps[i]->out.port != usb_manager::uninit_uint8 && eps[i]->out.iface != eps[i]->in.iface && std::find(claimed.begin(), claimed.end(), eps[i]->out.iface) == claimed.end()) @@ -723,7 +723,7 @@ int usb_io::claim_interfaces(bool claim) if (!claim_interterface(&eps[i]->out)) break; claimed.push_back(eps[i]->out.iface); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "claimed %s interface %d\n", usb_manager::endpoint_type((libusb_transfer_type)i).c_str(), eps[i]->out.iface); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "claimed %s interface %d\n", usb_manager::endpoint_type((libusb_transfer_type)i).c_str(), eps[i]->out.iface); } } } @@ -764,7 +764,7 @@ void usb_io::open(void) ref_device_ = libusb_ref_device(dev_info_.device); int ret = libusb_open(dev_info_.device, &handle_); - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "call libusb_open(%s, %s) = %s\n", hg_log::format_ptr(dev_info_.device).c_str() + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "call libusb_open(%s, %s) = %s\n", hg_log::format_ptr(dev_info_.device).c_str() , hg_log::format_ptr(handle_).c_str(), libusb_error_name(ret)); if (ret == LIBUSB_SUCCESS) { @@ -780,7 +780,7 @@ void usb_io::open(void) return; } last_err_ = usb_manager::usb_error_2_hg_err(ret); - HG_VLOG_MINI_4(LOG_LEVEL_FATAL, "Open USB%u.%u-%s failed: %s\n", HIBYTE(dev_info_.ver), LOBYTE(dev_info_.ver) / 0x10, hg_log::format_ptr(dev_info_.device).c_str(), libusb_error_name(ret)); + VLOG_MINI_4(LOG_LEVEL_FATAL, "Open USB%u.%u-%s failed: %s\n", HIBYTE(dev_info_.ver), LOBYTE(dev_info_.ver) / 0x10, hg_log::format_ptr(dev_info_.device).c_str(), libusb_error_name(ret)); init_err_msg_ = hg_scanner::error_description((scanner_err)last_err_); handle_ = NULL; } @@ -793,7 +793,7 @@ bool usb_io::on_io_error(scanner_err err, usb_manager::USBSIMPLEX* endp) if (err == SCANNER_ERR_TIMEOUT) { //因为在发送img参数出现timeout,暂时禁用 - // //HG_LOG(LOG_LEVEL_DEBUG_INFO, "Operation timeout\n"); + // //LOG_INFO(LOG_LEVEL_DEBUG_INFO, "Operation timeout\n"); // libusb_clear_halt(handle_, endp->port); // return libusb_reset_device(handle_) == LIBUSB_SUCCESS; @@ -856,7 +856,7 @@ int usb_io::control_io(uint8_t type, uint8_t req, uint16_t val, uint16_t ind, vo return last_err_; } } - HG_VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "libusb_control_transfer(%x, %x, %d, %d) = %s\n", type, req, val, ind, libusb_error_name(ret)); + VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "libusb_control_transfer(%x, %x, %d, %d) = %s\n", type, req, val, ind, libusb_error_name(ret)); last_err_ = usb_manager::usb_error_2_hg_err(ret); } @@ -892,7 +892,7 @@ int usb_io::read_bulk(void* buf, int* len) if (err) { - HG_VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "libusb_bulk_transfer(%x, %d/%d) = %s\n", endpoints_.bulk.in.port, *len, total, libusb_error_name(err)); + VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "libusb_bulk_transfer(%x, %d/%d) = %s\n", endpoints_.bulk.in.port, *len, total, libusb_error_name(err)); } return last_err_; @@ -918,7 +918,7 @@ int usb_io::write_bulk(void* buf, int* len) err = usb_manager::usb_error_2_hg_err(libusb_bulk_transfer(handle_, endpoints_.bulk.out.port, data, *len, &t, to_)); - //HG_VLOG_MINI_6(LOG_LEVEL_DEBUG_INFO, "First write port %x bulk %d/%d = %s(timeout = %d, packet size = %x)\n", endpoints_.bulk.out.port, t, *len, hg_scanner::strerr((scanner_err)err).c_str(), to_, endpoints_.bulk.out.max_packet); + //VLOG_MINI_6(LOG_LEVEL_DEBUG_INFO, "First write port %x bulk %d/%d = %s(timeout = %d, packet size = %x)\n", endpoints_.bulk.out.port, t, *len, hg_scanner::strerr((scanner_err)err).c_str(), to_, endpoints_.bulk.out.max_packet); // printf("First write port %x bulk %d/%d = %s(timeout = %d, packet size = %x)\n", endpoints_.bulk.out.port, t, *len, hg_scanner::strerr((scanner_err)err).c_str(), to_, endpoints_.bulk.out.max_packet); if (!on_io_error((scanner_err)err, &endpoints_.bulk.out)) { @@ -937,7 +937,7 @@ int usb_io::write_bulk(void* buf, int* len) err = usb_manager::usb_error_2_hg_err(libusb_bulk_transfer(handle_, endpoints_.bulk.out.port, data, *len - total, &t, to_)); total += t; } - //HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Last write bulk %d/%d = %s\n", total, *len, hg_scanner::strerr((scanner_err)err).c_str()); + //VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Last write bulk %d/%d = %s\n", total, *len, hg_scanner::strerr((scanner_err)err).c_str()); *len = total; last_err_ = err; diff --git a/hgdriver/wrapper/CMakeLists.txt b/hgdriver/wrapper/CMakeLists.txt index e85e72f..d36cb0f 100644 --- a/hgdriver/wrapper/CMakeLists.txt +++ b/hgdriver/wrapper/CMakeLists.txt @@ -1,6 +1,7 @@ project(hgdriver) string(TIMESTAMP CURRENT_YEAR "%Y") string(TIMESTAMP MONTHDAY "1%m%d1") +add_definitions(-DBACKEND_NAME=hgdriver) add_definitions(-DVERSION_MAJOR=ver_1) add_definitions(-DVERSION_MINOR=ver_2) add_definitions(-DVERSION_YEAR=${CURRENT_YEAR}) diff --git a/hgdriver/wrapper/hg_log.cpp b/hgdriver/wrapper/hg_log.cpp index 1070de0..787ea3a 100644 --- a/hgdriver/wrapper/hg_log.cpp +++ b/hgdriver/wrapper/hg_log.cpp @@ -6,14 +6,21 @@ #include #ifdef WIN32 #include +#include +#define MKDIR(a, b) mkdir(a) #else +#define MKDIR(a, b) mkdir(a, b) #include #include #include +#include +#include +#include #endif #include -#include "../../sdk/hginclude/hg_log.h" - +#include "../wrapper/hg_log.h" +#include +#include "ini_file.h" #define MAX_LOG_FILE_SIZE 100 * 1024 * 1024 #ifdef _INTSIZEOF @@ -21,6 +28,9 @@ #define _INTSIZEOF(n) ((sizeof(n) + sizeof(long) - 1) & ~(sizeof(long) - 1)) #endif +#ifdef WIN32 +extern std::string g_module_path; // Ending with '\\' +#endif class log_cls { @@ -161,16 +171,6 @@ extern "C" return format_ptr((void*)pthread_self()); #endif } - int init(hg_log_type type, hg_log_level level, char* log_file) - { - if (type == LOG_TYPE_CALLBACK) - lcb_ = (log_callback)log_file; - else - lcb_ = NULL; - log_cls::instance()->set_log_level(level); - - return log_cls::instance()->set_log_type(type, log_file); - } std::string current_time(void) { char buf[40]; @@ -188,7 +188,7 @@ extern "C" if (size > 1024 * 1024 * 1024) { double d = size; - + d /= 1024 * 1024 * 1024; sprintf(buf, "%.2fGB", d); } @@ -285,42 +285,202 @@ extern "C" return si.freeram * si.mem_unit; #endif } + static void str_tolower(std::string& str) + { + std::transform(str.begin(), str.end(), str.begin(), tolower); + } - void log(hg_log_level level, const char* info) +#ifndef WIN32 + typedef struct _find_file + { + std::string pattern; + std::string found; + }FINDFILE, * LPFF; + static std::string link_file(const char* lnk) + { + char path[256] = { 0 }; + int len = readlink(lnk, path, sizeof(path) - 1); + + return path; + } + static int enum_files(const char* dir, bool recursive, bool(*found_file)(const char* path_file, void* param), void* param) + { + int ret = 0; + DIR* pdir = nullptr; + struct dirent* ent = nullptr; + + pdir = opendir(dir); + if (!pdir) + return errno; + + while ((ent = readdir(pdir))) + { + if (ent->d_type & DT_DIR) + { + if (recursive) + { + if (strcmp(ent->d_name, ".") && strcmp(ent->d_name, "..")) + { + std::string sub(dir); + sub += "/"; + sub += ent->d_name; + ret = enum_files(sub.c_str(), recursive, found_file, param); + if (ret == 0x5e17) + break; + } + } + } + else + { + std::string file(dir); + + file += "/"; + file += ent->d_name; + if (!found_file(link_file(file.c_str()).c_str(), param)) + { + ret = 0x5e17; + break; + } + } + } + + return ret; + } + static bool on_found(const char* file, void* param) + { + LPFF lpff = (LPFF)param; + const char* name = strrchr(file, '/'); + + if (name++ == nullptr) + name = file; + + std::string lc(name); + str_tolower(lc); + if (lc.find(lpff->pattern) != std::string::npos) + { + lpff->found = file; + return false; + } + + return true; + } +#endif + static std::string get_self_path(void) + { +#ifdef WIN32 + return g_module_path; +#else + char path[128] = { 0 }; + FINDFILE ff; + size_t pos = 0; + + ff.pattern = GET_BACKEND_NAME; + ff.pattern += ".so"; + str_tolower(ff.pattern); + sprintf(path, "/proc/%u/map_files/", getpid()); + enum_files(path, false, on_found, &ff); + pos = ff.found.rfind('/'); + if (pos++ == std::string::npos) + ff.found += "/"; + else + ff.found.erase(pos); + + return ff.found; +#endif + } + static int get_log_config(const std::string& self_path, hg_log_type* type, std::string* path) + { + std::string me(self_path + "/configs/scanner.conf"); + simple_ini ini; + int lv = LOG_LEVEL_ALL; + hg_log_type tp = LOG_TYPE_FILE; + + if (!type) + type = &tp; + *type = LOG_TYPE_FILE; + if (ini.load(me.c_str()) == 0) + { + std::string val(ini.get("log", "type")); + if (val == "console") + *type = LOG_TYPE_CONSOLE; + else if (val == "none") + *type = LOG_TYPE_NONE; + else + *type = LOG_TYPE_FILE; + + if (*type == LOG_TYPE_FILE && path) + { + *path = ini.get("log", "path"); + } + + val = ini.get("log", "level"); + if (val == "debug") + lv = LOG_LEVEL_DEBUG_INFO; + else if (val == "warning") + lv = LOG_LEVEL_WARNING; + else if (val == "fatal") + lv = LOG_LEVEL_FATAL; + } + + return lv; + } + + int init(void) + { + char* file = nullptr; + std::string me(get_self_path()), path(""); + hg_log_type type = LOG_TYPE_FILE; + int level = get_log_config(me, &type, &path); + + if (type == LOG_TYPE_FILE) + { + if (path.empty()) + path = me; + path += "/log"; + if (MKDIR(path.c_str(), S_IREAD | S_IWRITE | S_IEXEC) && + errno != EEXIST) + { + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Create log-folder '%s' failed(%d), now try temporary directory\n", path.c_str(), errno); + path = simple_ini::temporary_path() + "/log"; + if (MKDIR(path.c_str(), S_IREAD | S_IWRITE | S_IEXEC) && + errno != EEXIST) + { + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "create temporary directory '%s' failed(%d), log to console\n", path.c_str(), errno); + type = LOG_TYPE_CONSOLE; + } + } + + if (type == LOG_TYPE_FILE) + { + std::string name(""); + + pe_path(&name); + if (name.empty()) + path += "/scanner.log"; + else + path += "/" + name + ".log"; + file = &path[0]; + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Log to file: '%s'\n", path.c_str()); + } + } + log_cls::instance()->set_log_level(level); + + return log_cls::instance()->set_log_type(type, file); + } + void log(int level, const char* info) { if (lcb_) lcb_(level, info); else if (log_cls::instance()->is_log_level_enabled(level)) log_cls::instance()->log(info); } - void vlog(hg_log_level level, const char* fmt, ...) + bool is_log_level_enabled(int level) { - if (lcb_) - { - va_list args; - char* buf = (char*)malloc(1024); - - va_start(args, fmt); - //_vsnprintf(&buf[0], estimate_bytes, format, args); - sprintf(buf, fmt, args); - va_end(args); - - lcb_(level, buf); - free(buf); - } - else if (log_cls::instance()->is_log_level_enabled(level)) - { - va_list args; - char* buf = (char*)malloc(1024); - - va_start(args, fmt); - //_vsnprintf(&buf[0], estimate_bytes, format, args); - sprintf(buf, fmt, args); - va_end(args); - - log_cls::instance()->log(buf); - free(buf); - } + return log_cls::instance()->is_log_level_enabled(level); + } + void log(const char* info) + { + log_cls::instance()->log(info); } } #ifdef EXPORT_AS_C @@ -328,7 +488,7 @@ extern "C" #endif #ifdef WIN32 -void hg_debug_log(hg_log_level level, const char* info) +void hg_debug_log(int level, const char* info) { hg_log::log(level, info); } diff --git a/hgdriver/wrapper/hg_log.h b/hgdriver/wrapper/hg_log.h new file mode 100644 index 0000000..28bf77d --- /dev/null +++ b/hgdriver/wrapper/hg_log.h @@ -0,0 +1,59 @@ +// this file is include huagao logging tools +// +// created: 2022-02-09 +// + +#pragma once + +#include +#include "../../sdk/hginclude/huagaoxxx_warraper_ex.h" + +#ifdef WIN32 +#define bzero(a, l) memset(a, 0, l) +#endif + +#ifdef OEM_HANWANG +#define hg_log hw_log +#define hg_log_type hw_log_type +#elif defined(OEM_LISICHENG) +#define hg_log lsc_log +#define hg_log_type lsc_log_type +#endif + +enum hg_log_type +{ + LOG_TYPE_NONE = 0, // no logging + LOG_TYPE_CONSOLE, // print to console + LOG_TYPE_FILE, // write log into file + LOG_TYPE_CALLBACK, // invoke callback log_callback +}; + +typedef void (*log_callback)(int, const char* info); + +#ifdef EXPORT_AS_C +extern "C" +{ +#endif + namespace hg_log + { + std::string format_ptr(void* ptr); + std::string format_current_thread_id(void); + std::string current_time(void); + std::string format_size(unsigned long size); + std::string u2utf8(const wchar_t* u); + std::string pe_path(std::string* name = nullptr); + unsigned long long available_memory(void); + + // Function: initialize the logging type and level + // + // Return: 0 - success, or -1 in LOG_TYPE_FILE and log_file cannot be created + int init(void); + + void log(int level, const char* info); + bool is_log_level_enabled(int level); + void log(const char* info); + } +#ifdef EXPORT_AS_C +} +#endif + diff --git a/hgdriver/wrapper/huagaoxxx_warraper_ex.cpp b/hgdriver/wrapper/huagaoxxx_warraper_ex.cpp index b36b3a0..1c034be 100644 --- a/hgdriver/wrapper/huagaoxxx_warraper_ex.cpp +++ b/hgdriver/wrapper/huagaoxxx_warraper_ex.cpp @@ -1,5 +1,5 @@ #include "../../sdk/hginclude/huagaoxxx_warraper_ex.h" -//#include "../../sdk/hginclude/hg_log.h" +#include "../wrapper/hg_log.h" #include "../hgdev/scanner_manager.h" #include @@ -21,7 +21,7 @@ extern "C" { scanner_err hg_scanner_initialize(sane_callback callback, void* reserve) { - // hg_log::init(LOG_TYPE_CONSOLE); + hg_log::init(); hg_scanner_mgr::set_version(VERSION_MAJOR, VERSION_MINOR, VERSION_YEAR, VERSION_BUILD - 100000); hg_scanner_mgr::instance(callback); @@ -98,6 +98,140 @@ extern "C" { return hg_scanner_mgr::instance()->hg_scanner_control(h, code, data, len); } + + void hg_scanner_set_sane_info(const char* name, const char* ver) + { + + } + const char* hg_scanner_err_name(int err) + { + RETURN_IF(err, SANE_STATUS_GOOD); + RETURN_IF(err, SANE_STATUS_UNSUPPORTED); + RETURN_IF(err, SANE_STATUS_CANCELLED); + RETURN_IF(err, SANE_STATUS_DEVICE_BUSY); + RETURN_IF(err, SANE_STATUS_INVAL); + RETURN_IF(err, SANE_STATUS_EOF); + RETURN_IF(err, SANE_STATUS_JAMMED); + RETURN_IF(err, SANE_STATUS_NO_DOCS); + RETURN_IF(err, SANE_STATUS_COVER_OPEN); + RETURN_IF(err, SANE_STATUS_IO_ERROR); + RETURN_IF(err, SANE_STATUS_NO_MEM); + RETURN_IF(err, SANE_STATUS_ACCESS_DENIED); + RETURN_IF(err, SCANNER_ERR_INVALID_PARAMETER); + RETURN_IF(err, SCANNER_ERR_USER_CANCELED); + RETURN_IF(err, SCANNER_ERR_INSUFFICIENT_MEMORY); + RETURN_IF(err, SCANNER_ERR_ACCESS_DENIED); + RETURN_IF(err, SCANNER_ERR_IO_PENDING); + RETURN_IF(err, SCANNER_ERR_NOT_EXACT); + RETURN_IF(err, SCANNER_ERR_CONFIGURATION_CHANGED); + RETURN_IF(err, SCANNER_ERR_NOT_OPEN); + RETURN_IF(err, SCANNER_ERR_NOT_START); + RETURN_IF(err, SCANNER_ERR_NOT_ANY_MORE); + RETURN_IF(err, SCANNER_ERR_NO_DATA); + RETURN_IF(err, SCANNER_ERR_HAS_DATA_YET); + RETURN_IF(err, SCANNER_ERR_OUT_OF_RANGE); + RETURN_IF(err, SCANNER_ERR_IO); + RETURN_IF(err, SCANNER_ERR_TIMEOUT); + RETURN_IF(err, SCANNER_ERR_OPEN_FILE_FAILED); + RETURN_IF(err, SCANNER_ERR_CREATE_FILE_FAILED); + RETURN_IF(err, SCANNER_ERR_WRITE_FILE_FAILED); + RETURN_IF(err, SCANNER_ERR_DATA_DAMAGED); + RETURN_IF(err, SCANNER_ERR_USB_INIT_FAILED); + RETURN_IF(err, SCANNER_ERR_USB_REGISTER_PNP_FAILED); + RETURN_IF(err, SCANNER_ERR_USB_CLAIM_INTERFACE_FAILED); + RETURN_IF(err, SCANNER_ERR_DEVICE_NOT_FOUND); + RETURN_IF(err, SCANNER_ERR_DEVICE_NOT_SUPPORT); + RETURN_IF(err, SCANNER_ERR_DEVICE_BUSY); + RETURN_IF(err, SCANNER_ERR_DEVICE_SLEEPING); + RETURN_IF(err, SCANNER_ERR_DEVICE_COUNT_MODE); + RETURN_IF(err, SCANNER_ERR_DEVICE_STOPPED); + RETURN_IF(err, SCANNER_ERR_DEVICE_COVER_OPENNED); + RETURN_IF(err, SCANNER_ERR_DEVICE_NO_PAPER); + RETURN_IF(err, SCANNER_ERR_DEVICE_FEEDING_PAPER); + RETURN_IF(err, SCANNER_ERR_DEVICE_DOUBLE_FEEDING); + RETURN_IF(err, SCANNER_ERR_DEVICE_PAPER_JAMMED); + RETURN_IF(err, SCANNER_ERR_DEVICE_STAPLE_ON); + RETURN_IF(err, SCANNER_ERR_DEVICE_PAPER_SKEW); + RETURN_IF(err, SCANNER_ERR_DEVICE_SIZE_CHECK); + RETURN_IF(err, SCANNER_ERR_DEVICE_DOGEAR); + RETURN_IF(err, SCANNER_ERR_DEVICE_NO_IMAGE); + RETURN_IF(err, SCANNER_ERR_DEVICE_SCANN_ERROR); + RETURN_IF(err, SCANNER_ERR_DEVICE_PC_BUSY); + + // NOTE: multi-thread unsafe here + static char g_unk_err[80] = { 0 }; + sprintf(g_unk_err, "\346\234\252\347\237\245\351\224\231\350\257\257\357\274\2320x%X", err); + + return g_unk_err; + } + const char* hg_scanner_err_description(int err) + { + RETURN_DESC_IF(err, SCANNER_ERR_OK); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_NOT_SUPPORT); + RETURN_DESC_IF(err, SCANNER_ERR_USER_CANCELED); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_BUSY); + RETURN_DESC_IF(err, SCANNER_ERR_INVALID_PARAMETER); + RETURN_DESC_IF(err, SCANNER_ERR_NO_DATA); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_PAPER_JAMMED); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_NO_PAPER); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_COVER_OPENNED); + RETURN_DESC_IF(err, SCANNER_ERR_IO); + RETURN_DESC_IF(err, SCANNER_ERR_INSUFFICIENT_MEMORY); + + RETURN_DESC_IF(err, SCANNER_ERR_ACCESS_DENIED); + RETURN_DESC_IF(err, SCANNER_ERR_INSUFFICIENT_MEMORY); + RETURN_DESC_IF(err, SCANNER_ERR_ACCESS_DENIED); + RETURN_DESC_IF(err, SCANNER_ERR_IO_PENDING); + RETURN_DESC_IF(err, SCANNER_ERR_NOT_EXACT); + RETURN_DESC_IF(err, SCANNER_ERR_CONFIGURATION_CHANGED); + RETURN_DESC_IF(err, SCANNER_ERR_NOT_OPEN); + RETURN_DESC_IF(err, SCANNER_ERR_NOT_START); + RETURN_DESC_IF(err, SCANNER_ERR_NOT_ANY_MORE); + RETURN_DESC_IF(err, SCANNER_ERR_NO_DATA); + RETURN_DESC_IF(err, SCANNER_ERR_HAS_DATA_YET); + RETURN_DESC_IF(err, SCANNER_ERR_OUT_OF_RANGE); + RETURN_DESC_IF(err, SCANNER_ERR_IO); + RETURN_DESC_IF(err, SCANNER_ERR_TIMEOUT); + RETURN_DESC_IF(err, SCANNER_ERR_OPEN_FILE_FAILED); + RETURN_DESC_IF(err, SCANNER_ERR_CREATE_FILE_FAILED); + RETURN_DESC_IF(err, SCANNER_ERR_WRITE_FILE_FAILED); + RETURN_DESC_IF(err, SCANNER_ERR_DATA_DAMAGED); + RETURN_DESC_IF(err, SCANNER_ERR_USB_INIT_FAILED); + RETURN_DESC_IF(err, SCANNER_ERR_USB_REGISTER_PNP_FAILED); + RETURN_DESC_IF(err, SCANNER_ERR_USB_CLAIM_INTERFACE_FAILED); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_NOT_FOUND); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_NOT_SUPPORT); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_BUSY); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_SLEEPING); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_COUNT_MODE); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_STOPPED); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_COVER_OPENNED); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_NO_PAPER); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_FEEDING_PAPER); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_DOUBLE_FEEDING); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_PAPER_JAMMED); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_STAPLE_ON); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_PAPER_SKEW); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_SIZE_CHECK); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_DOGEAR); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_NO_IMAGE); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_SCANN_ERROR); + RETURN_DESC_IF(err, SCANNER_ERR_DEVICE_PC_BUSY); + + // NOTE: multi-thread unsafe here + static char g_unk_err[80] = { 0 }; + sprintf(g_unk_err, "\346\234\252\347\237\245\351\224\231\350\257\257\357\274\2320x%X", err); + + return g_unk_err; + } + bool hg_scanner_log_is_enable(int level) + { + return hg_log::is_log_level_enabled(level); + } + void hg_scanner_log(const char* info) + { + hg_log::log(info); + } } diff --git a/hgsane/ini_file.cpp b/hgdriver/wrapper/ini_file.cpp similarity index 100% rename from hgsane/ini_file.cpp rename to hgdriver/wrapper/ini_file.cpp diff --git a/hgsane/ini_file.h b/hgdriver/wrapper/ini_file.h similarity index 100% rename from hgsane/ini_file.h rename to hgdriver/wrapper/ini_file.h diff --git a/hgsane/sane_hg_mdw.cpp b/hgsane/sane_hg_mdw.cpp index 960d4f8..ee05708 100644 --- a/hgsane/sane_hg_mdw.cpp +++ b/hgsane/sane_hg_mdw.cpp @@ -16,7 +16,6 @@ #include #endif -#include "../sdk/hginclude/hg_log.h" #include "ini_file.h" #include "../../sdk/include/sane/sane_option_definitions.h" @@ -36,15 +35,9 @@ #define iconv_t void* #endif - -#ifdef RUN_TEST -std::string jsontext("{\"device_type\":\"G100\",\"option_count\":51,\"1\":{\"category\":\"base\",\"name\":\"cfg-1\",\"title\":\"\\u6062\\u590d\\u9ed8\\u8ba4\\u8bbe\\u7f6e\",\"desc\":\"\\u6062\\u590d\\u9ed8\\u8ba4\\u8bbe\\u7f6e\",\"type\":\"button\",\"cur\":\"button\",\"default\":\"button\",\"size\":0},\"2\":{\"category\":\"advanced\",\"name\":\"cfg-2\",\"title\":\"\\u5e2e\\u52a9\",\"desc\":\"\\u663e\\u793a\\u8f6f\\u4ef6\\u5e2e\\u52a9\\u6587\\u6863\",\"type\":\"button\",\"cur\":\"true\",\"default\":\"true\",\"size\":4},\"3\":{\"category\":\"base\",\"name\":\"grp-1\",\"title\":\"\\u57fa\\u672c\\u8bbe\\u7f6e\",\"type\":\"group\"},\"4\":{\"category\":\"base\",\"name\":\"cfg-4\",\"title\":\"\\u989c\\u8272\\u6a21\\u5f0f\",\"desc\":\"\\u8bbe\\u7f6e\\u989c\\u8272\\u4f4d\\u6df1\",\"type\":\"string\",\"cur\":\"24\\u4f4d\\u5f69\\u8272\",\"default\":\"24\\u4f4d\\u5f69\\u8272\",\"size\":24,\"range\":[\"24\\u4f4d\\u5f69\\u8272\",\"256\\u7ea7\\u7070\\u5ea6\",\"\\u9ed1\\u767d\",\"\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"5\":{\"category\":\"base\",\"name\":\"cfg-5\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf-\\u591a\\u6d41\\u8f93\\u51fa\",\"desc\":\"\",\"type\":\"string\",\"cur\":\"\\u4e0d\\u9009\\u62e9\\u8f93\\u51fa\\u6a21\\u5f0f\",\"default\":\"\\u4e0d\\u9009\\u62e9\\u8f93\\u51fa\\u6a21\\u5f0f\",\"size\":28,\"range\":[\"\\u4e0d\\u9009\\u62e9\\u8f93\\u51fa\\u6a21\\u5f0f\",\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"\\u5f69\\u8272+\\u7070\\u5ea6\",\"\\u5f69\\u8272+\\u9ed1\\u767d\",\"\\u7070\\u5ea6+\\u9ed1\\u767d\"],\"depend_or\":[\"4==24\\u4f4d\\u5f69\\u8272\"]},\"6\":{\"category\":\"base\",\"name\":\"cfg-6\",\"title\":\"\\u7070\\u5ea6\\u6216\\u9ed1\\u767d\\u56fe\\u50cf - \\u9664\\u8272\",\"desc\":\"\\u9664\\u53bb\\u56fe\\u50cf\\u5f69\\u8272\",\"type\":\"string\",\"cur\":\"\\u4e0d\\u9664\\u8272\",\"default\":\"\\u4e0d\\u9664\\u8272\",\"size\":20,\"range\":[\"\\u4e0d\\u9664\\u8272\",\"\\u9664\\u7ea2\\u8272\",\"\\u9664\\u7eff\\u8272\",\"\\u9664\\u84dd\\u8272\",\"\\u7ea2\\u8272\\u589e\\u5f3a\",\"\\u7eff\\u8272\\u589e\\u5f3a\",\"\\u84dd\\u8272\\u589e\\u5f3a\"],\"depend_or\":[\"4==256\\u7ea7\\u7070\\u5ea6\",\"4==\\u9ed1\\u767d\"]},\"7\":{\"category\":\"base\",\"name\":\"cfg-7\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u591a\\u6d41\\u8f93\\u51fa\\u9664\\u7ea2\",\"desc\":\"\\u591a\\u901a\\u9053\\u8f93\\u51fa\\u4e2d\\uff0c\\u53bb\\u9664\\u7ea2\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"4==24\\u4f4d\\u5f69\\u8272\"]},\"8\":{\"category\":\"base\",\"name\":\"cfg-8\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u7b54\\u9898\\u5361\\u9664\\u7ea2\",\"desc\":\"\\u7b54\\u9898\\u5361\\u626b\\u63cf\\u4e2d\\u53bb\\u9664\\u7ea2\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"4==24\\u4f4d\\u5f69\\u8272\"]},\"9\":{\"category\":\"base\",\"name\":\"cfg-9\",\"title\":\"\\u80cc\\u666f\\u79fb\\u9664\",\"desc\":\"\\u79fb\\u9664\\u5f69\\u8272\\u56fe\\u50cf\\u80cc\\u666f\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"4==24\\u4f4d\\u5f69\\u8272\"]},\"10\":{\"category\":\"base\",\"name\":\"cfg-10\",\"title\":\" \\u80cc\\u666f\\u8272\\u5f69\\u6d6e\\u52a8\\u8303\\u56f4\",\"desc\":\"\\u8bbe\\u5b9a\\u80cc\\u666f\\u8272\\u5f69\\u7684\\u6d6e\\u52a8\\u8303\\u56f4\\uff0c\\u5728\\u8be5\\u8303\\u56f4\\u5185\\u7684\\u90fd\\u5f53\\u4f5c\\u80cc\\u666f\\u79fb\\u9664\",\"type\":\"int\",\"cur\":10,\"default\":10,\"size\":4,\"range\":{\"min\":1,\"max\":40},\"depend_or\":[\"9==true\"]},\"11\":{\"category\":\"base\",\"name\":\"cfg-11\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u566a\\u70b9\\u4f18\\u5316\",\"desc\":\"\\u566a\\u70b9\\u4f18\\u5316\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"4==\\u9ed1\\u767d\"]},\"12\":{\"category\":\"base\",\"name\":\"cfg-12\",\"title\":\" \\u566a\\u70b9\\u4f18\\u5316\\u5c3a\\u5bf8\",\"desc\":\"\\u566a\\u70b9\\u4f18\\u5316\\u5c3a\\u5bf8\",\"type\":\"int\",\"cur\":30,\"default\":30,\"size\":4,\"range\":{\"min\":10,\"max\":50},\"depend_or\":[\"11==true\"]},\"13\":{\"category\":\"base\",\"name\":\"cfg-13\",\"title\":\"\\u7eb8\\u5f20\\u5c3a\\u5bf8\",\"desc\":\"\\u8bbe\\u7f6e\\u7eb8\\u5f20\\u5927\\u5c0f\",\"type\":\"string\",\"cur\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"default\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"size\":44,\"range\":[\"A3\",\"8\\u5f00\",\"A4\",\"A4\\u6a2a\\u5411\",\"16\\u5f00\",\"16\\u5f00\\u6a2a\\u5411\",\"A5\",\"A5\\u6a2a\\u5411\",\"A6\",\"A6\\u6a2a\\u5411\",\"B4\",\"B5\",\"B5\\u6a2a\\u5411\",\"B6\",\"B6\\u6a2a\\u5411\",\"Letter\",\"Letter\\u6a2a\\u5411\",\"Double Letter\",\"LEGAL\",\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"\\u4e09\\u8054\\u8bd5\\u5377\"]},\"14\":{\"category\":\"base\",\"name\":\"cfg-14\",\"title\":\"\\u5c3a\\u5bf8\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u7eb8\\u5f20\\u5b9e\\u9645\\u5c3a\\u5bf8\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"13==A3\",\"13==A4\",\"13==A4\\u6a2a\\u5411\",\"13==A5\",\"13==A5\\u6a2a\\u5411\",\"13==A6\",\"13==A6\\u6a2a\\u5411\",\"13==B4\",\"13==B5\",\"13==B5\\u6a2a\\u5411\",\"13==B6\",\"13==B6\\u6a2a\\u5411\",\"13==Double Letter\",\"13==LEGAL\",\"13==Letter\",\"13==Letter\\u6a2a\\u5411\"]},\"15\":{\"category\":\"base\",\"name\":\"cfg-15\",\"title\":\"\\u626b\\u63cf\\u9875\\u9762\",\"desc\":\"\\u8bbe\\u7f6e\\u9875\\u9762\\u626b\\u63cf\\u65b9\\u5f0f\",\"type\":\"string\",\"cur\":\"\\u53cc\\u9762\",\"default\":\"\\u53cc\\u9762\",\"size\":40,\"range\":[\"\\u5355\\u9762\",\"\\u53cc\\u9762\",\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u901a\\u7528\\uff09\",\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u53d1\\u7968\\u7eb8\\uff09\",\"\\u5bf9\\u6298\"]},\"16\":{\"category\":\"base\",\"name\":\"cfg-16\",\"title\":\" \\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u7075\\u654f\\u5ea6\",\"desc\":\"\\u7075\\u654f\\u5ea6\\u8d8a\\u9ad8\\uff0c\\u5219\\u8d8a\\u5bb9\\u6613\\u8df3\\u8fc7\",\"type\":\"int\",\"cur\":50,\"default\":50,\"size\":4,\"range\":{\"min\":1,\"max\":100},\"depend_or\":[\"15==\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u901a\\u7528\\uff09\",\"15==\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u53d1\\u7968\\u7eb8\\uff09\"]},\"17\":{\"category\":\"base\",\"name\":\"cfg-17\",\"title\":\"\\u5206\\u8fa8\\u7387\",\"desc\":\"\\u626b\\u63cf\\u4eea\\u5206\\u8fa8\\u7387\",\"type\":\"int\",\"cur\":200,\"default\":200,\"size\":4,\"range\":{\"min\":100,\"max\":300}},\"18\":{\"category\":\"base\",\"name\":\"cfg-18\",\"title\":\"\\u4ea4\\u6362\\u6b63\\u53cd\\u9762\",\"desc\":\"\\u4ea4\\u6362\\u6b63\\u53cd\\u9762\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"15!=\\u5355\\u9762\"]},\"19\":{\"category\":\"base\",\"name\":\"cfg-19\",\"title\":\"\\u56fe\\u50cf\\u62c6\\u5206\",\"desc\":\"\\u81ea\\u52a8\\u62c6\\u5206\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"15!=\\u5bf9\\u6298\"]},\"20\":{\"category\":\"base\",\"name\":\"cfg-20\",\"title\":\"\\u81ea\\u52a8\\u7ea0\\u504f\",\"desc\":\"\\u81ea\\u52a8\\u7ea0\\u504f\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4,\"depend_or\":[\"15!=\\u5bf9\\u6298\"]},\"21\":{\"category\":\"base\",\"name\":\"cfg-21\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\",\"desc\":\"\\u79fb\\u9664\\u7eb8\\u5f20\\u4e2d\\u7684\\u7a7f\\u5b54\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"22\":{\"category\":\"base\",\"name\":\"cfg-22\",\"title\":\" \\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"type\":\"float\",\"cur\":0.100000,\"default\":0.100000,\"size\":4,\"range\":{\"min\":0.010000,\"max\":0.500000},\"depend_or\":[\"21==true\"]},\"23\":{\"category\":\"base\",\"name\":\"grp-2\",\"title\":\"\\u4eae\\u5ea6\",\"type\":\"group\"},\"24\":{\"category\":\"base\",\"name\":\"cfg-24\",\"title\":\"\\u4eae\\u5ea6\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u7247\\u4eae\\u5ea6\",\"type\":\"int\",\"cur\":128,\"default\":128,\"size\":4,\"range\":{\"min\":1,\"max\":255}},\"25\":{\"category\":\"base\",\"name\":\"cfg-25\",\"title\":\"\\u5bf9\\u6bd4\\u5ea6\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u7247\\u5bf9\\u6bd4\\u5ea6\",\"type\":\"int\",\"cur\":4,\"default\":4,\"size\":4,\"range\":{\"min\":1,\"max\":7}},\"26\":{\"category\":\"base\",\"name\":\"cfg-26\",\"title\":\"\\u4f3d\\u739b\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u7247\\u4f3d\\u739b\\u503c\",\"type\":\"float\",\"cur\":1.000000,\"default\":1.000000,\"size\":4,\"range\":{\"min\":0.010000,\"max\":5.000000}},\"27\":{\"category\":\"base\",\"name\":\"grp-3\",\"title\":\"\\u56fe\\u50cf\\u5904\\u7406\",\"type\":\"group\"},\"28\":{\"category\":\"base\",\"name\":\"cfg-28\",\"title\":\"\\u9510\\u5316\\u4e0e\\u6a21\\u7cca\",\"desc\":\"\\u9510\\u5316\\u4e0e\\u6a21\\u7cca\",\"type\":\"string\",\"cur\":\"\\u65e0\",\"default\":\"\\u65e0\",\"size\":20,\"range\":[\"\\u65e0\",\"\\u9510\\u5316\",\"\\u8fdb\\u4e00\\u6b65\\u9510\\u5316\",\"\\u6a21\\u7cca\",\"\\u8fdb\\u4e00\\u6b65\\u6a21\\u7cca\"]},\"29\":{\"category\":\"base\",\"name\":\"cfg-29\",\"title\":\"\\u6d88\\u9664\\u9ed1\\u6846\",\"desc\":\"\\u6d88\\u9664\\u9ed1\\u6846\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"30\":{\"category\":\"base\",\"name\":\"cfg-30\",\"title\":\"\\u6df1\\u8272\\u6837\\u5f20\",\"desc\":\"\\u6df1\\u8272\\u6837\\u5f20\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"15!=\\u5bf9\\u6298\",\"29!=true\",\"13!=\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"13!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"13!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"20!=true\"]},\"31\":{\"category\":\"advanced\",\"name\":\"cfg-31\",\"title\":\"\\u9608\\u503c\",\"desc\":\"\\u9608\\u503c\",\"type\":\"int\",\"cur\":40,\"default\":40,\"size\":4,\"range\":{\"min\":30,\"max\":50},\"depend_or\":[\"29==true\",\"13==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"13==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"13==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"20==true\"]},\"32\":{\"category\":\"advanced\",\"name\":\"cfg-32\",\"title\":\"\\u80cc\\u666f\\u6297\\u566a\\u7b49\\u7ea7\",\"desc\":\"\\u80cc\\u666f\\u6297\\u566a\\u7b49\\u7ea7\",\"type\":\"int\",\"cur\":8,\"default\":8,\"size\":4,\"range\":{\"min\":1,\"max\":20},\"depend_or\":[\"29==true\",\"13==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"13==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"13==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"20==true\"]},\"33\":{\"category\":\"advanced\",\"name\":\"cfg-33\",\"title\":\"\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"desc\":\"\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"type\":\"int\",\"cur\":5,\"default\":5,\"size\":4,\"range\":{\"min\":5,\"max\":30},\"depend_or\":[\"29==true\",\"13==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"13==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"20==true\",\"13==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\"]},\"34\":{\"category\":\"advanced\",\"name\":\"cfg-34\",\"title\":\"\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"desc\":\"\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"type\":\"string\",\"cur\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"default\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"size\":40,\"range\":[\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"\\u51f9\\u591a\\u8fb9\\u5f62\"],\"depend_or\":[\"29==true\"]},\"35\":{\"category\":\"base\",\"name\":\"cfg-35\",\"title\":\"\\u9632\\u6b62\\u6e17\\u900f\",\"desc\":\"\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"36\":{\"category\":\"base\",\"name\":\"cfg-36\",\"title\":\" \\u9632\\u6b62\\u6e17\\u900f\\u7b49\\u7ea7\",\"desc\":\"\",\"type\":\"string\",\"cur\":\"\\u8f83\\u5f31\",\"default\":\"\\u8f83\\u5f31\",\"size\":12,\"range\":[\"\\u8f83\\u5f31\",\"\\u5f31\",\"\\u4e00\\u822c\",\"\\u5f3a\",\"\\u8f83\\u5f3a\"],\"depend_or\":[\"35==true\"]},\"37\":{\"category\":\"base\",\"name\":\"cfg-37\",\"title\":\"\\u53bb\\u9664\\u6469\\u5c14\\u7eb9\",\"desc\":\"\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"38\":{\"category\":\"base\",\"name\":\"cfg-38\",\"title\":\"\\u9519\\u8bef\\u6269\\u6563\",\"desc\":\"\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"39\":{\"category\":\"base\",\"name\":\"cfg-39\",\"title\":\"\\u9664\\u7f51\\u7eb9\",\"desc\":\"\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"40\":{\"category\":\"base\",\"name\":\"grp-4\",\"title\":\"\\u9001\\u7eb8\\u65b9\\u5f0f\\u8bbe\\u7f6e\",\"type\":\"group\"},\"41\":{\"category\":\"base\",\"name\":\"cfg-41\",\"title\":\"\\u8d85\\u58f0\\u6ce2\\u68c0\\u6d4b\",\"desc\":\"\\u8d85\\u58f0\\u6ce2\\u68c0\\u6d4b\\u9001\\u7eb8\\u72b6\\u6001\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"42\":{\"category\":\"base\",\"name\":\"cfg-42\",\"title\":\"\\u88c5\\u8ba2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u7eb8\\u5f20\\u4e0a\\u662f\\u5426\\u6709\\u9489\\u4e66\\u9489\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"43\":{\"category\":\"base\",\"name\":\"cfg-43\",\"title\":\"\\u626b\\u63cf\\u5f20\\u6570\",\"desc\":\"\\u626b\\u63cf\\u7eb8\\u5f20\\u6570\\u91cf\",\"type\":\"string\",\"cur\":\"\\u8fde\\u7eed\\u626b\\u63cf\",\"default\":\"\\u8fde\\u7eed\\u626b\\u63cf\",\"size\":24,\"range\":[\"\\u8fde\\u7eed\\u626b\\u63cf\",\"\\u626b\\u63cf\\u6307\\u5b9a\\u5f20\\u6570\"]},\"44\":{\"category\":\"base\",\"name\":\"cfg-44\",\"title\":\" \\u626b\\u63cf\\u6570\\u91cf\",\"desc\":\"\\u626b\\u63cf\\u6307\\u5b9a\\u6570\\u91cf\",\"type\":\"int\",\"cur\":1,\"default\":1,\"size\":4,\"depend_or\":[\"43==\\u626b\\u63cf\\u6307\\u5b9a\\u5f20\\u6570\"]},\"45\":{\"category\":\"base\",\"name\":\"cfg-45\",\"title\":\"\\u6587\\u7a3f\\u65b9\\u5411\",\"desc\":\"\\u6587\\u7a3f\\u65b9\\u5411\",\"type\":\"string\",\"cur\":\"0\\u00b0\",\"default\":\"0\\u00b0\",\"size\":40,\"range\":[\"0\\u00b0\",\"90\\u00b0\",\"180\\u00b0\",\"-90\\u00b0\",\"\\u81ea\\u52a8\\u6587\\u672c\\u65b9\\u5411\\u8bc6\\u522b\\u00b0\"]},\"46\":{\"category\":\"base\",\"name\":\"cfg-46\",\"title\":\"\\u80cc\\u9762\\u65cb\\u8f6c180\\u00b0\",\"desc\":\"\\u80cc\\u9762\\u626b\\u63cf\\u7684\\u56fe\\u50cf\\u65cb\\u8f6c180\\u00b0\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"15!=\\u5355\\u9762\",\"15!=\\u5bf9\\u6298\",\"45!=\\u81ea\\u52a8\\u6587\\u672c\\u65b9\\u5411\\u8bc6\\u522b\\u00b0\"]},\"47\":{\"category\":\"base\",\"name\":\"cfg-47\",\"title\":\"\\u6298\\u89d2\\u68c0\\u6d4b\",\"desc\":\"\\u7eb8\\u5f20\\u6298\\u89d2\\u68c0\\u6d4b\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"48\":{\"category\":\"base\",\"name\":\"cfg-48\",\"title\":\" \\u6298\\u89d2\\u68c0\\u6d4b\\u590d\\u6742\\u5ea6\",\"desc\":\"\\u7eb8\\u5f20\\u6298\\u89d2\\u68c0\\u6d4b\\u590d\\u6742\\u5ea6\",\"type\":\"int\",\"cur\":10,\"default\":10,\"size\":4,\"range\":{\"min\":0,\"max\":100},\"depend_or\":[\"47==true\"]},\"49\":{\"category\":\"base\",\"name\":\"cfg-49\",\"title\":\"\\u6b6a\\u659c\\u68c0\\u6d4b\",\"desc\":\"\\u7eb8\\u5f20\\u6b6a\\u659c\\u68c0\\u6d4b\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"50\":{\"category\":\"base\",\"name\":\"cfg-50\",\"title\":\" \\u6b6a\\u659c\\u68c0\\u6d4b\\u590d\\u6742\\u5ea6\",\"desc\":\"\\u7eb8\\u5f20\\u6b6a\\u659c\\u68c0\\u6d4b\\u590d\\u6742\\u5ea6\",\"type\":\"int\",\"cur\":3,\"default\":3,\"size\":4,\"range\":{\"min\":1,\"max\":5},\"depend_or\":[\"49==true\"]}}"); -#endif - namespace local_utility { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - static char g_unk_err[80] = { 0 }; SANE_Status scanner_err_2_sane_statu(int hgerr) { #define RETURN_MATCH_ERROR(hg, sane) \ @@ -75,65 +68,6 @@ namespace local_utility return (SANE_Status)hgerr; } - const char* error_text(SANE_Status statu) - { - RETURN_IF(statu, SANE_STATUS_GOOD); - RETURN_IF(statu, SANE_STATUS_UNSUPPORTED); - RETURN_IF(statu, SANE_STATUS_CANCELLED); - RETURN_IF(statu, SANE_STATUS_DEVICE_BUSY); - RETURN_IF(statu, SANE_STATUS_INVAL); - RETURN_IF(statu, SANE_STATUS_EOF); - RETURN_IF(statu, SANE_STATUS_JAMMED); - RETURN_IF(statu, SANE_STATUS_NO_DOCS); - RETURN_IF(statu, SANE_STATUS_COVER_OPEN); - RETURN_IF(statu, SANE_STATUS_IO_ERROR); - RETURN_IF(statu, SANE_STATUS_NO_MEM); - RETURN_IF(statu, SANE_STATUS_ACCESS_DENIED); - RETURN_IF(statu, SCANNER_ERR_INVALID_PARAMETER); - RETURN_IF(statu, SCANNER_ERR_USER_CANCELED); - RETURN_IF(statu, SCANNER_ERR_INSUFFICIENT_MEMORY); - RETURN_IF(statu, SCANNER_ERR_ACCESS_DENIED); - RETURN_IF(statu, SCANNER_ERR_IO_PENDING); - RETURN_IF(statu, SCANNER_ERR_NOT_EXACT); - RETURN_IF(statu, SCANNER_ERR_CONFIGURATION_CHANGED); - RETURN_IF(statu, SCANNER_ERR_NOT_OPEN); - RETURN_IF(statu, SCANNER_ERR_NOT_START); - RETURN_IF(statu, SCANNER_ERR_NOT_ANY_MORE); - RETURN_IF(statu, SCANNER_ERR_NO_DATA); - RETURN_IF(statu, SCANNER_ERR_HAS_DATA_YET); - RETURN_IF(statu, SCANNER_ERR_OUT_OF_RANGE); - RETURN_IF(statu, SCANNER_ERR_IO); - RETURN_IF(statu, SCANNER_ERR_TIMEOUT); - RETURN_IF(statu, SCANNER_ERR_OPEN_FILE_FAILED); - RETURN_IF(statu, SCANNER_ERR_CREATE_FILE_FAILED); - RETURN_IF(statu, SCANNER_ERR_WRITE_FILE_FAILED); - RETURN_IF(statu, SCANNER_ERR_DATA_DAMAGED); - RETURN_IF(statu, SCANNER_ERR_USB_INIT_FAILED); - RETURN_IF(statu, SCANNER_ERR_USB_REGISTER_PNP_FAILED); - RETURN_IF(statu, SCANNER_ERR_USB_CLAIM_INTERFACE_FAILED); - RETURN_IF(statu, SCANNER_ERR_DEVICE_NOT_FOUND); - RETURN_IF(statu, SCANNER_ERR_DEVICE_NOT_SUPPORT); - RETURN_IF(statu, SCANNER_ERR_DEVICE_BUSY); - RETURN_IF(statu, SCANNER_ERR_DEVICE_SLEEPING); - RETURN_IF(statu, SCANNER_ERR_DEVICE_COUNT_MODE); - RETURN_IF(statu, SCANNER_ERR_DEVICE_STOPPED); - RETURN_IF(statu, SCANNER_ERR_DEVICE_COVER_OPENNED); - RETURN_IF(statu, SCANNER_ERR_DEVICE_NO_PAPER); - RETURN_IF(statu, SCANNER_ERR_DEVICE_FEEDING_PAPER); - RETURN_IF(statu, SCANNER_ERR_DEVICE_DOUBLE_FEEDING); - RETURN_IF(statu, SCANNER_ERR_DEVICE_PAPER_JAMMED); - RETURN_IF(statu, SCANNER_ERR_DEVICE_STAPLE_ON); - RETURN_IF(statu, SCANNER_ERR_DEVICE_PAPER_SKEW); - RETURN_IF(statu, SCANNER_ERR_DEVICE_SIZE_CHECK); - RETURN_IF(statu, SCANNER_ERR_DEVICE_DOGEAR); - RETURN_IF(statu, SCANNER_ERR_DEVICE_NO_IMAGE); - RETURN_IF(statu, SCANNER_ERR_DEVICE_SCANN_ERROR); - RETURN_IF(statu, SCANNER_ERR_DEVICE_PC_BUSY); - - sprintf(g_unk_err, "\346\234\252\347\237\245\351\224\231\350\257\257\357\274\232%X", statu); - - return g_unk_err; - } void* acquire_memory(size_t bytes, const char* info) { @@ -149,147 +83,10 @@ namespace local_utility free(m); } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - static iconv_t iconv_au8 = NULL; - static iconv_t iconv_u8a = NULL; - -#ifndef WIN32 - static std::string convert(iconv_t h, const void* in, size_t bytes) - { - std::string ret(""); - - if (h) - { - size_t rest = bytes, buf_size = bytes * 2, err = 0, out = buf_size - 1; - char* buf = (char*)local_utility::acquire_memory(buf_size, "local_utility::convert"), * src = (char*)in, * cur = buf; - - bzero(buf, buf_size); - err = iconv(h, (char**)&src, &rest, &cur, &out); - while (err == 0 && rest) - { - if (buf_size / bytes > 8) - break; - free(buf); - buf_size += bytes; - buf = (char*)local_utility::acquire_memory(buf_size, "local_utility::convert"); - bzero(buf, buf_size); - out = buf_size - 1; - rest = bytes; - src = (char*)in; - cur = buf; - err = iconv(h, (char**)&src, &rest, &cur, &out); - } - if (err == 0) - ret = std::string(buf, buf_size - 1 - out); - free(buf); - } - - return ret; - } -#endif - - bool char_transfer_init(void) - { -#ifdef RUN_TEST - FILE* src = fopen("/tmp/hg_g100.txt", "rb"); - bool found = false; - if (src) - { - long len = 0; - char* buf = NULL; - - fseek(src, 0, SEEK_END); - len = ftell(src); - fseek(src, 0, SEEK_SET); - buf = (char*)malloc(len + 4); - bzero(buf, len + 4); - fread(buf, 1, len, src); - fclose(src); - - // try parse ... - json* j = new json(); - if (j->attach_text(buf)) - { - jsontext = buf; - found = true; - } - delete j; - free(buf); - } - if (found) - hg_log::log(LOG_LEVEL_DEBUG_INFO, "Testing configuration loaded from /tmp/hg_g100.txt ^_^\n"); - else - hg_log::log(LOG_LEVEL_DEBUG_INFO, "'/tmp/hg_g100.txt' is not found or data damaged. :(\n"); -#endif - -#ifndef WIN32 - if (!iconv_au8) - { - iconv_au8 = iconv_open("gb2312", "utf-8"); - if (iconv_au8 == (iconv_t)-1) - { - iconv_au8 = NULL; - return false; - } - } - - if (!iconv_u8a) - { - iconv_u8a = iconv_open("utf-8", "gb2312"); - if (iconv_u8a == (iconv_t)-1) - { - iconv_u8a = NULL; - - return false; - } - } -#endif - return true; - } - std::string utf8_2_ansi(const char* utf8) - { - return utf8; - if (!iconv_u8a || !utf8 || *utf8 == 0) - return ""; - -#ifdef WIN32 - return utf8; -#else - return convert(iconv_u8a, utf8, strlen(utf8)); -#endif - } - std::string ansi_2_utf8(const char* ansi) - { - if (!iconv_au8 || !ansi || *ansi == 0) - return ""; - -#ifdef WIN32 - return ansi; -#else - return ansi; - return convert(iconv_au8, ansi, strlen(ansi)); -#endif - } - void char_transfer_uninit(void) - { -#ifndef WIN32 - if (iconv_au8) - { - iconv_close(iconv_au8); - iconv_au8 = NULL; - } - if (iconv_u8a) - { - iconv_close(iconv_u8a); - iconv_u8a = NULL; - } -#endif - } - - - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // json parser ... bool is_space(char ch) { return ch == ' ' || ch == '\t'; @@ -424,83 +221,6 @@ namespace local_utility ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void init_log(void) - { - std::string path(hg_log::pe_path()), - val(""); - simple_ini ini; - bool given_path = false; - hg_log_type logt = LOG_TYPE_FILE; - hg_log_level logl = LOG_LEVEL_ALL; - - hg_log::init(LOG_TYPE_CONSOLE, LOG_LEVEL_DEBUG_INFO); - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "current path: '%s'\n", path.c_str()); - if (path.empty()) - path = simple_ini::temporary_path(); - - // pwd/hgsane.conf - // - // [log] - // type=console // or none or other as file - // level=debug // or warning or fatal or other as all - // - if (ini.load((path + "/configs/scanner.conf").c_str()) == 0) - { - val = ini.get("log", "type"); - if (stricmp(val.c_str(), "console") == 0) - logt = LOG_TYPE_CONSOLE; - else if (stricmp(val.c_str(), "none") == 0) - logt = LOG_TYPE_NONE; - if (logt == LOG_TYPE_FILE) - { - val = ini.get("log", "file"); - if (!val.empty()) - { - path = val; - given_path = true; - } - } - val = ini.get("log", "level"); - if (stricmp(val.c_str(), "debug") == 0) - logl = LOG_LEVEL_DEBUG_INFO; - else if (stricmp(val.c_str(), "warning") == 0) - logl = LOG_LEVEL_WARNING; - else if (stricmp(val.c_str(), "fatal") == 0) - logl = LOG_LEVEL_FATAL; - } - if (logt == LOG_TYPE_FILE && !given_path) - { - std::string child("/scanner_log"); - path += child; - if (MKDIR(path.c_str(), S_IREAD | S_IWRITE | S_IEXEC) == 0 || errno == EEXIST) - { - path += "/log.txt"; - } - else - { - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "create folder '%s' failed(%d), now try temporary directory\n", path.c_str(), errno); - path = simple_ini::temporary_path() + child; - if (MKDIR(path.c_str(), S_IREAD | S_IWRITE | S_IEXEC) == 0 || errno == EEXIST) - path += "/log.txt"; - else - { - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "create temporary directory '%s' failed(%d), log to console\n", path.c_str(), errno); - logt = LOG_TYPE_CONSOLE; - logl = LOG_LEVEL_WARNING; - } - } - } - hg_log::init(logt, logl, &path[0]); - -#ifdef OEM_HANWANG - path = hg_log::current_time() + " hwsane is starting ...\n"; -#elif defined(OEM_LISICHENG) - path = hg_log::current_time() + " lscsane is starting ...\n"; -#else - path = hg_log::current_time() + " hgsane is starting ...\n"; -#endif - hg_log::log(LOG_LEVEL_FATAL, path.c_str()); - } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static sane_callback cb_ui_ = NULL; @@ -523,7 +243,6 @@ namespace local_utility RETURN_IF(ev, SANE_EVENT_SCAN_FINISHED); RETURN_IF(ev, SANE_EVENT_ABOUT_INFORMATION); RETURN_IF(ev, SANE_EVENT_SCANNER_CLOSED); - RETURN_IF(ev, SANE_EVENT_WIN_DEBUG_INFO); char unk[20]; sprintf(unk, "%d", ev); @@ -537,15 +256,9 @@ namespace local_utility if (SANE_EVENT_SUPPORT_ASYNC_IO == code) return cb_ui_ ? SCANNER_ERR_OK : SCANNER_ERR_DEVICE_NOT_SUPPORT; - if (code == SANE_EVENT_WIN_DEBUG_INFO) - { - hg_log::log((hg_log_level)*len, (char*)data); - return 0; - } - SANE_Handle h = hg_sane_middleware::scanner_handle_to_sane(dev); - HG_VLOG_MINI_1(LOG_LEVEL_ALL, "sane callback invoked of event %s\n", sane_event((SANE_Event)code).c_str()); + VLOG_MINI_1(LOG_LEVEL_ALL, "sane callback invoked of event %s\n", sane_event((SANE_Event)code).c_str()); if (cb_ui_) { @@ -559,9 +272,6 @@ namespace local_utility return 0; } - void ui_log_cb(hg_log_level level, const char* info) - { - } void get_version(SANE_Int* version_code) { @@ -569,17 +279,9 @@ namespace local_utility *version_code = SANE_VERSION_CODE(SANE_CURRENT_MAJOR, SANE_CURRENT_MINOR, VERSION_BUILD); // leading-char '1' is used for avoid compiler considering '0118' as an octal number :) unsigned long long v = hg_scanner_get_version(); - unsigned short* byt = (unsigned short*)&v; -#ifdef OEM_HANWANG - HG_VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "HanWang scanner driver version: %u.%u.%u.%u\n", byt[3], byt[2], byt[1], byt[0]); - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "hwsane driver version: %u.%u.%u\n", SANE_CURRENT_MAJOR, SANE_CURRENT_MINOR, VERSION_BUILD); -#elif defined(OEM_LISICHENG) - HG_VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "Lisicheng scanner driver version: %u.%u.%u.%u\n", byt[3], byt[2], byt[1], byt[0]); - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "lscsane driver version: %u.%u.%u\n", SANE_CURRENT_MAJOR, SANE_CURRENT_MINOR, VERSION_BUILD); -#else - HG_VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "Huagao scanner driver version: %u.%u.%u.%u\n", byt[3], byt[2], byt[1], byt[0]); - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "hgsane driver version: %u.%u.%u\n", SANE_CURRENT_MAJOR, SANE_CURRENT_MINOR, VERSION_BUILD); -#endif + unsigned short* w = (unsigned short*)&v; + + VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "scanner version: %u.%u.%u.%u\n", w[3], w[2], w[1], w[0]); } void stop_work(void) { @@ -590,426 +292,6 @@ namespace local_utility } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// test -#ifdef RUN_TEST -#include -#ifdef TEST_DEV -#include "scanner_manager.h" -#endif - -static json* jsn_inst = NULL; -static sane_callback g_cb = NULL; -void* g_param = NULL; -static unsigned int scan_count = -1; -static unsigned int scan_count_ = 1; -scanner_err hg_scanner_initialize(sane_callback callback, void* param) -{ -#ifdef TEST_DEV - hg_scanner_mgr::instance(); -#else - jsn_inst = new json(&jsontext[0]); -#endif - g_cb = callback; - g_param = param; - - return SCANNER_ERR_OK; -} -void hg_scanner_uninitialize(void) -{ -} -long hg_scanner_get_version(void) -{ - return SANE_VERSION_CODE(1, 0, 311); -} -static const char* scanner_name = "华高扫描仪(模拟)"; -scanner_err hg_scanner_enum(ScannerInfo* scanner_list, long* count, bool local_only) -{ -#ifdef TEST_DEV - return hg_scanner_mgr::instance()->hg_scanner_enum(scanner_list, count, local_only); -#endif - - if (!count) - return SCANNER_ERR_INVALID_PARAMETER; - - if (*count < 1) - { - *count = 1; - - return SCANNER_ERR_INSUFFICIENT_MEMORY; - } - - *count = 1; - strcpy(scanner_list->name, scanner_name); - strcpy(scanner_list->type, "G100"); - strcpy(scanner_list->model, "Multi-color"); - strcpy(scanner_list->vendor, "Huagao China."); - if (!jsn_inst) - { - std::string v(jsontext); - jsn_inst = new json(&v[0]); - } - - return SCANNER_ERR_OK; -} -static volatile bool run_ = true; -void* thread_pnp(void*) -{ - ScannerInfo devs[4]; - long count = sizeof(devs) / sizeof(devs[0]); - int ev = SANE_EVENT_DEVICE_ARRIVED; - - while (run_) - { - hg_scanner_enum(devs, &count, true); - for (int i = 0; i < count; ++i) - { - SANE_Device dev; - unsigned int len = sizeof(dev); - dev.name = devs[i].name; - dev.vendor = devs[i].vendor; - dev.model = devs[i].model; - dev.type = devs[i].type; - local_utility::ui_cb(NULL, ev, (void*)&dev, &len, NULL); - } - - ev = (rand() % 2 == 0) ? SANE_EVENT_DEVICE_ARRIVED : SANE_EVENT_DEVICE_LEFT; - count = sizeof(devs) / sizeof(devs[0]); - std::this_thread::sleep_for(std::chrono::milliseconds(180 * 1000)); - } - - return 0; -} -scanner_err hg_scanner_open(scanner_handle* h, const char* name, bool shared, const char* user, const char* pwd, const char* check, char* rsc/*rsc[80]*/) -{ - if (!h || !name) - return SCANNER_ERR_INVALID_PARAMETER; - - if (strcmp(name, scanner_name)) - return SCANNER_ERR_DEVICE_NOT_FOUND; - - *h = (scanner_handle)0x7e57; - - return SCANNER_ERR_OK; -} -scanner_err hg_scanner_close(scanner_handle h, bool force) -{ - return SCANNER_ERR_OK; -} -scanner_err hg_scanner_get_parameter(scanner_handle h, unsigned param_no, char* json_data, long* len) -{ - std::string v(""); - json* child = NULL; - char key[20]; - scanner_err err = SCANNER_ERR_OUT_OF_RANGE; - - if (!len || !jsn_inst) - err = SCANNER_ERR_INVALID_PARAMETER; - else - { - if (param_no == 0) - { - int count = 0; - jsn_inst->get_value("option_count", count); - *len = count; - err = SCANNER_ERR_OK; - } - else - { - bzero(key, 20); - sprintf(key, "%d", param_no); - jsn_inst->get_value(key, child); - if (child) - { - v = child->to_string(); - delete child; - - if (*len <= v.length()) - { - err = SCANNER_ERR_INSUFFICIENT_MEMORY; - *len = v.length() + 4; - } - else - { - strcpy(json_data, v.c_str()); - *len = v.length(); - err = SCANNER_ERR_OK; - } - } - } - } - - return err; -} -scanner_err hg_scanner_set_parameter(scanner_handle h, unsigned param_no, void* data, long len) -{ - scanner_err ret = SCANNER_ERR_OK; - - //if (param_no == 15) - //{ - // int dpi = *((int*)data), regular = (dpi + 50) / 100 * 100; - // - // if (dpi != regular) - // { - // *(SANE_Int*)data = regular; - // - // ret = SCANNER_ERR_NOT_EXACT; - // } - //} - - char path[20]; - json* child = NULL; - - sprintf(path, "%d", param_no); - jsn_inst->get_value(path, child); - if (child) - { - std::string type(""), title(""); - - child->get_value("title", title); - if (title == "扫描张数") - { - if (strcmp((char*)data, "连续扫描") == 0) - scan_count = -1; - else - { - scan_count = 0; - } - } - else if (title == " 扫描数量") - scan_count_ = *((int*)data); - sprintf(path, "%d/cur", param_no); - child->get_value("type", type); - if (type == "int") - { - jsn_inst->set_value(path, *((int*)data)); - } - else if (type == "bool") - { - jsn_inst->set_value(path, *((bool*)data)); - } - else if (type == "float") - { - jsn_inst->set_value(path, *((double*)data)); - } - else if(type != "button") - { - jsn_inst->set_value(path, std::string((char*)data)); - } - delete child; - } - - return ret; -} -static unsigned long long fake_total = 1920 * 800 * 3; -static unsigned long long fake_read = 0; -static volatile bool cancel = false; -static int pic_ind = 0; -static bool finished = false; -#include -#include -#include - -std::unique_ptr thread_img_handle; -typedef struct _img_header -{ - int width; // in pixel - int height; // in pixel - int bits; // per channel - int channels; // RGB - 3; GRAY - 1; ... - int line_bytes; // bytes of ONE line - unsigned total_bytes;// total bytes -}IMGHEAD, * LPIMGHEAD; -void* fake_thread(void* hs) -{ - std::string path(local_utility::get_self_path()); - char file[128]; - IMGHEAD imgh; - SANE_Image img; - unsigned count = scan_count == -1 ? -1 : scan_count_; - scanner_handle h = (scanner_handle)hs; - - path += "/sample/"; - local_utility::ui_cb(h, SANE_EVENT_WORKING, (void*)"scanning ...", NULL, NULL); - while (!cancel) - { - sprintf(file, "img_%x.txt", ++pic_ind); - FILE* src = fopen((path + file).c_str(), "rb"); - if (src) - { - fread(&imgh, sizeof(imgh), 1, src); - fclose(src); - sprintf(file, "img_%x.dat", pic_ind); - src = fopen((path + file).c_str(), "rb"); - if (src) - { - void* data = malloc(imgh.total_bytes); - fread(data, 1, imgh.total_bytes, src); - fclose(src); - img.bytes = imgh.total_bytes; - img.data = (unsigned char*)data; - img.header.bytes_per_line = imgh.line_bytes; - img.header.depth = 8; - img.header.format = SANE_FRAME_RGB; - img.header.last_frame = true; - img.header.lines = imgh.height; - img.header.pixels_per_line = imgh.width; - local_utility::ui_cb(h, SANE_EVENT_IMAGE_OK, &img, (unsigned int*)&pic_ind, NULL); - free(data); - } - else - { - unsigned int err = SCANNER_ERR_OPEN_FILE_FAILED; - path += file; - local_utility::ui_cb(h, SANE_EVENT_ERROR, &path[0], &err, NULL); - HG_VLOG_2(LOG_LEVEL_DEBUG_INFO, 512, "Open file failed(%d): %s\n", errno, path.c_str()); - break; - } - } - else - { - unsigned int err = SCANNER_ERR_OPEN_FILE_FAILED; - path += file; - local_utility::ui_cb(h, SANE_EVENT_ERROR, &path[0], &err, NULL); - HG_VLOG_2(LOG_LEVEL_DEBUG_INFO, 512, "Open file failed(%d): %s\n", errno, path.c_str()); - break; - } - if (pic_ind >= count) - break; - std::this_thread::sleep_for(std::chrono::milliseconds(150 + (rand() % 150))); - } - if (cancel) - path = "scan cancled by user"; - else - path = "scan finished"; - - unsigned ret = cancel ? SANE_STATUS_CANCELLED : SANE_STATUS_GOOD; - local_utility::ui_cb(h, SANE_EVENT_SCAN_FINISHED, &path[0], &ret, NULL); - finished = true; - - return 0; -} -scanner_err hg_scanner_start(scanner_handle h, void* async_event, int num) -{ - //if (local_utility::cb_ui_) - //{ - // if (thread_img_handle.get() && !finished) - // return SCANNER_ERR_DEVICE_BUSY; - //} - - finished = false; - fake_read = 0; - cancel = false; - srand(time(NULL)); - pic_ind = 0; - local_utility::ui_cb(h, SANE_EVENT_STATUS, (void*)"ready to start ...", NULL, NULL); - - if (local_utility::cb_ui_) - { - // thread_img_handle.reset(new std::thread(fake_thread, h)); - pthread_t id; - pthread_create(&id, NULL, fake_thread, (void*)h); - } - - return SCANNER_ERR_OK; -} -scanner_err hg_scanner_stop(scanner_handle h) -{ - cancel = true; - //if (local_utility::cb_ui_) - //{ - // if (thread_img_handle.get() && thread_img_handle->joinable()) - // thread_img_handle->join(); - // thread_img_handle.reset(); - //} - - return SCANNER_ERR_OK; -} -scanner_err hg_scanner_get_img_info(scanner_handle h, SANE_Parameters* bmi, long len) -{ - std::string path(local_utility::get_self_path()); - char file[128]; - - path += "/sample/"; - sprintf(file, "img_%x.txt", ++pic_ind); - FILE* src = fopen((path + file).c_str(), "rb"); - if (src) - { - IMGHEAD imgh; - fread(&imgh, sizeof(imgh), 1, src); - fclose(src); - bmi->bytes_per_line = imgh.line_bytes; - bmi->depth = 8; - bmi->format = SANE_FRAME_RGB; - bmi->last_frame = true; - bmi->lines = imgh.height; - bmi->pixels_per_line = imgh.width; - } - else - { - bmi->bytes_per_line = 1920 * 3; - bmi->depth = 8; - bmi->format = SANE_FRAME_RGB; - bmi->last_frame = true; - bmi->lines = 800; - bmi->pixels_per_line = 1920; - } - - return SCANNER_ERR_OK; -} -scanner_err hg_scanner_read_img_data(scanner_handle h, unsigned char* data, long* len) -{ -// if (*len <= 0 || fake_read >= fake_total) -// return SCANNER_ERR_NO_DATA; - if (cancel) - return (scanner_err)SANE_STATUS_CANCELLED; - - std::string path(local_utility::get_self_path()); - char file[128]; - static int offset = 0; - - path += "/sample/"; - sprintf(file, "img_%x.dat", ++pic_ind); - FILE* src = fopen((path + file).c_str(), "rb"); - if (src) - { - fseek(src, offset, SEEK_SET); - size_t r = fread(data, 1, *len, src); - if (r < *len) - offset = 0; - else - offset += r; - fclose(src); - *len = r; - } - else - { - int bytes = 1920 * 800 * 3 - offset; - if (bytes > *len) - bytes = *len; - for (long i = 0; i < bytes; ++i) - data[i] = rand(); - if (bytes <= *len) - offset = 0; - else - offset += bytes; - } - - return SCANNER_ERR_OK; -} -scanner_err hg_scanner_get_status(scanner_handle h, int setstutas) -{ - return SCANNER_ERR_OK; -} -scanner_err hg_scanner_reset(scanner_handle h) -{ - return SCANNER_ERR_OK; -} -scanner_err hg_scanner_control(scanner_handle h, unsigned long code, void* data, unsigned* len) -{ - return SCANNER_ERR_OK; -} -#endif ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1018,14 +300,15 @@ const SANE_Device** hg_sane_middleware::dev_list_ = NULL; hg_sane_middleware::hg_sane_middleware(void) : opt_0_(nullptr), std_opt_(nullptr) { + char sane_ver[40] = { 0 }; + + sprintf(sane_ver, "%u.%u.%u", SANE_CURRENT_MAJOR, SANE_CURRENT_MINOR, VERSION_BUILD); signal(SIGUSR1, &hg_sane_middleware::device_pnp); - local_utility::char_transfer_init(); + hg_scanner_set_sane_info(GET_BACKEND_NAME, sane_ver); hg_scanner_initialize(local_utility::ui_cb, NULL); } hg_sane_middleware::~hg_sane_middleware() { - local_utility::char_transfer_uninit(); - for (size_t i = 0; i < opts_.size(); ++i) { local_utility::free_memory(opts_[i].desc); @@ -1081,7 +364,7 @@ const SANE_Device** hg_sane_middleware::to_sane_device(ScannerInfo* hgscanner, i COPY_DEVICE_MEMBER(type); } - //HG_VLOG_MINI_2(LOG_LEVEL_ALL, "Memory usage: %u / %u\n", val - (char*)ret, total); + //VLOG_MINI_2(LOG_LEVEL_ALL, "Memory usage: %u / %u\n", val - (char*)ret, total); return (const SANE_Device**)ret; } @@ -1096,7 +379,7 @@ void hg_sane_middleware::free_sane_device(SANE_Device** dev) } void hg_sane_middleware::device_pnp(int sig) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Device list changed (%d)...", sig); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Device list changed (%d)...", sig); } SANE_Fixed hg_sane_middleware::double_2_sane_fixed(double v) { @@ -1225,7 +508,7 @@ SANE_Option_Descriptor* hg_sane_middleware::string_option_to_SANE_descriptor(con } } - //HG_VLOG_MINI_2(LOG_LEVEL_ALL, "Memory usage: %u/%u\n", str - (char*)sod, bytes); + //VLOG_MINI_2(LOG_LEVEL_ALL, "Memory usage: %u/%u\n", str - (char*)sod, bytes); return sod; } @@ -1286,7 +569,7 @@ SANE_Option_Descriptor* hg_sane_middleware::number_option_to_SANE_descriptor(con str = (char*)((SANE_Range*)str + 1); } - //HG_VLOG_MINI_2(LOG_LEVEL_ALL, "Memory usage: %u/%u\n", str - (char*)sod, bytes); + //VLOG_MINI_2(LOG_LEVEL_ALL, "Memory usage: %u/%u\n", str - (char*)sod, bytes); return sod; } @@ -1336,7 +619,7 @@ SANE_Option_Descriptor* hg_sane_middleware::number_option_to_SANE_descriptor(con str = (char*)(val + values.size()); } - //HG_VLOG_MINI_2(LOG_LEVEL_ALL, "Memory usage: %u/%u\n", str - (char*)sod, bytes); + //VLOG_MINI_2(LOG_LEVEL_ALL, "Memory usage: %u/%u\n", str - (char*)sod, bytes); return sod; } @@ -1386,7 +669,7 @@ SANE_Option_Descriptor* hg_sane_middleware::number_option_to_SANE_descriptor(con str = (char*)(val + values.size()); } - //HG_VLOG_MINI_2(LOG_LEVEL_ALL, "Memory usage: %u/%u\n", str - (char*)sod, bytes); + //VLOG_MINI_2(LOG_LEVEL_ALL, "Memory usage: %u/%u\n", str - (char*)sod, bytes); return sod; } @@ -1474,10 +757,10 @@ SANE_Option_Descriptor* hg_sane_middleware::from_json(scanner_handle h, json* js { if (range->first_child(val)) { - constraints.push_back(local_utility::utf8_2_ansi(val.c_str())); + constraints.push_back(val); while (range->next_child(val)) { - constraints.push_back(local_utility::utf8_2_ansi(val.c_str())); + constraints.push_back(val); } } delete range; @@ -1586,7 +869,7 @@ SANE_Option_Descriptor* hg_sane_middleware::from_json(scanner_handle h, json* js if (strcmp(ret->title, "\345\210\206\350\276\250\347\216\207") == 0) { - hg_log::log(LOG_LEVEL_DEBUG_INFO, "set \345\210\206\350\276\250\347\216\207 unit to DPI\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, "set \345\210\206\350\276\250\347\216\207 unit to DPI\n"); ret->unit = SANE_UNIT_DPI; } else if (strcmp(ret->name, SANE_STD_OPT_NAME_CUSTOM_AREA_LEFT) == 0 || @@ -1754,7 +1037,7 @@ bool hg_sane_middleware::get_current_value(scanner_handle handle, int option, vo jsn->get_value("title", val); - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "<--Get option(%d - %s) value: %s\n", option, val.c_str(), hg_sane_middleware::option_value_2_string(t, value).c_str()); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "<--Get option(%d - %s) value: %s\n", option, val.c_str(), hg_sane_middleware::option_value_2_string(t, value).c_str()); } delete jsn; @@ -1777,7 +1060,7 @@ void* hg_sane_middleware::get_default_value(scanner_handle handle, int option) data = local_utility::acquire_memory(sizeof(v), ""); memcpy(data, &v, sizeof(v)); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "option %d default value is: %s\n", option, v ? "true" : "false"); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "option %d default value is: %s\n", option, v ? "true" : "false"); } else if (val == "int") { @@ -1786,7 +1069,7 @@ void* hg_sane_middleware::get_default_value(scanner_handle handle, int option) data = local_utility::acquire_memory(sizeof(v), ""); memcpy(data, &v, sizeof(v)); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "option %d default value is: %d\n", option, v); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "option %d default value is: %d\n", option, v); } else if (val == "float") { @@ -1795,7 +1078,7 @@ void* hg_sane_middleware::get_default_value(scanner_handle handle, int option) data = local_utility::acquire_memory(sizeof(v), ""); memcpy(data, &v, sizeof(v)); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "option %d default value is: %f\n", option, v); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "option %d default value is: %f\n", option, v); } else if (val == "string") { @@ -1809,11 +1092,11 @@ void* hg_sane_middleware::get_default_value(scanner_handle handle, int option) size = val.length(); data = local_utility::acquire_memory(size + 4, ""); strcpy((char*)data, val.c_str()); - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "option %d default value is: %s\n", option, (char*)data); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "option %d default value is: %s\n", option, (char*)data); } else { - HG_VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "option %d type is '%s' and cannot be set value.\n", option, val.c_str()); + VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "option %d type is '%s' and cannot be set value.\n", option, val.c_str()); } } delete jsn; @@ -1978,7 +1261,7 @@ SANE_Option_Descriptor* hg_sane_middleware::get_option_descriptor(SANE_Handle h, opt_0_->type = SANE_TYPE_INT; opt_0_->size = sizeof(SANE_TYPE_INT); } - HG_LOG(LOG_LEVEL_DEBUG_INFO, "get_option_descriptor(0)\n"); + LOG_INFO(LOG_LEVEL_DEBUG_INFO, "get_option_descriptor(0)\n"); return opt_0_; } @@ -2040,7 +1323,7 @@ SANE_Status hg_sane_middleware::set_option(SANE_Handle h, SANE_Int option, SANE_ hg_scanner_get_parameter(handle, option, NULL, &count); *((SANE_Int*)value) = count; ret = SANE_STATUS_GOOD; - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "get option count = %d.\n", count); + VLOG_MINI_1(LOG_LEVEL_WARNING, "get option count = %d.\n", count); } else { @@ -2074,14 +1357,14 @@ SANE_Status hg_sane_middleware::set_option(SANE_Handle h, SANE_Int option, SANE_ { if (!desc) { - HG_VLOG_MINI_1(LOG_LEVEL_FATAL, "Option descriptor %d not found.\n", option); + VLOG_MINI_1(LOG_LEVEL_FATAL, "Option descriptor %d not found.\n", option); return SANE_STATUS_UNSUPPORTED; } else if (!value && desc->type != SANE_TYPE_BUTTON) { if (action == SANE_ACTION_SET_AUTO) // we assume the driver can set the option properbly, and no work to do { - HG_VLOG_MINI_2(LOG_LEVEL_WARNING, "Option %d(%s) call SANE_ACTION_SET_AUTO, we set default value.\n", option, desc->title); + VLOG_MINI_2(LOG_LEVEL_WARNING, "Option %d(%s) call SANE_ACTION_SET_AUTO, we set default value.\n", option, desc->title); value = get_default_value(handle, option); if (!value) @@ -2090,7 +1373,7 @@ SANE_Status hg_sane_middleware::set_option(SANE_Handle h, SANE_Int option, SANE_ } else { - HG_VLOG_MINI_2(LOG_LEVEL_WARNING, "Option descriptor %d(%s) need a value!.\n", option, desc->title); + VLOG_MINI_2(LOG_LEVEL_WARNING, "Option descriptor %d(%s) need a value!.\n", option, desc->title); return SANE_STATUS_INVAL; } @@ -2130,11 +1413,11 @@ SANE_Status hg_sane_middleware::set_option(SANE_Handle h, SANE_Int option, SANE_ if (prev == v) { - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "-->Set option(%d - %s) value: %s\n", option, desc->title, v.c_str()); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "-->Set option(%d - %s) value: %s\n", option, desc->title, v.c_str()); } else { - HG_VLOG_4(LOG_LEVEL_DEBUG_INFO, 512, "-->Set option(%d - %s) value: %s(Applied: %s)\n", option, desc->title, prev.c_str(), v.c_str()); + VLOG_4(LOG_LEVEL_DEBUG_INFO, 512, "-->Set option(%d - %s) value: %s(Applied: %s)\n", option, desc->title, prev.c_str(), v.c_str()); } if (err == SCANNER_ERR_OK) @@ -2147,7 +1430,7 @@ SANE_Status hg_sane_middleware::set_option(SANE_Handle h, SANE_Int option, SANE_ } else if (err == SCANNER_ERR_CONFIGURATION_CHANGED) { - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "the setting '%s' affects other options value, RELOAD ...\n", desc->title); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "the setting '%s' affects other options value, RELOAD ...\n", desc->title); on_SCANNER_ERR_CONFIGURATION_CHANGED(handle, dev.dev_name.c_str()); err = (scanner_err)SANE_INFO_RELOAD_OPTIONS; } @@ -2178,7 +1461,7 @@ SANE_Status hg_sane_middleware::io_control(SANE_Handle h, unsigned long code, vo if (ret == SCANNER_ERR_CONFIGURATION_CHANGED) { int nc = code; - HG_VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "the setting '0x%08x' affects other options value, RELOAD ...\n", nc); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "the setting '0x%08x' affects other options value, RELOAD ...\n", nc); on_SCANNER_ERR_CONFIGURATION_CHANGED(handle, od.dev_name.c_str()); } @@ -2230,7 +1513,7 @@ bool hg_sane_middleware::is_enable_and(const std::vector& master, std: std::vector::iterator it = std::find(curvals.begin(), curvals.end(), master[i].option_no); if (it == curvals.end()) { - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "option %d's current value is not found, other options depend it maybe in wrong status.\n", master[i].option_no); + VLOG_MINI_1(LOG_LEVEL_WARNING, "option %d's current value is not found, other options depend it maybe in wrong status.\n", master[i].option_no); continue; } enabled &= master[i].compare_val(it->val.c_str(), master[i].limit_l.c_str(), master[i].limit_r.c_str()); @@ -2247,7 +1530,7 @@ bool hg_sane_middleware::is_enable_or(const std::vector& master, std:: std::vector::iterator it = std::find(curvals.begin(), curvals.end(), master[i].option_no); if (it == curvals.end()) { - HG_VLOG_MINI_1(LOG_LEVEL_WARNING, "option %d's current value is not found, other options depend it maybe in wrong status.\n", master[i].option_no); + VLOG_MINI_1(LOG_LEVEL_WARNING, "option %d's current value is not found, other options depend it maybe in wrong status.\n", master[i].option_no); continue; } @@ -2577,8 +1860,6 @@ void hg_sane_middleware::on_SCANNER_ERR_CONFIGURATION_CHANGED(scanner_handle han extern "C" { // avoid compiler exporting name in C++ style !!! SANE_Status inner_sane_init(SANE_Int* version_code, SANE_Auth_Callback authorize) { - local_utility::init_log(); - local_utility::cb_auth_ = authorize; hg_sane_middleware::instance(); local_utility::get_version(version_code); @@ -2587,13 +1868,8 @@ extern "C" { // avoid compiler exporting name in C++ style !!! } void inner_sane_exit(void) { -#ifdef RUN_TEST - run_ = false; -#endif local_utility::stop_work(); hg_sane_middleware::clear(); - - hg_log::log(LOG_LEVEL_FATAL, (hg_log::current_time() + " hgsane exited.\n").c_str()); } SANE_Status inner_sane_get_devices(const SANE_Device*** device_list, SANE_Bool local_only) { @@ -2624,14 +1900,12 @@ extern "C" { // avoid compiler exporting name in C++ style !!! } SANE_Status inner_sane_start(SANE_Handle handle) { - HG_VLOG_MINI_1(LOG_LEVEL_ALL, "[%s] - sane_start\n", hg_log::format_current_thread_id().c_str()); + LOG_INFO(LOG_LEVEL_ALL, "sane_start\n"); return hg_sane_middleware::instance()->start(handle, NULL); } SANE_Status inner_sane_read(SANE_Handle handle, SANE_Byte* data, SANE_Int max_length, SANE_Int* length) { - // HG_VLOG_MINI_1(LOG_LEVEL_ALL, "[%s] - sane_read\n", hg_log::format_current_thread_id().c_str()); - if (!length) length = &max_length; else @@ -2645,7 +1919,7 @@ extern "C" { // avoid compiler exporting name in C++ style !!! } SANE_Status inner_sane_set_io_mode(SANE_Handle handle, SANE_Bool non_blocking) { - HG_VLOG_MINI_1(LOG_LEVEL_ALL, "[%s] - sane_set_io_mode\n", hg_log::format_current_thread_id().c_str()); + LOG_INFO(LOG_LEVEL_ALL, "sane_set_io_mode\n"); return non_blocking ? SANE_STATUS_UNSUPPORTED : SANE_STATUS_GOOD; } @@ -2655,27 +1929,16 @@ extern "C" { // avoid compiler exporting name in C++ style !!! } SANE_String_Const inner_sane_strstatus(SANE_Status status) { - return local_utility::error_text(status); + return hg_scanner_err_name(status); } SANE_Status inner_sane_init_ex(SANE_Int* version_code, sane_callback cb, void* param) { - local_utility::init_log(); local_utility::cb_ui_ = cb; local_utility::cb_ui_parm_ = param; hg_sane_middleware::instance(); local_utility::get_version(version_code); -#ifdef RUN_TEST - if (local_utility::cb_ui_) - { - // thread_img_handle.reset(new std::thread(fake_thread, h)); - pthread_t id; - pthread_create(&id, NULL, thread_pnp, NULL); - } -#endif - - return SANE_STATUS_GOOD; } SANE_Status inner_sane_io_control(SANE_Handle h, unsigned long code, void* data, unsigned* len) @@ -2685,13 +1948,6 @@ extern "C" { // avoid compiler exporting name in C++ style !!! void sanei_debug_msg(int level, int max_level, const char* be, const char* fmt, va_list ap) { - //char* f = (char*)local_utility::acquire_memory(strlen(fmt) + 20, "sanei_debug_msg"); - // - //strcpy(f, "%s - "); - //strcat(f, fmt); - //strcat(f, "\n"); - //hg_log::vlog(strlen(f) + 256, f, be, ap); - //free(f); } } diff --git a/hgsane/sane_option.cpp b/hgsane/sane_option.cpp index 335c8c3..f2e6935 100644 --- a/hgsane/sane_option.cpp +++ b/hgsane/sane_option.cpp @@ -1,6 +1,6 @@ #include "sane_option.h" #include -#include "../sdk/hginclude/hg_log.h" +#include "../sdk/hginclude/huagaoxxx_warraper_ex.h" #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) @@ -48,7 +48,7 @@ static void match_paper(char* buf, int cx, int cy) else strcpy(buf, g_paper[index].title); - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "match paper(%u * %u) to '%s'\n", cx, cy, (char*)buf); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "match paper(%u * %u) to '%s'\n", cx, cy, (char*)buf); } @@ -349,7 +349,7 @@ scanner_err sane_std_opts::set_value(scanner_handle h, int opt, void* buf) long len = 0; void* data = from_known_opt_value(op, buf, &len); - HG_VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "%d->%d: %s\n", opt, op->user.opt, (char*)data); + VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "%d->%d: %s\n", opt, op->user.opt, (char*)data); statu = hg_scanner_set_parameter(h, op->user.opt, data, len); if (statu == SCANNER_ERR_NOT_EXACT) diff --git a/sdk/hginclude/huagaoxxx_warraper_ex.h b/sdk/hginclude/huagaoxxx_warraper_ex.h index 9435a33..ec209ff 100644 --- a/sdk/hginclude/huagaoxxx_warraper_ex.h +++ b/sdk/hginclude/huagaoxxx_warraper_ex.h @@ -99,6 +99,11 @@ #define hg_scanner_get_status hw_scanner_get_status #define hg_scanner_reset hw_scanner_reset #define hg_scanner_control hw_scanner_control +#define hg_scanner_set_sane_info hw_scanner_set_sane_info +#define hg_scanner_err_name hw_scanner_err_name +#define hg_scanner_err_description hw_scanner_err_description +#define hg_scanner_log hw_scanner_log +#define hg_scanner_log_is_enable hw_scanner_log_is_enable #elif defined(OEM_LISICHENG) #define hg_scanner_initialize lsc_scanner_initialize #define hg_scanner_uninitialize lsc_scanner_uninitialize @@ -115,8 +120,16 @@ #define hg_scanner_get_status lsc_scanner_get_status #define hg_scanner_reset lsc_scanner_reset #define hg_scanner_control lsc_scanner_control +#define hg_scanner_set_sane_info lsc_scanner_set_sane_info +#define hg_scanner_err_name lsc_scanner_err_name +#define hg_scanner_err_description lsc_scanner_err_description +#define hg_scanner_log lsc_scanner_log +#define hg_scanner_log_is_enable lsc_scanner_log_is_enable #endif +#define _TO_STR(str) #str +#define MAKE_STR(str) _TO_STR(str) +#define GET_BACKEND_NAME MAKE_STR(BACKEND_NAME) typedef struct _device { @@ -386,10 +399,105 @@ extern "C"{ // Return: 错误码 scanner_err hg_scanner_control(scanner_handle h, unsigned long code, void* data, unsigned *len); + // Function: 设置SANE组件信息 + // + // Parameter: name - sane组件名字 + // + // ver - sane组件版本 + // + // Return: none + void hg_scanner_set_sane_info(const char* name, const char* ver); + + const char* hg_scanner_err_name(int err); + const char* hg_scanner_err_description(int err); + + enum log_level + { + LOG_LEVEL_ALL = 0, + LOG_LEVEL_DEBUG_INFO, + LOG_LEVEL_WARNING, + LOG_LEVEL_FATAL, + }; + bool hg_scanner_log_is_enable(int level); + void hg_scanner_log(const char* info); + #ifdef __cplusplus } #endif + +///////////////////////////////////////////////////////////////////////////////////// +// log ... +#define VLOG_MINI_BYTES 512 + +#define LOG_INFO(level, info) \ + if(hg_scanner_log_is_enable(level)) \ + hg_scanner_log(info); + +#define VLOG_1(level, bytes, fmt, arg1) \ + if(hg_scanner_log_is_enable(level)) \ + { \ + char* msgbuf = (char*)malloc(bytes); \ + sprintf(msgbuf, fmt, arg1); \ + hg_scanner_log(msgbuf); \ + free(msgbuf); \ + } +#define VLOG_MINI_1(level, fmt, arg1) VLOG_1(level, VLOG_MINI_BYTES, fmt, arg1) + +#define VLOG_2(level, bytes, fmt, arg1, arg2) \ + if(hg_scanner_log_is_enable(level)) \ + { \ + char* msgbuf = (char*)malloc(bytes); \ + sprintf(msgbuf, fmt, arg1, arg2); \ + hg_scanner_log(msgbuf); \ + free(msgbuf); \ + } +#define VLOG_MINI_2(level, fmt, arg1, arg2) VLOG_2(level, VLOG_MINI_BYTES, fmt, arg1, arg2) + +#define VLOG_3(level, bytes, fmt, arg1, arg2, arg3) \ + if(hg_scanner_log_is_enable(level)) \ + { \ + char* msgbuf = (char*)malloc(bytes); \ + sprintf(msgbuf, fmt, arg1, arg2, arg3); \ + hg_scanner_log(msgbuf); \ + free(msgbuf); \ + } +#define VLOG_MINI_3(level, fmt, arg1, arg2, arg3) VLOG_3(level, VLOG_MINI_BYTES, fmt, arg1, arg2, arg3) + +#define VLOG_4(level, bytes, fmt, arg1, arg2, arg3, arg4) \ + if(hg_scanner_log_is_enable(level)) \ + { \ + char* msgbuf = (char*)malloc(bytes); \ + sprintf(msgbuf, fmt, arg1, arg2, arg3, arg4); \ + hg_scanner_log(msgbuf); \ + free(msgbuf); \ + } +#define VLOG_MINI_4(level, fmt, arg1, arg2, arg3, arg4) \ + VLOG_4(level, VLOG_MINI_BYTES, fmt, arg1, arg2, arg3, arg4) + +#define VLOG_5(level, bytes, fmt, arg1, arg2, arg3, arg4, arg5) \ + if(hg_scanner_log_is_enable(level)) \ + { \ + char* msgbuf = (char*)malloc(bytes); \ + sprintf(msgbuf, fmt, arg1, arg2, arg3, arg4, arg5); \ + hg_scanner_log(msgbuf); \ + free(msgbuf); \ + } +#define VLOG_MINI_5(level, fmt, arg1, arg2, arg3, arg4, arg5) \ + VLOG_5(level, VLOG_MINI_BYTES, fmt, arg1, arg2, arg3, arg4, arg5) + +#define VLOG_6(level, bytes, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \ + if(hg_scanner_log_is_enable(level)) \ + { \ + char* msgbuf = (char*)malloc(bytes); \ + sprintf(msgbuf, fmt, arg1, arg2, arg3, arg4, arg5, arg6); \ + hg_scanner_log(msgbuf); \ + free(msgbuf); \ + } +#define VLOG_MINI_6(level, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \ + VLOG_6(level, VLOG_MINI_BYTES, fmt, arg1, arg2, arg3, arg4, arg5, arg6) + + #endif // WRRPER_SANE_SCANNER_H_EX