com.qualcomm.ftccommon

## Class FtcEventLoopHandler

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

-     public class FtcEventLoopHandler
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected UpdateUI.Callback` | `callback`
    `protected static boolean` | `DEBUG`
    `protected EventLoopManager` | `eventLoopManager`
    `protected HardwareFactory` | `hardwareFactory`
    `protected HardwareMap` | `hardwareMap` the actual hardware map seen by the user
    `protected HardwareMap` | `hardwareMapExtra` the hardware map in which we keep any extra devices (ones not used by the user) we need to instantiate
    `static java.lang.String` | `NO_VOLTAGE_SENSOR` This string is sent in the robot battery telemetry payload to identify that no voltage sensor is available on the robot.
    `protected java.lang.Object` | `refreshUserTelemetryLock`
    `protected double` | `robotBatteryInterval`
    `protected double` | `robotBatteryLoggingInterval`
    `protected ElapsedTime` | `robotBatteryLoggingTimer`
    `protected MovingStatistics` | `robotBatteryStatistics`
    `protected ElapsedTime` | `robotBatteryTimer`
    `protected BatteryChecker` | `robotControllerBatteryChecker`
    `protected double` | `robotControllerBatteryCheckerInterval`
    `protected Context` | `robotControllerContext`
    `static java.lang.String` | `TAG`
    `protected double` | `updateUIInterval`
    `protected ElapsedTime` | `updateUITimer`
    `protected double` | `userTelemetryInterval`
    `protected ElapsedTime` | `userTelemetryTimer`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FtcEventLoopHandler(HardwareFactory hardwareFactory, UpdateUI.Callback callback, Context robotControllerContext)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `protected static void` | `closeAutoCloseOnTeardown(HardwareMap hardwareMap)`
    `protected void` | `closeBatteryMonitoring()`
    `protected static void` | `closeHardwareMap(HardwareMap hardwareMap)`
    `protected static void` | `closeMotorControllers(HardwareMap hardwareMap)`
    `protected static void` | `closeServoControllers(HardwareMap hardwareMap)`
    `void` | `displayGamePadInfo(java.lang.String activeOpModeName)`
    `EventLoopManager` | `getEventLoopManager()`
    `java.util.List<LynxUsbDeviceImpl>` | `getExtantLynxDeviceImpls()`
    `Gamepad[]` | `getGamepads()`
    `<T> T` | `getHardwareDevice(java.lang.Class<? extends T> classOrInterface, SerialNumber serialNumber, <any> usbScanManagerSupplier)` Returns the device whose serial number is the one indicated, from the hardware map if possible but instantiating / opening it if necessary.
    `HardwareMap` | `getHardwareMap()`
    `java.lang.String` | `getOpMode(java.lang.String extra)`
    `void` | `init(EventLoopManager eventLoopManager)`
    `void` | `refreshUserTelemetry(TelemetryMessage telemetry, double requestedInterval)` Updates the (indicated) user's telemetry: the telemetry is transmitted if a sufficient interval has passed since the last transmission.
    `void` | `restartRobot()`
    `void` | `sendBatteryInfo()` Send robot phone power % and robot battery voltage level to Driver station
    `void` | `sendTelemetry(java.lang.String tag, java.lang.String msg)`
    `void` | `updateBatteryStatus(BatteryChecker.BatteryStatus status)`

    - ### 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

    - #### NO_VOLTAGE_SENSOR

          public static final java.lang.String NO_VOLTAGE_SENSOR

      This string is sent in the robot battery telemetry payload to identify that no voltage sensor is available on the robot.
      See Also:
        Constant Field Values

    - #### DEBUG

          protected static final boolean DEBUG

      See Also:
        Constant Field Values

    - #### callback

          protected final UpdateUI.Callback callback

    - #### hardwareFactory

          protected final HardwareFactory hardwareFactory

    - #### robotControllerContext

          protected final Context robotControllerContext

    - #### eventLoopManager

          protected EventLoopManager eventLoopManager

    - #### robotControllerBatteryChecker

          protected BatteryChecker robotControllerBatteryChecker

    - #### robotControllerBatteryCheckerInterval

          protected double robotControllerBatteryCheckerInterval

    - #### robotBatteryTimer

          protected ElapsedTime robotBatteryTimer

    - #### robotBatteryInterval

          protected double robotBatteryInterval

    - #### robotBatteryStatistics

          protected MovingStatistics robotBatteryStatistics

    - #### robotBatteryLoggingTimer

          protected ElapsedTime robotBatteryLoggingTimer

    - #### robotBatteryLoggingInterval

          protected double robotBatteryLoggingInterval

    - #### userTelemetryTimer

          protected ElapsedTime userTelemetryTimer

    - #### userTelemetryInterval

          protected double userTelemetryInterval

    - #### refreshUserTelemetryLock

          protected final java.lang.Object refreshUserTelemetryLock

    - #### updateUITimer

          protected ElapsedTime updateUITimer

    - #### updateUIInterval

          protected double updateUIInterval

    - #### hardwareMap

          protected HardwareMap hardwareMap

      the actual hardware map seen by the user

    - #### hardwareMapExtra

          protected HardwareMap hardwareMapExtra

      the hardware map in which we keep any extra devices (ones not used by the user) we need to instantiate

  - ### Constructor Detail

    - #### FtcEventLoopHandler

          public FtcEventLoopHandler(HardwareFactory hardwareFactory,
                                     UpdateUI.Callback callback,
                                     Context robotControllerContext)

  - ### Method Detail

    - #### init

          public void init(EventLoopManager eventLoopManager)

    - #### close

          public void close()

    - #### closeHardwareMap

          protected static void closeHardwareMap(HardwareMap hardwareMap)

    - #### getEventLoopManager

          public EventLoopManager getEventLoopManager()

    - #### getHardwareMap

          public HardwareMap getHardwareMap()
                                     throws RobotCoreException,
                                            java.lang.InterruptedException

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

    - #### getExtantLynxDeviceImpls

          public java.util.List<LynxUsbDeviceImpl> getExtantLynxDeviceImpls()

    - #### getHardwareDevice

          public <T> T getHardwareDevice(java.lang.Class<? extends T> classOrInterface,
                                         SerialNumber serialNumber,
                                         <any> usbScanManagerSupplier)

      Returns the device whose serial number is the one indicated, from the hardware map if possible but instantiating / opening it if necessary. null is returned if the object cannot be accessed.
      Parameters:
        `classOrInterface` - the interface to retrieve on the returned object
        `serialNumber` - the serial number of the object to retrieve
        `usbScanManagerSupplier` - how to get a `USBScanManager` if it ends up we need one

    - #### displayGamePadInfo

          public void displayGamePadInfo(java.lang.String activeOpModeName)

    - #### getGamepads

          public Gamepad[] getGamepads()

    - #### refreshUserTelemetry

          public void refreshUserTelemetry(TelemetryMessage telemetry,
                                           double requestedInterval)

      Updates the (indicated) user's telemetry: the telemetry is transmitted if a sufficient interval has passed since the last transmission. If the telemetry is transmitted, the telemetry is cleared and the timer is reset. A battery voltage key may be added to the message before transmission.
      Parameters:
        `telemetry` - the telemetry data to send
        `requestedInterval` - the minimum interval (s) since the last transmission. NaN indicates that a default transmission interval should be used
      See Also:
        `EventLoop.TELEMETRY_DEFAULT_INTERVAL`

    - #### sendBatteryInfo

          public void sendBatteryInfo()

      Send robot phone power % and robot battery voltage level to Driver station

    - #### sendTelemetry

          public void sendTelemetry(java.lang.String tag,
                                    java.lang.String msg)

    - #### closeMotorControllers

          protected static void closeMotorControllers(HardwareMap hardwareMap)

    - #### closeServoControllers

          protected static void closeServoControllers(HardwareMap hardwareMap)

    - #### closeAutoCloseOnTeardown

          protected static void closeAutoCloseOnTeardown(HardwareMap hardwareMap)

    - #### closeBatteryMonitoring

          protected void closeBatteryMonitoring()

    - #### restartRobot

          public void restartRobot()

    - #### getOpMode

          public java.lang.String getOpMode(java.lang.String extra)

    - #### updateBatteryStatus

          public void updateBatteryStatus(BatteryChecker.BatteryStatus status)