RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
org.wpilib.datalog.DataLog Class Reference
Inheritance diagram for org.wpilib.datalog.DataLog:
org.wpilib.datalog.DataLogBackgroundWriter

Public Member Functions

void flush ()
void pause ()
void resume ()
void stop ()
boolean hasSchema (String name)
void addSchema (String name, String type, byte[] schema, long timestamp)
void addSchema (String name, String type, byte[] schema)
void addSchema (String name, String type, String schema, long timestamp)
void addSchema (String name, String type, String schema)
void addSchema (Protobuf<?, ?> proto, long timestamp)
void addSchema (Protobuf<?, ?> proto)
void addSchema (Struct<?> struct, long timestamp)
void addSchema (Struct<?> struct)
int start (String name, String type, String metadata, long timestamp)
int start (String name, String type, String metadata)
int start (String name, String type)
void finish (int entry, long timestamp)
void finish (int entry)
void setMetadata (int entry, String metadata, long timestamp)
void setMetadata (int entry, String metadata)
void close ()
void appendRaw (int entry, byte[] data, long timestamp)
void appendRaw (int entry, byte[] data, int start, int len, long timestamp)
void appendRaw (int entry, ByteBuffer data, long timestamp)
void appendRaw (int entry, ByteBuffer data, int start, int len, long timestamp)
void appendBoolean (int entry, boolean value, long timestamp)
void appendInteger (int entry, long value, long timestamp)
void appendFloat (int entry, float value, long timestamp)
void appendDouble (int entry, double value, long timestamp)
void appendString (int entry, String value, long timestamp)
void appendBooleanArray (int entry, boolean[] arr, long timestamp)
void appendIntegerArray (int entry, long[] arr, long timestamp)
void appendFloatArray (int entry, float[] arr, long timestamp)
void appendDoubleArray (int entry, double[] arr, long timestamp)
void appendStringArray (int entry, String[] arr, long timestamp)
long getImpl ()

Protected Member Functions

 DataLog (long impl)

Protected Attributes

long m_impl

Detailed Description

A data log for high-speed writing of data values.

The finish() function is needed only to indicate in the log that a particular entry is no longer being used (it releases the name to ID mapping). The finish() function is not required to be called for data to be flushed to disk; entries in the log are written as append() calls are being made. In fact, finish() does not need to be called at all.

DataLog calls are thread safe. DataLog uses a typical multiple-supplier, single-consumer setup. Writes to the log are atomic, but there is no guaranteed order in the log when multiple threads are writing to it; whichever thread grabs the write mutex first will get written first. For this reason (as well as the fact that timestamps can be set to arbitrary values), records in the log are not guaranteed to be sorted by timestamp.

Definition at line 30 of file DataLog.java.

Constructor & Destructor Documentation

◆ DataLog()

org.wpilib.datalog.DataLog.DataLog ( long impl)
protected

Constructs.

Parameters
implimplementation handle

Definition at line 36 of file DataLog.java.

Member Function Documentation

◆ addSchema() [1/8]

void org.wpilib.datalog.DataLog.addSchema ( Protobuf<?, ?> proto)

Registers a protobuf schema. Duplicate calls to this function with the same name are silently ignored.

Parameters
protoprotobuf serialization object

Definition at line 162 of file DataLog.java.

◆ addSchema() [2/8]

void org.wpilib.datalog.DataLog.addSchema ( Protobuf<?, ?> proto,
long timestamp )

Registers a protobuf schema. Duplicate calls to this function with the same name are silently ignored.

Parameters
protoprotobuf serialization object
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 148 of file DataLog.java.

◆ addSchema() [3/8]

void org.wpilib.datalog.DataLog.addSchema ( String name,
String type,
byte[] schema )

Registers a data schema. Data schemas provide information for how a certain data type string can be decoded. The type string of a data schema indicates the type of the schema itself (e.g. "protobuf" for protobuf schemas, "struct" for struct schemas, etc). In the data log, schemas are saved just like normal records, with the name being generated from the provided name: "/.schema/name". Duplicate calls to this function with the same name are silently ignored.

Parameters
nameName (the string passed as the data type for records using this schema)
typeType of schema (e.g. "protobuf", "struct", etc)
schemaSchema data

Definition at line 103 of file DataLog.java.

◆ addSchema() [4/8]

void org.wpilib.datalog.DataLog.addSchema ( String name,
String type,
byte[] schema,
long timestamp )

Registers a data schema. Data schemas provide information for how a certain data type string can be decoded. The type string of a data schema indicates the type of the schema itself (e.g. "protobuf" for protobuf schemas, "struct" for struct schemas, etc). In the data log, schemas are saved just like normal records, with the name being generated from the provided name: "/.schema/name". Duplicate calls to this function with the same name are silently ignored.

Parameters
nameName (the string passed as the data type for records using this schema)
typeType of schema (e.g. "protobuf", "struct", etc)
schemaSchema data
timestampTime stamp in nanoseconds (may be 0 to indicate now)

Definition at line 85 of file DataLog.java.

◆ addSchema() [5/8]

