#include #include "sane/sane_ex.h" #include #include #include #pragma once 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(); public: 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 ... VAL_TYPE_TIPS_VAL, // status info tips and data info }; typedef struct _info// value_type == VAL_TUPE_TIPS { const wchar_t* desc; //data const wchar_t* info; //info tips }_INFOTIPS, * PINFOTIPS; // 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_NOT_FIND_TEST, // dll. not find test ,data is (wchar_t*)description, flag is (false) TEST_EVENT_IO_FAIL, // IO. err flag is SCANNER_ERR_DEVICE_NOT_SUPPORT or io err,data is null TEST_EVENT_MANUAL_CONFIRMATION, // After send cmd ,need manual confirmation. TEST_EVENT_RESULT, // test result, data is (wchar_t*)description, flag is (bool)result, true - test pass TEST_EVENT_HAVE_IMAGE, // have image. TEST_EVENT_DISTORTION_VAL, // get distortion_val, data is (float) data > 0 flag is true else false TEST_EVENT_FALT_INFO, // TEST_EVEB_GET_DEVICE_CONFIG_VIDPID, //get vid-pid; data is (int*) ;flag is (bool)result,true - get pass TEST_EVEB_GET_DEVICE_CONFIG_SP, //get sp; data is (int*) ;flag is (bool)result,true - get pass TEST_EVEB_GET_DEVICE_CONFIG_SLEEPTIME, //get sleeptime;data is (int*) ;flag is (bool)result,true - get pass TEST_EVEB_GET_DEVICE_CONFIG_SN, //get sn ;data is (wchar*) ;flag is (bool)result,true - get pass TEST_EVEB_GET_DEVICE_CONFIG_FW, //get fw ;data is (wchar*) ;flag is (bool)result,true - get pass TEST_EVEB_GET_DEVICE_CONFIG_DEVS_MODEL, //get devs_model ;data is (wchar*) ;flag is (bool)result,true - get 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; };