Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all known topics on networktables client connect #753

Merged
merged 2 commits into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@Description(
group = "edu.wpi.first.shuffleboard",
name = "NetworkTables",
version = "2.3.0",
version = "2.3.1",
summary = "Provides sources and widgets for NetworkTables"
)
public class NetworkTablesPlugin extends Plugin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableEvent;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.networktables.Topic;

import java.util.EnumSet;
import java.util.List;
Expand Down Expand Up @@ -49,6 +50,18 @@ public NetworkTableSourceType(NetworkTablesPlugin plugin) {
availableSourceIds.clear();
NetworkTableSource.removeAllCachedSources();
});
} else if (event.is(NetworkTableEvent.Kind.kConnected)) {
FxUtils.runOnFxThread(() -> {
for (Topic topic : event.getInstance().getTopics()) {
String uri = toUri(topic.getName());
if (!availableSources.containsKey(uri)) {
availableSources.put(uri, topic.genericSubscribe().get().getValue());
}
if (!availableSourceIds.contains(uri)) {
availableSourceIds.add(uri);
}
}
});
}
});
inst.addListener(
Expand Down