Code refactoring 21

This commit is contained in:
dreamsourcelabTAI 2022-09-23 15:44:22 +08:00
parent cec8dade5e
commit 34cab3cf23
21 changed files with 2315 additions and 2049 deletions

View File

@ -31,9 +31,9 @@ set(DS_TITLE DSView)
set(DS_DESCRIPTION "A GUI for instruments of DreamSourceLab") set(DS_DESCRIPTION "A GUI for instruments of DreamSourceLab")
set(DS_VERSION_MAJOR 1) set(DS_VERSION_MAJOR 1)
set(DS_VERSION_MINOR 2) set(DS_VERSION_MINOR 3)
set(DS_VERSION_MICRO 1) set(DS_VERSION_MICRO 0)
set(DS_VERSION_STRING ${DS_VERSION_MAJOR}.${DS_VERSION_MINOR}.${DS_VERSION_MICRO} ) set(DS_VERSION_STRING ${DS_VERSION_MAJOR}.${DS_VERSION_MINOR}.${DS_VERSION_MICRO}-dev )
configure_file ( configure_file (
${PROJECT_SOURCE_DIR}/DSView/config.h.in ${PROJECT_SOURCE_DIR}/DSView/config.h.in

View File

@ -30,6 +30,6 @@
#define DS_VERSION_MAJOR 1 #define DS_VERSION_MAJOR 1
#define DS_VERSION_MINOR 2 #define DS_VERSION_MINOR 2
#define DS_VERSION_MICRO 1 #define DS_VERSION_MICRO 1
#define DS_VERSION_STRING "1.2.1" #define DS_VERSION_STRING "1.3.0-dev"
#endif #endif

View File

@ -30,6 +30,7 @@ DeviceAgent::DeviceAgent()
_di = NULL; _di = NULL;
_dev_type = 0; _dev_type = 0;
_callback = NULL; _callback = NULL;
_is_new_device = false;
} }
void DeviceAgent::update() void DeviceAgent::update()
@ -48,6 +49,13 @@ void DeviceAgent::update()
_di = info.di; _di = info.di;
_dev_name = QString::fromLocal8Bit(info.name); _dev_name = QString::fromLocal8Bit(info.name);
_driver_name = QString::fromLocal8Bit(info.driver_name); _driver_name = QString::fromLocal8Bit(info.driver_name);
if (is_in_history(_dev_handle) == false){
_is_new_device = true;
}
else{
_is_new_device = false;
}
} }
} }
@ -60,11 +68,13 @@ void DeviceAgent::update()
GVariant* DeviceAgent::get_config(const sr_channel *ch, const sr_channel_group *group, int key) GVariant* DeviceAgent::get_config(const sr_channel *ch, const sr_channel_group *group, int key)
{ {
assert(_dev_handle); assert(_dev_handle);
GVariant *data = NULL; GVariant *data = NULL;
if (ds_get_actived_device_config(ch, group, key, &data) != SR_OK) if (ds_get_actived_device_config(ch, group, key, &data) != SR_OK)
{ {
if (is_hardware())
dsv_warn("%s%d", "WARNING: Failed to get value of config id:", key); dsv_warn("%s%d", "WARNING: Failed to get value of config id:", key);
else
dsv_detail("%s%d", "WARNING: Failed to get value of config id:", key);
} }
return data; return data;
} }
@ -75,7 +85,10 @@ bool DeviceAgent::set_config(sr_channel *ch, sr_channel_group *group, int key, G
if (ds_set_actived_device_config(ch, group, key, data) != SR_OK) if (ds_set_actived_device_config(ch, group, key, data) != SR_OK)
{ {
if (is_hardware())
dsv_warn("%s%d", "WARNING: Failed to set value of config id:", key); dsv_warn("%s%d", "WARNING: Failed to set value of config id:", key);
else
dsv_detail("%s%d", "WARNING: Failed to set value of config id:", key);
return false; return false;
} }
@ -244,6 +257,11 @@ bool DeviceAgent::stop()
return false; return false;
} }
void DeviceAgent::release()
{
ds_release_actived_device();
}
bool DeviceAgent::have_enabled_channel() bool DeviceAgent::have_enabled_channel()
{ {
assert(_dev_handle); assert(_dev_handle);
@ -314,5 +332,16 @@ GSList *DeviceAgent::get_channels()
return ds_get_actived_device_channels(); return ds_get_actived_device_channels();
} }
bool DeviceAgent::is_in_history(ds_device_handle dev_handle)
{
for(ds_device_handle h : _history_handles){
if (h == dev_handle){
return true;
}
}
_history_handles.push_back(dev_handle);
return false;
}
//---------------device config end -----------/ //---------------device config end -----------/

View File

@ -26,6 +26,7 @@
#include <stdint.h> #include <stdint.h>
#include <libsigrok.h> #include <libsigrok.h>
#include <QString> #include <QString>
#include <vector>
class IDeviceAgentCallback class IDeviceAgentCallback
{ {
@ -147,10 +148,20 @@ public:
*/ */
bool stop(); bool stop();
/**
* Stop and close.
*/
void release();
bool is_collecting(); bool is_collecting();
protected: inline bool is_new_device(){
return _is_new_device;
}
private:
void config_changed(); void config_changed();
bool is_in_history(ds_device_handle dev_handle);
//---------------device config-----------/ //---------------device config-----------/
public: public:
@ -172,7 +183,9 @@ private:
int _dev_type; int _dev_type;
QString _dev_name; QString _dev_name;
QString _driver_name; QString _driver_name;
bool _is_new_device;
struct sr_dev_inst *_di; struct sr_dev_inst *_di;
std::vector<ds_device_handle> _history_handles;
IDeviceAgentCallback *_callback; IDeviceAgentCallback *_callback;
}; };

View File

