From a760ddbefd0c3a58a0d9bf9b1fbc87008cbaae24 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 5 Jun 2023 15:57:45 +0800 Subject: [PATCH 1/4] fix: On loop mode, it have not free unused memory in time --- DSView/pv/data/logicsnapshot.cpp | 57 +++++++++++++++----------------- DSView/pv/data/logicsnapshot.h | 1 + 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/DSView/pv/data/logicsnapshot.cpp b/DSView/pv/data/logicsnapshot.cpp index 13894581..48069f09 100644 --- a/DSView/pv/data/logicsnapshot.cpp +++ b/DSView/pv/data/logicsnapshot.cpp @@ -117,6 +117,7 @@ void LogicSnapshot::first_payload(const sr_datafeed_logic &logic, uint64_t total bool channel_changed = false; uint16_t channel_num = 0; _able_free = able_free; + _lst_free_block_index = 0; for(void *p : _free_block_list){ free(p); @@ -231,10 +232,20 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic) return; _sample_count = _total_sample_count; } - - if (_is_loop && (_loop_offset + samples >= LeafBlockSamples * Scale)){ - move_first_node_to_last(); - _loop_offset -= LeafBlockSamples * Scale; + + if (_is_loop) + { + if (_loop_offset + samples >= LeafBlockSamples * Scale){ + move_first_node_to_last(); + _loop_offset -= LeafBlockSamples * Scale; + _lst_free_block_index = 0; + } + else{ + int free_count = _loop_offset / LeafBlockSamples; + if (free_count > _lst_free_block_index){ + free_head_blocks(free_count); + } + } } _ring_sample_count += _loop_offset; @@ -937,6 +948,8 @@ bool LogicSnapshot::block_pre_edge(uint64_t *lbp, uint64_t &index, bool last_sam const uint64_t last = last_sample ? ~0ULL : 0ULL; uint64_t block_start = index & ~LeafMask; + assert(lbp); + //----- Search Next Edge Within Current LeafBlock -----// if (level == 0) { @@ -1262,38 +1275,22 @@ void LogicSnapshot::free_decode_lpb(void *lbp) } void LogicSnapshot::free_head_blocks(int count) -{ - for (unsigned int i = 0; i < _channel_num; i++) - { - for (int j=0; j 0); + + for (int i = 0; i < (int)_channel_num; i++) + { + for (int j=_lst_free_block_index; j> count) << count; + _ch_data[i][0].value = (_ch_data[i][0].value >> count) << count; + } } + _lst_free_block_index = count; } } // namespace data diff --git a/DSView/pv/data/logicsnapshot.h b/DSView/pv/data/logicsnapshot.h index 940b5c10..859015e2 100644 --- a/DSView/pv/data/logicsnapshot.h +++ b/DSView/pv/data/logicsnapshot.h @@ -237,6 +237,7 @@ private: bool _able_free; std::vector _free_block_list; struct BlockIndex _cur_ref_block_indexs[CHANNEL_MAX_COUNT]; + int _lst_free_block_index; friend class LogicSnapshotTest::Pow2; friend class LogicSnapshotTest::Basic; From 189793e1bb205e0921c10dc21f4a23b17cc8997a Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 5 Jun 2023 17:05:25 +0800 Subject: [PATCH 2/4] fix: On decoder options dialog, to translate the label, click cancel, the decoder be created --- DSView/pv/dialogs/decoderoptionsdlg.cpp | 19 ++++++++++++++++--- DSView/pv/view/decodetrace.cpp | 6 +++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/DSView/pv/dialogs/decoderoptionsdlg.cpp b/DSView/pv/dialogs/decoderoptionsdlg.cpp index e195d445..d529eecb 100644 --- a/DSView/pv/dialogs/decoderoptionsdlg.cpp +++ b/DSView/pv/dialogs/decoderoptionsdlg.cpp @@ -171,13 +171,26 @@ void DecoderOptionsDlg::load_options_view() bool bLang = AppConfig::Instance()._appOptions.transDecoderDlg; if (LangResource::Instance()->is_lang_en() == false){ + QWidget *sp1 = new QWidget(); + sp1->setFixedHeight(5); + form->addRow(sp1); QString trans_lable(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DECODER_IF_TRANS), "Translate param names")); QCheckBox *ck_trans = new QCheckBox(); + ck_trans->setFixedSize(20,20); ck_trans->setChecked(bLang); connect(ck_trans, SIGNAL(released()), this, SLOT(on_trans_pramas())); - ck_trans->setStyleSheet("margin-left:60px"); - form->addRow(ck_trans, new QLabel(trans_lable)); - h_ex2 = 30; + ck_trans->setStyleSheet("margin-top:5px"); + QLabel *trans_lb = new QLabel(trans_lable); + + QHBoxLayout *trans_lay = new QHBoxLayout(); + QWidget *trans_wid = new QWidget(); + trans_wid->setLayout(trans_lay); + trans_lay->setSpacing(0); + trans_lay->setContentsMargins(10,0,0,0); + trans_lay->addWidget(ck_trans); + trans_lay->addWidget(trans_lb); + form->addRow("", trans_wid); + h_ex2 = 40; } //tr diff --git a/DSView/pv/view/decodetrace.cpp b/DSView/pv/view/decodetrace.cpp index bb26dc25..18cf3699 100644 --- a/DSView/pv/view/decodetrace.cpp +++ b/DSView/pv/view/decodetrace.cpp @@ -689,7 +689,11 @@ bool DecodeTrace::create_popup(bool isnew) } dlg.get_cursor_range(_decode_cursor1, _decode_cursor2); - } + } + + if (dlg.is_reload_form()){ + ret = false; + } if (QDialog::Rejected == dlg_ret || dlg.is_reload_form() == false){ break; From 6b5fb824c19f1f1545f93f87cb21e818858c880a Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 5 Jun 2023 17:16:01 +0800 Subject: [PATCH 3/4] fix: Can't restore decoder name from file on decoder pannel --- DSView/pv/sigsession.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index f6f7597b..e9e15de1 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -2323,7 +2323,7 @@ namespace pv { auto trace = get_decoder_trace(index); if (trace != NULL){ - trace->set_name(label); + set_trace_name(trace, label); } } From eb783ca690b8a0348a4801bda5ae916ad6ebb0e8 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 5 Jun 2023 19:27:21 +0800 Subject: [PATCH 4/4] One option for whether to switch data buffer on repeat mode --- DSView/pv/config/appconfig.cpp | 2 ++ DSView/pv/config/appconfig.h | 1 + DSView/pv/dialogs/applicationpardlg.cpp | 5 +++++ DSView/pv/sigsession.cpp | 11 +++++++++++ lang/cn/dlg.json | 4 ++++ lang/en/dlg.json | 4 ++++ 6 files changed, 27 insertions(+) diff --git a/DSView/pv/config/appconfig.cpp b/DSView/pv/config/appconfig.cpp index 169c174d..e5b6099b 100644 --- a/DSView/pv/config/appconfig.cpp +++ b/DSView/pv/config/appconfig.cpp @@ -100,6 +100,7 @@ void _loadApp(AppOptions &o, QSettings &st){ getFiled("transDecoderDlg", st, o.transDecoderDlg, true); getFiled("trigPosDisplayInMid", st, o.trigPosDisplayInMid, true); getFiled("displayProfileInBar", st, o.displayProfileInBar, false); + getFiled("swapBackBufferAlways", st, o.swapBackBufferAlways, false); QString fmt; getFiled("protocalFormats", st, fmt, ""); @@ -121,6 +122,7 @@ void _saveApp(AppOptions &o, QSettings &st){ setFiled("transDecoderDlg", st, o.transDecoderDlg); setFiled("trigPosDisplayInMid", st, o.trigPosDisplayInMid); setFiled("displayProfileInBar", st, o.displayProfileInBar); + setFiled("swapBackBufferAlways", st, o.swapBackBufferAlways); QString fmt = FormatArrayToString(o.m_protocolFormats); setFiled("protocalFormats", st, fmt); diff --git a/DSView/pv/config/appconfig.h b/DSView/pv/config/appconfig.h index 16d324e8..4aba8a30 100644 --- a/DSView/pv/config/appconfig.h +++ b/DSView/pv/config/appconfig.h @@ -64,6 +64,7 @@ struct AppOptions bool transDecoderDlg; bool trigPosDisplayInMid; bool displayProfileInBar; + bool swapBackBufferAlways; std::vector m_protocolFormats; }; diff --git a/DSView/pv/dialogs/applicationpardlg.cpp b/DSView/pv/dialogs/applicationpardlg.cpp index caadabae..a3e912ec 100644 --- a/DSView/pv/dialogs/applicationpardlg.cpp +++ b/DSView/pv/dialogs/applicationpardlg.cpp @@ -66,10 +66,14 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent) QCheckBox *ck_profileBar = new QCheckBox(); ck_profileBar->setChecked(app._appOptions.displayProfileInBar); + QCheckBox *ck_abortData = new QCheckBox(); + ck_abortData->setChecked(app._appOptions.swapBackBufferAlways); + lay.setHorizontalSpacing(8); if (mode == LOGIC){ lay.addRow(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_QUICK_SCROLL), "Quick scroll"), ck_quickScroll); + lay.addRow(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_USE_ABORT_DATA_REPEAT), "Used abort data"), ck_abortData); } else if (mode == DSO){ lay.addRow(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_TRIG_DISPLAY_MIDDLE), "Tig pos in middle"), ck_trigInMid); @@ -88,6 +92,7 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent) app._appOptions.quickScroll = ck_quickScroll->isChecked(); app._appOptions.trigPosDisplayInMid = ck_trigInMid->isChecked(); app._appOptions.displayProfileInBar = ck_profileBar->isChecked(); + app._appOptions.swapBackBufferAlways = ck_abortData->isChecked(); app.SaveApp(); diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index e9e15de1..2605f6a5 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -2102,6 +2102,17 @@ namespace pv bAddDecoder = true; } + if (is_repeat_mode()) + { + AppConfig &app = AppConfig::Instance(); + bool swapBackBufferAlways = app._appOptions.swapBackBufferAlways; + if (!swapBackBufferAlways && !_is_working && _capture_times > 1){ + bAddDecoder = false; + bSwapBuffer = false; + _capture_data->clear(); + } + } + if (bAddDecoder){ clear_all_decode_task2(); clear_decode_result(); diff --git a/lang/cn/dlg.json b/lang/cn/dlg.json index ae1740e7..feb607f4 100644 --- a/lang/cn/dlg.json +++ b/lang/cn/dlg.json @@ -698,5 +698,9 @@ { "id": "IDS_DLG_SERIAL_INPUT_AS_HEX", "text": "以十六进制格式输入" + }, + { + "id": "IDS_DLG_USE_ABORT_DATA_REPEAT", + "text": "重复模式下允许使用中途停止的数据" } ] \ No newline at end of file diff --git a/lang/en/dlg.json b/lang/en/dlg.json index 699519e8..db247012 100644 --- a/lang/en/dlg.json +++ b/lang/en/dlg.json @@ -698,5 +698,9 @@ { "id": "IDS_DLG_SERIAL_INPUT_AS_HEX", "text": "Input with hex format" + }, + { + "id": "IDS_DLG_USE_ABORT_DATA_REPEAT", + "text": "Allow use of the midway stopped data on repeat mode" } ] \ No newline at end of file