fix: When a new device is connected, the current acquisition task is forced to end

This commit is contained in:
dreamsourcelabTAI 2023-03-13 18:49:00 +08:00
parent 8f41334f05
commit 4050bd7b6f
3 changed files with 27 additions and 12 deletions

View File

@ -554,6 +554,11 @@ namespace pv
return;
}
if (_session->is_working()){
dsv_info("Save data: stop the current device.");
_session->stop_capture();
}
_session->set_saving(true);
StoreProgress *dlg = new StoreProgress(_session, this);
@ -564,6 +569,11 @@ namespace pv
{
using pv::dialogs::StoreProgress;
if (_session->is_working()){
dsv_info("Export data: stop the current device.");
_session->stop_capture();
}
StoreProgress *dlg = new StoreProgress(_session, this);
dlg->export_run();
}
@ -1112,7 +1122,7 @@ namespace pv
case Qt::Key_S:
_sampling_bar->run_or_stop();
break;
case Qt::Key_I:
_sampling_bar->run_or_stop_instant();
break;
@ -1683,6 +1693,7 @@ namespace pv
if (_session->get_device()->is_demo() == false)
{
QString msgText = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_TO_SWITCH_DEVICE), "To switch the new device?");
if (MsgBox::Confirm(msgText) == false){
_sampling_bar->update_device_list(); // Update the list only.
return;

View File

@ -169,7 +169,11 @@ namespace pv
bool SigSession::set_default_device()
{
assert(!_is_saving);
assert(!_is_working);
if (_is_working){
dsv_info("The current device is working, now to stop it.");
stop_capture();
}
struct ds_device_base_info *array = NULL;
int count = 0;
@ -1772,7 +1776,7 @@ namespace pv
if (_capture_data->get_analog()->last_ended() == false)
dsv_err("%s", "The collected data is error!");
// trigger next collect
// trig next collect
if (!_is_instant && is_repeat_mode() && _is_working && event == DS_EV_COLLECT_TASK_END)
{
_callback->trigger_message(DSV_MSG_TRIG_NEXT_COLLECT);
@ -1787,16 +1791,16 @@ namespace pv
break;
case DS_EV_NEW_DEVICE_ATTACH:
_callback->trigger_message(DSV_MSG_NEW_USB_DEVICE);
break;
case DS_EV_CURRENT_DEVICE_DETACH:
{
if (_is_working)
stop_capture();
if (DS_EV_NEW_DEVICE_ATTACH == event)
_callback->trigger_message(DSV_MSG_NEW_USB_DEVICE);
else
_callback->trigger_message(DSV_MSG_CURRENT_DEVICE_DETACHED);
}
_callback->trigger_message(DSV_MSG_CURRENT_DEVICE_DETACHED);
}
break;
case DS_EV_INACTIVE_DEVICE_DETACH:

View File

@ -1285,11 +1285,11 @@ SR_API void ds_log_level(int level);
#define DS_EV_COLLECT_TASK_END_BY_ERROR 106
enum bbbb
enum DS_DEVICE_EVENT_TYPE
{
DS_EV_NEW_DEVICE_ATTACH = 1,
DS_EV_CURRENT_DEVICE_DETACH = 2,
DS_EV_INACTIVE_DEVICE_DETACH = 3,
DS_EV_NEW_DEVICE_ATTACH = 1,
DS_EV_CURRENT_DEVICE_DETACH = 2,
DS_EV_INACTIVE_DEVICE_DETACH = 3,
};