ACADO Toolkit  1.2.0beta
Toolkit for Automatic Control and Dynamic Optimization
Public Member Functions | Protected Member Functions | Protected Attributes

Allows to manage single items of user-specified LogRecords of algorithmic information (for internal use). More...

#include <log_record_item.hpp>

List of all members.

Public Member Functions

 LogRecordItem ()
 Default constructor.
 LogRecordItem (LogName _name, const char *const _label, const char *const _startString, const char *const _endString, uint _width, uint _precision, const char *const _colSeparator, const char *const _rowSeparator)
 Constructor which takes the internal name of the logging item along with settings defining the output format of its numerical values.
 LogRecordItem (const Expression &_name, const char *const _label, const char *const _startString, const char *const _endString, uint _width, uint _precision, const char *const _colSeparator, const char *const _rowSeparator)
 Constructor which takes the internal name of the logging item along with settings defining the output format of its numerical values.
 LogRecordItem (const LogRecordItem &rhs)
 Copy constructor (deep copy).
 ~LogRecordItem ()
 Destructor.
LogRecordItemoperator= (const LogRecordItem &rhs)
 Assignment operator (deep copy).
BooleanType operator== (const LogRecordItem &rhs) const
 Returns whether two items are equal.
BooleanType operator!= (const LogRecordItem &rhs) const
 Returns whether two items are not equal.
const MatrixVariablesGridgetAllValues () const
 Returns all numerical values of the item.
returnValue setAllValues (LogFrequency _frequency, const MatrixVariablesGrid &_values)
 Assigns all numerical values of the item.
Matrix getValue (uint idx) const
 Returns numerical value at given time instant.
Matrix getFirstValue () const
 Returns numerical value at first time instant.
Matrix getLastValue () const
 Returns numerical value at last time instant.
returnValue setValue (LogFrequency _frequency, const Matrix &_value, double _time=-INFTY)
 Assigns the numerical value at current time instant.
returnValue getValueString (char **valueString) const
 Obtains a string containing all numerical values of the item in the pre-defined output format.
returnValue getValueString (char **valueString, uint idx) const
 Obtains a string containing the numerical value at a given time instant of the item in the pre-defined output format.
uint determineStringLength () const
 Returns the length of the string containing all numerical values of the item in the pre-defined output format.
uint determineStringLength (uint idx) const
 Returns the length of the containing the numerical value at a given time instant of the item in the pre-defined output format.
int getName () const
 Returns internal name of item.
LogRecordItemType getType () const
 Returns internal type of item (LogName enumeration or symbolic expression).
returnValue setNext (LogRecordItem *const _next)
 Assigns pointer to next LogRecordItem within a LogRecord.
LogRecordItemgetNext () const
 Returns pointer to next LogRecordItem within a LogRecord.
uint getNumPoints () const
 Returns number of time instants on which numerical values have been stored.
BooleanType isEmpty () const
 Returns whether item is empty.
