增加APP取图计数

This commit is contained in:
gb 2023-05-26 15:17:15 +08:00
parent 4f62c52b49
commit a041c851e4
4 changed files with 25 additions and 4 deletions

View File

@ -159,6 +159,7 @@ struct __declspec(novtable) ISaneInvoker : public IRef
COM_API_DECLARE(bool, is_online(void));
COM_API_DECLARE(bool, is_paper_on(void));
COM_API_DECLARE(int, last_error(void));
COM_API_DECLARE(int, image_fetched(IScanImg* tx)); // notify the image 'tx' has fetched by APP
// Function: 获取配置项信息
//

View File

@ -2451,6 +2451,7 @@ COM_API_IMPLEMENT(scanner, int, start(void))
scan_msg_ = "OK";
scan_err_ = false;
user_cancel_ = false;
fetch_imgs_ = 0;
app_wnd_ = setting_.get() ? setting_->hwnd() : callback::find_main_wnd();
ret = hg_sane_middleware::instance()->start(handle_, NULL);
@ -2617,6 +2618,16 @@ COM_API_IMPLEMENT(scanner, int, last_error(void))
{
return err_;
}
COM_API_IMPLEMENT(scanner, int, image_fetched(IScanImg* tx))
{
fetch_imgs_++;
if (ui_notify)
ui_notify(SANE_EVENT_IMG_UPLOADED, NULL, fetch_imgs_);
else if (indicator_.get())
indicator_->notify_data_arrived(false);
return 0;
}
COM_API_IMPLEMENT(scanner, bool, get_option_info(int sn, value_type* type, value_limit* limit, int* bytes))
{
@ -3295,10 +3306,10 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len)
}
else if (ev_code == SANE_EVENT_USB_DATA_RECEIVED)
{
if (indicator_.get())
indicator_->notify_data_arrived(false);
else if (ui_notify)
ui_notify(ev_code, data, 0);
//if (indicator_.get())
// indicator_->notify_data_arrived(false);
//else if (ui_notify)
// ui_notify(ev_code, data, 0);
}
else if (ev_code == SANE_EVENT_SCAN_FINISHED)
{

View File

@ -46,6 +46,7 @@ class scanner : public ISaneInvoker, virtual public refer
int ex_id_;
int prev_start_result_;
int dpi_;
int fetch_imgs_ = 0; // count for images has fetched by APP
bool is_bIndicator;
bool is_show_setting_;
unsigned int img_ind_;
@ -217,6 +218,7 @@ public:
COM_API_OVERRIDE(bool, is_online(void));
COM_API_OVERRIDE(bool, is_paper_on(void));
COM_API_OVERRIDE(int, last_error(void));
COM_API_OVERRIDE(int, image_fetched(IScanImg* tx));
COM_API_OVERRIDE(bool, get_option_info(int sn, value_type* type, value_limit* limit, int* bytes));
COM_API_OVERRIDE(bool, get_value(int sn, set_opt_value, void* param));
COM_API_OVERRIDE(bool, get_value(int sn, void* data, int* len)); // get operation with in-parameter

View File

@ -1363,6 +1363,8 @@ Result huagao_ds::imageMemXferGet(const Identity& origin, ImageMemXfer& data)
img->add_ref();
ret = success();
}
else
scanner_->image_fetched(img);
}
else if (img->read(dst, &want_read, off) == SCANNER_ERR_OK)
{
@ -1378,6 +1380,8 @@ Result huagao_ds::imageMemXferGet(const Identity& origin, ImageMemXfer& data)
img->add_ref();
ret = success();
}
else
scanner_->image_fetched(img);
}
else
{
@ -1418,6 +1422,7 @@ Result huagao_ds::imageNativeXferGet(const Identity& id, ImageNativeXfer& data)
total = img->bytes() - (unsigned int)off;
src = img->data(off, &total);
}
scanner_->image_fetched(img);
img->release();
return { ReturnCode::XferDone, ConditionCode::Success };
@ -1470,6 +1475,7 @@ Twpp::Result huagao_ds::imageFileXferGet(const Twpp::Identity& origin)
}
fclose(dst);
scanner_->image_fetched(img);
}
else
{
@ -1487,6 +1493,7 @@ Twpp::Result huagao_ds::imageFileXferGet(const Twpp::Identity& origin)
load_sane_util::log_info((L"Map file to " + load_sane_util::ansi2unic(m_fileXfer.filePath().string().c_str()) + L"\r\n").c_str(), 1);
img->keep_file(true);
scanner_->image_fetched(img);
img->release();
cv_e = load_sane_util::move_file(file.c_str(), m_fileXfer.filePath().string().c_str());
if (cv_e == 0)