添加设置属性值日志
This commit is contained in:
parent
35c7cbe569
commit
15fb8c3a6b
|
@ -198,8 +198,8 @@ char* scanner_hw::get_value(const char* name, void* value, size_t* size, int* er
|
||||||
|
|
||||||
if(strcmp(name, SANE_FULL_NAME(PAPER_ON)) == 0)
|
if(strcmp(name, SANE_FULL_NAME(PAPER_ON)) == 0)
|
||||||
{
|
{
|
||||||
ret = (char*)malloc(4);
|
ret = (char*)malloc(sizeof(int));
|
||||||
memset(ret, 0, 4);
|
*(int*)ret = 0;
|
||||||
*(bool*)ret = paper_on_;
|
*(bool*)ret = paper_on_;
|
||||||
if(size)
|
if(size)
|
||||||
*size = sizeof(bool);
|
*size = sizeof(bool);
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include <json/gb_json.h>
|
#include <json/gb_json.h>
|
||||||
#include <huagao/hgscanner_error.h>
|
#include <huagao/hgscanner_error.h>
|
||||||
|
#include <sane/sane_ex.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
sane_opt_provider::sane_opt_provider()
|
sane_opt_provider::sane_opt_provider()
|
||||||
|
@ -16,6 +18,20 @@ sane_opt_provider::~sane_opt_provider()
|
||||||
following_.clear();
|
following_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string sane_opt_provider::sane_value_2_text(const char* type, void* value)
|
||||||
|
{
|
||||||
|
if(strcmp(type, JSON_SANE_TYPE_BOOL) == 0)
|
||||||
|
return *(bool*)value ? "true" : "false";
|
||||||
|
else if(strcmp(type, JSON_SANE_TYPE_INT) == 0)
|
||||||
|
return std::to_string(*(int*)value);
|
||||||
|
else if(strcmp(type, JSON_SANE_TYPE_FIXED) == 0)
|
||||||
|
return std::to_string(*(double*)value);
|
||||||
|
else if(strcmp(type, JSON_SANE_TYPE_STRING) == 0)
|
||||||
|
return (char*)value;
|
||||||
|
else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
bool sane_opt_provider::set_opt_json_text(char* txt)
|
bool sane_opt_provider::set_opt_json_text(char* txt)
|
||||||
{
|
{
|
||||||
gb_json* jsn = new gb_json();
|
gb_json* jsn = new gb_json();
|
||||||
|
|
|
@ -22,6 +22,8 @@ protected:
|
||||||
public:
|
public:
|
||||||
sane_opt_provider();
|
sane_opt_provider();
|
||||||
|
|
||||||
|
static std::string sane_value_2_text(const char* type, void* value); // convert to readable text. e.g. bool to "true" or "false", ...
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~sane_opt_provider();
|
virtual ~sane_opt_provider();
|
||||||
|
|
||||||
|
|
|
@ -1716,8 +1716,9 @@ bool device_option::refine_data(const char* name, void* value)
|
||||||
now_->get_value(name, child);
|
now_->get_value(name, child);
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
std::string type("");
|
std::string type(""), org(""), result("");
|
||||||
child->get_value("type", type);
|
child->get_value("type", type);
|
||||||
|
org = sane_opt_provider::sane_value_2_text(type.c_str(), value);
|
||||||
if (type == JSON_SANE_TYPE_BOOL)
|
if (type == JSON_SANE_TYPE_BOOL)
|
||||||
{
|
{
|
||||||
refined = refine_data_to_range<bool>(child, value);
|
refined = refine_data_to_range<bool>(child, value);
|
||||||
|
@ -1734,6 +1735,11 @@ bool device_option::refine_data(const char* name, void* value)
|
||||||
{
|
{
|
||||||
refined = refine_string_data(child, value);
|
refined = refine_string_data(child, value);
|
||||||
}
|
}
|
||||||
|
if(refined)
|
||||||
|
{
|
||||||
|
result = sane_opt_provider::sane_value_2_text(type.c_str(), value);
|
||||||
|
utils::to_log(LOG_LEVEL_DEBUG, "Refine value of '%s' from '%s' to '%s'.\n", name, org.c_str(), result.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
child->release();
|
child->release();
|
||||||
}
|
}
|
||||||
|
@ -1788,11 +1794,13 @@ int device_option::update_data(const char* name, void* value, bool reorder_if_ne
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
child->get_value("type", type);
|
||||||
|
utils::to_log(LOG_LEVEL_DEBUG, "set option '%s' value to '%s' = %d.\n", name, sane_opt_provider::sane_value_2_text(type.c_str(), value).c_str(), err);
|
||||||
|
|
||||||
if (err == SCANNER_ERR_OK || err == SCANNER_ERR_NOT_EXACT
|
if (err == SCANNER_ERR_OK || err == SCANNER_ERR_NOT_EXACT
|
||||||
|| err == SCANNER_ERR_RELOAD_IMAGE_PARAM || err == SCANNER_ERR_RELOAD_OPT_PARAM
|
|| err == SCANNER_ERR_RELOAD_IMAGE_PARAM || err == SCANNER_ERR_RELOAD_OPT_PARAM
|
||||||
|| err == SCANNER_ERR_CONFIGURATION_CHANGED)
|
|| err == SCANNER_ERR_CONFIGURATION_CHANGED)
|
||||||
{
|
{
|
||||||
child->get_value("type", type);
|
|
||||||
if (type == JSON_SANE_TYPE_BOOL)
|
if (type == JSON_SANE_TYPE_BOOL)
|
||||||
{
|
{
|
||||||
child->set_value("cur", *(bool*)value);
|
child->set_value("cur", *(bool*)value);
|
||||||
|
|
Loading…
Reference in New Issue