diff --git a/code/base/test.vcxproj b/code/base/test.vcxproj index be9ebb9..d256bcf 100644 --- a/code/base/test.vcxproj +++ b/code/base/test.vcxproj @@ -71,7 +71,7 @@ - ..\..\..\sdk\include;$(IncludePath) + ..\..\..\sdk\include;C:\Users\modehua\Desktop\sane\code_production\app\HGProductionTool;$(IncludePath) diff --git a/code/base/test_base.cpp b/code/base/test_base.cpp index f441f61..44e57e5 100644 --- a/code/base/test_base.cpp +++ b/code/base/test_base.cpp @@ -12,7 +12,6 @@ static struct Test_Map const wchar_t* title; //"б" const int ver; io_code num; - }Test_Map_NO[] = { {HGPDTTOOLDB_NAME_DIAL_SWITCH ,HGPDTTOOLDB_TITLE_DIAL_SWITCH ,0,IO_CTRL_CODE_BASE}, @@ -50,7 +49,7 @@ Test_Map_Bool[] Test_Map_String[] { - {HGPDTTOOLDB_NAME_CLEAR_ROLLER_COUNT ,HGPDTTOOLDB_TITLE_CLEAR_ROLLER_COUNT,0,IO_CTRL_CODE_SET_CLEAR_ROLLER_COUNT}, + {L"123" ,HGPDTTOOLDB_TITLE_CLEAR_ROLLER_COUNT,0,IO_CTRL_CODE_SET_CLEAR_ROLLER_COUNT}, }, Test_Map_Int[] { @@ -66,7 +65,7 @@ Test_Map_Int[] //test static std::string jsontext1("{\"1\":{\"name\":\"test-8\",\"ver\":1}}"); -int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param) +int sane_ex_callback1(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param) { switch (code) { @@ -153,6 +152,7 @@ int get_json_config_file() fclose(fp); std::cout << buf << std::endl; } + int func_test_init(void* init) { return 0; @@ -167,8 +167,8 @@ int func_test_go(const wchar_t* name, const wchar_t* oper, ui_helper* helper) { return -1; } - helper->add_ref(); - helper->register_sane_callback(sane_ex_callback, NULL); + //helper->add_ref(); + helper->register_sane_callback(sane_ex_callback1, NULL); bool flag = false; wchar_t* des = NULL; @@ -185,16 +185,15 @@ int func_test_go(const wchar_t* name, const wchar_t* oper, ui_helper* helper) { SANE_Bool map_bool = true; unsigned int len = sizeof(SANE_Bool); - ret = helper->io_control(Test_Map_Bool[i].num,&map_bool, &len); + ret = helper->io_control(Test_Map_Bool[i].num,(void *)&map_bool, &len); if (ret == SCANNER_ERR_OK) { ev = ui_helper::TEST_EVENT_RESULT; helper->test_callback(Test_Map_Bool[i].name, ev, des, true); map_bool = false; ret = helper->io_control(Test_Map_Bool[i].num, &map_bool, &len); - - return SCANNER_ERR_OK; } + return SCANNER_ERR_OK; } else if(wcscmp(name, Test_Map_String[i].name) == 0) { @@ -209,8 +208,8 @@ int func_test_go(const wchar_t* name, const wchar_t* oper, ui_helper* helper) return SCANNER_ERR_OK; } } - helper->release(); - helper->unregister_sane_callback(sane_ex_callback); + //helper->release(); + //helper->unregister_sane_callback(sane_ex_callback); return SCANNER_ERR_OK; } int func_test_uninit(void* uninit) @@ -238,24 +237,3 @@ int main11() return 0; } - -parameter* ui_helper::get_user_input(data_from from, value_type type, const wchar_t* title, const wchar_t* desc = NULL) -{ - -} -int ui_helper::register_sane_callback(sane_callback cb, void* param) -{ - return 0; -} -int ui_helper::unregister_sane_callback(sane_callback cb) -{ - return 0; -} -int ui_helper::io_control(unsigned long code, void* data, unsigned* len) -{ - return 0; -} -void ui_helper::test_callback(const wchar_t* name/*test name*/, test_event ev, void* data, size_t flag) -{ - -} \ No newline at end of file diff --git a/code/base/test_base.h b/code/base/test_base.h index 41699db..198818e 100644 --- a/code/base/test_base.h +++ b/code/base/test_base.h @@ -1,7 +1,7 @@ #pragma once #include "string" #include "sane/sane_ex.h" - +#include "ui_helper.h" //////////////////////////////////////TITLE////////////////////////////////////// /* 拨码开关校验 */ #define HGPDTTOOLDB_TITLE_DIAL_SWITCH L"拨码开关校验" @@ -146,95 +146,6 @@ /* 清除滚轴计数 */ #define HGPDTTOOLDB_NAME_CLEAR_ROLLER_COUNT L"test-35" -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