diff --git a/build2/qt/HGScannerLib/HGScannerLib.def b/build2/qt/HGScannerLib/HGScannerLib.def index 3811566f..a0a4da85 100644 --- a/build2/qt/HGScannerLib/HGScannerLib.def +++ b/build2/qt/HGScannerLib/HGScannerLib.def @@ -18,8 +18,12 @@ HGLib_GetDeviceNameList HGLib_ReleaseDeviceNameList HGLib_OpenDevice HGLib_CloseDevice +HGLib_GetDeviceType HGLib_GetDeviceSN HGLib_GetDeviceFWVersion +HGLib_GetDeviceRollerCount +HGLib_GetDeviceTotalCount +HGLib_ClearDeviceRollerCount HGLib_SetDeviceParam HGLib_GetDeviceParamGroupList HGLib_GetDeviceParam @@ -48,8 +52,12 @@ Java_com_easing_java_HGScannerLib_DeinitDevice Java_com_easing_java_HGScannerLib_GetDeviceNameList Java_com_easing_java_HGScannerLib_OpenDevice Java_com_easing_java_HGScannerLib_CloseDevice +Java_com_easing_java_HGScannerLib_GetDeviceType Java_com_easing_java_HGScannerLib_GetDeviceSN Java_com_easing_java_HGScannerLib_GetDeviceFWVersion +Java_com_easing_java_HGScannerLib_GetDeviceRollerCount +Java_com_easing_java_HGScannerLib_GetDeviceTotalCount +Java_com_easing_java_HGScannerLib_ClearDeviceRollerCount Java_com_easing_java_HGScannerLib_StartDeviceScan Java_com_easing_java_HGScannerLib_StopDeviceScan Java_com_easing_java_HGScannerLib_GetDeviceParamGroupList diff --git a/doc/scannerlib/新版SDK接口说明.doc b/doc/scannerlib/新版SDK接口说明.doc index 51b68621..c55f78c8 100644 Binary files a/doc/scannerlib/新版SDK接口说明.doc and b/doc/scannerlib/新版SDK接口说明.doc differ diff --git a/doc/scannerlib/新版SDK接口说明.pdf b/doc/scannerlib/新版SDK接口说明.pdf index a3274927..1c735074 100644 Binary files a/doc/scannerlib/新版SDK接口说明.pdf and b/doc/scannerlib/新版SDK接口说明.pdf differ diff --git a/sdk/scannerlib/HGLibDeviceImpl.cpp b/sdk/scannerlib/HGLibDeviceImpl.cpp index 1fc43d27..f960f0df 100644 --- a/sdk/scannerlib/HGLibDeviceImpl.cpp +++ b/sdk/scannerlib/HGLibDeviceImpl.cpp @@ -391,58 +391,73 @@ HGBool HGLibDeviceImpl::Close() return HGTRUE; } +HGBool HGLibDeviceImpl::GetType(HGChar *type, HGUInt maxLen) +{ + assert(NULL != m_devHandle); + return GetValueStr256(0x8855, type, maxLen); +} + HGBool HGLibDeviceImpl::GetSN(HGChar* sn, HGUInt maxLen) { - if (NULL == sn || 0 == maxLen) - { - return HGFALSE; - } - assert(NULL != m_devHandle); - - std::string serialNum; - unsigned int serialNumLen = 0; - m_statusCode = sane_io_control(m_devHandle, IO_CTRL_CODE_GET_SERIAL, NULL, &serialNumLen); - if (SANE_STATUS_NO_MEM == m_statusCode && serialNumLen) - { - serialNum.resize(serialNumLen); - m_statusCode = sane_io_control(m_devHandle, IO_CTRL_CODE_GET_SERIAL, &serialNum[0], &serialNumLen); - } - - if (serialNum.empty() || maxLen < serialNum.size() + 1) - { - return HGFALSE; - } - - strcpy(sn, serialNum.c_str()); - return HGTRUE; + return GetValueStr256(0x8856, sn, maxLen); } HGBool HGLibDeviceImpl::GetFWVersion(HGChar* fwVersion, HGUInt maxLen) { - if (NULL == fwVersion || 0 == maxLen) - { - return HGFALSE; - } - assert(NULL != m_devHandle); + return GetValueStr256(0x8857, fwVersion, maxLen); +} - std::string versionNum; - unsigned int versionNumLen = 0; - m_statusCode = sane_io_control(m_devHandle, IO_CTRL_CODE_GET_HARDWARE_VERSION, NULL, &versionNumLen); - if (SANE_STATUS_NO_MEM == m_statusCode && versionNumLen) - { - versionNum.resize(versionNumLen); - m_statusCode = sane_io_control(m_devHandle, IO_CTRL_CODE_GET_HARDWARE_VERSION, &versionNum[0], &versionNumLen); - } +HGInt HGLibDeviceImpl::GetRollerCount() +{ + assert(NULL != m_devHandle); + HGInt ret = -1; + GetValueInt32(0x9902, &ret); + return ret; +} - if (versionNum.empty() || maxLen < versionNum.size() + 1) - { - return HGFALSE; - } +HGInt HGLibDeviceImpl::GetTotalCount() +{ + assert(NULL != m_devHandle); + HGInt ret = -1; + GetValueInt32(0x8849, &ret); + return ret; +} - strcpy(fwVersion, versionNum.c_str()); - return HGTRUE; +HGBool HGLibDeviceImpl::ClearRollerCount() +{ + assert(NULL != m_devHandle); + + std::string userName = "user"; + std::string password; + +#if defined(OEM_HANWANG) + password = "hanvonscan"; +#elif defined(OEM_LISICHENG) + password = "lanxum"; +#elif defined(OEM_CANGTIAN) + password = "cumtenn"; +#elif defined(OEM_ZHONGJING) + password = "microtek"; +#elif defined(OEM_ZIGUANG) + password = "uniscan"; +#elif defined(OEM_NEUTRAL) + password = "scan"; +#elif defined(OEM_DELI) + password = "deliscan"; +#else + password = "huagoscan"; +#endif + + HGBool ret = Login(userName.c_str(), password.c_str()); + if (ret) + { + ret = SetValueInt32(0x9902, 0); + Logout(); + } + + return ret; } HGBool HGLibDeviceImpl::SetParam(HGUInt option, const HGVoid* data) @@ -1073,6 +1088,81 @@ HGInt HGLibDeviceImpl::GetOperateCode() return m_statusCode; } +HGBool HGLibDeviceImpl::Login(const HGChar *user, const HGChar *pwd) +{ + if (NULL == user || strlen(user) >= 32 + || NULL == pwd || strlen(pwd) >= 32) + { + return HGFALSE; + } + + HGChar value[256] = {0}; + strcpy(value, user); + strcpy(value + 32, pwd); + return SetValueStr256(0x9900, value); +} + +HGBool HGLibDeviceImpl::Logout() +{ + HGChar value[256] = {0}; + return SetValueStr256(0x9901, value); +} + +HGBool HGLibDeviceImpl::SetValueInt32(HGUInt optionId, HGInt value) +{ + SANE_Int v = (SANE_Int)value; + m_statusCode = sane_control_option(m_devHandle, (SANE_Int)optionId, SANE_ACTION_SET_VALUE, &v, NULL); + return (SANE_STATUS_GOOD == m_statusCode) ? HGTRUE : HGFALSE; +} + +HGBool HGLibDeviceImpl::GetValueInt32(HGUInt optionId, HGInt *value) +{ + SANE_Int v = 0; + m_statusCode = sane_control_option(m_devHandle, (SANE_Int)optionId, SANE_ACTION_GET_VALUE, &v, NULL); + if (SANE_STATUS_GOOD != m_statusCode) + { + return HGFALSE; + } + + *value = (HGInt)v; + return HGTRUE; +} + +HGBool HGLibDeviceImpl::SetValueStr256(HGUInt optionId, const HGChar *value) +{ + if (NULL == value || strlen(value) >= 256) + { + return HGFALSE; + } + + const char *v = value; + m_statusCode = sane_control_option(m_devHandle, (SANE_Int)optionId, SANE_ACTION_SET_VALUE, (void*)v, NULL); + return (SANE_STATUS_GOOD == m_statusCode) ? HGTRUE : HGFALSE; +} + +HGBool HGLibDeviceImpl::GetValueStr256(HGUInt optionId, HGChar *value, HGUInt maxLen) +{ + if (NULL == value || 0 == maxLen) + { + return HGFALSE; + } + + char v[256] = {0}; + m_statusCode = sane_control_option(m_devHandle, (SANE_Int)optionId, SANE_ACTION_GET_VALUE, v, NULL); + if (SANE_STATUS_GOOD != m_statusCode) + { + return HGFALSE; + } + + if (maxLen <= strlen(v)) + { + return HGFALSE; + } + + strcpy(value, v); + return HGTRUE; +} + const char* HGLibDeviceImpl::GetGroupName(HGUInt group) { if (group > HGLIB_GROUP_NAME_PAPERFEEDING) diff --git a/sdk/scannerlib/HGLibDeviceImpl.hpp b/sdk/scannerlib/HGLibDeviceImpl.hpp index a47f3c4b..f60beb29 100644 --- a/sdk/scannerlib/HGLibDeviceImpl.hpp +++ b/sdk/scannerlib/HGLibDeviceImpl.hpp @@ -23,8 +23,12 @@ public: static HGLibDeviceImpl* Open(const HGChar* deviceName); HGBool Close(); + HGBool GetType(HGChar *type, HGUInt maxLen); HGBool GetSN(HGChar* sn, HGUInt maxLen); HGBool GetFWVersion(HGChar* fwVersion, HGUInt maxLen); + HGInt GetRollerCount(); + HGInt GetTotalCount(); + HGBool ClearRollerCount(); HGBool SetParam(HGUInt option, const HGVoid* data); HGLibDeviceParamGroup* GetParamGroupList(HGUInt* count); HGLibDeviceParam* GetParam(HGUInt option); @@ -42,6 +46,12 @@ public: HGInt GetOperateCode(); private: + HGBool Login(const HGChar *user, const HGChar *pwd); + HGBool Logout(); + HGBool SetValueInt32(HGUInt optionId, HGInt value); + HGBool GetValueInt32(HGUInt optionId, HGInt *value); + HGBool SetValueStr256(HGUInt optionId, const HGChar *value); + HGBool GetValueStr256(HGUInt optionId, HGChar *value, HGUInt maxLen); static const char* GetGroupName(HGUInt group); static HGUInt GetGroupName(const char* group); static const char* GetOptionName(HGUInt option); diff --git a/sdk/scannerlib/HGScannerLib.cpp b/sdk/scannerlib/HGScannerLib.cpp index 334a2c9f..2a5bf2ba 100644 --- a/sdk/scannerlib/HGScannerLib.cpp +++ b/sdk/scannerlib/HGScannerLib.cpp @@ -259,6 +259,17 @@ HGBool HGAPI HGLib_CloseDevice(HGLibDevice device) return deviceImpl->Close(); } +HGBool HGAPI HGLib_GetDeviceType(HGLibDevice device, HGChar *type, HGUInt maxLen) +{ + if (NULL == device) + { + return HGFALSE; + } + + HGLibDeviceImpl* deviceImpl = (HGLibDeviceImpl*)device; + return deviceImpl->GetType(type, maxLen); +} + HGBool HGAPI HGLib_GetDeviceSN(HGLibDevice device, HGChar* sn, HGUInt maxLen) { if (NULL == device) @@ -281,6 +292,39 @@ HGBool HGAPI HGLib_GetDeviceFWVersion(HGLibDevice device, HGChar* fwVersion, HGU return deviceImpl->GetFWVersion(fwVersion, maxLen); } +HGInt HGAPI HGLib_GetDeviceRollerCount(HGLibDevice device) +{ + if (NULL == device) + { + return -1; + } + + HGLibDeviceImpl* deviceImpl = (HGLibDeviceImpl*)device; + return deviceImpl->GetRollerCount(); +} + +HGInt HGAPI HGLib_GetDeviceTotalCount(HGLibDevice device) +{ + if (NULL == device) + { + return -1; + } + + HGLibDeviceImpl* deviceImpl = (HGLibDeviceImpl*)device; + return deviceImpl->GetTotalCount(); +} + +HGBool HGAPI HGLib_ClearDeviceRollerCount(HGLibDevice device) +{ + if (NULL == device) + { + return HGFALSE; + } + + HGLibDeviceImpl* deviceImpl = (HGLibDeviceImpl*)device; + return deviceImpl->ClearRollerCount(); +} + HGBool HGAPI HGLib_SetDeviceParam(HGLibDevice device, HGUInt option, const HGVoid* data) { if (NULL == device) diff --git a/sdk/scannerlib/HGScannerLib.h b/sdk/scannerlib/HGScannerLib.h index daba5ad6..ce559d41 100644 --- a/sdk/scannerlib/HGScannerLib.h +++ b/sdk/scannerlib/HGScannerLib.h @@ -569,12 +569,24 @@ HGEXPORT HGLibDevice HGAPI HGLib_OpenDevice(const HGChar *deviceName); /* 关闭设备 */ HGEXPORT HGBool HGAPI HGLib_CloseDevice(HGLibDevice device); +/* 获取设备型号 */ +HGEXPORT HGBool HGAPI HGLib_GetDeviceType(HGLibDevice device, HGChar *type, HGUInt maxLen); + /* 获取设备序列号 */ HGEXPORT HGBool HGAPI HGLib_GetDeviceSN(HGLibDevice device, HGChar *sn, HGUInt maxLen); /* 获取设备固件版本号*/ HGEXPORT HGBool HGAPI HGLib_GetDeviceFWVersion(HGLibDevice device, HGChar* fwVersion, HGUInt maxLen); +/* 获取设备滚轴计数 */ +HGEXPORT HGInt HGAPI HGLib_GetDeviceRollerCount(HGLibDevice device); + +/* 获取设备历史扫描张数 */ +HGEXPORT HGInt HGAPI HGLib_GetDeviceTotalCount(HGLibDevice device); + +/* 清除滚轴计数 */ +HGEXPORT HGBool HGAPI HGLib_ClearDeviceRollerCount(HGLibDevice device); + /* 设置设备参数 */ HGEXPORT HGBool HGAPI HGLib_SetDeviceParam(HGLibDevice device, HGUInt option, const HGVoid *data); diff --git a/sdk/scannerlib/HGScannerLibJni.cpp b/sdk/scannerlib/HGScannerLibJni.cpp index e1c79caa..61c8c0d2 100644 --- a/sdk/scannerlib/HGScannerLibJni.cpp +++ b/sdk/scannerlib/HGScannerLibJni.cpp @@ -335,6 +335,30 @@ extern "C" JNIEXPORT jboolean JNICALL Java_com_easing_java_HGScannerLib_CloseDev return (jboolean)ret; } +extern "C" JNIEXPORT jstring JNICALL Java_com_easing_java_HGScannerLib_GetDeviceType( + JNIEnv* env, jclass clazz, jlong dev) +{ + (void)clazz; + printf("\nJava_com_easing_java_HGScannerLib_GetDeviceType\n"); + + jstring type; + + HGChar type2[256]; + HGBool ret = HGLib_GetDeviceType((HGLibDevice)dev, type2, 256); + printf("ret=%d\n", ret); + if (ret) + { + type = env->NewStringUTF(type2); + } + else + { + type = env->NewStringUTF(NULL); + } + + printf("\n"); + return type; +} + extern "C" JNIEXPORT jstring JNICALL Java_com_easing_java_HGScannerLib_GetDeviceSN( JNIEnv* env, jclass clazz, jlong dev) { @@ -383,6 +407,48 @@ extern "C" JNIEXPORT jstring JNICALL Java_com_easing_java_HGScannerLib_GetDevice return fwVersion; } +extern "C" JNIEXPORT jint JNICALL Java_com_easing_java_HGScannerLib_GetDeviceRollerCount( + JNIEnv* env, jclass clazz, jlong dev) +{ + (void)env; + (void)clazz; + printf("\nJava_com_easing_java_HGScannerLib_GetDeviceRollerCount\n"); + + HGInt rollerCount = HGLib_GetDeviceRollerCount((HGLibDevice)dev); + printf("rollerCount=%d\n", rollerCount); + + printf("\n"); + return (jint)rollerCount; +} + +extern "C" JNIEXPORT jint JNICALL Java_com_easing_java_HGScannerLib_GetDeviceTotalCount( + JNIEnv* env, jclass clazz, jlong dev) +{ + (void)env; + (void)clazz; + printf("\nJava_com_easing_java_HGScannerLib_GetDeviceTotalCount\n"); + + HGInt totalCount = HGLib_GetDeviceTotalCount((HGLibDevice)dev); + printf("totalCount=%d\n", totalCount); + + printf("\n"); + return (jint)totalCount; +} + +extern "C" JNIEXPORT jboolean JNICALL Java_com_easing_java_HGScannerLib_ClearDeviceRollerCount( + JNIEnv* env, jclass clazz, jlong dev) +{ + (void)env; + (void)clazz; + printf("\nJava_com_easing_java_HGScannerLib_ClearDeviceRollerCount\n"); + + HGBool ret = HGLib_ClearDeviceRollerCount((HGLibDevice)dev); + printf("ret=%d\n", ret); + + printf("\n"); + return (jboolean)ret; +} + static void HGAPI DeviceScanEventFunc(HGLibDevice device, HGUInt event, HGBool err, const HGChar *info, HGPointer param) { (void)param; diff --git a/test/scannerlib/huagao/java/com/easing/java/HGScannerLib.java b/test/scannerlib/huagao/java/com/easing/java/HGScannerLib.java index 805a9c55..efc1c997 100644 --- a/test/scannerlib/huagao/java/com/easing/java/HGScannerLib.java +++ b/test/scannerlib/huagao/java/com/easing/java/HGScannerLib.java @@ -81,8 +81,12 @@ public class HGScannerLib { public native String[] GetDeviceNameList(); public native long OpenDevice(String deviceName); public native boolean CloseDevice(long dev); + public native String GetDeviceType(long dev); public native String GetDeviceSN(long dev); public native String GetDeviceFWVersion(long dev); + public native int GetDeviceRollerCount(long dev); + public native int GetDeviceTotalCount(long dev); + public native boolean ClearDeviceRollerCount(long dev); public native boolean StartDeviceScan(long dev); public native boolean StopDeviceScan(long dev); public native HGLibDeviceParamGroup[] GetDeviceParamGroupList(long dev);