|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--rrdService.util.MathExpressionVirtualDataSource
The class MathExpressionVirtualDataSource Create a new virtual data source by evaluating a mathematical expression, specified in Reverse Polish Notation (RPN). If you have ever used a traditional HP calculator you already know RPN. The idea behind RPN notation is, that you have a stack and push your data onto this stack. When ever you execute an operation, it takes as many data values from the stack as needed. The pushing of data is implicit, so when ever you specify a number or a variable, it gets pushed automatically.
If this is all a big load of incomprehensible words for you, maybe an
example helps (a more complete explanation is given in [1]): The
expression vname+3/2 becomes vname,3,2,/,+
in
RPN. First the three
values get pushed onto the stack (which now contains (the current
value of) vname, a 3 and a 2). Then the / operator pops two values
from the stack (3 and 2), divides the first argument by the second
(3/2) and pushes the result (1.5) back onto the stack. Then the +
operator pops two values (vname and 1.5) from the stack; both values
are added up and the result gets pushes back onto the stack. In the
end there is only one value left on the stack: The result of the
expression.
The rpn-expression in the CDEF function takes both, constant values as well as vname variables. The following operators can be used on these values:
If the stack contains the values A, B, C, D, E are presently on the stack, the IF operator will pop the values E D and C of the stack. It will look at C and if it is not 0 it will push D back onto the stack, otherwise E will be sent back to the stack.
CDEF:a=alpha,0,100,LIMIT
Note that the timezone offset is always calculated for the time the current sample was taken at. It has nuthing todo with the time you are doing the calculation.
Please note that you may only use vname variables that you previously defined by either DEF or CDEF. Furthermore, as of this writing (version 0.99.25), you must use at least one vname per expression, that is ``CDEF:fourtytwo=2,40,+'' will yield an error message but not a vname fourtytwo that's always equal to 42.
RoundRobinGraphic
, Serialized FormField Summary | |
private java.lang.String |
rpnExpression
rpnExpression of this virtual data source |
private java.lang.String |
virtualName
virtualName virtual name for a data source |
Constructor Summary | |
MathExpressionVirtualDataSource(java.lang.String virtualName,
java.lang.String rpnExpression)
Constructor of MathExpressionVirtualDataSource |
Method Summary | |
java.lang.String |
getRpnExpression()
Returns the rpnExpression of this virtual data source |
java.lang.String |
getVirtualName()
Returns the the virtual name for a data source |
void |
setRpnExpression(java.lang.String rpnExpression)
Replaces the rpnExpression of this virtual data source |
void |
setVirtualName(java.lang.String virtualName)
Replaces the the virtual name for a data source |
java.lang.String |
toString()
Returns a string representation of this virtual data source built from a rpn expression |
Methods inherited from class java.lang.Object |
|
Field Detail |
private java.lang.String rpnExpression
private java.lang.String virtualName
Constructor Detail |
public MathExpressionVirtualDataSource(java.lang.String virtualName, java.lang.String rpnExpression)
virtualName
- the virtual name for a data sourcerpnExpression
- the rpnExpression of this virtual data sourceMethod Detail |
public java.lang.String getRpnExpression()
public java.lang.String getVirtualName()
public void setRpnExpression(java.lang.String rpnExpression)
rpnExpression
- the rpnExpression of this virtual data source to setpublic void setVirtualName(java.lang.String virtualName)
virtualName
- the virtual name for a data source to setpublic java.lang.String toString()
toString
in class java.lang.Object
|
Copyright 1885-2001 FIRMENICH SA, Geneva | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |