RecordManager.cs - UF-CSSALT/SMARTS-SDK-Unity-Asset-Package GitHub Wiki

This class gives users a simple, intuitive, easy to use method for recording procedures and replaying them for later rescoring, debriefing, and demonstration. This class is fully exposed and has significant internal documentation describing its entire functionality. It is designed to record ATC data, Microcontroller data, and file headers, but its functionality and record potential can be expanded and modified to fit project specific recording needs.

Namespace

Default:

The Record_Manager.cs script is provided with the CSSALT SMARTS-SDK but exists outside of the SMARTS_SDK namespace.

Static Fields

Record_Manager.ME:

This is the singleton reference of the Record_Manager.cs script. It provides simple access to any external scripts trying to start/end records and replays.

Public Enums

Mode:

  • Record
  • Replay
  • Standby

Public Fields

string ReplayFilePath (readonly):

This field returns the file path being used for the current replay.

int ReplayFrameNumber (readonly):

This field returns the frame number of the current recorded frame being replayed.

float ReplayFrameTime (readonly):

This field returns the Time.time value of the recorded frame that is currently being replayed.

int MaxReplayFrameLoaded (readonly):

Because this class was built to use multithreading to optimize performance, records are loaded using a StreamReader on a separate thread. This field therefore returns the highest frame read in and loaded by the StreamReader.

float MaxReplayFrameTime (readonly):

Similarly to the MaxReplayFrameLoaded, this field returns the Time.time of the highest frame read in and loaded by the StreamReader.

bool RecordLoaded (readonly):

The RecordLoaded field returns true if the most recent requested record has been loaded in completely, false otherwise.

Public Methods

void StartRecord(string saveFilePath = “”)

This method is called to start recording a session. This sets the current operation mode to Mode.Record. When called, if the user specifies a specific location using the saveFilePath input parameter, the record will begin and the data will be recorded locally, and written to the file. If the user does not specify the file path, data will only be stored locally and not written to a file.

Input Parameters:

string saveFilePath:

If specified by the user, defines the location to save the recorded data to. If left unspecified, the data is recorded locally and is not written to a file.

void EndRecord()

When called, the current recording session is terminated. If writing to a file, the StreamWriter is closed. The operation mode is set to Standby.

void LoadRecord(string recordPath)

This method is called to begin loading a record. It is called internally by the ReplayRecordedData() method, but can be called externally to load in a record before the replay needs to occur. If the input string is not a valid file path, a FileNotFoundException will be thrown.

Input Parameters:

string recordPath:

The file path of the record to be loaded in. Must be a valid file path or an exception will be thrown.

void ReplayRecordedData(string filePath = “”)

Used to replay recorded data. When called the operation mode is set to Replay and the replay begins. If a filePath is specified, and valid, the recorded data from the file is extracted and replayed. However, if left unspecified, the locally recorded data is replayed. If the method LoadRecord() was called to load in a record and has completely loaded in the record, the filePath should be left unspecified, as the record already exists locally and can be immediately replayed. At the current moment, the replay will be played in its entirety without interruption. Further functionality can be added by users. This class will be modified to add functionality by CSSALT in a later Update.

Input Parameters:

string filePath:

If specified, the file path is used to load in a record. The file path must be valid otherwise an unhandled FileNotFoundException will be thrown.