@ -30,6 +30,8 @@
#include <QRadioButton> #include <QRadioButton>
#include "../ui/msgbox.h" #include "../ui/msgbox.h"
#include "../config/appconfig.h" #include "../config/appconfig.h"
#include "../interface/icallbacks.h"
#include "../log.h"
namespace pv { namespace pv {
namespace dialogs { namespace dialogs {
@ -122,8 +124,10 @@ void StoreProgress::reject()
{ {
using namespace Qt; using namespace Qt;
_store_session.cancel(); _store_session.cancel();
_store_session.session()->set_saving(false);
save_done(); save_done();
DSDialog::reject(); DSDialog::reject();
_store_session.session()->broadcast_msg(DSV_MSG_SAVE_COMPLETE);
} }
void StoreProgress::accept() void StoreProgress::accept()
@ -157,6 +161,7 @@ void StoreProgress::accept()
//start done //start done
if (_isExport){ if (_isExport){
if (_store_session.export_start()){ if (_store_session.export_start()){
_store_session.session()->set_saving(true);
QTimer::singleShot(100, this, SLOT(timeout())); QTimer::singleShot(100, this, SLOT(timeout()));
} }
else{ else{
@ -167,6 +172,7 @@ void StoreProgress::accept()
} }
else{ else{
if (_store_session.save_start()){ if (_store_session.save_start()){
_store_session.session()->set_saving(true);
QTimer::singleShot(100, this, SLOT(timeout())); QTimer::singleShot(100, this, SLOT(timeout()));
} }
else{ else{
@ -250,7 +256,9 @@ void StoreProgress::show_error()
void StoreProgress::closeEvent(QCloseEvent* e) void StoreProgress::closeEvent(QCloseEvent* e)
{ {
_store_session.cancel(); _store_session.cancel();
_store_session.session()->set_saving(false);
DSDialog::closeEvent(e); DSDialog::closeEvent(e);
_store_session.session()->broadcast_msg(DSV_MSG_SAVE_COMPLETE);
} }
void StoreProgress::on_progress_updated() void StoreProgress::on_progress_updated()

View File

@ -110,7 +110,7 @@ namespace pv
_device_agent = _session->get_device(); _device_agent = _session->get_device();
_session->add_msg_listener(this); _session->add_msg_listener(this);
_bFirstLoad = true; _is_auto_switch_device = false;
setup_ui(); setup_ui();
@ -270,6 +270,9 @@ namespace pv
connect(_protocol_widget, SIGNAL(protocol_updated()), this, SLOT(on_signals_changed())); connect(_protocol_widget, SIGNAL(protocol_updated()), this, SLOT(on_signals_changed()));
// SamplingBar // SamplingBar
connect(_sampling_bar, SIGNAL(sig_store_session_data()), this, SLOT(on_save()));
//
connect(_dso_trigger_widget, SIGNAL(set_trig_pos(int)), _view, SLOT(set_trig_pos(int))); connect(_dso_trigger_widget, SIGNAL(set_trig_pos(int)), _view, SLOT(set_trig_pos(int)));
_logo_bar->set_mainform_callback(this); _logo_bar->set_mainform_callback(this);
@ -305,8 +308,8 @@ namespace pv
{ {
assert(_sampling_bar); assert(_sampling_bar);
if (!selected_device->name().contains("virtual")) { if (!selected_device->name().contains("virtual")) {
_file_bar->set_settings_en(true);
_logo_bar->dsl_connected(true);
#if QT_VERSION >= 0x050400 #if QT_VERSION >= 0x050400
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
#else #else
@ -322,8 +325,8 @@ namespace pv
on_load_session(ses_name); on_load_session(ses_name);
} }
} else { } else {
_file_bar->set_settings_en(false);
_logo_bar->dsl_connected(false);
QDir dir(GetResourceDir()); QDir dir(GetResourceDir());
if (dir.exists()) { if (dir.exists()) {
@ -341,7 +344,6 @@ namespace pv
//load specified file name from application startup param //load specified file name from application startup param
if (_bFirstLoad){ if (_bFirstLoad){
_bFirstLoad = false;
QString ldFileName(AppControl::Instance()->_open_file_name.c_str()); QString ldFileName(AppControl::Instance()->_open_file_name.c_str());
@ -1354,6 +1356,14 @@ namespace pv
_measure_widget->reload(); _measure_widget->reload();
} }
bool MainWindow::confirm_to_store_data()
{
if (_session->have_hardware_data()){
return MsgBox::Confirm(tr("Save captured data?"));
}
return false;
}
void MainWindow::OnMessage(int msg) void MainWindow::OnMessage(int msg)
{ {
switch (msg) switch (msg)
@ -1380,11 +1390,13 @@ namespace pv
_trig_bar->update_view_status(); _trig_bar->update_view_status();
break; break;
case DSV_MSG_NEW_USB_DEVICE: case DSV_MSG_CURRENT_DEVICE_CHANGE_PREV:
check_usb_device_speed(); _protocol_widget->del_all_protocol();
_view->reload();
break; break;
case DSV_MSG_CURRENT_DEVICE_CHANGED: case DSV_MSG_CURRENT_DEVICE_CHANGED:
{
if (_msg != NULL){ if (_msg != NULL){
_msg->close(); _msg->close();
_msg = NULL; _msg = NULL;
@ -1392,11 +1404,10 @@ namespace pv
_sampling_bar->update_device_list(); _sampling_bar->update_device_list();
reset_all_view(); reset_all_view();
break; bool is_hardware = _session->get_device()->is_hardware();
_logo_bar->dsl_connected(is_hardware);
case DSV_MSG_CURRENT_DEVICE_CHANGE_PREV: _file_bar->update_view_status();
_protocol_widget->del_all_protocol(); }
_view->reload();
break; break;
case DSV_MSG_DEVICE_OPTIONS_UPDATED: case DSV_MSG_DEVICE_OPTIONS_UPDATED:
@ -1415,10 +1426,45 @@ namespace pv
reset_all_view(); reset_all_view();
break; break;
case DSV_MSG_NEW_USB_DEVICE:
if (confirm_to_store_data()){
_is_auto_switch_device = true;
on_save();
}
else{
_session->set_default_device();
check_usb_device_speed();
}
break;
case DSV_MSG_CURRENT_DEVICE_DETACHED: case DSV_MSG_CURRENT_DEVICE_DETACHED:
// Save current config, and switch to the last device.
_session->device_event_object()->device_updated(); _session->device_event_object()->device_updated();
session_save(); session_save();
_view->hide_calibration(); _view->hide_calibration();
if (confirm_to_store_data()){
_is_auto_switch_device = true;
on_save();
}
else{
_session->set_default_device();
}
break;
case DSV_MSG_SAVE_COMPLETE:
if (_is_auto_switch_device){
_is_auto_switch_device = false;
_session->set_default_device();
if (_session->get_device()->is_new_device())
check_usb_device_speed();
}
else{
ds_device_handle devh = _sampling_bar->get_next_device_handle();
if (devh != NULL_HANDLE){
dsv_info("%s", "Auto switch to the selected device.");
_session->set_device(devh);
}
}
break; break;
} }
} }

View File

@ -144,6 +144,7 @@ public:
private: private:
void check_usb_device_speed(); void check_usb_device_speed();
void reset_all_view(); void reset_all_view();
bool confirm_to_store_data();
private: private:
//ISessionCallback //ISessionCallback
@ -217,9 +218,9 @@ private:
QTranslator _qtTrans; QTranslator _qtTrans;
QTranslator _myTrans; QTranslator _myTrans;
EventObject _event; EventObject _event;
bool _bFirstLoad;
SigSession *_session; SigSession *_session;
DeviceAgent *_device_agent; DeviceAgent *_device_agent;
bool _is_auto_switch_device;
}; };
} // namespace pv } // namespace pv

File diff suppressed because it is too large Load Diff

View File

@ -291,12 +291,11 @@ public:
void check_update(); void check_update();
void set_map_zoom(int index); void set_map_zoom(int index);
void auto_end(); void auto_end();
void store_session_data();
bool have_hardware_data(); bool have_hardware_data();
struct ds_device_info* get_device_list(int &out_count, int &actived_index); struct ds_device_info* get_device_list(int &out_count, int &actived_index);
void add_msg_listener(IMessageListener *ln); void add_msg_listener(IMessageListener *ln);
void broadcast_msg(int msg); void broadcast_msg(int msg);
void on_work_mode_changed(); bool switch_work_mode(int mode);
private: private:
bool exec_capture(); bool exec_capture();
@ -412,7 +411,6 @@ private:
bool _dso_feed; bool _dso_feed;
float _stop_scale; float _stop_scale;
bool _bClose; bool _bClose;
bool _is_auto_sel_device;
uint64_t _save_start; uint64_t _save_start;
uint64_t _save_end; uint64_t _save_end;
@ -422,9 +420,9 @@ private:
int _repeat_hold_prg; // The time sleep progress int _repeat_hold_prg; // The time sleep progress
bool _is_saving; bool _is_saving;
bool _is_instant; bool _is_instant;
bool _is_trig_new_device_msg;
int _device_status; int _device_status;
ISessionCallback *_callback; ISessionCallback *_callback;
DeviceAgent _device_agent; DeviceAgent _device_agent;
std::vector<IMessageListener*> _msg_listeners; std::vector<IMessageListener*> _msg_listeners;

View File

@ -354,22 +354,21 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
const sr_dev_inst *sdi = NULL; const sr_dev_inst *sdi = NULL;
char meta[300] = {0}; char meta[300] = {0};
/*
sdi = _session->get_device()->dev_inst();
sprintf(meta, "%s", "[version]\n"); str += meta; sprintf(meta, "%s", "[version]\n"); str += meta;
sprintf(meta, "version = %d\n", File_Version); str += meta; sprintf(meta, "version = %d\n", File_Version); str += meta;
sprintf(meta, "%s", "[header]\n"); str += meta; sprintf(meta, "%s", "[header]\n"); str += meta;
if (sdi->driver) { int mode = _session->get_device()->get_work_mode();
sprintf(meta, "driver = %s\n", sdi->driver->name); str += meta;
sprintf(meta, "device mode = %d\n", sdi->mode); str += meta; if (true) {
sprintf(meta, "driver = %s\n", _session->get_device()->driver_name().toLocal8Bit().data()); str += meta;
sprintf(meta, "device mode = %d\n", mode); str += meta;
} }
sprintf(meta, "capturefile = data\n"); str += meta; sprintf(meta, "capturefile = data\n"); str += meta;
sprintf(meta, "total samples = %" PRIu64 "\n", snapshot->get_sample_count()); str += meta; sprintf(meta, "total samples = %" PRIu64 "\n", snapshot->get_sample_count()); str += meta;
if (sdi->mode != LOGIC) { if (mode != LOGIC) {
sprintf(meta, "total probes = %d\n", snapshot->get_channel_num()); str += meta; sprintf(meta, "total probes = %d\n", snapshot->get_channel_num()); str += meta;
sprintf(meta, "total blocks = %d\n", snapshot->get_block_num()); str += meta; sprintf(meta, "total blocks = %d\n", snapshot->get_block_num()); str += meta;
} }
@ -377,7 +376,7 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
data::LogicSnapshot *logic_snapshot = NULL; data::LogicSnapshot *logic_snapshot = NULL;
if ((logic_snapshot = dynamic_cast<data::LogicSnapshot*>(snapshot))) { if ((logic_snapshot = dynamic_cast<data::LogicSnapshot*>(snapshot))) {
uint16_t to_save_probes = 0; uint16_t to_save_probes = 0;
for (l = sdi->channels; l; l = l->next) { for (l = _session->get_device()->get_channels(); l; l = l->next) {
probe = (struct sr_channel *)l->data; probe = (struct sr_channel *)l->data;
if (probe->enabled && logic_snapshot->has_data(probe->index)) if (probe->enabled && logic_snapshot->has_data(probe->index))
to_save_probes++; to_save_probes++;
@ -390,7 +389,7 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
sprintf(meta, "samplerate = %s\n", s); str += meta; sprintf(meta, "samplerate = %s\n", s); str += meta;
if (sdi->mode == DSO) { if (mode == DSO) {
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_TIMEBASE); gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_TIMEBASE);
if (gvar != NULL) { if (gvar != NULL) {
uint64_t tmp_u64 = g_variant_get_uint64(gvar); uint64_t tmp_u64 = g_variant_get_uint64(gvar);
@ -427,9 +426,11 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
sprintf(meta, "ref max = %d\n", tmp_u32); str += meta; sprintf(meta, "ref max = %d\n", tmp_u32); str += meta;
g_variant_unref(gvar); g_variant_unref(gvar);
} }
} else if (sdi->mode == LOGIC) { }
else if (mode == LOGIC) {
sprintf(meta, "trigger time = %lld\n", _session->get_session_time().toMSecsSinceEpoch()); str += meta; sprintf(meta, "trigger time = %lld\n", _session->get_session_time().toMSecsSinceEpoch()); str += meta;
} else if (sdi->mode == ANALOG) { }
else if (mode == ANALOG) {
data::AnalogSnapshot *analog_snapshot = NULL; data::AnalogSnapshot *analog_snapshot = NULL;
if ((analog_snapshot = dynamic_cast<data::AnalogSnapshot*>(snapshot))) { if ((analog_snapshot = dynamic_cast<data::AnalogSnapshot*>(snapshot))) {
uint8_t tmp_u8 = analog_snapshot->get_unit_bytes(); uint8_t tmp_u8 = analog_snapshot->get_unit_bytes();
@ -452,17 +453,17 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
probecnt = 0; probecnt = 0;
for (l = sdi->channels; l; l = l->next) { for (l = _session->get_device()->get_channels(); l; l = l->next) {
probe = (struct sr_channel *)l->data; probe = (struct sr_channel *)l->data;
if (!snapshot->has_data(probe->index)) if (!snapshot->has_data(probe->index))
continue; continue;
if (sdi->mode == LOGIC && !probe->enabled) if (mode == LOGIC && !probe->enabled)
continue; continue;
if (probe->name) if (probe->name)
{ {
int sigdex = (sdi->mode == LOGIC) ? probe->index : probecnt; int sigdex = (mode == LOGIC) ? probe->index : probecnt;
sprintf(meta, "probe%d = %s\n", sigdex, probe->name); sprintf(meta, "probe%d = %s\n", sigdex, probe->name);
str += meta; str += meta;
} }
@ -472,7 +473,7 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
str += meta; str += meta;
} }
if (sdi->mode == DSO) if (mode == DSO)
{ {
sprintf(meta, " enable%d = %d\n", probecnt, probe->enabled); sprintf(meta, " enable%d = %d\n", probecnt, probe->enabled);
str += meta; str += meta;
@ -487,7 +488,7 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
sprintf(meta, " vTrig%d = %d\n", probecnt, probe->trig_value); sprintf(meta, " vTrig%d = %d\n", probecnt, probe->trig_value);
str += meta; str += meta;
if (sr_status_get(sdi, &status, false) == SR_OK) if (_session->get_device()->get_device_status(status, false))
{ {
if (probe->index == 0) if (probe->index == 0)
{ {
@ -553,7 +554,7 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
} }
} }
} }
else if (sdi->mode == ANALOG) else if (mode == ANALOG)
{ {
sprintf(meta, " enable%d = %d\n", probecnt, probe->enabled); sprintf(meta, " enable%d = %d\n", probecnt, probe->enabled);
str += meta; str += meta;
@ -572,7 +573,6 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
} }
probecnt++; probecnt++;
} }
*/
return true; return true;
} }

View File

@ -135,6 +135,13 @@ void FileBar::on_actionOpen_triggered()
//open data file //open data file
AppConfig &app = AppConfig::Instance(); AppConfig &app = AppConfig::Instance();
if (_session->have_hardware_data()){
if (MsgBox::Confirm(tr("Save captured data?"))){
sig_save();
return;
}
}
// Show the dialog // Show the dialog
const QString file_name = QFileDialog::getOpenFileName( const QString file_name = QFileDialog::getOpenFileName(
this, this,
@ -234,8 +241,9 @@ void FileBar::on_actionCapture_triggered()
void FileBar::update_view_status() void FileBar::update_view_status()
{ {
bool bEnable = _session->is_working() == false; bool bEnable = _session->is_working() == false;
bool is_hardware = _session->get_device()->is_hardware();
_file_button.setEnabled(bEnable); _file_button.setEnabled(bEnable);
_menu_session->setEnabled(bEnable); _menu_session->setEnabled(bEnable && is_hardware);
} }
} // namespace toolbars } // namespace toolbars

View File

@ -36,6 +36,7 @@
#include "../dsvdef.h" #include "../dsvdef.h"
#include "../log.h" #include "../log.h"
#include "../deviceagent.h" #include "../deviceagent.h"
#include "../ui/msgbox.h"
using std::map; using std::map;
using std::max; using std::max;
@ -68,6 +69,8 @@ namespace pv
_is_run_as_instant = false; _is_run_as_instant = false;
_last_device_handle = NULL_HANDLE; _last_device_handle = NULL_HANDLE;
_last_device_index = -1;
_next_switch_device = NULL_HANDLE;
_session = session; _session = session;
_device_agent = _session->get_device(); _device_agent = _session->get_device();
@ -959,7 +962,20 @@ namespace pv
_session->session_save(); _session->session_save();
ds_device_handle devHandle = (ds_device_handle)_device_selector.currentData().toULongLong(); ds_device_handle devHandle = (ds_device_handle)_device_selector.currentData().toULongLong();
if (_session->have_hardware_data()){
if (MsgBox::Confirm(tr("Save captured data?")))
{
_updating_device_list = true;
_device_selector.setCurrentIndex(_last_device_index);
_updating_device_list = false;
_next_switch_device = devHandle; // Save end, auto switch to this device.
sig_store_session_data();
return;
}
}
_session->set_device(devHandle); _session->set_device(devHandle);
_last_device_index = _device_selector.currentIndex();
} }
void SamplingBar::enable_toggle(bool enable) void SamplingBar::enable_toggle(bool enable)
@ -1099,7 +1115,7 @@ namespace pv
_last_device_handle = cur_dev_handle; _last_device_handle = cur_dev_handle;
} }
_last_device_index = select_index;
int width = _device_selector.sizeHint().width(); int width = _device_selector.sizeHint().width();
_device_selector.setFixedWidth(min(width + 15, _device_selector.maximumWidth())); _device_selector.setFixedWidth(min(width + 15, _device_selector.maximumWidth()));
_device_selector.view()->setMinimumWidth(width + 30); _device_selector.view()->setMinimumWidth(width + 30);
@ -1153,5 +1169,12 @@ namespace pv
} }
} }
ds_device_handle SamplingBar::get_next_device_handle()
{
ds_device_handle h = _next_switch_device;
_next_switch_device = NULL_HANDLE;
return h;
}
} // namespace toolbars } // namespace toolbars
} // namespace pv } // namespace pv

