fix: Failed to load the measure information of DSCope on bottom from file

This commit is contained in:
dreamsourcelabTAI 2023-06-20 16:35:56 +08:00
parent 7053af0a8f
commit 2f3227b668
3 changed files with 22 additions and 5 deletions

View File

@ -1096,7 +1096,7 @@ namespace pv
if (sessionObj.contains("measure")) if (sessionObj.contains("measure"))
{ {
auto *bottom_bar = _view->get_viewstatus(); auto *bottom_bar = _view->get_viewstatus();
bottom_bar->load_session(sessionObj["measure"].toArray()); bottom_bar->load_session(sessionObj["measure"].toArray(), format_ver);
} }
if (gvar_opts != NULL) if (gvar_opts != NULL)

View File

@ -258,7 +258,7 @@ QJsonArray ViewStatus::get_session()
return measureVar; return measureVar;
} }
void ViewStatus::load_session(QJsonArray measure_array) void ViewStatus::load_session(QJsonArray measure_array, int version)
{ {
if (_session->get_device()->get_work_mode() != DSO){ if (_session->get_device()->get_work_mode() != DSO){
return; return;
@ -270,10 +270,27 @@ void ViewStatus::load_session(QJsonArray measure_array)
std::get<2>(_mrects[i]) = DSO_MS_BEGIN; std::get<2>(_mrects[i]) = DSO_MS_BEGIN;
} }
for (const QJsonValue &measure_value : measure_array) { for (const QJsonValue &measure_value : measure_array)
{
QJsonObject m_obj = measure_value.toObject(); QJsonObject m_obj = measure_value.toObject();
int index = m_obj["site"].toInt(); int index = m_obj["site"].toInt();
int sig_index = m_obj["index"].toInt(); int sig_index = m_obj["index"].toInt();
if (version >= 3){
Signal *trace = NULL;
for(auto s : _session->get_signals()){
if (s->get_name().toInt() == sig_index){
trace = s;
break;
}
}
if (trace == NULL)
continue;
sig_index = trace->get_index();
}
enum DSO_MEASURE_TYPE ms_type = DSO_MEASURE_TYPE(m_obj["type"].toInt()); enum DSO_MEASURE_TYPE ms_type = DSO_MEASURE_TYPE(m_obj["type"].toInt());
set_measure(index, false, sig_index, ms_type); set_measure(index, false, sig_index, ms_type);
} }

View File

@ -54,7 +54,7 @@ public:
int sig_index, enum DSO_MEASURE_TYPE ms_type); int sig_index, enum DSO_MEASURE_TYPE ms_type);
QJsonArray get_session(); QJsonArray get_session();
void load_session(QJsonArray meausre_array); void load_session(QJsonArray meausre_array, int version);
void set_capture_status(bool triggered, int progess); void set_capture_status(bool triggered, int progess);
public slots: public slots: