2
0
forked from Ivasoft/DSView

Add tool button of device type

This commit is contained in:
DreamSourceLab
2019-11-03 18:21:46 -08:00
parent d33bb18350
commit 4e1c4ca3b2
13 changed files with 139 additions and 35 deletions

View File

@@ -133,5 +133,9 @@
<file>icons/dark/osc.png</file>
<file>icons/showDoc25.png</file>
<file>icons/showDoc31.png</file>
<file>icons/usb2.png</file>
<file>icons/usb3.png</file>
<file>icons/data.png</file>
<file>icons/demo.png</file>
</qresource>
</RCC>

BIN
DSView/icons/data.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
DSView/icons/demo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
DSView/icons/usb2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
DSView/icons/usb3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -58,7 +58,6 @@
#include "dialogs/deviceoptions.h"
#include "dialogs/storeprogress.h"
#include "dialogs/waitingdialog.h"
#include "dialogs/dsmessagebox.h"
#include "dialogs/regionoptions.h"
#include "toolbars/samplingbar.h"
@@ -86,6 +85,7 @@
#include <stdarg.h>
#include <glib.h>
#include <list>
#include <libusb.h>
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
@@ -99,7 +99,8 @@ MainWindow::MainWindow(DeviceManager &device_manager,
QWidget *parent) :
QMainWindow(parent),
_device_manager(device_manager),
_session(device_manager)
_session(device_manager),
_msg(NULL)
{
setup_ui();
if (open_file_name) {
@@ -346,6 +347,9 @@ void MainWindow::update_device_list()
{
assert(_sampling_bar);
if (_msg)
_msg->close();
switchLanguage(_language);
_session.stop_capture();
_view->reload();
@@ -434,6 +438,29 @@ void MainWindow::update_device_list()
_trigger_widget->init();
_dso_trigger_widget->init();
_measure_widget->reload();
// USB device speed check
if (!selected_device->name().contains("virtual")) {
int usb_speed;
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_session_error(tr("Speed limited"), tr("This is a super-speed usb device(USB 3.0). "
"Plug it into a USB 2.0 port will seriously affect its performance."
"Please replug it into a USB 3.0 port."));
}
}
}
void MainWindow::reload()
@@ -464,11 +491,13 @@ void MainWindow::show_session_error(
const QString text, const QString info_text)
{
dialogs::DSMessageBox msg(this);
_msg = &msg;
msg.mBox()->setText(text);
msg.mBox()->setInformativeText(info_text);
msg.mBox()->setStandardButtons(QMessageBox::Ok);
msg.mBox()->setIcon(QMessageBox::Warning);
msg.exec();
_msg = NULL;
}
void MainWindow::device_attach()

View File

@@ -29,6 +29,7 @@
#include <QMainWindow>
#include "sigsession.h"
#include "dialogs/dsmessagebox.h"
class QAction;
class QMenuBar;
@@ -106,7 +107,7 @@ private slots:
void reload();
void show_session_error(
void show_session_error(
const QString text, const QString info_text);
void run_stop();
@@ -161,6 +162,7 @@ private:
SigSession _session;
pv::view::View *_view;
dialogs::DSMessageBox *_msg;
QMenuBar *_menu_bar;
QMenu *_menu_file;

View File

@@ -22,6 +22,7 @@
#include <extdef.h>
#include <assert.h>
#include <boost/foreach.hpp>
#include <libusb.h>
#include <QAction>
#include <QDebug>
@@ -30,7 +31,6 @@
#include <QApplication>
#include "samplingbar.h"
#include "../devicemanager.h"
#include "../device/devinst.h"
#include "../dialogs/deviceoptions.h"
@@ -57,6 +57,7 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
_session(session),
_enable(true),
_sampling(false),
_device_type(this),
_device_selector(this),
_updating_device_selector(false),
_configure_button(this),
@@ -104,6 +105,8 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
leftMargin->setFixedWidth(4);
addWidget(leftMargin);
_device_type.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
addWidget(&_device_type);
addWidget(&_device_selector);
_configure_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
addWidget(&_configure_button);
@@ -146,6 +149,27 @@ void SamplingBar::changeEvent(QEvent *event)
void SamplingBar::retranslateUi()
{
shared_ptr<pv::device::DevInst> dev_inst = get_selected_device();
if (dev_inst && dev_inst->dev_inst()) {
if (dev_inst->name().contains("virtual-demo"))
_device_type.setText(tr("Demo"));
else if (dev_inst->name().contains("virtual"))
_device_type.setText(tr("File"));
else {
int usb_speed;
GVariant *gvar = dev_inst->get_config(NULL, NULL, SR_CONF_USB_SPEED);
if (gvar != NULL) {
usb_speed = g_variant_get_int32(gvar);
g_variant_unref(gvar);
}
if (usb_speed == LIBUSB_SPEED_HIGH)
_device_type.setText(tr("USB 2.0"));
else if (usb_speed == LIBUSB_SPEED_SUPER)
_device_type.setText(tr("USB 3.0"));
else
_device_type.setText(tr("USB UNKNOWN"));
}
}
_configure_button.setText(tr("Options"));
_mode_button.setText(tr("Mode"));
if (_instant) {
@@ -172,6 +196,26 @@ void SamplingBar::reStyle()
{
QString iconPath = ":/icons/" + qApp->property("Style").toString();
shared_ptr<pv::device::DevInst> dev_inst = get_selected_device();
if (dev_inst && dev_inst->dev_inst()) {
if (dev_inst->name().contains("virtual-demo"))
_device_type.setIcon(QIcon(":/icons/demo.png"));
else if (dev_inst->name().contains("virtual"))
_device_type.setIcon(QIcon(":/icons/data.png"));
else {
int usb_speed;
GVariant *gvar = dev_inst->get_config(NULL, NULL, SR_CONF_USB_SPEED);
if (gvar != NULL) {
usb_speed = g_variant_get_int32(gvar);
g_variant_unref(gvar);
}
if (usb_speed == LIBUSB_SPEED_SUPER)
_device_type.setIcon(QIcon(":/icons/usb3.png"));
else
_device_type.setIcon(QIcon(":/icons/usb2.png"));
}
}
_configure_button.setIcon(QIcon(iconPath+"/params.png"));
_mode_button.setIcon(_session.get_run_mode() == pv::SigSession::Single ? QIcon(iconPath+"/modes.png") :
QIcon(iconPath+"/moder.png"));
@@ -964,6 +1008,7 @@ void SamplingBar::reload()
enable_toggle(true);
}
retranslateUi();
reStyle();
update();
}

View File

@@ -139,6 +139,8 @@ private:
bool _enable;
bool _sampling;
QToolButton _device_type;
QComboBox _device_selector;
std::map<const void*, boost::weak_ptr<device::DevInst> >
_device_selector_map;

View File

@@ -921,7 +921,7 @@ SR_PRIV int dsl_fpga_arm(const struct sr_dev_inst *sdi)
}
}
if (!(devc->profile->dev_caps.feature_caps & CAPS_FEATURE_USB30)) {
if (!(devc->profile->usb_speed == LIBUSB_SPEED_SUPER)) {
// set GPIF to be wordwide
wr_cmd.header.dest = DSL_CTL_WORDWIDE;
wr_cmd.header.size = 1;
@@ -1173,6 +1173,16 @@ SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sd
snprintf(str, 128, "%d.%d", usb->bus, usb->address);
*data = g_variant_new_string(str);
break;
case SR_CONF_USB_SPEED:
if (!sdi)
return SR_ERR;
*data = g_variant_new_int32(devc->profile->usb_speed);
break;
case SR_CONF_USB30_SUPPORT:
if (!sdi)
return SR_ERR;
*data = g_variant_new_boolean(devc->profile->dev_caps.feature_caps & CAPS_FEATURE_USB30);
break;
case SR_CONF_LIMIT_SAMPLES:
if (!sdi)
return SR_ERR;
@@ -1612,16 +1622,16 @@ SR_PRIV int dsl_dev_status_get(const struct sr_dev_inst *sdi, struct sr_status *
static unsigned int get_single_buffer_time(const struct DSL_context *devc)
{
if (devc->profile->dev_caps.feature_caps & CAPS_FEATURE_USB30)
return 100;
if (devc->profile->usb_speed == LIBUSB_SPEED_SUPER)
return 10;
else
return 20;
}
static unsigned int get_total_buffer_time(const struct DSL_context *devc)
{
if (devc->profile->dev_caps.feature_caps & CAPS_FEATURE_USB30)
return 500;
if (devc->profile->usb_speed == LIBUSB_SPEED_SUPER)
return 40;
else
return 100;
}
@@ -1643,7 +1653,7 @@ SR_PRIV int dsl_header_size(const struct DSL_context *devc)
{
int size;
if (devc->profile->dev_caps.feature_caps & CAPS_FEATURE_USB30)
if (devc->profile->usb_speed == LIBUSB_SPEED_SUPER)
size = SR_KB(1);
else
size = SR_B(512);

View File

@@ -175,6 +175,7 @@ struct DSL_caps {
struct DSL_profile {
uint16_t vid;
uint16_t pid;
enum libusb_speed usb_speed;
const char *vendor;
const char *model;
@@ -431,7 +432,7 @@ static const struct DSL_profile supported_DSLogic[] = {
/*
* DSLogic
*/
{0x2A0E, 0x0001, "DreamSourceLab", "DSLogic", NULL,
{0x2A0E, 0x0001, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSLogic", NULL,
"DSLogic.fw",
"DSLogic33.bin",
"DSLogic50.bin",
@@ -457,7 +458,7 @@ static const struct DSL_profile supported_DSLogic[] = {
0}
},
{0x2A0E, 0x0003, "DreamSourceLab", "DSLogic Pro", NULL,
{0x2A0E, 0x0003, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSLogic Pro", NULL,
"DSLogicPro.fw",
"DSLogicPro.bin",
"DSLogicPro.bin",
@@ -481,7 +482,7 @@ static const struct DSL_profile supported_DSLogic[] = {
0}
},
{0x2A0E, 0x0020, "DreamSourceLab", "DSLogic PLus", NULL,
{0x2A0E, 0x0020, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSLogic PLus", NULL,
"DSLogicPlus.fw",
"DSLogicPlus.bin",
"DSLogicPlus.bin",
@@ -505,7 +506,7 @@ static const struct DSL_profile supported_DSLogic[] = {
0}
},
{0x2A0E, 0x0021, "DreamSourceLab", "DSLogic Basic", NULL,
{0x2A0E, 0x0021, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSLogic Basic", NULL,
"DSLogicBasic.fw",
"DSLogicBasic.bin",
"DSLogicBasic.bin",
@@ -529,7 +530,7 @@ static const struct DSL_profile supported_DSLogic[] = {
0}
},
{0x2A0E, 0x0029, "DreamSourceLab", "DSLogic U2Basic", NULL,
{0x2A0E, 0x0029, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSLogic U2Basic", NULL,
"DSLogicU2Basic.fw",
"DSLogicU2Basic.bin",
"DSLogicU2Basic.bin",
@@ -553,14 +554,14 @@ static const struct DSL_profile supported_DSLogic[] = {
0}
},
{ 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
};
static const struct DSL_profile supported_DSCope[] = {
/*
* DSCope
*/
{0x2A0E, 0x0002, "DreamSourceLab", "DSCope", NULL,
{0x2A0E, 0x0002, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSCope", NULL,
"DSCope.fw",
"DSCope.bin",
"DSCope.bin",
@@ -584,7 +585,7 @@ static const struct DSL_profile supported_DSCope[] = {
0}
},
{0x2A0E, 0x0004, "DreamSourceLab", "DSCope20", NULL,
{0x2A0E, 0x0004, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSCope20", NULL,
"DSCope20.fw",
"DSCope20.bin",
"DSCope20.bin",
@@ -608,7 +609,7 @@ static const struct DSL_profile supported_DSCope[] = {
0}
},
{0x2A0E, 0x0022, "DreamSourceLab", "DSCope B20", NULL,
{0x2A0E, 0x0022, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSCope B20", NULL,
"DSCopeB20.fw",
"DSCope20.bin",
"DSCope20.bin",
@@ -632,7 +633,7 @@ static const struct DSL_profile supported_DSCope[] = {
0}
},
{0x2A0E, 0x0023, "DreamSourceLab", "DSCope C20", NULL,
{0x2A0E, 0x0023, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSCope C20", NULL,
"DSCopeC20.fw",
"DSCopeC20P.bin",
"DSCopeC20P.bin",
@@ -657,7 +658,7 @@ static const struct DSL_profile supported_DSCope[] = {
},
{0x2A0E, 0x0024, "DreamSourceLab", "DSCope C20P", NULL,
{0x2A0E, 0x0024, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSCope C20P", NULL,
"DSCopeC20P.fw",
"DSCopeC20P.bin",
"DSCopeC20P.bin",
@@ -681,7 +682,7 @@ static const struct DSL_profile supported_DSCope[] = {
0}
},
{0x2A0E, 0x0025, "DreamSourceLab", "DSCope C20", NULL,
{0x2A0E, 0x0025, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSCope C20", NULL,
"DSCopeC20B.fw",
"DSCopeC20B.bin",
"DSCopeC20B.bin",
@@ -705,7 +706,7 @@ static const struct DSL_profile supported_DSCope[] = {
0}
},
{0x2A0E, 0x0026, "DreamSourceLab", "DSCope U2B20", NULL,
{0x2A0E, 0x0026, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSCope U2B20", NULL,
"DSCopeU2B20.fw",
"DSCopeU2B20.bin",
"DSCopeU2B20.bin",
@@ -729,7 +730,7 @@ static const struct DSL_profile supported_DSCope[] = {
22}
},
{0x2A0E, 0x0027, "DreamSourceLab", "DSCope U2P20", NULL,
{0x2A0E, 0x0027, LIBUSB_SPEED_HIGH, "DreamSourceLab", "DSCope U2P20", NULL,
"DSCopeU2P20.fw",
"DSCopeU2P20.bin",
"DSCopeU2P20.bin",
@@ -754,7 +755,7 @@ static const struct DSL_profile supported_DSCope[] = {
},
{ 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
};
static const gboolean default_ms_en[] = {

View File

@@ -264,6 +264,7 @@ static GSList *scan(GSList *options)
libusb_device **devlist;
int devcnt, ret, i, j;
const char *conn;
enum libusb_speed usb_speed;
drvc = di->priv;
@@ -305,10 +306,16 @@ static GSList *scan(GSList *options)
continue;
}
usb_speed = libusb_get_device_speed( devlist[i]);
if ((usb_speed != LIBUSB_SPEED_HIGH) &&
(usb_speed != LIBUSB_SPEED_SUPER))
continue;
prof = NULL;
for (j = 0; supported_DSLogic[j].vid; j++) {
if (des.idVendor == supported_DSLogic[j].vid &&
des.idProduct == supported_DSLogic[j].pid) {
des.idProduct == supported_DSLogic[j].pid &&
usb_speed == supported_DSLogic[j].usb_speed) {
prof = &supported_DSLogic[j];
}
}
@@ -939,15 +946,17 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
stropt = g_variant_get_string(data, NULL);
if (sdi->mode == LOGIC) {
for (i = 0; i < ARRAY_SIZE(channel_modes); i++) {
if (devc->language == LANGUAGE_CN) {
if (!strcmp(stropt, channel_modes[i].descr_cn)) {
devc->ch_mode = channel_modes[i].id;
break;
}
} else {
if (!strcmp(stropt, channel_modes[i].descr)) {
devc->ch_mode = channel_modes[i].id;
break;
if (devc->profile->dev_caps.channels & (1 << i)) {
if (devc->language == LANGUAGE_CN) {
if (!strcmp(stropt, channel_modes[i].descr_cn)) {
devc->ch_mode = channel_modes[i].id;
break;
}
} else {
if (!strcmp(stropt, channel_modes[i].descr)) {
devc->ch_mode = channel_modes[i].id;
break;
}
}
}
}

View File

@@ -801,6 +801,8 @@ enum {
SR_CONF_CAPTURE_RATIO,
/** */
SR_CONF_USB_SPEED,
SR_CONF_USB30_SUPPORT,
SR_CONF_DEVICE_MODE,
SR_CONF_INSTANT,
SR_CONF_STATUS,