|
SBB Host
Host communication with the self balancing bike.
|
A class for the core of the SBB Host application. More...
#include <SBBHostCore.h>
Public Member Functions | |
| SBBHostCore () | |
| Constructor. More... | |
| ~SBBHostCore () | |
| Desctructor. More... | |
| void | set_params (Params *params) |
| Set the parameters. More... | |
| void | reset_stream () |
| Reset the data streaming. More... | |
| int | stream (bool writeFlag) |
| Perform a stream step. More... | |
| void | beginlog (std::string path) |
| Begin the data logging. More... | |
| int | connect (bool logdata=false, std::string log_path="") |
| Connect the host port. More... | |
| void | disconnect () |
| Disconnect the host port. More... | |
| int | save (int id) |
| Save a log as a *.sbb file. More... | |
| int | save (int id, std::string name, std::string path) |
| Save a log as a *.sbb file. More... | |
| int | save_dat (int id, std::string str) |
| Save a log as *.dat file. More... | |
| int | save_mat (int id, std::string str) |
| Save a log as *.csv file. More... | |
| int | open (std::string str) |
| Open a log from a *.sbb file. More... | |
| int | find (int id) |
| Find a log using the ID. More... | |
| int | get_lastUnsaved (int *id) |
| Get the ID of the last unsaved log. More... | |
| bool | check_allSaved () |
| Check if all log are saved. More... | |
| void | set_path_logs (std::string folder) |
| Set the default path of all logs. More... | |
| bool | delete_log (int id) |
| Delete a log. More... | |
Public Attributes | |
| Params * | p_params |
| Pointer to the parameters structure created in SBBHostApp. More... | |
| unsigned int | numOfMissingPackets = 0 |
| Number of current missing packets. More... | |
| int | id_count = 0 |
| Counter of logged-data ID. More... | |
| long long | samples = -1 |
| Number of current logged sample. More... | |
| bool | dolog = false |
| true if do data logging. More... | |
| std::string | tmp_name = "" |
| Temporary name for the logged-data. More... | |
| HostPort | hostPort |
| HostPort object. More... | |
| HostPortTCP | hostPortTCP |
| HostPortTCP object. More... | |
| HostPortUDP | hostPortUDP |
| HostPortUDP object. More... | |
| Packet< float, PACKET_SIZE > | rx_packet |
| Rx Packet object. More... | |
| Packet< float, PACKET_SIZE > | tx_packet |
| Tx Packet object. More... | |
| Time | time |
| Time object. More... | |
| std::vector< LogData< float > * > | logData |
| Vector of pointers to LogData with base type float. More... | |
| File * | p_file = { nullptr } |
| Pointer to File object. More... | |
Private Member Functions | |
| size_t | save_dat_private (File *p_file, LogData< float > *p_logData) |
| Private routine to save *.csv format. More... | |
| bool | save_mat_private (std::string filename, LogData< float > *p_logData) |
| Private routine to save *.mat file. More... | |
A class for the core of the SBB Host application.
Class for the core management of the SBB Host Application. This class is used for signal streaming and logging via the the host port, and to store, save and open the logged-data files.
| SBBHostCore::SBBHostCore | ( | ) |
Constructor.
Default constractor.
| SBBHostCore::~SBBHostCore | ( | ) |
Desctructor.
Default destructor. It automatically destroies the host port.
| void SBBHostCore::beginlog | ( | std::string | path | ) |
Begin the data logging.
Function to begin the data logging with a given path. The log name is automatically generated from the current system time.
| path | The default path where to save the log when necessary. |
| bool SBBHostCore::check_allSaved | ( | ) |
Check if all log are saved.
Function to check if are logged data are saved.
| int SBBHostCore::connect | ( | bool | logdata = false, |
| std::string | log_path = "" |
||
| ) |
Connect the host port.
Function to connect the host port and begin the data streaming.
| logdata | The flag to enable the data logging. |
| log_path | The string og the default path where to save the log when necessary, |
| bool SBBHostCore::delete_log | ( | int | id | ) |
Delete a log.
Function to a log by specifying its ID.
| id | The ID of the log to delete. |
| void SBBHostCore::disconnect | ( | ) |
Disconnect the host port.
Function to disconnect the host port and stop the data streaming.
| int SBBHostCore::find | ( | int | id | ) |
Find a log using the ID.
Function to find a log by specifying its ID.
| id | The ID of the log to find. |
| int SBBHostCore::get_lastUnsaved | ( | int * | id | ) |
Get the ID of the last unsaved log.
Function to get the ID of the last unsaved logged data.
| id | Pointer to the ID of the log. |
| int SBBHostCore::open | ( | std::string | str | ) |
Open a log from a *.sbb file.
Function to open a *.sbb file and load the logged data.
| str | The path/name string of the file to open. |
| void SBBHostCore::reset_stream | ( | ) |
Reset the data streaming.
Function to reset the data streaming when finished.
| int SBBHostCore::save | ( | int | id | ) |
Save a log as a *.sbb file.
Function to save a log as a *.sbb file by specifying its ID with the default names.
| id | The ID of the logged-data to save. |
| int SBBHostCore::save | ( | int | id, |
| std::string | name, | ||
| std::string | path | ||
| ) |
Save a log as a *.sbb file.
Function to save a log as a *.sbb file by specifying its ID with specific name and path. Name and path are assigned to the logged-data.
| id | The ID of the logged-data to save. |
| name | The name of the file to save. |
| path | The path of the file to save. |
| int SBBHostCore::save_dat | ( | int | id, |
| std::string | str | ||
| ) |
Save a log as *.dat file.
Function to save a log as a *.dat file by specifying its ID. The first column is the Sample, while the other the signals. Values are separated by a comma.
| id | The ID of the logged-data to save. |
| str | The path/name string of the file to save |
| int SBBHostCore::save_mat | ( | int | id, |
| std::string | str | ||
| ) |
Save a log as *.csv file.
Function to save a log as a *.mat file by specifying its ID. The tinymatlibrary is used to save the *.mat file.
| id | The ID of the logged-data to save. |
| str | The path/name string of the file to save. |
|
private |
Private routine to save *.mat file.
Private function to save logged-data in *.mat (MATLAB) format. The file must not be open before and closed after.
| filename | The name of the file to save (including the path) |
| p_logData | Pointet to the LogData object to be saved. |
| void SBBHostCore::set_params | ( | Params * | params | ) |
Set the parameters.
Function to set the pointer to the parameters structure.
| params | Pointer to the parameter struct variable. |
| void SBBHostCore::set_path_logs | ( | std::string | folder | ) |
Set the default path of all logs.
Function to set the default path of all logs.
| int SBBHostCore::stream | ( | bool | writeFlag | ) |
Perform a stream step.
Function to perform a stream step. Must be called continously.
| writeFlag | The flag write the tx packet. |
| bool SBBHostCore::dolog = false |
true if do data logging.
| HostPortTCP SBBHostCore::hostPortTCP |
HostPortTCP object.
| HostPortUDP SBBHostCore::hostPortUDP |
HostPortUDP object.
| int SBBHostCore::id_count = 0 |
Counter of logged-data ID.
| std::vector<LogData<float>*> SBBHostCore::logData |
Vector of pointers to LogData with base type float.
| unsigned int SBBHostCore::numOfMissingPackets = 0 |
Number of current missing packets.
| Params* SBBHostCore::p_params |
Pointer to the parameters structure created in SBBHostApp.
| Packet<float, PACKET_SIZE> SBBHostCore::rx_packet |
Rx Packet object.
| long long SBBHostCore::samples = -1 |
Number of current logged sample.
| std::string SBBHostCore::tmp_name = "" |
Temporary name for the logged-data.
| Packet<float, PACKET_SIZE> SBBHostCore::tx_packet |
Tx Packet object.