View File

@ -86,6 +86,10 @@ namespace pv
void reload(); void reload();
void update_view_status(); void update_view_status();
void config_device(); void config_device();
ds_device_handle get_next_device_handle();
signals:
void sig_store_session_data();
private: private:
void changeEvent(QEvent *event); void changeEvent(QEvent *event);
@ -137,6 +141,8 @@ namespace pv
DeviceAgent *_device_agent; DeviceAgent *_device_agent;
ds_device_handle _last_device_handle; ds_device_handle _last_device_handle;
ds_device_handle _next_switch_device;
int _last_device_index;
bool _is_run_as_instant; bool _is_run_as_instant;
}; };

View File

@ -195,18 +195,20 @@ void DevMode::on_mode_change()
for(auto i = _mode_list.begin();i != _mode_list.end(); i++) for(auto i = _mode_list.begin();i != _mode_list.end(); i++)
{ {
if ((*i).first == action) { if ((*i).first == action){
if (_device_agent->get_work_mode() != (*i).second->mode) {
_session->set_repeat_mode(false); int mode = (*i).second->mode;
if (_device_agent->get_work_mode() == mode){
dsv_info("%s", "Current mode is set.");
break;
}
_session->stop_capture(); _session->stop_capture();
_session->set_repeat_mode(false);
_session->session_save(); _session->session_save();
_device_agent->set_config(NULL, NULL, _session->switch_work_mode(mode);
SR_CONF_DEVICE_MODE,
g_variant_new_int16((*i).second->mode));
_session->on_work_mode_changed(); auto *mode_name = get_mode_name(mode);
auto *mode_name = get_mode_name((*i).second->mode);
QString icon_fname = iconPath + "/" + QString::fromLocal8Bit(mode_name->_logo); QString icon_fname = iconPath + "/" + QString::fromLocal8Bit(mode_name->_logo);
_mode_btn->setIcon(QIcon(icon_fname)); _mode_btn->setIcon(QIcon(icon_fname));
@ -215,9 +217,6 @@ void DevMode::on_mode_change()
else else
_mode_btn->setText(mode_name->_name_en); _mode_btn->setText(mode_name->_name_en);
_session->broadcast_msg(DSV_MSG_DEVICE_MODE_CHANGED);
}
break; break;
} }
} }
@ -229,7 +228,7 @@ void DevMode::on_close()
assert(false); assert(false);
} }
if (_bFile && MsgBox::Confirm(tr("are you sure to close the device?"))){ if (_bFile && MsgBox::Confirm(tr("Are you sure to close the device?"))){
_session->close_file(_device_agent->handle()); _session->close_file(_device_agent->handle());
} }
} }

