Class NetworkAbstraction

java.lang.Object
networktablesviewer.NetworkAbstraction

public class NetworkAbstraction extends Object
This class provides a simpler way to access NT
  • 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

      public void connect(String host)
      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

      Checks to see which Topics are still being published
      Parameters:
      latest - Latest topic values
      Returns:
      Topic values with updates exists members
    • squashLatest

      Squashes latest and old TopicValues together Will include any old topics with no new values
      Parameters:
      current - Outdated topic values
      latest - Latest topic values
      Returns:
      Latest topic values without duplicates