From 475ded4b3ecfcdaede11516eaf1f06166c0e3189 Mon Sep 17 00:00:00 2001 From: masayume <1936714878@qq.com> Date: Wed, 19 May 2021 18:58:07 +0800 Subject: [PATCH] =?UTF-8?q?2021.5.18=09=E6=B7=BB=E5=8A=A0=E4=B8=89?= =?UTF-8?q?=E8=81=94=E5=9B=BA=E5=AE=9A=E5=B9=85=E9=9D=A2=202021.5.19=09?= =?UTF-8?q?=E5=B1=8F=E8=94=BD8=E5=BC=8016=E5=BC=80=E5=B0=BA=E5=AF=B8?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=20=09=E5=9C=A8=E6=8E=A5=E6=94=B6=E5=88=B0sto?= =?UTF-8?q?pscan=E4=B9=8B=E5=90=8E=E5=A2=9E=E5=8A=A0=E5=BB=B6=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E9=98=B2=E6=AD=A2=E8=AF=BB=E5=8F=96=E6=BB=9A=E8=BD=B4?= =?UTF-8?q?=E6=95=B0=E5=B9=B2=E6=89=B0dsp=E8=AF=BB=E5=86=99flash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- huagao/CBasicPage.cpp | 6 +++-- huagao/CTwainUI.h | 6 +++-- huagao/Device/GScanO200.cpp | 29 ++++++++++++++------- huagao/Device/GScanO400.cpp | 25 +++++++++++------- huagao/Device/IConfig.h | 7 +++-- huagao/Device/PaperSize.cpp | 1 + huagao/Device/PaperSize.h | 1 + huagao/ImageProcess/ImageApplyAutoCrop.cpp | 1 - huagao/huagaods.cpp | 22 +++++++++------- huagao/stdafx.h | Bin 12044 -> 12040 bytes 10 files changed, 63 insertions(+), 35 deletions(-) diff --git a/huagao/CBasicPage.cpp b/huagao/CBasicPage.cpp index d7601ae0..07017c4d 100644 --- a/huagao/CBasicPage.cpp +++ b/huagao/CBasicPage.cpp @@ -43,6 +43,7 @@ static std::vector surportStyles = { _T("匹配原始尺寸"), _T("最大扫描尺寸自动裁切"), _T("最大扫描尺寸"), + _T("三联试卷"), }; #endif @@ -85,6 +86,7 @@ static std::vector 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); } diff --git a/huagao/CTwainUI.h b/huagao/CTwainUI.h index 8f71ab26..f1ef380c 100644 --- a/huagao/CTwainUI.h +++ b/huagao/CTwainUI.h @@ -45,7 +45,8 @@ static std::map 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 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 diff --git a/huagao/Device/GScanO200.cpp b/huagao/Device/GScanO200.cpp index 6be915f9..1de02f7b 100644 --- a/huagao/Device/GScanO200.cpp +++ b/huagao/Device/GScanO200.cpp @@ -218,7 +218,7 @@ int GScanO200::aquire_bmpdata(std::vector& 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 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 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 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: diff --git a/huagao/Device/GScanO400.cpp b/huagao/Device/GScanO400.cpp index 5c1c9a81..d2c7c7ba 100644 --- a/huagao/Device/GScanO400.cpp +++ b/huagao/Device/GScanO400.cpp @@ -220,7 +220,7 @@ int GScanO400::aquire_bmpdata(std::vector& 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 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 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 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); } diff --git a/huagao/Device/IConfig.h b/huagao/Device/IConfig.h index b56e333b..35b747ce 100644 --- a/huagao/Device/IConfig.h +++ b/huagao/Device/IConfig.h @@ -27,7 +27,8 @@ static std::map 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 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 SupPaperTyps = { {{TwSS::None,PaperAlign::Rot0},G400_A3}, #endif {{TwSS::MaxSize,PaperAlign::Rot0},G400_LONGLETTER}, + {{TwSS::Trigeminy,PaperAlign::Rot0},G400_LONGLETTER}, #endif }; diff --git a/huagao/Device/PaperSize.cpp b/huagao/Device/PaperSize.cpp index 2d0feb17..9f80e75f 100644 --- a/huagao/Device/PaperSize.cpp +++ b/huagao/Device/PaperSize.cpp @@ -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) diff --git a/huagao/Device/PaperSize.h b/huagao/Device/PaperSize.h index 5d39dd0c..6c127e31 100644 --- a/huagao/Device/PaperSize.h +++ b/huagao/Device/PaperSize.h @@ -65,6 +65,7 @@ enum TwSS : unsigned short MaxSize = 54, K8 = 0x81, K16 = 0x82, + Trigeminy = 0x83, }; namespace Device { diff --git a/huagao/ImageProcess/ImageApplyAutoCrop.cpp b/huagao/ImageProcess/ImageApplyAutoCrop.cpp index 97c068fd..b929ab0e 100644 --- a/huagao/ImageProcess/ImageApplyAutoCrop.cpp +++ b/huagao/ImageProcess/ImageApplyAutoCrop.cpp @@ -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); diff --git a/huagao/huagaods.cpp b/huagao/huagaods.cpp index c263c006..6d2b07c8 100644 --- a/huagao/huagaods.cpp +++ b/huagao/huagaods.cpp @@ -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 resList = { 100.0,150.0,200.0,240.0,300.0,600.0 }; static list 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 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 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 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 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 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(); - m_scanparam->hardwarecaps.en_doublefeed = mech; + m_scanparam->hardwarecaps.en_doublefeed = mech ? 1 : 0; return success(); } return CapSupGetAllResetEx(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(); diff --git a/huagao/stdafx.h b/huagao/stdafx.h index 29b93edd16288e3767facff6f818d18eadf76718..4d5a64b6bace6268f4e8171984e3bf1d2a93466d 100644 GIT binary patch delta 26 hcmeB)>xkP>!@+1Y*2h{)o delta 21 ccmeB(>xtV?!@+1gxt61NvWlw6CQc4D093CAod5s;