Commit 39b7c2cb authored by Nicolas Van der Noot's avatar Nicolas Van der Noot
Browse files

flags sdl and java

parent 7e20b161
......@@ -32,6 +32,7 @@
* So, if your factor does not match these requirements, it will be rounded to fulfill them.
*
* * SDL plots options
* * options->flag_plot: 1 to activate SDL plots features (and keyboard/joystick interactions), 0 otherwise (default: 1)
* * options->curve_width: curves width in number of pixels (default: 3)
* * options->screen_width: plot screen width in number of pixels (default: 660)
* * options->screen_height: plot screen height in number of pixels (default: 520)
......@@ -54,6 +55,7 @@
* This frequence also determines the speed of the moving cursor.
*
* * Java visualization options
* * options->flag_visu: 1 to activate Java visualization features, 0 otherwise (default: 1)
* * options->nb_q: number of joints in the .mbs files used for visualization (default: mbs_data->njoint)
* * options->mbs_file: path and file name fot the .mbs file used for Java visualization
* (default: PROJECT_SOURCE_DIR"/dataR/"MBS_NAME".mbs")
......
......@@ -49,7 +49,7 @@ int main(int argc, char const *argv[])
mbs_dirdyn = mbs_new_dirdyn(mbs_data);
mbs_dirdyn->options->dt0 = 1e-3;
mbs_dirdyn->options->tf = 10.;
mbs_dirdyn->options->tf = 10.0;
// save options
mbs_dirdyn->options->resfilename = "MyDirdyn";
......@@ -58,7 +58,7 @@ int main(int argc, char const *argv[])
mbs_dirdyn->options->save2file = 1;
mbs_dirdyn->options->saveperiod = 5;
mbs_dirdyn->options->realtime = 0;
mbs_dirdyn->options->realtime = 1;
mbs_run_dirdyn(mbs_dirdyn, mbs_data);
......
......@@ -56,7 +56,10 @@ void mbs_realtime_init(MbsData* mbs_data, double dt0, double tf)
// initial plot
#ifdef SDL
plot_screen_sdl(realtime, options->t0, 2);
if (options->flag_plot)
{
plot_screen_sdl(realtime, options->t0, 2);
}
#endif
mbs_data->realtime = realtime;
......@@ -71,12 +74,18 @@ void mbs_realtime_update(Simu_realtime *realtime, double tsim)
{
// update simulation vectors save for the plot
#ifdef SDL
update_full_vectors(realtime, tsim);
if (realtime->flag_plot)
{
update_full_vectors(realtime, tsim);
}
#endif
// update simulation vectors save for the Java visualization
#ifdef JAVA
update_past_visu(realtime, tsim);
if (realtime->flag_visu)
{
update_past_visu(realtime, tsim);
}
#endif
}
......@@ -118,15 +127,21 @@ void mbs_realtime_loop(Simu_realtime *realtime, double tsim)
// -- Update SDL vectors to plot -- //
#ifdef SDL
// assign values for the plot
user_realtime_plot(mbs_data);
if (realtime->flag_plot)
{
// assign values for the plot
user_realtime_plot(mbs_data);
// check maximal values for the plot
update_y_min_max(realtime);
// check maximal values for the plot
update_y_min_max(realtime);
}
#endif
#ifdef JAVA
java_time_visu_past(realtime, tsim);
if (realtime->flag_visu)
{
java_time_visu_past(realtime, tsim);
}
#endif
......@@ -139,18 +154,24 @@ void mbs_realtime_loop(Simu_realtime *realtime, double tsim)
{
// plot screen sdl
#ifdef SDL
if (!i)
if (realtime->flag_plot)
{
update_plot_vectors(realtime, tsim);
plot_screen_sdl(realtime, tsim, 0);
if (!i)
{
update_plot_vectors(realtime, tsim);
plot_screen_sdl(realtime, tsim, 0);
}
}
#endif
// Java visualization
#ifdef JAVA
if (i == 1)
if (realtime->flag_visu)
{
update_java(realtime);
if (i == 1)
{
update_java(realtime);
}
}
#endif
......@@ -161,7 +182,10 @@ void mbs_realtime_loop(Simu_realtime *realtime, double tsim)
// handle events (coming from the keyboard...)
#ifdef SDL
events_simu(realtime, tsim);
if (realtime->flag_plot)
{
events_simu(realtime, tsim);
}
#endif
// gate locked: waiting time
......@@ -175,7 +199,10 @@ void mbs_realtime_loop(Simu_realtime *realtime, double tsim)
// handle events (coming from the keyboard...)
#ifdef SDL
events_simu(realtime, tsim);
if (realtime->flag_plot)
{
events_simu(realtime, tsim);
}
#endif
}
......@@ -199,7 +226,10 @@ void mbs_realtime_loop(Simu_realtime *realtime, double tsim)
// change the plot
#ifdef SDL
set_bottom_flag(realtime);
if (realtime->flag_plot)
{
set_bottom_flag(realtime);
}
#endif
realtime->speed_last_t_usec = speed_new_t_usec;
......@@ -215,7 +245,10 @@ void mbs_realtime_finish(Simu_realtime *realtime)
{
// SDL window
#ifdef SDL
last_break_gestion(realtime, realtime->tsim);
if (realtime->flag_plot)
{
last_break_gestion(realtime, realtime->tsim);
}
#endif
// Real-time constraints
......@@ -246,12 +279,14 @@ Realtime_option* init_Realtime_option()
options->init_speed_factor = 1.0; ///< initial speed factor
// SDL plots and interactions
options->curve_width = 3; ///< plot curve width in number of pixels
options->flag_plot = 1; ///< 1 if SDL plots features activated, 0 otherwise
options->curve_width = 3; ///< plot curve width in number of pixels
options->screen_width = 660; ///< plot screen width in number of pixels
options->screen_height = 520; ///< plot screen height in number of pixels
options->max_nb_curves = 12; ///< maximum number of curves plotted
options->max_nb_legends = 6; ///< maximum number of curves legends indicated
options->max_nb_legends = 6; ///< maximum number of curves legends indicated
options->y_min_init = -1.0; ///< initial lower bound for the y values plotted
options->y_max_init = 1.0; ///< initial upper bound for the y values plotted
......@@ -273,6 +308,8 @@ Realtime_option* init_Realtime_option()
options->fqc_screen = 30.0; ///< frequence of the SDL plots refreshment [Hz]
// Java visualization
options->flag_visu = 1; ///< 1 if Java visualization features activated, 0 otherwise
options->nb_q = 1; ///< number of joints in the .mbs used for visualization
// path and file name fot the .mbs file used for Java visualization
......@@ -488,11 +525,17 @@ Simu_realtime* init_simu_realtime(MbsData* mbs_data, Realtime_option *options, i
realtime->ext->mbs_data = mbs_data;
#ifdef JAVA
realtime->ext->java = init_realtime_java(options, mbs_data);
if (options->flag_visu)
{
realtime->ext->java = init_realtime_java(options, mbs_data);
}
#endif
#ifdef SDL
realtime->ext->sdl = init_realtime_sdl(init_screen_sdl(options));
if (options->flag_plot)
{
realtime->ext->sdl = init_realtime_sdl(init_screen_sdl(options));
}
#endif
// absolute time before starting loop
......@@ -586,6 +629,9 @@ Simu_realtime* init_simu_realtime(MbsData* mbs_data, Realtime_option *options, i
realtime->buffer_size = options->buffer_size;
realtime->flag_plot = options->flag_plot;
realtime->flag_visu = options->flag_visu;
realtime->init_t_sec = init_t_sec;
realtime->init_t_usec = init_t_usec;
......@@ -619,11 +665,17 @@ void free_simu_realtime(Simu_realtime *realtime)
int i;
#ifdef SDL
free_realtime_sdl(realtime->ext->sdl);
if (realtime->flag_plot)
{
free_realtime_sdl(realtime->ext->sdl);
}
#endif
#ifdef JAVA
free_realtime_java(realtime->ext->java);
if (realtime->flag_visu)
{
free_realtime_java(realtime->ext->java);
}
#endif
free(realtime->ext);
......
......@@ -62,6 +62,8 @@ typedef struct Realtime_option
double init_speed_factor; ///< initial speed factor
// SDL plots and interactions
int flag_plot; ///< 1 if SDL plots features activated, 0 otherwise
int curve_width; ///< plot curve width in number of pixels
int screen_width; ///< plot screen width in number of pixels
int screen_height; ///< plot screen height in number of pixels
......@@ -77,6 +79,8 @@ typedef struct Realtime_option
double fqc_screen; ///< frequence of the SDL plots refreshment [Hz]
// Java visualization
int flag_visu; ///< 1 if Java visualization features activated, 0 otherwise
int nb_q; ///< number of joints in the .mbs used for visualization
char *mbs_file; ///< path and file name fot the .mbs file used for Java visualization
......@@ -136,6 +140,9 @@ typedef struct Simu_realtime
int next_t_usec_gate; ///< next gate to wait for real time [us]
double next_tsim_gate; ///< next gate to wait for simulation time [s]
int flag_plot; ///< 1 if SDL plots features activated, 0 otherwise
int flag_visu; ///< 1 if Java visualization features activated, 0 otherwise
Realtime_constraint **constraints; ///< structures of multiple real-time constraints
Realtime_extern *ext; ///< external variables
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment