From 626eb1b690646dec1cd6c5de4f901d3d0882cc23 Mon Sep 17 00:00:00 2001 From: 13038267101 Date: Fri, 30 Dec 2022 00:07:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8=E6=A0=A1?= =?UTF-8?q?=E6=AD=A3=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/HGProductionTool/hgscanner.cpp | 4 ++++ app/HGProductionTool/mainwindow.cpp | 2 +- app/HGProductionTool/ui_helper.h | 1 + code/base/test_base.cpp | 31 ++++++++++++++++++++++++++--- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/app/HGProductionTool/hgscanner.cpp b/app/HGProductionTool/hgscanner.cpp index 25b324f..8d330e0 100644 --- a/app/HGProductionTool/hgscanner.cpp +++ b/app/HGProductionTool/hgscanner.cpp @@ -71,6 +71,10 @@ void hgscanner::test_callback(const wchar_t* name, test_event ev, void* data, si QString title = QString::fromStdWString(name); emit m_interface->testDistortion(title, data); } + else if (ev == TEST_EVENT_FALT_INFO) + { + std::string str = (char *)data; + } else if (ev == TEST_EVENT_HAVE_IMAGE) { SANE_Image *sane_img = (SANE_Image *)data; diff --git a/app/HGProductionTool/mainwindow.cpp b/app/HGProductionTool/mainwindow.cpp index 307b7ff..e2d33a9 100644 --- a/app/HGProductionTool/mainwindow.cpp +++ b/app/HGProductionTool/mainwindow.cpp @@ -283,7 +283,7 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigne emit p->sane_dev_remove(sane_dev->name); } - if (code == SANE_EVENT_IMAGE_OK || code == SANE_EVENT_SCAN_FINISHED || code == SANE_EVENT_ERROR) + if (code == SANE_EVENT_IMAGE_OK || code == SANE_EVENT_SCAN_FINISHED || code == SANE_EVENT_ERROR || code == SANE_EVENT_STATUS) { HGBase_EnterLock(p->m_lock); Form_mainInterface* interface = p->FindInterface(hdev); diff --git a/app/HGProductionTool/ui_helper.h b/app/HGProductionTool/ui_helper.h index d2862e0..321a44c 100644 --- a/app/HGProductionTool/ui_helper.h +++ b/app/HGProductionTool/ui_helper.h @@ -93,6 +93,7 @@ public: TEST_EVENT_RESULT, // test result, data is (wchar_t*)description, flag is (bool)result, true - test pass TEST_EVENT_HAVE_IMAGE, // have image. TEST_EVENT_DISTORTION, // user set a single page,flag is int + TEST_EVENT_FALT_INFO, // }; virtual void test_callback(const wchar_t* name/*test name*/, test_event ev, void* data, size_t flag)=0 ; diff --git a/code/base/test_base.cpp b/code/base/test_base.cpp index 73565f1..c300db3 100644 --- a/code/base/test_base.cpp +++ b/code/base/test_base.cpp @@ -7,7 +7,21 @@ #include "huagao/hgscanner_error.h" - +static std::string StringToUtf(std::string strValue) +{ + int nwLen = MultiByteToWideChar(CP_UTF8, 0, strValue.c_str(), -1, NULL, 0); + wchar_t* pwBuf = new wchar_t[nwLen + 1];//加上末尾'\0' + memset(pwBuf, 0, nwLen * 2 + 2); + MultiByteToWideChar(CP_UTF8, 0, strValue.c_str(), strValue.length(), pwBuf, nwLen); + int nLen = WideCharToMultiByte(CP_ACP, 0, pwBuf, -1, NULL, NULL, NULL, NULL); + char* pBuf = new char[nLen + 1]; + memset(pBuf, 0, nLen + 1); + WideCharToMultiByte(CP_ACP, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL); + std::string retStr = pBuf; + delete[]pBuf; + delete[]pwBuf; + return retStr; +} static int str_to_wchar(std::string str, wchar_t* s, size_t* strlen) { if (str.empty()) @@ -71,6 +85,7 @@ public: std::wstring wstr = L""; size_t l = 0; bool type = true; + int ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l); if (ret == ERROR_INSUFFICIENT_BUFFER) ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l); @@ -81,7 +96,7 @@ public: h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)wstr.c_str(), type); return -1; } - wprintf(L"%s\r\n", wstr.c_str()); + //std::string str = StringToUtf((char*)data); switch (code) { case SANE_EVENT_SCAN_FINISHED: @@ -128,6 +143,7 @@ public: else type = true; } + h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)wstr.c_str(), type); } break; @@ -136,6 +152,15 @@ public: h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)wstr.c_str(), false); } break; + case SANE_EVENT_STATUS: + { + if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_FLAT_FIELD) == 0) + { + //std::string str = StringToUtf((char*)data); + //h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_FALT_INFO, (void*)&str[0], type); + } + } + break; case SANE_EVENT_IMAGE_OK: { if ( wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0 @@ -537,7 +562,7 @@ public: /* 自动平场校正 */ int test_auto_flat_field(void *data) { - return SCANNER_ERR_OK; + return helper_->io_control(IO_CTRL_CODE_SET_AUTO_FALT, NULL, NULL);; } /* 重启设备 */ int test_reboot_device(void *data)