View File

@ -101,7 +101,8 @@ int Header::get_nameEditWidth()
pv::view::Trace* Header::get_mTrace(int &action, const QPoint &pt) pv::view::Trace* Header::get_mTrace(int &action, const QPoint &pt)
{ {
const int w = width(); const int w = width();
const auto &traces = _view.get_traces(ALL_VIEW); std::vector<Trace*> traces;
_view.get_traces(ALL_VIEW, traces);
for(auto &t : traces) for(auto &t : traces)
{ {
@ -124,7 +125,8 @@ void Header::paintEvent(QPaintEvent*)
style()->drawPrimitive(QStyle::PE_Widget, &o, &painter, this); style()->drawPrimitive(QStyle::PE_Widget, &o, &painter, this);
const int w = width(); const int w = width();
const auto &traces = _view.get_traces(ALL_VIEW); std::vector<Trace*> traces;
_view.get_traces(ALL_VIEW, traces);
const bool dragging = !_drag_traces.empty(); const bool dragging = !_drag_traces.empty();
QColor fore(QWidget::palette().color(QWidget::foregroundRole())); QColor fore(QWidget::palette().color(QWidget::foregroundRole()));
@ -143,7 +145,9 @@ void Header::mouseDoubleClickEvent(QMouseEvent *event)
{ {
assert(event); assert(event);
const auto &traces = _view.get_traces(ALL_VIEW); std::vector<Trace*> traces;
_view.get_traces(ALL_VIEW, traces);
if (event->button() & Qt::LeftButton) { if (event->button() & Qt::LeftButton) {
_mouse_down_point = event->pos(); _mouse_down_point = event->pos();
@ -166,7 +170,8 @@ void Header::mousePressEvent(QMouseEvent *event)
{ {
assert(event); assert(event);
const auto &traces = _view.get_traces(ALL_VIEW); std::vector<Trace*> traces;
_view.get_traces(ALL_VIEW, traces);
int action; int action;
const bool instant = _view.session().is_instant(); const bool instant = _view.session().is_instant();
@ -236,7 +241,8 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
_view.signals_changed(); _view.signals_changed();
_view.set_all_update(true); _view.set_all_update(true);
const auto &traces = _view.get_traces(ALL_VIEW); std::vector<Trace*> traces;
_view.get_traces(ALL_VIEW, traces);
for(auto &t : traces){ for(auto &t : traces){
t->select(false); t->select(false);
@ -288,7 +294,8 @@ void Header::wheelEvent(QWheelEvent *event)
if (isVertical) if (isVertical)
{ {
const auto &traces = _view.get_traces(ALL_VIEW); std::vector<Trace*> traces;
_view.get_traces(ALL_VIEW, traces);
// Vertical scrolling // Vertical scrolling
double shift = 0; double shift = 0;

View File

@ -366,7 +366,7 @@ void View::set_preScale_preOffset()
set_scale_offset(_preScale, _preOffset); set_scale_offset(_preScale, _preOffset);
} }
std::vector<Trace*> View::get_traces(int type) void View::get_traces(int type, std::vector<Trace*> &traces)
{ {
assert(_session); assert(_session);
@ -377,7 +377,6 @@ std::vector<Trace*> View::get_traces(int type)
const auto &spectrums = _session->get_spectrum_traces(); const auto &spectrums = _session->get_spectrum_traces();
std::vector<Trace*> traces;
for(auto &t : sigs) { for(auto &t : sigs) {
if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type) if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type)
traces.push_back(t); traces.push_back(t);
@ -409,7 +408,6 @@ std::vector<Trace*> View::get_traces(int type)
traces.push_back(math); traces.push_back(math);
stable_sort(traces.begin(), traces.end(), compare_trace_v_offsets); stable_sort(traces.begin(), traces.end(), compare_trace_v_offsets);
return traces;
} }
bool View::compare_trace_v_offsets(const Trace *a, bool View::compare_trace_v_offsets(const Trace *a,
@ -577,7 +575,8 @@ const QPoint& View::hover_point()
void View::normalize_layout() void View::normalize_layout()
{ {
auto traces = get_traces(ALL_VIEW); std::vector<Trace*> traces;
get_traces(ALL_VIEW, traces);
int v_min = INT_MAX; int v_min = INT_MAX;
for(auto &t : traces){ for(auto &t : traces){
@ -686,7 +685,10 @@ void View::signals_changed()
std::vector<Trace*> time_traces; std::vector<Trace*> time_traces;
std::vector<Trace*> fft_traces; std::vector<Trace*> fft_traces;
for(auto &t : get_traces(ALL_VIEW)) { std::vector<Trace*> traces;
get_traces(ALL_VIEW, traces);
for(auto &t : traces) {
if (_trace_view_map[t->get_type()] == TIME_VIEW) if (_trace_view_map[t->get_type()] == TIME_VIEW)
time_traces.push_back(t); time_traces.push_back(t);
else if (_trace_view_map[t->get_type()] == FFT_VIEW) else if (_trace_view_map[t->get_type()] == FFT_VIEW)
@ -845,7 +847,9 @@ int View::headerWidth()
{ {
int headerWidth = _header->get_nameEditWidth(); int headerWidth = _header->get_nameEditWidth();
const auto &traces = get_traces(ALL_VIEW); std::vector<Trace*> traces;
get_traces(ALL_VIEW, traces);
if (!traces.empty()) { if (!traces.empty()) {
for(auto &t : traces) for(auto &t : traces)
headerWidth = max(t->get_name_width() + t->get_leftWidth() + t->get_rightWidth(), headerWidth = max(t->get_name_width() + t->get_leftWidth() + t->get_rightWidth(),

View File

@ -144,7 +144,7 @@ public:
void set_scale_offset(double scale, int64_t offset); void set_scale_offset(double scale, int64_t offset);
void set_preScale_preOffset(); void set_preScale_preOffset();
std::vector<Trace*> get_traces(int type); void get_traces(int type, std::vector<Trace*> &traces);
/** /**
* Returns true if cursors are displayed. false otherwise. * Returns true if cursors are displayed. false otherwise.
@ -337,6 +337,9 @@ public:
void set_device(); void set_device();
void set_receive_len(uint64_t len); void set_receive_len(uint64_t len);
private:
private: private:
SigSession *_session; SigSession *_session;

View File

@ -113,8 +113,9 @@ Viewport::Viewport(View &parent, View_type type) :
int Viewport::get_total_height() int Viewport::get_total_height()
{ {
int h = 0; int h = 0;
std::vector<Trace*> traces;
_view.get_traces(_type, traces);
const auto &traces = _view.get_traces(_type);
for(auto &t : traces) { for(auto &t : traces) {
assert(t); assert(t);
h += (int)(t->get_totalHeight()); h += (int)(t->get_totalHeight());
@ -152,8 +153,8 @@ void Viewport::paintEvent(QPaintEvent *event)
QColor back(QWidget::palette().color(QWidget::backgroundRole())); QColor back(QWidget::palette().color(QWidget::backgroundRole()));
fore.setAlpha(View::ForeAlpha); fore.setAlpha(View::ForeAlpha);
_view.set_back(false); _view.set_back(false);
std::vector<Trace*> traces;
const auto &traces = _view.get_traces(_type); _view.get_traces(_type, traces);
for(auto &t : traces) for(auto &t : traces)
{ {
@ -200,7 +201,8 @@ void Viewport::paintEvent(QPaintEvent *event)
void Viewport::paintSignals(QPainter &p, QColor fore, QColor back) void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
{ {
const auto &traces = _view.get_traces(_type); std::vector<Trace*> traces;
_view.get_traces(_type, traces);
if (_view.session().get_device()->get_work_mode() == LOGIC) { if (_view.session().get_device()->get_work_mode() == LOGIC) {
@ -867,7 +869,8 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
_action_type = NO_ACTION; _action_type = NO_ACTION;
_dso_trig_moved = false; _dso_trig_moved = false;
const auto &traces = _view.get_traces(ALL_VIEW); std::vector<Trace*> traces;
_view.get_traces(ALL_VIEW, traces);
for(auto &t : traces){ for(auto &t : traces){
t->select(false); t->select(false);

View File

@ -433,7 +433,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
sr_dev_probes_free(sdi); sr_dev_probes_free(sdi);
setup_probes(sdi, num_probes); setup_probes(sdi, num_probes);
adjust_samplerate(devc); adjust_samplerate(devc);
sr_dbg("%s: setting mode to %d", __func__, sdi->mode); sr_info("%s: setting mode to %d", __func__, sdi->mode);
} }
else if (id == SR_CONF_PATTERN_MODE) { else if (id == SR_CONF_PATTERN_MODE) {
stropt = g_variant_get_string(data, NULL); stropt = g_variant_get_string(data, NULL);

View File

@ -157,11 +157,7 @@ SR_API int ds_lib_exit()
sr_info("Uninit %s.", SR_LIB_NAME); sr_info("Uninit %s.", SR_LIB_NAME);
if (ds_is_collecting()) ds_release_actived_device();
{
ds_stop_collect(); // stop collect.
}
sr_close_hotplug(lib_ctx.sr_ctx); sr_close_hotplug(lib_ctx.sr_ctx);
lib_ctx.lib_exit_flag = 1; // all thread to exit lib_ctx.lib_exit_flag = 1; // all thread to exit
@ -327,7 +323,7 @@ SR_API int ds_active_device(ds_device_handle handle)
if (ds_is_collecting()) if (ds_is_collecting())
{ {
sr_err("%s", "One device is collecting, switch device error."); sr_err("%s", "Error!The current device is collecting, can not switch it.");
return SR_ERR_CALL_STATUS; return SR_ERR_CALL_STATUS;
} }
@ -737,9 +733,6 @@ END:
*/ */
SR_API int ds_stop_collect() SR_API int ds_stop_collect()
{ {
struct sr_dev_inst *di;
di = lib_ctx.actived_device_instance;
sr_info("%s", "Stop collect."); sr_info("%s", "Stop collect.");
if (!ds_is_collecting()) if (!ds_is_collecting())
@ -756,7 +749,33 @@ SR_API int ds_stop_collect()
g_thread_join(lib_ctx.collect_thread); g_thread_join(lib_ctx.collect_thread);
lib_ctx.collect_thread = NULL; lib_ctx.collect_thread = NULL;
close_device_instance(di); return SR_OK;
}
/**
* Check if the device is collecting.
*/
SR_API int ds_is_collecting()
{
if (lib_ctx.collect_thread != NULL)
{
return 1;
}
return 0;
}
SR_API int ds_release_actived_device()
{
if (lib_ctx.actived_device_instance == NULL){
return SR_ERR_CALL_STATUS;
}
if (ds_is_collecting()){
ds_stop_collect();
}
sr_info("%s", "Release current actived device.");
close_device_instance(lib_ctx.actived_device_instance);
// Destroy current session. // Destroy current session.
sr_session_destroy(); sr_session_destroy();
@ -1027,18 +1046,6 @@ SR_PRIV int current_device_acquisition_stop()
return SR_ERR; return SR_ERR;
} }
/**
* Check if the device is collecting.
*/
SR_API int ds_is_collecting()
{
if (lib_ctx.collect_thread != NULL)
{
return 1;
}
return 0;
}
/**--------------------internal function end-----------*/ /**--------------------internal function end-----------*/
/**-------------------private function ---------------*/ /**-------------------private function ---------------*/
@ -1152,11 +1159,13 @@ static void hotplug_event_listen_callback(struct libusb_context *ctx, struct lib
lib_ctx.detach_device_handle); lib_ctx.detach_device_handle);
} }
if (lib_ctx.actived_device_instance != NULL && lib_ctx.actived_device_instance->handle == (ds_device_handle)dev && ds_is_collecting()) if (lib_ctx.actived_device_instance != NULL
&& lib_ctx.actived_device_instance->handle == (ds_device_handle)dev
&& ds_is_collecting())
{ {
sr_info("%s", "The actived device is detached, will stop collect thread."); sr_info("%s", "The actived device is detached, will stop collect thread.");
lib_ctx.is_stop_by_detached = 1; lib_ctx.is_stop_by_detached = 1;
ds_stop_collect(); ds_release_actived_device();
} }
/** /**

View File

@ -751,22 +751,22 @@ enum sr_config_option_id{
SR_CONF_LOGIC_ANALYZER = 10000, SR_CONF_LOGIC_ANALYZER = 10000,
/** The device can act as an oscilloscope. */ /** The device can act as an oscilloscope. */
SR_CONF_OSCILLOSCOPE, SR_CONF_OSCILLOSCOPE = 10001,
/** The device can act as a multimeter. */ /** The device can act as a multimeter. */
SR_CONF_MULTIMETER, SR_CONF_MULTIMETER = 10002,
/** The device is a demo device. */ /** The device is a demo device. */
SR_CONF_DEMO_DEV, SR_CONF_DEMO_DEV = 10003,
/** The device can act as a sound level meter. */ /** The device can act as a sound level meter. */
SR_CONF_SOUNDLEVELMETER, SR_CONF_SOUNDLEVELMETER = 10004,
/** The device can measure temperature. */ /** The device can measure temperature. */
SR_CONF_THERMOMETER, SR_CONF_THERMOMETER = 10005,
/** The device can measure humidity. */ /** The device can measure humidity. */
SR_CONF_HYGROMETER, SR_CONF_HYGROMETER = 10006,
/*--- Driver scan options -------------------------------------------*/ /*--- Driver scan options -------------------------------------------*/
@ -801,7 +801,7 @@ enum sr_config_option_id{
* This is always an optional parameter, since a driver typically * This is always an optional parameter, since a driver typically
* knows the speed at which the device wants to communicate. * knows the speed at which the device wants to communicate.
*/ */
SR_CONF_SERIALCOMM, SR_CONF_SERIALCOMM = 20001,
/*--- Device configuration ------------------------------------------*/ /*--- Device configuration ------------------------------------------*/
@ -809,222 +809,222 @@ enum sr_config_option_id{
SR_CONF_SAMPLERATE = 30000, SR_CONF_SAMPLERATE = 30000,
/** The device supports setting a pre/post-trigger capture ratio. */ /** The device supports setting a pre/post-trigger capture ratio. */
SR_CONF_CAPTURE_RATIO, SR_CONF_CAPTURE_RATIO = 30001,
/** */ /** */
SR_CONF_USB_SPEED, SR_CONF_USB_SPEED = 30002,
SR_CONF_USB30_SUPPORT, SR_CONF_USB30_SUPPORT = 30003,
SR_CONF_DEVICE_MODE, SR_CONF_DEVICE_MODE = 30004,
SR_CONF_INSTANT, SR_CONF_INSTANT = 30005,
SR_CONF_STATUS, SR_CONF_STATUS = 30006,
/** The device supports setting a pattern (pattern generator mode). */ /** The device supports setting a pattern (pattern generator mode). */
SR_CONF_PATTERN_MODE, SR_CONF_PATTERN_MODE = 30007,
/** The device supports Run Length Encoding. */ /** The device supports Run Length Encoding. */
SR_CONF_RLE, SR_CONF_RLE = 30008,
/** Need wait to uplad captured data */ /** Need wait to uplad captured data */
SR_CONF_WAIT_UPLOAD, SR_CONF_WAIT_UPLOAD = 30009,
/** The device supports setting trigger slope. */ /** The device supports setting trigger slope. */
SR_CONF_TRIGGER_SLOPE, SR_CONF_TRIGGER_SLOPE = 30010,
/** Trigger source. */ /** Trigger source. */
SR_CONF_TRIGGER_SOURCE, SR_CONF_TRIGGER_SOURCE = 30011,
/** Trigger channel */ /** Trigger channel */
SR_CONF_TRIGGER_CHANNEL, SR_CONF_TRIGGER_CHANNEL = 30012,
/** Trigger Value. */ /** Trigger Value. */
SR_CONF_TRIGGER_VALUE, SR_CONF_TRIGGER_VALUE = 30013,
/** Horizontal trigger position. */ /** Horizontal trigger position. */
SR_CONF_HORIZ_TRIGGERPOS, SR_CONF_HORIZ_TRIGGERPOS = 30014,
/** Trigger hold off time */ /** Trigger hold off time */
SR_CONF_TRIGGER_HOLDOFF, SR_CONF_TRIGGER_HOLDOFF = 30015,
/** Trigger Margin */ /** Trigger Margin */
SR_CONF_TRIGGER_MARGIN, SR_CONF_TRIGGER_MARGIN = 30016,
/** Buffer size. */ /** Buffer size. */
SR_CONF_BUFFERSIZE, SR_CONF_BUFFERSIZE = 30017,
/** Time base. */ /** Time base. */
SR_CONF_MAX_TIMEBASE, SR_CONF_MAX_TIMEBASE = 30018,
SR_CONF_MIN_TIMEBASE, SR_CONF_MIN_TIMEBASE = 30019,
SR_CONF_TIMEBASE, SR_CONF_TIMEBASE = 30020,
/** Filter. */ /** Filter. */
SR_CONF_FILTER, SR_CONF_FILTER = 30021,
/** DSO configure sync */ /** DSO configure sync */
SR_CONF_DSO_SYNC, SR_CONF_DSO_SYNC = 30022,
/** How many bits for each sample */ /** How many bits for each sample */
SR_CONF_UNIT_BITS, SR_CONF_UNIT_BITS = 30023,
SR_CONF_REF_MIN, SR_CONF_REF_MIN = 30024,
SR_CONF_REF_MAX, SR_CONF_REF_MAX = 30025,
/** Valid channel number */ /** Valid channel number */
SR_CONF_TOTAL_CH_NUM, SR_CONF_TOTAL_CH_NUM = 30026,
/** Valid channel number */ /** Valid channel number */
SR_CONF_VLD_CH_NUM, SR_CONF_VLD_CH_NUM = 30027,
/** 32 channel support */ /** 32 channel support */
SR_CONF_LA_CH32, SR_CONF_LA_CH32 = 30028,
/** Zero */ /** Zero */
SR_CONF_HAVE_ZERO, SR_CONF_HAVE_ZERO = 30029,
SR_CONF_ZERO, SR_CONF_ZERO = 30030,
SR_CONF_ZERO_SET, SR_CONF_ZERO_SET = 30031,
SR_CONF_ZERO_LOAD, SR_CONF_ZERO_LOAD = 30032,
SR_CONF_ZERO_DEFAULT, SR_CONF_ZERO_DEFAULT = 30033,
SR_CONF_ZERO_COMB_FGAIN, SR_CONF_ZERO_COMB_FGAIN = 30034,
SR_CONF_ZERO_COMB, SR_CONF_ZERO_COMB = 30035,
SR_CONF_VOCM, SR_CONF_VOCM = 30036,
SR_CONF_CALI, SR_CONF_CALI = 30037,
/** status for dso channel */ /** status for dso channel */
SR_CONF_STATUS_PERIOD, SR_CONF_STATUS_PERIOD = 30038,
SR_CONF_STATUS_PCNT, SR_CONF_STATUS_PCNT = 30039,
SR_CONF_STATUS_MAX, SR_CONF_STATUS_MAX = 30040,
SR_CONF_STATUS_MIN, SR_CONF_STATUS_MIN = 30041,
SR_CONF_STATUS_PLEN, SR_CONF_STATUS_PLEN = 30042,
SR_CONF_STATUS_LLEN, SR_CONF_STATUS_LLEN = 30043,
SR_CONF_STATUS_LEVEL, SR_CONF_STATUS_LEVEL = 30044,
SR_CONF_STATUS_PLEVEL, SR_CONF_STATUS_PLEVEL = 30045,
SR_CONF_STATUS_LOW, SR_CONF_STATUS_LOW = 30046,
SR_CONF_STATUS_HIGH, SR_CONF_STATUS_HIGH = 30047,
SR_CONF_STATUS_RLEN, SR_CONF_STATUS_RLEN = 30048,
SR_CONF_STATUS_FLEN, SR_CONF_STATUS_FLEN = 30049,
SR_CONF_STATUS_RMS, SR_CONF_STATUS_RMS = 30050,
SR_CONF_STATUS_MEAN, SR_CONF_STATUS_MEAN = 30051,
/** Stream */ /** Stream */
SR_CONF_STREAM, SR_CONF_STREAM = 30052,
/** DSO Roll */ /** DSO Roll */
SR_CONF_ROLL, SR_CONF_ROLL = 30053,
/** Test */ /** Test */
SR_CONF_TEST, SR_CONF_TEST = 30054,
SR_CONF_EEPROM, SR_CONF_EEPROM = 30055,
SR_CONF_TUNE, SR_CONF_TUNE = 30056,
SR_CONF_TUNE_SEL, SR_CONF_TUNE_SEL = 30057,
SR_CONF_EXTEND_ID, SR_CONF_EXTEND_ID = 30058,
SR_CONF_EXTEND_DATA, SR_CONF_EXTEND_DATA = 30059,
/** The device supports setting its sample interval, in ms. */ /** The device supports setting its sample interval, in ms. */
SR_CONF_SAMPLE_INTERVAL, SR_CONF_SAMPLE_INTERVAL = 30060,
/** Number of timebases, as related to SR_CONF_TIMEBASE. */ /** Number of timebases, as related to SR_CONF_TIMEBASE. */
SR_CONF_NUM_TIMEBASE, SR_CONF_NUM_TIMEBASE = 30061,
/** Number of vertical divisions, as related to SR_CONF_PROBE_VDIV. */ /** Number of vertical divisions, as related to SR_CONF_PROBE_VDIV. */
SR_CONF_NUM_VDIV, SR_CONF_NUM_VDIV = 30062,
/** clock type (internal/external) */ /** clock type (internal/external) */
SR_CONF_CLOCK_TYPE, SR_CONF_CLOCK_TYPE = 30063,
/** clock edge (posedge/negedge) */ /** clock edge (posedge/negedge) */
SR_CONF_CLOCK_EDGE, SR_CONF_CLOCK_EDGE = 30064,
/** Device operation mode */ /** Device operation mode */
SR_CONF_OPERATION_MODE, SR_CONF_OPERATION_MODE = 30065,
/** Device buffer options */ /** Device buffer options */
SR_CONF_BUFFER_OPTIONS, SR_CONF_BUFFER_OPTIONS = 30066,
/** Device channel mode */ /** Device channel mode */
SR_CONF_CHANNEL_MODE, SR_CONF_CHANNEL_MODE = 30067,
/** RLE compress support */ /** RLE compress support */
SR_CONF_RLE_SUPPORT, SR_CONF_RLE_SUPPORT = 30068,
/** Signal max height **/ /** Signal max height **/
SR_CONF_MAX_HEIGHT, SR_CONF_MAX_HEIGHT = 30069,
SR_CONF_MAX_HEIGHT_VALUE, SR_CONF_MAX_HEIGHT_VALUE = 30070,
/** Device sample threshold */ /** Device sample threshold */
SR_CONF_THRESHOLD, SR_CONF_THRESHOLD = 30071,
SR_CONF_VTH, SR_CONF_VTH = 30072,
/** Hardware capacity **/ /** Hardware capacity **/
SR_CONF_MAX_DSO_SAMPLERATE, SR_CONF_MAX_DSO_SAMPLERATE = 30073,
SR_CONF_MAX_DSO_SAMPLELIMITS, SR_CONF_MAX_DSO_SAMPLELIMITS = 30074,
SR_CONF_HW_DEPTH, SR_CONF_HW_DEPTH = 30075,
/** bandwidth */ /** bandwidth */
SR_CONF_BANDWIDTH, SR_CONF_BANDWIDTH = 30076,
SR_CONF_BANDWIDTH_LIMIT, SR_CONF_BANDWIDTH_LIMIT = 30077,
/*--- Probe configuration -------------------------------------------*/ /*--- Probe configuration -------------------------------------------*/
/** Probe options */ /** Probe options */
SR_CONF_PROBE_CONFIGS, SR_CONF_PROBE_CONFIGS = 30078,
/** Probe options */ /** Probe options */
SR_CONF_PROBE_SESSIONS, SR_CONF_PROBE_SESSIONS = 30079,
/** Enable */ /** Enable */
SR_CONF_PROBE_EN, SR_CONF_PROBE_EN = 30080,
/** Coupling */ /** Coupling */
SR_CONF_PROBE_COUPLING, SR_CONF_PROBE_COUPLING = 30081,
/** Volts/div */ /** Volts/div */
SR_CONF_PROBE_VDIV, SR_CONF_PROBE_VDIV = 30082,
/** Factor */ /** Factor */
SR_CONF_PROBE_FACTOR, SR_CONF_PROBE_FACTOR = 30083,
/** Mapping */ /** Mapping */
SR_CONF_PROBE_MAP_DEFAULT, SR_CONF_PROBE_MAP_DEFAULT = 30084,
SR_CONF_PROBE_MAP_UNIT, SR_CONF_PROBE_MAP_UNIT = 30085,
SR_CONF_PROBE_MAP_MIN, SR_CONF_PROBE_MAP_MIN = 30086,
SR_CONF_PROBE_MAP_MAX, SR_CONF_PROBE_MAP_MAX = 30087,
/** Vertical offset */ /** Vertical offset */
SR_CONF_PROBE_OFFSET, SR_CONF_PROBE_OFFSET = 30088,
SR_CONF_PROBE_HW_OFFSET, SR_CONF_PROBE_HW_OFFSET = 30089,
SR_CONF_PROBE_PREOFF, SR_CONF_PROBE_PREOFF = 30090,
SR_CONF_PROBE_PREOFF_DEFAULT, SR_CONF_PROBE_PREOFF_DEFAULT = 30091,
SR_CONF_PROBE_PREOFF_MARGIN, SR_CONF_PROBE_PREOFF_MARGIN = 30092,
/** VGain */ /** VGain */
SR_CONF_PROBE_VGAIN, SR_CONF_PROBE_VGAIN = 30093,
SR_CONF_PROBE_VGAIN_DEFAULT, SR_CONF_PROBE_VGAIN_DEFAULT = 30094,
SR_CONF_PROBE_VGAIN_RANGE, SR_CONF_PROBE_VGAIN_RANGE = 30095,
SR_CONF_PROBE_COMB_COMP_EN, SR_CONF_PROBE_COMB_COMP_EN = 30096,
SR_CONF_PROBE_COMB_COMP, SR_CONF_PROBE_COMB_COMP = 30097,
/*--- Special stuff -------------------------------------------------*/ /*--- Special stuff -------------------------------------------------*/
/** Device options for a particular device. */ /** Device options for a particular device. */
SR_CONF_DEVICE_OPTIONS, SR_CONF_DEVICE_OPTIONS = 30098,
/** Sessions */ /** Sessions */
SR_CONF_DEVICE_SESSIONS, SR_CONF_DEVICE_SESSIONS = 30099,
/** Session filename. */ /** Session filename. */
SR_CONF_SESSIONFILE, SR_CONF_SESSIONFILE = 30100,
/** The device supports specifying a capturefile to inject. */ /** The device supports specifying a capturefile to inject. */
SR_CONF_CAPTUREFILE, SR_CONF_CAPTUREFILE = 30101,
/** Session file version */ /** Session file version */
SR_CONF_FILE_VERSION, SR_CONF_FILE_VERSION = 30102,
/** The device supports setting the number of probes. */ /** The device supports setting the number of probes. */
SR_CONF_CAPTURE_NUM_PROBES, SR_CONF_CAPTURE_NUM_PROBES = 30103,
/** The device supports setting the number of data blocks. */ /** The device supports setting the number of data blocks. */
SR_CONF_NUM_BLOCKS, SR_CONF_NUM_BLOCKS = 30104,
/** language (string code) **/ /** language (string code) **/
SR_CONF_LANGUAGE, SR_CONF_LANGUAGE = 30105,
/*--- Acquisition modes ---------------------------------------------*/ /*--- Acquisition modes ---------------------------------------------*/
@ -1038,39 +1038,39 @@ enum sr_config_option_id{
* The device supports setting a sample number limit (how many * The device supports setting a sample number limit (how many
* samples should be acquired). * samples should be acquired).
*/ */
SR_CONF_LIMIT_SAMPLES, SR_CONF_LIMIT_SAMPLES = 50001,
/** /**
* Absolute time record for session driver * Absolute time record for session driver
*/ */
SR_CONF_TRIGGER_TIME, SR_CONF_TRIGGER_TIME = 50002,
/** /**
* Trigger position for session driver * Trigger position for session driver
*/ */
SR_CONF_TRIGGER_POS, SR_CONF_TRIGGER_POS = 50003,
/** /**
* The actual sample count received * The actual sample count received
*/ */
SR_CONF_ACTUAL_SAMPLES, SR_CONF_ACTUAL_SAMPLES = 50004,
/** /**
* The device supports setting a frame limit (how many * The device supports setting a frame limit (how many
* frames should be acquired). * frames should be acquired).
*/ */
SR_CONF_LIMIT_FRAMES, SR_CONF_LIMIT_FRAMES = 50005,
/** /**
* The device supports continuous sampling. Neither a time limit * The device supports continuous sampling. Neither a time limit
* nor a sample number limit has to be supplied, it will just acquire * nor a sample number limit has to be supplied, it will just acquire
* samples continuously, until explicitly stopped by a certain command. * samples continuously, until explicitly stopped by a certain command.
*/ */
SR_CONF_CONTINUOUS, SR_CONF_CONTINUOUS = 50006,
/** The device has internal storage, into which data is logged. This /** The device has internal storage, into which data is logged. This
* starts or stops the internal logging. */ * starts or stops the internal logging. */
SR_CONF_DATALOG, SR_CONF_DATALOG = 50007,
}; };
/** Device instance status. */ /** Device instance status. */
@ -1410,6 +1410,11 @@ SR_API int ds_stop_collect();
*/ */
SR_API int ds_is_collecting(); SR_API int ds_is_collecting();
/**
* Close the actived device.
*/
SR_API int ds_release_actived_device();
/*---config -----------------------------------------------*/ /*---config -----------------------------------------------*/
SR_API int ds_get_actived_device_config(const struct sr_channel *ch, SR_API int ds_get_actived_device_config(const struct sr_channel *ch,
const struct sr_channel_group *cg, const struct sr_channel_group *cg,