mirror of http://192.168.1.51:8099/lmh188/twain3.0
141 lines
3.0 KiB
C++
141 lines
3.0 KiB
C++
#pragma once
|
|
#include <memory>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <queue>
|
|
#include <Windows.h>
|
|
#include <time.h>
|
|
#include <mutex>
|
|
#include <thread>
|
|
#include <functional>
|
|
#include "filetools.h"
|
|
#include "PublicFunc.h"
|
|
|
|
enum tagDevState
|
|
{
|
|
DEV_STOP = -1,
|
|
DEV_ISRUNNING,
|
|
DEV_WRONG
|
|
};
|
|
typedef enum tagDevState DevState, PDevState;
|
|
|
|
|
|
//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,
|
|
//摺角
|
|
DOG_EAR=74,
|
|
//幅面检测错误
|
|
SIZE_ERROR=75,
|
|
//USB 未连接
|
|
USB_DISCONNECTED = 200,
|
|
//用户点击停止
|
|
USER_STOP = 201,
|
|
//自动校正完成
|
|
AUTO_FLAT_FINISHED = 202,
|
|
//usb 已连接
|
|
USB_CONNECTED,
|
|
HAVE_PAPER
|
|
} UsbSupported, * PUsbSupported;
|
|
|
|
|
|
enum tagEventIndex
|
|
{
|
|
EVENT_IMAGE,
|
|
EVENT_NUM
|
|
};
|
|
|
|
class CImageApply;
|
|
class IUsb;
|
|
class ImageMatQueue;
|
|
typedef void(*deviceevent_callback)(int eventID, void* userdata);
|
|
|
|
class IScanner
|
|
{
|
|
public:
|
|
IScanner() { bFilterMsg = false; }
|
|
virtual ~IScanner() { bFilterMsg = true; }
|
|
void ResetMsgFiter() { bFilterMsg = true; }
|
|
virtual void open(int vid, int pid) = 0;
|
|
virtual void regist_deviceevent_callback(deviceevent_callback callback, void* usrdata = 0) = 0;
|
|
virtual void DogEar_callback(std::function<void(int)> fun)=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 clear_hwerror() = 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;
|
|
void DoEvents() {
|
|
MSG msg;
|
|
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
|
//if (msg.message != WM_LBUTTONUP && bFilterMsg)
|
|
//{
|
|
// FileTools::write_log("C:\\Users\\666\\Desktop\\1.txt", to_string(msg.message));
|
|
// bFilterMsg = false;
|
|
// return;
|
|
//}
|
|
DispatchMessage(&msg);
|
|
TranslateMessage(&msg);
|
|
}
|
|
}
|
|
protected:
|
|
volatile UINT32 Error_Code;
|
|
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;
|
|
bool bFilterMsg;
|
|
}; |