From 9a7aeafa07552bb62b811aeff21f050486129f2a Mon Sep 17 00:00:00 2001 From: Carl Hauser Date: Tue, 10 Oct 2023 23:28:08 -0700 Subject: [PATCH] Bug fixes including choosers that don't appear and livewindow widgets that don't appear (#185) Fixed conflicts in moving these changes from the old NT3 world to the NT4-based SmartDashboard. --- .../first/smartdashboard/SmartDashboard.java | 34 +++++++++++++++++++ .../livewindow/elements/LWSubsystem.java | 8 +++++ .../wpi/first/smartdashboard/robot/Robot.java | 16 +++++++++ 3 files changed, 58 insertions(+) diff --git a/src/main/java/edu/wpi/first/smartdashboard/SmartDashboard.java b/src/main/java/edu/wpi/first/smartdashboard/SmartDashboard.java index 446df70..610c994 100644 --- a/src/main/java/edu/wpi/first/smartdashboard/SmartDashboard.java +++ b/src/main/java/edu/wpi/first/smartdashboard/SmartDashboard.java @@ -171,5 +171,39 @@ public void run() { teamProp.setValue(teamNumber); monitor.setProgress(1000); } + + + if (argParser.hasValue("ip")) { + monitor.setProgress(1000); + monitor.setNote("Connecting to robot at: " + argParser.getValue("ip")); + Robot.setHost(argParser.getValue("ip")); + System.out.println("IP: " + argParser.getValue("ip")); + } else { + NetworkTable.setDSClientEnabled(true); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + // No harm if the sleep is interrupted + } + monitor.setProgress(800); + 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(850); + monitor.setNote("Connecting to robot: " + teamNumber); + Robot.setHost(teamNumber); + teamProp.setValue(teamNumber); + monitor.setProgress(1000); + } } } diff --git a/src/main/java/edu/wpi/first/smartdashboard/livewindow/elements/LWSubsystem.java b/src/main/java/edu/wpi/first/smartdashboard/livewindow/elements/LWSubsystem.java index a254ba7..2acca2c 100644 --- a/src/main/java/edu/wpi/first/smartdashboard/livewindow/elements/LWSubsystem.java +++ b/src/main/java/edu/wpi/first/smartdashboard/livewindow/elements/LWSubsystem.java @@ -93,7 +93,11 @@ private void addSubsystemElement(String key, NetworkTable value) { System.out.println( "\nSubsystem \"" + getFieldName() + "\" does not contain widget \"" + key + "\""); System.out.println("Table: " + value); +<<<<<<< HEAD System.out.println("Type: " + value.getEntry(".type").getString(null)); +======= + System.out.println("Type: " + value.getString(".type", null)); +>>>>>>> 72dbfdf (Bug fixes including choosers that don't appear and livewindow widgets that don't appear (#185)) DataType dataType = DataType.getType(value); if (dataType != null) { System.out.println( @@ -116,7 +120,11 @@ private void addSubsystemElement(String key, NetworkTable value) { revalidate(); repaint(); } else { +<<<<<<< HEAD System.out.println("Skipping: No registered dataType for type " + value.getEntry(".type").getString(null)); +======= + System.out.println("Skipping: No registered dataType for type " + value.getString(".type", null) ); +>>>>>>> 72dbfdf (Bug fixes including choosers that don't appear and livewindow widgets that don't appear (#185)) } System.out.println(); } catch (InstantiationException | IllegalAccessException ex) { diff --git a/src/main/java/edu/wpi/first/smartdashboard/robot/Robot.java b/src/main/java/edu/wpi/first/smartdashboard/robot/Robot.java index c9eeab9..c63a85b 100644 --- a/src/main/java/edu/wpi/first/smartdashboard/robot/Robot.java +++ b/src/main/java/edu/wpi/first/smartdashboard/robot/Robot.java @@ -1,10 +1,19 @@ package edu.wpi.first.smartdashboard.robot; +<<<<<<< HEAD import java.util.function.Consumer; import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableEvent; import edu.wpi.first.networktables.NetworkTableInstance; +======= +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import edu.wpi.first.wpilibj.networktables.NetworkTable; +import edu.wpi.first.wpilibj.tables.IRemoteConnectionListener; +import edu.wpi.first.wpilibj.tables.ITable; +>>>>>>> 72dbfdf (Bug fixes including choosers that don't appear and livewindow widgets that don't appear (#185)) /** * @author Joe @@ -21,12 +30,19 @@ public class Robot { private static final NetworkTableInstance ntInstance = NetworkTableInstance.getDefault(); static { +<<<<<<< HEAD ntInstance.stopDSClient(); ntInstance.startClient4(identity); } public static void startDSClient() { ntInstance.startDSClient(); +======= + NetworkTable.setClientMode(); + NetworkTable.setNetworkIdentity(identity); + NetworkTable.setDSClientEnabled(false); + NetworkTable.initialize(); +>>>>>>> 72dbfdf (Bug fixes including choosers that don't appear and livewindow widgets that don't appear (#185)) } public static void setTeam(int team) {