Commit 2add0e3c authored by DreamSourceLab's avatar DreamSourceLab

v0.97 initial update, compile pass, run error

parent 7665adeb
......@@ -62,6 +62,7 @@ endif()
list(APPEND PKGDEPS
"libsigrok4DSL >= 0.2.0"
"libusb-1.0 >= 1.0.16"
"libzip >= 0.10"
)
if(ENABLE_DECODE)
list(APPEND PKGDEPS "libsigrokdecode>=0.3.0")
......@@ -93,6 +94,7 @@ find_package(Threads)
find_package(Boost 1.42 COMPONENTS filesystem system thread REQUIRED)
find_package(libusb-1.0 REQUIRED)
find_package(libzip REQUIRED)
find_package(FFTW REQUIRED)
#===============================================================================
......@@ -104,7 +106,7 @@ set(DS_DESCRIPTION "A GUI for instruments of DreamSourceLab")
set(DS_VERSION_MAJOR 0)
set(DS_VERSION_MINOR 9)
set(DS_VERSION_MICRO 6)
set(DS_VERSION_MICRO 7)
set(DS_VERSION_STRING
${DS_VERSION_MAJOR}.${DS_VERSION_MINOR}.${DS_VERSION_MICRO}
)
......@@ -202,6 +204,7 @@ set(DSView_SOURCES
pv/dialogs/dsmessagebox.cpp
pv/dialogs/shadow.cpp
pv/dialogs/dsdialog.cpp
pv/dialogs/interval.cpp
)
set(DSView_HEADERS
......@@ -257,6 +260,7 @@ set(DSView_HEADERS
pv/dialogs/dsmessagebox.h
pv/dialogs/shadow.h
pv/dialogs/dsdialog.h
pv/dialogs/interval.h
)
set(DSView_FORMS
......
[Desktop Entry]
Version=0.96
Exec=/usr/local/bin/DSView
Name=DSView
Comment=GUI Program for DreamSourceLab USB-based Instruments
Icon=/usr/local/share/DSView/logo.png
Type=Application
Terminal=false
Categories=Development
......@@ -10,8 +10,6 @@
<file>stylesheet.qss</file>
<file>icons/down-arrow.png</file>
<file>icons/slider-handle.png</file>
<file>icons/add.png</file>
<file>icons/del.png</file>
<file>icons/trigger.png</file>
<file>icons/measure.png</file>
<file>icons/search-bar.png</file>
......@@ -55,5 +53,16 @@
<file>icons/maximize.png</file>
<file>icons/minimize.png</file>
<file>icons/restore.png</file>
<file>icons/nav.png</file>
<file>icons/oneloop.png</file>
<file>icons/repeat.png</file>
<file>icons/moder.png</file>
<file>icons/moder_dis.png</file>
<file>icons/modes.png</file>
<file>icons/modes_dis.png</file>
<file>icons/add.png</file>
<file>icons/del.png</file>
<file>icons/add_dis.png</file>
<file>icons/del_dis.png</file>
</qresource>
</RCC>
......@@ -65,7 +65,7 @@ QWidget:item:selected
QCheckBox
{
spacing: 5px;
spacing: 0px;
outline: none;
color: #bbb;
margin-bottom: 2px;
......@@ -635,7 +635,7 @@ QComboBox::drop-down
{
subcontrol-origin: padding;
subcontrol-position: top right;
width: 15px;
width: 10px;
border-left-width: 0px;
border-left-color: darkgray;
......
......@@ -34,15 +34,15 @@ bool DSApplication::notify(QObject *receiver_, QEvent *event_)
return QApplication::notify(receiver_, event_);
} catch ( std::exception& e ) {
QMessageBox msg(NULL);
msg.setText("Application Error");
msg.setText(tr("Application Error"));
msg.setInformativeText(e.what());
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
} catch (...) {
QMessageBox msg(NULL);
msg.setText("Application Error");
msg.setInformativeText("An unexpected error occurred");
msg.setText(tr("Application Error"));
msg.setInformativeText(tr("An unexpected error occurred"));
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
......
DSView/icons/add.png

260 Bytes | W: | H:

DSView/icons/add.png

399 Bytes | W: | H:

DSView/icons/add.png
DSView/icons/add.png
DSView/icons/add.png
DSView/icons/add.png
  • 2-up
  • Swipe
  • Onion skin
DSView/icons/del.png

624 Bytes | W: | H:

DSView/icons/del.png

714 Bytes | W: | H:

DSView/icons/del.png
DSView/icons/del.png
DSView/icons/del.png
DSView/icons/del.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -34,7 +34,7 @@
#include <QDebug>
#include <QFile>
#include <QDir>
#include <QIcon>
#include <QTranslator>
#include "dsapplication.h"
#include "pv/devicemanager.h"
......@@ -143,9 +143,10 @@ int main(int argc, char *argv[])
a.setStyleSheet(qss.readAll());
qss.close();
w.show();
w.readSettings();
// Run the application
ret = a.exec();
ret = a.exec();
} catch(std::exception e) {
qDebug() << e.what();
......
......@@ -91,14 +91,20 @@ void AnalogSnapshot::clear()
init();
}
void AnalogSnapshot::first_payload(const sr_datafeed_analog &analog, uint64_t total_sample_count, unsigned int channel_num)
void AnalogSnapshot::first_payload(const sr_datafeed_analog &analog, uint64_t total_sample_count, GSList *channels)
{
_total_sample_count = total_sample_count;
_channel_num = channel_num;
_unit_size = sizeof(uint16_t)*channel_num;
_channel_num = 0;
for (const GSList *l = channels; l; l = l->next) {
sr_channel *const probe = (sr_channel*)l->data;
assert(probe);
if (probe->type == SR_CHANNEL_ANALOG && probe->enabled) {
_channel_num ++;
}
}
bool isOk = true;
uint64_t size = _total_sample_count * _unit_size + sizeof(uint64_t);
uint64_t size = _total_sample_count * _channel_num * BytesPerSample + sizeof(uint64_t);
if (size != _capacity) {
free_data();
_data = malloc(size);
......@@ -125,6 +131,13 @@ void AnalogSnapshot::first_payload(const sr_datafeed_analog &analog, uint64_t to
}
if (isOk) {
for (const GSList *l = channels; l; l = l->next) {
sr_channel *const probe = (sr_channel*)l->data;
assert(probe);
if (probe->type == SR_CHANNEL_ANALOG && probe->enabled) {
_ch_index.push_back(probe->index);
}
}
_capacity = size;
_memory_failed = false;
append_payload(analog);
......@@ -132,7 +145,6 @@ void AnalogSnapshot::first_payload(const sr_datafeed_analog &analog, uint64_t to
} else {
free_data();
free_envelop();
_capacity = 0;
_memory_failed = true;
}
}
......@@ -147,6 +159,27 @@ void AnalogSnapshot::append_payload(
append_payload_to_envelope_levels();
}
void AnalogSnapshot::append_data(void *data, uint64_t samples)
{
int unit_bytes = BytesPerSample * _channel_num;
if (_sample_count + samples < _total_sample_count)
_sample_count += samples;
else
_sample_count = _total_sample_count;
if (_ring_sample_count + samples > _total_sample_count) {
memcpy((uint8_t*)_data + _ring_sample_count * unit_bytes,
data, (_total_sample_count - _ring_sample_count) * unit_bytes);
_ring_sample_count = (samples + _ring_sample_count - _total_sample_count) % _total_sample_count;
memcpy((uint8_t*)_data,
data, _ring_sample_count * unit_bytes);
} else {
memcpy((uint8_t*)_data + _ring_sample_count * unit_bytes,
data, samples * unit_bytes);
_ring_sample_count += samples;
}
}
const uint16_t* AnalogSnapshot::get_samples(
int64_t start_sample, int64_t end_sample) const
{
......@@ -303,5 +336,20 @@ void AnalogSnapshot::append_payload_to_envelope_levels()
}
}
int AnalogSnapshot::get_ch_order(int sig_index)
{
int order = 0;
for (auto& iter:_ch_index) {
if (iter == sig_index)
break;
order++;
}
if (order >= _ch_index.size())
return -1;
else
return order;
}
} // namespace data
} // namespace pv
......@@ -68,6 +68,8 @@ private:
static const float LogEnvelopeScaleFactor;
static const uint64_t EnvelopeDataUnit;
static const int BytesPerSample = 2;
public:
AnalogSnapshot();
......@@ -76,7 +78,8 @@ public:
void clear();
void init();
void first_payload(const sr_datafeed_analog &analog, uint64_t total_sample_count, unsigned int channel_num);
void first_payload(const sr_datafeed_analog &analog,
uint64_t total_sample_count, GSList *channels);
void append_payload(const sr_datafeed_analog &analog);
......@@ -86,11 +89,16 @@ public:
void get_envelope_section(EnvelopeSection &s,
uint64_t start, uint64_t end, float min_length, int probe_index) const;
int get_ch_order(int sig_index);
private:
void append_data(void *data, uint64_t samples);
void free_envelop();
void reallocate_envelope(Envelope &l);
void append_payload_to_envelope_levels();
private:
struct Envelope _envelope_levels[2*DS_MAX_ANALOG_PROBES_NUM][ScaleStepCount];
......
......@@ -24,8 +24,6 @@
#include "decoder.h"
#include <pv/view/logicsignal.h>
using boost::shared_ptr;
using std::set;
using std::map;
......@@ -44,10 +42,6 @@ Decoder::Decoder(const srd_decoder *const dec) :
Decoder::~Decoder()
{
for (map<string, GVariant*>::const_iterator i = _options.begin();
i != _options.end(); i++)
g_variant_unref((*i).second);
for (map<string, GVariant*>::const_iterator i = _options_back.begin();
i != _options_back.end(); i++)
g_variant_unref((*i).second);
......@@ -68,14 +62,13 @@ void Decoder::show(bool show)
_shown = show;
}
const map<const srd_channel*, shared_ptr<view::LogicSignal> >&
const map<const srd_channel*, int>&
Decoder::channels() const
{
return _probes;
}
void Decoder::set_probes(std::map<const srd_channel*,
boost::shared_ptr<view::LogicSignal> > probes)
void Decoder::set_probes(std::map<const srd_channel *, int> probes)
{
_probes_back = probes;
_setted = true;
......@@ -89,6 +82,7 @@ const std::map<std::string, GVariant*>& Decoder::options() const
void Decoder::set_option(const char *id, GVariant *value)
{
assert(value);
g_variant_unref(_options_back[id]);
g_variant_ref(value);
_options_back[id] = value;
_setted = true;
......@@ -139,24 +133,8 @@ bool Decoder::have_required_probes() const
return true;
}
set< shared_ptr<pv::data::Logic> > Decoder::get_data()
srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session) const
{
set< shared_ptr<pv::data::Logic> > data;
for(map<const srd_channel*, shared_ptr<view::LogicSignal> >::
const_iterator i = _probes.begin();
i != _probes.end(); i++)
{
shared_ptr<view::LogicSignal> signal((*i).second);
assert(signal);
data.insert(signal->logic_data());
}
return data;
}
srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_size) const
{
(void)unit_size;
GHashTable *const opt_hash = g_hash_table_new_full(g_str_hash,
g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
......@@ -180,13 +158,11 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_si
GHashTable *const probes = g_hash_table_new_full(g_str_hash,
g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
for(map<const srd_channel*, shared_ptr<view::LogicSignal> >::
for(map<const srd_channel*, int>::
const_iterator i = _probes.begin();
i != _probes.end(); i++)
{
shared_ptr<view::LogicSignal> signal((*i).second);
GVariant *const gvar = g_variant_new_int32(
signal->probe()->index);
GVariant *const gvar = g_variant_new_int32((*i).second);
g_variant_ref_sink(gvar);
g_hash_table_insert(probes, (*i).first->id, gvar);
}
......@@ -196,6 +172,11 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_si
return decoder_inst;
}
int Decoder::get_channel_type(const srd_channel *ch)
{
return ch->type;
}
} // decode
} // data
} // pv
......@@ -35,15 +35,7 @@ struct srd_channel;
struct srd_session;
namespace pv {
namespace view {
class LogicSignal;
}
namespace data {
class Logic;
namespace decode {
class Decoder
......@@ -58,10 +50,8 @@ public:
bool shown() const;
void show(bool show = true);
const std::map<const srd_channel*,
boost::shared_ptr<view::LogicSignal> >& channels() const;
void set_probes(std::map<const srd_channel*,
boost::shared_ptr<view::LogicSignal> > probes);
const std::map<const srd_channel*, int>& channels() const;
void set_probes(std::map<const srd_channel*, int> probes);
const std::map<std::string, GVariant*>& options() const;
......@@ -69,10 +59,7 @@ public:
bool have_required_probes() const;
srd_decoder_inst* create_decoder_inst(
srd_session *session, int unit_size) const;
std::set< boost::shared_ptr<pv::data::Logic> > get_data();
srd_decoder_inst* create_decoder_inst(srd_session *session) const;
void set_decode_region(uint64_t start, uint64_t end);
uint64_t decode_start() const;
......@@ -80,17 +67,17 @@ public:
bool commit();
int get_channel_type(const srd_channel* ch);
private:
const srd_decoder *const _decoder;
bool _shown;
std::map<const srd_channel*, boost::shared_ptr<pv::view::LogicSignal> >
_probes;
std::map<const srd_channel*, int> _probes;
std::map<std::string, GVariant*> _options;
std::map<const srd_channel*, boost::shared_ptr<pv::view::LogicSignal> >
_probes_back;
std::map<const srd_channel*, int> _probes_back;
std::map<std::string, GVariant*> _options_back;
uint64_t _decode_start, _decode_end;
......
......@@ -38,6 +38,11 @@ RowData::RowData() :
}
RowData::~RowData()
{
clear();
}
void RowData::clear()
{
_annotations.clear();
}
......@@ -56,7 +61,10 @@ uint64_t RowData::get_max_annotation() const
uint64_t RowData::get_min_annotation() const
{
return _min_annotation;
if (_min_annotation == UINT64_MAX)
return 10;
else
return _min_annotation;
}
void RowData::get_annotation_subset(
......@@ -70,6 +78,18 @@ void RowData::get_annotation_subset(
dest.push_back(*i);
}
uint64_t RowData::get_annotation_index(uint64_t start_sample) const
{
uint64_t index = 0;
for (vector<Annotation>::const_iterator i = _annotations.begin();
i != _annotations.end(); i++) {
if ((*i).start_sample() > start_sample)
break;
index++;
}
return index;
}
bool RowData::push_annotation(const Annotation &a)
{
try {
......
......@@ -47,6 +47,8 @@ public:
std::vector<pv::data::decode::Annotation> &dest,
uint64_t start_sample, uint64_t end_sample) const;
uint64_t get_annotation_index(uint64_t start_sample) const;
bool push_annotation(const Annotation &a);
uint64_t get_annotation_size() const;
......@@ -54,6 +56,8 @@ public:
bool get_annotation(pv::data::decode::Annotation &ann,
uint64_t index) const;
void clear();
private:
uint64_t _max_annotation;
uint64_t _min_annotation;
......
This diff is collapsed.
......@@ -68,6 +68,7 @@ private:
static const double DecodeThreshold;
static const int64_t DecodeChunkLength;
static const unsigned int DecodeNotifyPeriod;
static const uint64_t MaxChunkSize = 1024 * 16;
public:
enum decode_state {
......@@ -96,6 +97,9 @@ public:
const decode::Row &row, uint64_t start_sample,
uint64_t end_sample) const;
uint64_t get_annotation_index(
const decode::Row &row, uint64_t start_sample) const;
uint64_t get_max_annotation(const decode::Row &row);
uint64_t get_min_annotation(const decode::Row &row); // except instant(end=start) annotation
......@@ -137,14 +141,13 @@ public:
bool out_of_memory() const;
void set_mark_index(int64_t index);
int64_t get_mark_index() const;
private:
boost::optional<uint64_t> wait_for_data() const;
// void decode_data(const uint64_t sample_count,
// const unsigned int unit_size, srd_session *const session);
void decode_data(const uint64_t decode_start, const uint64_t decode_end,
const unsigned int unit_size, srd_session *const session);
void decode_data(const uint64_t decode_start, const uint64_t decode_end, srd_session *const session);
void decode_proc();
......@@ -199,6 +202,8 @@ private:
bool _options_changed;
bool _no_memory;
int64_t _mark_index;
friend class DecoderStackTest::TwoDecoderStack;
};
......
......@@ -80,6 +80,7 @@ void DsoSnapshot::init()
_memory_failed = false;
_last_ended = true;
_envelope_done = false;
_ch_enable.clear();
for (unsigned int i = 0; i < _channel_num; i++) {
for (unsigned int level = 0; level < ScaleStepCount; level++) {
_envelope_levels[i][level].length = 0;
......@@ -96,15 +97,29 @@ void DsoSnapshot::clear()
init();
}
void DsoSnapshot::first_payload(const sr_datafeed_dso &dso, uint64_t total_sample_count, unsigned int channel_num, bool instant)
void DsoSnapshot::first_payload(const sr_datafeed_dso &dso, uint64_t total_sample_count,
std::map<int, bool> ch_enable, bool instant)
{
bool re_alloc = false;
unsigned int channel_num = 0;
for (auto& iter:ch_enable) {
if (iter.second)
channel_num++;
}
assert(channel_num != 0);
if (total_sample_count != _total_sample_count ||
channel_num != _channel_num)
re_alloc = true;
_total_sample_count = total_sample_count;
_channel_num = channel_num;
_instant = instant;
_ch_enable = ch_enable;
bool isOk = true;
uint64_t size = _total_sample_count * _unit_size + sizeof(uint64_t);
if (size != _capacity) {
uint64_t size = _total_sample_count * _channel_num + sizeof(uint64_t);
if (re_alloc || size != _capacity) {
free_data();
_data = malloc(size);
if (_data) {
......@@ -137,7 +152,6 @@ void DsoSnapshot::first_payload(const sr_datafeed_dso &dso, uint64_t total_sampl
} else {
free_data();
free_envelop();
_capacity = 0;
_memory_failed = true;
}
}
......@@ -147,7 +161,7 @@ void DsoSnapshot::append_payload(const sr_datafeed_dso &dso)
boost::lock_guard<boost::recursive_mutex> lock(_mutex);
if (_channel_num > 0 && dso.num_samples != 0) {
refill_data(dso.data, dso.num_samples, _instant);
append_data(dso.data, dso.num_samples, _instant);
// Generate the first mip-map from the data
if (_envelope_en)
......@@ -155,6 +169,18 @@ void DsoSnapshot::append_payload(const sr_datafeed_dso &dso)
}
}
void DsoSnapshot::append_data(void *data, uint64_t samples, bool instant)
{
if (instant) {
memcpy((uint8_t*)_data + _sample_count * _channel_num, data, samples*_channel_num);
_sample_count = (_sample_count + samples) % (_total_sample_count + 1);
} else {
memcpy((uint8_t*)_data, data, samples*_channel_num);
_sample_count = samples;
}
}
void DsoSnapshot::enable_envelope(bool enable)
{
boost::lock_guard<boost::recursive_mutex> lock(_mutex);
......@@ -382,5 +408,13 @@ double DsoSnapshot::cal_vmean(int index) const
return vmean;
}
bool DsoSnapshot::has_data(int index)
{
if (_ch_enable.find(index) != _ch_enable.end())
return _ch_enable[index];
else
return false;
}
} // namespace data
} // namespace pv
......@@ -77,7 +77,7 @@ public:
void clear();
void init();
void first_payload(const sr_datafeed_dso &dso, uint64_t total_sample_count, unsigned int channel_num, bool instant);
void first_payload(const sr_datafeed_dso &dso, uint64_t total_sample_count, std::map<int, bool> ch_enable, bool instant);
void append_payload(const sr_datafeed_dso &dso);
......@@ -92,7 +92,10 @@ public:
double cal_vrms(double zero_off, int index) const;
double cal_vmean(int index) const;
bool has_data(int index);
private:
void append_data(void *data, uint64_t samples, bool instant);
void free_envelop();
void reallocate_envelope(Envelope &l);
void append_payload_to_envelope_levels(bool header);
......@@ -102,6 +105,7 @@ private:
bool _envelope_en;
bool _envelope_done;
bool _instant;
std::map<int, bool> _ch_enable;
friend class DsoSnapshotTest::Basic;
};
......
This diff is collapsed.
......@@ -26,6 +26,8 @@
#include "snapshot.h"
#include <QString>
#include <utility>
#include <vector>
......@@ -43,19 +45,30 @@ namespace data {
class LogicSnapshot : public Snapshot
{
private:
struct MipMapLevel
{