From 0ca87ec8678bae55e6327460152a05b6772d5d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Tue, 23 Aug 2022 12:20:07 +0200 Subject: [PATCH] Fix trace parsing of old setup files --- Software/PC_Application/Traces/trace.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Software/PC_Application/Traces/trace.cpp b/Software/PC_Application/Traces/trace.cpp index b8a4c37..28eab3e 100644 --- a/Software/PC_Application/Traces/trace.cpp +++ b/Software/PC_Application/Traces/trace.cpp @@ -753,7 +753,21 @@ void Trace::fromJSON(nlohmann::json j) visible = j.value("visible", true); auto type = QString::fromStdString(j.value("type", "Live")); if(type == "Live") { - liveParam = QString::fromStdString(j.value("parameter", "S11")); + if(j.contains("parameter")) { + if(j["parameter"].type() == nlohmann::json::value_t::string) { + liveParam = QString::fromStdString(j.value("parameter", "S11")); + } else { + // old parameter setting is stored as a number + auto index = j.value("parameter", 0); + const QString parameterList[] = {"S11", "S12", "S21", "S22", "PORT1", "PORT2"}; + if(index < 6) { + liveParam = parameterList[index]; + } else { + liveParam = "S11"; + } + } + } + _liveType = j.value("livetype", LivedataType::Overwrite); paused = j.value("paused", false); } else if(type == "Touchstone" || type == "File") {