Anti-Sway Capstone 1.0
Loading...
Searching...
No Matches
record.c File Reference

Data Recording Interface. More...

#include <stdlib.h>
#include <string.h>
#include "matlabfiles.h"
#include "setup.h"
#include "record.h"
Include dependency graph for record.c:

Data Structures

struct  DataFile_t
 Data File. More...
 

Macros

#define DEFAULT_NUM_FILES   3
 Default number of Files to remember.
 
#define DEFAULT_NUM_VALS   10
 Default number of values for data arrays.
 
#define DEFAULT_RESIZE_FACTOR   2
 Default resize factor.
 

Functions

static void DeallocateHelper ()
 
static int ReallocateHelper (DataFile_t *f)
 
FileID_t OpenDataFile (char *name, char **entry_names, int num_entries)
 
int RecordData (FileID_t file, double data[], int data_length)
 
int RecordValue (FileID_t file, char *value_name, double value)
 
int SaveDataFiles ()
 

Variables

static DataFile_tfiles = NULL
 The data files this module is handling.
 
static int num_files = 0
 The number of files this module is handling.
 
static int capacity_files = 0
 The number of files this module can handle.
 

Detailed Description

Data Recording Interface.

Author
Anti-Sway Team: Nguyen, Tri; Espinola, Malachi; Tevy, Vattanary; Hokenstad, Ethan; Neff, Callen)
Version
0.1
Date
2024-06-03

Function Documentation

◆ DeallocateHelper()

static void DeallocateHelper ( )
inlinestatic

Deallocates the entire module

◆ OpenDataFile()

FileID_t OpenDataFile ( char * name,
char ** entry_names,
int num_entries )

Opens a data file

Parameters
nameThe name of the file
entry_namesThe name of each entry
num_entriesThe number of entries
Returns
The file ID upon success, or negative upon failure
Here is the call graph for this function:

◆ ReallocateHelper()

static int ReallocateHelper ( DataFile_t * f)
inlinestatic

Reallocates the entry_values for a DataFile_t

Parameters
fA pointer to the DataFile_t to resize
Returns
0 iff success, negative upon error
Postcondition
for all 0 <= i <= f->num_entries, f->entry_values[i] is now double its capacity from before, if, at the beginning of this function, f->num_vals == f->vals->capacity

◆ RecordData()

int RecordData ( FileID_t file,
double data[],
int data_length )

Records data for each entry

Parameters
fileThe FileID_t to record upon
dataThe array of data to record (in order of the entries)
data_lengthThe length of the data array
Returns
0 iff success, negative upon failure
Here is the call graph for this function:

◆ RecordValue()

int RecordValue ( FileID_t file,
char * value_name,
double value )

Records one-time data

Parameters
fileThe FileID_t to record upon
value_nameThe name of the value
valueThe value to record
Returns
0 iff success, negative upon failure

◆ SaveDataFiles()

int SaveDataFiles ( )

Records all data into actual files, and closes all files

Returns
0 iff success, negative upon failure
Here is the call graph for this function: