public class EventLoopManager
extends java.lang.Object
Takes RobocolDatagram messages, converts them into the appropriate data type, and then passes it to the current EventLoop.
| Modifier and Type | Class and Description |
|---|---|
static interface |
EventLoopManager.EventLoopMonitor
Callback to monitor when event loop changes state
|
static class |
EventLoopManager.State |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
RC_BATTERY_LEVEL_KEY |
static java.lang.String |
ROBOT_BATTERY_LEVEL_KEY |
RobotState |
state |
static java.lang.String |
SYSTEM_ERROR_KEY |
static java.lang.String |
SYSTEM_NONE_KEY |
static java.lang.String |
SYSTEM_WARNING_KEY |
| Constructor and Description |
|---|
EventLoopManager(RobocolDatagramSocket socket)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
buildAndSendTelemetry(java.lang.String tag,
java.lang.String msg) |
EventLoop |
getEventLoop()
Get the current event loop
|
Gamepad |
getGamepad()
Get the current gamepad state
|
Gamepad |
getGamepad(int port)
Get the gamepad connected to a particular user
|
Gamepad[] |
getGamepads()
Get the gamepads
|
Heartbeat |
getHeartbeat()
Get the current heartbeat state
|
EventLoopManager.EventLoopMonitor |
getMonitor()
return any event loop monitor previously set
|
void |
handleDroppedConnection() |
void |
refreshSystemTelemetry()
Do our best to maintain synchrony of the system error / warning state between applications
without incurring undo overhead.
|
void |
refreshSystemTelemetryNow()
Forces an immediate refresh of the system telemetry
|
void |
registerSyncdDevice(SyncdDevice device)
Register a sync'd device
|
void |
sendCommand(Command command) |
void |
sendTelemetryData(Telemetry telemetry)
Send telemetry data
|
void |
setEventLoop(EventLoop eventLoop)
Replace the current event loop with a new event loop
|
void |
setMonitor(EventLoopManager.EventLoopMonitor monitor)
Set a monitor for this event loop
|
void |
shutdown()
Shut down the event processor
|
void |
start(EventLoop eventLoop)
Start the event processor
|
void |
unregisterSyncdDevice(SyncdDevice device)
Unregisters a device from this event loop.
|
public static final java.lang.String SYSTEM_NONE_KEY
public static final java.lang.String SYSTEM_ERROR_KEY
public static final java.lang.String SYSTEM_WARNING_KEY
public static final java.lang.String ROBOT_BATTERY_LEVEL_KEY
public static final java.lang.String RC_BATTERY_LEVEL_KEY
public RobotState state
public EventLoopManager(RobocolDatagramSocket socket)
socket - socket for IO with remote devicepublic void setMonitor(EventLoopManager.EventLoopMonitor monitor)
monitor - event loop monitorpublic EventLoopManager.EventLoopMonitor getMonitor()
public EventLoop getEventLoop()
public Gamepad getGamepad()
Port 0 is assumed
getGamepad(int)public Gamepad getGamepad(int port)
port - user 0 and 1 are validpublic Gamepad[] getGamepads()
Array index will match the user number
public Heartbeat getHeartbeat()
public void refreshSystemTelemetryNow()
public void refreshSystemTelemetry()
public void handleDroppedConnection()
public void start(EventLoop eventLoop) throws RobotCoreException
eventLoop - set initial event loopRobotCoreException - if event loop fails to initpublic void shutdown()
public void registerSyncdDevice(SyncdDevice device)
device - sync'd deviceunregisterSyncdDevice(SyncdDevice)public void unregisterSyncdDevice(SyncdDevice device)
device - the device to be unregistered. May not be null.registerSyncdDevice(SyncdDevice)public void setEventLoop(EventLoop eventLoop) throws RobotCoreException
eventLoop - new event loopRobotCoreException - if event loop fails to initpublic void sendTelemetryData(Telemetry telemetry)
Send the telemetry data, and then clear the sent data
telemetry - telemetry datapublic void sendCommand(Command command)
public void buildAndSendTelemetry(java.lang.String tag,
java.lang.String msg)