MessageHandling.c
Go to the documentation of this file.
1 /*
2  * This file is part of qpOASES.
3  *
4  * qpOASES -- An Implementation of the Online Active Set Strategy.
5  * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka,
6  * Christian Kirches et al. All rights reserved.
7  *
8  * qpOASES is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * qpOASES is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with qpOASES; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 
36 #include <stdio.h>
37 
38 #ifdef __MATLAB__
39  #include "mex.h"
40 #endif
41 
43 #include <qpOASES_e/Utils.h>
44 
45 
47 
48 
49 #ifndef __SUPPRESSANYOUTPUT__
50 
53 {
54 /* miscellaneous */
55 { SUCCESSFUL_RETURN, "Successful return", VS_VISIBLE },
56 { RET_DIV_BY_ZERO, "Division by zero", VS_VISIBLE },
57 { RET_INDEX_OUT_OF_BOUNDS, "Index out of bounds", VS_VISIBLE },
58 { RET_INVALID_ARGUMENTS, "At least one of the arguments is invalid", VS_VISIBLE },
59 { RET_ERROR_UNDEFINED, "Error number undefined", VS_VISIBLE },
60 { RET_WARNING_UNDEFINED, "Warning number undefined", VS_VISIBLE },
61 { RET_INFO_UNDEFINED, "Info number undefined", VS_VISIBLE },
62 { RET_EWI_UNDEFINED, "Error/warning/info number undefined", VS_VISIBLE },
63 { RET_AVAILABLE_WITH_LINUX_ONLY, "This function is available under Linux only", VS_HIDDEN },
64 { RET_UNKNOWN_BUG, "The error occurred is not yet known", VS_VISIBLE },
65 { RET_PRINTLEVEL_CHANGED, "Print level changed", VS_VISIBLE },
66 { RET_NOT_YET_IMPLEMENTED, "Requested function is not yet implemented.", VS_VISIBLE },
67 /* Indexlist */
68 { RET_INDEXLIST_MUST_BE_REORDERD, "Index list has to be reordered", VS_VISIBLE },
69 { RET_INDEXLIST_EXCEEDS_MAX_LENGTH, "Index list exceeds its maximal physical length", VS_VISIBLE },
70 { RET_INDEXLIST_CORRUPTED, "Index list corrupted", VS_VISIBLE },
71 { RET_INDEXLIST_OUTOFBOUNDS, "Physical index is out of bounds", VS_VISIBLE },
72 { RET_INDEXLIST_ADD_FAILED, "Adding indices from another index set failed", VS_VISIBLE },
73 { RET_INDEXLIST_INTERSECT_FAILED, "Intersection with another index set failed", VS_VISIBLE },
74 /* SubjectTo / Bounds / Constraints */
75 { RET_INDEX_ALREADY_OF_DESIRED_STATUS, "Index is already of desired status", VS_VISIBLE },
76 { RET_ADDINDEX_FAILED, "Adding index to index set failed", VS_VISIBLE },
77 { RET_REMOVEINDEX_FAILED, "Removing index from index set failed", VS_VISIBLE },
78 { RET_SWAPINDEX_FAILED, "Cannot swap between different indexsets", VS_VISIBLE },
79 { RET_NOTHING_TO_DO, "Nothing to do", VS_VISIBLE },
80 { RET_SETUP_BOUND_FAILED, "Setting up bound index failed", VS_VISIBLE },
81 { RET_SETUP_CONSTRAINT_FAILED, "Setting up constraint index failed", VS_VISIBLE },
82 { RET_MOVING_BOUND_FAILED, "Moving bound between index sets failed", VS_VISIBLE },
83 { RET_MOVING_CONSTRAINT_FAILED, "Moving constraint between index sets failed", VS_VISIBLE },
84 { RET_SHIFTING_FAILED, "Shifting of bounds/constraints failed", VS_VISIBLE },
85 { RET_ROTATING_FAILED, "Rotating of bounds/constraints failed", VS_VISIBLE },
86 /* QProblem */
87 { RET_QPOBJECT_NOT_SETUP, "The QP object has not been setup correctly, use another constructor", VS_VISIBLE },
88 { RET_QP_ALREADY_INITIALISED, "QProblem has already been initialised", VS_VISIBLE },
89 { RET_NO_INIT_WITH_STANDARD_SOLVER, "Initialisation via extern QP solver is not yet implemented", VS_VISIBLE },
90 { RET_RESET_FAILED, "Reset failed", VS_VISIBLE },
91 { RET_INIT_FAILED, "Initialisation failed", VS_VISIBLE },
92 { RET_INIT_FAILED_TQ, "Initialisation failed due to TQ factorisation", VS_VISIBLE },
93 { RET_INIT_FAILED_CHOLESKY, "Initialisation failed due to Cholesky decomposition", VS_VISIBLE },
94 { RET_INIT_FAILED_HOTSTART, "Initialisation failed! QP could not be solved!", VS_VISIBLE },
95 { RET_INIT_FAILED_INFEASIBILITY, "Initial QP could not be solved due to infeasibility!", VS_VISIBLE },
96 { RET_INIT_FAILED_UNBOUNDEDNESS, "Initial QP could not be solved due to unboundedness!", VS_VISIBLE },
97 { RET_INIT_FAILED_REGULARISATION, "Initialisation failed as Hessian matrix could not be regularised", VS_VISIBLE },
98 { RET_INIT_SUCCESSFUL, "Initialisation done", VS_VISIBLE },
99 { RET_OBTAINING_WORKINGSET_FAILED, "Failed to obtain working set for auxiliary QP", VS_VISIBLE },
100 { RET_SETUP_WORKINGSET_FAILED, "Failed to setup working set for auxiliary QP", VS_VISIBLE },
101 { RET_SETUP_AUXILIARYQP_FAILED, "Failed to setup auxiliary QP for initialised homotopy", VS_VISIBLE },
102 { RET_NO_CHOLESKY_WITH_INITIAL_GUESS, "Externally computed Cholesky factor cannot be combined with an initial guess", VS_VISIBLE },
103 { RET_NO_EXTERN_SOLVER, "No extern QP solver available", VS_VISIBLE },
104 { RET_QP_UNBOUNDED, "QP is unbounded", VS_VISIBLE },
105 { RET_QP_INFEASIBLE, "QP is infeasible", VS_VISIBLE },
106 { RET_QP_NOT_SOLVED, "Problems occurred while solving QP with standard solver", VS_VISIBLE },
107 { RET_QP_SOLVED, "QP successfully solved", VS_VISIBLE },
108 { RET_UNABLE_TO_SOLVE_QP, "Problems occurred while solving QP", VS_VISIBLE },
109 { RET_INITIALISATION_STARTED, "Starting problem initialisation...", VS_VISIBLE },
110 { RET_HOTSTART_FAILED, "Unable to perform homotopy due to internal error", VS_VISIBLE },
111 { RET_HOTSTART_FAILED_TO_INIT, "Unable to initialise problem", VS_VISIBLE },
112 { RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED, "Unable to perform homotopy as previous QP is not solved", VS_VISIBLE },
113 { RET_ITERATION_STARTED, "Iteration", VS_VISIBLE },
114 { RET_SHIFT_DETERMINATION_FAILED, "Determination of shift of the QP data failed", VS_VISIBLE },
115 { RET_STEPDIRECTION_DETERMINATION_FAILED, "Determination of step direction failed", VS_VISIBLE },
116 { RET_STEPLENGTH_DETERMINATION_FAILED, "Determination of step direction failed", VS_VISIBLE },
117 { RET_OPTIMAL_SOLUTION_FOUND, "Optimal solution of neighbouring QP found", VS_VISIBLE },
118 { RET_HOMOTOPY_STEP_FAILED, "Unable to perform homotopy step", VS_VISIBLE },
119 { RET_HOTSTART_STOPPED_INFEASIBILITY, "Premature homotopy termination because QP is infeasible", VS_VISIBLE },
120 { RET_HOTSTART_STOPPED_UNBOUNDEDNESS, "Premature homotopy termination because QP is unbounded", VS_VISIBLE },
121 { RET_WORKINGSET_UPDATE_FAILED, "Unable to update working sets according to initial guesses", VS_VISIBLE },
122 { RET_MAX_NWSR_REACHED, "Maximum number of working set recalculations performed", VS_VISIBLE },
123 { RET_CONSTRAINTS_NOT_SPECIFIED, "Problem does comprise constraints! You have to specify new constraints' bounds", VS_VISIBLE },
124 { RET_INVALID_FACTORISATION_FLAG, "Invalid factorisation flag", VS_VISIBLE },
125 { RET_UNABLE_TO_SAVE_QPDATA, "Unable to save QP data", VS_VISIBLE },
126 { RET_STEPDIRECTION_FAILED_TQ, "Abnormal termination due to TQ factorisation", VS_VISIBLE },
127 { RET_STEPDIRECTION_FAILED_CHOLESKY, "Abnormal termination due to Cholesky factorisation", VS_VISIBLE },
128 { RET_CYCLING_DETECTED, "Cycling detected", VS_VISIBLE },
129 { RET_CYCLING_NOT_RESOLVED, "Cycling cannot be resolved, QP is probably infeasible", VS_VISIBLE },
130 { RET_CYCLING_RESOLVED, "Cycling probably resolved", VS_VISIBLE },
131 { RET_STEPSIZE, "", VS_VISIBLE },
132 { RET_STEPSIZE_NONPOSITIVE, "", VS_VISIBLE },
133 { RET_SETUPSUBJECTTOTYPE_FAILED, "Setup of SubjectToTypes failed", VS_VISIBLE },
134 { RET_ADDCONSTRAINT_FAILED, "Addition of constraint to working set failed", VS_VISIBLE },
135 { RET_ADDCONSTRAINT_FAILED_INFEASIBILITY, "Addition of constraint to working set failed", VS_VISIBLE },
136 { RET_ADDBOUND_FAILED, "Addition of bound to working set failed", VS_VISIBLE },
137 { RET_ADDBOUND_FAILED_INFEASIBILITY, "Addition of bound to working set failed", VS_VISIBLE },
138 { RET_REMOVECONSTRAINT_FAILED, "Removal of constraint from working set failed", VS_VISIBLE },
139 { RET_REMOVEBOUND_FAILED, "Removal of bound from working set failed", VS_VISIBLE },
140 { RET_REMOVE_FROM_ACTIVESET, "Removing from active set:", VS_VISIBLE },
141 { RET_ADD_TO_ACTIVESET, "Adding to active set:", VS_VISIBLE },
142 { RET_REMOVE_FROM_ACTIVESET_FAILED, "Removing from active set failed", VS_VISIBLE },
143 { RET_ADD_TO_ACTIVESET_FAILED, "Adding to active set failed", VS_VISIBLE },
144 { RET_CONSTRAINT_ALREADY_ACTIVE, "Constraint is already active", VS_VISIBLE },
145 { RET_ALL_CONSTRAINTS_ACTIVE, "All constraints are active, no further constraint can be added", VS_VISIBLE },
146 { RET_LINEARLY_DEPENDENT, "New bound/constraint is linearly dependent", VS_VISIBLE },
147 { RET_LINEARLY_INDEPENDENT, "New bound/constraint is linearly independent", VS_VISIBLE },
148 { RET_LI_RESOLVED, "Linear independence of active constraint matrix successfully resolved", VS_VISIBLE },
149 { RET_ENSURELI_FAILED, "Failed to ensure linear independence of active constraint matrix", VS_VISIBLE },
150 { RET_ENSURELI_FAILED_TQ, "Abnormal termination due to TQ factorisation", VS_VISIBLE },
151 { RET_ENSURELI_FAILED_NOINDEX, "QP is infeasible", VS_VISIBLE },
152 { RET_ENSURELI_FAILED_CYCLING, "QP is infeasible", VS_VISIBLE },
153 { RET_BOUND_ALREADY_ACTIVE, "Bound is already active", VS_VISIBLE },
154 { RET_ALL_BOUNDS_ACTIVE, "All bounds are active, no further bound can be added", VS_VISIBLE },
155 { RET_CONSTRAINT_NOT_ACTIVE, "Constraint is not active", VS_VISIBLE },
156 { RET_BOUND_NOT_ACTIVE, "Bound is not active", VS_VISIBLE },
157 { RET_HESSIAN_NOT_SPD, "Projected Hessian matrix not positive definite", VS_VISIBLE },
158 { RET_HESSIAN_INDEFINITE, "Hessian matrix is indefinite", VS_VISIBLE },
159 { RET_MATRIX_SHIFT_FAILED, "Unable to update matrices or to transform vectors", VS_VISIBLE },
160 { RET_MATRIX_FACTORISATION_FAILED, "Unable to calculate new matrix factorisations", VS_VISIBLE },
161 { RET_PRINT_ITERATION_FAILED, "Unable to print information on current iteration", VS_VISIBLE },
162 { RET_NO_GLOBAL_MESSAGE_OUTPUTFILE, "No global message output file initialised", VS_VISIBLE },
163 { RET_DISABLECONSTRAINTS_FAILED, "Unable to disable constraints", VS_VISIBLE },
164 { RET_ENABLECONSTRAINTS_FAILED, "Unable to enable constraints", VS_VISIBLE },
165 { RET_ALREADY_ENABLED, "Bound or constraint is already enabled", VS_VISIBLE },
166 { RET_ALREADY_DISABLED, "Bound or constraint is already disabled", VS_VISIBLE },
167 { RET_NO_HESSIAN_SPECIFIED, "No Hessian matrix has been specified", VS_VISIBLE },
168 { RET_USING_REGULARISATION, "Using regularisation as Hessian matrix is not positive definite", VS_VISIBLE },
169 { RET_EPS_MUST_BE_POSITVE, "Eps for regularisation must be sufficiently positive", VS_VISIBLE },
170 { RET_REGSTEPS_MUST_BE_POSITVE, "Maximum number of regularisation steps must be non-negative", VS_VISIBLE },
171 { RET_HESSIAN_ALREADY_REGULARISED, "Hessian has been already regularised", VS_VISIBLE },
172 { RET_CANNOT_REGULARISE_IDENTITY, "Identity Hessian matrix cannot be regularised", VS_VISIBLE },
173 { RET_CANNOT_REGULARISE_SPARSE, "Sparse matrix cannot be regularised as diagonal entry is missing", VS_VISIBLE },
174 { RET_NO_REGSTEP_NWSR, "No additional regularisation step could be performed due to limits", VS_VISIBLE },
175 { RET_FEWER_REGSTEPS_NWSR, "Fewer additional regularisation steps have been performed due to limits", VS_VISIBLE },
176 { RET_CHOLESKY_OF_ZERO_HESSIAN, "Cholesky decomposition of (unregularised) zero Hessian matrix", VS_VISIBLE },
177 { RET_ZERO_HESSIAN_ASSUMED, "Zero Hessian matrix assumed as null pointer passed without specifying hessianType", VS_VISIBLE },
178 { RET_CONSTRAINTS_ARE_NOT_SCALED, "(should not be thrown, no longer in use)", VS_VISIBLE },
179 { RET_INITIAL_BOUNDS_STATUS_NYI, "(should not be thrown, no longer in use)", VS_VISIBLE },
180 { RET_ERROR_IN_CONSTRAINTPRODUCT, "Error in user-defined constraint product function", VS_VISIBLE },
181 { RET_FIX_BOUNDS_FOR_LP, "All initial bounds must be fixed when solving an (unregularised) LP", VS_VISIBLE },
182 { RET_USE_REGULARISATION_FOR_LP, "Set options.enableRegularisation=BT_TRUE for solving LPs", VS_VISIBLE },
183 /* SQProblem */
184 { RET_UPDATEMATRICES_FAILED, "Unable to update QP matrices", VS_VISIBLE },
185 { RET_UPDATEMATRICES_FAILED_AS_QP_NOT_SOLVED, "Unable to update matrices as previous QP is not solved", VS_VISIBLE },
186 /* Utils */
187 { RET_UNABLE_TO_OPEN_FILE, "Unable to open file", VS_VISIBLE },
188 { RET_UNABLE_TO_WRITE_FILE, "Unable to write into file", VS_VISIBLE },
189 { RET_UNABLE_TO_READ_FILE, "Unable to read from file", VS_VISIBLE },
190 { RET_FILEDATA_INCONSISTENT, "File contains inconsistent data", VS_VISIBLE },
191 /* Options */
192 { RET_OPTIONS_ADJUSTED, "Options needed to be adjusted for consistency reasons", VS_VISIBLE },
193 /* SolutionAnalysis */
194 { RET_UNABLE_TO_ANALYSE_QPROBLEM, "Unable to analyse (S)QProblem(B) object", VS_VISIBLE },
195 /* Benchmark */
196 { RET_NWSR_SET_TO_ONE, "Maximum number of working set changes was set to 1", VS_VISIBLE },
197 { RET_UNABLE_TO_READ_BENCHMARK, "Unable to read benchmark data", VS_VISIBLE },
198 { RET_BENCHMARK_ABORTED, "Benchmark aborted", VS_VISIBLE },
199 { RET_INITIAL_QP_SOLVED, "Initial QP solved", VS_VISIBLE },
200 { RET_QP_SOLUTION_STARTED, "Solving QP no.", VS_VISIBLE },
201 { RET_BENCHMARK_SUCCESSFUL, "Benchmark terminated successfully", VS_VISIBLE },
202 /* Sparse matrices */
203 { RET_NO_DIAGONAL_AVAILABLE, "Sparse matrix does not have entries on full diagonal", VS_VISIBLE },
204 { RET_DIAGONAL_NOT_INITIALISED, "Diagonal data of sparse matrix has not been initialised", VS_VISIBLE },
205 /* Dropping of infeasible constraints */
206 { RET_ENSURELI_DROPPED, "Linear independence resolved by dropping blocking constraint", VS_VISIBLE },
207 /* Simple exitflags */
208 { RET_SIMPLE_STATUS_P1, "QP problem could not be solved within given number of iterations", VS_VISIBLE },
209 { RET_SIMPLE_STATUS_P0, "QP problem solved", VS_VISIBLE },
210 { RET_SIMPLE_STATUS_M1, "QP problem could not be solved due to an internal error", VS_VISIBLE },
211 { RET_SIMPLE_STATUS_M2, "QP problem is infeasible (and thus could not be solved)", VS_VISIBLE },
212 { RET_SIMPLE_STATUS_M3, "QP problem is unbounded (and thus could not be solved)", VS_VISIBLE },
213 /* IMPORTANT: Terminal list element! */
214 { TERMINAL_LIST_ELEMENT, "", VS_HIDDEN }
215 };
216 
217 #else /* __SUPPRESSANYOUTPUT__ */
218 
219 ReturnValueList returnValueList[1]; /* Do not use messages for embedded platforms! */
220 
221 #endif /* __SUPPRESSANYOUTPUT__ */
222 
223 
224 
225 /*****************************************************************************
226  * P U B L I C *
227  *****************************************************************************/
228 
229 /*
230  * M e s s a g e H a n d l i n g
231  */
233  FILE* _outputFile,
234  VisibilityStatus _errorVisibility,
235  VisibilityStatus _warningVisibility,
236  VisibilityStatus _infoVisibility
237  )
238 {
239  _THIS->errorVisibility = _errorVisibility;
240  _THIS->warningVisibility = _warningVisibility;
241  _THIS->infoVisibility = _infoVisibility;
242 
243  _THIS->outputFile = _outputFile;
244  _THIS->errorCount = 0;
245 }
246 
247 
248 
249 /*
250  * M e s s a g e H a n d l i n g
251  */
253  MessageHandling* TO
254  )
255 {
256  TO->errorVisibility = FROM->errorVisibility;
258  TO->infoVisibility = FROM->infoVisibility;
259 
260  TO->outputFile = FROM->outputFile;
261  TO->errorCount = FROM->errorCount;
262 }
263 
264 
265 
266 /*
267  * t h r o w E r r o r
268  */
270  returnValue Enumber,
271  const char* additionaltext,
272  const char* functionname,
273  const char* filename,
274  const unsigned long linenumber,
275  VisibilityStatus localVisibilityStatus
276  )
277 {
278  /* consistency check */
279  if ( Enumber <= SUCCESSFUL_RETURN )
281 
282  /* Call to common throwMessage function if error shall be displayed. */
283  if ( _THIS->errorVisibility == VS_VISIBLE )
284  return MessageHandling_throwMessage( _THIS,Enumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"ERROR" );
285  else
286  return Enumber;
287 }
288 
289 
290 /*
291  * t h r o w W a r n i n g
292  */
294  returnValue Wnumber,
295  const char* additionaltext,
296  const char* functionname,
297  const char* filename,
298  const unsigned long linenumber,
299  VisibilityStatus localVisibilityStatus
300  )
301 {
302  /* consistency check */
303  if ( Wnumber <= SUCCESSFUL_RETURN )
305 
306  /* Call to common throwMessage function if warning shall be displayed. */
307  if ( _THIS->warningVisibility == VS_VISIBLE )
308  return MessageHandling_throwMessage( _THIS,Wnumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"WARNING" );
309  else
310  return Wnumber;
311 }
312 
313 
314 /*
315  * t h r o w I n f o
316  */
318  returnValue Inumber,
319  const char* additionaltext,
320  const char* functionname,
321  const char* filename,
322  const unsigned long linenumber,
323  VisibilityStatus localVisibilityStatus
324  )
325 {
326  /* consistency check */
327  if ( Inumber < SUCCESSFUL_RETURN )
329 
330  /* Call to common throwMessage function if info shall be displayed. */
331  if ( _THIS->infoVisibility == VS_VISIBLE )
332  return MessageHandling_throwMessage( _THIS,Inumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"INFO" );
333  else
334  return Inumber;
335 }
336 
337 
338 /*
339  * r e s e t
340  */
342 {
346 
349 
350  return SUCCESSFUL_RETURN;
351 }
352 
353 
354 /*
355  * l i s t A l l M e s s a g e s
356  */
358 {
359  #ifndef __SUPPRESSANYOUTPUT__
360  int keypos = 0;
361  myStatic char myPrintfString[QPOASES_MAX_STRING_LENGTH];
362 
363  /* Run through whole returnValueList and print each item. */
364  while ( returnValueList[keypos].key != TERMINAL_LIST_ELEMENT )
365  {
366  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH," %d - %s \n",keypos,returnValueList[keypos].data );
367  qpOASES_myPrintf( myPrintfString );
368 
369  ++keypos;
370  }
371  #endif
372 
373  return SUCCESSFUL_RETURN;
374 }
375 
376 
377 
378 /*****************************************************************************
379  * P R O T E C T E D *
380  *****************************************************************************/
381 
382 
383 /*
384  * t h r o w M e s s a g e
385  */
387  returnValue RETnumber,
388  const char* additionaltext,
389  const char* functionname,
390  const char* filename,
391  const unsigned long linenumber,
392  VisibilityStatus localVisibilityStatus,
393  const char* RETstring
394  )
395 {
396  #ifndef __SUPPRESSANYOUTPUT__
397 
398  int keypos = 0;
399  myStatic char myPrintfString[QPOASES_MAX_STRING_LENGTH];
400 
401  /* 1) Determine number of whitespace for output. */
402  myStatic char whitespaces[QPOASES_MAX_STRING_LENGTH];
403  int numberOfWhitespaces = (_THIS->errorCount-1)*2;
404 
405  if ( numberOfWhitespaces < 0 )
406  numberOfWhitespaces = 0;
407 
408  if ( numberOfWhitespaces > 40 )
409  numberOfWhitespaces = 40;
410 
411  if ( numberOfWhitespaces >= (int)QPOASES_MAX_STRING_LENGTH )
412  numberOfWhitespaces = (int)QPOASES_MAX_STRING_LENGTH-1;
413 
414  memset( whitespaces, ' ', (size_t) numberOfWhitespaces );
415  whitespaces[numberOfWhitespaces] = '\0';
416 
417  /* 2) Find error/warning/info in list. */
418  while ( returnValueList[keypos].key != TERMINAL_LIST_ELEMENT )
419  {
420  if ( returnValueList[keypos].key == RETnumber )
421  break;
422  else
423  ++keypos;
424  }
425 
426  if ( returnValueList[keypos].key == TERMINAL_LIST_ELEMENT )
427  {
429  return RETnumber;
430  }
431 
432  /* 3) Print error/warning/info. */
433  if ( ( returnValueList[keypos].globalVisibilityStatus == VS_VISIBLE ) && ( localVisibilityStatus == VS_VISIBLE ) )
434  {
435  if ( _THIS->errorCount < 0 )
436  {
437  qpOASES_myPrintf( "\n" );
438  _THIS->errorCount = 0;
439  }
440 
441  if ( _THIS->errorCount > 0 )
442  {
443  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"%s->", whitespaces );
444  qpOASES_myPrintf( myPrintfString );
445  }
446 
447  if ( additionaltext == 0 )
448  {
449  #ifdef __DEBUG__
450  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"%s (%s, %s:%d): \t%s\n",
451  RETstring,functionname,filename,(int)linenumber,returnValueList[keypos].data
452  );
453  #else
454  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"%s: %s\n",
455  RETstring,returnValueList[keypos].data
456  );
457  #endif
458  qpOASES_myPrintf( myPrintfString );
459  }
460  else
461  {
462  #ifdef __DEBUG__
463  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"%s (%s, %s:%d): \t%s %s\n",
464  RETstring,functionname,filename,(int)linenumber,returnValueList[keypos].data,additionaltext
465  );
466  #else
467  snprintf( myPrintfString,QPOASES_MAX_STRING_LENGTH,"%s: %s %s\n",
468  RETstring,returnValueList[keypos].data,additionaltext
469  );
470  #endif
471  qpOASES_myPrintf( myPrintfString );
472  }
473 
474  /* take care of proper indention for subsequent error messages */
475  if ( RETstring[0] == 'E' )
476  {
477  ++(_THIS->errorCount);
478  }
479  else
480  {
481  if ( _THIS->errorCount > 0 )
482  qpOASES_myPrintf( "\n" );
483  _THIS->errorCount = 0;
484  }
485  }
486 
487  #endif /* __SUPPRESSANYOUTPUT__ */
488 
489  return RETnumber;
490 }
491 
492 
493 /****************************************************************************/
494 /* S T A T I C P U B L I C */
495 /****************************************************************************/
496 
498  const returnValue _returnValue
499  )
500 {
501  #ifndef __SUPPRESSANYOUTPUT__
502  int keypos = 0;
503 
504  /* 2) Find error/warning/info in list. */
505  while ( returnValueList[keypos].key != TERMINAL_LIST_ELEMENT )
506  {
507  if ( returnValueList[keypos].key == _returnValue )
508  break;
509  else
510  ++keypos;
511  }
512 
513  if ( returnValueList[keypos].key == TERMINAL_LIST_ELEMENT )
514  {
515  return "Unknown error code";
516  }
517 
518  return (returnValueList[keypos].data != 0) ? returnValueList[keypos].data : "No message for this error code";
519 
520  #else /* __SUPPRESSANYOUTPUT__ */
521 
522  return "No message for this error code";
523 
524  #endif /* __SUPPRESSANYOUTPUT__ */
525 }
526 
527 
528 
529 /*****************************************************************************
530  * G L O B A L M E S S A G E H A N D L E R *
531  *****************************************************************************/
532 
534 #if defined(__DSPACE__) || defined(__XPCTARGET__)
535 static MessageHandling qpOASES_globalMessageHandler;
536 #endif
537 /*MessageHandlingCON( 0,0,VS_VISIBLE,VS_VISIBLE,VS_VISIBLE );
538 MessageHandlingCON( qpOASES_getGlobalMessageHandler(),stdFile,VS_VISIBLE,VS_VISIBLE,VS_VISIBLE );
539 qpOASES_globalMessageHandler.outputFile = stdFile;*/
540 
541 
542 /*
543  * g e t G l o b a l M e s s a g e H a n d l e r
544  */
546 {
547  #ifndef __DSPACE__
548  #ifndef __XPCTARGET__
549  static MessageHandling qpOASES_globalMessageHandler;
550  #endif /* __DSPACE__ */
551  #endif /* __XPCTARGET__ */
552 
553  return &qpOASES_globalMessageHandler;
554 }
555 
556 
558 
559 
560 /*
561  * end of file
562  */
void MessageHandlingCPY(MessageHandling *FROM, MessageHandling *TO)
static returnValue MessageHandling_setErrorCount(MessageHandling *_THIS, int _errorCount)
#define __LINE__
static void MessageHandling_setOutputFile(MessageHandling *_THIS, FILE *_outputFile)
MessageHandling * qpOASES_getGlobalMessageHandler()
Allows to pass back messages to the calling function.
BEGIN_NAMESPACE_QPOASES ReturnValueList returnValueList[]
#define stdFile
returnValue MessageHandling_throwWarning(MessageHandling *_THIS, returnValue Wnumber, const char *additionaltext, const char *functionname, const char *filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus)
returnValue MessageHandling_throwInfo(MessageHandling *_THIS, returnValue Inumber, const char *additionaltext, const char *functionname, const char *filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus)
static void MessageHandling_setInfoVisibilityStatus(MessageHandling *_THIS, VisibilityStatus _infoVisibility)
Handles all kind of error messages, warnings and other information.
Data structure for entries in returnValueList.
returnValue qpOASES_myPrintf(const char *s)
Definition: Utils.c:269
returnValue MessageHandling_throwError(MessageHandling *_THIS, returnValue Enumber, const char *additionaltext, const char *functionname, const char *filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus)
static void MessageHandling_setErrorVisibilityStatus(MessageHandling *_THIS, VisibilityStatus _errorVisibility)
static void MessageHandling_setWarningVisibilityStatus(MessageHandling *_THIS, VisibilityStatus _warningVisibility)
void MessageHandlingCON(MessageHandling *_THIS, FILE *_outputFile, VisibilityStatus _errorVisibility, VisibilityStatus _warningVisibility, VisibilityStatus _infoVisibility)
returnValue MessageHandling_throwMessage(MessageHandling *_THIS, returnValue RETnumber, const char *additionaltext, const char *functionname, const char *filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus, const char *RETstring)
#define __FILE__
#define QPOASES_MAX_STRING_LENGTH
returnValue MessageHandling_listAllMessages(MessageHandling *_THIS)
const char * MessageHandling_getErrorCodeMessage(MessageHandling *_THIS, const returnValue _returnValue)
returnValue MessageHandling_reset(MessageHandling *_THIS)
#define myStatic
Definition: Types.h:103


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:53