public class FtcEventLoop extends FtcEventLoopBase
Modify this class with your own code, or create your own event loop by implementing EventLoop.
| Modifier and Type | Class and Description |
|---|---|
class |
FtcEventLoop.DefaultUsbModuleAttachmentHandler |
FtcEventLoopBase.LynxUsbDeviceContainer| Modifier and Type | Field and Description |
|---|---|
protected OpModeManagerImpl |
opModeManager |
protected java.util.concurrent.atomic.AtomicReference<OpMode> |
opModeStopRequested |
protected java.util.Map<java.lang.String,java.lang.Long> |
recentlyAttachedUsbDevices |
protected UsbModuleAttachmentHandler |
usbModuleAttachmentHandler |
protected Utility |
utility |
activityContext, ftcEventLoopHandler, networkConnectionHandler, programmingModeController, registeredOpModes, robotCfgFileMgr, runningOnDriverStation, TAG, usbScanManager, userOpmodeRegisterTELEMETRY_DEFAULT_INTERVAL| Constructor and Description |
|---|
FtcEventLoop(HardwareFactory hardwareFactory,
OpModeRegister userOpmodeRegister,
UpdateUI.Callback callback,
android.app.Activity activityContext,
ProgrammingModeController programmingModeController) |
| Modifier and Type | Method and Description |
|---|---|
protected static OpModeManagerImpl |
createOpModeManager(android.app.Activity activityContext) |
OpModeManagerImpl |
getOpModeManager()
Returns the OpModeManager associated with this event loop
|
protected SerialNumber |
getSerialNumberOfUsbDevice(android.hardware.usb.UsbDevice usbDevice) |
UsbModuleAttachmentHandler |
getUsbModuleAttachmentHandler() |
protected void |
handleCommandDiscoverLynxModules(java.lang.String extra) |
protected void |
handleCommandInitOpMode(java.lang.String extra) |
protected void |
handleCommandRunOpMode(java.lang.String extra) |
protected void |
handleCommandScan(java.lang.String extra) |
protected void |
handleCommandSetMatchNumber(java.lang.String extra) |
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
|
void |
loop()
Loop method, this will be called repeatedly while the robot is running.
|
void |
onUsbDeviceAttached(android.hardware.usb.UsbDevice usbDevice)
Deal with the fact that a UsbDevice has recently attached to the system
|
void |
pendUsbDeviceAttachment(SerialNumber serialNumber,
long time,
java.util.concurrent.TimeUnit unit) |
CallbackResult |
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(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
|
protected void |
sendUIState()
The driver station is requesting our opmode list/ UI state.
|
void |
setUsbModuleAttachmentHandler(UsbModuleAttachmentHandler handler) |
void |
teardown()
Teardown method
|
checkForChangedOpModes, enterFirmwareUpdateMode, getLynxUsbDeviceForFirmwareUpdate, getUSBAccessibleLynxDevices, handleCommandActivateConfiguration, handleCommandClearRememberedGroups, handleCommandDeleteConfiguration, handleCommandDisconnectWifiDirect, handleCommandDismissAllDialogs, handleCommandDismissDialog, handleCommandDismissProgress, handleCommandGetCandidateLynxFirmwareImages, handleCommandGetUSBAccessibleLynxModules, handleCommandLynxChangeModuleAddresses, handleCommandLynxFirmwareUpdate, handleCommandRequestAboutInfo, handleCommandRequestConfigurations, handleCommandRequestConfigurationTemplates, handleCommandRequestInspectionReport, handleCommandRequestParticularConfiguration, handleCommandRequestRememberedGroups, handleCommandRestartRobot, handleCommandSaveConfiguration, handleCommandShowDialog, handleCommandShowProgress, handleCommandShowToast, handleCommandStartDriverStationProgramAndManage, handleCommandStartProgrammingMode, handleCommandStopProgrammingMode, handleCommandVisuallyConfirmWifiReset, handleCommandVisuallyIdentify, startUsbScanMangerIfNecessary, talkToParentLynxModule, updateFirmwareOnce, updateLynxFirmwareprotected final Utility utility
protected final OpModeManagerImpl opModeManager
protected UsbModuleAttachmentHandler usbModuleAttachmentHandler
protected final java.util.Map<java.lang.String,java.lang.Long> recentlyAttachedUsbDevices
protected final java.util.concurrent.atomic.AtomicReference<OpMode> opModeStopRequested
public FtcEventLoop(HardwareFactory hardwareFactory,
OpModeRegister userOpmodeRegister,
UpdateUI.Callback callback,
android.app.Activity activityContext,
ProgrammingModeController programmingModeController)
protected static OpModeManagerImpl createOpModeManager(android.app.Activity activityContext)
public OpModeManagerImpl getOpModeManager()
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 EventLoopinit in class FtcEventLoopBaseeventLoopManager - 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
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.
Caller synchronizes: called on EventLoopRunnable.run() thread.
public void refreshUserTelemetry(TelemetryMessage telemetry,
double sInterval)
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,
java.lang.InterruptedException
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 EventLoopteardown in class FtcEventLoopBaseRobotCoreException - 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
Caller synchronizes: called on EventLoopRunnable.run() thread.
public CallbackResult processCommand(Command command)
throws java.lang.InterruptedException,
RobotCoreException
Called on RecvRunnable.run() thread. Method is thread safe, non-interfering
processCommand in interface EventLoopprocessCommand in class FtcEventLoopBasecommand - command to processjava.lang.InterruptedExceptionRobotCoreExceptionprotected void handleCommandScan(java.lang.String extra)
throws RobotCoreException,
java.lang.InterruptedException
RobotCoreExceptionjava.lang.InterruptedExceptionFtcConfigurationActivity#doUSBScanAndUpdateUI()protected void handleCommandDiscoverLynxModules(java.lang.String extra)
throws RobotCoreException,
java.lang.InterruptedException
RobotCoreExceptionjava.lang.InterruptedExceptionprotected void sendUIState()
sendUIState in class FtcEventLoopBaseprotected void handleCommandSetMatchNumber(java.lang.String extra)
protected void handleCommandInitOpMode(java.lang.String extra)
protected void handleCommandRunOpMode(java.lang.String extra)
public void requestOpModeStop(OpMode opModeToStopIfActive)
EventLoopopModeToStopIfActive - the OpMode to stop if it's currently activepublic void onUsbDeviceAttached(android.hardware.usb.UsbDevice usbDevice)
usbDevice - EventLoop.processedRecentlyAttachedUsbDevices()protected SerialNumber getSerialNumberOfUsbDevice(android.hardware.usb.UsbDevice usbDevice)
public void pendUsbDeviceAttachment(SerialNumber serialNumber, long time, java.util.concurrent.TimeUnit unit)
public void processedRecentlyAttachedUsbDevices()
throws RobotCoreException,
java.lang.InterruptedException
RobotCoreExceptionjava.lang.InterruptedExceptionEventLoop.handleUsbModuleDetach(RobotUsbModule),
EventLoop.onUsbDeviceAttached(UsbDevice)public void handleUsbModuleDetach(RobotUsbModule module)
throws RobotCoreException,
java.lang.InterruptedException
EventLoopRobotCoreExceptionjava.lang.InterruptedExceptionEventLoop.processedRecentlyAttachedUsbDevices()public void handleUsbModuleAttach(RobotUsbModule module)
throws RobotCoreException,
java.lang.InterruptedException
EventLoopRobotCoreExceptionjava.lang.InterruptedException