twain3.0/huagao/Device/GScan.h

130 lines
2.2 KiB
C++

#pragma once
#include <memory>
#include <vector>
#include <string>
#include <queue>
#include <Windows.h>
#include <time.h>
#include <mutex>
#include <thread>
#include "PublicFunc.h"
enum tagDevState
{
DEV_STOP = -1,
DEV_ISRUNNING,
DEV_WRONG
};
typedef enum tagDevState DevState, PDevState;
enum tagEventIndex
{
EVENT_IMAGE,
EVENT_NUM
};
class DiscardBlank;
class CImageApply;
class IGScan
{
public:
virtual ~IGScan()=0 {};
virtual void open(int vid, int pid) = 0;;
virtual int aquire_bmpdata(std::vector<unsigned char>& bmpdata) = 0;
virtual BOOL IsConnected() = 0;
virtual std::string GetFWVersion() = 0;
virtual std::string GetSerialNum() = 0;
virtual bool is_scan() = 0;
virtual BOOL Get_Scanner_PaperOn() = 0;
virtual void config_params(GScanCap& params) = 0;
virtual void Scanner_StartScan(UINT16 count) = 0;
virtual void Stop_scan() = 0;
virtual void ResetScanner() =0;
virtual bool Get_IsImageQueueEmpty() = 0;
virtual void reset() = 0;
virtual void setdecodepixtype(int twpixtype)= 0;
virtual UINT32 get_ErrorCode() = 0;
virtual void Set_ErrorCode(UINT32 value) = 0;
virtual int get_scanned_num() = 0;
};
class IUsb;
class ImageMatQueue;
class GScan
{
public:
GScan();
virtual ~GScan();
protected:
volatile UINT32 Error_Code;
void trim(std::string &s);
volatile int devState;
std::shared_ptr<ImageMatQueue> m_pImages;
std::mutex m_Locker;
std::mutex m_imgLocker;
std::string fwVersion;
std::string SerialNum;
int pixType;
};
//u32_Data
typedef enum tagUsbSupported {
//停止扫描
SCAN_STOP = -2,
//异常
HAVE_ERROR = -1,
//正常状态
NORMAL = 0,
//开盖
OPEN_COVER = 1,
// 无纸
NO_FEED = 2,
// 搓纸失败
FEED_IN_ERROR = 4,
// 卡纸
PAPER_JAM = 8,
// 检测到双张
DETECT_DOUBLE_FEED = 16,
// 检测到订书钉
DETECT_STAPLE = 32,
// 纸张倾斜
PAPER_SKEW = 64,
// 自动模式
AUTO_SCAN_MODE = 65,
// 手动模式
MANAUL_SCAN_MODE = 66,
// 计数模式
COUNT_MODE = 67,
// 硬件错误
HARDWARE_ERROR = 68,
// FPGA崩溃
FPGA_ERROR = 68,
// 开始
START_SCAN = 69,
//停止
STOP_SCAN = 70,
//有图
HAVE_IMAGE = 71,
// 更新扫描参数
UPDATE_SCAN_PARAMETER = 72,
// PC繁忙或出错
PC_SCAN_BUSY_or_ERROR = 73,
//USB 未连接
USB_DISCONNECTED = 200
} UsbSupported, * PUsbSupported;
void DoEvents();