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_TELEMETRY |
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
|
void |
handleDroppedConnection() |
void |
registerSyncdDevice(SyncdDevice device)
Register a sync'd device
|
void |
resetGamepads() |
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)
Unregister a sync'd device
|
public static final java.lang.String SYSTEM_TELEMETRY
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 handleDroppedConnection()
public void setMonitor(EventLoopManager.EventLoopMonitor monitor)
monitor
- event loop monitorpublic 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 devicepublic void unregisterSyncdDevice(SyncdDevice device)
device
- sync'd devicepublic void setEventLoop(EventLoop eventLoop) throws RobotCoreException
eventLoop
- new event loopRobotCoreException
- if event loop fails to initpublic 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 void resetGamepads()
public Heartbeat getHeartbeat()
public 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)