This commit is contained in:
13038267101 2022-07-14 13:58:34 +08:00
commit eb50f63e64
5 changed files with 1990 additions and 60 deletions

View File

@ -18,7 +18,7 @@
#define BRAND_TITLE_VERSION "\347\211\210\346\234\254"
// #define BRAND_TITLE_COPYRIGHT "版权"
#define BRAND_TITLE_COPYRIGHT "\347\211\210\346\235\203"
#define BRAND_COPYRIGHT "1998-2022 HANVONSCAN\344\277\235\347\225\231\346\211\200\346\234\211\346\235\203\345\210\251"
#define BRAND_COPYRIGHT "1998-2022 HANVONSCAN\343\200\202\344\277\235\347\225\231\346\211\200\346\234\211\346\235\203\345\210\251"
// #define BRAND_TITE_MANUFACTOR "制造商/开发商"
#define BRAND_TITE_MANUFACTOR "\345\210\266\351\200\240\345\225\206/\345\274\200\345\217\221\345\225\206"
// #define BRAND_TITLE_URL "公司网址"
@ -47,7 +47,7 @@
#define BRAND_TITLE_VERSION "\347\211\210\346\234\254"
// #define BRAND_TITLE_COPYRIGHT "版权"
#define BRAND_TITLE_COPYRIGHT "\347\211\210\346\235\203"
#define BRAND_COPYRIGHT "2010-2022 LANXUM\344\277\235\347\225\231\346\211\200\346\234\211\346\235\203\345\210\251"
#define BRAND_COPYRIGHT "2010-2022 LANXUM\343\200\202\344\277\235\347\225\231\346\211\200\346\234\211\346\235\203\345\210\251"
// #define BRAND_TITE_MANUFACTOR "制造商/开发商"
#define BRAND_TITE_MANUFACTOR "\345\210\266\351\200\240\345\225\206/\345\274\200\345\217\221\345\225\206"
// #define BRAND_TITLE_URL "公司网址"
@ -75,7 +75,7 @@
#define BRAND_TITLE_VERSION "\347\211\210\346\234\254"
// #define BRAND_TITLE_COPYRIGHT "版权"
#define BRAND_TITLE_COPYRIGHT "\347\211\210\346\235\203"
#define BRAND_COPYRIGHT "2017 HuaGoScan\344\277\235\347\225\231\346\211\200\346\234\211\346\235\203\345\210\251"
#define BRAND_COPYRIGHT "2017 HuaGoScan\343\200\202\344\277\235\347\225\231\346\211\200\346\234\211\346\235\203\345\210\251"
// #define BRAND_TITE_MANUFACTOR "制造商/开发商"
#define BRAND_TITE_MANUFACTOR "\345\210\266\351\200\240\345\225\206/\345\274\200\345\217\221\345\225\206"
// #define BRAND_TITLE_URL "公司网址"
@ -132,6 +132,8 @@
#define SCANNER_NAME_HG_G339 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G339"
// #define SCANNER_NAME_HG_G439 "华高扫描仪—G439"
#define SCANNER_NAME_HG_G439 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G439"
// #define SCANNER_NAME_HG_G402 "华高扫描仪—G402"
#define SCANNER_NAME_HG_G402 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G402"
// #define SCANNER_NAME_LSC_G42S "立思辰扫描仪—G42S"
#define SCANNER_NAME_LSC_G42S "\347\253\213\346\200\235\350\276\260\346\211\253\346\217\217\344\273\252\342\200\224G42S"
@ -150,4 +152,6 @@
#define SCANNER_NAME_HW_1060A "\346\261\211\347\216\213\346\211\253\346\217\217\344\273\252HW1060A"
// #define SCANNER_NAME_HW_9110F "汉王扫描仪—HW9110F"
#define SCANNER_NAME_HW_9110F "\346\261\211\347\216\213\346\211\253\346\217\217\344\273\252HW9110F"
// #define SCANNER_NAME_HW_7039F "汉王扫描仪—HW7039F"
#define SCANNER_NAME_HW_7039F "\346\261\211\347\216\213\346\211\253\346\217\217\344\273\252HW7039F"

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,117 @@
#pragma once
// hg_scanner is the base class of kinds of scanners
//
// created on 2022-01-30
//
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include "hg_scanner.h"
#ifdef OEM_HANWANG
#define hg_scanner_402 hw_scanner_402
#elif defined(OEM_LISICHENG)
#define hg_scanner_402 lsc_scanner_402
#endif
class hg_scanner_402 : public hg_scanner
{
//BlockingQueue<std::shared_ptr<std::vector<unsigned char>>> final_imgs_; // JPG ...
// image_data final_imgs_; // JPG ..
int pid_;
HGSCANCONF dev_conf_;
bool rewrite_conf_;
bool reset_;
bool is_kernelsnap_211209_;
int read_register(int addr, int* val);
int write_register(int addr, int val);
int write_command(int cmd);
std::string control_fetch(int addr, int val, int size);
std::string get_fpga(void);
int clr_roller_num(void);
int get_sleep_time(void);
int get_scan_mode(void);
int get_status(void);
bool is_dev_tx(void);
bool is_dev_image_process_done(void);
bool is_dev_image_keep_last_paper(void);
int get_scanned_count(void);
int get_image_count(void);
int get_front_data_size(void);
void init_version(void);
int get_device_sleep_stautus(void);
int get_device_paperon_stautus(void);
int writedown_device_configuration(HGSCANCONF *dev_conf = NULL);
int writedown_image_configuration(void);
int pop_first_image(void);
int read_one_image_from_usb(void);
void discard_all_images(void);
protected:
int on_color_mode_changed(int& color_mode) override;
virtual int on_paper_changed(int& paper) override;
virtual int on_paper_check_changed(bool& check) override;
virtual int on_resolution_changed(int& dpi) override;
virtual int on_ultrasonic_check_changed(bool& check) override;
virtual int on_staple_check_changed(bool& check) override;
virtual int on_skew_check_changed(bool& check) override;
virtual int on_skew_check_level_changed(int& check) override;
virtual void on_device_reconnected(void) override;
virtual int on_scanner_closing(bool force) override;
virtual void thread_handle_usb_read(void) override;
virtual void image_process(std::shared_ptr<tiny_buffer>& buff) override;
public:
hg_scanner_402(const char* dev_name, int pid,usb_io* io);
~hg_scanner_402();
public:
virtual int start(void) override;
//virtual int get_image_info(IMG_PARAM* ii) override;
//virtual int read_image_data(unsigned char* buf, int* len) override;
virtual int stop(void) override;
virtual int reset(void) override;
virtual int device_io_control(unsigned long code, void* data, unsigned* len) override;
public:
virtual int set_leaflet_scan(void);//单张扫描
virtual int get_abuot_info(void);//获取软件关于信息 (基类实现)
virtual int restore_default_setting(void);//恢复默认设置 (基类实现)
virtual int set_final_image_format(SANE_FinalImgFormat* fmt); // 设置图像处理最终输出final())的图像数据格式 (基类实现) ***
virtual int get_compression_format(void);//获取支持的压缩格式 ***功能不支持
virtual int get_roller_num(void); //获取滚轮张数 ***完成
virtual int clear_roller_num(void); // 清除滚轴计数 ***完成
virtual int set_compression_format(void);//设置图像数据最终输出的压缩格式 ***功能不支持
virtual int set_auto_color_type(void);// 设置自动匹配颜色模式 (基类实现) ***完成
virtual std::string get_firmware_version(void);
virtual std::string get_serial_num(void);
virtual std::string get_ip(void);
virtual int get_device_code(void);//获取设备编码
virtual int get_sleep_time(SANE_Power* getime);//获取功耗模式(休眠)
virtual int set_sleep_time(int setsleepime);//设置功耗模式(休眠)
virtual int get_dogear_distance(void);//获取折角检测最小距离阈值
virtual int set_dogear_distance(void);// 设置折角检测最小距离阈值
virtual int get_scanner_paperon(SANE_Bool* paperon = NULL);//获取设备有无纸张
virtual int set_scan_when_paper_on(void);//获取是否为检测到进纸盘上有纸即开始扫描
virtual int get_scan_when_paper_on(void);//设置是否为检测到进纸盘上有纸即开始扫描
virtual int get_scan_with_hole(void);// 获取是否为带孔扫描
virtual int set_scan_with_hole(void);// 设置是否为带孔扫描
virtual int get_scan_is_sleep(void);//获取设备是否休眠当中
};

