Class Control
java.lang.Object
io.github.roboblazers7617.buttonbox.Control
- Direct Known Subclasses:
Button,Joystick,Knob,LED,TestControl
Class for buttonbox controls that handles feedback and NetworkTables.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetId()Gets the ID of this control.getTable()Gets the NetworkTable used by this Control.voidsetTable(NetworkTable table) Sets the NetworkTable to be used by this Control.voidsetupNetworkTables(NetworkTable table) Called by the Control class when the NetworkTable is set bysetTable(NetworkTable).voidShould set up any simulation-specific things.voidUpdates the control's state on the client.voidInterfaces with the buttonbox hardware and updates the state of the physical control.voidUpdates the control's state on the client and hardware.voidUpdates the control's state on the server.
-
Constructor Details
-
Control
Creates a new Control.- Parameters:
id- The ID string that the device should use. This will be used as the name for the NetworkTables subtable for this control.
-
-
Method Details
-
updateServer
public void updateServer()Updates the control's state on the server.This doesn't do anything by default, and should be overridden by the class inheritting this.
-
updateOnClient
public void updateOnClient()Updates the control's state on the client and hardware. This is called by the program loop and is not intended to be overridden. -
updateClient
public void updateClient()Updates the control's state on the client. This should get any feedback from the server, but this should not interface with the buttonbox hardware.This doesn't do anything by default, and should be overridden by the class inheritting this.
-
updateHardware
public void updateHardware()Interfaces with the buttonbox hardware and updates the state of the physical control. Called afterupdateClient().This doesn't do anything by default, and should be overridden by the class inheritting this.
-
setupNetworkTables
Called by the Control class when the NetworkTable is set bysetTable(NetworkTable). intended to be called outside of the class.This should create all of the NetworkTables publishers and subscribers for the inheritting class.
- Parameters:
table- The table to use. When called bysetTable(NetworkTable), this is a subtable with the ID string as its key.
-
setupSimulation
public void setupSimulation()Should set up any simulation-specific things.Called as a part of the constructor if the library is running in simulation.
-
getId
Gets the ID of this control.- Returns:
- The ID of this control.
-
getTable
Gets the NetworkTable used by this Control.- Returns:
- The NetworkTable used by this control.
-
setTable
Sets the NetworkTable to be used by this Control. A subtable will be created with the ID string as its key.- Parameters:
table- The table to use.
-