mirror of http://192.168.1.51:8099/lmh188/twain3.0
2021.5.18 添加三联固定幅面
2021.5.19 屏蔽8开16开尺寸检测 在接收到stopscan之后增加延时,防止读取滚轴数干扰dsp读写flash
This commit is contained in:
parent
3a62d3d51b
commit
475ded4b3e
|
@ -43,6 +43,7 @@ static std::vector<CString> surportStyles = {
|
|||
_T("匹配原始尺寸"),
|
||||
_T("最大扫描尺寸自动裁切"),
|
||||
_T("最大扫描尺寸"),
|
||||
_T("三联试卷"),
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -85,6 +86,7 @@ static std::vector<CString> surportStyles = {
|
|||
_T("匹配原始尺寸"),
|
||||
_T("最大扫描尺寸自动裁切"),
|
||||
_T("最大扫描尺寸"),
|
||||
_T("三联试卷"),
|
||||
};
|
||||
#endif // G400
|
||||
|
||||
|
@ -278,7 +280,7 @@ void CBasicPage::updateCmbDuplex(BOOL insert)
|
|||
}
|
||||
}
|
||||
#ifndef G300
|
||||
if (tmp_paperindex == 19 || tmp_paperindex == 20 || tmp_paperindex == 21){
|
||||
if (tmp_paperindex == 19 || tmp_paperindex == 20 || tmp_paperindex == 21 || tmp_paperindex == 22 || tmp_paperindex == 1|| tmp_paperindex == 4|| tmp_paperindex == 5){
|
||||
(((CButton*)GetDlgItem(IDC_CKBSIZEDETECT)))->SetCheck(false);
|
||||
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(false);
|
||||
}
|
||||
|
@ -286,7 +288,7 @@ void CBasicPage::updateCmbDuplex(BOOL insert)
|
|||
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(true);
|
||||
}
|
||||
#else
|
||||
if (tmp_paperindex == 8) {
|
||||
if (tmp_paperindex == 8|| tmp_paperindex == 1) {
|
||||
(((CButton*)GetDlgItem(IDC_CKBSIZEDETECT)))->SetCheck(false);
|
||||
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(false);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,8 @@ static std::map<int, PaperStatus> paperStatusMap = {
|
|||
{18,{TwSS::USLegal,PaperAlign::Rot0}},
|
||||
{19,{TwSS::None,PaperAlign::Rot0}},
|
||||
{20,{TwSS::USStatement,PaperAlign::Rot0}},
|
||||
{21,{TwSS::MaxSize,PaperAlign::Rot0}}
|
||||
{21,{TwSS::MaxSize,PaperAlign::Rot0}},
|
||||
{22,{TwSS::Trigeminy,PaperAlign::Rot0}}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -86,7 +87,8 @@ static std::map<int, PaperStatus> paperStatusMap = {
|
|||
{18,{TwSS::USLegal,PaperAlign::Rot0}},
|
||||
{19,{TwSS::None,PaperAlign::Rot0}},
|
||||
{20,{TwSS::USStatement,PaperAlign::Rot0}},
|
||||
{21,{TwSS::MaxSize,PaperAlign::Rot0}}
|
||||
{21,{TwSS::MaxSize,PaperAlign::Rot0}},
|
||||
{22,{TwSS::Trigeminy,PaperAlign::Rot0}}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ int GScanO200::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
|||
if (m_pImages->empty()) {
|
||||
DoEvents();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
if (sw.elapsed_s() > 20.00)
|
||||
if (sw.elapsed_s() > 30.00)
|
||||
{
|
||||
if (m_threadUsb && m_threadUsb->joinable()) {
|
||||
devState = DEV_STOP;
|
||||
|
@ -328,9 +328,10 @@ int GScanO200::Get_Roller_num()
|
|||
{
|
||||
if (!(m_usb.get() && m_usb->is_open()))
|
||||
return false;
|
||||
USBCB usbcb = { GET_ROLLER_NUM ,0,0 };
|
||||
USBCB usbcb = { GET_ROLLER_NUM ,0,4 };
|
||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
m_usb->read_bulk(&usbcb, sizeof(usbcb));
|
||||
return usbcb.u32_Data;
|
||||
}
|
||||
|
@ -364,7 +365,7 @@ void GScanO200::config_params(GScanCap& params)
|
|||
|
||||
void GScanO200::Scanner_StartScan(UINT16 count)
|
||||
{
|
||||
roller_num = Get_Roller_num();
|
||||
|
||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||
if (m_threadUsb && m_threadUsb->joinable()) {
|
||||
devState = DEV_STOP;
|
||||
|
@ -441,7 +442,7 @@ void GScanO200::ResetScanner()
|
|||
{
|
||||
if (!(m_usb.get() && m_usb->is_connected()))
|
||||
return;
|
||||
|
||||
roller_num = Get_Roller_num();
|
||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||
USBCB usbcb = { INIT_HARDWARE_SYS ,0,0 };
|
||||
if (m_usb.get() && m_usb->is_connected())
|
||||
|
@ -584,7 +585,9 @@ void GScanO200::usbmain()
|
|||
if (sw.elapsed_ms() > 30000)
|
||||
{
|
||||
m_pImages->setscanflags(false);
|
||||
devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP;
|
||||
//devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP;
|
||||
devState = DevState::DEV_WRONG;
|
||||
Set_ErrorCode(AQUIRE_IMAGE_TIMEOUT);
|
||||
FileTools::writelog(log_ERROR, "USBmain aquire image timeout");
|
||||
return;
|
||||
}
|
||||
|
@ -626,17 +629,21 @@ void GScanO200::usbmain()
|
|||
break;
|
||||
}
|
||||
case STOP_SCAN:
|
||||
{
|
||||
m_pImages->setscanflags(false);
|
||||
if (get_aquire_image_count() != (Get_Roller_num() - roller_num))
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1500));
|
||||
auto rollernew= Get_Roller_num();
|
||||
if (get_aquire_image_count() != (rollernew - roller_num))
|
||||
{
|
||||
Set_ErrorCode(LOSE_IMAGE);
|
||||
set_lose_image_num(std::abs((Get_Roller_num() - roller_num) - get_aquire_image_count()));
|
||||
set_lose_image_num(std::abs((rollernew - roller_num) - get_aquire_image_count()));
|
||||
haveError = true;
|
||||
}
|
||||
devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP;
|
||||
//m_pImages->setscanflags(false);
|
||||
//devState = DEV_STOP;
|
||||
break;
|
||||
}
|
||||
case COUNT_MODE:
|
||||
case NO_FEED:
|
||||
case OPEN_COVER:
|
||||
|
@ -647,15 +654,17 @@ void GScanO200::usbmain()
|
|||
case PAPER_SKEW:
|
||||
case HARDWARE_ERROR:
|
||||
case PC_SCAN_BUSY_or_ERROR:
|
||||
case SIZE_ERROR:
|
||||
case SIZE_ERROR: {
|
||||
Set_ErrorCode(usbcb.u32_Data);
|
||||
m_pImages->setscanflags(false);
|
||||
devState = DEV_WRONG;
|
||||
if (get_aquire_image_count() != (Get_Roller_num() - roller_num))
|
||||
set_lose_image_num(std::abs((Get_Roller_num() - roller_num) - get_aquire_image_count()));
|
||||
auto rollernew = Get_Roller_num();
|
||||
if (get_aquire_image_count() != (rollernew - roller_num))
|
||||
set_lose_image_num(std::abs((rollernew - roller_num) - get_aquire_image_count()));
|
||||
if (huagods)
|
||||
dev_callback(usbcb.u32_Data, huagods);
|
||||
break;
|
||||
}
|
||||
case NORMAL:
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -220,7 +220,7 @@ int GScanO400::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
|||
if (m_pImages->empty()) {
|
||||
DoEvents();
|
||||
this_thread::sleep_for(chrono::milliseconds(1));
|
||||
if (sw.elapsed_s() > 20.00)
|
||||
if (sw.elapsed_s() > 30.00)
|
||||
{
|
||||
if (m_threadUsb && m_threadUsb->joinable()) {
|
||||
devState = DEV_STOP;
|
||||
|
@ -335,7 +335,7 @@ int GScanO400::Get_Roller_num()
|
|||
{
|
||||
if (!(m_usb.get() && m_usb->is_open()))
|
||||
return false;
|
||||
USBCB usbcb = { GET_ROLLER_NUM ,0,0 };
|
||||
USBCB usbcb = { GET_ROLLER_NUM ,0,4 };
|
||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||
m_usb->read_bulk(&usbcb, sizeof(usbcb));
|
||||
|
@ -344,6 +344,7 @@ int GScanO400::Get_Roller_num()
|
|||
|
||||
void GScanO400::config_params(GScanCap& params)
|
||||
{
|
||||
|
||||
if (m_usb.get() && m_usb->is_connected()) {
|
||||
G400ScanConfig cfg = G400ScanConfig(params);
|
||||
gcap = params;
|
||||
|
@ -368,7 +369,7 @@ void GScanO400::config_params(GScanCap& params)
|
|||
|
||||
void GScanO400::Scanner_StartScan(UINT16 count)
|
||||
{
|
||||
roller_num= Get_Roller_num();
|
||||
|
||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||
if (m_threadUsb && m_threadUsb->joinable()) {
|
||||
devState = DEV_STOP;
|
||||
|
@ -445,7 +446,7 @@ void GScanO400::ResetScanner()
|
|||
{
|
||||
if (!(m_usb.get() && m_usb->is_connected()))
|
||||
return;
|
||||
|
||||
roller_num = Get_Roller_num();
|
||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||
USBCB usbcb = { INIT_HARDWARE_SYS ,0,0 };
|
||||
if (m_usb.get() && m_usb->is_connected())
|
||||
|
@ -583,7 +584,8 @@ void GScanO400::usbmain()
|
|||
{
|
||||
m_pImages->setscanflags(false);
|
||||
Set_ErrorCode(AQUIRE_IMAGE_TIMEOUT);
|
||||
devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP;
|
||||
devState = DevState::DEV_WRONG;
|
||||
//devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP;
|
||||
FileTools::writelog(log_ERROR, "USBmain aquire image timeout");
|
||||
return;
|
||||
}
|
||||
|
@ -624,11 +626,14 @@ void GScanO400::usbmain()
|
|||
break;
|
||||
}
|
||||
case STOP_SCAN:
|
||||
{
|
||||
m_pImages->setscanflags(false);
|
||||
if (get_aquire_image_count() != (Get_Roller_num() - roller_num))
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
auto rollernew = Get_Roller_num();
|
||||
if (get_aquire_image_count() != (rollernew - roller_num))
|
||||
{
|
||||
Set_ErrorCode(LOSE_IMAGE);
|
||||
set_lose_image_num(std::abs((Get_Roller_num() - roller_num) - get_aquire_image_count()));
|
||||
set_lose_image_num(std::abs((rollernew - roller_num) - get_aquire_image_count()));
|
||||
haveError = true;
|
||||
}
|
||||
devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP;
|
||||
|
@ -636,6 +641,7 @@ void GScanO400::usbmain()
|
|||
//m_pImages->setscanflags(false);
|
||||
//devState = DEV_STOP;
|
||||
break;
|
||||
}
|
||||
case COUNT_MODE:
|
||||
case NO_FEED:
|
||||
case OPEN_COVER:
|
||||
|
@ -653,8 +659,9 @@ void GScanO400::usbmain()
|
|||
devState = DEV_WRONG;
|
||||
m_pImages->setscanflags(false);
|
||||
Set_ErrorCode(usbcb.u32_Data);
|
||||
if (get_aquire_image_count() != (Get_Roller_num() - roller_num))
|
||||
set_lose_image_num(std::abs((Get_Roller_num() - roller_num) - get_aquire_image_count()));
|
||||
auto rollernew = Get_Roller_num();
|
||||
if (get_aquire_image_count() != (rollernew - roller_num))
|
||||
set_lose_image_num(std::abs((rollernew - roller_num) - get_aquire_image_count()));
|
||||
if (huagods)
|
||||
dev_callback(usbcb.u32_Data, huagods);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ static std::map<PaperStatus, unsigned int> SupPaperTyps = {
|
|||
{{TwSS::USLegal,PaperAlign::Rot0},13},
|
||||
{{TwSS::None,PaperAlign::Rot0},0},
|
||||
{{TwSS::USStatement,PaperAlign::Rot0},16},
|
||||
{{TwSS::MaxSize,PaperAlign::Rot0},16}
|
||||
{{TwSS::MaxSize,PaperAlign::Rot0},16},
|
||||
{{TwSS::Trigeminy,PaperAlign::Rot0},16}
|
||||
#else
|
||||
{{TwSS::A3,PaperAlign::Rot0},0},
|
||||
{{TwSS::A4,PaperAlign::Rot0},1},
|
||||
|
@ -47,7 +48,8 @@ static std::map<PaperStatus, unsigned int> SupPaperTyps = {
|
|||
{{TwSS::USLegal,PaperAlign::Rot0},0},
|
||||
{{TwSS::None,PaperAlign::Rot0},0},
|
||||
{{TwSS::USStatement,PaperAlign::Rot0},16},
|
||||
{{TwSS::MaxSize,PaperAlign::Rot0},16}
|
||||
{{TwSS::MaxSize,PaperAlign::Rot0},16},
|
||||
{{TwSS::Trigeminy,PaperAlign::Rot0},16}
|
||||
#endif
|
||||
#else
|
||||
{{TwSS::A3,PaperAlign::Rot0},G400_A3},
|
||||
|
@ -72,6 +74,7 @@ static std::map<PaperStatus, unsigned int> SupPaperTyps = {
|
|||
{{TwSS::None,PaperAlign::Rot0},G400_A3},
|
||||
#endif
|
||||
{{TwSS::MaxSize,PaperAlign::Rot0},G400_LONGLETTER},
|
||||
{{TwSS::Trigeminy,PaperAlign::Rot0},G400_LONGLETTER},
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace Device {
|
|||
papersize.insert({ None,CSize(297,420) });
|
||||
papersize.insert({ K8,CSize(270,390) });
|
||||
papersize.insert({ K16,CSize(190,270) });
|
||||
papersize.insert({ Trigeminy,CSize(270,560) });
|
||||
}
|
||||
|
||||
CSize PaperSize::GetPaperSize(DWORD paperType, float dpi,int orentation)
|
||||
|
|
|
@ -65,6 +65,7 @@ enum TwSS : unsigned short
|
|||
MaxSize = 54,
|
||||
K8 = 0x81,
|
||||
K16 = 0x82,
|
||||
Trigeminy = 0x83,
|
||||
};
|
||||
|
||||
namespace Device {
|
||||
|
|
|
@ -61,7 +61,6 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side)
|
|||
return;
|
||||
}
|
||||
thre.release();
|
||||
dst.release();
|
||||
|
||||
cv::RotatedRect rect = hg::getBoundingRect(m_maxContour);
|
||||
cv::Rect boudingRect = cv::boundingRect(m_maxContour);
|
||||
|
|
|
@ -65,6 +65,7 @@ enum class CapTypeEx : unsigned short {
|
|||
enum class PaperSizeEx : unsigned short {
|
||||
K8 = 0x81,
|
||||
K16 = 0x82,
|
||||
Trigeminy = 0x83,
|
||||
};
|
||||
|
||||
|
||||
|
@ -189,16 +190,18 @@ static list<float> resList = { 100.0,150.0,200.0,240.0,300.0,600.0 };
|
|||
static list<UInt16> paperSizeList = { (UInt16)PaperSize::A3,(UInt16)PaperSize::A4,(UInt16)PaperSize::A5,(UInt16)PaperSize::A6,
|
||||
(UInt16)PaperSize::IsoB4,(UInt16)PaperSize::IsoB5,(UInt16)PaperSize::IsoB6,
|
||||
(UInt16)PaperSize::UsLetter,(UInt16)PaperSize::UsLegal,(UInt16)PaperSize::UsLedger,
|
||||
(UInt16)PaperSize::MaxSize,(UInt16)PaperSize::None,(UInt16)PaperSize::UsStatement };
|
||||
(UInt16)PaperSize::MaxSize,(UInt16)PaperSize::None,(UInt16)PaperSize::UsStatement,
|
||||
(UInt16)PaperSizeEx::K8,(UInt16)PaperSizeEx::K16,(UInt16)PaperSizeEx::Trigeminy };
|
||||
|
||||
#elif defined G300
|
||||
static list<UInt16> paperSizeList = { (UInt16)PaperSize::A4,(UInt16)PaperSize::A5,(UInt16)PaperSize::A6, (UInt16)PaperSize::IsoB5,(UInt16)PaperSize::IsoB6,
|
||||
(UInt16)PaperSize::UsLetter,(UInt16)PaperSize::UsLegal,(UInt16)PaperSize::None };
|
||||
(UInt16)PaperSize::UsLetter,(UInt16)PaperSize::UsLegal,(UInt16)PaperSize::None,(UInt16)PaperSizeEx::K16 };
|
||||
#elif defined G400
|
||||
static list<UInt16> paperSizeList = { (UInt16)PaperSize::A3,(UInt16)PaperSize::A4,(UInt16)PaperSize::A5,(UInt16)PaperSize::A6,
|
||||
(UInt16)PaperSize::IsoB4,(UInt16)PaperSize::IsoB5,(UInt16)PaperSize::IsoB6,
|
||||
(UInt16)PaperSize::UsLetter,(UInt16)PaperSize::UsLegal,(UInt16)PaperSize::UsLedger,
|
||||
(UInt16)PaperSize::MaxSize,(UInt16)PaperSize::None,(UInt16)PaperSize::UsStatement };
|
||||
(UInt16)PaperSize::MaxSize,(UInt16)PaperSize::None,(UInt16)PaperSize::UsStatement ,
|
||||
(UInt16)PaperSizeEx::K8,(UInt16)PaperSizeEx::K16,(UInt16)PaperSizeEx::Trigeminy };
|
||||
#endif // G200
|
||||
static list<float> imageRotateList = { 0.0,90.0,180.0,270.0 };
|
||||
|
||||
|
@ -420,8 +423,8 @@ Result HuagaoDs::customDataSet(const Twpp::Identity& origin, Twpp::CustomData& d
|
|||
memcpy((void*)str.c_str(), pdata, data.size());
|
||||
//vector<GScanCap> vc = js.parseJsonFromString(str);
|
||||
//m_scanparam.reset(new GScanCap(vc[0]));
|
||||
GScanCap *cap = new GScanCap(js.JsonToGscancap(json::parse(str)));
|
||||
m_scanparam.reset(cap);
|
||||
//std::unique_ptr<GScanCap> cap(new GScanCap(js.JsonToGscancap(json::parse(str))));
|
||||
m_scanparam.reset(new GScanCap(js.JsonToGscancap(json::parse(str))));
|
||||
return success();
|
||||
|
||||
}
|
||||
|
@ -739,6 +742,7 @@ void HuagaoDs::SetResoluton(const char* path, int resolution)
|
|||
//将数据写入文件,覆盖原始数据,让修改生效
|
||||
fwrite(buf, sizeof(char), len, file);
|
||||
fclose(file);
|
||||
delete[]buf;
|
||||
}
|
||||
|
||||
void HuagaoDs::dogear_callback(int indexpaper)
|
||||
|
@ -1078,10 +1082,10 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
#ifndef G300
|
||||
#if defined G200
|
||||
,PaperSize::A3,PaperSize::UsLedger,PaperSize::IsoB4,
|
||||
PaperSize::MaxSize,PaperSize::UsStatement,(PaperSize)PaperSizeEx::K8,(PaperSize)PaperSizeEx::K16
|
||||
PaperSize::MaxSize,PaperSize::UsStatement,(PaperSize)PaperSizeEx::K8,(PaperSize)PaperSizeEx::K16,(PaperSize)PaperSizeEx::Trigeminy
|
||||
#elif defined G400
|
||||
,PaperSize::A3,PaperSize::UsLedger,PaperSize::IsoB4,PaperSize::MaxSize,PaperSize::UsStatement,
|
||||
(PaperSize)PaperSizeEx::K8,(PaperSize)PaperSizeEx::K16
|
||||
(PaperSize)PaperSizeEx::K8,(PaperSize)PaperSizeEx::K16,(PaperSize)PaperSizeEx::Trigeminy
|
||||
#endif
|
||||
#endif //
|
||||
},m_scanparam->papertype, PaperSize::None,
|
||||
|
@ -1790,7 +1794,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
m_caps[CapType::DoubleFeedDetection] = [this](Msg msg, Capability& data)->Result {
|
||||
if (Msg::Set == msg) {
|
||||
auto mech = data.currentItem<Bool>();
|
||||
m_scanparam->hardwarecaps.en_doublefeed = mech;
|
||||
m_scanparam->hardwarecaps.en_doublefeed = mech ? 1 : 0;
|
||||
return success();
|
||||
}
|
||||
return CapSupGetAllResetEx<BYTE, Bool, CapType::DoubleFeedDetection>(msg, data, m_scanparam->hardwarecaps.en_doublefeed, TRUE);
|
||||
|
@ -2404,7 +2408,7 @@ Twpp::Result HuagaoDs::startScan()
|
|||
//info += "\n\t m_scanparam->indent :" + to_string(m_scanparam->indent);
|
||||
//info += "\n\t m_scanparam->AutoCrop_threshold :" + to_string(m_scanparam->AutoCrop_threshold);
|
||||
//info += "\n\t m_scanparam->is_convex :" + to_string(m_scanparam->is_convex);
|
||||
//FileTools::write_log(info);
|
||||
//FileTools::write_log("D:\\1.txt",info);
|
||||
FileTools::writelog(log_INFO,"start scan");
|
||||
#ifndef G200
|
||||
scanner->clear_hwerror();
|
||||
|
|
BIN
huagao/stdafx.h
BIN
huagao/stdafx.h
Binary file not shown.
Loading…
Reference in New Issue