com.qualcomm.ftccommon

## Class FtcEventLoopIdle

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

- All Implemented Interfaces:
    EventLoop

      public class FtcEventLoopIdle
      extends FtcEventLoopBase

  `FtcEventLoopIdle` is an eventloop that runs whenever a full `FtcEventLoop` is inappropriate. This event loop should be robust in the face of errors and exceptions, staying up until it's explicitly shut down.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class com.qualcomm.ftccommon.FtcEventLoopBase

      `FtcEventLoopBase.LynxUsbDeviceContainer`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `TAG`

    - ### Fields inherited from class com.qualcomm.ftccommon.FtcEventLoopBase

      `activityContext, ftcEventLoopHandler, networkConnectionHandler, programmingModeController, registeredOpModes, robotCfgFileMgr, runningOnDriverStation, usbScanManager, userOpmodeRegister`

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

      `TELEMETRY_DEFAULT_INTERVAL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FtcEventLoopIdle(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
    --- | ---
    `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(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)`
    `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.

    - ### Methods inherited from class com.qualcomm.ftccommon.FtcEventLoopBase

      `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, handleCommandVisuallyIdentify, processCommand, sendUIState, startUsbScanMangerIfNecessary, talkToParentLynxModule, updateFirmwareOnce, updateLynxFirmware`

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

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

- - ### Field Detail

    - #### TAG

          public static final java.lang.String TAG

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### FtcEventLoopIdle

          public FtcEventLoopIdle(HardwareFactory hardwareFactory,
                                  OpModeRegister userOpmodeRegister,
                                  UpdateUI.Callback callback,
                                  Activity activityContext,
                                  ProgrammingModeController programmingModeController)

  - ### Method Detail

    - #### 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`
      Overrides:
        `init` in class `FtcEventLoopBase`
      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`

    - #### loop

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

      Description copied from interface: `EventLoop`
      This method will be repeatedly called by the event loop manager. Threading: called on the EventLoopRunnable.run() thread.
      Throws:
        `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`

    - #### refreshUserTelemetry

          public void refreshUserTelemetry(TelemetryMessage telemetry,
                                           double sInterval)

      Description copied from interface: `EventLoop`
      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.
      Parameters:
        `telemetry` - the telemetry object to send
        `sInterval` - the required minimum interval. NaN indicates that a system default interval should be used.

    - #### 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`
      Overrides:
        `teardown` in class `FtcEventLoopBase`
      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`

    - #### pendUsbDeviceAttachment

          public void pendUsbDeviceAttachment(SerialNumber serialNumber,
                                              long time,
                                              java.util.concurrent.TimeUnit unit)

    - #### onUsbDeviceAttached

          public void onUsbDeviceAttached(UsbDevice usbDevice)

      Description copied from interface: `EventLoop`
      Notifies the event loop that a UsbDevice has just been attached to the system. User interface activities that receive UsbManager.ACTION_USB_DEVICE_ATTACHED notifications should retrieve the UsbDevice using intent.getParcelableExtra(UsbManager.EXTRA_DEVICE) then pass that along to this method in their event loop for processing.

      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.

      Parameters:
        `usbDevice` - the newly arrived device
      See Also:
        `EventLoop.processedRecentlyAttachedUsbDevices()`

    - #### processedRecentlyAttachedUsbDevices

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

      Description copied from interface: `EventLoop`
      Process the batch of newly arrived USB devices. This is called on the EventLoop thread by the EventLoopManager; there is sufficient time and correct context to, e.g., fully arm the associated module software to make the device operational within the app.
      Throws:
        `RobotCoreException`
        `java.lang.InterruptedException`
      See Also:
        `EventLoop.handleUsbModuleDetach(RobotUsbModule)`, `EventLoop.onUsbDeviceAttached(UsbDevice)`

    - #### handleUsbModuleDetach

          public void handleUsbModuleDetach(RobotUsbModule module)
                                     throws RobotCoreException,
                                            java.lang.InterruptedException

      Description copied from interface: `EventLoop`
      Process the fact that a usb module has now become detached from the system. This is called on the EventLoop thread by the EventLoopManager; there is sufficient time and correct context to, e.g., fully disarm and 'pretend' the associated module.
      Throws:
        `RobotCoreException`
        `java.lang.InterruptedException`
      See Also:
        `EventLoop.processedRecentlyAttachedUsbDevices()`

    - #### handleUsbModuleAttach

          public void handleUsbModuleAttach(RobotUsbModule module)
                                     throws RobotCoreException,
                                            java.lang.InterruptedException

      Description copied from interface: `EventLoop`
      Process the fact that (we believe) that the indicated module has now reappeared after a previously observed detachment.
      Throws:
        `RobotCoreException`
        `java.lang.InterruptedException`

    - #### getOpModeManager

          public OpModeManagerImpl getOpModeManager()

      Description copied from interface: `EventLoop`
      Returns the OpModeManager associated with this event loop
      Returns:
        the OpModeManager associated with this event loop

    - #### requestOpModeStop

          public void requestOpModeStop(OpMode opModeToStopIfActive)

      Description copied from interface: `EventLoop`
      Requests that an OpMode be stopped if it's the currently active one
      Parameters:
        `opModeToStopIfActive` - the OpMode to stop if it's currently active