From bf05fdf055f4957743de08ae12ecee2d2a296938 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Wed, 21 Dec 2022 17:55:12 +0800 Subject: [PATCH] Decode the data while collection the data, the step 1 --- DSView/pv/data/decoderstack.cpp | 13 +++++--- DSView/pv/data/decoderstack.h | 9 ++++++ DSView/pv/interface/icallbacks.h | 1 + DSView/pv/sigsession.cpp | 55 +++++++++++++++++++++++++------- DSView/pv/sigsession.h | 1 - 5 files changed, 63 insertions(+), 16 deletions(-) diff --git a/DSView/pv/data/decoderstack.cpp b/DSView/pv/data/decoderstack.cpp index 393c429f..c164459c 100644 --- a/DSView/pv/data/decoderstack.cpp +++ b/DSView/pv/data/decoderstack.cpp @@ -65,7 +65,8 @@ DecoderStack::DecoderStack(pv::SigSession *session, _no_memory = false; _mark_index = -1; _decoder_status = decoder_status; - _stask_stauts = NULL; + _stask_stauts = NULL; + _is_capture_end = true; _stack.push_back(new decode::Decoder(dec)); @@ -609,8 +610,6 @@ void DecoderStack::execute_decode_stack() // Get the intial sample count _sample_count = _snapshot->get_sample_count(); - - dsv_info("%s%llu", "decoder sample count: ", _sample_count); // Create the decoders for(auto dec : _stack) @@ -630,9 +629,15 @@ void DecoderStack::execute_decode_stack() prev_di = di; decode_start = dec->decode_start(); - decode_end = min(dec->decode_end(), _sample_count-1); + + if (_session->is_realtime_mode() == false) + decode_end = min(dec->decode_end(), _sample_count-1); + else + decode_end = max(dec->decode_end(), decode_end); } + dsv_info("decoder start sample:%llu, end sample:%llu, count:%llu", decode_start, decode_end, decode_end - decode_start + 1); + // Start the session srd_session_metadata_set(session, SRD_CONF_SAMPLERATE, g_variant_new_uint64((uint64_t)_samplerate)); diff --git a/DSView/pv/data/decoderstack.h b/DSView/pv/data/decoderstack.h index 3ce5c6d9..235ac38d 100644 --- a/DSView/pv/data/decoderstack.h +++ b/DSView/pv/data/decoderstack.h @@ -164,6 +164,14 @@ public: return _decoder_status; } + inline bool is_capture_end(){ + return _is_capture_end; + } + + inline void set_capture_end_flag(bool isEnd){ + _is_capture_end = isEnd; + } + private: void decode_data(const uint64_t decode_start, const uint64_t decode_end, srd_session *const session); void execute_decode_stack(); @@ -196,6 +204,7 @@ private: decode_task_status *_stask_stauts; mutable std::mutex _output_mutex; + bool _is_capture_end; friend class DecoderStackTest::TwoDecoderStack; }; diff --git a/DSView/pv/interface/icallbacks.h b/DSView/pv/interface/icallbacks.h index 52a1557c..2f8a6f57 100644 --- a/DSView/pv/interface/icallbacks.h +++ b/DSView/pv/interface/icallbacks.h @@ -74,6 +74,7 @@ public: #define DSV_MSG_COLLECT_END 5004 #define DSV_MSG_END_COLLECT_WORK_PREV 5005 #define DSV_MSG_END_COLLECT_WORK 5006 +#define DSV_MSG_REV_END_PACKET 5007 #define DSV_MSG_DEVICE_LIST_UPDATED 6000 #define DSV_MSG_BEGIN_DEVICE_OPTIONS 6001 //Begin show device options dialog. diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 444da686..186bebfc 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -478,6 +478,23 @@ namespace pv _is_working = true; _callback->trigger_message(DSV_MSG_START_COLLECT_WORK); + if (_device_agent.get_work_mode() == LOGIC) + { + for (auto de : _decode_traces) + { + de->decoder()->set_capture_end_flag(false); + + // On real-time mode, create the decode task when capture started. + if (is_realtime_mode()) + { + de->decoder()->frame_ended(); + de->frame_ended(); + add_decode_task(de); + } + } + } + + // Start a timer, for able to refresh the view per (1000 / 30)ms if (is_realtime_mode()){ _refresh_rt_timer.Start(1000 / 30); } @@ -1251,12 +1268,11 @@ namespace pv _dso_data->snapshot()->capture_ended(); _analog_data->snapshot()->capture_ended(); - for (auto trace : _decode_traces) - { - trace->decoder()->frame_ended(); - trace->frame_ended(); - add_decode_task(trace); - } + int mode = _device_agent.get_work_mode(); + + // Post a message to start all decode tasks. + if (mode == LOGIC) + _callback->trigger_message(DSV_MSG_REV_END_PACKET); if (packet->status != SR_PKT_OK) { @@ -1266,10 +1282,8 @@ namespace pv _callback->frame_ended(); - if (_device_agent.get_work_mode() != LOGIC) - { + if (mode != LOGIC) set_session_time(QDateTime::currentDateTime()); - } break; } @@ -1876,7 +1890,7 @@ namespace pv case DS_EV_INACTIVE_DEVICE_DETACH: _callback->trigger_message(DSV_MSG_DEVICE_LIST_UPDATED); // Update list only. - break; + break; default: dsv_err("%s", "Error!Unknown device event."); @@ -1943,7 +1957,7 @@ namespace pv case DSV_MSG_TRIG_NEXT_COLLECT: { - if (_is_working) + if (_is_working && is_repeat_mode()) { if (_repeat_intvl > 0) { @@ -1974,6 +1988,25 @@ namespace pv } break; + case DSV_MSG_REV_END_PACKET: + { + if (_device_agent.get_work_mode() == LOGIC) + { + for (auto de : _decode_traces) + { + de->decoder()->set_capture_end_flag(true); + + // If is not the real-time mode, try to create all decode tasks. + if (is_realtime_mode() == false){ + de->decoder()->frame_ended(); + de->frame_ended(); + add_decode_task(de); + } + } + } + } + break; + case DSV_MSG_COLLECT_END: break; } diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index ddce5473..19180a79 100644 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -374,7 +374,6 @@ private: void set_cur_snap_samplerate(uint64_t samplerate); void math_disable(); -private: bool exec_capture(); void exit_capture();