Fix vision settings save
This commit is contained in:
		
							parent
							
								
									1e09760688
								
							
						
					
					
						commit
						a6b151e7bd
					
				| 
						 | 
					@ -30,6 +30,7 @@ void VisionSettings::Set(const wpi::json& data,
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    data.dump(os, 4);
 | 
					    data.dump(os, 4);
 | 
				
			||||||
 | 
					    os << '\n';
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // terminate vision process so it reloads the file
 | 
					  // terminate vision process so it reloads the file
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -216,6 +216,13 @@ void ProcessWsText(wpi::WebSocket& ws, wpi::StringRef msg) {
 | 
				
			||||||
                    << '\n';
 | 
					                    << '\n';
 | 
				
			||||||
        return;
 | 
					        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") {
 | 
					  } else if (t == "networkSave") {
 | 
				
			||||||
    auto statusFunc = [s = ws.shared_from_this()](wpi::StringRef msg) {
 | 
					    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';
 | 
					      wpi::errs() << "could not read networkSave value: " << e.what() << '\n';
 | 
				
			||||||
      return;
 | 
					      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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user