diff --git a/device/gxx-linux/usb/inc/usbdevice.h b/device/gxx-linux/usb/inc/usbdevice.h index cccbb95..459aa17 100644 --- a/device/gxx-linux/usb/inc/usbdevice.h +++ b/device/gxx-linux/usb/inc/usbdevice.h @@ -12,14 +12,20 @@ #include "usb_io.h" #include - -#define ASYNC_EP +#include class UsbDevice +#ifdef ASYNC_EP + : public sane_cfg_provider +#endif { #ifdef ASYNC_EP async_usb_gadget *usb_; sane_cfg_mgr *cfg_; + uint32_t img_cnt_; + uint32_t scan_id_; + uint32_t dpi_; + std::string cfg_text_; dyn_mem_ptr unhandled_ep0(struct usb_functionfs_event* pev); dyn_mem_ptr handle_bulk_cmd(LPPACK_BASE pack, uint32_t* used, packet_data_base_ptr* required); @@ -35,6 +41,12 @@ class UsbDevice void do_system_command(const char* cmd); void init(void); + +public: + void save_image(MemoryPtr data, bool img); + + virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override; + virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; #endif public: diff --git a/device/gxx-linux/usb/src/common/data.cpp b/device/gxx-linux/usb/src/common/data.cpp index f524ea4..3a8f2d1 100644 --- a/device/gxx-linux/usb/src/common/data.cpp +++ b/device/gxx-linux/usb/src/common/data.cpp @@ -51,7 +51,7 @@ namespace sys_util //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // packet_data_base::packet_data_base() : pack_cmd_(0), pack_id_(0) - , progress_notify_(PROGRESS_NOTIFYER()) + , progress_notify_(PROGRESS_NOTIFYER()), user_data_(nullptr) {} packet_data_base::~packet_data_base() {} @@ -59,7 +59,7 @@ packet_data_base::~packet_data_base() int packet_data_base::notify_progress(uint64_t total, uint64_t cur_size, uint32_t err) { if (progress_notify_) - progress_notify_(total, cur_size, err); + progress_notify_(total, cur_size, err, user_data_); else return ENOENT; } @@ -78,9 +78,10 @@ int packet_data_base::get_packet_id(void) return pack_id_; } -void packet_data_base::set_progress_notify(PROGRESS_NOTIFYER notify) +void packet_data_base::set_progress_notify(PROGRESS_NOTIFYER notify, void* param) { progress_notify_ = notify; + user_data_ = param; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/device/gxx-linux/usb/src/common/data.h b/device/gxx-linux/usb/src/common/data.h index 833e10c..993de72 100644 --- a/device/gxx-linux/usb/src/common/data.h +++ b/device/gxx-linux/usb/src/common/data.h @@ -18,11 +18,12 @@ // /* packet parameter keeper, parameter of corresponding packet */ -#define PROGRESS_NOTIFYER std::function +#define PROGRESS_NOTIFYER std::function class packet_data_base : public refer { PROGRESS_NOTIFYER progress_notify_; + void* user_data_; protected: uint32_t pack_cmd_; @@ -40,7 +41,7 @@ public: int get_packet_command(void); int get_packet_id(void); - void set_progress_notify(PROGRESS_NOTIFYER notify = PROGRESS_NOTIFYER()); + void set_progress_notify(PROGRESS_NOTIFYER notify = PROGRESS_NOTIFYER(), void* param = nullptr); }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/device/gxx-linux/usb/src/common/json/json.cpp b/device/gxx-linux/usb/src/common/json/json.cpp index e8ae93f..e3b4b3a 100644 --- a/device/gxx-linux/usb/src/common/json/json.cpp +++ b/device/gxx-linux/usb/src/common/json/json.cpp @@ -380,7 +380,7 @@ bool json::get_value(const char* key, json*& val) if (child) { - if (child->type_ == VAL_TYPE_OBJECT) + if (child->type_ == VAL_TYPE_OBJECT || child->type_ == VAL_TYPE_ARRAY) { val = child; ret = true; diff --git a/device/gxx-linux/usb/src/common/packet.h b/device/gxx-linux/usb/src/common/packet.h index 4b32513..3337380 100644 --- a/device/gxx-linux/usb/src/common/packet.h +++ b/device/gxx-linux/usb/src/common/packet.h @@ -120,6 +120,9 @@ enum scanner_status SCANNER_STATUS_PAPER_ASKEW, SCANNER_STATUS_FEED_FAILED, SCANNER_STATUS_NO_PAPER, + SCANNER_STATUS_STAPLE_ON, + SCANNER_STATUS_SIZE_ERR, + SCANNER_STATUS_DOGEAR, SCANNER_STATUS_CFG_CHANGED, // PACK_BASE::payload - LPCFGVAL }; diff --git a/device/gxx-linux/usb/src/common/sane_cfg.cpp b/device/gxx-linux/usb/src/common/sane_cfg.cpp index 662352c..45174e9 100644 --- a/device/gxx-linux/usb/src/common/sane_cfg.cpp +++ b/device/gxx-linux/usb/src/common/sane_cfg.cpp @@ -30,7 +30,7 @@ sane_cfg_provider::sane_cfg_provider() sane_cfg_provider::~sane_cfg_provider() {} -std::string sane_cfg_provider::sane_option_value_get(json* jsn, const char* key) +std::string sane_cfg_provider::sane_option_value_get(json* jsn, const char* key, std::string* strval) { std::string type(""), ret(""); @@ -41,22 +41,34 @@ std::string sane_cfg_provider::sane_option_value_get(json* jsn, const char* key) bool v = false; if (jsn->get_value(key, v)) ret = std::string((char*)&v, sizeof(v)); + if(strval) + *strval = v ? "true" : "false"; } else if (type == "int") { - int v = false; + int v = 0; if (jsn->get_value(key, v)) ret = std::string((char*)&v, sizeof(v)); + if(strval) + *strval = std::to_string(v); } else if (type == "float") { double v = false; if (jsn->get_value(key, v)) - ret = std::string((char*)&v, sizeof(v)); + ret = std::string((char*)&v, sizeof(v)); + if(strval) + { + char buf[80] = {0}; + sprintf(buf, "%f", v); + *strval = buf; + } } else { jsn->get_value(key, ret); + if(strval) + *strval = ret; } } @@ -281,19 +293,19 @@ int sane_cfg_mgr::unreg_sane_provider(sane_cfg_provider* prvd) } // following APIs' parameters are same as sane_cfg_provider ... -int32_t sane_cfg_mgr::get_config(std::string& text, const char* cfg_name) +int32_t sane_cfg_mgr::get_config(std::string& text, const char* cfg_name, std::string* str) { if (cfg_name) { if (*cfg_name && cfg_api_.count(cfg_name)) { size_t len = 0; - int32_t err = cfg_api_[cfg_name].prvd->get_config(nullptr, &len, cfg_name); + int32_t err = cfg_api_[cfg_name].prvd->get_config(nullptr, &len, cfg_name, str); if (err == ENOMEM) { text.resize(len + 1); - err = cfg_api_[cfg_name].prvd->get_config(&text[0], &len, cfg_name); + err = cfg_api_[cfg_name].prvd->get_config(&text[0], &len, cfg_name, str); text.resize(len); } diff --git a/device/gxx-linux/usb/src/common/sane_cfg.h b/device/gxx-linux/usb/src/common/sane_cfg.h index e38fb06..31ceab6 100644 --- a/device/gxx-linux/usb/src/common/sane_cfg.h +++ b/device/gxx-linux/usb/src/common/sane_cfg.h @@ -43,7 +43,7 @@ protected: virtual ~sane_cfg_provider(); public: - static std::string sane_option_value_get(json* jsn, const char* key = "cur"/*cur, default*/); + static std::string sane_option_value_get(json* jsn, const char* key = "cur"/*cur, default*/, std::string* strval = nullptr/*convert value into string*/); static bool sane_option_value_set(json* jsn, void* data, const char* key = "cur"/*cur, default*/); public: @@ -56,11 +56,13 @@ public: // cfg_name - given configuration name, if set, put current value of the configuration in 'buf', // or put all configurations JSON text in 'buf' if was nullptr. refer to SANE-config // + // strval - to receive string format value + // // Return: 0 - on success // EINVAL - if paramter 'len' was nullptr // ENOMEM - if size of 'buf' was too small, the minimum size needed is stored in 'len' // ENOENT - the configuration named 'cfg_name' has not found - virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr) = 0; + virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) = 0; // Function: set value of configuration named 'cfg_name' // @@ -110,7 +112,7 @@ public: int unreg_sane_provider(sane_cfg_provider* prvd); // return 0, ENOENT // following APIs' parameters are same as sane_cfg_provider ... - int32_t get_config(std::string& text, const char* cfg_name = nullptr); + int32_t get_config(std::string& text, const char* cfg_name = nullptr, std::string* str = nullptr); int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo); }; @@ -123,7 +125,7 @@ protected: ~hardware(); public: - virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr) override; + virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* str = nullptr) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; }; @@ -138,7 +140,7 @@ protected: ~img_processor(); public: - virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr) override; + virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* str = nullptr) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; }; diff --git a/device/gxx-linux/usb/src/common/sys_util.cpp b/device/gxx-linux/usb/src/common/sys_util.cpp index e06b2d1..3bcd0a1 100644 --- a/device/gxx-linux/usb/src/common/sys_util.cpp +++ b/device/gxx-linux/usb/src/common/sys_util.cpp @@ -321,6 +321,41 @@ namespace sys_util return 0; } + std::string get_memory_usage(const char* prog_name) + { + std::string val(get_command_output((std::string("ps -Al | grep ") + prog_name).c_str())); + + if(val.length()) + { + int cnt = 0; + bool space = false; + for(int i = 0; i < val.length(); ++i) + { + if(val[i] == ' ') + { + if(!space) + { + space = true; + cnt++; + } + } + else + { + space = false; + if(cnt == 9) // this value is unreliable ... + { + val.erase(0, i); + cnt = val.find(" "); + if((size_t)cnt != std::string::npos) + val.erase(cnt); + break; + } + } + } + } + + return val; + } std::string format_readable_bytes(uint64_t bytes) { std::string str("\0", 80); diff --git a/device/gxx-linux/usb/src/common/sys_util.h b/device/gxx-linux/usb/src/common/sys_util.h index b89c9e4..4b2cac3 100644 --- a/device/gxx-linux/usb/src/common/sys_util.h +++ b/device/gxx-linux/usb/src/common/sys_util.h @@ -65,6 +65,7 @@ namespace sys_util } int32_t get_memory_info(uint64_t* total, uint64_t* available); + std::string get_memory_usage(const char* prog_name); // return output of command "ps -Al | grep prog_name" std::string format_readable_bytes(uint64_t bytes); // convert to readable text: 512B, 1.21KB, 1.10MB, 3.45GB, 1,234.56GB ... std::string get_command_output(const char* cmd, uint16_t max_line_len = 256, bool one_line = true); int get_disk_size(const char* path, uint64_t* total, uint64_t* avail, uint64_t* block_size); diff --git a/device/gxx-linux/usb/src/common/usb_io.cpp b/device/gxx-linux/usb/src/common/usb_io.cpp index 766db8e..1917405 100644 --- a/device/gxx-linux/usb/src/common/usb_io.cpp +++ b/device/gxx-linux/usb/src/common/usb_io.cpp @@ -43,12 +43,19 @@ usb_gadget* usb_gadget_config::get_config(void) } +static void print_mem_usage(const char* tips) +{ + std::string size(sys_util::get_memory_usage("scan")); + printf("\n--Memory usage of %s: %s--\n", tips, size.c_str()); +} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // async_usb_gadget async_usb_gadget::async_usb_gadget(usb_gadget* gadget, std::function unhandled_ep0 - , std::function cmd_handler) - : gadget_(gadget), unhandled_ep0_(unhandled_ep0), handle_cmd_(cmd_handler), threads_(new thread_pool(this)) + , std::function cmd_handler + , std::function dev_conn) + : gadget_(gadget), unhandled_ep0_(unhandled_ep0), handle_cmd_(cmd_handler), dev_connect_(dev_conn) + , threads_(new thread_pool(this)) , enc_head_(ENCRYPT_CMD_NONE), enc_payload_(ENCRYPT_NONE), enc_data_(0) { wait_ep0_ = new linux_event("wait_ep0"); @@ -56,8 +63,11 @@ async_usb_gadget::async_usb_gadget(usb_gadget* gadget, std::functionthread_new(&async_usb_gadget::thread_pump_task); + print_mem_usage("thread_new(&async_usb_gadget::thread_pump_task)"); thread_ep0_id_ = threads_->thread_new(&async_usb_gadget::thread_read_ep0); + print_mem_usage("thread_new(&async_usb_gadget::thread_read_ep0)"); threads_->thread_new(&async_usb_gadget::thread_check_ep0_status); + print_mem_usage("thread_new(&async_usb_gadget::thread_check_ep0_status)"); } async_usb_gadget::~async_usb_gadget() @@ -125,23 +135,27 @@ int async_usb_gadget::open_bulk(void) if (gadget_->ep_handles[EP_DESCRIPTOR_IN] < 0) { gadget_->ep_handles[EP_DESCRIPTOR_IN] = open(gadget_->ep_path[EP_DESCRIPTOR_IN], O_RDWR); + print_mem_usage("open_bulk_in"); err = gadget_->ep_handles[EP_DESCRIPTOR_IN] == -1 ? errno : 0; log_cls::log(LOG_LEVEL_ALL, "Open endpoint(%s) = %d (err = %d)\n", gadget_->ep_path[EP_DESCRIPTOR_IN], gadget_->ep_handles[EP_DESCRIPTOR_IN], err); if(gadget_->ep_handles[EP_DESCRIPTOR_IN] >= 0) { status_.in_status = BULK_STATUS_IDLE; thread_bulk_in_id_ = threads_->thread_new(&async_usb_gadget::thread_write_bulk); + print_mem_usage("thread_new(&async_usb_gadget::thread_write_bulk)"); } } if (gadget_->ep_handles[EP_DESCRIPTOR_OUT] < 0) { gadget_->ep_handles[EP_DESCRIPTOR_OUT] = open(gadget_->ep_path[EP_DESCRIPTOR_OUT], O_RDWR); + print_mem_usage("open_bulk_out"); err = gadget_->ep_handles[EP_DESCRIPTOR_OUT] == -1 ? errno : 0; log_cls::log(LOG_LEVEL_ALL, "Open endpoint(%s) = %d (err = %d)\n", gadget_->ep_path[EP_DESCRIPTOR_OUT], gadget_->ep_handles[EP_DESCRIPTOR_OUT], err); if(gadget_->ep_handles[EP_DESCRIPTOR_OUT] >= 0) { status_.out_status = BULK_STATUS_IDLE; thread_bulk_out_id_ = threads_->thread_new(&async_usb_gadget::thread_read_bulk); + print_mem_usage("thread_new(&async_usb_gadget::thread_read_bulk)"); } } @@ -225,11 +239,15 @@ int async_usb_gadget::handle_ctrl_message(dyn_mem_ptr data) if (gadget_->ep_handles[EP_DESCRIPTOR_IN] < 0) { open_bulk(); + print_mem_usage("open_bulk"); + dev_connect_(true); } break; case FUNCTIONFS_DISABLE: log_cls::log(LOG_LEVEL_ALL, "EP0 FFS DISABLE\n"); + dev_connect_(false); close_bulk(); + print_mem_usage("close_bulk"); break; case FUNCTIONFS_SETUP: // log_cls::log(LOG_LEVEL_ALL, "%s: control(type-%x, req-%x, ind-%x, val-%x, len-%x)\n", chronograph::now().c_str() @@ -364,8 +382,6 @@ int async_usb_gadget::inner_write_bulk(data_source_ptr data, int* err) ptr = buf->ptr(); off = 0; w = write(gadget_->ep_handles[EP_DESCRIPTOR_IN], ptr + off, len); - if(w > 0 && w + off == len) - status_.bytes_to_sent -= w; while(!reset_bulk_ && w > 0 && w + off < len) { status_.bytes_to_sent -= w; @@ -378,10 +394,14 @@ int async_usb_gadget::inner_write_bulk(data_source_ptr data, int* err) { if(err) *err = errno; - break; + log_cls::log(LOG_LEVEL_ALL, "inner_write_bulk error(%d/%d): %d (%s)\n", off, len, errno, strerror(errno)); + break; } else + { + status_.bytes_to_sent -= w; total += w; + } if(data->get_rest() == 0) break; @@ -389,7 +409,7 @@ int async_usb_gadget::inner_write_bulk(data_source_ptr data, int* err) } buf->release(); off = total; - log_cls::log(LOG_LEVEL_ALL, "Finished in send large content with %u bytes.\n", total); + log_cls::log(LOG_LEVEL_ALL, "Finished in sending large content with %u bytes.\n", total); } return off; @@ -742,7 +762,7 @@ void async_usb_gadget::thread_pump_task(void) BASE_PACKET_REPLY(*pack, dh->get_packet_command() + 1, dh->get_packet_id(), err); reply->set_len(sizeof(PACK_BASE)); - log_cls::log(LOG_LEVEL_ALL, "Finished received file with error(Max queue size is %u): %d, total size = 0x%x\n", max_que, err, total_size); + log_cls::log(LOG_LEVEL_ALL, "Finished receiving file with error(Max queue size is %u): %d, total size = 0x%x\n", max_que, err, total_size); dh->release(); dh = nullptr; diff --git a/device/gxx-linux/usb/src/common/usb_io.h b/device/gxx-linux/usb/src/common/usb_io.h index 261516c..01180d6 100644 --- a/device/gxx-linux/usb/src/common/usb_io.h +++ b/device/gxx-linux/usb/src/common/usb_io.h @@ -103,6 +103,7 @@ class async_usb_gadget : public refer std::function unhandled_ep0_; std::function handle_cmd_; + std::function dev_connect_; const char* ep0_status_desc(int ep0_status, char* unk_buf/*>= 40 bytes*/); void set_ep0_status(uint32_t id, int status, int data); @@ -126,7 +127,8 @@ class async_usb_gadget : public refer public: async_usb_gadget(usb_gadget* gadget, std::function unhandled_ep0 = std::function() - , std::function cmd_handler = std::function()); + , std::function cmd_handler = std::function() + , std::function dev_conn = std::function()); protected: ~async_usb_gadget(); diff --git a/device/gxx-linux/usb/src/usbdevice.cpp b/device/gxx-linux/usb/src/usbdevice.cpp index 13780a6..0875e6d 100644 --- a/device/gxx-linux/usb/src/usbdevice.cpp +++ b/device/gxx-linux/usb/src/usbdevice.cpp @@ -11,9 +11,11 @@ #include #include -#ifdef ASYNC_EP #include "log_util.h" +#ifdef ASYNC_EP +#include "common/sys_util.h" #include "common/json/json.h" +#include "commondef.h" #endif #define CONFIG_VALUE 1 @@ -312,6 +314,14 @@ void UsbDevice::fill_dev_descriptor(camtp_ctx * ctx, usb_gadget * usbctx,struct return; } +#ifdef ASYNC_EP +static void print_mem_usage(const char* desc) +{ + std::string size(sys_util::get_memory_usage("scan")); + + printf("\n--Memory usage of %s: %s--\n", desc, size.c_str()); +} +#endif UsbDevice::UsbDevice(std::function handler, std::function call_back) : b_connected(false) , connect_call(call_back) @@ -321,9 +331,14 @@ UsbDevice::UsbDevice(std::function dyn_mem_ptr { @@ -343,16 +358,20 @@ UsbDevice::UsbDevice(std::function *t = new thread_pool(this); + print_mem_usage("new thread_pool"); t->thread_new(&UsbDevice::do_system_command, R"(echo linaro | sudo -S sh -c "echo fe900000.dwc3 > /opt/cfg/usb_gadget/g1/UDC")"); camtp_load_config_file(camtp_context.get(), ""); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); + // std::this_thread::sleep_for(std::chrono::milliseconds(50)); usb_ctx = init_usb_camtp_gadget(camtp_context.get()); + print_mem_usage("init_usb_camtp_gadget"); if(usb_ctx && usb_ctx->usb_device >= 0) { get_system_output(R"(echo linaro | sudo -S sh -c "chmod 777 /dev/ffs-camtp -R")"); init_eps(usb_ctx, camtp_context->usb_cfg.usb_functionfs_mode, false); + print_mem_usage("init_eps"); - usb_ = new async_usb_gadget(usb_ctx, ctrl_unhandle, bulk_handle); + usb_ = new async_usb_gadget(usb_ctx, ctrl_unhandle, bulk_handle, call_back); + print_mem_usage("new async_usb_gadget"); } t->thread_stop(); t->release(); @@ -362,7 +381,6 @@ UsbDevice::UsbDevice(std::function /opt/cfg/usb_gadget/g1/UDC")"); - ctrl_handler = handler; } @@ -1362,12 +1380,12 @@ init_eps_error: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // #ifdef ASYNC_EP -#include "common/sys_util.h" -//static std::string img_opt1("{\"is-multiout\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\",\"desc\":\"\\u540c\\u65f6\\u8f93\\u51fa\\u591a\\u79cd\\u989c\\u8272\\u6a21\\u5f0f\\u7684\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"multiout-type\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\\u7c7b\\u578b\",\"desc\":\"\\u9009\\u62e9\\u591a\\u6d41\\u8f93\\u51fa\\u7684\\u7c7b\\u578b\",\"type\":\"string\",\"cur\":\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"default\":\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"size\":32,\"range\":[\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"\\u5f69\\u8272+\\u7070\\u5ea6\",\"\\u5f69\\u8272+\\u9ed1\\u767d\",\"\\u7070\\u5ea6+\\u9ed1\\u767d\"],\"depend_or\":[\"is-multiout==true\"]},\"mode\":{\"category\":\"base\",\"readonly\":false,\"affect\":6,\"group\":\"base\",\"visible\":true,\"field\":\"Hardware\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u989c\\u8272\\u6a21\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u8272\\u5f69\\u6a21\\u5f0f\",\"type\":\"string\",\"cur\":\"24\\u4f4d\\u5f69\\u8272\",\"default\":\"24\\u4f4d\\u5f69\\u8272\",\"size\":32,\"range\":[\"24\\u4f4d\\u5f69\\u8272\",\"256\\u7ea7\\u7070\\u5ea6\",\"\\u9ed1\\u767d\",\"\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"],\"depend_or\":[\"is-multiout!=true\"]},\"binary-threshold\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u9608\\u503c\",\"desc\":\"\\u9ad8\\u4e8e\\u8be5\\u9608\\u503c\\u4e3a1\\u767d\\u4f4e\\u4e8e\\u8be5\\u9608\\u503c\\u4e3a0\\u9ed1\",\"type\":\"int\",\"cur\":127,\"default\":127,\"size\":4,\"range\":{\"min\":0,\"max\":255,\"step\":1},\"depend_or\":[\"is-multiout==true\",\"mode==\\u9ed1\\u767d\"]},\"reverse-bw\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u53cd\\u8272\\u8f93\\u51fa\",\"desc\":\"\\u8f93\\u51fa\\u7684\\u9ed1\\u767d\\u56fe\\u50cf\\u4ee51\\u4ee3\\u8868\\u9ed1\\u82720\\u4ee3\\u8868\\u767d\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"is-multiout==true\",\"mode==\\u9ed1\\u767d\"]},\"filter\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u7070\\u5ea6\\u6216\\u9ed1\\u767d\\u56fe\\u50cf - \\u9664\\u8272\\u4e0e\\u589e\\u5f3a\",\"desc\":\"\\u6d88\\u9664\\u6216\\u589e\\u5f3a\\u6307\\u5b9a\\u8272\\u5f69\",\"type\":\"string\",\"cur\":\"\\u4e0d\\u9664\\u8272\",\"default\":\"\\u4e0d\\u9664\\u8272\",\"size\":24,\"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_and\":[\"is-multiout!=true\",\"mode!=24\\u4f4d\\u5f69\\u8272\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-multiout-red\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u591a\\u6d41\\u8f93\\u51fa\\u9664\\u7ea2\",\"desc\":\"\\u540c\\u65f6\\u8f93\\u51fa\\u5f69\\u8272\\u56fe\\u50cf\\u548c\\u7070\\u5ea6\\u9664\\u7ea2\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-answer-sheet-red\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u7b54\\u9898\\u5361\\u9664\\u7ea2\",\"desc\":\"\\u8f93\\u51fa\\u9664\\u7ea2\\u5f69\\u8272\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-erase-bkg\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u80cc\\u666f\\u79fb\\u9664\",\"desc\":\"\\u79fb\\u9664\\u6587\\u7a3f\\u80cc\\u666f\\u5e95\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"bkg-color-range\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u80cc\\u666f\\u8272\\u5f69\\u6d6e\\u52a8\\u8303\\u56f4\",\"desc\":\"\\u4e0e\\u80cc\\u666f\\u5e95\\u8272\\u504f\\u5dee\\u5728\\u8be5\\u503c\\u8303\\u56f4\\u5185\\u7684\\u989c\\u8272\\u90fd\\u5c06\\u88ab\\u79fb\\u9664\",\"type\":\"int\",\"cur\":20,\"default\":20,\"size\":4,\"range\":{\"min\":1,\"max\":128,\"step\":1},\"depend_or\":[\"is-erase-bkg==true\"]},\"sharpen\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9510\\u5316\\u4e0e\\u6a21\\u7cca\",\"desc\":\"\\u9009\\u62e9\\u9510\\u5316\\u6548\\u679c\\u6216\\u6a21\\u7cca\\u6548\\u679c\",\"type\":\"string\",\"cur\":\"\\u65e0\",\"default\":\"\\u65e0\",\"size\":24,\"range\":[\"\\u65e0\",\"\\u9510\\u5316\",\"\\u8fdb\\u4e00\\u6b65\\u9510\\u5316\",\"\\u6a21\\u7cca\",\"\\u8fdb\\u4e00\\u6b65\\u6a21\\u7cca\"],\"depend_and\":[\"is-multiout!=true\",\"mode!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-morr\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u53bb\\u9664\\u6469\\u5c14\\u7eb9\",\"desc\":\"\\u53bb\\u9664\\u56fe\\u50cf\\u4e2d\\u7684\\u6469\\u5c14\\u7eb9\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-grid\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9664\\u7f51\\u7eb9\",\"desc\":\"\\u53bb\\u9664\\u56fe\\u50cf\\u4e2d\\u7684\\u7f51\\u7eb9\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-err-extension\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9519\\u8bef\\u6269\\u6563\",\"desc\":\"\\u4ee5\\u70b9\\u9635\\u5f62\\u5f0f\\u6784\\u5efa\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"mode==\\u9ed1\\u767d\"]},\"is-noise-optimize\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u566a\\u70b9\\u4f18\\u5316\",\"desc\":\"\\u53bb\\u9664\\u56fe\\u50cf\\u4e2d\\u7684\\u5b64\\u7acb\\u9ed1\\u70b9\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"mode==\\u9ed1\\u767d\"]},\"noise-size\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u566a\\u70b9\\u4f18\\u5316\\u5c3a\\u5bf8\",\"desc\":\"\\u8bbe\\u7f6e\\u9700\\u8981\\u53bb\\u9664\\u7684\\u9ed1\\u8272\\u5b64\\u7acb\\u70b9\\u7684\\u8fde\\u901a\\u4e2a\\u6570\",\"type\":\"int\",\"cur\":30,\"default\":30,\"size\":4,\"range\":{\"min\":10,\"max\":50,\"step\":1},\"depend_or\":[\"is-noise-optimize==true\"]},\"blank-sensitivity\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u7075\\u654f\\u5ea6\",\"desc\":\"\\u6570\\u503c\\u8d8a\\u5927\\u5219\\u8d8a\\u5bb9\\u6613\\u8df3\\u8fc7\",\"type\":\"int\",\"cur\":50,\"default\":50,\"size\":4,\"range\":{\"min\":1,\"max\":100,\"step\":1},\"depend_or\":[\"page==\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u901a\\u7528\",\"==\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u53d1\\u7968\\u7eb8\"]},\"fold-type\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5bf9\\u6298\\u6a21\\u5f0f\",\"desc\":\"\",\"type\":\"string\",\"cur\":\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"default\":\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"size\":50,\"range\":[\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"\\u4e0a\\u4e0b\\u5bf9\\u6298\",\"\\u81ea\\u52a8\\u5bf9\\u6298\"],\"depend_or\":[\"page==\\u5bf9\\u6298\"]},\"is-exchange\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u4ea4\\u6362\\u6b63\\u53cd\\u9762\",\"desc\":\"\\u4ea4\\u6362\\u6bcf\\u5f20\\u6587\\u7a3f\\u7684\\u6b63\\u53cd\\u9762\\u51fa\\u56fe\\u987a\\u5e8f\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5355\\u9762\"]},\"is-custom-gamma\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"light\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u542f\\u7528\\u8272\\u8c03\\u66f2\\u7ebf\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u56fe\\u50cf\\u8272\\u8c03\\u6548\\u679c\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},"); -//static std::string img_opt2("\"brightness\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"light\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u4eae\\u5ea6\\u503c\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u4eae\\u5ea6\",\"type\":\"int\",\"cur\":128,\"default\":128,\"size\":4,\"range\":{\"min\":1,\"max\":255,\"step\":1},\"depend_and\":[\"is-custom-gamma==false\"]},\"contrast\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"light\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5bf9\\u6bd4\\u5ea6\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u5bf9\\u6bd4\\u5ea6\",\"type\":\"int\",\"cur\":4,\"default\":4,\"size\":4,\"range\":{\"min\":1,\"max\":7,\"step\":1},\"depend_and\":[\"is-custom-gamma==false\"]},\"gamma\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"light\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u4f3d\\u9a6c\\u503c\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u4f3d\\u739b\\u503c\",\"type\":\"float\",\"cur\":1.000000,\"default\":1.000000,\"size\":4,\"range\":{\"min\":0.010000,\"max\":5.000000,\"step\":0.499000},\"depend_and\":[\"is-custom-gamma==false\"]},\"color-correction\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u8272\\u504f\\u6821\\u6b63\",\"desc\":\"\\u8272\\u5f69\\u8fd8\\u539f\\u5ea6\\u77eb\\u6b63\\u529f\\u80fd\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"is-anti-skew\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u81ea\\u52a8\\u7ea0\\u504f\",\"desc\":\"\\u81ea\\u52a8\\u7ea0\\u6b63\\u6b6a\\u659c\\u9001\\u5165\\u7684\\u6587\\u7a3f\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4,\"depend_or\":[\"page!=\\u5bf9\\u6298\"]},\"is-split\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u56fe\\u50cf\\u62c6\\u5206\",\"desc\":\"\\u81ea\\u52a8\\u62c6\\u5206\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5bf9\\u6298\",\"!=\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u53d1\\u7968\\u7eb8\",\"!=\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u901a\\u7528\"]},\"is-erase-black-frame\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u6d88\\u9664\\u9ed1\\u6846\",\"desc\":\"\\u6d88\\u9664\\u6587\\u7a3f\\u8303\\u56f4\\u5916\\u7684\\u9ed1\\u8272\\u80cc\\u666f\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"bkg-fill-mode\":{\"category\":\"advanced\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\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\":[\"is-erase-black-frame==true\"]},\"is-fill-color\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u8272\\u5f69\\u586b\\u5145\",\"desc\":\"\\u542f\\u7528\\u540e\\u9ed1\\u6846\\u90e8\\u5206\\u5c06\\u586b\\u5145\\u4e3a\\u6587\\u7a3f\\u5e95\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-erase-black-frame==true\"]},\"threshold\":{\"category\":\"advanced\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9608\\u503c\",\"desc\":\"\\u6587\\u7a3f\\u5e95\\u8272\\u4e0e\\u9ed1\\u8272\\u80cc\\u666f\\u7070\\u5ea6\\u503c\\u7684\\u5dee\\u503c\\u5927\\u4e8e\\u8be5\\u503c\\u624d\\u4f1a\\u88ab\\u8bc6\\u522b\\u4e3a\\u6587\\u7a3f\",\"type\":\"int\",\"cur\":40,\"default\":40,\"size\":4,\"range\":{\"min\":30,\"max\":50,\"step\":1},\"depend_or\":[\"is-erase-black-frame==true\",\"paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"is-anti-skew==true\"]},\"anti-noise-level\":{\"category\":\"advanced\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u80cc\\u666f\\u6297\\u566a\\u7b49\\u7ea7\",\"desc\":\"\\u80fd\\u591f\\u5bb9\\u5fcd\\u7684\\u80cc\\u666f\\u6742\\u8272\\u6761\\u7eb9\\u7684\\u5bbd\\u5ea6\",\"type\":\"int\",\"cur\":8,\"default\":8,\"size\":4,\"range\":{\"min\":1,\"max\":20,\"step\":1},\"depend_or\":[\"is-erase-black-frame==true\",\"paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"is-anti-skew==true\"]},\"margin\":{\"category\":\"advanced\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"desc\":\"\\u5bfb\\u627e\\u6587\\u7a3f\\u8fb9\\u7f18\\u65f6\\u5bf9\\u8fb9\\u7f18\\u7684\\u4fb5\\u5165\\u7a0b\\u5ea6\",\"type\":\"int\",\"cur\":5,\"default\":5,\"size\":4,\"range\":{\"min\":5,\"max\":30,\"step\":1},\"depend_or\":[\"is-erase-black-frame==true\",\"paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"is-anti-skew==true\"]},\"is-dark-sample\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u6df1\\u8272\\u6837\\u5f20\",\"desc\":\"\\u542f\\u7528\\u8be5\\u6a21\\u5f0f\\u9632\\u6b62\\u6df1\\u8272\\u5e95\\u8272\\u7684\\u6587\\u7a3f\\u56fe\\u50cf\\u88ab\\u8bef\\u5904\\u7406\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5bf9\\u6298\",\"is-erase-black-frame!=true\",\"paper!=\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"is-anti-skew!=true\"]},\"is-anti-permeate\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9632\\u6b62\\u6e17\\u900f\",\"desc\":\"\\u9632\\u6b62\\u80cc\\u9762\\u56fe\\u6848\\u6e17\\u900f\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"permeate-level\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u9632\\u6b62\\u6e17\\u900f\\u7b49\\u7ea7\",\"desc\":\"\\u9009\\u62e9\\u9632\\u6b62\\u6e17\\u900f\\u7684\\u7b49\\u7ea7\",\"type\":\"string\",\"cur\":\"\\u8f83\\u5f31\",\"default\":\"\\u8f83\\u5f31\",\"size\":16,\"range\":[\"\\u5f31\",\"\\u8f83\\u5f31\",\"\\u4e00\\u822c\",\"\\u8f83\\u5f3a\",\"\\u5f3a\"],\"depend_or\":[\"is-anti-permeate==true\"]},\"is-rid-hole-l\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u5de6\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u4e0a\\u7684\\u5de6\\u4fa7\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-l\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u5de6\\u4fa7\\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.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-l==true\"]},\"is-rid-hole-r\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u53f3\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u4e0a\\u7684\\u53f3\\u4fa7\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-r\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u53f3\\u4fa7\\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.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-r==true\"]},\"is-rid-hole-t\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u4e0a\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u7684\\u4e0a\\u90e8\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-t\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u4e0a\\u4fa7\\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.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-t==true\"]},\"is-rid-hole-b\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u4e0b\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u7684\\u4e0b\\u90e8\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-b\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u4e0b\\u4fa7\\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.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-b==true\"]},\"direction\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u6587\\u7a3f\\u65b9\\u5411\",\"desc\":\"\\u8bbe\\u7f6e\\u56fe\\u50cf\\u7684\\u65b9\\u5411\",\"type\":\"string\",\"cur\":\"0\",\"default\":\"0\",\"size\":40,\"range\":[\"0\",\"90\",\"180\",\"-90\",\"\\u81ea\\u52a8\\u6587\\u672c\\u65b9\\u5411\\u8bc6\\u522b\"]},\"is-rotate-bkg-180\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u80cc\\u9762\\u65cb\\u8f6c180\",\"desc\":\"\\u80cc\\u9762\\u626b\\u63cf\\u7684\\u56fe\\u50cf\\u65cb\\u8f6c180\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5355\\u9762\",\"!=\\u5bf9\\u6298\",\"direction!=\\u81ea\\u52a8\\u6587\\u672c\\u65b9\\u5411\\u8bc6\\u522b\"]}}"); +// C2-B0-AF-79-75-D6 +//static std::string img_opt1("{\"is-multiout\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\",\"desc\":\"\\u540c\\u65f6\\u8f93\\u51fa\\u591a\\u79cd\\u989c\\u8272\\u6a21\\u5f0f\\u7684\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"multiout-type\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\\u7c7b\\u578b\",\"desc\":\"\\u9009\\u62e9\\u591a\\u6d41\\u8f93\\u51fa\\u7684\\u7c7b\\u578b\",\"type\":\"string\",\"cur\":\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"default\":\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"size\":32,\"range\":[\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"\\u5f69\\u8272+\\u7070\\u5ea6\",\"\\u5f69\\u8272+\\u9ed1\\u767d\",\"\\u7070\\u5ea6+\\u9ed1\\u767d\"],\"depend_or\":[\"is-multiout==true\"]},\"mode\":{\"category\":\"base\",\"readonly\":false,\"affect\":6,\"group\":\"base\",\"visible\":true,\"field\":\"Hardware\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u989c\\u8272\\u6a21\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u8272\\u5f69\\u6a21\\u5f0f\",\"type\":\"string\",\"cur\":\"24\\u4f4d\\u5f69\\u8272\",\"default\":\"24\\u4f4d\\u5f69\\u8272\",\"size\":32,\"range\":[\"24\\u4f4d\\u5f69\\u8272\",\"256\\u7ea7\\u7070\\u5ea6\",\"\\u9ed1\\u767d\",\"\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"],\"depend_or\":[\"is-multiout!=true\"]},\"binary-threshold\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u9608\\u503c\",\"desc\":\"\\u9ad8\\u4e8e\\u8be5\\u9608\\u503c\\u4e3a1��\\u767d����\\u4f4e\\u4e8e\\u8be5\\u9608\\u503c\\u4e3a0��\\u9ed1��\",\"type\":\"int\",\"cur\":127,\"default\":127,\"size\":4,\"range\":{\"min\":0,\"max\":255,\"step\":1},\"depend_or\":[\"is-multiout==true\",\"mode==\\u9ed1\\u767d\"]},\"reverse-bw\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u53cd\\u8272\\u8f93\\u51fa\",\"desc\":\"\\u8f93\\u51fa\\u7684\\u9ed1\\u767d\\u56fe\\u50cf\\u4ee5��1��\\u4ee3\\u8868\\u9ed1\\u8272����0��\\u4ee3\\u8868\\u767d\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"is-multiout==true\",\"mode==\\u9ed1\\u767d\"]},\"filter\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u7070\\u5ea6\\u6216\\u9ed1\\u767d\\u56fe\\u50cf - \\u9664\\u8272\\u4e0e\\u589e\\u5f3a\",\"desc\":\"\\u6d88\\u9664\\u6216\\u589e\\u5f3a\\u6307\\u5b9a\\u8272\\u5f69\",\"type\":\"string\",\"cur\":\"\\u4e0d\\u9664\\u8272\",\"default\":\"\\u4e0d\\u9664\\u8272\",\"size\":24,\"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_and\":[\"is-multiout!=true\",\"mode!=24\\u4f4d\\u5f69\\u8272\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-multiout-red\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u591a\\u6d41\\u8f93\\u51fa\\u9664\\u7ea2\",\"desc\":\"\\u540c\\u65f6\\u8f93\\u51fa\\u5f69\\u8272\\u56fe\\u50cf\\u548c\\u7070\\u5ea6\\u9664\\u7ea2\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-answer-sheet-red\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u7b54\\u9898\\u5361\\u9664\\u7ea2\",\"desc\":\"\\u8f93\\u51fa\\u9664\\u7ea2\\u5f69\\u8272\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-erase-bkg\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u80cc\\u666f\\u79fb\\u9664\",\"desc\":\"\\u79fb\\u9664\\u6587\\u7a3f\\u80cc\\u666f\\u5e95\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"bkg-color-range\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u80cc\\u666f\\u8272\\u5f69\\u6d6e\\u52a8\\u8303\\u56f4\",\"desc\":\"\\u4e0e\\u80cc\\u666f\\u5e95\\u8272\\u504f\\u5dee\\u5728\\u8be5\\u503c\\u8303\\u56f4\\u5185\\u7684\\u989c\\u8272��\\u90fd\\u5c06\\u88ab\\u79fb\\u9664\",\"type\":\"int\",\"cur\":20,\"default\":20,\"size\":4,\"range\":{\"min\":1,\"max\":128,\"step\":1},\"depend_or\":[\"is-erase-bkg==true\"]},\"sharpen\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9510\\u5316\\u4e0e\\u6a21\\u7cca\",\"desc\":\"\\u9009\\u62e9\\u9510\\u5316\\u6548\\u679c\\u6216\\u6a21\\u7cca\\u6548\\u679c\",\"type\":\"string\",\"cur\":\"\\u65e0\",\"default\":\"\\u65e0\",\"size\":24,\"range\":[\"\\u65e0\",\"\\u9510\\u5316\",\"\\u8fdb\\u4e00\\u6b65\\u9510\\u5316\",\"\\u6a21\\u7cca\",\"\\u8fdb\\u4e00\\u6b65\\u6a21\\u7cca\"],\"depend_and\":[\"is-multiout!=true\",\"mode!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-morr\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u53bb\\u9664\\u6469\\u5c14\\u7eb9\",\"desc\":\"\\u53bb\\u9664\\u56fe\\u50cf\\u4e2d\\u7684\\u6469\\u5c14\\u7eb9\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-grid\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9664\\u7f51\\u7eb9\",\"desc\":\"\\u53bb\\u9664\\u56fe\\u50cf\\u4e2d\\u7684\\u7f51\\u7eb9\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-err-extension\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9519\\u8bef\\u6269\\u6563\",\"desc\":\"\\u4ee5\\u70b9\\u9635\\u5f62\\u5f0f\\u6784\\u5efa\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"mode==\\u9ed1\\u767d\"]},\"is-noise-optimize\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u566a\\u70b9\\u4f18\\u5316\",\"desc\":\"\\u53bb\\u9664\\u56fe\\u50cf\\u4e2d\\u7684\\u5b64\\u7acb\\u9ed1\\u70b9\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"mode==\\u9ed1\\u767d\"]},\"noise-size\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u566a\\u70b9\\u4f18\\u5316\\u5c3a\\u5bf8\",\"desc\":\"\\u8bbe\\u7f6e\\u9700\\u8981\\u53bb\\u9664\\u7684\\u9ed1\\u8272\\u5b64\\u7acb\\u70b9\\u7684\\u8fde\\u901a\\u4e2a\\u6570\",\"type\":\"int\",\"cur\":30,\"default\":30,\"size\":4,\"range\":{\"min\":10,\"max\":50,\"step\":1},\"depend_or\":[\"is-noise-optimize==true\"]},\"blank-sensitivity\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u7075\\u654f\\u5ea6\",\"desc\":\"\\u6570\\u503c\\u8d8a\\u5927��\\u5219\\u8d8a\\u5bb9\\u6613\\u8df3\\u8fc7\",\"type\":\"int\",\"cur\":50,\"default\":50,\"size\":4,\"range\":{\"min\":1,\"max\":100,\"step\":1},\"depend_or\":[\"page==\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875��\\u901a\\u7528��\",\"==\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875��\\u53d1\\u7968\\u7eb8��\"]},\"fold-type\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5bf9\\u6298\\u6a21\\u5f0f\",\"desc\":\"\",\"type\":\"string\",\"cur\":\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"default\":\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"size\":50,\"range\":[\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"\\u4e0a\\u4e0b\\u5bf9\\u6298\",\"\\u81ea\\u52a8\\u5bf9\\u6298\"],\"depend_or\":[\"page==\\u5bf9\\u6298\"]},\"is-exchange\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u4ea4\\u6362\\u6b63\\u53cd\\u9762\",\"desc\":\"\\u4ea4\\u6362\\u6bcf\\u5f20\\u6587\\u7a3f\\u7684\\u6b63\\u53cd\\u9762\\u51fa\\u56fe\\u987a\\u5e8f\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5355\\u9762\"]},\"is-custom-gamma\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"light\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u542f\\u7528\\u8272\\u8c03\\u66f2\\u7ebf\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u56fe\\u50cf\\u8272\\u8c03\\u6548\\u679c\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},"); +//static std::string img_opt2("\"brightness\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"light\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u4eae\\u5ea6\\u503c\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u4eae\\u5ea6\",\"type\":\"int\",\"cur\":128,\"default\":128,\"size\":4,\"range\":{\"min\":1,\"max\":255,\"step\":1},\"depend_and\":[\"is-custom-gamma==false\"]},\"contrast\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"light\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5bf9\\u6bd4\\u5ea6\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u5bf9\\u6bd4\\u5ea6\",\"type\":\"int\",\"cur\":4,\"default\":4,\"size\":4,\"range\":{\"min\":1,\"max\":7,\"step\":1},\"depend_and\":[\"is-custom-gamma==false\"]},\"gamma\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"light\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u4f3d\\u9a6c\\u503c\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u4f3d\\u739b\\u503c\",\"type\":\"float\",\"cur\":1.000000,\"default\":1.000000,\"size\":4,\"range\":{\"min\":0.010000,\"max\":5.000000,\"step\":0.499000},\"depend_and\":[\"is-custom-gamma==false\"]},\"color-correction\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u8272\\u504f\\u6821\\u6b63\",\"desc\":\"\\u8272\\u5f69\\u8fd8\\u539f\\u5ea6\\u77eb\\u6b63\\u529f\\u80fd\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"is-anti-skew\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u81ea\\u52a8\\u7ea0\\u504f\",\"desc\":\"\\u81ea\\u52a8\\u7ea0\\u6b63\\u6b6a\\u659c\\u9001\\u5165\\u7684\\u6587\\u7a3f\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4,\"depend_or\":[\"page!=\\u5bf9\\u6298\"]},\"is-split\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u56fe\\u50cf\\u62c6\\u5206\",\"desc\":\"\\u81ea\\u52a8\\u62c6\\u5206\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5bf9\\u6298\",\"!=\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875��\\u53d1\\u7968\\u7eb8��\",\"!=\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875��\\u901a\\u7528��\"]},\"is-erase-black-frame\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u6d88\\u9664\\u9ed1\\u6846\",\"desc\":\"\\u6d88\\u9664\\u6587\\u7a3f\\u8303\\u56f4\\u5916\\u7684\\u9ed1\\u8272\\u80cc\\u666f\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"bkg-fill-mode\":{\"category\":\"advanced\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\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\":[\"is-erase-black-frame==true\"]},\"is-fill-color\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u8272\\u5f69\\u586b\\u5145\",\"desc\":\"\\u542f\\u7528\\u540e\\u9ed1\\u6846\\u90e8\\u5206\\u5c06\\u586b\\u5145\\u4e3a\\u6587\\u7a3f\\u5e95\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-erase-black-frame==true\"]},\"threshold\":{\"category\":\"advanced\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9608\\u503c\",\"desc\":\"\\u6587\\u7a3f\\u5e95\\u8272\\u4e0e\\u9ed1\\u8272\\u80cc\\u666f\\u7070\\u5ea6\\u503c\\u7684\\u5dee\\u503c\\u5927\\u4e8e\\u8be5\\u503c��\\u624d\\u4f1a\\u88ab\\u8bc6\\u522b\\u4e3a\\u6587\\u7a3f\",\"type\":\"int\",\"cur\":40,\"default\":40,\"size\":4,\"range\":{\"min\":30,\"max\":50,\"step\":1},\"depend_or\":[\"is-erase-black-frame==true\",\"paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"is-anti-skew==true\"]},\"anti-noise-level\":{\"category\":\"advanced\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u80cc\\u666f\\u6297\\u566a\\u7b49\\u7ea7\",\"desc\":\"\\u80fd\\u591f\\u5bb9\\u5fcd\\u7684\\u80cc\\u666f\\u6742\\u8272\\u6761\\u7eb9\\u7684\\u5bbd\\u5ea6\",\"type\":\"int\",\"cur\":8,\"default\":8,\"size\":4,\"range\":{\"min\":1,\"max\":20,\"step\":1},\"depend_or\":[\"is-erase-black-frame==true\",\"paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"is-anti-skew==true\"]},\"margin\":{\"category\":\"advanced\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"desc\":\"\\u5bfb\\u627e\\u6587\\u7a3f\\u8fb9\\u7f18\\u65f6\\u5bf9\\u8fb9\\u7f18\\u7684\\u4fb5\\u5165\\u7a0b\\u5ea6\",\"type\":\"int\",\"cur\":5,\"default\":5,\"size\":4,\"range\":{\"min\":5,\"max\":30,\"step\":1},\"depend_or\":[\"is-erase-black-frame==true\",\"paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"is-anti-skew==true\"]},\"is-dark-sample\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u6df1\\u8272\\u6837\\u5f20\",\"desc\":\"\\u542f\\u7528\\u8be5\\u6a21\\u5f0f\\u9632\\u6b62\\u6df1\\u8272\\u5e95\\u8272\\u7684\\u6587\\u7a3f\\u56fe\\u50cf\\u88ab\\u8bef\\u5904\\u7406\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5bf9\\u6298\",\"is-erase-black-frame!=true\",\"paper!=\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"is-anti-skew!=true\"]},\"is-anti-permeate\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u9632\\u6b62\\u6e17\\u900f\",\"desc\":\"\\u9632\\u6b62\\u80cc\\u9762\\u56fe\\u6848\\u6e17\\u900f\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"permeate-level\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u9632\\u6b62\\u6e17\\u900f\\u7b49\\u7ea7\",\"desc\":\"\\u9009\\u62e9\\u9632\\u6b62\\u6e17\\u900f\\u7684\\u7b49\\u7ea7\",\"type\":\"string\",\"cur\":\"\\u8f83\\u5f31\",\"default\":\"\\u8f83\\u5f31\",\"size\":16,\"range\":[\"\\u5f31\",\"\\u8f83\\u5f31\",\"\\u4e00\\u822c\",\"\\u8f83\\u5f3a\",\"\\u5f3a\"],\"depend_or\":[\"is-anti-permeate==true\"]},\"is-rid-hole-l\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664��\\u5de6\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u4e0a\\u7684\\u5de6\\u4fa7\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-l\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u5de6\\u4fa7\\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.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-l==true\"]},\"is-rid-hole-r\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664��\\u53f3\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u4e0a\\u7684\\u53f3\\u4fa7\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-r\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u53f3\\u4fa7\\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.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-r==true\"]},\"is-rid-hole-t\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664��\\u4e0a\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u7684\\u4e0a\\u90e8\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-t\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u4e0a\\u4fa7\\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.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-t==true\"]},\"is-rid-hole-b\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664��\\u4e0b\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u7684\\u4e0b\\u90e8\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-b\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"imgproc\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u4e0b\\u4fa7\\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.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-b==true\"]},\"direction\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u6587\\u7a3f\\u65b9\\u5411\",\"desc\":\"\\u8bbe\\u7f6e\\u56fe\\u50cf\\u7684\\u65b9\\u5411\",\"type\":\"string\",\"cur\":\"0��\",\"default\":\"0��\",\"size\":40,\"range\":[\"0��\",\"90��\",\"180��\",\"-90��\",\"\\u81ea\\u52a8\\u6587\\u672c\\u65b9\\u5411\\u8bc6\\u522b��\"]},\"is-rotate-bkg-180\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u80cc\\u9762\\u65cb\\u8f6c180��\",\"desc\":\"\\u80cc\\u9762\\u626b\\u63cf\\u7684\\u56fe\\u50cf\\u65cb\\u8f6c180��\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5355\\u9762\",\"!=\\u5bf9\\u6298\",\"direction!=\\u81ea\\u52a8\\u6587\\u672c\\u65b9\\u5411\\u8bc6\\u522b��\"]}}"); // -//static std::string hardware_opt("{\"paper\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u7eb8\\u5f20\\u5c3a\\u5bf8\",\"desc\":\"\\u8bbe\\u7f6e\\u51fa\\u56fe\\u5927\\u5c0f\",\"type\":\"string\",\"cur\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"default\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"size\":48,\"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\"]},\"is-size-check\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5c3a\\u5bf8\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u7eb8\\u5f20\\u5b9e\\u9645\\u5c3a\\u5bf8\\u4e0e\\u8bbe\\u7f6e\\u662f\\u5426\\u5339\\u914d\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"paper==A3\",\"==A4\",\"==A4\\u6a2a\\u5411\",\"==A5\",\"==A5\\u6a2a\\u5411\",\"==A6\",\"==A6\\u6a2a\\u5411\",\"==B4\",\"==B5\",\"==B5\\u6a2a\\u5411\",\"==B6\",\"==B6\\u6a2a\\u5411\",\"==Double Letter\",\"==LEGAL\",\"==Letter\",\"==Letter\\u6a2a\\u5411\"]},\"resolution\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5206\\u8fa8\\u7387\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u56fe\\u50cf\\u7684\\u5206\\u8fa8\\u7387\",\"type\":\"int\",\"cur\":200,\"default\":200,\"size\":4,\"range\":{\"min\":100,\"max\":600,\"step\":1}},\"image-quality\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u753b\\u8d28\",\"desc\":\"\\u9009\\u62e9\\u626b\\u63cf\\u4eea\\u7684\\u753b\\u8d28\\u6a21\\u5f0f\",\"type\":\"string\",\"cur\":\"\\u901f\\u5ea6\\u4f18\\u5148\",\"default\":\"\\u901f\\u5ea6\\u4f18\\u5148\",\"size\":24,\"range\":[\"\\u901f\\u5ea6\\u4f18\\u5148\",\"\\u753b\\u8d28\\u4f18\\u5148\"],\"depend_or\":[\"resolution>=300\"]},\"is-wait-scan\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5f85\\u7eb8\\u626b\\u63cf\",\"desc\":\"\\u542f\\u7528\\u540e\\u6587\\u7a3f\\u653e\\u5165\\u626b\\u63cf\\u4eea\\u65f6\\u5c06\\u81ea\\u52a8\\u542f\\u52a8\\u626b\\u63cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"scan-mode\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u626b\\u63cf\\u5f20\\u6570\",\"desc\":\"\\u9009\\u62e9\\u6307\\u5b9a\\u6570\\u91cf\\u626b\\u63cf\\u6216\\u8fde\\u7eed\\u626b\\u63cf\",\"type\":\"string\",\"cur\":\"\\u8fde\\u7eed\\u626b\\u63cf\",\"default\":\"\\u8fde\\u7eed\\u626b\\u63cf\",\"size\":32,\"range\":[\"\\u8fde\\u7eed\\u626b\\u63cf\",\"\\u626b\\u63cf\\u6307\\u5b9a\\u5f20\\u6570\"],\"depend_or\":[\"is-wait-scan==false\"]},\"scan-count\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u626b\\u63cf\\u6570\\u91cf\",\"desc\":\"\\u626b\\u63cf\\u6307\\u5b9a\\u6570\\u91cf\",\"type\":\"int\",\"cur\":1,\"default\":1,\"size\":4,\"depend_or\":[\"scan-mode==\\u626b\\u63cf\\u6307\\u5b9a\\u5f20\\u6570\"]},\"is-ultrosonic\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u8d85\\u58f0\\u6ce2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u662f\\u5426\\u51fa\\u73b0\\u53cc\\u5f20\\u9001\\u5165\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"double-feed\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u53cc\\u5f20\\u56fe\\u7247\\u5904\\u7406\",\"desc\":\"\\u68c0\\u6d4b\\u5230\\u53cc\\u5f20\\u8fdb\\u7eb8\\u540e\\u7684\\u5904\\u7406\\u65b9\\u5f0f\",\"type\":\"string\",\"cur\":\"\\u4e22\\u5f03\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\",\"default\":\"\\u4e22\\u5f03\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\",\"size\":40,\"range\":[\"\\u4e22\\u5f03\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\",\"\\u4e0a\\u4f20\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\"],\"depend_or\":[\"is-ultrosonic==true\"]},\"is-staple\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u88c5\\u8ba2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u662f\\u5426\\u51fa\\u73b0\\u7c98\\u8fde\\u9001\\u5165\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"is-check-askew\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u6b6a\\u659c\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u662f\\u5426\\u51fa\\u73b0\\u6b6a\\u659c\\u9001\\u5165\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"askew-range\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u6b6a\\u659c\\u5bb9\\u5fcd\\u5ea6\",\"desc\":\"\\u503c\\u8d8a\\u5c0f\\u80fd\\u5bb9\\u5fcd\\u5f97\\u9001\\u5165\\u6587\\u7a3f\\u6b6a\\u659c\\u89d2\\u5ea6\\u8d8a\\u5c0f\",\"type\":\"int\",\"cur\":3,\"default\":3,\"size\":4,\"range\":{\"min\":1,\"max\":5,\"step\":1},\"depend_or\":[\"is-check-askew==true\"]},\"is-check-dog-ear\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u6298\\u89d2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u6587\\u7a3f\\u662f\\u5426\\u5b58\\u5728\\u6298\\u89d2\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"dog-ear-size\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u6298\\u89d2\\u5927\\u5c0f\",\"desc\":\"\\u503c\\u8d8a\\u5c0f\\u80fd\\u68c0\\u6d4b\\u5230\\u7684\\u6298\\u89d2\\u8d8a\\u5c0f\",\"type\":\"int\",\"cur\":70,\"default\":70,\"size\":4,\"range\":{\"min\":0,\"max\":100,\"step\":1},\"depend_or\":[\"is-check-dog-ear==true\"]},\"feed-strength\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5206\\u7eb8\\u5f3a\\u5ea6\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u4eea\\u7684\\u5206\\u7eb8\\u529b\\u5ea6\",\"type\":\"string\",\"cur\":\"\\u5f31\",\"default\":\"\\u5f31\",\"size\":16,\"range\":[\"\\u5f31\",\"\\u4e00\\u822c\",\"\\u5f3a\"]},\"time-to-sleep\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u4f11\\u7720\\u65f6\\u95f4\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u4eea\\u7684\\u4f11\\u7720\\u65f6\\u95f4\",\"type\":\"string\",\"cur\":\"\\u4e0d\\u4f11\\u7720\",\"default\":\"\\u4e0d\\u4f11\\u7720\",\"size\":24,\"range\":[\"\\u4e0d\\u4f11\\u7720\",\"\\u4e94\\u5206\\u949f\",\"\\u5341\\u5206\\u949f\",\"\\u534a\\u5c0f\\u65f6\",\"\\u4e00\\u5c0f\\u65f6\",\"\\u4e24\\u5c0f\\u65f6\",\"\\u56db\\u5c0f\\u65f6\"]},\"is-auto-strength\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u81ea\\u52a8\\u5206\\u7eb8\\u5f3a\\u5ea6\",\"desc\":\"\\u626b\\u63cf\\u4eea\\u81ea\\u52a8\\u4fee\\u6b63\\u5206\\u7eb8\\u529b\\u5ea6\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"feed-strength-value\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u8fdb\\u7eb8\\u5931\\u8d25\\u7387\",\"desc\":\"\\u9ad8\\u4e8e\\u8be5\\u503c\\u65f6\\u626b\\u63cf\\u4eea\\u5c06\\u8c03\\u6574\\u5206\\u7eb8\\u529b\\u5ea6\",\"type\":\"float\",\"cur\":0.100000,\"default\":0.100000,\"size\":4,\"range\":{\"min\":0.100000,\"max\":0.900000,\"step\":0.080000},\"depend_or\":[\"is-auto-strength==true\"]}}"); +//static std::string hardware_opt("{\"paper\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u7eb8\\u5f20\\u5c3a\\u5bf8\",\"desc\":\"\\u8bbe\\u7f6e\\u51fa\\u56fe\\u5927\\u5c0f\",\"type\":\"string\",\"cur\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"default\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"size\":48,\"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\"]},\"is-size-check\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5c3a\\u5bf8\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u7eb8\\u5f20\\u5b9e\\u9645\\u5c3a\\u5bf8\\u4e0e\\u8bbe\\u7f6e\\u662f\\u5426\\u5339\\u914d\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"paper==A3\",\"==A4\",\"==A4\\u6a2a\\u5411\",\"==A5\",\"==A5\\u6a2a\\u5411\",\"==A6\",\"==A6\\u6a2a\\u5411\",\"==B4\",\"==B5\",\"==B5\\u6a2a\\u5411\",\"==B6\",\"==B6\\u6a2a\\u5411\",\"==Double Letter\",\"==LEGAL\",\"==Letter\",\"==Letter\\u6a2a\\u5411\"]},\"resolution\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5206\\u8fa8\\u7387\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u56fe\\u50cf\\u7684\\u5206\\u8fa8\\u7387\",\"type\":\"int\",\"cur\":200,\"default\":200,\"size\":4,\"range\":{\"min\":100,\"max\":600,\"step\":1}},\"image-quality\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u753b\\u8d28\",\"desc\":\"\\u9009\\u62e9\\u626b\\u63cf\\u4eea\\u7684\\u753b\\u8d28\\u6a21\\u5f0f\",\"type\":\"string\",\"cur\":\"\\u901f\\u5ea6\\u4f18\\u5148\",\"default\":\"\\u901f\\u5ea6\\u4f18\\u5148\",\"size\":24,\"range\":[\"\\u901f\\u5ea6\\u4f18\\u5148\",\"\\u753b\\u8d28\\u4f18\\u5148\"],\"depend_or\":[\"resolution>=300\"]},\"is-wait-scan\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5f85\\u7eb8\\u626b\\u63cf\",\"desc\":\"\\u542f\\u7528\\u540e��\\u6587\\u7a3f\\u653e\\u5165\\u626b\\u63cf\\u4eea\\u65f6\\u5c06\\u81ea\\u52a8\\u542f\\u52a8\\u626b\\u63cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"scan-mode\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u626b\\u63cf\\u5f20\\u6570\",\"desc\":\"\\u9009\\u62e9\\u6307\\u5b9a\\u6570\\u91cf\\u626b\\u63cf\\u6216\\u8fde\\u7eed\\u626b\\u63cf\",\"type\":\"string\",\"cur\":\"\\u8fde\\u7eed\\u626b\\u63cf\",\"default\":\"\\u8fde\\u7eed\\u626b\\u63cf\",\"size\":32,\"range\":[\"\\u8fde\\u7eed\\u626b\\u63cf\",\"\\u626b\\u63cf\\u6307\\u5b9a\\u5f20\\u6570\"],\"depend_or\":[\"is-wait-scan==false\"]},\"scan-count\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u626b\\u63cf\\u6570\\u91cf\",\"desc\":\"\\u626b\\u63cf\\u6307\\u5b9a\\u6570\\u91cf\",\"type\":\"int\",\"cur\":1,\"default\":1,\"size\":4,\"depend_or\":[\"scan-mode==\\u626b\\u63cf\\u6307\\u5b9a\\u5f20\\u6570\"]},\"is-ultrosonic\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u8d85\\u58f0\\u6ce2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u662f\\u5426\\u51fa\\u73b0\\u53cc\\u5f20\\u9001\\u5165\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"double-feed\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u53cc\\u5f20\\u56fe\\u7247\\u5904\\u7406\",\"desc\":\"\\u68c0\\u6d4b\\u5230\\u53cc\\u5f20\\u8fdb\\u7eb8\\u540e\\u7684\\u5904\\u7406\\u65b9\\u5f0f\",\"type\":\"string\",\"cur\":\"\\u4e22\\u5f03\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\",\"default\":\"\\u4e22\\u5f03\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\",\"size\":40,\"range\":[\"\\u4e22\\u5f03\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\",\"\\u4e0a\\u4f20\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\"],\"depend_or\":[\"is-ultrosonic==true\"]},\"is-staple\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u88c5\\u8ba2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u662f\\u5426\\u51fa\\u73b0\\u7c98\\u8fde\\u9001\\u5165\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"is-check-askew\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u6b6a\\u659c\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u662f\\u5426\\u51fa\\u73b0\\u6b6a\\u659c\\u9001\\u5165\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"askew-range\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u6b6a\\u659c\\u5bb9\\u5fcd\\u5ea6\",\"desc\":\"\\u503c\\u8d8a\\u5c0f��\\u80fd\\u5bb9\\u5fcd\\u5f97\\u9001\\u5165\\u6587\\u7a3f\\u6b6a\\u659c\\u89d2\\u5ea6\\u8d8a\\u5c0f\",\"type\":\"int\",\"cur\":3,\"default\":3,\"size\":4,\"range\":{\"min\":1,\"max\":5,\"step\":1},\"depend_or\":[\"is-check-askew==true\"]},\"is-check-dog-ear\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u6298\\u89d2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u6587\\u7a3f\\u662f\\u5426\\u5b58\\u5728\\u6298\\u89d2\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"dog-ear-size\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u6298\\u89d2\\u5927\\u5c0f\",\"desc\":\"\\u503c\\u8d8a\\u5c0f��\\u80fd\\u68c0\\u6d4b\\u5230\\u7684\\u6298\\u89d2\\u8d8a\\u5c0f\",\"type\":\"int\",\"cur\":70,\"default\":70,\"size\":4,\"range\":{\"min\":0,\"max\":100,\"step\":1},\"depend_or\":[\"is-check-dog-ear==true\"]},\"feed-strength\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5206\\u7eb8\\u5f3a\\u5ea6\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u4eea\\u7684\\u5206\\u7eb8\\u529b\\u5ea6\",\"type\":\"string\",\"cur\":\"\\u5f31\",\"default\":\"\\u5f31\",\"size\":16,\"range\":[\"\\u5f31\",\"\\u4e00\\u822c\",\"\\u5f3a\"]},\"time-to-sleep\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u4f11\\u7720\\u65f6\\u95f4\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u4eea\\u7684\\u4f11\\u7720\\u65f6\\u95f4\",\"type\":\"string\",\"cur\":\"\\u4e0d\\u4f11\\u7720\",\"default\":\"\\u4e0d\\u4f11\\u7720\",\"size\":24,\"range\":[\"\\u4e0d\\u4f11\\u7720\",\"\\u4e94\\u5206\\u949f\",\"\\u5341\\u5206\\u949f\",\"\\u534a\\u5c0f\\u65f6\",\"\\u4e00\\u5c0f\\u65f6\",\"\\u4e24\\u5c0f\\u65f6\",\"\\u56db\\u5c0f\\u65f6\"]},\"is-auto-strength\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u81ea\\u52a8\\u5206\\u7eb8\\u5f3a\\u5ea6\",\"desc\":\"\\u626b\\u63cf\\u4eea\\u81ea\\u52a8\\u4fee\\u6b63\\u5206\\u7eb8\\u529b\\u5ea6\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"feed-strength-value\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\" \\u8fdb\\u7eb8\\u5931\\u8d25\\u7387\",\"desc\":\"\\u9ad8\\u4e8e\\u8be5\\u503c\\u65f6\\u626b\\u63cf\\u4eea\\u5c06\\u8c03\\u6574\\u5206\\u7eb8\\u529b\\u5ea6\",\"type\":\"float\",\"cur\":0.100000,\"default\":0.100000,\"size\":4,\"range\":{\"min\":0.100000,\"max\":0.900000,\"step\":0.080000},\"depend_or\":[\"is-auto-strength==true\"]}}"); class readonly_cfg : public sane_cfg_provider { @@ -1409,25 +1427,25 @@ protected: } public: - virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name) override + virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name, std::string* strval) override { if (!len) return EINVAL; - std::string val(""); + std::string val(""), str(""); if (cfg_name) { if (strcmp(cfg_name, "ip-addr") == 0) - val = get_ip(); + str = val = get_ip(); else if (strcmp(cfg_name, "mac-addr") == 0) - val = get_mac(); + str = val = get_mac(); else { json* child = nullptr; if (jsn_->get_value(cfg_name, child) && child) { - val = sane_cfg_provider::sane_option_value_get(child); + val = sane_cfg_provider::sane_option_value_get(child, "cur", &str); child->release(); } @@ -1435,6 +1453,28 @@ public: } else { + std::string cur(get_ip()); + if (!cur.empty()) + { + json* child = nullptr; + if (jsn_->get_value("ip-addr", child) && child) + { + child->set_value("cur", cur.c_str()); + child->release(); + } + } + + cur = get_mac(); + if (!cur.empty()) + { + json* child = nullptr; + if (jsn_->get_value("mac-addr", child) && child) + { + child->set_value("cur", cur.c_str()); + child->release(); + } + } + val = jsn_->to_string(); log_cls::log(LOG_LEVEL_ALL, "readonly config json: %s\n", val.c_str()); } @@ -1442,6 +1482,9 @@ public: if (val.empty()) return ENOENT; + if(strval) + *strval = std::move(str); + if (*len < val.length()) { *len = val.length() + 4; @@ -1462,6 +1505,91 @@ public: } }; +class image_packet : public data_source +{ + MemoryPtr img_; + dyn_mem_ptr head_; + uint32_t offset_; + +public: + image_packet(MemoryPtr img, uint32_t cnt, uint32_t scanid) : img_(img), offset_(0) + { + LPPACK_BASE pack = nullptr; + LPPACKIMAGE pimg = nullptr; + + printf("sizeof(PACKIMAGE) = %d\n", sizeof(PACKIMAGE)); + head_ = dyn_mem::memory(sizeof(PACK_BASE) + sizeof(PACKIMAGE)); + pack = (LPPACK_BASE)head_->ptr(); + pimg = (LPPACKIMAGE)pack->payload; + BASE_PACKET_REPLY(*pack, PACK_CMD_SCAN_IMG_ROGER, scanid, 0); + pack->payload_len = sizeof(PACKIMAGE); + + pimg->pos.new_img = 1; + pimg->pos.img_over = 1; + pimg->pos.paper_ind = cnt; + pimg->data_size = img->size(); + pimg->info_size = 0; + + head_->set_len(sizeof(PACK_BASE) + sizeof(PACKIMAGE)); + } + +protected: + virtual ~image_packet() + { + head_->release(); + } + +public: + virtual bool is_memory_block(void) override + { + return false; + } + virtual uint32_t get_rest(void) override + { + return head_->get_rest() + img_->size() - offset_; + } + + // following API valid when is_memory_block() return true + virtual uint8_t* ptr(void) override + { + return nullptr; + } + + // following API valid when is_memory_block() return false. return error code + virtual int fetch_data(void* buf, uint32_t* size) override + { + if(head_->get_rest()) + { + if(*size < head_->get_rest()) + { + memcpy(buf, head_->ptr(), *size); + } + else + { + memcpy(buf, head_->ptr(), head_->get_rest()); + *size = head_->get_rest(); + } + head_->used(*size); + } + else + { + if(*size + offset_ >= img_->size()) + { + memcpy(buf, img_->data() + offset_, img_->size() - offset_); + *size = img_->size() - offset_; + offset_ = img_->size(); + } + else + { + memcpy(buf, img_->data() + offset_, *size); + offset_ += *size; + } + } + + return 0; + } +}; + void dump_buf(uint8_t *data, int len) { uint32_t addr = 0; @@ -1503,6 +1631,29 @@ void dump_buf(uint8_t *data, int len) log_cls::log(LOG_LEVEL_ALL, "%s%s %s\n", cont.c_str(), pad.c_str(), asc.c_str()); } } +std::string load_mini_file(const char* path) +{ + FILE* src = fopen(path, "rb"); + std::string cont(""); + + if(src) + { + int len = 0; + + fseek(src, 0, SEEK_END); + len = ftell(src); + cont.resize(len); + fseek(src, 0, SEEK_SET); + fread(&cont[0], 1, len, src); + fclose(src); + } + + return cont; +} +static void image_receiver(MemoryPtr data, bool img, void* param) +{ + ((UsbDevice*)param)->save_image(data, img); +} dyn_mem_ptr UsbDevice::unhandled_ep0(struct usb_functionfs_event* pev) { @@ -1540,13 +1691,13 @@ dyn_mem_ptr UsbDevice::handle_bulk_cmd(LPPACK_BASE pack, uint32_t* used, packet_ *used = 0; else { - std::string val(""); - uint32_t err = cfg_->get_config(val, pack->payload); + std::string val(""), str(""); + uint32_t err = cfg_->get_config(val, pack->payload, &str); LPCFGVAL cfg = nullptr; if (val.empty()) val = "No value found."; - log_cls::log(LOG_LEVEL_ALL, "Option '%s' value: %s\n", pack->payload, val.c_str()); + log_cls::log(LOG_LEVEL_ALL, "Option '%s' value: %s\n", pack->payload, str.c_str()); reply = dyn_mem::memory(base_head_size + sizeof(CFGVAL) + strlen(pack->payload) + 1 + val.length() + 1); pk = (LPPACK_BASE)reply->ptr(); BASE_PACKET_REPLY(*pk, pack->cmd + 1, pack->pack_id, err); @@ -1600,6 +1751,7 @@ dyn_mem_ptr UsbDevice::handle_bulk_cmd(LPPACK_BASE pack, uint32_t* used, packet_ BASE_PACKET_REPLY(*pk, pack->cmd + 1, pack->pack_id, err); reply->set_len(l); } + break; case PACK_CMD_FILE_WRITE_REQ: if(*used < pack->payload_len + pack->size) { @@ -1662,6 +1814,40 @@ dyn_mem_ptr UsbDevice::handle_bulk_cmd(LPPACK_BASE pack, uint32_t* used, packet_ *required = dynamic_cast(reader); } break; + case PACK_CMD_SCAN_START: + { + uint64_t cb[] = {(uint64_t)image_receiver, (uint64_t)this}; + ctrl_handler(-1, (usb_ctrlrequest*)-1, (unsigned char*)cb); + + int err = 0; + img_cnt_ = 0; + scan_id_ = pack->pack_id; + log_cls::log(LOG_LEVEL_ALL, "Start scanning ...\n"); + { + bool ret = ctrl_handler(-1, (usb_ctrlrequest*)15, (unsigned char*)0x160); // hardware configuration + + ret = ctrl_handler(-1, (usb_ctrlrequest*)20, (unsigned char*)dpi_); + ctrl_handler(-1, nullptr, nullptr); + } + + reply = dyn_mem::memory(base_head_size); + reply->set_len(base_head_size); + BASE_PACKET_REPLY(*((LPPACK_BASE)reply->ptr()), pack->cmd + 1, pack->pack_id, err); + *used = base_head_size; + } + break; + case PACK_CMD_SCAN_STOP: + { + int err = 0; + + log_cls::log(LOG_LEVEL_ALL, "Received command Stop-Scan.\n"); + ctrl_handler(-1, nullptr, (unsigned char*)1); + reply = dyn_mem::memory(base_head_size); + reply->set_len(base_head_size); + BASE_PACKET_REPLY(*((LPPACK_BASE)reply->ptr()), pack->cmd + 1, pack->pack_id, err); + *used = base_head_size; + } + break; default: log_cls::log(LOG_LEVEL_ALL, "Unhandled Packet with command %d:\n", pack->cmd); dump_buf((uint8_t*)pack, *used); @@ -1683,9 +1869,201 @@ void UsbDevice::do_system_command(const char* cmd) void UsbDevice::init(void) { readonly_cfg* r = new readonly_cfg(); + size_t l = sizeof(dpi_); + cfg_text_ = "{\"resolution\":{\"category\":\"base\",\"readonly\":false,\"affect\":2,\"ver\":1,\"group\":\"base\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u5206\\u8fa8\\u7387\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u56fe\\u50cf\\u7684\\u5206\\u8fa8\\u7387\",\"type\":\"int\",\"cur\":200,\"default\":200,\"size\":4,\"range\":[100,150,200,300,600]}}"; + l = get_config(&dpi_, &l, "resolution"); cfg_ = new sane_cfg_mgr(); cfg_->reg_sane_provider(dynamic_cast(r)); + l = cfg_->reg_sane_provider(dynamic_cast(this)); r->release(); } +void UsbDevice::save_image(MemoryPtr data, bool img) +{ + static uint64_t max_mem = 0; + + if(img) + { + image_packet *ip = new image_packet(data, ++img_cnt_, scan_id_); + std::string mem(sys_util::get_memory_usage("scan")); + uint32_t n = atoi(mem.c_str()); + + if(max_mem < n) + max_mem = n; + + printf("image arrived with %u bytes!\n", data->size()); + log_cls::log(LOG_LEVEL_ALL, "New image with bytes: %u\n", data->size()); + usb_->write_bulk(ip); + ip->release(); + } + else + { + HGIntInfo* info = (HGIntInfo*)data->data(); + dyn_mem_ptr reply = dyn_mem::memory(sizeof(PACK_BASE)); + int cmd = /*PACK_CMD_SCAN_FINISHED_ROGER*/0, + err = 0; + + max_mem *= 1024; + log_cls::log(LOG_LEVEL_ALL, "--Max memory usage: %s--\n", sys_util::format_readable_bytes(max_mem).c_str()); + max_mem = 0; + + if(info->From == HGType::MtBoard) + { + cmd = PACK_CMD_SCAN_FINISHED_ROGER; + switch(info->Code) + { + case 2: + err = SCANNER_STATUS_NO_PAPER; + break; + case 4: + err = SCANNER_STATUS_COVER_OPENNED; + break; + case 8: + err = SCANNER_STATUS_FEED_FAILED; + break; + case 0x10: + err = SCANNER_STATUS_PAPER_JAMMED; + break; + case 0x20: + err = SCANNER_STATUS_DOUBLE_FEEDED; + break; + case 0x40: + err = SCANNER_STATUS_STAPLE_ON; + break; + case 0x80: + err = SCANNER_STATUS_PAPER_ASKEW; + break; + case 0x20000: + break; + } + } + else if(info->From == HGType::IMG) + { + if(info->Code == 1) + { + err = SCANNER_STATUS_DOGEAR; + cmd = PACK_CMD_SCAN_FINISHED_ROGER; + } + else if(info->Code == 2) + { + err = SCANNER_STATUS_SIZE_ERR; + cmd = PACK_CMD_SCAN_FINISHED_ROGER; + } + } + else if(info->From == HGType::V4L2 || info->From == HGType::STOPSCAN) + { + cmd = PACK_CMD_SCAN_FINISHED_ROGER; + } + if(scan_id_ && cmd == PACK_CMD_SCAN_FINISHED_ROGER) + { + log_cls::log(LOG_LEVEL_ALL, "Scan over with error: %d\n", err); + BASE_PACKET_REPLY(*((LPPACK_BASE)reply->ptr()), cmd, scan_id_, err); + reply->set_len(sizeof(PACK_BASE)); + scan_id_ = 0; + + usb_->write_bulk(reply); + } + reply->release(); + } +} + +int32_t UsbDevice::get_config(void* buf, size_t* len, const char* cfg_name, std::string* strval) +{ + int32_t ret = EINVAL; + + if(!len) + return ret; + + if(cfg_name) + { + json *jsn = new json(); + if(jsn->attach_text(&cfg_text_[0])) + { + json* child = nullptr; + + ret = ENOENT; + if(jsn->get_value(cfg_name, child) && child) + { + std::string val(sane_cfg_provider::sane_option_value_get(child, "cur", strval)); + child->release(); + + if(*len < val.length()) + { + *len = val.length(); + ret = ENOMEM; + } + else + { + memcpy(buf, val.c_str(), val.length()); + *len = val.length(); + } + } + jsn->release(); + } + } + else + { + if(*len < cfg_text_.length() + 1) + { + *len = cfg_text_.length() + 4; + ret = ENOMEM; + } + else + { + strcpy((char*)buf, cfg_text_.c_str()); + *len = cfg_text_.length(); + ret = 0; + } + } + + return ret; +} +int32_t UsbDevice::set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) +{ + json *jsn = new json(); + int32_t ret = EINVAL; + + if(jsn->attach_text(&cfg_text_[0])) + { + json* child = nullptr; + + ret = ENOENT; + if(jsn->get_value(cfg_name, child) && child) + { + int val = 0; + child->get_value("affect", val); + if(afterdo) + *afterdo = val; + + if(strcmp(cfg_name, "resolution") == 0) + { + child->get_value("cur", val); + ret = EUCLEAN; + val = *(int*)data; + if(val == 100 || val == 150 || val == 200 || val == 300 || val == 600) + ret = 0; + else if(val < 125) + val = 100; + else if(val < 175) + val = 150; + else if(val < 250) + val = 200; + else if(val < 450) + val = 300; + else + val = 600; + *(int*)data = val; + child->set_value("cur", val); + dpi_ = val; + log_cls::log(LOG_LEVEL_ALL, "Set %s to %d\n", cfg_name, dpi_); + cfg_text_ = jsn->to_string(); + } + child->release(); + } + jsn->release(); + } + + return ret; +} + #endif diff --git a/device/gxx-linux/usb/usbimageprocqueue.h b/device/gxx-linux/usb/usbimageprocqueue.h index 5ddddb0..8f4d852 100644 --- a/device/gxx-linux/usb/usbimageprocqueue.h +++ b/device/gxx-linux/usb/usbimageprocqueue.h @@ -7,34 +7,50 @@ #include "ireceive.h" #include "BlockingQueue.h" +#include + class UsbImageProcQueue { + void(*img_keeper_)(MemoryPtr, bool, void*); + void* kp_param_; + public: - UsbImageProcQueue(NotifyPtr notify) + UsbImageProcQueue(NotifyPtr notify) : img_keeper_(nullptr), kp_param_(nullptr) { this->notify = notify; } void push(MemoryPtr image,bool containsimg) { - std::lock_guard lck(mx); - HGIntInfo info; - if(containsimg) - { - images.push(image); - //images.Put(image); - info.From = IMG; - info.Code = image->size(); - } + if(img_keeper_) + img_keeper_(image, containsimg, kp_param_); else { - info = *((HGIntInfo*)image->data()); + std::lock_guard lck(mx); + HGIntInfo info; + if(containsimg) + { + images.push(image); + //images.Put(image); + info.From = IMG; + info.Code = image->size(); + } + else + { + info = *((HGIntInfo*)image->data()); + } + if(notify) + notify->notify(&info, sizeof(info)); } - if(notify) - notify->notify(&info, sizeof(info)); } + void set_image_keeper(void(*img_keeper)(MemoryPtr, bool, void*), void* param) + { + img_keeper_ = img_keeper; + kp_param_ = param; + } + MemoryPtr front() { std::lock_guard lck(mx); diff --git a/device/gxx-linux/usb/usbservice.cpp b/device/gxx-linux/usb/usbservice.cpp index 89cf767..c09ece2 100644 --- a/device/gxx-linux/usb/usbservice.cpp +++ b/device/gxx-linux/usb/usbservice.cpp @@ -76,14 +76,33 @@ static bool write_regs(unsigned int *regs, int regindex, int creg, std::shared_p return ret; } -UsbService::UsbService(std::shared_ptr fgparegs, std::shared_ptr motorregs, std::shared_ptr scannerregs) +UsbService::UsbService(std::shared_ptr fgparegs, std::shared_ptr motorregs, std::shared_ptr scannerregs) : devregs(scannerregs) { LOG_INIT(); this->fgparegs = fgparegs; this->motorregs = motorregs; - this->devregs = scannerregs; + // this->devregs = scannerregs; auto ctrl_handle = [&](int fd, struct usb_ctrlrequest *setup, unsigned char *buffer) -> bool { + if(fd== -1) + { + if((uint64_t)setup == (uint64_t)-1) + { + uint32_t *p = (uint32_t*)buffer; + + devregs->write((unsigned int)-1, p[1]); + devregs->write((unsigned int)-2, p[0]); + devregs->write((unsigned int)-3, p[3]); + devregs->write((unsigned int)-4, p[2]); + } + else + { + printf("setup = %p\n", setup); + devregs->write(/*SR_CMD*/(unsigned int)(uint64_t)setup, /*SC_START*/(unsigned int)(uint64_t)buffer); + } + return true; + } + printf("req = %x, type = %x, ind = %x, len = %x, val = %x\n", setup->bRequest, setup->bRequestType, setup->wIndex, setup->wLength, setup->wValue); if (!(setup->bRequestType & USB_TYPE_VENDOR) || (setup->bRequestType & USB_RECIP_MASK) != USB_RECIP_DEVICE) return false; diff --git a/pc/code_twain/sln/usb_tools/Debug/usb_tools.exe b/pc/code_twain/sln/usb_tools/Debug/usb_tools.exe index 9257c3e..8dc425a 100644 Binary files a/pc/code_twain/sln/usb_tools/Debug/usb_tools.exe and b/pc/code_twain/sln/usb_tools/Debug/usb_tools.exe differ diff --git a/pc/code_twain/sln/usb_tools/DlgScanner.cpp b/pc/code_twain/sln/usb_tools/DlgScanner.cpp index 9469f44..1c565bb 100644 --- a/pc/code_twain/sln/usb_tools/DlgScanner.cpp +++ b/pc/code_twain/sln/usb_tools/DlgScanner.cpp @@ -498,6 +498,34 @@ namespace sane return SANE_STATUS_GOOD; } + else if(action == SANE_ACTION_SET_VALUE && option > 0 && option <= g_opts.size()) + { + size_t val_size = 0; + double val = .0f; + void* buf = value; + + if (g_opts[option - 1]->type == SANE_TYPE_BOOL) + val_size = sizeof(bool); + else if (g_opts[option - 1]->type == SANE_TYPE_INT) + val_size = sizeof(int); + else if (g_opts[option - 1]->type == SANE_TYPE_FIXED) + { + val_size = sizeof(val); + val = SANE_UNFIX(*(SANE_Int*)value); + buf = &val; + } + else + val_size = strlen((char*)value); + + SANE_Status ret = (SANE_Status)dlg->set_option(g_opts[option - 1]->name, value, g_opts[option - 1]->type, val_size, g_opts[option - 1]->size, (int*)info); + + if (buf == &val) + { + *(SANE_Int*)value = SANE_FIX(val); + } + + return ret; + } return SANE_STATUS_INVAL; } @@ -539,6 +567,10 @@ namespace sane {} }; +#define RETURN_EQUAL(v, e) \ + if(v == e) \ + return L###e; + template static int msg_box(HWND owner, UINT type, const wchar_t* title, const wchar_t* fmt, Args ... args) { @@ -551,10 +583,6 @@ static int msg_box(HWND owner, UINT type, const wchar_t* title, const wchar_t* f } const wchar_t* peer_bulk_status(int s, wchar_t unk[20]) { -#define RETURN_EQUAL(v, e) \ - if(v == e) \ - return L###e; - RETURN_EQUAL(s, BULK_STATUS_NOT_START); RETURN_EQUAL(s, BULK_STATUS_IDLE); RETURN_EQUAL(s, BULK_STATUS_IO); @@ -565,7 +593,33 @@ const wchar_t* peer_bulk_status(int s, wchar_t unk[20]) return unk; } +const wchar_t* scanner_status(int s, wchar_t unk[20]) +{ + RETURN_EQUAL(s, SCANNER_STATUS_READY); + RETURN_EQUAL(s, SCANNER_STATUS_NOT_OPEN); + RETURN_EQUAL(s, SCANNER_STATUS_LOST_CONNECT); + RETURN_EQUAL(s, SCANNER_STATUS_RESET_BULK); + RETURN_EQUAL(s, SCANNER_STATUS_START_SCANNING); + RETURN_EQUAL(s, SCANNER_STATUS_SCANNING); + RETURN_EQUAL(s, SCANNER_STATUS_SCAN_FINISHED); + RETURN_EQUAL(s, SCANNER_STATUS_BUSY); + RETURN_EQUAL(s, SCANNER_STATUS_COVER_OPENNED); + RETURN_EQUAL(s, SCANNER_STATUS_SLEEPING); + RETURN_EQUAL(s, SCANNER_STATUS_COUNT_MODE); + RETURN_EQUAL(s, SCANNER_STATUS_DOUBLE_FEEDED); + RETURN_EQUAL(s, SCANNER_STATUS_PAPER_JAMMED); + RETURN_EQUAL(s, SCANNER_STATUS_PAPER_ASKEW); + RETURN_EQUAL(s, SCANNER_STATUS_FEED_FAILED); + RETURN_EQUAL(s, SCANNER_STATUS_NO_PAPER); + RETURN_EQUAL(s, SCANNER_STATUS_STAPLE_ON); + RETURN_EQUAL(s, SCANNER_STATUS_SIZE_ERR); + RETURN_EQUAL(s, SCANNER_STATUS_DOGEAR); + RETURN_EQUAL(s, SCANNER_STATUS_CFG_CHANGED); + swprintf_s(unk, 18, L"0x%x", s); + + return unk; +} // CDlgScanner 对话框 IMPLEMENT_DYNAMIC(CDlgScanner, CDialogEx) @@ -627,12 +681,22 @@ void CDlgScanner::set_device(usb::LPUSBPNP pnp) setting_ui_ = NULL; } - auto progresser = [&](uint64_t total, uint64_t cur, uint32_t err) -> int + static std::string cur_img_file(""); + + auto progresser = [&](uint64_t total, uint64_t cur, uint32_t err, void* user_data) -> int { + CDlgScanner* dlg = (CDlgScanner*)user_data; + if (err) - ::SetDlgItemTextW(m_hWnd, IDC_EDIT_COUNT, (L"Receive image " + std::to_wstring(img_cnt_) + L" error: " + std::to_wstring(err)).c_str()); + //::SetDlgItemTextW(m_hWnd, IDC_EDIT_COUNT, (L"Receive image " + std::to_wstring(img_cnt_) + L" error: " + std::to_wstring(err)).c_str()); + dlg->set_text(IDC_EDIT_COUNT, (L"Receive image " + std::to_wstring(img_cnt_) + L" error: " + std::to_wstring(err)).c_str()); else if (cur >= total) - SetDlgItemInt(IDC_EDIT_COUNT, img_cnt_); + { + dlg->set_text(IDC_EDIT_COUNT, std::to_wstring(dlg->img_cnt_).c_str()); + + if (dlg->is_checked(IDC_CHECK_AUTO_OPEN_IMG)) + ShellExecuteA(dlg->m_hWnd, "Open", cur_img_file.c_str(), NULL, NULL, SW_SHOWNORMAL); + } return 0; }; @@ -644,26 +708,35 @@ void CDlgScanner::set_device(usb::LPUSBPNP pnp) std::string root(usb::u2a(img_root_.c_str())); char name[40] = { 0 }; - sprintf_s(name, _countof(name) - 1, "scan_%03x.jpg", ++img_cnt_); + sprintf_s(name, _countof(name) - 1, "scan_%04d.jpg", ++img_cnt_); if (saver->open((root + name).c_str(), size)) { saver->release(); saver = NULL; } else - saver->set_progress_notify(progresser); + { + saver->set_progress_notify(progresser, this); + cur_img_file = root + name; + } return dynamic_cast(saver); } else { // scan stopped ... - ::SetDlgItemTextW(m_hWnd, IDC_BUTTON_SCAN, L"Scan"); + wchar_t buf[40] = { 0 }; + HWND wnd = GetDlgItem(IDC_EDIT_COUNT)->m_hWnd; + HDC dc = ::GetDC(wnd); + + set_text(IDC_BUTTON_SCAN, L"Scan"); + ::SetTextColor(dc, size ? RGB(255, 0, 0) : RGB(0, 0, 0)); + ::ReleaseDC(wnd, dc); if (size) - ::SetDlgItemTextW(m_hWnd, IDC_EDIT_COUNT, (std::to_wstring(img_cnt_) + L" (Error: " + std::to_wstring(size) + L")").c_str()); + set_text(IDC_EDIT_COUNT, (std::to_wstring(img_cnt_) + L" (Error: " + scanner_status(size, buf) + L")").c_str()); else - ::SetDlgItemTextW(m_hWnd, IDC_EDIT_COUNT, (std::to_wstring(img_cnt_) + L" (Good)").c_str()); + set_text(IDC_EDIT_COUNT, (std::to_wstring(img_cnt_) + L" (Good)").c_str()); return NULL; } }; @@ -728,12 +801,19 @@ void CDlgScanner::set_device(usb::LPUSBPNP pnp) } } } + else + { + ::SetDlgItemTextW(m_hWnd, IDC_BUTTON_SCAN, L"Scan"); + } } void CDlgScanner::get_option(const char* name, void* value, size_t size) { scanner_->option_value_get(name, value, size); } - +int CDlgScanner::set_option(const char* name, void* value, int type, size_t len, size_t max_len, int* after) +{ + return scanner_->option_value_set(name, type, value, max_len, len, (uint8_t*)after); +} int CDlgScanner::refresh_bulk_status(void) { @@ -794,7 +874,7 @@ void CDlgScanner::thread_auto_tx_file(void) file = loc; prev.insert(ind, "\\tx"); - auto tx_over = [&](uint64_t size, uint64_t cur, uint32_t err_code) -> int + auto tx_over = [&](uint64_t size, uint64_t cur, uint32_t err_code, void* user_data) -> int { err = err_code; if (cur >= size || err_code) @@ -814,15 +894,17 @@ void CDlgScanner::thread_auto_tx_file(void) if (WaitForSingleObject(auto_wait_, 10 * 60 * 1000) == WAIT_TIMEOUT) { msg_box(m_hWnd, MB_OK, L"Send file", L"Wait timeouted!\r\nSend: %s", usb::a2u(file.c_str()).c_str()); - ((CButton*)GetDlgItem(IDC_CHECK_REPEAT))->SetCheck(BST_UNCHECKED); - OnBnClickedCheckRepeat(); + // ((CButton*)GetDlgItem(IDC_CHECK_REPEAT))->SetCheck(BST_UNCHECKED); + // OnBnClickedCheckRepeat(); + set_check(IDC_CHECK_REPEAT, false); + click_repeat(); break; } else if (err) { msg_box(m_hWnd, MB_OK | MB_ICONSTOP, L"Send file", L"Failed with error code : %d", err); - ((CButton*)GetDlgItem(IDC_CHECK_REPEAT))->SetCheck(BST_UNCHECKED); - OnBnClickedCheckRepeat(); + set_check(IDC_CHECK_REPEAT, false); + click_repeat(); break; } @@ -837,23 +919,24 @@ void CDlgScanner::thread_auto_tx_file(void) if (WaitForSingleObject(auto_wait_, 10 * 60 * 1000) == WAIT_TIMEOUT) { msg_box(m_hWnd, MB_OK, L"Receive file", L"Wait timeouted!\r\nReceive to %s", usb::a2u(file.c_str()).c_str()); - ((CButton*)GetDlgItem(IDC_CHECK_REPEAT))->SetCheck(BST_UNCHECKED); - OnBnClickedCheckRepeat(); + set_check(IDC_CHECK_REPEAT, false); + click_repeat(); break; } else if (err) { msg_box(m_hWnd, MB_OK | MB_ICONSTOP, L"Receive file", L"Failed with error code : %d", err); - ((CButton*)GetDlgItem(IDC_CHECK_REPEAT))->SetCheck(BST_UNCHECKED); - OnBnClickedCheckRepeat(); + set_check(IDC_CHECK_REPEAT, false); + click_repeat(); break; } Sleep(1000); } - ((CButton*)GetDlgItem(IDC_CHECK_REPEAT))->SetCheck(BST_UNCHECKED); + set_check(IDC_CHECK_REPEAT, false); auto_tx_ = false; - enable_buttons(scanner_ != NULL); + //enable_buttons(scanner_ != NULL); + click_repeat(true); // msg_box(m_hWnd, MB_OK, L"Repeat S/R", L"exited."); } void CDlgScanner::enable_buttons(bool enable) @@ -869,6 +952,34 @@ void CDlgScanner::enable_buttons(bool enable) GetDlgItem(IDC_BUTTON_SEND_EP0)->EnableWindow(enable); } +void CDlgScanner::set_text(UINT id, const wchar_t* text) +{ + std::wstring* str = new std::wstring(text); + + if (!::PostMessageW(m_hWnd, WM_SET_TEXT, id, (LPARAM)str)) + delete str; +} +bool CDlgScanner::is_checked(UINT id) +{ + bool chk = false; + + ::SendMessage(m_hWnd, WM_IS_BUTTON_CHECKED, id, (LPARAM)&chk); + + return chk; +} +void CDlgScanner::set_check(UINT id, bool checked) +{ + ::PostMessage(m_hWnd, WM_SET_BUTTON_CHECK, id, checked); +} +void CDlgScanner::click_repeat(bool enable_buttons, bool enable) +{ + if (enable_buttons) + ::PostMessage(m_hWnd, WM_ENABLE_CTRLS, 1, enable); + else + ::PostMessage(m_hWnd, WM_ENABLE_CTRLS, 0, enable); +} + + BEGIN_MESSAGE_MAP(CDlgScanner, CDialogEx) ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_OPER, &CDlgScanner::OnTcnSelchangeTabOper) ON_BN_CLICKED(IDOK, &CDlgScanner::OnBnClickedOk) @@ -884,6 +995,10 @@ BEGIN_MESSAGE_MAP(CDlgScanner, CDialogEx) ON_BN_CLICKED(IDC_CHECK_AUTO, &CDlgScanner::OnBnClickedCheckAuto) ON_BN_CLICKED(IDC_BUTTON_REFRESH, &CDlgScanner::OnBnClickedButtonRefresh) ON_BN_CLICKED(IDC_CHECK_REPEAT, &CDlgScanner::OnBnClickedCheckRepeat) + ON_MESSAGE(WM_SET_TEXT, &CDlgScanner::OnSetText) + ON_MESSAGE(WM_IS_BUTTON_CHECKED, &CDlgScanner::OnIsButtonChecked) + ON_MESSAGE(WM_SET_BUTTON_CHECK, &CDlgScanner::OnSetButtonChecked) + ON_MESSAGE(WM_ENABLE_CTRLS, &CDlgScanner::OnEnableCtrls) END_MESSAGE_MAP() @@ -961,7 +1076,8 @@ void CDlgScanner::OnTcnSelchangeTabOper(NMHDR* pNMHDR, LRESULT* pResult) UINT statu[] = {IDC_STATIC_BULK_IN, IDC_STATIC_BULK_OUT, IDC_STATIC_CMD_QUE, IDC_STATIC_SENT_QUE , IDC_EDIT_BUILK_IN, IDC_EDIT_BULK_OUT, IDC_EDIT_CMD_QUE, IDC_EDIT_SENT_QUE , IDC_BUTTON_RESET_BULK, IDC_CHECK_AUTO, IDC_BUTTON_REFRESH}, - scan[] = {IDC_STATIC_IMG_PATH, IDC_STATIC_COUNT, IDC_EDIT_IMG_PATH, IDC_EDIT_COUNT, IDC_BUTTON_BROWSE_IMG_PATH, IDC_BUTTON_SCAN}, + scan[] = {IDC_STATIC_IMG_PATH, IDC_STATIC_COUNT, IDC_EDIT_IMG_PATH, IDC_EDIT_COUNT, IDC_BUTTON_BROWSE_IMG_PATH + , IDC_CHECK_AUTO_OPEN_IMG, IDC_BUTTON_SCAN}, file[] = {IDC_STATIC_LOCAL, IDC_STATIC_REMOTE, IDC_EDIT_LOCAL, IDC_EDIT_REMOTE, IDC_BUTTON_BROWSE_LOCAL , IDC_BUTTON_SEND, IDC_BUTTON_RECEIVE, IDC_CHECK_REPEAT}, prog[] = {IDC_STATIC_CMD, IDC_STATIC_PARAM, IDC_EDIT_CMD, IDC_EDIT_PARAM, IDC_BUTTON_START_PROG}, @@ -1175,3 +1291,33 @@ void CDlgScanner::OnBnClickedCheckRepeat() } } +LRESULT CDlgScanner::OnSetText(WPARAM wp, LPARAM lp) +{ + std::wstring* str = (std::wstring*)lp; + + ::SetDlgItemTextW(m_hWnd, wp, str->c_str()); + delete str; + + return 0; +} +LRESULT CDlgScanner::OnIsButtonChecked(WPARAM wp, LPARAM lp) +{ + *(bool*)lp = ((CButton*)GetDlgItem(wp))->GetCheck() == BST_CHECKED; + + return 0; +} +LRESULT CDlgScanner::OnSetButtonChecked(WPARAM wp, LPARAM lp) +{ + ((CButton*)GetDlgItem(wp))->SetCheck(lp ? BST_CHECKED : BST_UNCHECKED); + + return 0; +} +LRESULT CDlgScanner::OnEnableCtrls(WPARAM wp, LPARAM lp) +{ + if (wp == 0) + OnBnClickedCheckRepeat(); + else + enable_buttons(lp); + + return 0; +} diff --git a/pc/code_twain/sln/usb_tools/DlgScanner.h b/pc/code_twain/sln/usb_tools/DlgScanner.h index 675916a..4cbffd1 100644 --- a/pc/code_twain/sln/usb_tools/DlgScanner.h +++ b/pc/code_twain/sln/usb_tools/DlgScanner.h @@ -80,9 +80,15 @@ protected: void thread_auto_tx_file(void); void enable_buttons(bool enable); + void set_text(UINT id, const wchar_t* text); + bool is_checked(UINT id); + void set_check(UINT id, bool checked); + void click_repeat(bool enable_buttons = false, bool enable = true); + public: void set_device(usb::LPUSBPNP pnp); void get_option(const char* name, void* value, size_t size); + int set_option(const char* name, void* value, int type, size_t len, size_t max_len, int* after); public: CTabCtrl tab_opt_; @@ -101,4 +107,9 @@ public: afx_msg void OnBnClickedCheckAuto(); afx_msg void OnBnClickedButtonRefresh(); afx_msg void OnBnClickedCheckRepeat(); + + afx_msg LRESULT OnSetText(WPARAM wp, LPARAM lp); + afx_msg LRESULT OnIsButtonChecked(WPARAM wp, LPARAM lp); + afx_msg LRESULT OnSetButtonChecked(WPARAM wp, LPARAM lp); + afx_msg LRESULT OnEnableCtrls(WPARAM wp, LPARAM lp); }; diff --git a/pc/code_twain/sln/usb_tools/resource.h b/pc/code_twain/sln/usb_tools/resource.h index b3abb80..50b49e1 100644 --- a/pc/code_twain/sln/usb_tools/resource.h +++ b/pc/code_twain/sln/usb_tools/resource.h @@ -72,7 +72,6 @@ #define IDC_STATIC_CMD 1043 #define IDC_STATIC_PARAM 1044 #define IDC_STATIC_COUNT 1045 -#define IDC_TAB_OPT 1046 #define IDC_EDIT_CMD_QUE 1047 #define IDC_EDIT_SENT_QUE 1048 #define IDC_EDIT_IND 1049 @@ -89,6 +88,8 @@ #define IDC_STATIC_CMD_QUE 1061 #define IDC_STATIC_SENT_QUE 1062 #define IDC_STATIC_OPTS 1063 +#define IDC_CHECK1 1064 +#define IDC_CHECK_AUTO_OPEN_IMG 1064 #define ID_TRAY_EXIT 32771 // Next default values for new objects @@ -97,7 +98,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 137 #define _APS_NEXT_COMMAND_VALUE 32772 -#define _APS_NEXT_CONTROL_VALUE 1064 +#define _APS_NEXT_CONTROL_VALUE 1065 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/pc/code_twain/sln/usb_tools/scanner/opt_ui/DlgPage.h b/pc/code_twain/sln/usb_tools/scanner/opt_ui/DlgPage.h index 4f88c15..f57d21d 100644 --- a/pc/code_twain/sln/usb_tools/scanner/opt_ui/DlgPage.h +++ b/pc/code_twain/sln/usb_tools/scanner/opt_ui/DlgPage.h @@ -27,6 +27,11 @@ #define WM_REFRESH_OPTION WM_USER + 311 // WPARAM: source option SN, LPARAM: unused now #define WM_GET_CONFIG_OBJ WM_USER + 312 // WPARAM: bool*, [in]create new if NULL; [out]created, LPARAM: to receive the gb::sane_config_schm* object +#define WM_SET_TEXT WM_USER + 320 // WPARAM: id; LPARAM: std::wstring* +#define WM_IS_BUTTON_CHECKED WM_USER + 321 // WPARAM: id; LPARAM: bool* +#define WM_SET_BUTTON_CHECK WM_USER + 322 // WPARAM: id; LPARAM: bool +#define WM_ENABLE_CTRLS WM_USER + 323 // WPARAM: id (0 is click repeat button); LPARAM: bool + extern HMODULE g_my_inst; namespace local_trans diff --git a/pc/code_twain/sln/usb_tools/scanner/scanner_handler.cpp b/pc/code_twain/sln/usb_tools/scanner/scanner_handler.cpp index edc1f61..a034a54 100644 --- a/pc/code_twain/sln/usb_tools/scanner/scanner_handler.cpp +++ b/pc/code_twain/sln/usb_tools/scanner/scanner_handler.cpp @@ -506,11 +506,17 @@ int scanner_handler::option_value_get(const char* name, void* buf, uint32_t size WAIT_COMMAND(call, clean, roger, buf); } -int scanner_handler::option_value_set(const char* name, uint32_t type, void* buf, uint32_t size, uint8_t* after) +int scanner_handler::option_value_set(const char* name, uint32_t type, void* buf, uint32_t size, uint32_t val_size, uint8_t* after) { + struct + { + void* buf; + uint8_t* after; + }param; auto call = [&](cmd_result* cmd) -> int { - return usb_->get_setting_val(cmd->get_id(), name); + memcpy(¶m, cmd->get_param(), sizeof(param)); + return usb_->set_setting(cmd->get_id(), name, type, param.buf, val_size, size); }; auto clean = [&](cmd_result* cmd) -> int { @@ -543,11 +549,6 @@ int scanner_handler::option_value_set(const char* name, uint32_t type, void* buf return nullptr; }; - struct - { - void* buf; - uint8_t* after; - }param; if (!is_scanner_available()) return ENODEV; diff --git a/pc/code_twain/sln/usb_tools/scanner/scanner_handler.h b/pc/code_twain/sln/usb_tools/scanner/scanner_handler.h index 45bca09..943cbe2 100644 --- a/pc/code_twain/sln/usb_tools/scanner/scanner_handler.h +++ b/pc/code_twain/sln/usb_tools/scanner/scanner_handler.h @@ -108,7 +108,7 @@ public: // following methods transferred by Bulk, blocked ... int option_get_all(std::string& json_opts); int option_value_get(const char* name, void* buf, uint32_t size/*buffer size of 'buf'*/); - int option_value_set(const char* name, uint32_t type, void* buf, uint32_t size/*buffer size of 'buf'*/, uint8_t* after); + int option_value_set(const char* name, uint32_t type, void* buf, uint32_t size/*buffer size of 'buf'*/, uint32_t val_size, uint8_t* after); int status_get(void); void set_image_receiver(std::function img); diff --git a/pc/code_twain/sln/usb_tools/scanner/usb/async_usb_host.cpp b/pc/code_twain/sln/usb_tools/scanner/usb/async_usb_host.cpp index 245c0f6..dee692f 100644 --- a/pc/code_twain/sln/usb_tools/scanner/usb/async_usb_host.cpp +++ b/pc/code_twain/sln/usb_tools/scanner/usb/async_usb_host.cpp @@ -584,10 +584,10 @@ int async_usb_host::get_setting_val(uint32_t pack_id, const char* name) return 0; } -int async_usb_host::set_setting(uint32_t pack_id, const char* name, int type, void* val, size_t size) +int async_usb_host::set_setting(uint32_t pack_id, const char* name, int type, void* val, size_t size, size_t size0) { int base = sizeof(PACK_BASE), - datal = strlen(name) + 1 + size; + datal = sizeof(CFGVAL) + strlen(name) + 1 + size; dyn_mem_ptr data(dyn_mem::memory(base + datal)), enc = nullptr; LPPACK_BASE pack = (LPPACK_BASE)data->ptr(); LPCFGVAL param = (LPCFGVAL)pack->payload; @@ -596,6 +596,8 @@ int async_usb_host::set_setting(uint32_t pack_id, const char* name, int type, vo pack->payload_len = datal; param->type = type; param->name_off = 0; + param->max_size = size0; + param->val_size = size; param->val_off = strlen(name) + 1; strcpy(param->data, name); memcpy(param->data + param->val_off, val, size); diff --git a/pc/code_twain/sln/usb_tools/scanner/usb/async_usb_host.h b/pc/code_twain/sln/usb_tools/scanner/usb/async_usb_host.h index e0fef72..67bcff6 100644 --- a/pc/code_twain/sln/usb_tools/scanner/usb/async_usb_host.h +++ b/pc/code_twain/sln/usb_tools/scanner/usb/async_usb_host.h @@ -85,7 +85,7 @@ public: int send_heart_beat(uint32_t pack_id); int get_settings(uint32_t pack_id); int get_setting_val(uint32_t pack_id, const char* name); - int set_setting(uint32_t pack_id, const char* name, int type, void* val, size_t size/*value size*/); + int set_setting(uint32_t pack_id, const char* name, int type, void* val, size_t size/*value size*/, size_t size0/*max size*/); int scan_start(uint32_t pack_id); int scan_stop(uint32_t pack_id); diff --git a/pc/code_twain/sln/usb_tools/usbtools.rc b/pc/code_twain/sln/usb_tools/usbtools.rc index 0b63488..70b31cc 100644 Binary files a/pc/code_twain/sln/usb_tools/usbtools.rc and b/pc/code_twain/sln/usb_tools/usbtools.rc differ