Package networktablesviewer
Class NetworkAbstraction
java.lang.Object
networktablesviewer.NetworkAbstraction
This class provides a simpler way to access NT
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassHolds information about a Topic -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new NetworkAbstraction with identifier NTVC-lcl This should only by one client connected to a NT server -
Method Summary
Modifier and TypeMethodDescriptionvoidCloses the connection and acquires the semaphore but never releases it This instance will be useless after this call This should be used to stop all other threads from trying to use this NT instance This will also free up the network identifier NTVC-lclvoidconnect()Connects to the NT server using information from the Driver Station Driver Station must be running for this method to workvoidConnects to the NT server given a hostnameintgetError()Gets the previous error (sticky)Gets the latest topics from the server May include duplicates and older valuesbooleanChecks if we are connected to the NT server It is possible for the port to be open but to not be connectedbooleanisOpen()Checks if NT port is opensquashLatest(ArrayList<NetworkAbstraction.TopicValue> current, ArrayList<NetworkAbstraction.TopicValue> latest) Squashes latest and old TopicValues together Will include any old topics with no new valuesChecks to see which Topics are still being published
-
Constructor Details
-
NetworkAbstraction
public NetworkAbstraction()Constructs a new NetworkAbstraction with identifier NTVC-lcl This should only by one client connected to a NT server
-
-
Method Details
-
connect
public void connect()Connects to the NT server using information from the Driver Station Driver Station must be running for this method to work -
isOpen
public boolean isOpen()Checks if NT port is open- Returns:
- true if NT port is open
-
connect
Connects to the NT server given a hostname- Parameters:
host- hostname of the server
-
isConnected
public boolean isConnected()Checks if we are connected to the NT server It is possible for the port to be open but to not be connected- Returns:
- true if conected with an NT server
-
closeAndLock
public void closeAndLock()Closes the connection and acquires the semaphore but never releases it This instance will be useless after this call This should be used to stop all other threads from trying to use this NT instance This will also free up the network identifier NTVC-lcl -
getError
public int getError()Gets the previous error (sticky)- Returns:
- error code: 0 - never connected, 1 - able to connect, 2 - disconnected
-
getLatest
Gets the latest topics from the server May include duplicates and older values- Returns:
- latest TopicValues
-
updateExists
public ArrayList<NetworkAbstraction.TopicValue> updateExists(ArrayList<NetworkAbstraction.TopicValue> latest) Checks to see which Topics are still being published- Parameters:
latest- Latest topic values- Returns:
- Topic values with updates exists members
-
squashLatest
public static ArrayList<NetworkAbstraction.TopicValue> squashLatest(ArrayList<NetworkAbstraction.TopicValue> current, ArrayList<NetworkAbstraction.TopicValue> latest) Squashes latest and old TopicValues together Will include any old topics with no new values- Parameters:
current- Outdated topic valueslatest- Latest topic values- Returns:
- Latest topic values without duplicates
-