Commit 5af0b462 authored by Sébastien Timmermans's avatar Sébastien Timmermans
Browse files

[ErrMsg] dirdyn mbs_error call clean

parent b72f8f65
......@@ -162,8 +162,10 @@ int mbs_run_dirdyn(MbsDirdyn* dd, MbsData* mbs_data)
// - - - - - - - - - - - - - -
err = mbs_dirdyn_init(dd, mbs_data);
if (err < 0){
// Freeing the buffers, without error catching
mbs_dirdyn_finish(dd, mbs_data);
return err;
mbs_error_msg("[%d] in mbs_run_dirdyn !! \n", _MBS_ERR_MOD_DIRDYN + err);
return _MBS_ERR_MOD_DIRDYN + err;
}
// 2. Run the simulation
......@@ -172,14 +174,17 @@ int mbs_run_dirdyn(MbsDirdyn* dd, MbsData* mbs_data)
if (err < 0){
// Freeing the buffers, without error catching
mbs_dirdyn_finish(dd, mbs_data);
return err;
mbs_error_msg("[%d] in mbs_run_dirdyn !! \n", _MBS_ERR_MOD_DIRDYN + err);
return _MBS_ERR_MOD_DIRDYN + err;
}
// 3. Finish the simulation
// - - - - - - - - - - - -
err = mbs_dirdyn_finish(dd, mbs_data);
if (err < 0) {
mbs_error_msg("[%d] in mbs_run_dirdyn !! \n", _MBS_ERR_MOD_DIRDYN + err);
return _MBS_ERR_MOD_DIRDYN + err;
}
return err;
}
......@@ -199,9 +204,8 @@ int mbs_dirdyn_save(MbsDirdyn* dd, MbsData *mbs_data, double t) {
{
mbs_msg(">>DIRDYN>> ***** mbs_dirdyn_save : impossible to save the files *****\n");
mbs_msg(">>DIRDYN>> ***** during buffer save *****\n");
mbs_msg(">>DIRDYN>>\n");
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", _MBS_ERR_MOD_DIRDYN + err);
return _MBS_ERR_MOD_DIRDYN + err;
mbs_msg("[%d] in mbs_dirdyn_save !! \n", err);
return err;
}
err = mbs_growing_buffer_save(dd->user_buffer, t);
......@@ -210,9 +214,8 @@ int mbs_dirdyn_save(MbsDirdyn* dd, MbsData *mbs_data, double t) {
{
mbs_msg(">>DIRDYN>> ***** mbs_dirdyn_save : impossible to save the files *****\n");
mbs_msg(">>DIRDYN>> ***** during growing buffer save *****\n");
mbs_msg(">>DIRDYN>>\n");
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", _MBS_ERR_MOD_DIRDYN + err);
return _MBS_ERR_MOD_DIRDYN + err;
mbs_msg("[%d] in mbs_dirdyn_save !! \n", err);
return err;
}
if (dd->options->save_visu)
......@@ -232,8 +235,8 @@ int mbs_dirdyn_save(MbsDirdyn* dd, MbsData *mbs_data, double t) {
mbs_msg(">>DIRDYN>> ***** mbs_dirdyn_save : impossible to save the files *****\n");
mbs_msg(">>DIRDYN>> ***** during growing buffer save *****\n");
mbs_msg(">>DIRDYN>> in the REAL-TIME process \n");
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", _MBS_ERR_MOD_DIRDYN + err);
return _MBS_ERR_MOD_DIRDYN + err;
mbs_msg("[%d] in mbs_dirdyn_save !! \n", err);
return err;
}
#endif
}
......@@ -259,8 +262,8 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
err = mbs_check_mbs_data_values(dd->mbs_aux, mbs_data);
if (err < 0) {
mbs_msg("\t >Dirdyn> Incoherences detected during module initialization! (See message above) \n");
mbs_error_msg("[%d] in mbs_dirdyn_init !! \n", err + _MBS_ERR_MOD_DIRDYN);
return err + _MBS_ERR_MOD_DIRDYN;
mbs_msg("[%d] in mbs_dirdyn_init !! \n", err);
return err;
}
// Check the usefulness of dirdyn
......@@ -269,8 +272,8 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
{
mbs_msg("\t >Dirdyn> If no independant nor driven joints are present, the direct dynamic process has no reason to be used !\n");
mbs_msg("\t >Dirdyn> Irrelevant process !\n");
err = _MBS_ERR_MOD_DIRDYN + _MBS_ERR_MOD_SPEC_11;
mbs_error_msg("[%d] in mbs_dirdyn_init !! \n", err);
err = _MBS_ERR_MOD_SPEC_11;
mbs_msg("[%d] in mbs_dirdyn_init !! \n", err);
return err;
}
else if (mbs_data->nqu == 0)
......@@ -284,9 +287,8 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
// Checking constraints and dependant variable coherence
err = mbs_check_nhu_nqv(mbs_data);
if (err < 0) {
mbs_msg("\t >Dirdyn> Inchoherence detected during module initialization! \n");
err += _MBS_ERR_MOD_DIRDYN;
mbs_error_msg("[%d] in mbs_dirdyn_init !! \n", err);
mbs_msg("\t >Dirdyn> Incoherence detected during module initialization! \n");
mbs_msg("[%d] in mbs_dirdyn_init !! \n", err);
return err;
}
// Set the selected integrator
......@@ -322,8 +324,8 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
if (err < 0)
{
mbs_msg("\t >Real-time> error during activation !\n");
mbs_error_msg("[%d] in mbs_dirdyn_init !! \n", _MBS_ERR_MOD_DIRDYN + err);
return _MBS_ERR_MOD_DIRDYN + err;
mbs_msg("[%d] in mbs_dirdyn_init !! \n", err);
return err;
}
}
#else
......@@ -331,8 +333,8 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
{
err = _MBS_ERR_INIT;
mbs_msg("\t >Real-time> To use the real-time features (mbs_dirdyn->options->realtime activated), set the CMake flag 'FLAG_REAL_TIME' to ON !\n");
mbs_error_msg("[%d] in mbs_dirdyn_init !! \n", _MBS_ERR_MOD_DIRDYN + err);
return _MBS_ERR_MOD_DIRDYN + err;
mbs_msg("[%d] in mbs_dirdyn_init !! \n", err);
return err;
}
#endif
......@@ -524,8 +526,8 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
free(bufElemNb);
mbs_msg("\t >Dirdyn> Error during buffer visu initialization num %d! \n", i);
mbs_error_msg("[%d] in mbs_dirdyn_init !! \n", _MBS_ERR_MOD_DIRDYN);
return _MBS_ERR_MOD_DIRDYN;
mbs_msg("[%d] in mbs_dirdyn_init !! \n", _MBS_ERR_MOD_SPEC_11);
return _MBS_ERR_MOD_SPEC_11;
}
}
......@@ -543,8 +545,8 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
free(bufElemNb);
mbs_msg("\t >Real-time> Error: real-time features must be activated to set 'save_visu' to 1 ! \n");
mbs_error_msg("[%d] in mbs_dirdyn_init !! \n", _MBS_ERR_MOD_DIRDYN + _MBS_ERR_INIT);
return _MBS_ERR_MOD_DIRDYN + _MBS_ERR_INIT;
mbs_msg("[%d] in mbs_dirdyn_init !! \n", _MBS_ERR_INIT);
return _MBS_ERR_INIT;
}
realtime = (Simu_realtime*)mbs_data->realtime;
......@@ -560,8 +562,8 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
free(bufElemNb);
mbs_msg("\t >Real-time> Error: flag_visu must be set to 1 to set 'save_value' to 1 ! \n");
mbs_error_msg("[%d] in mbs_dirdyn_init !! \n", _MBS_ERR_MOD_DIRDYN + _MBS_ERR_INIT);
return _MBS_ERR_MOD_DIRDYN + _MBS_ERR_INIT;
mbs_msg("[%d] in mbs_dirdyn_init !! \n", _MBS_ERR_INIT);
return _MBS_ERR_INIT;
}
visu = realtime->ext->visu;
......@@ -584,8 +586,8 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
free(bufElemNb);
mbs_msg("\t >Dirdyn> [REAL-TIME] Error during buffer visu initialization num %d! \n", i);
mbs_error_msg("[%d] in mbs_dirdyn_init !! \n", _MBS_ERR_MOD_DIRDYN);
return _MBS_ERR_MOD_DIRDYN;
mbs_msg("[%d] in mbs_dirdyn_init !! \n", _MBS_ERR_MOD_SPEC_11);
return _MBS_ERR_MOD_SPEC_11;
}
}
......@@ -599,8 +601,8 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
free(bufElemNb);
mbs_msg("\t >Real-time> Error: Java libraries must be activated to set 'save_visu' to 1 ! \n");
mbs_error_msg("[%d] in mbs_dirdyn_init !! \n", _MBS_ERR_MOD_DIRDYN + _MBS_ERR_INIT);
return _MBS_ERR_MOD_DIRDYN + _MBS_ERR_INIT;
mbs_msg("[%d] in mbs_dirdyn_init !! \n", _MBS_ERR_INIT);
return _MBS_ERR_INIT;
#endif
}
......@@ -654,15 +656,12 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
free(bufElemNb);
free(path_growing);
err += _MBS_ERR_MOD_DIRDYN;
mbs_error_msg("[%d] in mbs_dirdyn_init !! \n", err);
mbs_msg("[%d] in mbs_dirdyn_init !! \n", err);
return err;
}
err = mbs_dirdyn_save(dd, mbs_data, dd->tsim);
if (err < 0){
if (err < 0)
{
free(f);
free(f_anim);
free(respath);
......@@ -672,14 +671,10 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
free(bufElemNb);
free(path_growing);
err += _MBS_ERR_MOD_DIRDYN;
mbs_error_msg("[%d] in mbs_dirdyn_init !! \n", err);
mbs_msg("[%d] in mbs_dirdyn_init !! \n", err);
return err;
}
// release memory
free(f_anim);
free(f);
......@@ -720,14 +715,13 @@ int mbs_dirdyn_loop(MbsDirdyn* dd, MbsData* mbs_data)
while (cur_tf <= opts->tf)
{
err = dd->loop_integrator(cur_t0, cur_tf, mbs_data, dd);
if (err < 0){
err += _MBS_ERR_MOD_DIRDYN;
if (err < 0)
{
err2 = save_realtime_update(dd, mbs_data);
if (err2 < 0) {
mbs_msg("\t >Dirdyn> Error: in dirdyn loop during save realtime update ! \n");
}
mbs_error_msg(">>DIRDYN>> [%d] during direct dynamics loop.\n", err);
mbs_msg(">>DIRDYN>> [%d] during direct dynamics loop.\n", err);
return (err<0)?err:err2;
}
// Update times
......@@ -766,10 +760,8 @@ int mbs_dirdyn_finish(MbsDirdyn* dd, MbsData* mbs_data) {
err = mbs_realtime_finish((Simu_realtime*)mbs_data->realtime);
if (err < 0)
{
mbs_msg(">>DIRDYN>>\n");
mbs_msg(">>DIRDYN>> ***** realtime : impossible to finish !\n");
err = _MBS_ERR_MOD_DIRDYN + err; // arbitrary choice
mbs_error_msg("[%d] in mbs_dirdyn_finish !! \n", err);
mbs_msg("[%d] in mbs_dirdyn_finish !! \n", err);
return (err);
}
}
......@@ -805,10 +797,8 @@ int mbs_dirdyn_finish(MbsDirdyn* dd, MbsData* mbs_data) {
err1 = mbs_dirdyn_write_buffers(dd);
if (err1 < 0)
{
mbs_msg(">>DIRDYN>>\n");
mbs_msg(">>DIRDYN>> ***** mbs_dirdyn_write_buffers : impossible to save the files!\n");
err = _MBS_ERR_MOD_DIRDYN + err1; // arbitrary choice
mbs_error_msg("[%d] in mbs_dirdyn_finish !! \n", err);
mbs_msg("[%d] in mbs_dirdyn_finish !! \n", err);
return(err);
}
......@@ -826,7 +816,7 @@ int mbs_dirdyn_finish(MbsDirdyn* dd, MbsData* mbs_data) {
{
err = mbs_buffer_write(dd->buffer_visu[i]);
if (err < 0){
mbs_error_msg("\t >Dirdyn finish> Error with buffer during realtime simulation.\n");
mbs_msg("\t >Dirdyn finish> Error with buffer during realtime simulation.\n");
return (err);
}
mbs_delete_buffer(dd->buffer_visu[i]);
......@@ -856,22 +846,18 @@ int mbs_dirdyn_finish(MbsDirdyn* dd, MbsData* mbs_data) {
// memory has been released, raise error
if (err1 < 0 && err2 < 0)
{
err = _MBS_ERR_MOD_DIRDYN + err1; // arbitrary choice
err = err1; // arbitrary choice
mbs_error_msg("[%d] and [%d] in mbs_dirdyn_finish !! \n", err, _MBS_ERR_MOD_DIRDYN + err2);
mbs_msg("[%d] and [%d] in mbs_dirdyn_finish !! \n", err, err2);
return(err);
}
else if (err1 < 0) {
err = _MBS_ERR_MOD_DIRDYN + err1;
mbs_error_msg("[%d] in mbs_dirdyn_finish !! \n", err);
return(err);
mbs_msg("[%d] in mbs_dirdyn_finish !! \n", err1);
return(err1);
}
else if (err2 < 0) {
err = _MBS_ERR_MOD_DIRDYN + err2;
mbs_error_msg("[%d] in mbs_dirdyn_finish !! \n", err);
return(err);
mbs_msg("[%d] in mbs_dirdyn_finish !! \n", err2);
return(err2);
}
}
......
......@@ -246,7 +246,7 @@ extern "C" {
* -19 :
*
* Direct dynamics:
* -11 :
* -11 : buffer visualization
* -12 :
* -13 : Real-time
* -14 : Rosenbrock integrator
......
Supports Markdown
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