public interface EventLoop
Event loops need to implement this interface. Contains methods for managing the life cycle of your robot.
Modifier and Type | Field and Description |
---|---|
static double |
TELEMETRY_DEFAULT_INTERVAL
The value to pass to
refreshUserTelemetry(TelemetryMessage, double) as the time interval
parameter in order to cause a system default interval to be used. |
Modifier and Type | Method and Description |
---|---|
OpModeManagerImpl |
getOpModeManager()
Returns the OpModeManager associated with this event loop
|
void |
handleUsbModuleAttach(RobotUsbModule module)
Process the fact that (we believe) that the indicated module has now reappeared after a
previously observed detachment.
|
void |
handleUsbModuleDetach(RobotUsbModule module)
Process the fact that a usb module has now become detached from the system.
|
void |
init(EventLoopManager eventLoopManager)
Init method, this will be called before the first call to loop.
|
void |
loop()
This method will be repeatedly called by the event loop manager.
|
void |
onUsbDeviceAttached(android.hardware.usb.UsbDevice usbDevice)
Notifies the event loop that a UsbDevice has just been attached to the system.
|
void |
pendUsbDeviceAttachment(SerialNumber serialNumber,
long time,
java.util.concurrent.TimeUnit unit) |
CallbackResult |
processCommand(Command command)
Process command method, this will be called if the event loop manager receives a user defined
command.
|
void |
processedRecentlyAttachedUsbDevices()
Process the batch of newly arrived USB devices.
|
void |
refreshUserTelemetry(TelemetryMessage telemetry,
double sInterval)
Update's the user portion of the driver station screen with the contents of the telemetry object
here provided if a sufficiently long duration has passed since the last update.
|
void |
requestOpModeStop(OpMode opModeToStopIfActive)
Requests that an OpMode be stopped if it's the currently active one
|
void |
teardown()
Teardown method, this will be called after the last call to loop.
|
static final double TELEMETRY_DEFAULT_INTERVAL
refreshUserTelemetry(TelemetryMessage, double)
as the time interval
parameter in order to cause a system default interval to be used.void init(EventLoopManager eventLoopManager) throws RobotCoreException, java.lang.InterruptedException
eventLoopManager
- event loop manager that is responsible for this event loopRobotCoreException
- if a RobotCoreException is thrown, it will be handled
by the event loop manager. The manager will report that the robot failed
to start.java.lang.InterruptedException
void loop() throws RobotCoreException, java.lang.InterruptedException
RobotCoreException
- if a RobotCoreException is thrown, it will be handled
by the event loop manager. The manager may decide to either stop processing
this iteration of the loop, or it may decide to shut down the robot.java.lang.InterruptedException
void refreshUserTelemetry(TelemetryMessage telemetry, double sInterval)
telemetry
- the telemetry object to sendsInterval
- the required minimum interval. NaN indicates that a system default interval should be used.void teardown() throws RobotCoreException, java.lang.InterruptedException
RobotCoreException
- if a RobotCoreException is thrown, it will be handled by the event
loop manager. The manager will then attempt to shut down the robot without the benefit
of the teardown method.java.lang.InterruptedException
void onUsbDeviceAttached(android.hardware.usb.UsbDevice usbDevice)
Implementations of this method should avoid doing significant processing during this notification. Rather, they should squirrel the device away for processing during a later processedRecentlyAttachedUsbDevices call.
usbDevice
- the newly arrived deviceprocessedRecentlyAttachedUsbDevices()
void pendUsbDeviceAttachment(SerialNumber serialNumber, long time, java.util.concurrent.TimeUnit unit)
void processedRecentlyAttachedUsbDevices() throws RobotCoreException, java.lang.InterruptedException
RobotCoreException
java.lang.InterruptedException
handleUsbModuleDetach(RobotUsbModule)
,
onUsbDeviceAttached(UsbDevice)
void handleUsbModuleDetach(RobotUsbModule module) throws RobotCoreException, java.lang.InterruptedException
module
- RobotCoreException
java.lang.InterruptedException
processedRecentlyAttachedUsbDevices()
void handleUsbModuleAttach(RobotUsbModule module) throws RobotCoreException, java.lang.InterruptedException
module
- RobotCoreException
java.lang.InterruptedException
CallbackResult processCommand(Command command) throws java.lang.InterruptedException, RobotCoreException
command
- command to processjava.lang.InterruptedException
RobotCoreException
OpModeManagerImpl getOpModeManager()
void requestOpModeStop(OpMode opModeToStopIfActive)
opModeToStopIfActive
- the OpMode to stop if it's currently active