void org.wpilib.datalog.DataLog.addSchema ( String name,
String type,
String schema )

Registers a data schema. Data schemas provide information for how a certain data type string can be decoded. The type string of a data schema indicates the type of the schema itself (e.g. "protobuf" for protobuf schemas, "struct" for struct schemas, etc). In the data log, schemas are saved just like normal records, with the name being generated from the provided name: "/.schema/name". Duplicate calls to this function with the same name are silently ignored.

Parameters
nameName (the string passed as the data type for records using this schema)
typeType of schema (e.g. "protobuf", "struct", etc)
schemaSchema data

Definition at line 137 of file DataLog.java.

◆ addSchema() [6/8]

void org.wpilib.datalog.DataLog.addSchema ( String name,
String type,
String schema,
long timestamp )

Registers a data schema. Data schemas provide information for how a certain data type string can be decoded. The type string of a data schema indicates the type of the schema itself (e.g. "protobuf" for protobuf schemas, "struct" for struct schemas, etc). In the data log, schemas are saved just like normal records, with the name being generated from the provided name: "/.schema/name". Duplicate calls to this function with the same name are silently ignored.

Parameters
nameName (the string passed as the data type for records using this schema)
typeType of schema (e.g. "protobuf", "struct", etc)
schemaSchema data
timestampTime stamp in nanoseconds (may be 0 to indicate now)

Definition at line 119 of file DataLog.java.

◆ addSchema() [7/8]

void org.wpilib.datalog.DataLog.addSchema ( Struct<?> struct)

Registers a struct schema. Duplicate calls to this function with the same name are silently ignored.

Parameters
structstruct serialization object

Definition at line 183 of file DataLog.java.

◆ addSchema() [8/8]

void org.wpilib.datalog.DataLog.addSchema ( Struct<?> struct,
long timestamp )

Registers a struct schema. Duplicate calls to this function with the same name are silently ignored.

Parameters
structstruct serialization object
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 173 of file DataLog.java.

◆ appendBoolean()

void org.wpilib.datalog.DataLog.appendBoolean ( int entry,
boolean value,
long timestamp )

Appends a boolean record to the log.

Parameters
entryEntry index, as returned by start()
valueBoolean value to record
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 334 of file DataLog.java.

◆ appendBooleanArray()

void org.wpilib.datalog.DataLog.appendBooleanArray ( int entry,
boolean[] arr,
long timestamp )

Appends a boolean array record to the log.

Parameters
entryEntry index, as returned by start()
arrBoolean array to record
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 389 of file DataLog.java.

◆ appendDouble()

void org.wpilib.datalog.DataLog.appendDouble ( int entry,
double value,
long timestamp )

Appends a double record to the log.

Parameters
entryEntry index, as returned by start()
valueDouble value to record
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 367 of file DataLog.java.

◆ appendDoubleArray()

void org.wpilib.datalog.DataLog.appendDoubleArray ( int entry,
double[] arr,
long timestamp )

Appends a double array record to the log.

Parameters
entryEntry index, as returned by start()
arrDouble array to record
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 422 of file DataLog.java.

◆ appendFloat()

void org.wpilib.datalog.DataLog.appendFloat ( int entry,
float value,
long timestamp )

Appends a float record to the log.

Parameters
entryEntry index, as returned by start()
valueFloat value to record
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 356 of file DataLog.java.

◆ appendFloatArray()

void org.wpilib.datalog.DataLog.appendFloatArray ( int entry,
float[] arr,
long timestamp )

Appends a float array record to the log.

Parameters
entryEntry index, as returned by start()
arrFloat array to record
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 411 of file DataLog.java.

◆ appendInteger()

void org.wpilib.datalog.DataLog.appendInteger ( int entry,
long value,
long timestamp )

Appends an integer record to the log.

Parameters
entryEntry index, as returned by start()
valueInteger value to record
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 345 of file DataLog.java.

◆ appendIntegerArray()

void org.wpilib.datalog.DataLog.appendIntegerArray ( int entry,
long[] arr,
long timestamp )

Appends an integer array record to the log.

Parameters
entryEntry index, as returned by start()
arrInteger array to record
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 400 of file DataLog.java.

◆ appendRaw() [1/4]

void org.wpilib.datalog.DataLog.appendRaw ( int entry,
byte[] data,
int start,
int len,
long timestamp )

Appends a record to the log.

Parameters
entryEntry index, as returned by start()
dataByte array to record
startStart position of data (in byte array)
lenLength of data (must be less than or equal to data.length - start)
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 298 of file DataLog.java.

◆ appendRaw() [2/4]

void org.wpilib.datalog.DataLog.appendRaw ( int entry,
byte[] data,
long timestamp )

Appends a raw record to the log.

Parameters
entryEntry index, as returned by start()
dataByte array to record; will send entire array contents
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 285 of file DataLog.java.

◆ appendRaw() [3/4]

void org.wpilib.datalog.DataLog.appendRaw ( int entry,
ByteBuffer data,
int start,
int len,
long timestamp )

Appends a record to the log.

