2
0
forked from Ivasoft/DSView

Update the code style

This commit is contained in:
dreamsourcelabTAI
2022-11-02 17:37:17 +08:00
parent 2595f500a0
commit 57ae013256
49 changed files with 453 additions and 516 deletions

View File

@@ -50,14 +50,16 @@ std::deque<AnalogSnapshot*>& Analog::get_snapshots()
void Analog::clear()
{
//_snapshots.clear();
for(auto &s : _snapshots)
for(auto s : _snapshots){
s->clear();
}
}
void Analog::init()
{
//_snapshots.clear();
for(auto &s : _snapshots)
for(auto s : _snapshots){
s->init();
}
}
AnalogSnapshot* Analog::snapshot()

View File

@@ -106,9 +106,6 @@ void AnalogSnapshot::first_payload(const sr_datafeed_analog &analog, uint64_t to
sr_channel *const probe = (sr_channel*)l->data;
assert(probe);
// TODO: data of disabled channels should not be captured.
// if (probe->type == SR_CHANNEL_ANALOG && probe->enabled) {
// _channel_num ++;
// }
if (probe->type == SR_CHANNEL_ANALOG) {
_channel_num ++;
}
@@ -124,8 +121,6 @@ void AnalogSnapshot::first_payload(const sr_datafeed_analog &analog, uint64_t to
for (unsigned int i = 0; i < _channel_num; i++) {
uint64_t envelop_count = _total_sample_count / EnvelopeScaleFactor;
for (unsigned int level = 0; level < ScaleStepCount; level++) {
// envelop_count = ((envelop_count + EnvelopeDataUnit - 1) /
// EnvelopeDataUnit) * EnvelopeDataUnit;
_envelope_levels[i][level].count = envelop_count;
if (envelop_count == 0)
break;
@@ -149,7 +144,6 @@ void AnalogSnapshot::first_payload(const sr_datafeed_analog &analog, uint64_t to
sr_channel *const probe = (sr_channel*)l->data;
assert(probe);
// TODO: data of disabled channels should not be captured.
//if (probe->type == SR_CHANNEL_ANALOG && probe->enabled) {
if (probe->type == SR_CHANNEL_ANALOG) {
_ch_index.push_back(probe->index);
}
@@ -220,10 +214,6 @@ const uint8_t* AnalogSnapshot::get_samples(int64_t start_sample)
assert(start_sample >= 0);
assert(start_sample < (int64_t)get_sample_count());
// uint16_t *const data = new uint16_t[end_sample - start_sample];
// memcpy(data, (uint16_t*)_data + start_sample, sizeof(uint16_t) *
// (end_sample - start_sample));
// return data;
return (uint8_t*)_data + start_sample * _unit_bytes * _channel_num;
}
@@ -242,9 +232,6 @@ void AnalogSnapshot::get_envelope_section(EnvelopeSection &s,
s.scale = (1 << scale_power);
s.length = (count >> scale_power);
s.samples_num = _envelope_levels[probe_index][min_level].length;
// s.samples = new EnvelopeSample[s.length];
// memcpy(s.samples, _envelope_levels[min_level].samples + start,
// s.length * sizeof(EnvelopeSample));
s.samples = _envelope_levels[probe_index][min_level].samples;
}
@@ -255,8 +242,6 @@ void AnalogSnapshot::reallocate_envelope(Envelope &e)
if (new_data_length > e.data_length)
{
e.data_length = new_data_length;
// e.samples = (EnvelopeSample*)realloc(e.samples,
// new_data_length * sizeof(EnvelopeSample));
}
}
@@ -273,9 +258,6 @@ void AnalogSnapshot::append_payload_to_envelope_levels()
prev_length = e0.ring_length;
e0.ring_length = _ring_sample_count / EnvelopeScaleFactor;
// // Break off if there are no new samples to compute
// if (e0.ring_length == prev_length)
// continue;
if (e0.length == 0)
continue;

View File

@@ -42,10 +42,10 @@ Decoder::Decoder(const srd_decoder *const dec):
Decoder::~Decoder()
{
for (auto i = _options_back.begin();
i != _options_back.end(); i++)
for (auto i = _options_back.begin(); i != _options_back.end(); i++){
if ((*i).second)
g_variant_unref((*i).second);
}
}
void Decoder::set_probes(std::map<const srd_channel*, int> probes)
@@ -107,8 +107,7 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session)
GHashTable *const opt_hash = g_hash_table_new_full(g_str_hash,
g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
for (auto i = _options.begin();
i != _options.end(); i++)
for (auto i = _options.begin(); i != _options.end(); i++)
{
GVariant *const value = (*i).second;
g_variant_ref(value);
@@ -127,11 +126,11 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session)
GHashTable *const probes = g_hash_table_new_full(g_str_hash,
g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
for(auto i = _probes.begin(); i != _probes.end(); i++)
for(auto it = _probes.begin(); it != _probes.end(); it++)
{
GVariant *const gvar = g_variant_new_int32((*i).second);
GVariant *const gvar = g_variant_new_int32((*it).second);
g_variant_ref_sink(gvar);
g_hash_table_insert(probes, (*i).first->id, gvar);
g_hash_table_insert(probes, (*it).first->id, gvar);
}
srd_inst_channel_set_all(decoder_inst, probes);

View File

@@ -308,12 +308,13 @@ uint64_t DecoderStack::list_annotation_size()
{
std::lock_guard<std::mutex> lock(_output_mutex);
uint64_t max_annotation_size = 0;
for (auto i = _rows.begin();
i != _rows.end(); i++) {
auto iter = _rows_lshow.find((*i).first);
if (iter != _rows_lshow.end() && (*iter).second)
for (auto it = _rows.begin(); it != _rows.end(); it++) {
auto iter = _rows_lshow.find((*it).first);
if (iter != _rows_lshow.end() && (*iter).second){
max_annotation_size = max(max_annotation_size,
(*i).second->get_annotation_size());
(*it).second->get_annotation_size());
}
}
return max_annotation_size;
@@ -321,8 +322,7 @@ uint64_t DecoderStack::list_annotation_size()
uint64_t DecoderStack::list_annotation_size(uint16_t row_index)
{
for (auto i = _rows.begin();
i != _rows.end(); i++) {
for (auto i = _rows.begin(); i != _rows.end(); i++) {
auto iter = _rows_lshow.find((*i).first);
if (iter != _rows_lshow.end() && (*iter).second)
if (row_index-- == 0) {
@@ -335,8 +335,7 @@ uint64_t DecoderStack::list_annotation_size(uint16_t row_index)
bool DecoderStack::list_annotation(pv::data::decode::Annotation &ann,
uint16_t row_index, uint64_t col_index)
{
for (auto i = _rows.begin();
i != _rows.end(); i++) {
for (auto i = _rows.begin(); i != _rows.end(); i++) {
auto iter = _rows_lshow.find((*i).first);
if (iter != _rows_lshow.end() && (*iter).second) {
if (row_index-- == 0) {
@@ -351,8 +350,7 @@ bool DecoderStack::list_annotation(pv::data::decode::Annotation &ann,
bool DecoderStack::list_row_title(int row, QString &title)
{
for (auto i = _rows.begin();
i != _rows.end(); i++) {
for (auto i = _rows.begin();i != _rows.end(); i++) {
auto iter = _rows_lshow.find((*i).first);
if (iter != _rows_lshow.end() && (*iter).second) {
if (row-- == 0) {
@@ -376,8 +374,7 @@ void DecoderStack::init()
_error_message = QString();
_no_memory = false;
for (auto i = _rows.begin();
i != _rows.end(); i++) {
for (auto i = _rows.begin();i != _rows.end(); i++) {
(*i).second->clear();
}
@@ -426,21 +423,22 @@ void DecoderStack::do_decode_work()
init();
// Check that all decoders have the required channels
for(auto &dec : _stack)
for(auto dec : _stack){
if (!dec->have_required_probes()) {
_error_message = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DECODERSTACK_DECODE_WORK_ERROR),
"One or more required channels \nhave not been specified");
return;
}
}
// We get the logic data of the first channel in the list.
// This works because we are currently assuming all
// LogicSignals have the same data/snapshot
for (auto &dec : _stack) {
if (dec && !dec->channels().empty()) {
for(auto &sig : _session->get_signals()) {
if((sig->get_index() == (*dec->channels().begin()).second) &&
(logic_signal = dynamic_cast<view::LogicSignal*>(sig)) &&
for (auto dec : _stack) {
if (!dec->channels().empty()) {
for(auto s : _session->get_signals()) {
if((s->get_index() == (*dec->channels().begin()).second) &&
(logic_signal = dynamic_cast<view::LogicSignal*>(s)) &&
(data = logic_signal->logic_data()))
break;
}
@@ -614,7 +612,7 @@ void DecoderStack::execute_decode_stack()
dsv_info("%s%llu", "decoder sample count: ", _sample_count);
// Create the decoders
for(auto &dec : _stack)
for(auto dec : _stack)
{
srd_decoder_inst *const di = dec->create_decoder_inst(session);

View File

@@ -49,15 +49,17 @@ std::deque<DsoSnapshot*>& Dso::get_snapshots()
void Dso::clear()
{
//_snapshots.clear();
for(auto &s : _snapshots)
for(auto s : _snapshots){
s->clear();
}
}
void Dso::init()
{
//_snapshots.clear();
for(auto &s : _snapshots)
for(auto s : _snapshots){
s->init();
}
}
DsoSnapshot* Dso::snapshot()

View File

@@ -387,7 +387,6 @@ double DsoSnapshot::cal_vrms(double zero_off, int index)
double DsoSnapshot::cal_vmean(int index)
{
assert(index >= 0);
//assert(index < _channel_num);
// mean value
double vmean_pre = 0;

View File

@@ -45,14 +45,16 @@ std::deque<GroupSnapshot*>& Group::get_snapshots()
void Group::clear()
{
for(auto &s : _snapshots)
for(auto s : _snapshots){
s->clear();
}
}
void Group::init()
{
for(auto &s : _snapshots)
for(auto s : _snapshots){
s->init();
}
}
} // namespace data

View File

@@ -93,8 +93,9 @@ GroupSnapshot::GroupSnapshot(const LogicSnapshot *_logic_snapshot, std::list<int
GroupSnapshot::~GroupSnapshot()
{
for(auto &e : _envelope_levels)
for(auto &e : _envelope_levels){
free(e.samples);
}
}
void GroupSnapshot::init()
@@ -155,7 +156,6 @@ void GroupSnapshot::get_envelope_section(EnvelopeSection &s,
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) *

View File

@@ -49,15 +49,17 @@ std::deque<LogicSnapshot*>& Logic::get_snapshots()
void Logic::clear()
{
//_snapshots.clear();
for(auto &s : _snapshots)
for(auto s : _snapshots){
s->clear();
}
}
void Logic::init()
{
//_snapshots.clear();
for(auto &s : _snapshots)
for(auto s : _snapshots){
s->init();
}
}
LogicSnapshot* Logic::snapshot()

View File

@@ -60,11 +60,13 @@ LogicSnapshot::~LogicSnapshot()
void LogicSnapshot::free_data()
{
Snapshot::free_data();
for(auto& iter:_ch_data) {
for(auto& iter_rn:iter) {
for (unsigned int k = 0; k < Scale; k++)
for(auto& iter : _ch_data) {
for(auto& iter_rn : iter) {
for (unsigned int k = 0; k < Scale; k++){
if (iter_rn.lbp[k] != NULL)
free(iter_rn.lbp[k]);
}
}
std::vector<struct RootNode> void_vector;
iter.swap(void_vector);
@@ -113,8 +115,7 @@ void LogicSnapshot::capture_ended()
uint64_t index1 = block_index % RootScale;
int order = 0;
for(auto& iter:_ch_data) {
for(auto& iter : _ch_data) {
if (iter[index0].lbp[index1] == NULL){
iter[index0].lbp[index1] = malloc(LeafBlockSpace);
if (iter[index0].lbp[index1] == NULL)
@@ -195,8 +196,8 @@ void LogicSnapshot::first_payload(const sr_datafeed_logic &logic, uint64_t total
}
} else {
for(auto& iter:_ch_data) {
for(auto& iter_rn:iter) {
for(auto& iter : _ch_data) {
for(auto& iter_rn : iter) {
iter_rn.tog = 0;
iter_rn.value = 0;
}
@@ -257,7 +258,7 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic)
while (_sample_count > _block_num * LeafBlockSamples) {
uint8_t index0 = _block_num / RootScale;
uint8_t index1 = _block_num % RootScale;
for(auto& iter:_ch_data) {
for(auto& iter : _ch_data) {
if (iter[index0].lbp[index1] == NULL){
iter[index0].lbp[index1] = malloc(LeafBlockSpace);
@@ -324,23 +325,17 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic)
const uint64_t align_size = len / ScaleSize / _channel_num;
_ring_sample_count += align_size * Scale;
// uint64_t mipmap_index = pre_offset / Scale;
// uint64_t mipmap_offset = pre_offset % Scale;
// uint64_t *l1_mipmap;
for(auto& iter:_ch_data) {
for(auto& iter : _ch_data) {
uint64_t index0 = pre_index0;
uint64_t index1 = pre_index1;
src_ptr = (uint64_t *)_src_ptr + order;
_dest_ptr = iter[index0].lbp[index1];
dest_ptr = (uint64_t *)_dest_ptr + pre_offset;
// l1_mipmap = (uint64_t *)_dest_ptr + (LeafBlockSamples / Scale) + mipmap_index;
while (src_ptr < (uint64_t *)_src_ptr + (align_size * _channel_num)) {
const uint64_t tmp_u64 = *src_ptr;
*dest_ptr++ = tmp_u64;
// *l1_mipmap += ((_last_sample[i] ^ tmp_u64) != 0 ? 1ULL : 0ULL) << mipmap_offset;
// mipmap_offset = (mipmap_offset + 1) % Scale;
// l1_mipmap += (mipmap_offset == 0);
// _last_sample[i] = tmp_u64 & (1ULL << (Scale - 1)) ? ~0ULL : 0ULL;
src_ptr += _channel_num;
//mipmap
if (dest_ptr == (uint64_t *)_dest_ptr + (LeafBlockSamples / Scale)) {
@@ -383,16 +378,13 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic)
uint8_t *dp_tmp = (uint8_t *)_dest_ptr;
uint8_t *sp_tmp = (uint8_t *)_src_ptr;
while(len-- != 0) {
//*(uint8_t *)_dest_ptr++ = *(uint8_t *)_src_ptr++;
*dp_tmp++ = *sp_tmp++;
if (++_byte_fraction == ScaleSize) {
_ch_fraction = (_ch_fraction + 1) % _channel_num;
_byte_fraction = 0;
//_dest_ptr = (uint8_t *)_ch_data[_ch_fraction][index0].lbp[index1] + offset;
dp_tmp = (uint8_t *)_ch_data[_ch_fraction][index0].lbp[index1] + offset;
}
}
//_dest_ptr = (uint8_t *)_dest_ptr + _byte_fraction;
_dest_ptr = dp_tmp + _byte_fraction;
}
}
@@ -507,7 +499,6 @@ void LogicSnapshot::calc_mipmap(unsigned int order, uint8_t index0, uint8_t inde
const uint8_t *LogicSnapshot::get_samples(uint64_t start_sample, uint64_t &end_sample,
int sig_index)
{
//assert(data);
uint64_t sample_count = get_sample_count();
assert(start_sample < sample_count);
assert(end_sample <= sample_count);
@@ -534,7 +525,6 @@ bool LogicSnapshot::get_sample(uint64_t index, int sig_index)
int order = get_ch_order(sig_index);
assert(order != -1);
assert(_ch_data[order].size() != 0);
//assert(index < get_sample_count());
if (index < get_sample_count()) {
uint64_t index_mask = 1ULL << (index & LevelMask[0]);

View File

@@ -173,7 +173,7 @@ void SpectrumStack::calc_fft()
pv::data::Dso *data = NULL;
pv::view::DsoSignal *dsoSig = NULL;
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
if ((dsoSig = dynamic_cast<view::DsoSignal*>(s))) {
if (dsoSig->get_index() == _index && dsoSig->enabled()) {
data = dsoSig->dso_data();

View File

@@ -259,20 +259,20 @@ DsComboBox* DecoderOptionsDlg::create_probe_selector(
if (probe_iter == _dec->channels().end())
selector->setCurrentIndex(0);
int dex = 0;
for(size_t i = 0; i < sigs.size(); i++) {
const auto s = sigs[i];
assert(s);
for(auto s : sigs) {
if (dynamic_cast<view::LogicSignal*>(s) && s->enabled())
{
selector->addItem(s->get_name(),
QVariant::fromValue(s->get_index()));
selector->addItem(s->get_name(),QVariant::fromValue(s->get_index()));
if (probe_iter != _dec->channels().end()) {
if ((*probe_iter).second == s->get_index())
selector->setCurrentIndex(i + 1);
selector->setCurrentIndex(dex + 1);
}
}
++dex;
}
return selector;
@@ -336,7 +336,7 @@ void DecoderOptionsDlg::update_decode_range()
decode_end = tmp;
}
for(auto &dec : _trace->decoder()->stack()) {
for(auto dec : _trace->decoder()->stack()) {
dec->set_decode_region(decode_start, decode_end);
}
}
@@ -421,7 +421,7 @@ void DecoderOptionsDlg::create_decoder_form(
void DecoderOptionsDlg::commit_probes()
{
for(auto &dec : _trace->decoder()->stack()){
for(auto dec : _trace->decoder()->stack()){
commit_decoder_probes(dec);
}
}
@@ -441,20 +441,20 @@ void DecoderOptionsDlg::commit_decoder_probes(data::decode::Decoder *dec)
auto index_list = _trace->get_sig_index_list();
index_list->clear();
for(auto &s : _probe_selectors)
for(auto &p : _probe_selectors)
{
if(s._decoder != dec)
if(p._decoder != dec)
break;
const int selection = s._combo->itemData(
s._combo->currentIndex()).value<int>();
const int selection = p._combo->itemData(p._combo->currentIndex()).value<int>();
for(auto &sig : sigs)
if(sig->get_index() == selection) {
probe_map[s._pdch] = selection;
for(auto s : sigs){
if(s->get_index() == selection) {
probe_map[p._pdch] = selection;
index_list->push_back(selection);
break;
}
}
}
dec->set_probes(probe_map);

View File

@@ -164,8 +164,8 @@ void DeviceOptions::accept()
// Commit the properties
const auto &dev_props = _device_options_binding.properties();
for(auto &p : dev_props) {
assert(p);
for(auto p : dev_props) {
p->commit();
}
@@ -181,7 +181,8 @@ void DeviceOptions::accept()
if (probe->enabled)
hasEnabled = true;
}
} else {
}
else {
hasEnabled = true;
}
@@ -190,8 +191,7 @@ void DeviceOptions::accept()
while(it != _probe_options_binding_list.end()) {
const auto &probe_props = (*it)->properties();
for(auto &p :probe_props) {
assert(p);
for(auto p :probe_props) {
p->commit();
}
it++;
@@ -623,18 +623,19 @@ void DeviceOptions::analog_probes(QGridLayout &layout)
const auto &properties = probe_options_binding->properties();
int i = 1;
for(auto &p : properties)
for(auto p : properties)
{
assert(p);
const QString label = p->labeled_widget() ? QString() : p->label();
probe_layout->addWidget(new QLabel(label, probe_widget), i, 0, 1, 1);
QWidget * pow = p->get_widget(probe_widget);
pow->setEnabled(probe_checkBox->isChecked());
if (p->name().contains("Map Default")) {
pow->setProperty("index", probe->index);
connect(pow, SIGNAL(clicked()), this, SLOT(analog_channel_check()));
} else {
}
else {
if (probe_checkBox->isChecked() && p->name().contains("Map")) {
bool map_default = true;
GVariant* gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_MAP_DEFAULT);

View File

@@ -56,7 +56,7 @@ DsoMeasure::DsoMeasure(SigSession *session, View &parent,
_measure_tab->setTabPosition(QTabWidget::West);
_measure_tab->setUsesScrollButtons(false);
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
view::DsoSignal *dsoSig;
if ((dsoSig = dynamic_cast<view::DsoSignal*>(s)) && dsoSig->enabled()) {
QWidget *measure_widget = new QWidget(this);
@@ -155,12 +155,12 @@ void DsoMeasure::accept()
{
using namespace Qt;
QToolButton* sc=dynamic_cast<QToolButton*>(sender());
QToolButton* sc = dynamic_cast<QToolButton*>(sender());
if(sc != NULL) {
QVariant id = sc->property("id");
enum DSO_MEASURE_TYPE ms_type = DSO_MEASURE_TYPE(id.toInt());
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
view::DsoSignal *dsoSig = NULL;
if ((dsoSig = dynamic_cast<view::DsoSignal*>(s))) {
if (_measure_tab->currentWidget()->property("index").toInt() == dsoSig->get_index()) {

View File

@@ -68,7 +68,7 @@ FftOptions::FftOptions(QWidget *parent, SigSession *session) :
_dbv_combobox = new DsComboBox(this);
// setup _ch_combobox
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
view::DsoSignal *dsoSig = NULL;
if ((dsoSig = dynamic_cast<view::DsoSignal*>(s))) {
_ch_combobox->addItem(dsoSig->get_name(), QVariant::fromValue(dsoSig->get_index()));
@@ -92,7 +92,7 @@ FftOptions::FftOptions(QWidget *parent, SigSession *session) :
std::vector<QString> view_modes;
std::vector<int> dbv_ranges;
for(auto &t : _session->get_spectrum_traces()) {
for(auto t : _session->get_spectrum_traces()) {
view::SpectrumTrace *spectrumTraces = NULL;
if ((spectrumTraces = dynamic_cast<view::SpectrumTrace*>(t))) {
windows = spectrumTraces->get_spectrum_stack()->get_windows_support();
@@ -142,7 +142,7 @@ FftOptions::FftOptions(QWidget *parent, SigSession *session) :
}
// load current settings
for(auto &t : _session->get_spectrum_traces()) {
for(auto t : _session->get_spectrum_traces()) {
view::SpectrumTrace *spectrumTraces = NULL;
if ((spectrumTraces = dynamic_cast<view::SpectrumTrace*>(t))) {
if (spectrumTraces->enabled()) {
@@ -236,7 +236,7 @@ void FftOptions::accept()
QDialog::accept();
for(auto &t : _session->get_spectrum_traces()) {
for(auto t : _session->get_spectrum_traces()) {
view::SpectrumTrace *spectrumTraces = NULL;
if ((spectrumTraces = dynamic_cast<view::SpectrumTrace*>(t))) {
spectrumTraces->set_enable(false);

View File

@@ -75,7 +75,7 @@ LissajousOptions::LissajousOptions(SigSession *session, QWidget *parent) :
QHBoxLayout *xlayout = new QHBoxLayout();
QHBoxLayout *ylayout = new QHBoxLayout();
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
view::DsoSignal *dsoSig = NULL;
if ((dsoSig = dynamic_cast<view::DsoSignal*>(s))) {
QString index_str = QString::number(dsoSig->get_index());
@@ -182,7 +182,7 @@ void LissajousOptions::accept()
bool enable = (xindex != -1 && yindex != -1 && _enable->isChecked());
_session->lissajous_rebuild(enable, xindex, yindex, _percent->value());
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
view::DsoSignal *dsoSig = NULL;
if ((dsoSig = dynamic_cast<view::DsoSignal*>(s))) {
dsoSig->set_show(!enable);

View File

@@ -79,7 +79,7 @@ MathOptions::MathOptions(SigSession *session, QWidget *parent) :
QHBoxLayout *src1_layout = new QHBoxLayout();
QHBoxLayout *src2_layout = new QHBoxLayout();
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
view::DsoSignal *dsoSig = NULL;;
if ((dsoSig = dynamic_cast<view::DsoSignal*>(s))) {
QString index_str = QString::number(dsoSig->get_index());
@@ -207,7 +207,7 @@ void MathOptions::accept()
view::DsoSignal *dsoSig1 = NULL;
view::DsoSignal *dsoSig2 = NULL;
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
view::DsoSignal *dsoSig = NULL;;
if ((dsoSig = dynamic_cast<view::DsoSignal*>(s))) {
if (dsoSig->get_index() == src1)

View File

@@ -63,7 +63,7 @@ ProtocolList::ProtocolList(QWidget *parent, SigSession *session) :
auto &decode_sigs = _session->get_decode_signals();
int index = 0;
for(auto &d : decode_sigs) {
for(auto d : decode_sigs) {
_protocol_combobox->addItem(d->get_name());
if (decoder_model->getDecoderStack() == d->decoder())
_protocol_combobox->setCurrentIndex(index);
@@ -133,7 +133,7 @@ void ProtocolList::set_protocol(int index)
const auto &decode_sigs = _session->get_decode_signals();
int cur_index = 0;
for(auto &d : decode_sigs) {
for(auto d : decode_sigs) {
if (index == cur_index) {
decoder_stack = d->decoder();
break;
@@ -175,7 +175,7 @@ void ProtocolList::on_row_check(bool show)
const auto &decode_sigs = _session->get_decode_signals();
int cur_index = 0;
for(auto &d : decode_sigs) {
for(auto d : decode_sigs) {
if (cur_index == _protocol_combobox->currentIndex()) {
decoder_stack = d->decoder();
break;

View File

@@ -52,10 +52,9 @@ Search::Search(QWidget *parent, SigSession *session, std::map<uint16_t, QString>
int index = 0;
for(auto &sig : _session->get_signals()) {
assert(sig);
for(auto s : _session->get_signals()) {
view::LogicSignal *logic_sig = NULL;
if ((logic_sig = dynamic_cast<view::LogicSignal*>(sig))) {
if ((logic_sig = dynamic_cast<view::LogicSignal*>(s))) {
QLineEdit *search_lineEdit = new QLineEdit(this);
if (pattern.find(logic_sig->get_index()) != pattern.end())
search_lineEdit->setText(pattern[logic_sig->get_index()]);
@@ -113,10 +112,9 @@ std::map<uint16_t, QString> Search::get_pattern()
std::map<uint16_t, QString> pattern;
int index = 0;
for(auto &sig :_session->get_signals()) {
assert(sig);
for(auto s :_session->get_signals()) {
view::LogicSignal *logic_sig = NULL;
if ((logic_sig = dynamic_cast<view::LogicSignal*>(sig))) {
if ((logic_sig = dynamic_cast<view::LogicSignal*>(s))) {
pattern[logic_sig->get_index()] = _search_lineEdit_vec[index]->text();
index++;
}

View File

@@ -53,6 +53,7 @@ StoreProgress::StoreProgress(SigSession *session, QWidget *parent) :
_isExport = false;
_done = false;
_isBusy = false;
QGridLayout *grid = new QGridLayout();
_grid = grid;
@@ -70,7 +71,7 @@ StoreProgress::StoreProgress(SigSession *session, QWidget *parent) :
_fileLab->setMaximumHeight(50);
_openButton = new QPushButton(this);
_openButton->setText(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CHANGE), "change"));
_openButton->setText(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CHANGE_FILE), "change"));
_space = new QWidget(this);
_space->setMinimumHeight(80);
@@ -139,6 +140,9 @@ void StoreProgress::accept()
return;
}
if (_isBusy)
return;
_progress.setVisible(true);
_fileLab->setVisible(false);
_fileLab->setVisible(false);
@@ -163,8 +167,10 @@ void StoreProgress::accept()
//start done
if (_isExport){
if (_store_session.export_start()){
_isBusy = true;
_store_session.session()->set_saving(true);
QTimer::singleShot(100, this, SLOT(timeout()));
QTimer::singleShot(100, this, SLOT(timeout()));
setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_EXPORTING), "Exporting..."));
}
else{
save_done();
@@ -174,8 +180,10 @@ void StoreProgress::accept()
}
else{
if (_store_session.save_start()){
_isBusy = true;
_store_session.session()->set_saving(true);
QTimer::singleShot(100, this, SLOT(timeout()));
QTimer::singleShot(100, this, SLOT(timeout()));
setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SAVING), "Saving..."));
}
else{
save_done();
@@ -202,7 +210,7 @@ void StoreProgress::timeout()
void StoreProgress::save_run(ISessionDataGetter *getter)
{
_isExport = false;
setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SAVING), "Saving..."));
setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SAVE), "Save"));
QString file = _store_session.MakeSaveFile(false);
_fileLab->setText(file);
_store_session._sessionDataGetter = getter;
@@ -234,7 +242,7 @@ void StoreProgress::export_run()
}
_isExport = true;
setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_EXPORTING), "Exporting..."));
setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_EXPORT), "Export"));
QString file = _store_session.MakeExportFile(false);
_fileLab->setText(file);

View File

@@ -84,6 +84,7 @@ private:
QPushButton *_openButton;
QGridLayout *_grid;
QWidget *_space;
bool _isBusy;
};
} // dialogs

View File

@@ -188,8 +188,7 @@ void WaitingDialog::changeText()
if (zero_fgain) {
view::DsoSignal *dsoSig = NULL;
for(auto &s : _session->get_signals())
{
for(auto s : _session->get_signals()){
if ((dsoSig = dynamic_cast<view::DsoSignal*>(s)))
dsoSig->set_enable(dsoSig->get_index() == 0);
}

View File

@@ -400,7 +400,7 @@ void DsoTriggerDock::init()
disconnect(_channel_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(channel_changed(int)));
_channel_comboBox->clear();
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
view::DsoSignal *dsoSig = NULL;
if ((dsoSig = dynamic_cast<view::DsoSignal*>(s))) {
_channel_comboBox->addItem(dsoSig->get_name(), QVariant::fromValue(dsoSig->get_index()));

View File

@@ -606,10 +606,8 @@ void MeasureDock::update_edge()
const auto &sigs = _session->get_signals();
for(size_t i = 0; i < sigs.size(); i++) {
view::Signal *s = sigs[i];
for(auto s : _session->get_signals()) {
view::LogicSignal *logicSig = NULL;
assert(s);
if ((logicSig = dynamic_cast<view::LogicSignal*>(s)) &&
(logicSig->enabled()) &&
@@ -657,15 +655,10 @@ DsComboBox* MeasureDock::create_probe_selector(QWidget *parent)
void MeasureDock::update_probe_selector(DsComboBox *selector)
{
selector->clear();
const auto &sigs = _session->get_signals();
selector->clear();
for(size_t i = 0; i < sigs.size(); i++) {
const auto s = sigs[i];
assert(s);
if (dynamic_cast<LogicSignal*>(s) && s->enabled())
{
for(auto s : _session->get_signals()) {
if (dynamic_cast<LogicSignal*>(s) && s->enabled()){
selector->addItem(QString::number(s->get_index()));
}
}

View File

@@ -451,7 +451,7 @@ void ProtocolDock::decoded_progress(int progress)
const auto &decode_sigs = _session->get_decode_signals();
int index = 0;
for(auto &d : decode_sigs) {
for(auto d : decode_sigs) {
pg = d->get_progress();
if (d->decoder()->out_of_memory())
err = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_OUT_OF_MEMORY), "Out of Memory");
@@ -486,7 +486,7 @@ void ProtocolDock::set_model()
// clear mark_index of all DecoderStacks
const auto &decode_sigs = _session->get_decode_signals();
for(auto &d : decode_sigs) {
for(auto d : decode_sigs) {
d->decoder()->set_mark_index(-1);
}
}
@@ -502,7 +502,7 @@ void ProtocolDock::update_model()
decoder_model->setDecoderStack(decode_sigs.at(0)->decoder());
else {
unsigned int index = 0;
for(auto &d : decode_sigs) {
for(auto d : decode_sigs) {
if (d->decoder() == decoder_model->getDecoderStack()) {
decoder_model->setDecoderStack(d->decoder());
break;
@@ -544,7 +544,7 @@ void ProtocolDock::item_clicked(const QModelIndex &index)
if (decoder_stack->list_annotation(ann, index.column(), index.row())) {
const auto &decode_sigs = _session->get_decode_signals();
for(auto &d : decode_sigs) {
for(auto d : decode_sigs) {
d->decoder()->set_mark_index(-1);
}
@@ -639,7 +639,7 @@ void ProtocolDock::nav_table_view()
decoder_stack->list_annotation(ann, index.column(), index.row());
const auto &decode_sigs = _session->get_decode_signals();
for(auto &d : decode_sigs) {
for(auto d : decode_sigs) {
d->decoder()->set_mark_index(-1);
}
decoder_stack->set_mark_index((ann.start_sample()+ann.end_sample())/2);
@@ -848,21 +848,19 @@ void ProtocolDock::OnProtocolDelete(void *handle){
return;
}
for (auto it = _protocol_lay_items.begin(); it != _protocol_lay_items.end(); it++)
{
if ((*it) == handle)
{
auto lay = (*it);
void *key_handel = lay->get_protocol_key_handel();
_protocol_lay_items.erase(it);
DESTROY_QT_LATER(lay);
_session->remove_decoder_by_key_handel(key_handel);
protocol_updated();
break;
}
}
for (auto it = _protocol_lay_items.begin(); it != _protocol_lay_items.end(); it++)
{
if ((*it) == handle)
{
auto lay = (*it);
void *key_handel = lay->get_protocol_key_handel();
_protocol_lay_items.erase(it);
DESTROY_QT_LATER(lay);
_session->remove_decoder_by_key_handel(key_handel);
protocol_updated();
break;
}
}
}
void ProtocolDock::OnProtocolFormatChanged(QString format, void *handle){

View File

@@ -914,9 +914,8 @@ void TriggerDock::try_commit_trigger()
if (commit_trigger() == false)
{
/* simple trigger check trigger_enable */
for(auto &s : _session->get_signals())
for(auto s : _session->get_signals())
{
assert(s);
view::LogicSignal *logicSig = NULL;
if ((logicSig = dynamic_cast<view::LogicSignal*>(s))) {
if (logicSig->commit_trig())
@@ -938,9 +937,7 @@ void TriggerDock::try_commit_trigger()
msg.exec();
if (msg.mBox()->clickedButton() == cancelButton) {
for(auto &s : _session->get_signals())
{
assert(s);
for(auto s : _session->get_signals()){
view::LogicSignal *logicSig = NULL;
if ((logicSig = dynamic_cast<view::LogicSignal*>(s))) {
logicSig->set_trig(view::LogicSignal::NONTRIG);

View File

@@ -23,12 +23,14 @@
#include <assert.h>
DsTimer::DsTimer(){
DsTimer::DsTimer()
{
_binded = false;
_isActived = false;
}
void DsTimer::on_timeout(){
void DsTimer::on_timeout()
{
_call(); //call back
}

View File

@@ -95,10 +95,8 @@ public slots:
private slots:
void on_load_file(QString file_name);
void on_open_doc();
void on_protocol(bool visible);
void on_trigger(bool visible);
void on_measure(bool visible);
void on_search(bool visible);
void on_screenShot();

View File

@@ -42,8 +42,7 @@ Binding::Binding(){
void Binding::commit()
{
for(auto &p : _properties) {
assert(p);
for(auto p : _properties) {
p->commit();
}
}
@@ -53,10 +52,8 @@ void Binding::add_properties_to_form(QFormLayout *layout,
{
assert(layout);
for(auto &p : _properties)
for(auto p : _properties)
{
assert(p);
QWidget *const widget = p->get_widget(layout->parentWidget(), auto_commit);
if (p->labeled_widget()){
@@ -93,9 +90,8 @@ std::map<Property*,GVariant*> Binding::get_property_value()
{
std::map <Property*,GVariant*> pvalue;
for(auto &p : _properties)
for(auto p : _properties)
{
assert(p);
pvalue[p] = p->get_value();
}

View File

@@ -79,12 +79,12 @@ namespace pv
_error = No_err;
_is_instant = false;
_is_working = false;
_is_repeat_mode = false;
_is_saving = false;
_device_status = ST_INIT;
_noData_cnt = 0;
_data_lock = false;
_data_updated = false;
_opt_mode = OPT_SINGLE;
this->add_msg_listener(this);
@@ -110,7 +110,6 @@ namespace pv
_group_data = new data::Group();
_group_cnt = 0;
_feed_timer.Stop();
_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));
@@ -222,9 +221,9 @@ namespace pv
_cur_samplelimits = _device_agent.get_sample_limit();
if (_device_agent.get_work_mode() == DSO)
_is_repeat_mode = true;
_opt_mode = OPT_REPEAT;
else
_is_repeat_mode = false;
_opt_mode = OPT_SINGLE;
// The current device changed.
_callback->trigger_message(DSV_MSG_CURRENT_DEVICE_CHANGED);
@@ -390,8 +389,7 @@ namespace pv
// update current hw offset
for (auto &s : _signals)
{
assert(s);
{
view::DsoSignal *dsoSig = NULL;
if ((dsoSig = dynamic_cast<view::DsoSignal *>(s)))
{
@@ -425,8 +423,7 @@ namespace pv
// SpectrumStack
for (auto &m : _spectrum_traces)
{
assert(m);
{
m->get_spectrum_stack()->init();
}
@@ -537,7 +534,7 @@ namespace pv
}
bool wait_upload = false;
if (!_is_repeat_mode)
if (is_single_mode())
{
GVariant *gvar = _device_agent.get_config(NULL, NULL, SR_CONF_WAIT_UPLOAD);
if (gvar != NULL)
@@ -553,7 +550,7 @@ namespace pv
_repeat_timer.Stop();
_repeat_wait_prog_timer.Stop();
if (_repeat_hold_prg != 0 && _is_repeat_mode){
if (_repeat_hold_prg != 0 && is_repeat_mode()){
_repeat_hold_prg = 0;
_callback->repeat_hold(_repeat_hold_prg);
}
@@ -562,8 +559,7 @@ namespace pv
exit_capture();
if (_is_repeat_mode && _device_agent.is_collecting() == false)
{
if (is_repeat_mode() && _device_agent.is_collecting() == false){
// On repeat mode, the working status is changed, to post the event message.
_callback->trigger_message(DSV_MSG_END_COLLECT_WORK);
}
@@ -578,7 +574,6 @@ namespace pv
{
_is_instant = false;
//_feed_timer
_feed_timer.Stop();
if (_device_agent.is_collecting())
@@ -624,10 +619,9 @@ namespace pv
{
std::set<data::SignalData *> data;
for (auto &sig : _signals)
{
assert(sig);
data.insert(sig->data());
for (auto &s : _signals)
{
data.insert(s->data());
}
return data;
@@ -920,8 +914,7 @@ namespace pv
_dso_data->init();
// SpectrumStack
for (auto &m : _spectrum_traces)
{
assert(m);
{
m->get_spectrum_stack()->init();
}
@@ -1070,7 +1063,6 @@ namespace pv
// reset scale of dso signal
for (auto &s : _signals)
{
assert(s);
view::DsoSignal *dsoSig = NULL;
if ((dsoSig = dynamic_cast<view::DsoSignal *>(s)))
{
@@ -1111,7 +1103,6 @@ namespace pv
// calculate related spectrum results
for (auto &m : _spectrum_traces)
{
assert(m);
if (m->enabled())
m->get_spectrum_stack()->calc_fft();
}
@@ -1126,6 +1117,7 @@ namespace pv
_trigger_flag = dso.trig_flag;
_trigger_ch = dso.trig_ch;
//Trigger update()
receive_data(dso.num_samples);
if (!_is_instant)
@@ -1149,7 +1141,6 @@ namespace pv
// reset scale of analog signal
for (auto &s : _signals)
{
assert(s);
view::AnalogSignal *analogSig = NULL;
if ((analogSig = dynamic_cast<view::AnalogSignal *>(s)))
{
@@ -1243,8 +1234,6 @@ namespace pv
{
for (auto &g : _group_traces)
{
assert(g);
auto p = new data::GroupSnapshot(_logic_data->get_snapshots().front(), g->get_index_list());
_group_data->push_snapshot(p);
}
@@ -1295,8 +1284,7 @@ namespace pv
if (_device_agent.have_instance())
{
for (auto &s : _signals)
{
assert(s);
{
if (dynamic_cast<view::LogicSignal *>(s) && s->enabled())
{
logic_ch_num++;
@@ -1602,7 +1590,7 @@ namespace pv
int SigSession::get_repeat_hold()
{
if (!_is_instant && _is_working && _is_repeat_mode)
if (!_is_instant && _is_working && is_repeat_mode())
return _repeat_hold_prg;
else
return 0;
@@ -1856,7 +1844,7 @@ namespace pv
dsv_err("%s", "The collected data is error!");
// trigger next collect
if (!_is_instant && _is_repeat_mode && _is_working && event == DS_EV_COLLECT_TASK_END)
if (!_is_instant && is_repeat_mode() && _is_working && event == DS_EV_COLLECT_TASK_END)
{
_callback->trigger_message(DSV_MSG_TRIG_NEXT_COLLECT);
}
@@ -1905,13 +1893,13 @@ namespace pv
}
}
void SigSession::set_repeat_mode(bool repeat)
void SigSession::set_operation_mode(COLLECT_OPT_MODE repeat)
{
assert(!_is_working);
if (_is_repeat_mode != repeat)
if (_opt_mode != repeat)
{
_is_repeat_mode = repeat;
_opt_mode = repeat;
_repeat_hold_prg = 0;
}
}
@@ -1950,38 +1938,41 @@ namespace pv
break;
case DSV_MSG_TRIG_NEXT_COLLECT:
{
if (_is_working)
{
if (_repeat_intvl > 0)
if (_is_working)
{
_repeat_hold_prg = 100;
_repeat_timer.Start(_repeat_intvl * 1000);
int intvl = _repeat_intvl * 1000 / 20;
if (_repeat_intvl > 0)
{
_repeat_hold_prg = 100;
_repeat_timer.Start(_repeat_intvl * 1000);
int intvl = _repeat_intvl * 1000 / 20;
if (intvl >= 100){
_repeat_wait_prog_step = 5;
}
else if (_repeat_intvl >= 1){
intvl = _repeat_intvl * 1000 / 10;
_repeat_wait_prog_step = 10;
}
else{
intvl = _repeat_intvl * 1000 / 5;
_repeat_wait_prog_step = 20;
}
if (intvl >= 100){
_repeat_wait_prog_step = 5;
}
else if (_repeat_intvl >= 1){
intvl = _repeat_intvl * 1000 / 10;
_repeat_wait_prog_step = 10;
}
else{
intvl = _repeat_intvl * 1000 / 5;
_repeat_wait_prog_step = 20;
}
_repeat_wait_prog_timer.Start(intvl);
}
else
{
_repeat_hold_prg = 0;
exec_capture();
_repeat_wait_prog_timer.Start(intvl);
}
else
{
_repeat_hold_prg = 0;
exec_capture();
}
}
}
}
break;
}
break;
case DSV_MSG_COLLECT_END:
break;
}
}
void SigSession::DeviceConfigChanged()

View File

@@ -65,8 +65,7 @@ class MathStack;
namespace decode {
class Decoder;
}
}
}
namespace device {
@@ -82,6 +81,17 @@ class LissajousTrace;
class MathTrace;
}
enum DEVICE_STATUS_TYPE{
ST_INIT = 0,
ST_RUNNING = 1,
ST_STOPPED = 2,
};
enum COLLECT_OPT_MODE{
OPT_SINGLE = 0,
OPT_REPEAT = 1,
OPT_REALTIME = 2,
};
using namespace pv::data;
//created by MainWindow
@@ -91,15 +101,14 @@ class SigSession:
{
private:
static constexpr float Oversampling = 2.0f;
static const int RefreshTime = 500;
static const int RepeatHoldDiv = 20;
public:
static const int RefreshTime = 500;
static const int RepeatHoldDiv = 20;
static const int FeedInterval = 50;
static const int WaitShowTime = 500;
public:
enum error_state {
enum SESSION_ERROR_STATUS {
No_err,
Hw_err,
Malloc_err,
@@ -109,12 +118,6 @@ public:
Data_overflow
};
enum device_status_type{
ST_INIT = 0,
ST_RUNNING = 1,
ST_STOPPED = 2,
};
private:
SigSession(SigSession &o);
@@ -149,7 +152,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);
@@ -166,9 +168,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();
std::vector<view::GroupSignal*>& get_group_signals();
@@ -234,11 +234,11 @@ public:
data::Snapshot* get_snapshot(int type);
inline error_state get_error(){
inline SESSION_ERROR_STATUS get_error(){
return _error;
}
inline void set_error(error_state state){
inline void set_error(SESSION_ERROR_STATUS state){
_error = state;
}
@@ -313,14 +313,22 @@ public:
return _device_status == ST_STOPPED;
}
void set_repeat_mode(bool repeat);
void set_operation_mode(COLLECT_OPT_MODE repeat);
inline bool is_repeat_mode(){
return _is_repeat_mode;
return _opt_mode == OPT_REPEAT;
}
inline bool is_single_mode(){
return _opt_mode == OPT_SINGLE;
}
inline bool is_realtime_mode(){
return _opt_mode == OPT_REALTIME;
}
inline bool is_repeating(){
return _is_repeat_mode && !_is_instant;
return _opt_mode == OPT_REPEAT && !_is_instant;
}
inline void session_save(){
@@ -332,7 +340,7 @@ public:
}
inline void decode_done(){
_callback->decode_done();
_callback->decode_done();
}
inline bool is_saving(){
@@ -474,7 +482,7 @@ private:
uint8_t _trigger_ch;
bool _hw_replied;
error_state _error;
SESSION_ERROR_STATUS _error;
uint64_t _error_pattern;
int _map_zoom;
bool _dso_feed;
@@ -484,7 +492,6 @@ private:
uint64_t _save_start;
uint64_t _save_end;
bool _is_working;
bool _is_repeat_mode;
double _repeat_intvl; // The progress wait timer interval.
int _repeat_hold_prg; // The time sleep progress
int _repeat_wait_prog_step;
@@ -493,6 +500,7 @@ private:
int _device_status;
int _capture_time_id;
int _confirm_store_time_id;
COLLECT_OPT_MODE _opt_mode;
ISessionCallback *_callback;

View File

@@ -131,9 +131,8 @@ bool StoreSession::save_start()
assert(_sessionDataGetter);
std::set<int> type_set;
for(auto &sig : _session->get_signals()) {
assert(sig);
type_set.insert(sig->get_type());
for(auto s : _session->get_signals()) {
type_set.insert(s->get_type());
}
if (type_set.size() > 1) {
@@ -224,7 +223,7 @@ void StoreSession::save_proc(data::Snapshot *snapshot)
if ((logic_snapshot = dynamic_cast<data::LogicSnapshot*>(snapshot))) {
uint16_t to_save_probes = 0;
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
if (s->enabled() && logic_snapshot->has_data(s->get_index()))
to_save_probes++;
}
@@ -232,7 +231,7 @@ void StoreSession::save_proc(data::Snapshot *snapshot)
num = logic_snapshot->get_block_num();
bool sample;
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
int ch_type = s->get_type();
if (ch_type == SR_CHANNEL_LOGIC) {
int ch_index = s->get_index();
@@ -274,9 +273,10 @@ void StoreSession::save_proc(data::Snapshot *snapshot)
}
}
}
} else {
}
else {
int ch_type = -1;
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
ch_type = s->get_type();
break;
}
@@ -585,9 +585,8 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
bool StoreSession::export_start()
{
std::set<int> type_set;
for(auto &sig : _session->get_signals()) {
assert(sig);
int _tp = sig->get_type();
for(auto s : _session->get_signals()) {
int _tp = s->get_type();
type_set.insert(_tp);
}
@@ -757,7 +756,7 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
buf_vec.clear();
buf_sample.clear();
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
int ch_type = s->get_type();
if (ch_type == SR_CHANNEL_LOGIC) {
int ch_index = s->get_index();
@@ -894,23 +893,22 @@ bool StoreSession::decoders_gen(std::string &str)
bool StoreSession::json_decoders(QJsonArray &array)
{
for(auto &t : _session->get_decode_signals()) {
for(auto s : _session->get_decode_signals()) {
QJsonObject dec_obj;
QJsonArray stack_array;
QJsonObject show_obj;
const auto &stack = t->decoder();
const auto &stack = s->decoder();
const auto &decoder = stack->stack();
for(auto &dec : decoder) {
for(auto dec : decoder) {
QJsonArray ch_array;
const srd_decoder *const d = dec->decoder();;
const bool have_probes = (d->channels || d->opt_channels) != 0;
if (have_probes) {
for(auto i = dec->channels().begin();
i != dec->channels().end(); i++) {
for(auto it = dec->channels().begin();it != dec->channels().end(); it++) {
QJsonObject ch_obj;
ch_obj[(*i).first->id] = QJsonValue::fromVariant((*i).second);
ch_obj[(*it).first->id] = QJsonValue::fromVariant((*it).second);
ch_array.push_back(ch_obj);
}
}
@@ -1195,7 +1193,7 @@ double StoreSession::get_integer(GVariant *var)
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64))
val = g_variant_get_uint64(var);
else
assert(0);
assert(false);
return val;
}
@@ -1350,8 +1348,7 @@ QString StoreSession::MakeExportFile(bool bDlg)
bool StoreSession::IsLogicDataType()
{
std::set<int> type_set;
for(auto &sig : _session->get_signals()) {
assert(sig);
for(auto sig : _session->get_signals()) {
type_set.insert(sig->get_type());
}

View File

@@ -103,12 +103,13 @@ namespace pv
addWidget(&_sample_rate);
_action_single = new QAction(this);
_action_repeat = new QAction(this);
_action_realtime = new QAction(this);
_mode_menu = new QMenu(this);
_mode_menu->addAction(_action_single);
_mode_menu->addAction(_action_repeat);
_mode_menu->addAction(_action_realtime);
_mode_button.setMenu(_mode_menu);
_mode_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
@@ -128,6 +129,7 @@ namespace pv
connect(&_sample_count, SIGNAL(currentIndexChanged(int)), this, SLOT(on_samplecount_sel(int)));
connect(_action_single, SIGNAL(triggered()), this, SLOT(on_mode()));
connect(_action_repeat, SIGNAL(triggered()), this, SLOT(on_mode()));
connect(_action_realtime, SIGNAL(triggered()), this, SLOT(on_mode()));
connect(&_sample_rate, SIGNAL(currentIndexChanged(int)), this, SLOT(on_samplerate_sel(int)));
}
@@ -202,6 +204,7 @@ namespace pv
_action_single->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_SINGLE_ACTION), "&Single"));
_action_repeat->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_REPEAT_ACTION), "&Repetitive"));
_action_realtime->setText(L_S(STR_PAGE_TOOLBAR, S_ID(IDS_TOOLBAR_REALTIME_ACTION), "Real&time"));
}
void SamplingBar::reStyle()
@@ -242,6 +245,7 @@ namespace pv
_instant_button.setIcon(QIcon(iconPath + "/single.svg"));
_action_single->setIcon(QIcon(iconPath + "/oneloop.svg"));
_action_repeat->setIcon(QIcon(iconPath + "/repeat.svg"));
_action_realtime->setIcon(QIcon(iconPath + "/update.svg"));
}
}
@@ -444,9 +448,7 @@ namespace pv
{
for (int i = _sample_rate.count() - 1; i >= 0; i--)
{
if (samplerate >= _sample_rate.itemData(
i)
.value<uint64_t>())
if (samplerate >= _sample_rate.itemData(i).value<uint64_t>())
{
_sample_rate.setCurrentIndex(i);
break;
@@ -687,9 +689,7 @@ namespace pv
{
for (int i = 0; i < _sample_count.count(); i++)
{
if (duration >= _sample_count.itemData(
i)
.value<double>())
if (duration >= _sample_count.itemData(i).value<double>())
{
_sample_count.setCurrentIndex(i);
break;
@@ -1062,7 +1062,7 @@ namespace pv
if (act == _action_single)
{
_mode_button.setIcon(QIcon(iconPath + "/modes.svg"));
_session->set_repeat_mode(false);
_session->set_operation_mode(OPT_SINGLE);
}
else if (act == _action_repeat)
{
@@ -1075,9 +1075,14 @@ namespace pv
if (interval_dlg.is_done())
{
_session->set_repeat_intvl(interval_dlg.get_interval());
_session->set_repeat_mode(true);
_session->set_operation_mode(OPT_REPEAT);
}
}
else if (act == _action_realtime)
{
_mode_button.setIcon(QIcon(iconPath + "/update.svg"));
_session->set_operation_mode(OPT_REALTIME);
}
}
void SamplingBar::update_device_list()

View File

@@ -138,6 +138,7 @@ namespace pv
QMenu *_mode_menu;
QAction *_action_repeat;
QAction *_action_single;
QAction *_action_realtime;
DeviceAgent *_device_agent;
ds_device_handle _last_device_handle;

View File

@@ -161,7 +161,7 @@ void LangResource::load_page(Lang_resource_page &p, QString file)
if (raw_bytes.length() == 0)
return;
dsv_info("Load lang resouce file: %s", file.toLocal8Bit().data());
//dsv_info("Load lang resouce file: %s", file.toLocal8Bit().data());
QJsonParseError error;
QString jsonStr(raw_bytes.data());

View File

@@ -258,7 +258,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QColo
uint64_t end_sample = (uint64_t)max((right + pixels_offset) *
samples_per_pixel, 0.0);
for(auto &dec : _decoder_stack->stack()) {
for(auto dec : _decoder_stack->stack()) {
start_sample = max(dec->decode_start(), start_sample);
end_sample = min(dec->decode_end(), end_sample);
break;
@@ -275,7 +275,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QColo
assert(_decoder_stack);
for(auto &dec :_decoder_stack->stack()) {
for(auto dec :_decoder_stack->stack()) {
if (dec->shown()) {
const std::map<const pv::data::decode::Row, bool> rows = _decoder_stack->get_rows_gshow();
for (std::map<const pv::data::decode::Row, bool>::const_iterator i = rows.begin();
@@ -369,15 +369,17 @@ void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a,
p.drawPoints(triangle, 9);
}
if (a.start_sample() == a.end_sample())
if (a.start_sample() == a.end_sample()){
draw_instant(a, p, fill, outline, text_color, h,
start, y, min_annWidth);
}
else {
draw_range(a, p, fill, outline, text_color, h,
start, end, y, fore, back);
if ((a.type()/100 == 2) && (end - start > 20)) {
for(auto &dec : _decoder_stack->stack()) {
for (auto& iter: dec->channels()) {
for(auto dec : _decoder_stack->stack()) {
for (auto& iter : dec->channels()) {
int type = dec->get_channel_type(iter.first);
if ((type == SRD_CHANNEL_COMMON) ||
((type%100 != a.type()%100) && (type%100 != 0)))
@@ -385,9 +387,9 @@ void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a,
LogicSignal *logic_sig = NULL;
for(auto &sig : _session->get_signals()) {
if((sig->get_index() == iter.second) &&
(logic_sig = dynamic_cast<view::LogicSignal*>(sig))) {
for(auto s : _session->get_signals()) {
if((s->get_index() == iter.second) &&
(logic_sig = dynamic_cast<view::LogicSignal*>(s))) {
logic_sig->paint_mark(p, start, end, type/100);
break;
}
@@ -495,7 +497,7 @@ void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p,
QString best_annotation;
int best_width = 0;
for(auto &&a : annotations) {
for(auto &a : annotations) {
const int w = p.boundingRect(QRectF(), 0, a).width();
if (w <= rect.width() && w > best_width)
best_annotation = a, best_width = w;
@@ -588,11 +590,10 @@ void DecodeTrace::on_decode_done()
int DecodeTrace::rows_size()
{
using pv::data::decode::Decoder;
int size = 0;
for(auto &dec : _decoder_stack->stack()) {
if (dec->shown()) {
for(auto dec : _decoder_stack->stack()) {
if (dec->shown()) {
auto rows = _decoder_stack->get_rows_gshow();
for (auto i = rows.begin(); i != rows.end(); i++) {
@@ -602,7 +603,8 @@ int DecodeTrace::rows_size()
(*i).second)
size++;
}
} else {
}
else {
size++;
}
}
@@ -663,7 +665,7 @@ void DecodeTrace::frame_ended()
_decode_cursor2 = 0;
}
for(auto &dec : _decoder_stack->stack()) {
for(auto dec : _decoder_stack->stack()) {
dec->set_decode_region(_decode_start, _decode_end);
dec->commit();
}
@@ -685,7 +687,7 @@ bool DecodeTrace::create_popup(bool isnew)
if (QDialog::Accepted == dlg.exec())
{
for(auto &dec : _decoder_stack->stack())
for(auto dec : _decoder_stack->stack())
{
if (dec->commit() || _decoder_stack->options_changed()) {
_decoder_stack->set_options_changed(true);

View File

@@ -204,7 +204,7 @@ void DevMode::on_mode_change()
}
_session->stop_capture();
_session->set_repeat_mode(false);
_session->set_operation_mode(OPT_SINGLE);
_session->session_save();
_session->switch_work_mode(mode);

View File

@@ -104,10 +104,8 @@ pv::view::Trace* Header::get_mTrace(int &action, const QPoint &pt)
std::vector<Trace*> traces;
_view.get_traces(ALL_VIEW, traces);
for(auto &t : traces)
for(auto t : traces)
{
assert(t);
if ((action = t->pt_in_rect(t->get_y(), w, pt)))
return t;
}
@@ -132,9 +130,8 @@ void Header::paintEvent(QPaintEvent*)
QColor fore(QWidget::palette().color(QWidget::foregroundRole()));
fore.setAlpha(View::ForeAlpha);
for(auto &t : traces)
for(auto t : traces)
{
assert(t);
t->paint_label(painter, w, dragging ? QPoint(-1, -1) : _mouse_point, fore);
}
@@ -153,15 +150,17 @@ void Header::mouseDoubleClickEvent(QMouseEvent *event)
_mouse_down_point = event->pos();
// Save the offsets of any Traces which will be dragged
for(auto &t : traces)
for(auto t : traces){
if (t->selected())
_drag_traces.push_back(
make_pair(t, t->get_v_offset()));
}
// Select the Trace if it has been clicked
for(auto &t : traces)
for(auto t : traces){
if (t->mouse_double_click(width(), event->pos()))
break;
}
}
}
@@ -183,10 +182,11 @@ void Header::mousePressEvent(QMouseEvent *event)
_mouse_down_point = event->pos();
// Save the offsets of any Traces which will be dragged
for(auto &t : traces)
for(auto t : traces){
if (t->selected())
_drag_traces.push_back(
make_pair(t, t->get_v_offset()));
}
// Select the Trace if it has been clicked
const auto mTrace = get_mTrace(action, event->pos());
@@ -203,16 +203,18 @@ void Header::mousePressEvent(QMouseEvent *event)
mTrace->set_old_v_offset(mTrace->get_v_offset());
}
for(auto &t : traces)
for(auto t : traces){
if (t->mouse_press(width(), event->pos()))
break;
}
if (~QApplication::keyboardModifiers() & Qt::ControlModifier) {
// Unselect all other Traces because the Ctrl is not
// pressed
for(auto &t : traces)
for(auto t : traces){
if (t != mTrace)
t->select(false);
}
}
update();
}
@@ -244,7 +246,7 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
std::vector<Trace*> traces;
_view.get_traces(ALL_VIEW, traces);
for(auto &t : traces){
for(auto t : traces){
t->select(false);
}
}

View File

@@ -80,10 +80,8 @@ SpectrumTrace::SpectrumTrace(pv::SigSession *session,
_offset(0)
{
_typeWidth = 0;
const auto &sigs = _session->get_signals();
for(size_t i = 0; i < sigs.size(); i++) {
const auto s = sigs[i];
assert(s);
for(auto s : _session->get_signals()) {
if (dynamic_cast<DsoSignal*>(s) && index == s->get_index())
_colour = s->get_colour();
}
@@ -305,7 +303,7 @@ void SpectrumTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QCo
double vdiv = 0;
double vfactor = 0;
for(auto &s : _session->get_signals()) {
for(auto s : _session->get_signals()) {
DsoSignal *dsoSig = NULL;
if ((dsoSig = dynamic_cast<DsoSignal*>(s))) {
if(dsoSig->get_index() == _spectrum_stack->get_index()) {

View File

@@ -358,11 +358,7 @@ void View::set_scale_offset(double scale, int64_t offset)
}
void View::set_preScale_preOffset()
{
//assert(_preScale <= _maxscale);
//assert(_preScale >= _minscale);
//assert(_preOffset >= 0);
{
set_scale_offset(_preScale, _preOffset);
}
@@ -377,35 +373,37 @@ void View::get_traces(int type, std::vector<Trace*> &traces)
const auto &spectrums = _session->get_spectrum_traces();
for(auto &t : sigs) {
for(auto t : sigs) {
if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type)
traces.push_back(t);
}
for(auto &t : decode_sigs) {
for(auto t : decode_sigs) {
if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type)
traces.push_back(t);
}
for(auto &t : groups) {
for(auto t : groups) {
if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type)
traces.push_back(t);
}
for(auto &t : spectrums) {
for(auto t : spectrums) {
if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type)
traces.push_back(t);
}
auto lissajous = _session->get_lissajous_trace();
if (lissajous && lissajous->enabled() &&
(type == ALL_VIEW || _trace_view_map[lissajous->get_type()] == type))
(type == ALL_VIEW || _trace_view_map[lissajous->get_type()] == type)){
traces.push_back(lissajous);
}
auto math = _session->get_math_trace();
if (math && math->enabled() &&
(type == ALL_VIEW || _trace_view_map[math->get_type()] == type))
(type == ALL_VIEW || _trace_view_map[math->get_type()] == type)){
traces.push_back(math);
}
stable_sort(traces.begin(), traces.end(), compare_trace_v_offsets);
}
@@ -540,8 +538,7 @@ void View::set_trig_pos(int percent)
}
void View::set_search_pos(uint64_t search_pos, bool hit)
{
//assert(search_pos >= 0);
{
QColor fore(QWidget::palette().color(QWidget::foregroundRole()));
fore.setAlpha(View::BackAlpha);
@@ -575,17 +572,17 @@ const QPoint& View::hover_point()
void View::normalize_layout()
{
int v_min = INT_MAX;
std::vector<Trace*> traces;
get_traces(ALL_VIEW, traces);
int v_min = INT_MAX;
for(auto &t : traces){
for(auto t : traces){
v_min = min(t->get_v_offset(), v_min);
}
const int delta = -min(v_min, 0);
for(auto &t : traces){
for(auto t : traces){
t->set_v_offset(t->get_v_offset() + delta);
}
@@ -593,7 +590,6 @@ void View::normalize_layout()
v_scroll_value_changed(verticalScrollBar()->sliderPosition());
}
int View::get_spanY()
{
return _spanY;
@@ -684,11 +680,11 @@ void View::signals_changed()
uint8_t max_height = MaxHeightUnit;
std::vector<Trace*> time_traces;
std::vector<Trace*> fft_traces;
std::vector<Trace*> traces;
get_traces(ALL_VIEW, traces);
for(auto &t : traces) {
for(auto t : traces) {
if (_trace_view_map[t->get_type()] == TIME_VIEW)
time_traces.push_back(t);
else if (_trace_view_map[t->get_type()] == FFT_VIEW)
@@ -703,13 +699,14 @@ void View::signals_changed()
_viewport_list.push_back(_fft_viewport);
_vsplitter->refresh();
}
for(auto &t : fft_traces) {
for(auto t : fft_traces) {
t->set_view(this);
t->set_viewport(_fft_viewport);
t->set_totalHeight(_fft_viewport->height());
t->set_v_offset(_fft_viewport->geometry().bottom());
}
} else {
}
else {
_fft_viewport->setVisible(false);
_vsplitter->refresh();
@@ -724,8 +721,7 @@ void View::signals_changed()
}
if (!time_traces.empty() && _time_viewport) {
for(auto &t : time_traces) {
assert(t);
for(auto t : time_traces) {
if (dynamic_cast<DsoSignal*>(t) ||
t->enabled())
total_rows += t->rows_size();
@@ -768,7 +764,7 @@ void View::signals_changed()
_spanY = _signalHeight + 2 * actualMargin;
int next_v_offset = actualMargin;
for(auto &t : time_traces) {
for(auto t : time_traces) {
t->set_view(this);
t->set_viewport(_time_viewport);
if (t->rows_size() == 0)
@@ -851,9 +847,9 @@ int View::headerWidth()
get_traces(ALL_VIEW, traces);
if (!traces.empty()) {
for(auto &t : traces)
headerWidth = max(t->get_name_width() + t->get_leftWidth() + t->get_rightWidth(),
headerWidth);
for(auto t : traces){
headerWidth = max(t->get_name_width() + t->get_leftWidth() + t->get_rightWidth(), headerWidth);
}
}
setViewportMargins(headerWidth, RulerHeight, 0, 0);
@@ -1102,8 +1098,8 @@ QRect View::get_view_rect()
{
if (_device_agent->get_work_mode() == DSO) {
const auto &sigs = _session->get_signals();
for(auto &s : sigs) {
return s->get_view_rect();
if(sigs.size() > 0) {
return sigs[0]->get_view_rect();
}
}
@@ -1114,11 +1110,11 @@ int View::get_view_width()
{
int view_width = 0;
if (_device_agent->get_work_mode() == DSO) {
const auto &sigs = _session->get_signals();
for(auto &s : sigs) {
for(auto s : _session->get_signals()) {
view_width = max(view_width, s->get_view_rect().width());
}
} else {
}
else {
view_width = _viewcenter->width();
}
@@ -1129,11 +1125,11 @@ int View::get_view_height()
{
int view_height = 0;
if (_device_agent->get_work_mode() == DSO) {
const auto &sigs = _session->get_signals();
for(auto &s : sigs) {
for(auto s : _session->get_signals()) {
view_height = max(view_height, s->get_view_rect().height());
}
} else {
}
else {
view_height = _viewcenter->height();
}

View File

@@ -88,8 +88,8 @@ Viewport::Viewport(View &parent, View_type type) :
_mm_duty = View::Unknown_Str;
_measure_en = true;
_edge_hit = false;
transfer_started = false;
timer_cnt = 0;
_transfer_started = false;
_timer_cnt = 0;
_clickX = 0;
_sample_received = 0;
@@ -103,7 +103,7 @@ Viewport::Viewport(View &parent, View_type type) :
setContextMenuPolicy(Qt::CustomContextMenu);
connect(&trigger_timer, SIGNAL(timeout()),this, SLOT(on_trigger_timer()));
connect(&_trigger_timer, SIGNAL(timeout()),this, SLOT(on_trigger_timer()));
connect(&_drag_timer, SIGNAL(timeout()),this, SLOT(on_drag_timer()));
connect(yAction, SIGNAL(triggered(bool)), this, SLOT(add_cursor_y()));
@@ -117,8 +117,7 @@ int Viewport::get_total_height()
std::vector<Trace*> traces;
_view.get_traces(_type, traces);
for(auto &t : traces) {
assert(t);
for(auto t : traces) {
h += (int)(t->get_totalHeight());
}
h += 2 * View::SignalMargin;
@@ -154,13 +153,11 @@ void Viewport::paintEvent(QPaintEvent *event)
QColor back(QWidget::palette().color(QWidget::backgroundRole()));
fore.setAlpha(View::ForeAlpha);
_view.set_back(false);
std::vector<Trace*> traces;
_view.get_traces(_type, traces);
for(auto &t : traces)
{
assert(t);
for(auto t : traces){
t->paint_back(p, 0, _view.get_view_width(), fore, back);
if (_view.back_ready())
break;
@@ -169,11 +166,12 @@ void Viewport::paintEvent(QPaintEvent *event)
if (_view.session().get_device()->get_work_mode() == LOGIC ||
_view.session().is_instant())
{
if (_view.session().is_stopped_status()){
if (_view.session().is_stopped_status())// || _view.session().is_realtime_mode()){
{
paintSignals(p, fore, back);
}
else if (_view.session().is_running_status()){
if (_view.session().is_repeat_mode() && !transfer_started) {
if (_view.session().is_repeat_mode() && !_transfer_started) {
_view.set_capture_status();
paintSignals(p, fore, back);
}
@@ -187,9 +185,7 @@ void Viewport::paintEvent(QPaintEvent *event)
paintSignals(p, fore, back);
}
for(auto &t : traces)
{
assert(t);
for(auto t : traces){
if (t->enabled())
t->paint_fore(p, 0, _view.get_view_width(), fore, back);
}
@@ -209,8 +205,6 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
for(auto t : traces)
{
assert(t);
if (t->enabled())
t->paint_mid(p, 0, t->get_view_rect().right(), fore, back);
}
@@ -224,21 +218,19 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
_curOffset = _view.offset();
_curSignalHeight = _view.get_signalHeight();
pixmap = QPixmap(size());
pixmap.fill(Qt::transparent);
_pixmap = QPixmap(size());
_pixmap.fill(Qt::transparent);
QPainter dbp(&pixmap);
QPainter dbp(&_pixmap);
for(auto t : traces)
{
assert(t);
if (t->enabled())
t->paint_mid(dbp, 0, t->get_view_rect().right(), fore, back);
}
_need_update = false;
}
p.drawPixmap(0, 0, pixmap);
p.drawPixmap(0, 0, _pixmap);
}
// plot cursors
@@ -429,7 +421,7 @@ void Viewport::paintProgress(QPainter &p, QColor fore, QColor back)
p.drawEllipse(logoPoints[19].x() - 0.5 * logoRadius, logoPoints[19].y() - logoRadius,
logoRadius, logoRadius);
if (!transfer_started) {
if (!_transfer_started) {
const int width = _view.get_view_width();
const QPoint cenLeftPos = QPoint(width / 2 - 0.05 * width, height() / 2);
const QPoint cenRightPos = QPoint(width / 2 + 0.05 * width, height() / 2);
@@ -438,11 +430,11 @@ void Viewport::paintProgress(QPainter &p, QColor fore, QColor back)
QColor foreBack = fore;
foreBack.setAlpha(View::BackAlpha);
p.setPen(Qt::NoPen);
p.setBrush((timer_cnt % 3) == 0 ? fore : foreBack);
p.setBrush((_timer_cnt % 3) == 0 ? fore : foreBack);
p.drawEllipse(cenLeftPos, trigger_radius, trigger_radius);
p.setBrush((timer_cnt % 3) == 1 ? fore : foreBack);
p.setBrush((_timer_cnt % 3) == 1 ? fore : foreBack);
p.drawEllipse(cenPos, trigger_radius, trigger_radius);
p.setBrush((timer_cnt % 3) == 2 ? fore : foreBack);
p.setBrush((_timer_cnt % 3) == 2 ? fore : foreBack);
p.drawEllipse(cenRightPos, trigger_radius, trigger_radius);
bool triggered;
@@ -520,10 +512,8 @@ void Viewport::mousePressEvent(QMouseEvent *event)
event->button() == Qt::LeftButton &&
_view.session().get_device()->get_work_mode() == DSO) {
const auto &sigs = _view.session().get_signals();
for(auto &s : sigs) {
assert(s);
for(auto s : _view.session().get_signals())
{
if (!s->enabled())
continue;
DsoSignal *dsoSig = NULL;
@@ -638,9 +628,9 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
_mouse_down_offset + (_mouse_down_point - event->pos()).x());
}
_drag_strength = (_mouse_down_point - event->pos()).x();
} else if (_type == FFT_VIEW) {
for(auto &t: _view.session().get_spectrum_traces()) {
assert(t);
}
else if (_type == FFT_VIEW) {
for(auto t: _view.session().get_spectrum_traces()) {
if(t->enabled()) {
double delta = (_mouse_point - event->pos()).x();
t->set_offset(delta);
@@ -662,16 +652,15 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
}
}
}
if (_action_type == CURS_MOVE) {
TimeMarker* grabbed_marker = _view.get_ruler()->get_grabbed_cursor();
if (grabbed_marker) {
int curX = _view.hover_point().x();
uint64_t index0 = 0, index1 = 0, index2 = 0;
bool logic = false;
const auto &sigs = _view.session().get_signals();
for(auto &s: sigs) {
assert(s);
for(auto s : _view.session().get_signals()) {
view::LogicSignal *logicSig = NULL;
view::DsoSignal *dsoSig = NULL;
if ((_view.session().get_device()->get_work_mode() == LOGIC) &&
@@ -733,8 +722,7 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
}
if (!(event->buttons() | Qt::NoButton)) {
if (_action_type == DSO_XM_STEP1 || _action_type == DSO_XM_STEP2) {
for(auto &s : _view.session().get_signals()) {
assert(s);
for(auto s : _view.session().get_signals()) {
if (!s->get_view_rect().contains(event->pos())) {
clear_dso_xm();
}
@@ -806,8 +794,7 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
if (_mouse_down_point.x() == event->pos().x()) {
const auto &sigs = _view.session().get_signals();
for(auto &s : sigs) {
assert(s);
for(auto s : sigs) {
view::LogicSignal *logicSig = NULL;
if ((logicSig = dynamic_cast<view::LogicSignal*>(s))) {
if (logicSig->edge(event->pos(), _edge_start, 10)) {
@@ -830,8 +817,7 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
if (_mouse_down_point.x() == event->pos().x()) {
const auto &sigs = _view.session().get_signals();
for(auto &s : sigs) {
assert(s);
for(auto s : sigs) {
if (abs(event->pos().y() - s->get_y()) < _view.get_signalHeight()) {
_action_type = LOGIC_EDGE;
_edge_start = _view.pixel2index(event->pos().x());
@@ -868,7 +854,7 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
std::vector<Trace*> traces;
_view.get_traces(ALL_VIEW, traces);
for(auto &t : traces){
for(auto t : traces){
t->select(false);
}
}
@@ -988,9 +974,7 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event)
uint64_t index;
uint64_t index0 = 0, index1 = 0, index2 = 0;
if (_view.session().get_device()->get_work_mode() == LOGIC) {
const auto &sigs = _view.session().get_signals();
for(auto &s : sigs) {
assert(s);
for(auto s : _view.session().get_signals()) {
view::LogicSignal *logicSig = NULL;
if ((logicSig = dynamic_cast<view::LogicSignal*>(s))) {
if (logicSig->measure(event->pos(), index0, index1, index2)) {
@@ -1024,8 +1008,7 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event)
measure_updated();
}
else if (_action_type == NO_ACTION) {
for(auto &s : _view.session().get_signals()) {
assert(s);
for(auto s : _view.session().get_signals()) {
if (s->get_view_rect().contains(event->pos())) {
_dso_xm_index[0] = _view.pixel2index(event->pos().x());
_dso_xm_y = event->pos().y();
@@ -1232,10 +1215,8 @@ void Viewport::measure()
_measure_type = NO_MEASURE;
if (_type == TIME_VIEW) {
const uint64_t sample_rate = _view.session().cur_snap_samplerate();
const auto &sigs = _view.session().get_signals();
for(auto &s : sigs) {
assert(s);
for(auto s : _view.session().get_signals()) {
view::LogicSignal *logicSig = NULL;
view::DsoSignal *dsoSig = NULL;
view::AnalogSignal *analogSig = NULL;
@@ -1316,9 +1297,9 @@ void Viewport::measure()
_measure_type = NO_MEASURE;
}
}
} else if (_type == FFT_VIEW) {
for(auto &t : _view.session().get_spectrum_traces()) {
assert(t);
}
else if (_type == FFT_VIEW) {
for(auto t : _view.session().get_spectrum_traces()) {
if(t->enabled()) {
t->measure(_mouse_point);
}
@@ -1388,11 +1369,10 @@ void Viewport::paintMeasure(QPainter &p, QColor fore, QColor back)
}
}
const auto &sigs = _view.session().get_signals();
if (_action_type == NO_ACTION &&
_measure_type == DSO_VALUE) {
for(auto &s : sigs) {
for(auto s : _view.session().get_signals()) {
view::DsoSignal *dsoSig = NULL;
view::AnalogSignal* analogSig = NULL;
@@ -1421,7 +1401,7 @@ void Viewport::paintMeasure(QPainter &p, QColor fore, QColor back)
}
if (_dso_ym_valid) {
for(auto &s : sigs) {
for(auto s : _view.session().get_signals()) {
view::DsoSignal *dsoSig = NULL;
if ((dsoSig = dynamic_cast<view::DsoSignal*>(s))) {
if (dsoSig->get_index() == _dso_ym_sig_index) {
@@ -1673,21 +1653,21 @@ void Viewport::set_measure_en(int enable)
void Viewport::start_trigger_timer(int msec)
{
assert(msec > 0);
transfer_started = false;
timer_cnt = 0;
trigger_timer.start(msec);
_transfer_started = false;
_timer_cnt = 0;
_trigger_timer.start(msec);
}
void Viewport::stop_trigger_timer()
{
transfer_started = true;
timer_cnt = 0;
trigger_timer.stop();
_transfer_started = true;
_timer_cnt = 0;
_trigger_timer.stop();
}
void Viewport::on_trigger_timer()
{
timer_cnt++;
_timer_cnt++;
update();
}

View File

@@ -90,22 +90,15 @@ public:
explicit Viewport(View &parent, View_type type);
int get_total_height();
QPoint get_mouse_point();
QString get_measure(QString option);
void set_measure_en(int enable);
void start_trigger_timer(int msec);
void stop_trigger_timer();
void clear_measure();
void clear_dso_xm();
void set_need_update(bool update);
bool get_dso_trig_moved();
protected:
@@ -146,82 +139,75 @@ signals:
void prgRate(int progress);
private:
View &_view;
View_type _type;
bool _need_update;
View &_view;
View_type _type;
bool _need_update;
QPixmap _pixmap;
QMenu *_cmenu;
QPixmap pixmap;
QMenu *_cmenu;
uint64_t _sample_received;
QPoint _mouse_point;
QPoint _mouse_down_point;
int64_t _mouse_down_offset;
double _curScale;
int64_t _curOffset;
int _curSignalHeight;
uint64_t _sample_received;
QPoint _mouse_point;
QPoint _mouse_down_point;
int64_t _mouse_down_offset;
double _curScale;
int64_t _curOffset;
int _curSignalHeight;
//QPixmap pixmap;
bool _measure_en;
ActionType _action_type;
bool _measure_en;
ActionType _action_type;
MeasureType _measure_type;
uint64_t _cur_sample;
uint64_t _nxt_sample;
uint64_t _thd_sample;
int64_t _cur_preX;
int64_t _cur_aftX;
int64_t _cur_thdX;
int _cur_midY;
int _cur_preY;
int _cur_preY_top;
int _cur_preY_bottom;
int _cur_aftY;
bool _edge_hit;
QString _mm_width;
QString _mm_period;
QString _mm_freq;
QString _mm_duty;
uint64_t _cur_sample;
uint64_t _nxt_sample;
uint64_t _thd_sample;
int64_t _cur_preX;
int64_t _cur_aftX;
int64_t _cur_thdX;
int _cur_midY;
int _cur_preY;
int _cur_preY_top;
int _cur_preY_bottom;
int _cur_aftY;
bool _edge_hit;
QString _mm_width;
QString _mm_period;
QString _mm_freq;
QString _mm_duty;
uint64_t _edge_rising;
uint64_t _edge_falling;
uint64_t _edge_start;
uint64_t _edge_end;
QString _em_rising;
QString _em_falling;
QString _em_edges;
uint64_t _edge_rising;
uint64_t _edge_falling;
uint64_t _edge_start;
uint64_t _edge_end;
QString _em_rising;
QString _em_falling;
QString _em_edges;
QTimer trigger_timer;
bool transfer_started;
int timer_cnt;
QTimer _trigger_timer;
bool _transfer_started;
int _timer_cnt;
Signal *_drag_sig;
uint64_t _hover_index;
bool _hover_hit;
uint16_t _hover_sig_index;
double _hover_sig_value;
Signal *_drag_sig;
QElapsedTimer _elapsed_time;
QTimer _drag_timer;
int _drag_strength;
bool _dso_xm_valid;
int _dso_xm_y;
uint64_t _dso_xm_index[DsoMeasureStages];
uint64_t _hover_index;
bool _hover_hit;
uint16_t _hover_sig_index;
double _hover_sig_value;
QElapsedTimer _elapsed_time;
QTimer _drag_timer;
int _drag_strength;
bool _dso_xm_valid;
int _dso_xm_y;
uint64_t _dso_xm_index[DsoMeasureStages];
bool _dso_ym_valid;
uint16_t _dso_ym_sig_index;
double _dso_ym_sig_value;
uint64_t _dso_ym_index;
int _dso_ym_start;
int _dso_ym_end;
int _waiting_trig;
bool _dso_trig_moved;
bool _curs_moved;
bool _xcurs_moved;
int _clickX;
bool _dso_ym_valid;
uint16_t _dso_ym_sig_index;
double _dso_ym_sig_value;
uint64_t _dso_ym_index;
int _dso_ym_start;
int _dso_ym_end;
int _waiting_trig;
bool _dso_trig_moved;
bool _curs_moved;
bool _xcurs_moved;
int _clickX;
};
} // namespace view

View File

@@ -84,10 +84,8 @@ void ViewStatus::paintEvent(QPaintEvent *)
for(size_t i = 0; i < _mrects.size(); i++) {
int sig_index = std::get<1>(_mrects[i]);
view::DsoSignal *dsoSig = NULL;
const auto &sigs = _session->get_signals();
for(auto &s : sigs) {
assert(s);
for(auto s : _session->get_signals()) {
if (!s->enabled())
continue;
if ((dsoSig = dynamic_cast<DsoSignal*>(s))) {

View File

@@ -43,9 +43,8 @@ XCursor::XCursor(View &view, QColor &colour,
_colour(colour)
{
_dsoSig = NULL;
const auto &sigs = _view.session().get_signals();
for(auto &s : sigs) {
for(auto s : _view.session().get_signals()) {
DsoSignal *dsoSig = NULL;
if ((dsoSig = dynamic_cast<DsoSignal*>(s)))
if (dsoSig->enabled()) {

View File

@@ -57,26 +57,17 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack,
_layout->setContentsMargins(0, 0, 0, 0);
_layout->setVerticalSpacing(2);
//setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
//setWidgetResizable(true);
QString iconPath = GetIconPath();
_layout->addWidget(new QLabel(QString("<h3 style='font-style:italic'>%1</h3>").arg(_dec->decoder()->name), _widget),
//_layout->addWidget(new QLabel(QString("<span style='text-decoration:underline'>%1</span>").arg(_dec->decoder()->name), _widget),
0, 0);
_layout->setColumnStretch(0, 1);
const srd_decoder *const d = _dec->decoder();
assert(d);
const bool have_probes = (d->channels || d->opt_channels) != 0;
if (!have_probes) {
// _del_button = new QPushButton(QIcon(iconPath+"/del.svg"), QString(), _widget);
// _layout->addWidget(_del_button, 0, 1);
//connect(_del_button, SIGNAL(clicked()), this, SLOT(on_del_stack()));
}
_index = 0;
for(auto &dec : _decoder_stack->stack()) {
for(auto dec : _decoder_stack->stack()) {
if (dec == _dec)
break;
_index++;
@@ -167,7 +158,7 @@ void DecoderGroupBox::tog_icon()
void DecoderGroupBox::on_del_stack()
{
int i = _index;
for(auto &dec : _decoder_stack->stack()) {
for(auto dec : _decoder_stack->stack()) {
if (i-- == 0) {
del_stack(dec);
break;

View File

@@ -288,8 +288,8 @@
"text": "搜索选项"
},
{
"id": "IDS_DLG_CHANGE",
"text": "变"
"id": "IDS_DLG_CHANGE_FILE",
"text": "变"
},
{
"id": "IDS_DLG_SAVING",
@@ -303,10 +303,14 @@
"id": "IDS_DLG_COMPRESSED_DATA",
"text": "压缩数据"
},
{
"id": "IDS_DLG_EXPORT",
"text": "导出"
},
{
"id": "IDS_DLG_EXPORTING",
"text": "导出中..."
},
},
{
"id": "IDS_DLG_DONT_CONNECT_PROBES",
"text": "不要连接任何探头!"

View File

@@ -39,6 +39,10 @@
"id": "IDS_TOOLBAR_REPEAT_ACTION",
"text": "重复(&R)"
},
{
"id": "IDS_TOOLBAR_REALTIME_ACTION",
"text": "实时(&T)"
},
{
"id": "IDS_TOOLBAR_TRIGGER",
"text": "触发"

View File

@@ -288,7 +288,7 @@
"text": "Search Options"
},
{
"id": "IDS_DLG_CHANGE",
"id": "IDS_DLG_CHANGE_FILE",
"text": "change"
},
{
@@ -303,6 +303,10 @@
"id": "IDS_DLG_COMPRESSED_DATA",
"text": "Compressed data"
},
{
"id": "IDS_DLG_EXPORT",
"text": "Export"
},
{
"id": "IDS_DLG_EXPORTING",
"text": "Exporting..."

View File

@@ -39,6 +39,10 @@
"id": "IDS_TOOLBAR_REPEAT_ACTION",
"text": "&Repetitive"
},
{
"id": "IDS_TOOLBAR_REALTIME_ACTION",
"text": "Real&time"
},
{
"id": "IDS_TOOLBAR_TRIGGER",
"text": "Trigger"