Skip to content

Commit

Permalink
Enable DSClient after loading save.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
chauser committed Sep 5, 2023
1 parent 6068a32 commit 33469b7
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions src/main/java/edu/wpi/first/smartdashboard/SmartDashboard.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.wpi.first.smartdashboard;

import edu.wpi.first.wpilibj.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTablesJNI;
import edu.wpi.first.smartdashboard.extensions.FileSniffer;
import edu.wpi.first.smartdashboard.gui.DashboardFrame;
Expand Down Expand Up @@ -101,32 +102,6 @@ public void run() {
System.exit(2);
}

if (argParser.hasValue("ip")) {
monitor.setProgress(650);
monitor.setNote("Connecting to robot at: " + argParser.getValue("ip"));
Robot.setHost(argParser.getValue("ip"));
System.out.println("IP: " + argParser.getValue("ip"));
} else {
monitor.setProgress(600);
monitor.setNote("Getting Team Number");
StringProperty teamProp = frame.getPrefs().team;
String teamNumber = teamProp.getValue();

teamNumberLoop:
while (teamNumber.equals("0")) {
String input = JOptionPane.showInputDialog("Input Team Number\\Host");
if (input == null) {
break teamNumberLoop;
}
teamNumber = input;
}

monitor.setProgress(650);
monitor.setNote("Connecting to robot: " + teamNumber);
Robot.setHost(teamNumber);
teamProp.setValue(teamNumber);
}

try {
SwingUtilities.invokeAndWait(new Runnable() {

Expand Down Expand Up @@ -157,5 +132,32 @@ public void run() {
ex.printStackTrace();
System.exit(2);
}

NetworkTable.setDSClientEnabled(true);
if (argParser.hasValue("ip")) {
monitor.setProgress(650);
monitor.setNote("Connecting to robot at: " + argParser.getValue("ip"));
Robot.setHost(argParser.getValue("ip"));
System.out.println("IP: " + argParser.getValue("ip"));
} else {
monitor.setProgress(600);
monitor.setNote("Getting Team Number");
StringProperty teamProp = frame.getPrefs().team;
String teamNumber = teamProp.getValue();

teamNumberLoop:
while (teamNumber.equals("0")) {
String input = JOptionPane.showInputDialog("Input Team Number\\Host");
if (input == null) {
break teamNumberLoop;
}
teamNumber = input;
}

monitor.setProgress(650);
monitor.setNote("Connecting to robot: " + teamNumber);
Robot.setHost(teamNumber);
teamProp.setValue(teamNumber);
}
}
}

0 comments on commit 33469b7

Please sign in to comment.