mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-23 13:42:55 +08:00
fix: Signal bind a error type
This commit is contained in:
parent
55e3483bff
commit
e4e5f07682
@ -347,6 +347,7 @@ set(DSView_SOURCES
|
||||
DSView/pv/dialogs/decoderoptionsdlg.cpp
|
||||
DSView/pv/utility/encoding.cpp
|
||||
DSView/pv/utility/path.cpp
|
||||
DSView/pv/utility/array.cpp
|
||||
DSView/pv/deviceagent.cpp
|
||||
DSView/pv/ui/langresource.cpp
|
||||
)
|
||||
@ -439,6 +440,7 @@ set(DSView_HEADERS
|
||||
DSView/pv/dialogs/decoderoptionsdlg.h
|
||||
DSView/pv/utility/encoding.h
|
||||
DSView/pv/utility/path.h
|
||||
DSView/pv/utility/array.h
|
||||
DSView/pv/deviceagent.h
|
||||
)
|
||||
|
||||
|
@ -448,7 +448,7 @@ void DecoderStack::do_decode_work()
|
||||
}
|
||||
}
|
||||
|
||||
if (!data == NULL)
|
||||
if (data == NULL)
|
||||
return;
|
||||
|
||||
// Check we have a snapshot of data
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "logicsnapshot.h"
|
||||
#include "../dsvdef.h"
|
||||
#include "../log.h"
|
||||
#include "../utility/array.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -48,9 +49,11 @@ const uint64_t LogicSnapshot::LevelOffset[LogicSnapshot::ScaleLevel] = {
|
||||
};
|
||||
|
||||
LogicSnapshot::LogicSnapshot() :
|
||||
Snapshot(1, 0, 0),
|
||||
_block_num(0)
|
||||
Snapshot(1, 0, 0)
|
||||
{
|
||||
_channel_num = 0;
|
||||
_block_num = 0;
|
||||
_total_sample_count = 0;
|
||||
}
|
||||
|
||||
LogicSnapshot::~LogicSnapshot()
|
||||
@ -93,7 +96,6 @@ void LogicSnapshot::init_all()
|
||||
_data = NULL;
|
||||
_memory_failed = false;
|
||||
_last_ended = true;
|
||||
_times = 0;
|
||||
}
|
||||
|
||||
void LogicSnapshot::clear()
|
||||
@ -156,23 +158,23 @@ void LogicSnapshot::first_payload(const sr_datafeed_logic &logic, uint64_t total
|
||||
{
|
||||
bool channel_changed = false;
|
||||
uint16_t 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_LOGIC) {
|
||||
channel_num += probe->enabled;
|
||||
if (!channel_changed && probe->enabled) {
|
||||
if (probe->type == SR_CHANNEL_LOGIC && probe->enabled) {
|
||||
channel_num++;
|
||||
if (!channel_changed){
|
||||
channel_changed = !has_data(probe->index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (total_sample_count != _total_sample_count ||
|
||||
channel_num != _channel_num ||
|
||||
channel_changed) {
|
||||
if (total_sample_count != _total_sample_count
|
||||
|| channel_num != _channel_num
|
||||
|| channel_changed) {
|
||||
|
||||
free_data();
|
||||
|
||||
_ch_index.clear();
|
||||
|
||||
_total_sample_count = total_sample_count;
|
||||
@ -194,8 +196,8 @@ void LogicSnapshot::first_payload(const sr_datafeed_logic &logic, uint64_t total
|
||||
_ch_index.push_back(probe->index);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for(auto& iter : _ch_data) {
|
||||
for(auto& iter_rn : iter) {
|
||||
iter_rn.tog = 0;
|
||||
@ -204,18 +206,15 @@ void LogicSnapshot::first_payload(const sr_datafeed_logic &logic, uint64_t total
|
||||
}
|
||||
}
|
||||
|
||||
assert(_channel_num < LOGIC_TMP_BUF_MAX_SIZE);
|
||||
|
||||
_sample_count = 0;
|
||||
|
||||
_last_sample.clear();
|
||||
_sample_cnt.clear();
|
||||
_block_cnt.clear();
|
||||
_ring_sample_cnt.clear();
|
||||
|
||||
for (unsigned int i = 0; i < _channel_num; i++) {
|
||||
_last_sample.push_back(0);
|
||||
_sample_cnt.push_back(0);
|
||||
_block_cnt.push_back(0);
|
||||
_ring_sample_cnt.push_back(0);
|
||||
_last_sample[i] = 0;
|
||||
_sample_cnt[i] = 0;
|
||||
_block_cnt[i] = 0;
|
||||
_ring_sample_cnt[i] = 0;
|
||||
}
|
||||
|
||||
append_payload(logic);
|
||||
@ -224,7 +223,7 @@ void LogicSnapshot::first_payload(const sr_datafeed_logic &logic, uint64_t total
|
||||
|
||||
void LogicSnapshot::append_payload(const sr_datafeed_logic &logic)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
if (logic.format == LA_CROSS_DATA)
|
||||
append_cross_payload(logic);
|
||||
@ -296,14 +295,6 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic)
|
||||
const uint64_t index1 = (_ring_sample_count >> LeafBlockPower) % RootScale;
|
||||
const uint64_t offset = (_ring_sample_count % LeafBlockSamples) / Scale;
|
||||
|
||||
// _dest_ptr = (uint64_t *)_ch_data[i][index0].lbp[index1] + offset;
|
||||
// uint64_t mipmap_index = offset / 8 / Scale;
|
||||
// uint64_t mipmap_offset = (offset / 8) % Scale;
|
||||
// uint64_t *l1_mipmap = (uint64_t *)_ch_data[i][index0].lbp[index1] +
|
||||
// (LeafBlockSamples / Scale) + mipmap_index;
|
||||
// *l1_mipmap += ((_last_sample[i] ^ *(uint64_t *)_dest_ptr) != 0 ? 1ULL : 0ULL) << mipmap_offset;
|
||||
// _last_sample[i] = *(uint64_t *)_dest_ptr & (1ULL << (Scale - 1)) ? ~0ULL : 0ULL;
|
||||
|
||||
_ch_fraction = (_ch_fraction + 1) % _channel_num;
|
||||
if (_ch_fraction == 0)
|
||||
_ring_sample_count += Scale;
|
||||
@ -393,8 +384,6 @@ void LogicSnapshot::append_split_payload(const sr_datafeed_logic &logic)
|
||||
{
|
||||
assert(logic.format == LA_SPLIT_DATA);
|
||||
|
||||
_times++;
|
||||
|
||||
uint64_t samples = logic.length * 8;
|
||||
uint16_t order = logic.order;
|
||||
assert(order < _ch_data.size());
|
||||
@ -460,8 +449,8 @@ void LogicSnapshot::append_split_payload(const sr_datafeed_logic &logic)
|
||||
}
|
||||
}
|
||||
|
||||
_sample_count = *min_element(_sample_cnt.begin(), _sample_cnt.end());
|
||||
_ring_sample_count = *min_element(_ring_sample_cnt.begin(), _ring_sample_cnt.end());
|
||||
_sample_count = array::find_min_uint64(_sample_cnt, _channel_num);
|
||||
_ring_sample_count = array::find_min_uint64(_ring_sample_cnt, _channel_num);
|
||||
}
|
||||
|
||||
void LogicSnapshot::calc_mipmap(unsigned int order, uint8_t index0, uint8_t index1, uint64_t samples)
|
||||
@ -1032,16 +1021,15 @@ uint8_t *LogicSnapshot::get_block_buf(int block_index, int sig_index, bool &samp
|
||||
int LogicSnapshot::get_ch_order(int sig_index)
|
||||
{
|
||||
uint16_t order = 0;
|
||||
for (auto& iter:_ch_index) {
|
||||
if (iter == sig_index)
|
||||
break;
|
||||
order++;
|
||||
|
||||
for (uint16_t i : _ch_index) {
|
||||
if (i == sig_index)
|
||||
return order;
|
||||
else
|
||||
order++;
|
||||
}
|
||||
|
||||
if (order >= _ch_index.size())
|
||||
return -1;
|
||||
else
|
||||
return order;
|
||||
return -1;
|
||||
}
|
||||
|
||||
} // namespace data
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <map>
|
||||
|
||||
#define CHANNEL_MAX_COUNT 128
|
||||
#define LOGIC_TMP_BUF_MAX_SIZE 512
|
||||
|
||||
namespace LogicSnapshotTest {
|
||||
class Pow2;
|
||||
@ -186,18 +187,16 @@ private:
|
||||
|
||||
private:
|
||||
std::vector<std::vector<struct RootNode>> _ch_data;
|
||||
uint64_t _block_num;
|
||||
uint8_t _byte_fraction;
|
||||
uint16_t _ch_fraction;
|
||||
void *_src_ptr;
|
||||
void *_dest_ptr;
|
||||
uint64_t _block_num;
|
||||
uint8_t _byte_fraction;
|
||||
uint16_t _ch_fraction;
|
||||
void *_src_ptr;
|
||||
void *_dest_ptr;
|
||||
|
||||
std::vector<uint64_t> _sample_cnt;
|
||||
std::vector<uint64_t> _block_cnt;
|
||||
std::vector<uint64_t> _ring_sample_cnt;
|
||||
std::vector<uint64_t> _last_sample;
|
||||
|
||||
int _times;
|
||||
uint64_t _sample_cnt[LOGIC_TMP_BUF_MAX_SIZE];
|
||||
uint64_t _block_cnt[LOGIC_TMP_BUF_MAX_SIZE];
|
||||
uint64_t _ring_sample_cnt[LOGIC_TMP_BUF_MAX_SIZE];
|
||||
uint64_t _last_sample[LOGIC_TMP_BUF_MAX_SIZE];
|
||||
|
||||
friend class LogicSnapshotTest::Pow2;
|
||||
friend class LogicSnapshotTest::Basic;
|
||||
|
@ -37,10 +37,10 @@ Snapshot::Snapshot(int unit_size, uint64_t total_sample_count, unsigned int chan
|
||||
_total_sample_count(total_sample_count),
|
||||
_ring_sample_count(0),
|
||||
_unit_size(unit_size),
|
||||
_memory_failed(false),
|
||||
_last_ended(true)
|
||||
_memory_failed(false)
|
||||
{
|
||||
assert(_unit_size > 0);
|
||||
_last_ended = true;
|
||||
_unit_bytes = 1;
|
||||
_unit_pitch = 0;
|
||||
_have_data = false;
|
||||
@ -108,7 +108,7 @@ uint64_t Snapshot::ring_end()
|
||||
|
||||
void Snapshot::capture_ended()
|
||||
{
|
||||
set_last_ended(true);
|
||||
_last_ended = true;
|
||||
}
|
||||
|
||||
} // namespace data
|
||||
|
@ -65,10 +65,6 @@ public:
|
||||
return _last_ended;
|
||||
}
|
||||
|
||||
inline void set_last_ended(bool ended){
|
||||
_last_ended = ended;
|
||||
}
|
||||
|
||||
inline unsigned int get_channel_num(){
|
||||
return _channel_num;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ void SpectrumStack::calc_fft()
|
||||
}
|
||||
}
|
||||
|
||||
if (!data)
|
||||
if (data == NULL)
|
||||
return;
|
||||
|
||||
// Check we have a snapshot of data
|
||||
|
@ -46,7 +46,6 @@ public:
|
||||
virtual void receive_data_len(quint64 len)=0;
|
||||
|
||||
virtual void receive_header()=0;
|
||||
virtual void data_received()=0;
|
||||
virtual void trigger_message(int msg)=0;
|
||||
};
|
||||
|
||||
|
@ -1390,10 +1390,6 @@ namespace pv
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::data_received()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::check_usb_device_speed()
|
||||
{
|
||||
// USB device speed check
|
||||
|
@ -161,7 +161,6 @@ private:
|
||||
void decode_done();
|
||||
void receive_data_len(quint64 len);
|
||||
void receive_header();
|
||||
void data_received();
|
||||
void trigger_message(int msg);
|
||||
void session_save();
|
||||
|
||||
|
@ -1046,8 +1046,6 @@ namespace pv
|
||||
|
||||
receive_data(logic.length * 8 / get_ch_num(SR_CHANNEL_LOGIC));
|
||||
|
||||
_callback->data_received();
|
||||
|
||||
_data_updated = true;
|
||||
}
|
||||
|
||||
|
@ -130,6 +130,10 @@ public:
|
||||
return &_device_agent;
|
||||
}
|
||||
|
||||
inline void set_callback(ISessionCallback *callback){
|
||||
_callback = callback;
|
||||
}
|
||||
|
||||
bool init();
|
||||
void uninit();
|
||||
void Open();
|
||||
@ -140,8 +144,7 @@ public:
|
||||
bool set_file(QString name);
|
||||
void close_file(ds_device_handle dev_handle);
|
||||
bool start_capture(bool instant);
|
||||
void stop_capture();
|
||||
|
||||
void stop_capture();
|
||||
uint64_t cur_samplerate();
|
||||
uint64_t cur_snap_samplerate();
|
||||
|
||||
@ -152,8 +155,6 @@ public:
|
||||
double cur_sampletime();
|
||||
double cur_snap_sampletime();
|
||||
double cur_view_time();
|
||||
void set_cur_snap_samplerate(uint64_t samplerate);
|
||||
void set_cur_samplelimits(uint64_t samplelimits);
|
||||
|
||||
inline void set_session_time(QDateTime time){
|
||||
_session_time = time;
|
||||
@ -213,7 +214,6 @@ public:
|
||||
void data_auto_lock(int lock);
|
||||
void data_auto_unlock();
|
||||
bool get_data_auto_lock();
|
||||
|
||||
void spectrum_rebuild();
|
||||
void lissajous_rebuild(bool enable, int xindex, int yindex, double percent);
|
||||
void lissajous_disable();
|
||||
@ -222,8 +222,6 @@ public:
|
||||
pv::view::DsoSignal *dsoSig2,
|
||||
data::MathStack::MathType type);
|
||||
|
||||
void math_disable();
|
||||
|
||||
inline bool trigd(){
|
||||
return _trigger_flag;
|
||||
}
|
||||
@ -292,10 +290,6 @@ public:
|
||||
return _is_instant;
|
||||
}
|
||||
|
||||
inline void set_callback(ISessionCallback *callback){
|
||||
_callback = callback;
|
||||
}
|
||||
|
||||
inline bool is_working(){
|
||||
return _is_working;
|
||||
}
|
||||
@ -374,6 +368,11 @@ public:
|
||||
void broadcast_msg(int msg);
|
||||
bool switch_work_mode(int mode);
|
||||
|
||||
private:
|
||||
void set_cur_samplelimits(uint64_t samplelimits);
|
||||
void set_cur_snap_samplerate(uint64_t samplerate);
|
||||
void math_disable();
|
||||
|
||||
private:
|
||||
bool exec_capture();
|
||||
void exit_capture();
|
||||
|
60
DSView/pv/utility/array.cpp
Normal file
60
DSView/pv/utility/array.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of the DSView project.
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2022 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 "array.h"
|
||||
#include <assert.h>
|
||||
|
||||
namespace pv
|
||||
{
|
||||
namespace array
|
||||
{
|
||||
uint64_t find_min_uint64(uint64_t *arr, int size)
|
||||
{
|
||||
assert(arr);
|
||||
assert(size);
|
||||
|
||||
uint64_t *p = arr;
|
||||
uint64_t v = *p;
|
||||
|
||||
for (int i=1; i<size; i++){
|
||||
p++;
|
||||
if (*p < v)
|
||||
v = *p;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
uint64_t find_max_uint64(uint64_t *arr, int size)
|
||||
{
|
||||
assert(arr);
|
||||
assert(size);
|
||||
|
||||
uint64_t *p = arr;
|
||||
uint64_t v = *p;
|
||||
|
||||
for (int i=1; i<size; i++){
|
||||
p++;
|
||||
if (*p > v)
|
||||
v = *p;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
37
DSView/pv/utility/array.h
Normal file
37
DSView/pv/utility/array.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of the DSView project.
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2022 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 UTILITY_ARRAY_H
|
||||
#define UTILITY_ARRAY_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace pv
|
||||
{
|
||||
namespace array
|
||||
{
|
||||
uint64_t find_min_uint64(uint64_t *arr, int size);
|
||||
|
||||
uint64_t find_max_uint64(uint64_t *arr, int size);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -105,6 +105,8 @@ AnalogSignal::AnalogSignal(view::AnalogSignal *s, pv::data::Analog *data, sr_cha
|
||||
_hover_point(QPointF(-1, -1)),
|
||||
_hover_value(0)
|
||||
{
|
||||
_signal_type = ANALOG_SIGNAL;
|
||||
|
||||
_typeWidth = 5;
|
||||
_bits = s->get_bits();
|
||||
_ref_min = s->get_ref_min();
|
||||
|
@ -56,6 +56,7 @@ LogicSignal::LogicSignal(view::LogicSignal *s,
|
||||
_data(data),
|
||||
_trig(s->get_trig())
|
||||
{
|
||||
_signal_type = LOGIC_SIGNAL;
|
||||
}
|
||||
|
||||
LogicSignal::~LogicSignal()
|
||||
|
@ -33,16 +33,17 @@ namespace view {
|
||||
|
||||
Signal::Signal(sr_channel *probe) :
|
||||
Trace(probe->name, probe->index, probe->type),
|
||||
_probe(probe),
|
||||
_signal_type(UNKNOWN_SIGNAL)
|
||||
{
|
||||
_probe(probe)
|
||||
{
|
||||
_signal_type = UNKNOWN_SIGNAL;
|
||||
session = AppControl::Instance()->GetSession();
|
||||
}
|
||||
|
||||
Signal::Signal(const Signal &s, sr_channel *probe) :
|
||||
Trace((const Trace &)s),
|
||||
_probe(probe)
|
||||
{
|
||||
{
|
||||
_signal_type = UNKNOWN_SIGNAL;
|
||||
session = AppControl::Instance()->GetSession();
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,6 @@ class Signal : public Trace
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
|
||||
protected:
|
||||
Signal(sr_channel * const probe);
|
||||
|
||||
|
@ -322,10 +322,6 @@ void SpectrumTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QCo
|
||||
_vmin = _vmax - _dbv_range;
|
||||
}
|
||||
|
||||
//const double max_value = *std::max_element(dc_ignored ? ++samples.begin() : samples.begin(), samples.end());
|
||||
//const double min_value = *std::min_element(dc_ignored ? ++samples.begin() : samples.begin(), samples.end());
|
||||
//_vmax = (_view_mode == 0) ? max_value : 20*log10(max_value);
|
||||
//_vmin = (_view_mode == 0) ? min_value : 20*log10(min_value);
|
||||
const double scale = height / (_vmax - _vmin);
|
||||
|
||||
double x = (view_start-view_off)*pixels_per_sample;
|
||||
|
@ -489,11 +489,6 @@ void View::set_trig_time()
|
||||
_trig_time_setted = true;
|
||||
}
|
||||
|
||||
bool View::trig_time_setted()
|
||||
{
|
||||
return _trig_time_setted;
|
||||
}
|
||||
|
||||
void View::receive_end()
|
||||
{
|
||||
if (_device_agent->get_work_mode() == LOGIC) {
|
||||
|
@ -299,7 +299,10 @@ public slots:
|
||||
|
||||
// --
|
||||
void set_trig_time();
|
||||
bool trig_time_setted();
|
||||
|
||||
inline bool trig_time_setted(){
|
||||
return _trig_time_setted;
|
||||
}
|
||||
|
||||
//
|
||||
void header_updated();
|
||||
|
Loading…
x
Reference in New Issue
Block a user