AURobotServers  4
Public Member Functions | Public Attributes | List of all members
UVarLog Class Reference

#include <uvarlog.h>

Inheritance diagram for UVarLog:
Inheritance graph

Public Member Functions

void changed (double *data, bool isDouble=true, UTime *updTime=NULL)
 
virtual bool decodeReplayLine (char *)
 
virtual int getElementCnt2 () const
 
int getHistoryRows ()
 
const char * getLogFilename ()
 
int getMeanMinMax (int element, UTime toTime, double *mean, double *min, double *max, int sampleInterval=1)
 
UMatrixgetTimeSeries (UMatrix *buffer, int maxRows)
 
int getTimeVector (double *buffer, int bufferCnt, int element)
 
UTime getUpdTime ()
 
int getVectorToTime (double *buffer, int bufferCnt, int element, UTime tot, int interval, double *gotdt)
 
bool hasHist () const
 
bool makeHist (int histCnt, int elementCnt, double maxUpdateRate)
 
bool openLog (bool doOpen, const char *preName=NULL, const char *varName=NULL)
 
bool setMaxUpdateRate (double maxUpdateRate)
 
bool setReplay (bool doOpen, const char *preName, const char *varName, UReplay *replayParent)
 
 UVarLog ()
 
virtual ~UVarLog ()
 

Public Attributes

UVarHisthist
 

Detailed Description

A variable history maintainer

Constructor & Destructor Documentation

UVarLog::UVarLog ( )

Constructor

UVarLog::~UVarLog ( )
virtual

Destructor

Member Function Documentation

void UVarLog::changed ( double *  data,
bool  isDouble = true,
UTime updTime = NULL 
)
inline

This variable is updated

References UTime::now().

Referenced by UVariable::setUpdated().

virtual bool UVarLog::decodeReplayLine ( char *  )
inlinevirtual

Decode this replay line, that is assumed to be valid.

Parameters
lineis a pointer to the line.
Returns
true if the line is valid and used (step is successfull).
false if line is not a valid step.

Reimplemented in UVariable.

Referenced by UVarHist::decodeReplayLine().

virtual int UVarLog::getElementCnt2 ( ) const
inlinevirtual
int UVarLog::getHistoryRows ( )
inline

Get number of rows in the time series.

Returns
the number of history rows, excluding the newest, that is used for temporary values.
const char* UVarLog::getLogFilename ( )
inline

Get logfile name (full path)

Referenced by UFunctionVarPool::handleVar().

int UVarLog::getMeanMinMax ( int  element,
UTime  toTime,
double *  mean,
double *  min,
double *  max,
int  sampleInterval = 1 
)

Get some statistics from the time series

Parameters
elementis the element (history column) to use, 0=first element.
toTimeis the end time where the vector should end.
meanis set to the mean value in the specified time series (unchanged if no data) - may be NULL
minis set to the minimum value in the specified time series (unchanged if no data) - may be NULL
maxis set to the maximum value in the time series (unchanged if no data) - may be NULL.
sampleIntervalis the interval between samples to test (default is 1)
Returns
number of elements used - 0 if no data.
UMatrix * UVarLog::getTimeSeries ( UMatrix buffer,
int  maxRows 
)

Get time series as a matrix with all comumns a maximum of rows. The first row is the newest (history) data (not current data). the buffer matrix will be resized (if needed) to fit data size.

Parameters
bufferis the matrix that is to be filled with the data.
maxRowsis the maximum size of the data.

Referenced by testVar().

int UVarLog::getTimeVector ( double *  buffer,
int  bufferCnt,
int  element 
)

Get a time series vector from current history

Parameters
bufferis a result buffer for the values
bufferCntis the size of the buffer (maximum this number of elements will be loaded into buffer.
elementis the element (history column) to use, 0=first element.
Returns
number of elements returned (may be less than or equal to bufferCnt dependent of available data and history buffer size.
0 if no history is available.
UTime UVarLog::getUpdTime ( )
inline

Get update time of newest element

References ULogFile::openLog(), UReplay::replayParent, and UReplay::setReplay().

int UVarLog::getVectorToTime ( double *  buffer,
int  bufferCnt,
int  element,
UTime  tot,
int  interval,
double *  gotdt 
)

Get a time series vector from current history with specifiet update rate and end time. if update rate is not possible, then average rate is returned. The method is to skip recorded updates until specified dt is passed, then use and increase to next expected time

Parameters
bufferis a result buffer for the values
bufferCntis the size of the buffer (maximum this number of elements will be loaded into buffer.
elementis the element (history column) to use, 0=first element.
totis the end time where the vector should end.
intervalis interval of the samples taken, 1 is all, 2 is every second.
gotdtis the (average) sample rate of saved data.
Returns
number of elements returned (may be less than or equal to bufferCnt dependent of available data and history buffer size.
0 if no history is available.
bool UVarLog::hasHist ( ) const
inline
bool UVarLog::makeHist ( int  histCnt,
int  elementCnt,
double  maxUpdateRate 
)

Make time series history for this variable

Parameters
varCntis the number of variable to be allocated for on-line history.
elementCntis number of elements in each history entry.
maxUpdateRateis the maximum update rewate for the time series (must be greater than 1e-6)'
Returns
true if created.

References UVarHist::UVarHist().

Referenced by UVariable::makeTimeSeries(), and testVar().

bool UVarLog::openLog ( bool  doOpen,
const char *  preName = NULL,
const char *  varName = NULL 
)

Open log

Parameters
doOpenif true: opens replay file and set replay status - requires name and resource parent to work. if false: closes replay file and stops replay.
varParentis the variable owner of this history structure (mainly used during replay)
preNameis the full name of the structure that holds the variable (may be empty) (supposed to end in a '.'), this will be part of the filename.
varNameis the variable name and is added to the replay path, the pre-name and extended with a .log to form the full logfile name.
Returns
true if log is open.

Referenced by UVariable::openVarLog().

bool UVarLog::setMaxUpdateRate ( double  maxUpdateRate)

Set maksimum update rate for time series

Parameters
maxUpdateRateis the maximum update rewate for the time series (must be greater than 1e-6)'
Returns
true if set.

Referenced by UFunctionVarPool::handleVarValues().

bool UVarLog::setReplay ( bool  doOpen,
const char *  preName,
const char *  varName,
UReplay replayParent 
)

Open log

Parameters
doOpenif true: opens replay file and set replay status - requires name and resource parent to work. if false: closes replay file and stops replay.
varParentis the variable owner of this history structure (mainly used during replay)
preNameis the full name of the structure that holds the variable (may be empty) (supposed to end in a '.'), this will be part of the filename.
varNameis the variable name and is added to the replay path, the pre-name and extended with a .log to form the full logfile name.
parentis the resource replay parent (that will be informed on steps).
Returns
true if logfile is open.

Referenced by UFunctionVarPool::handleVarValues().

Member Data Documentation

UVarHist* UVarLog::hist

The documentation for this class was generated from the following files: