| Modifier and Type | Class and Description |
|---|---|
class |
FtcEventLoop.DefaultUsbModuleAttachmentHandler |
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Set<java.lang.String> |
attachedUsbDevices |
protected java.lang.Object |
attachedUsbDevicesLock |
protected FtcEventLoopHandler |
ftcEventLoopHandler |
protected OpModeManager |
opModeManager |
protected java.util.concurrent.atomic.AtomicReference<OpMode> |
opModeStopRequested |
protected OpModeRegister |
register |
protected Context |
robotControllerContext |
protected UsbModuleAttachmentHandler |
usbModuleAttachmentHandler |
TELEMETRY_DEFAULT_INTERVAL| Constructor and Description |
|---|
FtcEventLoop(HardwareFactory hardwareFactory,
OpModeRegister register,
UpdateUI.Callback callback,
Context robotControllerContext) |
| Modifier and Type | Method and Description |
|---|---|
protected OpModeManager |
createOpModeManager() |
OpModeManager |
getOpModeManager()
Returns the OpModeManager associated with this event loop
|
protected java.lang.String |
getSerialNumberOfUsbDevice(UsbDevice usbDevice) |
UsbModuleAttachmentHandler |
getUsbModuleAttachmentHandler() |
void |
handleUsbModuleDetach(RobotUsbModule module)
Process the fact that a usb module has now become detached from the system.
|
void |
init(EventLoopManager eventLoopManager)
Init method
|
void |
loop()
Loop method, this will be called repeatedly while the robot is running.
|
void |
onUsbDeviceAttached(UsbDevice usbDevice)
Deal with the fact that a UsbDevice has recently attached to the system
|
void |
processCommand(Command command)
If the driver station sends over a command, it will be routed to this method.
|
void |
processedRecentlyAttachedUsbDevices()
Process any usb devices that might have recently attached.
|
void |
refreshUserTelemetry(Telemetry 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 |
setUsbModuleAttachmentHandler(UsbModuleAttachmentHandler handler) |
void |
teardown()
Teardown method
|
protected Context robotControllerContext
protected FtcEventLoopHandler ftcEventLoopHandler
protected OpModeManager opModeManager
protected OpModeRegister register
protected UsbModuleAttachmentHandler usbModuleAttachmentHandler
protected final java.lang.Object attachedUsbDevicesLock
protected java.util.Set<java.lang.String> attachedUsbDevices
protected java.util.concurrent.atomic.AtomicReference<OpMode> opModeStopRequested
public FtcEventLoop(HardwareFactory hardwareFactory,
OpModeRegister register,
UpdateUI.Callback callback,
Context robotControllerContext)
protected OpModeManager createOpModeManager()
public OpModeManager getOpModeManager()
EventLoopgetOpModeManager in interface EventLooppublic UsbModuleAttachmentHandler getUsbModuleAttachmentHandler()
public void setUsbModuleAttachmentHandler(UsbModuleAttachmentHandler handler)
public void init(EventLoopManager eventLoopManager) throws RobotCoreException, java.lang.InterruptedException
This code will run when the robot first starts up. Place any initialization code in this method.
It is important to save a copy of the event loop manager from this method, as that is how you'll get access to the gamepad.
If an Exception is thrown then the event loop manager will not start the robot.
Caller synchronizes: called on RobotSetupRunnable.run() thread
init in interface EventLoopeventLoopManager - 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.InterruptedExceptionpublic void loop()
throws RobotCoreException
loop in interface EventLoopRobotCoreException - 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.
Caller synchronizes: called on EventLoopRunnable.run() thread.
public void refreshUserTelemetry(Telemetry telemetry, double sInterval)
EventLooprefreshUserTelemetry in interface EventLooptelemetry - the telemetry object to sendsInterval - the required minimum interval. NaN indicates that a system default interval should be used.public void teardown()
throws RobotCoreException
This method will be called when the robot is being shut down. This method should stop the robot. There will be no more changes to write to the hardware after this method is called.
If an exception is thrown, then the event loop manager will attempt to shut down the robot without the benefit of this method.
teardown in interface EventLoopRobotCoreException - 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.
Caller synchronizes: called on EventLoopRunnable.run() thread.
public void processCommand(Command command)
Called on RecvRunnable.run() thread. Method is thread safem, non-interfering
processCommand in interface EventLoopcommand - command to processpublic void requestOpModeStop(OpMode opModeToStopIfActive)
EventLooprequestOpModeStop in interface EventLoopopModeToStopIfActive - the OpMode to stop if it's currently activepublic void onUsbDeviceAttached(UsbDevice usbDevice)
onUsbDeviceAttached in interface EventLoopusbDevice - EventLoop.processedRecentlyAttachedUsbDevices()protected java.lang.String getSerialNumberOfUsbDevice(UsbDevice usbDevice)
public void processedRecentlyAttachedUsbDevices()
throws RobotCoreException,
java.lang.InterruptedException
processedRecentlyAttachedUsbDevices in interface EventLoopRobotCoreExceptionjava.lang.InterruptedExceptionEventLoop.handleUsbModuleDetach(RobotUsbModule),
EventLoop.onUsbDeviceAttached(UsbDevice)public void handleUsbModuleDetach(RobotUsbModule module)
throws RobotCoreException,
java.lang.InterruptedException
EventLoophandleUsbModuleDetach in interface EventLoopRobotCoreExceptionjava.lang.InterruptedExceptionEventLoop.processedRecentlyAttachedUsbDevices()