mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-23 13:42:55 +08:00
Code refactoring 18
This commit is contained in:
parent
787d9b1378
commit
ec1b385ba8
@ -26,22 +26,9 @@
|
||||
#include <stdint.h>
|
||||
#include <libsigrok.h>
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
namespace pv{
|
||||
// class SigSession;
|
||||
}
|
||||
|
||||
class DeviceAgent: public QObject
|
||||
class DeviceAgent
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
// friend class SigSession;
|
||||
|
||||
signals:
|
||||
void device_updated();
|
||||
void config_changed();
|
||||
|
||||
public:
|
||||
DeviceAgent();
|
||||
|
||||
|
@ -997,7 +997,6 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod
|
||||
_selected_protocol_id = QString(dec->id);
|
||||
this->on_add_protocol();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace dock
|
||||
} // namespace pv
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "../data/decodermodel.h"
|
||||
#include "protocolitemlayer.h"
|
||||
#include "keywordlineedit.h"
|
||||
#include "searchcombobox.h"
|
||||
#include "searchcombobox.h"
|
||||
|
||||
struct DecoderInfoItem{
|
||||
void *_data_handle; //srd_decoder* type
|
||||
@ -70,7 +70,8 @@ namespace dock {
|
||||
class ProtocolDock : public QScrollArea,
|
||||
public IProtocolItemLayerCallback,
|
||||
public IKeywordActive,
|
||||
public ISearchItemClick
|
||||
public ISearchItemClick,
|
||||
public IMessageListener
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -105,6 +106,7 @@ private:
|
||||
|
||||
//ISearchItemClick
|
||||
void OnItemClick(void *sender, void *data_handle);
|
||||
|
||||
|
||||
signals:
|
||||
void protocol_updated();
|
||||
|
@ -955,6 +955,7 @@ void TriggerDock::OnMessage(int msg)
|
||||
{
|
||||
case DSV_MSG_DEVICE_OPTIONS_UPDATED:
|
||||
case DSV_MSG_DEVICE_DURATION_UPDATED:
|
||||
case DSV_MSG_CURRENT_DEVICE_CHANGED:
|
||||
device_updated();
|
||||
break;
|
||||
case DSV_MSG_COLLECT_START_PREV:
|
||||
|
@ -69,11 +69,15 @@ public:
|
||||
#define DSV_MSG_COLLECT_START 5002
|
||||
#define DSV_MSG_COLLECT_END_PREV 5003
|
||||
#define DSV_MSG_COLLECT_END 5004
|
||||
|
||||
#define DSV_MSG_BEGIN_DEVICE_OPTIONS 6001 //Begin show device options dialog.
|
||||
#define DSV_MSG_END_DEVICE_OPTIONS 6002
|
||||
#define DSV_MSG_DEVICE_OPTIONS_UPDATED 6003
|
||||
#define DSV_MSG_DEVICE_DURATION_UPDATED 6004
|
||||
#define DSV_MSG_DEVICE_MODE_CHANGED 6005
|
||||
#define DSV_MSG_CURRENT_DEVICE_CHANGE_PREV 6006
|
||||
#define DSV_MSG_CURRENT_DEVICE_CHANGED 6007
|
||||
#define DSV_MSG_NEW_USB_DEVICE 6008
|
||||
|
||||
class IMessageListener
|
||||
{
|
||||
|
@ -230,7 +230,6 @@ namespace pv
|
||||
// event
|
||||
connect(&_event, SIGNAL(capture_state_changed(int)), this, SLOT(on_capture_state_changed(int)));
|
||||
connect(&_event, SIGNAL(session_error()), this, SLOT(on_session_error()));
|
||||
connect(&_event, SIGNAL(show_error(QString)), this, SLOT(on_show_error(QString)));
|
||||
connect(&_event, SIGNAL(signals_changed()), this, SLOT(on_signals_changed()));
|
||||
connect(&_event, SIGNAL(receive_trigger(quint64)), this, SLOT(on_receive_trigger(quint64)));
|
||||
connect(&_event, SIGNAL(frame_ended()), this, SLOT(on_frame_ended()));
|
||||
@ -291,57 +290,6 @@ namespace pv
|
||||
assert(_sampling_bar);
|
||||
|
||||
/*
|
||||
|
||||
if (_msg)
|
||||
_msg->close();
|
||||
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
|
||||
switchLanguage(app._frameOptions.language);
|
||||
_session->stop_capture();
|
||||
_view->reload();
|
||||
_trigger_widget->device_updated();
|
||||
|
||||
_protocol_widget->del_all_protocol();
|
||||
|
||||
_trig_bar->reload();
|
||||
|
||||
DevInst *selected_device = _device_agent;
|
||||
_device_manager.add_device(selected_device);
|
||||
_session->init_signals();
|
||||
_sampling_bar->set_device_list(_device_manager.devices(), selected_device);
|
||||
|
||||
File *file_dev = NULL;
|
||||
if((file_dev = dynamic_cast<File*>(selected_device))) {
|
||||
// check version
|
||||
if (selected_device->dev_inst()->mode == LOGIC) {
|
||||
GVariant* gvar = selected_device->get_config(NULL, NULL, SR_CONF_FILE_VERSION);
|
||||
if (gvar != NULL) {
|
||||
int16_t version = g_variant_get_int16(gvar);
|
||||
g_variant_unref(gvar);
|
||||
if (version == 1) {
|
||||
show_error(tr("Current loading file has an old format. "
|
||||
"This will lead to a slow loading speed. "
|
||||
"Please resave it after loaded."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// load decoders
|
||||
StoreSession ss(_session);
|
||||
bool bFlag = ss.load_decoders(_protocol_widget, file_dev->get_decoders());
|
||||
|
||||
// load session
|
||||
load_session_json(file_dev->get_session(), true, !bFlag);
|
||||
|
||||
// load data
|
||||
const QString errorMessage(
|
||||
QString(tr("Failed to capture file data!")));
|
||||
_session->start_capture(true);
|
||||
}
|
||||
|
||||
if (!selected_device->name().contains("virtual")) {
|
||||
_file_bar->set_settings_en(true);
|
||||
_logo_bar->dsl_connected(true);
|
||||
@ -374,32 +322,9 @@ namespace pv
|
||||
on_load_session(ses_name);
|
||||
}
|
||||
}
|
||||
_sampling_bar->reload();
|
||||
_view->status_clear();
|
||||
_trigger_widget->init();
|
||||
_dso_trigger_widget->init();
|
||||
_measure_widget->reload();
|
||||
|
||||
|
||||
// USB device speed check
|
||||
if (!selected_device->name().contains("virtual")) {
|
||||
int usb_speed = LIBUSB_SPEED_HIGH;
|
||||
GVariant *gvar = selected_device->get_config(NULL, NULL, SR_CONF_USB_SPEED);
|
||||
if (gvar != NULL) {
|
||||
usb_speed = g_variant_get_int32(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
|
||||
bool usb30_support = false;
|
||||
gvar = selected_device->get_config(NULL, NULL, SR_CONF_USB30_SUPPORT);
|
||||
if (gvar != NULL) {
|
||||
usb30_support = g_variant_get_boolean(gvar);
|
||||
g_variant_unref(gvar);
|
||||
|
||||
if (usb30_support && usb_speed == LIBUSB_SPEED_HIGH)
|
||||
show_error(tr("Plug it into a USB 2.0 port will seriously affect its performance."
|
||||
"Please replug it into a USB 3.0 port."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_trig_bar->restore_status();
|
||||
|
||||
@ -439,22 +364,16 @@ namespace pv
|
||||
}
|
||||
|
||||
void MainWindow::show_error(QString error)
|
||||
{
|
||||
_event.show_error(error); // safe call
|
||||
}
|
||||
|
||||
void MainWindow::on_show_error(QString error)
|
||||
{
|
||||
{
|
||||
MsgBox::Show(NULL, error.toStdString().c_str(), this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// void MainWindow::on_device_detach()
|
||||
//{
|
||||
/*
|
||||
|
||||
_device_agent->device_updated();
|
||||
//_session->stop_hot_plug_proc();
|
||||
|
||||
_session->set_repeating(false);
|
||||
_session->stop_capture();
|
||||
@ -513,25 +432,22 @@ namespace pv
|
||||
|
||||
switch (_session->get_error())
|
||||
{
|
||||
case SigSession::Hw_err:
|
||||
_session->set_repeating(false);
|
||||
case SigSession::Hw_err:
|
||||
_session->stop_capture();
|
||||
title = tr("Hardware Operation Failed");
|
||||
details = tr("Please replug device to refresh hardware configuration!");
|
||||
break;
|
||||
case SigSession::Malloc_err:
|
||||
_session->set_repeating(false);
|
||||
case SigSession::Malloc_err:
|
||||
_session->stop_capture();
|
||||
title = tr("Malloc Error");
|
||||
details = tr("Memory is not enough for this sample!\nPlease reduce the sample depth!");
|
||||
break;
|
||||
case SigSession::Test_data_err:
|
||||
_session->set_repeating(false);
|
||||
case SigSession::Test_data_err:
|
||||
_session->stop_capture();
|
||||
_sampling_bar->set_sampling(false);
|
||||
_session->capture_state_changed(SigSession::Stopped);
|
||||
_sampling_bar->set_sampling(false);
|
||||
title = tr("Data Error");
|
||||
error_pattern = _session->get_error_pattern();
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
if (error_pattern & 0x01)
|
||||
@ -549,8 +465,7 @@ namespace pv
|
||||
details = tr("the content of received packet are not expected!");
|
||||
_session->refresh(0);
|
||||
break;
|
||||
case SigSession::Data_overflow:
|
||||
_session->set_repeating(false);
|
||||
case SigSession::Data_overflow:
|
||||
_session->stop_capture();
|
||||
title = tr("Data Overflow");
|
||||
details = tr("USB bandwidth can not support current sample rate! \nPlease reduce the sample rate!");
|
||||
@ -1450,6 +1365,30 @@ namespace pv
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::check_usb_device_speed()
|
||||
{
|
||||
// USB device speed check
|
||||
if (_device_agent->is_hardware()) {
|
||||
int usb_speed = LIBUSB_SPEED_HIGH;
|
||||
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_USB_SPEED);
|
||||
if (gvar != NULL) {
|
||||
usb_speed = g_variant_get_int32(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
|
||||
bool usb30_support = false;
|
||||
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_USB30_SUPPORT);
|
||||
if (gvar != NULL) {
|
||||
usb30_support = g_variant_get_boolean(gvar);
|
||||
g_variant_unref(gvar);
|
||||
|
||||
if (usb30_support && usb_speed == LIBUSB_SPEED_HIGH)
|
||||
show_error(tr("Plug it into a USB 2.0 port will seriously affect its performance."
|
||||
"Please replug it into a USB 3.0 port."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::trigger_message(int msg)
|
||||
{
|
||||
_event.trigger_message(msg);
|
||||
@ -1462,6 +1401,40 @@ namespace pv
|
||||
|
||||
void MainWindow::OnMessage(int msg)
|
||||
{
|
||||
}
|
||||
switch (msg)
|
||||
{
|
||||
case DSV_MSG_DEVICE_LIST_UPDATE:
|
||||
_sampling_bar->update_device_list();
|
||||
break;
|
||||
|
||||
case DSV_MSG_COLLECT_START:
|
||||
_sampling_bar->set_sampling(false);
|
||||
break;
|
||||
|
||||
case DSV_MSG_COLLECT_END:
|
||||
_sampling_bar->set_sampling(true);
|
||||
break;
|
||||
case DSV_MSG_NEW_USB_DEVICE:
|
||||
check_usb_device_speed();
|
||||
break;
|
||||
|
||||
case DSV_MSG_CURRENT_DEVICE_CHANGED:
|
||||
if (_msg != NULL)
|
||||
_msg->close();
|
||||
|
||||
_sampling_bar->update_device_list();
|
||||
_trig_bar->reload();
|
||||
_sampling_bar->reload();
|
||||
_view->status_clear();
|
||||
_trigger_widget->init();
|
||||
_dso_trigger_widget->init();
|
||||
_measure_widget->reload();
|
||||
break;
|
||||
|
||||
case DSV_MSG_CURRENT_DEVICE_CHANGE_PREV:
|
||||
_protocol_widget->del_all_protocol();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace pv
|
||||
|
@ -119,8 +119,7 @@ private slots:
|
||||
|
||||
void on_capture_state_changed(int state);
|
||||
void on_data_updated();
|
||||
|
||||
void on_show_error(QString str);
|
||||
|
||||
void on_session_error();
|
||||
void on_signals_changed();
|
||||
void on_receive_trigger(quint64 trigger_pos);
|
||||
@ -144,6 +143,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
void check_usb_device_speed();
|
||||
|
||||
private:
|
||||
//ISessionCallback
|
||||
|
@ -70,23 +70,21 @@ SigSession::SigSession()
|
||||
{
|
||||
// TODO: This should not be necessary
|
||||
_session = this;
|
||||
_group_cnt = 0;
|
||||
_bHotplugStop = false;
|
||||
_group_cnt = 0;
|
||||
|
||||
_map_zoom = 0;
|
||||
_repeat_hold_prg = 0;
|
||||
_repeating = false;
|
||||
_repeat_intvl = 1;
|
||||
_run_mode = Single;
|
||||
_repeat_intvl = 1;
|
||||
_error = No_err;
|
||||
_bInstant = false;
|
||||
_is_instant = false;
|
||||
_is_working = false;
|
||||
_is_repeat_mode = false;
|
||||
_is_saving = false;
|
||||
|
||||
_noData_cnt = 0;
|
||||
_data_lock = false;
|
||||
_data_updated = false;
|
||||
_active_last_device_flag = false;
|
||||
_bSaving = false;
|
||||
_bRepeatMode = false;
|
||||
_active_last_device_flag = false;
|
||||
|
||||
this->add_msg_listener(this);
|
||||
|
||||
@ -94,10 +92,9 @@ SigSession::SigSession()
|
||||
|
||||
_lissajous_trace = NULL;
|
||||
_math_trace = NULL;
|
||||
|
||||
_dso_feed = false;
|
||||
_stop_scale = 1;
|
||||
_bDecodeRunning = false;
|
||||
_is_decoding = false;
|
||||
_bClose = false;
|
||||
_callback = NULL;
|
||||
|
||||
@ -110,6 +107,7 @@ SigSession::SigSession()
|
||||
|
||||
_feed_timer.Stop();
|
||||
_feed_timer.SetCallback(std::bind(&SigSession::feed_timeout, this));
|
||||
_repeate_timer.SetCallback(std::bind(&SigSession::repeat_capture_wait_timout, this));
|
||||
}
|
||||
|
||||
SigSession::SigSession(SigSession &o)
|
||||
@ -121,11 +119,159 @@ SigSession::~SigSession()
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t SigSession::cur_samplelimits()
|
||||
bool SigSession::init()
|
||||
{
|
||||
return _cur_samplelimits;
|
||||
ds_log_set_context(dsv_log_context());
|
||||
|
||||
ds_set_event_callback(device_lib_event_callback);
|
||||
|
||||
ds_set_datafeed_callback(data_feed_callback);
|
||||
|
||||
// firmware resource directory
|
||||
QString resdir = GetResourceDir();
|
||||
std::string res_path = pv::path::ToUnicodePath(resdir);
|
||||
ds_set_firmware_resource_dir(res_path.c_str());
|
||||
|
||||
if (ds_lib_init() != SR_OK)
|
||||
{
|
||||
dsv_err("%s", "DSView run ERROR: collect lib init failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SigSession::uninit()
|
||||
{
|
||||
this->Close();
|
||||
|
||||
ds_lib_exit();
|
||||
}
|
||||
|
||||
bool SigSession::set_default_device()
|
||||
{
|
||||
assert(!_is_saving);
|
||||
assert(!_is_working);
|
||||
|
||||
struct ds_device_info *array = NULL;
|
||||
int count = 0;
|
||||
|
||||
if (ds_get_device_list(&array, &count) != SR_OK)
|
||||
{
|
||||
dsv_err("%s", "Get device list error!");
|
||||
return false;
|
||||
}
|
||||
if (count < 1 || array == NULL)
|
||||
{
|
||||
dsv_err("%s", "SigSession::set_default_device, Device list is empty!");
|
||||
return false;
|
||||
}
|
||||
|
||||
struct ds_device_info *dev = (array + count - 1);
|
||||
ds_device_handle dev_handle = dev->handle;
|
||||
|
||||
free(array);
|
||||
|
||||
if (set_device(dev_handle)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SigSession::set_device(ds_device_handle dev_handle)
|
||||
{
|
||||
assert(!_is_saving);
|
||||
assert(!_is_working);
|
||||
|
||||
if (_callback != NULL){
|
||||
_callback->trigger_message(DSV_MSG_CURRENT_DEVICE_CHANGE_PREV);
|
||||
}
|
||||
|
||||
if (ds_active_device(dev_handle) != SR_OK){
|
||||
dsv_err("%s", "Switch device error!");
|
||||
return false;
|
||||
}
|
||||
_device_agent.update();
|
||||
|
||||
init_signals();
|
||||
|
||||
RELEASE_ARRAY(_group_traces);
|
||||
clear_all_decoder();
|
||||
|
||||
if (_device_agent.is_file())
|
||||
dsv_info("%s\"%s\"", "Switch to file: ", _device_agent.name().toUtf8().data());
|
||||
else
|
||||
dsv_info("%s\"%s\"", "Switch to device: ", _device_agent.name().toUtf8().data());
|
||||
|
||||
_cur_snap_samplerate = _device_agent.get_sample_rate();
|
||||
_cur_samplelimits = _device_agent.get_sample_limit();
|
||||
|
||||
if (_device_agent.get_work_mode() == DSO)
|
||||
_is_repeat_mode = true;
|
||||
else
|
||||
_is_repeat_mode = false;
|
||||
|
||||
// The current device changed.
|
||||
_callback->trigger_message(DSV_MSG_CURRENT_DEVICE_CHANGED);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool SigSession::set_file(QString name)
|
||||
{
|
||||
assert(!_is_saving);
|
||||
assert(!_is_working);
|
||||
|
||||
dsv_info("Load file:\"%s\"", name.toUtf8().data());
|
||||
|
||||
std::string path = path::ToUnicodePath(name);
|
||||
|
||||
if (ds_device_from_file(path.c_str()) != SR_OK)
|
||||
{
|
||||
dsv_err("%s", "Load file error!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return set_default_device();
|
||||
}
|
||||
|
||||
void SigSession::close_file(ds_device_handle dev_handle)
|
||||
{
|
||||
assert(!_is_saving);
|
||||
assert(!_is_working);
|
||||
|
||||
if (ds_remove_device(dev_handle) != SR_OK){
|
||||
dsv_err("%s", "Remove virtual deivice error!");
|
||||
}
|
||||
stop_capture();
|
||||
set_default_device();
|
||||
}
|
||||
|
||||
|
||||
bool SigSession::have_hardware_data()
|
||||
{
|
||||
if (_device_agent.have_instance() && _device_agent.is_hardware()){
|
||||
Snapshot *data = get_signal_snapshot();
|
||||
return data->have_data();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
struct ds_device_info* SigSession::get_device_list(int &out_count, int &actived_index)
|
||||
{
|
||||
out_count = 0;
|
||||
actived_index = -1;
|
||||
struct ds_device_info *array = NULL;
|
||||
|
||||
if (ds_get_device_list(&array, &out_count) == SR_OK)
|
||||
{
|
||||
actived_index = ds_get_actived_device_index();
|
||||
return array;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint64_t SigSession::cur_samplerate()
|
||||
{
|
||||
// samplerate for current viewport
|
||||
@ -196,12 +342,9 @@ void SigSession::set_cur_samplelimits(uint64_t samplelimits)
|
||||
}
|
||||
|
||||
void SigSession::capture_init()
|
||||
{
|
||||
if (!_bInstant)
|
||||
set_repeating(get_run_mode() == Repetitive);
|
||||
|
||||
{
|
||||
// update instant setting
|
||||
_device_agent.set_config(NULL, NULL, SR_CONF_INSTANT, g_variant_new_boolean(_bInstant));
|
||||
_device_agent.set_config(NULL, NULL, SR_CONF_INSTANT, g_variant_new_boolean(_is_instant));
|
||||
_callback->update_capture();
|
||||
|
||||
set_cur_snap_samplerate(_device_agent.get_sample_rate());
|
||||
@ -266,32 +409,37 @@ void SigSession::container_init()
|
||||
if (_math_trace)
|
||||
_math_trace->get_math_stack()->init();
|
||||
|
||||
|
||||
// DecoderModel
|
||||
//pv::data::DecoderModel *decoder_model = get_decoder_model();
|
||||
//decoder_model->setDecoderStack(NULL);
|
||||
// DecoderStack
|
||||
for(auto &d : _decode_traces)
|
||||
{
|
||||
d->decoder()->init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SigSession::start_capture(bool instant)
|
||||
{
|
||||
// Check that a device instance has been selected.
|
||||
void SigSession::start_capture(bool instant)
|
||||
{
|
||||
assert(!_is_working);
|
||||
assert(_callback);
|
||||
|
||||
// Check that a device instance has been selected.
|
||||
if (_device_agent.have_instance() == false) {
|
||||
dsv_err("%s", "No device selected");
|
||||
capture_state_changed(SigSession::Stopped);
|
||||
dsv_err("%s", "No device selected");
|
||||
return;
|
||||
}
|
||||
|
||||
// update setting
|
||||
if (_device_agent.is_file())
|
||||
_bInstant = true;
|
||||
_is_instant = true;
|
||||
else
|
||||
_bInstant = instant;
|
||||
_is_instant = instant;
|
||||
}
|
||||
|
||||
void SigSession::exec_capture()
|
||||
{
|
||||
if (_device_agent.is_running()){
|
||||
dsv_err("%s", "Device is running.");
|
||||
assert(false);
|
||||
}
|
||||
|
||||
_callback->trigger_message(DSV_MSG_COLLECT_START_PREV);
|
||||
|
||||
@ -299,9 +447,6 @@ void SigSession::start_capture(bool instant)
|
||||
int run_dex = 0;
|
||||
clear_all_decode_task(run_dex);
|
||||
|
||||
// stop previous capture
|
||||
stop_capture();
|
||||
|
||||
// reset measure of dso signal
|
||||
for(auto &s : _signals)
|
||||
{
|
||||
@ -314,31 +459,50 @@ void SigSession::start_capture(bool instant)
|
||||
|
||||
if (_device_agent.have_enabled_channel() == false){
|
||||
_callback->show_error("No probes enabled.");
|
||||
data_updated();
|
||||
set_repeating(false);
|
||||
capture_state_changed(SigSession::Stopped);
|
||||
data_updated();
|
||||
_is_working = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_device_agent.start() == false)
|
||||
{
|
||||
dsv_err("%s", "Start collect error!");
|
||||
}
|
||||
|
||||
_is_working = true;
|
||||
}
|
||||
|
||||
void SigSession::stop_capture()
|
||||
{
|
||||
_callback->trigger_message(DSV_MSG_COLLECT_END_PREV);
|
||||
|
||||
{
|
||||
assert(_is_working);
|
||||
|
||||
data_unlock();
|
||||
|
||||
if (this->is_running()){
|
||||
_device_agent.stop();
|
||||
}
|
||||
bool wait_upload = false;
|
||||
if (!_is_repeat_mode) {
|
||||
GVariant *gvar = _device_agent.get_config(NULL, NULL, SR_CONF_WAIT_UPLOAD);
|
||||
if (gvar != NULL) {
|
||||
wait_upload = g_variant_get_boolean(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
}
|
||||
if (!wait_upload) {
|
||||
_is_working = false;
|
||||
_callback->trigger_message(DSV_MSG_COLLECT_END_PREV);
|
||||
exit_capture();
|
||||
}
|
||||
else{
|
||||
dsv_info("%s", "Device is uploading.");
|
||||
}
|
||||
}
|
||||
|
||||
bool SigSession::is_running()
|
||||
{
|
||||
return _device_agent.is_running();
|
||||
void SigSession::exit_capture()
|
||||
{
|
||||
_is_instant = false;
|
||||
|
||||
if (_device_agent.is_running()){
|
||||
_device_agent.stop();
|
||||
}
|
||||
}
|
||||
|
||||
bool SigSession::get_capture_status(bool &triggered, int &progress)
|
||||
@ -486,11 +650,11 @@ void SigSession::del_group()
|
||||
|
||||
void SigSession::init_signals()
|
||||
{
|
||||
assert(!_is_working);
|
||||
|
||||
if (_device_agent.have_instance() == false){
|
||||
assert(false);
|
||||
}
|
||||
|
||||
stop_capture();
|
||||
}
|
||||
|
||||
std::vector<view::Signal*> sigs;
|
||||
view::Signal *signal = NULL;
|
||||
@ -830,7 +994,7 @@ void SigSession::feed_in_dso(const sr_datafeed_dso &dso)
|
||||
}
|
||||
|
||||
// first payload
|
||||
_dso_data->snapshot()->first_payload(dso, _device_agent.get_sample_limit(), sig_enable, _bInstant);
|
||||
_dso_data->snapshot()->first_payload(dso, _device_agent.get_sample_limit(), sig_enable, _is_instant);
|
||||
} else {
|
||||
// Append to the existing data snapshot
|
||||
_dso_data->snapshot()->append_payload(dso);
|
||||
@ -872,7 +1036,7 @@ void SigSession::feed_in_dso(const sr_datafeed_dso &dso)
|
||||
_trigger_ch = dso.trig_ch;
|
||||
receive_data(dso.num_samples);
|
||||
|
||||
if (!_bInstant)
|
||||
if (!_is_instant)
|
||||
data_lock();
|
||||
|
||||
_data_updated = true;
|
||||
@ -1363,16 +1527,6 @@ uint64_t SigSession::get_error_pattern()
|
||||
return _error_pattern;
|
||||
}
|
||||
|
||||
SigSession::run_mode SigSession::get_run_mode()
|
||||
{
|
||||
return _run_mode;
|
||||
}
|
||||
|
||||
void SigSession::set_run_mode(run_mode mode)
|
||||
{
|
||||
_run_mode = mode;
|
||||
}
|
||||
|
||||
double SigSession::get_repeat_intvl()
|
||||
{
|
||||
return _repeat_intvl;
|
||||
@ -1383,18 +1537,6 @@ void SigSession::set_repeat_intvl(double interval)
|
||||
_repeat_intvl = interval;
|
||||
}
|
||||
|
||||
void SigSession::set_repeating(bool repeat)
|
||||
{
|
||||
_repeating = repeat;
|
||||
if (!_repeating)
|
||||
_repeat_hold_prg = 0;
|
||||
}
|
||||
|
||||
bool SigSession::isRepeating()
|
||||
{
|
||||
return _repeating;
|
||||
}
|
||||
|
||||
bool SigSession::repeat_check()
|
||||
{
|
||||
if (_device_agent.is_running() ||
|
||||
@ -1474,23 +1616,6 @@ uint64_t SigSession::get_save_end()
|
||||
return _save_end;
|
||||
}
|
||||
|
||||
void SigSession::exit_capture()
|
||||
{
|
||||
set_repeating(false);
|
||||
bool wait_upload = false;
|
||||
if (get_run_mode() != SigSession::Repetitive) {
|
||||
GVariant *gvar = _device_agent.get_config(NULL, NULL, SR_CONF_WAIT_UPLOAD);
|
||||
if (gvar != NULL) {
|
||||
wait_upload = g_variant_get_boolean(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
}
|
||||
if (!wait_upload) {
|
||||
stop_capture();
|
||||
capture_state_changed(SigSession::Stopped);
|
||||
}
|
||||
}
|
||||
|
||||
float SigSession::stop_scale()
|
||||
{
|
||||
return _stop_scale;
|
||||
@ -1502,20 +1627,16 @@ void SigSession::set_stop_scale(float scale)
|
||||
}
|
||||
|
||||
void SigSession::Open()
|
||||
{
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void SigSession::Close()
|
||||
{
|
||||
if (_bClose)
|
||||
return;
|
||||
return;
|
||||
|
||||
_bClose = true;
|
||||
|
||||
stop_capture(); //stop capture
|
||||
|
||||
clear_all_decoder(); //clear all decode task, and stop decode thread
|
||||
_bClose = true;
|
||||
stop_capture();
|
||||
|
||||
// TODO: This should not be necessary
|
||||
_session = NULL;
|
||||
@ -1527,13 +1648,13 @@ void SigSession::set_stop_scale(float scale)
|
||||
std::lock_guard<std::mutex> lock(_decode_task_mutex);
|
||||
_decode_tasks.push_back(trace);
|
||||
|
||||
if (!_bDecodeRunning)
|
||||
if (!_is_decoding)
|
||||
{
|
||||
if (_decode_thread.joinable())
|
||||
_decode_thread.join();
|
||||
|
||||
_decode_thread = std::thread(&SigSession::decode_task_proc, this);
|
||||
_bDecodeRunning = true;
|
||||
_is_decoding = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1657,7 +1778,7 @@ void SigSession::set_stop_scale(float scale)
|
||||
}
|
||||
|
||||
dsv_info("%s", "------->decode thread end");
|
||||
_bDecodeRunning = false;
|
||||
_is_decoding = false;
|
||||
}
|
||||
|
||||
Snapshot* SigSession::get_signal_snapshot()
|
||||
@ -1674,7 +1795,7 @@ void SigSession::set_stop_scale(float scale)
|
||||
void SigSession::device_lib_event_callback(int event)
|
||||
{
|
||||
if (_session == NULL){
|
||||
dsv_err("%s", "device_lib_event_callback() error, _session is null.");
|
||||
dsv_err("%s", "Error!Global variable \"_session\" is null.");
|
||||
return;
|
||||
}
|
||||
_session->on_device_lib_event(event);
|
||||
@ -1683,221 +1804,65 @@ void SigSession::set_stop_scale(float scale)
|
||||
void SigSession::on_device_lib_event(int event)
|
||||
{
|
||||
if (event == DS_EV_COLLECT_TASK_START){
|
||||
set_capture_state(Running);
|
||||
_callback->trigger_message(DSV_MSG_COLLECT_START);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event == DS_EV_COLLECT_TASK_END){
|
||||
set_capture_state(Stopped);
|
||||
_callback->trigger_message(DSV_MSG_COLLECT_END);
|
||||
|
||||
if (_logic_data->snapshot()->last_ended() == false){
|
||||
dsv_err("%s", "The collected data is error!");
|
||||
}
|
||||
if (_dso_data->snapshot()->last_ended() == false){
|
||||
dsv_err("%s", "The collected data is error!");
|
||||
}
|
||||
if (_analog_data->snapshot()->last_ended() == false){
|
||||
dsv_err("%s", "The collected data is error!");
|
||||
}
|
||||
_bInstant = false;
|
||||
if (_logic_data->snapshot()->last_ended() == false)
|
||||
dsv_err("%s", "The collected data is error!");
|
||||
if (_dso_data->snapshot()->last_ended() == false)
|
||||
dsv_err("%s", "The collected data is error!");
|
||||
if (_analog_data->snapshot()->last_ended() == false)
|
||||
dsv_err("%s", "The collected data is error!");
|
||||
|
||||
bool bInstant = _is_instant;
|
||||
_is_instant = false;
|
||||
|
||||
if (!bInstant && _is_repeat_mode){
|
||||
if (_repeat_intvl > 0)
|
||||
_repeate_timer.Start(_repeat_intvl * 1000);
|
||||
else
|
||||
this->exec_capture();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (event == DS_EV_NEW_DEVICE_ATTACH || event == DS_EV_CURRENT_DEVICE_DETACH)
|
||||
{
|
||||
if (this->is_running())
|
||||
_device_agent.stop();
|
||||
|
||||
update_collect_status_view();
|
||||
if (_is_working)
|
||||
this->stop_capture();
|
||||
|
||||
|
||||
if (have_hardware_data())
|
||||
{
|
||||
// Try to save current device data, and auto select the lastest device later.
|
||||
_active_last_device_flag = true;
|
||||
if (!_bSaving)
|
||||
if (!_is_saving)
|
||||
store_session_data();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->is_running())
|
||||
_device_agent.stop();
|
||||
|
||||
update_collect_status_view();
|
||||
if (_is_working)
|
||||
this->stop_capture();
|
||||
|
||||
if (event == DS_EV_NEW_DEVICE_ATTACH || event == DS_EV_CURRENT_DEVICE_DETACH)
|
||||
{
|
||||
if (_bSaving)
|
||||
if (_is_saving)
|
||||
_active_last_device_flag = true; //Auto switch device after save data.
|
||||
else
|
||||
set_default_device();
|
||||
}
|
||||
else if (_callback != NULL)
|
||||
else
|
||||
{
|
||||
_callback->trigger_message(DSV_MSG_DEVICE_LIST_UPDATE); // Update list only.
|
||||
}
|
||||
}
|
||||
|
||||
bool SigSession::set_default_device()
|
||||
{
|
||||
struct ds_device_info *array = NULL;
|
||||
int count = 0;
|
||||
|
||||
if (ds_get_device_list(&array, &count) != SR_OK)
|
||||
{
|
||||
dsv_err("%s", "Get device list error!");
|
||||
return false;
|
||||
}
|
||||
if (count < 1 || array == NULL)
|
||||
{
|
||||
dsv_err("%s", "SigSession::set_default_device, Device list is empty!");
|
||||
return false;
|
||||
}
|
||||
|
||||
struct ds_device_info *dev = (array + count - 1);
|
||||
ds_device_handle dev_handle = dev->handle;
|
||||
|
||||
free(array);
|
||||
|
||||
bool ret = set_device(dev_handle);
|
||||
|
||||
if (ret && _callback != NULL){
|
||||
_callback->trigger_message(DSV_MSG_DEVICE_LIST_UPDATE);
|
||||
init_device_view();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool SigSession::set_device(ds_device_handle dev_handle)
|
||||
{
|
||||
assert(!_bSaving);
|
||||
|
||||
if (ds_active_device(dev_handle) != SR_OK){
|
||||
dsv_err("%s", "Switch device error!");
|
||||
return false;
|
||||
}
|
||||
_device_agent.update();
|
||||
|
||||
init_signals();
|
||||
|
||||
RELEASE_ARRAY(_group_traces);
|
||||
clear_all_decoder();
|
||||
|
||||
if (_device_agent.is_file())
|
||||
dsv_info("%s\"%s\"", "Switch to file: ", _device_agent.name().toUtf8().data());
|
||||
else
|
||||
dsv_info("%s\"%s\"", "Switch to device: ", _device_agent.name().toUtf8().data());
|
||||
|
||||
_cur_snap_samplerate = _device_agent.get_sample_rate();
|
||||
_cur_samplelimits = _device_agent.get_sample_limit();
|
||||
|
||||
if (_device_agent.get_work_mode() == DSO)
|
||||
set_run_mode(Repetitive);
|
||||
else
|
||||
set_run_mode(Single);
|
||||
|
||||
_callback->device_setted();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SigSession::set_file(QString name)
|
||||
{
|
||||
dsv_info("Load file:\"%s\"", name.toUtf8().data());
|
||||
|
||||
std::string path = path::ToUnicodePath(name);
|
||||
|
||||
if (ds_device_from_file(path.c_str()) != SR_OK)
|
||||
{
|
||||
dsv_err("%s", "Load file error!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return set_default_device();
|
||||
}
|
||||
|
||||
void SigSession::close_file(ds_device_handle dev_handle)
|
||||
{
|
||||
ds_remove_device(dev_handle);
|
||||
set_repeating(false);
|
||||
stop_capture();
|
||||
capture_state_changed(SigSession::Stopped);
|
||||
set_default_device();
|
||||
}
|
||||
|
||||
bool SigSession::init()
|
||||
{
|
||||
ds_log_set_context(dsv_log_context());
|
||||
|
||||
ds_set_event_callback(device_lib_event_callback);
|
||||
|
||||
ds_set_datafeed_callback(data_feed_callback);
|
||||
|
||||
// firmware resource directory
|
||||
QString resdir = GetResourceDir();
|
||||
std::string res_path = pv::path::ToUnicodePath(resdir);
|
||||
ds_set_firmware_resource_dir(res_path.c_str());
|
||||
|
||||
if (ds_lib_init() != SR_OK)
|
||||
{
|
||||
dsv_err("%s", "DSView run ERROR: collect lib init failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SigSession::uninit()
|
||||
{
|
||||
this->Close();
|
||||
|
||||
ds_lib_exit();
|
||||
}
|
||||
|
||||
void SigSession::update_collect_status_view()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SigSession::init_device_view()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SigSession::store_session_data()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool SigSession::have_hardware_data()
|
||||
{
|
||||
if (_device_agent.have_instance() && _device_agent.is_hardware()){
|
||||
Snapshot *data = get_signal_snapshot();
|
||||
return data->have_data();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SigSession::update_graph_view()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
struct ds_device_info* SigSession::get_device_list(int &out_count, int &actived_index)
|
||||
{
|
||||
out_count = 0;
|
||||
actived_index = -1;
|
||||
struct ds_device_info *array = NULL;
|
||||
|
||||
if (ds_get_device_list(&array, &out_count) == SR_OK)
|
||||
{
|
||||
actived_index = ds_get_actived_device_index();
|
||||
return array;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void SigSession::add_msg_listener(IMessageListener *ln)
|
||||
{
|
||||
_msg_listeners.push_back(ln);
|
||||
@ -1911,6 +1876,19 @@ bool SigSession::init()
|
||||
}
|
||||
}
|
||||
|
||||
void SigSession::set_repeat_mode(bool repeat)
|
||||
{
|
||||
assert(!_is_working);
|
||||
assert(_is_repeat_mode != repeat);
|
||||
_is_repeat_mode = repeat;
|
||||
_repeat_hold_prg = 0;
|
||||
}
|
||||
|
||||
void SigSession::repeat_capture_wait_timout()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SigSession::OnMessage(int msg)
|
||||
{
|
||||
if (msg == DSV_MSG_DEVICE_OPTIONS_UPDATED){
|
||||
|
@ -96,12 +96,7 @@ public:
|
||||
static const int FeedInterval = 50;
|
||||
static const int WaitShowTime = 500;
|
||||
|
||||
public:
|
||||
enum run_mode {
|
||||
Single,
|
||||
Repetitive
|
||||
};
|
||||
|
||||
public:
|
||||
enum error_state {
|
||||
No_err,
|
||||
Hw_err,
|
||||
@ -123,16 +118,25 @@ public:
|
||||
inline DeviceAgent* get_device(){
|
||||
return &_device_agent;
|
||||
}
|
||||
|
||||
|
||||
bool init();
|
||||
void uninit();
|
||||
void Open();
|
||||
void Close();
|
||||
|
||||
bool set_default_device();
|
||||
bool set_device(ds_device_handle dev_handle);
|
||||
bool set_file(QString name);
|
||||
void close_file(ds_device_handle dev_handle);
|
||||
bool set_default_device();
|
||||
|
||||
void start_capture(bool instant);
|
||||
void stop_capture();
|
||||
|
||||
uint64_t cur_samplerate();
|
||||
uint64_t cur_snap_samplerate();
|
||||
uint64_t cur_samplelimits();
|
||||
|
||||
inline uint64_t cur_samplelimits(){
|
||||
return _cur_samplelimits;
|
||||
}
|
||||
|
||||
double cur_sampletime();
|
||||
double cur_snap_sampletime();
|
||||
@ -141,13 +145,10 @@ public:
|
||||
void set_cur_snap_samplerate(uint64_t samplerate);
|
||||
void set_cur_samplelimits(uint64_t samplelimits);
|
||||
void set_session_time(QDateTime time);
|
||||
|
||||
QDateTime get_session_time();
|
||||
uint64_t get_trigger_pos();
|
||||
|
||||
uint64_t get_trigger_pos();
|
||||
bool get_capture_status(bool &triggered, int &progress);
|
||||
|
||||
void container_init();
|
||||
std::set<data::SignalData*> get_data();
|
||||
std::vector<view::Signal*>& get_signals();
|
||||
std::vector<view::GroupSignal*>& get_group_signals();
|
||||
@ -167,16 +168,10 @@ public:
|
||||
view::LissajousTrace* get_lissajous_trace();
|
||||
view::MathTrace* get_math_trace();
|
||||
|
||||
void init_signals();
|
||||
void add_group();
|
||||
void del_group();
|
||||
|
||||
uint16_t get_ch_num(int type);
|
||||
|
||||
inline bool is_instant(){
|
||||
return _bInstant;
|
||||
}
|
||||
|
||||
|
||||
bool get_data_lock();
|
||||
void data_auto_lock(int lock);
|
||||
void data_auto_unlock();
|
||||
@ -198,13 +193,9 @@ public:
|
||||
void set_error(error_state state);
|
||||
void clear_error();
|
||||
|
||||
uint64_t get_error_pattern();
|
||||
run_mode get_run_mode();
|
||||
void set_run_mode(run_mode mode);
|
||||
uint64_t get_error_pattern();
|
||||
double get_repeat_intvl();
|
||||
void set_repeat_intvl(double interval);
|
||||
|
||||
bool isRepeating();
|
||||
void set_repeat_intvl(double interval);
|
||||
bool repeat_check();
|
||||
int get_repeat_hold();
|
||||
int get_map_zoom();
|
||||
@ -212,36 +203,45 @@ public:
|
||||
|
||||
void set_save_end(uint64_t end);
|
||||
uint64_t get_save_start();
|
||||
uint64_t get_save_end();
|
||||
|
||||
uint64_t get_save_end();
|
||||
void set_stop_scale(float scale);
|
||||
float stop_scale();
|
||||
|
||||
void exit_capture();
|
||||
|
||||
void Open();
|
||||
void Close();
|
||||
|
||||
void clear_all_decoder(bool bUpdateView = true);
|
||||
|
||||
inline bool is_closed(){
|
||||
return _bClose;
|
||||
}
|
||||
|
||||
inline bool is_instant(){
|
||||
return _is_instant;
|
||||
}
|
||||
|
||||
inline void set_callback(ISessionCallback *callback){
|
||||
_callback = callback;
|
||||
}
|
||||
|
||||
inline bool is_working(){
|
||||
return _is_working;
|
||||
}
|
||||
|
||||
void set_repeat_mode(bool repeat);
|
||||
|
||||
inline bool is_repeat_mode(){
|
||||
return _is_repeat_mode;
|
||||
}
|
||||
|
||||
public:
|
||||
inline void capture_state_changed(int state){
|
||||
_callback->capture_state_changed(state);
|
||||
}
|
||||
|
||||
inline void session_save(){
|
||||
_callback->session_save();
|
||||
_callback->session_save();
|
||||
}
|
||||
|
||||
inline void repeat_resume(){
|
||||
_callback->repeat_resume();
|
||||
_callback->repeat_resume();
|
||||
}
|
||||
|
||||
inline void show_region(uint64_t start, uint64_t end, bool keep){
|
||||
@ -253,35 +253,28 @@ public:
|
||||
}
|
||||
|
||||
inline bool is_saving(){
|
||||
return _bSaving;
|
||||
return _is_saving;
|
||||
}
|
||||
|
||||
inline void set_saving(bool flag){
|
||||
_bSaving = flag;
|
||||
}
|
||||
|
||||
bool init();
|
||||
|
||||
void uninit();
|
||||
|
||||
_is_saving = flag;
|
||||
}
|
||||
|
||||
void reload();
|
||||
void refresh(int holdtime);
|
||||
void start_capture(bool instant);
|
||||
void stop_capture();
|
||||
bool is_running();
|
||||
void check_update();
|
||||
void set_repeating(bool repeat);
|
||||
void refresh(int holdtime);
|
||||
void check_update();
|
||||
void set_map_zoom(int index);
|
||||
void auto_end();
|
||||
|
||||
void store_session_data();
|
||||
bool have_hardware_data();
|
||||
struct ds_device_info* get_device_list(int &out_count, int &actived_index);
|
||||
|
||||
void add_msg_listener(IMessageListener *ln);
|
||||
void broadcast_msg(int msg);
|
||||
|
||||
private:
|
||||
void exec_capture();
|
||||
void exit_capture();
|
||||
|
||||
inline void data_updated(){
|
||||
_callback->data_updated();
|
||||
}
|
||||
@ -292,9 +285,7 @@ private:
|
||||
|
||||
inline void receive_data(quint64 len){
|
||||
_callback->receive_data_len(len);
|
||||
}
|
||||
|
||||
void set_capture_state(capture_state state);
|
||||
}
|
||||
|
||||
void add_decode_task(view::DecodeTrace *trace);
|
||||
void remove_decode_task(view::DecodeTrace *trace);
|
||||
@ -309,7 +300,9 @@ private:
|
||||
void data_unlock();
|
||||
void nodata_timeout();
|
||||
void feed_timeout();
|
||||
void repeat_update();
|
||||
void repeat_update();
|
||||
void container_init();
|
||||
void init_signals();
|
||||
|
||||
//IMessageListener
|
||||
void OnMessage(int msg);
|
||||
@ -343,37 +336,23 @@ private:
|
||||
void on_device_lib_event(int event);
|
||||
|
||||
Snapshot* get_signal_snapshot();
|
||||
|
||||
void update_collect_status_view();
|
||||
void init_device_view();
|
||||
void update_graph_view();
|
||||
|
||||
void repeat_capture_wait_timout();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The device instance that will be used in the next capture session.
|
||||
*/
|
||||
mutable std::mutex _sampling_mutex;
|
||||
mutable std::mutex _data_mutex;
|
||||
mutable std::mutex _decode_task_mutex;
|
||||
|
||||
mutable std::mutex _decode_task_mutex;
|
||||
std::thread _decode_thread;
|
||||
|
||||
volatile bool _bHotplugStop;
|
||||
volatile bool _bDecodeRunning;
|
||||
|
||||
capture_state _capture_state;
|
||||
bool _bInstant;
|
||||
volatile bool _is_decoding;
|
||||
uint64_t _cur_snap_samplerate;
|
||||
uint64_t _cur_samplelimits;
|
||||
|
||||
std::vector<view::Signal*> _signals;
|
||||
std::vector<view::GroupSignal*> _group_traces;
|
||||
|
||||
std::vector<view::DecodeTrace*> _decode_traces;
|
||||
std::vector<view::DecodeTrace*> _decode_tasks;
|
||||
pv::data::DecoderModel *_decoder_model;
|
||||
|
||||
std::vector<view::SpectrumTrace*> _spectrum_traces;
|
||||
view::LissajousTrace *_lissajous_trace;
|
||||
view::MathTrace *_math_trace;
|
||||
@ -386,6 +365,7 @@ private:
|
||||
|
||||
DsTimer _feed_timer;
|
||||
DsTimer _out_timer;
|
||||
DsTimer _repeate_timer;
|
||||
int _noData_cnt;
|
||||
bool _data_lock;
|
||||
bool _data_updated;
|
||||
@ -399,25 +379,22 @@ private:
|
||||
|
||||
error_state _error;
|
||||
uint64_t _error_pattern;
|
||||
|
||||
run_mode _run_mode;
|
||||
double _repeat_intvl;
|
||||
int _repeat_hold_prg;
|
||||
int _map_zoom;
|
||||
|
||||
int _map_zoom;
|
||||
bool _dso_feed;
|
||||
float _stop_scale;
|
||||
bool _bClose;
|
||||
bool _active_last_device_flag;
|
||||
bool _bRepeatMode;
|
||||
bool _bRunning;
|
||||
|
||||
bool _bSaving;
|
||||
|
||||
uint64_t _save_start;
|
||||
uint64_t _save_end;
|
||||
bool _is_working;
|
||||
bool _is_repeat_mode;
|
||||
double _repeat_intvl; // The progress check timer interval.
|
||||
int _repeat_hold_prg; // The time sleep progress
|
||||
bool _is_saving;
|
||||
bool _is_instant;
|
||||
|
||||
ISessionCallback *_callback;
|
||||
|
||||
DeviceAgent _device_agent;
|
||||
std::vector<IMessageListener*> _msg_listeners;
|
||||
|
||||
|
@ -70,7 +70,6 @@ SamplingBar::SamplingBar(SigSession *session, QWidget *parent) :
|
||||
|
||||
_session = session;
|
||||
_device_agent = _session->get_device();
|
||||
_session->add_msg_listener(this);
|
||||
|
||||
setMovable(false);
|
||||
setContentsMargins(0,0,0,0);
|
||||
@ -318,11 +317,6 @@ void SamplingBar::zero_adj()
|
||||
commit_hori_res();
|
||||
}
|
||||
|
||||
bool SamplingBar::get_sampling()
|
||||
{
|
||||
return _sampling;
|
||||
}
|
||||
|
||||
void SamplingBar::set_sampling(bool sampling)
|
||||
{
|
||||
_sampling = sampling;
|
||||
@ -963,8 +957,9 @@ void SamplingBar::reload()
|
||||
_mode_action->setVisible(false);
|
||||
}
|
||||
else {
|
||||
_mode_button.setIcon(_session->get_run_mode() == pv::SigSession::Single ? QIcon(iconPath+"/modes.svg") :
|
||||
QIcon(iconPath+"/moder.svg"));
|
||||
|
||||
QString icon = _session->is_repeat_mode() ? "/moder.svg" : "/modes.svg";
|
||||
_mode_button.setIcon(QIcon(iconPath + icon));
|
||||
_mode_action->setVisible(true);
|
||||
}
|
||||
_run_stop_action->setVisible(true);
|
||||
@ -1046,6 +1041,7 @@ void SamplingBar::on_mode()
|
||||
switch (msg)
|
||||
{
|
||||
case DSV_MSG_DEVICE_LIST_UPDATE:
|
||||
case DSV_MSG_CURRENT_DEVICE_CHANGED:
|
||||
update_device_list();
|
||||
break;
|
||||
case DSV_MSG_COLLECT_START:
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include "../ui/dscombobox.h"
|
||||
#include "../interface/icallbacks.h"
|
||||
|
||||
struct st_dev_inst;
|
||||
class QAction;
|
||||
@ -59,7 +58,7 @@ namespace pv
|
||||
namespace toolbars
|
||||
{
|
||||
|
||||
class SamplingBar : public QToolBar, public IMessageListener
|
||||
class SamplingBar : public QToolBar
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -79,18 +78,16 @@ namespace pv
|
||||
SamplingBar(SigSession *session, QWidget *parent);
|
||||
|
||||
void update_sample_rate_selector();
|
||||
|
||||
|
||||
void enable_toggle(bool enable);
|
||||
|
||||
void enable_toggle(bool enable);
|
||||
void enable_instant(bool enable);
|
||||
|
||||
double hori_knob(int dir);
|
||||
double commit_hori_res();
|
||||
double get_hori_res();
|
||||
|
||||
void set_sample_rate(uint64_t sample_rate);
|
||||
void update_device_list();
|
||||
void set_sampling(bool sampling);
|
||||
void reload();
|
||||
|
||||
private:
|
||||
void enable_run_stop(bool enable);
|
||||
@ -104,8 +101,6 @@ namespace pv
|
||||
void commit_settings();
|
||||
void setting_adj();
|
||||
|
||||
void set_sampling(bool sampling);
|
||||
|
||||
//IMessageListener
|
||||
void OnMessage(int msg);
|
||||
|
||||
@ -118,7 +113,7 @@ namespace pv
|
||||
void on_samplecount_sel(int index);
|
||||
void on_configure();
|
||||
void zero_adj();
|
||||
void reload();
|
||||
|
||||
|
||||
private:
|
||||
SigSession *_session;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <QToolButton>
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
|
||||
class DockOptions;
|
||||
|
||||
|
@ -1387,6 +1387,9 @@ void View::OnMessage(int msg)
|
||||
case DSV_MSG_DEVICE_MODE_CHANGED:
|
||||
mode_changed();
|
||||
break;
|
||||
case DSV_MSG_CURRENT_DEVICE_CHANGED:
|
||||
reload();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user