Parameters
entryEntry index, as returned by start()
dataBuffer to record
startStart position of data (in buffer)
lenLength of data (must be less than or equal to data.capacity() - start)
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 323 of file DataLog.java.

◆ appendRaw() [4/4]

void org.wpilib.datalog.DataLog.appendRaw ( int entry,
ByteBuffer data,
long timestamp )

Appends a record to the log.

Parameters
entryEntry index, as returned by start()
dataBuffer to record; will send from data.position() to data.limit()
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 309 of file DataLog.java.

◆ appendString()

void org.wpilib.datalog.DataLog.appendString ( int entry,
String value,
long timestamp )

Appends a string record to the log.

Parameters
entryEntry index, as returned by start()
valueString value to record
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 378 of file DataLog.java.

◆ appendStringArray()

void org.wpilib.datalog.DataLog.appendStringArray ( int entry,
String[] arr,
long timestamp )

Appends a string array record to the log.

Parameters
entryEntry index, as returned by start()
arrString array to record
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 433 of file DataLog.java.

◆ close()

void org.wpilib.datalog.DataLog.close ( )

Definition at line 273 of file DataLog.java.

◆ finish() [1/2]

void org.wpilib.datalog.DataLog.finish ( int entry)

Finish an entry.

Parameters
entryEntry index

Definition at line 247 of file DataLog.java.

◆ finish() [2/2]

void org.wpilib.datalog.DataLog.finish ( int entry,
long timestamp )

Finish an entry.

Parameters
entryEntry index
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 238 of file DataLog.java.

◆ flush()

void org.wpilib.datalog.DataLog.flush ( )

Explicitly flushes the log data to disk.

Definition at line 41 of file DataLog.java.

◆ getImpl()

long org.wpilib.datalog.DataLog.getImpl ( )

Gets the JNI implementation handle.

Returns
data log handle.

Definition at line 442 of file DataLog.java.

◆ hasSchema()

boolean org.wpilib.datalog.DataLog.hasSchema ( String name)

Returns whether there is a data schema already registered with the given name.

Parameters
nameName (the string passed as the data type for records using this schema)
Returns
True if schema already registered

Definition at line 69 of file DataLog.java.

◆ pause()

void org.wpilib.datalog.DataLog.pause ( )

Pauses appending of data records to the log. While paused, no data records are saved (e.g. AppendX is a no-op). Has no effect on entry starts / finishes / metadata changes.

Definition at line 49 of file DataLog.java.

◆ resume()

void org.wpilib.datalog.DataLog.resume ( )

Resumes appending of data records to the log.

Reimplemented in org.wpilib.datalog.DataLogBackgroundWriter.

Definition at line 54 of file DataLog.java.

◆ setMetadata() [1/2]

void org.wpilib.datalog.DataLog.setMetadata ( int entry,
String metadata )

Updates the metadata for an entry.

Parameters
entryEntry index
metadataNew metadata for the entry

Definition at line 268 of file DataLog.java.

◆ setMetadata() [2/2]

void org.wpilib.datalog.DataLog.setMetadata ( int entry,
String metadata,
long timestamp )

Updates the metadata for an entry.

Parameters
entryEntry index
metadataNew metadata for the entry
timestampTime stamp in nanoseconds (0 to indicate now)

Definition at line 258 of file DataLog.java.

◆ start() [1/3]

int org.wpilib.datalog.DataLog.start ( String name,
String type )

Start an entry. Duplicate names are allowed (with the same type), and result in the same index being returned (start/finish are reference counted). A duplicate name with a different type will result in an error message being printed to the console and 0 being returned (which will be ignored by the append functions).

Parameters
nameName
typeData type
Returns
Entry index

Definition at line 228 of file DataLog.java.

◆ start() [2/3]

int org.wpilib.datalog.DataLog.start ( String name,
String type,
String metadata )

Start an entry. Duplicate names are allowed (with the same type), and result in the same index being returned (start/finish are reference counted). A duplicate name with a different type will result in an error message being printed to the console and 0 being returned (which will be ignored by the append functions).

Parameters
nameName
typeData type
metadataInitial metadata (e.g. data properties)
Returns
Entry index

Definition at line 214 of file DataLog.java.

◆ start() [3/3]

int org.wpilib.datalog.DataLog.start ( String name,
String type,
String metadata,
long timestamp )

Start an entry. Duplicate names are allowed (with the same type), and result in the same index being returned (start/finish are reference counted). A duplicate name with a different type will result in an error message being printed to the console and 0 being returned (which will be ignored by the append functions).

Parameters
nameName
typeData type
metadataInitial metadata (e.g. data properties)
timestampTime stamp in nanoseconds (0 to indicate now)
Returns
Entry index

Definition at line 199 of file DataLog.java.

◆ stop()

void org.wpilib.datalog.DataLog.stop ( )

Stops appending all records to the log, and closes the log file.

Definition at line 59 of file DataLog.java.

Member Data Documentation

◆ m_impl

long org.wpilib.datalog.DataLog.m_impl
protected

Implementation handle.

Definition at line 462 of file DataLog.java.


The documentation for this class was generated from the following file: