mirror of http://192.168.1.51:8099/lmh188/twain3.0
1.增加清除错误接口;
2.整合IGscan和Gscan接口为IScanner接口,去掉不必要的多继承; 3.调整开始扫描逻辑;
This commit is contained in:
parent
185fcf5a7d
commit
169dab7d5c
|
@ -1,40 +1,36 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "GScan.h"
|
#include "GScan.h"
|
||||||
#include "stdio.h"
|
#include <stdio.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "ImageProcess/ImageApplyHeaders.h"
|
#include "ImageProcess/ImageApplyHeaders.h"
|
||||||
#include "ImageMatQueue.h"
|
#include "ImageMatQueue.h"
|
||||||
|
|
||||||
|
|
||||||
GScan::GScan()
|
//GScan::GScan()
|
||||||
:pixType(0)
|
// :pixType(0)
|
||||||
, m_pImages(new ImageMatQueue())
|
// , m_pImages(new ImageMatQueue())
|
||||||
{
|
//{
|
||||||
devState = DEV_STOP;
|
// devState = DEV_STOP;
|
||||||
Error_Code = 0;
|
// Error_Code = 0;
|
||||||
}
|
//}
|
||||||
|
|
||||||
GScan::~GScan()
|
//void DoEvents()
|
||||||
{
|
//{
|
||||||
}
|
// MSG msg;
|
||||||
|
// if (PeekMessage(&msg , NULL, 0, 0, PM_REMOVE)) {
|
||||||
|
// DispatchMessage(&msg);
|
||||||
|
// TranslateMessage(&msg);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
void DoEvents()
|
//void GScan::trim(std::string &s)
|
||||||
{
|
//{
|
||||||
MSG msg;
|
// int index = 0;
|
||||||
if (PeekMessage(&msg , NULL, 0, 0, PM_REMOVE)) {
|
// if (!s.empty()) {
|
||||||
DispatchMessage(&msg);
|
// while ((index = s.find(' ', index)) != string::npos)
|
||||||
TranslateMessage(&msg);
|
// s.erase(index, 1);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
void GScan::trim(std::string &s)
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
if (!s.empty()) {
|
|
||||||
while ((index = s.find(' ', index)) != string::npos)
|
|
||||||
s.erase(index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,76 +9,14 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "PublicFunc.h"
|
#include "PublicFunc.h"
|
||||||
|
|
||||||
|
|
||||||
enum tagDevState
|
enum tagDevState
|
||||||
{
|
{
|
||||||
DEV_STOP = -1,
|
DEV_STOP = -1,
|
||||||
DEV_ISRUNNING,
|
DEV_ISRUNNING,
|
||||||
DEV_WRONG
|
DEV_WRONG
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum tagDevState DevState, PDevState;
|
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 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;
|
|
||||||
};
|
|
||||||
|
|
||||||
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
|
//u32_Data
|
||||||
typedef enum tagUsbSupported {
|
typedef enum tagUsbSupported {
|
||||||
|
@ -124,8 +62,57 @@ typedef enum tagUsbSupported {
|
||||||
PC_SCAN_BUSY_or_ERROR = 73,
|
PC_SCAN_BUSY_or_ERROR = 73,
|
||||||
//USB δÁ¬½Ó
|
//USB δÁ¬½Ó
|
||||||
USB_DISCONNECTED = 200
|
USB_DISCONNECTED = 200
|
||||||
} UsbSupported, * PUsbSupported;
|
} UsbSupported, *PUsbSupported;
|
||||||
|
|
||||||
|
|
||||||
|
enum tagEventIndex
|
||||||
|
{
|
||||||
|
EVENT_IMAGE,
|
||||||
|
EVENT_NUM
|
||||||
|
};
|
||||||
|
|
||||||
void DoEvents();
|
class DiscardBlank;
|
||||||
|
class CImageApply;
|
||||||
|
class IUsb;
|
||||||
|
class ImageMatQueue;
|
||||||
|
|
||||||
|
class IScanner
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IScanner(){};
|
||||||
|
|
||||||
|
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 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)) {
|
||||||
|
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;
|
||||||
|
};
|
|
@ -103,6 +103,10 @@ void GScan200::reset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GScan200::clear_hwerror()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void GScan200::setdecodepixtype(int twpixtype)
|
void GScan200::setdecodepixtype(int twpixtype)
|
||||||
{
|
{
|
||||||
pixType = (twpixtype == 0) ? 1 : 0;
|
pixType = (twpixtype == 0) ? 1 : 0;
|
||||||
|
@ -125,11 +129,6 @@ int GScan200::get_scanned_num()
|
||||||
return scanned_count;
|
return scanned_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GScan200::set_scan_status(bool isscan)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GScan200::image_call_s(void* fdata, int fsize, void* bdata, int bsize, void* userdata)
|
void GScan200::image_call_s(void* fdata, int fsize, void* bdata, int bsize, void* userdata)
|
||||||
{
|
{
|
||||||
GScan200* This = (GScan200*)userdata;
|
GScan200* This = (GScan200*)userdata;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
class IGDevice;
|
class IGDevice;
|
||||||
|
|
||||||
class GScan200 : public IGScan, GScan
|
class GScan200 : public IScanner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GScan200();
|
GScan200();
|
||||||
|
@ -23,11 +23,11 @@ public:
|
||||||
virtual void ResetScanner() override;
|
virtual void ResetScanner() override;
|
||||||
virtual bool Get_IsImageQueueEmpty() override;
|
virtual bool Get_IsImageQueueEmpty() override;
|
||||||
virtual void reset() override;
|
virtual void reset() override;
|
||||||
|
virtual void clear_hwerror() override;
|
||||||
virtual void setdecodepixtype(int twpixtype) override;
|
virtual void setdecodepixtype(int twpixtype) override;
|
||||||
virtual UINT32 get_ErrorCode() override;
|
virtual UINT32 get_ErrorCode() override;
|
||||||
virtual void Set_ErrorCode(UINT32 value) override;
|
virtual void Set_ErrorCode(UINT32 value) override;
|
||||||
virtual int get_scanned_num() override;
|
virtual int get_scanned_num() override;
|
||||||
void set_scan_status(bool isscan);
|
|
||||||
private:
|
private:
|
||||||
static void image_call_s(void *fdata, int fsize, void *bdata, int bsize, void *userdata);
|
static void image_call_s(void *fdata, int fsize, void *bdata, int bsize, void *userdata);
|
||||||
static void event_call_g200(int error_value, void* userdata);
|
static void event_call_g200(int error_value, void* userdata);
|
||||||
|
|
|
@ -78,72 +78,74 @@ typedef enum tagUsbKeyWords : UINT32
|
||||||
//获取序列号命令
|
//获取序列号命令
|
||||||
GET_SERIAL = 29,
|
GET_SERIAL = 29,
|
||||||
//获取滚轴数
|
//获取滚轴数
|
||||||
GET_ROLLER_NUM=0x1e,
|
GET_ROLLER_NUM = 0x1e,
|
||||||
//清零滚轴数
|
//清零滚轴数
|
||||||
CLR_ROLLER_NUM=0x1f,
|
CLR_ROLLER_NUM = 0x1f,
|
||||||
//清除扫描总张数
|
//清除扫描总张数
|
||||||
CLR_SCAN_NUM=0x20,
|
CLR_SCAN_NUM = 0x20,
|
||||||
//准备更新固件
|
//准备更新固件
|
||||||
PRE_UPGRADE=0X21,
|
PRE_UPGRADE = 0X21,
|
||||||
//开始更新固件
|
//开始更新固件
|
||||||
START_UPGRADE=0x22,
|
START_UPGRADE = 0x22,
|
||||||
//彩色的AD参数
|
//彩色的AD参数
|
||||||
RGB_ADI_PARA=0x23,
|
RGB_ADI_PARA = 0x23,
|
||||||
//灰度的AD参数
|
//灰度的AD参数
|
||||||
ADI_PARA=0x24,
|
ADI_PARA = 0x24,
|
||||||
//获取CIS参数(曝光时间,ad参数)
|
//获取CIS参数(曝光时间,ad参数)
|
||||||
GET_CIS_PARA=0x25,
|
GET_CIS_PARA = 0x25,
|
||||||
//扫描张数
|
//扫描张数
|
||||||
START_COMMAND_COUNT=0x26,
|
START_COMMAND_COUNT = 0x26,
|
||||||
//下发休眠时间
|
//下发休眠时间
|
||||||
SET_SLEEP_TIME=0x27,
|
SET_SLEEP_TIME = 0x27,
|
||||||
//获取休眠时间
|
//获取休眠时间
|
||||||
GET_SLEEP_TIME=0x28,
|
GET_SLEEP_TIME = 0x28,
|
||||||
//清除缓存
|
//清除缓存
|
||||||
CLR_CACHE=0x29,
|
CLR_CACHE = 0x29,
|
||||||
//下发速度模式
|
//下发速度模式
|
||||||
SET_SPEED_MODE=0x2a,
|
SET_SPEED_MODE = 0x2a,
|
||||||
//获取扫描速度模式
|
//获取扫描速度模式
|
||||||
GET_SPEED_MODE=0X2b,
|
GET_SPEED_MODE = 0X2b,
|
||||||
//设置固件版本一共8个字节
|
//设置固件版本一共8个字节
|
||||||
SET_FW_VERSION=0X2c,
|
SET_FW_VERSION = 0X2c,
|
||||||
//获取DSP版本
|
//获取DSP版本
|
||||||
GET_DSP_VERSION=0X2d,
|
GET_DSP_VERSION = 0X2d,
|
||||||
//采集板FPGA固件版本
|
//采集板FPGA固件版本
|
||||||
GET_SCANFPGA_VERSION=0x2e,
|
GET_SCANFPGA_VERSION = 0x2e,
|
||||||
//电机板FPGA固件版本
|
//电机板FPGA固件版本
|
||||||
GET_MOTORFPGA_VERSION =0X2f,
|
GET_MOTORFPGA_VERSION = 0X2f,
|
||||||
//设置制造商信息
|
//设置制造商信息
|
||||||
SET_USB_INFOR_MANUFACTURE=0X30,
|
SET_USB_INFOR_MANUFACTURE = 0X30,
|
||||||
//获取制造商信息
|
//获取制造商信息
|
||||||
GET_USB_INFOR_MANUFACTURE=0X31,
|
GET_USB_INFOR_MANUFACTURE = 0X31,
|
||||||
//设置产品型号信息
|
//设置产品型号信息
|
||||||
SET_USB_INFOR_MODEL_NAME=0X32,
|
SET_USB_INFOR_MODEL_NAME = 0X32,
|
||||||
//获取产品型号信息
|
//获取产品型号信息
|
||||||
GET_USB_INFOR_MODEL_NAME=0X33,
|
GET_USB_INFOR_MODEL_NAME = 0X33,
|
||||||
//设置USB PID / VID信息
|
//设置USB PID / VID信息
|
||||||
SET_USB_INFOR_VIDPID=0X34,
|
SET_USB_INFOR_VIDPID = 0X34,
|
||||||
GET_USB_INFOR_VIDPID=0X35,
|
GET_USB_INFOR_VIDPID = 0X35,
|
||||||
//设置卡纸急停检测灵敏度
|
//设置卡纸急停检测灵敏度
|
||||||
SET_JAM_DETECT_SENSITIVE=0X36,
|
SET_JAM_DETECT_SENSITIVE = 0X36,
|
||||||
//获取卡纸急停检测灵敏度
|
//获取卡纸急停检测灵敏度
|
||||||
GET_JAM_DETECT_SENSITIVE=0X37,
|
GET_JAM_DETECT_SENSITIVE = 0X37,
|
||||||
//设置横向畸变系数
|
//设置横向畸变系数
|
||||||
SET_JUST_COF_H=0x38,
|
SET_JUST_COF_H = 0x38,
|
||||||
//读取横向畸变系数
|
//读取横向畸变系数
|
||||||
GET_JUST_COF_H=0x39,
|
GET_JUST_COF_H = 0x39,
|
||||||
#ifndef G200
|
#ifndef G200
|
||||||
CLEAR_HWERROR = 0x40,//G400 清除硬件异常
|
CLEAR_HWERROR = 0x40,//G400 清除硬件异常
|
||||||
#endif // !G200
|
#endif // !G200
|
||||||
//设置纵向畸变系数
|
//ÉèÖÃ×ÝÏò»û±äϵÊý
|
||||||
SET_JUST_COF_V = 0x41,
|
SET_JUST_COF_V = 0x41,
|
||||||
//读取纵向畸变系数
|
//读取纵向畸变系数
|
||||||
GET_JUST_COF_V
|
GET_JUST_COF_V
|
||||||
|
|
||||||
} UsbKeyWords, * PUsbKeyWords;
|
} UsbKeyWords, *PUsbKeyWords;
|
||||||
|
|
||||||
GScanO200::GScanO200()
|
GScanO200::GScanO200():
|
||||||
|
m_bread_fixed_ratio_fromDSP(false)
|
||||||
{
|
{
|
||||||
|
m_pImages.reset(new ImageMatQueue());
|
||||||
}
|
}
|
||||||
|
|
||||||
GScanO200::~GScanO200()
|
GScanO200::~GScanO200()
|
||||||
|
@ -201,6 +203,11 @@ int GScanO200::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
||||||
else {
|
else {
|
||||||
if (m_pImages->valid()) {
|
if (m_pImages->valid()) {
|
||||||
bmpdata = *(m_pImages->popBmpdata());
|
bmpdata = *(m_pImages->popBmpdata());
|
||||||
|
//static int aqimgindex = 0;
|
||||||
|
//FileTools::write_log("1.txt", "aquireed image " + to_string(++aqimgindex));
|
||||||
|
//FileTools::write_log("E:\\Users\\huago\\Desktop\\1.txt", "aquired image "+ to_string(++aqimgindex));
|
||||||
|
|
||||||
|
|
||||||
#ifdef LOG_NORMAL
|
#ifdef LOG_NORMAL
|
||||||
static int aquireindex = 0;
|
static int aquireindex = 0;
|
||||||
FileTools::write_log("out.txt", "aquire image index " + std::to_string(++aquireindex));
|
FileTools::write_log("out.txt", "aquire image index " + std::to_string(++aquireindex));
|
||||||
|
@ -224,24 +231,22 @@ std::string GScanO200::GetFWVersion()
|
||||||
lock_guard< mutex> lock(m_imgLocker);
|
lock_guard< mutex> lock(m_imgLocker);
|
||||||
if (fwVersion.empty()) {
|
if (fwVersion.empty()) {
|
||||||
#ifndef G200
|
#ifndef G200
|
||||||
fwVersion = " ";
|
fwVersion.resize(10);
|
||||||
USBCB cmd = { GET_FW_VERSION,10,0, };
|
|
||||||
m_usb->write_bulk(&cmd, sizeof(cmd));
|
|
||||||
m_usb->read_bulk(&fwVersion[0], 10);
|
|
||||||
//std::string ver=fwVersion.substr((fwVersion.length() - 2), 2);
|
|
||||||
//int verValue = atoi(ver.c_str());
|
|
||||||
//m_bread_fixed_ratio_fromDSP = verValue >= 15;
|
|
||||||
//writelog(m_bread_fixed_ratio_fromDSP ? "can get ratio from dsp" : "can not get dsp ratio");
|
|
||||||
//updateHVRatio()
|
|
||||||
#else // !G200
|
#else // !G200
|
||||||
fwVersion = " ";
|
fwVersion.resize(8);
|
||||||
USBCB cmd = { GET_FW_VERSION,8,0, };
|
|
||||||
m_usb->write_bulk(&cmd, sizeof(cmd));
|
|
||||||
m_usb->read_bulk(&fwVersion[0], 8);
|
|
||||||
#endif
|
#endif
|
||||||
|
USBCB cmd = { GET_FW_VERSION,fwVersion.size(),0, };
|
||||||
|
m_usb->write_bulk(&cmd, sizeof(cmd));
|
||||||
|
m_usb->read_bulk(&fwVersion[0], fwVersion.size());
|
||||||
|
#ifdef G200
|
||||||
|
std::string ver = fwVersion.substr((fwVersion.length() - 2), 2);
|
||||||
|
int verValue = atoi(ver.c_str());
|
||||||
|
m_bread_fixed_ratio_fromDSP = verValue >= 15;
|
||||||
|
writelog(m_bread_fixed_ratio_fromDSP ? "can get ratio from dsp" : "can not get dsp ratio");
|
||||||
|
updateHVRatio();
|
||||||
|
#endif // G200
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
return fwVersion;
|
return fwVersion;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -249,22 +254,19 @@ std::string GScanO200::GetFWVersion()
|
||||||
|
|
||||||
std::string GScanO200::GetSerialNum()
|
std::string GScanO200::GetSerialNum()
|
||||||
{
|
{
|
||||||
|
//return "G20018000298";
|
||||||
if (m_usb.get() && m_usb->is_connected())
|
if (m_usb.get() && m_usb->is_connected())
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||||
if (SerialNum.empty()) {
|
if (SerialNum.empty()) {
|
||||||
#ifndef G200
|
#ifndef G200
|
||||||
SerialNum = " ";
|
SerialNum.resize(14);
|
||||||
USBCB usbcb = { GET_SERIAL,14,0 };
|
|
||||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
|
||||||
m_usb->read_bulk(&SerialNum[0], 14);
|
|
||||||
#else // !G200
|
#else // !G200
|
||||||
SerialNum = " ";
|
SerialNum.resize(12);
|
||||||
USBCB usbcb = { GET_SERIAL,12,0 };
|
|
||||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
|
||||||
m_usb->read_bulk(&SerialNum[0], 12);
|
|
||||||
#endif
|
#endif
|
||||||
|
USBCB usbcb = { GET_SERIAL,SerialNum.size(),0 };
|
||||||
|
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||||
|
m_usb->read_bulk(&SerialNum[0], SerialNum.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
return SerialNum;
|
return SerialNum;
|
||||||
|
@ -310,12 +312,52 @@ void GScanO200::Scanner_StartScan(UINT16 count)
|
||||||
{
|
{
|
||||||
if (m_usb.get() && m_usb->is_connected()) {
|
if (m_usb.get() && m_usb->is_connected()) {
|
||||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||||
USBCB usbcb = { START_COMMAND,(UINT32)count ,0 };
|
|
||||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
|
||||||
if (m_threadUsb && m_threadUsb->joinable()) {
|
if (m_threadUsb && m_threadUsb->joinable()) {
|
||||||
devState = DEV_STOP;
|
devState = DEV_STOP;
|
||||||
m_threadUsb->join();
|
m_threadUsb->join();
|
||||||
}
|
}
|
||||||
|
#ifndef G200
|
||||||
|
USBCB paperstatus = { GET_PAPER_STATUS ,0,0 };
|
||||||
|
m_usb->write_bulk(&paperstatus, sizeof(paperstatus));
|
||||||
|
m_usb->read_bulk(&paperstatus, sizeof(paperstatus));
|
||||||
|
if (paperstatus.u32_Data == 0) {
|
||||||
|
m_pImages->setscanflags(false);
|
||||||
|
devState = DEV_WRONG;
|
||||||
|
Set_ErrorCode(NO_FEED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif // !G200
|
||||||
|
|
||||||
|
|
||||||
|
USBCB status = { GET_DSP_STATUS ,0,0 };
|
||||||
|
m_usb->write_bulk(&status, sizeof(status));
|
||||||
|
m_usb->read_bulk(&status, sizeof(status));
|
||||||
|
|
||||||
|
switch (status.u32_Data)
|
||||||
|
{
|
||||||
|
case COUNT_MODE:
|
||||||
|
case NO_FEED:
|
||||||
|
case OPEN_COVER:
|
||||||
|
case FEED_IN_ERROR:
|
||||||
|
case PAPER_JAM:
|
||||||
|
case DETECT_DOUBLE_FEED:
|
||||||
|
case DETECT_STAPLE:
|
||||||
|
case PAPER_SKEW:
|
||||||
|
case HARDWARE_ERROR:
|
||||||
|
case PC_SCAN_BUSY_or_ERROR:
|
||||||
|
m_pImages->setscanflags(false);
|
||||||
|
devState = DEV_WRONG;
|
||||||
|
Set_ErrorCode(status.u32_Data);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gcap.is_duplex)
|
||||||
|
count = count == 65535 ? 65535 : count / 2;
|
||||||
|
USBCB usbcb = { START_COMMAND,(UINT32)count ,0 };
|
||||||
|
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||||
|
|
||||||
m_pImages->setscanflags(true);
|
m_pImages->setscanflags(true);
|
||||||
m_threadUsb.reset(new std::thread(&GScanO200::usbmain, this));
|
m_threadUsb.reset(new std::thread(&GScanO200::usbmain, this));
|
||||||
m_pImages->run();
|
m_pImages->run();
|
||||||
|
@ -330,8 +372,10 @@ void GScanO200::Stop_scan()
|
||||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||||
USBCB usbcb = { STOP ,0,0 };
|
USBCB usbcb = { STOP ,0,0 };
|
||||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||||
m_pImages->setscanflags(false);
|
#ifdef G200
|
||||||
devState = DEV_STOP;
|
//m_pImages->setscanflags(false);
|
||||||
|
//devState = DEV_STOP;
|
||||||
|
#endif // G200
|
||||||
}
|
}
|
||||||
|
|
||||||
void GScanO200::ResetScanner()
|
void GScanO200::ResetScanner()
|
||||||
|
@ -353,6 +397,7 @@ void GScanO200::reset()
|
||||||
{
|
{
|
||||||
while (!m_pImages->empty())
|
while (!m_pImages->empty())
|
||||||
m_pImages->clear();
|
m_pImages->clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GScanO200::setdecodepixtype(int twpixtype)
|
void GScanO200::setdecodepixtype(int twpixtype)
|
||||||
|
@ -417,11 +462,11 @@ void GScanO200::updateHVRatio()
|
||||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||||
m_usb->read_bulk(&usbcb, sizeof(usbcb));
|
m_usb->read_bulk(&usbcb, sizeof(usbcb));
|
||||||
float hratio = *((float*)(&usbcb.u32_Data));
|
float hratio = *((float*)(&usbcb.u32_Data));
|
||||||
usbcb= { GET_JUST_COF_V ,0,0 };
|
usbcb = { GET_JUST_COF_V ,0,0 };
|
||||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||||
m_usb->read_bulk(&usbcb, sizeof(usbcb));
|
m_usb->read_bulk(&usbcb, sizeof(usbcb));
|
||||||
float vratio = *((float*)(&usbcb.u32_Data));
|
float vratio = *((float*)(&usbcb.u32_Data));
|
||||||
writelog("fx: " + to_string(hratio) + " fy :" + to_string(vratio));
|
//writelog("fx: " + to_string(hratio) + " fy :" + to_string(vratio));
|
||||||
m_pImages->updatefixratio(hratio, vratio);
|
m_pImages->updatefixratio(hratio, vratio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -430,10 +475,8 @@ void GScanO200::usbmain()
|
||||||
{
|
{
|
||||||
std::shared_ptr<std::vector<char>> imgData;
|
std::shared_ptr<std::vector<char>> imgData;
|
||||||
devState = DEV_ISRUNNING;
|
devState = DEV_ISRUNNING;
|
||||||
|
bool haveError = false;
|
||||||
while (devState == DEV_ISRUNNING) {
|
while (devState == DEV_ISRUNNING) {
|
||||||
//int mmused = GetMemoryUsage::CurrentProcessMemoryInfo();//当前进程内存使用量
|
|
||||||
|
|
||||||
//bool need_loop = (m_pImages->getdpi() > 240.0) && mmused >500;//进程内存占用率大于600MB
|
|
||||||
if ((m_usb.get() && !m_usb->is_connected())) {
|
if ((m_usb.get() && !m_usb->is_connected())) {
|
||||||
this_thread::sleep_for(chrono::milliseconds(200));
|
this_thread::sleep_for(chrono::milliseconds(200));
|
||||||
continue;
|
continue;
|
||||||
|
@ -468,7 +511,9 @@ void GScanO200::usbmain()
|
||||||
}
|
}
|
||||||
case STOP_SCAN:
|
case STOP_SCAN:
|
||||||
m_pImages->setscanflags(false);
|
m_pImages->setscanflags(false);
|
||||||
devState = DEV_STOP;
|
devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP;
|
||||||
|
//m_pImages->setscanflags(false);
|
||||||
|
//devState = DEV_STOP;
|
||||||
break;
|
break;
|
||||||
case COUNT_MODE:
|
case COUNT_MODE:
|
||||||
case NO_FEED:
|
case NO_FEED:
|
||||||
|
@ -480,9 +525,18 @@ void GScanO200::usbmain()
|
||||||
case PAPER_SKEW:
|
case PAPER_SKEW:
|
||||||
case HARDWARE_ERROR:
|
case HARDWARE_ERROR:
|
||||||
case PC_SCAN_BUSY_or_ERROR:
|
case PC_SCAN_BUSY_or_ERROR:
|
||||||
|
#ifdef G200
|
||||||
Set_ErrorCode(usbcb.u32_Data);
|
Set_ErrorCode(usbcb.u32_Data);
|
||||||
m_pImages->setscanflags(false);
|
m_pImages->setscanflags(false);
|
||||||
devState = DEV_WRONG;
|
devState = DEV_WRONG;
|
||||||
|
#else
|
||||||
|
if (!haveError)
|
||||||
|
{
|
||||||
|
haveError = true;
|
||||||
|
Set_ErrorCode(usbcb.u32_Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -9,7 +9,7 @@ typedef struct tag_USBCB {
|
||||||
}USBCB, * PUSBCB;
|
}USBCB, * PUSBCB;
|
||||||
|
|
||||||
|
|
||||||
class GScanO200 : public IGScan, GScan
|
class GScanO200 : public IScanner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GScanO200();
|
GScanO200();
|
||||||
|
|
|
@ -34,7 +34,7 @@ int GScanVirtual::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (Get_IsImageQueueEmpty() && is_scan()) {
|
if (Get_IsImageQueueEmpty() && is_scan()) {
|
||||||
DoEvents();
|
//DoEvents();
|
||||||
this_thread::sleep_for(chrono::milliseconds(1));
|
this_thread::sleep_for(chrono::milliseconds(1));
|
||||||
if (sw.elapsed_s() > 15.00)
|
if (sw.elapsed_s() > 15.00)
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,7 @@ int GScanVirtual::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
||||||
m_threadUsb.reset();
|
m_threadUsb.reset();
|
||||||
}
|
}
|
||||||
Stop_scan();//ֹͣɨÃè
|
Stop_scan();//ֹͣɨÃè
|
||||||
ResetScanner();
|
//ResetScanner();
|
||||||
return HARDWARE_ERROR;
|
return HARDWARE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +120,10 @@ void GScanVirtual::Stop_scan()
|
||||||
fs.close();
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GScanVirtual::clear_hwerror()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void GScanVirtual::ResetScanner()
|
void GScanVirtual::ResetScanner()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
class GScanVirtual : public IGScan, GScan
|
class GScanVirtual : public IScanner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GScanVirtual();
|
GScanVirtual();
|
||||||
|
@ -19,6 +19,7 @@ public:
|
||||||
virtual void config_params(GScanCap& params) override;
|
virtual void config_params(GScanCap& params) override;
|
||||||
virtual void Scanner_StartScan(UINT16 count) override;
|
virtual void Scanner_StartScan(UINT16 count) override;
|
||||||
virtual void Stop_scan() override;
|
virtual void Stop_scan() override;
|
||||||
|
virtual void clear_hwerror() override;
|
||||||
virtual void ResetScanner() override;
|
virtual void ResetScanner() override;
|
||||||
virtual bool Get_IsImageQueueEmpty() override;
|
virtual bool Get_IsImageQueueEmpty() override;
|
||||||
virtual void reset() override;
|
virtual void reset() override;
|
||||||
|
|
Loading…
Reference in New Issue