From 391da4144e73dcb3ac52daaff8d9bc076a1118d1 Mon Sep 17 00:00:00 2001 From: lovelyyoung <1002639516@qq.com> Date: Tue, 7 Jul 2020 09:54:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E3=80=81=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- huagao/huagaods.cpp | 130 +++++++++++++++++++++++++++++++++++--------- huagao/huagaods.hpp | 3 +- 2 files changed, 107 insertions(+), 26 deletions(-) diff --git a/huagao/huagaods.cpp b/huagao/huagaods.cpp index bd6399cc..8d0f26fe 100644 --- a/huagao/huagaods.cpp +++ b/huagao/huagaods.cpp @@ -113,18 +113,18 @@ static list paperSizeList = { (UInt16)PaperSize::A3,(UInt16)PaperSize::A static list imageRotateList = { 0.0,90.0,180.0,270.0 }; -static map noticeMsgMap = { {OPEN_COVER,_T("扫描仪开盖")}, - {NO_FEED,_T("无纸!")}, - {FEED_IN_ERROR,_T("搓纸失败!")}, - {PAPER_JAM,_T("卡纸!")}, - {DETECT_DOUBLE_FEED,_T("双张!")}, - {DETECT_STAPLE,_T("订书针!")}, - {PAPER_SKEW,_T("纸张歪斜!")}, - {COUNT_MODE,_T("计数模式,请退出计数模式!")}, - {HARDWARE_ERROR,_T("硬件错误")}, - {FPGA_ERROR,_T("FPGA 异常")}, - {USB_DISCONNECTED,_T("USB连接异常")} -}; +//static map noticeMsgMap = { {OPEN_COVER,_T("扫描仪开盖")}, +// {NO_FEED,_T("无纸!")}, +// {FEED_IN_ERROR,_T("搓纸失败!")}, +// {PAPER_JAM,_T("卡纸!")}, +// {DETECT_DOUBLE_FEED,_T("双张!")}, +// {DETECT_STAPLE,_T("订书针!")}, +// {PAPER_SKEW,_T("纸张歪斜!")}, +// {COUNT_MODE,_T("计数模式,请退出计数模式!")}, +// {HARDWARE_ERROR,_T("硬件错误")}, +// {FPGA_ERROR,_T("FPGA 异常")}, +// {USB_DISCONNECTED,_T("USB连接异常")} +//}; static void DeleteWnd(CDialog* pWnd) { if (pWnd && pWnd->GetSafeHwnd()) { @@ -387,13 +387,17 @@ Result HuagaoDs::identityOpenDs(const Identity&) { m_iBitdepth = m_scanparam->pixtype == 2 ? 24 : (m_scanparam->pixtype == 1 ? 8 : 0); scanner->open(0x064B, 0x7823); if (!scanner->IsConnected()) { - MessageBox(NULL, _T("未找到扫描仪!请检查电源或者USB连接线是否接通!"), _T("提示"), MB_SYSTEMMODAL | MB_OK | MB_ICONINFORMATION); + //MessageBox(NULL, _T("未找到扫描仪!请检查电源或者USB连接线是否接通!"), _T("提示"), MB_SYSTEMMODAL | MB_OK | MB_ICONINFORMATION); + //CString str("201"); + ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString("201"), NULL, SW_HIDE); return checkDeviceOnline(); } hMutex = CreateMutex(NULL, FALSE, _T("LookitApp")); if (GetLastError() == ERROR_ALREADY_EXISTS) { //如果已经存在同名的Mutex会得到这个错误. CloseHandle(hMutex); - MessageBox(NULL, _T("设备已被其他程序占用,请关闭占用程序之后再重试!"), _T("提示"), MB_OK); + //MessageBox(NULL, _T("设备已被其他程序占用,请关闭占用程序之后再重试!"), _T("提示"), MB_OK); + //CString str("202"); + ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), CString("202"), NULL, SW_HIDE); return seqError(); } @@ -567,8 +571,8 @@ Result HuagaoDs::identityOpenDs(const Identity&) { else { m_scanparam->multi_output_red = 0;//非彩色模式下多流输出不可用 - if (m_scanparam->pixtype == (int)PixelType::BlackWhite) - m_scanparam->sharpen = SharpenBlur::Sharpen_None; + //if (m_scanparam->pixtype == (int)PixelType::BlackWhite) + // m_scanparam->sharpen = SharpenBlur::Sharpen_None; } m_iBitdepth = mech == PixelType::Rgb ? 24 : (mech == PixelType::Gray ? 8 : 1); return success(); @@ -743,7 +747,11 @@ Result HuagaoDs::identityOpenDs(const Identity&) { if (contains) { m_scanparam->papertype = (byte)res; if (res == (byte)PaperSize::None) + { m_scanparam->autodescrew = 1;//设置papertype为NONE 则默认自动裁切 + m_scanparam->paperAlign = PaperAlign::Rot0; + } + return success(); } return badValue(); @@ -1094,12 +1102,11 @@ Result HuagaoDs::identityOpenDs(const Identity&) { } }; - m_query[CapType::IAutomaticCropUsesFrame] = msgSupportGetAllSetReset; + m_query[CapType::IAutomaticCropUsesFrame] = msgSupportGetAll; m_caps[CapType::IAutomaticCropUsesFrame] = [this](Msg msg, Capability& data)->Result { switch (msg) { case Msg::Get: - data = Capability::createEnumeration( - { Bool(), Bool(true) }, Bool(m_scanparam->is_autocrop)); + data = Capability::Capability::createOneValue(m_scanparam->is_autocrop); return success(); case Msg::Reset: case Msg::GetCurrent: @@ -1111,11 +1118,38 @@ Result HuagaoDs::identityOpenDs(const Identity&) { data = Capability::createOneValue(false); return success(); + //case Msg::Set: { + // auto autocrop = data.currentItem(); + // m_scanparam->is_autocrop = (bool)autocrop; + // if (autocrop) + // m_scanparam->papertype = (byte)PaperSize::None; + // return success(); + //} + default: + return capBadOperation(); + } + }; + + m_query[CapType::AutoScan] = msgSupportGetAllSetReset; + m_caps[CapType::AutoScan] = [this](Msg msg, Capability& data)->Result { + switch (msg) { + case Msg::Get: + data = Capability::createEnumeration( + { Bool(), Bool(true) }, m_autoscan); + return success(); + case Msg::Reset: + case Msg::GetCurrent: + m_autoscan = true; + data = Capability::createOneValue(m_autoscan); + return success(); + + case Msg::GetDefault: + data = Capability::createOneValue(true); + return success(); + case Msg::Set: { - auto autocrop = data.currentItem(); - m_scanparam->is_autocrop = (bool)autocrop; - if (autocrop) - m_scanparam->papertype = (byte)PaperSize::None; + auto autoscan = data.currentItem(); + m_autoscan = autoscan; return success(); } default: @@ -1141,6 +1175,12 @@ Result HuagaoDs::identityOpenDs(const Identity&) { case Msg::Set: { auto autosize = data.currentItem(); + if (autosize == AutoSize::Auto) + { + m_scanparam->is_autocrop = 1; + m_scanparam->papertype = (byte)Twpp::PaperSize::None; + m_scanparam->paperAlign = PaperAlign::Rot0; + } m_autosize = (byte)autosize; return success(); } @@ -1149,6 +1189,39 @@ Result HuagaoDs::identityOpenDs(const Identity&) { } }; + m_query[CapType::IAutomaticBorderDetection] = msgSupportGetAllSetReset; + m_caps[CapType::IAutomaticBorderDetection] = [this](Msg msg, Capability& data)->Result { + switch (msg) { + case Msg::Get: + data = Capability::createEnumeration( + { Bool(), Bool(true) }, m_autoboarderdetcet); + return success(); + case Msg::Reset: + case Msg::GetCurrent: + m_autoscan = true; + data = Capability::createOneValue(m_autoboarderdetcet); + return success(); + + case Msg::GetDefault: + data = Capability::createOneValue(false); + return success(); + + case Msg::Set: { + auto autodetectborder = data.currentItem(); + if (autodetectborder) + { + m_scanparam->is_autocrop = true; + m_scanparam->papertype = (byte)Twpp::PaperSize::None; + m_scanparam->paperAlign = PaperAlign::Rot0; + } + m_autoboarderdetcet = autodetectborder; + return success(); + } + default: + return capBadOperation(); + } + }; + m_query[CapType::IImageMerge] = msgSupportGetAllSetReset; m_caps[CapType::IImageMerge] = [this](Msg msg, Capability& data)->Result { switch (msg) { @@ -1772,7 +1845,11 @@ Result HuagaoDs::pendingXfersEnd(const Identity&, PendingXfers& data) { scanner->Set_ErrorCode(0); guiIndicator.reset(); if (ret != -1) { - MessageBox(guiTwain ? guiTwain->m_hWnd : NULL, noticeMsgMap[ret], _T("提示"), MB_SYSTEMMODAL | MB_OK | MB_ICONINFORMATION);// + //ShellExecute(NULL, _T("open"), _T("aa.exe"), CString("1"), _T(""), SW_HIDE); + //MessageBox(guiTwain ? guiTwain->m_hWnd : NULL, noticeMsgMap[ret], _T("提示"), MB_SYSTEMMODAL | MB_OK | MB_ICONINFORMATION);// + CString str; + str.Format(_T("%d"), ret); + ShellExecute(NULL, TEXT("open"), GetHidedlgPath(), str, NULL, SW_HIDE); #ifndef G200 scanner->clear_hwerror(); #endif // G200 @@ -2208,7 +2285,10 @@ Twpp::Result HuagaoDs::startScan() scanner->Set_ErrorCode(0); guiIndicator.reset(); if (retCode != -1) { - MessageBox(guiTwain ? guiTwain->m_hWnd : NULL, noticeMsgMap[retCode], _T("提示"), MB_SYSTEMMODAL | MB_OK | MB_ICONINFORMATION); + //MessageBox(guiTwain ? guiTwain->m_hWnd : NULL, noticeMsgMap[retCode], _T("提示"), MB_SYSTEMMODAL | MB_OK | MB_ICONINFORMATION); + CString str; + str.Format(_T("%d"), retCode); + ShellExecute(guiTwain ? guiTwain->m_hWnd : NULL, TEXT("open"), GetHidedlgPath(), str, NULL, SW_HIDE); #ifndef G200 scanner->clear_hwerror(); #endif // diff --git a/huagao/huagaods.hpp b/huagao/huagaods.hpp index 3742d687..457a0ba1 100644 --- a/huagao/huagaods.hpp +++ b/huagao/huagaods.hpp @@ -83,7 +83,8 @@ private: Twpp::UInt32 m_memXferYOff = 0; Twpp::UInt16 m_pendingXfers = 0; Twpp::UInt16 m_autosize = 0; - + Twpp::Bool m_autoscan = true; + Twpp::Bool m_autoboarderdetcet = false; Twpp::Int16 m_capXferCount = -1; Twpp::Fix32 m_brightness = 0.0f; Twpp::XferMech m_capXferMech = Twpp::XferMech::Native;