mirror of http://192.168.1.51:8099/lmh188/twain3.0
调整、增加部分协议
This commit is contained in:
parent
788f1c5cf9
commit
391da4144e
|
@ -113,18 +113,18 @@ static list<UInt16> paperSizeList = { (UInt16)PaperSize::A3,(UInt16)PaperSize::A
|
|||
|
||||
static list<float> imageRotateList = { 0.0,90.0,180.0,270.0 };
|
||||
|
||||
static map<unsigned int, CString> 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<unsigned int, CString> 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<CapType::IAutomaticCropUsesFrame>(
|
||||
{ Bool(), Bool(true) }, Bool(m_scanparam->is_autocrop));
|
||||
data = Capability::Capability::createOneValue<CapType::IAutomaticCropUsesFrame>(m_scanparam->is_autocrop);
|
||||
return success();
|
||||
case Msg::Reset:
|
||||
case Msg::GetCurrent:
|
||||
|
@ -1111,11 +1118,38 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
data = Capability::createOneValue<CapType::IAutomaticCropUsesFrame>(false);
|
||||
return success();
|
||||
|
||||
//case Msg::Set: {
|
||||
// auto autocrop = data.currentItem<CapType::IAutomaticCropUsesFrame>();
|
||||
// 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<CapType::AutoScan>(
|
||||
{ Bool(), Bool(true) }, m_autoscan);
|
||||
return success();
|
||||
case Msg::Reset:
|
||||
case Msg::GetCurrent:
|
||||
m_autoscan = true;
|
||||
data = Capability::createOneValue<CapType::AutoScan>(m_autoscan);
|
||||
return success();
|
||||
|
||||
case Msg::GetDefault:
|
||||
data = Capability::createOneValue<CapType::AutoScan>(true);
|
||||
return success();
|
||||
|
||||
case Msg::Set: {
|
||||
auto autocrop = data.currentItem<CapType::IAutomaticCropUsesFrame>();
|
||||
m_scanparam->is_autocrop = (bool)autocrop;
|
||||
if (autocrop)
|
||||
m_scanparam->papertype = (byte)PaperSize::None;
|
||||
auto autoscan = data.currentItem<CapType::AutoScan>();
|
||||
m_autoscan = autoscan;
|
||||
return success();
|
||||
}
|
||||
default:
|
||||
|
@ -1141,6 +1175,12 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
|
||||
case Msg::Set: {
|
||||
auto autosize = data.currentItem<CapType::IAutoSize>();
|
||||
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<CapType::IAutomaticBorderDetection>(
|
||||
{ Bool(), Bool(true) }, m_autoboarderdetcet);
|
||||
return success();
|
||||
case Msg::Reset:
|
||||
case Msg::GetCurrent:
|
||||
m_autoscan = true;
|
||||
data = Capability::createOneValue<CapType::IAutomaticBorderDetection>(m_autoboarderdetcet);
|
||||
return success();
|
||||
|
||||
case Msg::GetDefault:
|
||||
data = Capability::createOneValue<CapType::IAutomaticBorderDetection>(false);
|
||||
return success();
|
||||
|
||||
case Msg::Set: {
|
||||
auto autodetectborder = data.currentItem<CapType::IAutomaticBorderDetection>();
|
||||
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 //
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue