[rrd-users] Re: Clipping data with sequences of IFs in a CDEF. Can it be done ?

Alex van den Bogaerdt alex at ergens.op.het.net
Wed Oct 16 01:50:55 MEST 2002

On Tue, Oct 15, 2002 at 10:59:22PM +1000, Stanley Hopcroft wrote:
> CDEF:clipped=x,UpperBound,GT,UpperBound,x,IF,LowerBound,LT,LowerBound,x,IF
> (the intent is that clipped is x:  LowerBound <= x <= UpperBound. I
> thought the CDEF would evaluate to
> min(x,UpperBound),LowerBound,LT,LowerBound,x,IF. Perhaps this is what I 
> should have done in the first place.)

This CDEF indeed does not work.  As always: mimic RRDtool and debug step
by step:

1:   x,UpperBound,GT      ---->  p
2:   p,UpperBound,x,IF    ---->  q
3:   q,LowerBound,LT      ---->  r
4:   r,LowerBound,x,IF    ---->  result of CDEF

In (1,2) you return min(x,UpperBound).  That's what you need.
In (3,4) you check the result of (1,2) agains LowerBound but return
either LowerBound (good) or x (bad).

Look at step (4): if (r) return LowerBound else return x
The value of 'r' is: q<LowerBound (true or false).
So, "if min(x,UpperBound) < LowerBound then return LowerBound else return x".

You need to replace 'x' in (4) with the result of (1,2).  This can be
done by just doing the calculation again, or you can do this by carefully
using DUP maybe together with EXC and/or POP.


Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

More information about the rrd-users mailing list