Class RecordingTelemetry

java.lang.Object
org.horizon36596.simloop.opmode.RecordingTelemetry
All Implemented Interfaces:
org.firstinspires.ftc.robotcore.external.Telemetry

public final class RecordingTelemetry extends Object implements org.firstinspires.ftc.robotcore.external.Telemetry
A Telemetry that keeps what the Driver Station would have shown, so a test can read it back.

Every update() renders the current items and lines to text, one string per Driver Station line, and appends that list to transmissions(). The rendering follows the SDK's defaults: an item reads "caption : value", the items on one Telemetry.Line are joined with " | ", and with auto-clear on (the default) every item that is not retained is removed when the next item or line is added after an update - not at the update itself, which is when the SDK's own telemetry clears too. So an update with nothing new added shows the same lines again, as the Driver Station would: an iterative OpMode that calls telemetry.update() itself, followed by the SDK's own update after loop(), still ends on what it added. Lines added through log() go to loggedLines().

What it deliberately does not do. Nothing is sent anywhere, speak(String) is silent, and the transmission interval is stored but not honoured: every update is recorded, because a sim tick is not a real 250 ms. Formatted values (addData(caption, "%.2f", x)) use Locale.ROOT, so a run reads the same on a laptop set to any language; the robot uses its own default locale.

Not thread-safe. The runner only lets one thread touch it at a time, and a test reads it after the run.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.firstinspires.ftc.robotcore.external.Telemetry

    org.firstinspires.ftc.robotcore.external.Telemetry.DisplayFormat, org.firstinspires.ftc.robotcore.external.Telemetry.Item, org.firstinspires.ftc.robotcore.external.Telemetry.Line, org.firstinspires.ftc.robotcore.external.Telemetry.Log
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty telemetry with the SDK's default separators and auto-clear on.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    org.firstinspires.ftc.robotcore.external.Telemetry.Item
    addData(String caption, Object value)
     
    org.firstinspires.ftc.robotcore.external.Telemetry.Item
    addData(String caption, String format, Object... args)
     
    <T> org.firstinspires.ftc.robotcore.external.Telemetry.Item
    addData(String caption, String format, org.firstinspires.ftc.robotcore.external.Func<T> valueProducer)
     
    <T> org.firstinspires.ftc.robotcore.external.Telemetry.Item
    addData(String caption, org.firstinspires.ftc.robotcore.external.Func<T> valueProducer)
     
    org.firstinspires.ftc.robotcore.external.Telemetry.Line
     
    org.firstinspires.ftc.robotcore.external.Telemetry.Line
    addLine(String lineCaption)
     
    void
    Removes every item that is not retained, and every line left with no retained item.
    void
    Removes every item and line, retained or not, every action, and the log.
     
     
    int
    Returns the stored interval, in milliseconds; it is not honoured, see the class javadoc.
    boolean
     
    Returns the lines shown by the most recent update(), or an empty list if none has happened.
    org.firstinspires.ftc.robotcore.external.Telemetry.Log
    log()
     
    Returns every line added through log(), oldest first, however many the log's capacity shows.
    boolean
     
    boolean
    removeItem(org.firstinspires.ftc.robotcore.external.Telemetry.Item item)
     
    boolean
    removeLine(org.firstinspires.ftc.robotcore.external.Telemetry.Line line)
     
    void
    setAutoClear(boolean autoClear)
     
    void
    setCaptionValueSeparator(String captionValueSeparator)
     
    void
    setDisplayFormat(org.firstinspires.ftc.robotcore.external.Telemetry.DisplayFormat displayFormat)
    Accepted and ignored: the recorded text is the same in every display format.
    void
    setItemSeparator(String itemSeparator)
     
    void
    setMsTransmissionInterval(int msTransmissionInterval)
    Stores the interval, in milliseconds; it is not honoured, see the class javadoc.
    void
    speak(String text)
    Does nothing: there is no Driver Station to speak through.
    void
    speak(String text, String languageCode, String countryCode)
    Does nothing: there is no Driver Station to speak through.
    Returns every update so far, oldest first: each one is the list of Driver Station lines it showed.
    boolean
    Runs the actions, renders every item and line to text and records that as one transmission.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.firstinspires.ftc.robotcore.external.Telemetry

    setNumDecimalPlaces
  • Constructor Details

    • RecordingTelemetry

      public RecordingTelemetry()
      Creates an empty telemetry with the SDK's default separators and auto-clear on.
  • Method Details

    • transmissions

      public List<List<String>> transmissions()
      Returns every update so far, oldest first: each one is the list of Driver Station lines it showed. The list is a snapshot; later updates do not change it.
      Returns:
      every update so far, oldest first: each one is the list of Driver Station lines it showed
    • lastTransmission

      public List<String> lastTransmission()
      Returns the lines shown by the most recent update(), or an empty list if none has happened.
      Returns:
      the lines shown by the most recent update(), or an empty list if none has happened
    • loggedLines

      public List<String> loggedLines()
      Returns every line added through log(), oldest first, however many the log's capacity shows.
      Returns:
      every line added through log(), oldest first, however many the log's capacity shows
    • addData

      public org.firstinspires.ftc.robotcore.external.Telemetry.Item addData(String caption, String format, Object... args)
      Specified by:
      addData in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • addData

      public org.firstinspires.ftc.robotcore.external.Telemetry.Item addData(String caption, Object value)
      Specified by:
      addData in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • addData

      public <T> org.firstinspires.ftc.robotcore.external.Telemetry.Item addData(String caption, org.firstinspires.ftc.robotcore.external.Func<T> valueProducer)
      Specified by:
      addData in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • addData

      public <T> org.firstinspires.ftc.robotcore.external.Telemetry.Item addData(String caption, String format, org.firstinspires.ftc.robotcore.external.Func<T> valueProducer)
      Specified by:
      addData in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • removeItem

      public boolean removeItem(org.firstinspires.ftc.robotcore.external.Telemetry.Item item)
      Specified by:
      removeItem in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • clear

      public void clear()
      Removes every item that is not retained, and every line left with no retained item.
      Specified by:
      clear in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • clearAll

      public void clearAll()
      Removes every item and line, retained or not, every action, and the log.
      Specified by:
      clearAll in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • addAction

      public Object addAction(Runnable action)
      Specified by:
      addAction in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • removeAction

      public boolean removeAction(Object token)
      Specified by:
      removeAction in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • speak

      public void speak(String text)
      Does nothing: there is no Driver Station to speak through.
      Specified by:
      speak in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • speak

      public void speak(String text, String languageCode, String countryCode)
      Does nothing: there is no Driver Station to speak through.
      Specified by:
      speak in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • update

      public boolean update()
      Runs the actions, renders every item and line to text and records that as one transmission. With auto-clear on, the next item or line added clears the non-retained ones first.
      Specified by:
      update in interface org.firstinspires.ftc.robotcore.external.Telemetry
      Returns:
      true, as the SDK does when it sends
    • addLine

      public org.firstinspires.ftc.robotcore.external.Telemetry.Line addLine()
      Specified by:
      addLine in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • addLine

      public org.firstinspires.ftc.robotcore.external.Telemetry.Line addLine(String lineCaption)
      Specified by:
      addLine in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • removeLine

      public boolean removeLine(org.firstinspires.ftc.robotcore.external.Telemetry.Line line)
      Specified by:
      removeLine in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • isAutoClear

      public boolean isAutoClear()
      Specified by:
      isAutoClear in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • setAutoClear

      public void setAutoClear(boolean autoClear)
      Specified by:
      setAutoClear in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • getMsTransmissionInterval

      public int getMsTransmissionInterval()
      Returns the stored interval, in milliseconds; it is not honoured, see the class javadoc.
      Specified by:
      getMsTransmissionInterval in interface org.firstinspires.ftc.robotcore.external.Telemetry
      Returns:
      the stored interval, in milliseconds; it is not honoured, see the class javadoc
    • setMsTransmissionInterval

      public void setMsTransmissionInterval(int msTransmissionInterval)
      Stores the interval, in milliseconds; it is not honoured, see the class javadoc.
      Specified by:
      setMsTransmissionInterval in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • getItemSeparator

      public String getItemSeparator()
      Specified by:
      getItemSeparator in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • setItemSeparator

      public void setItemSeparator(String itemSeparator)
      Specified by:
      setItemSeparator in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • getCaptionValueSeparator

      public String getCaptionValueSeparator()
      Specified by:
      getCaptionValueSeparator in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • setCaptionValueSeparator

      public void setCaptionValueSeparator(String captionValueSeparator)
      Specified by:
      setCaptionValueSeparator in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • setDisplayFormat

      public void setDisplayFormat(org.firstinspires.ftc.robotcore.external.Telemetry.DisplayFormat displayFormat)
      Accepted and ignored: the recorded text is the same in every display format.
      Specified by:
      setDisplayFormat in interface org.firstinspires.ftc.robotcore.external.Telemetry
    • log

      public org.firstinspires.ftc.robotcore.external.Telemetry.Log log()
      Specified by:
      log in interface org.firstinspires.ftc.robotcore.external.Telemetry