com.qualcomm.ftccommon

## Class FtcEventLoopBase

- java.lang.Object
- - com.qualcomm.ftccommon.FtcEventLoopBase

- All Implemented Interfaces:
    EventLoop
  Direct Known Subclasses:
    FtcEventLoop, FtcEventLoopIdle

      public abstract class FtcEventLoopBase
      extends java.lang.Object
      implements EventLoop

  `FtcEventLoopBase` is an abstract base that handles defines core event processing logic that's available whether or not a Robot is currently extant or not

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `FtcEventLoopBase.LynxUsbDeviceContainer` abstracts whether we've got a live LynxUsbDeviceImpl or we just opened something locally ourselves.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Activity` | `activityContext`
    `protected FtcEventLoopHandler` | `ftcEventLoopHandler`
    `protected NetworkConnectionHandler` | `networkConnectionHandler`
    `protected ProgrammingModeController` | `programmingModeController`
    `protected RegisteredOpModes` | `registeredOpModes`
    `protected RobotConfigFileManager` | `robotCfgFileMgr`
    `protected boolean` | `runningOnDriverStation`
    `static java.lang.String` | `TAG`
    `protected USBScanManager` | `usbScanManager`
    `protected OpModeRegister` | `userOpmodeRegister`

    - ### Fields inherited from interface com.qualcomm.robotcore.eventloop.EventLoop

      `TELEMETRY_DEFAULT_INTERVAL`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `FtcEventLoopBase(HardwareFactory hardwareFactory, OpModeRegister userOpmodeRegister, UpdateUI.Callback callback, Activity activityContext, ProgrammingModeController programmingModeController)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `checkForChangedOpModes()`
    `protected boolean` | `enterFirmwareUpdateMode(RobotUsbDevice robotUsbDevice)`
    `protected FtcEventLoopBase.LynxUsbDeviceContainer` | `getLynxUsbDeviceForFirmwareUpdate(SerialNumber serialNumber)`
    `protected java.util.List<USBAccessibleLynxModule>` | `getUSBAccessibleLynxDevices(boolean forFirmwareUpdate)`
    `protected void` | `handleCommandActivateConfiguration(java.lang.String data)`
    `protected void` | `handleCommandClearRememberedGroups()` Clear the list of remembered groups
    `protected void` | `handleCommandDeleteConfiguration(java.lang.String fileInfo)`
    `protected void` | `handleCommandDisconnectWifiDirect()`
    `protected void` | `handleCommandDismissAllDialogs(Command command)`
    `protected void` | `handleCommandDismissDialog(Command command)`
    `protected void` | `handleCommandDismissProgress(Command command)`
    `protected void` | `handleCommandGetCandidateLynxFirmwareImages(Command commandRequest)`
    `protected void` | `handleCommandGetUSBAccessibleLynxModules(Command commandRequest)`
    `protected void` | `handleCommandLynxChangeModuleAddresses(Command commandRequest)`
    `protected void` | `handleCommandLynxFirmwareUpdate(Command commandRequest)` Update the firmware of the device indicated in the command.
    `protected void` | `handleCommandRequestAboutInfo(Command command)`
    `protected void` | `handleCommandRequestConfigurations()` Serialize the entire list of config file metadata and send to the driver station
    `protected void` | `handleCommandRequestConfigurationTemplates()` Serialize the entire list of config file metadata and send to the driver station
    `protected void` | `handleCommandRequestInspectionReport()` Return an inspection report of this (robot controller) device back to the caller
    `protected void` | `handleCommandRequestParticularConfiguration(java.lang.String data)`
    `protected void` | `handleCommandRequestRememberedGroups()` Serialize the list of remembered Wifi Direct groups and send it to the driver station
    `protected void` | `handleCommandRestartRobot()`
    `protected void` | `handleCommandSaveConfiguration(java.lang.String fileInfo)`
    `protected void` | `handleCommandShowDialog(Command command)`
    `protected void` | `handleCommandShowProgress(Command command)`
    `protected void` | `handleCommandShowToast(Command command)`
    `protected void` | `handleCommandStartDriverStationProgramAndManage()`
    `protected void` | `handleCommandStartProgrammingMode()` Starts programming mode on the robot controller, as requested by driver station.
    `protected void` | `handleCommandStopProgrammingMode()` Stops programming mode on the robot controller, as requested by driver station.
    `protected CallbackResult` | `handleCommandVisuallyIdentify(Command command)`
    `void` | `init(EventLoopManager eventLoopManager)` Init method, this will be called before the first call to loop.
    `CallbackResult` | `processCommand(Command command)` Process command method, this will be called if the event loop manager receives a user defined command.
    `protected void` | `sendUIState()`
    `protected USBScanManager` | `startUsbScanMangerIfNecessary()`
    `protected void` | `talkToParentLynxModule(DeviceManager deviceManager, LynxUsbDevice lynxUsbDevice, int moduleAddress, Consumer<LynxModule> consumer)`
    `void` | `teardown()` Teardown method, this will be called after the last call to loop.
    `protected boolean` | `updateFirmwareOnce(FtcEventLoopBase.LynxUsbDeviceContainer lynxUsbDevice, java.lang.String imageFileName, byte[] firmwareImage, SerialNumber serialNumber)`
    `protected boolean` | `updateLynxFirmware(SerialNumber serialNumber, com.qualcomm.ftccommon.CommandList.FWImage imageFileName)` Updates the firmware of the Expansion Hub in the indicated USB-attached device to be the indicated firmware.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.qualcomm.robotcore.eventloop.EventLoop

      `getOpModeManager, handleUsbModuleAttach, handleUsbModuleDetach, loop, onUsbDeviceAttached, pendUsbDeviceAttachment, processedRecentlyAttachedUsbDevices, refreshUserTelemetry, requestOpModeStop`

- - ### Field Detail

    - #### TAG

          public static final java.lang.String TAG

      See Also:
        Constant Field Values

    - #### networkConnectionHandler

          protected NetworkConnectionHandler networkConnectionHandler

    - #### activityContext

          protected Activity activityContext

    - #### robotCfgFileMgr

          protected RobotConfigFileManager robotCfgFileMgr

    - #### ftcEventLoopHandler

          protected FtcEventLoopHandler ftcEventLoopHandler

    - #### runningOnDriverStation

          protected boolean runningOnDriverStation

    - #### programmingModeController

          protected final ProgrammingModeController programmingModeController

    - #### usbScanManager

          protected USBScanManager usbScanManager

    - #### userOpmodeRegister

          protected final OpModeRegister userOpmodeRegister

    - #### registeredOpModes

          protected final RegisteredOpModes registeredOpModes

  - ### Constructor Detail

    - #### FtcEventLoopBase

          protected FtcEventLoopBase(HardwareFactory hardwareFactory,
                                     OpModeRegister userOpmodeRegister,
                                     UpdateUI.Callback callback,
                                     Activity activityContext,
                                     ProgrammingModeController programmingModeController)

  - ### Method Detail

    - #### startUsbScanMangerIfNecessary

          protected USBScanManager startUsbScanMangerIfNecessary()
                                                          throws RobotCoreException

      Throws:
        `RobotCoreException`

    - #### teardown

          public void teardown()
                        throws RobotCoreException,
                               java.lang.InterruptedException

      Description copied from interface: `EventLoop`
      Teardown method, this will be called after the last call to loop. You should place your robot into a safe state before this method exits, since there will be no more changes to communicate with your robot. Threading: called on the EventLoopRunnable.run() thread.
      Specified by:
        `teardown` in interface `EventLoop`
      Throws:
        `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`

    - #### processCommand

          public CallbackResult processCommand(Command command)
                                        throws java.lang.InterruptedException,
                                               RobotCoreException

      Description copied from interface: `EventLoop`
      Process command method, this will be called if the event loop manager receives a user defined command. How this command is handled is up to the event loop implementation. Threading: called on the RecvRunnable.run() thread.
      Specified by:
        `processCommand` in interface `EventLoop`
      Parameters:
        `command` - command to process
      Throws:
        `java.lang.InterruptedException`
        `RobotCoreException`

    - #### handleCommandActivateConfiguration

          protected void handleCommandActivateConfiguration(java.lang.String data)

    - #### sendUIState

          protected void sendUIState()

    - #### checkForChangedOpModes

          protected void checkForChangedOpModes()

    - #### init

          public void init(EventLoopManager eventLoopManager)
                    throws RobotCoreException,
                           java.lang.InterruptedException

      Description copied from interface: `EventLoop`
      Init method, this will be called before the first call to loop. You should set up your hardware in this method. Threading: called on the RobotSetupRunnable.run() thread, before the EventLoopRunnable.run() thread is created.
      Specified by:
        `init` in interface `EventLoop`
      Parameters:
        `eventLoopManager` - event loop manager that is responsible for this event loop
      Throws:
        `RobotCoreException` - 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`

    - #### handleCommandRestartRobot

          protected void handleCommandRestartRobot()

    - #### handleCommandRequestParticularConfiguration

          protected void handleCommandRequestParticularConfiguration(java.lang.String data)

    - #### handleCommandDeleteConfiguration

          protected void handleCommandDeleteConfiguration(java.lang.String fileInfo)

    - #### handleCommandSaveConfiguration

          protected void handleCommandSaveConfiguration(java.lang.String fileInfo)

    - #### handleCommandRequestConfigurations

          protected void handleCommandRequestConfigurations()

      Serialize the entire list of config file metadata and send to the driver station

    - #### handleCommandRequestRememberedGroups

          protected void handleCommandRequestRememberedGroups()

      Serialize the list of remembered Wifi Direct groups and send it to the driver station

    - #### handleCommandClearRememberedGroups

          protected void handleCommandClearRememberedGroups()

      Clear the list of remembered groups

    - #### handleCommandLynxFirmwareUpdate

          protected void handleCommandLynxFirmwareUpdate(Command commandRequest)

      Update the firmware of the device indicated in the command. Note: we need to run this in a worker thread so that our command processor here remains responsive and able to process new messages.

    - #### updateLynxFirmware

          protected boolean updateLynxFirmware(SerialNumber serialNumber,
                                               com.qualcomm.ftccommon.CommandList.FWImage imageFileName)

      Updates the firmware of the Expansion Hub in the indicated USB-attached device to be the indicated firmware.

    - #### updateFirmwareOnce

          protected boolean updateFirmwareOnce(FtcEventLoopBase.LynxUsbDeviceContainer lynxUsbDevice,
                                               java.lang.String imageFileName,
                                               byte[] firmwareImage,
                                               SerialNumber serialNumber)

    - #### enterFirmwareUpdateMode

          protected boolean enterFirmwareUpdateMode(RobotUsbDevice robotUsbDevice)

    - #### handleCommandGetUSBAccessibleLynxModules

          protected void handleCommandGetUSBAccessibleLynxModules(Command commandRequest)

    - #### getLynxUsbDeviceForFirmwareUpdate

          protected FtcEventLoopBase.LynxUsbDeviceContainer getLynxUsbDeviceForFirmwareUpdate(SerialNumber serialNumber)

    - #### getUSBAccessibleLynxDevices

          protected java.util.List<USBAccessibleLynxModule> getUSBAccessibleLynxDevices(boolean forFirmwareUpdate)
                                                                                 throws RobotCoreException

      Throws:
        `RobotCoreException`

    - #### handleCommandLynxChangeModuleAddresses

          protected void handleCommandLynxChangeModuleAddresses(Command commandRequest)

    - #### talkToParentLynxModule

          protected void talkToParentLynxModule(DeviceManager deviceManager,
                                                LynxUsbDevice lynxUsbDevice,
                                                int moduleAddress,
                                                Consumer<LynxModule> consumer)
                                         throws RobotCoreException,
                                                java.lang.InterruptedException,
                                                LynxNackException

      Throws:
        `RobotCoreException`
        `java.lang.InterruptedException`
        `LynxNackException`

    - #### handleCommandGetCandidateLynxFirmwareImages

          protected void handleCommandGetCandidateLynxFirmwareImages(Command commandRequest)

    - #### handleCommandRequestConfigurationTemplates

          protected void handleCommandRequestConfigurationTemplates()

      Serialize the entire list of config file metadata and send to the driver station

    - #### handleCommandStartProgrammingMode

          protected void handleCommandStartProgrammingMode()

      Starts programming mode on the robot controller, as requested by driver station.

    - #### handleCommandStartDriverStationProgramAndManage

          protected void handleCommandStartDriverStationProgramAndManage()

    - #### handleCommandStopProgrammingMode

          protected void handleCommandStopProgrammingMode()

      Stops programming mode on the robot controller, as requested by driver station.

    - #### handleCommandShowDialog

          protected void handleCommandShowDialog(Command command)

    - #### handleCommandDismissDialog

          protected void handleCommandDismissDialog(Command command)

    - #### handleCommandDismissAllDialogs

          protected void handleCommandDismissAllDialogs(Command command)

    - #### handleCommandShowProgress

          protected void handleCommandShowProgress(Command command)

    - #### handleCommandDismissProgress

          protected void handleCommandDismissProgress(Command command)

    - #### handleCommandShowToast

          protected void handleCommandShowToast(Command command)

    - #### handleCommandRequestInspectionReport

          protected void handleCommandRequestInspectionReport()

      Return an inspection report of this (robot controller) device back to the caller

    - #### handleCommandRequestAboutInfo

          protected void handleCommandRequestAboutInfo(Command command)

    - #### handleCommandDisconnectWifiDirect

          protected void handleCommandDisconnectWifiDirect()

    - #### handleCommandVisuallyIdentify

          protected CallbackResult handleCommandVisuallyIdentify(Command command)