com.qualcomm.robotcore.hardware

## Class I2cDeviceSynchReadHistoryImpl

- java.lang.Object
- - com.qualcomm.robotcore.hardware.I2cDeviceSynchReadHistoryImpl

- All Implemented Interfaces:
    I2cDeviceSynchReadHistory
  Direct Known Subclasses:
    I2cDeviceSynchImpl, I2cDeviceSynchImplOnSimple

      public class I2cDeviceSynchReadHistoryImpl
      extends java.lang.Object
      implements I2cDeviceSynchReadHistory

  `I2cDeviceSynchReadHistoryImpl` is a helper class providing an implementation of the I2c read history queue

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.concurrent.BlockingQueue<TimestampedI2cData>` | `historyQueue`
    `protected int` | `historyQueueCapacity`
    `protected java.lang.Object` | `historyQueueLock`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `I2cDeviceSynchReadHistoryImpl()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addToHistoryQueue(TimestampedI2cData data)`
    `java.util.concurrent.BlockingQueue<TimestampedI2cData>` | `getHistoryQueue()` (Advanced) Returns a queue into which, if requested, `TimestampedI2cData`s are (optionally) placed as they become available.
    `int` | `getHistoryQueueCapacity()` Returns the current capacity of the history queue.
    `void` | `setHistoryQueueCapacity(int capacity)` Sets the maximum number of `TimestampedI2cData`s that will simultaneously be stored in the history queue.

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

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

- - ### Field Detail

    - #### historyQueueLock

          protected final java.lang.Object historyQueueLock

    - #### historyQueue

          protected java.util.concurrent.BlockingQueue<TimestampedI2cData> historyQueue

    - #### historyQueueCapacity

          protected int historyQueueCapacity

  - ### Constructor Detail

    - #### I2cDeviceSynchReadHistoryImpl

          public I2cDeviceSynchReadHistoryImpl()

  - ### Method Detail

    - #### getHistoryQueue

          public java.util.concurrent.BlockingQueue<TimestampedI2cData> getHistoryQueue()

      Description copied from interface: `I2cDeviceSynchReadHistory`
      (Advanced) Returns a queue into which, if requested, `TimestampedI2cData`s are (optionally) placed as they become available.

      To access these `TimestampedI2cData`s, call `I2cDeviceSynchReadHistory.setHistoryQueueCapacity(int)` to enable the history queue. Once enabled, the history queue can be accessed using `I2cDeviceSynchReadHistory.getHistoryQueue()` and the methods thereon used to access `TimestampedI2cData`s as they become available.

      When `I2cDeviceSynchReadHistory.setHistoryQueueCapacity(int)` is called, any history queue returned previously by `I2cDeviceSynchReadHistory.getHistoryQueue()` becomes invalid and must be re-fetched.

      Specified by:
        `getHistoryQueue` in interface `I2cDeviceSynchReadHistory`
      Returns:
        a queue through which I2c `TimestampedI2cData`s may be retrieved.
      See Also:
        `I2cDeviceSynchReadHistory.setHistoryQueueCapacity(int)`

    - #### setHistoryQueueCapacity

          public void setHistoryQueueCapacity(int capacity)

      Description copied from interface: `I2cDeviceSynchReadHistory`
      Sets the maximum number of `TimestampedI2cData`s that will simultaneously be stored in the history queue. If the queue is full and new `TimestampedI2cData`s become available, older data will be discarded. The history queue initially has a capacity of zero.

      Note that calling this method invalidates any history queue retrieved previously through `I2cDeviceSynchReadHistory.getHistoryQueue()`.

      Specified by:
        `setHistoryQueueCapacity` in interface `I2cDeviceSynchReadHistory`
      Parameters:
        `capacity` - the maximum number of items that may be stored in the history queue
      See Also:
        `I2cDeviceSynchReadHistory.getHistoryQueue()`, `I2cDeviceSynchReadHistory.getHistoryQueueCapacity()`

    - #### getHistoryQueueCapacity

          public int getHistoryQueueCapacity()

      Description copied from interface: `I2cDeviceSynchReadHistory`
      Returns the current capacity of the history queue.
      Specified by:
        `getHistoryQueueCapacity` in interface `I2cDeviceSynchReadHistory`
      Returns:
        the current capacity of the history queue.
      See Also:
        `I2cDeviceSynchReadHistory.setHistoryQueueCapacity(int)`, `I2cDeviceSynchReadHistory.getHistoryQueue()`

    - #### addToHistoryQueue

          public void addToHistoryQueue(TimestampedI2cData data)