2
0
forked from Ivasoft/DSView

Merge branch 'fix_la_issue' into develop

This commit is contained in:
DreamSourceLab
2015-05-07 19:54:08 +08:00
19 changed files with 173 additions and 89 deletions

View File

@@ -433,6 +433,11 @@ void DecoderStack::decode_proc()
_decode_state = Stopped;
}
uint64_t DecoderStack::sample_count() const
{
return _sample_count;
}
void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder)
{
assert(pdata);

View File

@@ -120,6 +120,8 @@ public:
void options_changed(bool changed);
uint64_t sample_count() const;
private:
boost::optional<uint64_t> wait_for_data() const;

View File

@@ -369,11 +369,12 @@ void TriggerDock::device_change()
if (stream ||
strcmp(_session.get_device()->dev_inst()->driver->name, "DSLogic") != 0) {
position_spinBox->setDisabled(true);
position_slider->setDisabled(true);
const int maxRange = SR_MB(11)*100/_session.get_device()->get_sample_limit();
position_spinBox->setRange(0, maxRange);
position_slider->setRange(0, maxRange);
} else {
position_spinBox->setDisabled(false);
position_slider->setDisabled(false);
position_spinBox->setRange(0, 99);
position_slider->setRange(0, 99);
}
}

View File

@@ -180,7 +180,7 @@ void MainWindow::setup_ui()
connect(_sampling_bar, SIGNAL(device_selected()), this,
SLOT(update_device_list()));
connect(_sampling_bar, SIGNAL(device_updated()), &_session,
connect(_sampling_bar, SIGNAL(device_updated()), this,
SLOT(reload()));
connect(_sampling_bar, SIGNAL(run_stop()), this,
SLOT(run_stop()));
@@ -317,6 +317,12 @@ void MainWindow::update_device_list()
_logo_bar->dsl_connected(false);
}
void MainWindow::reload()
{
_trigger_widget->device_change();
_session.reload();
}
void MainWindow::load_file(QString file_name)
{
try {

View File

@@ -90,6 +90,8 @@ private slots:
*/
void update_device_list();
void reload();
void show_session_error(
const QString text, const QString info_text);

View File

@@ -667,6 +667,7 @@ void SigSession::init_signals()
assert(_dev_inst);
stop_capture();
vector< boost::shared_ptr<view::Signal> > sigs;
boost::shared_ptr<view::Signal> signal;
unsigned int logic_probe_count = 0;
unsigned int dso_probe_count = 0;
@@ -726,8 +727,6 @@ void SigSession::init_signals()
// Make the logic probe list
{
_signals.clear();
for (const GSList *l = _dev_inst->dev_inst()->channels; l; l = l->next) {
const sr_channel *const probe =
(const sr_channel *)l->data;
@@ -752,8 +751,13 @@ void SigSession::init_signals()
break;
}
if(signal.get())
_signals.push_back(signal);
sigs.push_back(signal);
}
_signals.clear();
vector< boost::shared_ptr<view::Signal> >().swap(_signals);
_signals = sigs;
signals_changed();
data_updated();
}
@@ -766,12 +770,11 @@ void SigSession::reload()
if (_capture_state == Running)
stop_capture();
vector< boost::shared_ptr<view::Signal> > sigs;
boost::shared_ptr<view::Signal> signal;
// Make the logic probe list
{
_signals.clear();
for (const GSList *l = _dev_inst->dev_inst()->channels; l; l = l->next) {
const sr_channel *const probe =
(const sr_channel *)l->data;
@@ -779,7 +782,10 @@ void SigSession::reload()
signal.reset();
switch(probe->type) {
case SR_CHANNEL_LOGIC:
if (probe->enabled)
if (probe->enabled && probe->index < _signals.size())
signal = boost::shared_ptr<view::Signal>(
new view::LogicSignal(*_signals[probe->index].get(), _logic_data, probe));
else if (probe->enabled)
signal = boost::shared_ptr<view::Signal>(
new view::LogicSignal(_dev_inst, _logic_data, probe));
break;
@@ -796,8 +802,12 @@ void SigSession::reload()
break;
}
if (signal.get())
_signals.push_back(signal);
sigs.push_back(signal);
}
_signals.clear();
vector< boost::shared_ptr<view::Signal> >().swap(_signals);
_signals = sigs;
}
signals_changed();

View File

@@ -667,19 +667,21 @@ void SamplingBar::on_run_stop()
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
if (!dev_inst)
return;
GVariant* gvar = dev_inst->get_config(NULL, NULL, SR_CONF_ZERO);
if (gvar != NULL) {
bool zero = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (zero) {
QMessageBox msg(this);
msg.setText("Zero Adjustment");
msg.setInformativeText("Please adjust zero skew and save the result!");
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
zero_adj();
return;
if (dev_inst->dev_inst()->mode == DSO) {
GVariant* gvar = dev_inst->get_config(NULL, NULL, SR_CONF_ZERO);
if (gvar != NULL) {
bool zero = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (zero) {
QMessageBox msg(this);
msg.setText("Zero Adjustment");
msg.setInformativeText("Please adjust zero skew and save the result!");
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
zero_adj();
return;
}
}
}
run_stop();
@@ -695,22 +697,24 @@ void SamplingBar::on_instant_stop()
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
if (!dev_inst)
return;
GVariant* gvar = dev_inst->get_config(NULL, NULL, SR_CONF_ZERO);
if (gvar != NULL) {
bool zero = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (zero) {
QMessageBox msg(this);
msg.setText("Zero Adjustment");
if(strcmp(dev_inst->dev_inst()->driver->name, "DSLogic") == 0)
msg.setInformativeText("Please adjust zero skew and save the result!\nPlease left both of channels unconnect for zero adjustment!");
else
msg.setInformativeText("Please adjust zero skew and save the result!");
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
zero_adj();
return;
if (dev_inst->dev_inst()->mode == DSO) {
GVariant* gvar = dev_inst->get_config(NULL, NULL, SR_CONF_ZERO);
if (gvar != NULL) {
bool zero = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (zero) {
QMessageBox msg(this);
msg.setText("Zero Adjustment");
if(strcmp(dev_inst->dev_inst()->driver->name, "DSLogic") == 0)
msg.setInformativeText("Please adjust zero skew and save the result!\nPlease left both of channels unconnect for zero adjustment!");
else
msg.setInformativeText("Please adjust zero skew and save the result!");
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
zero_adj();
return;
}
}
}
instant_stop();

View File

@@ -117,10 +117,12 @@ const QColor DecodeTrace::OutlineColours[16] = {
DecodeTrace::DecodeTrace(pv::SigSession &session,
boost::shared_ptr<pv::data::DecoderStack> decoder_stack, int index) :
Trace(QString::fromUtf8(
decoder_stack->stack().front()->decoder()->name), Trace::DS_DECODER),
decoder_stack->stack().front()->decoder()->name), index, Trace::DS_DECODER),
_session(session),
_decoder_stack(decoder_stack),
_show_hide_mapper(this)
_show_hide_mapper(this),
_popup_form(NULL),
_popup()
{
assert(_decoder_stack);
@@ -297,21 +299,11 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right)
bool DecodeTrace::create_popup()
{
// Clear the layout
// Transfer the layout and the child widgets to a temporary widget
// which then goes out of scope destroying the layout and all the child
// widgets.
//if (_popup_form)
// QWidget().setLayout(_popup_form);
int ret = false;
QDialog popup;
QFormLayout popup_form;
popup.setLayout(&popup_form);
populate_popup_form(&popup, &popup_form);
_popup = new QDialog();
create_popup_form();
if (QDialog::Accepted == popup.exec())
if (QDialog::Accepted == _popup->exec())
{
BOOST_FOREACH(shared_ptr<data::decode::Decoder> dec,
_decoder_stack->stack())
@@ -321,12 +313,28 @@ bool DecodeTrace::create_popup()
ret = true;
}
}
return ret;
}
else
return false;
_popup = NULL;
_popup_form = NULL;
return ret;
}
void DecodeTrace::create_popup_form()
{
// Clear the layout
// Transfer the layout and the child widgets to a temporary widget
// which then goes out of scope destroying the layout and all the child
// widgets.
if (_popup_form)
QWidget().setLayout(_popup_form);
_popup_form = new QFormLayout(_popup);
_popup->setLayout(_popup_form);
populate_popup_form(_popup, _popup_form);
}
void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
{
@@ -368,8 +376,8 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
new pv::widgets::DecoderMenu(parent);
connect(decoder_menu, SIGNAL(decoder_selected(srd_decoder*)),
this, SLOT(on_stack_decoder(srd_decoder*)));
connect(decoder_menu, SIGNAL(selected()),
parent, SLOT(accept()));
//connect(decoder_menu, SIGNAL(selected()),
// parent, SLOT(accept()));
QPushButton *const stack_button =
new QPushButton(tr("Stack Decoder"), parent);
@@ -547,7 +555,8 @@ bool DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left,
shared_ptr<Logic> data;
shared_ptr<LogicSignal> logic_signal;
const int64_t sample_count = _session.get_device()->get_sample_limit();
//const int64_t sample_count = _session.get_device()->get_sample_limit();
const int64_t sample_count = _decoder_stack->sample_count();
if (sample_count == 0)
return true;
@@ -768,7 +777,7 @@ void DecodeTrace::on_stack_decoder(srd_decoder *decoder)
new data::decode::Decoder(decoder)));
//_decoder_stack->begin_decode();
create_popup();
create_popup_form();
}
void DecodeTrace::on_show_hide_decoder(int index)

