Robotran C Documentation
Macros | Functions | Variables
set_output.c File Reference
#include <stdlib.h>
#include <string.h>
#include "mbs_data.h"
#include "mbs_define.h"
#include "set_output.h"
#include "auto_output.h"
#include "mbs_message.h"

Macros

#define MSG_ERR   ">> BUFFERS>> "
 
#define MSG_PRE   " >> "
 

Functions

int set_output_to_mbs (MbsData *mbs_data, int verbosity)
 Set the address of this buffers in MbsData to expose memory + synchronize verbosity. More...
 
int set_mbs_to_output (MbsData *mbs_data)
 Set the value of this buffers from MbsData to use another module memory. More...
 
void reset_flag_output ()
 reset the flag_output to 0. Useful when running several simulation in a row with different save2file settings. More...
 
void init_set_output (int max_nb_curves)
 initialize the static auto_output structure More...
 
int define_output_vector (char *label, int size)
 set needed information to handle the specified vector name in the auto_output structure. More...
 
void free_set_output ()
 release memory of auto_output More...
 
int set_output (double value, char *label)
 function called by the user to output the time evolution of a value More...
 
int set_output_vector (double *vector, char *label)
 function called by the user to output the time evolution of a whole vector. More...
 
int set_output_vector_from_id (double *vector, char *label, int output_id)
 function called by the user to output the time evolution of a whole vector. It is very similar to set_output_vector, with the output_id (starting at zero) of the vector that is known This allow to run the set_output function faster. By calling this function with an unknown vector (i.e. output_id = -1, the function will search for the correct index by itself - slower) More...
 
int set_output_partial_vector_from_id (double *vector, char *label, int output_id, int start, int number)
 Set part of a vector into a buffer (from its id). More...
 
int set_output_value (double value, int val_index, char *label)
 function called by the user to output the time evolution of a value in a vector. More...
 
int set_output_value_from_id (double value, int val_index, char *label, int output_id)
 
double get_output_value (int index)
 get the output value corresponding to the requested index More...
 
char * get_output_label (int index)
 get the output label corresponding to the requested index More...
 
char * get_output_vector_label (int index)
 get the output vector label corresponding to the requested index More...
 
int get_output_vector_size (int index)
 get the output vector size corresponding to the requested index More...
 
int get_output_nb ()
 get the number of user inputs More...
 
int get_output_vector_nb ()
 get the number of user vector inputs More...
 
int get_output_nb_new ()
 get the number of new user inputs More...
 
double * get_output_vector_ptr (int index)
 get the pointer to the output vector at the requested index More...
 
void set_output_nb_new (int nb)
 set the number of new user inputs More...
 

Variables

static AutoOutputauto_output
 
int flag_output = 0
 1 if init_set_output was called, 0 otherwise More...
 
int flag_warning_output_raised = 0
 1 if a warning message has already been raised, 0 otherwise More...
 
int set_output_verbose = 1
 1 if we want to print messages, 1 is the default. (0 no messages) More...
 

Detailed Description

Define functions called by the user to output his own variables.

Date
20/12/2023
Author
Robotran Team

Macro Definition Documentation

◆ MSG_ERR

#define MSG_ERR   ">> BUFFERS>> "

◆ MSG_PRE

#define MSG_PRE   " >> "

Function Documentation

◆ define_output_vector()

int define_output_vector ( char *  label,
int  size 
)

set needed information to handle the specified vector name in the auto_output structure.

In the default MBsysC behavior, if the vector definition fails, the current module will stop.

If you redirected the mbs_error_msg() via mbs_set_error_msg_fct_ptr() to a function that does not stop the process you are responsible to set MbsData::flag_stop to 1 to prevent further execution.

Parameters
[in]labelthe label of the vector
[in]sizethe number of element to save in the vector (or the size of the saved vector)
Returns
The status, negative in case of error.

◆ free_set_output()

void free_set_output ( )

release memory of auto_output

◆ get_output_label()

char* get_output_label ( int  index)

get the output label corresponding to the requested index

Parameters
[in]indexrequested index
Returns
requested label or "no_output" if there is no output for the requested index

◆ get_output_nb()

int get_output_nb ( )

get the number of user inputs

Returns
number of user inputs

◆ get_output_nb_new()

int get_output_nb_new ( )

get the number of new user inputs

Returns
number of new user inputs

◆ get_output_value()

double get_output_value ( int  index)

get the output value corresponding to the requested index

Parameters
[in]indexrequested index
Returns
requested value or -1 if there is no output for the requested index

◆ get_output_vector_label()

char* get_output_vector_label ( int  index)

get the output vector label corresponding to the requested index

Parameters
[in]indexrequested index
Returns
requested vector label or "no_output" if there is no output for the requested index

◆ get_output_vector_nb()

int get_output_vector_nb ( )

get the number of user vector inputs

Returns
number of user vector inputs

◆ get_output_vector_ptr()

double* get_output_vector_ptr ( int  index)

get the pointer to the output vector at the requested index

Parameters
[in]indexrequested index
Returns
requested vector pointer for the requested index or NULL.

◆ get_output_vector_size()

int get_output_vector_size ( int  index)

get the output vector size corresponding to the requested index

Parameters
[in]indexrequested index
Returns
requested vector size for the requested index or -1 in case of error.

◆ init_set_output()

void init_set_output ( int  max_nb_curves)

initialize the static auto_output structure

◆ reset_flag_output()

void reset_flag_output ( )

reset the flag_output to 0. Useful when running several simulation in a row with different save2file settings.

◆ set_mbs_to_output()

int set_mbs_to_output ( MbsData mbs_data)

Set the value of this buffers from MbsData to use another module memory.

◆ set_output()

int set_output ( double  value,
char *  label 
)

function called by the user to output the time evolution of a value

If the output fails, a warning message is raised. If you want to stop the computation set MbsData::flag_stop to 1.

Parameters
[in]valuecurrent value to output
[in]labellabel of the value
Returns
The status, negative in case of error.

◆ set_output_nb_new()

void set_output_nb_new ( int  nb)

set the number of new user inputs

Parameters
[in]nbnumber of new outputs to set

◆ set_output_partial_vector_from_id()

int set_output_partial_vector_from_id ( double *  vector,
char *  label,
int  output_id,
int  start,
int  number 
)

Set part of a vector into a buffer (from its id).

The behavior is the same as set_output_vector_from_id() except that only the specified number of values are saved stating at the specified index. The starting index refer to the buffer indexing. The values are taken from the beginning of the provided array.

In the default MBsysC behavior, if the function fails, the current module will stop.

Parameters
[in]vectorPointer to the vector with values to be send to buffer.
[in]labelCurrent output label, NULL can be provided (no coherence check).
[in]output_idIndex of the output vector, starting at zero (if not known, -1).
[in]startIndex in the buffer array to start to save the provided vector. The value must be strictly positive and fit in the buffer size. The first index is 0.
[in]numberNumber of value to be saved from the vector to the buffer. If this number exceed the size of the vector, an undefined behavior occurs. If start + number exceed the buffer size, an error is raised.
Returns
The status, negative in case of error.

◆ set_output_to_mbs()

int set_output_to_mbs ( MbsData mbs_data,
int  verbosity 
)

Set the address of this buffers in MbsData to expose memory + synchronize verbosity.

◆ set_output_value()

int set_output_value ( double  value,
int  val_index,
char *  label 
)

function called by the user to output the time evolution of a value in a vector.

Parameters
[in]valuecurrent output value
[in]val_indexindex of the value in the saved vector, first index is 1
[in]labelcurrent output label
Returns
The status, negative in case of error.

◆ set_output_value_from_id()

int set_output_value_from_id ( double  value,
int  val_index,
char *  label,
int  output_id 
)

◆ set_output_vector()

int set_output_vector ( double *  vector,
char *  label 
)

function called by the user to output the time evolution of a whole vector.

In the default MBsysC behavior, if the function fails, the current module will stop.

If you redirected the mbs_error_msg() via mbs_set_error_msg_fct_ptr() to a function that does not stop the process you can set MbsData::flag_stop to 1 to prevent further computation. If you let it continue, the vector is not saved.

Parameters
[in]vectorpointer to the current outputs vector
[in]labelcurrent output label
Returns
The status, negative in case of error.

◆ set_output_vector_from_id()

int set_output_vector_from_id ( double *  vector,
char *  label,
int  output_id 
)

function called by the user to output the time evolution of a whole vector. It is very similar to set_output_vector, with the output_id (starting at zero) of the vector that is known This allow to run the set_output function faster. By calling this function with an unknown vector (i.e. output_id = -1, the function will search for the correct index by itself - slower)

In the default MBsysC behavior, if the function fails, the current module will stop.

If you redirected the mbs_error_msg() via mbs_set_error_msg_fct_ptr() to a function that does not stop the process you can set MbsData::flag_stop to 1 to prevent further computation. If you let it continue, the vector is not saved.

Parameters
[in]vectorpointer to the current outputs vector
[in]labelcurrent output label (NULL if not known)
[in]output_idid of the output vector, starting at zero (if not known, -1)
Returns
The status, negative in case of error.

Variable Documentation

◆ auto_output

AutoOutput* auto_output
static

◆ flag_output

int flag_output = 0

1 if init_set_output was called, 0 otherwise

◆ flag_warning_output_raised

int flag_warning_output_raised = 0

1 if a warning message has already been raised, 0 otherwise

◆ set_output_verbose

int set_output_verbose = 1

1 if we want to print messages, 1 is the default. (0 no messages)