实现部分导出接口
This commit is contained in:
parent
3e1653647b
commit
d23ef7e61e
330
code/base/base.h
330
code/base/base.h
|
@ -1,330 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "sane/sane_ex.h"
|
|
||||||
|
|
||||||
class ref
|
|
||||||
{
|
|
||||||
volatile long ref_;
|
|
||||||
public:
|
|
||||||
ref() : ref_(1)
|
|
||||||
{}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ~ref()
|
|
||||||
{}
|
|
||||||
|
|
||||||
public:
|
|
||||||
long add_ref(void)
|
|
||||||
{
|
|
||||||
return _InterlockedIncrement(&ref_);
|
|
||||||
}
|
|
||||||
long release(void)
|
|
||||||
{
|
|
||||||
long r = _InterlockedDecrement(&ref_);
|
|
||||||
|
|
||||||
if (r == 0)
|
|
||||||
delete this;
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class parameter : public ref
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
parameter()
|
|
||||||
{}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ~parameter()
|
|
||||||
{}
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual size_t get_size(void) = 0;
|
|
||||||
virtual void* get_data(void) = 0; // return data pointer, bool*, int*, double*, (wchar_t*)
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ui_helper : public ref
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ui_helper()
|
|
||||||
{}
|
|
||||||
protected:
|
|
||||||
virtual ~ui_helper()
|
|
||||||
{}
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum data_from
|
|
||||||
{
|
|
||||||
DATA_FROM_KNOWN = 0, // pre-defined data name, i.e. resulotion, paper, bright, ...
|
|
||||||
DATA_FROM_USER, // need a window for user inputing
|
|
||||||
};
|
|
||||||
enum value_type
|
|
||||||
{
|
|
||||||
VAL_TYPE_BOOL = 0,
|
|
||||||
VAL_TYPE_INT,
|
|
||||||
VAL_TYPE_FLOAT,
|
|
||||||
VAL_TYPE_STRING,
|
|
||||||
VAL_TYPE_CUSTOM, // custom data, such as gamma table ...
|
|
||||||
};
|
|
||||||
|
|
||||||
// get testing parameter ...
|
|
||||||
virtual parameter* get_user_input(data_from from, value_type type
|
|
||||||
, const wchar_t* title // window title when from == DATA_FROM_USER, or parameter name when from == DATA_FROM_KNOWN
|
|
||||||
, const wchar_t* desc = NULL // description of the parameter if from was DATA_FROM_USER, unused in DATA_FROM_KNOWN
|
|
||||||
) = 0;
|
|
||||||
|
|
||||||
enum test_event
|
|
||||||
{
|
|
||||||
TEST_EVENT_TIPS = 0, // messages in testing process, data is (wchar_t*), flag is unused
|
|
||||||
TEST_EVENT_xxx, // should be complemented ...
|
|
||||||
TEST_EVENT_RESULT, // test result, data is (wchar_t*)description, flag is (bool)result, true - test pass
|
|
||||||
};
|
|
||||||
virtual void test_callback(const wchar_t* name/*test name*/, test_event ev, void* data, size_t flag) = 0;
|
|
||||||
|
|
||||||
// register/unregister sane callback, the sane_callback in UI module should dispatch the events to these registered callback
|
|
||||||
virtual int register_sane_callback(sane_callback cb, void* param) = 0;
|
|
||||||
virtual int unregister_sane_callback(sane_callback cb) = 0;
|
|
||||||
|
|
||||||
// All IO operations are blocking
|
|
||||||
virtual int io_control(unsigned long code, void* data, unsigned* len) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef TEST_DLL
|
|
||||||
#define DECL_API(ret) __declspec(dllexport) ret __stdcall
|
|
||||||
#else
|
|
||||||
#define DECL_API(ret) __declspec(dllimport) ret __stdcall
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Function: initialize module
|
|
||||||
DECL_API(int) func_test_init(void*);
|
|
||||||
|
|
||||||
// Function: to get testing function list supported by this module/DLL
|
|
||||||
//
|
|
||||||
// Parameter: buf - to receive the list JSON
|
|
||||||
//
|
|
||||||
// len - [in] space of 'buf' in words, [out] words copied in buf, or less buffer size in words if return ERROR_INSUFFICIENT_BUFFER
|
|
||||||
//
|
|
||||||
// Return: ERROR_SUCCESS - JSON configuration has copied into buf
|
|
||||||
// ERROR_INSUFFICIENT_BUFFER - buffer is too small, and the minium size in words is stored in 'len'
|
|
||||||
// ERROR_INVALID_PARAMETER - NULL for parameter 'len' is not acceptable
|
|
||||||
DECL_API(int) func_test_get_list(wchar_t* buf // to receive the JSON text
|
|
||||||
, size_t* len); // [in] space of 'buf' in words, [out] words copied in buf, or less buffer size in words if return ERROR_INSUFFICIENT_BUFFER
|
|
||||||
|
|
||||||
// Function: do ONE function test
|
|
||||||
//
|
|
||||||
// Parameter: name - function name
|
|
||||||
//
|
|
||||||
// oper - test operation, "start", "pause", "resume", "stop", ...
|
|
||||||
//
|
|
||||||
// helper - parameter and testing process callback
|
|
||||||
//
|
|
||||||
// Return: error code
|
|
||||||
DECL_API(int) func_test_go(const wchar_t* name // test name
|
|
||||||
, const wchar_t* oper // test oper - "start", "pause", "resume", "stop", ...
|
|
||||||
, ui_helper* helper);
|
|
||||||
|
|
||||||
// Function: uninitialize module
|
|
||||||
DECL_API(int) func_test_uninit(void*);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/*/ testing-DLL load code ...
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <Windows.h>
|
|
||||||
|
|
||||||
class json : public ref
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
json();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
~json();
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool attach(const wchar_t* text);
|
|
||||||
bool get_value(const wchar_t* key, int& val);
|
|
||||||
bool get_value(const wchar_t* key, std::wstring& val);
|
|
||||||
bool get_value(const wchar_t* key, json*& val);
|
|
||||||
};
|
|
||||||
|
|
||||||
class test_factory
|
|
||||||
{
|
|
||||||
typedef struct _test_func
|
|
||||||
{
|
|
||||||
std::wstring name;
|
|
||||||
int ver;
|
|
||||||
int(__stdcall* test_api)(const wchar_t*, const wchar_t*, ui_helper*);
|
|
||||||
|
|
||||||
struct _test_func()
|
|
||||||
{
|
|
||||||
name = L"";
|
|
||||||
ver = 0;
|
|
||||||
test_api = NULL;
|
|
||||||
}
|
|
||||||
bool operator==(const wchar_t* n)
|
|
||||||
{
|
|
||||||
return name == n;
|
|
||||||
}
|
|
||||||
}TESTFUNC, *LPTESTFUNC;
|
|
||||||
std::vector<TESTFUNC> test_;
|
|
||||||
|
|
||||||
void add_api(const wchar_t* name, int ver, int(__stdcall* test_api)(const wchar_t*, const wchar_t*, ui_helper*))
|
|
||||||
{
|
|
||||||
std::vector<TESTFUNC>::iterator it = std::find(test_.begin(), test_.end(), name);
|
|
||||||
|
|
||||||
if (it == test_.end())
|
|
||||||
{
|
|
||||||
TESTFUNC tf;
|
|
||||||
|
|
||||||
tf.name = name;
|
|
||||||
tf.ver = ver;
|
|
||||||
tf.test_api = test_api;
|
|
||||||
test_.push_back(tf);
|
|
||||||
}
|
|
||||||
else if (ver > it->ver)
|
|
||||||
{
|
|
||||||
it->test_api = test_api;
|
|
||||||
it->ver = ver;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void load_test_dll(const wchar_t* path_dll)
|
|
||||||
{
|
|
||||||
HMODULE mod = LoadLibraryW(path_dll);
|
|
||||||
int(__stdcall * init)(void*) = NULL;
|
|
||||||
int(__stdcall * get)(void*, size_t*) = NULL;
|
|
||||||
int(__stdcall * go)(const wchar_t*, const wchar_t*, ui_helper*) = NULL;
|
|
||||||
FARPROC* api = (FARPROC*)&init;
|
|
||||||
wchar_t* buf = NULL;
|
|
||||||
size_t len = 0;
|
|
||||||
json* root = NULL, * child = NULL;
|
|
||||||
|
|
||||||
if (!mod)
|
|
||||||
return;
|
|
||||||
|
|
||||||
*api = GetProcAddress(mod, "func_test_init");
|
|
||||||
if (!api)
|
|
||||||
{
|
|
||||||
FreeLibrary(mod);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
init(NULL);
|
|
||||||
|
|
||||||
api = (FARPROC*)&get;
|
|
||||||
*api = GetProcAddress(mod, "func_test_get_list");
|
|
||||||
if(!api)
|
|
||||||
{
|
|
||||||
FreeLibrary(mod);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
api = (FARPROC*)&go;
|
|
||||||
*api = GetProcAddress(mod, "func_test_go");
|
|
||||||
if (!api)
|
|
||||||
{
|
|
||||||
FreeLibrary(mod);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(get(buf, &len) != ERROR_INSUFFICIENT_BUFFER)
|
|
||||||
{
|
|
||||||
FreeLibrary(mod);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = new wchar_t[len + 8];
|
|
||||||
memset(buf, 0, (len + 8) * 2);
|
|
||||||
if (get(buf, &len))
|
|
||||||
{
|
|
||||||
delete[] buf;
|
|
||||||
FreeLibrary(mod);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse json ...
|
|
||||||
len = 0;
|
|
||||||
root = new json();
|
|
||||||
if (root->attach(buf))
|
|
||||||
{
|
|
||||||
for (int i = 1; 1; ++i)
|
|
||||||
{
|
|
||||||
swprintf_s(buf, 20, L"%d", i);
|
|
||||||
if (!root->get_value(buf, child) || !child)
|
|
||||||
break;
|
|
||||||
|
|
||||||
std::wstring name(L"");
|
|
||||||
int ver = 0;
|
|
||||||
if (child->get_value(L"name", name) && child->get_value(L"ver", ver))
|
|
||||||
{
|
|
||||||
add_api(name.c_str(), ver, go);
|
|
||||||
len++;
|
|
||||||
}
|
|
||||||
child->release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
root->release();
|
|
||||||
delete[] buf;
|
|
||||||
if (len == 0)
|
|
||||||
FreeLibrary(mod);
|
|
||||||
}
|
|
||||||
void init(void)
|
|
||||||
{
|
|
||||||
wchar_t path[MAX_PATH] = { 0 };
|
|
||||||
std::wstring dir(L"");
|
|
||||||
size_t pos = 0;
|
|
||||||
HANDLE hf = INVALID_HANDLE_VALUE;
|
|
||||||
WIN32_FIND_DATAW fd = { 0 };
|
|
||||||
|
|
||||||
GetModuleFileNameW(NULL, path, _countof(path) - 1);
|
|
||||||
dir = pos;
|
|
||||||
pos = dir.rfind(L'\\');
|
|
||||||
if (pos++ == std::wstring::npos)
|
|
||||||
return;
|
|
||||||
|
|
||||||
dir.erase(pos);
|
|
||||||
dir += L"dlls\\";
|
|
||||||
hf = FindFirstFileW((dir + L"*.dll").c_str(), &fd);
|
|
||||||
if (hf != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
load_test_dll((dir + fd.cFileName).c_str());
|
|
||||||
} while (FindNextFileW(hf, &fd));
|
|
||||||
|
|
||||||
FindClose(hf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
test_factory()
|
|
||||||
{
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
~test_factory()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool is_test_available(const wchar_t* name) // check if the test item with name 'name' is supported
|
|
||||||
{
|
|
||||||
std::vector<TESTFUNC>::iterator it = std::find(test_.begin(), test_.end(), name);
|
|
||||||
|
|
||||||
return it != test_.end();
|
|
||||||
}
|
|
||||||
int test(const wchar_t* name, ui_helper* ui, const wchar_t* oper = L"start")
|
|
||||||
{
|
|
||||||
std::vector<TESTFUNC>::iterator it = std::find(test_.begin(), test_.end(), name);
|
|
||||||
|
|
||||||
if (it == test_.end())
|
|
||||||
return ERROR_NOT_SUPPORTED;
|
|
||||||
|
|
||||||
return it->test_api(name, oper, ui);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/////////////////////////*////////////////////////////////////////////////////////////////////////
|
|
|
@ -373,7 +373,7 @@ extern "C" {
|
||||||
// 则会在len中返回所需要的最小内存长度,并返回 SANE_STATUS_NO_MEM 错误
|
// 则会在len中返回所需要的最小内存长度,并返回 SANE_STATUS_NO_MEM 错误
|
||||||
IO_CTRL_CODE_RESTORE_SETTINGS, // 恢复默认设置 data - NULL, len - NULL
|
IO_CTRL_CODE_RESTORE_SETTINGS, // 恢复默认设置 data - NULL, len - NULL
|
||||||
IO_CTRL_CODE_GET_DEFAULT_VALUE, // 获取设置项默认值 data - 同sane_control_option - SANE_ACTION_GET_VALUE时的定义, *len - [in] 设置项序号,同sane_control_option中option的值
|
IO_CTRL_CODE_GET_DEFAULT_VALUE, // 获取设置项默认值 data - 同sane_control_option - SANE_ACTION_GET_VALUE时的定义, *len - [in] 设置项序号,同sane_control_option中option的值
|
||||||
IO_CTRL_CODE_CLEAR_ROLLER_COUNT, // 清除滚轴计数 data - NULL, len - to receive current roller count, can be NULL
|
IO_CTRL_CODE_SET_CLEAR_ROLLER_COUNT, // 清除滚轴计数 data - NULL, len - to receive current roller count, can be NULL
|
||||||
IO_CTRL_CODE_GET_FINAL_IMAGE_FORMAT, // 获取图像处理最终输出(final())的图像数据格式 data - (SANE_FinalImgFormat*), len - bytes of data
|
IO_CTRL_CODE_GET_FINAL_IMAGE_FORMAT, // 获取图像处理最终输出(final())的图像数据格式 data - (SANE_FinalImgFormat*), len - bytes of data
|
||||||
IO_CTRL_CODE_SET_FINAL_IMAGE_FORMAT, // 设置图像处理最终输出(final())的图像数据格式 data - (SANE_FinalImgFormat*), len - bytes of data
|
IO_CTRL_CODE_SET_FINAL_IMAGE_FORMAT, // 设置图像处理最终输出(final())的图像数据格式 data - (SANE_FinalImgFormat*), len - bytes of data
|
||||||
IO_CTRL_CODE_GET_FINAL_COMPRESSION, // 获取支持的压缩格式,data - (SANE_Int*), to receive supported SANE_CompressionType, data[0]: supported counts, data[1]: default value, data[2]: current value; data[3...]: all supported values
|
IO_CTRL_CODE_GET_FINAL_COMPRESSION, // 获取支持的压缩格式,data - (SANE_Int*), to receive supported SANE_CompressionType, data[0]: supported counts, data[1]: default value, data[2]: current value; data[3...]: all supported values
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.2.32616.157
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcxproj", "{3D2FC7CE-4033-48E9-BDC2-2DCBECB398DD}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{3D2FC7CE-4033-48E9-BDC2-2DCBECB398DD}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{3D2FC7CE-4033-48E9-BDC2-2DCBECB398DD}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{3D2FC7CE-4033-48E9-BDC2-2DCBECB398DD}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{3D2FC7CE-4033-48E9-BDC2-2DCBECB398DD}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{3D2FC7CE-4033-48E9-BDC2-2DCBECB398DD}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{3D2FC7CE-4033-48E9-BDC2-2DCBECB398DD}.Release|x64.Build.0 = Release|x64
|
||||||
|
{3D2FC7CE-4033-48E9-BDC2-2DCBECB398DD}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{3D2FC7CE-4033-48E9-BDC2-2DCBECB398DD}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {C210926E-9DF8-4FEE-881F-C1173532BAA1}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,144 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{3d2fc7ce-4033-48e9-bdc2-2dcbecb398dd}</ProjectGuid>
|
||||||
|
<RootNamespace>test</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="test_base.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="sane\sane.h" />
|
||||||
|
<ClInclude Include="sane\sanei.h" />
|
||||||
|
<ClInclude Include="sane\sanei_backend.h" />
|
||||||
|
<ClInclude Include="sane\sanei_debug.h" />
|
||||||
|
<ClInclude Include="sane\sane_ex.h" />
|
||||||
|
<ClInclude Include="sane\sane_option_definitions.h" />
|
||||||
|
<ClInclude Include="test_base.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="源文件">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="头文件">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="资源文件">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="test_base.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="test_base.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="sane\sane.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="sane\sane_ex.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="sane\sane_option_definitions.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="sane\sanei.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="sane\sanei_backend.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="sane\sanei_debug.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup />
|
||||||
|
</Project>
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,527 @@
|
||||||
|
#pragma once
|
||||||
|
#include "string"
|
||||||
|
#include "sane/sane_ex.h"
|
||||||
|
//////////////////////////////////////TITLE//////////////////////////////////////
|
||||||
|
/* 拨码开关校验 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_DIAL_SWITCH L"拨码开关校验"
|
||||||
|
/* 检查船型开关功能 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_ROCKER_SWITCH L"检查船型开关功能"
|
||||||
|
/* 设备上电并观察开机状态 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_BOOT_STATUS L"设备上电并观察开机状态"
|
||||||
|
/* 检查液晶显示 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_LCD_DISPLAY L"检查液晶显示"
|
||||||
|
/* 清理纸道功能确认 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_CLEAR_PAPER_PATH L"清理纸道功能确认"
|
||||||
|
/* 按键功能检测 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_KEY_FUNCTION L"按键功能检测"
|
||||||
|
/* 计数模式检测 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_COUNTING_MODE L"计数模式检测"
|
||||||
|
/* 歪斜检测 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_SKEW_DETECTION L"歪斜检测"
|
||||||
|
/* 分纸电机检测 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_SEPARATER_MOTOR L"分纸电机检测"
|
||||||
|
/* CIS原图初检 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE L"CIS原图初检"
|
||||||
|
/* 主机风扇功能检测 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_HOST_FAN L"主机风扇功能检测"
|
||||||
|
/* 超声波模块检验 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_ULTRASONIC_MODULE L"超声波模块检验"
|
||||||
|
/* LED灯状态检查 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_LED_LIGHT L"LED灯状态检查"
|
||||||
|
/* 复位检查 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_RESET L"复位检查"
|
||||||
|
/* 走纸检查 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_PAPER_FEED L"走纸检查"
|
||||||
|
/* 开盖传感器检查 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_COVER_SENSOR L"开盖传感器检查"
|
||||||
|
/* 扫描传感器检查 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_SCANNING_SENSOR L"扫描传感器检查"
|
||||||
|
/* 配置速度模式 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_CONFIGURE_SPEED_MODE L"配置速度模式"
|
||||||
|
/* 放置校正纸 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_PLACE_CORRECTION_PAPER L"放置校正纸"
|
||||||
|
/* 自动平场校正 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_AUTO_FLAT_FIELD L"自动平场校正"
|
||||||
|
/* 重启设备 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_REBOOT_DEVICE L"重启设备"
|
||||||
|
/* 扫描图像质量确认 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_IMAGE_QUALITY L"扫描图像质量确认"
|
||||||
|
/* 色卡纸成像质量评估 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_COLORCARD_IMAGEING_QUALITY L"色卡纸成像质量评估"
|
||||||
|
/* 色卡纸偏色成像质量评估 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_COLORCARD_BIAS_IMAGEING_QUALITY L"色卡纸偏色成像质量评估"
|
||||||
|
/* 清晰度质量评估 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_CLARITY_QUALITY L"清晰度质量评估"
|
||||||
|
/* 畸变修正 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_DISTORTION L"畸变修正"
|
||||||
|
/* 设置休眠 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_DORMANCY L"设置休眠"
|
||||||
|
/* 歪斜挡位检测 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_SKEW_GEAR L"歪斜挡位检测"
|
||||||
|
/* 分纸强度检测 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_PAPER_SEPARATION_STRENGTH L"分纸强度检测"
|
||||||
|
/* 机械走纸倾斜检测 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_MECH_PAPER_FEEDING_INCLINATION L"机械走纸倾斜检测"
|
||||||
|
/* 单张测试1 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_1 L"单张测试1"
|
||||||
|
/* 单张测试2 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_2 L"单张测试2"
|
||||||
|
/* 单张测试3 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_3 L"单张测试3"
|
||||||
|
/* 压力测试2轮 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_PRESSUER_TEST L"压力测试2轮"
|
||||||
|
/* 清除滚轴计数 */
|
||||||
|
#define HGPDTTOOLDB_TITLE_CLEAR_ROLLER_COUNT L"清除滚轴计数"
|
||||||
|
//////////////////////////////////////NAME//////////////////////////////////////
|
||||||
|
/* 拨码开关校验 */
|
||||||
|
#define HGPDTTOOLDB_NAME_DIAL_SWITCH L"test-1"
|
||||||
|
/* 检查船型开关功能 */
|
||||||
|
#define HGPDTTOOLDB_NAME_ROCKER_SWITCH L"test-2"
|
||||||
|
/* 设备上电并观察开机状态 */
|
||||||
|
#define HGPDTTOOLDB_NAME_BOOT_STATUS L"test-3"
|
||||||
|
/* 检查液晶显示 */
|
||||||
|
#define HGPDTTOOLDB_NAME_LCD_DISPLAY L"test-4"
|
||||||
|
/* 清理纸道功能确认 */
|
||||||
|
#define HGPDTTOOLDB_NAME_CLEAR_PAPER_PATH L"test-5"
|
||||||
|
/* 按键功能检测 */
|
||||||
|
#define HGPDTTOOLDB_NAME_KEY_FUNCTION L"test-6"
|
||||||
|
/* 计数模式检测 */
|
||||||
|
#define HGPDTTOOLDB_NAME_COUNTING_MODE L"test-7"
|
||||||
|
/* 歪斜检测 */
|
||||||
|
#define HGPDTTOOLDB_NAME_SKEW_DETECTION L"test-8"
|
||||||
|
/* 分纸电机检测 */
|
||||||
|
#define HGPDTTOOLDB_NAME_SEPARATER_MOTOR L"test-9"
|
||||||
|
/* CIS原图初检 */
|
||||||
|
#define HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE L"test-10"
|
||||||
|
/* 主机风扇功能检测 */
|
||||||
|
#define HGPDTTOOLDB_NAME_HOST_FAN L"test-11"
|
||||||
|
/* 超声波模块检验 */
|
||||||
|
#define HGPDTTOOLDB_NAME_ULTRASONIC_MODULE L"test-12"
|
||||||
|
/* LED灯状态检查 */
|
||||||
|
#define HGPDTTOOLDB_NAME_LED_LIGHT L"test-13"
|
||||||
|
/* 复位检查 */
|
||||||
|
#define HGPDTTOOLDB_NAME_RESET L"test-14"
|
||||||
|
/* 走纸检查 */
|
||||||
|
#define HGPDTTOOLDB_NAME_PAPER_FEED L"test-15"
|
||||||
|
/* 开盖传感器检查 */
|
||||||
|
#define HGPDTTOOLDB_NAME_COVER_SENSOR L"test-16"
|
||||||
|
/* 扫描传感器检查 */
|
||||||
|
#define HGPDTTOOLDB_NAME_SCANNING_SENSOR L"test-17"
|
||||||
|
|
||||||
|
/* 配置速度模式 */
|
||||||
|
#define HGPDTTOOLDB_NAME_CONFIGURE_SPEED_MODE L"test-18"
|
||||||
|
/* 放置校正纸 */
|
||||||
|
#define HGPDTTOOLDB_NAME_PLACE_CORRECTION_PAPER L"test-19"
|
||||||
|
/* 自动平场校正 */
|
||||||
|
#define HGPDTTOOLDB_NAME_AUTO_FLAT_FIELD L"test-20"
|
||||||
|
/* 重启设备 */
|
||||||
|
#define HGPDTTOOLDB_NAME_REBOOT_DEVICE L"test-21"
|
||||||
|
/* 扫描图像质量确认 */
|
||||||
|
#define HGPDTTOOLDB_NAME_IMAGE_QUALITY L"test-22"
|
||||||
|
/* 色卡纸成像质量评估 */
|
||||||
|
#define HGPDTTOOLDB_NAME_COLORCARD_IMAGEING_QUALITY L"test-23"
|
||||||
|
/* 色卡纸偏色成像质量评估 */
|
||||||
|
#define HGPDTTOOLDB_NAME_COLORCARD_BIAS_IMAGEING_QUALITY L"test-24"
|
||||||
|
/* 清晰度质量评估 */
|
||||||
|
#define HGPDTTOOLDB_NAME_CLARITY_QUALITY L"test-25"
|
||||||
|
/* 畸变修正 */
|
||||||
|
#define HGPDTTOOLDB_NAME_DISTORTION L"test-26"
|
||||||
|
/* 设置休眠 */
|
||||||
|
#define HGPDTTOOLDB_NAME_DORMANCY L"test-27"
|
||||||
|
/* 歪斜挡位检测 */
|
||||||
|
#define HGPDTTOOLDB_NAME_SKEW_GEAR L"test-28"
|
||||||
|
/* 分纸强度检测 */
|
||||||
|
#define HGPDTTOOLDB_NAME_PAPER_SEPARATION_STRENGTH L"test-29"
|
||||||
|
/* 机械走纸倾斜检测 */
|
||||||
|
#define HGPDTTOOLDB_NAME_MECH_PAPER_FEEDING_INCLINATION L"test-30"
|
||||||
|
/* 单张测试1 */
|
||||||
|
#define HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST_1 L"test-31"
|
||||||
|
/* 单张测试2 */
|
||||||
|
#define HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST_2 L"test-32"
|
||||||
|
/* 单张测试3 */
|
||||||
|
#define HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST_3 L"test-33"
|
||||||
|
/* 压力测试2轮 */
|
||||||
|
#define HGPDTTOOLDB_NAME_PRESSUER_TEST L"test-34"
|
||||||
|
/* 清除滚轴计数 */
|
||||||
|
#define HGPDTTOOLDB_NAME_CLEAR_ROLLER_COUNT L"test-35"
|
||||||
|
enum scanner_err
|
||||||
|
{
|
||||||
|
SCANNER_ERR_OK = 0, // 成功,正常状态
|
||||||
|
|
||||||
|
// 1:软件逻辑错误
|
||||||
|
SCANNER_ERR_INVALID_PARAMETER = 0x100, // 非法的参数调用
|
||||||
|
SCANNER_ERR_USER_CANCELED, // 用户取消了操作
|
||||||
|
SCANNER_ERR_INSUFFICIENT_MEMORY, // 分配的内存不足
|
||||||
|
SCANNER_ERR_ACCESS_DENIED, // 访问被拒绝
|
||||||
|
SCANNER_ERR_IO_PENDING, // 异步访问,数据稍后返回
|
||||||
|
SCANNER_ERR_NOT_EXACT, // 数据不精确,精确的数据已经在同一缓存中返回
|
||||||
|
SCANNER_ERR_CONFIGURATION_CHANGED, // 设备的配置项发生改变,需要重新加载显示
|
||||||
|
SCANNER_ERR_NOT_OPEN, // 设备未打开
|
||||||
|
SCANNER_ERR_NOT_START, // 设备没有启动
|
||||||
|
SCANNER_ERR_NOT_ANY_MORE, // 用于回调返回,在本次扫描中,对相同操作不再回调
|
||||||
|
SCANNER_ERR_NO_DATA, // 没有数据
|
||||||
|
SCANNER_ERR_HAS_DATA_YET, // 有数据未被读取(异步操作中)
|
||||||
|
SCANNER_ERR_OUT_OF_RANGE, // 相关操作超出范围
|
||||||
|
SCANNER_ERR_IO, // IO错误
|
||||||
|
SCANNER_ERR_TIMEOUT, // 超时错误
|
||||||
|
SCANNER_ERR_OPEN_FILE_FAILED, // 打开本地文件失败
|
||||||
|
SCANNER_ERR_CREATE_FILE_FAILED, // 创建本地文件失败
|
||||||
|
SCANNER_ERR_WRITE_FILE_FAILED, // 写本地文件失败
|
||||||
|
SCANNER_ERR_DATA_DAMAGED, // 数据损坏(内置资源数据损坏)
|
||||||
|
SCANNER_ERR_OPENED_BY_OTHER_PROCESS, // 设备已经被其它进程打开占用
|
||||||
|
|
||||||
|
// 2:USB错误
|
||||||
|
SCANNER_ERR_USB_INIT_FAILED = 0x5b00, // libusb_init 失败
|
||||||
|
SCANNER_ERR_USB_REGISTER_PNP_FAILED, // 注册USB监听事件失败
|
||||||
|
SCANNER_ERR_USB_CLAIM_INTERFACE_FAILED, // failed in calling libusb_claim_interface
|
||||||
|
|
||||||
|
// 3:硬件错误
|
||||||
|
SCANNER_ERR_DEVICE_NOT_FOUND = 0x0de00, // 设备未找到
|
||||||
|
SCANNER_ERR_DEVICE_NOT_SUPPORT, // 设备不支持该操作
|
||||||
|
SCANNER_ERR_DEVICE_BUSY, // 设备正忙,不能响应该操作
|
||||||
|
SCANNER_ERR_DEVICE_SLEEPING, // 设备处于睡眠状态
|
||||||
|
SCANNER_ERR_DEVICE_COUNT_MODE, // 设备处于计数扫描状态?
|
||||||
|
SCANNER_ERR_DEVICE_STOPPED, // 扫描停止
|
||||||
|
SCANNER_ERR_DEVICE_COVER_OPENNED, // 扫描仪盖板呈打开状态
|
||||||
|
SCANNER_ERR_DEVICE_NO_PAPER, // 没有纸张输入
|
||||||
|
SCANNER_ERR_DEVICE_FEEDING_PAPER, // 搓纸失败
|
||||||
|
SCANNER_ERR_DEVICE_DOUBLE_FEEDING, // 双张检测
|
||||||
|
SCANNER_ERR_DEVICE_PAPER_JAMMED, // 卡纸
|
||||||
|
SCANNER_ERR_DEVICE_STAPLE_ON, // 有钉书钉
|
||||||
|
SCANNER_ERR_DEVICE_PAPER_SKEW, // 纸张倾斜
|
||||||
|
SCANNER_ERR_DEVICE_SIZE_CHECK, // 尺寸检测错误
|
||||||
|
SCANNER_ERR_DEVICE_DOGEAR, // 纸张有折角
|
||||||
|
SCANNER_ERR_DEVICE_NO_IMAGE, // 设备没取到图
|
||||||
|
SCANNER_ERR_DEVICE_SCANN_ERROR, // 设备扫图失败
|
||||||
|
SCANNER_ERR_DEVICE_PC_BUSY, // PC繁忙或出错
|
||||||
|
SCANNER_ERR_DEVICE_ISLOCK, // 设备被锁定
|
||||||
|
SCANNER_ERR_DEVICE_UPGRADE_SUCCESSFUL, // 固件升级成功
|
||||||
|
SCANNER_ERR_DEVICE_UPGRADE_FAIL // 固件升级失败
|
||||||
|
};
|
||||||
|
|
||||||
|
class ref
|
||||||
|
{
|
||||||
|
volatile long ref_;
|
||||||
|
public:
|
||||||
|
ref() : ref_(1)
|
||||||
|
{}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~ref()
|
||||||
|
{}
|
||||||
|
|
||||||
|
public:
|
||||||
|
long add_ref(void)
|
||||||
|
{
|
||||||
|
return _InterlockedIncrement(&ref_);
|
||||||
|
}
|
||||||
|
long release(void)
|
||||||
|
{
|
||||||
|
long r = _InterlockedDecrement(&ref_);
|
||||||
|
|
||||||
|
if (r == 0)
|
||||||
|
delete this;
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class parameter : public ref
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
parameter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~parameter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual size_t get_size(void) = 0;
|
||||||
|
virtual void* get_data(void) = 0; // return data pointer, bool*, int*, double*, (wchar_t*)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ui_helper : public ref
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ui_helper()
|
||||||
|
{}
|
||||||
|
protected:
|
||||||
|
virtual ~ui_helper()
|
||||||
|
{}
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum data_from
|
||||||
|
{
|
||||||
|
DATA_FROM_KNOWN = 0, // pre-defined data name, i.e. resulotion, paper, bright, ...
|
||||||
|
DATA_FROM_USER, // need a window for user inputing
|
||||||
|
};
|
||||||
|
enum value_type
|
||||||
|
{
|
||||||
|
VAL_TYPE_BOOL = 0,
|
||||||
|
VAL_TYPE_INT,
|
||||||
|
VAL_TYPE_FLOAT,
|
||||||
|
VAL_TYPE_STRING,
|
||||||
|
VAL_TYPE_CUSTOM, // custom data, such as gamma table ...
|
||||||
|
};
|
||||||
|
|
||||||
|
// get testing parameter ...
|
||||||
|
virtual parameter* get_user_input(data_from from, value_type type
|
||||||
|
, const wchar_t* title // window title when from == DATA_FROM_USER, or parameter name when from == DATA_FROM_KNOWN
|
||||||
|
, const wchar_t* desc = NULL // description of the parameter if from was DATA_FROM_USER, unused in DATA_FROM_KNOWN
|
||||||
|
) = 0;
|
||||||
|
|
||||||
|
enum test_event
|
||||||
|
{
|
||||||
|
TEST_EVENT_TIPS = 0, // messages in testing process, data is (wchar_t*), flag is unused
|
||||||
|
TEST_EVENT_xxx, // should be complemented ...
|
||||||
|
TEST_EVENT_RESULT, // test result, data is (wchar_t*)description, flag is (bool)result, true - test pass
|
||||||
|
};
|
||||||
|
virtual void test_callback(const wchar_t* name/*test name*/, test_event ev, void* data, size_t flag) = 0;
|
||||||
|
|
||||||
|
// register/unregister sane callback, the sane_callback in UI module should dispatch the events to these registered callback
|
||||||
|
virtual int register_sane_callback(sane_callback cb, void* param) = 0;
|
||||||
|
virtual int unregister_sane_callback(sane_callback cb) = 0;
|
||||||
|
|
||||||
|
// All IO operations are blocking
|
||||||
|
virtual int io_control(unsigned long code, void* data, unsigned* len) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef TEST_DLL
|
||||||
|
#define DECL_API(ret) __declspec(dllexport) ret __stdcall
|
||||||
|
#else
|
||||||
|
#define DECL_API(ret) __declspec(dllimport) ret __stdcall
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Function: initialize module
|
||||||
|
DECL_API(int) func_test_init(void*);
|
||||||
|
|
||||||
|
// Function: to get testing function list supported by this module/DLL
|
||||||
|
//
|
||||||
|
// Parameter: buf - to receive the list JSON
|
||||||
|
//
|
||||||
|
// len - [in] space of 'buf' in words, [out] words copied in buf, or less buffer size in words if return ERROR_INSUFFICIENT_BUFFER
|
||||||
|
//
|
||||||
|
// Return: ERROR_SUCCESS - JSON configuration has copied into buf
|
||||||
|
// ERROR_INSUFFICIENT_BUFFER - buffer is too small, and the minium size in words is stored in 'len'
|
||||||
|
// ERROR_INVALID_PARAMETER - NULL for parameter 'len' is not acceptable
|
||||||
|
DECL_API(int) func_test_get_list(wchar_t* buf // to receive the JSON text
|
||||||
|
, size_t* len); // [in] space of 'buf' in words, [out] words copied in buf, or less buffer size in words if return ERROR_INSUFFICIENT_BUFFER
|
||||||
|
|
||||||
|
// Function: do ONE function test
|
||||||
|
//
|
||||||
|
// Parameter: name - function name
|
||||||
|
//
|
||||||
|
// oper - test operation, "start", "pause", "resume", "stop", ...
|
||||||
|
//
|
||||||
|
// helper - parameter and testing process callback
|
||||||
|
//
|
||||||
|
// Return: error code
|
||||||
|
DECL_API(int) func_test_go(const wchar_t* name // test name
|
||||||
|
, const wchar_t* oper // test oper - "start", "pause", "resume", "stop", ...
|
||||||
|
, ui_helper* helper);
|
||||||
|
|
||||||
|
// Function: uninitialize module
|
||||||
|
DECL_API(int) func_test_uninit(void*);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/*/ testing-DLL load code ...
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
class json : public ref
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
json();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~json();
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool attach(const wchar_t* text);
|
||||||
|
bool get_value(const wchar_t* key, int& val);
|
||||||
|
bool get_value(const wchar_t* key, std::wstring& val);
|
||||||
|
bool get_value(const wchar_t* key, json*& val);
|
||||||
|
};
|
||||||
|
|
||||||
|
class test_factory
|
||||||
|
{
|
||||||
|
typedef struct _test_func
|
||||||
|
{
|
||||||
|
std::wstring name;
|
||||||
|
int ver;
|
||||||
|
int(__stdcall* test_api)(const wchar_t*, const wchar_t*, ui_helper*);
|
||||||
|
|
||||||
|
struct _test_func()
|
||||||
|
{
|
||||||
|
name = L"";
|
||||||
|
ver = 0;
|
||||||
|
test_api = NULL;
|
||||||
|
}
|
||||||
|
bool operator==(const wchar_t* n)
|
||||||
|
{
|
||||||
|
return name == n;
|
||||||
|
}
|
||||||
|
}TESTFUNC, *LPTESTFUNC;
|
||||||
|
std::vector<TESTFUNC> test_;
|
||||||
|
|
||||||
|
void add_api(const wchar_t* name, int ver, int(__stdcall* test_api)(const wchar_t*, const wchar_t*, ui_helper*))
|
||||||
|
{
|
||||||
|
std::vector<TESTFUNC>::iterator it = std::find(test_.begin(), test_.end(), name);
|
||||||
|
|
||||||
|
if (it == test_.end())
|
||||||
|
{
|
||||||
|
TESTFUNC tf;
|
||||||
|
|
||||||
|
tf.name = name;
|
||||||
|
tf.ver = ver;
|
||||||
|
tf.test_api = test_api;
|
||||||
|
test_.push_back(tf);
|
||||||
|
}
|
||||||
|
else if (ver > it->ver)
|
||||||
|
{
|
||||||
|
it->test_api = test_api;
|
||||||
|
it->ver = ver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void load_test_dll(const wchar_t* path_dll)
|
||||||
|
{
|
||||||
|
HMODULE mod = LoadLibraryW(path_dll);
|
||||||
|
int(__stdcall * init)(void*) = NULL;
|
||||||
|
int(__stdcall * get)(void*, size_t*) = NULL;
|
||||||
|
int(__stdcall * go)(const wchar_t*, const wchar_t*, ui_helper*) = NULL;
|
||||||
|
FARPROC* api = (FARPROC*)&init;
|
||||||
|
wchar_t* buf = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
json* root = NULL, * child = NULL;
|
||||||
|
|
||||||
|
if (!mod)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*api = GetProcAddress(mod, "func_test_init");
|
||||||
|
if (!api)
|
||||||
|
{
|
||||||
|
FreeLibrary(mod);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
init(NULL);
|
||||||
|
|
||||||
|
api = (FARPROC*)&get;
|
||||||
|
*api = GetProcAddress(mod, "func_test_get_list");
|
||||||
|
if(!api)
|
||||||
|
{
|
||||||
|
FreeLibrary(mod);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
api = (FARPROC*)&go;
|
||||||
|
*api = GetProcAddress(mod, "func_test_go");
|
||||||
|
if (!api)
|
||||||
|
{
|
||||||
|
FreeLibrary(mod);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(get(buf, &len) != ERROR_INSUFFICIENT_BUFFER)
|
||||||
|
{
|
||||||
|
FreeLibrary(mod);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = new wchar_t[len + 8];
|
||||||
|
memset(buf, 0, (len + 8) * 2);
|
||||||
|
if (get(buf, &len))
|
||||||
|
{
|
||||||
|
delete[] buf;
|
||||||
|
FreeLibrary(mod);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse json ...
|
||||||
|
len = 0;
|
||||||
|
root = new json();
|
||||||
|
if (root->attach(buf))
|
||||||
|
{
|
||||||
|
for (int i = 1; 1; ++i)
|
||||||
|
{
|
||||||
|
swprintf_s(buf, 20, L"%d", i);
|
||||||
|
if (!root->get_value(buf, child) || !child)
|
||||||
|
break;
|
||||||
|
|
||||||
|
std::wstring name(L"");
|
||||||
|
int ver = 0;
|
||||||
|
if (child->get_value(L"name", name) && child->get_value(L"ver", ver))
|
||||||
|
{
|
||||||
|
add_api(name.c_str(), ver, go);
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
child->release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
root->release();
|
||||||
|
delete[] buf;
|
||||||
|
if (len == 0)
|
||||||
|
FreeLibrary(mod);
|
||||||
|
}
|
||||||
|
void init(void)
|
||||||
|
{
|
||||||
|
wchar_t path[MAX_PATH] = { 0 };
|
||||||
|
std::wstring dir(L"");
|
||||||
|
size_t pos = 0;
|
||||||
|
HANDLE hf = INVALID_HANDLE_VALUE;
|
||||||
|
WIN32_FIND_DATAW fd = { 0 };
|
||||||
|
|
||||||
|
GetModuleFileNameW(NULL, path, _countof(path) - 1);
|
||||||
|
dir = pos;
|
||||||
|
pos = dir.rfind(L'\\');
|
||||||
|
if (pos++ == std::wstring::npos)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dir.erase(pos);
|
||||||
|
dir += L"dlls\\";
|
||||||
|
hf = FindFirstFileW((dir + L"*.dll").c_str(), &fd);
|
||||||
|
if (hf != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
load_test_dll((dir + fd.cFileName).c_str());
|
||||||
|
} while (FindNextFileW(hf, &fd));
|
||||||
|
|
||||||
|
FindClose(hf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
test_factory()
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
~test_factory()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool is_test_available(const wchar_t* name) // check if the test item with name 'name' is supported
|
||||||
|
{
|
||||||
|
std::vector<TESTFUNC>::iterator it = std::find(test_.begin(), test_.end(), name);
|
||||||
|
|
||||||
|
return it != test_.end();
|
||||||
|
}
|
||||||
|
int test(const wchar_t* name, ui_helper* ui, const wchar_t* oper = L"start")
|
||||||
|
{
|
||||||
|
std::vector<TESTFUNC>::iterator it = std::find(test_.begin(), test_.end(), name);
|
||||||
|
|
||||||
|
if (it == test_.end())
|
||||||
|
return ERROR_NOT_SUPPORTED;
|
||||||
|
|
||||||
|
return it->test_api(name, oper, ui);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/////////////////////////*////////////////////////////////////////////////////////////////////////
|
Loading…
Reference in New Issue