#include "realtime.h"
#include "time_functions.h"
#include "useful_functions.h"
#include "user_realtime.h"
#include "mbs_message.h"
#include "mbs_errors_names.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
Macros | |
#define | USEC_TO_SEC 1.0e-6 |
factor from us to s More... | |
#define | DEFAULT_DELTA_T_USEC (int) 1e5 |
default time between 2 refresh moments (in us) More... | |
#define | NB_REAL_TIME_CONSTRAINTS 2 |
number of real-time constraints More... | |
#define | REAL_TIME_SPEED_PERIOD_USEC 25e4 |
real time speed factor computation time [s] More... | |
#define | DEFAULT_MAX_MODELS 20 |
default maximal numbers of models to load More... | |
Functions | |
void | mbs_realtime_reset () |
reset the realtime structures and flag. Useful in case we want to run several simulations in a row in the same process. More... | |
int | mbs_realtime_init (MbsData *mbs_data, double t0, double tf, double dt0) |
initialize the real-time structures More... | |
void | mbs_realtime_update (Simu_realtime *realtime, double tsim) |
update save vectors for past investigations (graphs and Java visualization) More... | |
int | mbs_realtime_loop (Simu_realtime *realtime, double tsim) |
one loop iteration of the real-time process More... | |
int | mbs_realtime_finish (Simu_realtime *realtime) |
release memory used for the real-time related functions More... | |
Realtime_option * | init_Realtime_option (MbsData *mbs_data) |
generates a real-time options structures with the default values More... | |
void | free_Realtime_option (Realtime_option *options) |
release memory for the options structure More... | |
int | check_user_realtime_options (Realtime_option *options) |
check that the modifications performed by the user on the options are correct More... | |
void | compute_buffer_size (Realtime_option *options) |
automatically compute the buffer size More... | |
Realtime_constraint * | init_realtime_constraint (int delta_t_usec, int cur_t_usec, double tsim) |
initialize one real-time constraint More... | |
Simu_realtime * | init_realtime (MbsData *mbs_data, Realtime_option *options, int *err) |
initialize the real-time structure More... | |
Simu_realtime * | init_simu_realtime (MbsData *mbs_data, Realtime_option *options, int nb_constraints, double *fqc_tab, int *err) |
initialize the structure with all the real-time constraints More... | |
void | free_realtime_constraint (Realtime_constraint *constraint) |
free one real-time constraint More... | |
int | free_simu_realtime (Simu_realtime *realtime) |
free the structure of all the real-time constraints More... | |
void | update_realtime_constraint (Realtime_constraint *constraint, int simu_speed_flag) |
update one real-time constraint More... | |
void | update_simu_realtime (Simu_realtime *realtime) |
update the structure of all the constraints More... | |
double | get_simu_speed_factor (int simu_speed_flag) |
get simulation factor depending on the 'simu_speed_flag' flag More... | |
int | get_simu_speed_flag (double simu_speed_factor) |
get the 'simu_speed_flag' flag depending on simulation factor More... | |
void | update_realtime_constraints_break (Simu_realtime *realtime, int delta_break_u_sec) |
update the real-time constraints after a break More... | |
#define DEFAULT_DELTA_T_USEC (int) 1e5 |
default time between 2 refresh moments (in us)
#define DEFAULT_MAX_MODELS 20 |
default maximal numbers of models to load
#define NB_REAL_TIME_CONSTRAINTS 2 |
number of real-time constraints
#define REAL_TIME_SPEED_PERIOD_USEC 25e4 |
real time speed factor computation time [s]
#define USEC_TO_SEC 1.0e-6 |
factor from us to s
int check_user_realtime_options | ( | Realtime_option * | options | ) |
check that the modifications performed by the user on the options are correct
[in,out] | options | options structure |
void compute_buffer_size | ( | Realtime_option * | options | ) |
automatically compute the buffer size
[in,out] | options | options structure |
void free_realtime_constraint | ( | Realtime_constraint * | constraint | ) |
free one real-time constraint
[out] | constraint | constraint to release memory |
void free_Realtime_option | ( | Realtime_option * | options | ) |
release memory for the options structure
[out] | options | options structure |
int free_simu_realtime | ( | Simu_realtime * | realtime | ) |
free the structure of all the real-time constraints
[out] | realtime | real-time structure to release memory |
double get_simu_speed_factor | ( | int | simu_speed_flag | ) |
get simulation factor depending on the 'simu_speed_flag' flag
[in] | simu_speed_flag | index used to compute the speed factor |
int get_simu_speed_flag | ( | double | simu_speed_factor | ) |
get the 'simu_speed_flag' flag depending on simulation factor
[in] | simu_speed_factor | speed factor |
Simu_realtime* init_realtime | ( | MbsData * | mbs_data, |
Realtime_option * | options, | ||
int * | err | ||
) |
initialize the real-time structure
[in,out] | mbs_data | Robotran main structure |
[in] | options | options structure |
[in,out] | err | <0 if error occurs |
Realtime_constraint* init_realtime_constraint | ( | int | delta_t_usec, |
int | cur_t_usec, | ||
double | tsim | ||
) |
initialize one real-time constraint
[in] | delta_t_usec | time step for this constraint [us] |
[in] | cur_t_usec | current time (real-time) [us] |
[in] | tsim | current simulation time [s] |
Realtime_option* init_Realtime_option | ( | MbsData * | mbs_data | ) |
generates a real-time options structures with the default values
< initial simulation time [s]
< final simulation time [s]
< simulation time step [s]
< 1 to start with a break, 0 otherwise
< 1 to finish with a break, 0 otherwise
< size of the buffer for 3D visu and sdl
< initial speed factor
< 1 if SDL plots features activated, 0 otherwise
< plot curve width in number of pixels
< plot screen width in number of pixels
< plot screen height in number of pixels
< maximum number of curves plotted
< maximum number of curves legends indicated
< initial lower bound for the y values plotted
< initial upper bound for the y values plotted
< frequence of the SDL plots refreshment [Hz]
< 1 if Java visualization features activated, 0 otherwise
< number of models to load
< initial visu viewpoint ID
< frequence of the 3D visualization refreshment [Hz]
Simu_realtime* init_simu_realtime | ( | MbsData * | mbs_data, |
Realtime_option * | options, | ||
int | nb_constraints, | ||
double * | fqc_tab, | ||
int * | err | ||
) |
initialize the structure with all the real-time constraints
[in,out] | mbs_data | Robotran main structure |
[in] | options | options structure |
[in] | nb_constraints | number of real-time constraints |
[in] | fqc_tab | tabular with the constraints freqeuncies |
[in,out] | err | <0 if error occurs |
int mbs_realtime_finish | ( | Simu_realtime * | realtime | ) |
release memory used for the real-time related functions
[out] | realtime | real-time structure to release memory |
int mbs_realtime_init | ( | MbsData * | mbs_data, |
double | t0, | ||
double | tf, | ||
double | dt0 | ||
) |
initialize the real-time structures
[in,out] | mbs_data | Robotran main structure |
[in] | t0 | initial time [s] |
[in] | tf | final time [s] |
[in] | dt0 | intitial time step [s] |
int mbs_realtime_loop | ( | Simu_realtime * | realtime, |
double | tsim | ||
) |
one loop iteration of the real-time process
[in,out] | realtime | real-time structure |
[in] | tsim | current simulation time [s] |
void mbs_realtime_reset | ( | ) |
reset the realtime structures and flag. Useful in case we want to run several simulations in a row in the same process.
void mbs_realtime_update | ( | Simu_realtime * | realtime, |
double | tsim | ||
) |
update save vectors for past investigations (graphs and Java visualization)
[in,out] | realtime | real-time structure |
[in] | tsim | current simulation time [s] |
void update_realtime_constraint | ( | Realtime_constraint * | constraint, |
int | simu_speed_flag | ||
) |
update one real-time constraint
[in] | constraint | real-time constraint |
[in] | simu_speed_flag | index used to compute the speed factor |
void update_realtime_constraints_break | ( | Simu_realtime * | realtime, |
int | delta_break_u_sec | ||
) |
update the real-time constraints after a break
[in,out] | realtime | real-time structure |
[in] | delta_break_u_sec | delta of time for next gate [us] |
void update_simu_realtime | ( | Simu_realtime * | realtime | ) |
update the structure of all the constraints
[in,out] | realtime | real-time structure |