Commit 3a3f0a6b authored by François Heremans's avatar François Heremans
Browse files

Single shared auto_plot for websocket & sdl

parent 73907726
......@@ -8,6 +8,7 @@
#include "auto_plot.h"
static AutoPlot *auto_plot; // static AutoPlot structure with all the current user plots information
int flag_plot = 0; //!< 1 if init_set_plot was called, 0 otherwise
/*! \brief reset the flag_plot to 0. Useful when running
......@@ -25,27 +26,15 @@ void reset_flag_plot()
* \param[in,out] screen_sdl SDL gestion main structure
*/
#ifdef SDL
void init_set_plot(Screen_sdl *screen_sdl)
{
flag_plot = 1;
auto_plot = init_auto_plot(screen_sdl->max_nb_curves);
screen_sdl->auto_plot = auto_plot;
}
#endif
#ifdef WEBSOCKET
void init_set_plot_web(Realtime_extern *realtime_ext, int max_nb_curves)
AutoPlot* init_set_plot(int max_nb_curves)
{
flag_plot = 1;
auto_plot = init_auto_plot(max_nb_curves);
realtime_ext->auto_plot = auto_plot;
return auto_plot;
}
#endif
/*! \brief release memory of auto_plot
*/
......
......@@ -12,14 +12,8 @@
#include "user_realtime.h"
#include "plot_sdl.h"
#ifdef SDL
void init_set_plot(Screen_sdl *screen_sdl);
#endif
#ifdef WEBSOCKET
void init_set_plot_web(Realtime_extern *realtime_ext, int max_nb_curves);
#endif
AutoPlot* init_set_plot(int max_nb_curves);
void reset_flag_plot();
void free_set_plot();
......
......@@ -661,16 +661,27 @@ Simu_realtime* init_simu_realtime(MbsData* mbs_data, Realtime_option *options, i
}
#endif
#ifdef SDL
#if defined(SDL) || defined(WEBSOCKET)
if (options->flag_plot)
{
realtime->ext->sdl = init_realtime_sdl(init_screen_sdl(options, err));
// auto plot
realtime->ext->auto_plot = init_set_plot(options->max_nb_curves);
#ifdef SDL
realtime->ext->sdl = init_realtime_sdl(init_screen_sdl(options, err, realtime->ext->auto_plot ));
if (*err < 0)
{
mbs_msg("[%d] in init_realtime_sdl !! \n", *err);
return NULL;
}
#endif
}
#else
if (options->flag_plot)
{
......@@ -681,11 +692,6 @@ Simu_realtime* init_simu_realtime(MbsData* mbs_data, Realtime_option *options, i
}
#endif
#ifdef WEBSOCKET
init_set_plot_web(realtime->ext, 10);
// printf("\n Plot activated to websocket !\n");
#endif
// absolute time before starting loop
time_get(&init_t_sec, &init_t_usec);
......
......@@ -35,7 +35,7 @@
* \param[in,out] err <0 if error occurs
* \return the initialized SDL main data structure
*/
Screen_sdl* init_screen_sdl(Realtime_option *options, int *err)
Screen_sdl* init_screen_sdl(Realtime_option *options, int *err, AutoPlot *auto_plot)
{
// -- Variables declaration -- //
......@@ -485,8 +485,8 @@ Screen_sdl* init_screen_sdl(Realtime_option *options, int *err)
screen_sdl->max_nb_curves = max_nb_curves;
// auto plot
init_set_plot(screen_sdl);
screen_sdl->auto_plot = auto_plot;
// clean the screen for the first time
refresh_screen(screen_sdl);
......
......@@ -249,7 +249,7 @@ typedef struct Screen_sdl
void wait_key_generic(Simu_realtime *realtime, int cur_t_usec, double tsim);
Screen_sdl* init_screen_sdl(Realtime_option *options, int *err);
Screen_sdl* init_screen_sdl(Realtime_option *options, int *err, AutoPlot *auto_plot);
void new_curves_save(Screen_sdl *screen_sdl, int nb_new_curves, double *y_curves);
TTF_Font* init_font(char *folder, int font_size, int *err);
void free_screen_sdl(Screen_sdl *screen_sdl);
......
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