1.适配卓育云ODM厂商 --23.04.24

2.对接爱云校做协议适配 --23.04.24
This commit is contained in:
masayume_ht 2023-04-24 19:30:39 +08:00
parent 2e08abac89
commit c6c27637bf
19 changed files with 170 additions and 37 deletions

View File

@ -84,4 +84,6 @@
5.UI开放色偏校正增加色偏校正协议 --23.01.05
6.除背景色二值化阈值调整为50100-50 --23.02.21
7.添加3288 linux待纸扫描功能 --23.03.08
8.添加安卓设备锁定协议支持 --23.03.13
8.添加安卓设备锁定协议支持 --23.03.13
9.适配卓育云ODM厂商 --23.04.24
10.对接爱云校做协议适配 --23.04.24

View File

@ -65,12 +65,14 @@ BOOL CAboutDlg::OnInitDialog()
HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP5));
#elif defined CUMTENN
HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP7));
#elif defined ZHUOYUYUN
HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP8));
#else
HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BMPABOUTDLG));
#endif
pStatic->ModifyStyle(0xF, SS_BITMAP | SS_CENTERIMAGE);
pStatic->SetBitmap(hBitmap);
#if defined MAKEHUAGAO || defined LANXUM || defined HANVON || defined AUGE ||defined MAKERIGHTWAY || defined CUMTENN
#if defined MAKEHUAGAO || defined LANXUM || defined HANVON || defined AUGE ||defined MAKERIGHTWAY || defined CUMTENN || defined ZHUOYUYUN
GetDlgItem(IDC_PICABOUTHUAGO)->ShowWindow(TRUE);
#else
GetDlgItem(IDC_PICABOUTHUAGO)->ShowWindow(FALSE);

View File

@ -42,7 +42,7 @@ BOOL CAdvancedDLG::OnInitDialog()
CTabPageSSL::OnInitDialog();
m_Edit_noise.SetSlideLink(this, IDC_SLIDER_NOISE);
m_Edit_noise.SetParams(1, 20, 1);
m_Edit_noise.SetParams(2, 20, 1);
m_Edit_noise.SetValue(noise);
m_Edit_indent.SetSlideLink(this, IDC_SLIDER_INDENT);

View File

@ -116,7 +116,7 @@ BOOL CTwainMutex::CloseTwainMutex()
if (!b_ret)
{
MessageBox(NULL, TEXT("ÊÍ·Å×ÊԴʧ°Ü"), 0, MB_ICONWARNING);
MessageBox(NULL, TEXT("×ÊÔ´ÊÍ·Åʧ°Ü"), 0, MB_ICONWARNING);
}
m_hTwainMutex=NULL;
return b_ret;

View File

