Fix vision settings save

This commit is contained in:
Peter Johnson 2018-12-20 14:13:11 -08:00
parent 1e09760688
commit a6b151e7bd
No known key found for this signature in database
GPG Key ID: D39DD4DA7D41E329
2 changed files with 8 additions and 10 deletions

View File

@ -30,6 +30,7 @@ void VisionSettings::Set(const wpi::json& data,
return;
}
data.dump(os, 4);
os << '\n';
}
// terminate vision process so it reloads the file

View File

@ -216,6 +216,13 @@ void ProcessWsText(wpi::WebSocket& ws, wpi::StringRef msg) {
<< '\n';
return;
}
} else if (subType == "Save") {
try {
VisionSettings::GetInstance()->Set(j.at("settings"), statusFunc);
} catch (const wpi::json::exception& e) {
wpi::errs() << "could not read visionSave value: " << e.what() << '\n';
return;
}
}
} else if (t == "networkSave") {
auto statusFunc = [s = ws.shared_from_this()](wpi::StringRef msg) {
@ -244,16 +251,6 @@ void ProcessWsText(wpi::WebSocket& ws, wpi::StringRef msg) {
wpi::errs() << "could not read networkSave value: " << e.what() << '\n';
return;
}
} else if (t == "visionSave") {
auto statusFunc = [s = ws.shared_from_this()](wpi::StringRef msg) {
SendWsText(*s, {{"type", "status"}, {"message", msg}});
};
try {
VisionSettings::GetInstance()->Set(j.at("settings"), statusFunc);
} catch (const wpi::json::exception& e) {
wpi::errs() << "could not read visionSave value: " << e.what() << '\n';
return;
}
}
}