Package com.reduxrobotics.canand
Class CanandEventLoop
java.lang.Object
com.reduxrobotics.canand.CanandEventLoop
- All Implemented Interfaces:
Runnable
Class that runs the CAN packet ingest loop, and starts the CANLink interface.
In order to start the Redux CANLink server, either instantiate any Redux device in your robot code or call
CanandEventLoop.getInstance();somewhere in an init function
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(CanandDevice listener) Adds a listener for CAN messages to the event loop.static CanandEventLoopReturns a handle to the event loop.voidremoveListener(CanandDevice listener) Removes a listener for CAN messages, if it is in fact listening.voidrun()voidsetDevicePresenceThreshold(CanandDevice device, double threshold) Sets the device presence threshold of how many seconds must pass without a message for the device checker to consider them disconnected from bus.voidsetDevicePresenceWarnings(CanandDevice device, boolean enabled) Set whether to enable device presence warnings to the driver station for a single device (defaults to true).voidsetGlobalDevicePresenceWarnings(boolean enabled) Set whether to enable device presence warnings to the driver station globally (defaults to true).
-
Method Details
-
getInstance
Returns a handle to the event loop. Starts it if not started.- Returns:
- the singleton instance
-
setGlobalDevicePresenceWarnings
public void setGlobalDevicePresenceWarnings(boolean enabled) Set whether to enable device presence warnings to the driver station globally (defaults to true).- Parameters:
enabled- true to enable, false to suppress
-
setDevicePresenceWarnings
Set whether to enable device presence warnings to the driver station for a single device (defaults to true).- Parameters:
device- the CanandDevice to considerenabled- true to enable, false to suppress
-
setDevicePresenceThreshold
Sets the device presence threshold of how many seconds must pass without a message for the device checker to consider them disconnected from bus.- Parameters:
device- the CanandDevice to act onthreshold- the new threshold, in seconds.
-
addListener
Adds a listener for CAN messages to the event loop.- Parameters:
listener- aCanandDevice
-
removeListener
Removes a listener for CAN messages, if it is in fact listening.- Parameters:
listener- theCanandDeviceto remove
-
run
public void run()
-