SBB Host
Host communication with the self balancing bike.
Loading...
Searching...
No Matches
LogData< T > Class Template Reference

A templated-class for managing logged-data. More...

#include <LogData.h>

Public Member Functions

 LogData (std::string str_name, std::string str_path, std::vector< std::string > signal_names, int ID, size_t num_of_signals, size_t num_of_samples, Time *p_time=nullptr, std::string theAuthor="unknown")
 Constructor. More...
 
 ~LogData ()
 Destructor. More...
 
get (int i, int j)
 Get a single sample of a signal. More...
 
std::vector< T > get (int i)
 Get all samples of a signal. More...
 
int push_back (T *packet)
 Push data to the log buffer. More...
 
std::string getAuthor ()
 Get author name. More...
 
std::string getDate ()
 Get the date. More...
 
size_t save (File *p_file)
 Save the log. More...
 

Public Attributes

size_t num_samples
 Number of logged samples. More...
 
size_t num_signals
 Number of logged signals. More...
 
size_t max_num_samples
 Max number of logged samples (reserved for vectors). More...
 
std::vector< std::vector< T > > data
 Vector of vector of type T (i.e. a matrix with num_signals rows and max_num_samples columns) More...
 
std::vector< size_t > samples
 Vector of samples. More...
 
std::vector< std::string > signals
 Vector of signal names. More...
 
std::string name
 Name of the log. More...
 
std::string path
 Path of the corresponding log file. More...
 
std::string author
 Author of the log. More...
 
Timetime
 Variable to store the initial time. More...
 
int id = -1
 ID of the log. More...
 
bool saved
 True if the log has been saved. More...
 

Detailed Description

template<typename T>
class LogData< T >

A templated-class for managing logged-data.

Templated-class for managing logged-data with used-defined type, used in SBBHostCore.

See also
SBBHostCore
Template Parameters
TThe base type of the packet.
Author
Stefano Lovato
Date
2022

Constructor & Destructor Documentation

◆ LogData()

template<typename T >
LogData< T >::LogData ( std::string  str_name,
std::string  str_path,
std::vector< std::string >  signal_names,
int  ID,
size_t  num_of_signals,
size_t  num_of_samples,
Time p_time = nullptr,
std::string  theAuthor = "unknown" 
)
inline

Constructor.

Default constructor of the logged data.

Parameters
str_nameTh name of the logged data.
str_pathThe path of the corresponding file (if any).
signal_namesThe vector of signal names.
IDThe ID of the log.
num_of_signalsThe number of signals of the log.
num_of_samplesThe number of samples of the log.

◆ ~LogData()

template<typename T >
LogData< T >::~LogData ( )
inline

Destructor.

Default destructor. It clears the logged data.

Member Function Documentation

◆ get() [1/2]

template<typename T >
std::vector< T > LogData< T >::get ( int  i)
inline

Get all samples of a signal.

Function to get all samples of a given signal.

Parameters
iThe index of the signal.
Returns
The vector containing the i-th signal data.

◆ get() [2/2]

template<typename T >
T LogData< T >::get ( int  i,
int  j 
)
inline

Get a single sample of a signal.

Function to get a single sample of a given signal.

Parameters
iThe index of the signal.
jThe index of the sample.
Returns
The j-th sample of the i-th signal.

◆ getAuthor()

template<typename T >
std::string LogData< T >::getAuthor ( )
inline

Get author name.

Function to get the author of the log.

Returns
The name of the author.

◆ getDate()

template<typename T >
std::string LogData< T >::getDate ( )
inline

Get the date.

Function to get the creation date and time of the log.

Returns
The data as a formatted string.

◆ push_back()

template<typename T >
int LogData< T >::push_back ( T *  packet)
inline

Push data to the log buffer.

Function to push data to the log buffer.

Parameters
packetThe pointer to the signal packet to pust
Returns
The number of written elements.

◆ save()

template<typename T >
size_t LogData< T >::save ( File p_file)
inline

Save the log.

Function to save the log to a file. The file must be open before. The file is not closed after the saving.

Parameters
p_fileThe pointer to the File object.
Returns
The number of samples written to the file.

Member Data Documentation

◆ author

template<typename T >
std::string LogData< T >::author

Author of the log.

◆ data

template<typename T >
std::vector<std::vector<T> > LogData< T >::data

Vector of vector of type T (i.e. a matrix with num_signals rows and max_num_samples columns)

◆ id

template<typename T >
int LogData< T >::id = -1

ID of the log.

◆ max_num_samples

template<typename T >
size_t LogData< T >::max_num_samples

Max number of logged samples (reserved for vectors).

◆ name

template<typename T >
std::string LogData< T >::name

Name of the log.

◆ num_samples

template<typename T >
size_t LogData< T >::num_samples

Number of logged samples.

◆ num_signals

template<typename T >
size_t LogData< T >::num_signals

Number of logged signals.

◆ path

template<typename T >
std::string LogData< T >::path

Path of the corresponding log file.

◆ samples

template<typename T >
std::vector<size_t> LogData< T >::samples

Vector of samples.

◆ saved

template<typename T >
bool LogData< T >::saved

True if the log has been saved.

◆ signals

template<typename T >
std::vector<std::string> LogData< T >::signals

Vector of signal names.

◆ time

template<typename T >
Time* LogData< T >::time

Variable to store the initial time.