-
Notifications
You must be signed in to change notification settings - Fork 107
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 NetworkTableSource #646
Changes from 8 commits
640cf32
daa5110
abd31fb
c9efca1
fd1075b
e8cd49e
d2e9bd8
40450c5
fc680f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,3 +88,7 @@ bower_components | |
**/generated | ||
*/generated_tests | ||
/bin/ | ||
|
||
### NetworkTables | ||
networktables.ini | ||
networktables.ini.bak |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package edu.wpi.grip.core.operations.network; | ||
|
||
|
||
/** | ||
* A factory to create {@link NetworkReceiver NetworkRecievers}. | ||
*/ | ||
@FunctionalInterface | ||
public interface MapNetworkReceiverFactory { | ||
NetworkReceiver create(String path); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package edu.wpi.grip.core.operations.network; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import static com.google.common.base.Preconditions.checkArgument; | ||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
/** | ||
* Manages the interface between the {@link PublishAnnotatedOperation} and the actual network | ||
* protocol implemented by a specific {@link Manager}. | ||
*/ | ||
public abstract class NetworkReceiver implements AutoCloseable { | ||
|
||
protected final String path; | ||
|
||
/** | ||
* Create a new NetworkReceiver with the specified path. | ||
* | ||
* @param path The path of the object to get | ||
*/ | ||
public NetworkReceiver(String path) { | ||
checkNotNull(path, "Path cannot be null"); | ||
checkArgument(!path.isEmpty(), "Path cannot be an empty string"); | ||
this.path = path; | ||
} | ||
|
||
/** | ||
* Get the value of the object. | ||
* | ||
* @return The value of this NetworkReceiver | ||
*/ | ||
public abstract Object getValue(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be generic? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want NetworkReceiver to not care what kind of object it gets. This means GRIP will handle any mismatch in NetworkTableEntrySource instead of NetworkReceiver |
||
|
||
/** | ||
* Add a listener to the NetworkReceiver item. | ||
* | ||
* @param consumer The consumer to call when this item has a update | ||
*/ | ||
public abstract void addListener(Consumer<Object> consumer); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be generic? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
/** | ||
* Close the network reciever. This should not throw an exception. | ||
*/ | ||
public abstract void close(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,5 +193,13 @@ public static SocketHint<Number> createNumberSocketHint(final String identifier, | |
defaultValue) { | ||
return createNumberSocketHintBuilder(identifier, defaultValue).build(); | ||
} | ||
|
||
public static SocketHint<String> createStringSocketHint(final String identifier, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have Javadoc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other methods in the class do not have any Javadoc. Should I add for all of them? |
||
String defaultValue) { | ||
return new SocketHint.Builder<String>(String.class) | ||
.identifier(identifier) | ||
.initialValue(defaultValue) | ||
.build(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a protected field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in person