SCRIPT namespace replacements

This commit is contained in:
PJ Reiniger
2025-11-07 20:00:05 -05:00
committed by Peter Johnson
parent ae6c043632
commit 9aca8e0fd6
2622 changed files with 22275 additions and 22275 deletions

View File

@@ -59,19 +59,19 @@ bool server = false;
struct CameraConfig {
std::string name;
std::string path;
wpi::json config;
wpi::util::json config;
};
std::vector<CameraConfig> cameras;
bool ReadCameraConfig(const wpi::json& config) {
bool ReadCameraConfig(const wpi::util::json& config) {
CameraConfig c;
// name
try {
c.name = config.at("name").get<std::string>();
} catch (const wpi::json::exception& e) {
wpi::print(stderr, "config error in '{}': could not read camera name: {}\n",
} catch (const wpi::util::json::exception& e) {
wpi::util::print(stderr, "config error in '{}': could not read camera name: {}\n",
configFile, e.what());
return false;
}
@@ -79,8 +79,8 @@ bool ReadCameraConfig(const wpi::json& config) {
// path
try {
c.path = config.at("path").get<std::string>();
} catch (const wpi::json::exception& e) {
wpi::print(stderr,
} catch (const wpi::util::json::exception& e) {
wpi::util::print(stderr,
"config error in '{}': camera '{}': could not read path: {}\n",
configFile, c.name, e.what());
return false;
@@ -94,26 +94,26 @@ bool ReadCameraConfig(const wpi::json& config) {
bool ReadConfig() {
// open config file
auto fileBuffer = wpi::MemoryBuffer::GetFile(configFile);
auto fileBuffer = wpi::util::MemoryBuffer::GetFile(configFile);
if (!fileBuffer) {
wpi::print(stderr, "could not open '{}': {}\n", configFile,
wpi::util::print(stderr, "could not open '{}': {}\n", configFile,
fileBuffer.error().message());
return false;
}
// parse file
wpi::json j;
wpi::util::json j;
try {
j = wpi::json::parse(fileBuffer.value()->GetCharBuffer());
} catch (const wpi::json::parse_error& e) {
wpi::print(stderr, "config error in '{}': byte {}: {}\n", configFile,
j = wpi::util::json::parse(fileBuffer.value()->GetCharBuffer());
} catch (const wpi::util::json::parse_error& e) {
wpi::util::print(stderr, "config error in '{}': byte {}: {}\n", configFile,
e.byte, e.what());
return false;
}
// top level must be an object
if (!j.is_object()) {
wpi::print(stderr, "config error in '{}': must be JSON object\n",
wpi::util::print(stderr, "config error in '{}': must be JSON object\n",
configFile);
return false;
}
@@ -121,8 +121,8 @@ bool ReadConfig() {
// team number
try {
team = j.at("team").get<unsigned int>();
} catch (const wpi::json::exception& e) {
wpi::print(stderr, "config error in '{}': could not read team number: {}\n",
} catch (const wpi::util::json::exception& e) {
wpi::util::print(stderr, "config error in '{}': could not read team number: {}\n",
configFile, e.what());
return false;
}
@@ -131,18 +131,18 @@ bool ReadConfig() {
if (j.count("ntmode") != 0) {
try {
auto str = j.at("ntmode").get<std::string>();
if (wpi::equals_lower(str, "client")) {
if (wpi::util::equals_lower(str, "client")) {
server = false;
} else if (wpi::equals_lower(str, "server")) {
} else if (wpi::util::equals_lower(str, "server")) {
server = true;
} else {
wpi::print(
wpi::util::print(
stderr,
"config error in '{}': could not understand ntmode value '{}'\n",
configFile, str);
}
} catch (const wpi::json::exception& e) {
wpi::print(stderr, "config error in '{}': could not read ntmode: {}\n",
} catch (const wpi::util::json::exception& e) {
wpi::util::print(stderr, "config error in '{}': could not read ntmode: {}\n",
configFile, e.what());
}
}
@@ -154,8 +154,8 @@ bool ReadConfig() {
return false;
}
}
} catch (const wpi::json::exception& e) {
wpi::print(stderr, "config error in '{}': could not read cameras: {}\n",
} catch (const wpi::util::json::exception& e) {
wpi::util::print(stderr, "config error in '{}': could not read cameras: {}\n",
configFile, e.what());
return false;
}
@@ -164,9 +164,9 @@ bool ReadConfig() {
}
void StartCamera(const CameraConfig& config) {
wpi::print("Starting camera '{}' on {}\n", config.name, config.path);
wpi::util::print("Starting camera '{}' on {}\n", config.name, config.path);
auto camera =
frc::CameraServer::StartAutomaticCapture(config.name, config.path);
wpi::CameraServer::StartAutomaticCapture(config.name, config.path);
camera.SetConfigJson(config.config);
}
@@ -183,12 +183,12 @@ int main(int argc, char* argv[]) {
}
// start NetworkTables
auto ntinst = nt::NetworkTableInstance::GetDefault();
auto ntinst = wpi::nt::NetworkTableInstance::GetDefault();
if (server) {
std::puts("Setting up NetworkTables server");
ntinst.StartServer();
} else {
wpi::print("Setting up NetworkTables client for team {}\n", team);
wpi::util::print("Setting up NetworkTables client for team {}\n", team);
ntinst.StartClient("multicameraserver");
ntinst.SetServerTeam(team);
}