Add a NetworkTables client to download paths

Rename shooter CSV file
Add workspace file
This commit is contained in:
nathanrsxtn
2022-03-01 20:23:01 -07:00
parent cd4fd4938a
commit 2fc3297c64
24 changed files with 444 additions and 14 deletions
@@ -0,0 +1,34 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Scanner;
import edu.wpi.first.networktables.EntryListenerFlags;
import edu.wpi.first.networktables.NetworkTableInstance;
public class NetworkTablesDesktopClient {
public static void main(String[] args) {
NetworkTableInstance instance = NetworkTableInstance.getDefault();
instance.getTable("Recording").addEntryListener((table, key, entry, value, flags) -> {
// File file = new File(key);
Path path = Path.of("..", "src", "main", "deploy", "pathplanner", key);
File file = path.toFile();
try {
System.err.println("Creating path " + key);
file.createNewFile();
Files.writeString(file.toPath(), value.getString());
System.err.println("Recorded path to " + file.getPath());
} catch (IOException exception) {
exception.printStackTrace();
}
}, EntryListenerFlags.kNew);
// instance.startClientTeam(4388);
instance.startClient("localhost");
instance.startDSClient();
try (Scanner scanner = new Scanner(System.in)) {
System.err.println("Press enter to stop...");
scanner.nextLine();
}
}
}