returnValue enableWriteProtection ()
 Enables write-protection of the item (i.e.
returnValue disableWriteProtection ()
 Disables write-protection of the item (values can be written again).
BooleanType isWriteProtected () const
 Returns whether item is write-protected.
uint getNumDoubles () const

Protected Member Functions

returnValue assignDigits (uint &toDigit, uint fromDigit, uint defaultDigit)
 Assigns one digit information to the other.

Protected Attributes

MatrixVariablesGrid values
 The actual numerical values at all time instants.
int name
 Internal name defined by a LogName.
LogRecordItemType type
 Internal type of item (LogName enumeration or symbolic expression).
char * label
 Label to be printed before the numerical values.
char * startString
 Prefix before printing the numerical values.
char * endString
 Suffix after printing the numerical values.
uint width
 Total number of digits per single numerical value.
uint precision
 Number of decimals per single numerical value.
char * colSeparator
 Separator between the columns of the numerical values.
char * rowSeparator
 Separator between the rows of the numerical values.
BooleanType writeProtected
 Flag indicating whether item is write-protected (i.e.
LogRecordItemnext
 Pointer to next LogRecordItem within a LogRecord.

Detailed Description

The class LogRecordItem allows to manage single items of user-specified logging records of algorithmic information to be stored during runtime. It is intended for internal use only and is used by the class LogRecord.

All information is internally stored in Matrix format; as information is usually not only stored once but at different instants, e.g. at each iteration, information is stored in a MatrixVariablesGrid. Besides the actual numerical values of the information, also the output format of these values is stored within this class. It describes who the information is to be printed into a string by, e.g., defining a label, separators or the decimal precision to be shown.

Note that LogRecordItems are assumed to be stored as a singly-linked list within a LogRecord. Thus, also a pointer to the next item is stored.

Author:
Hans Joachim Ferreau, Boris Houska

Constructor & Destructor Documentation

LogRecordItem::LogRecordItem ( LogName  _name,
const char *const  _label,
const char *const  _startString,
const char *const  _endString,
uint  _width,
uint  _precision,
const char *const  _colSeparator,
const char *const  _rowSeparator 
)
Parameters:
[in]_nameInternal name defined by a LogName.
[in]_labelLabel to be printed before the numerical values.
[in]_startStringPrefix before printing the numerical values.
[in]_endStringSuffix after printing the numerical values.
[in]_widthTotal number of digits per single numerical value.
[in]_precisionNumber of decimals per single numerical value.
[in]_colSeparatorSeparator between the columns of the numerical values.
[in]_rowSeparatorSeparator between the rows of the numerical values.

References acadoAssignString(), assignDigits(), BT_FALSE, colSeparator, DEFAULT_COL_SEPARATOR, DEFAULT_END_STRING, DEFAULT_LABEL, DEFAULT_PRECISION, DEFAULT_ROW_SEPARATOR, DEFAULT_START_STRING, DEFAULT_WIDTH, endString, label, LRT_ENUM, name, next, precision, rowSeparator, startString, type, width, and writeProtected.

LogRecordItem::LogRecordItem ( const Expression _name,
const char *const  _label,
const char *const  _startString,
const char *const  _endString,
uint  _width,
uint  _precision,
const char *const  _colSeparator,
const char *const  _rowSeparator 
)
Parameters:
[in]_nameInternal name defined by a symbolic expression (its global index).
[in]_labelLabel to be printed before the numerical values.
[in]_startStringPrefix before printing the numerical values.
[in]_endStringSuffix after printing the numerical values.
[in]_widthTotal number of digits per single numerical value.
[in]_precisionNumber of decimals per single numerical value.
[in]_colSeparatorSeparator between the columns of the numerical values.
[in]_rowSeparatorSeparator between the rows of the numerical values.

References acadoAssignString(), assignDigits(), BT_FALSE, colSeparator, DEFAULT_COL_SEPARATOR, DEFAULT_END_STRING, DEFAULT_LABEL, DEFAULT_PRECISION, DEFAULT_ROW_SEPARATOR, DEFAULT_START_STRING, DEFAULT_WIDTH, endString, Expression::getComponent(), label, LRT_VARIABLE, name, next, precision, rowSeparator, startString, type, width, and writeProtected.


Member Function Documentation

returnValue LogRecordItem::assignDigits ( uint toDigit,
uint  fromDigit,
uint  defaultDigit 
) [protected]
Parameters:
[out]toDigitReference to digit information to be assigned.
[in]fromDigitDigit information to be copied.
[in]defaultDigitDefault digit information to be copied in case fromDigit is invalid.
Returns:
SUCCESSFUL_RETURN

References SUCCESSFUL_RETURN.

Referenced by LogRecordItem(), and operator=().

Returns:
SUCCESSFUL_RETURN

References BT_FALSE, SUCCESSFUL_RETURN, and writeProtected.

Referenced by LogRecord::disableWriteProtection().

no values can be written).

Returns:
SUCCESSFUL_RETURN

References BT_TRUE, SUCCESSFUL_RETURN, and writeProtected.

Referenced by LogRecord::enableWriteProtection().

Returns:
Matrix-valued variables grid containing all numerical values

References values.

Referenced by LogRecord::getAll().

Returns:
Matrix containing the numerical value

References emptyMatrix_, getNumPoints(), and getValue().

Referenced by LogRecord::getFirst().

Matrix LogRecordItem::getLastValue ( ) const [inline]
Returns:
Matrix containing the numerical value

References emptyMatrix_, getNumPoints(), and getValue().

Referenced by LogRecord::getLast().

int LogRecordItem::getName ( ) const [inline]
Returns:
Internal name of item

References name.

Referenced by LogRecord::addItem(), LogRecord::find(), LogRecord::findNonEmpty(), and LogRecord::printInfo().

LogRecordItem * LogRecordItem::getNext ( ) const [inline]
uint LogRecordItem::getNumDoubles ( ) const [inline]
uint LogRecordItem::getNumPoints ( ) const [inline]
Returns:
Internal yype of item

References type.

Referenced by LogRecord::addItem(), LogRecord::find(), and LogRecord::findNonEmpty().

Matrix LogRecordItem::getValue ( uint  idx) const [inline]
Parameters:
[in]idxIndex of time instant.
Returns:
Matrix containing the numerical value

References emptyMatrix_, MatrixVariablesGrid::getMatrix(), getNumPoints(), and values.

Referenced by getFirstValue(), and getLastValue().

returnValue LogRecordItem::getValueString ( char **  valueString) const [inline]
Parameters:
[out]valueStringString containing all numerical values of the item.
Note:
The argument string must not be allocated when calling this function and has to be de-allocated manually afterwards.
Returns:
SUCCESSFUL_RETURN

References Matrix::appendRows(), colSeparator, endString, MatrixVariablesGrid::getMatrix(), getNumPoints(), label, precision, Matrix::printToString(), rowSeparator, startString, uint, values, and width.

Referenced by LogRecord::print().

returnValue LogRecordItem::getValueString ( char **  valueString,
uint  idx 
) const [inline]
Parameters:
[out]valueStringString containing all numerical values of the item.
[in]idxIndex of time instant.
Note:
The argument string must not be allocated when calling this function and has to be de-allocated manually afterwards.
Returns:
SUCCESSFUL_RETURN

References colSeparator, endString, MatrixVariablesGrid::getMatrix(), getNumPoints(), label, precision, Matrix::printToString(), rowSeparator, startString, SUCCESSFUL_RETURN, values, and width.

BooleanType LogRecordItem::isEmpty ( ) const [inline]
Returns:
BT_TRUE iff no numerical values have been stored,
BT_FALSE otherwise

References BT_FALSE, BT_TRUE, and getNumPoints().

Referenced by LogRecord::findNonEmpty().

Returns:
BT_TRUE iff item is write-protected,
BT_FALSE otherwise

References writeProtected.

Referenced by LogRecord::setAll(), and LogRecord::setLast().

BooleanType LogRecordItem::operator!= ( const LogRecordItem rhs) const
Parameters:
[in]rhsRight-hand side object.
Returns:
BT_TRUE iff they are not equal,
BT_FALSE otherwise

References BT_FALSE, and BT_TRUE.

LogRecordItem & LogRecordItem::operator= ( const LogRecordItem rhs)
BooleanType LogRecordItem::operator== ( const LogRecordItem rhs) const
Parameters:
[in]rhsRight-hand side object.
Returns:
BT_TRUE iff they are equal,
BT_FALSE otherwise

References acadoIsEqual(), BT_FALSE, BT_TRUE, colSeparator, endString, label, name, precision, rowSeparator, startString, type, and width.

In case the LogFrequency is set to LOG_AT_EACH_ITERATION, the full matrix-valued variables grid is assigned; otherwise only the first or last matrix is assigned, respectively.

Parameters:
[in]_frequencyLog frequency defining which values are to be assigned.
[in]_valuesNew values to be assigned.
Returns:
SUCCESSFUL_RETURN

References MatrixVariablesGrid::addMatrix(), MatrixVariablesGrid::getFirstMatrix(), Grid::getFirstTime(), MatrixVariablesGrid::getLastMatrix(), Grid::getNumPoints(), MatrixVariablesGrid::init(), LOG_AT_EACH_ITERATION, LOG_AT_END, LOG_AT_START, SUCCESSFUL_RETURN, and values.

Referenced by LogRecord::setAll().

returnValue LogRecordItem::setNext ( LogRecordItem *const  _next) [inline]
Parameters:
[in]_nextNew pointer to next item.
Returns:
SUCCESSFUL_RETURN

References next, and SUCCESSFUL_RETURN.

Referenced by LogRecord::addItem().

returnValue LogRecordItem::setValue ( LogFrequency  _frequency,
const Matrix _value,
double  _time = -INFTY 
)
Parameters:
[in]_frequencyLog frequency defining which values are to be assigned.
[in]_valueNew value to be assigned.
[in]_timeTime label of the instant.
Returns:
SUCCESSFUL_RETURN

References acadoIsEqual(), MatrixVariablesGrid::addMatrix(), BT_TRUE, getNumPoints(), INFTY, MatrixVariablesGrid::init(), LOG_AT_EACH_ITERATION, LOG_AT_END, LOG_AT_START, SUCCESSFUL_RETURN, and values.

Referenced by LogRecord::setLast().


Member Data Documentation

char* LogRecordItem::colSeparator [protected]
char* LogRecordItem::endString [protected]
char* LogRecordItem::label [protected]
int LogRecordItem::name [protected]
char* LogRecordItem::rowSeparator [protected]
char* LogRecordItem::startString [protected]

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines