Skip to content

Commit

Permalink
Initial misc instrument serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
azonenberg committed Nov 15, 2023
1 parent 2aea450 commit b0877aa
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
75 changes: 74 additions & 1 deletion src/ngscopeclient/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,11 @@ bool Session::PreLoadInstruments(int version, const YAML::Node& node, bool onlin
if(!PreLoadBERT(version, inst, online))
return false;
}
else if(inst["type"].as<string>() == "misc")
{
if(!PreLoadMisc(version, inst, online))
return false;
}

//Unknown instrument type - too new file format?
else
Expand Down Expand Up @@ -999,7 +1004,7 @@ bool Session::PreLoadLoad(int version, const YAML::Node& node, bool online)
node["args"].as<string>()
);
*/
LogError("offline loading of multiloads not implemented yet");
LogError("offline loading of loads not implemented yet");
return false;
}

Expand All @@ -1016,6 +1021,71 @@ bool Session::PreLoadLoad(int version, const YAML::Node& node, bool online)
return true;
}

bool Session::PreLoadMisc(int version, const YAML::Node& node, bool online)
{
//Create the instrument
SCPIMiscInstrument* misc = nullptr;

auto transtype = node["transport"].as<string>();
auto driver = node["driver"].as<string>();

if(online)
{
if( (transtype == "null") && (driver != "demoload") )
{
m_mainWindow->ShowErrorPopup(
"Unable to reconnect",
"The session file does not contain any connection information.\n\n"
"Loading in offline mode.");
}

else
{
//Create the PSU
auto transport = CreateTransportForNode(node);

if(transport)
{
misc = SCPIMiscInstrument::CreateInstrument(driver, transport);
if(!VerifyInstrument(node, misc))
{
delete misc;
misc = nullptr;
}
}
}
}

if(!misc)
{
/*
//Create the mock scope
scope = new MockOscilloscope(
node["name"].as<string>(),
node["vendor"].as<string>(),
node["serial"].as<string>(),
transtype,
driver,
node["args"].as<string>()
);
*/
LogError("offline loading of misc instruments not implemented yet");
return false;
}

//Make any config settings to the instrument from our preference settings
//ApplyPreferences(misc);

//All good. Add to our list of loads etc
AddMiscInstrument(misc);
m_idtable.emplace(node["id"].as<uintptr_t>(), (Instrument*)misc);

//Run the preload
misc->PreLoadConfiguration(version, node, m_idtable, m_warnings);

return true;
}

bool Session::PreLoadBERT(int version, const YAML::Node& node, bool online)
{
//Create the instrument
Expand Down Expand Up @@ -1574,6 +1644,7 @@ YAML::Node Session::SerializeInstrumentConfiguration()
auto funcgen = dynamic_cast<SCPIFunctionGenerator*>(inst);
auto load = dynamic_cast<SCPILoad*>(inst);
auto bert = dynamic_cast<SCPIBERT*>(inst);
auto misc = dynamic_cast<SCPIMiscInstrument*>(inst);
if(scope)
{
if(m_scopeDeskewCal.find(scope) != m_scopeDeskewCal.end())
Expand All @@ -1592,6 +1663,8 @@ YAML::Node Session::SerializeInstrumentConfiguration()
config["type"] = "load";
else if(bert)
config["type"] = "bert";
else if(misc)
config["type"] = "misc";

node["inst" + config["id"].as<string>()] = config;
}
Expand Down
1 change: 1 addition & 0 deletions src/ngscopeclient/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ class Session
bool PreLoadMultimeter(int version, const YAML::Node& node, bool online);
bool PreLoadBERT(int version, const YAML::Node& node, bool online);
bool PreLoadLoad(int version, const YAML::Node& node, bool online);
bool PreLoadMisc(int version, const YAML::Node& node, bool online);
bool LoadFilters(int version, const YAML::Node& node);
bool LoadInstrumentInputs(int version, const YAML::Node& node);
bool LoadWaveformData(int version, const std::string& dataDir);
Expand Down

0 comments on commit b0877aa

Please sign in to comment.