2
0
forked from Ivasoft/DSView

Remove class: data::Logic, data::Dso, data::Analog

This commit is contained in:
dreamsourcelabTAI
2023-01-09 17:28:50 +08:00
parent b5b54200ca
commit 0058271d8b
38 changed files with 364 additions and 982 deletions

View File

@@ -241,9 +241,7 @@ set(DSView_SOURCES
DSView/pv/data/snapshot.cpp
DSView/pv/data/signaldata.cpp
DSView/pv/data/logicsnapshot.cpp
DSView/pv/data/logic.cpp
DSView/pv/data/analogsnapshot.cpp
DSView/pv/data/analog.cpp
DSView/pv/dialogs/deviceoptions.cpp
DSView/pv/prop/property.cpp
DSView/pv/prop/int.cpp
@@ -273,7 +271,6 @@ set(DSView_SOURCES
DSView/pv/dialogs/about.cpp
DSView/pv/dialogs/search.cpp
DSView/pv/data/dsosnapshot.cpp
DSView/pv/data/dso.cpp
DSView/pv/view/dsosignal.cpp
DSView/pv/view/dsldial.cpp
DSView/pv/dock/dsotriggerdock.cpp

View File

@@ -1,71 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "analog.h"
#include "analogsnapshot.h"
#include <assert.h>
using namespace std;
namespace pv {
namespace data {
Analog::Analog(AnalogSnapshot *snapshot) :
SignalData()
{
assert(snapshot);
_snapshots.push_front(snapshot);
}
void Analog::push_snapshot(AnalogSnapshot *snapshot)
{
_snapshots.push_front(snapshot);
}
std::deque<AnalogSnapshot*>& Analog::get_snapshots()
{
return _snapshots;
}
void Analog::clear()
{
//_snapshots.clear();
for(auto s : _snapshots){
s->clear();
}
}
void Analog::init()
{
//_snapshots.clear();
for(auto s : _snapshots){
s->init();
}
}
AnalogSnapshot* Analog::snapshot()
{
return _snapshots[0];
}
} // namespace data
} // namespace pv

View File

@@ -1,56 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSVIEW_PV_DATA_ANALOG_H
#define DSVIEW_PV_DATA_ANALOG_H
#include "signaldata.h"
#include <deque>
namespace pv {
namespace data {
class AnalogSnapshot;
class Analog : public SignalData
{
public:
Analog(AnalogSnapshot *snapshot);
void push_snapshot(AnalogSnapshot *snapshot);
std::deque<AnalogSnapshot*>& get_snapshots();
void clear();
void init();
AnalogSnapshot* snapshot();
private:
std::deque<AnalogSnapshot*> _snapshots;
};
} // namespace data
} // namespace pv
#endif // DSVIEW_PV_DATA_ANALOG_H

View File

@@ -26,7 +26,6 @@
#include <assert.h>
#include "decoderstack.h"
#include "logic.h"
#include "logicsnapshot.h"
#include "decode/decoder.h"
#include "decode/annotation.h"
@@ -67,6 +66,7 @@ DecoderStack::DecoderStack(pv::SigSession *session,
_decoder_status = decoder_status;
_stask_stauts = NULL;
_is_capture_end = true;
_snapshot = NULL;
_stack.push_back(new decode::Decoder(dec));
@@ -373,6 +373,7 @@ void DecoderStack::init()
_samples_decoded = 0;
_error_message = QString();
_no_memory = false;
_snapshot = NULL;
for (auto i = _rows.begin();i != _rows.end(); i++) {
(*i).second->clear();
@@ -410,8 +411,6 @@ void DecoderStack::do_decode_work()
_stask_stauts->_bStop = false;
_stask_stauts->_decoder = this;
_decoder_status->clear(); //clear old items
pv::data::Logic *data = NULL;
if (!_options_changed)
{
@@ -421,6 +420,8 @@ void DecoderStack::do_decode_work()
init();
_snapshot = NULL;
// Check that all decoders have the required channels
for(auto dec : _stack){
if (!dec->have_required_probes()) {
@@ -437,35 +438,27 @@ void DecoderStack::do_decode_work()
if (!dec->channels().empty()) {
for(auto s : _session->get_signals()) {
if(s->get_index() == (*dec->channels().begin()).second && s->signal_type() == LOGIC_SIGNAL)
{
pv::view::LogicSignal *logicSig = (pv::view::LogicSignal*)s;
data = logicSig->logic_data();
if (data != NULL)
{
_snapshot = ((pv::view::LogicSignal*)s)->logic_data();
if (_snapshot != NULL)
break;
}
}
if (data != NULL)
if (_snapshot != NULL)
break;
}
}
if (data == NULL)
if (_snapshot == NULL)
return;
if (_session->is_realtime_mode() == false)
{
// Check we have a snapshot of data
const auto &snapshots = data->get_snapshots();
if (snapshots.empty())
return;
_snapshot = snapshots.front();
if (_snapshot->empty())
return;
if (_session->is_realtime_mode() == false && _snapshot->empty())
{
return;
}
// Get the samplerate
_samplerate = data->samplerate();
_samplerate = _snapshot->samplerate();
if (_samplerate == 0.0)
return;

View File

@@ -57,7 +57,6 @@ class Decoder;
class RowData;
}
class Logic;
class DecoderStack;
struct decode_task_status

View File

@@ -1,71 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2013 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "dso.h"
#include "dsosnapshot.h"
#include <assert.h>
using namespace std;
namespace pv {
namespace data {
Dso::Dso(DsoSnapshot *snapshot) :
SignalData()
{
assert(snapshot);
_snapshots.push_front(snapshot);
}
void Dso::push_snapshot(DsoSnapshot *snapshot)
{
_snapshots.push_front(snapshot);
}
std::deque<DsoSnapshot*>& Dso::get_snapshots()
{
return _snapshots;
}
void Dso::clear()
{
//_snapshots.clear();
for(auto s : _snapshots){
s->clear();
}
}
void Dso::init()
{
//_snapshots.clear();
for(auto s : _snapshots){
s->init();
}
}
DsoSnapshot* Dso::snapshot()
{
return _snapshots[0];
}
} // namespace data
} // namespace pv

View File

@@ -1,56 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2013 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSVIEW_PV_DATA_DSO_H
#define DSVIEW_PV_DATA_DSO_H
#include "signaldata.h"
#include <deque>
namespace pv {
namespace data {
class DsoSnapshot;
class Dso : public SignalData
{
public:
Dso(DsoSnapshot *snapshot);
void push_snapshot(DsoSnapshot *snapshot);
std::deque<DsoSnapshot*>& get_snapshots();
void clear();
void init();
DsoSnapshot* snapshot();
private:
std::deque<DsoSnapshot*> _snapshots;
};
} // namespace data
} // namespace pv
#endif // DSVIEW_PV_DATA_DSO_H

View File

@@ -1,71 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "logic.h"
#include "logicsnapshot.h"
#include <assert.h>
using namespace std;
namespace pv {
namespace data {
Logic::Logic(LogicSnapshot *snapshot) :
SignalData()
{
assert(snapshot);
_snapshots.push_front(snapshot);
}
void Logic::push_snapshot(LogicSnapshot *snapshot)
{
_snapshots.push_front(snapshot);
}
std::deque<LogicSnapshot*>& Logic::get_snapshots()
{
return _snapshots;
}
void Logic::clear()
{
//_snapshots.clear();
for(auto s : _snapshots){
s->clear();
}
}
void Logic::init()
{
//_snapshots.clear();
for(auto s : _snapshots){
s->init();
}
}
LogicSnapshot* Logic::snapshot()
{
return _snapshots[0];
}
} // namespace data
} // namespace pv

View File

@@ -1,58 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSVIEW_PV_DATA_LOGIC_H
#define DSVIEW_PV_DATA_LOGIC_H
#include "signaldata.h"
#include <deque>
namespace pv {
namespace data {
class LogicSnapshot;
class Logic : public SignalData
{
public:
Logic(LogicSnapshot *snapshot);
void push_snapshot(LogicSnapshot *snapshot);
std::deque<LogicSnapshot*>& get_snapshots();
void clear();
void init();
LogicSnapshot* snapshot();
private:
std::deque<LogicSnapshot*> _snapshots;
};
} // namespace data
} // namespace pv
#endif // DSVIEW_PV_DATA_LOGIC_H

View File

@@ -20,8 +20,6 @@
*/
#include "mathstack.h"
#include "dso.h"
#include "dsosnapshot.h"
#include "../sigsession.h"
#include "../view/dsosignal.h"
@@ -320,15 +318,8 @@ void MathStack::calc_math()
_math_state = Running;
const auto data = _dsoSig1->dso_data();
const auto &snapshots = data->get_snapshots();
if (snapshots.empty())
return;
const auto snapshot = snapshots.front();
if (snapshot->empty())
return;
if (_math.size() < _total_sample_num)
if (data->empty() || _math.size() < _total_sample_num)
return;
if (!_dsoSig1->enabled() || !_dsoSig2->enabled())
@@ -345,9 +336,9 @@ void MathStack::calc_math()
const int index1 = _dsoSig1->get_index();
const int index2 = _dsoSig2->get_index();
const int num_channels = snapshot->get_channel_num();
const uint8_t* value = snapshot->get_samples(0, 0, 0);
_sample_num = snapshot->get_sample_count();
const int num_channels = data->get_channel_num();
const uint8_t* value = data->get_samples(0, 0, 0);
_sample_num = data->get_sample_count();
assert(_sample_num <= _total_sample_num);
double value1, value2;

View File

@@ -44,7 +44,6 @@ class dslDial;
namespace data {
class DsoSnapshot;
class Dso;
class MathStack : public QObject, public SignalData
{

View File

@@ -112,5 +112,11 @@ void Snapshot::capture_ended()
_last_ended = true;
}
void Snapshot::set_samplerate(double samplerate)
{
assert(samplerate > 0);
_samplerate = samplerate;
}
} // namespace data
} // namespace pv

View File

@@ -70,6 +70,12 @@ public:
return _have_data;
}
inline double samplerate(){
return _samplerate;
}
void set_samplerate(double samplerate);
virtual void capture_ended();
virtual bool has_data(int index) = 0;
virtual int get_block_num() = 0;
@@ -101,6 +107,7 @@ protected:
bool _memory_failed;
bool _last_ended;
bool _have_data;
double _samplerate;
};
} // namespace data

View File

@@ -21,7 +21,6 @@
#include "spectrumstack.h"
#include "dso.h"
#include "dsosnapshot.h"
#include "../sigsession.h"
#include "../view/dsosignal.h"
@@ -170,7 +169,7 @@ void SpectrumStack::calc_fft()
{
_spectrum_state = Running;
// Get the dso data
pv::data::Dso *data = NULL;
pv::data::DsoSnapshot *data = NULL;
pv::view::DsoSignal *dsoSig = NULL;
for(auto s : _session->get_signals()) {
@@ -183,17 +182,10 @@ void SpectrumStack::calc_fft()
}
}
if (data == NULL)
if (data == NULL || data->empty())
return;
// Check we have a snapshot of data
const auto &snapshots = data->get_snapshots();
if (snapshots.empty())
return;
_snapshot = snapshots.front();
if (_snapshot->get_sample_count() < _sample_num*_sample_interval)
if (data->get_sample_count() < _sample_num * _sample_interval)
return;
// Get the samplerate
@@ -205,7 +197,7 @@ void SpectrumStack::calc_fft()
const int offset = dsoSig->get_hw_offset();
const double vscale = dsoSig->get_vDialValue() * dsoSig->get_factor() * DS_CONF_DSO_VDIVS / (1000*255.0);
const uint16_t step = _sample_interval;
const uint8_t *const samples = _snapshot->get_samples(0, _sample_num*_sample_interval-1, _index);
const uint8_t *const samples = data->get_samples(0, _sample_num*_sample_interval-1, _index);
double wsum = 0;
for (unsigned int i = 0; i < _sample_num; i++) {

View File

@@ -44,7 +44,6 @@ class DsoSignal;
namespace data {
class DsoSnapshot;
class Dso;
class SpectrumStack : public QObject, public SignalData
{
@@ -101,8 +100,6 @@ private:
int _windows_index;
bool _dc_ignore;
int _sample_interval;
pv::data::DsoSnapshot *_snapshot;
spectrum_state _spectrum_state;
fftw_plan _fft_plan;

View File

@@ -130,7 +130,7 @@ void SearchDock::on_previous()
assert(snapshot);
const auto logic_snapshot = dynamic_cast<data::LogicSnapshot*>(snapshot);
if (!logic_snapshot || logic_snapshot->empty()) {
if (logic_snapshot == NULL || logic_snapshot->empty()) {
dialogs::DSMessageBox msg(this);
msg.mBox()->setText(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_SEARCH), "Search"));
msg.mBox()->setInformativeText(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_NO_SAMPLE_DATA), "No Sample data!"));
@@ -192,7 +192,7 @@ void SearchDock::on_next()
assert(snapshot);
const auto logic_snapshot = dynamic_cast<data::LogicSnapshot*>(snapshot);
if (!logic_snapshot || logic_snapshot->empty()) {
if (logic_snapshot == NULL || logic_snapshot->empty()) {
dialogs::DSMessageBox msg(this);
msg.mBox()->setText(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_SEARCH), "Search"));
msg.mBox()->setInformativeText(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_NO_SAMPLE_DATA), "No Sample data!"));

View File

@@ -67,10 +67,6 @@ class SearchDock;
namespace view {
class View;
}
namespace device{
class DevInst;
}
//The mainwindow,referenced by MainFrame
//TODO: create graph view,toolbar,and show device list

View File

@@ -25,11 +25,8 @@
#include "sigsession.h"
#include "mainwindow.h"
#include "data/analog.h"
#include "data/analogsnapshot.h"
#include "data/dso.h"
#include "data/dsosnapshot.h"
#include "data/logic.h"
#include "data/logicsnapshot.h"
#include "data/decoderstack.h"
#include "data/decode/decoder.h"
@@ -61,6 +58,11 @@
namespace pv
{
SessionData::SessionData()
{
_cur_snap_samplerate = 0;
_cur_samplelimits = 0;
}
// TODO: This should not be necessary
SigSession *SigSession::_session = NULL;
@@ -83,7 +85,14 @@ namespace pv
_data_updated = false;
_opt_mode = OPT_SINGLE;
_rt_refresh_time_id = 0;
_rt_ck_refresh_time_id = 0;
_rt_ck_refresh_time_id = 0;
_view_data = NULL;
_capture_data = NULL;
_data_list.push_back(new SessionData());
_data_list.push_back(new SessionData());
_view_data = _data_list[0];
_capture_data = _data_list[0];
this->add_msg_listener(this);
@@ -91,7 +100,6 @@ namespace pv
_lissajous_trace = NULL;
_math_trace = NULL;
_dso_feed = false;
_stop_scale = 1;
_is_decoding = false;
_bClose = false;
@@ -102,11 +110,6 @@ namespace pv
_device_agent.set_callback(this);
// Create snapshots & data containers
_logic_data = new data::Logic(new data::LogicSnapshot());
_dso_data = new data::Dso(new data::DsoSnapshot());
_analog_data = new data::Analog(new data::AnalogSnapshot());
_feed_timer.SetCallback(std::bind(&SigSession::feed_timeout, this));
_repeat_timer.SetCallback(std::bind(&SigSession::repeat_capture_wait_timeout, this));
_repeat_wait_prog_timer.SetCallback(std::bind(&SigSession::repeat_wait_prog_timeout, this));
@@ -120,6 +123,13 @@ namespace pv
SigSession::~SigSession()
{
for(auto p : _data_list){
p->get_logic()->clear();
p->get_dso()->clear();
p->get_analog()->clear();
delete p;
}
_data_list.clear();
}
bool SigSession::init()
@@ -214,8 +224,8 @@ namespace pv
init_signals();
_cur_snap_samplerate = _device_agent.get_sample_rate();
_cur_samplelimits = _device_agent.get_sample_limit();
_capture_data->_cur_snap_samplerate = _device_agent.get_sample_rate();
_capture_data->_cur_samplelimits = _device_agent.get_sample_limit();
if (_device_agent.get_work_mode() == DSO)
_opt_mode = OPT_REPEAT;
@@ -302,7 +312,11 @@ namespace pv
uint64_t SigSession::cur_snap_samplerate()
{
// samplerate for current snapshot
return _cur_snap_samplerate;
return _capture_data->_cur_snap_samplerate;
}
uint64_t SigSession::cur_samplelimits(){
return _capture_data->_cur_samplelimits;
}
double SigSession::cur_sampletime()
@@ -323,28 +337,25 @@ namespace pv
void SigSession::set_cur_snap_samplerate(uint64_t samplerate)
{
assert(samplerate != 0);
_cur_snap_samplerate = samplerate;
// sample rate for all SignalData
// Logic/Analog/Dso
if (_logic_data)
_logic_data->set_samplerate(_cur_snap_samplerate);
if (_analog_data)
_analog_data->set_samplerate(_cur_snap_samplerate);
if (_dso_data)
_dso_data->set_samplerate(_cur_snap_samplerate);
_capture_data->_cur_snap_samplerate = samplerate;
_capture_data->get_logic()->set_samplerate(samplerate);
_capture_data->get_analog()->set_samplerate(samplerate);
_capture_data->get_dso()->set_samplerate(samplerate);
// DecoderStack
for (auto d : _decode_traces)
{
d->decoder()->set_samplerate(_cur_snap_samplerate);
d->decoder()->set_samplerate(samplerate);
}
// Math
if (_math_trace && _math_trace->enabled())
_math_trace->get_math_stack()->set_samplerate(_device_agent.get_sample_rate());
// SpectrumStack
for (auto m : _spectrum_traces)
m->get_spectrum_stack()->set_samplerate(_cur_snap_samplerate);
for (auto m : _spectrum_traces){
m->get_spectrum_stack()->set_samplerate(samplerate);
}
_callback->cur_snap_samplerate_changed();
}
@@ -352,7 +363,7 @@ namespace pv
void SigSession::set_cur_samplelimits(uint64_t samplelimits)
{
assert(samplelimits != 0);
_cur_samplelimits = samplelimits;
_capture_data->_cur_samplelimits = samplelimits;
}
void SigSession::capture_init()
@@ -399,17 +410,9 @@ namespace pv
void SigSession::container_init()
{
// Logic
if (_logic_data)
_logic_data->init();
// Dso
if (_analog_data)
_analog_data->init();
// Analog
if (_dso_data)
_dso_data->init();
_capture_data->get_logic()->init();
_capture_data->get_analog()->init();
_capture_data->get_dso()->init();
// SpectrumStack
for (auto m : _spectrum_traces)
@@ -462,7 +465,7 @@ namespace pv
_callback->trigger_message(DSV_MSG_START_COLLECT_WORK_PREV);
get_dso_data()->set_threshold(0); // Reset threshold value
_view_data->get_dso()->set_threshold(0); // Reset threshold value
if (exec_capture())
{
@@ -626,19 +629,7 @@ namespace pv
std::vector<view::Signal *> &SigSession::get_signals()
{
return _signals;
}
std::set<data::SignalData *> SigSession::get_data()
{
std::set<data::SignalData *> data;
for (auto s : _signals)
{
data.insert(s->data());
}
return data;
}
}
void SigSession::check_update()
{
@@ -713,20 +704,20 @@ namespace pv
{
case SR_CHANNEL_LOGIC:
if (probe->enabled){
view::Signal *signal = new view::LogicSignal(_logic_data, probe);
view::Signal *signal = new view::LogicSignal(_view_data->get_logic(), probe);
sigs.push_back(signal);
}
break;
case SR_CHANNEL_DSO:{
view::Signal *signal = new view::DsoSignal(_dso_data, probe);
view::Signal *signal = new view::DsoSignal(_view_data->get_dso(), probe);
sigs.push_back(signal);
}
break;
case SR_CHANNEL_ANALOG:
if (probe->enabled){
view::Signal *signal = new view::AnalogSignal(_analog_data, probe);
view::Signal *signal = new view::AnalogSignal(_view_data->get_analog(), probe);
sigs.push_back(signal);
}
break;
@@ -775,7 +766,7 @@ namespace pv
{
if ((*i)->signal_type() == LOGIC_SIGNAL){
view::LogicSignal *logicSig = (view::LogicSignal*)(*i);
signal = new view::LogicSignal(logicSig, _logic_data, probe);
signal = new view::LogicSignal(logicSig, _view_data->get_logic(), probe);
}
break;
@@ -784,7 +775,7 @@ namespace pv
}
if (signal == NULL)
{
signal = new view::LogicSignal(_logic_data, probe);
signal = new view::LogicSignal(_view_data->get_logic(), probe);
}
}
break;
@@ -799,7 +790,7 @@ namespace pv
{
if ((*i)->signal_type() == ANALOG_SIGNAL){
view::AnalogSignal *analogSig = (view::AnalogSignal*)(*i);
signal = new view::AnalogSignal(analogSig, _analog_data, probe);
signal = new view::AnalogSignal(analogSig, _view_data->get_analog(), probe);
}
break;
}
@@ -807,7 +798,7 @@ namespace pv
}
if (signal == NULL)
{
signal = new view::AnalogSignal(_analog_data, probe);
signal = new view::AnalogSignal(_view_data->get_analog(), probe);
}
}
break;
@@ -832,33 +823,24 @@ namespace pv
_data_lock = true;
if (_logic_data)
{
_logic_data->init();
_view_data->get_logic()->init();
for (auto d : _decode_traces)
{
d->decoder()->init();
}
for (auto d : _decode_traces)
{
d->decoder()->init();
}
if (_dso_data)
{
_dso_data->init();
// SpectrumStack
for (auto m : _spectrum_traces)
{
m->get_spectrum_stack()->init();
}
if (_math_trace)
_math_trace->get_math_stack()->init();
_view_data->get_dso()->init();
// SpectrumStack
for (auto m : _spectrum_traces)
{
m->get_spectrum_stack()->init();
}
if (_analog_data)
{
_analog_data->init();
}
if (_math_trace)
_math_trace->get_math_stack()->init();
_view_data->get_analog()->init();
_out_timer.TimeOut(holdtime, std::bind(&SigSession::feed_timeout, this));
_data_updated = true;
@@ -938,24 +920,24 @@ namespace pv
}
}
void SigSession::feed_in_logic(const sr_datafeed_logic &logic)
void SigSession::feed_in_logic(const sr_datafeed_logic &o)
{
if (!_logic_data || _logic_data->snapshot()->memory_failed())
{
dsv_err("%s", "Unexpected logic packet");
return;
}
if (logic.data_error == 1)
if (o.data_error == 1)
{
_error = Test_data_err;
_error_pattern = logic.error_pattern;
_error_pattern = o.error_pattern;
_callback->session_error();
}
if (_logic_data->snapshot()->last_ended())
if (_view_data->get_logic()->memory_failed())
{
_logic_data->snapshot()->first_payload(logic, _device_agent.get_sample_limit(), _device_agent.get_channels());
dsv_err("%s", "Unexpected logic packet");
return;
}
if (_view_data->get_logic()->last_ended())
{
_view_data->get_logic()->first_payload(o, _device_agent.get_sample_limit(), _device_agent.get_channels());
// @todo Putting this here means that only listeners querying
// for logic will be notified. Currently the only user of
// frame_began is DecoderStack, but in future we need to signal
@@ -965,30 +947,30 @@ namespace pv
else
{
// Append to the existing data snapshot
_logic_data->snapshot()->append_payload(logic);
_view_data->get_logic()->append_payload(o);
}
if (_logic_data->snapshot()->memory_failed())
if (_view_data->get_logic()->memory_failed())
{
_error = Malloc_err;
_callback->session_error();
return;
}
receive_data(logic.length * 8 / get_ch_num(SR_CHANNEL_LOGIC));
receive_data(o.length * 8 / get_ch_num(SR_CHANNEL_LOGIC));
_data_updated = true;
}
void SigSession::feed_in_dso(const sr_datafeed_dso &dso)
void SigSession::feed_in_dso(const sr_datafeed_dso &o)
{
if (!_dso_data || _dso_data->snapshot()->memory_failed())
if (_view_data->get_dso()->memory_failed())
{
dsv_err("%s", "Unexpected dso packet");
return; // This dso packet was not expected.
}
if (_dso_data->snapshot()->last_ended())
if (_view_data->get_dso()->last_ended())
{
std::map<int, bool> sig_enable;
// reset scale of dso signal
@@ -1002,12 +984,12 @@ namespace pv
}
// first payload
_dso_data->snapshot()->first_payload(dso, _device_agent.get_sample_limit(), sig_enable, _is_instant);
_view_data->get_dso()->first_payload(o, _device_agent.get_sample_limit(), sig_enable, _is_instant);
}
else
{
// Append to the existing data snapshot
_dso_data->snapshot()->append_payload(dso);
_view_data->get_dso()->append_payload(o);
}
for (auto s : _signals)
@@ -1018,13 +1000,13 @@ namespace pv
}
}
if (dso.num_samples != 0)
if (o.num_samples != 0)
{
// update current sample rate
set_cur_snap_samplerate(_device_agent.get_sample_rate());
}
if (_dso_data->snapshot()->memory_failed())
if (_view_data->get_dso()->memory_failed())
{
_error = Malloc_err;
_callback->session_error();
@@ -1045,11 +1027,11 @@ namespace pv
_math_trace->get_math_stack()->calc_math();
}
_trigger_flag = dso.trig_flag;
_trigger_ch = dso.trig_ch;
_trigger_flag = o.trig_flag;
_trigger_ch = o.trig_ch;
//Trigger update()
receive_data(dso.num_samples);
receive_data(o.num_samples);
if (!_is_instant)
{
@@ -1059,15 +1041,15 @@ namespace pv
_data_updated = true;
}
void SigSession::feed_in_analog(const sr_datafeed_analog &analog)
void SigSession::feed_in_analog(const sr_datafeed_analog &o)
{
if (!_analog_data || _analog_data->snapshot()->memory_failed())
if (_view_data->get_analog()->memory_failed())
{
dsv_err("%s", "Unexpected analog packet");
return; // This analog packet was not expected.
}
if (_analog_data->snapshot()->last_ended())
if (_view_data->get_analog()->last_ended())
{
// reset scale of analog signal
for (auto s : _signals)
@@ -1079,22 +1061,22 @@ namespace pv
}
// first payload
_analog_data->snapshot()->first_payload(analog, _device_agent.get_sample_limit(), _device_agent.get_channels());
_view_data->get_analog()->first_payload(o, _device_agent.get_sample_limit(), _device_agent.get_channels());
}
else
{
// Append to the existing data snapshot
_analog_data->snapshot()->append_payload(analog);
_view_data->get_analog()->append_payload(o);
}
if (_analog_data->snapshot()->memory_failed())
if (_view_data->get_analog()->memory_failed())
{
_error = Malloc_err;
_callback->session_error();
return;
}
receive_data(analog.num_samples);
receive_data(o.num_samples);
_data_updated = true;
}
@@ -1160,9 +1142,9 @@ namespace pv
}
case SR_DF_END:
{
_logic_data->snapshot()->capture_ended();
_dso_data->snapshot()->capture_ended();
_analog_data->snapshot()->capture_ended();
_view_data->get_logic()->capture_ended();
_view_data->get_dso()->capture_ended();
_view_data->get_analog()->capture_ended();
int mode = _device_agent.get_work_mode();
@@ -1427,7 +1409,7 @@ namespace pv
void SigSession::lissajous_rebuild(bool enable, int xindex, int yindex, double percent)
{
DESTROY_OBJECT(_lissajous_trace);
_lissajous_trace = new view::LissajousTrace(enable, _dso_data, xindex, yindex, percent);
_lissajous_trace = new view::LissajousTrace(enable, _view_data->get_dso(), xindex, yindex, percent);
signals_changed();
}
@@ -1449,7 +1431,7 @@ namespace pv
if (_math_trace && _math_trace->enabled())
{
_math_trace->get_math_stack()->set_samplerate(_dso_data->samplerate());
_math_trace->get_math_stack()->set_samplerate(_view_data->get_dso()->samplerate());
_math_trace->get_math_stack()->realloc(_device_agent.get_sample_limit());
_math_trace->get_math_stack()->calc_math();
}
@@ -1487,11 +1469,11 @@ namespace pv
data::Snapshot *SigSession::get_snapshot(int type)
{
if (type == SR_CHANNEL_LOGIC)
return _logic_data->snapshot();
return _view_data->get_logic();
else if (type == SR_CHANNEL_ANALOG)
return _analog_data->snapshot();
return _view_data->get_analog();
else if (type == SR_CHANNEL_DSO)
return _dso_data->snapshot();
return _view_data->get_dso();
else
return NULL;
}
@@ -1698,11 +1680,11 @@ namespace pv
{
int mode = _device_agent.get_work_mode();
if (mode == ANALOG)
return _analog_data->snapshot();
return _view_data->get_analog();
else if (mode == DSO)
return _dso_data->snapshot();
return _view_data->get_dso();
else
return _logic_data->snapshot();
return _view_data->get_logic();
}
void SigSession::device_lib_event_callback(int event)
@@ -1733,7 +1715,9 @@ namespace pv
case DS_EV_DEVICE_STOPPED:
_device_status = ST_STOPPED;
// Confirm that SR_DF_END was received
if (!_logic_data->snapshot()->last_ended() || !_dso_data->snapshot()->last_ended() || !_analog_data->snapshot()->last_ended())
if ( !_view_data->get_logic()->last_ended()
|| !_view_data->get_dso()->last_ended()
|| !_view_data->get_analog()->last_ended())
{
dsv_err("%s", "Error!The data is not completed.");
assert(false);
@@ -1750,11 +1734,13 @@ namespace pv
{
_callback->trigger_message(DSV_MSG_COLLECT_END);
if (_logic_data->snapshot()->last_ended() == false)
if (_view_data->get_logic()->last_ended() == false)
dsv_err("%s", "The collected data is error!");
if (_dso_data->snapshot()->last_ended() == false)
if (_view_data->get_dso()->last_ended() == false)
dsv_err("%s", "The collected data is error!");
if (_analog_data->snapshot()->last_ended() == false)
if (_view_data->get_analog()->last_ended() == false)
dsv_err("%s", "The collected data is error!");
// trigger next collect
@@ -1954,19 +1940,4 @@ namespace pv
return false;
}
data::LogicSnapshot* SigSession::get_logic_data()
{
return _logic_data->snapshot();
}
data::AnalogSnapshot* SigSession::get_analog_data()
{
return _analog_data->snapshot();
}
data::DsoSnapshot* SigSession::get_dso_data()
{
return _dso_data->snapshot();
}
} // namespace pv

View File

@@ -39,8 +39,10 @@
#include <libsigrok.h>
#include "deviceagent.h"
#include "eventobject.h"
#include "data/logicsnapshot.h"
#include "data/analogsnapshot.h"
#include "data/dsosnapshot.h"
struct srd_decoder;
struct srd_channel;
class DecoderStatus;
@@ -52,14 +54,9 @@ namespace pv {
namespace data {
class SignalData;
class Snapshot;
class Analog;
class AnalogSnapshot;
class Dso;
class DsoSnapshot;
class Logic;
class LogicSnapshot;
class Group;
class GroupSnapshot;
class DecoderModel;
class MathStack;
@@ -68,10 +65,6 @@ namespace decode {
}
}
namespace device {
class DevInst;
}
namespace view {
class Signal;
class GroupSignal;
@@ -90,6 +83,33 @@ enum COLLECT_OPT_MODE{
OPT_SINGLE = 0,
OPT_REPEAT = 1,
OPT_REALTIME = 2,
};
class SessionData
{
public:
SessionData();
inline data::LogicSnapshot* get_logic(){
return &logic;
}
inline data::AnalogSnapshot* get_analog(){
return &analog;
}
inline data::DsoSnapshot* get_dso(){
return &dso;
}
public:
uint64_t _cur_snap_samplerate;
uint64_t _cur_samplelimits;
private:
data::LogicSnapshot logic;
data::AnalogSnapshot analog;
data::DsoSnapshot dso;
};
using namespace pv::data;
@@ -148,10 +168,7 @@ public:
uint64_t cur_samplerate();
uint64_t cur_snap_samplerate();
inline uint64_t cur_samplelimits(){
return _cur_samplelimits;
}
uint64_t cur_samplelimits();
double cur_sampletime();
double cur_snap_sampletime();
double cur_view_time();
@@ -170,7 +187,7 @@ public:
bool is_first_store_confirm();
bool get_capture_status(bool &triggered, int &progress);
std::set<data::SignalData*> get_data();
std::vector<view::Signal*>& get_signals();
bool add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus,
@@ -366,10 +383,6 @@ public:
bool switch_work_mode(int mode);
bool have_new_realtime_refresh(bool keep);
data::LogicSnapshot* get_logic_data();
data::AnalogSnapshot* get_analog_data();
data::DsoSnapshot* get_dso_data();
private:
void set_cur_samplelimits(uint64_t samplelimits);
void set_cur_snap_samplerate(uint64_t samplerate);
@@ -425,10 +438,10 @@ private:
void feed_in_header(const sr_dev_inst *sdi);
void feed_in_meta(const sr_dev_inst *sdi, const sr_datafeed_meta &meta);
void feed_in_trigger(const ds_trigger_pos &trigger_pos);
void feed_in_logic(const sr_datafeed_logic &logic);
void feed_in_logic(const sr_datafeed_logic &o);
void feed_in_dso(const sr_datafeed_dso &dso);
void feed_in_analog(const sr_datafeed_analog &analog);
void feed_in_dso(const sr_datafeed_dso &o);
void feed_in_analog(const sr_datafeed_analog &o);
void data_feed_in(const struct sr_dev_inst *sdi,
const struct sr_datafeed_packet *packet);
@@ -448,9 +461,7 @@ private:
mutable std::mutex _data_mutex;
mutable std::mutex _decode_task_mutex;
std::thread _decode_thread;
volatile bool _is_decoding;
uint64_t _cur_snap_samplerate;
uint64_t _cur_samplelimits;
volatile bool _is_decoding;
std::vector<view::Signal*> _signals;
std::vector<view::DecodeTrace*> _decode_traces;
@@ -460,11 +471,6 @@ private:
view::LissajousTrace *_lissajous_trace;
view::MathTrace *_math_trace;
data::Logic *_logic_data;
data::Dso *_dso_data;
data::Analog *_analog_data;
int _group_cnt;
DsTimer _feed_timer;
DsTimer _out_timer;
DsTimer _repeat_timer;
@@ -484,7 +490,6 @@ private:
SESSION_ERROR_STATUS _error;
uint64_t _error_pattern;
int _map_zoom;
bool _dso_feed;
float _stop_scale;
bool _bClose;
@@ -508,6 +513,9 @@ private:
DeviceAgent _device_agent;
std::vector<IMessageListener*> _msg_listeners;
DeviceEventObject _device_event;
SessionData *_view_data;
SessionData *_capture_data;
std::vector<SessionData*> _data_list;
private:
// TODO: This should not be necessary. Multiple concurrent

View File

@@ -26,7 +26,6 @@
#include "storesession.h"
#include "sigsession.h"
#include "data/logic.h"
#include "data/logicsnapshot.h"
#include "data/dsosnapshot.h"
#include "data/analogsnapshot.h"

View File

@@ -45,11 +45,6 @@ namespace pv
{
class SigSession;
namespace device
{
class DevInst;
}
namespace view{
class View;
}

View File

@@ -22,7 +22,6 @@
#include <math.h>
#include "../view/analogsignal.h"
#include "../data/analog.h"
#include "../data/analogsnapshot.h"
#include "../view/view.h"
#include "../dsvdef.h"
@@ -44,7 +43,7 @@ const QColor AnalogSignal::SignalColours[4] = {
const float AnalogSignal::EnvelopeThreshold = 16.0f;
AnalogSignal::AnalogSignal(data::Analog *data, sr_channel *probe) :
AnalogSignal::AnalogSignal(data::AnalogSnapshot *data, sr_channel *probe) :
Signal(probe),
_data(data),
_rects(NULL),
@@ -96,7 +95,7 @@ AnalogSignal::AnalogSignal(data::Analog *data, sr_channel *probe) :
}
}
AnalogSignal::AnalogSignal(view::AnalogSignal *s, pv::data::Analog *data, sr_channel *probe) :
AnalogSignal::AnalogSignal(view::AnalogSignal *s, pv::data::AnalogSnapshot *data, sr_channel *probe) :
Signal(*s, probe),
_data(data),
_rects(NULL),
@@ -124,36 +123,6 @@ AnalogSignal::~AnalogSignal()
}
}
pv::data::SignalData* AnalogSignal::data()
{
return _data;
}
void AnalogSignal::set_scale(int height)
{
_scale = height / (_ref_max - _ref_min);
}
float AnalogSignal::get_scale()
{
return _scale;
}
int AnalogSignal::get_bits()
{
return _bits;
}
double AnalogSignal::get_ref_min()
{
return _ref_min;
}
double AnalogSignal::get_ref_max()
{
return _ref_max;
}
int AnalogSignal::get_hw_offset()
{
int hw_offset = 0;
@@ -205,12 +174,7 @@ bool AnalogSignal::measure(const QPointF &p)
if (!window.contains(p))
return false;
const auto &snapshots = _data->get_snapshots();
if (snapshots.empty())
return false;
const auto snapshot = snapshots.front();
if (snapshot->empty())
if (_data->have_data() == false)
return false;
const double scale = _view->scale();
@@ -220,7 +184,7 @@ bool AnalogSignal::measure(const QPointF &p)
const double samples_per_pixel = samplerate * scale;
_hover_index = floor((p.x() + pixels_offset) * samples_per_pixel+0.5);
if (_hover_index >= snapshot->get_sample_count())
if (_hover_index >= _data->get_sample_count())
return false;
_hover_point = get_point(_hover_index, _hover_value);
@@ -246,15 +210,7 @@ QPointF AnalogSignal::get_point(uint64_t index, float &value)
if (!enabled())
return pt;
const auto &snapshots = _data->get_snapshots();
if (snapshots.empty())
return pt;
const auto snapshot = snapshots.front();
if (snapshot->empty())
return pt;
const int order = snapshot->get_ch_order(get_index());
const int order = _data->get_ch_order(get_index());
if (order == -1)
return pt;
@@ -264,11 +220,11 @@ QPointF AnalogSignal::get_point(uint64_t index, float &value)
const double samplerate = _view->session().cur_snap_samplerate();
const double samples_per_pixel = samplerate * scale;
if (index >= snapshot->get_sample_count())
if (index >= _data->get_sample_count())
return pt;
const uint64_t ring_index = (uint64_t)(snapshot->get_ring_start() + floor(index)) % snapshot->get_sample_count();
value = *(snapshot->get_samples(ring_index) + order*snapshot->get_unit_bytes());
const uint64_t ring_index = (uint64_t)(_data->get_ring_start() + floor(index)) % _data->get_sample_count();
value = *(_data->get_samples(ring_index) + order * _data->get_unit_bytes());
const int height = get_totalHeight();
const float top = get_y() - height * 0.5;
@@ -390,9 +346,6 @@ double AnalogSignal::pos2ratio(int pos)
return min(max(pos - top, 0), height) * 1.0 / height;
}
/**
*
**/
void AnalogSignal::set_zero_vpos(int pos)
{
if (enabled()) {
@@ -420,11 +373,6 @@ double AnalogSignal::get_zero_ratio()
return value2ratio(_zero_offset);
}
int AnalogSignal::get_zero_offset()
{
return _zero_offset;
}
/**
* Event
**/
@@ -507,23 +455,15 @@ void AnalogSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QCol
assert(scale > 0);
const int64_t offset = _view->offset();
const auto &snapshots = _data->get_snapshots();
if (snapshots.empty())
return;
const auto snapshot = snapshots.front();
if (snapshot->empty())
return;
const int order = snapshot->get_ch_order(get_index());
const int order = _data->get_ch_order(get_index());
if (order == -1)
return;
const double pixels_offset = offset;
const double samplerate = _data->samplerate();
const int64_t cur_sample_count = snapshot->get_sample_count();
const int64_t cur_sample_count = _data->get_sample_count();
const double samples_per_pixel = samplerate * scale;
const uint64_t ring_start = snapshot->get_ring_start();
const uint64_t ring_start = _data->get_ring_start();
int64_t start_pixel;
uint64_t start_index;
@@ -535,16 +475,18 @@ void AnalogSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QCol
if (show_length <= 0)
return;
if (samples_per_pixel < EnvelopeThreshold)
paint_trace(p, snapshot, zeroY,
if (samples_per_pixel < EnvelopeThreshold){
paint_trace(p, _data, zeroY,
start_pixel, start_index, show_length,
samples_per_pixel, order,
top, bottom, width);
else
paint_envelope(p, snapshot, zeroY,
}
else{
paint_envelope(p, _data, zeroY,
start_pixel, start_index, show_length,
samples_per_pixel, order,
top, bottom, width);
}
}
void AnalogSignal::paint_fore(QPainter &p, int left, int right, QColor fore, QColor back)

View File

@@ -29,8 +29,6 @@
namespace pv {
namespace data {
class Logic;
class Analog;
class AnalogSnapshot;
}
@@ -52,26 +50,36 @@ private:
static const uint8_t DefaultBits = 8;
public:
AnalogSignal(pv::data::Analog *data,
AnalogSignal(pv::data::AnalogSnapshot *data,
sr_channel *probe);
AnalogSignal(view::AnalogSignal* s, pv::data::Analog *data, sr_channel *probe);
AnalogSignal(view::AnalogSignal* s, pv::data::AnalogSnapshot *data, sr_channel *probe);
virtual ~AnalogSignal();
pv::data::SignalData* data();
inline void set_scale(int height){
_scale = height / (_ref_max - _ref_min);
}
inline float get_scale(){
return _scale;
}
inline int get_bits(){
return _bits;
}
inline double get_ref_min(){
return _ref_min;
}
inline double get_ref_max(){
return _ref_max;
}
void set_scale(int height);
float get_scale();
int get_bits();
double get_ref_min();
double get_ref_max();
int get_hw_offset();
int commit_settings();
/**
*
*/
bool measure(const QPointF &p);
bool get_hover(uint64_t &index, QPointF &p, double &value);
QPointF get_point(uint64_t index, float &value);
@@ -87,19 +95,16 @@ public:
double get_mapMin();
double get_mapMax();
uint64_t get_factor();
/**
*
**/
void set_zero_vpos(int pos);
int get_zero_vpos();
void set_zero_ratio(double ratio);
double get_zero_ratio();
int get_zero_offset();
/**
*
*/
inline int get_zero_offset(){
return _zero_offset;
}
int ratio2value(double ratio);
int ratio2pos(double ratio);
double value2ratio(int value);
@@ -152,7 +157,7 @@ private:
void paint_hover_measure(QPainter &p, QColor fore, QColor back);
private:
pv::data::Analog *_data;
pv::data::AnalogSnapshot *_data;
QRectF *_rects;

View File

@@ -38,7 +38,6 @@
#include "../sigsession.h"
#include "../data/decoderstack.h"
#include "../data/decode/decoder.h"
#include "../data/logic.h"
#include "../data/logicsnapshot.h"
#include "../data/decode/annotation.h"
#include "../view/logicsignal.h"

View File

@@ -47,10 +47,6 @@ class DeviceAgent;
namespace pv {
namespace device{
class DevInst;
}
class SigSession;
namespace view {

View File

@@ -27,7 +27,6 @@
#include "view.h"
#include "../dsvdef.h"
#include "../data/dso.h"
#include "../data/dsosnapshot.h"
#include "../sigsession.h"
#include "../log.h"
@@ -53,7 +52,7 @@ const QColor DsoSignal::SignalColours[4] = {
const float DsoSignal::EnvelopeThreshold = 256.0f;
DsoSignal::DsoSignal(data::Dso *data,
DsoSignal::DsoSignal(data::DsoSnapshot *data,
sr_channel *probe):
Signal(probe),
_data(data),
@@ -111,46 +110,11 @@ DsoSignal::~DsoSignal()
{
}
pv::data::SignalData* DsoSignal::data()
{
return _data;
}
pv::data::Dso* DsoSignal::dso_data()
{
return _data;
}
void DsoSignal::set_scale(int height)
{
_scale = height / (_ref_max - _ref_min) * session->stop_scale();
}
float DsoSignal::get_scale()
{
return _scale;
}
uint8_t DsoSignal::get_bits()
{
return _bits;
}
double DsoSignal::get_ref_min()
{
return _ref_min;
}
double DsoSignal::get_ref_max()
{
return _ref_max;
}
int DsoSignal::get_name_width()
{
return 0;
}
void DsoSignal::set_enable(bool enable)
{
if (session->get_device()->name() == "DSLogic" && get_index() == 0){
@@ -201,11 +165,6 @@ void DsoSignal::set_enable(bool enable)
_en_lock = false;
}
bool DsoSignal::get_vDialActive()
{
return _vDialActive;
}
void DsoSignal::set_vDialActive(bool active)
{
if (enabled())
@@ -410,11 +369,6 @@ int DsoSignal::commit_settings()
return ret;
}
dslDial * DsoSignal::get_vDial()
{
return _vDial;
}
uint64_t DsoSignal::get_vDialValue()
{
return _vDial->get_value();
@@ -425,11 +379,6 @@ uint16_t DsoSignal::get_vDialSel()
return _vDial->get_sel();
}
uint8_t DsoSignal::get_acCoupling()
{
return _acCoupling;
}
void DsoSignal::set_acCoupling(uint8_t coupling)
{
if (enabled()) {
@@ -575,21 +524,6 @@ uint64_t DsoSignal::get_factor()
}
}
void DsoSignal::set_show(bool show)
{
_show = show;
}
bool DsoSignal::show()
{
return _show;
}
void DsoSignal::set_mValid(bool valid)
{
_mValid = valid;
}
QString DsoSignal::get_measure(enum DSO_MEASURE_TYPE type)
{
const QString mNone = "--";
@@ -720,15 +654,7 @@ void DsoSignal::paint_prepare()
{
assert(_view);
const auto &snapshots = _data->get_snapshots();
if (snapshots.empty())
return;
const auto snapshot = snapshots.front();
if (snapshot->empty())
return;
if (!snapshot->has_data(get_index()))
if (_data->empty() || !_data->has_data(get_index()))
return;
if (session->trigd()) {
@@ -741,9 +667,10 @@ void DsoSignal::paint_prepare()
}
int64_t trig_index = _view->get_trig_cursor()->index();
if (trig_index >= (int64_t)snapshot->get_sample_count())
if (trig_index >= (int64_t)_data->get_sample_count())
return;
const uint8_t *const trig_samples = snapshot->get_samples(0, 0, get_index());
const uint8_t *const trig_samples = _data->get_samples(0, 0, get_index());
for (uint16_t i = 0; i < TrigHRng; i++) {
const int64_t i0 = trig_index - i - 1;
const int64_t i1 = trig_index - i;
@@ -860,23 +787,15 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor
assert(scale > 0);
const int64_t offset = _view->offset();
const auto &snapshots = _data->get_snapshots();
if (snapshots.empty())
if (_data->empty() || !_data->has_data(index))
return;
const auto snapshot = snapshots.front();
if (snapshot->empty())
return;
if (!snapshot->has_data(index))
return;
const uint16_t enabled_channels = snapshot->get_channel_num();
const uint16_t enabled_channels = _data->get_channel_num();
const double pixels_offset = offset;
const double samplerate = _data->samplerate();
//const double samplerate = session->get_device()->get_sample_rate();
//const double samplerate = session->cur_snap_samplerate();
const int64_t last_sample = max((int64_t)(snapshot->get_sample_count() - 1), (int64_t)0);
const int64_t last_sample = max((int64_t)(_data->get_sample_count() - 1), (int64_t)0);
const double samples_per_pixel = samplerate * scale;
const double start = offset * samples_per_pixel - _view->trig_hoff();
const double end = start + samples_per_pixel * width;
@@ -888,13 +807,13 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor
const int hw_offset = get_hw_offset();
if (samples_per_pixel < EnvelopeThreshold) {
snapshot->enable_envelope(false);
paint_trace(p, snapshot, zeroY, left,
_data->enable_envelope(false);
paint_trace(p, _data, zeroY, left,
start_sample, end_sample, hw_offset,
pixels_offset, samples_per_pixel, enabled_channels);
} else {
snapshot->enable_envelope(true);
paint_envelope(p, snapshot, zeroY, left,
_data->enable_envelope(true);
paint_envelope(p, _data, zeroY, left,
start_sample, end_sample, hw_offset,
pixels_offset, samples_per_pixel, enabled_channels);
}
@@ -936,9 +855,9 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor
_pcount = count + (plevel & !startXORend);
_rms = (index == 0) ? status.ch0_acc_square : status.ch1_acc_square;
_rms = sqrt(_rms / snapshot->get_sample_count());
_rms = sqrt(_rms / _data->get_sample_count());
_mean = (index == 0) ? status.ch0_acc_mean : status.ch1_acc_mean;
_mean = hw_offset - _mean / snapshot->get_sample_count();
_mean = hw_offset - _mean / _data->get_sample_count();
}
}
}
@@ -1499,16 +1418,11 @@ bool DsoSignal::measure(const QPointF &p)
if (!window.contains(p))
return false;
const auto &snapshots = _data->get_snapshots();
if (snapshots.empty())
return false;
auto snapshot = const_cast<data::DsoSnapshot*>(snapshots.front());
if (snapshot->empty())
if (_data->empty())
return false;
_hover_index = _view->pixel2index(p.x());
if (_hover_index >= snapshot->get_sample_count())
if (_hover_index >= _data->get_sample_count())
return false;
_hover_point = get_point(_hover_index, _hover_value);
@@ -1534,18 +1448,13 @@ QPointF DsoSignal::get_point(uint64_t index, float &value)
if (!enabled())
return pt;
const auto &snapshots = _data->get_snapshots();
if (snapshots.empty())
if (_data->empty())
return pt;
const auto snapshot = snapshots.front();
if (snapshot->empty())
if (index >= _data->get_sample_count())
return pt;
if (index >= snapshot->get_sample_count())
return pt;
value = *snapshot->get_samples(index, index, get_index());
value = *_data->get_samples(index, index, get_index());
const float top = get_view_rect().top();
const float bottom = get_view_rect().bottom();
const int hw_offset = get_hw_offset();
@@ -1561,18 +1470,13 @@ double DsoSignal::get_voltage(uint64_t index)
if (!enabled())
return 1;
auto &snapshots = _data->get_snapshots();
if (snapshots.empty())
if (_data->empty())
return 1;
auto snapshot = const_cast<data::DsoSnapshot*>(snapshots.front());
if (snapshot->empty())
if (index >= _data->get_sample_count())
return 1;
if (index >= snapshot->get_sample_count())
return 1;
const double value = *snapshot->get_samples(index, index, get_index());
const double value = *_data->get_samples(index, index, get_index());
const int hw_offset = get_hw_offset();
return (hw_offset - value) * _scale *
_vDial->get_value() * _vDial->get_factor() *

View File

@@ -28,9 +28,6 @@
namespace pv {
namespace data {
class Logic;
class Dso;
class Analog;
class DsoSnapshot;
}
@@ -85,34 +82,58 @@ private:
static const uint16_t MS_RectHeight = 25;
public:
DsoSignal(pv::data::Dso *data,
DsoSignal(pv::data::DsoSnapshot *data,
sr_channel *probe);
virtual ~DsoSignal();
pv::data::SignalData* data();
pv::data::Dso* dso_data();
inline data::DsoSnapshot* dso_data(){
return _data;
}
void set_scale(int height);
float get_scale();
uint8_t get_bits();
double get_ref_min();
double get_ref_max();
int get_name_width();
inline float get_scale(){
return _scale;
}
inline uint8_t get_bits(){
return _bits;
}
inline double get_ref_min(){
return _ref_min;
}
inline double get_ref_max(){
return _ref_max;
}
inline int get_name_width(){
return 0;
}
/**
*
*/
void set_enable(bool enable);
bool get_vDialActive();
inline bool get_vDialActive(){
return _vDialActive;
}
void set_vDialActive(bool active);
bool go_vDialPre(bool manul);
bool go_vDialNext(bool manul);
dslDial *get_vDial();
inline dslDial *get_vDial(){
return _vDial;
}
uint64_t get_vDialValue();
uint16_t get_vDialSel();
uint8_t get_acCoupling();
inline uint8_t get_acCoupling(){
return _acCoupling;
}
void set_acCoupling(uint8_t coupling);
void set_trig_vpos(int pos, bool delta_change = true);
@@ -121,9 +142,18 @@ public:
void set_factor(uint64_t factor);
uint64_t get_factor();
void set_show(bool show);
bool show();
void set_mValid(bool valid);
inline void set_show(bool show){
_show = show;
}
inline bool show(){
return _show;
}
inline void set_mValid(bool valid){
_mValid = valid;
}
bool load_settings();
int commit_settings();
@@ -230,7 +260,7 @@ private:
void call_auto_end();
private:
pv::data::Dso *_data;
pv::data::DsoSnapshot *_data;
float _scale;
bool _en_lock;
bool _show;

View File

@@ -29,11 +29,6 @@
namespace pv {
namespace data {
class Logic;
class Analog;
}
namespace view {
//created by SigSession

View File

@@ -26,7 +26,6 @@
#include "view.h"
#include "../dsvdef.h"
#include "lissajoustrace.h"
#include "../data/dso.h"
#include "../data/dsosnapshot.h"
#include "../sigsession.h"
@@ -38,7 +37,7 @@ namespace pv {
namespace view {
LissajousTrace::LissajousTrace(bool enable,
data::Dso *data,
data::DsoSnapshot *data,
int xIndex, int yIndex, int percent):
Trace("Lissajous", xIndex, SR_CHANNEL_LISSAJOUS),
_data(data),
@@ -79,12 +78,12 @@ int LissajousTrace::percent()
return _percent;
}
pv::data::Dso* LissajousTrace::get_data()
pv::data::DsoSnapshot* LissajousTrace::get_data()
{
return _data;
}
void LissajousTrace::set_data(data::Dso *data)
void LissajousTrace::set_data(data::DsoSnapshot *data)
{
_data = data;
}
@@ -147,28 +146,24 @@ void LissajousTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QC
assert(right >= left);
if (enabled()) {
const auto &snapshots = _data->get_snapshots();
if (snapshots.empty())
return;
auto snapshot = snapshots.front();
if (snapshot->empty())
if (_data->empty())
return;
int left = _border.left();
int bottom = _border.bottom();
double scale = _border.width() / 255.0;
uint64_t sample_count = snapshot->get_sample_count() * min(_percent / 100.0, 1.0);
uint64_t sample_count = _data->get_sample_count() * min(_percent / 100.0, 1.0);
QPointF *points = new QPointF[sample_count];
QPointF *point = points;
int channel_num = snapshot->get_channel_num();
int channel_num = _data->get_channel_num();
if (_xIndex >= channel_num || _yIndex >= channel_num) {
p.setPen(view::View::Red);
p.drawText(_border.marginsRemoved(QMargins(10, 30, 10, 30)),
L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DATA_SOURCE_ERROR), "Data source error."));
} else {
const uint8_t *const samples = snapshot->get_samples(0, sample_count-1, 0);
const uint8_t *const samples = _data->get_samples(0, sample_count-1, 0);
for (uint64_t i = 0; i < sample_count; i++) {
*point++ = QPointF(left + samples[i + _xIndex] * scale,

View File

@@ -28,9 +28,6 @@
namespace pv {
namespace data {
class Logic;
class Dso;
class Analog;
class DsoSnapshot;
}
@@ -46,7 +43,7 @@ private:
static const int DIV_NUM = 10;
public:
LissajousTrace(bool enable, pv::data::Dso *data,
LissajousTrace(bool enable, pv::data::DsoSnapshot *data,
int xIndex, int yIndex, int percent);
virtual ~LissajousTrace();
@@ -57,8 +54,8 @@ public:
int yIndex();
int percent();
pv::data::Dso* get_data();
void set_data(pv::data::Dso* data);
pv::data::DsoSnapshot* get_data();
void set_data(pv::data::DsoSnapshot* data);
int rows_size();
@@ -89,7 +86,7 @@ public:
void paint_label(QPainter &p, int right, const QPoint pt, QColor fore);
private:
pv::data::Dso *_data;
pv::data::DsoSnapshot *_data;
bool _enable;
int _xIndex;

View File

@@ -23,8 +23,7 @@
#include <libsigrokdecode.h>
#include <math.h>
#include "logicsignal.h"
#include "view.h"
#include "../data/logic.h"
#include "view.h"
#include "../data/logicsnapshot.h"
#include "view.h"
#include "../dsvdef.h"
@@ -40,7 +39,7 @@ const float LogicSignal::Oversampling = 1.0f;
const int LogicSignal::StateHeight = 12;
const int LogicSignal::StateRound = 5;
LogicSignal::LogicSignal(data::Logic *data,
LogicSignal::LogicSignal(data::LogicSnapshot *data,
sr_channel *probe) :
Signal(probe),
_data(data)
@@ -50,7 +49,7 @@ LogicSignal::LogicSignal(data::Logic *data,
}
LogicSignal::LogicSignal(view::LogicSignal *s,
data::Logic *data,
data::LogicSnapshot *data,
sr_channel *probe) :
Signal(*s, probe),
_data(data),
@@ -65,26 +64,6 @@ LogicSignal::~LogicSignal()
_cur_pulses.clear();
}
const sr_channel* LogicSignal::probe()
{
return _probe;
}
pv::data::SignalData* LogicSignal::data()
{
return _data;
}
pv::data::Logic* LogicSignal::logic_data()
{
return _data;
}
LogicSignal::LogicSetRegions LogicSignal::get_trig()
{
return _trig;
}
void LogicSignal::set_trig(int trig)
{
if (trig > NONTRIG && trig <= EDGTRIG)
@@ -95,7 +74,6 @@ void LogicSignal::set_trig(int trig)
bool LogicSignal::commit_trig()
{
if (_trig == NONTRIG) {
ds_trigger_probe_set(_index_list.front(), 'X', 'X');
return false;
@@ -134,18 +112,14 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColo
const int high_offset = y - _totalHeight + 0.5f;
const int low_offset = y + 0.5f;
const auto &snapshots =_data->get_snapshots();
double samplerate = _data->samplerate();
if (snapshots.empty() || samplerate == 0)
if (_data->empty() || samplerate == 0)
return;
auto snapshot = const_cast<data::LogicSnapshot*>(snapshots.front());
if (snapshot->empty())
return;
if (!snapshot->has_data(_probe->index))
if (!_data->has_data(_probe->index))
return;
const int64_t last_sample = snapshot->get_ring_sample_count() - 1;
const int64_t last_sample = _data->get_ring_sample_count() - 1;
const double samples_per_pixel = samplerate * scale;
uint16_t width = right - left;
@@ -160,7 +134,7 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColo
width = min(width, (uint16_t)ceil((end_index + 1)/samples_per_pixel - offset));
const uint16_t max_togs = width / TogMaxScale;
const bool first_sample = snapshot->get_display_edges(_cur_pulses, _cur_edges,
const bool first_sample = _data->get_display_edges(_cur_pulses, _cur_edges,
start_index, end_index, width, max_togs,
offset,
samples_per_pixel, _probe->index);
@@ -294,34 +268,32 @@ bool LogicSignal::measure(const QPointF &p, uint64_t &index0, uint64_t &index1,
{
const float gap = abs(p.y() - get_y());
if (gap < get_totalHeight() * 0.5) {
const auto &snapshots =_data->get_snapshots();
if (snapshots.empty())
if (_data->empty() || !_data->has_data(_probe->index))
return false;
const auto snapshot = snapshots.front();
if (snapshot->empty() || !snapshot->has_data(_probe->index))
return false;
const uint64_t end = snapshot->get_sample_count() - 1;
const uint64_t end = _data->get_sample_count() - 1;
uint64_t index = _data->samplerate() * _view->scale() * (_view->offset() + p.x());
if (index > end)
return false;
bool sample = snapshot->get_sample(index, get_index());
if (index == 0)
bool sample = _data->get_sample(index, get_index());
if (index == 0){
index0 = index;
}
else {
index--;
if (snapshot->get_pre_edge(index, sample, 1, get_index()))
if (_data->get_pre_edge(index, sample, 1, get_index()))
index0 = index;
else
index0 = 0;
}
sample = snapshot->get_sample(index, get_index());
sample = _data->get_sample(index, get_index());
index++;
if (snapshot->get_nxt_edge(index, sample, end, 1, get_index()))
if (_data->get_nxt_edge(index, sample, end, 1, get_index())){
index1 = index;
}
else {
if (index0 == 0)
return false;
@@ -330,9 +302,9 @@ bool LogicSignal::measure(const QPointF &p, uint64_t &index0, uint64_t &index1,
return true;
}
sample = snapshot->get_sample(index, get_index());
sample = _data->get_sample(index, get_index());
index++;
if (snapshot->get_nxt_edge(index, sample, end, 1, get_index()))
if (_data->get_nxt_edge(index, sample, end, 1, get_index()))
index2 = index;
else
index2 = end + 1;
@@ -346,36 +318,31 @@ bool LogicSignal::edge(const QPointF &p, uint64_t &index, int radius)
{
uint64_t pre_index, nxt_index;
const float gap = abs(p.y() - get_y());
if (gap < get_totalHeight() * 0.5) {
const auto &snapshots = _data->get_snapshots();
if (snapshots.empty())
if (_data->empty() || !_data->has_data(_probe->index))
return false;
const auto snapshot = snapshots.front();
if (snapshot->empty() || !snapshot->has_data(_probe->index))
return false;
const uint64_t end = snapshot->get_sample_count() - 1;
const
double pos = _data->samplerate() * _view->scale() * (_view->offset() + p.x());
const uint64_t end = _data->get_sample_count() - 1;
const double pos = _data->samplerate() * _view->scale() * (_view->offset() + p.x());
index = floor(pos + 0.5);
if (index > end)
return false;
bool sample = snapshot->get_sample(index, get_index());
bool sample = _data->get_sample(index, get_index());
if (index == 0)
pre_index = index;
else {
index--;
if (snapshot->get_pre_edge(index, sample, 1, get_index()))
if (_data->get_pre_edge(index, sample, 1, get_index()))
pre_index = index;
else
pre_index = 0;
}
sample = snapshot->get_sample(index, get_index());
sample = _data->get_sample(index, get_index());
index++;
if (snapshot->get_nxt_edge(index, sample, end, 1, get_index()))
if (_data->get_nxt_edge(index, sample, end, 1, get_index()))
nxt_index = index;
else
nxt_index = 0;
@@ -406,29 +373,24 @@ bool LogicSignal::edges(const QPointF &p, uint64_t start, uint64_t &rising, uint
}
bool LogicSignal::edges(uint64_t end, uint64_t start, uint64_t &rising, uint64_t &falling)
{
const auto &snapshots = _data->get_snapshots();
if (snapshots.empty())
return false;
const auto snapshot = snapshots.front();
if (snapshot->empty() || !snapshot->has_data(_probe->index))
{
if (_data->empty() || !_data->has_data(_probe->index))
return false;
uint64_t index = min(start, end);
const uint64_t sample_count = snapshot->get_sample_count();
const uint64_t sample_count = _data->get_sample_count();
end = max(start, end);
start = index;
if (end > (sample_count - 1))
return false;
const int ch_index = get_index();
bool sample = snapshot->get_sample(start, ch_index);
bool sample = _data->get_sample(start, ch_index);
rising = 0;
falling = 0;
do {
if (snapshot->get_nxt_edge(index, sample, sample_count, 1, ch_index)) {
if (_data->get_nxt_edge(index, sample, sample_count, 1, ch_index)) {
if (index > end)
break;
rising += !sample;

View File

@@ -31,10 +31,8 @@
namespace pv {
namespace data {
class Logic;
class Analog;
}
class LogicSnapshot;
}
namespace view {
@@ -63,23 +61,26 @@ public:
};
public:
LogicSignal(data::Logic* data, sr_channel *probe);
LogicSignal(data::LogicSnapshot *data, sr_channel *probe);
LogicSignal(view::LogicSignal*s, pv::data::Logic *data, sr_channel *probe);
LogicSignal(view::LogicSignal*s, data::LogicSnapshot *data, sr_channel *probe);
virtual ~LogicSignal();
const sr_channel* probe();
inline const sr_channel* probe(){
return _probe;
}
pv::data::SignalData* data();
inline data::LogicSnapshot* logic_data(){
return _data;
}
inline LogicSetRegions get_trig(){
return _trig;
}
pv::data::Logic* logic_data();
/**
*
*/
LogicSetRegions get_trig();
void set_trig(int trig);
bool commit_trig();
/**
@@ -115,7 +116,7 @@ private:
float x_offset, float y_offset);
private:
pv::data::Logic* _data;
pv::data::LogicSnapshot* _data;
std::vector< std::pair<uint16_t, bool> > _cur_edges;
std::vector<std::pair<bool, bool>> _cur_pulses;
LogicSetRegions _trig;

View File

@@ -23,7 +23,6 @@
#include <math.h>
#include <QTimer>
#include "mathtrace.h"
#include "../data/dso.h"
#include "../data/dsosnapshot.h"
#include "../data/mathstack.h"
#include "view.h"

View File

@@ -28,9 +28,6 @@
namespace pv {
namespace data {
class Logic;
class Dso;
class Analog;
class DsoSnapshot;
class MathStack;
}

View File

@@ -69,7 +69,7 @@ protected:
Signal(const Signal &s, sr_channel * const probe);
public:
virtual pv::data::SignalData* data() = 0;
// virtual pv::data::SignalData* data() = 0;
/**
* Returns true if the trace is visible and enabled.

View File

@@ -28,7 +28,6 @@
#include "spectrumtrace.h"
#include "../sigsession.h"
#include "../data/dso.h"
#include "../data/dsosnapshot.h"
#include "../view/dsosignal.h"
#include "../view/viewport.h"

View File

@@ -42,7 +42,6 @@
#include "analogsignal.h"
#include "../sigsession.h"
#include "../data/logic.h"
#include "../data/logicsnapshot.h"
#include "../dialogs/calibration.h"
#include "../dialogs/lissajousoptions.h"
@@ -518,10 +517,6 @@ void View::normalize_layout()
void View::get_scroll_layout(int64_t &length, int64_t &offset)
{
const auto data_set = _session->get_data();
if (data_set.empty())
return;
length = ceil(_session->cur_snap_sampletime() / _scale);
offset = _offset;
}

View File

@@ -28,7 +28,6 @@
#include "logicsignal.h"
#include "analogsignal.h"
#include "spectrumtrace.h"
#include "../data/logic.h"
#include "../data/logicsnapshot.h"
#include "../sigsession.h"
#include "../dialogs/dsomeasure.h"