mirror of http://192.168.1.51:8099/lmh188/twain3.0
增加扫描无纸提示。
This commit is contained in:
parent
6fa11fc381
commit
eb87926c8a
|
@ -516,6 +516,7 @@ void GScanO200::clear_hwerror()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GScanO200::usbhotplug_callback(bool isconnect, void* userdata)
|
void GScanO200::usbhotplug_callback(bool isconnect, void* userdata)
|
||||||
{
|
{
|
||||||
GScanO200* This = (GScanO200*)userdata;
|
GScanO200* This = (GScanO200*)userdata;
|
||||||
|
|
|
@ -452,7 +452,6 @@ Result CapSupGetAll(Msg msg, Capability& data, std::initializer_list<T> values,
|
||||||
return { ReturnCode::Failure, ConditionCode::CapBadOperation };
|
return { ReturnCode::Failure, ConditionCode::CapBadOperation };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1, typename T2, Twpp::CapType cap>
|
template<typename T1, typename T2, Twpp::CapType cap>
|
||||||
Result CapSupGetAll(Msg msg, Capability& data, T1& currvalue, T2 defaultvalue) {
|
Result CapSupGetAll(Msg msg, Capability& data, T1& currvalue, T2 defaultvalue) {
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
|
@ -641,8 +640,8 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
||||||
BITMAPINFOHEADER& bmInfo = *((BITMAPINFOHEADER*)header());
|
BITMAPINFOHEADER& bmInfo = *((BITMAPINFOHEADER*)header());
|
||||||
bmInfo.biHeight = 2000;
|
bmInfo.biHeight = 2000;
|
||||||
bmInfo.biWidth = 2000;
|
bmInfo.biWidth = 2000;
|
||||||
bmInfo.biBitCount = m_scanparam->pixtype == 2 ? 24 : (m_scanparam->pixtype == 1 ? 8 : 0);
|
bmInfo.biBitCount = m_scanparam->pixtype == 2 ? 24 : (m_scanparam->pixtype == 1 ? 8 : 1);
|
||||||
m_iBitdepth = m_scanparam->pixtype == 2 ? 24 : (m_scanparam->pixtype == 1 ? 8 : 0);
|
m_iBitdepth = m_scanparam->pixtype == 2 ? 24 : (m_scanparam->pixtype == 1 ? 8 : 1);
|
||||||
#ifdef LANXUM
|
#ifdef LANXUM
|
||||||
scanner->open(0x31c9, 0x8200);
|
scanner->open(0x31c9, 0x8200);
|
||||||
#else
|
#else
|
||||||
|
@ -785,7 +784,8 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
||||||
}
|
}
|
||||||
return badValue();
|
return badValue();
|
||||||
}
|
}
|
||||||
return CapSupGetAllReset<int, PixelType, CapType::IPixelType>(msg, data, m_scanparam->pixtype, PixelType::Rgb);
|
return CapSupGetAllReset<int, PixelType, CapType::IPixelType>(msg, data, { PixelType::BlackWhite,PixelType::Gray,PixelType::Rgb }, m_scanparam->pixtype, PixelType::Rgb,
|
||||||
|
m_scanparam->pixtype == (int)PixelType::Rgb ? 2 : (m_scanparam->pixtype == (int)PixelType::Gray ? 1 : 0), 2);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_query[CapType::IAutomaticColorEnabled] = msgSupportGetAllSetReset;
|
m_query[CapType::IAutomaticColorEnabled] = msgSupportGetAllSetReset;
|
||||||
|
@ -1598,7 +1598,7 @@ Result HuagaoDs::identityCloseDs(const Identity&) {
|
||||||
// no need to explicitly release any resources if using RAII
|
// no need to explicitly release any resources if using RAII
|
||||||
// TWPP will free the whole source on its own after this method
|
// TWPP will free the whole source on its own after this method
|
||||||
|
|
||||||
if (guiIndicator)
|
if (guiIndicator->GetSafeHwnd())
|
||||||
guiIndicator->DestroyWindow();
|
guiIndicator->DestroyWindow();
|
||||||
|
|
||||||
if (guiTwain.get())
|
if (guiTwain.get())
|
||||||
|
@ -1634,7 +1634,7 @@ Result HuagaoDs::pendingXfersEnd(const Identity&, PendingXfers& data) {
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
scanner->Set_ErrorCode(0);
|
scanner->Set_ErrorCode(0);
|
||||||
if (guiIndicator)
|
if (guiIndicator->GetSafeHwnd())
|
||||||
guiIndicator->ShowWindow(SW_HIDE);
|
guiIndicator->ShowWindow(SW_HIDE);
|
||||||
//if (guiIndicator.get())
|
//if (guiIndicator.get())
|
||||||
// guiIndicator.reset();
|
// guiIndicator.reset();
|
||||||
|
@ -1668,7 +1668,7 @@ Result HuagaoDs::pendingXfersReset(const Identity&, PendingXfers& data) {
|
||||||
scanner->ResetScanner();
|
scanner->ResetScanner();
|
||||||
}
|
}
|
||||||
//guiIndicator.reset();
|
//guiIndicator.reset();
|
||||||
if (guiIndicator)
|
if (guiIndicator->GetSafeHwnd())
|
||||||
guiIndicator->DestroyWindow();
|
guiIndicator->DestroyWindow();
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
@ -1719,23 +1719,28 @@ Result HuagaoDs::userInterfaceEnable(const Identity&, UserInterface& ui) {
|
||||||
//{
|
//{
|
||||||
// MessageBox(NULL, TEXT("MemoryFile"), _T("bb"), MB_OK);
|
// MessageBox(NULL, TEXT("MemoryFile"), _T("bb"), MB_OK);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (!ui.showUi()) {
|
if (!ui.showUi()) {
|
||||||
// this is an exception when we want to set state explicitly, notifyXferReady can be called only in enabled state
|
// this is an exception when we want to set state explicitly, notifyXferReady can be called only in enabled state
|
||||||
// with hidden UI, the usual workflow DsState::Enabled -> notifyXferReady() -> DsState::XferReady is a single step
|
// with hidden UI, the usual workflow DsState::Enabled -> notifyXferReady() -> DsState::XferReady is a single step
|
||||||
|
while (!scanner->Get_Scanner_PaperOn())
|
||||||
|
{
|
||||||
|
if (MessageBox(NULL, L"检测到无纸,请添加纸张", L"提示", MB_YESNO) == IDNO)
|
||||||
|
return seqError();
|
||||||
|
}
|
||||||
setState(DsState::Enabled);
|
setState(DsState::Enabled);
|
||||||
auto ret = startScan();
|
auto ret = startScan();
|
||||||
if (ret.status().condition() == Twpp::CC::NoMedia)
|
//if (ret.status().condition() == Twpp::CC::NoMedia)
|
||||||
return ret;
|
// return ret;
|
||||||
if (ret == success()) {
|
if (ret == success()) {
|
||||||
m_pendingXfers = 1;
|
m_pendingXfers = 1;
|
||||||
auto notified = notifyXferReady();
|
|
||||||
return success();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_pendingXfers = 0;
|
m_pendingXfers = 0;
|
||||||
setState(DsState::Open);
|
//setState(DsState::Open);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
auto notified = notifyXferReady();
|
||||||
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
return showTwainUI(ui);
|
return showTwainUI(ui);
|
||||||
|
@ -1748,6 +1753,8 @@ Result HuagaoDs::userInterfaceEnableUiOnly(const Identity&, UserInterface& ui) {
|
||||||
|
|
||||||
Result HuagaoDs::imageInfoGet(const Identity&, ImageInfo& data) {
|
Result HuagaoDs::imageInfoGet(const Identity&, ImageInfo& data) {
|
||||||
// our image does not change
|
// our image does not change
|
||||||
|
if (m_pendingXfers == 0)
|
||||||
|
return success();
|
||||||
auto dib = header();
|
auto dib = header();
|
||||||
data.setBitsPerPixel(static_cast<Int16>(dib->biBitCount));
|
data.setBitsPerPixel(static_cast<Int16>(dib->biBitCount));
|
||||||
data.setHeight(dib->biHeight);
|
data.setHeight(dib->biHeight);
|
||||||
|
@ -2038,6 +2045,13 @@ Twpp::Result HuagaoDs::showTwainUI(Twpp::UserInterface& ui, bool bUiOnly)
|
||||||
|
|
||||||
//!< show ui to scan button push
|
//!< show ui to scan button push
|
||||||
auto scanFunction = [this](const GScanCap& caps) {
|
auto scanFunction = [this](const GScanCap& caps) {
|
||||||
|
while (!scanner->Get_Scanner_PaperOn())
|
||||||
|
{
|
||||||
|
if (MessageBox(guiTwain.get()->GetSafeHwnd(), L"检测到无纸,请添加纸张", L"提示", MB_YESNO) == IDNO){
|
||||||
|
m_pendingXfers = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
m_pendingXfers = 1;
|
m_pendingXfers = 1;
|
||||||
m_scanparam.reset(new GScanCap(caps));
|
m_scanparam.reset(new GScanCap(caps));
|
||||||
saveGscanCapSetting();
|
saveGscanCapSetting();
|
||||||
|
@ -2229,7 +2243,7 @@ Twpp::Result HuagaoDs::startScan()
|
||||||
int retCode = scanner->aquire_bmpdata(*bmpData.get());
|
int retCode = scanner->aquire_bmpdata(*bmpData.get());
|
||||||
if (retCode != 0) {
|
if (retCode != 0) {
|
||||||
scanner->Set_ErrorCode(0);
|
scanner->Set_ErrorCode(0);
|
||||||
if (guiIndicator)
|
if (guiIndicator->GetSafeHwnd())
|
||||||
guiIndicator->DestroyWindow();
|
guiIndicator->DestroyWindow();
|
||||||
|
|
||||||
//if(guiIndicator.get())
|
//if(guiIndicator.get())
|
||||||
|
|
Loading…
Reference in New Issue