View File

@ -12,6 +12,7 @@
#include "hg_scanner_239.h"
#include "hg_scanner_300.h"
#include "hg_scanner_400.h"
#include "hg_scanner_402.h"
/// <summary>
/// supporting devices :
@ -22,30 +23,36 @@ static struct
std::string name; // product name
std::string type; // product type
std::string rsc; // USB resource, version-addr. e.g. "USB2.0-1"
hg_scanner* (* create_scanner)(const char*, usb_io*, scanner_handle*);
}
g_supporting_devices[] = {
#ifdef OEM_LISICHENG
{0x31c9, 0x8420, SCANNER_NAME_LSC_G42S, "G426xF", ""}
, {0x31c9, 0x8520, SCANNER_NAME_LSC_G52S, "G52x0F", ""}
, {0x31c9, 0x8620, SCANNER_NAME_LSC_G62S, "G6290U", ""}
, {0x31c9, 0x8629, SCANNER_NAME_LSC_G62S, "G6290U", ""}
, {0x31c9, 0x8730, SCANNER_NAME_LSC_G73S, "G73x0U", ""}
, {0x31c9, 0x8739, SCANNER_NAME_LSC_G73S, "G73x0U", ""},
{0x31c9, 0x8420, SCANNER_NAME_LSC_G42S, "G426xF", "", &hg_scanner_mgr::create_scanner_g300}
, {0x31c9, 0x8520, SCANNER_NAME_LSC_G52S, "G52x0F", "", &hg_scanner_mgr::create_scanner_g400}
, {0x31c9, 0x8620, SCANNER_NAME_LSC_G62S, "G6290U", "", &hg_scanner_mgr::create_scanner_g100}
, {0x31c9, 0x8629, SCANNER_NAME_LSC_G62S, "G6290U", "", &hg_scanner_mgr::create_scanner_g239}
, {0x31c9, 0x8730, SCANNER_NAME_LSC_G73S, "G73x0U", "", &hg_scanner_mgr::create_scanner_g100}
, {0x31c9, 0x8739, SCANNER_NAME_LSC_G73S, "G73x0U", "", &hg_scanner_mgr::create_scanner_g239}
, {0x31c9, 0x8529, SCANNER_NAME_LSC_G52S, "G52x0F", "", &hg_scanner_mgr::create_scanner_g239}
, {0x31c9, 0x8429, SCANNER_NAME_LSC_G42S, "G42x0F", "", &hg_scanner_mgr::create_scanner_empty}
#elif defined(OEM_HANWANG)
{0x2903, 0x7000, SCANNER_NAME_HW_7000, "HW-74x0WA", ""}
, {0x2903, 0x1000, SCANNER_NAME_HW_1060A, "HW-1060A", ""}
, {0x2903, 0x8000, SCANNER_NAME_HW_8090F, "HW-8090F", ""}
, {0x2903, 0x9000, SCANNER_NAME_HW_9110F, "HW-9110F", ""},
{0x2903, 0x7000, SCANNER_NAME_HW_7000, "HW-74x0WA", "", &hg_scanner_mgr::create_scanner_g400}
, {0x2903, 0x1000, SCANNER_NAME_HW_1060A, "HW-1060A", "", &hg_scanner_mgr::create_scanner_g300}
, {0x2903, 0x8000, SCANNER_NAME_HW_8090F, "HW-8090F", "", &hg_scanner_mgr::create_scanner_g239}
, {0x2903, 0x9000, SCANNER_NAME_HW_9110F, "HW-9110F", "", &hg_scanner_mgr::create_scanner_g239}
, {0x2903, 0x7039, SCANNER_NAME_HW_7039F, "HW-7039F", "", &hg_scanner_mgr::create_scanner_g239}
#else
{0x3072, 0x100, SCANNER_NAME_HG_G100, "GScanO200", ""}
, {0x3072, 0x200, SCANNER_NAME_HG_G200, "GScanO200", ""}
, {0x3072, 0x300, SCANNER_NAME_HG_G300, "GScanO400", ""}
, {0x3072, 0x400, SCANNER_NAME_HG_G400, "GScanO400", ""}
, {0x3072, 0x139, SCANNER_NAME_HG_G139, "GScanO1003399", ""}
, {0x3072, 0x239, SCANNER_NAME_HG_G239, "GScanO1003399", ""}
, {0x3072, 0x339, SCANNER_NAME_HG_G339, "GScanO1003399", ""}
, {0x3072, 0x439, SCANNER_NAME_HG_G439, "GScanO1003399", ""}
, {0x064B, 0x7823, SCANNER_NAME_HG_G200, "GScanO200", ""}
{0x3072, 0x100, SCANNER_NAME_HG_G100, "GScanO200", "", &hg_scanner_mgr::create_scanner_g100}
, {0x3072, 0x200, SCANNER_NAME_HG_G200, "GScanO200", "", &hg_scanner_mgr::create_scanner_g100}
, {0x3072, 0x300, SCANNER_NAME_HG_G300, "GScanO400", "", &hg_scanner_mgr::create_scanner_g300}
, {0x3072, 0x400, SCANNER_NAME_HG_G400, "GScanO400", "", &hg_scanner_mgr::create_scanner_g400}
, {0x3072, 0x139, SCANNER_NAME_HG_G139, "GScanO1003399", "", &hg_scanner_mgr::create_scanner_g239}
, {0x3072, 0x239, SCANNER_NAME_HG_G239, "GScanO1003399", "", &hg_scanner_mgr::create_scanner_g239}
, {0x3072, 0x339, SCANNER_NAME_HG_G339, "GScanO1003399", "", &hg_scanner_mgr::create_scanner_empty}
, {0x3072, 0x439, SCANNER_NAME_HG_G439, "GScanO1003399", "", &hg_scanner_mgr::create_scanner_g239}
, {0x064B, 0x7823, SCANNER_NAME_HG_G200, "GScanO200", "", &hg_scanner_mgr::create_scanner_empty}
, {0x3072, 0x402, SCANNER_NAME_HG_G402, "GScanO4003399", "", &hg_scanner_mgr::create_scanner_g402}
#endif
};
static std::string g_vendor = COMPANY_NAME;
@ -123,6 +130,59 @@ void hg_scanner_mgr::set_version(int hh, int hl, int lh, int ll)
hg_scanner_mgr::ver_patch_ = ll;
}
hg_scanner* hg_scanner_mgr::create_scanner_empty(const char* name, usb_io* io, scanner_handle* h)
{
if (h)
*h = nullptr;
return nullptr;
}
hg_scanner* hg_scanner_mgr::create_scanner_g100(const char* name, usb_io* io, scanner_handle* h)
{
hg_scanner_200* s = new hg_scanner_200(name, 0x100, io);
if (h)
*h = s;
return dynamic_cast<hg_scanner*>(s);
}
hg_scanner* hg_scanner_mgr::create_scanner_g239(const char* name, usb_io* io, scanner_handle* h)
{
hg_scanner_239* s = new hg_scanner_239(name, 0x239, io);
if (h)
*h = s;
return dynamic_cast<hg_scanner*>(s);
}
hg_scanner* hg_scanner_mgr::create_scanner_g300(const char* name, usb_io* io, scanner_handle* h)
{
hg_scanner_300* s = new hg_scanner_300(name, 0x300, io);
if (h)
*h = s;
return dynamic_cast<hg_scanner*>(s);
}
hg_scanner* hg_scanner_mgr::create_scanner_g400(const char* name, usb_io* io, scanner_handle* h)
{
hg_scanner_400* s = new hg_scanner_400(name, 0x400, io);
if (h)
*h = s;
return dynamic_cast<hg_scanner*>(s);
}
hg_scanner* hg_scanner_mgr::create_scanner_g402(const char* name, usb_io* io, scanner_handle* h)
{
hg_scanner_402* s = new hg_scanner_402(name, 0x400, io);
if (h)
*h = s;
return dynamic_cast<hg_scanner*>(s);
}
void hg_scanner_mgr::usb_event_handle(usb_event ev, libusb_device* device, int vid, int pid, int usb_ver_h, int usb_ver_l, bool* retry, void* user) // usb_ver_h.usb_ver_l
{
hg_scanner_mgr* obj = (hg_scanner_mgr*)user;
@ -463,11 +523,13 @@ scanner_err hg_scanner_mgr::hg_scanner_open(scanner_handle* h, const char* name,
ret = (scanner_err)usb_manager::instance()->open(it->dev, &io, &msg);
if (ret == SCANNER_ERR_OK)
{
hg_scanner* scanner = NULL;
hg_scanner* scanner = g_supporting_devices[it->ind].create_scanner(g_supporting_devices[it->ind].name.c_str(), io, h);
if (!scanner)
{
if (g_supporting_devices[it->ind].pid == 0x100 ||
g_supporting_devices[it->ind].pid == 0x200 ||
g_supporting_devices[it->ind].pid == 0x8620||
g_supporting_devices[it->ind].pid == 0x8730 )
g_supporting_devices[it->ind].pid == 0x8620 ||
g_supporting_devices[it->ind].pid == 0x8730)
{
hg_scanner_200* s200 = new hg_scanner_200(g_supporting_devices[it->ind].name.c_str(), 0x100, io);
@ -476,18 +538,21 @@ scanner_err hg_scanner_mgr::hg_scanner_open(scanner_handle* h, const char* name,
}
else if (g_supporting_devices[it->ind].pid == 0x239 ||
g_supporting_devices[it->ind].pid == 0x139 ||
g_supporting_devices[it->ind].pid == 0x8000||
g_supporting_devices[it->ind].pid == 0x9000||
g_supporting_devices[it->ind].pid == 0x8739||
g_supporting_devices[it->ind].pid == 0x8629 )
g_supporting_devices[it->ind].pid == 0x8000 ||
g_supporting_devices[it->ind].pid == 0x9000 ||
g_supporting_devices[it->ind].pid == 0x8739 ||
g_supporting_devices[it->ind].pid == 0x8629 ||
g_supporting_devices[it->ind].pid == 0x0439 ||
g_supporting_devices[it->ind].pid == 0x7039 ||
g_supporting_devices[it->ind].pid == 0x8529)
{
hg_scanner_239* s239 = new hg_scanner_239(g_supporting_devices[it->ind].name.c_str(),0x239, io);
hg_scanner_239* s239 = new hg_scanner_239(g_supporting_devices[it->ind].name.c_str(), 0x239, io);
scanner = dynamic_cast<hg_scanner*>(s239);
*h = (scanner_handle)s239;
}
else if (g_supporting_devices[it->ind].pid == 0x400 ||
g_supporting_devices[it->ind].pid == 0x7000||
g_supporting_devices[it->ind].pid == 0x7000 ||
g_supporting_devices[it->ind].pid == 0x8520)
{
hg_scanner_400* s400 = new hg_scanner_400(g_supporting_devices[it->ind].name.c_str(), 0x400, io);
@ -495,18 +560,17 @@ scanner_err hg_scanner_mgr::hg_scanner_open(scanner_handle* h, const char* name,
*h = (scanner_handle)s400;
}
else if (g_supporting_devices[it->ind].pid == 0x300 ||
g_supporting_devices[it->ind].pid == 0x1000||
g_supporting_devices[it->ind].pid == 0x1000 ||
g_supporting_devices[it->ind].pid == 0x8420)
{
hg_scanner_300* s300 = new hg_scanner_300(g_supporting_devices[it->ind].name.c_str(),0x300, io);
hg_scanner_300* s300 = new hg_scanner_300(g_supporting_devices[it->ind].name.c_str(), 0x300, io);
scanner = dynamic_cast<hg_scanner*>(s300);
*h = (scanner_handle)s300;
}
}
if (scanner)
{
scanner->set_ui_callback(&hg_scanner_mgr::ui_default_callback, hg_scanner_mgr::async_io_enabled_);
}
std::lock_guard<std::mutex> lock(mutex_dev_);
std::vector<OLSCANNER>::iterator ptr = std::find(online_devices_.begin(), online_devices_.end(), name);

View File

@ -88,6 +88,13 @@ public:
static void clear(void);
static void set_version(int hh, int hl, int lh, int ll);
static hg_scanner* create_scanner_empty(const char* name, usb_io* io, scanner_handle* h);
static hg_scanner* create_scanner_g100(const char* name, usb_io* io, scanner_handle* h);
static hg_scanner* create_scanner_g239(const char* name, usb_io* io, scanner_handle* h);
static hg_scanner* create_scanner_g300(const char* name, usb_io* io, scanner_handle* h);
static hg_scanner* create_scanner_g400(const char* name, usb_io* io, scanner_handle* h);
static hg_scanner* create_scanner_g402(const char* name, usb_io* io, scanner_handle* h);
public:
scanner_err hg_scanner_enum(ScannerInfo* scanner_list, long* count, bool local_only);
scanner_err hg_scanner_open(scanner_handle* h, const char* name, bool shared, const char* user, const char* pwd, const char* check, char* rsc);