2
0
forked from Ivasoft/DSView

Restore the view index of decoder trace from file

This commit is contained in:
dreamsourcelabTAI
2023-05-29 11:16:22 +08:00
parent 5f2e62f400
commit 5b9b1daf11
10 changed files with 50 additions and 21 deletions

View File

@@ -753,7 +753,7 @@ namespace pv
StoreSession ss(_session);
QJsonArray decodeJson;
ss.json_decoders(decodeJson);
ss.gen_decoders_json(decodeJson);
sessionVar["decoder"] = decodeJson;
if (_device_agent->get_work_mode() == DSO)
@@ -1074,6 +1074,7 @@ namespace pv
haveDecoder = true;
StoreSession ss(_session);
ss.load_decoders(_protocol_widget, deArray);
_view->update_all_trace_postion();
}
}
@@ -1776,6 +1777,7 @@ namespace pv
StoreSession ss(_session);
QJsonArray deArray = get_decoder_json_from_file(_device_agent->path());
ss.load_decoders(_protocol_widget, deArray);
_view->update_all_trace_postion();
}
_session->start_capture(true);
@@ -1797,6 +1799,7 @@ namespace pv
StoreSession ss(_session);
QJsonArray deArray = get_decoder_json_from_file(_device_agent->path());
ss.load_decoders(_protocol_widget, deArray);
_view->update_all_trace_postion();
}
}
}
@@ -1847,6 +1850,7 @@ namespace pv
StoreSession ss(_session);
QJsonArray deArray = get_decoder_json_from_file(_device_agent->path());
ss.load_decoders(_protocol_widget, deArray);
_view->update_all_trace_postion();
}
}
}
@@ -1975,6 +1979,7 @@ namespace pv
StoreSession ss(_session);
QJsonArray deArray = get_decoder_json_from_file(_device_agent->path());
ss.load_decoders(_protocol_widget, deArray);
_view->update_all_trace_postion();
if (msg == DSV_MSG_END_DEVICE_OPTIONS)
_session->start_capture(false); // Auto load data.

View File

