diff --git a/DSView/pv/data/decoderstack.cpp b/DSView/pv/data/decoderstack.cpp index a5d58f8f..5726d52b 100644 --- a/DSView/pv/data/decoderstack.cpp +++ b/DSView/pv/data/decoderstack.cpp @@ -67,6 +67,7 @@ DecoderStack::DecoderStack(pv::SigSession *session, _stask_stauts = NULL; _is_capture_end = true; _snapshot = NULL; + _progress = 0; _stack.push_back(new decode::Decoder(dec)); @@ -396,7 +397,7 @@ void DecoderStack::begin_decode_work() assert(_decode_state == Stopped); _error_message = ""; - _decode_state = Running; + _decode_state = Running; do_decode_work(); _decode_state = Stopped; } @@ -514,6 +515,9 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod bool bCheckEnd = false; uint64_t end_index = decode_end; + + _progress = 0; + uint64_t sended_len = 0; while(i < end_index && !_no_memory && !status->_bStop) { @@ -581,7 +585,10 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod break; } - i = chunk_end; + sended_len += chunk_end - i; + _progress = (int)(sended_len * 100 / end_index); + + i = chunk_end; //use mutex { @@ -593,8 +600,12 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod last_cnt = i; new_decode_data(); } + entry_cnt++; - } + } + + _progress = 100; + new_decode_data(); // the task is normal ends,so all samples was processed; if (!bError && bEndTime){ diff --git a/DSView/pv/data/decoderstack.h b/DSView/pv/data/decoderstack.h index c6c071a9..622a5617 100644 --- a/DSView/pv/data/decoderstack.h +++ b/DSView/pv/data/decoderstack.h @@ -169,6 +169,11 @@ public: inline void set_capture_end_flag(bool isEnd){ _is_capture_end = isEnd; + if (!isEnd){_progress = 0;} + } + + inline int get_progress(){ + return _progress; } private: @@ -204,6 +209,7 @@ private: decode_task_status *_stask_stauts; mutable std::mutex _output_mutex; bool _is_capture_end; + int _progress; friend class DecoderStackTest::TwoDecoderStack; }; diff --git a/DSView/pv/dock/protocoldock.cpp b/DSView/pv/dock/protocoldock.cpp index 2d70833f..7a540ea0 100644 --- a/DSView/pv/dock/protocoldock.cpp +++ b/DSView/pv/dock/protocoldock.cpp @@ -462,7 +462,7 @@ void ProtocolDock::decoded_progress(int progress) lay.SetProgress(pg, err); // have custom data format - if (progress == 100 && lay.m_decoderStatus != NULL){ + if (pg == 100 && lay.m_decoderStatus != NULL){ lay.enable_format(lay.m_decoderStatus->m_bNumeric); } } @@ -997,6 +997,12 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod _selected_protocol_id = QString(dec->id); this->on_add_protocol(); } - } + } + + void ProtocolDock::ResetView() + { + decoded_progress(0); + } + } // namespace dock } // namespace pv diff --git a/DSView/pv/dock/protocoldock.h b/DSView/pv/dock/protocoldock.h index ff085854..6d2e5ba1 100644 --- a/DSView/pv/dock/protocoldock.h +++ b/DSView/pv/dock/protocoldock.h @@ -84,6 +84,8 @@ public: void del_all_protocol(); bool add_protocol_by_id(QString id, bool silent, std::list &sub_decoders); + void ResetView(); + private: void changeEvent(QEvent *event); void retranslateUi(); diff --git a/DSView/pv/interface/icallbacks.h b/DSView/pv/interface/icallbacks.h index 2f8a6f57..d3ebc219 100644 --- a/DSView/pv/interface/icallbacks.h +++ b/DSView/pv/interface/icallbacks.h @@ -91,6 +91,8 @@ public: #define DSV_MSG_TRIG_NEXT_COLLECT 7001 #define DSV_MSG_SAVE_COMPLETE 7002 +#define DSV_MSG_CLEAR_DECODE_DATA 8001 + class IMessageListener { public: diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 12957584..bee8d86e 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -1738,6 +1738,10 @@ namespace pv } } break; + + case DSV_MSG_CLEAR_DECODE_DATA: + _protocol_widget->ResetView(); + break; } } diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 7e18ed49..7922cffe 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -524,12 +524,14 @@ namespace pv if (mode == LOGIC) { + bool bClearDecodeData = false; // On repeate mode, the last data can use to decode, so can't remove the current decode task. // And on this mode, the decode task will be created when capture end. if (is_repeat_mode() == false){ int run_dex = 0; clear_all_decode_task(run_dex); clear_decode_result(); + bClearDecodeData = true; } for (auto de : _decode_traces) @@ -543,6 +545,9 @@ namespace pv add_decode_task(de); } } + + if (bClearDecodeData) + _callback->trigger_message(DSV_MSG_CLEAR_DECODE_DATA); } return true; diff --git a/DSView/pv/view/decodetrace.cpp b/DSView/pv/view/decodetrace.cpp index 1693712d..8b68ed7d 100644 --- a/DSView/pv/view/decodetrace.cpp +++ b/DSView/pv/view/decodetrace.cpp @@ -124,7 +124,6 @@ DecodeTrace::DecodeTrace(pv::SigSession *session, _colour = DecodeColours[index % countof(DecodeColours)]; _pub_input_layer = NULL; - _progress = 0; _decode_start = 0; _decode_end = INT64_MAX; _decoder_stack = decoder_stack; @@ -555,17 +554,7 @@ void DecodeTrace::draw_unshown_row(QPainter &p, int y, int h, int left, void DecodeTrace::on_new_decode_data() { - uint64_t real_end = min(_decoder_stack->sample_count(), _decode_end+1); - const int64_t need_sample_count = real_end - _decode_start; - if (real_end == 0) { - _progress = 0; - } else if (need_sample_count <= 0) { - _progress = 100; - } else { - const uint64_t samples_decoded = _decoder_stack->samples_decoded(); - _progress = floor(samples_decoded * 100.0 / need_sample_count); - } - decoded_progress(_progress); + decoded_progress(_decoder_stack->get_progress()); if (_view && _view->session().is_stopped_status()) _view->data_updated(); @@ -575,7 +564,7 @@ void DecodeTrace::on_new_decode_data() int DecodeTrace::get_progress() { - return _progress; + return _decoder_stack->get_progress(); } void DecodeTrace::on_decode_done() diff --git a/DSView/pv/view/decodetrace.h b/DSView/pv/view/decodetrace.h index a152cac1..0d66a0b0 100644 --- a/DSView/pv/view/decodetrace.h +++ b/DSView/pv/view/decodetrace.h @@ -192,7 +192,6 @@ private: uint64_t _decode_cursor2; QFormLayout *_pub_input_layer; - int _progress; std::vector _cur_row_headings;