code_device/hgsane/sane_hg_mdw.h

99 lines
3.0 KiB
C
Raw Normal View History

2022-07-18 02:54:41 +00:00
#pragma once
2022-05-03 03:56:07 +00:00
2023-09-09 10:09:20 +00:00
#include "sane/sane_ex.h"
#include "../sdk/hginclude/huagaoxxx_warraper_ex.h"
2022-05-03 03:56:07 +00:00
#include <vector>
#include <algorithm>
#include <string>
2023-09-09 10:09:20 +00:00
class device_opts;
class hg_sane_middleware
{
2023-09-09 10:09:20 +00:00
typedef struct _dev_inst
{
scanner_handle dev;
std::string name;
device_opts* opts;
_dev_inst()
{
dev = nullptr;
name = "";
opts = nullptr;
}
}DEVINST, * LPDEVINST;
2022-05-03 03:56:07 +00:00
2023-09-09 10:09:20 +00:00
bool init_ok_;
std::vector<LPDEVINST> openning_;
2023-09-18 03:21:14 +00:00
LPDEVINST offline_;
2022-05-03 03:56:07 +00:00
static hg_sane_middleware *inst_;
static const SANE_Device** dev_list_;
2023-09-09 10:09:20 +00:00
static const SANE_Device** to_sane_device(ScannerInfo* hgscanner, int count); // 将驱动层传回的设备列表数据转换为标准SANE协议的设备列表
2022-05-03 03:56:07 +00:00
static void free_sane_device(SANE_Device** dev); // 释放由to_sane_device返回的指针
static void device_pnp(int sig); // 热插拔事件监控
static SANE_Fixed double_2_sane_fixed(double v);
static double sane_fixed_2_double(SANE_Fixed v);
2023-09-09 10:09:20 +00:00
static scanner_handle sane_handle_to_scanner(SANE_Handle h);
static void free_device_instance(LPDEVINST inst);
2023-09-09 10:09:20 +00:00
LPDEVINST find_openning_device(SANE_Handle h, bool rmv = false);
LPDEVINST find_openning_device(const char* name, bool rmv = false);
bool reload_options(LPDEVINST inst);
2023-09-09 10:09:20 +00:00
scanner_err read_value(scanner_handle h, const char* name, SANE_Value_Type type, size_t len, void* value, bool to_default);
scanner_err write_value(scanner_handle h, const char* name, SANE_Value_Type type, void* value, bool to_default, LPDEVINST optinst, SANE_Int* affect);
SANE_Status get_current_value(LPDEVINST inst, const void* opt, void* value, bool default_val);
SANE_Status set_value(LPDEVINST inst, const void* opt, void* value, SANE_Int* affect, bool to_default);
SANE_Status get_option_fixed_id(LPDEVINST inst, const void* opt, void* value);
2022-05-03 03:56:07 +00:00
protected:
hg_sane_middleware(void);
~hg_sane_middleware();
public:
2023-08-22 08:47:28 +00:00
enum
{
APP_CALLBACK_AUTH = 0,
APP_CALLBACK_EX,
};
static void set_app_callback(void* cb, void* param = nullptr, int type = APP_CALLBACK_AUTH);
static void get_version(SANE_Int* ver);
2022-05-03 03:56:07 +00:00
static hg_sane_middleware* instance(void);
static void clear(void);
static SANE_Handle scanner_handle_to_sane(scanner_handle h);
// methods ...
public:
SANE_Status get_devices(const SANE_Device*** device_list, SANE_Bool local_only);
SANE_Status open_device(SANE_String_Const devicename, SANE_Handle* handle);
SANE_Status close_device(SANE_Handle h);
SANE_Status get_image_parameters(SANE_Handle handle, SANE_Parameters* params);
SANE_Status start(SANE_Handle h, void* async_event);
SANE_Status read(SANE_Handle h, void* buf, int* bytes);
SANE_Status stop(SANE_Handle h);
SANE_Option_Descriptor* get_option_descriptor(SANE_Handle h, const void* option);
2023-09-09 10:09:20 +00:00
SANE_Status control_option(SANE_Handle h, const void* option, SANE_Action action, void* value, SANE_Int* after_do);
2022-05-03 03:56:07 +00:00
// extension ...
2023-09-09 10:09:20 +00:00
SANE_Status ex_io_control(SANE_Handle h, unsigned long code, void* data, unsigned* len);
2022-05-03 03:56:07 +00:00
public:
2023-01-19 07:43:59 +00:00
bool is_ready(void);
2022-05-03 03:56:07 +00:00
};
2022-06-15 03:05:36 +00:00
namespace local_utility
{
void free_memory(void* m);
int sane_statu_2_scanner_err(int statu);
}