完善HGLib库的获取和设置设备参数功能
This commit is contained in:
parent
3bca38d7ea
commit
ce963988e3
|
@ -9,11 +9,6 @@ HG_DECLARE_HANDLE(HGVersionMgr);
|
||||||
#define HGVERSION_APPNAME_SCANNER "Scanner"
|
#define HGVERSION_APPNAME_SCANNER "Scanner"
|
||||||
#define HGVERSION_APPNAME_DRIVER "Driver"
|
#define HGVERSION_APPNAME_DRIVER "Driver"
|
||||||
|
|
||||||
#define HGVERSION_DEVACTION_START "start"
|
|
||||||
#define HGVERSION_DEVACTION_CLOSE "close"
|
|
||||||
#define HGVERSION_DEVACTION_CLEAN "clean"
|
|
||||||
#define HGVERSION_DEVACTION_COUNT "count"
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
HGBool postCrashInfo; /* 是否上报崩溃信息 */
|
HGBool postCrashInfo; /* 是否上报崩溃信息 */
|
||||||
|
|
|
@ -612,69 +612,6 @@ static HGResult PostInfo(int type, const std::string& appName, const std::string
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HGResult PostDeviceInfo(const std::string& sn, const std::string& type, const std::string& name,
|
|
||||||
const std::string& fw, const std::string& act, int cnt)
|
|
||||||
{
|
|
||||||
HGResult ret = HGBASE_ERR_FAIL;
|
|
||||||
CURL* curl = curl_easy_init();
|
|
||||||
if (NULL != curl)
|
|
||||||
{
|
|
||||||
std::stringstream out;
|
|
||||||
|
|
||||||
char countStr[16];
|
|
||||||
sprintf(countStr, "%d", cnt);
|
|
||||||
std::string url = "http://cd.holdtecs.net:50080/api/bhs?sn=" + sn + "&type=" + type + "&name=" + name + "&fw=" + fw
|
|
||||||
+ "&act=" + act + "&cnt" + countStr;
|
|
||||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 2);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
||||||
|
|
||||||
struct curl_slist* headers = NULL;
|
|
||||||
headers = curl_slist_append(headers, "Accept-Encoding:gzip, deflate, sdch");
|
|
||||||
headers = curl_slist_append(headers, "Accept-Language:zh-CN,zh;q=0.8");
|
|
||||||
headers = curl_slist_append(headers, "Connection:keep-alive");
|
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
|
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &out);
|
|
||||||
|
|
||||||
/* Perform the request, res will get the return code */
|
|
||||||
CURLcode res = curl_easy_perform(curl);
|
|
||||||
/* Check for errors */
|
|
||||||
if (res != CURLE_OK)
|
|
||||||
fprintf(stderr, "curl_easy_perform() failed: %s", curl_easy_strerror(res));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string str_json = out.str(); // 返回值
|
|
||||||
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "str_json=%s", str_json.c_str());
|
|
||||||
|
|
||||||
cJSON* json = cJSON_Parse(str_json.c_str());
|
|
||||||
if (NULL != json)
|
|
||||||
{
|
|
||||||
cJSON* p = json->child;
|
|
||||||
while (NULL != p)
|
|
||||||
{
|
|
||||||
if (0 == strcmp(p->string, "code") && p->type == cJSON_Number)
|
|
||||||
{
|
|
||||||
if (1 == p->valueint)
|
|
||||||
ret = HGBASE_ERR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = p->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON_Delete(json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
curl_slist_free_all(headers);
|
|
||||||
/* always cleanup */
|
|
||||||
curl_easy_cleanup(curl);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HGResult PostInstallInfo(const std::string& appName, const std::string& desc)
|
static HGResult PostInstallInfo(const std::string& appName, const std::string& desc)
|
||||||
{
|
{
|
||||||
return PostInfo(1, appName, desc, "", "", "", "");
|
return PostInfo(1, appName, desc, "", "", "", "");
|
||||||
|
@ -904,14 +841,6 @@ HGResult HGVersionMgrImpl::PostCrashInfo(const HGChar* appName, const HGChar* de
|
||||||
return ::PostCrashInfo(appName, desc, crashFilePath, exceptionAddr);
|
return ::PostCrashInfo(appName, desc, crashFilePath, exceptionAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
HGResult HGVersionMgrImpl::PostDeviceInfo(const HGChar* sn, const HGChar* type, const HGChar* name, const HGChar* fw, const HGChar* act, int cnt)
|
|
||||||
{
|
|
||||||
if (!m_serverCfg.postDeviceInfo)
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
|
|
||||||
return ::PostDeviceInfo(sn, type, name, fw, act, cnt);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult HGVersionMgrImpl::PostUserFeedback(const HGChar* appName, const HGChar* desc, const HGChar* feedback, const HGChar* contact)
|
HGResult HGVersionMgrImpl::PostUserFeedback(const HGChar* appName, const HGChar* desc, const HGChar* feedback, const HGChar* contact)
|
||||||
{
|
{
|
||||||
return ::PostUserFeedback(appName, desc, feedback, contact);
|
return ::PostUserFeedback(appName, desc, feedback, contact);
|
||||||
|
|
|
@ -14,7 +14,6 @@ public:
|
||||||
HGResult PostInstallInfo(const HGChar* appName, const HGChar* desc);
|
HGResult PostInstallInfo(const HGChar* appName, const HGChar* desc);
|
||||||
HGResult PostUninstallInfo(const HGChar* appName, const HGChar* desc);
|
HGResult PostUninstallInfo(const HGChar* appName, const HGChar* desc);
|
||||||
HGResult PostCrashInfo(const HGChar* appName, const HGChar* desc, const HGChar* crashFilePath, const HGChar* exceptionAddr);
|
HGResult PostCrashInfo(const HGChar* appName, const HGChar* desc, const HGChar* crashFilePath, const HGChar* exceptionAddr);
|
||||||
HGResult PostDeviceInfo(const HGChar *sn, const HGChar* type, const HGChar* name, const HGChar* fw, const HGChar* act, int cnt);
|
|
||||||
HGResult PostUserFeedback(const HGChar* appName, const HGChar* desc, const HGChar* feedback, const HGChar* contact);
|
HGResult PostUserFeedback(const HGChar* appName, const HGChar* desc, const HGChar* feedback, const HGChar* contact);
|
||||||
HGResult GetVersionList(const HGChar* appName, HGVersionInfo** info, HGUInt* count);
|
HGResult GetVersionList(const HGChar* appName, HGVersionInfo** info, HGUInt* count);
|
||||||
HGResult HttpDownload(const HGChar* url, const HGChar* saveFilePath, HGHttpDownloadFunc func, HGPointer param);
|
HGResult HttpDownload(const HGChar* url, const HGChar* saveFilePath, HGHttpDownloadFunc func, HGPointer param);
|
||||||
|
|
|
@ -4,6 +4,47 @@
|
||||||
#include "base/HGImage.h"
|
#include "base/HGImage.h"
|
||||||
#include "HGString.h"
|
#include "HGString.h"
|
||||||
|
|
||||||
|
struct DeviceParam
|
||||||
|
{
|
||||||
|
DeviceParam()
|
||||||
|
{
|
||||||
|
valueType = 0;
|
||||||
|
intValue = 0;
|
||||||
|
doubleValue = 0;
|
||||||
|
boolValue = false;
|
||||||
|
|
||||||
|
rangeType = 0;
|
||||||
|
intValueMin = 0;
|
||||||
|
intValueMax = 0;
|
||||||
|
doubleValueMin = 0;
|
||||||
|
doubleValueMax = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ÅäÖÃÃû
|
||||||
|
std::string title;
|
||||||
|
|
||||||
|
int valueType;
|
||||||
|
std::string stringValue;
|
||||||
|
int intValue;
|
||||||
|
double doubleValue;
|
||||||
|
bool boolValue;
|
||||||
|
|
||||||
|
int rangeType;
|
||||||
|
std::vector<std::string> stringValueList;
|
||||||
|
std::vector<int> intValueList;
|
||||||
|
std::vector<double> doubleValueList;
|
||||||
|
int intValueMin;
|
||||||
|
int intValueMax;
|
||||||
|
double doubleValueMin;
|
||||||
|
double doubleValueMax;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DeviceParamsGroup
|
||||||
|
{
|
||||||
|
std::string groupName;
|
||||||
|
std::vector<DeviceParam> devParams;
|
||||||
|
};
|
||||||
|
|
||||||
HGLock HGLibDeviceImpl::m_lock = NULL;
|
HGLock HGLibDeviceImpl::m_lock = NULL;
|
||||||
HGLibDeviceHotPlugEventFunc HGLibDeviceImpl::m_hotPlugEventFunc = NULL;
|
HGLibDeviceHotPlugEventFunc HGLibDeviceImpl::m_hotPlugEventFunc = NULL;
|
||||||
HGPointer HGLibDeviceImpl::m_hotPlugEventParam = NULL;
|
HGPointer HGLibDeviceImpl::m_hotPlugEventParam = NULL;
|
||||||
|
@ -158,22 +199,345 @@ HGBool HGLibDeviceImpl::Close()
|
||||||
|
|
||||||
HGBool HGLibDeviceImpl::SetParam(const HGLibDeviceSetParam* param, HGUInt count)
|
HGBool HGLibDeviceImpl::SetParam(const HGLibDeviceSetParam* param, HGUInt count)
|
||||||
{
|
{
|
||||||
return HGFALSE;
|
assert(NULL != m_devHandle);
|
||||||
|
if (NULL == param || 0 == count)
|
||||||
|
return HGFALSE;
|
||||||
|
|
||||||
|
HGBool ret = HGTRUE;
|
||||||
|
for (HGUInt i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
bool find = false;
|
||||||
|
|
||||||
|
SANE_Int num_dev_options = 0;
|
||||||
|
sane_control_option(m_devHandle, 0, SANE_ACTION_GET_VALUE, &num_dev_options, NULL);
|
||||||
|
for (int j = 1; j < num_dev_options; ++j)
|
||||||
|
{
|
||||||
|
const SANE_Option_Descriptor* desp = sane_get_option_descriptor(m_devHandle, j);
|
||||||
|
if (NULL == desp)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const char* title = desp->title;
|
||||||
|
while (' ' == *title)
|
||||||
|
++title;
|
||||||
|
|
||||||
|
if (0 == strcmp(param[i].title, title))
|
||||||
|
{
|
||||||
|
if (SANE_TYPE_STRING == desp->type)
|
||||||
|
{
|
||||||
|
if (SANE_STATUS_GOOD != sane_control_option(m_devHandle, j, SANE_ACTION_SET_VALUE, (void*)param[i].stringValue, NULL))
|
||||||
|
ret = HGFALSE;
|
||||||
|
}
|
||||||
|
else if (SANE_TYPE_INT == desp->type)
|
||||||
|
{
|
||||||
|
SANE_Int value = param[i].intValue;
|
||||||
|
if (SANE_STATUS_GOOD != sane_control_option(m_devHandle, j, SANE_ACTION_SET_VALUE, &value, NULL))
|
||||||
|
ret = HGFALSE;
|
||||||
|
}
|
||||||
|
else if (SANE_TYPE_FIXED == desp->type)
|
||||||
|
{
|
||||||
|
SANE_Fixed value = SANE_FIX(param[i].doubleValue);
|
||||||
|
if (SANE_STATUS_GOOD != sane_control_option(m_devHandle, j, SANE_ACTION_SET_VALUE, &value, NULL))
|
||||||
|
ret = HGFALSE;
|
||||||
|
}
|
||||||
|
else if (SANE_TYPE_BOOL == desp->type)
|
||||||
|
{
|
||||||
|
SANE_Bool value = (SANE_Bool)param[i].boolValue;
|
||||||
|
if (SANE_STATUS_GOOD != sane_control_option(m_devHandle, j, SANE_ACTION_SET_VALUE, &value, NULL))
|
||||||
|
ret = HGFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
find = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!find)
|
||||||
|
ret = HGFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGLibDeviceGetParamGroup* HGLibDeviceImpl::GetParamGroupList(HGUInt* count)
|
HGLibDeviceGetParamGroup* HGLibDeviceImpl::GetParamGroupList(HGUInt* count)
|
||||||
{
|
{
|
||||||
return NULL;
|
assert(NULL != m_devHandle);
|
||||||
|
if (NULL == count)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
std::vector<DeviceParamsGroup> devParams;
|
||||||
|
|
||||||
|
SANE_Int num_dev_options = 0;
|
||||||
|
sane_control_option(m_devHandle, 0, SANE_ACTION_GET_VALUE, &num_dev_options, NULL);
|
||||||
|
for (int i = 1; i < num_dev_options; ++i)
|
||||||
|
{
|
||||||
|
const SANE_Option_Descriptor* desp = sane_get_option_descriptor(m_devHandle, i);
|
||||||
|
if (NULL == desp)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const char* title = desp->title;
|
||||||
|
while (' ' == *title)
|
||||||
|
++title;
|
||||||
|
|
||||||
|
if (SANE_TYPE_GROUP == desp->type)
|
||||||
|
{
|
||||||
|
DeviceParamsGroup group;
|
||||||
|
group.groupName = title;
|
||||||
|
devParams.push_back(group);
|
||||||
|
}
|
||||||
|
else if (SANE_TYPE_STRING == desp->type)
|
||||||
|
{
|
||||||
|
char value[256] = { 0 };
|
||||||
|
sane_control_option(m_devHandle, i, SANE_ACTION_GET_VALUE, value, NULL);
|
||||||
|
|
||||||
|
DeviceParam devParam;
|
||||||
|
devParam.title = title;
|
||||||
|
devParam.valueType = HGLIB_DEVPARAM_TYPE_STRING;
|
||||||
|
devParam.stringValue = value;
|
||||||
|
|
||||||
|
assert(SANE_CONSTRAINT_STRING_LIST == desp->constraint_type);
|
||||||
|
|
||||||
|
devParam.rangeType = HGLIB_DEVPARAM_RANGETYPE_STRINGLIST;
|
||||||
|
const SANE_String_Const* p = desp->constraint.string_list;
|
||||||
|
while (NULL != *p)
|
||||||
|
{
|
||||||
|
devParam.stringValueList.push_back(*p);
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(!devParams.empty());
|
||||||
|
devParams[devParams.size() - 1].devParams.push_back(devParam);
|
||||||
|
}
|
||||||
|
else if (SANE_TYPE_INT == desp->type)
|
||||||
|
{
|
||||||
|
SANE_Int value = 0;
|
||||||
|
sane_control_option(m_devHandle, i, SANE_ACTION_GET_VALUE, &value, NULL);
|
||||||
|
|
||||||
|
DeviceParam devParam;
|
||||||
|
devParam.title = title;
|
||||||
|
devParam.valueType = HGLIB_DEVPARAM_TYPE_INT;
|
||||||
|
devParam.intValue = (int)value;
|
||||||
|
|
||||||
|
if (SANE_CONSTRAINT_WORD_LIST == desp->constraint_type)
|
||||||
|
{
|
||||||
|
devParam.rangeType = HGLIB_DEVPARAM_RANGETYPE_INTLIST;
|
||||||
|
const SANE_Word* p = desp->constraint.word_list;
|
||||||
|
for (SANE_Int i = 0; i < p[0]; ++i)
|
||||||
|
{
|
||||||
|
devParam.intValueList.push_back(p[i + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (SANE_CONSTRAINT_RANGE == desp->constraint_type)
|
||||||
|
{
|
||||||
|
devParam.rangeType = HGLIB_DEVPARAM_RANGETYPE_INTRANGE;
|
||||||
|
devParam.intValueMin = desp->constraint.range->min;
|
||||||
|
devParam.intValueMax = desp->constraint.range->max;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(!devParams.empty());
|
||||||
|
devParams[devParams.size() - 1].devParams.push_back(devParam);
|
||||||
|
}
|
||||||
|
else if (SANE_TYPE_FIXED == desp->type)
|
||||||
|
{
|
||||||
|
SANE_Word value = 0;
|
||||||
|
sane_control_option(m_devHandle, i, SANE_ACTION_GET_VALUE, &value, NULL);
|
||||||
|
|
||||||
|
DeviceParam devParam;
|
||||||
|
devParam.title = title;
|
||||||
|
devParam.valueType = HGLIB_DEVPARAM_TYPE_DOUBLE;
|
||||||
|
devParam.doubleValue = SANE_UNFIX(value);
|
||||||
|
|
||||||
|
if (SANE_CONSTRAINT_WORD_LIST == desp->constraint_type)
|
||||||
|
{
|
||||||
|
devParam.rangeType = HGLIB_DEVPARAM_RANGETYPE_DOUBLELIST;
|
||||||
|
const SANE_Word* p = desp->constraint.word_list;
|
||||||
|
for (SANE_Int i = 0; i < p[0]; ++i)
|
||||||
|
{
|
||||||
|
devParam.doubleValueList.push_back(SANE_UNFIX(p[i + 1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (SANE_CONSTRAINT_RANGE == desp->constraint_type)
|
||||||
|
{
|
||||||
|
devParam.rangeType = HGLIB_DEVPARAM_RANGETYPE_DOUBLERANGE;
|
||||||
|
devParam.doubleValueMin = SANE_UNFIX(desp->constraint.range->min);
|
||||||
|
devParam.doubleValueMax = SANE_UNFIX(desp->constraint.range->max);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(!devParams.empty());
|
||||||
|
devParams[devParams.size() - 1].devParams.push_back(devParam);
|
||||||
|
}
|
||||||
|
else if (SANE_TYPE_BOOL == desp->type)
|
||||||
|
{
|
||||||
|
SANE_Bool value = 0;
|
||||||
|
sane_control_option(m_devHandle, i, SANE_ACTION_GET_VALUE, &value, NULL);
|
||||||
|
|
||||||
|
DeviceParam devParam;
|
||||||
|
devParam.title = title;
|
||||||
|
devParam.valueType = HGLIB_DEVPARAM_TYPE_BOOL;
|
||||||
|
devParam.boolValue = (bool)value;
|
||||||
|
|
||||||
|
devParam.rangeType = HGLIB_DEVPARAM_RANGETYPE_NULL;
|
||||||
|
|
||||||
|
assert(!devParams.empty());
|
||||||
|
devParams[devParams.size() - 1].devParams.push_back(devParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*count = (HGUInt)devParams.size();
|
||||||
|
HGLibDeviceGetParamGroup* paramGroup = (HGLibDeviceGetParamGroup*)malloc((*count) * sizeof(HGLibDeviceGetParamGroup));
|
||||||
|
if (NULL != paramGroup)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (int)devParams.size(); ++i)
|
||||||
|
{
|
||||||
|
paramGroup[i].groupName = (HGChar *)malloc(devParams[i].groupName.size() + 1);
|
||||||
|
if (NULL != paramGroup[i].groupName)
|
||||||
|
strcpy(paramGroup[i].groupName, devParams[i].groupName.c_str());
|
||||||
|
|
||||||
|
paramGroup[i].paramCount = (HGUInt)devParams[i].devParams.size();
|
||||||
|
paramGroup[i].param = (HGLibDeviceGetParam*)malloc(paramGroup[i].paramCount * sizeof(HGLibDeviceGetParam));
|
||||||
|
if (NULL != paramGroup[i].param)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < (int)devParams[i].devParams.size(); ++j)
|
||||||
|
{
|
||||||
|
HGLibDeviceGetParam& dest = paramGroup[i].param[j];
|
||||||
|
DeviceParam& src = devParams[i].devParams[j];
|
||||||
|
|
||||||
|
dest.param.title = (HGChar *)malloc(src.title.size() + 1);
|
||||||
|
if (NULL != dest.param.title)
|
||||||
|
strcpy(dest.param.title, src.title.c_str());
|
||||||
|
|
||||||
|
dest.param.type = src.valueType;
|
||||||
|
if (HGLIB_DEVPARAM_TYPE_INT == dest.param.type)
|
||||||
|
dest.param.intValue = src.intValue;
|
||||||
|
else if (HGLIB_DEVPARAM_TYPE_DOUBLE == dest.param.type)
|
||||||
|
dest.param.doubleValue = src.doubleValue;
|
||||||
|
else if (HGLIB_DEVPARAM_TYPE_BOOL == dest.param.type)
|
||||||
|
dest.param.boolValue = (HGBool)src.boolValue;
|
||||||
|
else if (HGLIB_DEVPARAM_TYPE_STRING == dest.param.type)
|
||||||
|
{
|
||||||
|
dest.param.stringValue = (HGChar *)malloc(src.stringValue.size() + 1);
|
||||||
|
if (NULL != dest.param.stringValue)
|
||||||
|
strcpy(dest.param.stringValue, src.stringValue.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
dest.rangeType = src.rangeType;
|
||||||
|
if (HGLIB_DEVPARAM_RANGETYPE_INTLIST == dest.rangeType)
|
||||||
|
{
|
||||||
|
dest.intValueList.count = src.intValueList.size();
|
||||||
|
dest.intValueList.value = (HGInt *)malloc(dest.intValueList.count * sizeof(HGInt));
|
||||||
|
if (NULL != dest.intValueList.value)
|
||||||
|
{
|
||||||
|
for (int k = 0; k < (int)src.intValueList.size(); ++k)
|
||||||
|
{
|
||||||
|
dest.intValueList.value[k] = src.intValueList[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (HGLIB_DEVPARAM_RANGETYPE_DOUBLELIST == dest.rangeType)
|
||||||
|
{
|
||||||
|
dest.doubleValueList.count = src.doubleValueList.size();
|
||||||
|
dest.doubleValueList.value = (HGDouble*)malloc(dest.doubleValueList.count * sizeof(HGDouble));
|
||||||
|
if (NULL != dest.doubleValueList.value)
|
||||||
|
{
|
||||||
|
for (int k = 0; k < (int)src.doubleValueList.size(); ++k)
|
||||||
|
{
|
||||||
|
dest.doubleValueList.value[k] = src.doubleValueList[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (HGLIB_DEVPARAM_RANGETYPE_INTRANGE == dest.rangeType)
|
||||||
|
{
|
||||||
|
dest.intValueRange.minValue = src.intValueMin;
|
||||||
|
dest.intValueRange.maxValue = src.intValueMax;
|
||||||
|
}
|
||||||
|
else if (HGLIB_DEVPARAM_RANGETYPE_DOUBLERANGE == dest.rangeType)
|
||||||
|
{
|
||||||
|
dest.doubleValueRange.minValue = src.doubleValueMin;
|
||||||
|
dest.doubleValueRange.maxValue = src.doubleValueMax;
|
||||||
|
}
|
||||||
|
else if (HGLIB_DEVPARAM_RANGETYPE_STRINGLIST == dest.rangeType)
|
||||||
|
{
|
||||||
|
dest.stringValueList.count = src.stringValueList.size();
|
||||||
|
dest.stringValueList.value = (HGChar **)malloc(dest.stringValueList.count * sizeof(HGChar *));
|
||||||
|
if (NULL != dest.stringValueList.value)
|
||||||
|
{
|
||||||
|
for (int k = 0; k < (int)src.stringValueList.size(); ++k)
|
||||||
|
{
|
||||||
|
dest.stringValueList.value[k] = (HGChar *)malloc(src.stringValueList[k].size() + 1);
|
||||||
|
if (NULL != dest.stringValueList.value[k])
|
||||||
|
strcpy(dest.stringValueList.value[k], src.stringValueList[k].c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return paramGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGBool HGLibDeviceImpl::ReleaseParamGroupList(HGLibDeviceGetParamGroup* paramGroup, HGUInt count)
|
HGBool HGLibDeviceImpl::ReleaseParamGroupList(HGLibDeviceGetParamGroup* paramGroup, HGUInt count)
|
||||||
{
|
{
|
||||||
return HGFALSE;
|
if (NULL == paramGroup || 0 == count)
|
||||||
|
{
|
||||||
|
return HGFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (HGUInt i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
for (HGUInt j = 0; j < paramGroup[i].paramCount; ++j)
|
||||||
|
{
|
||||||
|
free(paramGroup[i].param[j].param.title);
|
||||||
|
if (HGLIB_DEVPARAM_TYPE_STRING == paramGroup[i].param[j].param.type)
|
||||||
|
free(paramGroup[i].param[j].param.stringValue);
|
||||||
|
|
||||||
|
if (HGLIB_DEVPARAM_RANGETYPE_INTLIST == paramGroup[i].param[j].rangeType)
|
||||||
|
free(paramGroup[i].param[j].intValueList.value);
|
||||||
|
else if (HGLIB_DEVPARAM_RANGETYPE_DOUBLELIST == paramGroup[i].param[j].rangeType)
|
||||||
|
free(paramGroup[i].param[j].doubleValueList.value);
|
||||||
|
else if (HGLIB_DEVPARAM_RANGETYPE_STRINGLIST == paramGroup[i].param[j].rangeType)
|
||||||
|
{
|
||||||
|
for (HGUInt k = 0; k < paramGroup[i].param[j].stringValueList.count; ++k)
|
||||||
|
free(paramGroup[i].param[j].stringValueList.value[k]);
|
||||||
|
free(paramGroup[i].param[j].stringValueList.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(paramGroup[i].groupName);
|
||||||
|
free(paramGroup[i].param);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(paramGroup);
|
||||||
|
return HGTRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGBool HGLibDeviceImpl::ResetParam()
|
HGBool HGLibDeviceImpl::ResetParam()
|
||||||
{
|
{
|
||||||
return HGFALSE;
|
assert(NULL != m_devHandle);
|
||||||
|
|
||||||
|
HGBool ret = HGFALSE;
|
||||||
|
|
||||||
|
SANE_Int num_dev_options = 0;
|
||||||
|
sane_control_option(m_devHandle, 0, SANE_ACTION_GET_VALUE, &num_dev_options, NULL);
|
||||||
|
for (int i = 1; i < num_dev_options; ++i)
|
||||||
|
{
|
||||||
|
const SANE_Option_Descriptor* desp = sane_get_option_descriptor(m_devHandle, i);
|
||||||
|
if (NULL == desp)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const char* title = desp->title;
|
||||||
|
while (' ' == *title)
|
||||||
|
++title;
|
||||||
|
|
||||||
|
if (0 == strcmp(OPTION_TITLE_HFMRSZ, title) && SANE_TYPE_BUTTON == desp->type)
|
||||||
|
{
|
||||||
|
if (SANE_STATUS_GOOD == sane_control_option(m_devHandle, i, SANE_ACTION_SET_VALUE, NULL, NULL))
|
||||||
|
ret = HGTRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGBool HGLibDeviceImpl::StartScan(HGLibDeviceScanEventFunc eventFunc, HGPointer eventParam,
|
HGBool HGLibDeviceImpl::StartScan(HGLibDeviceScanEventFunc eventFunc, HGPointer eventParam,
|
||||||
|
|
|
@ -28,11 +28,12 @@ HG_DECLARE_HANDLE(HGLibDevice);
|
||||||
#define HGLIB_DEVPARAM_TYPE_BOOL 4L
|
#define HGLIB_DEVPARAM_TYPE_BOOL 4L
|
||||||
|
|
||||||
/* 设备参数取值范围类型 */
|
/* 设备参数取值范围类型 */
|
||||||
#define HGLIB_DEVPARAM_RANDETYPE_INTLIST 1L
|
#define HGLIB_DEVPARAM_RANGETYPE_NULL 0L
|
||||||
#define HGLIB_DEVPARAM_RANDETYPE_STRINGLIST 2L
|
#define HGLIB_DEVPARAM_RANGETYPE_INTLIST 1L
|
||||||
#define HGLIB_DEVPARAM_RANDETYPE_DOUBLELIST 3L
|
#define HGLIB_DEVPARAM_RANGETYPE_STRINGLIST 2L
|
||||||
#define HGLIB_DEVPARAM_RANDETYPE_INTRANGE 4L
|
#define HGLIB_DEVPARAM_RANGETYPE_DOUBLELIST 3L
|
||||||
#define HGLIB_DEVPARAM_RANDETYPE_DOUBLERANGE 5L
|
#define HGLIB_DEVPARAM_RANGETYPE_INTRANGE 4L
|
||||||
|
#define HGLIB_DEVPARAM_RANGETYPE_DOUBLERANGE 5L
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue