Commit 5626a9ba authored by DreamSourceLab's avatar DreamSourceLab

add session load/store funtion

parent e37d3aec
...@@ -357,6 +357,10 @@ install(FILES res/DSLogicPro.fw DESTINATION bin/res/) ...@@ -357,6 +357,10 @@ install(FILES res/DSLogicPro.fw DESTINATION bin/res/)
install(FILES res/DSLogicPro.bin DESTINATION bin/res/) install(FILES res/DSLogicPro.bin DESTINATION bin/res/)
install(FILES res/DSCope.fw DESTINATION bin/res/) install(FILES res/DSCope.fw DESTINATION bin/res/)
install(FILES res/DSCope.bin DESTINATION bin/res/) install(FILES res/DSCope.bin DESTINATION bin/res/)
install(FILES res/DSLogic_ini.dsc DESTINATION bin/res/)
install(FILES res/DSLogic_ini.dsc.bak DESTINATION bin/res/)
install(FILES res/DSCope_ini.dsc DESTINATION bin/res/)
install(FILES res/DSCope_ini.dsc.bak DESTINATION bin/res/)
#=============================================================================== #===============================================================================
#= Packaging (handled by CPack) #= Packaging (handled by CPack)
......
...@@ -138,7 +138,7 @@ void DsoTriggerDock::pos_changed(int pos) ...@@ -138,7 +138,7 @@ void DsoTriggerDock::pos_changed(int pos)
int ret; int ret;
ret = _session.get_device()->set_config(NULL, NULL, ret = _session.get_device()->set_config(NULL, NULL,
SR_CONF_HORIZ_TRIGGERPOS, SR_CONF_HORIZ_TRIGGERPOS,
g_variant_new_uint16((uint16_t)pos)); g_variant_new_byte((uint8_t)pos));
if (!ret) { if (!ret) {
QMessageBox msg(this); QMessageBox msg(this);
msg.setText(tr("Trigger Setting Issue")); msg.setText(tr("Trigger Setting Issue"));
...@@ -206,7 +206,7 @@ void DsoTriggerDock::init() ...@@ -206,7 +206,7 @@ void DsoTriggerDock::init()
GVariant* gvar = _session.get_device()->get_config(NULL, NULL, GVariant* gvar = _session.get_device()->get_config(NULL, NULL,
SR_CONF_HORIZ_TRIGGERPOS); SR_CONF_HORIZ_TRIGGERPOS);
if (gvar != NULL) { if (gvar != NULL) {
uint16_t pos = g_variant_get_uint16(gvar); uint16_t pos = g_variant_get_byte(gvar);
g_variant_unref(gvar); g_variant_unref(gvar);
position_slider->setValue(pos); position_slider->setValue(pos);
} }
...@@ -222,7 +222,7 @@ void DsoTriggerDock::init() ...@@ -222,7 +222,7 @@ void DsoTriggerDock::init()
gvar = _session.get_device()->get_config(NULL, NULL, gvar = _session.get_device()->get_config(NULL, NULL,
SR_CONF_TRIGGER_SLOPE); SR_CONF_TRIGGER_SLOPE);
if (gvar != NULL) { if (gvar != NULL) {
uint8_t slope = g_variant_get_uint16(gvar); uint8_t slope = g_variant_get_byte(gvar);
g_variant_unref(gvar); g_variant_unref(gvar);
type_group->button(slope)->setChecked(true); type_group->button(slope)->setChecked(true);
} }
......
...@@ -300,7 +300,7 @@ void TriggerDock::adv_trigger() ...@@ -300,7 +300,7 @@ void TriggerDock::adv_trigger()
if (stream) { if (stream) {
QMessageBox msg(this); QMessageBox msg(this);
msg.setText(tr("Trigger")); msg.setText(tr("Trigger"));
msg.setInformativeText(tr("Stram Mode Don't Support Advanced Trigger!")); msg.setInformativeText(tr("Stream Mode Don't Support Advanced Trigger!"));
msg.setStandardButtons(QMessageBox::Ok); msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning); msg.setIcon(QMessageBox::Warning);
msg.exec(); msg.exec();
...@@ -522,5 +522,78 @@ void TriggerDock::init() ...@@ -522,5 +522,78 @@ void TriggerDock::init()
//position_slider->setValue(pos); //position_slider->setValue(pos);
} }
QJsonObject TriggerDock::get_session()
{
QJsonObject trigSes;
trigSes["triggerMode"] = adv_radioButton->isChecked() ? 1 : 0;
trigSes["triggerPos"] = position_slider->value();
trigSes["triggerStages"] = stages_comboBox->currentIndex();
trigSes["triggerSerial"] = _adv_tabWidget->currentIndex();
for (int i = 0; i < stages_comboBox->count(); i++) {
QString value0_str = "triggerValue0" + QString::number(i);
QString inv0_str = "triggerInv0" + QString::number(i);
QString count0_str = "triggerCount0" + QString::number(i);
QString value1_str = "triggerValue1" + QString::number(i);
QString inv1_str = "triggerInv1" + QString::number(i);
QString count1_str = "triggerCount1" + QString::number(i);
QString logic_str = "triggerLogic" + QString::number(i);
trigSes[value0_str] = _value0_lineEdit_list.at(i)->text();
trigSes[value1_str] = _value1_lineEdit_list.at(i)->text();
trigSes[inv0_str] = _inv0_comboBox_list.at(i)->currentIndex();
trigSes[inv1_str] = _inv1_comboBox_list.at(i)->currentIndex();
trigSes[count0_str] = _count0_spinBox_list.at(i)->value();
trigSes[count1_str] = _count1_spinBox_list.at(i)->value();
trigSes[logic_str] = _logic_comboBox_list.at(i)->currentIndex();
}
trigSes["triggerStart"] = _serial_start_lineEdit->text();
trigSes["triggerStop"] = _serial_stop_lineEdit->text();
trigSes["triggerClock"] = _serial_edge_lineEdit->text();
trigSes["triggerChannel"] = _serial_data_comboBox->currentIndex();
trigSes["triggerData"] = _serial_value_lineEdit->text();
return trigSes;
}
void TriggerDock::set_session(QJsonObject ses)
{
position_slider->setValue(ses["triggerPos"].toDouble());
stages_comboBox->setCurrentIndex(ses["triggerStages"].toDouble());
_adv_tabWidget->setCurrentIndex(ses["triggerSerial"].toDouble());
if (ses["triggerMode"].toDouble() == 0)
simple_radioButton->click();
else
adv_radioButton->click();
for (int i = 0; i < stages_comboBox->count(); i++) {
QString value0_str = "triggerValue0" + QString::number(i);
QString inv0_str = "triggerInv0" + QString::number(i);
QString count0_str = "triggerCount0" + QString::number(i);
QString value1_str = "triggerValue1" + QString::number(i);
QString inv1_str = "triggerInv1" + QString::number(i);
QString count1_str = "triggerCount1" + QString::number(i);
QString logic_str = "triggerLogic" + QString::number(i);
_value0_lineEdit_list.at(i)->setText(ses[value0_str].toString());
_value1_lineEdit_list.at(i)->setText(ses[value1_str].toString());
_inv0_comboBox_list.at(i)->setCurrentIndex(ses[inv0_str].toDouble());
_inv1_comboBox_list.at(i)->setCurrentIndex(ses[inv1_str].toDouble());
_count0_spinBox_list.at(i)->setValue(ses[count0_str].toDouble());
_count1_spinBox_list.at(i)->setValue(ses[count1_str].toDouble());
_logic_comboBox_list.at(i)->setCurrentIndex(ses[logic_str].toDouble());
}
_serial_start_lineEdit->setText(ses["triggerStart"].toString());
_serial_stop_lineEdit->setText(ses["triggerStop"].toString());
_serial_edge_lineEdit->setText(ses["triggerClock"].toString());
_serial_data_comboBox->setCurrentIndex(ses["triggerChannel"].toDouble());
_serial_value_lineEdit->setText(ses["triggerData"].toString());
value_changed();
logic_changed(0);
inv_changed(0);
count_changed();
}
} // namespace dock } // namespace dock
} // namespace pv } // namespace pv
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <QSpinBox> #include <QSpinBox>
#include <QGroupBox> #include <QGroupBox>
#include <QTableWidget> #include <QTableWidget>
#include <QJsonObject>
#include <QVector> #include <QVector>
#include <QVBoxLayout> #include <QVBoxLayout>
...@@ -63,9 +64,12 @@ public: ...@@ -63,9 +64,12 @@ public:
void init(); void init();
QJsonObject get_session();
void set_session(QJsonObject ses);
signals: signals:
private slots: public slots:
void simple_trigger(); void simple_trigger();
void adv_trigger(); void adv_trigger();
void trigger_stages_changed(int index); void trigger_stages_changed(int index);
......
...@@ -146,6 +146,10 @@ void MainWindow::setup_ui() ...@@ -146,6 +146,10 @@ void MainWindow::setup_ui()
SLOT(on_save())); SLOT(on_save()));
connect(_file_bar, SIGNAL(on_screenShot()), this, connect(_file_bar, SIGNAL(on_screenShot()), this,
SLOT(on_screenShot())); SLOT(on_screenShot()));
connect(_file_bar, SIGNAL(load_session(QString)), this,
SLOT(load_session(QString)));
connect(_file_bar, SIGNAL(store_session(QString)), this,
SLOT(store_session(QString)));
#ifdef ENABLE_DECODE #ifdef ENABLE_DECODE
// protocol dock // protocol dock
...@@ -311,10 +315,13 @@ void MainWindow::update_device_list() ...@@ -311,10 +315,13 @@ void MainWindow::update_device_list()
errorMessage, infoMessage)); errorMessage, infoMessage));
} }
if (strcmp(selected_device->dev_inst()->driver->name, "demo") != 0) if (strcmp(selected_device->dev_inst()->driver->name, "demo") != 0) {
_logo_bar->dsl_connected(true); _logo_bar->dsl_connected(true);
else QString ses_name = config_path + QString::fromLocal8Bit(selected_device->dev_inst()->driver->name) + "_ini.dsc";
load_session(ses_name);
} else {
_logo_bar->dsl_connected(false); _logo_bar->dsl_connected(false);
}
} }
void MainWindow::reload() void MainWindow::reload()
...@@ -537,7 +544,7 @@ void MainWindow::on_save() ...@@ -537,7 +544,7 @@ void MainWindow::on_save()
// Show the dialog // Show the dialog
const QString file_name = QFileDialog::getSaveFileName( const QString file_name = QFileDialog::getSaveFileName(
this, tr("Save File"), "", tr("DSView Sessions (*.dsl)")); this, tr("Save File"), "", tr("DSView Data (*.dsl)"));
if (file_name.isEmpty()) if (file_name.isEmpty())
return; return;
...@@ -546,6 +553,189 @@ void MainWindow::on_save() ...@@ -546,6 +553,189 @@ void MainWindow::on_save()
dlg->run(); dlg->run();
} }
bool MainWindow::load_session(QString name)
{
QFile sessionFile(name.toStdString().c_str());
if (!sessionFile.open(QIODevice::ReadOnly)) {
QMessageBox msg(this);
msg.setText(tr("File Error"));
msg.setInformativeText(tr("Couldn't open session file!"));
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
return false;
}
QByteArray sessionData = sessionFile.readAll();
QJsonDocument sessionDoc = QJsonDocument::fromJson(sessionData);
QJsonObject sessionObj = sessionDoc.object();
// check device and mode
const sr_dev_inst *const sdi = _session.get_device()->dev_inst();
if (strcmp(sdi->driver->name, sessionObj["Device"].toString().toLocal8Bit()) != 0 ||
sdi->mode != sessionObj["DeviceMode"].toDouble()) {
QMessageBox msg(this);
msg.setText(tr("Session Error"));
msg.setInformativeText(tr("Session File is not compatible with current device or mode!"));
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
return false;
}
// load device settings
GVariant *gvar_opts;
gsize num_opts;
if ((sr_config_list(sdi->driver, sdi, NULL, SR_CONF_DEVICE_SESSIONS, &gvar_opts) == SR_OK)) {
const int *const options = (const int32_t *)g_variant_get_fixed_array(
gvar_opts, &num_opts, sizeof(int32_t));
for (unsigned int i = 0; i < num_opts; i++) {
const struct sr_config_info *const info =
sr_config_info_get(options[i]);
if (info->datatype == SR_T_BOOL)
_session.get_device()->set_config(NULL, NULL, info->key, g_variant_new_boolean(sessionObj[info->name].toDouble()));
else if (info->datatype == SR_T_UINT64)
_session.get_device()->set_config(NULL, NULL, info->key, g_variant_new_uint64(sessionObj[info->name].toString().toULongLong()));
else if (info->datatype == SR_T_UINT8)
_session.get_device()->set_config(NULL, NULL, info->key, g_variant_new_byte(sessionObj[info->name].toString().toUInt()));
else if (info->datatype == SR_T_FLOAT)
_session.get_device()->set_config(NULL, NULL, info->key, g_variant_new_double(sessionObj[info->name].toDouble()));
else if (info->datatype == SR_T_CHAR)
_session.get_device()->set_config(NULL, NULL, info->key, g_variant_new_string(sessionObj[info->name].toString().toLocal8Bit()));
}
}
_sampling_bar->update_record_length();
_sampling_bar->update_sample_rate();
// load channel settings
for (const GSList *l = _session.get_device()->dev_inst()->channels; l; l = l->next) {
sr_channel *const probe = (sr_channel*)l->data;
assert(probe);
bool isEnabled = false;
foreach (const QJsonValue &value, sessionObj["channel"].toArray()) {
QJsonObject obj = value.toObject();
qDebug("obj.index = %d", obj["index"].toDouble());
if ((probe->index == obj["index"].toDouble()) &&
(probe->type == obj["type"].toDouble())) {
isEnabled = true;
probe->enabled = obj["enabled"].toBool();
//probe->colour = obj["colour"].toString();
probe->name = g_strdup(obj["name"].toString().toStdString().c_str());
probe->vdiv = obj["vdiv"].toDouble();
probe->coupling = obj["coupling"].toDouble();
probe->vfactor = obj["vfactor"].toDouble();
probe->trig_value = obj["trigValue"].toDouble();
//probe->zeroPos = obj["zeroPos"].toDouble();
break;
}
}
if (!isEnabled)
probe->enabled = false;
}
_session.init_signals();
// load signal setting
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals()) {
foreach (const QJsonValue &value, sessionObj["channel"].toArray()) {
QJsonObject obj = value.toObject();
if ((s->get_index() == obj["index"].toDouble()) &&
(s->get_type() == obj["type"].toDouble())) {
s->set_colour(QColor(obj["colour"].toString()));
s->set_trig(obj["strigger"].toDouble());
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
dsoSig->update_hDial();
//dsoSig->update_vDial();
dsoSig->set_zeroRate(obj["zeroPos"].toDouble());
dsoSig->set_enable(obj["enabled"].toBool());
dsoSig->set_trigRate(obj["trigValue"].toDouble());
}
break;
}
}
}
// load trigger settings
if (sessionObj.contains("trigger")) {
_trigger_widget->set_session(sessionObj["trigger"].toObject());
}
on_trigger(false);
}
bool MainWindow::store_session(QString name)
{
QFile sessionFile(name.toStdString().c_str());
if (!sessionFile.open(QIODevice::WriteOnly)) {
QMessageBox msg(this);
msg.setText(tr("File Error"));
msg.setInformativeText(tr("Couldn't open session file to write!"));
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
return false;
}
GVariant *gvar_opts;
GVariant *gvar;
gsize num_opts;
const sr_dev_inst *const sdi = _session.get_device()->dev_inst();
QJsonObject sessionVar;
QJsonObject triggerVar;
QJsonArray channelVar;
sessionVar["Device"] = QJsonValue::fromVariant(sdi->driver->name);
sessionVar["DeviceMode"] = QJsonValue::fromVariant(sdi->mode);
if ((sr_config_list(sdi->driver, sdi, NULL, SR_CONF_DEVICE_SESSIONS, &gvar_opts) != SR_OK))
return false; /* Driver supports no device instance sessions. */
const int *const options = (const int32_t *)g_variant_get_fixed_array(
gvar_opts, &num_opts, sizeof(int32_t));
for (unsigned int i = 0; i < num_opts; i++) {
const struct sr_config_info *const info =
sr_config_info_get(options[i]);
gvar = _session.get_device()->get_config(NULL, NULL, info->key);
if (gvar != NULL) {
if (info->datatype == SR_T_BOOL)
sessionVar[info->name] = QJsonValue::fromVariant(g_variant_get_boolean(gvar));
else if (info->datatype == SR_T_UINT64)
sessionVar[info->name] = QJsonValue::fromVariant(QString::number(g_variant_get_uint64(gvar)));
else if (info->datatype == SR_T_UINT8)
sessionVar[info->name] = QJsonValue::fromVariant(QString::number(g_variant_get_byte(gvar)));
else if (info->datatype == SR_T_FLOAT)
sessionVar[info->name] = QJsonValue::fromVariant(g_variant_get_double(gvar));
else if (info->datatype == SR_T_CHAR)
sessionVar[info->name] = QJsonValue::fromVariant(g_variant_get_string(gvar, NULL));
g_variant_unref(gvar);
}
}
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals()) {
QJsonObject s_obj;
s_obj["index"] = s->get_index();
s_obj["type"] = s->get_type();
s_obj["enabled"] = s->enabled();
s_obj["name"] = s->get_name();
s_obj["colour"] = QJsonValue::fromVariant(s->get_colour());
s_obj["strigger"] = s->get_trig();
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
s_obj["vdiv"] = QJsonValue::fromVariant(dsoSig->get_vDialValue());
s_obj["vfactor"] = QJsonValue::fromVariant(dsoSig->get_factor());
s_obj["coupling"] = dsoSig->get_acCoupling();
s_obj["trigValue"] = dsoSig->get_trigRate();
s_obj["zeroPos"] = dsoSig->get_zeroRate();
}
channelVar.append(s_obj);
}
sessionVar["channel"] = channelVar;
if (_session.get_device()->dev_inst()->mode == LOGIC) {
sessionVar["trigger"] = _trigger_widget->get_session();
}
QJsonDocument sessionDoc(sessionVar);
sessionFile.write(sessionDoc.toJson());
return true;
}
bool MainWindow::eventFilter(QObject *object, QEvent *event) bool MainWindow::eventFilter(QObject *object, QEvent *event)
{ {
......
...@@ -117,6 +117,9 @@ private slots: ...@@ -117,6 +117,9 @@ private slots:
void on_save(); void on_save();
bool load_session(QString name);
bool store_session(QString name);
/* /*
* hotplug slot function * hotplug slot function
*/ */
......
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
#include <QMessageBox> #include <QMessageBox>
#include <QProgressDialog> #include <QProgressDialog>
#include <QFile> #include <QFile>
#include <QJsonArray>
#include <QJsonDocument>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
...@@ -152,7 +154,6 @@ void SigSession::set_device(boost::shared_ptr<device::DevInst> dev_inst) throw(Q ...@@ -152,7 +154,6 @@ void SigSession::set_device(boost::shared_ptr<device::DevInst> dev_inst) throw(Q
} }
} }
void SigSession::set_file(const string &name) throw(QString) void SigSession::set_file(const string &name) throw(QString)
{ {
// Deslect the old device, because file type detection in File::create // Deslect the old device, because file type detection in File::create
...@@ -600,7 +601,7 @@ void SigSession::add_group() ...@@ -600,7 +601,7 @@ void SigSession::add_group()
std::vector< boost::shared_ptr<view::Signal> >::iterator i = _signals.begin(); std::vector< boost::shared_ptr<view::Signal> >::iterator i = _signals.begin();
while (i != _signals.end()) { while (i != _signals.end()) {
if ((*i)->get_type() == view::Trace::DS_LOGIC && (*i)->selected()) if ((*i)->get_type() == SR_CHANNEL_LOGIC && (*i)->selected())
probe_index_list.push_back((*i)->get_index()); probe_index_list.push_back((*i)->get_index());
i++; i++;
} }
...@@ -851,7 +852,22 @@ void SigSession::feed_in_meta(const sr_dev_inst *sdi, ...@@ -851,7 +852,22 @@ void SigSession::feed_in_meta(const sr_dev_inst *sdi,
void SigSession::feed_in_trigger(const ds_trigger_pos &trigger_pos) void SigSession::feed_in_trigger(const ds_trigger_pos &trigger_pos)
{ {
receive_trigger(trigger_pos.real_pos); if (_dev_inst->dev_inst()->mode != DSO) {
receive_trigger(trigger_pos.real_pos);
} else {
int probe_count = 0;
int probe_en_count = 0;
for (const GSList *l = _dev_inst->dev_inst()->channels;
l; l = l->next) {
const sr_channel *const probe = (const sr_channel *)l->data;
if (probe->type == SR_CHANNEL_DSO) {
probe_count++;
if (probe->enabled)
probe_en_count++;
}
}
receive_trigger(trigger_pos.real_pos * probe_count / probe_en_count);
}
} }
void SigSession::feed_in_logic(const sr_datafeed_logic &logic) void SigSession::feed_in_logic(const sr_datafeed_logic &logic)
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <QVariant> #include <QVariant>
#include <QTimer> #include <QTimer>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
#include <QJsonObject>
#include <libsigrok4DSL/libsigrok.h> #include <libsigrok4DSL/libsigrok.h>
#include <libusb.h> #include <libusb.h>
......
...@@ -46,6 +46,24 @@ FileBar::FileBar(SigSession &session, QWidget *parent) : ...@@ -46,6 +46,24 @@ FileBar::FileBar(SigSession &session, QWidget *parent) :
{ {
setMovable(false); setMovable(false);
_action_load = new QAction(this);
_action_load->setText(QApplication::translate(
"File", "&Load Session...", 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));
_action_store->setIcon(QIcon::fromTheme("file",
QIcon(":/icons/open.png")));
_action_store->setObjectName(QString::fromUtf8("actionStore"));
_file_button.addAction(_action_store);
connect(_action_store, SIGNAL(triggered()), this, SLOT(on_actionStore_triggered()));
_action_open = new QAction(this); _action_open = new QAction(this);
_action_open->setText(QApplication::translate( _action_open->setText(QApplication::translate(
"File", "&Open...", 0)); "File", "&Open...", 0));
...@@ -96,7 +114,7 @@ void FileBar::on_actionOpen_triggered() ...@@ -96,7 +114,7 @@ void FileBar::on_actionOpen_triggered()
// Show the dialog // Show the dialog
const QString file_name = QFileDialog::getOpenFileName( const QString file_name = QFileDialog::getOpenFileName(
this, tr("Open File"), "", tr( this, tr("Open File"), "", tr(
"DSView Sessions (*.dsl);;All Files (*.*)")); "DSView Data (*.dsl);;All Files (*.*)"));
if (!file_name.isEmpty()) if (!file_name.isEmpty())
load_file(file_name); load_file(file_name);
} }
...@@ -175,7 +193,7 @@ void FileBar::on_actionSave_triggered() ...@@ -175,7 +193,7 @@ void FileBar::on_actionSave_triggered()
}else { }else {
QString file_name = QFileDialog::getSaveFileName( QString file_name = QFileDialog::getSaveFileName(
this, tr("Save File"), "", this, tr("Save File"), "",
tr("DSView Session (*.dsl)")); tr("DSView Data (*.dsl)"));
if (!file_name.isEmpty()) { if (!file_name.isEmpty()) {
QFileInfo f(file_name); QFileInfo f(file_name);
if(f.suffix().compare("dsl")) if(f.suffix().compare("dsl"))
...@@ -185,6 +203,31 @@ void FileBar::on_actionSave_triggered() ...@@ -185,6 +203,31 @@ void FileBar::on_actionSave_triggered()
} }
} }
void FileBar::on_actionLoad_triggered()
{
// Show the dialog
const QString file_name = QFileDialog::getOpenFileName(
this, tr("Open Session"), "", tr(
"DSView Session (*.dsc)"));
if (!file_name.isEmpty())
load_session(file_name);
}
void FileBar::on_actionStore_triggered()
{
QString default_name = _session.get_device()->dev_inst()->driver->name;
QString file_name = QFileDialog::getSaveFileName(
this, tr("Save Session"), default_name,
tr("DSView Session (*.dsc)"));
if (!file_name.isEmpty()) {
QFileInfo f(file_name);
if(f.suffix().compare("dsc"))
file_name.append(tr(".dsc"));
store_session(file_name);
}
}
void FileBar::on_actionCapture_triggered() void FileBar::on_actionCapture_triggered()
{ {
on_screenShot(); on_screenShot();
......
...@@ -53,8 +53,12 @@ signals: ...@@ -53,8 +53,12 @@ signals:
void load_file(QString); void load_file(QString);
void save(); void save();
void on_screenShot(); void on_screenShot();
void load_session(QString);
void store_session(QString);
private slots: private slots:
void on_actionLoad_triggered();
void on_actionStore_triggered();
void on_actionOpen_triggered(); void on_actionOpen_triggered();
void on_actionSave_triggered(); void on_actionSave_triggered();
void on_actionCapture_triggered(); void on_actionCapture_triggered();
...@@ -66,6 +70,8 @@ private: ...@@ -66,6 +70,8 @@ private:
QToolButton _file_button; QToolButton _file_button;
QAction *_action_load;
QAction *_action_store;
QAction *_action_open; QAction *_action_open;
QAction *_action_save; QAction *_action_save;
QAction *_action_export; QAction *_action_export;
......
...@@ -54,7 +54,7 @@ const float AnalogSignal::EnvelopeThreshold = 256.0f; ...@@ -54,7 +54,7 @@ const float AnalogSignal::EnvelopeThreshold = 256.0f;
AnalogSignal::AnalogSignal(boost::shared_ptr<pv::device::DevInst> dev_inst, AnalogSignal::AnalogSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
boost::shared_ptr<data::Analog> data, boost::shared_ptr<data::Analog> data,
const sr_channel * const probe) : const sr_channel * const probe) :
Signal(dev_inst, probe, DS_ANALOG), Signal(dev_inst, probe, SR_CHANNEL_ANALOG),
_data(data) _data(data)
{ {
_colour = SignalColours[probe->index % countof(SignalColours)]; _colour = SignalColours[probe->index % countof(SignalColours)];
......
...@@ -117,7 +117,7 @@ const QColor DecodeTrace::OutlineColours[16] = { ...@@ -117,7 +117,7 @@ const QColor DecodeTrace::OutlineColours[16] = {
DecodeTrace::DecodeTrace(pv::SigSession &session, DecodeTrace::DecodeTrace(pv::SigSession &session,
boost::shared_ptr<pv::data::DecoderStack> decoder_stack, int index) : boost::shared_ptr<pv::data::DecoderStack> decoder_stack, int index) :
Trace(QString::fromUtf8( Trace(QString::fromUtf8(
decoder_stack->stack().front()->decoder()->name), index, Trace::DS_DECODER), decoder_stack->stack().front()->decoder()->name), index, SR_CHANNEL_DECODER),
_session(session), _session(session),
_decoder_stack(decoder_stack), _decoder_stack(decoder_stack),
_show_hide_mapper(this), _show_hide_mapper(this),
......
...@@ -112,7 +112,7 @@ const int DsoSignal::RightMargin = 30; ...@@ -112,7 +112,7 @@ const int DsoSignal::RightMargin = 30;
DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst, DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
boost::shared_ptr<data::Dso> data, boost::shared_ptr<data::Dso> data,
const sr_channel * const probe): const sr_channel * const probe):
Signal(dev_inst, probe, DS_DSO), Signal(dev_inst, probe, SR_CHANNEL_DSO),