ACADO Toolkit
1.2.0beta
Toolkit for Automatic Control and Dynamic Optimization
|
Allows to manage single items of user-specified LogRecords of algorithmic information (for internal use). More...
#include <log_record_item.hpp>
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. | |
LogRecordItem & | operator= (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 MatrixVariablesGrid & | getAllValues () 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. | |
LogRecordItem * | getNext () 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. | |
LogRecordItem * | next |
Pointer to next LogRecordItem within a LogRecord. |
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.
References BT_FALSE, colSeparator, endString, label, LRT_UNKNOWN, name, next, precision, rowSeparator, startString, type, width, and writeProtected.
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 | ||
) |
[in] | _name | Internal name defined by a LogName. |
[in] | _label | Label to be printed before the numerical values. |
[in] | _startString | Prefix before printing the numerical values. |
[in] | _endString | Suffix after printing the numerical values. |
[in] | _width | Total number of digits per single numerical value. |
[in] | _precision | Number of decimals per single numerical value. |
[in] | _colSeparator | Separator between the columns of the numerical values. |
[in] | _rowSeparator | Separator 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 | ||
) |
[in] | _name | Internal name defined by a symbolic expression (its global index). |
[in] | _label | Label to be printed before the numerical values. |
[in] | _startString | Prefix before printing the numerical values. |
[in] | _endString | Suffix after printing the numerical values. |
[in] | _width | Total number of digits per single numerical value. |
[in] | _precision | Number of decimals per single numerical value. |
[in] | _colSeparator | Separator between the columns of the numerical values. |
[in] | _rowSeparator | Separator 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.
LogRecordItem::LogRecordItem | ( | const LogRecordItem & | rhs | ) |
[in] | rhs | Right-hand side object. |
References acadoAssignString(), assignDigits(), colSeparator, DEFAULT_COL_SEPARATOR, DEFAULT_END_STRING, DEFAULT_LABEL, DEFAULT_PRECISION, DEFAULT_ROW_SEPARATOR, DEFAULT_START_STRING, DEFAULT_WIDTH, endString, label, name, next, precision, rowSeparator, startString, type, values, width, and writeProtected.
References colSeparator, endString, label, rowSeparator, and startString.
returnValue LogRecordItem::assignDigits | ( | uint & | toDigit, |
uint | fromDigit, | ||
uint | defaultDigit | ||
) | [protected] |
[out] | toDigit | Reference to digit information to be assigned. |
[in] | fromDigit | Digit information to be copied. |
[in] | defaultDigit | Default digit information to be copied in case fromDigit is invalid. |
References SUCCESSFUL_RETURN.
Referenced by LogRecordItem(), and operator=().
uint LogRecordItem::determineStringLength | ( | ) | const [inline] |
References Matrix::appendRows(), colSeparator, Matrix::determineStringLength(), endString, MatrixVariablesGrid::getMatrix(), getNumPoints(), label, precision, rowSeparator, startString, uint, values, and width.
Referenced by LogRecord::determineRecordStringLength().
uint LogRecordItem::determineStringLength | ( | uint | idx | ) | const [inline] |
[in] | idx | Index of time instant. |
References colSeparator, Matrix::determineStringLength(), endString, MatrixVariablesGrid::getMatrix(), getNumPoints(), label, precision, rowSeparator, startString, SUCCESSFUL_RETURN, values, and width.
returnValue LogRecordItem::disableWriteProtection | ( | ) | [inline] |
References BT_FALSE, SUCCESSFUL_RETURN, and writeProtected.
Referenced by LogRecord::disableWriteProtection().
returnValue LogRecordItem::enableWriteProtection | ( | ) | [inline] |
no values can be written).
References BT_TRUE, SUCCESSFUL_RETURN, and writeProtected.
Referenced by LogRecord::enableWriteProtection().
const MatrixVariablesGrid & LogRecordItem::getAllValues | ( | ) | const [inline] |
References values.
Referenced by LogRecord::getAll().
Matrix LogRecordItem::getFirstValue | ( | ) | const [inline] |
References emptyMatrix_, getNumPoints(), and getValue().
Referenced by LogRecord::getFirst().
Matrix LogRecordItem::getLastValue | ( | ) | const [inline] |
References emptyMatrix_, getNumPoints(), and getValue().
Referenced by LogRecord::getLast().
int LogRecordItem::getName | ( | ) | const [inline] |
References name.
Referenced by LogRecord::addItem(), LogRecord::find(), LogRecord::findNonEmpty(), and LogRecord::printInfo().
LogRecordItem * LogRecordItem::getNext | ( | ) | const [inline] |
References next.
Referenced by LogRecord::clearAllItems(), LogRecord::determineRecordStringLength(), LogRecord::find(), LogRecord::findNonEmpty(), LogRecord::getMaxNumMatrices(), LogRecord::getNumDoubles(), LogRecord::LogRecord(), LogRecord::operator()(), LogRecord::operator=(), LogRecord::operator==(), LogRecord::print(), and LogRecord::printInfo().
uint LogRecordItem::getNumDoubles | ( | ) | const [inline] |
References MatrixVariablesGrid::getDim(), and values.
Referenced by LogRecord::getNumDoubles().
uint LogRecordItem::getNumPoints | ( | ) | const [inline] |
References Grid::getNumPoints(), and values.
Referenced by determineStringLength(), getFirstValue(), getLastValue(), LogRecord::getMaxNumMatrices(), getValue(), getValueString(), isEmpty(), and setValue().
LogRecordItemType LogRecordItem::getType | ( | ) | const [inline] |
References type.
Referenced by LogRecord::addItem(), LogRecord::find(), and LogRecord::findNonEmpty().
Matrix LogRecordItem::getValue | ( | uint | idx | ) | const [inline] |
[in] | idx | Index of time instant. |
References emptyMatrix_, MatrixVariablesGrid::getMatrix(), getNumPoints(), and values.
Referenced by getFirstValue(), and getLastValue().
returnValue LogRecordItem::getValueString | ( | char ** | valueString | ) | const [inline] |
[out] | valueString | String containing all numerical values of the item. |
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] |
[out] | valueString | String containing all numerical values of the item. |
[in] | idx | Index of time instant. |
References colSeparator, endString, MatrixVariablesGrid::getMatrix(), getNumPoints(), label, precision, Matrix::printToString(), rowSeparator, startString, SUCCESSFUL_RETURN, values, and width.
BooleanType LogRecordItem::isEmpty | ( | ) | const [inline] |
References BT_FALSE, BT_TRUE, and getNumPoints().
Referenced by LogRecord::findNonEmpty().
BooleanType LogRecordItem::isWriteProtected | ( | ) | const [inline] |
References writeProtected.
Referenced by LogRecord::setAll(), and LogRecord::setLast().
BooleanType LogRecordItem::operator!= | ( | const LogRecordItem & | rhs | ) | const |
LogRecordItem & LogRecordItem::operator= | ( | const LogRecordItem & | rhs | ) |
[in] | rhs | Right-hand side object. |
References acadoAssignString(), assignDigits(), colSeparator, DEFAULT_COL_SEPARATOR, DEFAULT_END_STRING, DEFAULT_LABEL, DEFAULT_PRECISION, DEFAULT_ROW_SEPARATOR, DEFAULT_START_STRING, DEFAULT_WIDTH, endString, label, name, next, precision, rowSeparator, startString, type, values, width, and writeProtected.
BooleanType LogRecordItem::operator== | ( | const LogRecordItem & | rhs | ) | const |
[in] | rhs | Right-hand side object. |
References acadoIsEqual(), BT_FALSE, BT_TRUE, colSeparator, endString, label, name, precision, rowSeparator, startString, type, and width.
returnValue LogRecordItem::setAllValues | ( | LogFrequency | _frequency, |
const MatrixVariablesGrid & | _values | ||
) |
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.
[in] | _frequency | Log frequency defining which values are to be assigned. |
[in] | _values | New values to be assigned. |
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] |
[in] | _next | New pointer to next item. |
References next, and SUCCESSFUL_RETURN.
Referenced by LogRecord::addItem().
returnValue LogRecordItem::setValue | ( | LogFrequency | _frequency, |
const Matrix & | _value, | ||
double | _time = -INFTY |
||
) |
[in] | _frequency | Log frequency defining which values are to be assigned. |
[in] | _value | New value to be assigned. |
[in] | _time | Time label of the instant. |
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().
char* LogRecordItem::colSeparator [protected] |
Referenced by determineStringLength(), getValueString(), LogRecordItem(), operator=(), operator==(), and ~LogRecordItem().
char* LogRecordItem::endString [protected] |
Referenced by determineStringLength(), getValueString(), LogRecordItem(), operator=(), operator==(), and ~LogRecordItem().
char* LogRecordItem::label [protected] |
Referenced by determineStringLength(), getValueString(), LogRecordItem(), operator=(), operator==(), and ~LogRecordItem().
int LogRecordItem::name [protected] |
Referenced by getName(), LogRecordItem(), operator=(), and operator==().
LogRecordItem* LogRecordItem::next [protected] |
Referenced by getNext(), LogRecordItem(), operator=(), and setNext().
uint LogRecordItem::precision [protected] |
Referenced by determineStringLength(), getValueString(), LogRecordItem(), operator=(), and operator==().
char* LogRecordItem::rowSeparator [protected] |
Referenced by determineStringLength(), getValueString(), LogRecordItem(), operator=(), operator==(), and ~LogRecordItem().
char* LogRecordItem::startString [protected] |
Referenced by determineStringLength(), getValueString(), LogRecordItem(), operator=(), operator==(), and ~LogRecordItem().
LogRecordItemType LogRecordItem::type [protected] |
Referenced by getType(), LogRecordItem(), operator=(), and operator==().
MatrixVariablesGrid LogRecordItem::values [protected] |
Referenced by determineStringLength(), getAllValues(), getNumDoubles(), getNumPoints(), getValue(), getValueString(), LogRecordItem(), operator=(), setAllValues(), and setValue().
uint LogRecordItem::width [protected] |
Referenced by determineStringLength(), getValueString(), LogRecordItem(), operator=(), and operator==().
BooleanType LogRecordItem::writeProtected [protected] |
no values can be written).
Referenced by disableWriteProtection(), enableWriteProtection(), isWriteProtected(), LogRecordItem(), and operator=().