View File

@@ -128,6 +128,8 @@ protected:
void paint_type_options(QPainter &p, int right, bool hover, int action);
private:
void create_popup_form();
void populate_popup_form(QWidget *parent, QFormLayout *form);
void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p,
@@ -196,6 +198,8 @@ private:
std::vector<QString> _cur_row_headings;
QSignalMapper _show_hide_mapper;
QFormLayout *_popup_form;
QDialog *_popup;
};
} // namespace view

View File

@@ -76,6 +76,15 @@ LogicSignal::LogicSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
_colour = SignalColours[probe->index % countof(SignalColours)];
}
LogicSignal::LogicSignal(const Signal &s,
boost::shared_ptr<pv::data::Logic> data,
const sr_channel * const probe) :
Signal(s, probe),
_data(data)
{
assert(probe->index >= 0);
}
LogicSignal::~LogicSignal()
{
}
@@ -288,7 +297,7 @@ bool LogicSignal::measure(const QPointF &p, uint64_t &index0, uint64_t &index1,
return false;
uint64_t index = _data->samplerate() * (_view->offset() - _data->get_start_time() + p.x() * _view->scale());
if (index == 0)
if (index == 0 || index >= (snapshot->get_sample_count() - 1))
return false;
const uint64_t sig_mask = 1ULL << get_index();

View File

@@ -58,6 +58,10 @@ public:
boost::shared_ptr<pv::data::Logic> data,
const sr_channel * const probe);
LogicSignal(const Signal &s,
boost::shared_ptr<pv::data::Logic> data,
const sr_channel * const probe);
virtual ~LogicSignal();
const sr_channel* probe() const;

View File

@@ -102,9 +102,8 @@ QString Ruler::format_freq(double period, unsigned precision)
} else {
const int order = ceil(log10f(period));
assert(order >= FirstSIPrefixPower);
const unsigned int prefix = ceil((order - FirstSIPrefixPower) / 3.0f);
const double multiplier = pow(10.0,
static_cast<double>(- prefix * 3 - FirstSIPrefixPower));
const int prefix = ceil((order - FirstSIPrefixPower) / 3.0f);
const double multiplier = pow(10.0, max(-prefix * 3.0 - FirstSIPrefixPower, 0.0));
QString s;
QTextStream ts(&s);
@@ -115,11 +114,10 @@ QString Ruler::format_freq(double period, unsigned precision)
}
}
QString Ruler::format_time(double t, unsigned int prefix,
QString Ruler::format_time(double t, int prefix,
unsigned int precision)
{
const double multiplier = pow(10.0,
static_cast<double>(- prefix * 3 - FirstSIPrefixPower + 6));
const double multiplier = pow(10.0, -prefix * 3 - FirstSIPrefixPower + 6.0);
QString s;
QTextStream ts(&s);

View File

@@ -63,7 +63,7 @@ public:
public:
Ruler(View &parent);
static QString format_time(double t, unsigned int prefix,
static QString format_time(double t, int prefix,
unsigned precision = pricision);
static QString format_freq(double period, unsigned precision = pricision);
QString format_time(double t);

View File

@@ -42,6 +42,13 @@ Signal::Signal(boost::shared_ptr<pv::device::DevInst> dev_inst,
{
}
Signal::Signal(const Signal &s, const sr_channel * const probe) :
Trace((const Trace &)s),
_dev_inst(s._dev_inst),
_probe(probe)
{
}
bool Signal::enabled() const
{
return _probe->enabled;

View File

@@ -59,6 +59,11 @@ protected:
Signal(boost::shared_ptr<pv::device::DevInst> dev_inst,
const sr_channel * const probe, int type);
/**
* Copy constructor
*/
Signal(const Signal &s, const sr_channel * const probe);
public:
virtual boost::shared_ptr<pv::data::SignalData> data() const = 0;

View File

@@ -53,19 +53,9 @@ const QPen Trace::SignalAxisPen = QColor(128, 128, 128, 64);
const QPen Trace::AxisPen(QColor(128, 128, 128, 64));
const int Trace::LabelHitPadding = 2;
Trace::Trace(QString name, int type) :
_name(name),
_v_offset(0),
_type(type),
_sec_index(0),
_signalHeight(30),
_trig(0)
{
}
Trace::Trace(QString name, int index, int type) :
_name(name),
_v_offset(0),
_v_offset(INT_MAX),
_type(type),
_sec_index(0),
_signalHeight(30),
@@ -76,7 +66,7 @@ Trace::Trace(QString name, int index, int type) :
Trace::Trace(QString name, std::list<int> index_list, int type, int sec_index) :
_name(name),
_v_offset(0),
_v_offset(INT_MAX),
_type(type),
_index_list(index_list),
_sec_index(sec_index),
@@ -85,6 +75,21 @@ Trace::Trace(QString name, std::list<int> index_list, int type, int sec_index) :
{
}
Trace::Trace(const Trace &t) :
_view(t._view),
_name(t._name),
_colour(t._colour),
_v_offset(t._v_offset),
_type(t._type),
_index_list(t._index_list),
_sec_index(t._sec_index),
_old_v_offset(t._old_v_offset),
_signalHeight(t._signalHeight),
_trig(t._trig),
_text_size(t._text_size)
{
}
QString Trace::get_name() const
{
return _name;

View File

@@ -84,12 +84,16 @@ public:
static const QPen SignalAxisPen;
protected:
Trace(QString name, int type);
Trace(QString name, int index, int type);
Trace(QString name, std::list<int> index_list, int type, int sec_index);
/**
* Copy constructor
*/
Trace(const Trace &t);
public:
enum {DS_LOGIC = 0, DS_ANALOG, DS_GROUP, DS_DSO, DS_DECODER};
enum {DS_LOGIC = 0, DS_ANALOG, DS_DSO, DS_GROUP, DS_DECODER};
public:
/**

View File

@@ -32,6 +32,7 @@
#include <QMouseEvent>
#include <QScrollBar>
#include "groupsignal.h"
#include "decodetrace.h"
#include "header.h"
#include "devmode.h"
@@ -274,13 +275,14 @@ void View::set_preScale_preOffset()
vector< boost::shared_ptr<Trace> > View::get_traces() const
{
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() + decode_sigs.size());
sigs.size() + groups.size() + decode_sigs.size());
#else
vector< boost::shared_ptr<Trace> > traces(sigs.size());
vector< boost::shared_ptr<Trace> > traces(sigs.size() + groups.size());
#endif
vector< boost::shared_ptr<Trace> >::iterator i = traces.begin();
@@ -288,6 +290,7 @@ vector< boost::shared_ptr<Trace> > View::get_traces() const
#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;
@@ -298,7 +301,10 @@ bool View::compare_trace_v_offsets(const boost::shared_ptr<Trace> &a,
{
assert(a);
assert(b);
return a->get_v_offset() < b->get_v_offset();
if (a->get_type() != b->get_type())
return a->get_type() > b->get_type();
else
return a->get_v_offset() < b->get_v_offset();
}
bool View::cursors_shown() const

View File

@@ -308,7 +308,10 @@ void Viewport::paintProgress(QPainter &p)
(status.captured_cnt1 << 8) +
(status.captured_cnt2 << 16) +
(status.captured_cnt3 << 24));
captured_progress = captured_cnt * 100.0 / _total_sample_len;
if (triggred)
captured_progress = (_total_sample_len - captured_cnt) * 100.0 / _total_sample_len;
else
captured_progress = captured_cnt * 100.0 / _total_sample_len;
p.setPen(Trace::dsLightBlue);