improve session load/store scheme

This commit is contained in:
DreamSourceLab 2015-06-19 18:16:54 +08:00
parent 9d871219bc
commit 4348c2a895
24 changed files with 368 additions and 138 deletions

View File

@ -180,7 +180,7 @@ GSList* DevInst::get_dev_mode_list()
assert(_owner);
sr_dev_inst *const sdi = dev_inst();
assert(sdi);
return sr_dev_mode_list(sdi->driver);
return sr_dev_mode_list(sdi);
}
bool DevInst::is_trigger_enabled() const

View File

@ -317,7 +317,10 @@ void MainWindow::update_device_list()
if (strcmp(selected_device->dev_inst()->driver->name, "demo") != 0) {
_logo_bar->dsl_connected(true);
QString ses_name = config_path + QString::fromLocal8Bit(selected_device->dev_inst()->driver->name) + "_ini.dsc";
QString ses_name = config_path +
QString::fromLocal8Bit(selected_device->dev_inst()->driver->name) +
QString::number(selected_device->dev_inst()->mode) +
".dsc";
load_session(ses_name);
} else {
_logo_bar->dsl_connected(false);
@ -486,6 +489,19 @@ void MainWindow::capture_state_changed(int state)
}
}
void MainWindow::closeEvent(QCloseEvent *event)
{
QDir dir(QCoreApplication::applicationDirPath());
if (dir.cd("res")) {
QString driver_name = _session.get_device()->dev_inst()->driver->name;
QString mode_name = QString::number(_session.get_device()->dev_inst()->mode);
QString file_name = dir.absolutePath() + "/" + driver_name + mode_name + ".dsc";
if (!file_name.isEmpty())
store_session(file_name);
}
event->accept();
}
void MainWindow::on_protocol(bool visible)
{
#ifdef ENABLE_DECODE

View File

@ -72,6 +72,9 @@ public:
const char *open_file_name = NULL,
QWidget *parent = 0);
protected:
void closeEvent(QCloseEvent *event);
private:
void setup_ui();

View File

@ -102,7 +102,7 @@ SigSession::SigSession(DeviceManager &device_manager) :
_refresh_timer.setSingleShot(true);
_data_lock = false;
connect(this, SIGNAL(start_timer(int)), &_view_timer, SLOT(start(int)));
connect(&_view_timer, SIGNAL(timeout()), this, SLOT(refresh()));
//connect(&_view_timer, SIGNAL(timeout()), this, SLOT(refresh()));
connect(&_refresh_timer, SIGNAL(timeout()), this, SLOT(data_unlock()));
}

View File

@ -48,29 +48,42 @@ FileBar::FileBar(SigSession &session, QWidget *parent) :
_action_load = new QAction(this);
_action_load->setText(QApplication::translate(
"File", "&Load Session...", 0));
"File", "&Load...", 0));
_action_load->setIcon(QIcon::fromTheme("file",
QIcon(":/icons/open.png")));
_action_load->setObjectName(QString::fromUtf8("actionLoad"));
_file_button.addAction(_action_load);
connect(_action_load, SIGNAL(triggered()), this, SLOT(on_actionLoad_triggered()));
_action_store = new QAction(this);
_action_store->setText(QApplication::translate(
"File", "S&tore Session...", 0));
"File", "S&tore...", 0));
_action_store->setIcon(QIcon::fromTheme("file",
QIcon(":/icons/save.png")));
_action_store->setObjectName(QString::fromUtf8("actionStore"));
_file_button.addAction(_action_store);
connect(_action_store, SIGNAL(triggered()), this, SLOT(on_actionStore_triggered()));
_action_default = new QAction(this);
_action_default->setText(QApplication::translate(
"File", "&Default...", 0));
_action_default->setIcon(QIcon::fromTheme("file",
QIcon(":/icons/gear.png")));
_action_default->setObjectName(QString::fromUtf8("actionDefault"));
connect(_action_default, SIGNAL(triggered()), this, SLOT(on_actionDefault_triggered()));
_menu_session = new QMenu(tr("Session"), parent);
_menu_session->setIcon(QIcon::fromTheme("file",
QIcon(":/icons/gear.png")));
_menu_session->setObjectName(QString::fromUtf8("menuSession"));
_menu_session->addAction(_action_load);
_menu_session->addAction(_action_store);
_menu_session->addAction(_action_default);
_action_open = new QAction(this);
_action_open->setText(QApplication::translate(
"File", "&Open...", 0));
_action_open->setIcon(QIcon::fromTheme("file",
QIcon(":/icons/open.png")));
_action_open->setObjectName(QString::fromUtf8("actionOpen"));
_file_button.addAction(_action_open);
connect(_action_open, SIGNAL(triggered()), this, SLOT(on_actionOpen_triggered()));
_action_save = new QAction(this);
@ -79,14 +92,12 @@ FileBar::FileBar(SigSession &session, QWidget *parent) :
_action_save->setIcon(QIcon::fromTheme("file",
QIcon(":/icons/save.png")));
_action_save->setObjectName(QString::fromUtf8("actionSave"));
_file_button.addAction(_action_save);
connect(_action_save, SIGNAL(triggered()), this, SLOT(on_actionSave_triggered()));
_action_export = new QAction(this);
_action_export->setText(QApplication::translate("File", "&Export...", 0));
_action_export->setIcon(QIcon::fromTheme("file",QIcon(":/icons/instant.png")));
_action_export->setObjectName(QString::fromUtf8("actionExport"));
_file_button.addAction(_action_export);
connect(_action_export, SIGNAL(triggered()), this, SLOT(on_actionExport_triggered()));
@ -96,7 +107,6 @@ FileBar::FileBar(SigSession &session, QWidget *parent) :
_action_capture->setIcon(QIcon::fromTheme("file",
QIcon(":/icons/capture.png")));
_action_capture->setObjectName(QString::fromUtf8("actionCapture"));
_file_button.addAction(_action_capture);
connect(_action_capture, SIGNAL(triggered()), this, SLOT(on_actionCapture_triggered()));
_file_button.setPopupMode(QToolButton::InstantPopup);
@ -106,6 +116,13 @@ FileBar::FileBar(SigSession &session, QWidget *parent) :
_file_button.setIcon(QIcon(":/icons/file.png"));
#endif
_menu = new QMenu(this);
_menu->addMenu(_menu_session);
_menu->addAction(_action_open);
_menu->addAction(_action_save);
_menu->addAction(_action_export);
_menu->addAction(_action_capture);
_file_button.setMenu(_menu);
addWidget(&_file_button);
}
@ -214,6 +231,26 @@ void FileBar::on_actionLoad_triggered()
load_session(file_name);
}
void FileBar::on_actionDefault_triggered()
{
QDir dir(QCoreApplication::applicationDirPath());
if (!dir.cd("res")) {
QMessageBox msg(this);
msg.setText(tr("Session Load"));
msg.setInformativeText(tr("Cannot find default session file for this device!"));
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
return;
}
QString driver_name = _session.get_device()->dev_inst()->driver->name;
QString mode_name = QString::number(_session.get_device()->dev_inst()->mode);
QString file_name = dir.absolutePath() + "/" + driver_name + mode_name + ".def.dsc";
if (!file_name.isEmpty())
load_session(file_name);
}
void FileBar::on_actionStore_triggered()
{
QString default_name = _session.get_device()->dev_inst()->driver->name;

View File

@ -27,6 +27,7 @@
#include <QToolBar>
#include <QToolButton>
#include <QAction>
#include <QMenu>
#include "../sigsession.h"
@ -59,6 +60,7 @@ signals:
private slots:
void on_actionLoad_triggered();
void on_actionStore_triggered();
void on_actionDefault_triggered();
void on_actionOpen_triggered();
void on_actionSave_triggered();
void on_actionCapture_triggered();
@ -70,8 +72,13 @@ private:
QToolButton _file_button;
QMenu *_menu;
QMenu *_menu_session;
QAction *_action_load;
QAction *_action_store;
QAction *_action_default;
QAction *_action_open;
QAction *_action_save;
QAction *_action_export;

Binary file not shown.

View File

@ -6,6 +6,7 @@
"Sample count": "1048576",
"Sample rate": "100000000",
"Time base": "10000",
"Trigger hold off": "0",
"Trigger slope": "0",
"Trigger source": "0",
"channel": [

View File

@ -4,14 +4,15 @@
"Horizontal trigger position": "0",
"Operation Mode": "Normal",
"Sample count": "1048576",
"Sample rate": "100000000",
"Time base": "10000",
"Sample rate": "50000",
"Time base": "2000000000",
"Trigger hold off": "0",
"Trigger slope": "0",
"Trigger source": "0",
"channel": [
{
"colour": "#eeb211",
"coupling": 0,
"coupling": 1,
"enabled": true,
"index": 0,
"name": "0",

View File

@ -7,6 +7,7 @@
"Sample count": "16777216",
"Sample rate": "100000000",
"Threshold Level": 1,
"Trigger hold off": "0",
"Trigger slope": "0",
"Trigger source": "0",
"Using Clock Negedge": 0,

View File

@ -6,52 +6,13 @@
"Operation Mode": "Normal",
"Sample count": "16777216",
"Sample rate": "100000000",
"Threshold Level": 1,
"Threshold Level": "1.8/2.5/3.3V Level",
"Trigger hold off": "0",
"Trigger slope": "0",
"Trigger source": "0",
"Using Clock Negedge": 0,
"Using External Clock": 0,
"channel": [
{
"colour": "#16191a",
"enabled": true,
"index": 0,
"name": "0",
"strigger": 0,
"type": 10000
},
{
"colour": "#8f5202",
"enabled": true,
"index": 1,
"name": "1",
"strigger": 0,
"type": 10000
},
{
"colour": "#cc0000",
"enabled": true,
"index": 2,
"name": "2",
"strigger": 0,
"type": 10000
},
{
"colour": "#f57900",
"enabled": true,
"index": 3,
"name": "3",
"strigger": 0,
"type": 10000
},
{
"colour": "#edd400",
"enabled": true,
"index": 4,
"name": "4",
"strigger": 0,
"type": 10000
},
{
"colour": "#73d216",
"enabled": true,
@ -60,62 +21,6 @@
"strigger": 0,
"type": 10000
},
{
"colour": "#3465a4",
"enabled": true,
"index": 6,
"name": "6",
"strigger": 0,
"type": 10000
},
{
"colour": "#75507b",
"enabled": true,
"index": 7,
"name": "7",
"strigger": 0,
"type": 10000
},
{
"colour": "#16191a",
"enabled": true,
"index": 8,
"name": "8",
"strigger": 0,
"type": 10000
},
{
"colour": "#8f5202",
"enabled": true,
"index": 9,
"name": "9",
"strigger": 0,
"type": 10000
},
{
"colour": "#cc0000",
"enabled": true,
"index": 10,
"name": "10",
"strigger": 0,
"type": 10000
},
{
"colour": "#f57900",
"enabled": true,
"index": 11,
"name": "11",
"strigger": 0,
"type": 10000
},
{
"colour": "#edd400",
"enabled": true,
"index": 12,
"name": "12",
"strigger": 0,
"type": 10000
},
{
"colour": "#73d216",
"enabled": true,
@ -123,22 +28,6 @@
"name": "13",
"strigger": 0,
"type": 10000
},
{
"colour": "#3465a4",
"enabled": true,
"index": 14,
"name": "14",
"strigger": 0,
"type": 10000
},
{
"colour": "#75507b",
"enabled": true,
"index": 15,
"name": "15",
"strigger": 0,
"type": 10000
}
],
"trigger": {

View File

@ -0,0 +1,43 @@
{
"Device": "DSLogic",
"DeviceMode": 1,
"Filter Targets": "None",
"Horizontal trigger position": "0",
"Operation Mode": "Normal",
"Sample count": "1048576",
"Sample rate": "100000000",
"Threshold Level": "1.8/2.5/3.3V Level",
"Trigger hold off": "0",
"Trigger slope": "0",
"Trigger source": "0",
"Using Clock Negedge": 0,
"Using External Clock": 0,
"channel": [
{
"colour": "#eeb211",
"coupling": 0,
"enabled": true,
"index": 0,
"name": "0",
"strigger": 0,
"trigValue": 0.5,
"type": 10001,
"vdiv": 1000,
"vfactor": 1,
"zeroPos": 0.5
},
{
"colour": "#009925",
"coupling": 0,
"enabled": true,
"index": 1,
"name": "1",
"strigger": 0,
"trigValue": 0.5,
"type": 10001,
"vdiv": 1000,
"vfactor": 1,
"zeroPos": 0.5
}
]
}

43
DSView/res/DSLogic1.dsc Normal file
View File

@ -0,0 +1,43 @@
{
"Device": "DSLogic",
"DeviceMode": 1,
"Filter Targets": "None",
"Horizontal trigger position": "0",
"Operation Mode": "Normal",
"Sample count": "1048576",
"Sample rate": "100000000",
"Threshold Level": "1.8/2.5/3.3V Level",
"Trigger hold off": "0",
"Trigger slope": "0",
"Trigger source": "0",
"Using Clock Negedge": 0,
"Using External Clock": 0,
"channel": [
{
"colour": "#eeb211",
"coupling": 0,
"enabled": true,
"index": 0,
"name": "0",
"strigger": 0,
"trigValue": 0.5,
"type": 10001,
"vdiv": 1000,
"vfactor": 1,
"zeroPos": 0.5
},
{
"colour": "#009925",
"coupling": 0,
"enabled": true,
"index": 1,
"name": "1",
"strigger": 0,
"trigValue": 0.5,
"type": 10001,
"vdiv": 1000,
"vfactor": 1,
"zeroPos": 0.5
}
]
}

View File

@ -0,0 +1,89 @@
{
"Device": "DSLogic",
"DeviceMode": 2,
"Filter Targets": "None",
"Horizontal trigger position": "0",
"Operation Mode": "Normal",
"Sample count": "16777216",
"Sample rate": "100000000",
"Threshold Level": "1.8/2.5/3.3V Level",
"Trigger hold off": "0",
"Trigger slope": "0",
"Trigger source": "0",
"Using Clock Negedge": 0,
"Using External Clock": 0,
"channel": [
{
"colour": "#1185d1",
"enabled": true,
"index": 0,
"name": "0",
"strigger": 0,
"type": 10002
},
{
"colour": "#eeb211",
"enabled": true,
"index": 1,
"name": "1",
"strigger": 0,
"type": 10002
},
{
"colour": "#d50f25",
"enabled": true,
"index": 2,
"name": "2",
"strigger": 0,
"type": 10002
},
{
"colour": "#009925",
"enabled": true,
"index": 3,
"name": "3",
"strigger": 0,
"type": 10002
},
{
"colour": "#1185d1",
"enabled": true,
"index": 4,
"name": "4",
"strigger": 0,
"type": 10002
},
{
"colour": "#eeb211",
"enabled": true,
"index": 5,
"name": "5",
"strigger": 0,
"type": 10002
},
{
"colour": "#d50f25",
"enabled": true,
"index": 6,
"name": "6",
"strigger": 0,
"type": 10002
},
{
"colour": "#009925",
"enabled": true,
"index": 7,
"name": "7",
"strigger": 0,
"type": 10002
},
{
"colour": "#1185d1",
"enabled": true,
"index": 8,
"name": "8",
"strigger": 0,
"type": 10002
}
]
}

89
DSView/res/DSLogic2.dsc Normal file
View File

@ -0,0 +1,89 @@
{
"Device": "DSLogic",
"DeviceMode": 2,
"Filter Targets": "None",
"Horizontal trigger position": "0",
"Operation Mode": "Normal",
"Sample count": "16777216",
"Sample rate": "100000000",
"Threshold Level": "1.8/2.5/3.3V Level",
"Trigger hold off": "0",
"Trigger slope": "0",
"Trigger source": "0",
"Using Clock Negedge": 0,
"Using External Clock": 0,
"channel": [
{
"colour": "#1185d1",
"enabled": true,
"index": 0,
"name": "0",
"strigger": 0,
"type": 10002
},
{
"colour": "#eeb211",
"enabled": true,
"index": 1,
"name": "1",
"strigger": 0,
"type": 10002
},
{
"colour": "#d50f25",
"enabled": true,
"index": 2,
"name": "2",
"strigger": 0,
"type": 10002
},
{
"colour": "#009925",
"enabled": true,
"index": 3,
"name": "3",
"strigger": 0,
"type": 10002
},
{
"colour": "#1185d1",
"enabled": true,
"index": 4,
"name": "4",
"strigger": 0,
"type": 10002
},
{
"colour": "#eeb211",
"enabled": true,
"index": 5,
"name": "5",
"strigger": 0,
"type": 10002
},
{
"colour": "#d50f25",
"enabled": true,
"index": 6,
"name": "6",
"strigger": 0,
"type": 10002
},
{
"colour": "#009925",
"enabled": true,
"index": 7,
"name": "7",
"strigger": 0,
"type": 10002
},
{
"colour": "#1185d1",
"enabled": true,
"index": 8,
"name": "8",
"strigger": 0,
"type": 10002
}
]
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -369,10 +369,10 @@ SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver)
return NULL;
}
SR_API GSList *sr_dev_mode_list(const struct sr_dev_driver *driver)
SR_API GSList *sr_dev_mode_list(const struct sr_dev_inst *sdi)
{
if (driver && driver->dev_mode_list)
return driver->dev_mode_list();
if (sdi && sdi->driver && sdi->driver->dev_mode_list)
return sdi->driver->dev_mode_list(sdi);
else
return NULL;
}

View File

@ -767,8 +767,9 @@ static GSList *dev_list(void)
return ((struct drv_context *)(di->priv))->instances;
}
static GSList *dev_mode_list(void)
static GSList *dev_mode_list(const struct sr_dev_inst *sdi)
{
(void)sdi;
GSList *l = NULL;
int i;

View File

@ -47,6 +47,10 @@ static struct sr_dev_mode mode_list[] = {
{"OSC", DSO},
};
static struct sr_dev_mode pro_mode_list[] = {
{"LA", LOGIC},
};
static const char *opmodes[] = {
"Normal",
"Internal Test",
@ -833,15 +837,20 @@ static GSList *dev_list(void)
return ((struct drv_context *)(di->priv))->instances;
}
static GSList *dev_mode_list(void)
static GSList *dev_mode_list(const struct sr_dev_inst *sdi)
{
GSList *l = NULL;
int i;
for(i = 0; i < ARRAY_SIZE(mode_list); i++) {
l = g_slist_append(l, &mode_list[i]);
if (strcmp(sdi->model, "DSLogic Pro") == 0) {
for(i = 0; i < ARRAY_SIZE(pro_mode_list); i++) {
l = g_slist_append(l, &pro_mode_list[i]);
}
} else {
for(i = 0; i < ARRAY_SIZE(mode_list); i++) {
l = g_slist_append(l, &mode_list[i]);
}
}
return l;
}

View File

@ -266,8 +266,9 @@ static GSList *hw_dev_list(void)
return ((struct drv_context *)(di->priv))->instances;
}
static GSList *hw_dev_mode_list(void)
static GSList *hw_dev_mode_list(const struct sr_dev_inst *sdi)
{
(void)sdi;
GSList *l = NULL;
int i;

View File

@ -966,7 +966,7 @@ struct sr_dev_driver {
int (*cleanup) (void);
GSList *(*scan) (GSList *options);
GSList *(*dev_list) (void);
GSList *(*dev_mode_list) (void);
GSList *(*dev_mode_list) (const struct sr_dev_inst *sdi);
int (*dev_clear) (void);
int (*config_get) (int id, GVariant **data,

View File

@ -53,7 +53,7 @@ SR_API int sr_dev_trigger_set(const struct sr_dev_inst *sdi, int probenum,
const char *trigger);
SR_API gboolean sr_dev_has_option(const struct sr_dev_inst *sdi, int key);
SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver);
SR_API GSList *sr_dev_mode_list(const struct sr_dev_driver *driver);
SR_API GSList *sr_dev_mode_list(const struct sr_dev_inst *sdi);
SR_API int sr_dev_clear(const struct sr_dev_driver *driver);
SR_API int sr_dev_open(struct sr_dev_inst *sdi);
SR_API int sr_dev_close(struct sr_dev_inst *sdi);