@@ -889,6 +889,7 @@ namespace pv
int logic_chan_num = 0;
int dso_chan_num = 0;
int all_chann_num = 0;
int start_view_dex = -1;
set_cur_snap_samplerate(_device_agent.get_sample_rate());
set_cur_samplelimits(_device_agent.get_sample_limit());
@@ -917,6 +918,8 @@ namespace pv
if ((*i)->signal_type() == SR_CHANNEL_LOGIC){
view::LogicSignal *logicSig = (view::LogicSignal*)(*i);
signal = new view::LogicSignal(logicSig, _view_data->get_logic(), probe);
if (logicSig->get_view_index() < start_view_dex || start_view_dex == -1)
start_view_dex = logicSig->get_view_index();
}
break;
@@ -971,7 +974,7 @@ namespace pv
clear_signals();
std::vector<view::Signal *>().swap(_signals);
_signals = sigs;
make_channels_view_index();
make_channels_view_index(start_view_dex);
if (_device_agent.get_work_mode() == LOGIC){
for (int i=0; i<view_indexs.size() && i<_signals.size(); i++){
@@ -2334,10 +2337,13 @@ namespace pv
return NULL;
}
void SigSession::make_channels_view_index()
void SigSession::make_channels_view_index(int start_dex)
{
int index = 0;
if (start_dex != -1)
index = start_dex;
for(auto t : _signals){
t->set_view_index(index++);
}

View File

@@ -518,7 +518,7 @@ private:
}
view::Trace* get_channel_by_index(int orgIndex);
void make_channels_view_index();
void make_channels_view_index(int start_dex = -1);
private:
mutable std::mutex _sampling_mutex;

View File

@@ -999,7 +999,7 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
bool StoreSession::decoders_gen(std::string &str)
{
QJsonArray dec_array;
if (!json_decoders(dec_array))
if (!gen_decoders_json(dec_array))
return false;
QJsonDocument sessionDoc(dec_array);
QString data = QString::fromUtf8(sessionDoc.toJson());
@@ -1007,7 +1007,7 @@ bool StoreSession::decoders_gen(std::string &str)
return true;
}
bool StoreSession::json_decoders(QJsonArray &array)
bool StoreSession::gen_decoders_json(QJsonArray &array)
{
for(auto s : _session->get_decode_signals()) {
QJsonObject dec_obj;
@@ -1074,9 +1074,11 @@ bool StoreSession::json_decoders(QJsonArray &array)
}
show_obj[d->id] = QJsonValue::fromVariant(dec->shown());
}
dec_obj["version"] = DEOCDER_CONFIG_VERSION;
dec_obj["label"] = QString(s->get_name().toUtf8().data());
dec_obj["stacked decoders"] = stack_array;
dec_obj["view_index"] = s->get_view_index();
auto rows = stack->get_rows_gshow();
for (auto i = rows.begin(); i != rows.end(); i++) {
@@ -1150,6 +1152,11 @@ bool StoreSession::load_decoders(dock::ProtocolDock *widget, QJsonArray &dec_arr
_session->set_decoder_row_label(dec_index, dec_obj["label"].toString());
}
if (dec_obj.contains("view_index")){
int chan_view_index = dec_obj["view_index"].toInt();
_session->get_decoder_trace(dec_index)->set_view_index(chan_view_index);
}
std::list<int> bind_indexs;
std::vector<view::DecodeTrace*> &aft_dsigs = _session->get_decode_signals();

View File

@@ -82,7 +82,7 @@ private:
public:
bool json_decoders(QJsonArray &array);
bool gen_decoders_json(QJsonArray &array);
bool load_decoders(dock::ProtocolDock *widget, QJsonArray &dec_array);
QString MakeSaveFile(bool bDlg);
QString MakeExportFile(bool bDlg);

View File

@@ -123,7 +123,6 @@ DecodeTrace::DecodeTrace(pv::SigSession *session,
_colour = DecodeColours[index % countof(DecodeColours)];
_pub_input_layer = NULL;
_decode_start = 0;
_decode_end = INT64_MAX;
_decoder_stack = decoder_stack;

View File

@@ -189,9 +189,7 @@ private:
uint64_t _decode_end;
uint64_t _decode_cursor1; // the cursor key, sample start index
uint64_t _decode_cursor2;
QFormLayout *_pub_input_layer;
uint64_t _decode_cursor2;
std::vector<QString> _cur_row_headings;

View File

@@ -247,6 +247,10 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
{
std::vector<Trace*> traces;
for (auto s : _view.session().get_decode_signals()){
traces.push_back(s);
}
for (auto s : _view.session().get_signals()){
traces.push_back(s);
}

View File

@@ -58,7 +58,7 @@ Trace::Trace(QString name, uint16_t index, int type) :
_typeWidth(SquareNum)
{
_index_list.push_back(index);
_view_index = 0;
_view_index = -1;
}
Trace::Trace(QString name, std::list<int> index_list, int type, int sec_index) :
@@ -71,7 +71,7 @@ Trace::Trace(QString name, std::list<int> index_list, int type, int sec_index) :
_totalHeight(30),
_typeWidth(SquareNum)
{
_view_index = 0;
_view_index = -1;
}
Trace::Trace(const Trace &t) :
@@ -87,7 +87,7 @@ Trace::Trace(const Trace &t) :
_typeWidth(t._typeWidth),
_text_size(t._text_size)
{
_view_index = 0;
_view_index = -1;
}

View File

@@ -719,17 +719,27 @@ void View::signals_changed()
_spanY = _signalHeight + 2 * actualMargin;
int next_v_offset = actualMargin;
//Make list by view index;
//Make list by view-index;
if (mode == LOGIC)
{
sort(logic_traces.begin(), logic_traces.end(), compare_trace_view_index);
{
time_traces.clear();
for(auto t : decoder_traces){
time_traces.push_back(t);
}
std::vector<Trace*> all_traces;
for(auto t : logic_traces){
all_traces.push_back(t);
}
for(auto t : decoder_traces){
if (t->get_view_index() != -1)
all_traces.push_back(t);
else
time_traces.push_back(t);
}
sort(all_traces.begin(), all_traces.end(), compare_trace_view_index);
for(auto t : all_traces){
time_traces.push_back(t);
}
}