@ -135,7 +135,7 @@ BOOL CTwainUI::OnInitDialog()
else
{
if (atoi(m_hardwareVersion.substr(4, 6).c_str()) >= 220401)
if (atoi(m_hardwareVersion.substr(4, 6).c_str()) >= 230130)
{
setvisable_size(true);
}
@ -152,7 +152,7 @@ BOOL CTwainUI::OnInitDialog()
((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_SHOW);
}
#elif defined(G300)
if (atoi(m_hardwareVersion.substr(4, 6).c_str()) >= 221106)
if (atoi(m_hardwareVersion.substr(4, 6).c_str()) >= 230130)
{
((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->ShowWindow(SW_SHOW);
((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_SHOW);

View File

@ -894,6 +894,8 @@ void GScanO1003399::imgproce(std::shared_ptr<std::vector<char>>& buff)
_tcscat(szIniFile, _T("\\twain_32\\CumTennScan\\tessdata\\osd.traineddata"));
#elif defined NOLOGO
_tcscat(szIniFile, _T("\\twain_32\\Scan\\tessdata\\osd.traineddata"));
#elif defiend ZHUOYUYUN
_tcscat(szIniFile, _T("\\twain_32\\ZhuoYuYunScan\\tessdata\\osd.traineddata"));
#else
_tcscat(szIniFile, _T("\\twain_32\\HuaGoScan\\tessdata\\osd.traineddata"));
#endif //

View File

@ -414,7 +414,7 @@ void GScanO400::config_params(GScanCap& params)
else
params.resolution_native = 200.0f;
#elif defined(G300)
if (atoi(fw.substr(4, 6).c_str()) >= 221106)
if (atoi(fw.substr(4, 6).c_str()) >= 230130)
{
int dpi = 1;
if (params.is_high_imagequality)

View File

@ -312,6 +312,8 @@ void ImageMatQueue::setparam(const GScanCap& param)
_tcscat(szIniFile, _T("\\twain_32\\Scan\\tessdata\\osd.traineddata"));
#elif defined CUMTENN
_tcscat(szIniFile, _T("\\twain_32\\CumTennScan\\tessdata\\osd.traineddata"));
#elif defined ZHUOYUYUN
_tcscat(szIniFile, _T("\\twain_32\\ZhuoYuYunScan\\tessdata\\osd.traineddata"));
#else
_tcscat(szIniFile, _T("\\twain_32\\HuaGoScan\\tessdata\\osd.traineddata"));
#endif //

View File

@ -473,6 +473,8 @@ CString GetHidedlgPath()
_tcscat(szIniFile, _T("\\twain_32\\RIGHTWAYSCAN\\hidedlg.exe"));
#elif defined NOLOGO
_tcscat(szIniFile, _T("\\twain_32\\Scan\\hidedlg.exe"));
#elif defiend ZHUOYUYUN
_tcscat(szIniFile, _T("\\twain_32\\ZhuoYuYunScan\\hidedlg.exe"));
#else // MAKEHUAGAO
_tcscat(szIniFile, _T("\\twain_32\\ZhibenScan\\hidedlg.exe"));
#endif

View File

@ -107,6 +107,7 @@ const std::string ANSWERSHEETFILTER = "iAnswersheetFilter";
//twain 弹框配置等参数
const std::string ROLLERMSGDATE = "RollerMsgDate";
const std::string PRINTFCAPABILITY = "PrintfCapability";
const std::string CONFIG_DOUBLEFEEDDETECTION = "Config_DoubleFeedDetection";
#pragma pack(push)
#pragma pack(4)
/******************

View File

@ -7,6 +7,8 @@
#include <timeapi.h>
#include <time.h>
#include <fcntl.h>
#include <codecvt>
#include <locale>
#include <log4cplus/log4cplus.h>
#include "PublicFunc.h"
@ -25,6 +27,17 @@ enum log_lv :int {
class FileTools
{
public:
static std::string GetProcessName()
{
char Path[_MAX_PATH]{ 0 };
char name[_MAX_PATH]{ 0 };
::GetModuleFileNameA(NULL, Path, _MAX_PATH);
::_splitpath(Path, NULL, NULL, name, NULL);
return name;
}
static std::vector<std::string> getFiles(std::string path)
{
std::vector<std::string> files;
@ -235,6 +248,62 @@ public:
return retval;
}
static std::string to_web_utf(const std::wstring& unic)
{
std::string webu("");
char buf[20] = { 0 };
for (size_t i = 0; i < unic.length(); ++i)
{
wchar_t v = unic[i];
//if (v <= 0x7f)
// webu.append(1, (char)v);
//else
{
sprintf_s(buf, _countof(buf) - 1, "%04X", v);
webu += buf;
}
}
return webu;
}
static std::wstring String2Wstring(std::string wstr)
{
std::wstring res;
int len = MultiByteToWideChar(CP_ACP, 0, wstr.c_str(), wstr.size(), nullptr, 0);
if (len < 0) {
return res;
}
wchar_t* buffer = new wchar_t[len + 1];
if (buffer == nullptr) {
return res;
}
MultiByteToWideChar(CP_ACP, 0, wstr.c_str(), wstr.size(), buffer, len);
buffer[len] = '\0';
res.append(buffer);
delete[] buffer;
return res;
}
static std::string utf82str(std::string str)
{
std::string u8;
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> converter;
for (size_t i = 0; i < str.length();)
{
char32_t c = strtol(str.substr(i, 4).c_str(), nullptr, 16);
u8 += converter.to_bytes(c);
i += 4;
}
return u8;
}
//½«stringת»»³Éwstring
private:
static void getFiles(std::string path, std::vector<std::string>& files)
{

View File

@ -1257,6 +1257,24 @@ void Twain_config::GetOrSetPintfCapability(int& value,bool is_get)
}
}
void Twain_config::GetOrSetDoubleNames(std::vector<std::string>& v, bool is_get)
{
loadjson(GetTwainInIPath() + TCHAR2STRING(TWAIN_CONFIG_JSON));
if (is_get) {
if (!m_json[CONFIG_DOUBLEFEEDDETECTION].is_array()) {
savejson(defaultjson(), GetTwainInIPath() + TCHAR2STRING(TWAIN_CONFIG_JSON));
return;
}
m_json[CONFIG_DOUBLEFEEDDETECTION].get_to(v);
//for (auto& node : v)
// node = FileTools::utf82str(node);
}
else {
m_json[CONFIG_DOUBLEFEEDDETECTION] = v;
savejson(m_json, GetTwainInIPath() + TCHAR2STRING(TWAIN_CONFIG_JSON));
}
}
void Twain_config::setrollermsgdata(int value)
{
loadjson(GetTwainInIPath() + TCHAR2STRING(TWAIN_CONFIG_JSON));
@ -1315,5 +1333,7 @@ json Twain_config::defaultjson()
json tmp;
tmp[ROLLERMSGDATE] = 0;
tmp[PRINTFCAPABILITY] = 0;
std::string str = FileTools::to_web_utf(FileTools::String2Wstring("ºÃ·ÖÊýÔľíɨÃè¶Ë"));
tmp[CONFIG_DOUBLEFEEDDETECTION] = {str};
return tmp;
}

View File

@ -108,6 +108,7 @@ public:
int getrollermsgdate();
void setrollermsgdata(int value);
void GetOrSetPintfCapability(int& value,bool is_get);
void GetOrSetDoubleNames(std::vector<std::string>& v, bool is_get);
private:
std::string GetTwainInIPath();

View File

@ -176,7 +176,7 @@ void autoCrop_desaskew_fillBlank(const cv::Mat& src, cv::Mat& dst, bool isAutoCr
hg::threshold_Mat(resizeMat, thre, threshold);
if (noise > 0)
cv::morphologyEx(thre, thre, cv::MORPH_OPEN, getStructuringElement(cv::MORPH_RECT, cv::Size(noise * FX_FY, 1)),
cv::morphologyEx(thre, thre, cv::MORPH_OPEN, getStructuringElement(cv::MORPH_RECT, cv::Size(std::ceil(noise * FX_FY), 1)),
cv::Point(-1, -1), 1, cv::BORDER_CONSTANT, cv::Scalar::all(0));
std::vector<cv::Vec4i> hierarchy;

View File

@ -113,6 +113,8 @@ static constexpr const Identity srcIdent(
"AUGE",
#elif defined LANXUM
"LANXUM",
#elif defiend ZHUOYUYUN
"ZHUOYUYUN",
#elif defined CUMTENN
"CUMTENN",
#elif defined MAKERIGHTWAY
@ -129,6 +131,8 @@ static constexpr const Identity srcIdent(
"G62S Series",
#elif defined HANVON
"HW-8000",
#elif defiend ZHUOYUYUN
"ZY-2100S",
#else // ISG100
"G100 Series",
#endif
@ -137,6 +141,8 @@ static constexpr const Identity srcIdent(
"G73S Series",
#elif defined HANVON
"HW-9000",
#elif defiend ZHUOYUYUN
"ZY-2100S",
#elif defined CUMTENN
"CTS A3",
#else // ISG100
@ -148,6 +154,8 @@ static constexpr const Identity srcIdent(
"G42S Series",
#elif defined CUMTENN
"CTS A4",
#elif defiend ZHUOYUYUN
"ZY-2100S",
#elif defined HANVON
#ifdef ANDROIDSERIAL
"HW-1000",
@ -161,6 +169,8 @@ static constexpr const Identity srcIdent(
#elif defined(G400) // G200
#ifdef LANXUM
"G52S Series",
#elif defiend ZHUOYUYUN
"ZY-2100S",
#elif defined HANVON
#ifdef ANDROIDSERIAL
"HW-7000",
@ -181,6 +191,8 @@ static constexpr const Identity srcIdent(
"Scan G100 TWAIN"
#elif defined AUGE
"AUGESCAN G100 TWAIN"
#elif defiend ZHUOYUYUN
"ZHUOYUYUNSCAN G100 TWAIN"
#elif defined HANVON
"Hanvon HW-8000 TAWIN"
#elif defined LANXUM //!LANXUM
@ -191,6 +203,8 @@ static constexpr const Identity srcIdent(
#else // ISG100
#ifdef MAKEHUAGAO
"HUAGOSCAN G200 TWAIN"
#elif defiend ZHUOYUYUN
"ZHUOYUYUNSCAN G200 TWAIN"
#elif defined NOLOGO
"Scan G200 TWAIN"
#elif defined CUMTENN
@ -222,6 +236,8 @@ static constexpr const Identity srcIdent(
#endif // ANDROIDSERIES
#elif defined NOLOGO
"Scan G300 TWAIN"
#elif defiend ZHUOYUYUN
"ZHUOYUYUNSCAN G300 TWAIN"
#elif defined CUMTENN
"CUMTENN CTS A4 TWAIN"
#elif defined LANXUM //!LANXUM
@ -244,6 +260,8 @@ static constexpr const Identity srcIdent(
#endif // ANDROIDSERIES
#elif defined LANXUM //!LANXUM
"LANXUMSCAN G52S TWAIN"
#elif defiend ZHUOYUYUN
"ZHUOYUYUNSCAN G400 TWAIN"
#elif defined NOLOGO
"Scan G400 TWAIN"
#else // !MAKEHUAGAO
@ -351,6 +369,11 @@ static std::vector<Vid_pid> DeviceID{
#endif // ISG100
};
#elif defiend ZHUOYUYUN
static std::vector<Vid_pid> DeviceID{
{0x3072,0x2100},
};
#elif defined AUGE
static std::vector<Vid_pid> DeviceID{
{0x3072,0x0130},
@ -966,7 +989,7 @@ void HuagaoDs::dogear_callback(int indexpaper)
onDeviceEvent(DOG_EAR);
}
Result HuagaoDs::identityOpenDs(const Identity&) {
Result HuagaoDs::identityOpenDs(const Identity& origin) {
#ifdef G400
hMutex = CreateMutex(NULL, FALSE, _T("LookitApp_4"));
#elif defined G300
@ -984,6 +1007,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
return { ReturnCode::Failure, ConditionCode::CapBadOperation };
}
Twain_config().GetOrSetPintfCapability(is_printfcapability, true);
auto usblist = UsbScan_List::find_all_usb();
if (!usblist.empty())
{
@ -998,7 +1022,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
if (!scanner.get()) {
#ifdef G200
if (pid == 0x139 || pid == 0x239 || pid == 0x8739 || pid == 0x8629 || pid == 0x130 ||pid == 0x8000 || pid == 0x9000 ||
pid == 0x138 || pid == 0x238)
pid == 0x138 || pid == 0x238 || pid == 0x2100)
scanner.reset(new GScanO1003399());
else
scanner.reset(new GScanO200());
@ -1828,7 +1852,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
CapabilityPrintf(msg, enum2str(CapTypeEx::TwEx_CropNoise), msg == Msg::Set ? to_string((int)data.currentItem<UInt32>()) : "");
if (Msg::Set == msg) {
auto mech = data.currentItem<UInt32>();
if ((mech > 20 || mech < 0) && ((bool)m_scanparam->is_autocrop == true))
if ((mech > 20 || mech < 1) && ((bool)m_scanparam->is_autocrop == true))
return badValue();
m_scanparam->noise = mech;
return success();
@ -2219,38 +2243,46 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
}
return CapSupGetAllResetEx<UInt32, UInt32, (CapType)CapTypeEx::TwEx_DogEarDistance>(msg, data, m_scanparam->dogeardistance, 70);
};
//双张检测 与官方标准定义有所差异 此协议修改为bool型 爱云校使用bool类型其余使用标准twain协议
m_query[CapType::DoubleFeedDetection] = msgSupportGetAllSetReset;
m_caps[CapType::DoubleFeedDetection] = [this](Msg msg, Capability& data)->Result {
CapabilityPrintf(msg, enum2str(CapType::DoubleFeedDetection), msg == Msg::Set ? to_string((float)data.currentItem<UInt16>()) : "");
switch (msg) {
case Msg::Get:
data = Capability::createEnumeration<UInt16>(CapType::DoubleFeedDetection, { 0 ,1}, m_scanparam->hardwarecaps.en_doublefeed ? 0 : 1, 0);
return { ReturnCode::Success, ConditionCode::Success };
case Msg::GetCurrent:
data = Capability::createOneValue<UInt16>(CapType::DoubleFeedDetection, (UInt16)m_scanparam->hardwarecaps.en_doublefeed ? 0 : 1);
return { ReturnCode::Success, ConditionCode::Success };
case Msg::Reset:
case Msg::GetDefault:
m_scanparam->hardwarecaps.en_doublefeed = 1;
data = Capability::createOneValue<UInt16>(CapType::DoubleFeedDetection, 0);
return { ReturnCode::Success, ConditionCode::Success };
case Msg::Set: {
auto mech = data.currentItem<UInt16>();
m_scanparam->hardwarecaps.en_doublefeed = mech ? 0 : 1;
return success();
}
std::vector<std::string> names;
Twain_config().GetOrSetDoubleNames(names,true);
FileTools::writelog(log_INFO, " DoubleFeedDetection "+ FileTools::GetProcessName());
if (std::find(names.begin(), names.end(), FileTools::to_web_utf(FileTools::String2Wstring(FileTools::GetProcessName()))) == names.end()) {
FileTools::writelog(log_INFO, " DoubleFeedDetection 11111 ");
switch (msg) {
case Msg::Get:
data = Capability::createEnumeration<UInt16>(CapType::DoubleFeedDetection, { 0 ,1 }, m_scanparam->hardwarecaps.en_doublefeed ? 0 : 1, 0);
return { ReturnCode::Success, ConditionCode::Success };
case Msg::GetCurrent:
data = Capability::createOneValue<UInt16>(CapType::DoubleFeedDetection, (UInt16)m_scanparam->hardwarecaps.en_doublefeed ? 0 : 1);
return { ReturnCode::Success, ConditionCode::Success };
case Msg::Reset:
case Msg::GetDefault:
m_scanparam->hardwarecaps.en_doublefeed = 1;
data = Capability::createOneValue<UInt16>(CapType::DoubleFeedDetection, 0);
return { ReturnCode::Success, ConditionCode::Success };
case Msg::Set: {
auto mech = data.currentItem<UInt16>();
m_scanparam->hardwarecaps.en_doublefeed = mech ? 0 : 1;
return success();
}
default:
return { ReturnCode::Failure, ConditionCode::CapBadOperation };
default:
return { ReturnCode::Failure, ConditionCode::CapBadOperation };
}
}
else{
FileTools::writelog(log_INFO, " DoubleFeedDetection 22222 ");
if (Msg::Set == msg) {
auto mech = data.currentItem<UInt16>();
m_scanparam->hardwarecaps.en_doublefeed = mech ? 1 : 0;
return success();
}
return CapSupGetAllResetEx<BYTE, UInt16, CapType::DoubleFeedDetection>(msg, data, m_scanparam->hardwarecaps.en_doublefeed, TRUE);
}
//if (Msg::Set == msg) {
// auto mech = data.currentItem<UInt16>();
// m_scanparam->hardwarecaps.en_doublefeed = mech ? 1 : 0;
// return success();
//}
//return CapSupGetAllResetEx<BYTE, UInt16, CapType::DoubleFeedDetection>(msg, data, m_scanparam->hardwarecaps.en_doublefeed, TRUE);
};
#ifdef G200

Binary file not shown.

BIN
huagao/logoZhuoYuYun.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Binary file not shown.