Class SignalLogger
Static class for controlling the Phoenix 6 signal logger.
public static class SignalLogger
- Inheritance
-
SignalLogger
- Inherited Members
Remarks
This logs all the signals from the CAN buses into .hoot files. Each file name starts with the CANivore serial number or SocketCAN interface for a generic SocketCAN adapter (non-FRC Linux only), followed by the timestamp. In the header of a hoot file, the CANivore name and firmware version are logged in plain text.
During Hoot Replay, the signal logger always runs while replay is running. All custom signals written during replay will be automatically placed underhoot_replay/. Additionally, the
log will contain all status signals and custom signals from the original log.
Methods
AddSchema(string, HootSchemaType, byte[])
Adds the schema to the log file.
The schema name should typically exactly match the name of the type (without any extra prefix or suffix). For protobuf, first register all relevant file descriptors by file name (such as "geometry2d.proto"). Then, for each top-level type being used, add a separate empty schema with the full name of the type(such as "wpi.proto.ProtobufPose2d").public static StatusCode AddSchema(string name, HootSchemaType type, byte[] data)
Parameters
namestringName of the schema
typeHootSchemaTypeType of the schema, such as struct or protobuf
databyte[]Schema bytes to write
Returns
- StatusCode
Status of adding the schema
AddSchema(string, HootSchemaType, string)
Adds the schema to the log file.
The schema name should typically exactly match the name of the type (without any extra prefix or suffix). For protobuf, first register all relevant file descriptors by file name (such as "geometry2d.proto"). Then, for each top-level type being used, add a separate empty schema with the full name of the type(such as "wpi.proto.ProtobufPose2d").public static StatusCode AddSchema(string name, HootSchemaType type, string data)
Parameters
namestringName of the schema
typeHootSchemaTypeType of the schema, such as struct or protobuf
datastringSchema string to write
Returns
- StatusCode
Status of adding the schema
HasSchema(string, HootSchemaType)
Checks if the schema has already been added to the log files.
public static bool HasSchema(string name, HootSchemaType type)
Parameters
namestringName of the schema
typeHootSchemaTypeType of the schema, such as struct or protobuf
Returns
- bool
Whether the schema has been added to the log files
SetPath(string)
Sets the destination for logging, restarting logger if the path changed.
public static StatusCode SetPath(string path)
Parameters
pathstringFolder path for the log files; path must exist
Returns
- StatusCode
Status of setting the path and restarting the log
Remarks
If this is not called or the path is left empty, the default path is a logs folder in the current working directory. Typical use for this routine is to use a removable USB flash drive for logging.
This is ignored during Hoot Replay, where the hoot log will always be written to a subfolder next to the log being replayed.Start()
Starts logging status signals.
public static StatusCode Start()
Returns
- StatusCode
Status of starting the logger
Remarks
This is ignored during Hoot Replay, where logging is automatically started when Hoot Replay starts running or restarts.
Stop()
Stops logging status signals.
public static StatusCode Stop()
Returns
- StatusCode
Status of stopping the logger
Remarks
This is ignored during Hoot Replay, where logging is automatically stopped when Hoot Replay is stopped or reaches the end of the file.
WriteBoolean(string, bool, double)
Writes the boolean to the log file.
public static StatusCode WriteBoolean(string name, bool value, double latencySeconds = 0)
Parameters
namestringName of the signal
valueboolValue to write
latencySecondsdoubleLatency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log
Returns
- StatusCode
Status of writing the data
WriteBooleanArray(string, bool[], double)
Writes the array of booleans to the log file.
public static StatusCode WriteBooleanArray(string name, bool[] values, double latencySeconds = 0)
Parameters
namestringName of the signal
valuesbool[]Array of values to write
latencySecondsdoubleLatency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log
Returns
- StatusCode
Status of writing the data
WriteDouble(string, double, string, double)
Writes the double to the log file.
public static StatusCode WriteDouble(string name, double value, string units = "", double latencySeconds = 0)
Parameters
namestringName of the signal
valuedoubleValue to write
unitsstringUnits of the signal
latencySecondsdoubleLatency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log
Returns
- StatusCode
Status of writing the data
WriteDoubleArray(string, double[], string, double)
Writes the array of doubles to the log file.
public static StatusCode WriteDoubleArray(string name, double[] values, string units = "", double latencySeconds = 0)
Parameters
namestringName of the signal
valuesdouble[]Array of values to write
unitsstringUnits of the signal
latencySecondsdoubleLatency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log
Returns
- StatusCode
Status of writing the data
WriteFloat(string, float, string, double)
Writes the float to the log file.
public static StatusCode WriteFloat(string name, float value, string units = "", double latencySeconds = 0)
Parameters
namestringName of the signal
valuefloatValue to write
unitsstringUnits of the signal
latencySecondsdoubleLatency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log
Returns
- StatusCode
Status of writing the data
WriteFloatArray(string, float[], string, double)
Writes the array of floats to the log file.
public static StatusCode WriteFloatArray(string name, float[] values, string units = "", double latencySeconds = 0)
Parameters
namestringName of the signal
valuesfloat[]Array of values to write
unitsstringUnits of the signal
latencySecondsdoubleLatency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log
Returns
- StatusCode
Status of writing the data
WriteInteger(string, long, string, double)
Writes the integer to the log file.
public static StatusCode WriteInteger(string name, long value, string units = "", double latencySeconds = 0)
Parameters
namestringName of the signal
valuelongValue to write
unitsstringUnits of the signal
latencySecondsdoubleLatency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log
Returns
- StatusCode
Status of writing the data
WriteIntegerArray(string, long[], string, double)
Writes the array of integers to the log file.
public static StatusCode WriteIntegerArray(string name, long[] values, string units = "", double latencySeconds = 0)
Parameters
namestringName of the signal
valueslong[]Array of values to write
unitsstringUnits of the signal
latencySecondsdoubleLatency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log
Returns
- StatusCode
Status of writing the data
WriteRaw(string, byte[], double)
Writes the raw data bytes to the log file.
public static StatusCode WriteRaw(string name, byte[] data, double latencySeconds = 0)
Parameters
namestringName of the signal
databyte[]Raw data bytes
latencySecondsdoubleLatency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log
Returns
- StatusCode
Status of writing the data
WriteSchemaValue(string, string, HootSchemaType, byte[], double)
Writes the schema-serialized bytes to the log file.
The name of the associated schema must exactly match the type of the data (such as "Pose2d" or "wpi.proto.ProtobufPose2d"). Additionally, the schema name must be registered with AddSchema(string, HootSchemaType, byte[]) before calling this API.public static StatusCode WriteSchemaValue(string name, string schema, HootSchemaType type, byte[] data, double latencySeconds = 0)
Parameters
namestringName of the signal
schemastringName of the associated schema
typeHootSchemaTypeType of the associated schema, such as struct or protobuf
databyte[]Serialized data bytes
latencySecondsdoubleLatency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log
Returns
- StatusCode
Status of writing the data
WriteString(string, string, double)
Writes the string to the log file.
public static StatusCode WriteString(string name, string value, double latencySeconds = 0)
Parameters
namestringName of the signal
valuestringValue to write
latencySecondsdoubleLatency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log
Returns
- StatusCode
Status of writing the data
WriteStringArray(string, string[], double)
Writes the array of strings to the log file.
public static StatusCode WriteStringArray(string name, string[] values, double latencySeconds = 0)
Parameters
namestringName of the signal
valuesstring[]Array of values to write
latencySecondsdoubleLatency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log
Returns
- StatusCode
Status of writing the data