fix: On real-time mode, the decode task show an error progress value

This commit is contained in:
dreamsourcelabTAI 2023-03-01 17:40:05 +08:00
parent b3d0e04e31
commit 0a0ad7e367
9 changed files with 43 additions and 19 deletions

View File

@ -67,6 +67,7 @@ DecoderStack::DecoderStack(pv::SigSession *session,
_stask_stauts = NULL; _stask_stauts = NULL;
_is_capture_end = true; _is_capture_end = true;
_snapshot = NULL; _snapshot = NULL;
_progress = 0;
_stack.push_back(new decode::Decoder(dec)); _stack.push_back(new decode::Decoder(dec));
@ -396,7 +397,7 @@ void DecoderStack::begin_decode_work()
assert(_decode_state == Stopped); assert(_decode_state == Stopped);
_error_message = ""; _error_message = "";
_decode_state = Running; _decode_state = Running;
do_decode_work(); do_decode_work();
_decode_state = Stopped; _decode_state = Stopped;
} }
@ -514,6 +515,9 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod
bool bCheckEnd = false; bool bCheckEnd = false;
uint64_t end_index = decode_end; uint64_t end_index = decode_end;
_progress = 0;
uint64_t sended_len = 0;
while(i < end_index && !_no_memory && !status->_bStop) 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; break;
} }
i = chunk_end; sended_len += chunk_end - i;
_progress = (int)(sended_len * 100 / end_index);
i = chunk_end;
//use mutex //use mutex
{ {
@ -593,8 +600,12 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod
last_cnt = i; last_cnt = i;
new_decode_data(); new_decode_data();
} }
entry_cnt++; entry_cnt++;
} }
_progress = 100;
new_decode_data();
// the task is normal ends,so all samples was processed; // the task is normal ends,so all samples was processed;
if (!bError && bEndTime){ if (!bError && bEndTime){

View File

@ -169,6 +169,11 @@ public:
inline void set_capture_end_flag(bool isEnd){ inline void set_capture_end_flag(bool isEnd){
_is_capture_end = isEnd; _is_capture_end = isEnd;
if (!isEnd){_progress = 0;}
}
inline int get_progress(){
return _progress;
} }
private: private:
@ -204,6 +209,7 @@ private:
decode_task_status *_stask_stauts; decode_task_status *_stask_stauts;
mutable std::mutex _output_mutex; mutable std::mutex _output_mutex;
bool _is_capture_end; bool _is_capture_end;
int _progress;
friend class DecoderStackTest::TwoDecoderStack; friend class DecoderStackTest::TwoDecoderStack;
}; };

View File

@ -462,7 +462,7 @@ void ProtocolDock::decoded_progress(int progress)
lay.SetProgress(pg, err); lay.SetProgress(pg, err);
// have custom data format // 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); 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); _selected_protocol_id = QString(dec->id);
this->on_add_protocol(); this->on_add_protocol();
} }
} }
void ProtocolDock::ResetView()
{
decoded_progress(0);
}
} // namespace dock } // namespace dock
} // namespace pv } // namespace pv

View File

@ -84,6 +84,8 @@ public:
void del_all_protocol(); void del_all_protocol();
bool add_protocol_by_id(QString id, bool silent, std::list<pv::data::decode::Decoder*> &sub_decoders); bool add_protocol_by_id(QString id, bool silent, std::list<pv::data::decode::Decoder*> &sub_decoders);
void ResetView();
private: private:
void changeEvent(QEvent *event); void changeEvent(QEvent *event);
void retranslateUi(); void retranslateUi();

View File

@ -91,6 +91,8 @@ public:
#define DSV_MSG_TRIG_NEXT_COLLECT 7001 #define DSV_MSG_TRIG_NEXT_COLLECT 7001
#define DSV_MSG_SAVE_COMPLETE 7002 #define DSV_MSG_SAVE_COMPLETE 7002
#define DSV_MSG_CLEAR_DECODE_DATA 8001
class IMessageListener class IMessageListener
{ {
public: public:

View File

@ -1738,6 +1738,10 @@ namespace pv
} }
} }
break; break;
case DSV_MSG_CLEAR_DECODE_DATA:
_protocol_widget->ResetView();
break;
} }
} }

View File

@ -524,12 +524,14 @@ namespace pv
if (mode == LOGIC) if (mode == LOGIC)
{ {
bool bClearDecodeData = false;
// On repeate mode, the last data can use to decode, so can't remove the current decode task. // 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. // And on this mode, the decode task will be created when capture end.
if (is_repeat_mode() == false){ if (is_repeat_mode() == false){
int run_dex = 0; int run_dex = 0;
clear_all_decode_task(run_dex); clear_all_decode_task(run_dex);
clear_decode_result(); clear_decode_result();
bClearDecodeData = true;
} }
for (auto de : _decode_traces) for (auto de : _decode_traces)
@ -543,6 +545,9 @@ namespace pv
add_decode_task(de); add_decode_task(de);
} }
} }
if (bClearDecodeData)
_callback->trigger_message(DSV_MSG_CLEAR_DECODE_DATA);
} }
return true; return true;

View File

@ -124,7 +124,6 @@ DecodeTrace::DecodeTrace(pv::SigSession *session,
_colour = DecodeColours[index % countof(DecodeColours)]; _colour = DecodeColours[index % countof(DecodeColours)];
_pub_input_layer = NULL; _pub_input_layer = NULL;
_progress = 0;
_decode_start = 0; _decode_start = 0;
_decode_end = INT64_MAX; _decode_end = INT64_MAX;
_decoder_stack = decoder_stack; _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() void DecodeTrace::on_new_decode_data()
{ {
uint64_t real_end = min(_decoder_stack->sample_count(), _decode_end+1); decoded_progress(_decoder_stack->get_progress());
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);
if (_view && _view->session().is_stopped_status()) if (_view && _view->session().is_stopped_status())
_view->data_updated(); _view->data_updated();
@ -575,7 +564,7 @@ void DecodeTrace::on_new_decode_data()
int DecodeTrace::get_progress() int DecodeTrace::get_progress()
{ {
return _progress; return _decoder_stack->get_progress();
} }
void DecodeTrace::on_decode_done() void DecodeTrace::on_decode_done()

View File

@ -192,7 +192,6 @@ private:
uint64_t _decode_cursor2; uint64_t _decode_cursor2;
QFormLayout *_pub_input_layer; QFormLayout *_pub_input_layer;
int _progress;
std::vector<QString> _cur_row_headings; std::vector<QString> _cur_row_headings;