[ntcore] Change Java event mask to EnumSet (#4564)

Also convert NetworkTableInstance.getNetworkMode() to return EnumSet.
This commit is contained in:
Peter Johnson
2022-11-04 20:25:37 -07:00
committed by GitHub
parent fa44a07938
commit 5005e2ca04
12 changed files with 216 additions and 115 deletions

View File

@@ -17,6 +17,7 @@ import edu.wpi.first.networktables.NetworkTableListener;
import edu.wpi.first.networktables.StringPublisher;
import edu.wpi.first.networktables.Topic;
import java.util.Collection;
import java.util.EnumSet;
/**
* The preferences class provides a relatively simple way to save important values to the roboRIO to
@@ -77,7 +78,7 @@ public final class Preferences {
m_listener =
NetworkTableListener.createListener(
m_tableSubscriber,
NetworkTableEvent.kImmediate | NetworkTableEvent.kPublish,
EnumSet.of(NetworkTableEvent.Kind.kImmediate, NetworkTableEvent.Kind.kPublish),
event -> {
if (event.topicInfo != null) {
Topic topic = event.topicInfo.getTopic();

View File

@@ -155,7 +155,7 @@ public abstract class RobotBase implements AutoCloseable {
// wait for the NT server to actually start
try {
int count = 0;
while ((inst.getNetworkMode() & NetworkTableInstance.kNetModeStarting) != 0) {
while (inst.getNetworkMode().contains(NetworkTableInstance.NetworkMode.kStarting)) {
Thread.sleep(10);
count++;
if (count > 100) {