Commit aa9d7c40 authored by DreamSourceLab's avatar DreamSourceLab
Browse files

Add multibytes search feature for protocol list viewer;Add absolute time to...

Add multibytes search feature for protocol list viewer;Add absolute time to session file;fix other minor issues
parent b1446b78
......@@ -62,20 +62,9 @@ int main(int argc, char *argv[])
DSApplication a(argc, argv);
// Language
#ifdef LANGUAGE_ZH_CN
QTranslator qtTrans;
qtTrans.load(":/qt_zh_CN");
a.installTranslator(&qtTrans);
QTranslator DSViewTrans;
DSViewTrans.load(":/DSView_zh");
a.installTranslator(&DSViewTrans);
#endif
// Set some application metadata
QApplication::setApplicationVersion(DS_VERSION_STRING);
QApplication::setApplicationName("DSView(Beta)");
QApplication::setApplicationName("DSView");
QApplication::setOrganizationDomain("http://www.DreamSourceLab.com");
// Parse arguments
......@@ -130,7 +119,6 @@ int main(int argc, char *argv[])
}
do {
#ifdef ENABLE_DECODE
// Initialise libsigrokdecode
if (srd_init(NULL) != SRD_OK) {
......
......@@ -60,7 +60,7 @@ const int64_t DecoderStack::DecodeChunkLength = 4 * 1024;
//const int64_t DecoderStack::DecodeChunkLength = 1024 * 1024;
const unsigned int DecoderStack::DecodeNotifyPeriod = 1024;
//mutex DecoderStack::_global_decode_mutex;
mutex DecoderStack::_global_decode_mutex;
DecoderStack::DecoderStack(pv::SigSession &session,
const srd_decoder *const dec) :
......@@ -145,12 +145,11 @@ void DecoderStack::build_row()
_rows[row] = decode::RowData();
std::map<const decode::Row, bool>::const_iterator iter = _rows_gshow.find(row);
if (iter == _rows_gshow.end()) {
_rows_gshow[row] = true;
if (row.title().contains("bit", Qt::CaseInsensitive) ||
row.title().contains("warning", Qt::CaseInsensitive)) {
_rows_gshow[row] = false;
_rows_lshow[row] = false;
} else {
_rows_gshow[row] = true;
_rows_lshow[row] = true;
}
}
......@@ -169,12 +168,11 @@ void DecoderStack::build_row()
_rows[row] = decode::RowData();
std::map<const decode::Row, bool>::const_iterator iter = _rows_gshow.find(row);
if (iter == _rows_gshow.end()) {
_rows_gshow[row] = true;
if (row.title().contains("bit", Qt::CaseInsensitive) ||
row.title().contains("warning", Qt::CaseInsensitive)) {
_rows_gshow[row] = false;
_rows_lshow[row] = false;
} else {
_rows_gshow[row] = true;
_rows_lshow[row] = true;
}
}
......@@ -553,7 +551,7 @@ void DecoderStack::decode_data(
void DecoderStack::decode_proc()
{
//lock_guard<mutex> decode_lock(_global_decode_mutex);
lock_guard<mutex> decode_lock(_global_decode_mutex);
optional<uint64_t> sample_count;
srd_session *session;
......
......@@ -169,7 +169,7 @@ private:
* @todo A proper solution should be implemented to allow multiple
* decode operations.
*/
//static boost::mutex _global_decode_mutex;
static boost::mutex _global_decode_mutex;
std::list< boost::shared_ptr<decode::Decoder> > _stack;
......
......@@ -183,6 +183,13 @@ GSList* DevInst::get_dev_mode_list()
return sr_dev_mode_list(sdi);
}
QString DevInst::name()
{
sr_dev_inst *const sdi = dev_inst();
assert(sdi);
return QString::fromLocal8Bit(sdi->driver->name);
}
bool DevInst::is_trigger_enabled() const
{
return false;
......
......@@ -109,6 +109,13 @@ public:
*/
GSList* get_dev_mode_list();
/**
* @brief Get the device name from the driver
*
* @return device name
*/
QString name();
virtual bool is_trigger_enabled() const;
public:
......
......@@ -47,7 +47,7 @@ using std::ostringstream;
using std::runtime_error;
using std::string;
char config_path[256];
extern char AppDataPath[256];
namespace pv {
......@@ -103,12 +103,9 @@ std::list<boost::shared_ptr<device::DevInst> > DeviceManager::driver_scan(
// Check If DSL hardware driver
if (strncmp(driver->name, "virtual", 7)) {
QDir dir(QCoreApplication::applicationDirPath());
if (!dir.cd("res"))
QDir dir(DS_RES_PATH);
if (!dir.exists())
return driver_devices;
QString str = dir.absolutePath() + "/";
QString str_utf8 = QString::fromLocal8Bit(str.toLocal8Bit());
strcpy(config_path, str_utf8.toUtf8().data());
}
// Do the scan
......
......@@ -243,7 +243,7 @@ void DsoTriggerDock::type_changed()
void DsoTriggerDock::device_change()
{
if (strcmp(_session.get_device()->dev_inst()->driver->name, "DSLogic") != 0) {
if (_session.get_device()->name() != "DSLogic") {
position_spinBox->setDisabled(true);
position_slider->setDisabled(true);
} else {
......
......@@ -39,6 +39,7 @@
#include <QHeaderView>
#include <QScrollBar>
#include <QLineEdit>
#include <QRegExp>
#include <boost/foreach.hpp>
#include <boost/shared_ptr.hpp>
......@@ -544,16 +545,54 @@ void ProtocolDock::search_pre()
{
// now the proxy only contains rows that match the name
// let's take the pre one and map it to the original model
if (_model_proxy.rowCount() == 0)
if (_model_proxy.rowCount() == 0) {
_table_view->scrollToTop();
_table_view->clearSelection();
_matchs_label->setText(QString::number(0));
_cur_search_index = -1;
return;
_cur_search_index -= 1;
if (_cur_search_index <= -1 || _cur_search_index >= _model_proxy.rowCount())
_cur_search_index = _model_proxy.rowCount() - 1;
QModelIndex matchingIndex = _model_proxy.mapToSource(_model_proxy.index(ceil(_cur_search_index),_model_proxy.filterKeyColumn()));
if(matchingIndex.isValid()){
}
int i;
uint64_t rowCount = _model_proxy.rowCount();
QModelIndex matchingIndex;
pv::data::DecoderModel *decoder_model = _session.get_decoder_model();
boost::shared_ptr<pv::data::DecoderStack> decoder_stack = decoder_model->getDecoderStack();
do {
_cur_search_index--;
if (_cur_search_index <= -1 || _cur_search_index >= _model_proxy.rowCount())
_cur_search_index = _model_proxy.rowCount() - 1;
matchingIndex = _model_proxy.mapToSource(_model_proxy.index(ceil(_cur_search_index),_model_proxy.filterKeyColumn()));
if (!decoder_stack || !matchingIndex.isValid())
break;
i = 1;
uint64_t row = matchingIndex.row() + 1;
uint64_t col = matchingIndex.column();
pv::data::decode::Annotation ann;
bool ann_valid;
while(i < _str_list.size()) {
QString nxt = _str_list.at(i);
do {
ann_valid = decoder_stack->list_annotation(ann, col, row);
row++;
}while(ann_valid && (ann.type() < 100 || ann.type() > 999));
QString source = ann.annotations().at(0);
if (ann_valid && source.contains(nxt))
i++;
else
break;
}
}while(i < _str_list.size() && --rowCount);
if(i >= _str_list.size() && matchingIndex.isValid()){
_table_view->scrollTo(matchingIndex);
_table_view->setCurrentIndex(matchingIndex);
_table_view->clicked(matchingIndex);
} else {
_table_view->scrollToTop();
_table_view->clearSelection();
_matchs_label->setText(QString::number(0));
_cur_search_index = -1;
}
}
......@@ -561,24 +600,67 @@ void ProtocolDock::search_nxt()
{
// now the proxy only contains rows that match the name
// let's take the pre one and map it to the original model
if (_model_proxy.rowCount() == 0)
if (_model_proxy.rowCount() == 0) {
_table_view->scrollToTop();
_table_view->clearSelection();
_matchs_label->setText(QString::number(0));
_cur_search_index = -1;
return;
_cur_search_index += 1;
if (_cur_search_index < 0 || _cur_search_index >= _model_proxy.rowCount())
_cur_search_index = 0;
QModelIndex matchingIndex = _model_proxy.mapToSource(_model_proxy.index(floor(_cur_search_index),_model_proxy.filterKeyColumn()));
if(matchingIndex.isValid()){
}
int i;
uint64_t rowCount = _model_proxy.rowCount();
QModelIndex matchingIndex;
pv::data::DecoderModel *decoder_model = _session.get_decoder_model();
boost::shared_ptr<pv::data::DecoderStack> decoder_stack = decoder_model->getDecoderStack();
do {
_cur_search_index++;
if (_cur_search_index < 0 || _cur_search_index >= _model_proxy.rowCount())
_cur_search_index = 0;
matchingIndex = _model_proxy.mapToSource(_model_proxy.index(floor(_cur_search_index),_model_proxy.filterKeyColumn()));
if (!decoder_stack || !matchingIndex.isValid())
break;
i = 1;
uint64_t row = matchingIndex.row() + 1;
uint64_t col = matchingIndex.column();
pv::data::decode::Annotation ann;
bool ann_valid;
while(i < _str_list.size()) {
QString nxt = _str_list.at(i);
do {
ann_valid = decoder_stack->list_annotation(ann, col, row);
row++;
}while(ann_valid && (ann.type() < 100 || ann.type() > 999));
QString source = ann.annotations().at(0);
if (ann_valid && source.contains(nxt))
i++;
else
break;
}
}while(i < _str_list.size() && --rowCount);
if(i >= _str_list.size() && matchingIndex.isValid()){
_table_view->scrollTo(matchingIndex);
_table_view->setCurrentIndex(matchingIndex);
_table_view->clicked(matchingIndex);
} else {
_table_view->scrollToTop();
_table_view->clearSelection();
_matchs_label->setText(QString::number(0));
_cur_search_index = -1;
}
}
void ProtocolDock::search_done()
{
QString str = _search_edit->text().trimmed();
_model_proxy.setFilterFixedString(str);
_matchs_label->setText(QString::number(_model_proxy.rowCount()));
QRegExp rx("(-)");
_str_list = str.split(rx);
_model_proxy.setFilterFixedString(_str_list.first());
if (_str_list.size() > 1)
_matchs_label->setText("...");
else
_matchs_label->setText(QString::number(_model_proxy.rowCount()));
}
......
......@@ -89,6 +89,7 @@ private:
SigSession &_session;
QSortFilterProxyModel _model_proxy;
double _cur_search_index;
QStringList _str_list;
QSplitter *_split_widget;
QWidget *_up_widget;
......
......@@ -285,7 +285,7 @@ void TriggerDock::simple_trigger()
void TriggerDock::adv_trigger()
{
if (strcmp(_session.get_device()->dev_inst()->driver->name, "DSLogic") == 0) {
if (_session.get_device()->name() == "DSLogic") {
bool stream = false;
GVariant *gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_STREAM);
if (gvar != NULL) {
......@@ -368,7 +368,7 @@ void TriggerDock::device_change()
g_variant_unref(gvar);
}
if (!strncmp(_session.get_device()->dev_inst()->driver->name, "virtual", 7) ||
if (_session.get_device()->name().contains("virtual") ||
stream) {
simple_radioButton->setChecked(true);
simple_trigger();
......
......@@ -87,6 +87,8 @@ using boost::dynamic_pointer_cast;
using std::list;
using std::vector;
extern char AppDataPath[256];
namespace pv {
MainWindow::MainWindow(DeviceManager &device_manager,
......@@ -316,16 +318,17 @@ void MainWindow::update_device_list()
errorMessage, infoMessage));
}
if (strncmp(selected_device->dev_inst()->driver->name, "virtual", 7)) {
if (!selected_device->name().contains("virtual")) {
_logo_bar->dsl_connected(true);
QString ses_name = config_path +
QString::fromUtf8(selected_device->dev_inst()->driver->name) +
QString ses_name = DS_RES_PATH +
selected_device->name() +
QString::number(selected_device->dev_inst()->mode) +
".dsc";
load_session(ses_name);
} else {
_logo_bar->dsl_connected(false);
}
_view->status_clear();
}
void MainWindow::reload()
......@@ -386,6 +389,8 @@ void MainWindow::device_detach()
if (_session.get_capture_state() == SigSession::Running)
_session.stop_capture();
session_save();
struct sr_dev_driver **const drivers = sr_driver_list();
struct sr_dev_driver **driver;
for (driver = drivers; *driver; driver++)
......@@ -488,40 +493,25 @@ void MainWindow::capture_state_changed(int state)
_sampling_bar->enable_toggle(state != SigSession::Running);
_trig_bar->enable_toggle(state != SigSession::Running);
_measure_dock->widget()->setEnabled(state != SigSession::Running);
if (_session.get_device()->dev_inst()->mode == LOGIC &&
state == SigSession::Stopped) {
GVariant *gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_RLE);
if (gvar != NULL) {
bool rle = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (rle) {
gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_ACTUAL_SAMPLES);
if (gvar != NULL) {
uint64_t actual_samples = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
if (actual_samples != _session.cur_samplelimits()) {
show_session_error(tr("RLE Mode Warning"),
tr("Hardware buffer is full!\nActually received samples is less than setted sample depth!"));
}
}
}
}
}
}
}
void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::session_save()
{
QDir dir(QCoreApplication::applicationDirPath());
if (dir.cd("res")) {
QString driver_name = _session.get_device()->dev_inst()->driver->name;
QDir dir(DS_RES_PATH);
if (dir.exists()) {
QString driver_name = _session.get_device()->name();
QString mode_name = QString::number(_session.get_device()->dev_inst()->mode);
QString file_name = dir.absolutePath() + "/" + driver_name + mode_name + ".dsc";
if (strncmp(driver_name.toLocal8Bit(), "virtual", 7) &&
!file_name.isEmpty())
store_session(file_name);
}
}
void MainWindow::closeEvent(QCloseEvent *event)
{
session_save();
event->accept();
}
......
......@@ -86,6 +86,8 @@ private:
bool eventFilter(QObject *object, QEvent *event);
void session_save();
private slots:
void load_file(QString file_name);
......
......@@ -232,7 +232,7 @@ void SigSession::save_file(const QString name, int type){
}
sr_session_save(name.toLocal8Bit().data(), _dev_inst->dev_inst(),
data, unit_size, sample_count);
data, unit_size, sample_count, _trigger_time.toMSecsSinceEpoch(), _trigger_pos);
}
QList<QString> SigSession::getSuportedExportFormats(){
......@@ -408,8 +408,7 @@ void SigSession::set_default_device(boost::function<void (const QString)> error_
// Try and find the DreamSourceLab device and select that by default
BOOST_FOREACH (boost::shared_ptr<pv::device::DevInst> dev, devices)
if (dev->dev_inst() &&
strncmp(dev->dev_inst()->driver->name,
"virtual", 7) != 0) {
!dev->name().contains("virtual")) {
default_device = dev;
break;
}
......@@ -530,7 +529,7 @@ void SigSession::start_capture(bool instant,
}
// update setting
if (strcmp(_dev_inst->dev_inst()->driver->name, "virtual-session"))
if (_dev_inst->name() != "virtual-session")
_instant = instant;
else
_instant = true;
......@@ -674,10 +673,6 @@ void SigSession::check_update()
}
}
void SigSession::feed_in_header(const sr_dev_inst *sdi)
{
}
void SigSession::add_group()
{
std::list<int> probe_index_list;
......@@ -909,7 +904,7 @@ void SigSession::refresh(int holdtime)
{
boost::lock_guard<boost::mutex> lock(_data_mutex);
if (strncmp(_dev_inst->dev_inst()->driver->name, "virtual", 7)) {
if (!_dev_inst->name().contains("virtual")) {
_data_lock = true;
_refresh_timer.start(holdtime);
}
......@@ -951,6 +946,26 @@ bool SigSession::get_data_lock()
return _data_lock;
}
void SigSession::feed_in_header(const sr_dev_inst *sdi)
{
_trigger_pos = 0;
_trigger_time = QDateTime::currentDateTime();
const int64_t secs = -cur_sampletime();
_trigger_time = _trigger_time.addSecs(secs);
if (_dev_inst->name() == "virtual-session") {
int64_t time;
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_TRIGGER_TIME);
if (gvar != NULL) {
time = g_variant_get_int64(gvar);
g_variant_unref(gvar);
if (time != 0)
_trigger_time = QDateTime::fromMSecsSinceEpoch(time);
}
}
receive_header();
}
void SigSession::feed_in_meta(const sr_dev_inst *sdi,
const sr_datafeed_meta &meta)
{
......@@ -973,7 +988,14 @@ void SigSession::feed_in_meta(const sr_dev_inst *sdi,
void SigSession::feed_in_trigger(const ds_trigger_pos &trigger_pos)
{
if (_dev_inst->dev_inst()->mode != DSO) {
receive_trigger(trigger_pos.real_pos);
_trigger_pos = trigger_pos.real_pos;
receive_trigger(_trigger_pos);
if (_dev_inst->name() != "virtual-session") {
const double time = trigger_pos.real_pos * 1.0 / _cur_samplerate;
_trigger_time = QDateTime::currentDateTime();
const int64_t secs = time - cur_sampletime();
_trigger_time = _trigger_time.addSecs(secs);
}
} else {
int probe_count = 0;
int probe_en_count = 0;
......@@ -986,7 +1008,8 @@ void SigSession::feed_in_trigger(const ds_trigger_pos &trigger_pos)
probe_en_count++;
}
}
receive_trigger(trigger_pos.real_pos * probe_count / probe_en_count);
_trigger_pos = trigger_pos.real_pos * probe_count / probe_en_count;
receive_trigger(_trigger_pos);
}
}
......@@ -1218,9 +1241,6 @@ void SigSession::hotplug_proc(boost::function<void (const QString)> error_handle
if (_hot_detach) {
qDebug("DreamSourceLab hardware detached!");
device_detach();
_logic_data.reset();
_dso_data.reset();
_analog_data.reset();
_hot_detach = false;
}
boost::this_thread::sleep(boost::posix_time::millisec(100));
......@@ -1487,4 +1507,14 @@ vector< boost::shared_ptr<view::MathTrace> > SigSession::get_math_signals()
return _math_traces;
}
QDateTime SigSession::get_trigger_time() const
{
return _trigger_time;
}
uint64_t SigSession::get_trigger_pos() const
{
return _trigger_pos;
}
} // namespace pv
......@@ -131,6 +131,8 @@ public:
uint64_t cur_samplerate() const;
uint64_t cur_samplelimits() const;
double cur_sampletime() const;
QDateTime get_trigger_time() const;
uint64_t get_trigger_pos() const;
void start_capture(bool instant,
boost::function<void (const QString)> error_handler);
......@@ -274,6 +276,9 @@ private:
bool _data_lock;
bool _data_updated;
QDateTime _trigger_time;
uint64_t _trigger_pos;
signals:
void capture_state_changed(int state);
......@@ -292,6 +297,8 @@ signals:
void receive_trigger(quint64 trigger_pos);
void receive_header();
void dso_ch_changed(uint16_t num);
void frame_began();
......
......@@ -34,6 +34,8 @@
#include <deque>
extern char AppDataPath[256];
namespace pv {
namespace toolbars {
......@@ -109,11 +111,7 @@ FileBar::FileBar(SigSession &session, QWidget *parent) :
connect(_action_capture, SIGNAL(triggered()), this, SLOT(on_actionCapture_triggered()));
_file_button.setPopupMode(QToolButton::InstantPopup);
#ifdef LANGUAGE_ZH_CN
_file_button.setIcon(QIcon(":/icons/file_cn.png"));
#else
_file_button.setIcon(QIcon(":/icons/file.png"));
#endif
_menu = new QMenu(this);
_menu->addMenu(_menu_session);
......@@ -226,8 +224,8 @@ void FileBar::on_actionLoad_triggered()
void FileBar::on_actionDefault_triggered()
{
QDir dir(QCoreApplication::applicationDirPath());
if (!dir.cd("res")) {
QDir dir(DS_RES_PATH);
if (!dir.exists()) {
QMessageBox msg(this);
msg.setText(tr("Session Load"));
msg.setInformativeText(tr("Cannot find default session file for this device!"));
......@@ -237,7 +235,7 @@ void FileBar::on_actionDefault_triggered()
return;
}
QString driver_name = _session.get_device()->dev_inst()->driver->name;
QString driver_name = _session.get_device()->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())
......@@ -246,7 +244,7 @@ void FileBar::on_actionDefault_triggered()
void FileBar::on_actionStore_triggered()
{
QString default_name = _session.get_device()->dev_inst()->driver->name;
QString default_name = _session.get_device()->name();
QString file_name = QFileDialog::getSaveFileName(
this, tr("Save Session"), default_name,
tr("DSView Session (*.dsc)"));
......@@ -266,13 +264,8 @@ void FileBar::on_actionCapture_triggered()
void FileBar::enable_toggle(bool enable)
{
_file_button.setDisabled(!enable);
#ifdef LANGUAGE_ZH_CN
_file_button.setIcon(enable ? QIcon(":/icons/file_cn.png") :
QIcon(":/icons/file_dis_cn.png"));
#else
_file_button.setIcon(enable ? QIcon(":/icons/file.png") :
QIcon(":/icons/file_dis.png"));
#endif
}
} // namespace toolbars
......
......@@ -87,19 +87,11 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
_sample_rate(this),
_updating_sample_rate(false),
_updating_sample_count(false),
#ifdef LANGUAGE_ZH_CN
_icon_stop(":/icons/stop_cn.png"),
_icon_start(":/icons/start_cn.png"),
_icon_instant(":/icons/instant_cn.png"),
_icon_start_dis(":/icons/start_dis_cn.png"),
_icon_instant_dis(":/icons/instant_dis_cn.png"),
#else
_icon_stop(":/icons/stop.png"),
_icon_start(":/icons/start.png"),
_icon_instant(":/icons/instant.png"),
_icon_start_dis(":/icons/start_dis.png"),
_icon_instant_dis(":/icons/instant_dis.png"),
#endif
_run_stop_button(this),
_instant_button(this),
_instant(false)
......@@ -115,13 +107,9 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
connect(&_instant_button, SIGNAL(clicked()),
this, SLOT(on_instant_stop()));
#ifdef LANGUAGE_ZH_CN
_configure_button.setIcon(QIcon::fromTheme("configure",
QIcon(":/icons/params_cn.png")));
#else
_configure_button.setIcon(QIcon::fromTheme("configure",
QIcon(":/icons/params.png")));
#endif
_run_stop_button.setIcon(_icon_start);
_instant_button.setIcon(_icon_instant);
......@@ -337,13 +325,8 @@ void SamplingBar::set_sampling(bool sampling)
}
_configure_button.setEnabled(!sampling);
#ifdef LANGUAGE_ZH_CN
_configure_button.setIcon(sampling ? QIcon(":/icons/params_dis_cn.png") :
QIcon(":/icons/params_cn.png"));
#else
_configure_button.setIcon(sampling ? QIcon(":/icons/params_dis.png") :
QIcon(":/icons/params.png"));
#endif
}
void SamplingBar::set_sample_rate(uint64_t sample_rate)
......@@ -492,7 +475,7 @@ void SamplingBar::on_samplecount_sel(int index)
boost::shared_ptr<pv::device::DevInst> _devInst = get_selected_device();
assert(_devInst);
if (strcmp(_devInst->dev_inst()->driver->name, "DSLogic") == 0 && _devInst->dev_inst()->mode != DSO) {
if (_devInst->name() == "DSLogic" && _devInst->dev_inst()->mode != DSO) {
// Set the sample count
_devInst->set_config(NULL, NULL,
......@@ -517,7 +500,7 @@ void SamplingBar::on_samplerate_sel(int index)
// Get last samplerate
//last_sample_rate = get_selected_device()->get_sample_rate();
if (strcmp(_devInst->dev_inst()->driver->name, "DSLogic") == 0 && _devInst->dev_inst()->mode != DSO) {
if (_devInst->name() == "DSLogic" && _devInst->dev_inst()->mode != DSO) {
// Set the samplerate
get_selected_device()->set_config(NULL, NULL,
SR_CONF_SAMPLERATE,
......
......@@ -52,24 +52,6 @@ TrigBar::TrigBar(SigSession &session, QWidget *parent) :
connect(&_search_button, SIGNAL(clicked()),
this, SLOT(search_clicked()));
#ifdef LANGUAGE_ZH_CN
_trig_button.setIcon(QIcon::fromTheme("trig",
QIcon(":/icons/trigger_cn.png")));
_trig_button.setCheckable(true);
_protocol_button.setIcon(QIcon::fromTheme("trig",
QIcon(":/icons/protocol_cn.png")));
#ifdef ENABLE_DECODE
_protocol_button.setCheckable(true);
#endif
_measure_button.setIcon(QIcon::fromTheme("trig",
QIcon(":/icons/measure_cn.png")));
_measure_button.setCheckable(true);
_search_button.setIcon(QIcon::fromTheme("trig",
QIcon(":/icons/search-bar_cn.png")));
_search_button.setCheckable(true);
_math_button.setIcon(QIcon::fromTheme("trig",
QIcon(":/icons/math_cn.png")));
#else
_trig_button.setIcon(QIcon::fromTheme("trig",
QIcon(":/icons/trigger.png")));
_trig_button.setCheckable(true);
......@@ -86,7 +68,6 @@ TrigBar::TrigBar(SigSession &session, QWidget *parent) :
_search_button.setCheckable(true);
_math_button.setIcon(QIcon::fromTheme("trig",
QIcon(":/icons/math.png")));
#endif
_action_fft = new QAction(this);
_action_fft->setText(QApplication::translate(
......@@ -142,18 +123,6 @@ void TrigBar::enable_toggle(bool enable)
_search_button.setDisabled(!enable);
_math_button.setDisabled(!enable);
#ifdef LANGUAGE_ZH_CN
_trig_button.setIcon(enable ? QIcon::fromTheme("trig", QIcon(":/icons/trigger_cn.png")) :
QIcon::fromTheme("trig", QIcon(":/icons/trigger_dis_cn.png")));
_protocol_button.setIcon(enable ? QIcon::fromTheme("trig", QIcon(":/icons/protocol_cn.png")) :
QIcon::fromTheme("trig", QIcon(":/icons/protocol_dis_cn.png")));
_measure_button.setIcon(enable ? QIcon::fromTheme("trig", QIcon(":/icons/measure_cn.png")) :
QIcon::fromTheme("trig", QIcon(":/icons/measure_dis_cn.png")));
_search_button.setIcon(enable ? QIcon::fromTheme("trig", QIcon(":/icons/search-bar_cn.png")) :
QIcon::fromTheme("trig", QIcon(":/icons/search-bar_dis_cn.png")));
_math_button.setIcon(enable ? QIcon::fromTheme("trig", QIcon(":/icons/math_cn.png")) :
QIcon::fromTheme("trig", QIcon(":/icons/math_dis_cn.png")));
#else
_trig_button.setIcon(enable ? QIcon::fromTheme("trig", QIcon(":/icons/trigger.png")) :
QIcon::fromTheme("trig", QIcon(":/icons/trigger_dis.png")));
_protocol_button.setIcon(enable ? QIcon::fromTheme("trig", QIcon(":/icons/protocol.png")) :
......@@ -164,20 +133,13 @@ void TrigBar::enable_toggle(bool enable)
QIcon::fromTheme("trig", QIcon(":/icons/search-bar_dis.png")));
_math_button.setIcon(enable ? QIcon::fromTheme("trig", QIcon(":/icons/math.png")) :
QIcon::fromTheme("trig", QIcon(":/icons/math_dis.png")));
#endif
}
void TrigBar::enable_protocol(bool enable)
{
_protocol_button.setDisabled(!enable);
#ifdef LANGUAGE_ZH_CN
_protocol_button.setIcon(enable ? QIcon::fromTheme("trig", QIcon(":/icons/protocol_cn.png")) :
QIcon::fromTheme("trig", QIcon(":/icons/protocol_dis_cn.png")));
#else
_protocol_button.setIcon(enable ? QIcon::fromTheme("trig", QIcon(":/icons/protocol.png")) :
QIcon::fromTheme("trig", QIcon(":/icons/protocol_dis.png")));
#endif
}
void TrigBar::close_all()
......
......@@ -199,7 +199,7 @@ float DsoSignal::get_scale()
void DsoSignal::set_enable(bool enable)
{
if ((strcmp(_dev_inst->dev_inst()->driver->name, "DSLogic") == 0) &&
if (_dev_inst->name() == "DSLogic" &&
get_index() == 0)
return;
_view->session().refresh(INT_MAX);
......@@ -524,7 +524,7 @@ bool DsoSignal::load_settings()
qDebug() << "ERROR: config_get SR_CONF_TRIGGER_VALUE failed.";
return false;
}
bool isDSCope = (strcmp(_dev_inst->dev_inst()->driver->name, "DSCope") == 0);
bool isDSCope = (_dev_inst->name() == "DSCope");
if (isDSCope) {
_trig_vpos = min(max(trigger_value/255.0, 0+TrigMargin), 1-TrigMargin);
} else {
......@@ -617,7 +617,7 @@ void DsoSignal::set_trig_vpos(int pos)
int trig_value;
if (enabled()) {
double delta = min((double)max(pos - UpMargin, 0), get_view_rect().height()) * 1.0 / get_view_rect().height();
bool isDSCope = (strcmp(_dev_inst->dev_inst()->driver->name, "DSCope") == 0);
bool isDSCope = (_dev_inst->name() == "DSCope");
if (isDSCope) {
trig_value = delta * 255.0 + 0.5;
_trig_vpos = min(max(trig_value/255.0, 0+TrigMargin), 1-TrigMargin);
......@@ -637,7 +637,7 @@ void DsoSignal::set_trigRate(double rate)
{
int trig_value;
double delta = rate;
bool isDSCope = (strcmp(_dev_inst->dev_inst()->driver->name, "DSCope") == 0);
bool isDSCope = (_dev_inst->name() == "DSCope");
if (isDSCope) {
trig_value = delta * 255.0 + 0.5;
_trig_vpos = min(max(trig_value/255.0, 0+TrigMargin), 1-TrigMargin);
......@@ -781,7 +781,7 @@ QString DsoSignal::get_ms_string(int index) const
void DsoSignal::update_zeroPos()
{
if (strcmp(_dev_inst->dev_inst()->driver->name, "DSCope") == 0) {
if (_dev_inst->name() == "DSCope") {
//double vpos_off = (0.5 - _zeroPos) * _vDial->get_value() * DS_CONF_DSO_VDIVS;
double vpos_off = (0.5 - (get_zeroPos() - UpMargin) * 1.0/get_view_rect().height()) * _vDial->get_value() * DS_CONF_DSO_VDIVS;
_dev_inst->set_config(_probe, NULL, SR_CONF_VPOS,
......@@ -888,7 +888,7 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right)
return;
const uint16_t number_channels = snapshot->get_channel_num();
if ((strcmp(_dev_inst->dev_inst()->driver->name, "DSLogic") == 0) &&
if (_dev_inst->name() == "DSLogic" &&
(unsigned int)get_index() >= number_channels)
return;
......@@ -999,7 +999,7 @@ void DsoSignal::paint_trace(QPainter &p,
float top = get_view_rect().top();
float bottom = get_view_rect().bottom();
float zeroP = _zeroPos * get_view_rect().height() + top;;
if (strcmp(_dev_inst->dev_inst()->driver->name, "DSCope") == 0 &&
if (_dev_inst->name() == "DSCope" &&
_view->session().get_capture_state() == SigSession::Running)
_zero_off = _zeroPos * 255;
float x = (start / samples_per_pixel - pixels_offset) + left;
......@@ -1055,7 +1055,7 @@ void DsoSignal::paint_envelope(QPainter &p,
float top = get_view_rect().top();
float bottom = get_view_rect().bottom();
float zeroP = _zeroPos * get_view_rect().height() + top;
if (strcmp(_dev_inst->dev_inst()->driver->name, "DSCope") == 0 &&
if (_dev_inst->name() == "DSCope" &&
_view->session().get_capture_state() == SigSession::Running)
_zero_off = _zeroPos * 255;
for(uint64_t sample = 0; sample < e.length-1; sample++) {
......@@ -1172,7 +1172,7 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
const QRectF x100_rect = get_rect(DSO_X100, y, right);
if (chEn_rect.contains(pt)) {
if (strcmp(_dev_inst->dev_inst()->driver->name, "virtual-session") &&
if (_dev_inst->name() != "virtual-session" &&
!_view->session().get_data_lock())
set_enable(!enabled());
return true;
......@@ -1197,9 +1197,9 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
setted = true;
}
}
} else if (strcmp(_dev_inst->dev_inst()->driver->name, "virtual-session") &&
} else if (_dev_inst->name() != "virtual-session" &&
acdc_rect.contains(pt)) {
if (strcmp(_view->session().get_device()->dev_inst()->driver->name, "DSLogic") == 0)
if (_dev_inst->name() == "DSLogic")
set_acCoupling((get_acCoupling()+1)%2);
else
set_acCoupling((get_acCoupling()+1)%2);
......
......@@ -73,7 +73,7 @@ View::View(SigSession &session, pv::toolbars::SamplingBar *sampling_bar, QWidget
QScrollArea(parent),
_session(session),
_sampling_bar(sampling_bar),
_scale(1e-8),
_scale(1e-5),
_preScale(1e-6),
_maxscale(1e9),
_minscale(1e-15),
......@@ -81,7 +81,6 @@ View::View(SigSession &session, pv::toolbars::SamplingBar *sampling_bar, QWidget
_preOffset(0),
_updating_scroll(false),
_show_cursors(false),
_trig_pos(0),
_hover_point(-1, -1)
{
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
......@@ -136,12 +135,13 @@ View::View(SigSession &session, pv::toolbars::SamplingBar *sampling_bar, QWidget
_viewcenter = new QWidget(this);
_viewcenter->setContentsMargins(0,0,0,0);
QGridLayout* layout = new QGridLayout(_viewcenter);
layout->setSpacing(0);
layout->setContentsMargins(0,0,0,0);
_viewcenter->setLayout(layout);
layout->addWidget(_vsplitter, 0, 0);
QWidget* bottom = new QWidget(this);
bottom->setFixedHeight(10);
layout->addWidget(bottom, 1, 0);
_viewbottom = new widgets::ViewStatus(this);
_viewbottom->setFixedHeight(StatusHeight);
layout->addWidget(_viewbottom, 1, 0);
setViewport(_viewcenter);
connect(_vsplitter, SIGNAL(splitterMoved(int,int)),
this, SLOT(splitterMoved(int, int)));
......@@ -152,8 +152,14 @@ View::View(SigSession &session, pv::toolbars::SamplingBar *sampling_bar, QWidget
this, SLOT(signals_changed()), Qt::DirectConnection);
connect(&_session, SIGNAL(data_updated()),
this, SLOT(data_updated()));
connect(&_session, SIGNAL(receive_header()),
this, SLOT(receive_header()));
connect(&_session, SIGNAL(receive_trigger(quint64)),
this, SLOT(set_trig_pos(quint64)));
connect(&_session, SIGNAL(frame_ended()),
this, SLOT(receive_end()));
connect(&_session, SIGNAL(frame_began()),
this, SLOT(frame_began()));
connect(&_session, SIGNAL(show_region(uint64_t,uint64_t)),
this, SLOT(show_region(uint64_t, uint64_t)));
......@@ -321,27 +327,6 @@ void View::set_preScale_preOffset()
vector< boost::shared_ptr<Trace> > View::get_traces(int type)
{
// const vector< boost::shared_ptr<Signal> > sigs(_session.get_signals());
// const vector< boost::shared_ptr<GroupSignal> > groups(_session.get_group_signals());
//#ifdef ENABLE_DECODE
// const vector< boost::shared_ptr<DecodeTrace> > decode_sigs(
// _session.get_decode_signals());
// vector< boost::shared_ptr<Trace> > traces(
// sigs.size() + groups.size() + decode_sigs.size());
//#else
// vector< boost::shared_ptr<Trace> > traces(sigs.size() + groups.size());
//#endif
// vector< boost::shared_ptr<Trace> >::iterator i = traces.begin();
// i = copy(sigs.begin(), sigs.end(), i);
//#ifdef ENABLE_DECODE
// i = copy(decode_sigs.begin(), decode_sigs.end(), i);
//#endif
// i = copy(groups.begin(), groups.end(), i);
// stable_sort(traces.begin(), traces.end(), compare_trace_v_offsets);
// return traces;
const vector< boost::shared_ptr<Signal> > sigs(_session.get_signals());
const vector< boost::shared_ptr<GroupSignal> > groups(_session.get_group_signals());
#ifdef ENABLE_DECODE
......@@ -422,20 +407,52 @@ void View::show_search_cursor(bool show)
viewport_update();
}
void View::status_clear()
{
_viewbottom->clear();
}
void View::receive_header()
{
status_clear();
}
void View::frame_began()
{
if (_session.get_device()->dev_inst()->mode == LOGIC)
_viewbottom->set_trig_time(_session.get_trigger_time());
}
void View::receive_end()
{
if (_session.get_device()->dev_inst()->mode == LOGIC) {
GVariant *gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_RLE);
if (gvar != NULL) {
bool rle = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (rle) {
gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_ACTUAL_SAMPLES);
if (gvar != NULL) {
uint64_t actual_samples = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
if (actual_samples != _session.cur_samplelimits()) {
_viewbottom->set_rle_depth(actual_samples);
}
}
}
}
}
}
void View::set_trig_pos(quint64 trig_pos)
{
const double time = trig_pos * 1.0 / _session.cur_samplerate();
_trig_pos = trig_pos;
_trig_cursor->set_index(trig_pos);
if (ds_trigger_get_en()) {
if (ds_trigger_get_en() || _session.get_device()->name() == "virtual-session") {
_show_trig_cursor = true;
set_scale_offset(_scale, time - _scale * get_view_width() / 2);
}
_trigger_time = QDateTime::currentDateTime();
const int64_t secs = time - _session.get_device()->get_sample_time();
_trigger_time = _trigger_time.addSecs(secs);
_ruler->update();
viewport_update();
}
......@@ -452,11 +469,6 @@ void View::set_search_pos(uint64_t search_pos)
viewport_update();
}
uint64_t View::get_trig_pos()
{
return _trig_pos;
}
uint64_t View::get_search_pos()
{
return _search_pos;
......@@ -555,7 +567,7 @@ void View::update_scale_offset()
_preScale = _scale;
_preOffset = _offset;
_trig_cursor->set_index(_trig_pos);
_trig_cursor->set_index(_session.get_trigger_pos());
_ruler->update();
viewport_update();
......@@ -611,7 +623,6 @@ void View::signals_changed()
}
const double height = (_time_viewport->height()
- horizontalScrollBar()->height()
- 2 * SignalMargin * time_traces.size()) * 1.0 / total_rows;
if (_session.get_device()->dev_inst()->mode == LOGIC) {
......@@ -998,11 +1009,6 @@ void View::update_calibration()
}
}
QString View::trigger_time()
{
return _trigger_time.toString("yyyy-MM-dd hh:mm:ss ddd");
}
void View::show_region(uint64_t start, uint64_t end)
{
assert(start <= end);
......
......@@ -43,6 +43,7 @@
#include "../view/viewport.h"
#include "cursor.h"
#include "signal.h"
#include "../widgets/viewstatus.h"
namespace pv {
......@@ -83,6 +84,8 @@ public:
static constexpr double MaxViewRate = 1.0;
static const int MaxPixelsPerSample = 100;
static const int StatusHeight = 25;
public:
explicit View(SigSession &session, pv::toolbars::SamplingBar *sampling_bar, QWidget *parent = 0);
......@@ -158,7 +161,6 @@ public:
//void set_trig_pos(uint64_t trig_pos);
void set_search_pos(uint64_t search_pos);
uint64_t get_trig_pos();
uint64_t get_search_pos();
/*
......@@ -187,8 +189,6 @@ public:
void set_sample_limit(uint64_t sample_limit, bool force = false);
QString trigger_time();
QString get_measure(QString option);
void viewport_update();
......@@ -233,6 +233,7 @@ public slots:
void show_region(uint64_t start, uint64_t end);
// -- calibration
void update_calibration();
void status_clear();
private slots:
......@@ -245,8 +246,14 @@ private slots:
void header_updated();
void receive_header();
void set_trig_pos(quint64 trig_pos);
void receive_end();
void frame_began();
// calibration for oscilloscope
void show_calibration();
void hide_calibration();
......@@ -260,6 +267,7 @@ private:
pv::toolbars::SamplingBar *_sampling_bar;
QWidget *_viewcenter;
widgets::ViewStatus *_viewbottom;
QSplitter *_vsplitter;
Viewport * _time_viewport;
Viewport * _fft_viewport;
......@@ -291,14 +299,12 @@ private:
Cursor *_trig_cursor;
bool _show_trig_cursor;
uint64_t _trig_pos;
Cursor *_search_cursor;
bool _show_search_cursor;
uint64_t _search_pos;
QPointF _hover_point;
dialogs::Calibration *_cali;
QDateTime _trigger_time;
};
} // namespace view
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment