Class ProtobufLogEntry<T>

java.lang.Object
edu.wpi.first.util.datalog.DataLogEntry
edu.wpi.first.util.datalog.ProtobufLogEntry<T>
Type Parameters:
T - value class

public final class ProtobufLogEntry<T> extends DataLogEntry
Log protobuf-encoded values.
  • Method Details

    • create

      public static <T, MessageType extends us.hebi.quickbuf.ProtoMessage<?>> ProtobufLogEntry<T> create(DataLog log, String name, Protobuf<T,MessageType> proto, String metadata, long timestamp)
      Creates a protobuf-encoded log entry.
      Type Parameters:
      T - value class (inferred from proto)
      MessageType - protobuf message type (inferred from proto)
      Parameters:
      log - datalog
      name - name of the entry
      proto - protobuf serialization implementation
      metadata - metadata
      timestamp - entry creation timestamp (0=now)
      Returns:
      ProtobufLogEntry
    • create

      public static <T, MessageType extends us.hebi.quickbuf.ProtoMessage<?>> ProtobufLogEntry<T> create(DataLog log, String name, Protobuf<T,MessageType> proto, String metadata)
      Creates a protobuf-encoded log entry.
      Type Parameters:
      T - value class (inferred from proto)
      MessageType - protobuf message type (inferred from proto)
      Parameters:
      log - datalog
      name - name of the entry
      proto - protobuf serialization implementation
      metadata - metadata
      Returns:
      ProtobufLogEntry
    • create

      public static <T, MessageType extends us.hebi.quickbuf.ProtoMessage<?>> ProtobufLogEntry<T> create(DataLog log, String name, Protobuf<T,MessageType> proto, long timestamp)
      Creates a protobuf-encoded log entry.
      Type Parameters:
      T - value class (inferred from proto)
      MessageType - protobuf message type (inferred from proto)
      Parameters:
      log - datalog
      name - name of the entry
      proto - protobuf serialization implementation
      timestamp - entry creation timestamp (0=now)
      Returns:
      ProtobufLogEntry
    • create

      public static <T, MessageType extends us.hebi.quickbuf.ProtoMessage<?>> ProtobufLogEntry<T> create(DataLog log, String name, Protobuf<T,MessageType> proto)
      Creates a protobuf-encoded log entry.
      Type Parameters:
      T - value class (inferred from proto)
      MessageType - protobuf message type (inferred from proto)
      Parameters:
      log - datalog
      name - name of the entry
      proto - protobuf serialization implementation
      Returns:
      ProtobufLogEntry
    • append

      public void append(T value, long timestamp)
      Appends a record to the log.
      Parameters:
      value - Value to record
      timestamp - Time stamp (0 to indicate now)
    • append

      public void append(T value)
      Appends a record to the log.
      Parameters:
      value - Value to record
    • update

      public void update(T value, long timestamp)
      Updates the last value and appends a record to the log if it has changed.

      Note: the last value is local to this class instance; using update() with two instances pointing to the same underlying log entry name will likely result in unexpected results.

      Parameters:
      value - Value to record
      timestamp - Time stamp (0 to indicate now)
    • update

      public void update(T value)
      Updates the last value and appends a record to the log if it has changed.

      Note: the last value is local to this class instance; using update() with two instances pointing to the same underlying log entry name will likely result in unexpected results.

      Parameters:
      value - Value to record
    • hasLastValue

      public boolean hasLastValue()
      Gets whether there is a last value.

      Note: the last value is local to this class instance and updated only with update(), not append().

      Returns:
      True if last value exists, false otherwise.
    • getLastValue

      public T getLastValue()
      Gets the last value.

      Note: the last value is local to this class instance and updated only with update(), not append().

      Returns:
      Last value, or null if none.