diff --git a/CMakeLists.txt b/CMakeLists.txt index 76575bf6..a9592251 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -269,9 +269,7 @@ set(DSView_SOURCES DSView/pv/dock/measuredock.cpp DSView/pv/dock/searchdock.cpp DSView/pv/toolbars/logobar.cpp - DSView/pv/data/groupsnapshot.cpp DSView/pv/view/groupsignal.cpp - DSView/pv/data/group.cpp DSView/pv/dialogs/about.cpp DSView/pv/dialogs/search.cpp DSView/pv/data/dsosnapshot.cpp diff --git a/DSView/pv/data/dsosnapshot.cpp b/DSView/pv/data/dsosnapshot.cpp index 5faaab6f..8a03ffb1 100644 --- a/DSView/pv/data/dsosnapshot.cpp +++ b/DSView/pv/data/dsosnapshot.cpp @@ -48,6 +48,7 @@ DsoSnapshot::DsoSnapshot() : _envelope_en = false; _envelope_done = false; _instant = false; + _threshold = 0; memset(_envelope_levels, 0, sizeof(_envelope_levels)); } @@ -478,18 +479,30 @@ uint64_t DsoSnapshot::get_block_size(int block_index) } } -bool DsoSnapshot::get_max_min_value(uint8_t &maxv, uint8_t &minv) +bool DsoSnapshot::get_max_min_value(uint8_t &maxv, uint8_t &minv, int chan_index) { - if (this->empty() == false){ + if (_sample_count == 0){ return false; } + + if (chan_index < 0 || chan_index >= _ch_data.size()){ + assert(false); + } + + uint8_t *p = _ch_data[chan_index]; + maxv = *p; + minv = *p; + + for (uint64_t i=1; i<_sample_count; i++){ + p++; + if (*p > maxv) + maxv = *p; + if (*p < minv) + minv = *p; + } return true; } -void* DsoSnapshot::get_data(){ - assert(0); -} - } // namespace data } // namespace pv diff --git a/DSView/pv/data/dsosnapshot.h b/DSView/pv/data/dsosnapshot.h index a37274e7..1340a79b 100644 --- a/DSView/pv/data/dsosnapshot.h +++ b/DSView/pv/data/dsosnapshot.h @@ -102,8 +102,15 @@ public: int get_block_num(); uint64_t get_block_size(int block_index); - bool get_max_min_value(uint8_t &maxv, uint8_t &minv); - void* get_data(); + bool get_max_min_value(uint8_t &maxv, uint8_t &minv, int chan_index); + + inline void set_threshold(float threshold){ + _threshold = threshold; + } + + inline float get_threshold(){ + return _threshold; + } private: void append_data(void *data, uint64_t samples, bool instant); @@ -119,6 +126,7 @@ private: bool _instant; std::map _ch_enable; std::vector _ch_data; + float _threshold; friend class DsoSnapshotTest::Basic; }; diff --git a/DSView/pv/data/group.cpp b/DSView/pv/data/group.cpp deleted file mode 100644 index 8094343e..00000000 --- a/DSView/pv/data/group.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of the DSView project. - * DSView is based on PulseView. - * - * Copyright (C) 2013 DreamSourceLab - * - * 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 "group.h" -#include "groupsnapshot.h" - - -using namespace std; - -namespace pv { -namespace data { - -Group::Group() : - SignalData() -{ -} - -void Group::push_snapshot(GroupSnapshot *snapshot) -{ - _snapshots.push_back(snapshot); -} - -std::deque& Group::get_snapshots() -{ - return _snapshots; -} - -void Group::clear() -{ - for(auto s : _snapshots){ - s->clear(); - } -} - -void Group::init() -{ - for(auto s : _snapshots){ - s->init(); - } -} - -} // namespace data -} // namespace pv diff --git a/DSView/pv/data/group.h b/DSView/pv/data/group.h deleted file mode 100644 index bc6e4e53..00000000 --- a/DSView/pv/data/group.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of the DSView project. - * DSView is based on PulseView. - * - * Copyright (C) 2013 DreamSourceLab - * - * 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_GROUP_H -#define DSVIEW_PV_DATA_GROUP_H - -#include "signaldata.h" - -#include - -namespace pv { -namespace data { - -class GroupSnapshot; - -class Group : public SignalData -{ -public: - Group(); - - void push_snapshot(GroupSnapshot *snapshot); - - std::deque& get_snapshots(); - - void clear(); - void init(); - -private: - std::deque _snapshots; -}; - -} // namespace data -} // namespace pv - -#endif // DSVIEW_PV_DATA_GROUP_H diff --git a/DSView/pv/data/groupsnapshot.cpp b/DSView/pv/data/groupsnapshot.cpp deleted file mode 100644 index 69ba1b1f..00000000 --- a/DSView/pv/data/groupsnapshot.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/* - * This file is part of the DSView project. - * DSView is based on PulseView. - * - * Copyright (C) 2013 DreamSourceLab - * - * 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 -#include -#include -#include - -#include - -#include "logicsnapshot.h" -#include "groupsnapshot.h" -#include "../dsvdef.h" - -using namespace std; - -namespace pv { -namespace data { - -const int GroupSnapshot::EnvelopeScalePower = 4; -const int GroupSnapshot::EnvelopeScaleFactor = 1 << EnvelopeScalePower; -const float GroupSnapshot::LogEnvelopeScaleFactor = - logf(EnvelopeScaleFactor); -const uint64_t GroupSnapshot::EnvelopeDataUnit = 64*1024; // bytes -const uint16_t GroupSnapshot::value_mask[16] = {0x1, 0x2, 0x4, 0x8, - 0x10, 0x20, 0x40, 0x80, - 0x100, 0x200, 0x400, 0x800, - 0x1000, 0x2000, 0x4000, 0x8000}; - -GroupSnapshot::GroupSnapshot(const LogicSnapshot *_logic_snapshot, std::list index_list) -{ - assert(_logic_snapshot); - - LogicSnapshot *logic_snapshot = const_cast(_logic_snapshot); - - - memset(_envelope_levels, 0, sizeof(_envelope_levels)); - // _data = logic_snapshot->get_data(); - _sample_count = logic_snapshot->get_sample_count(); - _unit_size = logic_snapshot->unit_size(); - _index_list = index_list; - - _mask = 0; - std::list::iterator j = _index_list.begin(); - while(j != _index_list.end()) - _mask |= value_mask[(*j++)]; - - for (int i=0; i<32; i++) { - _bubble_start[i] = -1; - _bubble_end[i] = -1; - } - uint16_t mask = _mask; - int i = 0; - int k = 0; - int zero = 0; - int zero_pre = 0; - // max bubble count: 31 - do { - if (mask & 0x1) { - if (_bubble_start[k] != -1 && - _bubble_end[k] == -1) - _bubble_end[k++] = i - zero_pre; - } else { - if (_bubble_start[k] == -1) { - _bubble_start[k] = i - zero; - zero_pre = zero; - } - zero++; - } - i++; - }while(mask >>= 1); - - append_payload(); -} - -GroupSnapshot::~GroupSnapshot() -{ - for(auto &e : _envelope_levels){ - free(e.samples); - } -} - -void GroupSnapshot::init() -{ - -} - -void GroupSnapshot::clear() -{ - -} - -uint64_t GroupSnapshot::get_sample_count() -{ - return _sample_count; -} - -void GroupSnapshot::append_payload() -{ - - append_payload_to_envelope_levels(); -} - -const uint16_t* GroupSnapshot::get_samples( - int64_t start_sample, int64_t end_sample) -{ - assert(start_sample >= 0); - assert(start_sample < (int64_t)_sample_count); - assert(end_sample >= 0); - assert(end_sample < (int64_t)_sample_count); - assert(start_sample <= end_sample); - - int64_t i; - uint16_t tmpl, tmpr; - - uint16_t *const data = new uint16_t[end_sample - start_sample]; - - for(i = start_sample; i < end_sample; i++) { - if (_unit_size == 2) - tmpl = *((uint16_t*)_data + i) & _mask; - else - tmpl = *((uint8_t*)_data + i) & _mask; - for(int j=0; _bubble_start[j] != -1; j++) { - tmpr = tmpl & (0xffff >> (16 - _bubble_start[j])); - tmpl >>= _bubble_end[j]; - tmpl <<= _bubble_start[j]; - tmpl += tmpr; - } - *(data + i - start_sample) = tmpl; - } - return data; -} - -void GroupSnapshot::get_envelope_section(EnvelopeSection &s, - uint64_t start, uint64_t end, float min_length) -{ - assert(end <= _sample_count); - assert(start <= end); - assert(min_length > 0); - - const unsigned int min_level = max((int)floorf(logf(min_length) / - LogEnvelopeScaleFactor) - 1, 0); - const unsigned int scale_power = (min_level + 1) * - EnvelopeScalePower; - start >>= scale_power; - end >>= scale_power; - - s.start = start << scale_power; - s.scale = 1 << scale_power; - s.length = end - start; - s.samples = new EnvelopeSample[s.length]; - memcpy(s.samples, _envelope_levels[min_level].samples + start, - s.length * sizeof(EnvelopeSample)); -} - -void GroupSnapshot::reallocate_envelope(Envelope &e) -{ - const uint64_t new_data_length = ((e.length + EnvelopeDataUnit - 1) / - EnvelopeDataUnit) * EnvelopeDataUnit; - if (new_data_length > e.data_length) - { - e.data_length = new_data_length; - e.samples = (EnvelopeSample*)realloc(e.samples, - new_data_length * sizeof(EnvelopeSample)); - } -} - -void GroupSnapshot::append_payload_to_envelope_levels() -{ - Envelope &e0 = _envelope_levels[0]; - uint64_t prev_length; - EnvelopeSample *dest_ptr; - - // Expand the data buffer to fit the new samples - prev_length = e0.length; - e0.length = _sample_count / EnvelopeScaleFactor; - - // Break off if there are no new samples to compute - if (e0.length == prev_length) - return; - - reallocate_envelope(e0); - - dest_ptr = e0.samples + prev_length; - - // Iterate through the samples to populate the first level mipmap - uint16_t group_value[EnvelopeScaleFactor]; - const uint8_t *const end_src_ptr = (uint8_t*)_data + - e0.length * EnvelopeScaleFactor * _unit_size; - for (const uint8_t *src_ptr = (uint8_t*)_data + - prev_length * EnvelopeScaleFactor * _unit_size; - src_ptr < end_src_ptr; src_ptr += EnvelopeScaleFactor * _unit_size) - { - uint16_t tmpr; - for(int i = 0; i < EnvelopeScaleFactor; i++) { - if (_unit_size == 2) - group_value[i] = *((uint16_t*)src_ptr + i) & _mask; - else - group_value[i] = *((uint8_t*)src_ptr + i) & _mask; - for(int j=0; _bubble_start[j] != -1; j++) { - tmpr = group_value[i] & (0xffff >> (16 - _bubble_start[j])); - group_value[i] >>= _bubble_end[j]; - group_value[i] <<= _bubble_start[j]; - group_value[i] += tmpr; - } - } - - const EnvelopeSample sub_sample = { - *min_element(group_value, group_value + EnvelopeScaleFactor), - *max_element(group_value, group_value + EnvelopeScaleFactor), - }; - - *dest_ptr++ = sub_sample; - } - - // Compute higher level mipmaps - for (unsigned int level = 1; level < ScaleStepCount; level++) - { - Envelope &e = _envelope_levels[level]; - const Envelope &el = _envelope_levels[level-1]; - - // Expand the data buffer to fit the new samples - prev_length = e.length; - e.length = el.length / EnvelopeScaleFactor; - - // Break off if there are no more samples to computed - if (e.length == prev_length) - break; - - reallocate_envelope(e); - - // Subsample the level lower level - const EnvelopeSample *src_ptr = - el.samples + prev_length * EnvelopeScaleFactor; - const EnvelopeSample *const end_dest_ptr = e.samples + e.length; - for (dest_ptr = e.samples + prev_length; - dest_ptr < end_dest_ptr; dest_ptr++) - { - const EnvelopeSample *const end_src_ptr = - src_ptr + EnvelopeScaleFactor; - - EnvelopeSample sub_sample = *src_ptr++; - while (src_ptr < end_src_ptr) - { - sub_sample.min = min(sub_sample.min, src_ptr->min); - sub_sample.max = max(sub_sample.max, src_ptr->max); - src_ptr++; - } - - *dest_ptr = sub_sample; - } - } -} - -} // namespace data -} // namespace pv diff --git a/DSView/pv/data/groupsnapshot.h b/DSView/pv/data/groupsnapshot.h deleted file mode 100644 index 683e4f96..00000000 --- a/DSView/pv/data/groupsnapshot.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This file is part of the DSView project. - * DSView is based on PulseView. - * - * Copyright (C) 2013 DreamSourceLab - * - * 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_GROUPSNAPSHOT_H -#define DSVIEW_PV_DATA_GROUPSNAPSHOT_H - -#include "../view/signal.h" - -#include -#include -#include - -namespace GroupSnapshotTest { -class Basic; -} - -namespace pv { -namespace data { - -class LogicSnapshot; - -class GroupSnapshot -{ -public: - struct EnvelopeSample - { - uint16_t min; - uint16_t max; - }; - - struct EnvelopeSection - { - uint64_t start; - unsigned int scale; - uint64_t length; - EnvelopeSample *samples; - }; - -private: - struct Envelope - { - uint64_t length; - uint64_t data_length; - EnvelopeSample *samples; - }; - -private: - static const unsigned int ScaleStepCount = 16; - static const int EnvelopeScalePower; - static const int EnvelopeScaleFactor; - static const float LogEnvelopeScaleFactor; - static const uint64_t EnvelopeDataUnit; - static const uint16_t value_mask[16]; - -public: - GroupSnapshot(const LogicSnapshot *_logic_snapshot, std::list index_list); - - virtual ~GroupSnapshot(); - - void clear(); - void init(); - - void append_payload(); - - uint64_t get_sample_count(); - - const uint16_t* get_samples(int64_t start_sample, - int64_t end_sample); - - void get_envelope_section(EnvelopeSection &s, - uint64_t start, uint64_t end, float min_length); - -private: - void reallocate_envelope(Envelope &l); - - void append_payload_to_envelope_levels(); - -private: - struct Envelope _envelope_levels[ScaleStepCount]; - - const void *_data; - uint64_t _sample_count; - int _unit_size; - view::Signal *_signal; - std::list _index_list; - uint16_t _mask; - int _bubble_start[32]; - int _bubble_end[32]; - - friend class GroupSnapshotTest::Basic; -}; - -} // namespace data -} // namespace pv - -#endif // DSVIEW_PV_DATA_GROUPSNAPSHOT_H diff --git a/DSView/pv/dialogs/dsdialog.h b/DSView/pv/dialogs/dsdialog.h index b8ab9903..faa1a1ad 100644 --- a/DSView/pv/dialogs/dsdialog.h +++ b/DSView/pv/dialogs/dsdialog.h @@ -56,7 +56,14 @@ public: void setTitle(QString title); void reload(); int exec(); - inline bool IsClickYes(){return _clickYes;} + + inline bool IsClickYes(){ + return _clickYes; + } + + inline bool IsAccept(){ + return _clickYes; + } void SetTitleSpace(int h); diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 2e964be3..3bd60704 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -1682,8 +1682,7 @@ namespace pv case DSV_MSG_DEVICE_MODE_CHANGED: _sampling_bar->update_sample_rate_selector(); - _view->mode_changed(); - _protocol_widget->del_all_protocol(); + _view->mode_changed(); reset_all_view(); load_device_config(); update_toolbar_view_status(); diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 61da699c..d58e1bd5 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -31,8 +31,6 @@ #include "data/dsosnapshot.h" #include "data/logic.h" #include "data/logicsnapshot.h" -#include "data/group.h" -#include "data/groupsnapshot.h" #include "data/decoderstack.h" #include "data/decode/decoder.h" #include "data/decodermodel.h" @@ -70,8 +68,7 @@ namespace pv SigSession::SigSession() { // TODO: This should not be necessary - _session = this; - _group_cnt = 0; + _session = this; _map_zoom = 0; _repeat_hold_prg = 0; @@ -86,7 +83,7 @@ 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; this->add_msg_listener(this); @@ -109,8 +106,6 @@ namespace pv _logic_data = new data::Logic(new data::LogicSnapshot()); _dso_data = new data::Dso(new data::DsoSnapshot()); _analog_data = new data::Analog(new data::AnalogSnapshot()); - _group_data = new data::Group(); - _group_cnt = 0; _feed_timer.SetCallback(std::bind(&SigSession::feed_timeout, this)); _repeat_timer.SetCallback(std::bind(&SigSession::repeat_capture_wait_timeout, this)); @@ -193,7 +188,7 @@ namespace pv { assert(!_is_saving); assert(!_is_working); - assert(_callback); + assert(_callback); _callback->trigger_message(DSV_MSG_CURRENT_DEVICE_CHANGE_PREV); @@ -217,7 +212,6 @@ namespace pv clear_all_decoder(); - RELEASE_ARRAY(_group_traces); init_signals(); _cur_snap_samplerate = _device_agent.get_sample_rate(); @@ -338,10 +332,7 @@ namespace pv _analog_data->set_samplerate(_cur_snap_samplerate); if (_dso_data) _dso_data->set_samplerate(_cur_snap_samplerate); - // Group - if (_group_data) - _group_data->set_samplerate(_cur_snap_samplerate); - + // DecoderStack for (auto d : _decode_traces) { @@ -411,11 +402,7 @@ namespace pv // Logic if (_logic_data) _logic_data->init(); - - // Group - if (_group_data) - _group_data->init(); - + // Dso if (_analog_data) _analog_data->init(); @@ -475,6 +462,8 @@ namespace pv _callback->trigger_message(DSV_MSG_START_COLLECT_WORK_PREV); + get_dso_data()->set_threshold(0); // Reset threshold value + if (exec_capture()) { _capture_time_id++; @@ -639,11 +628,6 @@ namespace pv return _signals; } - std::vector &SigSession::get_group_signals() - { - return _group_traces; - } - std::set SigSession::get_data() { std::set data; @@ -679,82 +663,6 @@ namespace pv } } - void SigSession::add_group() - { - std::list probe_index_list; - - auto i = _signals.begin(); - while (i != _signals.end()) - { - if ((*i)->get_type() == SR_CHANNEL_LOGIC && (*i)->selected()) - probe_index_list.push_back((*i)->get_index()); - i++; - } - - if (probe_index_list.size() > 1) - { - _group_data->init(); - _group_data->set_samplerate(_cur_snap_samplerate); - auto signal = new view::GroupSignal("New Group", _group_data, probe_index_list, _group_cnt); - _group_traces.push_back(signal); - _group_cnt++; - - const auto &snapshots = _logic_data->get_snapshots(); - if (!snapshots.empty()) - { - auto p = new data::GroupSnapshot(snapshots.front(), signal->get_index_list()); - _group_data->push_snapshot(p); - } - - signals_changed(); - data_updated(); - } - } - - void SigSession::del_group() - { - auto i = _group_traces.begin(); - - while (i != _group_traces.end()) - { - - pv::view::GroupSignal *psig = *(i); - - if (psig->selected()) - { - auto j = _group_traces.begin(); - while (j != _group_traces.end()) - { - if ((*j)->get_sec_index() > psig->get_sec_index()) - (*j)->set_sec_index((*j)->get_sec_index() - 1); - j++; - } - - auto &snapshots = _group_data->get_snapshots(); - if (!snapshots.empty()) - { - int dex = psig->get_sec_index(); - pv::data::GroupSnapshot *pshot = _group_data->get_snapshots().at(dex); - delete pshot; - - auto k = snapshots.begin(); - k += (*i)->get_sec_index(); - _group_data->get_snapshots().erase(k); - } - - delete psig; - - i = _group_traces.erase(i); - - _group_cnt--; - continue; - } - i++; - } - - signals_changed(); - data_updated(); - } void SigSession::init_signals() { @@ -766,15 +674,9 @@ namespace pv } std::vector sigs; - view::Signal *signal = NULL; unsigned int logic_probe_count = 0; unsigned int dso_probe_count = 0; - unsigned int analog_probe_count = 0; - - _logic_data->clear(); - _dso_data->clear(); - _analog_data->clear(); - _group_data->clear(); + unsigned int analog_probe_count = 0; // Detect what data types we will receive if (_device_agent.have_instance()) @@ -802,36 +704,33 @@ namespace pv } } - // Make the logic probe list - RELEASE_ARRAY(_group_traces); - - std::vector().swap(_group_traces); - for (GSList *l = _device_agent.get_channels(); l; l = l->next) { - sr_channel *probe = - (sr_channel *)l->data; - assert(probe); - signal = NULL; + sr_channel *probe = (sr_channel *)l->data; + assert(probe); switch (probe->type) { case SR_CHANNEL_LOGIC: - if (probe->enabled) - signal = new view::LogicSignal(_logic_data, probe); + if (probe->enabled){ + view::Signal *signal = new view::LogicSignal(_logic_data, probe); + sigs.push_back(signal); + } break; - case SR_CHANNEL_DSO: - signal = new view::DsoSignal(_dso_data, probe); + case SR_CHANNEL_DSO:{ + view::Signal *signal = new view::DsoSignal(_dso_data, probe); + sigs.push_back(signal); + } break; case SR_CHANNEL_ANALOG: - if (probe->enabled) - signal = new view::AnalogSignal(_analog_data, probe); + if (probe->enabled){ + view::Signal *signal = new view::AnalogSignal(_analog_data, probe); + sigs.push_back(signal); + } break; - } - if (signal != NULL) - sigs.push_back(signal); + } } RELEASE_ARRAY(_signals); @@ -1261,14 +1160,6 @@ namespace pv } case SR_DF_END: { - if (!_logic_data->snapshot()->empty()) - { - for (auto g : _group_traces) - { - auto p = new data::GroupSnapshot(_logic_data->get_snapshots().front(), g->get_index_list()); - _group_data->push_snapshot(p); - } - } _logic_data->snapshot()->capture_ended(); _dso_data->snapshot()->capture_ended(); _analog_data->snapshot()->capture_ended(); @@ -2026,11 +1917,10 @@ namespace pv assert(!_is_working); if (_device_agent.get_work_mode() != mode) - { + { GVariant *val = g_variant_new_int16(mode); _device_agent.set_config(NULL, NULL, SR_CONF_DEVICE_MODE, val); - clear_all_decoder(); init_signals(); dsv_info("%s", "Work mode is changed."); broadcast_msg(DSV_MSG_DEVICE_MODE_CHANGED); @@ -2064,4 +1954,19 @@ 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 diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index 19180a79..7f312369 100644 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -171,8 +171,7 @@ public: bool is_first_store_confirm(); bool get_capture_status(bool &triggered, int &progress); std::set get_data(); - std::vector& get_signals(); - std::vector& get_group_signals(); + std::vector& get_signals(); bool add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus, std::list &sub_decoders); @@ -202,9 +201,7 @@ public: inline view::MathTrace* get_math_trace(){ return _math_trace; } - - void add_group(); - void del_group(); + uint16_t get_ch_num(int type); inline bool get_data_lock(){ @@ -369,6 +366,10 @@ 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); @@ -435,10 +436,9 @@ private: const struct sr_datafeed_packet *packet); static void device_lib_event_callback(int event); + void on_device_lib_event(int event); - Snapshot* get_signal_snapshot(); - void repeat_capture_wait_timeout(); void repeat_wait_prog_timeout(); void realtime_refresh_timeout(); @@ -452,8 +452,7 @@ private: uint64_t _cur_snap_samplerate; uint64_t _cur_samplelimits; - std::vector _signals; - std::vector _group_traces; + std::vector _signals; std::vector _decode_traces; std::vector _decode_tasks; pv::data::DecoderModel *_decoder_model; @@ -463,8 +462,7 @@ private: data::Logic *_logic_data; data::Dso *_dso_data; - data::Analog *_analog_data; - data::Group *_group_data; + data::Analog *_analog_data; int _group_cnt; DsTimer _feed_timer; diff --git a/DSView/pv/toolbars/filebar.cpp b/DSView/pv/toolbars/filebar.cpp index 526464f2..909f1e74 100644 --- a/DSView/pv/toolbars/filebar.cpp +++ b/DSView/pv/toolbars/filebar.cpp @@ -38,8 +38,7 @@ namespace toolbars { FileBar::FileBar(SigSession *session, QWidget *parent) : QToolBar("File Bar", parent), _session(session), - _file_button(this), - _cvt_button(this) + _file_button(this) { setMovable(false); setContentsMargins(0,0,0,0); @@ -84,12 +83,6 @@ FileBar::FileBar(SigSession *session, QWidget *parent) : _file_button.setMenu(_menu); addWidget(&_file_button); - - _cvt_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - _cvt_action = addWidget(&_cvt_button); - _cvt_button.setObjectName(QString::fromUtf8("menuSession")); - //_cvt_action->setVisible(false); - retranslateUi(); connect(_action_load, SIGNAL(triggered()), this, SLOT(on_actionLoad_triggered())); @@ -123,7 +116,6 @@ void FileBar::retranslateUi() _action_save->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_FILEBAR_SAVE), "&Save...")); _action_export->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_FILEBAR_EXPORT), "&Export...")); _action_capture->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_FILEBAR_CAPTURE), "&Capture...")); - _cvt_button.setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_FILEBAR_CONVERT_LOGIC), "Lo&gic")); } void FileBar::reStyle() @@ -139,7 +131,6 @@ void FileBar::reStyle() _action_export->setIcon(QIcon(iconPath+"/export.svg")); _action_capture->setIcon(QIcon(iconPath+"/capture.svg")); _file_button.setIcon(QIcon(iconPath+"/file.svg")); - _cvt_button.setIcon(QIcon(iconPath+"/la.svg")); } void FileBar::on_actionOpen_triggered() diff --git a/DSView/pv/toolbars/filebar.h b/DSView/pv/toolbars/filebar.h index 8463d6cc..af758f65 100644 --- a/DSView/pv/toolbars/filebar.h +++ b/DSView/pv/toolbars/filebar.h @@ -68,8 +68,6 @@ private: SigSession* _session; QToolButton _file_button; - QToolButton _cvt_button; - QAction *_cvt_action; QMenu *_menu; QMenu *_menu_session; //when the hardware device is connected,it will be enable QAction *_action_load; diff --git a/DSView/pv/view/groupsignal.cpp b/DSView/pv/view/groupsignal.cpp index caa6bf38..a6a17537 100644 --- a/DSView/pv/view/groupsignal.cpp +++ b/DSView/pv/view/groupsignal.cpp @@ -20,9 +20,7 @@ */ #include "../dsvdef.h" -#include "groupsignal.h" -#include "../data/group.h" -#include "../data/groupsnapshot.h" +#include "groupsignal.h" #include "view.h" #include @@ -40,10 +38,9 @@ const QColor GroupSignal::SignalColours[4] = { const float GroupSignal::EnvelopeThreshold = 256.0f; -GroupSignal::GroupSignal(QString name, data::Group *data, +GroupSignal::GroupSignal(QString name, std::list probe_index_list, int group_index) : - Trace(name, probe_index_list, SR_CHANNEL_GROUP, group_index), - _data(data) + Trace(name, probe_index_list, SR_CHANNEL_GROUP, group_index) { _colour = SignalColours[probe_index_list.front() % countof(SignalColours)]; _scale = _totalHeight * 1.0f / std::pow(2.0, static_cast(probe_index_list.size())); @@ -60,7 +57,7 @@ bool GroupSignal::enabled() pv::data::SignalData* GroupSignal::data() { - return _data; + return NULL; } void GroupSignal::set_scale(float scale) @@ -70,162 +67,30 @@ void GroupSignal::set_scale(float scale) void GroupSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor back) { - (void)fore; - (void)back; - assert(_data); - assert(_view); - assert(right >= left); - - const int y = get_y() + _totalHeight * 0.5; - const double scale = _view->scale(); - assert(scale > 0); - const int64_t offset = _view->offset(); - - _scale = _totalHeight * 1.0f / std::pow(2.0, static_cast(_index_list.size())); - - const auto &snapshots = _data->get_snapshots(); - if (snapshots.empty()) - return; - - const auto snapshot = snapshots.at(_sec_index); - - const double pixels_offset = offset; - const double samplerate = _data->samplerate(); - const int64_t last_sample = snapshot->get_sample_count() - 1; - const double samples_per_pixel = samplerate * scale; - const double start = offset * samples_per_pixel; - const double end = start + samples_per_pixel * (right - left); - - const int64_t start_sample = min(max((int64_t)floor(start), - (int64_t)0), last_sample); - const int64_t end_sample = min(max((int64_t)ceil(end) + 1, - (int64_t)0), last_sample); - - if (samples_per_pixel < EnvelopeThreshold) - paint_trace(p, snapshot, y, left, - start_sample, end_sample, - pixels_offset, samples_per_pixel); - else - paint_envelope(p, snapshot, y, left, - start_sample, end_sample, - pixels_offset, samples_per_pixel); + } void GroupSignal::paint_trace(QPainter &p, - const pv::data::GroupSnapshot *snapshot, int y, int left, const int64_t start, const int64_t end, const double pixels_offset, const double samples_per_pixel) { - const int64_t sample_count = end - start; - - pv::data::GroupSnapshot *pshot = const_cast(snapshot); - - const uint16_t *samples = pshot->get_samples(start, end); - assert(samples); - - p.setPen(_colour); - - QPointF *points = new QPointF[sample_count]; - QPointF *point = points; - - for (int64_t sample = start; sample != end; sample++) { - const float x = (sample / samples_per_pixel - - pixels_offset) + left; - *point++ = QPointF(x, - y - samples[sample - start] * _scale); - } - - p.drawPolyline(points, point - points); - - delete[] samples; - delete[] points; + } void GroupSignal::paint_envelope(QPainter &p, - const pv::data::GroupSnapshot *snapshot, int y, int left, const int64_t start, const int64_t end, const double pixels_offset, const double samples_per_pixel) -{ - using namespace Qt; - using pv::data::GroupSnapshot; +{ - GroupSnapshot::EnvelopeSection e; - - pv::data::GroupSnapshot *pshot = const_cast(snapshot); - pshot->get_envelope_section(e, start, end, samples_per_pixel); - - if (e.length < 2) - return; - - p.setPen(QPen(NoPen)); - p.setBrush(_colour); - - QRectF *const rects = new QRectF[e.length]; - QRectF *rect = rects; - - for(uint64_t sample = 0; sample < e.length-1; sample++) { - const float x = ((e.scale * sample + e.start) / - samples_per_pixel - pixels_offset) + left; - const GroupSnapshot::EnvelopeSample *const s = - e.samples + sample; - - // We overlap this sample with the next so that vertical - // gaps do not appear during steep rising or falling edges - const float b = y - max(s->max, (s+1)->min) * _scale; - const float t = y - min(s->min, (s+1)->max) * _scale; - - float h = b - t; - if(h >= 0.0f && h <= 1.0f) - h = 1.0f; - if(h <= 0.0f && h >= -1.0f) - h = -1.0f; - - *rect++ = QRectF(x, t, 1.0f, h); - } - - p.drawRects(rects, e.length); - - delete[] rects; - delete[] e.samples; + } void GroupSignal::paint_type_options(QPainter &p, int right, const QPoint pt, QColor fore) -{ - (void)pt; - - int y = get_y(); - const QRectF group_index_rect = get_rect(CHNLREG, y, right); - QString index_string; - int last_index; - p.setPen(QPen(fore, 1, Qt::DashLine)); - p.drawLine(group_index_rect.bottomLeft(), group_index_rect.bottomRight()); - std::list::iterator i = _index_list.begin(); - last_index = (*i); - index_string = QString::number(last_index); - while (++i != _index_list.end()) { - if ((*i) == last_index + 1 && index_string.indexOf("-") < 3 && index_string.indexOf("-") > 0) - index_string.replace(QString::number(last_index), QString::number((*i))); - else if ((*i) == last_index + 1) - index_string = QString::number((*i)) + "-" + index_string; - else - index_string = QString::number((*i)) + "," + index_string; - last_index = (*i); - } - p.setPen(fore); - p.drawText(group_index_rect, Qt::AlignRight | Qt::AlignVCenter, index_string); +{ } QRectF GroupSignal::get_rect(GroupSetRegions type, int y, int right) -{ - const QSizeF name_size(right - get_leftWidth() - get_rightWidth(), SquareWidth); - - if (type == CHNLREG) - return QRectF( - get_leftWidth() + name_size.width() + Margin, - y - SquareWidth / 2, - SquareWidth * SquareNum, SquareWidth); - else - return QRectF(0, 0, 0, 0); +{ } } // namespace view diff --git a/DSView/pv/view/groupsignal.h b/DSView/pv/view/groupsignal.h index a86c388e..a998050b 100644 --- a/DSView/pv/view/groupsignal.h +++ b/DSView/pv/view/groupsignal.h @@ -24,7 +24,6 @@ #define DSVIEW_SV_GROUPSIGNAL_H #include "signal.h" -#include "../data/groupsnapshot.h" #include @@ -33,8 +32,6 @@ namespace pv { namespace data { class Logic; class Analog; -class Group; -class GroupSnapshot; } namespace view { @@ -54,7 +51,6 @@ private: public: GroupSignal(QString name, - pv::data::Group *data, std::list probe_index_list, int group_index); virtual ~GroupSignal(); @@ -82,18 +78,15 @@ protected: void paint_type_options(QPainter &p, int right, const QPoint pt, QColor fore); private: - void paint_trace(QPainter &p, - const pv::data::GroupSnapshot *snapshot, + void paint_trace(QPainter &p, int y, int left, const int64_t start, const int64_t end, const double pixels_offset, const double samples_per_pixel); - void paint_envelope(QPainter &p, - const pv::data::GroupSnapshot *snapshot, + void paint_envelope(QPainter &p, int y, int left, const int64_t start, const int64_t end, const double pixels_offset, const double samples_per_pixel); -private: - pv::data::Group *_data; +private: float _scale; }; diff --git a/DSView/pv/view/header.cpp b/DSView/pv/view/header.cpp index 0bd4ab2e..363f1bc2 100644 --- a/DSView/pv/view/header.cpp +++ b/DSView/pv/view/header.cpp @@ -51,9 +51,7 @@ namespace view { Header::Header(View &parent) : QWidget(&parent), - _view(parent), - _action_add_group(new QAction(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_ADD_GROUP), "Add Group"), this)), - _action_del_group(new QAction(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DEL_GROUP), "Del Group"), this)) + _view(parent) { _moveFlag = false; _colorFlag = false; @@ -66,11 +64,6 @@ Header::Header(View &parent) : setMouseTracking(true); - connect(_action_del_group, SIGNAL(triggered()), - this, SLOT(on_action_del_group_triggered())); - connect(_action_add_group, SIGNAL(triggered()), - this, SLOT(on_action_add_group_triggered())); - connect(nameEdit, SIGNAL(editingFinished()), this, SLOT(on_action_set_name_triggered())); @@ -114,7 +107,7 @@ pv::view::Trace* Header::get_mTrace(int &action, const QPoint &pt) } void Header::paintEvent(QPaintEvent*) -{ +{ using pv::view::Trace; QStyleOption o; @@ -446,16 +439,6 @@ void Header::on_action_set_name_triggered() header_updated(); } -void Header::on_action_add_group_triggered() -{ - _view.session().add_group(); -} - -void Header::on_action_del_group_triggered() -{ - _view.session().del_group(); -} - void Header::header_resize() { //if (nameEdit->isVisible()) { diff --git a/DSView/pv/view/header.h b/DSView/pv/view/header.h index cf7741e4..d9a9ffe6 100644 --- a/DSView/pv/view/header.h +++ b/DSView/pv/view/header.h @@ -72,10 +72,6 @@ public: private slots: void on_action_set_name_triggered(); - void on_action_add_group_triggered(); - - void on_action_del_group_triggered(); - signals: void traces_moved(); void header_updated(); @@ -98,9 +94,6 @@ private: std::list > _drag_traces; Trace *_context_trace; - - QAction *_action_add_group; - QAction *_action_del_group; }; } // namespace view diff --git a/DSView/pv/view/view.cpp b/DSView/pv/view/view.cpp index 1989f827..5f3a13b9 100644 --- a/DSView/pv/view/view.cpp +++ b/DSView/pv/view/view.cpp @@ -334,7 +334,6 @@ void View::get_traces(int type, std::vector &traces) assert(_session); auto &sigs = _session->get_signals(); - const auto &groups = _session->get_group_signals(); const auto &decode_sigs = _session->get_decode_signals(); @@ -349,11 +348,6 @@ void View::get_traces(int type, std::vector &traces) if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type) traces.push_back(t); } - - for(auto t : groups) { - if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type) - traces.push_back(t); - } for(auto t : spectrums) { if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type) diff --git a/lang/cn/dlg.json b/lang/cn/dlg.json index 9265d373..052a5e1d 100644 --- a/lang/cn/dlg.json +++ b/lang/cn/dlg.json @@ -646,5 +646,9 @@ { "id": "IDS_DLG_SAMPLES_CAPTURED", "text": "捕获样本!" + }, + { + "id": "IDS_DLG_FILE_THRESHOLD", + "text": "阈值: " } ] \ No newline at end of file diff --git a/lang/cn/msg.json b/lang/cn/msg.json index 3b5ebdba..af8595da 100644 --- a/lang/cn/msg.json +++ b/lang/cn/msg.json @@ -350,5 +350,9 @@ { "id": "IDS_MSG_BOX_CONFIRM", "text": "确认" + }, + { + "id": "IDS_MSG_NO_DATA", + "text": "没有数据!" } ] \ No newline at end of file diff --git a/lang/en/dlg.json b/lang/en/dlg.json index 684279e2..a7f15fb1 100644 --- a/lang/en/dlg.json +++ b/lang/en/dlg.json @@ -646,5 +646,9 @@ { "id": "IDS_DLG_SAMPLES_CAPTURED", "text": "Samples Captured!" + }, + { + "id": "IDS_DLG_FILE_THRESHOLD", + "text": "Threshold: " } ] \ No newline at end of file diff --git a/lang/en/msg.json b/lang/en/msg.json index 252e601a..a8292eee 100644 --- a/lang/en/msg.json +++ b/lang/en/msg.json @@ -351,5 +351,9 @@ { "id": "IDS_MSG_BOX_CONFIRM", "text": "Confirm" + }, + { + "id": "IDS_MSG_NO_DATA", + "text": "Have no data!" } ] \ No newline at end of file