Table of Contents

Class HootReplay

Namespace
CTRE.Phoenix6
Assembly
Phoenix6.Hardware.dll

Static class for controlling Phoenix 6 hoot log replay.

public static class HootReplay
Inheritance
HootReplay
Inherited Members

Remarks

This replays all signals in the given hoot log in simulation. Hoot logs can be created by a robot program using SignalLogger. Only one hoot log, corresponding to one CAN bus, may be replayed at a time.

The signal logger always runs while replay is running. All custom signals written during replay will be automatically placed under hoot_replay/. Additionally, the log will contain all status signals and custom signals from the original log.

During replay, all transmits from the robot program are ignored. This includes features such as control requests, configs, and setting signal update frequency. Additionally, Tuner X is not functional during log replay.

To use Hoot Replay, call LoadFile(string) before any devices are constructed to load a hoot file and start replay. Alternatively, the CANBus(string, string) constructor can be used when constructing devices.

After devices are constructed, Hoot Replay can be controlled using Play(), Pause(), Stop(), and Restart(). Additionally, Hoot Replay supports StepTiming(double) while paused. The current file can be closed using CloseFile(), after which a new file may be loaded.

Methods

CloseFile()

Ends the hoot log replay. This stops the replay if it is running, closes the hoot log, and clears all signals read from the file.

public static void CloseFile()

GetBoolean(string)

Gets a boolean user signal.

public static SignalMeasurement<bool> GetBoolean(string name)

Parameters

name string

Name of the signal

Returns

SignalMeasurement<bool>

Structure with all information about the signal

GetBooleanArray(string)

Gets a boolean array user signal.

public static SignalMeasurement<bool[]> GetBooleanArray(string name)

Parameters

name string

Name of the signal

Returns

SignalMeasurement<bool[]>

Structure with all information about the signal

GetDouble(string)

Gets a double user signal.

public static SignalMeasurement<double> GetDouble(string name)

Parameters

name string

Name of the signal

Returns

SignalMeasurement<double>

Structure with all information about the signal

GetDoubleArray(string)

Gets a double array user signal.

public static SignalMeasurement<double[]> GetDoubleArray(string name)

Parameters

name string

Name of the signal

Returns

SignalMeasurement<double[]>

Structure with all information about the signal

GetFloat(string)

Gets a float user signal.

public static SignalMeasurement<float> GetFloat(string name)

Parameters

name string

Name of the signal

Returns

SignalMeasurement<float>

Structure with all information about the signal

GetFloatArray(string)

Gets a float array user signal.

public static SignalMeasurement<float[]> GetFloatArray(string name)

Parameters

name string

Name of the signal

Returns

SignalMeasurement<float[]>

Structure with all information about the signal

GetInteger(string)

Gets an integer user signal.

public static SignalMeasurement<long> GetInteger(string name)

Parameters

name string

Name of the signal

Returns

SignalMeasurement<long>

Structure with all information about the signal

GetIntegerArray(string)

Gets an integer array user signal.

public static SignalMeasurement<long[]> GetIntegerArray(string name)

Parameters

name string

Name of the signal

Returns

SignalMeasurement<long[]>

Structure with all information about the signal

GetRaw(string)

Gets a raw-bytes user signal.

public static SignalMeasurement<byte[]> GetRaw(string name)

Parameters

name string

Name of the signal

Returns

SignalMeasurement<byte[]>

Structure with all information about the signal

GetSchemaValue(string, HootSchemaType)

Gets a schema-serialized user signal.

public static SignalMeasurement<byte[]> GetSchemaValue(string name, HootSchemaType type)

Parameters

name string

Name of the signal

type HootSchemaType

Type of the schema, such as struct or protobuf

Returns

SignalMeasurement<byte[]>

Structure with all information about the signal

GetString(string)

Gets a string user signal.

public static SignalMeasurement<string> GetString(string name)

Parameters

name string

Name of the signal

Returns

SignalMeasurement<string>

Structure with all information about the signal

GetStringArray(string)

Gets a string array user signal.

public static SignalMeasurement<string[]> GetStringArray(string name)

Parameters

name string

Name of the signal

Returns

SignalMeasurement<string[]>

Structure with all information about the signal

IsFileLoaded()

Gets whether a valid hoot log file is currently loaded.

public static bool IsFileLoaded()

Returns

bool

true if a valid hoot log file is loaded

IsFinished()

Gets whether hoot log replay has reached the end of the log.

public static bool IsFinished()

Returns

bool

true if replay has reached the end of the log, or if no log is currently loaded

IsPlaying()

Gets whether hoot log replay is actively playing.

This API will return true in programs that do not support replay, making it safe to call without first checking if the program supports replay.
public static bool IsPlaying()

Returns

bool

true if replay is playing back signals

LoadFile(string)

Loads the given file and starts signal log replay. Only one hoot log, corresponding to one CAN bus, may be replayed at a time.

This must be called before constructing any devices or checking CAN bus status. The CANBus(string, string) constructor can be used when constructing devices to guarantee that this API is called first.
public static StatusCode LoadFile(string filepath)

Parameters

filepath string

Path and name of the hoot file to load

Returns

StatusCode

Status of opening and reading the file for replay

Remarks

When using relative paths, the file path is typically relative to the top-level folder of the robot project.

This API is blocking on the file read.

Pause()

Pauses the hoot log replay. This maintains the current position in the log replay so it can be resumed later.

public static StatusCode Pause()

Returns

StatusCode

Status of pausing replay

Play()

Starts or resumes the hoot log replay.

public static StatusCode Play()

Returns

StatusCode

Status of starting or resuming replay

Restart()

Restarts the hoot log replay from the start of the log. This is equivalent to calling Stop() followed by Play().

public static StatusCode Restart()

Returns

StatusCode

Status of restarting replay

SetSpeed(double)

Sets the speed of the hoot log replay. A speed of 1.0 corresponds to replaying the file in real time, and larger values increase the speed.

  • Minimum Value0.01
  • Maximum Value100.0
  • Default Value1.0
public static void SetSpeed(double speed)

Parameters

speed double

Speed of the hoot log replay

StepTiming(double)

Advances the hoot log replay time by the given value. Replay must be paused or stopped before advancing its time.

public static StatusCode StepTiming(double stepTimeSeconds)

Parameters

stepTimeSeconds double

The amount of time to advance

Returns

StatusCode

Status of advancing the replay time

Stop()

Stops the hoot log replay. This resets the current position in the log replay to the start.

public static StatusCode Stop()

Returns

StatusCode

Status of stopping replay

WaitForPlaying(double)

Waits until hoot log replay is actively playing.

This API will immediately return true in programs that do not support replay, making it safe to call without first checking if the program supports replay.

Since this can block the calling thread, this should not be called with a non-zero timeout on the main thread.

This can also be used with a timeout of 0 to perform a non-blocking check, which is equivalent to IsPlaying().
public static bool WaitForPlaying(double timeoutSeconds)

Parameters

timeoutSeconds double

Max time to wait for replay to start playing

Returns

bool

true if replay is playing back signals