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)
|
||||
{
|
||||
GScanO200* This = (GScanO200*)userdata;
|
||||
|
|
|
@ -452,7 +452,6 @@ Result CapSupGetAll(Msg msg, Capability& data, std::initializer_list<T> values,
|
|||
return { ReturnCode::Failure, ConditionCode::CapBadOperation };
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, Twpp::CapType cap>
|
||||
Result CapSupGetAll(Msg msg, Capability& data, T1& currvalue, T2 defaultvalue) {
|
||||
switch (msg) {
|
||||
|
@ -641,8 +640,8 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
BITMAPINFOHEADER& bmInfo = *((BITMAPINFOHEADER*)header());
|
||||
bmInfo.biHeight = 2000;
|
||||
bmInfo.biWidth = 2000;
|
||||
bmInfo.biBitCount = m_scanparam->pixtype == 2 ? 24 : (m_scanparam->pixtype == 1 ? 8 : 0);
|
||||
m_iBitdepth = 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 : 1);
|
||||
#ifdef LANXUM
|
||||
scanner->open(0x31c9, 0x8200);
|
||||
#else
|
||||
|
@ -785,7 +784,8 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
|
|||
}
|
||||
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;
|
||||
|
@ -1598,7 +1598,7 @@ Result HuagaoDs::identityCloseDs(const Identity&) {
|
|||
// no need to explicitly release any resources if using RAII
|
||||
// TWPP will free the whole source on its own after this method
|
||||
|
||||
if (guiIndicator)
|
||||
if (guiIndicator->GetSafeHwnd())
|
||||
guiIndicator->DestroyWindow();
|
||||
|
||||
if (guiTwain.get())
|
||||
|
@ -1634,7 +1634,7 @@ Result HuagaoDs::pendingXfersEnd(const Identity&, PendingXfers& data) {
|
|||
|
||||
if (ret != 0) {
|
||||
scanner->Set_ErrorCode(0);
|
||||
if (guiIndicator)
|
||||
if (guiIndicator->GetSafeHwnd())
|
||||
guiIndicator->ShowWindow(SW_HIDE);
|
||||
//if (guiIndicator.get())
|
||||
// guiIndicator.reset();
|
||||
|
@ -1668,7 +1668,7 @@ Result HuagaoDs::pendingXfersReset(const Identity&, PendingXfers& data) {
|
|||
scanner->ResetScanner();
|
||||
}
|
||||
//guiIndicator.reset();
|
||||
if (guiIndicator)
|
||||
if (guiIndicator->GetSafeHwnd())
|
||||
guiIndicator->DestroyWindow();
|
||||
return success();
|
||||
}
|
||||
|
@ -1719,23 +1719,28 @@ Result HuagaoDs::userInterfaceEnable(const Identity&, UserInterface& ui) {
|
|||
//{
|
||||
// MessageBox(NULL, TEXT("MemoryFile"), _T("bb"), MB_OK);
|
||||
//}
|
||||
|
||||
if (!ui.showUi()) {
|
||||
// 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
|
||||
while (!scanner->Get_Scanner_PaperOn())
|
||||
{
|
||||
if (MessageBox(NULL, L"检测到无纸,请添加纸张", L"提示", MB_YESNO) == IDNO)
|
||||
return seqError();
|
||||
}
|
||||
setState(DsState::Enabled);
|
||||
auto ret = startScan();
|
||||
if (ret.status().condition() == Twpp::CC::NoMedia)
|
||||
return ret;
|
||||
//if (ret.status().condition() == Twpp::CC::NoMedia)
|
||||
// return ret;
|
||||
if (ret == success()) {
|
||||
m_pendingXfers = 1;
|
||||
auto notified = notifyXferReady();
|
||||
return success();
|
||||
}
|
||||
else {
|
||||
m_pendingXfers = 0;
|
||||
setState(DsState::Open);
|
||||
return ret;
|
||||
//setState(DsState::Open);
|
||||
}
|
||||
auto notified = notifyXferReady();
|
||||
return success();
|
||||
}
|
||||
|
||||
return showTwainUI(ui);
|
||||
|
@ -1748,6 +1753,8 @@ Result HuagaoDs::userInterfaceEnableUiOnly(const Identity&, UserInterface& ui) {
|
|||
|
||||
Result HuagaoDs::imageInfoGet(const Identity&, ImageInfo& data) {
|
||||
// our image does not change
|
||||
if (m_pendingXfers == 0)
|
||||
return success();
|
||||
auto dib = header();
|
||||
data.setBitsPerPixel(static_cast<Int16>(dib->biBitCount));
|
||||
data.setHeight(dib->biHeight);
|
||||
|
@ -2038,6 +2045,13 @@ Twpp::Result HuagaoDs::showTwainUI(Twpp::UserInterface& ui, bool bUiOnly)
|
|||
|
||||
//!< show ui to scan button push
|
||||
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_scanparam.reset(new GScanCap(caps));
|
||||
saveGscanCapSetting();
|
||||
|
@ -2229,7 +2243,7 @@ Twpp::Result HuagaoDs::startScan()
|
|||
int retCode = scanner->aquire_bmpdata(*bmpData.get());
|
||||
if (retCode != 0) {
|
||||
scanner->Set_ErrorCode(0);
|
||||
if (guiIndicator)
|
||||
if (guiIndicator->GetSafeHwnd())
|
||||
guiIndicator->DestroyWindow();
|
||||
|
||||
//if(guiIndicator.get())
|
||||
|
|
Loading…
Reference in New Issue